Skip to content

Commit dc81795

Browse files
authored
v0.7.32: concurrency control, seo/geo, new lib, buffer & flint integrations
2 parents e01bfb1 + 3ac5e90 commit dc81795

776 files changed

Lines changed: 87161 additions & 9423 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: add-block-preview
3+
description: Gate a block's visibility — ship an unreleased block as a preview (hidden until revealed via AppConfig/env), reveal it to admins/orgs, GA it, or kill-switch a shipped block
4+
argument-hint: <block-type>
5+
---
6+
7+
# Add Block Preview Skill
8+
9+
You manage **block visibility gating** in Sim — hiding blocks from every discovery surface (toolbar, cmd+K search, copilot @-mentions, agent tool picker, mothership VFS/metadata/tools, Access Control list, public docs/catalog) while **never** gating execution of already-placed instances.
10+
11+
## The model
12+
13+
Three levers, evaluated in `apps/sim/lib/core/config/block-visibility.ts` and folded into the registry accessors (`apps/sim/blocks/registry.ts`):
14+
15+
1. **`preview: true`** on the `BlockConfig` (static, in code) — the block is default-hidden EVERYWHERE (hosted, self-hosted, dev, SSR) until revealed. Fail-closed.
16+
2. **The hosted `block-visibility` AppConfig document** — per-block rule keyed by the existing block type:
17+
18+
```jsonc
19+
{
20+
"<block-type>": {
21+
"enabled": false, // required. true = GA (visible to everyone)
22+
"orgIds": ["org_..."], // optional allowlist clauses (any match reveals)
23+
"userIds": ["user_..."],
24+
"adminEnabled": true // platform admins (user.role === 'admin')
25+
}
26+
}
27+
```
28+
29+
3. **`PREVIEW_BLOCKS` env** (comma-separated block types) — the off-AppConfig reveal path for self-hosters and local dev.
30+
31+
A revealed block that is not globally GA (`enabled !== true`, or env-revealed) renders with a **" (Preview)"** name suffix on discovery surfaces. `getBlock()` stays pure, so placed instances keep their canonical name and always execute.
32+
33+
## Lifecycle of a preview block
34+
35+
1. **Author** the block normally (`/add-block` etc.) and set `preview: true` on its `BlockConfig`. **Ship no `BlockMeta` and no docs until GA**`check-block-registry` deliberately skips preview blocks in meta coverage, and `generate-docs` skips them at every gate.
36+
2. **Local dev:** set `PREVIEW_BLOCKS=<block-type>` in your env to see it (with the suffix).
37+
3. **Merge/deploy.** The block's code is live everywhere but visible nowhere — no AppConfig rule exists and self-hosters have no env entry.
38+
4. **Hosted preview:** add a rule to the `block-visibility` AppConfig document and start a deployment (no code deploy):
39+
- Admins only: `{ "enabled": false, "adminEnabled": true }`
40+
- Design-partner org: `{ "enabled": false, "orgIds": ["org_123"] }`
41+
- GA via config (code cleanup pending): `{ "enabled": true }` — suffix disappears everywhere within ~30s (AppConfig TTL) + client refetch.
42+
43+
Same runbook as `feature-flags`: edit the hosted document, `aws appconfig start-deployment` with the `sim-<env>-fast` strategy (see the infra README).
44+
5. **GA cleanup:** delete `preview: true` from the block (now visible to self-hosters on their next upgrade), add its `BlockMeta` + regen docs, and drop the AppConfig entry. For a v2 upgrade, this is also when v1 gets `hideFromToolbar: true` (the superseded-version paradigm).
45+
46+
## Kill switch (shipped blocks)
47+
48+
To pull an already-GA block from discovery surfaces on hosted (incident, deprecation): add `{ "<block-type>": { "enabled": false } }` to the document. Allowlist clauses can carve out exceptions. **Execution is NOT stopped** — workflows already using the block keep running; the kill switch only prevents new placement/discovery.
49+
50+
## Invariants (do not violate)
51+
52+
- **Execution is never gated.** The executor, serializer, drop-naming, and `isBlockTypeAccessControlExempt` resolve via pure `getBlock`. Do not add visibility checks to execution paths.
53+
- **Clone-not-remove:** gated blocks stay in `getAllBlocks()` output as clones with `hideFromToolbar: true``.find`-by-type consumers rely on this. Never filter them out.
54+
- **Keys are registry block types.** Never `custom_block_*` (parse drops them — custom blocks have their own enabled/disabled lifecycle).
55+
- **The shared hidden-predicate is `isHiddenUnder`** (`apps/sim/blocks/visibility/context.ts`). Never restate the preview/disabled rule inline at a new consumer.
56+
- **Process-global caches stay ungated.** `getStaticComponentFiles` (VFS) and `getExposedIntegrationTools` build the ungated universe; per-viewer filtering happens at stamp/consumer time. Never move gating into a shared builder.
57+
- Gating is **surface hiding, not secrecy** — the full config ships in the client JS bundle. Anything truly secret cannot be a registered block.
58+
59+
## Tests
60+
61+
Evaluation semantics: `apps/sim/lib/core/config/block-visibility.test.ts`. Registry projection: `apps/sim/blocks/visibility/visibility.test.ts`. When gating behavior changes, extend those — mock `isPlatformAdmin` for the admin clause; use the local `withAppConfig` harness.

