Skip to content

Commit 2686f04

Browse files
perf(dev): SIM_DEV_MINIMAL_REGISTRY mode to slash local dev-server RAM (#5223)
* perf(dev): SIM_DEV_MINIMAL_REGISTRY mode to slash local dev-server RAM Adds a dev-only escape hatch (`bun run dev:minimal`, or `dev:full:minimal` with the realtime server): when SIM_DEV_MINIMAL_REGISTRY=1, a Turbopack/webpack resolve-alias swaps the two heavy registries for tiny curated variants — `@/tools/registry` → 2 tools, `@/blocks/registry-maps` → ~20 core blocks. The shared workspace layout drags the full ~247-tool registry (~2,074 modules) into every route via providers/utils → tools/params, and the editor/executor pull all ~268 block configs; aliasing both stops Turbopack from compiling those graphs at all. To make the blocks alias clean, the heavy block import maps move out of registry.ts into registry-maps.ts (registry.ts keeps only its accessors, importing the maps); its public API is unchanged and full builds/tests use the full maps. The alias is gated on isDev + the flag and is never applied in production. Measured (Turbopack dev, authenticated, /logs): peak next-server RSS ~16 GB → ~4.7 GB, compile 4.9 min → ~18 s; the workflow editor route similarly drops to ~5 GB / ~17 s. Only http_request + function_execute and the curated core blocks work in minimal mode; unset the flag for the full set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * perf(dev): add table block to minimal registry; doc block registration in registry-maps Adds the Table block to the SIM_DEV_MINIMAL_REGISTRY curated set so the tables surface works under dev:minimal. Updates the integration skills/rules and CLAUDE.md to point block registration at blocks/registry-maps.ts (the BLOCK_REGISTRY / BLOCK_META_REGISTRY maps), reflecting that registry.ts now holds only the accessor functions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(dev): rename dev:full:minimal → dev:full:minimal-registry Matches the dev:full:* formatting and makes the suffix self-explanatory — it is the registry that's minimal, not the dev stack. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2554725 commit 2686f04

16 files changed

Lines changed: 1047 additions & 915 deletions

.claude/commands/add-block.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,20 @@ export const ServiceV2Block: BlockConfig = {
600600

601601
## Registering Blocks
602602

603-
After creating the block, remind the user to:
604-
1. Import in `apps/sim/blocks/registry.ts`
605-
2. Add to the `registry` object (alphabetically):
603+
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:
606604

607605
```typescript
608-
import { ServiceBlock } from '@/blocks/blocks/service'
606+
import { ServiceBlock, ServiceBlockMeta } from '@/blocks/blocks/service'
609607

610-
export const registry: Record<string, BlockConfig> = {
608+
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
611609
// ... existing blocks ...
612610
service: ServiceBlock,
613611
}
612+
613+
export const BLOCK_META_REGISTRY: Record<string, BlockMeta> = {
614+
// ... existing metas ...
615+
service: ServiceBlockMeta,
616+
}
614617
```
615618

616619
## Complete Example
@@ -840,7 +843,7 @@ Derive templates from the service's real use cases. Each prompt should name a co
840843
- [ ] Tools.access lists all tool IDs (snake_case)
841844
- [ ] Tools.config.tool returns correct tool ID (snake_case)
842845
- [ ] Outputs match tool outputs
843-
- [ ] Block registered in registry.ts
846+
- [ ] Block + meta registered in registry-maps.ts (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`)
844847
- [ ] If icon missing: asked user to provide SVG
845848
- [ ] If triggers exist: `triggers` config set, trigger subBlocks spread
846849
- [ ] Optional/rarely-used fields set to `mode: 'advanced'`

.claude/commands/add-integration.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,25 @@ export const tools: Record<string, ToolConfig> = {
364364
}
365365
```
366366

367-
### Block Registry (`apps/sim/blocks/registry.ts`)
367+
### Block Registry (`apps/sim/blocks/registry-maps.ts`)
368+
369+
The data maps (`BLOCK_REGISTRY` + `BLOCK_META_REGISTRY`) live in `registry-maps.ts`; `registry.ts` holds only the accessor functions. Add the import and an entry to each map alphabetically:
368370

369371
```typescript
370372
// Add import (alphabetically)
371-
import { {Service}Block } from '@/blocks/blocks/{service}'
373+
import { {Service}Block, {Service}BlockMeta } from '@/blocks/blocks/{service}'
372374

373-
// Add to registry (alphabetically)
374-
export const registry: Record<string, BlockConfig> = {
375+
// Add to the config map (alphabetically)
376+
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
375377
// ... existing blocks ...
376378
{service}: {Service}Block,
377379
}
380+
381+
// Add to the catalog-meta map (alphabetically)
382+
export const BLOCK_META_REGISTRY: Record<string, BlockMeta> = {
383+
// ... existing metas ...
384+
{service}: {Service}BlockMeta,
385+
}
378386
```
379387

380388
### Trigger Registry (`apps/sim/triggers/registry.ts`) - If triggers exist
@@ -443,7 +451,7 @@ If creating V2 versions (API-aligned outputs):
443451
- [ ] Configured tools.access with all tool IDs
444452
- [ ] Configured tools.config.tool selector
445453
- [ ] Defined outputs matching tool outputs
446-
- [ ] Registered block in `blocks/registry.ts`
454+
- [ ] Registered block + meta in `blocks/registry-maps.ts` (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`)
447455
- [ ] If triggers: set `triggers.enabled` and `triggers.available`
448456
- [ ] If triggers: spread trigger subBlocks with `getTrigger()`
449457
- [ ] Exported `{Service}BlockMeta` with at least 7 templates

.claude/commands/validate-integration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Read **every** file for the integration — do not skip any:
2424
apps/sim/tools/{service}/ # All tool files, types.ts, index.ts
2525
apps/sim/blocks/blocks/{service}.ts # Block definition
2626
apps/sim/tools/registry.ts # Tool registry entries for this service
27-
apps/sim/blocks/registry.ts # Block registry entry for this service
27+
apps/sim/blocks/registry-maps.ts # Block + meta registry entry (BLOCK_REGISTRY / BLOCK_META_REGISTRY)
2828
apps/sim/components/icons.tsx # Icon definition
2929
apps/sim/lib/auth/auth.ts # OAuth config — should use getCanonicalScopesForProvider()
3030
apps/sim/lib/oauth/oauth.ts # OAuth provider config — single source of truth for scopes
@@ -190,7 +190,7 @@ For **each tool** in `tools.access`:
190190
- [ ] `bgColor` uses the service's brand color hex
191191
- [ ] `icon` references the correct icon component from `@/components/icons`
192192
- [ ] `authMode` is set correctly (`AuthMode.OAuth` or `AuthMode.ApiKey`)
193-
- [ ] Block is registered in `blocks/registry.ts` alphabetically
193+
- [ ] Block + meta are registered in `blocks/registry-maps.ts` (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`) alphabetically
194194

195195
### BlockMeta
196196
- [ ] `{Service}BlockMeta` is exported in the same file as the block

.claude/rules/sim-integrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The full authoring instructions — tool/block/icon/trigger scaffolding, SubBloc
1313

1414
## Hard rules (don't get these wrong)
1515

16-
- Tool IDs are `snake_case` (`service_action`). Register tools in `tools/registry.ts`, blocks in `blocks/registry.ts` (alphabetically), triggers in `triggers/registry.ts`.
16+
- Tool IDs are `snake_case` (`service_action`). Register tools in `tools/registry.ts`, blocks in `blocks/registry-maps.ts` (the `BLOCK_REGISTRY` config map + `BLOCK_META_REGISTRY` catalog-meta map, alphabetically`blocks/registry.ts` holds only the accessor functions), triggers in `triggers/registry.ts`.
1717
- Type coercions (`Number()`, etc.) belong in `tools.config.params` (runs at execution, after variable resolution) — never in `tools.config.tool` (runs at serialization; coercing there destroys dynamic `<Block.output>` references).
1818
- `canonicalParamId` must NOT match any subblock's `id`, must be unique per operation/condition context, and all subblocks in a canonical group must share the same `required` status. The `inputs` section and the params function reference canonical IDs, not raw subblock IDs.
1919
- Blocks must also set the catalog/UI metadata fields `integrationType`, `tags`, `authMode`, `docsLink`, and export a `{Service}BlockMeta` — see the `/add-block` skill's BlockMeta section for details.

.cursor/commands/add-block.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,17 +608,20 @@ export const ServiceV2Block: BlockConfig = {
608608

609609
## Registering Blocks
610610

611-
After creating the block, remind the user to:
612-
1. Import in `apps/sim/blocks/registry.ts`
613-
2. Add to the `registry` object (alphabetically):
611+
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:
614612

615613
```typescript
616-
import { ServiceBlock } from '@/blocks/blocks/service'
614+
import { ServiceBlock, ServiceBlockMeta } from '@/blocks/blocks/service'
617615

618-
export const registry: Record<string, BlockConfig> = {
616+
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
619617
// ... existing blocks ...
620618
service: ServiceBlock,
621619
}
620+
621+
export const BLOCK_META_REGISTRY: Record<string, BlockMeta> = {
622+
// ... existing metas ...
623+
service: ServiceBlockMeta,
624+
}
622625
```
623626

624627
## Complete Example
@@ -847,7 +850,7 @@ Derive templates from the service's real use cases. Each prompt should name a co
847850
- [ ] Tools.access lists all tool IDs (snake_case)
848851
- [ ] Tools.config.tool returns correct tool ID (snake_case)
849852
- [ ] Outputs match tool outputs
850-
- [ ] Block registered in registry.ts
853+
- [ ] Block + meta registered in registry-maps.ts (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`)
851854
- [ ] If icon missing: asked user to provide SVG
852855
- [ ] If triggers exist: `triggers` config set, trigger subBlocks spread
853856
- [ ] Optional/rarely-used fields set to `mode: 'advanced'`

.cursor/commands/add-integration.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,25 @@ export const tools: Record<string, ToolConfig> = {
337337
}
338338
```
339339

340-
### Block Registry (`apps/sim/blocks/registry.ts`)
340+
### Block Registry (`apps/sim/blocks/registry-maps.ts`)
341+
342+
The data maps (`BLOCK_REGISTRY` + `BLOCK_META_REGISTRY`) live in `registry-maps.ts`; `registry.ts` holds only the accessor functions. Add the import and an entry to each map alphabetically:
341343

342344
```typescript
343345
// Add import (alphabetically)
344-
import { {Service}Block } from '@/blocks/blocks/{service}'
346+
import { {Service}Block, {Service}BlockMeta } from '@/blocks/blocks/{service}'
345347

346-
// Add to registry (alphabetically)
347-
export const registry: Record<string, BlockConfig> = {
348+
// Add to the config map (alphabetically)
349+
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
348350
// ... existing blocks ...
349351
{service}: {Service}Block,
350352
}
353+
354+
// Add to the catalog-meta map (alphabetically)
355+
export const BLOCK_META_REGISTRY: Record<string, BlockMeta> = {
356+
// ... existing metas ...
357+
{service}: {Service}BlockMeta,
358+
}
351359
```
352360

353361
### Trigger Registry (`apps/sim/triggers/registry.ts`) - If triggers exist
@@ -416,7 +424,7 @@ If creating V2 versions (API-aligned outputs):
416424
- [ ] Configured tools.access with all tool IDs
417425
- [ ] Configured tools.config.tool selector
418426
- [ ] Defined outputs matching tool outputs
419-
- [ ] Registered block in `blocks/registry.ts`
427+
- [ ] Registered block + meta in `blocks/registry-maps.ts` (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`)
420428
- [ ] If triggers: set `triggers.enabled` and `triggers.available`
421429
- [ ] If triggers: spread trigger subBlocks with `getTrigger()`
422430

.cursor/commands/validate-integration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Read **every** file for the integration — do not skip any:
1919
apps/sim/tools/{service}/ # All tool files, types.ts, index.ts
2020
apps/sim/blocks/blocks/{service}.ts # Block definition
2121
apps/sim/tools/registry.ts # Tool registry entries for this service
22-
apps/sim/blocks/registry.ts # Block registry entry for this service
22+
apps/sim/blocks/registry-maps.ts # Block + meta registry entry (BLOCK_REGISTRY / BLOCK_META_REGISTRY)
2323
apps/sim/components/icons.tsx # Icon definition
2424
apps/sim/lib/auth/auth.ts # OAuth config — should use getCanonicalScopesForProvider()
2525
apps/sim/lib/oauth/oauth.ts # OAuth provider config — single source of truth for scopes
@@ -185,7 +185,7 @@ For **each tool** in `tools.access`:
185185
- [ ] `bgColor` uses the service's brand color hex
186186
- [ ] `icon` references the correct icon component from `@/components/icons`
187187
- [ ] `authMode` is set correctly (`AuthMode.OAuth` or `AuthMode.ApiKey`)
188-
- [ ] Block is registered in `blocks/registry.ts` alphabetically
188+
- [ ] Block + meta are registered in `blocks/registry-maps.ts` (`BLOCK_REGISTRY` / `BLOCK_META_REGISTRY`) alphabetically
189189

190190
### BlockMeta
191191
- [ ] `{Service}BlockMeta` is exported in the same file as the block

.cursor/rules/sim-integrations.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The full authoring instructions — tool/block/icon/trigger scaffolding, SubBloc
1010

1111
## Hard rules (don't get these wrong)
1212

13-
- Tool IDs are `snake_case` (`service_action`). Register tools in `tools/registry.ts`, blocks in `blocks/registry.ts` (alphabetically), triggers in `triggers/registry.ts`.
13+
- Tool IDs are `snake_case` (`service_action`). Register tools in `tools/registry.ts`, blocks in `blocks/registry-maps.ts` (the `BLOCK_REGISTRY` config map + `BLOCK_META_REGISTRY` catalog-meta map, alphabetically — `blocks/registry.ts` holds only the accessor functions), triggers in `triggers/registry.ts`.
1414
- Type coercions (`Number()`, etc.) belong in `tools.config.params` (runs at execution, after variable resolution) — never in `tools.config.tool` (runs at serialization; coercing there destroys dynamic `<Block.output>` references).
1515
- `canonicalParamId` must NOT match any subblock's `id`, must be unique per operation/condition context, and all subblocks in a canonical group must share the same `required` status. The `inputs` section and the params function reference canonical IDs, not raw subblock IDs.
1616
- Blocks must also set the catalog/UI metadata fields `integrationType`, `tags`, `authMode`, `docsLink`, and export a `{Service}BlockMeta` — see the `/add-block` skill's BlockMeta section for details.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ New integrations are built in order: **Tools** → **Block** → **Icon** → (o
469469

470470
Two hard rules that the skills assume:
471471

472-
- **Tool IDs are `snake_case`** (`service_action`) and must be registered in `tools/registry.ts`; blocks register in `blocks/registry.ts` (alphabetically).
472+
- **Tool IDs are `snake_case`** (`service_action`) and must be registered in `tools/registry.ts`; blocks register in `blocks/registry-maps.ts` — the `BLOCK_REGISTRY` config map and `BLOCK_META_REGISTRY` catalog-meta map (alphabetically). `blocks/registry.ts` holds only the accessor functions (`getBlock`, `getAllBlocks`, …).
473473
- **`tools.config.tool` runs during serialization (before variable resolution)** — never do `Number()` or other type coercions there, or dynamic references like `<Block.output>` are destroyed. Put all type coercions in `tools.config.params`, which runs during execution after variables resolve.
474474

475475
For the full authoring instructions — SubBlock property tables, `condition`/`dependsOn`/`required`/`mode`/`canonicalParamId` syntax, required block metadata (`integrationType`, `tags`, `authMode`, `docsLink`, `{Service}BlockMeta`), file-input/`normalizeFileInput` patterns, and checklists — use the skills: `/add-integration` (end-to-end), `/add-tools`, `/add-block`, `/add-trigger`.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { AgentBlock } from '@/blocks/blocks/agent'
2+
import { ApiBlock } from '@/blocks/blocks/api'
3+
import { ApiTriggerBlock } from '@/blocks/blocks/api_trigger'
4+
import { ChatTriggerBlock } from '@/blocks/blocks/chat_trigger'
5+
import { ConditionBlock } from '@/blocks/blocks/condition'
6+
import { EvaluatorBlock } from '@/blocks/blocks/evaluator'
7+
import { FunctionBlock } from '@/blocks/blocks/function'
8+
import { GenericWebhookBlock } from '@/blocks/blocks/generic_webhook'
9+
import { InputTriggerBlock } from '@/blocks/blocks/input_trigger'
10+
import { KnowledgeBlock } from '@/blocks/blocks/knowledge'
11+
import { ManualTriggerBlock } from '@/blocks/blocks/manual_trigger'
12+
import { MemoryBlock } from '@/blocks/blocks/memory'
13+
import { NoteBlock } from '@/blocks/blocks/note'
14+
import { ResponseBlock } from '@/blocks/blocks/response'
15+
import { RouterBlock } from '@/blocks/blocks/router'
16+
import { ScheduleBlock } from '@/blocks/blocks/schedule'
17+
import { StartTriggerBlock } from '@/blocks/blocks/start_trigger'
18+
import { StarterBlock } from '@/blocks/blocks/starter'
19+
import { TableBlock } from '@/blocks/blocks/table'
20+
import { VariablesBlock } from '@/blocks/blocks/variables'
21+
import { WorkflowBlock } from '@/blocks/blocks/workflow'
22+
import type { BlockConfig, BlockMeta } from '@/blocks/types'
23+
24+
/**
25+
* Dev-only minimal block maps. Swapped in for `@/blocks/registry-maps` via a
26+
* resolve-alias when `SIM_DEV_MINIMAL_REGISTRY=1` (see next.config.ts) so the
27+
* dev server only compiles a curated core set of block configs instead of all
28+
* ~268. Only these blocks resolve in the editor/executor in minimal mode; unset
29+
* the flag for the full set. NEVER aliased in production.
30+
*/
31+
export const BLOCK_REGISTRY: Record<string, BlockConfig> = {
32+
agent: AgentBlock,
33+
api: ApiBlock,
34+
api_trigger: ApiTriggerBlock,
35+
chat_trigger: ChatTriggerBlock,
36+
condition: ConditionBlock,
37+
evaluator: EvaluatorBlock,
38+
function: FunctionBlock,
39+
generic_webhook: GenericWebhookBlock,
40+
input_trigger: InputTriggerBlock,
41+
knowledge: KnowledgeBlock,
42+
manual_trigger: ManualTriggerBlock,
43+
memory: MemoryBlock,
44+
note: NoteBlock,
45+
response: ResponseBlock,
46+
router: RouterBlock,
47+
schedule: ScheduleBlock,
48+
start_trigger: StartTriggerBlock,
49+
starter: StarterBlock,
50+
table: TableBlock,
51+
variables: VariablesBlock,
52+
workflow: WorkflowBlock,
53+
}
54+
55+
export const BLOCK_META_REGISTRY: Record<string, BlockMeta> = {}

0 commit comments

Comments
 (0)