@nodetool-ai/protocol 0.7.0-rc.22 → 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
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/protocol — Script authoring rules
|
|
3
|
+
*
|
|
4
|
+
* What the script writer asks a model for, and how its answer becomes cast and
|
|
5
|
+
* lines: the formats, the pace table, the system prompt, the prompt shaping,
|
|
6
|
+
* the JSON schema the structured call is forced into, and the parse that mints
|
|
7
|
+
* or retains line ids.
|
|
8
|
+
*
|
|
9
|
+
* Imported words take a different path on purpose (PRD § 9.2, criterion 4).
|
|
10
|
+
* {@link splitImportedText} cuts pasted or extracted text into lines with no
|
|
11
|
+
* model in the loop, and the attribution call is handed a schema with no field
|
|
12
|
+
* to write text into — {@link applyAttribution} reads every line's text from
|
|
13
|
+
* the split, never from the answer. A model that ignores the schema and returns
|
|
14
|
+
* its own prose therefore cannot rewrite the creator's words; the worst it can
|
|
15
|
+
* do is misattribute them.
|
|
16
|
+
*
|
|
17
|
+
* Pure, and shared: the browser's `writeScript` and the headless `write_script`
|
|
18
|
+
* capability author through this, so a script written in the flow and one
|
|
19
|
+
* written by an agent are the same artifact.
|
|
20
|
+
*/
|
|
21
|
+
import { isRecord, isString } from "./predicates.js";
|
|
22
|
+
/** The five § 9.2 formats. Order is the order the cards are shown in. */
|
|
23
|
+
export const SCRIPT_FORMATS = [
|
|
24
|
+
{
|
|
25
|
+
id: "voiceover",
|
|
26
|
+
label: "Voiceover narration",
|
|
27
|
+
description: "One voice reads over picture.",
|
|
28
|
+
castShape: "narrator",
|
|
29
|
+
speakers: ["Narrator"],
|
|
30
|
+
sections: ["Open", "Body", "Close"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "dialogue",
|
|
34
|
+
label: "Dialogue",
|
|
35
|
+
description: "Two or more characters talk to each other.",
|
|
36
|
+
castShape: "characters",
|
|
37
|
+
speakers: ["Character A", "Character B"],
|
|
38
|
+
sections: ["Scene"]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "interview",
|
|
42
|
+
label: "Interview",
|
|
43
|
+
description: "A host asks, a guest answers.",
|
|
44
|
+
castShape: "host-and-guest",
|
|
45
|
+
speakers: ["Host", "Guest"],
|
|
46
|
+
sections: ["Intro", "Questions", "Outro"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "ad-read",
|
|
50
|
+
label: "Ad read",
|
|
51
|
+
description: "One voice sells something in a set time.",
|
|
52
|
+
castShape: "narrator",
|
|
53
|
+
speakers: ["Narrator"],
|
|
54
|
+
sections: ["Hook", "Pitch", "Call to action"]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "tutorial",
|
|
58
|
+
label: "Tutorial",
|
|
59
|
+
description: "One voice walks through the steps.",
|
|
60
|
+
castShape: "narrator",
|
|
61
|
+
speakers: ["Narrator"],
|
|
62
|
+
sections: ["Intro", "Steps", "Recap"]
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
export const scriptFormatById = (id) => SCRIPT_FORMATS.find((format) => format.id === id);
|
|
66
|
+
/** The lengths offered beside the format cards, in seconds (PRD § 9.2). */
|
|
67
|
+
export const SCRIPT_LENGTH_CHOICES = [30, 60, 120];
|
|
68
|
+
/**
|
|
69
|
+
* Words a minute per pace. The figures are ordinary spoken-delivery rates —
|
|
70
|
+
* audiobook, presenter, ad read — and they are what turns a word count into
|
|
71
|
+
* the seconds shown under the review's title and asked of the writer.
|
|
72
|
+
*/
|
|
73
|
+
export const PACE_WORDS_PER_MINUTE = {
|
|
74
|
+
slow: 110,
|
|
75
|
+
normal: 140,
|
|
76
|
+
fast: 170
|
|
77
|
+
};
|
|
78
|
+
/** Words in a stretch of text, counting a run of whitespace as one break. */
|
|
79
|
+
export const countScriptWords = (text) => {
|
|
80
|
+
const trimmed = text.trim();
|
|
81
|
+
return trimmed === "" ? 0 : trimmed.split(/\s+/).length;
|
|
82
|
+
};
|
|
83
|
+
/** How long `words` take to say at `pace`, in seconds. */
|
|
84
|
+
export const estimateSpokenSeconds = (words, pace = "normal") => (words / PACE_WORDS_PER_MINUTE[pace]) * 60;
|
|
85
|
+
/** How many words fit in `seconds` at `pace` — the writer's length target. */
|
|
86
|
+
export const wordsForSeconds = (seconds, pace = "normal") => Math.max(1, Math.round((seconds / 60) * PACE_WORDS_PER_MINUTE[pace]));
|
|
87
|
+
export const SCRIPT_TOOL_NAME = "script";
|
|
88
|
+
export const SCRIPT_TOOL_DESCRIPTION = "Submit the finished script: the cast, and the lines each of them speaks.";
|
|
89
|
+
export const SCRIPT_WRITER_SYSTEM_PROMPT = [
|
|
90
|
+
"You are a scriptwriter. Turn the user's brief into lines that will be read",
|
|
91
|
+
"aloud. Write only what is spoken: no camera notes, no stage description, no",
|
|
92
|
+
"markdown. Give every line to one speaker from the cast you return. Keep each",
|
|
93
|
+
"line to a single spoken thought, short enough to say in one breath. Use the",
|
|
94
|
+
"direction field for a performance note when one is needed, and leave it out",
|
|
95
|
+
"otherwise. Call the script tool exactly once."
|
|
96
|
+
].join(" ");
|
|
97
|
+
/** The brief, format, length and existing script as the prompt shows them. */
|
|
98
|
+
export function buildScriptWriterPrompt(input) {
|
|
99
|
+
const format = scriptFormatById(input.format);
|
|
100
|
+
const pace = input.pace ?? "normal";
|
|
101
|
+
const words = wordsForSeconds(input.lengthSeconds, pace);
|
|
102
|
+
const parts = [input.brief.trim()];
|
|
103
|
+
if (format) {
|
|
104
|
+
parts.push(`Format: ${format.label} — ${format.description} Cast: ${format.speakers.join(", ")}. Sections: ${format.sections.join(", ")}.`);
|
|
105
|
+
}
|
|
106
|
+
parts.push(`Length: about ${input.lengthSeconds} seconds at a ${pace} read, which is roughly ${words} words in total.`);
|
|
107
|
+
if (input.language) {
|
|
108
|
+
parts.push(`Write it in ${input.language}.`);
|
|
109
|
+
}
|
|
110
|
+
if (input.existing) {
|
|
111
|
+
const lines = [];
|
|
112
|
+
for (const section of input.existing.sections) {
|
|
113
|
+
lines.push(`## ${section.title}`);
|
|
114
|
+
for (const line of section.lines) {
|
|
115
|
+
const speaker = input.existing.cast.find((member) => member.id === line.speakerId);
|
|
116
|
+
lines.push(`[${line.id}] ${speaker?.name ?? "—"}: ${line.text}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
parts.push([
|
|
120
|
+
"Here is the script as it stands. Rewrite it against the brief above.",
|
|
121
|
+
"Every line you keep — even reworded — must come back with the id it",
|
|
122
|
+
"carries here, so its recording and its shot link survive. Use a new id",
|
|
123
|
+
"only for a line that did not exist.",
|
|
124
|
+
"",
|
|
125
|
+
...lines
|
|
126
|
+
].join("\n"));
|
|
127
|
+
}
|
|
128
|
+
return parts.join("\n\n");
|
|
129
|
+
}
|
|
130
|
+
/** Structured output: a cast, and sections of lines attributed to it. */
|
|
131
|
+
export function buildScriptSchema(options = {}) {
|
|
132
|
+
const id = {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: options.retainIds && options.retainIds.length > 0
|
|
135
|
+
? "The id this line already carries, when it is a line you kept. Omit for a new line."
|
|
136
|
+
: "Omit — ids are assigned for you."
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
type: "object",
|
|
140
|
+
properties: {
|
|
141
|
+
speakers: {
|
|
142
|
+
type: "array",
|
|
143
|
+
minItems: 1,
|
|
144
|
+
description: "Everyone who speaks, in the order they first speak.",
|
|
145
|
+
items: {
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: {
|
|
148
|
+
name: { type: "string", description: "How the speaker is named in the script." }
|
|
149
|
+
},
|
|
150
|
+
required: ["name"]
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
sections: {
|
|
154
|
+
type: "array",
|
|
155
|
+
minItems: 1,
|
|
156
|
+
items: {
|
|
157
|
+
type: "object",
|
|
158
|
+
properties: {
|
|
159
|
+
title: { type: "string", description: "What this part of the script is." },
|
|
160
|
+
lines: {
|
|
161
|
+
type: "array",
|
|
162
|
+
minItems: 1,
|
|
163
|
+
items: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
id,
|
|
167
|
+
speaker: {
|
|
168
|
+
type: "string",
|
|
169
|
+
description: "The name of the speaker who says this line."
|
|
170
|
+
},
|
|
171
|
+
text: {
|
|
172
|
+
type: "string",
|
|
173
|
+
description: "The spoken words, exactly as they are to be read."
|
|
174
|
+
},
|
|
175
|
+
direction: {
|
|
176
|
+
type: "string",
|
|
177
|
+
description: "Optional performance note, e.g. 'wry, unhurried'."
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
required: ["speaker", "text"]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
required: ["title", "lines"]
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
required: ["speakers", "sections"]
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/** Mints `${prefix}_1`, `${prefix}_2`, … so a parse is reproducible in a test. */
|
|
192
|
+
const counter = (prefix) => {
|
|
193
|
+
let n = 0;
|
|
194
|
+
return () => {
|
|
195
|
+
n += 1;
|
|
196
|
+
return `${prefix}_${n}`;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
const cleanText = (value) => isString(value) ? value.trim() : "";
|
|
200
|
+
/**
|
|
201
|
+
* The model's answer as cast and sections. Unknown speaker names become new
|
|
202
|
+
* cast members; a line naming no known speaker keeps the section's last
|
|
203
|
+
* speaker, because an unattributed line still has to be voiced by someone.
|
|
204
|
+
*/
|
|
205
|
+
export function parseWrittenScript(raw, options) {
|
|
206
|
+
const answer = isRecord(raw) ? raw : {};
|
|
207
|
+
const nextSpeakerId = counter(`${options.idPrefix}_spk`);
|
|
208
|
+
const nextSectionId = counter(`${options.idPrefix}_sec`);
|
|
209
|
+
const nextLineId = counter(`${options.idPrefix}_line`);
|
|
210
|
+
const retained = new Set(options.retainIds ?? []);
|
|
211
|
+
const usedIds = new Set();
|
|
212
|
+
const cast = [];
|
|
213
|
+
const held = new Map((options.existingCast ?? []).map((member) => [
|
|
214
|
+
member.name.trim().toLowerCase(),
|
|
215
|
+
member
|
|
216
|
+
]));
|
|
217
|
+
const byName = new Map();
|
|
218
|
+
const speakerFor = (name) => {
|
|
219
|
+
const key = name.trim().toLowerCase();
|
|
220
|
+
if (key === "")
|
|
221
|
+
return null;
|
|
222
|
+
const already = byName.get(key);
|
|
223
|
+
if (already)
|
|
224
|
+
return already;
|
|
225
|
+
const kept = held.get(key);
|
|
226
|
+
const created = kept
|
|
227
|
+
? { id: kept.id, name: kept.name }
|
|
228
|
+
: { id: nextSpeakerId(), name: name.trim() };
|
|
229
|
+
cast.push(created);
|
|
230
|
+
byName.set(key, created);
|
|
231
|
+
return created;
|
|
232
|
+
};
|
|
233
|
+
for (const entry of Array.isArray(answer["speakers"]) ? answer["speakers"] : []) {
|
|
234
|
+
if (isRecord(entry)) {
|
|
235
|
+
speakerFor(cleanText(entry["name"]));
|
|
236
|
+
}
|
|
237
|
+
else if (isString(entry)) {
|
|
238
|
+
speakerFor(entry);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const sections = [];
|
|
242
|
+
const rawSections = Array.isArray(answer["sections"]) ? answer["sections"] : [];
|
|
243
|
+
for (const rawSection of rawSections) {
|
|
244
|
+
if (!isRecord(rawSection))
|
|
245
|
+
continue;
|
|
246
|
+
const lines = [];
|
|
247
|
+
const rawLines = Array.isArray(rawSection["lines"]) ? rawSection["lines"] : [];
|
|
248
|
+
let lastSpeakerId = null;
|
|
249
|
+
for (const rawLine of rawLines) {
|
|
250
|
+
if (!isRecord(rawLine))
|
|
251
|
+
continue;
|
|
252
|
+
const text = cleanText(rawLine["text"]);
|
|
253
|
+
if (text === "")
|
|
254
|
+
continue;
|
|
255
|
+
const speaker = speakerFor(cleanText(rawLine["speaker"]));
|
|
256
|
+
if (speaker)
|
|
257
|
+
lastSpeakerId = speaker.id;
|
|
258
|
+
// An id is honoured only when the document already carries it and no
|
|
259
|
+
// earlier line in this answer claimed it, so a model that repeats one id
|
|
260
|
+
// cannot fold two lines onto the same take.
|
|
261
|
+
const claimed = cleanText(rawLine["id"]);
|
|
262
|
+
const id = claimed !== "" && retained.has(claimed) && !usedIds.has(claimed)
|
|
263
|
+
? claimed
|
|
264
|
+
: nextLineId();
|
|
265
|
+
usedIds.add(id);
|
|
266
|
+
const line = {
|
|
267
|
+
id,
|
|
268
|
+
speakerId: speaker?.id ?? lastSpeakerId,
|
|
269
|
+
text
|
|
270
|
+
};
|
|
271
|
+
const direction = cleanText(rawLine["direction"]);
|
|
272
|
+
if (direction !== "") {
|
|
273
|
+
line.direction = direction;
|
|
274
|
+
}
|
|
275
|
+
lines.push(line);
|
|
276
|
+
}
|
|
277
|
+
if (lines.length === 0)
|
|
278
|
+
continue;
|
|
279
|
+
sections.push({
|
|
280
|
+
id: nextSectionId(),
|
|
281
|
+
title: cleanText(rawSection["title"]) || `Section ${sections.length + 1}`,
|
|
282
|
+
lines
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return { cast, sections };
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The script a writer run falls back to when the provider answers with nothing
|
|
289
|
+
* usable — the brief itself, split into lines and given the format's first
|
|
290
|
+
* speaker. Deterministic, and the same rule the storyboard's Director applies.
|
|
291
|
+
*/
|
|
292
|
+
export function fallbackScript(input, options) {
|
|
293
|
+
const format = scriptFormatById(input.format);
|
|
294
|
+
const name = format?.speakers[0] ?? "Narrator";
|
|
295
|
+
const texts = splitImportedText(input.brief);
|
|
296
|
+
const nextLineId = counter(`${options.idPrefix}_line`);
|
|
297
|
+
const speaker = {
|
|
298
|
+
id: `${options.idPrefix}_spk_1`,
|
|
299
|
+
name
|
|
300
|
+
};
|
|
301
|
+
return {
|
|
302
|
+
cast: [speaker],
|
|
303
|
+
sections: [
|
|
304
|
+
{
|
|
305
|
+
id: `${options.idPrefix}_sec_1`,
|
|
306
|
+
title: format?.sections[0] ?? "Script",
|
|
307
|
+
lines: texts.map((text) => ({
|
|
308
|
+
id: nextLineId(),
|
|
309
|
+
speakerId: speaker.id,
|
|
310
|
+
text
|
|
311
|
+
}))
|
|
312
|
+
}
|
|
313
|
+
]
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
// ── Imported words ──────────────────────────────────────────────────────────
|
|
317
|
+
/**
|
|
318
|
+
* The longest a split line gets before sentence boundaries are used as well.
|
|
319
|
+
* A line is what one take records, so a whole pasted paragraph in one line
|
|
320
|
+
* would be one long take nobody can re-voice a part of.
|
|
321
|
+
*/
|
|
322
|
+
const MAX_LINE_CHARS = 240;
|
|
323
|
+
/** Split a run of text at sentence ends, keeping the punctuation. */
|
|
324
|
+
const sentences = (text) => {
|
|
325
|
+
const parts = text.match(/[^.!?…]+[.!?…]*\s*/g);
|
|
326
|
+
return (parts ?? [text]).map((part) => part.trim()).filter((part) => part !== "");
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Pasted, uploaded or extracted text as lines, with no model involved: blank
|
|
330
|
+
* lines separate blocks, newlines separate lines, and a line too long to say
|
|
331
|
+
* in one take is cut at its sentence ends. Only whitespace between words is
|
|
332
|
+
* dropped, so the words and their order come out of this exactly as they went
|
|
333
|
+
* in (PRD § 9.1, criterion 4).
|
|
334
|
+
*/
|
|
335
|
+
export function splitImportedText(text) {
|
|
336
|
+
const out = [];
|
|
337
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
338
|
+
const line = raw.trim();
|
|
339
|
+
if (line === "")
|
|
340
|
+
continue;
|
|
341
|
+
if (line.length <= MAX_LINE_CHARS) {
|
|
342
|
+
out.push(line);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
for (const sentence of sentences(line)) {
|
|
346
|
+
out.push(sentence);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
export const ATTRIBUTION_TOOL_NAME = "script_attribution";
|
|
352
|
+
export const ATTRIBUTION_TOOL_DESCRIPTION = "Say who speaks each numbered line, and how. The words themselves are final.";
|
|
353
|
+
export const ATTRIBUTION_SYSTEM_PROMPT = [
|
|
354
|
+
"You are casting a script that is already written. The lines are final: never",
|
|
355
|
+
"reword, merge, split, reorder or drop one. For every line you are given, by",
|
|
356
|
+
"its number, name the speaker who says it and, where it helps, a short",
|
|
357
|
+
"performance note. Return one entry per line, in order.",
|
|
358
|
+
"Call the attribution tool exactly once."
|
|
359
|
+
].join(" ");
|
|
360
|
+
/** The split lines as the attribution prompt shows them: numbered, verbatim. */
|
|
361
|
+
export function buildAttributionPrompt(lines, input) {
|
|
362
|
+
const format = scriptFormatById(input.format);
|
|
363
|
+
const head = [
|
|
364
|
+
input.brief.trim() === "" ? "" : `Context: ${input.brief.trim()}`,
|
|
365
|
+
format
|
|
366
|
+
? `Format: ${format.label}. Expected cast: ${format.speakers.join(", ")}.`
|
|
367
|
+
: ""
|
|
368
|
+
].filter((part) => part !== "");
|
|
369
|
+
return [
|
|
370
|
+
...head,
|
|
371
|
+
"Assign a speaker to every line below. Do not change a word of them.",
|
|
372
|
+
"",
|
|
373
|
+
...lines.map((line, index) => `${index + 1}. ${line}`)
|
|
374
|
+
].join("\n");
|
|
375
|
+
}
|
|
376
|
+
/** Structured output with nowhere to write the words (PRD § 9.2, D10). */
|
|
377
|
+
export function buildAttributionSchema(lineCount) {
|
|
378
|
+
return {
|
|
379
|
+
type: "object",
|
|
380
|
+
properties: {
|
|
381
|
+
speakers: {
|
|
382
|
+
type: "array",
|
|
383
|
+
minItems: 1,
|
|
384
|
+
items: {
|
|
385
|
+
type: "object",
|
|
386
|
+
properties: { name: { type: "string" } },
|
|
387
|
+
required: ["name"]
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
lines: {
|
|
391
|
+
type: "array",
|
|
392
|
+
minItems: lineCount,
|
|
393
|
+
maxItems: lineCount,
|
|
394
|
+
items: {
|
|
395
|
+
type: "object",
|
|
396
|
+
properties: {
|
|
397
|
+
number: {
|
|
398
|
+
type: "integer",
|
|
399
|
+
minimum: 1,
|
|
400
|
+
maximum: lineCount,
|
|
401
|
+
description: "The number the line was given in the prompt."
|
|
402
|
+
},
|
|
403
|
+
speaker: { type: "string", description: "Who says it." },
|
|
404
|
+
direction: {
|
|
405
|
+
type: "string",
|
|
406
|
+
description: "Optional performance note."
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
required: ["number", "speaker"]
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
required: ["speakers", "lines"]
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* The attribution answer applied to the split lines. `lines` is the only
|
|
418
|
+
* source of text this function has, so the words cannot come from the model
|
|
419
|
+
* whatever it returned (PRD § 9.7 criterion 4).
|
|
420
|
+
*/
|
|
421
|
+
export function applyAttribution(lines, raw, options) {
|
|
422
|
+
const answer = isRecord(raw) ? raw : {};
|
|
423
|
+
const nextSpeakerId = counter(`${options.idPrefix}_spk`);
|
|
424
|
+
const nextLineId = counter(`${options.idPrefix}_line`);
|
|
425
|
+
const cast = [];
|
|
426
|
+
const held = new Map((options.existingCast ?? []).map((member) => [
|
|
427
|
+
member.name.trim().toLowerCase(),
|
|
428
|
+
member
|
|
429
|
+
]));
|
|
430
|
+
const byName = new Map();
|
|
431
|
+
const speakerFor = (name) => {
|
|
432
|
+
const key = name.trim().toLowerCase();
|
|
433
|
+
if (key === "")
|
|
434
|
+
return null;
|
|
435
|
+
const already = byName.get(key);
|
|
436
|
+
if (already)
|
|
437
|
+
return already;
|
|
438
|
+
const kept = held.get(key);
|
|
439
|
+
const created = kept
|
|
440
|
+
? { id: kept.id, name: kept.name }
|
|
441
|
+
: { id: nextSpeakerId(), name: name.trim() };
|
|
442
|
+
cast.push(created);
|
|
443
|
+
byName.set(key, created);
|
|
444
|
+
return created;
|
|
445
|
+
};
|
|
446
|
+
for (const entry of Array.isArray(answer["speakers"]) ? answer["speakers"] : []) {
|
|
447
|
+
if (isRecord(entry)) {
|
|
448
|
+
speakerFor(cleanText(entry["name"]));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// Attribution by line number, so an answer that skips or reorders entries
|
|
452
|
+
// still lands on the line it named.
|
|
453
|
+
const attributed = new Map();
|
|
454
|
+
for (const entry of Array.isArray(answer["lines"]) ? answer["lines"] : []) {
|
|
455
|
+
if (!isRecord(entry))
|
|
456
|
+
continue;
|
|
457
|
+
const number = Number(entry["number"]);
|
|
458
|
+
if (!Number.isInteger(number))
|
|
459
|
+
continue;
|
|
460
|
+
attributed.set(number, {
|
|
461
|
+
speaker: cleanText(entry["speaker"]),
|
|
462
|
+
direction: cleanText(entry["direction"])
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
let lastSpeakerId = null;
|
|
466
|
+
const written = lines.map((text, index) => {
|
|
467
|
+
const entry = attributed.get(index + 1);
|
|
468
|
+
const speaker = entry ? speakerFor(entry.speaker) : null;
|
|
469
|
+
if (speaker)
|
|
470
|
+
lastSpeakerId = speaker.id;
|
|
471
|
+
const line = {
|
|
472
|
+
id: options.lineIds?.[index] ?? nextLineId(),
|
|
473
|
+
speakerId: speaker?.id ?? lastSpeakerId,
|
|
474
|
+
text
|
|
475
|
+
};
|
|
476
|
+
const direction = entry?.direction ?? "";
|
|
477
|
+
if (direction !== "") {
|
|
478
|
+
line.direction = direction;
|
|
479
|
+
}
|
|
480
|
+
return line;
|
|
481
|
+
});
|
|
482
|
+
// Nobody was named: the lines still need a voice, so the format's first
|
|
483
|
+
// speaker takes them all.
|
|
484
|
+
if (cast.length === 0 && written.length > 0) {
|
|
485
|
+
const only = speakerFor("Narrator");
|
|
486
|
+
if (only) {
|
|
487
|
+
for (const line of written) {
|
|
488
|
+
line.speakerId = only.id;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
cast,
|
|
494
|
+
sections: [
|
|
495
|
+
{
|
|
496
|
+
id: `${options.idPrefix}_sec_1`,
|
|
497
|
+
title: options.sectionTitle ?? "Script",
|
|
498
|
+
lines: written
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
//# sourceMappingURL=script-authoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-authoring.js","sourceRoot":"","sources":["../src/script-authoring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAoBrD,yEAAyE;AACzE,MAAM,CAAC,MAAM,cAAc,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SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/protocol — Filling a template script.
|
|
3
|
+
*
|
|
4
|
+
* A script written once and approved becomes a template when its lines carry
|
|
5
|
+
* `{{key}}` placeholders: a batch fills them per row and voices the result.
|
|
6
|
+
* {@link fillScript} is that substitution, pure, so the `nodetool.script.FillScript`
|
|
7
|
+
* node, an agent capability and the editor all fill a script the same way.
|
|
8
|
+
*
|
|
9
|
+
* Two rules the tests pin:
|
|
10
|
+
*
|
|
11
|
+
* - **An unresolved placeholder stays.** A key with no value is reported in
|
|
12
|
+
* `unresolved` and left in the text verbatim. Blanking it would ship a line
|
|
13
|
+
* reading "Buy today" and nothing downstream could tell that from an
|
|
14
|
+
* authored gap.
|
|
15
|
+
* - **Takes survive.** A line's `takes` and `currentTakeId` ride through
|
|
16
|
+
* untouched. Staleness is derived, not stored: `needsVoicing`
|
|
17
|
+
* (`@nodetool-ai/timeline`) compares each take's `textSnapshot` against the
|
|
18
|
+
* line's text, so a line whose text moved is already stale and a line that
|
|
19
|
+
* held still is already voiced. A later `VoiceScript` therefore pays only
|
|
20
|
+
* for the lines the fill actually changed.
|
|
21
|
+
*/
|
|
22
|
+
import type { ScriptDocumentSchema } from "./api-schemas/scripts.js";
|
|
23
|
+
export interface FillScriptResult {
|
|
24
|
+
/** A new document; the input is never mutated. */
|
|
25
|
+
document: ScriptDocumentSchema;
|
|
26
|
+
/** Keys that were substituted at least once, in first-seen order. */
|
|
27
|
+
filled: string[];
|
|
28
|
+
/** Keys the text names that `values` has no entry for, in first-seen order. */
|
|
29
|
+
unresolved: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fill `{{key}}` placeholders in every line's text.
|
|
33
|
+
*
|
|
34
|
+
* Only `ScriptLine.text` is filled — a speaker name or a section title is
|
|
35
|
+
* structure, not spoken words. Lines with no placeholder come back by
|
|
36
|
+
* reference, so a caller can tell what the fill touched by identity.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fillScript(doc: ScriptDocumentSchema, values: Record<string, string>): FillScriptResult;
|
|
39
|
+
//# sourceMappingURL=script-fill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-fill.d.ts","sourceRoot":"","sources":["../src/script-fill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAUrE,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,qEAAqE;IACrE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+EAA+E;IAC/E,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAmBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,gBAAgB,CAoBlB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nodetool-ai/protocol — Filling a template script.
|
|
3
|
+
*
|
|
4
|
+
* A script written once and approved becomes a template when its lines carry
|
|
5
|
+
* `{{key}}` placeholders: a batch fills them per row and voices the result.
|
|
6
|
+
* {@link fillScript} is that substitution, pure, so the `nodetool.script.FillScript`
|
|
7
|
+
* node, an agent capability and the editor all fill a script the same way.
|
|
8
|
+
*
|
|
9
|
+
* Two rules the tests pin:
|
|
10
|
+
*
|
|
11
|
+
* - **An unresolved placeholder stays.** A key with no value is reported in
|
|
12
|
+
* `unresolved` and left in the text verbatim. Blanking it would ship a line
|
|
13
|
+
* reading "Buy today" and nothing downstream could tell that from an
|
|
14
|
+
* authored gap.
|
|
15
|
+
* - **Takes survive.** A line's `takes` and `currentTakeId` ride through
|
|
16
|
+
* untouched. Staleness is derived, not stored: `needsVoicing`
|
|
17
|
+
* (`@nodetool-ai/timeline`) compares each take's `textSnapshot` against the
|
|
18
|
+
* line's text, so a line whose text moved is already stale and a line that
|
|
19
|
+
* held still is already voiced. A later `VoiceScript` therefore pays only
|
|
20
|
+
* for the lines the fill actually changed.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The placeholder grammar: `{{key}}`, with optional inner whitespace. A key is
|
|
24
|
+
* a word plus `.`/`-`, which covers the CSV column names a batch fills from.
|
|
25
|
+
* `fillTimelineText` (`@nodetool-ai/timeline`) matches the same grammar, so a
|
|
26
|
+
* script and the cut's text overlay accept one set of values.
|
|
27
|
+
*/
|
|
28
|
+
const PLACEHOLDER = /\{\{\s*([A-Za-z0-9_][A-Za-z0-9_.-]*)\s*\}\}/g;
|
|
29
|
+
/** Substitute one string, recording which keys resolved and which did not. */
|
|
30
|
+
function fillText(text, values, filled, unresolved) {
|
|
31
|
+
return text.replace(PLACEHOLDER, (match, key) => {
|
|
32
|
+
if (!Object.prototype.hasOwnProperty.call(values, key)) {
|
|
33
|
+
unresolved.add(key);
|
|
34
|
+
return match;
|
|
35
|
+
}
|
|
36
|
+
filled.add(key);
|
|
37
|
+
return values[key];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fill `{{key}}` placeholders in every line's text.
|
|
42
|
+
*
|
|
43
|
+
* Only `ScriptLine.text` is filled — a speaker name or a section title is
|
|
44
|
+
* structure, not spoken words. Lines with no placeholder come back by
|
|
45
|
+
* reference, so a caller can tell what the fill touched by identity.
|
|
46
|
+
*/
|
|
47
|
+
export function fillScript(doc, values) {
|
|
48
|
+
const filled = new Set();
|
|
49
|
+
const unresolved = new Set();
|
|
50
|
+
const sections = doc.sections.map((section) => {
|
|
51
|
+
let changed = false;
|
|
52
|
+
const lines = section.lines.map((line) => {
|
|
53
|
+
const text = fillText(line.text, values, filled, unresolved);
|
|
54
|
+
if (text === line.text)
|
|
55
|
+
return line;
|
|
56
|
+
changed = true;
|
|
57
|
+
return { ...line, text };
|
|
58
|
+
});
|
|
59
|
+
return changed ? { ...section, lines } : section;
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
document: { ...doc, sections },
|
|
63
|
+
filled: [...filled],
|
|
64
|
+
unresolved: [...unresolved]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=script-fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-fill.js","sourceRoot":"","sources":["../src/script-fill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;;GAKG;AACH,MAAM,WAAW,GAAG,8CAA8C,CAAC;AAWnE,8EAA8E;AAC9E,SAAS,QAAQ,CACf,IAAY,EACZ,MAA8B,EAC9B,MAAmB,EACnB,UAAuB;IAEvB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;QACtD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YACvD,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,GAAyB,EACzB,MAA8B;IAE9B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5C,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,KAAK,GAAG,OAAO,CAA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