.agents/skills/add-block/SKILL.md

Lines changed: 67 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: add-block
33
description: Create or update a Sim integration block with correct subBlocks, conditions, dependsOn, modes, canonicalParamId usage, outputs, and tool wiring. Use when working on `apps/sim/blocks/blocks/{service}.ts` or aligning a block with its tools.
4+
argument-hint: <service-name>
45
---
56

67
# Add Block Skill
@@ -443,7 +444,7 @@ Maps multiple UI fields to a single serialized parameter:
443444

444445
**Critical constraints:**
445446
- `canonicalParamId` must NOT match any other subblock's `id` in the same block (causes conflicts)
446-
- `canonicalParamId` must be unique per block (only one basic/advanced pair per canonicalParamId)
447+
- A `canonicalParamId` links exactly one basic/advanced pair for a single logical parameter. Do NOT reuse the same `canonicalParamId` for different parameters, even under mutually-exclusive conditions/operations
447448
- ONLY use `canonicalParamId` to link basic/advanced mode alternatives for the same logical parameter
448449
- Do NOT use it for any other purpose
449450

@@ -533,7 +534,10 @@ tools: {
533534
Block outputs only support:
534535
- `type` - The data type ('string', 'number', 'boolean', 'json', 'array')
535536
- `description` - Human readable description
536-
- Nested object structure (for complex types)
537+
- `condition` - Optional visibility condition
538+
- `hiddenFromDisplay` - Optional flag to hide from the output display
539+
540+
**Nested object/`properties` outputs are tool-output-only and will fail TypeScript at build time on block outputs.** For complex shapes use `type: 'json'` and describe the inner fields in the `description` string.
537541

538542
```typescript
539543
outputs: {
@@ -556,7 +560,7 @@ outputs: {
556560

557561
### Typed JSON Outputs
558562

559-
When using `type: 'json'` and you know the object shape in advance, **describe the inner fields in the description** so downstream blocks know what properties are available. For well-known, stable objects, use nested output definitions instead:
563+
When using `type: 'json'` and you know the object shape in advance, **describe the inner fields in the description** so downstream blocks know what properties are available. Block outputs have no nested `properties` form — always keep the output flat and put the shape in the `description`:
560564

561565
```typescript
562566
outputs: {
@@ -568,26 +572,10 @@ outputs: {
568572
type: 'json',
569573
description: 'Zone plan information (id, name, price, currency, frequency, is_subscribed)',
570574
},
571-
572-
// BEST: Use nested output definition when the shape is stable and well-known
573-
plan: {
574-
id: { type: 'string', description: 'Plan identifier' },
575-
name: { type: 'string', description: 'Plan name' },
576-
price: { type: 'number', description: 'Plan price' },
577-
currency: { type: 'string', description: 'Price currency' },
578-
},
579575
}
580576
```
581577

582-
Use the nested pattern when:
583-
- The object has a small, stable set of fields (< 10)
584-
- Downstream blocks will commonly access specific properties
585-
- The API response shape is well-documented and unlikely to change
586-
587-
Use `type: 'json'` with a descriptive string when:
588-
- The object has many fields or a dynamic shape
589-
- It represents a list/array of items
590-
- The shape varies by operation
578+
Nested object outputs (`plan: { id: { type: 'string' }, ... }`) are a **tool-output** feature only — `OutputFieldDefinition` for blocks does not allow them and they fail TypeScript at build time.
591579

592580
If the output shape is unknown because the underlying tool response is undocumented, you MUST tell the user and stop. Unknown is not the same as variable. Never guess block outputs.
593581

@@ -627,96 +615,20 @@ export const ServiceV2Block: BlockConfig = {
627615
}
628616
```
629617

630-
## Block Metadata (BlockMeta)
631-
632-
Every integration block **must** export a `{Service}BlockMeta` object at the bottom of the block file. This metadata drives the integration catalog, tag filters, and workflow template suggestions shown to users.
633-
634-
### Structure
635-
636-
```typescript
637-
import type { BlockConfig, BlockMeta } from '@/blocks/types'
638-
639-
// ... block definition above ...
640-
641-
export const {Service}BlockMeta = {
642-
tags: ['messaging', 'automation'], // Same tags as the block's tags field
643-
url: 'https://{service}.com', // Canonical homepage of the external service
644-
templates: [ // Optional but strongly encouraged
645-
{
646-
icon: {Service}Icon,
647-
title: '{Service} use-case title',
648-
prompt: 'Build a workflow that ...',
649-
modules: ['agent', 'workflows'], // Modules the template uses
650-
category: 'productivity', // Template category
651-
tags: ['automation'], // Template-level tags
652-
alsoIntegrations: ['slack'], // Other blocks referenced in the prompt (optional)
653-
},
654-
],
655-
skills: [ // Optional but strongly encouraged
656-
{
657-
name: 'summarize-thread', // kebab-case, becomes the created skill's name
658-
description: 'One line: what it does and when to use it.',
659-
content:
660-
'# Summarize Thread\n\n...\n\n## Steps\n1. ...\n\n## Output\n...', // markdown
661-
},
662-
],
663-
} as const satisfies BlockMeta
664-
```
665-
666-
### Rules
667-
668-
- **Import `BlockMeta`** from `@/blocks/types` alongside `BlockConfig`
669-
- **`tags`** must match the `tags` array on the block config exactly
670-
- **`url`** is the canonical homepage of the external service the block integrates with (e.g. `'https://exa.ai'`, `'https://salesforce.com'`) — the catalog "link back to the tool". It is distinct from `BlockConfig.docsLink`, which points at Sim's own integration docs on `docs.sim.ai`. Use the service's real root domain over `https` (verify it actually resolves), no tracking params, no trailing slash. Omit `url` only for first-party/built-in blocks that have no external service (e.g. `agent`, `function`, `condition`, `api`, `response`)
671-
- **Templates are optional** but should be added for any integration that has a recognizable use case — aim for 2–4 templates per block
672-
- **Template `prompt`** should start with "Build a workflow that..." or "Create a workflow that..." and be concrete enough to generate a real workflow in Mothership
673-
- **Template `modules`** lists the Sim modules the template relies on: `'knowledge-base' | 'tables' | 'files' | 'workflows' | 'scheduled' | 'agent'`
674-
- **Template `category`** is one of: `'popular' | 'sales' | 'support' | 'engineering' | 'marketing' | 'productivity' | 'operations'`
675-
- **`alsoIntegrations`** names other block types (e.g. `'slack'`, `'linear'`) referenced in the template prompt — helps the catalog surface this template when those blocks are selected
676-
- Place the export **after** the main `{Service}Block` export, at the very bottom of the file
677-
678-
#### `skills` — curated, ready-to-add agent skills
679-
680-
`skills` is an optional array of `SuggestedSkill` (`{ name, description, content }`) shown on the integration's detail page; users click **Add** to create the skill in their workspace. Aim for 3–5 skills for mainstream services, 2–3 for niche/low-level ones.
681-
682-
- **`name`** — kebab-case, lowercase letters/numbers/hyphens, ≤ 64 chars, unique within the integration, verb-led (e.g. `summarize-thread`).
683-
- **`description`** — one line, ≤ 1024 chars: what it does and when to use it.
684-
- **`content`** — markdown instructions for the agent (literal `\n` for newlines): a `# Title`, then `## Steps` and an output/guidance section. Keep ~600–2000 chars.
685-
- **Ground every skill in operations the block actually exposes.** Cross-check each skill's steps against the block's `tools.access` list — never describe an action the integration cannot perform (e.g. "receive messages" when the block only sends).
686-
- **Skills MUST be derived from real, popular use cases found online — never invented.** Before adding a skill, web-search the service's documented use cases (vendor use-case/solutions pages, official docs describing the workflow, reputable "top automations for X" articles). If you cannot source a use case as something people genuinely do with the service, do not add it. Do not hallucinate skills.
687-
688-
### Register in the blocksMeta object
689-
690-
After adding `{Service}BlockMeta` to the block file, register it in `apps/sim/blocks/registry.ts`:
691-
692-
```typescript
693-
// Add import (alongside the block import, alphabetically)
694-
import { ServiceBlock, ServiceBlockMeta } from '@/blocks/blocks/service'
695-
696-
// Add to blocksMeta object (alphabetically)
697-
export const blocksMeta = {
698-
// ... existing entries ...
699-
service: ServiceBlockMeta,
700-
}
701-
```
702-
703618
## Registering Blocks
704619

705-
After creating the block, remind the user to:
706-
1. Import `{Service}Block` and `{Service}BlockMeta` in `apps/sim/blocks/registry.ts`
707-
2. Add to the `registry` object (alphabetically):
708-
3. Add to the `blocksMeta` object (alphabetically):
620+
After creating the block, remind the user to register it in `apps/sim/blocks/registry-maps.ts` (the data maps live here; `registry.ts` holds only the accessor functions). Add the import and an entry to each map alphabetically:
709621

710622
```typescript
711623
import { ServiceBlock, ServiceBlockMeta } from '@/blocks/blocks/service'
712624

713-
export const registry: Record<string, BlockConfig> = {
625+
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
714626
// ... existing blocks ...
715627
service: ServiceBlock,
716628
}
717629

718-
export const blocksMeta = {
719-
// ... existing entries ...
630+
export const BLOCK_META_REGISTRY: Record<string, BlockMeta> = {
631+
// ... existing metas ...
720632
service: ServiceBlockMeta,
721633
}
722634
```
@@ -837,6 +749,13 @@ Please provide the SVG and I'll convert it to a React component.
837749
You can usually find this in the service's brand/press kit page, or copy it from their website.
838750
```
839751

752+
When converting the SVG: a **monochrome** logo (single white or black mark) must
753+
use `fill='currentColor'`, never a hardcoded `#fff`/`#000000`. Block icons render
754+
both inside their `bgColor` tile and "bare" on a neutral page (the home Suggested
755+
actions list) in light and dark mode; a hardcoded white/black mark goes invisible
756+
bare on the matching background. Multi-color brand logos keep their own fills.
757+
Verify with `bun run check:bare-icons`.
758+
840759
## Advanced Mode for Optional Fields
841760

842761
Optional fields that are rarely used should be set to `mode: 'advanced'` so they don't clutter the basic UI. This includes:
@@ -893,6 +812,48 @@ Use `wandConfig` for fields that are hard to fill out manually, such as timestam
893812

894813
All tool IDs referenced in `tools.access` and returned by `tools.config.tool` MUST use `snake_case` (e.g., `x_create_tweet`, `slack_send_message`). Never use camelCase or PascalCase.
895814

815+
## BlockMeta (Required)
816+
817+
Every block file must export a `{Service}BlockMeta` alongside the block — **minimum 7 templates**. Look at existing examples in `apps/sim/blocks/blocks/` (e.g. `browser_use.ts`, `google_sheets.ts`) for the pattern.
818+
819+
```typescript
820+
import type { BlockMeta } from '@/blocks/types'
821+
822+
export const {Service}BlockMeta = {
823+
tags: ['tag1', 'tag2'], // IntegrationTag[]
824+
url: 'https://{service}.com', // external service homepage (verify it resolves) — NOT docs.sim.ai
825+
templates: [
826+
{
827+
icon: {Service}Icon,
828+
title: '{Service} <use-case>', // 2–5 words
829+
prompt: 'Build a workflow that...', // specific use case, 1–3 sentences
830+
modules: ['agent', 'workflows'], // 'agent' | 'workflows' | 'tables' | 'files' | 'scheduled' | 'knowledge-base'
831+
category: 'operations', // 'operations' | 'marketing' | 'sales' | 'engineering' | 'productivity' | 'support' | 'popular'
832+
tags: ['automation'],
833+
alsoIntegrations: ['slack'], // optional — other block IDs referenced in the prompt
834+
featured: true, // optional
835+
},
836+
// ... at least 6 more
837+
],
838+
skills: [ // SuggestedSkill[] — 3–5 mainstream, 2–3 niche
839+
{
840+
name: 'summarize-thread', // kebab-case, ≤64 chars, unique, verb-led
841+
description: 'One line: what it does and when to use it.', // ≤1024 chars
842+
content:
843+
'# Summarize Thread\n\n...\n\n## Steps\n1. ...\n\n## Output\n...', // markdown
844+
},
845+
// ... more
846+
],
847+
} as const satisfies BlockMeta
848+
```
849+
850+
Derive templates from the service's real use cases. Each prompt should name a concrete trigger, transformation, and output — not a generic description of what the service does.
851+
852+
`skills` are curated, ready-to-add agent skills shown on the integration's detail page (users click **Add** to create them in their workspace). Two hard rules:
853+
854+
- **Ground every skill in operations the block actually exposes** — cross-check each skill's steps against `tools.access`. Never describe an action the integration cannot perform.
855+
- **Derive skills from real, popular use cases found online — never invent them.** Web-search the service's documented use cases (vendor use-case/solutions pages, official docs describing the workflow, reputable "top automations for X" articles) and only add a skill you can source as something people genuinely do with the service. Do not hallucinate skills.
856+
896857
## Checklist Before Finishing
897858

898859
- [ ] `integrationType` is set to the correct `IntegrationType` enum value
@@ -906,16 +867,14 @@ All tool IDs referenced in `tools.access` and returned by `tools.config.tool` MU
906867
- [ ] Tools.access lists all tool IDs (snake_case)
907868
- [ ] Tools.config.tool returns correct tool ID (snake_case)
908869
- [ ] Outputs match tool outputs
909-
- [ ] Block registered in `registry.ts` blocks object (alphabetically)
910-
- [ ] `{Service}BlockMeta` exported at bottom of block file with `tags` and `templates`
911-
- [ ] `url` set on `{Service}BlockMeta` to the external service's verified homepage (omit only for first-party blocks with no external service)
912-
- [ ] `skills` added to `{Service}BlockMeta`, each grounded in the block's `tools.access` and derived from a real online-sourced use case (not invented)
913-
- [ ] `BlockMeta` imported from `@/blocks/types` alongside `BlockConfig`
914-
- [ ] Block meta registered in `registry.ts` blocksMeta object (alphabetically)
870+
- [ ] Block + meta registered in registry-maps.ts (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`)
915871
- [ ] If icon missing: asked user to provide SVG
916872
- [ ] If triggers exist: `triggers` config set, trigger subBlocks spread
917873
- [ ] Optional/rarely-used fields set to `mode: 'advanced'`
918874
- [ ] Timestamps and complex inputs have `wandConfig` enabled
875+
- [ ] Exported `{Service}BlockMeta` with at least 7 templates
876+
- [ ] `url` set on `{Service}BlockMeta` to the external service's verified homepage (omit only for first-party blocks with no external service)
877+
- [ ] `skills` added to `{Service}BlockMeta`, each grounded in `tools.access` and sourced from a real online use case (not invented)
919878

920879
## Final Validation (Required)
921880

@@ -929,4 +888,5 @@ After creating the block, you MUST validate it against every tool it references:
929888
- Type coercions in `tools.config.params` for any params that need conversion (Number(), Boolean(), JSON.parse())
930889
3. **Verify block outputs** cover the key fields returned by all tools
931890
4. **Verify conditions** — each subBlock should only show for the operations that actually use it
932-
5. **If any tool outputs are still unknown**, explicitly tell the user instead of guessing block outputs
891+
5. **Verify `{Service}BlockMeta` is exported** with at least 7 templates, each having `icon`, `title`, `prompt`, `modules`, `category`, and `tags`
892+
6. **If any tool outputs are still unknown**, explicitly tell the user instead of guessing block outputs

0 commit comments

Comments
 (0)