@bastani/atomic 0.10.4-alpha.2 → 0.10.5-alpha.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/CHANGELOG.md +238 -0
- package/dist/_shared/chunk-CDOYTDYM.js +4 -0
- package/dist/_shared/chunk-CDOYTDYM.js.map +1 -0
- package/dist/_shared/compile-cache-warmup-host-RU5L7I7A.js +1 -1
- package/dist/_shared/dist-KOELCESV.js +48 -3
- package/dist/_shared/fork-row-index-UAUAQRD5.js +47 -2
- package/dist/_shared/http-YFAPTIZD.js +16 -4
- package/dist/_shared/http-YFAPTIZD.js.map +1 -1
- package/dist/_shared/lib-4PES5P4V.js +59 -14
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +1706 -258
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +317 -64
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/{mode-shared-HP7GUA7J.js → mode-shared-2QJSCUM6.js} +432 -81
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -0
- package/dist/_shared/p0-cli-BB45ZQY6.js +3482 -0
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -0
- package/dist/_shared/p0-cli-GUFK7TPN.js +2 -2838
- package/dist/_shared/p0-cli-GUFK7TPN.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-YK3KDTLN.js → p1a-prewarm-UQY3X2UK.js} +270 -73
- package/dist/_shared/p1a-prewarm-UQY3X2UK.js.map +1 -0
- package/dist/_shared/{p1b-elig-PXQA2FYP.js → p1b-elig-ENCUPKKJ.js} +190 -121
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +1 -0
- package/dist/_shared/p2-common-YLSYXMDQ.js +1 -3
- package/dist/_shared/p2-common-YLSYXMDQ.js.map +1 -1
- package/dist/_shared/p2-shell-TJBYQMCJ.js +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +500 -127
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +4 -4
- package/dist/_shared/sdk-WQIOHVKO.js +56 -11
- package/dist/_shared/session-data-AHTU7IS6.js +48 -3
- package/dist/_shared/session-manager-list-2BLEEZVG.js +2 -2
- package/dist/_shared/settings-startup-65YEWRV2.js.map +1 -1
- package/dist/_shared/sql-session-store-5FD3WBMZ.js +57 -12
- package/dist/_shared/{startup-0-0-X4NF3GKM.js → startup-0-0-TYUFUOJZ.js} +528 -321
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +1 -0
- package/dist/_shared/{startup-0-1-7QTG6VJZ.js → startup-0-1-D4LGGINF.js} +284 -81
- package/dist/_shared/startup-0-1-D4LGGINF.js.map +1 -0
- package/dist/_shared/{startup-0-2-KFDYPDJK.js → startup-0-2-SZGQIWHI.js} +483 -154
- package/dist/_shared/startup-0-2-SZGQIWHI.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +340 -110
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js +261 -59
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +1 -1
- package/dist/_shared/startup-0-5-OHJNE6JH.js +421 -148
- package/dist/_shared/startup-0-5-OHJNE6JH.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +62 -11
- package/dist/_shared/startup-10-0-TDQNBDDL.js.map +1 -1
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +12 -11
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +53 -158
- package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +231 -46
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +115 -35
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-KQJBDKRU.js → startup-8-1-SJW2GMAM.js} +203 -62
- package/dist/_shared/startup-8-1-SJW2GMAM.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +55 -10
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +47 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +48 -3
- package/dist/builtin/intercom/CHANGELOG.md +59 -0
- package/dist/builtin/intercom/README.md +0 -1
- package/dist/builtin/intercom/broker/broker-instance.ts +13 -57
- package/dist/builtin/intercom/broker/broker-process.ts +30 -10
- package/dist/builtin/intercom/broker/broker-routing.ts +12 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +2557 -498
- package/dist/builtin/intercom/broker/broker.ts +164 -55
- package/dist/builtin/intercom/broker/client.ts +36 -16
- package/dist/builtin/intercom/broker/control.ts +83 -20
- package/dist/builtin/intercom/broker/durable-ended-queue.ts +65 -19
- package/dist/builtin/intercom/broker/host-command-environment.ts +7 -2
- package/dist/builtin/intercom/broker/multinode-router.ts +1675 -387
- package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
- package/dist/builtin/intercom/broker/paths.ts +68 -6
- package/dist/builtin/intercom/broker/pending-send-registry.ts +5 -0
- package/dist/builtin/intercom/broker/registration-bounds.ts +38 -0
- package/dist/builtin/intercom/broker/retiring-broker-check.ts +178 -0
- package/dist/builtin/intercom/broker/return-paths.ts +268 -7
- package/dist/builtin/intercom/broker/send-handler.ts +253 -28
- package/dist/builtin/intercom/broker/send-order-gate.ts +410 -0
- package/dist/builtin/intercom/broker/spawn.ts +950 -202
- package/dist/builtin/intercom/broker/sql-lease-store.ts +37 -0
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +7 -0
- package/dist/builtin/intercom/broker/windows-cwd.ts +546 -0
- package/dist/builtin/intercom/index.bundle.mjs +3506 -2328
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +4 -0
- package/dist/builtin/intercom/types.ts +2 -0
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +46 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +336 -86
- package/dist/builtin/web-access/CHANGELOG.md +12 -0
- package/dist/builtin/web-access/index.bundle.mjs +23 -38
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/cli.js +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/internal-intercom-broker.js +119 -4
- package/dist/bun/internal-intercom-broker.js.map +1 -1
- package/dist/bun/register-theme-validator.js +6 -0
- package/dist/bun/register-theme-validator.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +1102 -0
- package/dist/cli/auth-cli.code.js.map +1 -0
- package/dist/cli/auth-cli.impl.js +36 -0
- package/dist/cli/auth-cli.impl.js.map +1 -0
- package/dist/cli/auth-cli.js +30 -1096
- package/dist/cli/auth-cli.js.map +1 -1
- package/dist/cli/blueprint-command.code.js +906 -0
- package/dist/cli/blueprint-command.code.js.map +1 -0
- package/dist/cli/blueprint-command.impl.js +36 -0
- package/dist/cli/blueprint-command.impl.js.map +1 -0
- package/dist/cli/blueprint-command.js +30 -900
- package/dist/cli/blueprint-command.js.map +1 -1
- package/dist/cli/intercom-command.code.js +153 -0
- package/dist/cli/intercom-command.code.js.map +1 -0
- package/dist/cli/intercom-command.impl.js +36 -0
- package/dist/cli/intercom-command.impl.js.map +1 -0
- package/dist/cli/intercom-command.js +33 -105
- package/dist/cli/intercom-command.js.map +1 -1
- package/dist/cli/list-models.code.js +60 -0
- package/dist/cli/list-models.code.js.map +1 -0
- package/dist/cli/list-models.impl.js +36 -0
- package/dist/cli/list-models.impl.js.map +1 -0
- package/dist/cli/list-models.js +33 -57
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.code.js +55 -0
- package/dist/cli/session-picker.code.js.map +1 -0
- package/dist/cli/session-picker.impl.js +36 -0
- package/dist/cli/session-picker.impl.js.map +1 -0
- package/dist/cli/session-picker.js +33 -52
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.code.js +5 -0
- package/dist/cli/startup-ui.code.js.map +1 -0
- package/dist/cli/startup-ui.impl.js +36 -0
- package/dist/cli/startup-ui.impl.js.map +1 -0
- package/dist/cli/startup-ui.js +35 -4
- package/dist/cli/storage-command.code.js +3 -0
- package/dist/cli/storage-command.code.js.map +1 -0
- package/dist/cli/storage-command.impl.js +36 -0
- package/dist/cli/storage-command.impl.js.map +1 -0
- package/dist/cli/storage-command.js +35 -2
- package/dist/cli/storage-search-session.code.js +189 -0
- package/dist/cli/storage-search-session.code.js.map +1 -0
- package/dist/cli/storage-search-session.impl.js +36 -0
- package/dist/cli/storage-search-session.impl.js.map +1 -0
- package/dist/cli/storage-search-session.js +33 -186
- package/dist/cli/storage-search-session.js.map +1 -1
- package/dist/cli/team-command.code.js +217 -0
- package/dist/cli/team-command.code.js.map +1 -0
- package/dist/cli/team-command.impl.js +36 -0
- package/dist/cli/team-command.impl.js.map +1 -0
- package/dist/cli/team-command.js +32 -213
- package/dist/cli/team-command.js.map +1 -1
- package/dist/cli.js +60 -11
- package/dist/cli.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -3
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -0
- package/dist/core/compaction/compaction.d.ts +6 -0
- package/dist/core/compaction/model-resolver.d.ts +1 -1
- package/dist/core/debug.code.js +3 -0
- package/dist/core/debug.code.js.map +1 -0
- package/dist/core/debug.impl.js +36 -0
- package/dist/core/debug.impl.js.map +1 -0
- package/dist/core/debug.js +35 -2
- package/dist/core/default-model-api-prewarm.d.ts +5 -0
- package/dist/core/export-html/card-projection.code.js +257 -0
- package/dist/core/export-html/card-projection.code.js.map +1 -0
- package/dist/core/export-html/card-projection.impl.js +36 -0
- package/dist/core/export-html/card-projection.impl.js.map +1 -0
- package/dist/core/export-html/card-projection.js +34 -255
- package/dist/core/export-html/card-projection.js.map +1 -1
- package/dist/core/export-html/index.code.js +655 -0
- package/dist/core/export-html/index.code.js.map +1 -0
- package/dist/core/export-html/index.impl.js +36 -0
- package/dist/core/export-html/index.impl.js.map +1 -0
- package/dist/core/export-html/index.js +30 -604
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/json-spans.code.js +3 -0
- package/dist/core/export-html/json-spans.code.js.map +1 -0
- package/dist/core/export-html/json-spans.impl.js +36 -0
- package/dist/core/export-html/json-spans.impl.js.map +1 -0
- package/dist/core/export-html/json-spans.js +35 -2
- package/dist/core/export-html/oversized-render-inputs.code.js +125 -0
- package/dist/core/export-html/oversized-render-inputs.code.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js +36 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.js +31 -120
- package/dist/core/export-html/oversized-render-inputs.js.map +1 -1
- package/dist/core/export-html/tool-renderer.code.js +350 -0
- package/dist/core/export-html/tool-renderer.code.js.map +1 -0
- package/dist/core/export-html/tool-renderer.impl.js +36 -0
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -0
- package/dist/core/export-html/tool-renderer.js +33 -347
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/jiti-loader.code.js +3 -0
- package/dist/core/extensions/jiti-loader.code.js.map +1 -0
- package/dist/core/extensions/jiti-loader.impl.js +36 -0
- package/dist/core/extensions/jiti-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-loader.js +35 -2
- package/dist/core/extensions/jiti-static-loader.code.js +3 -0
- package/dist/core/extensions/jiti-static-loader.code.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.impl.js +36 -0
- package/dist/core/extensions/jiti-static-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +35 -2
- package/dist/core/extensions/loader-host-modules.code.js +3 -0
- package/dist/core/extensions/loader-host-modules.code.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.impl.js +36 -0
- package/dist/core/extensions/loader-host-modules.impl.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.js +35 -2
- package/dist/core/extensions/loader-virtual-modules.d.ts +1 -6
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +3 -3
- package/dist/core/extensions/session-events.d.ts +4 -0
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/intercom-broker-control-host.code.js +5 -0
- package/dist/core/intercom-broker-control-host.code.js.map +1 -0
- package/dist/core/intercom-broker-control-host.impl.js +36 -0
- package/dist/core/intercom-broker-control-host.impl.js.map +1 -0
- package/dist/core/intercom-broker-control-host.js +35 -4
- package/dist/core/intercom-broker-control.code.js +63 -0
- package/dist/core/intercom-broker-control.code.js.map +1 -0
- package/dist/core/intercom-broker-control.d.ts +21 -0
- package/dist/core/intercom-broker-control.impl.js +36 -0
- package/dist/core/intercom-broker-control.impl.js.map +1 -0
- package/dist/core/intercom-broker-control.js +35 -17
- package/dist/core/intercom-broker-control.js.map +1 -1
- package/dist/core/package-manager-storage-adapters.code.js +3 -0
- package/dist/core/package-manager-storage-adapters.code.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.impl.js +36 -0
- package/dist/core/package-manager-storage-adapters.impl.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.js +35 -2
- package/dist/core/process-start-token.d.ts +8 -2
- package/dist/core/process-tree-containment.d.ts +27 -0
- package/dist/core/queued-message-delivery.d.ts +5 -2
- package/dist/core/resume/blueprint/process.d.ts +3 -1
- package/dist/core/sdk.code.js +9 -0
- package/dist/core/sdk.code.js.map +1 -0
- package/dist/core/sdk.impl.js +36 -0
- package/dist/core/sdk.impl.js.map +1 -0
- package/dist/core/sdk.js +35 -8
- package/dist/core/session-manager-core.d.ts +15 -5
- package/dist/core/session-manager-core.js +195 -38
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.code.js +3 -0
- package/dist/core/session-manager-list.code.js.map +1 -0
- package/dist/core/session-manager-list.impl.js +36 -0
- package/dist/core/session-manager-list.impl.js.map +1 -0
- package/dist/core/session-manager-list.js +35 -2
- package/dist/core/session-manager-types.d.ts +20 -0
- package/dist/core/session-manager.code.js +8 -0
- package/dist/core/session-manager.code.js.map +1 -0
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.impl.js +36 -0
- package/dist/core/session-manager.impl.js.map +1 -0
- package/dist/core/session-manager.js +35 -7
- package/dist/core/session-storage.code.js +3 -0
- package/dist/core/session-storage.code.js.map +1 -0
- package/dist/core/session-storage.impl.js +36 -0
- package/dist/core/session-storage.impl.js.map +1 -0
- package/dist/core/session-storage.js +35 -2
- package/dist/core/storage/file-identity.d.ts +3 -0
- package/dist/core/storage/file-identity.js +296 -86
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -1
- package/dist/core/storage/index.js +52 -7
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +47 -2
- package/dist/core/storage/node-sqlite.js +49 -4
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.code.js +37 -0
- package/dist/core/storage/offline-snapshot-file.code.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.impl.js +36 -0
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.js +33 -34
- package/dist/core/storage/offline-snapshot-file.js.map +1 -1
- package/dist/core/storage/provider.js +52 -7
- package/dist/core/storage/selection.js +49 -4
- package/dist/core/storage/session/branch-fork-source.code.js +146 -0
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.impl.js +36 -0
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.js +32 -97
- package/dist/core/storage/session/branch-fork-source.js.map +1 -1
- package/dist/core/storage/session/card-view.code.js +60 -0
- package/dist/core/storage/session/card-view.code.js.map +1 -0
- package/dist/core/storage/session/card-view.impl.js +36 -0
- package/dist/core/storage/session/card-view.impl.js.map +1 -0
- package/dist/core/storage/session/card-view.js +34 -58
- package/dist/core/storage/session/card-view.js.map +1 -1
- package/dist/core/storage/session/child-reader.code.js +139 -0
- package/dist/core/storage/session/child-reader.code.js.map +1 -0
- package/dist/core/storage/session/child-reader.d.ts +1 -0
- package/dist/core/storage/session/child-reader.impl.js +36 -0
- package/dist/core/storage/session/child-reader.impl.js.map +1 -0
- package/dist/core/storage/session/child-reader.js +33 -91
- package/dist/core/storage/session/child-reader.js.map +1 -1
- package/dist/core/storage/session/chunked-resume-projection.code.js +3 -0
- package/dist/core/storage/session/chunked-resume-projection.code.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js +36 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.js +35 -2
- package/dist/core/storage/session/expanded-child-details.code.js +684 -0
- package/dist/core/storage/session/expanded-child-details.code.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.impl.js +36 -0
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.js +31 -634
- package/dist/core/storage/session/expanded-child-details.js.map +1 -1
- package/dist/core/storage/session/fork-row-bytes.code.js +3 -0
- package/dist/core/storage/session/fork-row-bytes.code.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js +36 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.js +35 -2
- package/dist/core/storage/session/fork-row-index.code.js +3 -0
- package/dist/core/storage/session/fork-row-index.code.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.impl.js +36 -0
- package/dist/core/storage/session/fork-row-index.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.js +35 -2
- package/dist/core/storage/session/fork-staging.code.js +580 -0
- package/dist/core/storage/session/fork-staging.code.js.map +1 -0
- package/dist/core/storage/session/fork-staging.impl.js +36 -0
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -0
- package/dist/core/storage/session/fork-staging.js +30 -574
- package/dist/core/storage/session/fork-staging.js.map +1 -1
- package/dist/core/storage/session/fork-window.code.js +522 -0
- package/dist/core/storage/session/fork-window.code.js.map +1 -0
- package/dist/core/storage/session/fork-window.impl.js +36 -0
- package/dist/core/storage/session/fork-window.impl.js.map +1 -0
- package/dist/core/storage/session/fork-window.js +30 -471
- package/dist/core/storage/session/fork-window.js.map +1 -1
- package/dist/core/storage/session/history-pages.code.js +3 -0
- package/dist/core/storage/session/history-pages.code.js.map +1 -0
- package/dist/core/storage/session/history-pages.impl.js +36 -0
- package/dist/core/storage/session/history-pages.impl.js.map +1 -0
- package/dist/core/storage/session/history-pages.js +35 -2
- package/dist/core/storage/session/jsonl-entry-projection.code.js +3 -0
- package/dist/core/storage/session/jsonl-entry-projection.code.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +36 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.js +35 -2
- package/dist/core/storage/session/jsonl-session-store.code.js +3 -0
- package/dist/core/storage/session/jsonl-session-store.code.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js +36 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.js +35 -2
- package/dist/core/storage/session/memory-session-store.code.js +3 -0
- package/dist/core/storage/session/memory-session-store.code.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.impl.js +36 -0
- package/dist/core/storage/session/memory-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.js +35 -2
- package/dist/core/storage/session/pinned-branch-resume.code.js +117 -0
- package/dist/core/storage/session/pinned-branch-resume.code.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js +36 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.js +33 -69
- package/dist/core/storage/session/pinned-branch-resume.js.map +1 -1
- package/dist/core/storage/session/released-history-files.code.js +465 -0
- package/dist/core/storage/session/released-history-files.code.js.map +1 -0
- package/dist/core/storage/session/released-history-files.impl.js +36 -0
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -0
- package/dist/core/storage/session/released-history-files.js +32 -461
- package/dist/core/storage/session/released-history-files.js.map +1 -1
- package/dist/core/storage/session/resident-fork-rows.code.js +57 -0
- package/dist/core/storage/session/resident-fork-rows.code.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js +36 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.js +32 -53
- package/dist/core/storage/session/resident-fork-rows.js.map +1 -1
- package/dist/core/storage/session/session-resume.code.js +3 -0
- package/dist/core/storage/session/session-resume.code.js.map +1 -0
- package/dist/core/storage/session/session-resume.impl.js +36 -0
- package/dist/core/storage/session/session-resume.impl.js.map +1 -0
- package/dist/core/storage/session/session-resume.js +35 -2
- package/dist/core/storage/session/snapshot-cut.code.js +3 -0
- package/dist/core/storage/session/snapshot-cut.code.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.impl.js +36 -0
- package/dist/core/storage/session/snapshot-cut.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.js +35 -2
- package/dist/core/storage/session/snapshot-history.code.js +107 -0
- package/dist/core/storage/session/snapshot-history.code.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.impl.js +36 -0
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.js +34 -60
- package/dist/core/storage/session/snapshot-history.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.code.js +3 -0
- package/dist/core/storage/session/sql-session-store.code.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.impl.js +36 -0
- package/dist/core/storage/session/sql-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.js +35 -2
- package/dist/core/storage/session/tree-outline.code.js +3 -0
- package/dist/core/storage/session/tree-outline.code.js.map +1 -0
- package/dist/core/storage/session/tree-outline.impl.js +36 -0
- package/dist/core/storage/session/tree-outline.impl.js.map +1 -0
- package/dist/core/storage/session/tree-outline.js +35 -2
- package/dist/core/storage/session/tree-presentation.code.js +342 -0
- package/dist/core/storage/session/tree-presentation.code.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.impl.js +36 -0
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.js +31 -337
- package/dist/core/storage/session/tree-presentation.js.map +1 -1
- package/dist/core/storage/session/types.d.ts +26 -0
- package/dist/core/storage/storage-status.code.js +3 -0
- package/dist/core/storage/storage-status.code.js.map +1 -0
- package/dist/core/storage/storage-status.impl.js +36 -0
- package/dist/core/storage/storage-status.impl.js.map +1 -0
- package/dist/core/storage/storage-status.js +35 -2
- package/dist/core/storage/team.code.js +3 -0
- package/dist/core/storage/team.code.js.map +1 -0
- package/dist/core/storage/team.impl.js +36 -0
- package/dist/core/storage/team.impl.js.map +1 -0
- package/dist/core/storage/team.js +35 -2
- package/dist/core/structured-output/index.code.js +3 -0
- package/dist/core/structured-output/index.code.js.map +1 -0
- package/dist/core/structured-output/index.impl.js +36 -0
- package/dist/core/structured-output/index.impl.js.map +1 -0
- package/dist/core/structured-output/index.js +35 -2
- package/dist/core/tasks/command-output.d.ts +4 -1
- package/dist/core/tasks/supervisor.d.ts +2 -0
- package/dist/core/tasks/task-completion-entry.code.js +254 -0
- package/dist/core/tasks/task-completion-entry.code.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.impl.js +36 -0
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.js +33 -251
- package/dist/core/tasks/task-completion-entry.js.map +1 -1
- package/dist/core/tasks/task-file-history.code.js +424 -0
- package/dist/core/tasks/task-file-history.code.js.map +1 -0
- package/dist/core/tasks/task-file-history.impl.js +36 -0
- package/dist/core/tasks/task-file-history.impl.js.map +1 -0
- package/dist/core/tasks/task-file-history.js +32 -375
- package/dist/core/tasks/task-file-history.js.map +1 -1
- package/dist/core/tasks/task-reference-archive.code.js +514 -0
- package/dist/core/tasks/task-reference-archive.code.js.map +1 -0
- package/dist/core/tasks/task-reference-archive.js +34 -467
- package/dist/core/tasks/task-reference-archive.js.map +1 -1
- package/dist/core/tasks/task-reference-identity.code.js +164 -0
- package/dist/core/tasks/task-reference-identity.code.js.map +1 -0
- package/dist/core/tasks/task-reference-identity.js +32 -160
- package/dist/core/tasks/task-reference-identity.js.map +1 -1
- package/dist/core/tasks/task-reference-stream.code.js +3 -0
- package/dist/core/tasks/task-reference-stream.code.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.impl.js +36 -0
- package/dist/core/tasks/task-reference-stream.impl.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.js +35 -2
- package/dist/core/tasks/task-unsaved-answer.code.js +3 -0
- package/dist/core/tasks/task-unsaved-answer.code.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js +36 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.js +35 -2
- package/dist/core/tasks/task-view-source.code.js +3 -0
- package/dist/core/tasks/task-view-source.code.js.map +1 -0
- package/dist/core/tasks/task-view-source.d.ts +9 -0
- package/dist/core/tasks/task-view-source.impl.js +36 -0
- package/dist/core/tasks/task-view-source.impl.js.map +1 -0
- package/dist/core/tasks/task-view-source.js +35 -2
- package/dist/core/tools/read-url.code.js +1530 -0
- package/dist/core/tools/read-url.code.js.map +1 -0
- package/dist/core/tools/read-url.impl.js +36 -0
- package/dist/core/tools/read-url.impl.js.map +1 -0
- package/dist/core/tools/read-url.js +30 -1524
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/core/worktree-snapshot/blob-store.js +50 -5
- package/dist/core/worktree-snapshot/errors.code.js +6 -0
- package/dist/core/worktree-snapshot/errors.code.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.impl.js +36 -0
- package/dist/core/worktree-snapshot/errors.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.js +35 -5
- package/dist/core/worktree-snapshot/session-index-reset.code.js +136 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +36 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.js +34 -134
- package/dist/core/worktree-snapshot/session-index-reset.js.map +1 -1
- package/dist/extensions/codemode/execute.code.js +618 -0
- package/dist/extensions/codemode/execute.code.js.map +1 -0
- package/dist/extensions/codemode/execute.impl.js +36 -0
- package/dist/extensions/codemode/execute.impl.js.map +1 -0
- package/dist/extensions/codemode/execute.js +30 -612
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/renderer.code.js +110 -0
- package/dist/extensions/codemode/renderer.code.js.map +1 -0
- package/dist/extensions/codemode/renderer.impl.js +36 -0
- package/dist/extensions/codemode/renderer.impl.js.map +1 -0
- package/dist/extensions/codemode/renderer.js +33 -107
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/mcp/cli.code.js +565 -0
- package/dist/extensions/mcp/cli.code.js.map +1 -0
- package/dist/extensions/mcp/cli.impl.js +36 -0
- package/dist/extensions/mcp/cli.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.js +32 -561
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/cli.lazy.code.js +52 -0
- package/dist/extensions/mcp/cli.lazy.code.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.impl.js +36 -0
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +36 -7
- package/dist/extensions/mcp/cli.lazy.js.map +1 -1
- package/dist/extensions/mcp/client/transports/stdio.d.ts +2 -0
- package/dist/extensions/mcp/runtime.code.js +5 -0
- package/dist/extensions/mcp/runtime.code.js.map +1 -0
- package/dist/extensions/mcp/runtime.impl.js +36 -0
- package/dist/extensions/mcp/runtime.impl.js.map +1 -0
- package/dist/extensions/mcp/runtime.js +35 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/main-first-time-setup.code.js +12 -0
- package/dist/main-first-time-setup.code.js.map +1 -0
- package/dist/main-first-time-setup.impl.js +36 -0
- package/dist/main-first-time-setup.impl.js.map +1 -0
- package/dist/main-first-time-setup.js +35 -11
- package/dist/main-first-time-setup.js.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +2 -2
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +6 -1
- package/dist/modes/interactive/agent-view/contracts.d.ts +4 -0
- package/dist/modes/interactive/chat-reader-records.d.ts +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +338 -0
- package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js +36 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.js +33 -290
- package/dist/modes/interactive/components/stored-tree-view.js.map +1 -1
- package/dist/modes/interactive/components/task-selection-state.d.ts +8 -3
- package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +191 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +36 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.js +34 -189
- package/dist/modes/interactive/components/user-message-selector-archive.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode-deps.js +4 -0
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +4 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts +22 -0
- package/dist/modes/interactive/interactive-startup.d.ts +2 -0
- package/dist/modes/interactive/program-status-reporter.d.ts +2 -1
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive/steering-queue-controller.d.ts +4 -0
- package/dist/modes/interactive/theme/theme-schema-factory.d.ts +26 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +4 -5
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +30 -5
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts +32 -1
- package/dist/modes/rpc/agent-view-rpc-types.d.ts +12 -1
- package/dist/modes/rpc/agent-view-rpc-types.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +3 -1
- package/dist/modes/rpc/rpc-types.d.ts +12 -0
- package/dist/package-manager-cli.code.js +1140 -0
- package/dist/package-manager-cli.code.js.map +1 -0
- package/dist/package-manager-cli.impl.js +36 -0
- package/dist/package-manager-cli.impl.js.map +1 -0
- package/dist/package-manager-cli.js +36 -1067
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.js +2 -2
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/13.js +1 -0
- package/dist/startup-stages/2.js +1 -7
- package/dist/startup-stages/3.js +6 -2
- package/dist/startup-stages/4.js +2 -1
- package/dist/startup-stages/5.js +1 -7
- package/dist/startup-stages/6.js +7 -10
- package/dist/startup-stages/7.js +10 -3
- package/dist/startup-stages/8.js +3 -6
- package/dist/startup-stages/9.js +6 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/canonical-path.js +2 -0
- package/dist/utils/canonical-path.js.map +1 -1
- package/dist/utils/child-process.d.ts +41 -1
- package/dist/utils/compile-cache-warmup-host.js +63 -18
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/credential-redaction.d.ts +50 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/memoize-async.d.ts +32 -0
- package/dist/utils/memoize-async.js +91 -0
- package/dist/utils/memoize-async.js.map +1 -0
- package/dist/utils/photon.js +19 -29
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +7 -4
- package/dist/utils/startup-database-spare.code.js +108 -0
- package/dist/utils/startup-database-spare.code.js.map +1 -0
- package/dist/utils/startup-database-spare.impl.js +36 -0
- package/dist/utils/startup-database-spare.impl.js.map +1 -0
- package/dist/utils/startup-database-spare.js +33 -105
- package/dist/utils/startup-database-spare.js.map +1 -1
- package/dist/utils/tools-manager.code.js +3 -0
- package/dist/utils/tools-manager.code.js.map +1 -0
- package/dist/utils/tools-manager.impl.js +36 -0
- package/dist/utils/tools-manager.impl.js.map +1 -0
- package/dist/utils/tools-manager.js +35 -2
- package/dist/utils/windows-cwd.js +585 -0
- package/dist/utils/windows-cwd.js.map +1 -0
- package/docs/extensions.md +1 -1
- package/docs/getting-started/installation.md +2 -0
- package/docs/intercom/operations.md +1 -0
- package/docs/reference/cli.md +2 -2
- package/package.json +24 -24
- package/dist/_shared/mode-shared-HP7GUA7J.js.map +0 -1
- package/dist/_shared/p1a-prewarm-YK3KDTLN.js.map +0 -1
- package/dist/_shared/p1b-elig-PXQA2FYP.js.map +0 -1
- package/dist/_shared/startup-0-0-X4NF3GKM.js.map +0 -1
- package/dist/_shared/startup-0-1-7QTG6VJZ.js.map +0 -1
- package/dist/_shared/startup-0-2-KFDYPDJK.js.map +0 -1
- package/dist/_shared/startup-8-1-KQJBDKRU.js.map +0 -1
|
@@ -1,618 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
* How long a script waits for a free worker before failing. Bounds the wait when every worker is
|
|
20
|
-
* held by a script that waits on another script, for example an in-process subagent that uses codemode.
|
|
21
|
-
*/
|
|
22
|
-
const CODEMODE_WORKER_WAIT_MS = 6e4;
|
|
23
|
-
let activeCodemodeWorkers = 0;
|
|
24
|
-
/** Scripts waiting for a worker, in arrival order. */
|
|
25
|
-
const codemodeWorkerWaiters = [];
|
|
26
|
-
/**
|
|
27
|
-
* Reserve one worker slot, waiting in arrival order while all are taken. Resolves with why it could
|
|
28
|
-
* not reserve one: the signal aborted, or `timeoutMs` passed.
|
|
29
|
-
*/
|
|
30
|
-
function reserveCodemodeWorker(signal, timeoutMs) {
|
|
31
|
-
if (signal?.aborted) return Promise.resolve("aborted");
|
|
32
|
-
return new Promise((resolve) => {
|
|
33
|
-
const settle = (outcome) => {
|
|
34
|
-
clearTimeout(timer);
|
|
35
|
-
signal?.removeEventListener("abort", onAbort);
|
|
36
|
-
const index = codemodeWorkerWaiters.indexOf(grant);
|
|
37
|
-
if (index >= 0) codemodeWorkerWaiters.splice(index, 1);
|
|
38
|
-
resolve(outcome);
|
|
39
|
-
};
|
|
40
|
-
const grant = () => settle("reserved");
|
|
41
|
-
const onAbort = () => settle("aborted");
|
|
42
|
-
const timer = setTimeout(() => settle("timeout"), timeoutMs);
|
|
43
|
-
codemodeWorkerWaiters.push(grant);
|
|
44
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
45
|
-
admitCodemodeWorkers();
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/** Give free slots to waiting scripts in arrival order. */
|
|
49
|
-
function admitCodemodeWorkers() {
|
|
50
|
-
while (codemodeWorkerWaiters.length > 0 && activeCodemodeWorkers < maxCodemodeWorkers()) {
|
|
51
|
-
activeCodemodeWorkers++;
|
|
52
|
-
codemodeWorkerWaiters.shift()?.();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function releaseCodemodeWorker() {
|
|
56
|
-
activeCodemodeWorkers--;
|
|
57
|
-
admitCodemodeWorkers();
|
|
58
|
-
}
|
|
59
|
-
const IMAGE_EXTENSIONS = {
|
|
60
|
-
"image/png": ".png",
|
|
61
|
-
"image/jpeg": ".jpg",
|
|
62
|
-
"image/gif": ".gif",
|
|
63
|
-
"image/webp": ".webp"
|
|
64
|
-
};
|
|
65
|
-
const SVG_MIME_TYPE = "image/svg+xml";
|
|
66
|
-
/** `image()` cannot show SVG, so generated SVG documents are saved by the host and named in the result. */
|
|
67
|
-
async function saveSvgs(svgs) {
|
|
68
|
-
const unique = [...new Map(svgs.map((svg) => [svg.data, svg])).values()];
|
|
69
|
-
return Promise.all(unique.map(async ({ data }) => {
|
|
70
|
-
const bytes = Buffer.from(data, "base64");
|
|
71
|
-
const kind = `${SVG_MIME_TYPE}, ${formatSize(bytes.length)}`;
|
|
72
|
-
try {
|
|
73
|
-
return {
|
|
74
|
-
type: "text",
|
|
75
|
-
text: `[SVG saved to ${await writeOutputFile("atomic-codemode", ".svg", bytes)} (${kind})]`
|
|
76
|
-
};
|
|
77
|
-
} catch (error) {
|
|
78
|
-
return {
|
|
79
|
-
type: "text",
|
|
80
|
-
text: `[SVG (${kind}) could not be saved: ${error instanceof Error ? error.message : String(error)}]`
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
async function saveImages(items) {
|
|
86
|
-
const labels = /* @__PURE__ */ new Map();
|
|
87
|
-
const label = async ({ data, mimeType }) => {
|
|
88
|
-
const bytes = Buffer.from(data, "base64");
|
|
89
|
-
const kind = `${mimeType}, ${formatSize(bytes.length)}`;
|
|
90
|
-
const extension = IMAGE_EXTENSIONS[mimeType];
|
|
91
|
-
if (!extension) throw new Error(`No file extension for image type ${mimeType}`);
|
|
92
|
-
try {
|
|
93
|
-
return `[Image saved to ${await writeOutputFile("atomic-codemode", extension, bytes)} (${kind})]`;
|
|
94
|
-
} catch (error) {
|
|
95
|
-
return `[Image (${kind}) could not be saved: ${error instanceof Error ? error.message : String(error)}]`;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
return (await Promise.all(items.map(async (item) => {
|
|
99
|
-
if (item.type !== "image") return [item];
|
|
100
|
-
let pending = labels.get(item.data);
|
|
101
|
-
if (!pending) {
|
|
102
|
-
pending = label(item);
|
|
103
|
-
labels.set(item.data, pending);
|
|
104
|
-
}
|
|
105
|
-
return [{
|
|
106
|
-
type: "text",
|
|
107
|
-
text: await pending
|
|
108
|
-
}, item];
|
|
109
|
-
}))).flat();
|
|
110
|
-
}
|
|
111
|
-
function readCodemodeStore(branch) {
|
|
112
|
-
const store = /* @__PURE__ */ new Map();
|
|
113
|
-
for (const entry of branch) {
|
|
114
|
-
if (entry.type !== "custom" || entry.customType !== "codemode-store" || typeof entry.data !== "object" || entry.data === null) continue;
|
|
115
|
-
const data = entry.data;
|
|
116
|
-
if (!data.set || typeof data.set !== "object" || !Array.isArray(data.delete) || !data.delete.every((key) => typeof key === "string")) continue;
|
|
117
|
-
for (const key of data.delete) store.delete(key);
|
|
118
|
-
for (const [key, value] of Object.entries(data.set)) store.set(key, value);
|
|
119
|
-
}
|
|
120
|
-
return Object.fromEntries(store);
|
|
121
|
-
}
|
|
122
|
-
function textOf(result) {
|
|
123
|
-
return result.content.filter((block) => block.type === "text").map((block) => block.text).join("\n");
|
|
124
|
-
}
|
|
125
|
-
/** Explicit public catalog fields. Provider configuration and credential-bearing URLs never cross into the VM. */
|
|
126
|
-
function toCodemodeModelInfo(model) {
|
|
127
|
-
return {
|
|
128
|
-
type: model.type,
|
|
129
|
-
provider: model.provider,
|
|
130
|
-
id: model.id,
|
|
131
|
-
name: model.name,
|
|
132
|
-
api: model.api,
|
|
133
|
-
input: model.input,
|
|
134
|
-
..."reasoning" in model ? { reasoning: model.reasoning } : {},
|
|
135
|
-
..."contextWindow" in model ? { contextWindow: model.contextWindow } : {},
|
|
136
|
-
..."maxTokens" in model ? { maxTokens: model.maxTokens } : {},
|
|
137
|
-
cost: isModelType(model, "chat") ? model.fastRoute?.serviceTier && getServiceTierCost(model, model.fastRoute.serviceTier) || model.cost : model.cost
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
/** Separate text items and collect console calls after the script's other output. */
|
|
141
|
-
function formatOutput(output) {
|
|
142
|
-
const total = output.filter((item) => item.type === "text" && !item.console).length;
|
|
143
|
-
const items = [];
|
|
144
|
-
const consoleLines = [];
|
|
145
|
-
let index = 0;
|
|
146
|
-
for (const item of output) if (item.type === "image") items.push(item);
|
|
147
|
-
else if (item.console) consoleLines.push(item.text);
|
|
148
|
-
else {
|
|
149
|
-
index++;
|
|
150
|
-
items.push({
|
|
151
|
-
type: "text",
|
|
152
|
-
text: total > 1 ? `==> text ${index}/${total} <==\n${item.text}` : item.text
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if (consoleLines.length > 0) items.push({
|
|
156
|
-
type: "text",
|
|
157
|
-
text: `<console_output>\n${consoleLines.join("\n")}\n</console_output>`
|
|
158
|
-
});
|
|
159
|
-
return items;
|
|
160
|
-
}
|
|
161
|
-
/** Providers may concatenate adjacent text blocks without a separator. */
|
|
162
|
-
function joinAdjacentText(items) {
|
|
163
|
-
const joined = [];
|
|
164
|
-
let parts = [];
|
|
165
|
-
let lastPart = "";
|
|
166
|
-
const flush = () => {
|
|
167
|
-
if (parts.length > 0) joined.push({
|
|
168
|
-
type: "text",
|
|
169
|
-
text: parts.join("")
|
|
170
|
-
});
|
|
171
|
-
parts = [];
|
|
172
|
-
lastPart = "";
|
|
173
|
-
};
|
|
174
|
-
for (const item of items) {
|
|
175
|
-
if (item.type !== "text") {
|
|
176
|
-
flush();
|
|
177
|
-
joined.push(item);
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
if (lastPart !== "" && !lastPart.endsWith("\n")) {
|
|
181
|
-
parts.push("\n");
|
|
182
|
-
lastPart = "\n";
|
|
183
|
-
}
|
|
184
|
-
parts.push(item.text);
|
|
185
|
-
if (item.text !== "") lastPart = item.text;
|
|
186
|
-
}
|
|
187
|
-
flush();
|
|
188
|
-
return joined;
|
|
189
|
-
}
|
|
190
|
-
const MODEL_TYPES = [
|
|
191
|
-
"chat",
|
|
192
|
-
"image",
|
|
193
|
-
"classifier"
|
|
194
|
-
];
|
|
195
|
-
function modelType(value) {
|
|
196
|
-
if (value === "chat" || value === "image" || value === "classifier") return value;
|
|
197
|
-
throw new Error("Model type must be \"chat\", \"image\", or \"classifier\"");
|
|
198
|
-
}
|
|
199
|
-
function withArticle(word) {
|
|
200
|
-
return `${/^[aeiou]/.test(word) ? "an" : "a"} ${word}`;
|
|
201
|
-
}
|
|
202
|
-
function isRecord(value) {
|
|
203
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
204
|
-
}
|
|
205
|
-
function describeValue(value) {
|
|
206
|
-
if (value === void 0 || value === null) return String(value);
|
|
207
|
-
if (Array.isArray(value)) return value.length === 0 ? "an empty array" : "an array";
|
|
208
|
-
if (typeof value === "object") {
|
|
209
|
-
const keys = Object.keys(value);
|
|
210
|
-
if (keys.length === 0) return "{}";
|
|
211
|
-
return `{ ${keys.slice(0, 6).join(", ")}${keys.length > 6 ? ", ..." : ""} }`;
|
|
212
|
-
}
|
|
213
|
-
return typeof value === "string" ? "a string" : `a ${typeof value}`;
|
|
214
|
-
}
|
|
215
|
-
const CLASSIFIER_CONTEXT_SHAPE = "{ state: { ... }, images?: [{ type: \"image\", data: <base64>, mimeType }], questions: { <id>: { type: \"choice\", instructions, criteria: { <label>: <meaning> } } | { type: \"score\", instructions, criteria: [<lowest level>, ..., <highest level>] } | { type: \"bool\", instructions, criteria: { true: <meaning>, false: <meaning> } } } }";
|
|
216
|
-
function checkClassifierContext(context) {
|
|
217
|
-
const fail = (problem) => /* @__PURE__ */ new Error(`models.classify() ${problem}. Expected context: ${CLASSIFIER_CONTEXT_SHAPE}. See "Classify" in ${CODEMODE_DOCS_PATH}.`);
|
|
218
|
-
if (!isRecord(context)) throw fail(`expects a context object as its second argument, got ${describeValue(context)}`);
|
|
219
|
-
if (!isRecord(context.state)) throw fail(`context.state must be an object, got ${describeValue(context.state)}`);
|
|
220
|
-
const { images } = context;
|
|
221
|
-
if (images !== void 0) {
|
|
222
|
-
if (!Array.isArray(images)) throw fail(`context.images must be an array, got ${describeValue(images)}`);
|
|
223
|
-
images.forEach((image, index) => {
|
|
224
|
-
if (!isRecord(image) || image.type !== "image" || typeof image.data !== "string" || typeof image.mimeType !== "string") throw fail(`context.images[${index}] must be an image block, got ${describeValue(image)}`);
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
const { questions } = context;
|
|
228
|
-
if (!isRecord(questions) || Object.keys(questions).length === 0) throw fail(`context.questions must map question IDs to questions, got ${describeValue(questions)}`);
|
|
229
|
-
const isStrings = (values) => values.length > 0 && values.every((value) => typeof value === "string");
|
|
230
|
-
for (const [questionId, question] of Object.entries(questions)) {
|
|
231
|
-
const at = `context.questions.${questionId}`;
|
|
232
|
-
if (!isRecord(question)) throw fail(`${at} must be a question object, got ${describeValue(question)}`);
|
|
233
|
-
if (typeof question.instructions !== "string") throw fail(`${at}.instructions must be a string`);
|
|
234
|
-
const { criteria } = question;
|
|
235
|
-
if (question.type === "choice") {
|
|
236
|
-
if (!isRecord(criteria) || !isStrings(Object.values(criteria))) throw fail(`${at} is a "choice" question, so criteria must map each label to its meaning`);
|
|
237
|
-
} else if (question.type === "score") {
|
|
238
|
-
if (!Array.isArray(criteria) || !isStrings(criteria)) throw fail(`${at} is a "score" question, so criteria must list the levels as strings, lowest first`);
|
|
239
|
-
} else if (question.type === "bool") {
|
|
240
|
-
if (!isRecord(criteria) || typeof criteria.true !== "string" || typeof criteria.false !== "string") throw fail(`${at} is a "bool" question, so criteria must be { true: string, false: string }`);
|
|
241
|
-
} else throw fail(`${at}.type must be "choice", "score", or "bool", got ${JSON.stringify(question.type)}`);
|
|
242
|
-
}
|
|
243
|
-
return context;
|
|
244
|
-
}
|
|
245
|
-
function checkImagesContext(context) {
|
|
246
|
-
const fail = (problem) => /* @__PURE__ */ new Error(`models.generateImages() ${problem}. Expected context: { input: [{ type: "text", text: <prompt> }, ...optional { type: "image", data: <base64>, mimeType } references] }. See "Generate images" in ${CODEMODE_DOCS_PATH}.`);
|
|
247
|
-
if (!isRecord(context)) throw fail(`expects a context object as its second argument, got ${describeValue(context)}`);
|
|
248
|
-
const { input } = context;
|
|
249
|
-
if (!Array.isArray(input) || input.length === 0) throw fail(`context.input must be a non-empty array of blocks, got ${describeValue(input)}`);
|
|
250
|
-
input.forEach((block, index) => {
|
|
251
|
-
if (isRecord(block) && block.type === "text" && typeof block.text === "string") return;
|
|
252
|
-
if (isRecord(block) && block.type === "image" && typeof block.data === "string" && typeof block.mimeType === "string") {
|
|
253
|
-
if (block.role === void 0 || IMAGE_ROLES.includes(block.role)) return;
|
|
254
|
-
throw fail(`context.input[${index}].role must be "markup" or "mask" when set, got ${describeValue(block.role)}`);
|
|
255
|
-
}
|
|
256
|
-
throw fail(`context.input[${index}] must be a text or image block, got ${describeValue(block)}`);
|
|
257
|
-
});
|
|
258
|
-
return context;
|
|
259
|
-
}
|
|
260
|
-
const IMAGE_ROLES = ["markup", "mask"];
|
|
261
|
-
const IMAGE_REQUEST_OPTIONS = [
|
|
262
|
-
"size",
|
|
263
|
-
"quality",
|
|
264
|
-
"n",
|
|
265
|
-
"background",
|
|
266
|
-
"outputFormat",
|
|
267
|
-
"outputCompression",
|
|
268
|
-
"frameCount",
|
|
269
|
-
"frameDurationMs",
|
|
270
|
-
"complexity",
|
|
271
|
-
"svg",
|
|
272
|
-
"moderation",
|
|
273
|
-
"safetyIdentifier"
|
|
274
|
-
];
|
|
275
|
-
/** Only request-shaping options reach the provider: scripts never supply credentials, headers, fetch or hooks. */
|
|
276
|
-
function checkImageOptions(options) {
|
|
277
|
-
if (options === void 0 || options === null) return {};
|
|
278
|
-
const allowed = IMAGE_REQUEST_OPTIONS.join(", ");
|
|
279
|
-
if (!isRecord(options)) throw new Error(`models.generateImages() expects options as its third argument to be an object, got ${describeValue(options)}. Allowed options: ${allowed}. See "Generate images" in ${CODEMODE_DOCS_PATH}.`);
|
|
280
|
-
const rejected = Object.keys(options).filter((key) => !IMAGE_REQUEST_OPTIONS.includes(key));
|
|
281
|
-
if (rejected.length > 0) throw new Error(`models.generateImages() does not accept the option ${rejected.map((key) => `"${key}"`).join(", ")}. Allowed options: ${allowed}. See "Generate images" in ${CODEMODE_DOCS_PATH}.`);
|
|
282
|
-
return Object.fromEntries(IMAGE_REQUEST_OPTIONS.flatMap((key) => options[key] === void 0 ? [] : [[key, options[key]]]));
|
|
283
|
-
}
|
|
284
|
-
function provider(value) {
|
|
285
|
-
if (value === void 0 || value === null) return void 0;
|
|
286
|
-
if (typeof value === "string") return value;
|
|
287
|
-
throw new Error("provider must be a string");
|
|
288
|
-
}
|
|
289
|
-
function preview(args) {
|
|
290
|
-
try {
|
|
291
|
-
return (JSON.stringify(args) ?? "").slice(0, 200);
|
|
292
|
-
} catch {
|
|
293
|
-
return "";
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
function createLimiter(limit) {
|
|
297
|
-
let active = 0;
|
|
298
|
-
const waiting = [];
|
|
299
|
-
return async (run) => {
|
|
300
|
-
if (active >= limit) await new Promise((resolve) => waiting.push(resolve));
|
|
301
|
-
active++;
|
|
302
|
-
try {
|
|
303
|
-
return await run();
|
|
304
|
-
} finally {
|
|
305
|
-
active--;
|
|
306
|
-
waiting.shift()?.();
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* The script-callable tool another form of its name names (`mcp.<server>.<tool>`,
|
|
312
|
-
* `mcp__<raw-server>__<tool>`, `<server>__<tool>`, `<tool>`), or `undefined`. Throws, listing the
|
|
313
|
-
* matching names, when the form names more than one tool (#4065).
|
|
314
|
-
*/
|
|
315
|
-
function resolveScriptTool(tools, query) {
|
|
316
|
-
const names = resolveToolNames(query, tools.map((tool) => tool.name));
|
|
317
|
-
if (names.length > 1) throw new Error(`Tool name "${query}" is ambiguous; it matches ${names.map((name) => toCodemodeIdentifier(name)).join(", ")}. Use one of these names.`);
|
|
318
|
-
return tools.find((tool) => tool.name === names[0]);
|
|
319
|
-
}
|
|
320
|
-
function discoveryGlobals(tools, samples, options) {
|
|
321
|
-
const entry = (name) => ({
|
|
322
|
-
name: toCodemodeIdentifier(name),
|
|
323
|
-
description: samples.get(name) ?? ""
|
|
324
|
-
});
|
|
325
|
-
const modelOnly = (query) => {
|
|
326
|
-
const wanted = query.trim().toLowerCase();
|
|
327
|
-
const name = options.getModelOnlyTools?.().find((name) => name !== "codemode" && !tools.some((tool) => tool.name === name) && [name, toCodemodeIdentifier(name)].some((candidate) => candidate.toLowerCase() === wanted));
|
|
328
|
-
return name ? {
|
|
329
|
-
name,
|
|
330
|
-
description: `\`${name}\` is model-only: call it directly as a top-level tool, not from a script.`
|
|
331
|
-
} : void 0;
|
|
332
|
-
};
|
|
333
|
-
return [
|
|
334
|
-
{
|
|
335
|
-
name: "searchTools",
|
|
336
|
-
spread: true,
|
|
337
|
-
execute: (args) => {
|
|
338
|
-
const [query, config] = args;
|
|
339
|
-
if (typeof query !== "string") throw new Error("searchTools() expects a query string");
|
|
340
|
-
const limit = config?.limit ?? 8;
|
|
341
|
-
if (typeof limit !== "number" || !Number.isInteger(limit) || limit <= 0) throw new Error("searchTools() limit must be a positive integer");
|
|
342
|
-
if (config?.namespace !== void 0 && typeof config.namespace !== "string") throw new Error("searchTools() namespace must be a string");
|
|
343
|
-
const docs = tools.flatMap((tool) => {
|
|
344
|
-
const namespace = options.getToolNamespace?.(tool.name);
|
|
345
|
-
return config?.namespace && namespace?.name !== config.namespace ? [] : [createToolSearchDocument(tool, namespace)];
|
|
346
|
-
});
|
|
347
|
-
const hint = config?.namespace ? void 0 : modelOnly(query);
|
|
348
|
-
const matches = new Bm25Ranker().rank(query, docs, limit).map((match) => entry(match.name));
|
|
349
|
-
return hint ? [hint, ...matches].slice(0, limit) : matches;
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
name: "describeTool",
|
|
354
|
-
spread: true,
|
|
355
|
-
execute: (args) => {
|
|
356
|
-
const [name] = args;
|
|
357
|
-
if (typeof name !== "string") throw new Error("describeTool() expects a tool name");
|
|
358
|
-
const tool = tools.find((tool) => tool.name === name || toCodemodeIdentifier(tool.name) === name) ?? resolveScriptTool(tools, name);
|
|
359
|
-
return tool ? samples.get(tool.name) : modelOnly(name)?.description;
|
|
360
|
-
}
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
name: "describeNamespace",
|
|
364
|
-
spread: true,
|
|
365
|
-
execute: (args) => {
|
|
366
|
-
const [name] = args;
|
|
367
|
-
if (typeof name !== "string") throw new Error("describeNamespace() expects a namespace name");
|
|
368
|
-
let namespace;
|
|
369
|
-
const names = [];
|
|
370
|
-
for (const tool of tools) {
|
|
371
|
-
const toolNamespace = options.getToolNamespace?.(tool.name);
|
|
372
|
-
if (toolNamespace?.name !== name) continue;
|
|
373
|
-
namespace ??= toolNamespace;
|
|
374
|
-
names.push(toCodemodeIdentifier(tool.name));
|
|
375
|
-
}
|
|
376
|
-
if (!namespace) return void 0;
|
|
377
|
-
return {
|
|
378
|
-
name,
|
|
379
|
-
...namespace.description ? { description: namespace.description } : {},
|
|
380
|
-
...namespace.instructions ? { instructions: namespace.instructions } : {},
|
|
381
|
-
tools: names
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
];
|
|
386
|
-
}
|
|
387
|
-
function modelGlobals(ctx, id, calls, publish, addUsage, addGeneratedImages) {
|
|
388
|
-
const models = ctx.modelRegistry;
|
|
389
|
-
const limit = createLimiter(4);
|
|
390
|
-
let count = 0;
|
|
391
|
-
const runModelCall = async (name, type, [ref, context, callOptions], checkContext, run) => {
|
|
392
|
-
const listHint = `List the ${type} models you can use with models.getAvailableOfType("${type}").`;
|
|
393
|
-
if (!isRecord(ref) || typeof ref.provider !== "string" || typeof ref.id !== "string") {
|
|
394
|
-
const undefinedHint = ref === void 0 || ref === null ? " models.getModelOfType() returns undefined for an unknown provider or id." : "";
|
|
395
|
-
throw new Error(`${name}() expects ${withArticle(type)} model as its first argument, got ${describeValue(ref)}.${undefinedHint} ${listHint}`);
|
|
396
|
-
}
|
|
397
|
-
const { provider: providerId, id: modelId } = ref;
|
|
398
|
-
const model = models.getModelOfType(type, providerId, modelId);
|
|
399
|
-
if (!model) {
|
|
400
|
-
const actualType = MODEL_TYPES.find((other) => other !== type && models.getModelOfType(other, providerId, modelId) !== void 0);
|
|
401
|
-
throw new Error(actualType ? `"${providerId}/${modelId}" is ${withArticle(actualType)} model, not ${withArticle(type)} model. ${listHint}` : `Unknown ${type} model "${providerId}/${modelId}". ${listHint}`);
|
|
402
|
-
}
|
|
403
|
-
const checked = checkContext(context);
|
|
404
|
-
const checkedOptions = type === "image" ? checkImageOptions(callOptions) : void 0;
|
|
405
|
-
const record = {
|
|
406
|
-
id: `${id}/${name}/${++count}`,
|
|
407
|
-
name,
|
|
408
|
-
args: `${model.provider}/${model.id}`,
|
|
409
|
-
status: "running"
|
|
410
|
-
};
|
|
411
|
-
calls.push(record);
|
|
412
|
-
publish();
|
|
413
|
-
const start = performance.now();
|
|
414
|
-
const result = await limit(() => run(model, checked, checkedOptions));
|
|
415
|
-
record.durationMs = performance.now() - start;
|
|
416
|
-
record.status = result.stopReason === "stop" ? "ok" : result.stopReason === "aborted" ? "cancelled" : "error";
|
|
417
|
-
if (result.errorMessage) record.error = result.errorMessage.slice(0, 500);
|
|
418
|
-
if (result.usage) {
|
|
419
|
-
record.cost = result.usage.cost.total;
|
|
420
|
-
addUsage(result.usage);
|
|
421
|
-
}
|
|
422
|
-
publish();
|
|
423
|
-
return result;
|
|
424
|
-
};
|
|
425
|
-
return [
|
|
426
|
-
{
|
|
427
|
-
name: "models.getModelsOfType",
|
|
428
|
-
spread: true,
|
|
429
|
-
execute: (args) => {
|
|
430
|
-
const [type, source] = args;
|
|
431
|
-
return models.getModelsOfType(modelType(type), provider(source)).map(toCodemodeModelInfo);
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
name: "models.getAvailableOfType",
|
|
436
|
-
spread: true,
|
|
437
|
-
execute: async (args, { signal }) => {
|
|
438
|
-
const [type, source] = args;
|
|
439
|
-
return (await models.getAvailableOfType(modelType(type), provider(source), { signal })).map(toCodemodeModelInfo);
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
name: "models.getModelOfType",
|
|
444
|
-
spread: true,
|
|
445
|
-
execute: (args) => {
|
|
446
|
-
const [type, source, modelId] = args;
|
|
447
|
-
if (typeof source !== "string" || typeof modelId !== "string") throw new Error(`models.getModelOfType(type, provider, id) expects three strings, got (${args.map(describeValue).join(", ")}). The provider and the id are separate arguments, for example models.getModelOfType("classifier", "typesafe", "jev-latest").`);
|
|
448
|
-
const model = models.getModelOfType(modelType(type), source, modelId);
|
|
449
|
-
return model ? toCodemodeModelInfo(model) : void 0;
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
name: "models.classify",
|
|
454
|
-
spread: true,
|
|
455
|
-
execute: (args, { signal }) => runModelCall("models.classify", "classifier", args, checkClassifierContext, (model, context) => models.classify(model, context, { signal }))
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
name: "models.generateImages",
|
|
459
|
-
spread: true,
|
|
460
|
-
execute: (args, { signal }) => runModelCall("models.generateImages", "image", args, checkImagesContext, async (model, context, callOptions) => {
|
|
461
|
-
const result = await models.generateImages(model, context, {
|
|
462
|
-
...callOptions,
|
|
463
|
-
signal
|
|
464
|
-
});
|
|
465
|
-
addGeneratedImages(result.output.filter((block) => block.type === "image"));
|
|
466
|
-
return result;
|
|
467
|
-
})
|
|
468
|
-
}
|
|
469
|
-
];
|
|
470
|
-
}
|
|
471
|
-
async function executeCodemode(id, input, signal, update, ctx, options = {}) {
|
|
472
|
-
const start = performance.now();
|
|
473
|
-
const { code, options: source } = parseCodemodeSource(input.code);
|
|
474
|
-
const calls = [];
|
|
475
|
-
let usage;
|
|
476
|
-
let generatedImages = 0;
|
|
477
|
-
const generatedSvgs = [];
|
|
478
|
-
const snapshot = () => ({ calls: calls.map((call) => ({ ...call })) });
|
|
479
|
-
const publish = () => update?.({
|
|
480
|
-
content: [],
|
|
481
|
-
details: snapshot()
|
|
482
|
-
});
|
|
483
|
-
publish();
|
|
484
|
-
const callable = ctx ? getCodemodeCallableTools(ctx.tools) : [];
|
|
485
|
-
const guidelines = options.getToolGuidelines?.();
|
|
486
|
-
const samples = new Map(callable.map((tool) => [tool.name, renderToolSample(toCodemodeDeclaration(tool, guidelines?.get(tool.name)))]));
|
|
487
|
-
const deadline = source.timeoutMs ?? Number.POSITIVE_INFINITY;
|
|
488
|
-
const waitStartedAt = performance.now();
|
|
489
|
-
const admission = await reserveCodemodeWorker(signal, Math.min(deadline, CODEMODE_WORKER_WAIT_MS));
|
|
490
|
-
const waitedMs = performance.now() - waitStartedAt;
|
|
491
|
-
if (admission !== "reserved") {
|
|
492
|
-
const waited = ((performance.now() - start) / 1e3).toFixed(1);
|
|
493
|
-
const reason = signal?.reason;
|
|
494
|
-
const error = admission === "aborted" ? `Script aborted: ${reason instanceof Error ? reason.message : "Execution aborted"}` : deadline <= CODEMODE_WORKER_WAIT_MS ? `Script timed out: Execution timed out after ${deadline} ms while waiting for a free codemode worker` : `No codemode worker became free within ${CODEMODE_WORKER_WAIT_MS / 1e3} seconds. All ${maxCodemodeWorkers()} workers, shared by every session in this process, are held by other scripts. Retry after they finish.`;
|
|
495
|
-
return {
|
|
496
|
-
content: [{
|
|
497
|
-
type: "text",
|
|
498
|
-
text: `Script failed\nWall time ${waited} seconds\nOutput:\n`
|
|
499
|
-
}, {
|
|
500
|
-
type: "text",
|
|
501
|
-
text: `Script error:\n${error}\n\nThe script did not start.`
|
|
502
|
-
}],
|
|
503
|
-
details: snapshot(),
|
|
504
|
-
isError: true
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
let reserved = true;
|
|
508
|
-
let sandbox;
|
|
509
|
-
let result;
|
|
510
|
-
try {
|
|
511
|
-
const workerUrl = await getCodemodeWorkerUrlAsync();
|
|
512
|
-
sandbox = new CodemodeSandbox({
|
|
513
|
-
tools: callable.map((tool) => ({
|
|
514
|
-
name: tool.name,
|
|
515
|
-
description: samples.get(tool.name),
|
|
516
|
-
execute: async (args, { signal: callSignal }) => {
|
|
517
|
-
const record = {
|
|
518
|
-
id: `${id}/?`,
|
|
519
|
-
name: tool.name,
|
|
520
|
-
args: preview(args),
|
|
521
|
-
status: "running"
|
|
522
|
-
};
|
|
523
|
-
calls.push(record);
|
|
524
|
-
publish();
|
|
525
|
-
const started = performance.now();
|
|
526
|
-
if (!ctx) throw new Error("Tool calls need a session");
|
|
527
|
-
const outcome = await ctx.executeTool(tool.name, args, { signal: callSignal });
|
|
528
|
-
record.id = outcome.toolCall.id;
|
|
529
|
-
record.durationMs = performance.now() - started;
|
|
530
|
-
record.status = outcome.isError ? callSignal.aborted ? "cancelled" : "error" : "ok";
|
|
531
|
-
const text = textOf(outcome.result);
|
|
532
|
-
if (outcome.isError) record.error = (text || `Tool ${tool.name} failed`).slice(0, 500);
|
|
533
|
-
publish();
|
|
534
|
-
if (tool.outputSchema && outcome.result.structuredContent !== void 0) return outcome.result.structuredContent;
|
|
535
|
-
if (outcome.isError) throw new Error(text || `Tool ${tool.name} failed`);
|
|
536
|
-
return text;
|
|
1
|
+
// Written by the build (scripts/in-place-update-gate.mjs): when this module's code cannot load in a process of an earlier release
|
|
2
|
+
// that an in-place update left running, the process is told to restart.
|
|
3
|
+
let module;
|
|
4
|
+
try {
|
|
5
|
+
module = await import("./execute.code.js");
|
|
6
|
+
} catch (error) {
|
|
7
|
+
const root = new URL("../../", import.meta.url);
|
|
8
|
+
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
+
const key = `${root.href}#0.10.5-alpha.1`;
|
|
10
|
+
let release = releases.get(key);
|
|
11
|
+
if (release === undefined) {
|
|
12
|
+
const current = (async () => {
|
|
13
|
+
for (const path of ["modes/interactive/interactive-mode-deps.js","_shared/chunk-CDOYTDYM.js","_shared/p0-cli-GUFK7TPN.js"]) {
|
|
14
|
+
try {
|
|
15
|
+
const held = await import(new URL(path, root).href);
|
|
16
|
+
if (typeof held.VERSION === "string") return { version: held.VERSION, name: held.APP_NAME };
|
|
17
|
+
} catch {
|
|
18
|
+
// Not a file this process can load: the next.
|
|
537
19
|
}
|
|
538
|
-
})),
|
|
539
|
-
globals: [...discoveryGlobals(callable, samples, options), ...options.models && ctx && ctx.subagentPolicy?.codemodeRoutingOnly !== true ? modelGlobals(ctx, id, calls, publish, (extra) => {
|
|
540
|
-
usage = usage ? combineUsage(usage, extra) : extra;
|
|
541
|
-
}, (images) => {
|
|
542
|
-
for (const image of images) if (image.mimeType === SVG_MIME_TYPE) generatedSvgs.push(image);
|
|
543
|
-
else generatedImages++;
|
|
544
|
-
}) : []],
|
|
545
|
-
timeoutMs: Math.max(1, Math.round(deadline - waitedMs)),
|
|
546
|
-
memoryLimitBytes: 268435456,
|
|
547
|
-
wasm: loadQuickJSWasm(getQuickJSWasmPath()),
|
|
548
|
-
workerUrl,
|
|
549
|
-
acquireWorker: () => {
|
|
550
|
-
if (!reserved) throw new Error("The script already settled");
|
|
551
|
-
reserved = false;
|
|
552
|
-
return releaseCodemodeWorker;
|
|
553
20
|
}
|
|
21
|
+
return undefined;
|
|
22
|
+
})().then((found) => {
|
|
23
|
+
if (found === undefined && releases.get(key) === current) releases.delete(key);
|
|
24
|
+
return found;
|
|
554
25
|
});
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
store: ctx ? readCodemodeStore(ctx.sessionManager.getBranch()) : {}
|
|
558
|
-
});
|
|
559
|
-
} finally {
|
|
560
|
-
await sandbox?.close();
|
|
561
|
-
if (reserved) {
|
|
562
|
-
reserved = false;
|
|
563
|
-
releaseCodemodeWorker();
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
for (const call of calls) if (call.status === "running") call.status = "cancelled";
|
|
567
|
-
const scriptOutput = [...result.output];
|
|
568
|
-
if (result.ok) {
|
|
569
|
-
if (Object.keys(result.storeWrites.set).length || result.storeWrites.delete.length) await options.appendEntry?.(CODEMODE_STORE_ENTRY_TYPE, result.storeWrites);
|
|
570
|
-
if (result.value !== void 0) scriptOutput.push({
|
|
571
|
-
type: "text",
|
|
572
|
-
text: typeof result.value === "string" ? result.value : JSON.stringify(result.value) ?? String(result.value)
|
|
573
|
-
});
|
|
26
|
+
releases.set(key, current);
|
|
27
|
+
release = current;
|
|
574
28
|
}
|
|
575
|
-
|
|
576
|
-
if (
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
});
|
|
580
|
-
if (generatedImages > 0 && !content.some((block) => block.type === "image")) content.push({
|
|
581
|
-
type: "text",
|
|
582
|
-
text: `Note: models.generateImages() returned ${generatedImages} image${generatedImages === 1 ? "" : "s"} that the script did not show. Show each image block of result.output with image(block).`
|
|
29
|
+
const running = await release;
|
|
30
|
+
if (running === undefined || running.version === "0.10.5-alpha.1") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.5-alpha.1 while this session was running; restart it to keep using codemode.", {
|
|
32
|
+
cause: error,
|
|
583
33
|
});
|
|
584
|
-
content = joinAdjacentText(content);
|
|
585
|
-
const text = content.filter((block) => block.type === "text").map((block) => block.text).join("\n");
|
|
586
|
-
const budget = (source.maxOutputTokens ?? 1e4) * 4;
|
|
587
|
-
const details = snapshot();
|
|
588
|
-
if (text.length > budget) {
|
|
589
|
-
let path;
|
|
590
|
-
let notice;
|
|
591
|
-
try {
|
|
592
|
-
path = await writeOutputFile("atomic-codemode", ".txt", text);
|
|
593
|
-
details.fullOutputPath = path;
|
|
594
|
-
notice = `Full output: ${path}`;
|
|
595
|
-
} catch (error) {
|
|
596
|
-
notice = `Could not save full output: ${error instanceof Error ? error.message : String(error)}`;
|
|
597
|
-
}
|
|
598
|
-
const head = Math.floor(budget / 2);
|
|
599
|
-
const tail = budget - head;
|
|
600
|
-
content = [{
|
|
601
|
-
type: "text",
|
|
602
|
-
text: `Warning: truncated output (original token count: ${Math.ceil(text.length / 4)})\n${sliceHead(text, head)}\n... output truncated ...\n${sliceTail(text, tail)}\n${notice}`
|
|
603
|
-
}, ...content.filter((block) => block.type === "image")];
|
|
604
|
-
}
|
|
605
|
-
content = joinAdjacentText([...await saveImages(content), ...await saveSvgs(generatedSvgs)]);
|
|
606
|
-
return {
|
|
607
|
-
content: [{
|
|
608
|
-
type: "text",
|
|
609
|
-
text: `${result.ok ? "Script completed" : "Script failed"}\nWall time ${((performance.now() - start) / 1e3).toFixed(1)} seconds\nOutput:\n`
|
|
610
|
-
}, ...content],
|
|
611
|
-
details,
|
|
612
|
-
...usage ? { usage } : {},
|
|
613
|
-
...result.ok ? {} : { isError: true }
|
|
614
|
-
};
|
|
615
34
|
}
|
|
616
|
-
export { executeCodemode, readCodemodeStore, toCodemodeModelInfo };
|
|
617
|
-
|
|
618
|
-
//# sourceMappingURL=execute.js.map
|
|
35
|
+
export const { executeCodemode, readCodemodeStore, toCodemodeModelInfo } = module;
|
|
36
|
+
//# sourceMappingURL=execute.js.map
|