@nodetool-ai/protocol 0.7.0-rc.23 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/ai-video-production.d.ts +249 -0
- package/dist/ai-video-production.d.ts.map +1 -0
- package/dist/ai-video-production.js +131 -0
- package/dist/ai-video-production.js.map +1 -0
- package/dist/api-schemas/agent-access.d.ts +134 -0
- package/dist/api-schemas/agent-access.d.ts.map +1 -0
- package/dist/api-schemas/agent-access.js +93 -0
- package/dist/api-schemas/agent-access.js.map +1 -0
- package/dist/api-schemas/api-error-code.d.ts +11 -1
- package/dist/api-schemas/api-error-code.d.ts.map +1 -1
- package/dist/api-schemas/api-error-code.js +10 -0
- package/dist/api-schemas/api-error-code.js.map +1 -1
- package/dist/api-schemas/applications.d.ts +1411 -0
- package/dist/api-schemas/applications.d.ts.map +1 -0
- package/dist/api-schemas/applications.js +333 -0
- package/dist/api-schemas/applications.js.map +1 -0
- package/dist/api-schemas/assets.d.ts +230 -0
- package/dist/api-schemas/assets.d.ts.map +1 -1
- package/dist/api-schemas/assets.js +131 -5
- package/dist/api-schemas/assets.js.map +1 -1
- package/dist/api-schemas/code-gen.d.ts +176 -0
- package/dist/api-schemas/code-gen.d.ts.map +1 -0
- package/dist/api-schemas/code-gen.js +205 -0
- package/dist/api-schemas/code-gen.js.map +1 -0
- package/dist/api-schemas/collections.d.ts.map +1 -1
- package/dist/api-schemas/collections.js +3 -4
- package/dist/api-schemas/collections.js.map +1 -1
- package/dist/api-schemas/costs.d.ts +179 -0
- package/dist/api-schemas/costs.d.ts.map +1 -1
- package/dist/api-schemas/costs.js +100 -4
- package/dist/api-schemas/costs.js.map +1 -1
- package/dist/api-schemas/credits.d.ts +42 -0
- package/dist/api-schemas/credits.d.ts.map +1 -0
- package/dist/api-schemas/credits.js +43 -0
- package/dist/api-schemas/credits.js.map +1 -0
- package/dist/api-schemas/documents.d.ts +163 -0
- package/dist/api-schemas/documents.d.ts.map +1 -0
- package/dist/api-schemas/documents.js +75 -0
- package/dist/api-schemas/documents.js.map +1 -0
- package/dist/api-schemas/files.d.ts +13 -0
- package/dist/api-schemas/files.d.ts.map +1 -1
- package/dist/api-schemas/files.js +8 -0
- package/dist/api-schemas/files.js.map +1 -1
- package/dist/api-schemas/fonts.d.ts +17 -1
- package/dist/api-schemas/fonts.d.ts.map +1 -1
- package/dist/api-schemas/fonts.js +19 -3
- package/dist/api-schemas/fonts.js.map +1 -1
- package/dist/api-schemas/index.d.ts +23 -1
- package/dist/api-schemas/index.d.ts.map +1 -1
- package/dist/api-schemas/index.js +23 -1
- package/dist/api-schemas/index.js.map +1 -1
- package/dist/api-schemas/jobs.d.ts +12 -0
- package/dist/api-schemas/jobs.d.ts.map +1 -1
- package/dist/api-schemas/jobs.js +12 -2
- package/dist/api-schemas/jobs.js.map +1 -1
- package/dist/api-schemas/js-scripts.d.ts +364 -0
- package/dist/api-schemas/js-scripts.d.ts.map +1 -0
- package/dist/api-schemas/js-scripts.js +333 -0
- package/dist/api-schemas/js-scripts.js.map +1 -0
- package/dist/api-schemas/mcp-config.d.ts.map +1 -1
- package/dist/api-schemas/mcp-config.js +3 -1
- package/dist/api-schemas/mcp-config.js.map +1 -1
- package/dist/api-schemas/memories.d.ts +84 -0
- package/dist/api-schemas/memories.d.ts.map +1 -0
- package/dist/api-schemas/memories.js +54 -0
- package/dist/api-schemas/memories.js.map +1 -0
- package/dist/api-schemas/messages.d.ts +1 -0
- package/dist/api-schemas/messages.d.ts.map +1 -1
- package/dist/api-schemas/messages.js +4 -4
- package/dist/api-schemas/messages.js.map +1 -1
- package/dist/api-schemas/models.d.ts +156 -0
- package/dist/api-schemas/models.d.ts.map +1 -1
- package/dist/api-schemas/models.js +51 -6
- package/dist/api-schemas/models.js.map +1 -1
- package/dist/api-schemas/nodes.d.ts +97 -0
- package/dist/api-schemas/nodes.d.ts.map +1 -1
- package/dist/api-schemas/nodes.js +89 -0
- package/dist/api-schemas/nodes.js.map +1 -1
- package/dist/api-schemas/projects.d.ts +427 -0
- package/dist/api-schemas/projects.d.ts.map +1 -0
- package/dist/api-schemas/projects.js +224 -0
- package/dist/api-schemas/projects.js.map +1 -0
- package/dist/api-schemas/recipes.d.ts +172 -0
- package/dist/api-schemas/recipes.d.ts.map +1 -0
- package/dist/api-schemas/recipes.js +144 -0
- package/dist/api-schemas/recipes.js.map +1 -0
- package/dist/api-schemas/resources.d.ts +112 -0
- package/dist/api-schemas/resources.d.ts.map +1 -0
- package/dist/api-schemas/resources.js +44 -0
- package/dist/api-schemas/resources.js.map +1 -0
- package/dist/api-schemas/scripts.d.ts +1571 -0
- package/dist/api-schemas/scripts.d.ts.map +1 -0
- package/dist/api-schemas/scripts.js +153 -0
- package/dist/api-schemas/scripts.js.map +1 -0
- package/dist/api-schemas/sdk-execution-v1.d.ts +467 -0
- package/dist/api-schemas/sdk-execution-v1.d.ts.map +1 -0
- package/dist/api-schemas/sdk-execution-v1.js +115 -0
- package/dist/api-schemas/sdk-execution-v1.js.map +1 -0
- package/dist/api-schemas/sdk-lifecycle-v1.d.ts +217 -0
- package/dist/api-schemas/sdk-lifecycle-v1.d.ts.map +1 -0
- package/dist/api-schemas/sdk-lifecycle-v1.js +117 -0
- package/dist/api-schemas/sdk-lifecycle-v1.js.map +1 -0
- package/dist/api-schemas/sdk-models-v1.d.ts +181 -0
- package/dist/api-schemas/sdk-models-v1.d.ts.map +1 -0
- package/dist/api-schemas/sdk-models-v1.js +108 -0
- package/dist/api-schemas/sdk-models-v1.js.map +1 -0
- package/dist/api-schemas/sdk-v1-http-operations.d.ts +941 -0
- package/dist/api-schemas/sdk-v1-http-operations.d.ts.map +1 -0
- package/dist/api-schemas/sdk-v1-http-operations.js +465 -0
- package/dist/api-schemas/sdk-v1-http-operations.js.map +1 -0
- package/dist/api-schemas/sdk-v1-operations.d.ts +151 -0
- package/dist/api-schemas/sdk-v1-operations.d.ts.map +1 -0
- package/dist/api-schemas/sdk-v1-operations.js +97 -0
- package/dist/api-schemas/sdk-v1-operations.js.map +1 -0
- package/dist/api-schemas/sdk-v1-websocket-operations.d.ts +97 -0
- package/dist/api-schemas/sdk-v1-websocket-operations.d.ts.map +1 -0
- package/dist/api-schemas/sdk-v1-websocket-operations.js +96 -0
- package/dist/api-schemas/sdk-v1-websocket-operations.js.map +1 -0
- package/dist/api-schemas/sdk-v1.d.ts +15 -0
- package/dist/api-schemas/sdk-v1.d.ts.map +1 -0
- package/dist/api-schemas/sdk-v1.js +22 -0
- package/dist/api-schemas/sdk-v1.js.map +1 -0
- package/dist/api-schemas/segmentation.d.ts +75 -0
- package/dist/api-schemas/segmentation.d.ts.map +1 -0
- package/dist/api-schemas/segmentation.js +54 -0
- package/dist/api-schemas/segmentation.js.map +1 -0
- package/dist/api-schemas/settings.d.ts +159 -0
- package/dist/api-schemas/settings.d.ts.map +1 -1
- package/dist/api-schemas/settings.js +70 -0
- package/dist/api-schemas/settings.js.map +1 -1
- package/dist/api-schemas/sketch.d.ts +847 -0
- package/dist/api-schemas/sketch.d.ts.map +1 -0
- package/dist/api-schemas/sketch.js +544 -0
- package/dist/api-schemas/sketch.js.map +1 -0
- package/dist/api-schemas/skills.d.ts +27 -14
- package/dist/api-schemas/skills.d.ts.map +1 -1
- package/dist/api-schemas/skills.js +64 -11
- package/dist/api-schemas/skills.js.map +1 -1
- package/dist/api-schemas/storage.d.ts +8 -0
- package/dist/api-schemas/storage.d.ts.map +1 -1
- package/dist/api-schemas/storage.js +7 -0
- package/dist/api-schemas/storage.js.map +1 -1
- package/dist/api-schemas/storyboards.d.ts +7026 -0
- package/dist/api-schemas/storyboards.d.ts.map +1 -0
- package/dist/api-schemas/storyboards.js +393 -0
- package/dist/api-schemas/storyboards.js.map +1 -0
- package/dist/api-schemas/threads.d.ts +12 -4
- package/dist/api-schemas/threads.d.ts.map +1 -1
- package/dist/api-schemas/threads.js +12 -4
- package/dist/api-schemas/threads.js.map +1 -1
- package/dist/api-schemas/timeline-tool-contracts.d.ts +1650 -0
- package/dist/api-schemas/timeline-tool-contracts.d.ts.map +1 -0
- package/dist/api-schemas/timeline-tool-contracts.js +725 -0
- package/dist/api-schemas/timeline-tool-contracts.js.map +1 -0
- package/dist/api-schemas/timeline-tool-params.d.ts +1237 -0
- package/dist/api-schemas/timeline-tool-params.d.ts.map +1 -0
- package/dist/api-schemas/timeline-tool-params.js +1518 -0
- package/dist/api-schemas/timeline-tool-params.js.map +1 -0
- package/dist/api-schemas/timeline.d.ts +12803 -0
- package/dist/api-schemas/timeline.d.ts.map +1 -0
- package/dist/api-schemas/timeline.js +1838 -0
- package/dist/api-schemas/timeline.js.map +1 -0
- package/dist/api-schemas/ui-tool-contract.d.ts +35 -0
- package/dist/api-schemas/ui-tool-contract.d.ts.map +1 -0
- package/dist/api-schemas/ui-tool-contract.js +31 -0
- package/dist/api-schemas/ui-tool-contract.js.map +1 -0
- package/dist/api-schemas/workflows.d.ts +852 -18
- package/dist/api-schemas/workflows.d.ts.map +1 -1
- package/dist/api-schemas/workflows.js +484 -6
- package/dist/api-schemas/workflows.js.map +1 -1
- package/dist/api-schemas/workspace.d.ts +45 -0
- package/dist/api-schemas/workspace.d.ts.map +1 -1
- package/dist/api-schemas/workspace.js +47 -1
- package/dist/api-schemas/workspace.js.map +1 -1
- package/dist/api-types.d.ts +621 -27
- package/dist/api-types.d.ts.map +1 -1
- package/dist/api-types.js +246 -1
- package/dist/api-types.js.map +1 -1
- package/dist/app-deployment.d.ts +37 -0
- package/dist/app-deployment.d.ts.map +1 -0
- package/dist/app-deployment.js +42 -0
- package/dist/app-deployment.js.map +1 -0
- package/dist/asset-generation.d.ts +58 -0
- package/dist/asset-generation.d.ts.map +1 -0
- package/dist/asset-generation.js +147 -0
- package/dist/asset-generation.js.map +1 -0
- package/dist/blend-modes.d.ts +20 -0
- package/dist/blend-modes.d.ts.map +1 -0
- package/dist/blend-modes.js +33 -0
- package/dist/blend-modes.js.map +1 -0
- package/dist/bridge-frames.d.ts +654 -0
- package/dist/bridge-frames.d.ts.map +1 -0
- package/dist/bridge-frames.js +448 -0
- package/dist/bridge-frames.js.map +1 -0
- package/dist/bridge-frames.schema.json +862 -0
- package/dist/bridge-protocol.d.ts +57 -20
- package/dist/bridge-protocol.d.ts.map +1 -1
- package/dist/bridge-protocol.js +57 -20
- package/dist/bridge-protocol.js.map +1 -1
- package/dist/builtin-packs.d.ts +45 -0
- package/dist/builtin-packs.d.ts.map +1 -0
- package/dist/builtin-packs.js +115 -0
- package/dist/builtin-packs.js.map +1 -0
- package/dist/caption-word.d.ts +15 -0
- package/dist/caption-word.d.ts.map +1 -0
- package/dist/caption-word.js +10 -0
- package/dist/caption-word.js.map +1 -0
- package/dist/cloud-profile.d.ts +187 -0
- package/dist/cloud-profile.d.ts.map +1 -0
- package/dist/cloud-profile.js +281 -0
- package/dist/cloud-profile.js.map +1 -0
- package/dist/creative.d.ts +486 -0
- package/dist/creative.d.ts.map +1 -0
- package/dist/creative.js +269 -0
- package/dist/creative.js.map +1 -0
- package/dist/custom-providers.d.ts +70 -0
- package/dist/custom-providers.d.ts.map +1 -0
- package/dist/custom-providers.js +125 -0
- package/dist/custom-providers.js.map +1 -0
- package/dist/document-ops.d.ts +15 -0
- package/dist/document-ops.d.ts.map +1 -0
- package/dist/document-ops.js +2 -0
- package/dist/document-ops.js.map +1 -0
- package/dist/game-assets.d.ts +344 -0
- package/dist/game-assets.d.ts.map +1 -0
- package/dist/game-assets.js +297 -0
- package/dist/game-assets.js.map +1 -0
- package/dist/game-design.d.ts +90 -0
- package/dist/game-design.d.ts.map +1 -0
- package/dist/game-design.js +417 -0
- package/dist/game-design.js.map +1 -0
- package/dist/game-flow-prompt.d.ts +68 -0
- package/dist/game-flow-prompt.d.ts.map +1 -0
- package/dist/game-flow-prompt.js +121 -0
- package/dist/game-flow-prompt.js.map +1 -0
- package/dist/game-graph.d.ts +96 -0
- package/dist/game-graph.d.ts.map +1 -0
- package/dist/game-graph.js +481 -0
- package/dist/game-graph.js.map +1 -0
- package/dist/game-migration.d.ts +4 -0
- package/dist/game-migration.d.ts.map +1 -0
- package/dist/game-migration.js +6 -0
- package/dist/game-migration.js.map +1 -0
- package/dist/game-slot-prompt.d.ts +90 -0
- package/dist/game-slot-prompt.d.ts.map +1 -0
- package/dist/game-slot-prompt.js +237 -0
- package/dist/game-slot-prompt.js.map +1 -0
- package/dist/game.d.ts +1663 -0
- package/dist/game.d.ts.map +1 -0
- package/dist/game.js +228 -0
- package/dist/game.js.map +1 -0
- package/dist/graph.d.ts +191 -5
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +497 -0
- package/dist/graph.js.map +1 -1
- package/dist/index.d.ts +47 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -2
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +38 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +69 -0
- package/dist/loop.js.map +1 -0
- package/dist/mcp-server-config.d.ts +113 -0
- package/dist/mcp-server-config.d.ts.map +1 -0
- package/dist/mcp-server-config.js +147 -0
- package/dist/mcp-server-config.js.map +1 -0
- package/dist/messages.d.ts +1565 -243
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +709 -22
- package/dist/messages.js.map +1 -1
- package/dist/model-selection.d.ts +20 -0
- package/dist/model-selection.d.ts.map +1 -0
- package/dist/model-selection.js +27 -0
- package/dist/model-selection.js.map +1 -0
- package/dist/nodetool-models.d.ts +71 -0
- package/dist/nodetool-models.d.ts.map +1 -0
- package/dist/nodetool-models.js +138 -0
- package/dist/nodetool-models.js.map +1 -0
- package/dist/package-assets.d.ts +39 -0
- package/dist/package-assets.d.ts.map +1 -0
- package/dist/package-assets.js +63 -0
- package/dist/package-assets.js.map +1 -0
- package/dist/platform.d.ts +66 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +68 -0
- package/dist/platform.js.map +1 -0
- package/dist/predicates.d.ts +43 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +65 -0
- package/dist/predicates.js.map +1 -0
- package/dist/processing-messages.schema.json +2525 -0
- package/dist/production-authoring.d.ts +757 -0
- package/dist/production-authoring.d.ts.map +1 -0
- package/dist/production-authoring.js +736 -0
- package/dist/production-authoring.js.map +1 -0
- package/dist/render-record.d.ts +86 -0
- package/dist/render-record.d.ts.map +1 -0
- package/dist/render-record.js +133 -0
- package/dist/render-record.js.map +1 -0
- package/dist/resource-id.d.ts +22 -0
- package/dist/resource-id.d.ts.map +1 -0
- package/dist/resource-id.js +32 -0
- package/dist/resource-id.js.map +1 -0
- package/dist/resource-uri.d.ts +15 -0
- package/dist/resource-uri.d.ts.map +1 -0
- package/dist/resource-uri.js +88 -0
- package/dist/resource-uri.js.map +1 -0
- package/dist/sandbox-capability.d.ts +86 -0
- package/dist/sandbox-capability.d.ts.map +1 -0
- package/dist/sandbox-capability.js +106 -0
- package/dist/sandbox-capability.js.map +1 -0
- package/dist/sandbox-host.d.ts +98 -0
- package/dist/sandbox-host.d.ts.map +1 -0
- package/dist/sandbox-host.js +311 -0
- package/dist/sandbox-host.js.map +1 -0
- package/dist/sandbox-package.d.ts +674 -0
- package/dist/sandbox-package.d.ts.map +1 -0
- package/dist/sandbox-package.js +622 -0
- package/dist/sandbox-package.js.map +1 -0
- package/dist/sandbox-wasm.d.ts +84 -0
- package/dist/sandbox-wasm.d.ts.map +1 -0
- package/dist/sandbox-wasm.js +139 -0
- package/dist/sandbox-wasm.js.map +1 -0
- package/dist/screenplay-authoring.d.ts +69 -0
- package/dist/screenplay-authoring.d.ts.map +1 -0
- package/dist/screenplay-authoring.js +351 -0
- package/dist/screenplay-authoring.js.map +1 -0
- package/dist/script-authoring.d.ts +161 -0
- package/dist/script-authoring.d.ts.map +1 -0
- package/dist/script-authoring.js +503 -0
- package/dist/script-authoring.js.map +1 -0
- package/dist/script-fill.d.ts +39 -0
- package/dist/script-fill.d.ts.map +1 -0
- package/dist/script-fill.js +67 -0
- package/dist/script-fill.js.map +1 -0
- package/dist/script-link.d.ts +110 -0
- package/dist/script-link.d.ts.map +1 -0
- package/dist/script-link.js +252 -0
- package/dist/script-link.js.map +1 -0
- package/dist/sha256.d.ts +11 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +110 -0
- package/dist/sha256.js.map +1 -0
- package/dist/shot-prompt.d.ts +78 -0
- package/dist/shot-prompt.d.ts.map +1 -0
- package/dist/shot-prompt.js +120 -0
- package/dist/shot-prompt.js.map +1 -0
- package/dist/skill-document.d.ts +36 -0
- package/dist/skill-document.d.ts.map +1 -0
- package/dist/skill-document.js +137 -0
- package/dist/skill-document.js.map +1 -0
- package/dist/style-presets.d.ts +73 -0
- package/dist/style-presets.d.ts.map +1 -0
- package/dist/style-presets.js +147 -0
- package/dist/style-presets.js.map +1 -0
- package/dist/supervisor.d.ts +227 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +116 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/token-providers.d.ts +31 -0
- package/dist/token-providers.d.ts.map +1 -0
- package/dist/token-providers.js +52 -0
- package/dist/token-providers.js.map +1 -0
- package/dist/toolSchemas.d.ts +10 -14
- package/dist/toolSchemas.d.ts.map +1 -1
- package/dist/toolSchemas.js +13 -23
- package/dist/toolSchemas.js.map +1 -1
- package/dist/triggers.d.ts +41 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +50 -0
- package/dist/triggers.js.map +1 -0
- package/dist/trpc-policy.d.ts +3 -0
- package/dist/trpc-policy.d.ts.map +1 -0
- package/dist/trpc-policy.js +3 -0
- package/dist/trpc-policy.js.map +1 -0
- package/dist/type-metadata.d.ts +5 -0
- package/dist/type-metadata.d.ts.map +1 -1
- package/dist/type-metadata.js +17 -8
- package/dist/type-metadata.js.map +1 -1
- package/dist/typecheck.d.ts.map +1 -1
- package/dist/typecheck.js +5 -4
- package/dist/typecheck.js.map +1 -1
- package/dist/wasm-binary.d.ts +61 -0
- package/dist/wasm-binary.d.ts.map +1 -0
- package/dist/wasm-binary.js +215 -0
- package/dist/wasm-binary.js.map +1 -0
- package/dist/workflow-plan.d.ts +197 -0
- package/dist/workflow-plan.d.ts.map +1 -0
- package/dist/workflow-plan.js +438 -0
- package/dist/workflow-plan.js.map +1 -0
- package/dist/wrap-primitives.d.ts +0 -11
- package/dist/wrap-primitives.d.ts.map +1 -1
- package/dist/wrap-primitives.js +3 -9
- package/dist/wrap-primitives.js.map +1 -1
- package/dist/ws-commands.d.ts +665 -0
- package/dist/ws-commands.d.ts.map +1 -0
- package/dist/ws-commands.js +610 -0
- package/dist/ws-commands.js.map +1 -0
- package/dist/zod-schema.d.ts +20 -0
- package/dist/zod-schema.d.ts.map +1 -0
- package/dist/zod-schema.js +298 -0
- package/dist/zod-schema.js.map +1 -0
- package/package.json +84 -7
- package/schema/sdk-v1.asyncapi.implemented.json +65 -0
- package/schema/sdk-v1.asyncapi.json +65 -0
- package/schema/sdk-v1.discovery.schema.json +1218 -0
- package/schema/sdk-v1.execution.schema.json +2792 -0
- package/schema/sdk-v1.lifecycle.schema.json +1031 -0
- package/schema/sdk-v1.manifest.json +71 -0
- package/schema/sdk-v1.openapi.implemented.json +730 -0
- package/schema/sdk-v1.openapi.json +730 -0
- package/schema/sdk-v1.operations.json +732 -0
- package/dist/agent-protocol.d.ts +0 -217
- package/dist/agent-protocol.d.ts.map +0 -1
- package/dist/agent-protocol.js +0 -85
- package/dist/agent-protocol.js.map +0 -1
package/dist/messages.js
CHANGED
|
@@ -9,7 +9,24 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Every message is discriminated by a literal `type` field so that
|
|
11
11
|
* consumers can switch on `msg.type` for exhaustive handling.
|
|
12
|
+
*
|
|
13
|
+
* Zod is the source of truth: every `ProcessingMessage` variant (and the
|
|
14
|
+
* types it embeds) is defined as a Zod schema first, with its TypeScript
|
|
15
|
+
* type derived via `z.infer`. Where Zod's inference can't reproduce a
|
|
16
|
+
* shape exactly — index signatures, `unknown` fields whose optionality
|
|
17
|
+
* must stay exact — the TypeScript interface is still hand-written and
|
|
18
|
+
* exported as before, and the schema is annotated `z.ZodType<ThatType>`
|
|
19
|
+
* so the two never drift silently.
|
|
20
|
+
*
|
|
21
|
+
* `processingMessageSchema` (a `z.discriminatedUnion` on `type`) is the
|
|
22
|
+
* single runtime validator for the whole union; `packages/protocol`'s
|
|
23
|
+
* build emits it as JSON Schema to `dist/processing-messages.schema.json`
|
|
24
|
+
* (see `scripts/generate-processing-messages-schema.ts`) for non-TS
|
|
25
|
+
* consumers (the Python worker, external SDKs) to validate against.
|
|
12
26
|
*/
|
|
27
|
+
import { z } from "zod";
|
|
28
|
+
import { isRecord, isString } from "./predicates.js";
|
|
29
|
+
import { supervisorDecisionSchema, supervisorEscalationSchema } from "./supervisor.js";
|
|
13
30
|
// ---------------------------------------------------------------------------
|
|
14
31
|
// Enums
|
|
15
32
|
// ---------------------------------------------------------------------------
|
|
@@ -23,7 +40,697 @@ export var TaskUpdateEvent;
|
|
|
23
40
|
TaskUpdateEvent["StepCompleted"] = "step_completed";
|
|
24
41
|
TaskUpdateEvent["StepFailed"] = "step_failed";
|
|
25
42
|
TaskUpdateEvent["TaskCompleted"] = "task_completed";
|
|
43
|
+
TaskUpdateEvent["TaskFailed"] = "task_failed";
|
|
26
44
|
})(TaskUpdateEvent || (TaskUpdateEvent = {}));
|
|
45
|
+
/** Zod schema for {@link TaskUpdateEvent}. */
|
|
46
|
+
export const taskUpdateEventSchema = z.enum(TaskUpdateEvent);
|
|
47
|
+
export const severitySchema = z.enum(["info", "warning", "error"]);
|
|
48
|
+
export const contentTypeSchema = z.enum([
|
|
49
|
+
"text",
|
|
50
|
+
"audio",
|
|
51
|
+
"image",
|
|
52
|
+
"video",
|
|
53
|
+
"document",
|
|
54
|
+
"tool_call",
|
|
55
|
+
"agent_status"
|
|
56
|
+
]);
|
|
57
|
+
// `TaskRef`/`StepRef` are mutually recursive and carry an index signature
|
|
58
|
+
// (`[key: string]: unknown`) on top of explicit optional fields — a shape
|
|
59
|
+
// `z.infer` cannot reproduce exactly (Zod's `.catchall()` would also widen
|
|
60
|
+
// the explicit fields' key type). The interfaces above remain the source
|
|
61
|
+
// of truth for the TS types; these schemas are hand-annotated to them and
|
|
62
|
+
// validate the same shape at runtime. `z.lazy` breaks the recursive cycle.
|
|
63
|
+
export const stepRefSchema = z.lazy(() => z
|
|
64
|
+
.object({
|
|
65
|
+
id: z.string().optional(),
|
|
66
|
+
name: z.string().optional(),
|
|
67
|
+
instructions: z.string().optional(),
|
|
68
|
+
status: z.string().optional(),
|
|
69
|
+
tool: z.string().nullable().optional(),
|
|
70
|
+
result: z.unknown().optional(),
|
|
71
|
+
error: z.string().nullable().optional(),
|
|
72
|
+
completed: z.boolean().optional(),
|
|
73
|
+
start_time: z.number().optional()
|
|
74
|
+
})
|
|
75
|
+
.catchall(z.unknown()));
|
|
76
|
+
export const taskRefSchema = z.lazy(() => z
|
|
77
|
+
.object({
|
|
78
|
+
id: z.string().optional(),
|
|
79
|
+
name: z.string().optional(),
|
|
80
|
+
title: z.string().optional(),
|
|
81
|
+
description: z.string().optional(),
|
|
82
|
+
instructions: z.string().optional(),
|
|
83
|
+
status: z.string().optional(),
|
|
84
|
+
steps: z.array(stepRefSchema).optional(),
|
|
85
|
+
result: z.unknown().optional(),
|
|
86
|
+
error: z.string().nullable().optional()
|
|
87
|
+
})
|
|
88
|
+
.catchall(z.unknown()));
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Server → Client messages
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
export const validationIssueSchema = z.object({
|
|
93
|
+
node_id: z.string(),
|
|
94
|
+
node_type: z.string().nullable().optional(),
|
|
95
|
+
property: z.string(),
|
|
96
|
+
message: z.string()
|
|
97
|
+
});
|
|
98
|
+
export const jobUpdateSchema = z.object({
|
|
99
|
+
type: z.literal("job_update"),
|
|
100
|
+
status: z.string(),
|
|
101
|
+
job_id: z.string().nullable().optional(),
|
|
102
|
+
workflow_id: z.string().nullable().optional(),
|
|
103
|
+
message: z.string().nullable().optional(),
|
|
104
|
+
result: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
105
|
+
error: z.string().nullable().optional(),
|
|
106
|
+
traceback: z.string().nullable().optional(),
|
|
107
|
+
duration: z.number().nullable().optional(),
|
|
108
|
+
/**
|
|
109
|
+
* 1-based position in the server's pending-run queue. Present when
|
|
110
|
+
* `status === "queued"` because the client already has
|
|
111
|
+
* `MAX_CONCURRENT_JOBS` runs in flight. The run starts automatically
|
|
112
|
+
* (a `running` update follows) once an earlier run finishes.
|
|
113
|
+
*/
|
|
114
|
+
queue_position: z.number().nullable().optional(),
|
|
115
|
+
/**
|
|
116
|
+
* Per-property issues from pre-flight graph validation. Present when
|
|
117
|
+
* `status === "failed"` and the failure was caused by a validation error
|
|
118
|
+
* (not a runtime exception). Frontend uses this to highlight specific
|
|
119
|
+
* fields on the offending nodes instead of showing a node-level banner.
|
|
120
|
+
*/
|
|
121
|
+
validation_issues: z.array(validationIssueSchema).nullable().optional(),
|
|
122
|
+
/**
|
|
123
|
+
* Machine-readable reason for a `failed` status, when one exists. Set to
|
|
124
|
+
* `BUDGET_EXCEEDED` when an app's spend budget refused the run — a websocket
|
|
125
|
+
* client has no other way to tell that apart from a node crash, since both
|
|
126
|
+
* arrive as `failed` with prose in `error`. Absent for ordinary failures.
|
|
127
|
+
*/
|
|
128
|
+
error_code: z.string().nullable().optional()
|
|
129
|
+
});
|
|
130
|
+
/**
|
|
131
|
+
* Media generation tracking (docs/media-generation-tracking-design.md).
|
|
132
|
+
*
|
|
133
|
+
* A generation is one provider call that produces media, tracked as a row
|
|
134
|
+
* from before the call to its terminal state. These schemas travel on the
|
|
135
|
+
* `prediction` message and into the ledger row.
|
|
136
|
+
*/
|
|
137
|
+
export const generationSurfaceSchema = z.enum([
|
|
138
|
+
"workflow",
|
|
139
|
+
"capability",
|
|
140
|
+
"chat",
|
|
141
|
+
"rpc",
|
|
142
|
+
"cli"
|
|
143
|
+
]);
|
|
144
|
+
/**
|
|
145
|
+
* Public generation status derived from the durable lifecycle dimensions.
|
|
146
|
+
* `interrupted` remains readable for rows written by the legacy startup sweep.
|
|
147
|
+
*/
|
|
148
|
+
export const generationStatusSchema = z.enum([
|
|
149
|
+
"pending",
|
|
150
|
+
"running",
|
|
151
|
+
"recovering",
|
|
152
|
+
"completed",
|
|
153
|
+
"failed",
|
|
154
|
+
"cancelled",
|
|
155
|
+
"needs_attention",
|
|
156
|
+
"interrupted"
|
|
157
|
+
]);
|
|
158
|
+
export const generationSubmissionStatusSchema = z.enum([
|
|
159
|
+
"accepted",
|
|
160
|
+
"submitting",
|
|
161
|
+
"submitted",
|
|
162
|
+
"submission_unknown"
|
|
163
|
+
]);
|
|
164
|
+
export const generationProviderStatusSchema = z.enum([
|
|
165
|
+
"unknown",
|
|
166
|
+
"queued",
|
|
167
|
+
"running",
|
|
168
|
+
"succeeded",
|
|
169
|
+
"failed",
|
|
170
|
+
"cancelled"
|
|
171
|
+
]);
|
|
172
|
+
export const generationOutputStatusSchema = z.enum([
|
|
173
|
+
"pending",
|
|
174
|
+
"saving",
|
|
175
|
+
"ready",
|
|
176
|
+
"retrying",
|
|
177
|
+
"unavailable"
|
|
178
|
+
]);
|
|
179
|
+
export const generationAttachmentStatusSchema = z.enum([
|
|
180
|
+
"pending",
|
|
181
|
+
"attached",
|
|
182
|
+
"superseded",
|
|
183
|
+
"target_deleted",
|
|
184
|
+
"retrying"
|
|
185
|
+
]);
|
|
186
|
+
/** Who asked for the generation; every field the row carries back. */
|
|
187
|
+
export const generationOriginSchema = z.object({
|
|
188
|
+
surface: generationSurfaceSchema,
|
|
189
|
+
thread_id: z.string().nullable().optional(),
|
|
190
|
+
tool_call_id: z.string().nullable().optional(),
|
|
191
|
+
job_id: z.string().nullable().optional(),
|
|
192
|
+
node_id: z.string().nullable().optional(),
|
|
193
|
+
/**
|
|
194
|
+
* The RPC request the client correlates the reply on, for the `rpc` surface.
|
|
195
|
+
*
|
|
196
|
+
* A `generate_media` reply is an `rpc_response` carrying no `job_id` and no
|
|
197
|
+
* `thread_id`, so it is written to the socket that asked and dropped if that
|
|
198
|
+
* socket has gone — a browser reload loses it. Naming the request id here
|
|
199
|
+
* puts it on the row beside the outcome, so a client that reconnects can ask
|
|
200
|
+
* what became of the request it persisted instead of re-subscribing to an id
|
|
201
|
+
* whose reply was already delivered to a dead socket.
|
|
202
|
+
*/
|
|
203
|
+
request_id: z.string().nullable().optional()
|
|
204
|
+
});
|
|
205
|
+
/**
|
|
206
|
+
* What the provider said about the call: its own request id, and its own
|
|
207
|
+
* charge when it states one. A stated charge wins over the catalog estimate.
|
|
208
|
+
*/
|
|
209
|
+
export const generationReceiptSchema = z.object({
|
|
210
|
+
provider_request_id: z.string().nullable().optional(),
|
|
211
|
+
cost: z
|
|
212
|
+
.object({
|
|
213
|
+
amount: z.number(),
|
|
214
|
+
currency: z.string().nullable().optional(),
|
|
215
|
+
billing_unit: z.string().nullable().optional(),
|
|
216
|
+
quantity: z.number().nullable().optional(),
|
|
217
|
+
unit_price: z.number().nullable().optional()
|
|
218
|
+
})
|
|
219
|
+
.nullable()
|
|
220
|
+
.optional()
|
|
221
|
+
});
|
|
222
|
+
export const providerCostSchema = z.object({
|
|
223
|
+
provider: z.string(),
|
|
224
|
+
amount: z.number(),
|
|
225
|
+
unit: z.string(),
|
|
226
|
+
/** Provider model / endpoint the charge applies to (e.g. a FAL endpoint id). */
|
|
227
|
+
model: z.string().nullable().optional(),
|
|
228
|
+
/** Billing unit the provider prices by (e.g. "megapixels", "seconds", "images"). */
|
|
229
|
+
billing_unit: z.string().nullable().optional(),
|
|
230
|
+
/** Number of billing units consumed. */
|
|
231
|
+
quantity: z.number().nullable().optional(),
|
|
232
|
+
/** Price per billing unit, in `unit`/currency terms. */
|
|
233
|
+
unit_price: z.number().nullable().optional(),
|
|
234
|
+
/** ISO 4217 currency of `amount`/`unit_price` (e.g. "USD"). */
|
|
235
|
+
currency: z.string().nullable().optional(),
|
|
236
|
+
/**
|
|
237
|
+
* Token counts behind a token-billed charge. A model call reports these so
|
|
238
|
+
* the ledger row is auditable the same way a chat turn's row is; a
|
|
239
|
+
* per-output generation (FAL, kie) leaves them unset.
|
|
240
|
+
*/
|
|
241
|
+
input_tokens: z.number().nullable().optional(),
|
|
242
|
+
output_tokens: z.number().nullable().optional(),
|
|
243
|
+
cached_tokens: z.number().nullable().optional(),
|
|
244
|
+
/**
|
|
245
|
+
* Provider-side request identifier (e.g. a FAL queue request id). Lets the
|
|
246
|
+
* runner reconcile the initial estimate against the provider's actual billed
|
|
247
|
+
* cost after the fact. `amount` is an estimate until reconciled.
|
|
248
|
+
*/
|
|
249
|
+
provider_request_id: z.string().nullable().optional()
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
252
|
+
* Machine-readable companion to `node_update.error`. Lets a surface act on a
|
|
253
|
+
* failure — reopen provider onboarding on the offending key, say — without
|
|
254
|
+
* matching the prose the provider layer wrote.
|
|
255
|
+
*/
|
|
256
|
+
export const nodeErrorDetailSchema = z.object({
|
|
257
|
+
/** `provider_auth`: the provider refused the credential (401/403). */
|
|
258
|
+
code: z.string(),
|
|
259
|
+
/** Provider id as the runtime knows it (e.g. `openai`). */
|
|
260
|
+
provider: z.string().nullable().optional(),
|
|
261
|
+
/** Secret key holding that provider's credential (e.g. `OPENAI_API_KEY`). */
|
|
262
|
+
secret_key: z.string().nullable().optional()
|
|
263
|
+
});
|
|
264
|
+
export const nodeUpdateSchema = z.object({
|
|
265
|
+
type: z.literal("node_update"),
|
|
266
|
+
node_id: z.string(),
|
|
267
|
+
node_name: z.string(),
|
|
268
|
+
node_type: z.string(),
|
|
269
|
+
status: z.string(),
|
|
270
|
+
error: z.string().nullable().optional(),
|
|
271
|
+
/** Structured cause behind `error`, when the failure has one. */
|
|
272
|
+
error_detail: nodeErrorDetailSchema.nullable().optional(),
|
|
273
|
+
result: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
274
|
+
properties: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
275
|
+
/** Actual provider charge for the last completed run (when reported by the node). */
|
|
276
|
+
provider_cost: providerCostSchema.nullable().optional(),
|
|
277
|
+
workflow_id: z.string().nullable().optional(),
|
|
278
|
+
/**
|
|
279
|
+
* Run identity. Stamped downstream by the relay (the unified websocket runner
|
|
280
|
+
* and the browser runner), not by the kernel actor, so it is optional on the
|
|
281
|
+
* wire. Consumers that can see more than one run at a time — mini apps, a
|
|
282
|
+
* second tab, the editor running the same workflow — key off this to keep
|
|
283
|
+
* runs from contaminating each other.
|
|
284
|
+
*/
|
|
285
|
+
job_id: z.string().nullable().optional()
|
|
286
|
+
});
|
|
287
|
+
/**
|
|
288
|
+
* A generator committed one complete artifact (one `process()` result, or one
|
|
289
|
+
* `genProcess` stream-end). Authoritative variant carrier — never suppressed.
|
|
290
|
+
*
|
|
291
|
+
* The kernel actor emits a BARE event: `node_id`, `node_name`, `node_type`,
|
|
292
|
+
* `outputs`. `job_id` and `index` are stamped DOWNSTREAM by the relay (the
|
|
293
|
+
* unified websocket runner / browser runner), so both are optional on the wire
|
|
294
|
+
* — see the generation-events RFC §4.2 / §5 / Decision 8.
|
|
295
|
+
*/
|
|
296
|
+
export const generationCompleteSchema = z.object({
|
|
297
|
+
type: z.literal("generation_complete"),
|
|
298
|
+
node_id: z.string(),
|
|
299
|
+
node_name: z.string(),
|
|
300
|
+
node_type: z.string(),
|
|
301
|
+
/**
|
|
302
|
+
* k-th committed generation of this node in this run. Stamped downstream by
|
|
303
|
+
* the relay (DB ordering on the server, arrival order in the browser), absent
|
|
304
|
+
* on the bare actor emit.
|
|
305
|
+
*/
|
|
306
|
+
index: z.number().optional(),
|
|
307
|
+
/** The complete result dict for this artifact (same shape as a process() return). */
|
|
308
|
+
outputs: z.record(z.string(), z.unknown()),
|
|
309
|
+
/**
|
|
310
|
+
* Scalar input properties resolved for this run — declared props, user-typed
|
|
311
|
+
* dynamic props, and edge inputs, filtered to strings/numbers/booleans. The
|
|
312
|
+
* actor stamps these so the relay can persist generation params (notably the
|
|
313
|
+
* `prompt` that produced an image) into auto-saved asset metadata. Absent when
|
|
314
|
+
* the node has no scalar inputs.
|
|
315
|
+
*/
|
|
316
|
+
properties: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
317
|
+
/** Stamped downstream by the runner relay, NOT by the actor. */
|
|
318
|
+
job_id: z.string().nullable().optional(),
|
|
319
|
+
workflow_id: z.string().nullable().optional()
|
|
320
|
+
});
|
|
321
|
+
export const nodeProgressSchema = z.object({
|
|
322
|
+
type: z.literal("node_progress"),
|
|
323
|
+
node_id: z.string(),
|
|
324
|
+
progress: z.number(),
|
|
325
|
+
total: z.number(),
|
|
326
|
+
chunk: z.string().optional(),
|
|
327
|
+
workflow_id: z.string().nullable().optional(),
|
|
328
|
+
/** Run identity, stamped downstream by the relay. See {@link NodeUpdate.job_id}. */
|
|
329
|
+
job_id: z.string().nullable().optional()
|
|
330
|
+
});
|
|
331
|
+
export const edgeUpdateSchema = z.object({
|
|
332
|
+
type: z.literal("edge_update"),
|
|
333
|
+
// Both ids are stamped by the unified websocket runner if absent. The kernel
|
|
334
|
+
// emits `job_id` (the run id); `workflow_id` is backfilled from the active
|
|
335
|
+
// run. Edge animations are scoped per run, so consumers key off `job_id`.
|
|
336
|
+
workflow_id: z.string().nullable().optional(),
|
|
337
|
+
job_id: z.string().nullable().optional(),
|
|
338
|
+
edge_id: z.string(),
|
|
339
|
+
status: z.string(),
|
|
340
|
+
counter: z.number().nullable().optional()
|
|
341
|
+
});
|
|
342
|
+
export const outputUpdateSchema = z.object({
|
|
343
|
+
type: z.literal("output_update"),
|
|
344
|
+
node_id: z.string(),
|
|
345
|
+
node_name: z.string(),
|
|
346
|
+
output_name: z.string(),
|
|
347
|
+
value: z.unknown(),
|
|
348
|
+
output_type: z.string(),
|
|
349
|
+
metadata: z.record(z.string(), z.unknown()),
|
|
350
|
+
/**
|
|
351
|
+
* NEW. "append" = `value` is a chunk to concatenate onto the live display
|
|
352
|
+
* buffer; "replace" = `value` is a whole snapshot that overwrites it. Absent
|
|
353
|
+
* ⇒ treated as "append" (today's behavior) for back-compat.
|
|
354
|
+
*/
|
|
355
|
+
disposition: z.enum(["append", "replace"]).optional(),
|
|
356
|
+
/** NEW (optional). Marks the final chunk of an append stream. */
|
|
357
|
+
done: z.boolean().optional(),
|
|
358
|
+
workflow_id: z.string().nullable().optional(),
|
|
359
|
+
/** Run identity, stamped downstream by the relay. See {@link NodeUpdate.job_id}. */
|
|
360
|
+
job_id: z.string().nullable().optional()
|
|
361
|
+
});
|
|
362
|
+
export const saveUpdateSchema = z.object({
|
|
363
|
+
type: z.literal("save_update"),
|
|
364
|
+
node_id: z.string(),
|
|
365
|
+
name: z.string(),
|
|
366
|
+
value: z.unknown(),
|
|
367
|
+
output_type: z.string(),
|
|
368
|
+
metadata: z.record(z.string(), z.unknown())
|
|
369
|
+
});
|
|
370
|
+
// `binary: Uint8Array` needs `z.instanceof`, which Zod infers exactly as
|
|
371
|
+
// `Uint8Array` — plain `z.infer` is fine here, no hand-written type needed.
|
|
372
|
+
export const binaryUpdateSchema = z.object({
|
|
373
|
+
type: z.literal("binary_update"),
|
|
374
|
+
node_id: z.string(),
|
|
375
|
+
output_name: z.string(),
|
|
376
|
+
binary: z.instanceof(Uint8Array)
|
|
377
|
+
});
|
|
378
|
+
export const logUpdateSchema = z.object({
|
|
379
|
+
type: z.literal("log_update"),
|
|
380
|
+
node_id: z.string(),
|
|
381
|
+
node_name: z.string(),
|
|
382
|
+
content: z.string(),
|
|
383
|
+
severity: severitySchema,
|
|
384
|
+
workflow_id: z.string().nullable().optional()
|
|
385
|
+
});
|
|
386
|
+
export const notificationSchema = z.object({
|
|
387
|
+
type: z.literal("notification"),
|
|
388
|
+
node_id: z.string(),
|
|
389
|
+
content: z.string(),
|
|
390
|
+
severity: severitySchema,
|
|
391
|
+
workflow_id: z.string().nullable().optional()
|
|
392
|
+
});
|
|
393
|
+
export const errorMessageSchema = z.object({
|
|
394
|
+
type: z.literal("error"),
|
|
395
|
+
message: z.string(),
|
|
396
|
+
thread_id: z.string().nullable().optional(),
|
|
397
|
+
workflow_id: z.string().nullable().optional()
|
|
398
|
+
});
|
|
399
|
+
export const toolCallUpdateSchema = z.object({
|
|
400
|
+
type: z.literal("tool_call_update"),
|
|
401
|
+
node_id: z.string().nullable().optional(),
|
|
402
|
+
thread_id: z.string().nullable().optional(),
|
|
403
|
+
workflow_id: z.string().nullable().optional(),
|
|
404
|
+
tool_call_id: z.string().nullable().optional(),
|
|
405
|
+
name: z.string(),
|
|
406
|
+
args: z.record(z.string(), z.unknown()),
|
|
407
|
+
message: z.string().nullable().optional(),
|
|
408
|
+
step_id: z.string().nullable().optional(),
|
|
409
|
+
agent_execution_id: z.string().nullable().optional(),
|
|
410
|
+
/**
|
|
411
|
+
* The tool_call_id of an enclosing `run_subtask` call, if this event was
|
|
412
|
+
* emitted from inside a subtask. Null/undefined at the root level. Used by
|
|
413
|
+
* the renderer to nest tool-call cards.
|
|
414
|
+
*/
|
|
415
|
+
parent_tool_call_id: z.string().nullable().optional(),
|
|
416
|
+
/**
|
|
417
|
+
* Recursion depth: 0 at the chat root, 1 inside a top-level run_subtask, etc.
|
|
418
|
+
* Optional — renderers that don't care can ignore it.
|
|
419
|
+
*/
|
|
420
|
+
subtask_depth: z.number().nullable().optional()
|
|
421
|
+
});
|
|
422
|
+
export const toolResultUpdateSchema = z.object({
|
|
423
|
+
type: z.literal("tool_result_update"),
|
|
424
|
+
node_id: z.string(),
|
|
425
|
+
thread_id: z.string().nullable().optional(),
|
|
426
|
+
workflow_id: z.string().nullable().optional(),
|
|
427
|
+
result: z.record(z.string(), z.unknown()),
|
|
428
|
+
tool_call_id: z.string().nullable().optional(),
|
|
429
|
+
name: z.string().nullable().optional(),
|
|
430
|
+
is_error: z.boolean().optional(),
|
|
431
|
+
parent_tool_call_id: z.string().nullable().optional(),
|
|
432
|
+
subtask_depth: z.number().nullable().optional()
|
|
433
|
+
});
|
|
434
|
+
export const taskUpdateSchema = z.object({
|
|
435
|
+
type: z.literal("task_update"),
|
|
436
|
+
node_id: z.string().nullable().optional(),
|
|
437
|
+
thread_id: z.string().nullable().optional(),
|
|
438
|
+
workflow_id: z.string().nullable().optional(),
|
|
439
|
+
task: taskRefSchema,
|
|
440
|
+
step: stepRefSchema.nullable().optional(),
|
|
441
|
+
event: taskUpdateEventSchema
|
|
442
|
+
});
|
|
443
|
+
export const stepResultSchema = z.object({
|
|
444
|
+
type: z.literal("step_result"),
|
|
445
|
+
step: stepRefSchema,
|
|
446
|
+
result: z.unknown(),
|
|
447
|
+
error: z.string().nullable().optional(),
|
|
448
|
+
is_task_result: z.boolean().optional(),
|
|
449
|
+
thread_id: z.string().nullable().optional(),
|
|
450
|
+
workflow_id: z.string().nullable().optional()
|
|
451
|
+
});
|
|
452
|
+
export const planningUpdateSchema = z.object({
|
|
453
|
+
type: z.literal("planning_update"),
|
|
454
|
+
node_id: z.string().nullable().optional(),
|
|
455
|
+
thread_id: z.string().nullable().optional(),
|
|
456
|
+
workflow_id: z.string().nullable().optional(),
|
|
457
|
+
phase: z.string(),
|
|
458
|
+
status: z.string(),
|
|
459
|
+
content: z.string().nullable().optional()
|
|
460
|
+
});
|
|
461
|
+
export const chunkSchema = z.object({
|
|
462
|
+
type: z.literal("chunk"),
|
|
463
|
+
node_id: z.string().nullable().optional(),
|
|
464
|
+
thread_id: z.string().nullable().optional(),
|
|
465
|
+
workflow_id: z.string().nullable().optional(),
|
|
466
|
+
/**
|
|
467
|
+
* Run identity, stamped downstream by the relay for workflow-sourced chunks.
|
|
468
|
+
* Absent on chat chunks, which are scoped by `thread_id` instead.
|
|
469
|
+
* See {@link NodeUpdate.job_id}.
|
|
470
|
+
*/
|
|
471
|
+
job_id: z.string().nullable().optional(),
|
|
472
|
+
content_type: contentTypeSchema.optional(),
|
|
473
|
+
/**
|
|
474
|
+
* Text chunks and externally-sourced audio carry a string (base64 for
|
|
475
|
+
* binary payloads). In-process audio/CV chunks carry their samples as a
|
|
476
|
+
* native interleaved `Float32Array` — no per-hop encode/decode. The
|
|
477
|
+
* websocket transport encodes native samples to base64 (`encoding:
|
|
478
|
+
* "f32le"`) at the wire boundary; worker postMessage structured-clones
|
|
479
|
+
* them natively.
|
|
480
|
+
*/
|
|
481
|
+
content: z.union([z.string(), z.instanceof(Float32Array)]),
|
|
482
|
+
content_metadata: z.record(z.string(), z.unknown()).optional(),
|
|
483
|
+
done: z.boolean().optional(),
|
|
484
|
+
thinking: z.boolean().optional(),
|
|
485
|
+
/**
|
|
486
|
+
* The tool_call_id of an enclosing `run_subtask` call when this chunk was
|
|
487
|
+
* emitted from inside a subtask. Null/undefined at the root.
|
|
488
|
+
*/
|
|
489
|
+
parent_tool_call_id: z.string().nullable().optional(),
|
|
490
|
+
/** Recursion depth: 0 at the chat root, 1 inside run_subtask, etc. */
|
|
491
|
+
subtask_depth: z.number().nullable().optional()
|
|
492
|
+
});
|
|
493
|
+
/**
|
|
494
|
+
* Opaque, provider-agnostic continuation token for resuming an upstream
|
|
495
|
+
* conversation session across turns. Persisted on the ASSISTANT message that
|
|
496
|
+
* concluded the turn (it records the state *after* this turn). On the next turn
|
|
497
|
+
* a provider that supports server/SDK-side sessions resumes from this token and
|
|
498
|
+
* sends only the new user delta instead of replaying the whole transcript;
|
|
499
|
+
* stateless providers ignore it.
|
|
500
|
+
*
|
|
501
|
+
* Provider-agnostic by design. For the Claude Agent SDK, `token` is the SDK
|
|
502
|
+
* `session_id`. An OpenAI Responses provider reuses this exact shape: store the
|
|
503
|
+
* Responses `previous_response_id` as `token`, send the request with
|
|
504
|
+
* `store: true`, then on each subsequent turn pass `previous_response_id =
|
|
505
|
+
* token` and submit only the delta — reading and writing the token on the same
|
|
506
|
+
* `provider_session` message column. The semantics are identical and
|
|
507
|
+
* best-effort: a token may have expired or been pruned (Responses state lapses
|
|
508
|
+
* after ~30 days; the Agent SDK's session JSONL can be deleted), so a failed
|
|
509
|
+
* resume must fall back to a fresh session rather than erroring.
|
|
510
|
+
*/
|
|
511
|
+
export const providerSessionSchema = z.object({
|
|
512
|
+
/** Provider that owns the token (e.g. `PROVIDER_IDS.CLAUDE_AGENT_SDK`). */
|
|
513
|
+
providerId: z.string(),
|
|
514
|
+
/** Model the session was created with; a mismatch forces a fresh session. */
|
|
515
|
+
model: z.string(),
|
|
516
|
+
/**
|
|
517
|
+
* The opaque continuation token: the Agent SDK `session_id` here;
|
|
518
|
+
* `previous_response_id` for an OpenAI Responses provider.
|
|
519
|
+
*/
|
|
520
|
+
token: z.string(),
|
|
521
|
+
/**
|
|
522
|
+
* Count of conversation messages already absorbed by this session — the
|
|
523
|
+
* resume cut point. The next turn sends only `messages.slice(checkpoint)`.
|
|
524
|
+
*/
|
|
525
|
+
checkpoint: z.number(),
|
|
526
|
+
/** Optional hash of the system prompt; a mismatch invalidates the session. */
|
|
527
|
+
systemHash: z.string().optional()
|
|
528
|
+
});
|
|
529
|
+
export const todoStatusSchema = z.enum(["pending", "in_progress", "completed"]);
|
|
530
|
+
export const todoItemSchema = z.object({
|
|
531
|
+
content: z.string(),
|
|
532
|
+
status: todoStatusSchema
|
|
533
|
+
});
|
|
534
|
+
export const todoUpdateSchema = z.object({
|
|
535
|
+
type: z.literal("todo_update"),
|
|
536
|
+
thread_id: z.string().nullable().optional(),
|
|
537
|
+
workflow_id: z.string().nullable().optional(),
|
|
538
|
+
node_id: z.string().nullable().optional(),
|
|
539
|
+
todos: z.array(todoItemSchema)
|
|
540
|
+
});
|
|
541
|
+
/**
|
|
542
|
+
* `Prediction` mixes fully-typed known fields with an index signature for
|
|
543
|
+
* provider-specific extras. `.catchall(z.unknown())` matches that shape.
|
|
544
|
+
*/
|
|
545
|
+
export const predictionSchema = z
|
|
546
|
+
.object({
|
|
547
|
+
type: z.literal("prediction"),
|
|
548
|
+
id: z.string(),
|
|
549
|
+
user_id: z.string(),
|
|
550
|
+
node_id: z.string(),
|
|
551
|
+
workflow_id: z.string().nullable().optional(),
|
|
552
|
+
provider: z.string().nullable().optional(),
|
|
553
|
+
model: z.string().nullable().optional(),
|
|
554
|
+
capability: z.string().nullable().optional(),
|
|
555
|
+
version: z.string().nullable().optional(),
|
|
556
|
+
node_type: z.string().nullable().optional(),
|
|
557
|
+
status: generationStatusSchema,
|
|
558
|
+
submission_status: generationSubmissionStatusSchema.optional(),
|
|
559
|
+
provider_status: generationProviderStatusSchema.optional(),
|
|
560
|
+
output_status: generationOutputStatusSchema.optional(),
|
|
561
|
+
attachment_status: generationAttachmentStatusSchema.optional(),
|
|
562
|
+
params: z.record(z.string(), z.unknown()).optional(),
|
|
563
|
+
data: z.unknown().nullable().optional(),
|
|
564
|
+
cost: z.number().nullable().optional(),
|
|
565
|
+
logs: z.string().nullable().optional(),
|
|
566
|
+
error: z.string().nullable().optional(),
|
|
567
|
+
duration: z.number().nullable().optional(),
|
|
568
|
+
created_at: z.string().nullable().optional(),
|
|
569
|
+
started_at: z.string().nullable().optional(),
|
|
570
|
+
completed_at: z.string().nullable().optional(),
|
|
571
|
+
/** Who asked. Present on every message the generation seam emits. */
|
|
572
|
+
origin: generationOriginSchema.optional(),
|
|
573
|
+
/** Assets the seam persisted; on `completed` only. */
|
|
574
|
+
asset_ids: z.array(z.string()).optional(),
|
|
575
|
+
/** The provider's own request id and charge, when it stated them. */
|
|
576
|
+
receipt: generationReceiptSchema.nullable().optional()
|
|
577
|
+
})
|
|
578
|
+
.catchall(z.unknown());
|
|
579
|
+
export const llmCallUpdateSchema = z.object({
|
|
580
|
+
type: z.literal("llm_call"),
|
|
581
|
+
node_id: z.string(),
|
|
582
|
+
node_name: z.string().nullable().optional(),
|
|
583
|
+
provider: z.string(),
|
|
584
|
+
model: z.string(),
|
|
585
|
+
messages: z.array(z.object({ role: z.string(), content: z.unknown() })),
|
|
586
|
+
response: z.unknown(),
|
|
587
|
+
tool_calls: z
|
|
588
|
+
.array(z.object({ id: z.string(), name: z.string(), args: z.unknown() }))
|
|
589
|
+
.nullable()
|
|
590
|
+
.optional(),
|
|
591
|
+
tokens_input: z.number().nullable().optional(),
|
|
592
|
+
tokens_output: z.number().nullable().optional(),
|
|
593
|
+
cost: z.number().nullable().optional(),
|
|
594
|
+
duration_ms: z.number(),
|
|
595
|
+
error: z.string().nullable().optional(),
|
|
596
|
+
timestamp: z.string()
|
|
597
|
+
});
|
|
598
|
+
/**
|
|
599
|
+
* One provider call that failed, with everything a maintainer needs to
|
|
600
|
+
* reproduce it. Emitted once per failure from `BaseProvider`'s central failure
|
|
601
|
+
* paths, so chat, workflow nodes and the media surfaces all report the same
|
|
602
|
+
* record instead of each re-deriving it from the error prose.
|
|
603
|
+
*/
|
|
604
|
+
export const providerCallFailedSchema = z.object({
|
|
605
|
+
type: z.literal("provider_call_failed"),
|
|
606
|
+
/** Provider id as the runtime knows it (e.g. `openai`). */
|
|
607
|
+
provider: z.string(),
|
|
608
|
+
/** Model the call asked for, when it named one. */
|
|
609
|
+
model: z.string().nullable().optional(),
|
|
610
|
+
/** Provider method that threw (e.g. `generateMessages`, `textToImage`). */
|
|
611
|
+
operation: z.string(),
|
|
612
|
+
/**
|
|
613
|
+
* Failure class, derived once on the server: `auth`, `payment`,
|
|
614
|
+
* `not_found`, `rate_limit`, `timeout`, `server`, `network`, `client` or
|
|
615
|
+
* `unknown`. Surfaces branch on this instead of matching prose.
|
|
616
|
+
*/
|
|
617
|
+
kind: z.string(),
|
|
618
|
+
/** HTTP status, when the failure carried one. */
|
|
619
|
+
status: z.number().nullable().optional(),
|
|
620
|
+
/** Error message as the provider wrote it, plus NodeTool's remedy hint. */
|
|
621
|
+
message: z.string(),
|
|
622
|
+
/** Error class name, when the provider threw a typed error. */
|
|
623
|
+
error_name: z.string().nullable().optional(),
|
|
624
|
+
/** Provider-side request id, when the error carried one. */
|
|
625
|
+
request_id: z.string().nullable().optional(),
|
|
626
|
+
/** Milliseconds from the call starting to the throw. */
|
|
627
|
+
duration_ms: z.number().nullable().optional(),
|
|
628
|
+
/** `wire` when the payload below is the body the provider sent. */
|
|
629
|
+
request_source: z.string().nullable().optional(),
|
|
630
|
+
/** The request, redacted and size-bounded. Secrets never reach this. */
|
|
631
|
+
request: z.unknown().nullable().optional(),
|
|
632
|
+
/**
|
|
633
|
+
* The run the call belonged to. Stamped downstream by the relay, not by the
|
|
634
|
+
* provider — which knows nothing about workflows.
|
|
635
|
+
*/
|
|
636
|
+
workflow_id: z.string().nullable().optional(),
|
|
637
|
+
job_id: z.string().nullable().optional(),
|
|
638
|
+
timestamp: z.string()
|
|
639
|
+
});
|
|
640
|
+
// ---------------------------------------------------------------------------
|
|
641
|
+
// Discriminated union – matches Python ProcessingMessage
|
|
642
|
+
// ---------------------------------------------------------------------------
|
|
643
|
+
/**
|
|
644
|
+
* Single runtime validator for the whole `ProcessingMessage` union,
|
|
645
|
+
* discriminated on `type`. `packages/protocol`'s build converts this to
|
|
646
|
+
* JSON Schema (see `scripts/generate-processing-messages-schema.ts`) so
|
|
647
|
+
* non-TypeScript consumers can validate the same shapes.
|
|
648
|
+
*/
|
|
649
|
+
export const processingMessageSchema = z.discriminatedUnion("type", [
|
|
650
|
+
jobUpdateSchema,
|
|
651
|
+
nodeUpdateSchema,
|
|
652
|
+
generationCompleteSchema,
|
|
653
|
+
nodeProgressSchema,
|
|
654
|
+
edgeUpdateSchema,
|
|
655
|
+
outputUpdateSchema,
|
|
656
|
+
saveUpdateSchema,
|
|
657
|
+
binaryUpdateSchema,
|
|
658
|
+
logUpdateSchema,
|
|
659
|
+
notificationSchema,
|
|
660
|
+
errorMessageSchema,
|
|
661
|
+
toolCallUpdateSchema,
|
|
662
|
+
toolResultUpdateSchema,
|
|
663
|
+
taskUpdateSchema,
|
|
664
|
+
stepResultSchema,
|
|
665
|
+
planningUpdateSchema,
|
|
666
|
+
chunkSchema,
|
|
667
|
+
predictionSchema,
|
|
668
|
+
llmCallUpdateSchema,
|
|
669
|
+
providerCallFailedSchema,
|
|
670
|
+
todoUpdateSchema,
|
|
671
|
+
supervisorEscalationSchema,
|
|
672
|
+
supervisorDecisionSchema
|
|
673
|
+
]);
|
|
674
|
+
// ---------------------------------------------------------------------------
|
|
675
|
+
// Per-type schema lookup + type guards
|
|
676
|
+
// ---------------------------------------------------------------------------
|
|
677
|
+
/** Every per-type schema, keyed by its `type` discriminator. */
|
|
678
|
+
export const processingMessageSchemas = {
|
|
679
|
+
job_update: jobUpdateSchema,
|
|
680
|
+
node_update: nodeUpdateSchema,
|
|
681
|
+
generation_complete: generationCompleteSchema,
|
|
682
|
+
node_progress: nodeProgressSchema,
|
|
683
|
+
edge_update: edgeUpdateSchema,
|
|
684
|
+
output_update: outputUpdateSchema,
|
|
685
|
+
save_update: saveUpdateSchema,
|
|
686
|
+
binary_update: binaryUpdateSchema,
|
|
687
|
+
log_update: logUpdateSchema,
|
|
688
|
+
notification: notificationSchema,
|
|
689
|
+
error: errorMessageSchema,
|
|
690
|
+
tool_call_update: toolCallUpdateSchema,
|
|
691
|
+
tool_result_update: toolResultUpdateSchema,
|
|
692
|
+
task_update: taskUpdateSchema,
|
|
693
|
+
step_result: stepResultSchema,
|
|
694
|
+
planning_update: planningUpdateSchema,
|
|
695
|
+
chunk: chunkSchema,
|
|
696
|
+
prediction: predictionSchema,
|
|
697
|
+
llm_call: llmCallUpdateSchema,
|
|
698
|
+
provider_call_failed: providerCallFailedSchema,
|
|
699
|
+
todo_update: todoUpdateSchema,
|
|
700
|
+
supervisor_escalation: supervisorEscalationSchema,
|
|
701
|
+
supervisor_decision: supervisorDecisionSchema
|
|
702
|
+
};
|
|
703
|
+
/**
|
|
704
|
+
* Cheap discriminant check shared by every `is*` guard below: narrows on
|
|
705
|
+
* `type` alone (no field validation) so guards stay usable in hot paths.
|
|
706
|
+
* Use `processingMessageSchemas[type].safeParse(value)` when a caller needs
|
|
707
|
+
* full structural validation instead of just narrowing an already-trusted
|
|
708
|
+
* `ProcessingMessage`.
|
|
709
|
+
*/
|
|
710
|
+
function hasType(value, type) {
|
|
711
|
+
return (typeof value === "object" &&
|
|
712
|
+
value !== null &&
|
|
713
|
+
value.type === type);
|
|
714
|
+
}
|
|
715
|
+
export function isJobUpdate(value) {
|
|
716
|
+
return hasType(value, "job_update");
|
|
717
|
+
}
|
|
718
|
+
export function isNodeUpdate(value) {
|
|
719
|
+
return hasType(value, "node_update");
|
|
720
|
+
}
|
|
721
|
+
export function isOutputUpdate(value) {
|
|
722
|
+
return hasType(value, "output_update");
|
|
723
|
+
}
|
|
724
|
+
export function isChunk(value) {
|
|
725
|
+
return hasType(value, "chunk");
|
|
726
|
+
}
|
|
727
|
+
export function isProviderCallFailed(value) {
|
|
728
|
+
return hasType(value, "provider_call_failed");
|
|
729
|
+
}
|
|
730
|
+
/** True when `value` is a structurally valid `ProcessingMessage`. */
|
|
731
|
+
export function isProcessingMessage(value) {
|
|
732
|
+
return processingMessageSchema.safeParse(value).success;
|
|
733
|
+
}
|
|
27
734
|
// ---------------------------------------------------------------------------
|
|
28
735
|
// Utility functions
|
|
29
736
|
// ---------------------------------------------------------------------------
|
|
@@ -33,13 +740,13 @@ export var TaskUpdateEvent;
|
|
|
33
740
|
* Mirrors Python's sanitize_memory_uris_for_client().
|
|
34
741
|
*/
|
|
35
742
|
export function sanitizeMemoryUris(value) {
|
|
36
|
-
if (
|
|
743
|
+
if (isString(value)) {
|
|
37
744
|
return (value.startsWith("memory://") ? "" : value);
|
|
38
745
|
}
|
|
39
746
|
if (Array.isArray(value)) {
|
|
40
747
|
return value.map(sanitizeMemoryUris);
|
|
41
748
|
}
|
|
42
|
-
if (value
|
|
749
|
+
if (isRecord(value)) {
|
|
43
750
|
const result = {};
|
|
44
751
|
for (const [k, v] of Object.entries(value)) {
|
|
45
752
|
result[k] = sanitizeMemoryUris(v);
|
|
@@ -48,24 +755,4 @@ export function sanitizeMemoryUris(value) {
|
|
|
48
755
|
}
|
|
49
756
|
return value;
|
|
50
757
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Encode a BinaryUpdate into a single Buffer/Uint8Array suitable for
|
|
53
|
-
* binary WebSocket transmission.
|
|
54
|
-
* Format: JSON header (node_id + output_name) + null byte + raw binary.
|
|
55
|
-
* Mirrors Python's BinaryUpdate.encode().
|
|
56
|
-
*/
|
|
57
|
-
export function encodeBinaryUpdate(update) {
|
|
58
|
-
const header = JSON.stringify({
|
|
59
|
-
type: update.type,
|
|
60
|
-
node_id: update.node_id,
|
|
61
|
-
output_name: update.output_name
|
|
62
|
-
});
|
|
63
|
-
const headerBytes = new TextEncoder().encode(header);
|
|
64
|
-
const separator = new Uint8Array([0]); // null byte separator
|
|
65
|
-
const result = new Uint8Array(headerBytes.length + 1 + update.binary.length);
|
|
66
|
-
result.set(headerBytes, 0);
|
|
67
|
-
result.set(separator, headerBytes.length);
|
|
68
|
-
result.set(update.binary, headerBytes.length + 1);
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
758
|
//# sourceMappingURL=messages.js.map
|