diff --git a/.github/workflows/publish-sim-cli.yml b/.github/workflows/publish-sim-cli.yml
index 8146da78d87..4ba40ae9560 100644
--- a/.github/workflows/publish-sim-cli.yml
+++ b/.github/workflows/publish-sim-cli.yml
@@ -6,8 +6,14 @@ on:
paths:
- 'packages/sim-cli/**'
# The build bundles its workspace dependencies, so a change there
- # changes what ships.
+ # changes what ships. `bun run check:sim-cli-bundle` fails when this
+ # list and the bundle's workspace packages disagree.
+ - 'packages/table-cells/**'
- 'packages/utils/**'
+ - 'packages/workflow-code/**'
+ - 'packages/workflow-sdk/**'
+ - 'packages/workflow-types/**'
+ - 'packages/workspace-code/**'
# A change to how the package is built or published has to republish it.
- '.github/workflows/publish-sim-cli.yml'
diff --git a/apps/docs/content/docs/cli/scripting.mdx b/apps/docs/content/docs/cli/scripting.mdx
index 1214f561331..90617965b3e 100644
--- a/apps/docs/content/docs/cli/scripting.mdx
+++ b/apps/docs/content/docs/cli/scripting.mdx
@@ -168,12 +168,12 @@ The CLI resends a request the API answers `429` only when sending it twice is sa
| Code | `sim workflows source apply` or `create` |
| --- | --- |
| `0` | Applied or created, or a dry run with no errors |
-| `1` | The source has errors (each printed as `file:line:column` with its frame and hint), or command/request failure |
+| `1` | The source has errors (each printed as `file:line:column` with its frame and hint), `create`'s workflow name is taken (`SOURCE_NAME_TAKEN`: pass `--name`), or command/request failure |
| `5` | The workflow changed since the directory was read (`409 SOURCE_STALE`): get it again, reapply the edit, and retry |
| `6` | The workflow or its folder is locked (`423`, `E_APPLY_LOCKED`); a locked block exits `1` (`E_APPLY_LOCKED_BLOCK`) |
| `7` | The source is over the size limits (`413`) |
| `9` | Still rate limited (`429`) after the CLI's retries; nothing was written |
-| `10` | `--dir` is a workflow folder of a workspace directory another `sim` command is using (`SOURCE_DIR_BUSY`); nothing was written: run it again once the other finished |
+| `10` | Busy, retry: another `sim` command is using `--dir`, or the workspace directory it is a workflow folder of (`SOURCE_DIR_BUSY`); nothing was read or written: run it again once the other finished |
| `13` | `AUTH_REQUIRED`: not logged in, or the server refused the credential; nothing was sent |
| `14` | Run without `--yes` and with no terminal to ask: the plan was printed with no errors and nothing was written; run the same command with `--yes` |
| `130` | Interrupted (Ctrl-C). A write already sent is finished and saved into the directory first, waiting up to 60s for its answer; a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check |
@@ -183,6 +183,7 @@ The CLI resends a request the API answers `429` only when sending it twice is sa
| `0` | Clean: nothing to apply, and the server changed nothing since the directory was read |
| `1` | Command/request failure |
| `7` | The source is too large for the server to read in one dry run |
+| `10` | `sim workspaces source status` only: another `sim workspaces source` command is using the directory (`SOURCE_DIR_BUSY`); nothing was read: run it again once the other finished |
| `11` | Local changes only: applying writes them |
| `12` | The server changed since the directory was read (drift, or a conflict with local changes) |
| `13` | `AUTH_REQUIRED`: not logged in, or the server refused the credential; the local changes are still shown |
@@ -191,13 +192,17 @@ The CLI resends a request the API answers `429` only when sending it twice is sa
| --- | --- |
| `0` | No errors (warnings may still print) |
| `1` | The source has errors, or a warning that fails the check on a block the edit added (see `--strict`), or no block catalog is cached: run the get once |
+| `10` | `sim workspaces source check` only: another `sim workspaces source` command is using the directory (`SOURCE_DIR_BUSY`); nothing was read: run it again once the other finished |
| Code | `sim workflows source get --dir` or `sim workspaces source get` |
| --- | --- |
| `0` | Written |
-| `1` | The directory holds edits no apply has saved (`SOURCE_LOCAL_EDITS`) or another workflow's source (`SOURCE_WORKFLOW_MISMATCH`): apply them, get into another directory, or pass `--force`; or command/request failure |
+| `1` | The directory holds edits no apply has saved (`SOURCE_LOCAL_EDITS`) or another workflow's source (`SOURCE_WORKFLOW_MISMATCH`): apply them, get into another directory, or pass `--force`; it is the other kind of source directory (`SOURCE_DIR_KIND_MISMATCH`, even with `--force`); for a workspace, `--workspace` names another workspace than the one the directory was read from (`SOURCE_OTHER_WORKSPACE`) or a downloaded binary file does not match its listing (`SOURCE_BLOB_MISMATCH`); or command/request failure |
| `7` | The workflow, or a kind of resource, is too large for one directory |
| `9` | Still rate limited (`429`) after the CLI's retries; nothing was written |
+| `10` | Busy, retry: another `sim` command is using the directory (or, for a workflow folder, its workspace directory) (`SOURCE_DIR_BUSY`); nothing was read or written: run it again once the other finished |
+| `13` | `AUTH_REQUIRED`: not logged in, the login expired, or the server refused the credential; nothing was read or written: run `sim login` and the get again |
+| `130` | Interrupted (Ctrl-C): run the get again |
| Code | `sim workspaces source apply` |
| --- | --- |
diff --git a/apps/docs/content/docs/platform/enterprise/audit-logs.mdx b/apps/docs/content/docs/platform/enterprise/audit-logs.mdx
index c052d61cd71..a34860bc9ad 100644
--- a/apps/docs/content/docs/platform/enterprise/audit-logs.mdx
+++ b/apps/docs/content/docs/platform/enterprise/audit-logs.mdx
@@ -104,7 +104,7 @@ Events use identifiers such as `resource.action`. These categories are represent
| Links | `sim_link.created`, `sim_link.updated`, `sim_link.deleted` |
| Exports and drains | `audit_logs.exported`, `data_drain.created`, `data_drain.updated`, `data_drain.ran`, `data_drain.tested` |
-Authentication failures and password-reset requests use an anonymous actor and record the target account separately. Impersonation and administrative session revocations identify the operator and target organization. Table-row mutations record summaries and counts without copying row contents.
+Authentication failures and password-reset requests use an anonymous actor and record the target account separately. Impersonation and administrative session revocations identify the operator and target organization. Table-row mutations record summaries and counts without copying row contents. A workflow or workspace written from source by the CLI (`workflow.created`, `workflow.updated` or `workspace.updated`) records `metadata.client` as `cli` and, when the source directory is in a git repository and `git` can read them, `metadata.gitSha` (the commit checked out) and `metadata.repo` (the `origin` remote URL, with any credentials removed). Either may be absent, for example `repo` in a repository with no `origin`.
When a workflow run makes the same kind of change to a table many times in quick succession, such as inserting rows in a loop, the repeats are merged into one `table.updated` entry. The merged entry keeps every row ID in `metadata.rowIds`, sums the counts, and records in `metadata.rollup` how many changes it covers and when the first and last happened. The actor of any workflow-made entry names the workflow (`metadata.actor.workflowId`) and the run (`metadata.actor.executionId`). Credential use by a workflow run is merged the same way: one `credential.accessed` entry per credential, counting the repeats, that names the workflow (`metadata.workflowId`) and the run (`metadata.executionId`).
diff --git a/apps/docs/content/docs/workflows/code.mdx b/apps/docs/content/docs/workflows/code.mdx
index e686757a492..03a2d5dfae4 100644
--- a/apps/docs/content/docs/workflows/code.mdx
+++ b/apps/docs/content/docs/workflows/code.mdx
@@ -19,9 +19,9 @@ Claude Code, Cursor, Codex and other coding agents work from a directory that `g
2. Edit `workflow.ts`.
3. `sim workflows source check --dir
` compiles it offline.
4. `sim workflows source status --dir ` shows what changed and what to run next.
+5. `sim workflows source apply --dir --dry-run`, then `--yes`, saves the draft.
To write a block the workflow does not use yet, `sim workflows source params ` (for example `table.upsertRow` or `trigger.schedule`) prints its params, required ones first with their options and defaults, and its outputs, from the cached block catalog without a request. A namespace such as `gmail` lists its builders.
-5. `sim workflows source apply --dir --dry-run`, then `--yes`, saves the draft.
For a whole workspace, use `sim workspaces source` with the same steps; see [Workspace as code](/workflows/workspace-code).
@@ -206,6 +206,7 @@ Run `sim workflows source apply --dir --dry-run` in CI to cat
- **Commit** `workflow.ts`, `functions/`, `.sim/lock.json`, `.sim/base.json`, `.sim/written.json`, `tsconfig.json` and `.gitattributes`. CI finds the workflow from `workflowId` in `.sim/base.json`, and `status` and `get` use `.sim/written.json` to tell your edits apart from what the CLI last wrote.
- **Optionally gitignore** `.sim/sdk/`, the generated type declarations of the blocks in use (a few dozen files); `get` and `check` write them again. Gitignore `tsconfig.full.json`, which names the CLI's cache on your machine; `check` writes it again. A single-workflow directory gets no `.gitignore`, so add the lines yourself.
- **A whole workspace** in one repository, with dry runs on pull requests, apply on merge and promotion from one workspace to another, is covered in [Git and CI](/workflows/workspace-code#git-and-ci) and [Promote to another workspace](/workflows/workspace-code#promote-to-another-workspace).
+- **Git provenance:** in a git repository, `apply` and `create` send the commit checked out (`HEAD`) and the `origin` remote URL, with any credentials, query or fragment removed, as `provenance.gitSha` and `provenance.repo`, each only when `git` can read it (a repository with no `origin` sends only the commit). A saved write records what was sent in its [audit log](/platform/enterprise/audit-logs) entry (`workflow.updated` or `workflow.created`). A directory outside a repository sends neither.
- **Credentials:** use a personal API key (**Settings → Sim API keys**, passed as `SIM_API_KEY`) or an OAuth login, not a workspace API key. Saving and dry-running source act as a person, so a workspace key is refused with `403`. Set `SIM_WORKSPACE` unless you pass `--workspace`, and `SIM_ENDPOINT` if you use a self-hosted Sim. See [Authenticating CI](/cli/authentication#authenticating-ci).
## Working with other people
diff --git a/apps/docs/content/docs/workflows/workspace-code.mdx b/apps/docs/content/docs/workflows/workspace-code.mdx
index c19b2711db9..343e84c0deb 100644
--- a/apps/docs/content/docs/workflows/workspace-code.mdx
+++ b/apps/docs/content/docs/workflows/workspace-code.mdx
@@ -108,6 +108,8 @@ Commit the record with the rest of the directory, so a promotion from CI or anot
Commit the whole directory, including `.sim/`: its base files are what an apply compares with, from any clone. The generated `.gitignore` leaves out only temporary files. A fresh clone can run `check`, `apply --dry-run` and `apply` with nothing else. See [Workspace source in CI](/cli/scripting#workspace-source-in-ci) for a GitHub Actions setup.
+In a git repository, `apply` sends the commit checked out (`HEAD`) and the `origin` remote URL, with any credentials, query or fragment removed, as `provenance.gitSha` and `provenance.repo`, each only when `git` can read it (a repository with no `origin` sends only the commit). An apply that writes records what was sent in its `workspace.updated` [audit log](/platform/enterprise/audit-logs) entry. A directory outside a repository sends neither.
+
## Good to know
- Secret values never appear. Workflows read environment variables as `env.NAME`, tool code as `$env.NAME`, and credentials by key.
diff --git a/biome.json b/biome.json
index b0416e01262..546485bb175 100644
--- a/biome.json
+++ b/biome.json
@@ -37,6 +37,7 @@
"!**/packages/workflow-sdk/src/codegen/core-text.generated.ts",
"!**/packages/workflow-sdk/src/codegen/cookbook-text.generated.ts",
"!**/packages/workflow-sdk/src/codegen/workspace-cookbook-text.generated.ts",
+ "!**/packages/workflow-sdk/src/codegen/workspace-text.generated.ts",
"!**/packages/workflow-sdk/cookbook/workspace/tools/*.js",
"!**/apps/docs/.content",
"!**/apps/desktop/release",
diff --git a/bun.lock b/bun.lock
index 056fe46baf8..0cb4d786ab5 100644
--- a/bun.lock
+++ b/bun.lock
@@ -755,7 +755,7 @@
},
"packages/sim-cli": {
"name": "sim",
- "version": "2.2.0",
+ "version": "2.3.0",
"bin": {
"sim": "dist/index.js",
},
diff --git a/package.json b/package.json
index 05f2d676768..eda9b13af7c 100644
--- a/package.json
+++ b/package.json
@@ -39,6 +39,9 @@
"check:mcp-operations": "bun run scripts/generate-v2-mcp-operations.ts --check",
"generate:cli-docs": "bun run scripts/generate-cli-docs.ts",
"check:cli-docs": "bun run scripts/generate-cli-docs.ts --check",
+ "check:sim-cli-bundle": "bun run scripts/check-sim-cli-bundle.ts",
+ "generate:workflow-sdk-embedded-text": "bun run packages/workflow-sdk/scripts/generate-embedded-text.ts",
+ "check:workflow-sdk-embedded-text": "bun run packages/workflow-sdk/scripts/generate-embedded-text.ts --check",
"generate:v2-route-table": "bun run scripts/generate-v2-route-table.ts",
"check:v2-route-table": "bun run scripts/generate-v2-route-table.ts --check",
"check:canonical-index": "bun run scripts/check-canonical-index-surface.ts",
diff --git a/packages/sim-cli/THIRD_PARTY_LICENSES b/packages/sim-cli/THIRD_PARTY_LICENSES
index 5bf48a1bb88..ebc4e0ef953 100644
--- a/packages/sim-cli/THIRD_PARTY_LICENSES
+++ b/packages/sim-cli/THIRD_PARTY_LICENSES
@@ -1,5 +1,11 @@
The Sim CLI bundle includes the following third-party software.
+@babel/parser
+Copyright (C) 2012-2014 by various contributors (see AUTHORS)
+
+@noble/hashes
+Copyright (c) 2022 Paul Miller (https://paulmillr.com)
+
chalk
Copyright (c) Sindre Sorhus (https://sindresorhus.com)
@@ -22,6 +28,9 @@ retry
Copyright (c) 2011 Tim Koschützki (tim@debuggable.com)
Copyright (c) 2011 Felix Geisendörfer (felix@debuggable.com)
+zod
+Copyright (c) 2025 Colin McDonnell
+
Each dependency above is licensed under the MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/packages/sim-cli/package.json b/packages/sim-cli/package.json
index 282abb9a606..3467697e29e 100644
--- a/packages/sim-cli/package.json
+++ b/packages/sim-cli/package.json
@@ -1,6 +1,6 @@
{
"name": "sim",
- "version": "2.2.0",
+ "version": "2.3.0",
"description": "Sim CLI - talk to the Sim API from your terminal",
"type": "module",
"imports": {
diff --git a/packages/sim-cli/src/commands/protocol/workspace-source-apply.test.ts b/packages/sim-cli/src/commands/protocol/workspace-source-apply.test.ts
index 11300b73418..a054f034f21 100644
--- a/packages/sim-cli/src/commands/protocol/workspace-source-apply.test.ts
+++ b/packages/sim-cli/src/commands/protocol/workspace-source-apply.test.ts
@@ -814,24 +814,29 @@ describe('workspaces source apply', () => {
expect(request).not.toHaveBeenCalled()
})
- it('removes the code file of a tool the apply reprinted as stored(), from disk and the record', async () => {
- const declaration = (code: string) =>
- `// @sim-sdk 1\nexport default defineTool({ title: 'Lookup', code: ${code} })\n`
- write('tools/lookup.ts', declaration("codeFile('./lookup.js')"))
+ it('keeps the code file of a tool the apply reprinted as stored(), warns, and never sends it again', async () => {
+ const schema = "{ type: 'function', function: { name: 'lookup', parameters: {} } }"
+ const declaration = (call: 'codeFile' | 'stored', code: string) =>
+ `// @sim-sdk 1\nimport { ${call}, defineTool } from '@sim/workflow-sdk/workspace'\n\nexport default defineTool({ title: 'Lookup', schema: ${schema}, code: ${code} })\n`
+ write('tools/lookup.ts', declaration('codeFile', "codeFile('./lookup.js')"))
write('tools/lookup.js', 'return 1\n')
write('tools/other.js', 'return 2\n')
request.mockResolvedValue(
answer({
applied: [{ kind: 'custom-tool', key: 'lookup', action: 'update', id: 'tool_1' }],
- files: { 'tools/lookup.ts': declaration('stored()') },
+ files: { 'tools/lookup.ts': declaration('stored', 'stored()') },
})
)
await apply('--yes')
expect(bodies()[0].files['tools/lookup.js']).toBe('return 1\n')
- expect(existsSync(join(dir, 'tools/lookup.js'))).toBe(false)
+ // The person's only copy of the code: like a workflow's function file, it is never deleted.
+ expect(readFileSync(join(dir, 'tools/lookup.js'), 'utf8')).toBe('return 1\n')
expect(readFileSync(join(dir, 'tools/other.js'), 'utf8')).toBe('return 2\n')
+ expect(vi.mocked(console.error).mock.calls.flat().join('\n')).toContain(
+ 'warning: tools/lookup.js is no longer named by tools/lookup.ts'
+ )
const record = JSON.parse(readFileSync(join(dir, '.sim/written.json'), 'utf8'))
expect(Object.keys(record.files)).toContain('tools/lookup.ts')
expect(Object.keys(record.files)).not.toContain('tools/lookup.js')
diff --git a/packages/sim-cli/src/commands/protocol/workspace-source-apply.ts b/packages/sim-cli/src/commands/protocol/workspace-source-apply.ts
index 9c901d7fc70..b11758c4894 100644
--- a/packages/sim-cli/src/commands/protocol/workspace-source-apply.ts
+++ b/packages/sim-cli/src/commands/protocol/workspace-source-apply.ts
@@ -80,6 +80,7 @@ import {
ONLY_KINDS_HELP,
parseKinds,
readWorkspaceDir,
+ toolOfCodeFile,
type WorkspaceSubmission,
} from './workspace-source-dir'
@@ -353,9 +354,9 @@ async function deletedRecordedPaths(
/**
* The text files the directory sent for a resource the apply reprinted that the reprint no longer
- * holds: a tool whose code the server keeps as `stored()` (a credential in it) is reprinted
- * without `tools/.js`, which left on disk would refuse the next apply (`E_TOOL_CODE`).
- * Workflow folders keep files no lock named, so their function files are pruned by lock instead
+ * holds, such as a tool whose code the server keeps as `stored()` (a credential in it), reprinted
+ * without `tools/.js` ({@link saveApplied} keeps that one on disk). Workflow folders keep
+ * files no lock named, so their function files are pruned by lock instead
* ({@link orphanedWorkflowFiles}); blobs are never reprinted.
*/
function droppedResourceFiles(
@@ -385,8 +386,10 @@ function droppedResourceFiles(
* their digests in `.sim/written.json` (`written` is what it held), beside the digests of the
* blobs the server now holds. The function files a written workflow no longer uses, and the files
* a reprinted resource no longer has, are removed from disk and the record; the record also drops
- * the files of resources the apply deleted ({@link deletedRecordedPaths}). `records` are the
- * stored-edges records of the workflows it reprinted.
+ * the files of resources the apply deleted ({@link deletedRecordedPaths}). A tool's code file the
+ * reprint no longer names is the person's only copy of that code, so like a workflow's function
+ * file it stays on disk, leaves the record, and is named in a warning; no apply sends it again.
+ * `records` are the stored-edges records of the workflows it reprinted.
*/
async function saveApplied(
dir: string,
@@ -396,13 +399,18 @@ async function saveApplied(
records: ReadonlyArray
): Promise {
assertWorkspacePaths(Object.keys(data.files))
- const orphaned = [
- ...(await orphanedWorkflowFiles(dir, data.files, written.digests)),
- ...droppedResourceFiles(submission.files, data.files),
- ]
+ const toolCode: Array<{ path: string; declaration: string }> = []
+ const orphaned = await orphanedWorkflowFiles(dir, data.files, written.digests)
+ for (const path of droppedResourceFiles(submission.files, data.files)) {
+ const tool = toolOfCodeFile(path)
+ if (tool) toolCode.push({ path, declaration: tool.declaration })
+ else orphaned.push(path)
+ }
const kept = { ...written.digests, ...appliedBlobDigests(submission, data.base) }
const deleted = await deletedRecordedPaths(dir, written.digests, submission.kinds, data.base)
- for (const path of [...orphaned, ...deleted]) delete kept[path]
+ for (const path of [...orphaned, ...deleted, ...toolCode.map(({ path }) => path)]) {
+ delete kept[path]
+ }
const record = writtenRecord(
data.files,
kept,
@@ -417,6 +425,11 @@ async function saveApplied(
],
remove: [...orphaned, ...removedWorkflowRecords(deleted)],
})
+ for (const { path, declaration } of toolCode) {
+ printError(
+ `warning: ${path} is no longer named by ${declaration} (its code is now kept as stored() or printed inline), so it was left on disk as written and no apply sends it: delete it, or name it again with codeFile(). Never commit one that holds a credential.`
+ )
+ }
}
/** The workflow a directory's base belongs to (a workflow source directory), or `null`. */
diff --git a/packages/sim-cli/src/commands/protocol/workspace-source-dir.ts b/packages/sim-cli/src/commands/protocol/workspace-source-dir.ts
index 2a9551628ad..2f114af9085 100644
--- a/packages/sim-cli/src/commands/protocol/workspace-source-dir.ts
+++ b/packages/sim-cli/src/commands/protocol/workspace-source-dir.ts
@@ -36,6 +36,7 @@ import {
type TableDecl,
} from '@sim/workspace-code/kinds/table'
import { parseTableRows, tableRowsPath } from '@sim/workspace-code/kinds/table-rows'
+import { toolCodec, toolDeclarationPath } from '@sim/workspace-code/kinds/tools'
import { unchangedFiles, workflowFolder } from '@sim/workspace-code/kinds/workflow'
import {
DECLARATION_EXTENSION,
@@ -556,24 +557,53 @@ export interface WorkspaceSubmission {
/** Files under a kind folder that are not sent: hidden names and unsupported characters. */
ignored: string[]
/**
- * Files under a workflow folder's `functions/` that neither its `workflow.ts` nor its lock names:
- * never sent, as a workflow directory's apply never sends them.
+ * Code files nothing names: under a workflow folder's `functions/`, one neither its `workflow.ts`
+ * nor its lock names, and a tool's code file its declaration does not name. Never sent, as a
+ * workflow directory's apply never sends them.
*/
unnamed: string[]
/** The blobs this read hashed or reused a recorded digest for, with their stats. */
hashed: ReadonlyMap
}
+/** The tool a code file (`tools/.js`) belongs to and its declaration path; `null` for any other path. */
+export function toolOfCodeFile(path: string): { key: string; declaration: string } | null {
+ if (kindOfPath(path) !== 'custom-tool') return null
+ const [key] = toolCodec.group([path]).groups.keys()
+ if (key === undefined) return null
+ const declaration = toolDeclarationPath(key)
+ return path === declaration ? null : { key, declaration }
+}
+
+/**
+ * Whether `path` is a tool's code file that the tool's declaration does not name: the declaration
+ * reads whole without it (its code is `stored()` or inline), so the server would only refuse it as
+ * unused (`E_TOOL_CODE`). One with no declaration is still sent, so the server names what is
+ * missing.
+ */
+function isUnnamedToolCode(files: Readonly>, path: string): boolean {
+ const tool = toolOfCodeFile(path)
+ const text = tool ? files[tool.declaration] : undefined
+ if (!tool || text === undefined) return false
+ return toolCodec.parse(tool.key, { [tool.declaration]: text }, []).decl !== undefined
+}
+
/**
- * Drops from `files` each file under a workflow folder's `functions/` that neither the folder's
- * `workflow.ts` nor its lock names ({@link codeFilePaths}, the rule a workflow directory's apply
- * and status read), returning their paths: an apply never sends one, so a status never counts it
- * as a change and the folder is not sent as edited for it.
+ * Drops from `files` each code file nothing names, returning their paths: a file under a workflow
+ * folder's `functions/` that neither the folder's `workflow.ts` nor its lock names
+ * ({@link codeFilePaths}, the rule a workflow directory's apply and status read), and a tool's code
+ * file its declaration does not name ({@link isUnnamedToolCode}). An apply never sends one, so a
+ * status never counts it as a change and the folder is not sent as edited for it.
*/
function dropUnnamedCodeFiles(files: Record): string[] {
const named = new Map>()
const unnamed: string[] = []
for (const path of Object.keys(files)) {
+ if (isUnnamedToolCode(files, path)) {
+ unnamed.push(path)
+ delete files[path]
+ continue
+ }
if (kindOfPath(path) !== 'workflow') continue
const segments = path.split('/')
if (segments[2] !== SOURCE_CODE_DIR) continue
diff --git a/packages/sim-cli/src/contract/commands.ts b/packages/sim-cli/src/contract/commands.ts
index 7113d0a2b8f..5ab9ccd4322 100644
--- a/packages/sim-cli/src/contract/commands.ts
+++ b/packages/sim-cli/src/contract/commands.ts
@@ -638,6 +638,7 @@ export const CLI_CONTRACT: CliContract = {
getWorkflowOutline: {
command: 'workflows outline',
describe: 'Show a workflow’s draft as a compact read-only outline',
+ dataKeys: true,
},
getWorkflowSource: {
command: 'workflows source get',
diff --git a/packages/sim-cli/src/contract/types.ts b/packages/sim-cli/src/contract/types.ts
index 779e1b1f251..d04c8572557 100644
--- a/packages/sim-cli/src/contract/types.ts
+++ b/packages/sim-cli/src/contract/types.ts
@@ -348,6 +348,11 @@ export interface CommandSpec {
* column. Only meaningful when `columns` is absent.
*/
expand?: string
+ /**
+ * The record's keys are data, not field names, as in `workflows outline`'s blocks keyed by block
+ * id: the display formats print each key as sent rather than humanized, so it can be copied back.
+ */
+ dataKeys?: true
/**
* The response IS a document, not a record to look at.
*
diff --git a/packages/sim-cli/src/http/client.ts b/packages/sim-cli/src/http/client.ts
index 6b0a597bc1e..76633701c6f 100644
--- a/packages/sim-cli/src/http/client.ts
+++ b/packages/sim-cli/src/http/client.ts
@@ -831,14 +831,6 @@ export class SimClient {
return { response, url }
}
- /**
- * Explains a redirect instead of following it, naming the endpoint to switch to.
- *
- * The destination comes from `Location` resolved against the request URL, so a
- * relative target works and no string surgery is done on the configured
- * endpoint. A `Location` that is missing or unparseable still has to produce a
- * sentence — the redirect is the finding either way.
- */
/**
* What to do about a credential the server refused, by where it came from: `sim login` replaces
* a stored login, but a key from `SIM_API_KEY` or `--api-key` overrides any login, so logging in
@@ -853,6 +845,14 @@ export class SimClient {
return `run: ${login}`
}
+ /**
+ * Explains a redirect instead of following it, naming the endpoint to switch to.
+ *
+ * The destination comes from `Location` resolved against the request URL, so a
+ * relative target works and no string surgery is done on the configured
+ * endpoint. A `Location` that is missing or unparseable still has to produce a
+ * sentence — the redirect is the finding either way.
+ */
private toRedirectError(url: string, path: string, response: Response): SimApiError {
const requestId = responseRequestId(response)
const location = response.headers.get('location')?.trim()
diff --git a/packages/sim-cli/src/runtime/result.test.ts b/packages/sim-cli/src/runtime/result.test.ts
index 709cce18f4f..691c6a75277 100644
--- a/packages/sim-cli/src/runtime/result.test.ts
+++ b/packages/sim-cli/src/runtime/result.test.ts
@@ -46,6 +46,18 @@ describe('inferred cells pick a format from the key shape', () => {
})
})
+describe('a record keyed by data rather than by field names', () => {
+ // `workflows outline` answers `{ blocks: { : {...} } }`: once the
+ // single-key wrapper is unwrapped, each label is a block id the reader copies.
+ const blockId = '112f78c0-9170-4843-abb7-d07329fe3cc7'
+ const outline = { blocks: { [blockId]: { type: 'agent', name: 'Agent 1', enabled: true } } }
+
+ it('labels each entry with its key exactly as the API sent it', () => {
+ renderResult('getWorkflowOutline', 'text', outline, CLI_CONTRACT.getWorkflowOutline ?? {})
+ expect(logged[0].split('\t')[0]).toBe(blockId)
+ })
+})
+
describe('cells the user named, not the API', () => {
// `tables rows list` and `tables rows query` expand `data`, whose keys are
// whatever the caller called their columns. A key shape is a promise about
diff --git a/packages/sim-cli/src/runtime/result.ts b/packages/sim-cli/src/runtime/result.ts
index 2c29007ad09..bc05e727868 100644
--- a/packages/sim-cli/src/runtime/result.ts
+++ b/packages/sim-cli/src/runtime/result.ts
@@ -210,6 +210,14 @@ function inferHeader(key: string, format: ColumnSpec['format'] | null): string {
return humanizeKey(trimmed || key)
}
+/** A record's fields, each labelled by its humanized field name, or as sent when its keys are data. */
+function inferredFields(record: object, dataKeys: boolean): Array<[string, string]> {
+ return Object.entries(record).map<[string, string]>(([key, value]) => [
+ dataKeys ? key : inferHeader(key, inferFormat(key, value)),
+ inferredCell(key, value),
+ ])
+}
+
function columnsFrom(specs: ColumnSpec[]): Column[] {
return specs.map((spec) => ({
header: spec.header,
@@ -456,10 +464,7 @@ export function renderResult(
const fields = spec.fields
? fieldsFrom(data, spec.fields, options)
: data && typeof data === 'object'
- ? Object.entries(data).map<[string, string]>(([key, value]) => [
- inferHeader(key, inferFormat(key, value)),
- inferredCell(key, value),
- ])
+ ? inferredFields(data, spec.dataKeys === true)
: []
printRecord(format, fields, data)
diff --git a/packages/workflow-sdk/README.md b/packages/workflow-sdk/README.md
index c2106c43538..b89d18588df 100644
--- a/packages/workflow-sdk/README.md
+++ b/packages/workflow-sdk/README.md
@@ -54,8 +54,9 @@ have the CLI confirm the directory holds that workflow.
`.sim/starter.json`, and creates nothing; the create that follows targets that workspace, and
one into another workspace is refused unless `--workspace` names it.
-`apply` and `create` ask for confirmation on a terminal; elsewhere pass `--yes` (without it they
-refuse with `CONFIRMATION_REQUIRED`). `--dry-run` never asks.
+`apply` and `create` ask for confirmation on a terminal. With no terminal to ask and no `--yes`,
+they print the plan, write nothing and exit `14` (or `1` when the plan has errors): run the same
+command with `--yes` to write it. `--dry-run` never asks.
## Where the types live
@@ -165,8 +166,8 @@ files are stored verbatim. One file per block; imports between function files ar
| Path | Contents |
|------|----------|
-| `src/core.d.ts` | Authoring types. Exports exactly `SDK_CORE_EXPORTS` from `@sim/workflow-code`; after editing run `bun scripts/generate-embedded-text.ts`. |
-| `cookbook/examples/*.ts` | The examples the CLI writes into `.sim/examples/`. After editing run `bun scripts/generate-embedded-text.ts`; `apps/sim/lib/workflows/code/real-catalog.test.ts` type-checks and compiles each against the real catalog (its `COOKBOOK_WORKSPACE` lists the resources they name). |
+| `src/core.d.ts` | Authoring types. Exports exactly `SDK_CORE_EXPORTS` from `@sim/workflow-code`; after editing run `bun run generate:workflow-sdk-embedded-text` from the repository root (`check:workflow-sdk-embedded-text`, part of `bun run check:audits`, fails when it is stale). |
+| `cookbook/examples/*.ts` | The examples the CLI writes into `.sim/examples/`. After editing run `bun run generate:workflow-sdk-embedded-text`; `apps/sim/lib/workflows/code/real-catalog.test.ts` type-checks and compiles each against the real catalog (its `COOKBOOK_WORKSPACE` lists the resources they name). |
| `src/runtime.ts` | The runtime entry: every export throws `SimSdkNotExecutable`. |
| `src/codegen/` | `generateSdkTypes(catalog, { blockTypes })` (catalog → `.d.ts` and the `INDEX.md` builder list, for every block or a directory's subset, deterministic, sorted by path), `describeBuilder`/`lookupBuilder` (one builder's params and outputs, for `sim workflows source params`), `generateWorkspaceTypes(manifest)` (`workspace.d.ts`), and `layout.ts`: which declaration files a directory's tsconfig files include. |
| `test/examples` | Five example workflows, also compiled against the real catalog with zero diagnostics in `apps/sim/lib/workflows/code/sdk-examples.test.ts`. |
diff --git a/packages/workflow-sdk/scripts/generate-embedded-text.ts b/packages/workflow-sdk/scripts/generate-embedded-text.ts
index 37b9a65359c..7df5fb29dba 100644
--- a/packages/workflow-sdk/scripts/generate-embedded-text.ts
+++ b/packages/workflow-sdk/scripts/generate-embedded-text.ts
@@ -4,13 +4,15 @@
* `src/codegen/*.generated.ts`: `src/core.d.ts` as `CORE_DTS` (the authoring declarations),
* `cookbook/examples/*.ts` as `COOKBOOK_EXAMPLES` (the example workflows), the workspace declaration SDK
* `src/workspace/*.d.ts` as `WORKSPACE_SDK_DTS`, and the example workspace directory
- * `cookbook/workspace/**` as `WORKSPACE_COOKBOOK`. `core-text.test.ts`, `cookbook-text.test.ts`
- * and `workspace-text.test.ts` fail when any drifts.
+ * `cookbook/workspace/**` as `WORKSPACE_COOKBOOK`. The output is written as generated (biome
+ * skips these files), so `--check` compares it byte for byte; `core-text.test.ts`,
+ * `cookbook-text.test.ts` and `workspace-text.test.ts` also fail when any drifts.
*
- * bun scripts/generate-embedded-text.ts && bunx biome check --write src/codegen
+ * bun run generate:workflow-sdk-embedded-text
+ * bun run check:workflow-sdk-embedded-text
*/
-import { readFileSync, writeFileSync } from 'node:fs'
+import { existsSync, readFileSync, writeFileSync } from 'node:fs'
import path from 'node:path'
import { type EmbeddedFolder, embeddedFolderTexts } from '../src/codegen/embedded-files'
@@ -63,19 +65,30 @@ function literal(value: unknown): string {
return JSON.stringify(value).replaceAll("'", '\\u0027')
}
+const checkOnly = process.argv.includes('--check')
+const stale: string[] = []
+
for (const { source, target, name, doc, files } of EMBEDDED) {
const absolute = path.join(packageRoot, source)
const declaration = files
? `export const ${name}: Readonly> = ${literal(embeddedFolderTexts(absolute, files))}`
: `export const ${name} = ${literal(readFileSync(absolute, 'utf8'))}`
- writeFileSync(
- path.join(packageRoot, target),
- [
- `// Generated by scripts/generate-embedded-text.ts from ${source}; do not edit.`,
- '',
- `/** ${doc} */`,
- declaration,
- '',
- ].join('\n')
+ const text = [
+ `// Generated by scripts/generate-embedded-text.ts from ${source}; do not edit.`,
+ '',
+ `/** ${doc} */`,
+ declaration,
+ '',
+ ].join('\n')
+ const output = path.join(packageRoot, target)
+ if (!checkOnly) writeFileSync(output, text)
+ else if (!existsSync(output) || readFileSync(output, 'utf8') !== text) stale.push(target)
+}
+
+if (stale.length > 0) {
+ console.error(
+ `✗ stale in packages/workflow-sdk: ${stale.join(', ')}. Run \`bun run generate:workflow-sdk-embedded-text\` and commit the result.`
)
+ process.exit(1)
}
+if (checkOnly) console.log('✓ the workflow SDK embedded text is current')
diff --git a/packages/workflow-sdk/src/codegen/workspace-text.generated.ts b/packages/workflow-sdk/src/codegen/workspace-text.generated.ts
index c57d5d713a3..be5e5add44e 100644
--- a/packages/workflow-sdk/src/codegen/workspace-text.generated.ts
+++ b/packages/workflow-sdk/src/codegen/workspace-text.generated.ts
@@ -1,25 +1,4 @@
// Generated by scripts/generate-embedded-text.ts from src/workspace; do not edit.
/** The workspace declaration SDK, file name → text (`index.d.ts` re-exports the rest). */
-export const WORKSPACE_SDK_DTS: Readonly> = {
- 'credentials.d.ts':
- '/**\n * Credential declarations: `credentials.ts` at the root of a workspace source directory names the\n * saved credentials its workflows use, each by the provider it is for. Never a token: connect one\n * with `sim credentials connect --name ""`.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineCredentials } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineCredentials({\n * slack: { provider: \u0027slack\u0027 },\n * gmail: { provider: \u0027google-email\u0027, name: \u0027Support inbox\u0027 },\n * })\n * ```\n *\n * A workflow uses one as `credential(\u0027slack\u0027)`, which type-checks against these keys. An apply\n * binds each key to a credential of this workspace: the one bound to it already; else the only\n * credential of the provider no other declared key holds, narrowed to the display name `name`\n * when given. A key nothing binds to, or several credentials could bind to, is reported, and a\n * workflow using it is held back while the rest of the apply goes ahead. Applying the same\n * directory to another workspace binds each key to that workspace\u0027s own credential. Removing a key\n * unbinds it only with `--allow-delete`; the credential itself is never deleted.\n */\n\n/** One declared credential. */\nexport interface CredentialDeclaration {\n /** The provider the credential is for (`slack`, `google-email`, …). */\n provider: string\n /** The display name that picks one of several credentials of the provider. */\n name?: string\n}\n\n/** Declares the workspace\u0027s credentials by key. Its default export is the whole file. */\nexport declare function defineCredentials>(\n credentials: T\n): T\n\n/**\n * The credential keys a `credentials.ts` declaration adds, each with its provider, as\n * `workspace.d.ts` merges them into `credential(\u0027…\u0027)`.\n */\nexport type DeclaredCredentials = {\n [K in keyof T]: T[K] extends { provider: infer P } ? { provider: P } : never\n}\n',
- 'deployment.d.ts':
- '/**\n * Deployment declarations: `deployments/.ts` in a workspace source directory deploys\n * `workflows//`, so its schedule, webhook, API and chat triggers run.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineDeployment, env } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineDeployment({\n * live: \u0027draft\u0027,\n * chat: {\n * identifier: \u0027support\u0027,\n * title: \u0027Support\u0027,\n * auth: { password: env.SUPPORT_CHAT_PASSWORD },\n * outputs: [{ block: \u0027Answer\u0027, path: \u0027content\u0027 }],\n * },\n * })\n * ```\n *\n * An apply deploys after it writes the workflows. Removing the file undeploys the workflow, which\n * stops its schedules, webhooks, API and chat, and needs `--allow-delete`. Deploying needs a\n * workspace admin and is refused to a workspace API key. Publishing to an MCP server is not part\n * of source.\n */\nimport type { EnvRef } from \u0027@sim/workflow-sdk\u0027\n\nexport { env, stored } from \u0027@sim/workflow-sdk\u0027\n\n/** Who may open a chat. */\nexport type ChatAuth =\n | \u0027public\u0027\n /**\n * A password from an environment variable, by name, never the value itself; or `stored()`, the\n * password the chat already stores (valid only for a chat that has one).\n */\n | { password: EnvRef }\n /** These emails (or `@domain.com` patterns), signing in with a code. */\n | { emails: string[] }\n /** These emails (or `@domain.com` patterns), signing in through the workspace\u0027s SSO. */\n | { sso: string[] }\n\n/** One output a chat answers with. */\nexport interface ChatOutput {\n /** The block\u0027s name, as the workflow names it. */\n block: string\n /** The output path on that block (`content`, `result.text`). */\n path: string\n}\n\n/** The chat a deployment serves. */\nexport interface ChatDeployment {\n /** The chat\u0027s URL path segment, unique across the platform. */\n identifier: string\n title: string\n description?: string\n auth: ChatAuth\n outputs?: ChatOutput[]\n /** The chat\u0027s look; an omitted field takes the platform default. */\n customizations?: { primaryColor?: string; welcomeMessage?: string; imageUrl?: string }\n /** Show the model\u0027s thinking to clients that ask for it. */\n includeThinking?: boolean\n /** Show tool calls to clients that ask for them. */\n includeToolCalls?: boolean\n}\n\n/** A deployment declaration. */\nexport interface DeploymentDeclaration {\n /**\n * `\u0027draft\u0027`: an apply deploys the draft whenever it differs from the live version (after this\n * apply\u0027s workflow edits), as long as it holds only what the workflow folder declares: a draft\n * edited outside source is not deployed, and the apply warns. `\u0027pinned\u0027`: an apply never\n * redeploys, and says when the draft differs.\n */\n live: \u0027draft\u0027 | \u0027pinned\u0027\n /** Public: anyone may run the workflow\u0027s API without a key. Private when omitted. */\n api?: { public?: boolean }\n /** The chat the deployment serves; none when omitted. */\n chat?: ChatDeployment\n}\n\n/** Declares a workflow\u0027s deployment. Its default export is the whole file. */\nexport declare function defineDeployment(deployment: DeploymentDeclaration): DeploymentDeclaration\n',
- 'file.d.ts':
- '/**\n * Workspace files need no declaration: every file under `files/` is one workspace file, at the\n * folder path and name it has there (`files/reports/q1.pdf` is `q1.pdf` in the `reports`\n * folder), synced by content hash. Each apply that changes a file\u0027s bytes records a new version\n * of it, so an earlier one can be restored in the Files tab. Files over 10 MB, or whose name no\n * directory can hold (a reserved character, or a path that differs only in letter case from\n * another file or folder), are left out of a get (listed in `.sim/skipped.json`) and never written\n * by an apply; a file the directory no longer holds is deleted only with `--allow-delete`.\n */\nexport {}\n',
- 'index.d.ts':
- '/**\n * The workspace declaration SDK: `import { … } from \u0027@sim/workflow-sdk/workspace\u0027` in the\n * declaration files of a workspace source directory (`tables/.ts`, …). Like the workflow\n * SDK, nothing here runs: the server reads each file statically.\n */\nexport * from \u0027./credentials\u0027\nexport * from \u0027./deployment\u0027\nexport * from \u0027./file\u0027\nexport * from \u0027./knowledge\u0027\nexport * from \u0027./mcp\u0027\nexport * from \u0027./secrets\u0027\nexport * from \u0027./skill\u0027\nexport * from \u0027./table\u0027\nexport * from \u0027./tool\u0027\n',
- 'knowledge.d.ts':
- '/**\n * Knowledge base declarations: `knowledge//knowledge.ts` in a workspace source directory,\n * beside `knowledge//docs/`, which holds one file per document.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineKnowledgeBase } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineKnowledgeBase({\n * name: \u0027Policies\u0027,\n * description: \u0027Refund and shipping policies\u0027,\n * chunking: { maxSize: 1024, minSize: 100, overlap: 200 },\n * })\n * ```\n *\n * Documents sync by content: adding a file to `docs/` uploads it, editing one replaces the stored\n * document (a new upload that takes the old one\u0027s tag values), and removing one deletes it only with\n * `--allow-delete`. Every uploaded or replaced document is indexed after the apply. Documents a\n * connector syncs are never part of source.\n */\n\n/** How documents are split into chunks before they are embedded. */\nexport interface KnowledgeChunking {\n /** Largest chunk, in tokens (100–4000; 1024 when omitted). */\n maxSize?: number\n /** Smallest chunk, in characters (1–2000; 100 when omitted). */\n minSize?: number\n /** Tokens neighbouring chunks share (0–500; 200 when omitted). */\n overlap?: number\n strategy?: \u0027auto\u0027 | \u0027text\u0027 | \u0027regex\u0027 | \u0027recursive\u0027 | \u0027sentence\u0027 | \u0027token\u0027\n strategyOptions?: {\n /** The split pattern of the `regex` strategy. */\n pattern?: string\n separators?: string[]\n recipe?: \u0027plain\u0027 | \u0027markdown\u0027 | \u0027code\u0027\n /** `regex` only: every match is its own chunk. */\n strictBoundaries?: boolean\n }\n}\n\n/** A knowledge base declaration. */\nexport interface KnowledgeBaseDeclaration {\n name: string\n description?: string\n /** The knowledge base folder path (`/support`); the workspace root when omitted. */\n folder?: string\n /**\n * Applies to documents indexed from now on; stored chunks keep the settings they were made\n * with.\n */\n chunking?: KnowledgeChunking\n /** The embedding model, fixed when the knowledge base is created. */\n embeddingModel?: string\n}\n\n/** Declares a knowledge base. Its default export is the whole file. */\nexport declare function defineKnowledgeBase(\n knowledgeBase: KnowledgeBaseDeclaration\n): KnowledgeBaseDeclaration\n',
- 'mcp.d.ts':
- '/**\n * MCP server declarations: `mcp/.ts` declares one server the workspace\u0027s agents call tools\n * on.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineMcpServer, env } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineMcpServer({\n * name: \u0027GitHub\u0027,\n * url: \u0027https://api.githubcopilot.com/mcp/\u0027,\n * headers: { Authorization: \u0027Bearer {{GITHUB_TOKEN}}\u0027, \u0027X-Team\u0027: env.GITHUB_TEAM },\n * })\n * ```\n *\n * A workflow names the server by its key and one of its tools by name:\n * `mcp(\u0027github\u0027).tool(\u0027create_issue\u0027)`. Secrets never sit in source: a credential header\n * (`Authorization`, `Cookie`, or a name with `key`, `token`, `secret`, `auth`, …) holds env\n * references (`env.NAME`, or `{{NAME}}` in its text after a scheme such as `Bearer`) or\n * `stored()`, which keeps the value the server holds. The server\u0027s id derives from its URL, so a\n * `url` with another host or path replaces the server; a new query string updates it in place.\n */\nimport type { EnvRef } from \u0027@sim/workflow-sdk\u0027\n\nexport { env, stored } from \u0027@sim/workflow-sdk\u0027\n\n/** A header value: text (`{{NAME}}` names an env variable), `env.NAME`, or `stored()`. */\nexport type McpHeaderValue = string | EnvRef\n\n/** How the server authenticates. */\nexport interface McpServerAuth {\n /** `headers` (the default) sends the declared headers; `oauth` signs in with an OAuth grant. */\n type: \u0027none\u0027 | \u0027headers\u0027 | \u0027oauth\u0027\n /** A pre-registered OAuth client, for a server without dynamic client registration. */\n clientId?: string\n}\n\n/** An MCP server declaration. */\nexport interface McpServerDeclaration {\n /** The display name; the key when left out. */\n name?: string\n description?: string\n /** An `http://` or `https://` URL. A new host or path replaces the server; a new query does not. */\n url: string\n transport?: \u0027streamable-http\u0027\n headers?: { [name: string]: McpHeaderValue }\n /** `{ type: \u0027headers\u0027 }` when left out. The OAuth client secret is set in the server settings. */\n auth?: McpServerAuth\n /** Milliseconds a request waits; 30000 when left out. */\n timeout?: number\n /** 3 when left out. */\n retries?: number\n /** `true` when left out. */\n enabled?: boolean\n}\n\n/** Declares an MCP server. Its default export is the whole file. */\nexport declare function defineMcpServer(server: McpServerDeclaration): McpServerDeclaration\n',
- 'secrets.d.ts':
- '/**\n * Secret declarations: `secrets.ts` at the root of a workspace source directory names the\n * workspace secrets its workflows read, by name and what each is for. Never a value: set one with\n * `sim secrets set --scope workspace`, or in the workspace\u0027s secrets settings.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineSecrets } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineSecrets({\n * ANTHROPIC_API_KEY: { description: \u0027Model access for the support agent\u0027 },\n * STRIPE_KEY: {},\n * })\n * ```\n *\n * A workflow reads one as `env.NAME`, which type-checks against these names. An apply sets only\n * descriptions: a name the workspace holds no value for is reported, and a workflow using it is\n * held back (not written) while the rest of the apply goes ahead. Removing a name changes nothing\n * on the server.\n */\n\n/** One declared secret. */\nexport interface SecretDeclaration {\n /** What the secret is for, shown to teammates (at most 500 characters). */\n description?: string\n}\n\n/** Declares the workspace\u0027s secrets by name. Its default export is the whole file. */\nexport declare function defineSecrets>(\n secrets: T\n): T\n\n/** The env names a `secrets.ts` declaration adds, as `workspace.d.ts` merges them into `env`. */\nexport type DeclaredSecretNames = { [K in keyof T]: true }\n',
- 'skill.d.ts':
- '/**\n * Skills are markdown, not TypeScript: `skills/.md` is a frontmatter block of `name` and\n * `description`, then the skill\u0027s content.\n *\n * ```md\n * ---\n * name: tone\n * description: "Answer in the support team\u0027s voice: short, warm, specific."\n * ---\n * Write like a person, not a policy.\n * ```\n *\n * A value is plain text on one line, or a JSON string (`"…"`) when it holds a line break,\n * surrounding spaces, quotes, `: ` or ` #`, ends in `:`, or starts with anything but a letter,\n * digit or `(`. Quote a value YAML would read as a boolean, number or date (`"yes"`, `"1e3"`) too,\n * so other markdown tools read it as text. The name is kebab-case; a workflow names the skill by\n * its key, `skill(\u0027tone\u0027)`. This module declares nothing.\n */\nexport {}\n',
- 'table.d.ts':
- '/**\n * Table declarations: `tables/.ts` in a workspace source directory.\n *\n * ```ts\n * // @sim-sdk 1\n * import { column, defineTable } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineTable({\n * name: \u0027leads\u0027,\n * columns: {\n * email: column.string({ required: true, unique: true }),\n * status: column.select({ options: [\u0027new\u0027, \u0027won\u0027, \u0027lost\u0027] }),\n * score: column.number(),\n * },\n * })\n * ```\n *\n * A column\u0027s object key is its source key and stays bound to the stored column; `name` renames\n * the stored column while keeping its cells.\n *\n * Rows are part of source only when `rows` opts in: `tables/.rows.jsonl` beside the\n * declaration holds one JSON object per line, keyed by column key (a select cell by option name).\n * `{ mode: \u0027seed\u0027 }` writes them into the table when an apply creates it (or adopts it empty);\n * `{ mode: \u0027managed\u0027, key }` keeps the table\u0027s rows equal to the file, each matched by the unique\n * `key` column (removing a row needs `--allow-delete`); a stored row whose `key` cell is empty is\n * left out of the file and kept as it is.\n */\nimport type { Json } from \u0027@sim/workflow-sdk\u0027\n\ndeclare const COLUMN: unique symbol\n\n/**\n * A declared column: the cell type `T` it holds, the name `N` it is stored under, and whether\n * every row must hold a value (`R`); a cell of a column that is not required may be empty (`null`).\n */\nexport interface Column {\n readonly [COLUMN]: { value: T; name: N; required: R }\n}\n\n/** Options every column type takes. */\nexport interface ColumnOptions<\n N extends string | undefined = string | undefined,\n R extends boolean = boolean,\n> {\n /** The stored column name, when it differs from the column\u0027s key. */\n name?: N\n /** Every row must hold a value. */\n required?: R\n /** No two rows may hold the same value. */\n unique?: boolean\n}\n\n/** The shared options a `select` column takes: never `unique`. */\ntype SelectOptions = Omit<\n ColumnOptions,\n \u0027unique\u0027\n>\n\n/** The column helpers: `column.string()`, `column.select({ options: [...] })`, … */\nexport declare const column: {\n string(\n options?: ColumnOptions\n ): Column\n number(\n options?: ColumnOptions\n ): Column\n /** A number shown as money; `currencyCode` is an ISO 4217 code (`USD` when omitted). */\n currency(\n options?: ColumnOptions & { currencyCode?: string }\n ): Column\n boolean(\n options?: ColumnOptions\n ): Column\n /** An ISO 8601 date or date-time string. */\n date(\n options?: ColumnOptions\n ): Column\n /** A time to live: a date-time after which the row expires. A table holds at most one. */\n ttl(\n options?: ColumnOptions\n ): Column\n json(\n options?: ColumnOptions\n ): Column\n /** One option per cell, from `options`. */\n select<\n const O extends readonly [string, ...string[]],\n const N extends string | undefined = undefined,\n const R extends boolean = false,\n >(options: SelectOptions & { options: O; multiple?: false }): Column\n /** Several options per cell. */\n select<\n const O extends readonly [string, ...string[]],\n const N extends string | undefined = undefined,\n const R extends boolean = false,\n >(options: SelectOptions & { options: O; multiple: true }): Column\n}\n\n/** Any column, whatever it holds. */\ntype AnyColumn = Column\n\n/** A table declaration. */\nexport interface TableDeclaration = Record> {\n /** The table name: a letter or `_`, then letters, digits and `_`. */\n name: string\n description?: string\n /** The table folder path (`/reports`); the workspace root when omitted. */\n folder?: string\n columns: C\n /** Rows as source, from `tables/.rows.jsonl`; omitted leaves rows out of source. */\n rows?: TableRows\n}\n\n/**\n * How a table\u0027s rows are source: `seed` rows go into the table once, when an apply creates it;\n * `managed` rows are the whole table, matched to stored rows by the unique `key` column.\n */\nexport type TableRows = { mode: \u0027seed\u0027 } | { mode: \u0027managed\u0027; key: K }\n\n/** Declares a table. Its default export is the whole file. */\nexport declare function defineTable>(\n table: TableDeclaration\n): TableDeclaration\n\n/** The stored name of column `K`: its `name` option, else its key. */\ntype StoredName = C extends Column\n ? [N] extends [string]\n ? N\n : K\n : K\n\n/** A cell of column `C`: its value, or `null` when the column is not required. */\ntype CellOf = C extends Column\n ? R extends true\n ? V\n : V | null\n : never\n\n/**\n * A declared table\u0027s row, keyed by stored column name: `RowOf`. A cell of a column\n * that is not required may be `null`.\n */\nexport type RowOf = T extends TableDeclaration\n ? { [K in keyof C as StoredName]: CellOf }\n : never\n',
- 'tool.d.ts':
- '/**\n * Custom tool declarations: `tools/.ts`, with the tool\u0027s code beside it in `tools/.js`.\n *\n * ```ts\n * // @sim-sdk 1\n * import { codeFile, defineTool } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineTool({\n * title: \u0027Lookup order\u0027,\n * schema: {\n * type: \u0027function\u0027,\n * function: {\n * name: \u0027lookup_order\u0027,\n * description: \u0027Find an order by id.\u0027,\n * parameters: {\n * type: \u0027object\u0027,\n * properties: { orderId: { type: \u0027string\u0027 } },\n * required: [\u0027orderId\u0027],\n * },\n * },\n * },\n * code: codeFile(\u0027./lookup-order.js\u0027),\n * })\n * ```\n *\n * The code file runs with each parameter as a variable; `$env.NAME` reads an environment variable\n * by name. The key is the tool\u0027s identity: a workflow names it as `customTool(\u0027lookup-order\u0027)`.\n * Code holding a literal credential prints as `code: stored()`, which keeps the code the server\n * holds without showing it.\n */\nimport type { CodeFileRef, Json } from \u0027@sim/workflow-sdk\u0027\n\nexport { codeFile, stored } from \u0027@sim/workflow-sdk\u0027\n\n/** JSON as an object literal writes it: an optional member may be absent. */\ntype SchemaJson = Json | readonly SchemaJson[] | { readonly [key: string]: SchemaJson | undefined }\n\n/** The function declaration a model calls the tool by, stored verbatim. */\nexport interface ToolSchema {\n type: \u0027function\u0027\n function: {\n /** What the model calls: letters, digits, `_` and `-`, at most 64 characters. */\n name: string\n description?: string\n /** A JSON Schema object describing the arguments. */\n parameters: {\n type: \u0027object\u0027\n properties: { [name: string]: Json }\n required?: string[]\n readonly [extra: string]: SchemaJson | undefined\n }\n readonly [extra: string]: SchemaJson | undefined\n }\n readonly [extra: string]: SchemaJson | undefined\n}\n\n/** A custom tool declaration. */\nexport interface ToolDeclaration {\n /** The tool\u0027s display title, unique in the workspace. */\n title: string\n schema: ToolSchema\n /** `codeFile(\u0027./.js\u0027)`, the code inline as a string, or `stored()` to keep the stored code. */\n code: CodeFileRef | string\n}\n\n/** Declares a custom tool. Its default export is the whole file. */\nexport declare function defineTool(tool: ToolDeclaration): ToolDeclaration\n',
-}
+export const WORKSPACE_SDK_DTS: Readonly> = {"credentials.d.ts":"/**\n * Credential declarations: `credentials.ts` at the root of a workspace source directory names the\n * saved credentials its workflows use, each by the provider it is for. Never a token: connect one\n * with `sim credentials connect --name \"\"`.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineCredentials } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineCredentials({\n * slack: { provider: \u0027slack\u0027 },\n * gmail: { provider: \u0027google-email\u0027, name: \u0027Support inbox\u0027 },\n * })\n * ```\n *\n * A workflow uses one as `credential(\u0027slack\u0027)`, which type-checks against these keys. An apply\n * binds each key to a credential of this workspace: the one bound to it already; else the only\n * credential of the provider no other declared key holds, narrowed to the display name `name`\n * when given. A key nothing binds to, or several credentials could bind to, is reported, and a\n * workflow using it is held back while the rest of the apply goes ahead. Applying the same\n * directory to another workspace binds each key to that workspace\u0027s own credential. Removing a key\n * unbinds it only with `--allow-delete`; the credential itself is never deleted.\n */\n\n/** One declared credential. */\nexport interface CredentialDeclaration {\n /** The provider the credential is for (`slack`, `google-email`, …). */\n provider: string\n /** The display name that picks one of several credentials of the provider. */\n name?: string\n}\n\n/** Declares the workspace\u0027s credentials by key. Its default export is the whole file. */\nexport declare function defineCredentials>(\n credentials: T\n): T\n\n/**\n * The credential keys a `credentials.ts` declaration adds, each with its provider, as\n * `workspace.d.ts` merges them into `credential(\u0027…\u0027)`.\n */\nexport type DeclaredCredentials = {\n [K in keyof T]: T[K] extends { provider: infer P } ? { provider: P } : never\n}\n","deployment.d.ts":"/**\n * Deployment declarations: `deployments/.ts` in a workspace source directory deploys\n * `workflows//`, so its schedule, webhook, API and chat triggers run.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineDeployment, env } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineDeployment({\n * live: \u0027draft\u0027,\n * chat: {\n * identifier: \u0027support\u0027,\n * title: \u0027Support\u0027,\n * auth: { password: env.SUPPORT_CHAT_PASSWORD },\n * outputs: [{ block: \u0027Answer\u0027, path: \u0027content\u0027 }],\n * },\n * })\n * ```\n *\n * An apply deploys after it writes the workflows. Removing the file undeploys the workflow, which\n * stops its schedules, webhooks, API and chat, and needs `--allow-delete`. Deploying needs a\n * workspace admin and is refused to a workspace API key. Publishing to an MCP server is not part\n * of source.\n */\nimport type { EnvRef } from \u0027@sim/workflow-sdk\u0027\n\nexport { env, stored } from \u0027@sim/workflow-sdk\u0027\n\n/** Who may open a chat. */\nexport type ChatAuth =\n | \u0027public\u0027\n /**\n * A password from an environment variable, by name, never the value itself; or `stored()`, the\n * password the chat already stores (valid only for a chat that has one).\n */\n | { password: EnvRef }\n /** These emails (or `@domain.com` patterns), signing in with a code. */\n | { emails: string[] }\n /** These emails (or `@domain.com` patterns), signing in through the workspace\u0027s SSO. */\n | { sso: string[] }\n\n/** One output a chat answers with. */\nexport interface ChatOutput {\n /** The block\u0027s name, as the workflow names it. */\n block: string\n /** The output path on that block (`content`, `result.text`). */\n path: string\n}\n\n/** The chat a deployment serves. */\nexport interface ChatDeployment {\n /** The chat\u0027s URL path segment, unique across the platform. */\n identifier: string\n title: string\n description?: string\n auth: ChatAuth\n outputs?: ChatOutput[]\n /** The chat\u0027s look; an omitted field takes the platform default. */\n customizations?: { primaryColor?: string; welcomeMessage?: string; imageUrl?: string }\n /** Show the model\u0027s thinking to clients that ask for it. */\n includeThinking?: boolean\n /** Show tool calls to clients that ask for them. */\n includeToolCalls?: boolean\n}\n\n/** A deployment declaration. */\nexport interface DeploymentDeclaration {\n /**\n * `\u0027draft\u0027`: an apply deploys the draft whenever it differs from the live version (after this\n * apply\u0027s workflow edits), as long as it holds only what the workflow folder declares: a draft\n * edited outside source is not deployed, and the apply warns. `\u0027pinned\u0027`: an apply never\n * redeploys, and says when the draft differs.\n */\n live: \u0027draft\u0027 | \u0027pinned\u0027\n /** Public: anyone may run the workflow\u0027s API without a key. Private when omitted. */\n api?: { public?: boolean }\n /** The chat the deployment serves; none when omitted. */\n chat?: ChatDeployment\n}\n\n/** Declares a workflow\u0027s deployment. Its default export is the whole file. */\nexport declare function defineDeployment(deployment: DeploymentDeclaration): DeploymentDeclaration\n","file.d.ts":"/**\n * Workspace files need no declaration: every file under `files/` is one workspace file, at the\n * folder path and name it has there (`files/reports/q1.pdf` is `q1.pdf` in the `reports`\n * folder), synced by content hash. Each apply that changes a file\u0027s bytes records a new version\n * of it, so an earlier one can be restored in the Files tab. Files over 10 MB, or whose name no\n * directory can hold (a reserved character, or a path that differs only in letter case from\n * another file or folder), are left out of a get (listed in `.sim/skipped.json`) and never written\n * by an apply; a file the directory no longer holds is deleted only with `--allow-delete`.\n */\nexport {}\n","index.d.ts":"/**\n * The workspace declaration SDK: `import { … } from \u0027@sim/workflow-sdk/workspace\u0027` in the\n * declaration files of a workspace source directory (`tables/.ts`, …). Like the workflow\n * SDK, nothing here runs: the server reads each file statically.\n */\nexport * from \u0027./credentials\u0027\nexport * from \u0027./deployment\u0027\nexport * from \u0027./file\u0027\nexport * from \u0027./knowledge\u0027\nexport * from \u0027./mcp\u0027\nexport * from \u0027./secrets\u0027\nexport * from \u0027./skill\u0027\nexport * from \u0027./table\u0027\nexport * from \u0027./tool\u0027\n","knowledge.d.ts":"/**\n * Knowledge base declarations: `knowledge//knowledge.ts` in a workspace source directory,\n * beside `knowledge//docs/`, which holds one file per document.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineKnowledgeBase } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineKnowledgeBase({\n * name: \u0027Policies\u0027,\n * description: \u0027Refund and shipping policies\u0027,\n * chunking: { maxSize: 1024, minSize: 100, overlap: 200 },\n * })\n * ```\n *\n * Documents sync by content: adding a file to `docs/` uploads it, editing one replaces the stored\n * document (a new upload that takes the old one\u0027s tag values), and removing one deletes it only with\n * `--allow-delete`. Every uploaded or replaced document is indexed after the apply. Documents a\n * connector syncs are never part of source.\n */\n\n/** How documents are split into chunks before they are embedded. */\nexport interface KnowledgeChunking {\n /** Largest chunk, in tokens (100–4000; 1024 when omitted). */\n maxSize?: number\n /** Smallest chunk, in characters (1–2000; 100 when omitted). */\n minSize?: number\n /** Tokens neighbouring chunks share (0–500; 200 when omitted). */\n overlap?: number\n strategy?: \u0027auto\u0027 | \u0027text\u0027 | \u0027regex\u0027 | \u0027recursive\u0027 | \u0027sentence\u0027 | \u0027token\u0027\n strategyOptions?: {\n /** The split pattern of the `regex` strategy. */\n pattern?: string\n separators?: string[]\n recipe?: \u0027plain\u0027 | \u0027markdown\u0027 | \u0027code\u0027\n /** `regex` only: every match is its own chunk. */\n strictBoundaries?: boolean\n }\n}\n\n/** A knowledge base declaration. */\nexport interface KnowledgeBaseDeclaration {\n name: string\n description?: string\n /** The knowledge base folder path (`/support`); the workspace root when omitted. */\n folder?: string\n /**\n * Applies to documents indexed from now on; stored chunks keep the settings they were made\n * with.\n */\n chunking?: KnowledgeChunking\n /** The embedding model, fixed when the knowledge base is created. */\n embeddingModel?: string\n}\n\n/** Declares a knowledge base. Its default export is the whole file. */\nexport declare function defineKnowledgeBase(\n knowledgeBase: KnowledgeBaseDeclaration\n): KnowledgeBaseDeclaration\n","mcp.d.ts":"/**\n * MCP server declarations: `mcp/.ts` declares one server the workspace\u0027s agents call tools\n * on.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineMcpServer, env } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineMcpServer({\n * name: \u0027GitHub\u0027,\n * url: \u0027https://api.githubcopilot.com/mcp/\u0027,\n * headers: { Authorization: \u0027Bearer {{GITHUB_TOKEN}}\u0027, \u0027X-Team\u0027: env.GITHUB_TEAM },\n * })\n * ```\n *\n * A workflow names the server by its key and one of its tools by name:\n * `mcp(\u0027github\u0027).tool(\u0027create_issue\u0027)`. Secrets never sit in source: a credential header\n * (`Authorization`, `Cookie`, or a name with `key`, `token`, `secret`, `auth`, …) holds env\n * references (`env.NAME`, or `{{NAME}}` in its text after a scheme such as `Bearer`) or\n * `stored()`, which keeps the value the server holds. The server\u0027s id derives from its URL, so a\n * `url` with another host or path replaces the server; a new query string updates it in place.\n */\nimport type { EnvRef } from \u0027@sim/workflow-sdk\u0027\n\nexport { env, stored } from \u0027@sim/workflow-sdk\u0027\n\n/** A header value: text (`{{NAME}}` names an env variable), `env.NAME`, or `stored()`. */\nexport type McpHeaderValue = string | EnvRef\n\n/** How the server authenticates. */\nexport interface McpServerAuth {\n /** `headers` (the default) sends the declared headers; `oauth` signs in with an OAuth grant. */\n type: \u0027none\u0027 | \u0027headers\u0027 | \u0027oauth\u0027\n /** A pre-registered OAuth client, for a server without dynamic client registration. */\n clientId?: string\n}\n\n/** An MCP server declaration. */\nexport interface McpServerDeclaration {\n /** The display name; the key when left out. */\n name?: string\n description?: string\n /** An `http://` or `https://` URL. A new host or path replaces the server; a new query does not. */\n url: string\n transport?: \u0027streamable-http\u0027\n headers?: { [name: string]: McpHeaderValue }\n /** `{ type: \u0027headers\u0027 }` when left out. The OAuth client secret is set in the server settings. */\n auth?: McpServerAuth\n /** Milliseconds a request waits; 30000 when left out. */\n timeout?: number\n /** 3 when left out. */\n retries?: number\n /** `true` when left out. */\n enabled?: boolean\n}\n\n/** Declares an MCP server. Its default export is the whole file. */\nexport declare function defineMcpServer(server: McpServerDeclaration): McpServerDeclaration\n","secrets.d.ts":"/**\n * Secret declarations: `secrets.ts` at the root of a workspace source directory names the\n * workspace secrets its workflows read, by name and what each is for. Never a value: set one with\n * `sim secrets set --scope workspace`, or in the workspace\u0027s secrets settings.\n *\n * ```ts\n * // @sim-sdk 1\n * import { defineSecrets } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineSecrets({\n * ANTHROPIC_API_KEY: { description: \u0027Model access for the support agent\u0027 },\n * STRIPE_KEY: {},\n * })\n * ```\n *\n * A workflow reads one as `env.NAME`, which type-checks against these names. An apply sets only\n * descriptions: a name the workspace holds no value for is reported, and a workflow using it is\n * held back (not written) while the rest of the apply goes ahead. Removing a name changes nothing\n * on the server.\n */\n\n/** One declared secret. */\nexport interface SecretDeclaration {\n /** What the secret is for, shown to teammates (at most 500 characters). */\n description?: string\n}\n\n/** Declares the workspace\u0027s secrets by name. Its default export is the whole file. */\nexport declare function defineSecrets>(\n secrets: T\n): T\n\n/** The env names a `secrets.ts` declaration adds, as `workspace.d.ts` merges them into `env`. */\nexport type DeclaredSecretNames = { [K in keyof T]: true }\n","skill.d.ts":"/**\n * Skills are markdown, not TypeScript: `skills/.md` is a frontmatter block of `name` and\n * `description`, then the skill\u0027s content.\n *\n * ```md\n * ---\n * name: tone\n * description: \"Answer in the support team\u0027s voice: short, warm, specific.\"\n * ---\n * Write like a person, not a policy.\n * ```\n *\n * A value is plain text on one line, or a JSON string (`\"…\"`) when it holds a line break,\n * surrounding spaces, quotes, `: ` or ` #`, ends in `:`, or starts with anything but a letter,\n * digit or `(`. Quote a value YAML would read as a boolean, number or date (`\"yes\"`, `\"1e3\"`) too,\n * so other markdown tools read it as text. The name is kebab-case; a workflow names the skill by\n * its key, `skill(\u0027tone\u0027)`. This module declares nothing.\n */\nexport {}\n","table.d.ts":"/**\n * Table declarations: `tables/.ts` in a workspace source directory.\n *\n * ```ts\n * // @sim-sdk 1\n * import { column, defineTable } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineTable({\n * name: \u0027leads\u0027,\n * columns: {\n * email: column.string({ required: true, unique: true }),\n * status: column.select({ options: [\u0027new\u0027, \u0027won\u0027, \u0027lost\u0027] }),\n * score: column.number(),\n * },\n * })\n * ```\n *\n * A column\u0027s object key is its source key and stays bound to the stored column; `name` renames\n * the stored column while keeping its cells.\n *\n * Rows are part of source only when `rows` opts in: `tables/.rows.jsonl` beside the\n * declaration holds one JSON object per line, keyed by column key (a select cell by option name).\n * `{ mode: \u0027seed\u0027 }` writes them into the table when an apply creates it (or adopts it empty);\n * `{ mode: \u0027managed\u0027, key }` keeps the table\u0027s rows equal to the file, each matched by the unique\n * `key` column (removing a row needs `--allow-delete`); a stored row whose `key` cell is empty is\n * left out of the file and kept as it is.\n */\nimport type { Json } from \u0027@sim/workflow-sdk\u0027\n\ndeclare const COLUMN: unique symbol\n\n/**\n * A declared column: the cell type `T` it holds, the name `N` it is stored under, and whether\n * every row must hold a value (`R`); a cell of a column that is not required may be empty (`null`).\n */\nexport interface Column {\n readonly [COLUMN]: { value: T; name: N; required: R }\n}\n\n/** Options every column type takes. */\nexport interface ColumnOptions<\n N extends string | undefined = string | undefined,\n R extends boolean = boolean,\n> {\n /** The stored column name, when it differs from the column\u0027s key. */\n name?: N\n /** Every row must hold a value. */\n required?: R\n /** No two rows may hold the same value. */\n unique?: boolean\n}\n\n/** The shared options a `select` column takes: never `unique`. */\ntype SelectOptions = Omit<\n ColumnOptions,\n \u0027unique\u0027\n>\n\n/** The column helpers: `column.string()`, `column.select({ options: [...] })`, … */\nexport declare const column: {\n string(\n options?: ColumnOptions\n ): Column\n number(\n options?: ColumnOptions\n ): Column\n /** A number shown as money; `currencyCode` is an ISO 4217 code (`USD` when omitted). */\n currency(\n options?: ColumnOptions & { currencyCode?: string }\n ): Column\n boolean(\n options?: ColumnOptions\n ): Column\n /** An ISO 8601 date or date-time string. */\n date(\n options?: ColumnOptions\n ): Column\n /** A time to live: a date-time after which the row expires. A table holds at most one. */\n ttl(\n options?: ColumnOptions\n ): Column\n json(\n options?: ColumnOptions\n ): Column\n /** One option per cell, from `options`. */\n select<\n const O extends readonly [string, ...string[]],\n const N extends string | undefined = undefined,\n const R extends boolean = false,\n >(options: SelectOptions & { options: O; multiple?: false }): Column\n /** Several options per cell. */\n select<\n const O extends readonly [string, ...string[]],\n const N extends string | undefined = undefined,\n const R extends boolean = false,\n >(options: SelectOptions & { options: O; multiple: true }): Column\n}\n\n/** Any column, whatever it holds. */\ntype AnyColumn = Column\n\n/** A table declaration. */\nexport interface TableDeclaration = Record> {\n /** The table name: a letter or `_`, then letters, digits and `_`. */\n name: string\n description?: string\n /** The table folder path (`/reports`); the workspace root when omitted. */\n folder?: string\n columns: C\n /** Rows as source, from `tables/.rows.jsonl`; omitted leaves rows out of source. */\n rows?: TableRows\n}\n\n/**\n * How a table\u0027s rows are source: `seed` rows go into the table once, when an apply creates it;\n * `managed` rows are the whole table, matched to stored rows by the unique `key` column.\n */\nexport type TableRows = { mode: \u0027seed\u0027 } | { mode: \u0027managed\u0027; key: K }\n\n/** Declares a table. Its default export is the whole file. */\nexport declare function defineTable>(\n table: TableDeclaration\n): TableDeclaration\n\n/** The stored name of column `K`: its `name` option, else its key. */\ntype StoredName = C extends Column\n ? [N] extends [string]\n ? N\n : K\n : K\n\n/** A cell of column `C`: its value, or `null` when the column is not required. */\ntype CellOf = C extends Column\n ? R extends true\n ? V\n : V | null\n : never\n\n/**\n * A declared table\u0027s row, keyed by stored column name: `RowOf`. A cell of a column\n * that is not required may be `null`.\n */\nexport type RowOf = T extends TableDeclaration\n ? { [K in keyof C as StoredName]: CellOf }\n : never\n","tool.d.ts":"/**\n * Custom tool declarations: `tools/.ts`, with the tool\u0027s code beside it in `tools/.js`.\n *\n * ```ts\n * // @sim-sdk 1\n * import { codeFile, defineTool } from \u0027@sim/workflow-sdk/workspace\u0027\n *\n * export default defineTool({\n * title: \u0027Lookup order\u0027,\n * schema: {\n * type: \u0027function\u0027,\n * function: {\n * name: \u0027lookup_order\u0027,\n * description: \u0027Find an order by id.\u0027,\n * parameters: {\n * type: \u0027object\u0027,\n * properties: { orderId: { type: \u0027string\u0027 } },\n * required: [\u0027orderId\u0027],\n * },\n * },\n * },\n * code: codeFile(\u0027./lookup-order.js\u0027),\n * })\n * ```\n *\n * The code file runs with each parameter as a variable; `$env.NAME` reads an environment variable\n * by name. The key is the tool\u0027s identity: a workflow names it as `customTool(\u0027lookup-order\u0027)`.\n * Code holding a literal credential prints as `code: stored()`, which keeps the code the server\n * holds without showing it.\n */\nimport type { CodeFileRef, Json } from \u0027@sim/workflow-sdk\u0027\n\nexport { codeFile, stored } from \u0027@sim/workflow-sdk\u0027\n\n/** JSON as an object literal writes it: an optional member may be absent. */\ntype SchemaJson = Json | readonly SchemaJson[] | { readonly [key: string]: SchemaJson | undefined }\n\n/** The function declaration a model calls the tool by, stored verbatim. */\nexport interface ToolSchema {\n type: \u0027function\u0027\n function: {\n /** What the model calls: letters, digits, `_` and `-`, at most 64 characters. */\n name: string\n description?: string\n /** A JSON Schema object describing the arguments. */\n parameters: {\n type: \u0027object\u0027\n properties: { [name: string]: Json }\n required?: string[]\n readonly [extra: string]: SchemaJson | undefined\n }\n readonly [extra: string]: SchemaJson | undefined\n }\n readonly [extra: string]: SchemaJson | undefined\n}\n\n/** A custom tool declaration. */\nexport interface ToolDeclaration {\n /** The tool\u0027s display title, unique in the workspace. */\n title: string\n schema: ToolSchema\n /** `codeFile(\u0027./.js\u0027)`, the code inline as a string, or `stored()` to keep the stored code. */\n code: CodeFileRef | string\n}\n\n/** Declares a custom tool. Its default export is the whole file. */\nexport declare function defineTool(tool: ToolDeclaration): ToolDeclaration\n"}
diff --git a/scripts/check-sim-cli-bundle.ts b/scripts/check-sim-cli-bundle.ts
new file mode 100644
index 00000000000..942ef134428
--- /dev/null
+++ b/scripts/check-sim-cli-bundle.ts
@@ -0,0 +1,141 @@
+#!/usr/bin/env bun
+/**
+ * Keeps two hand-kept lists in step with what the published `sim` CLI actually bundles. The
+ * package builds with `--packages=bundle`, so every workspace package and npm dependency it
+ * imports ships inside `dist/`:
+ *
+ * - `packages/sim-cli/THIRD_PARTY_LICENSES` names every npm package in the bundle and no other.
+ * The minified bundle drops their license banners, so this file is the notice their licenses
+ * require to ship with each copy.
+ * - `.github/workflows/publish-sim-cli.yml` watches every workspace package in the bundle, so a
+ * change to one (a compiler fix in `@sim/workflow-code`, say) republishes the CLI that ships it.
+ *
+ * The bundle graph comes from the entry points the package's own `build` script names, bundled in
+ * memory with a metafile; nothing is written. Fix a finding by editing the list it names: add a
+ * newly bundled package's notice or trigger path, or drop one the bundle no longer holds.
+ *
+ * Run: `bun run check:sim-cli-bundle`
+ */
+import path from 'node:path'
+import { compareStrings } from '@sim/utils/string'
+
+const ROOT = path.resolve(import.meta.dir, '..')
+const CLI_DIR = 'packages/sim-cli'
+const LICENSES_FILE = `${CLI_DIR}/THIRD_PARTY_LICENSES`
+const PUBLISH_WORKFLOW = '.github/workflows/publish-sim-cli.yml'
+
+/** An npm package name, as each notice in {@link LICENSES_FILE} opens with one on its own line. */
+const PACKAGE_NAME = /^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/
+/** The package an input under `node_modules` belongs to, at its innermost `node_modules`. */
+const NPM_PACKAGE = /(?:^|\/)node_modules\/((?:@[^/]+\/)?[^/]+)\/(?!.*\/node_modules\/)/
+/** A workspace package's source, outside any `node_modules`. */
+const WORKSPACE_PACKAGE = /^packages\/([^/]+)\//
+/** A trigger path watching a whole workspace package. */
+const WATCHED_PACKAGE = /^packages\/([^/]+)\/\*\*$/
+
+/** The entry points `packages/sim-cli`'s `build` script bundles. */
+async function buildEntryPoints(): Promise {
+ const manifest = await Bun.file(path.join(ROOT, CLI_DIR, 'package.json')).json()
+ const bundleStep = String(manifest.scripts.build).split('&&')[0]
+ const entries = bundleStep
+ .split(/\s+/)
+ .filter((token) => token.startsWith('src/') && token.endsWith('.ts'))
+ if (entries.length === 0) {
+ throw new Error(`No entry points found in ${CLI_DIR}'s build script: ${bundleStep}`)
+ }
+ return entries.map((entry) => path.join(ROOT, CLI_DIR, entry))
+}
+
+/** Every source file the CLI bundle holds, relative to the repo root. */
+async function bundledInputs(): Promise {
+ const result = await Bun.build({
+ entrypoints: await buildEntryPoints(),
+ target: 'node',
+ format: 'esm',
+ packages: 'bundle',
+ metafile: true,
+ })
+ if (!result.success || !result.metafile) {
+ throw new Error(`Bundling ${CLI_DIR} failed:\n${result.logs.join('\n')}`)
+ }
+ return Object.keys(result.metafile.inputs).map((input) =>
+ path.relative(ROOT, path.resolve(process.cwd(), input))
+ )
+}
+
+/** The package names {@link LICENSES_FILE} gives a notice for. */
+async function noticedPackages(): Promise> {
+ const lines = (await Bun.file(path.join(ROOT, LICENSES_FILE)).text()).split('\n')
+ return new Set(
+ lines.filter(
+ (line, index) => index > 0 && lines[index - 1].trim() === '' && PACKAGE_NAME.test(line.trim())
+ )
+ )
+}
+
+/** The workspace packages {@link PUBLISH_WORKFLOW}'s push trigger watches. */
+async function watchedPackages(): Promise> {
+ const workflow = Bun.YAML.parse(await Bun.file(path.join(ROOT, PUBLISH_WORKFLOW)).text()) as {
+ on?: { push?: { paths?: unknown } }
+ }
+ const paths = workflow.on?.push?.paths
+ if (!Array.isArray(paths)) throw new Error(`${PUBLISH_WORKFLOW} has no on.push.paths list`)
+ return new Set(paths.flatMap((entry) => WATCHED_PACKAGE.exec(String(entry))?.[1] ?? []))
+}
+
+/** One message per name in `names` that `known` lacks, in name order. */
+function missingFrom(
+ names: ReadonlySet,
+ known: ReadonlySet,
+ message: (name: string) => string
+): string[] {
+ return [...names]
+ .filter((name) => !known.has(name))
+ .sort(compareStrings)
+ .map(message)
+}
+
+async function main(): Promise {
+ const inputs = await bundledInputs()
+ const npmPackages = new Set(inputs.flatMap((input) => NPM_PACKAGE.exec(input)?.[1] ?? []))
+ const workspacePackages = new Set(
+ inputs.flatMap((input) =>
+ input.includes('node_modules/') ? [] : (WORKSPACE_PACKAGE.exec(input)?.[1] ?? [])
+ )
+ )
+ const [noticed, watched] = await Promise.all([noticedPackages(), watchedPackages()])
+
+ const problems = [
+ ...missingFrom(
+ npmPackages,
+ noticed,
+ (name) => `${name} is bundled but has no notice in ${LICENSES_FILE}.`
+ ),
+ ...missingFrom(
+ noticed,
+ npmPackages,
+ (name) => `${LICENSES_FILE} has a notice for ${name}, which the bundle no longer holds.`
+ ),
+ ...missingFrom(
+ workspacePackages,
+ watched,
+ (name) =>
+ `packages/${name} is bundled but ${PUBLISH_WORKFLOW} does not watch 'packages/${name}/**', so a change there never republishes the CLI.`
+ ),
+ ...missingFrom(
+ watched,
+ workspacePackages,
+ (name) => `${PUBLISH_WORKFLOW} watches 'packages/${name}/**', which the bundle does not hold.`
+ ),
+ ]
+
+ if (problems.length > 0) {
+ console.error(`✗ the sim CLI bundle and its lists disagree:\n- ${problems.join('\n- ')}`)
+ process.exit(1)
+ }
+ console.log(
+ `✓ ${npmPackages.size} bundled npm packages have notices; ${workspacePackages.size} bundled workspace packages republish the CLI`
+ )
+}
+
+if (import.meta.main) await main()