@bastani/atomic 0.10.4 → 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 +44 -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} +519 -316
- 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 +21 -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 +6 -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/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 +30 -1096
- package/dist/cli/auth-cli.impl.js.map +1 -1
- package/dist/cli/auth-cli.js +11 -7
- 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 +30 -900
- package/dist/cli/blueprint-command.impl.js.map +1 -1
- package/dist/cli/blueprint-command.js +11 -7
- 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 +33 -105
- package/dist/cli/intercom-command.impl.js.map +1 -1
- package/dist/cli/intercom-command.js +11 -7
- 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 +33 -57
- package/dist/cli/list-models.impl.js.map +1 -1
- package/dist/cli/list-models.js +11 -7
- 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 +33 -52
- package/dist/cli/session-picker.impl.js.map +1 -1
- package/dist/cli/session-picker.js +11 -7
- 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 +35 -4
- package/dist/cli/startup-ui.js +11 -7
- 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 +35 -2
- package/dist/cli/storage-command.js +11 -7
- 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 +33 -186
- package/dist/cli/storage-search-session.impl.js.map +1 -1
- package/dist/cli/storage-search-session.js +11 -7
- 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 +32 -213
- package/dist/cli/team-command.impl.js.map +1 -1
- package/dist/cli/team-command.js +11 -7
- 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 +35 -2
- package/dist/core/debug.js +11 -7
- 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 +34 -255
- package/dist/core/export-html/card-projection.impl.js.map +1 -1
- package/dist/core/export-html/card-projection.js +11 -7
- 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 +30 -604
- package/dist/core/export-html/index.impl.js.map +1 -1
- package/dist/core/export-html/index.js +11 -7
- 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 +35 -2
- package/dist/core/export-html/json-spans.js +11 -7
- 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 +31 -120
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -1
- package/dist/core/export-html/oversized-render-inputs.js +11 -7
- 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 +33 -347
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -1
- package/dist/core/export-html/tool-renderer.js +11 -7
- 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 +35 -2
- package/dist/core/extensions/jiti-loader.js +11 -7
- 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 +35 -2
- package/dist/core/extensions/jiti-static-loader.js +11 -7
- 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 +35 -2
- package/dist/core/extensions/loader-host-modules.js +11 -7
- 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 +35 -4
- package/dist/core/intercom-broker-control-host.js +11 -7
- 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 +35 -17
- package/dist/core/intercom-broker-control.impl.js.map +1 -1
- package/dist/core/intercom-broker-control.js +11 -7
- 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 +35 -2
- package/dist/core/package-manager-storage-adapters.js +11 -7
- 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 +35 -8
- package/dist/core/sdk.js +11 -7
- 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 +35 -2
- package/dist/core/session-manager-list.js +11 -7
- 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 +35 -7
- package/dist/core/session-manager.js +11 -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 +35 -2
- package/dist/core/session-storage.js +11 -7
- 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 +33 -34
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.js +11 -7
- 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 +32 -97
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.js +11 -7
- 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 +34 -58
- package/dist/core/storage/session/card-view.impl.js.map +1 -1
- package/dist/core/storage/session/card-view.js +11 -7
- 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 +33 -91
- package/dist/core/storage/session/child-reader.impl.js.map +1 -1
- package/dist/core/storage/session/child-reader.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/chunked-resume-projection.js +11 -7
- 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 +31 -634
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -1
- package/dist/core/storage/session/expanded-child-details.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/fork-row-bytes.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/fork-row-index.js +11 -7
- 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 +30 -574
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -1
- package/dist/core/storage/session/fork-staging.js +11 -7
- 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 +30 -471
- package/dist/core/storage/session/fork-window.impl.js.map +1 -1
- package/dist/core/storage/session/fork-window.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/history-pages.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/jsonl-entry-projection.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/jsonl-session-store.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/memory-session-store.js +11 -7
- 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 +33 -69
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -1
- package/dist/core/storage/session/pinned-branch-resume.js +11 -7
- 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 +32 -461
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -1
- package/dist/core/storage/session/released-history-files.js +11 -7
- 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 +32 -53
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -1
- package/dist/core/storage/session/resident-fork-rows.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/session-resume.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/snapshot-cut.js +11 -7
- 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 +34 -60
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -1
- package/dist/core/storage/session/snapshot-history.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/sql-session-store.js +11 -7
- 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 +35 -2
- package/dist/core/storage/session/tree-outline.js +11 -7
- 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 +31 -337
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -1
- package/dist/core/storage/session/tree-presentation.js +11 -7
- 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 +35 -2
- package/dist/core/storage/storage-status.js +11 -7
- 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 +35 -2
- package/dist/core/storage/team.js +11 -7
- 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 +35 -2
- package/dist/core/structured-output/index.js +11 -7
- 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 +33 -251
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -1
- package/dist/core/tasks/task-completion-entry.js +11 -7
- 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 +32 -375
- package/dist/core/tasks/task-file-history.impl.js.map +1 -1
- package/dist/core/tasks/task-file-history.js +11 -7
- package/dist/core/tasks/{task-reference-archive.impl.js → task-reference-archive.code.js} +51 -6
- package/dist/core/tasks/{task-reference-archive.impl.js.map → task-reference-archive.code.js.map} +1 -1
- package/dist/core/tasks/task-reference-archive.js +11 -7
- package/dist/core/tasks/{task-reference-identity.impl.js → task-reference-identity.code.js} +1 -1
- package/dist/core/tasks/{task-reference-identity.impl.js.map → task-reference-identity.code.js.map} +1 -1
- package/dist/core/tasks/task-reference-identity.js +11 -7
- 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 +35 -2
- package/dist/core/tasks/task-reference-stream.js +11 -7
- 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 +35 -2
- package/dist/core/tasks/task-unsaved-answer.js +11 -7
- 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 +35 -2
- package/dist/core/tasks/task-view-source.js +12 -8
- 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 +30 -1524
- package/dist/core/tools/read-url.impl.js.map +1 -1
- package/dist/core/tools/read-url.js +11 -7
- 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 +35 -5
- package/dist/core/worktree-snapshot/errors.js +11 -7
- 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 +34 -134
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.js +11 -7
- 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 +30 -612
- package/dist/extensions/codemode/execute.impl.js.map +1 -1
- package/dist/extensions/codemode/execute.js +11 -7
- 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 +33 -107
- package/dist/extensions/codemode/renderer.impl.js.map +1 -1
- package/dist/extensions/codemode/renderer.js +11 -7
- 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 +32 -561
- package/dist/extensions/mcp/cli.impl.js.map +1 -1
- package/dist/extensions/mcp/cli.js +11 -7
- 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 -7
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -1
- package/dist/extensions/mcp/cli.lazy.js +11 -7
- 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 +35 -4
- package/dist/extensions/mcp/runtime.js +11 -7
- 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 +35 -11
- package/dist/main-first-time-setup.impl.js.map +1 -1
- package/dist/main-first-time-setup.js +11 -7
- 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 +33 -290
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.js +11 -7
- 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 +34 -189
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.js +11 -7
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -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 -1067
- package/dist/package-manager-cli.impl.js.map +1 -1
- package/dist/package-manager-cli.js +11 -7
- 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 +33 -105
- package/dist/utils/startup-database-spare.impl.js.map +1 -1
- package/dist/utils/startup-database-spare.js +11 -7
- 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 +35 -2
- package/dist/utils/tools-manager.js +11 -7
- 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 +1 -1
- 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
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
import "../../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
|
+
import { APP_NAME, getExportTemplateDirAsync, normalizePath, resolvePath } from "../../_shared/p0-cli-BB45ZQY6.js";
|
|
3
|
+
import { getResolvedThemeColors, getThemeExportColors } from "../../_shared/p2-shell-main-B2WIALFD.js";
|
|
4
|
+
import { SessionManager } from "../../_shared/startup-10-0-TDQNBDDL.js";
|
|
5
|
+
import { editsFor } from "../../_shared/json-spans-NW7ALLIY.js";
|
|
6
|
+
import { captureHtmlHistory, encodeSessionData, sessionDataBytes } from "../../_shared/session-data-AHTU7IS6.js";
|
|
7
|
+
import { open, readFile, realpath, rename, rm, stat } from "node:fs/promises";
|
|
8
|
+
import { basename, join } from "path";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
11
|
+
import { SessionNotFoundError } from "../storage/session/errors.js";
|
|
12
|
+
// dist/core/export-html/render-inputs.js
|
|
13
|
+
const TEMPLATE_RENDERED_TOOLS = /* @__PURE__ */ new Set([
|
|
14
|
+
"bash",
|
|
15
|
+
"read",
|
|
16
|
+
"write",
|
|
17
|
+
"edit",
|
|
18
|
+
"ls"
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* The entries this pass can read: tool results, and assistant messages with a call of a tool the template does not
|
|
22
|
+
* render, besides entries larger than a page. A store skips every other entry for this pass (#5571).
|
|
23
|
+
*/
|
|
24
|
+
const RENDER_INPUT_SELECTION = { exceptCalls: [...TEMPLATE_RENDERED_TOOLS] };
|
|
25
|
+
/** An extension can keep and mutate a previous call's arguments or result while rendering a different call.
|
|
26
|
+
* Retain those exposed inputs until the export is serialized. Do not retain other message blocks or history. */
|
|
27
|
+
async function renderHtmlInputs(source, renderer) {
|
|
28
|
+
const events = [];
|
|
29
|
+
const lastUse = /* @__PURE__ */ new Map();
|
|
30
|
+
const oversized = /* @__PURE__ */ new Map();
|
|
31
|
+
for await (const { items } of source.readHistory(RENDER_INPUT_SELECTION)) for (const item of items) {
|
|
32
|
+
if (!("entry" in item)) {
|
|
33
|
+
const { oversizedRenderInputs } = await import("./oversized-render-inputs.code.js").catch((error) => __atomicOnDemandFailed(error, "session export"));
|
|
34
|
+
const h = await oversizedRenderInputs(item, source, TEMPLATE_RENDERED_TOOLS, (id) => lastUse.has(id));
|
|
35
|
+
if (h.spans.size) oversized.set(item.seq, h.spans);
|
|
36
|
+
for (const event of h.events) {
|
|
37
|
+
lastUse.set(event.id, events.length);
|
|
38
|
+
events.push(event);
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (item.entry.type !== "message") continue;
|
|
43
|
+
const message = item.entry.message;
|
|
44
|
+
if (message.role === "assistant" && Array.isArray(message.content)) for (const [index, block] of message.content.entries()) {
|
|
45
|
+
if (block.type !== "toolCall" || TEMPLATE_RENDERED_TOOLS.has(block.name)) continue;
|
|
46
|
+
lastUse.set(block.id, events.length);
|
|
47
|
+
events.push({
|
|
48
|
+
kind: "call",
|
|
49
|
+
seq: item.seq,
|
|
50
|
+
index,
|
|
51
|
+
id: block.id,
|
|
52
|
+
name: block.name,
|
|
53
|
+
args: block.arguments
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (message.role === "toolResult" && message.toolCallId && (!TEMPLATE_RENDERED_TOOLS.has(message.toolName ?? "") || lastUse.has(message.toolCallId))) {
|
|
57
|
+
lastUse.set(message.toolCallId, events.length);
|
|
58
|
+
events.push({
|
|
59
|
+
kind: "result",
|
|
60
|
+
seq: item.seq,
|
|
61
|
+
id: message.toolCallId,
|
|
62
|
+
name: message.toolName ?? "",
|
|
63
|
+
content: message.content,
|
|
64
|
+
details: message.details,
|
|
65
|
+
isError: message.isError || false
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const calls = /* @__PURE__ */ new Map();
|
|
70
|
+
const rendered = /* @__PURE__ */ new Map();
|
|
71
|
+
const argumentsAt = /* @__PURE__ */ new Map();
|
|
72
|
+
const resultAt = /* @__PURE__ */ new Map();
|
|
73
|
+
const active = /* @__PURE__ */ new Set();
|
|
74
|
+
try {
|
|
75
|
+
for (const [i, event] of events.entries()) {
|
|
76
|
+
const { id } = event;
|
|
77
|
+
if (event.kind === "call") {
|
|
78
|
+
active.add(id);
|
|
79
|
+
calls.set(id, event);
|
|
80
|
+
const at = argumentsAt.get(event.seq) ?? /* @__PURE__ */ new Map();
|
|
81
|
+
at.set(event.index, event.args);
|
|
82
|
+
argumentsAt.set(event.seq, at);
|
|
83
|
+
const callHtml = renderer.renderCall(id, event.name, event.args);
|
|
84
|
+
if (callHtml) rendered.set(id, { callHtml });
|
|
85
|
+
} else if (rendered.has(id) || !TEMPLATE_RENDERED_TOOLS.has(event.name)) {
|
|
86
|
+
active.add(id);
|
|
87
|
+
resultAt.set(event.seq, event);
|
|
88
|
+
const result = renderer.renderResult(id, event.name, event.content, event.details, event.isError);
|
|
89
|
+
if (result) {
|
|
90
|
+
const call = calls.get(id);
|
|
91
|
+
const callHtml = call && renderer.renderCall(id, call.name, call.args);
|
|
92
|
+
rendered.set(id, {
|
|
93
|
+
...rendered.get(id),
|
|
94
|
+
...callHtml !== void 0 ? { callHtml } : {},
|
|
95
|
+
resultHtmlCollapsed: result.collapsed,
|
|
96
|
+
resultHtmlExpanded: result.expanded
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (lastUse.get(id) === i) {
|
|
101
|
+
calls.delete(id);
|
|
102
|
+
if (active.delete(id)) renderer.releaseCall?.(id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
for (const id of active) renderer.releaseCall?.(id);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
rendered,
|
|
110
|
+
oversizedPatches(seq) {
|
|
111
|
+
const spans = oversized.get(seq);
|
|
112
|
+
if (!spans) return;
|
|
113
|
+
const values = [];
|
|
114
|
+
const add = (key, value) => {
|
|
115
|
+
const span = spans.get(key);
|
|
116
|
+
if (span) values.push({
|
|
117
|
+
span,
|
|
118
|
+
json: JSON.stringify(value)
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
for (const [i, args] of argumentsAt.get(seq) ?? []) add(`arg:${i}`, args);
|
|
122
|
+
const r = resultAt.get(seq);
|
|
123
|
+
if (r) {
|
|
124
|
+
add("content", r.content);
|
|
125
|
+
add("details", r.details);
|
|
126
|
+
}
|
|
127
|
+
return editsFor(values);
|
|
128
|
+
},
|
|
129
|
+
/** Main serializes the whole export at one point. Take that cut only for values an extension could
|
|
130
|
+
* have mutated; unrelated rows remain in the durable store and never enter this snapshot. */
|
|
131
|
+
freezeInputs() {
|
|
132
|
+
const seqs = [...argumentsAt.keys(), ...resultAt.keys()].sort((a, b) => a - b);
|
|
133
|
+
for (const seq of seqs) {
|
|
134
|
+
const at = argumentsAt.get(seq);
|
|
135
|
+
if (at) for (const [index, args] of at) {
|
|
136
|
+
const copy = JSON.parse(JSON.stringify({ arguments: args }));
|
|
137
|
+
at.set(index, copy.arguments);
|
|
138
|
+
}
|
|
139
|
+
const result = resultAt.get(seq);
|
|
140
|
+
if (result) {
|
|
141
|
+
const copy = JSON.parse(JSON.stringify({
|
|
142
|
+
content: result.content,
|
|
143
|
+
details: result.details
|
|
144
|
+
}));
|
|
145
|
+
resultAt.set(seq, {
|
|
146
|
+
...result,
|
|
147
|
+
content: copy.content,
|
|
148
|
+
details: copy.details
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
/** Restore precisely the mutable inputs passed to this export's renderers to a freshly read durable row. */
|
|
154
|
+
entry(seq, raw) {
|
|
155
|
+
if (raw.type !== "message") return raw;
|
|
156
|
+
const message = raw.message;
|
|
157
|
+
const at = argumentsAt.get(seq);
|
|
158
|
+
if (at && message.role === "assistant") return {
|
|
159
|
+
...raw,
|
|
160
|
+
message: {
|
|
161
|
+
...message,
|
|
162
|
+
content: message.content.map((block, index) => block.type === "toolCall" && at.has(index) ? {
|
|
163
|
+
...block,
|
|
164
|
+
arguments: at.get(index)
|
|
165
|
+
} : block)
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const result = resultAt.get(seq);
|
|
169
|
+
return result && message.role === "toolResult" ? {
|
|
170
|
+
...raw,
|
|
171
|
+
message: {
|
|
172
|
+
...message,
|
|
173
|
+
content: result.content,
|
|
174
|
+
details: result.details
|
|
175
|
+
}
|
|
176
|
+
} : raw;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// dist/core/export-html/saved-agent-cards.js
|
|
181
|
+
function record(value) {
|
|
182
|
+
return value !== null && typeof value === "object" ? value : void 0;
|
|
183
|
+
}
|
|
184
|
+
/** A scoped receipt must be readable by the ordinary tool renderer before replacing its fallback. */
|
|
185
|
+
function readableResult(content, nestedCalls) {
|
|
186
|
+
if (!Array.isArray(content) || !content.every((item) => {
|
|
187
|
+
const block = record(item);
|
|
188
|
+
return block?.type === "text" && typeof block.text === "string" || block?.type === "image" && typeof block.data === "string" && typeof block.mimeType === "string";
|
|
189
|
+
})) return false;
|
|
190
|
+
const calls = record(nestedCalls)?.calls;
|
|
191
|
+
return !Array.isArray(calls) || calls.every((item) => {
|
|
192
|
+
const call = record(item);
|
|
193
|
+
return call && typeof call.name === "string" && typeof call.status === "string" && (call.error === void 0 || typeof call.error === "string") && (call.durationMs === void 0 || typeof call.durationMs === "number") && (call.argumentsBytes === void 0 || typeof call.argumentsBytes === "number");
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function marker(entry) {
|
|
197
|
+
return entry?.type === "custom" && entry.customType === "subagent-child";
|
|
198
|
+
}
|
|
199
|
+
/** Resolve only bookkeeping ancestors, once each, including on forks or out-of-order recordings. */
|
|
200
|
+
function previousTurns(sm, marker) {
|
|
201
|
+
let markers;
|
|
202
|
+
return (entry) => {
|
|
203
|
+
let parent = entry.parentId ? sm.getEntry(entry.parentId) : void 0;
|
|
204
|
+
if (!parent || !marker(parent)) return parent;
|
|
205
|
+
markers ??= /* @__PURE__ */ new Map();
|
|
206
|
+
const path = [];
|
|
207
|
+
while (parent && marker(parent)) {
|
|
208
|
+
if (markers.has(parent.id)) {
|
|
209
|
+
parent = markers.get(parent.id);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
path.push(parent.id);
|
|
213
|
+
markers.set(parent.id, void 0);
|
|
214
|
+
parent = parent.parentId ? sm.getEntry(parent.parentId) : void 0;
|
|
215
|
+
}
|
|
216
|
+
for (const id of path) markers.set(id, parent);
|
|
217
|
+
return parent;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/** The viewer stops at a missing or self parent, but a disconnected parent cycle has no selectable path. */
|
|
221
|
+
function rootedLaunches(sm, entries) {
|
|
222
|
+
const checking = 1;
|
|
223
|
+
const rooted = 2;
|
|
224
|
+
const cyclic = 3;
|
|
225
|
+
let states;
|
|
226
|
+
const parent = (seq) => {
|
|
227
|
+
const entry = entries[seq - 1];
|
|
228
|
+
return entry?.parentId && entry.parentId !== entry.id ? sm.getEntrySeq(entry.parentId) ?? 0 : 0;
|
|
229
|
+
};
|
|
230
|
+
return (id) => {
|
|
231
|
+
const start = sm.getEntrySeq(id);
|
|
232
|
+
if (start === void 0) return false;
|
|
233
|
+
if (!parent(start)) return true;
|
|
234
|
+
states ??= new Uint8Array(entries.length + 1);
|
|
235
|
+
let seq = start;
|
|
236
|
+
while (seq && !states[seq]) {
|
|
237
|
+
states[seq] = checking;
|
|
238
|
+
seq = parent(seq);
|
|
239
|
+
}
|
|
240
|
+
const outcome = !seq || states[seq] === rooted ? rooted : cyclic;
|
|
241
|
+
for (seq = start; seq && states[seq] === checking; seq = parent(seq)) states[seq] = outcome;
|
|
242
|
+
return outcome === rooted;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function singleLaunchCall(content) {
|
|
246
|
+
let call = null;
|
|
247
|
+
for (const block of content) {
|
|
248
|
+
if (block?.type !== "toolCall") continue;
|
|
249
|
+
if (call || block.name !== "subagent") return null;
|
|
250
|
+
const args = record(block.arguments);
|
|
251
|
+
if (!args || args.action !== void 0 || args.tasks !== void 0 || typeof args.agent !== "string" || typeof args.task !== "string") return null;
|
|
252
|
+
call = block;
|
|
253
|
+
}
|
|
254
|
+
return call;
|
|
255
|
+
}
|
|
256
|
+
function savedReceipt(id, entry) {
|
|
257
|
+
if (entry.type !== "message" || entry.message.role !== "toolResult") return;
|
|
258
|
+
const receipt = entry.message;
|
|
259
|
+
if (receipt.toolName !== "subagent" || receipt.isError || !receipt.toolCallId) return;
|
|
260
|
+
const details = record(receipt.details);
|
|
261
|
+
if (details?.mode !== "single" || !Array.isArray(details.results)) return;
|
|
262
|
+
if (details.ownerSessionId !== void 0 && details.ownerSessionId !== id) return;
|
|
263
|
+
if (details.results.length === 0) {
|
|
264
|
+
const response = record(details.taskResponse);
|
|
265
|
+
const observation = record(response?.observation);
|
|
266
|
+
if (response?.kind === "admitted" && observation?.kind === "yielded" && typeof observation.taskId === "string") {
|
|
267
|
+
if (readableResult(receipt.content, receipt.nestedCalls)) return { toolCallId: receipt.toolCallId };
|
|
268
|
+
}
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const child = record(details.results[0]);
|
|
272
|
+
if (details.results.length !== 1 || child?.status !== "ok" || child.detached || typeof child.agent !== "string" || typeof child.task !== "string") return;
|
|
273
|
+
let answer = child.finalOutput;
|
|
274
|
+
let answerBlock;
|
|
275
|
+
const messages = Array.isArray(child.messages) ? child.messages : void 0;
|
|
276
|
+
if (answer === void 0 && messages) {
|
|
277
|
+
const last = record(messages[messages.length - 1]);
|
|
278
|
+
if (last?.role === "assistant" && last.stopReason === "stop" && !last.errorMessage && Array.isArray(last.content)) for (let i = last.content.length - 1; i >= 0; i--) {
|
|
279
|
+
const block = record(last.content[i]);
|
|
280
|
+
if (block?.type === "text" && typeof block.text === "string" && block.text.trim()) {
|
|
281
|
+
answer = block.text;
|
|
282
|
+
answerBlock = i;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (typeof answer !== "string" || !answer.trim()) return;
|
|
288
|
+
if (!messages?.some((value) => {
|
|
289
|
+
const msg = record(value);
|
|
290
|
+
return msg?.role === "assistant" && Array.isArray(msg.content) && msg.content.some((b) => {
|
|
291
|
+
const block = record(b);
|
|
292
|
+
return block?.type === "toolCall" && typeof block.name === "string";
|
|
293
|
+
});
|
|
294
|
+
}) && !(Array.isArray(child.toolCalls) && child.toolCalls.length && child.toolCalls.every((s) => {
|
|
295
|
+
const summary = record(s);
|
|
296
|
+
const line = summary?.expandedText || summary?.text;
|
|
297
|
+
return typeof line === "string" && line.length > 0;
|
|
298
|
+
}))) return;
|
|
299
|
+
if (readableResult(receipt.content, receipt.nestedCalls)) return {
|
|
300
|
+
toolCallId: receipt.toolCallId,
|
|
301
|
+
child,
|
|
302
|
+
answerBlock
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/** Visit the entire captured tree without retaining message bodies. The file's selectable branches, not
|
|
306
|
+
* the branch selected when opening the file, determine which receipt each exported card can show. */
|
|
307
|
+
async function savedFileCards(source) {
|
|
308
|
+
const entries = [];
|
|
309
|
+
const positions = /* @__PURE__ */ new Map();
|
|
310
|
+
for await (const { items } of source.readHistory()) for (const item of items) {
|
|
311
|
+
const held = "entry" in item ? {
|
|
312
|
+
entry: item.entry,
|
|
313
|
+
answerBlock: void 0
|
|
314
|
+
} : await (await import("./card-projection.code.js").catch((error) => __atomicOnDemandFailed(error, "session export"))).chunkedCardEntry(source.readHistoryChunks(item));
|
|
315
|
+
const e = held.entry;
|
|
316
|
+
const compare = (value) => {
|
|
317
|
+
if (typeof value !== "string") throw new Error("A saved agent launch is missing its identity");
|
|
318
|
+
return "entry" in item ? createHash("sha256").update(value, "utf16le").digest("hex") : value;
|
|
319
|
+
};
|
|
320
|
+
const receipt = savedReceipt(source.header.id, e);
|
|
321
|
+
const call = e.type === "message" && e.message.role === "assistant" && Array.isArray(e.message.content) ? singleLaunchCall(e.message.content) : null;
|
|
322
|
+
entries.push({
|
|
323
|
+
id: e.id,
|
|
324
|
+
parentId: e.parentId,
|
|
325
|
+
marker: marker(e),
|
|
326
|
+
result: e.type === "message" && e.message.role === "toolResult",
|
|
327
|
+
...call ? { call: {
|
|
328
|
+
id: call.id,
|
|
329
|
+
arguments: {
|
|
330
|
+
agent: compare(call.arguments.agent),
|
|
331
|
+
task: compare(call.arguments.task)
|
|
332
|
+
}
|
|
333
|
+
} } : {},
|
|
334
|
+
...receipt ? { receipt: {
|
|
335
|
+
toolCallId: receipt.toolCallId,
|
|
336
|
+
answerBlock: receipt.answerBlock === void 0 ? void 0 : held.answerBlock ?? receipt.answerBlock,
|
|
337
|
+
...receipt.child ? { child: {
|
|
338
|
+
agent: compare(receipt.child.agent),
|
|
339
|
+
task: compare(receipt.child.task)
|
|
340
|
+
} } : {}
|
|
341
|
+
} } : {}
|
|
342
|
+
});
|
|
343
|
+
positions.set(e.id, entries.length);
|
|
344
|
+
}
|
|
345
|
+
return cardsFor({
|
|
346
|
+
getEntry(id) {
|
|
347
|
+
return entries[(positions.get(id) ?? 0) - 1];
|
|
348
|
+
},
|
|
349
|
+
getEntrySeq(id) {
|
|
350
|
+
return positions.get(id);
|
|
351
|
+
},
|
|
352
|
+
getEntryCount() {
|
|
353
|
+
return positions.size;
|
|
354
|
+
}
|
|
355
|
+
}, entries, (e) => e.marker, (e) => e.result, (e) => e.receipt, (e) => e.call ?? null);
|
|
356
|
+
}
|
|
357
|
+
function cardsFor(sm, entries, marker, isToolResult, readReceipt, launchOf) {
|
|
358
|
+
if (sm.getEntryCount() !== entries.length) return;
|
|
359
|
+
const previousTurn = previousTurns(sm, marker);
|
|
360
|
+
let calls;
|
|
361
|
+
let rooted;
|
|
362
|
+
let cards;
|
|
363
|
+
for (const entry of entries) {
|
|
364
|
+
const receipt = readReceipt(entry);
|
|
365
|
+
if (!receipt) continue;
|
|
366
|
+
const launch = previousTurn(entry);
|
|
367
|
+
if (!launch) continue;
|
|
368
|
+
calls ??= /* @__PURE__ */ new Map();
|
|
369
|
+
let call = calls.get(launch);
|
|
370
|
+
if (call === void 0) {
|
|
371
|
+
call = launchOf(launch);
|
|
372
|
+
calls.set(launch, call);
|
|
373
|
+
}
|
|
374
|
+
if (!call || call.id !== receipt.toolCallId) continue;
|
|
375
|
+
if (receipt.child && (receipt.child.agent !== call.arguments.agent || receipt.child.task !== call.arguments.task)) continue;
|
|
376
|
+
rooted ??= rootedLaunches(sm, entries);
|
|
377
|
+
if (!rooted(launch.id)) continue;
|
|
378
|
+
cards ??= [];
|
|
379
|
+
cards.push({
|
|
380
|
+
launch: launch.id,
|
|
381
|
+
receipt: entry.id,
|
|
382
|
+
answerBlock: receipt.answerBlock
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (!cards) return;
|
|
386
|
+
const tips = new Map(cards.map((card) => [card.receipt, card]));
|
|
387
|
+
for (const entry of entries) {
|
|
388
|
+
if (!marker(entry)) continue;
|
|
389
|
+
const parent = previousTurn(entry);
|
|
390
|
+
const card = parent && tips.get(parent.id);
|
|
391
|
+
if (card) tips.set(entry.id, card);
|
|
392
|
+
}
|
|
393
|
+
const parents = /* @__PURE__ */ new Set();
|
|
394
|
+
const supported = /* @__PURE__ */ new Set();
|
|
395
|
+
const contradicted = /* @__PURE__ */ new Set();
|
|
396
|
+
for (const entry of entries) {
|
|
397
|
+
if (!entry.parentId || entry.parentId === entry.id || !tips.has(entry.parentId)) continue;
|
|
398
|
+
parents.add(entry.parentId);
|
|
399
|
+
if (marker(entry)) continue;
|
|
400
|
+
(isToolResult(entry) ? contradicted : supported).add(entry.parentId);
|
|
401
|
+
}
|
|
402
|
+
if (!contradicted.size) return cards;
|
|
403
|
+
for (const id of tips.keys()) if (!parents.has(id)) supported.add(id);
|
|
404
|
+
for (const outcomes of [supported, contradicted]) for (const id of outcomes) {
|
|
405
|
+
const parent = sm.getEntry(id)?.parentId;
|
|
406
|
+
if (parent && tips.has(parent)) outcomes.add(parent);
|
|
407
|
+
}
|
|
408
|
+
for (const [id, card] of tips) {
|
|
409
|
+
if (!supported.has(id) || !contradicted.has(id)) continue;
|
|
410
|
+
card.prefixes ??= [];
|
|
411
|
+
card.prefixes.push(id);
|
|
412
|
+
card.branches ??= [];
|
|
413
|
+
}
|
|
414
|
+
for (const entry of entries) {
|
|
415
|
+
if (!entry.parentId || !supported.has(entry.parentId) || !contradicted.has(entry.parentId)) continue;
|
|
416
|
+
if (contradicted.has(entry.id) || isToolResult(entry)) continue;
|
|
417
|
+
tips.get(entry.parentId).branches.push(entry.id);
|
|
418
|
+
}
|
|
419
|
+
const selected = cards.filter((card) => supported.has(card.receipt));
|
|
420
|
+
return selected.length ? selected : void 0;
|
|
421
|
+
}
|
|
422
|
+
// dist/core/export-html/index.js
|
|
423
|
+
/** Parse a color string to RGB values. Supports hex (#RRGGBB) and rgb(r,g,b) formats. */
|
|
424
|
+
function parseColor(color) {
|
|
425
|
+
const hexMatch = color.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
|
|
426
|
+
if (hexMatch) return {
|
|
427
|
+
r: Number.parseInt(hexMatch[1], 16),
|
|
428
|
+
g: Number.parseInt(hexMatch[2], 16),
|
|
429
|
+
b: Number.parseInt(hexMatch[3], 16)
|
|
430
|
+
};
|
|
431
|
+
const rgbMatch = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
432
|
+
if (rgbMatch) return {
|
|
433
|
+
r: Number.parseInt(rgbMatch[1], 10),
|
|
434
|
+
g: Number.parseInt(rgbMatch[2], 10),
|
|
435
|
+
b: Number.parseInt(rgbMatch[3], 10)
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/** Calculate relative luminance of a color (0-1, higher = lighter). */
|
|
439
|
+
function getLuminance(r, g, b) {
|
|
440
|
+
const toLinear = (c) => {
|
|
441
|
+
const s = c / 255;
|
|
442
|
+
return s <= .03928 ? s / 12.92 : ((s + .055) / 1.055) ** 2.4;
|
|
443
|
+
};
|
|
444
|
+
return .2126 * toLinear(r) + .7152 * toLinear(g) + .0722 * toLinear(b);
|
|
445
|
+
}
|
|
446
|
+
/** Adjust color brightness. Factor > 1 lightens, < 1 darkens. */
|
|
447
|
+
function adjustBrightness(color, factor) {
|
|
448
|
+
const parsed = parseColor(color);
|
|
449
|
+
if (!parsed) return color;
|
|
450
|
+
const adjust = (c) => Math.min(255, Math.max(0, Math.round(c * factor)));
|
|
451
|
+
return `rgb(${adjust(parsed.r)}, ${adjust(parsed.g)}, ${adjust(parsed.b)})`;
|
|
452
|
+
}
|
|
453
|
+
/** Derive export background colors from a base color (e.g., userMessageBg). */
|
|
454
|
+
function deriveExportColors(baseColor) {
|
|
455
|
+
const parsed = parseColor(baseColor);
|
|
456
|
+
if (!parsed) return {
|
|
457
|
+
pageBg: "rgb(24, 24, 30)",
|
|
458
|
+
cardBg: "rgb(30, 30, 36)",
|
|
459
|
+
infoBg: "rgb(60, 55, 40)"
|
|
460
|
+
};
|
|
461
|
+
if (getLuminance(parsed.r, parsed.g, parsed.b) > .5) return {
|
|
462
|
+
pageBg: adjustBrightness(baseColor, .96),
|
|
463
|
+
cardBg: baseColor,
|
|
464
|
+
infoBg: `rgb(${Math.min(255, parsed.r + 10)}, ${Math.min(255, parsed.g + 5)}, ${Math.max(0, parsed.b - 20)})`
|
|
465
|
+
};
|
|
466
|
+
return {
|
|
467
|
+
pageBg: adjustBrightness(baseColor, .7),
|
|
468
|
+
cardBg: adjustBrightness(baseColor, .85),
|
|
469
|
+
infoBg: `rgb(${Math.min(255, parsed.r + 20)}, ${Math.min(255, parsed.g + 15)}, ${parsed.b})`
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Generate CSS custom property declarations from theme colors.
|
|
474
|
+
*/
|
|
475
|
+
function generateThemeVars(themeName) {
|
|
476
|
+
const colors = getResolvedThemeColors(themeName);
|
|
477
|
+
const lines = [];
|
|
478
|
+
for (const [key, value] of Object.entries(colors)) lines.push(`--${key}: ${value};`);
|
|
479
|
+
const themeExport = getThemeExportColors(themeName);
|
|
480
|
+
const derivedColors = deriveExportColors(colors.userMessageBg || "#343541");
|
|
481
|
+
lines.push(`--exportPageBg: ${themeExport.pageBg ?? derivedColors.pageBg};`);
|
|
482
|
+
lines.push(`--exportCardBg: ${themeExport.cardBg ?? derivedColors.cardBg};`);
|
|
483
|
+
lines.push(`--exportInfoBg: ${themeExport.infoBg ?? derivedColors.infoBg};`);
|
|
484
|
+
return lines.join("\n ");
|
|
485
|
+
}
|
|
486
|
+
/** The fixed HTML before and after the streamed session data. */
|
|
487
|
+
async function htmlTemplate(themeName, cards) {
|
|
488
|
+
const templateDir = await getExportTemplateDirAsync();
|
|
489
|
+
const [template, templateCss, templateJs, markedJs, markedCjkFriendlyJs, hljsJs] = await Promise.all([
|
|
490
|
+
["template.html"],
|
|
491
|
+
["template.css"],
|
|
492
|
+
["template.js"],
|
|
493
|
+
["vendor", "marked.min.js"],
|
|
494
|
+
["vendor", "marked-cjk-friendly.min.js"],
|
|
495
|
+
["vendor", "highlight.min.js"]
|
|
496
|
+
].map((parts) => readFile(join(templateDir, ...parts), "utf-8")));
|
|
497
|
+
const themeVars = generateThemeVars(themeName);
|
|
498
|
+
const colors = getResolvedThemeColors(themeName);
|
|
499
|
+
const themeExport = getThemeExportColors(themeName);
|
|
500
|
+
const derivedExportColors = deriveExportColors(colors.userMessageBg || "#343541");
|
|
501
|
+
const bodyBg = themeExport.pageBg ?? derivedExportColors.pageBg;
|
|
502
|
+
const containerBg = themeExport.cardBg ?? derivedExportColors.cardBg;
|
|
503
|
+
const infoBg = themeExport.infoBg ?? derivedExportColors.infoBg;
|
|
504
|
+
let viewer = templateJs;
|
|
505
|
+
let includesCards = false;
|
|
506
|
+
const toolRow = /function renderToolCall\(call\) \{\r?\n +const result = findToolResult\(call\.id\);/;
|
|
507
|
+
const startRows = " const fragment = document.createDocumentFragment();";
|
|
508
|
+
const paintedRows = " messagesEl.appendChild(fragment);";
|
|
509
|
+
const initialRender = " // Initial render";
|
|
510
|
+
if (cards && toolRow.test(viewer) && [
|
|
511
|
+
startRows,
|
|
512
|
+
paintedRows,
|
|
513
|
+
initialRender
|
|
514
|
+
].every((slot) => viewer.includes(slot))) {
|
|
515
|
+
const cardViewer = await readFile(join(templateDir, "saved-agent-viewer.js"), "utf8").catch(() => void 0);
|
|
516
|
+
if (cardViewer) {
|
|
517
|
+
viewer = viewer.replace(toolRow, "function renderToolCall(call, result = findToolResult(call.id)) {").replace(startRows, () => `${startRows}\n acceptedCards = null;`).replace(paintedRows, () => `${paintedRows}\n paintSavedAgentCards();`).replace(initialRender, () => `${cardViewer}\n${initialRender}`);
|
|
518
|
+
includesCards = true;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const css = templateCss.replace("{{THEME_VARS}}", () => themeVars).replace("{{BODY_BG}}", () => bodyBg).replace("{{CONTAINER_BG}}", () => containerBg).replace("{{INFO_BG}}", () => infoBg);
|
|
522
|
+
const [prefix, suffix] = template.split("{{SESSION_DATA}}");
|
|
523
|
+
if (prefix === void 0 || suffix === void 0) throw new Error("Session export template is missing its data slot");
|
|
524
|
+
const fill = (part) => part.replace("{{CSS}}", () => css).replace("{{JS}}", () => viewer).replace("{{MARKED_JS}}", () => markedJs).replace("{{MARKED_CJK_FRIENDLY_JS}}", () => markedCjkFriendlyJs).replace("{{HIGHLIGHT_JS}}", () => hljsJs);
|
|
525
|
+
return [
|
|
526
|
+
fill(prefix),
|
|
527
|
+
fill(suffix),
|
|
528
|
+
includesCards
|
|
529
|
+
];
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Export session to HTML using SessionManager and AgentState.
|
|
533
|
+
* Used by TUI's /export command.
|
|
534
|
+
*/
|
|
535
|
+
async function exportSessionToHtml(sm, state, options) {
|
|
536
|
+
return writeSessionHtml(sm, state, typeof options === "string" ? { outputPath: options } : options || {});
|
|
537
|
+
}
|
|
538
|
+
async function writeSessionHtml(sm, state, opts, standalone = false) {
|
|
539
|
+
const sessionFile = sm.getSessionFile();
|
|
540
|
+
const sessionBasename = sessionFile ? basename(sessionFile, ".jsonl") : sm.getSessionId();
|
|
541
|
+
const source = await captureHtmlHistory(sm).catch((error) => {
|
|
542
|
+
if (error instanceof SessionNotFoundError) throw new Error("Nothing to export yet - start a conversation first");
|
|
543
|
+
throw error;
|
|
544
|
+
});
|
|
545
|
+
const cards = standalone ? await savedFileCards(source) : void 0;
|
|
546
|
+
const inputs = opts.toolRenderer ? await renderHtmlInputs(source, opts.toolRenderer) : void 0;
|
|
547
|
+
const presentation = {
|
|
548
|
+
systemPrompt: state?.systemPrompt,
|
|
549
|
+
tools: state?.tools?.map((t) => ({
|
|
550
|
+
name: t.name,
|
|
551
|
+
description: t.description,
|
|
552
|
+
parameters: t.parameters
|
|
553
|
+
}))
|
|
554
|
+
};
|
|
555
|
+
const [prefix, suffix, includesCards] = await htmlTemplate(opts.themeName, cards);
|
|
556
|
+
inputs?.freezeInputs();
|
|
557
|
+
const metadataJson = JSON.stringify({
|
|
558
|
+
leafId: source.leafId,
|
|
559
|
+
...presentation,
|
|
560
|
+
savedAgentCards: includesCards ? cards : void 0
|
|
561
|
+
});
|
|
562
|
+
let outputPath = opts.outputPath ? normalizePath(opts.outputPath) : void 0;
|
|
563
|
+
if (!outputPath) outputPath = `${APP_NAME}-session-${sessionBasename}.html`;
|
|
564
|
+
const target = await realpath(outputPath).catch(() => outputPath);
|
|
565
|
+
const mode = await stat(target).then((s) => s.mode & 4095, () => 384);
|
|
566
|
+
const partial = `${target}.${randomUUID()}.partial`;
|
|
567
|
+
try {
|
|
568
|
+
const output = await open(partial, "wx", 384);
|
|
569
|
+
try {
|
|
570
|
+
await output.writeFile(prefix);
|
|
571
|
+
for await (const encoded of encodeSessionData(sessionDataBytes(source, metadataJson, inputs))) await output.writeFile(encoded);
|
|
572
|
+
await output.writeFile(suffix);
|
|
573
|
+
await output.chmod(mode);
|
|
574
|
+
} finally {
|
|
575
|
+
await output.close();
|
|
576
|
+
}
|
|
577
|
+
await rename(partial, target);
|
|
578
|
+
} catch (error) {
|
|
579
|
+
await rm(partial, { force: true });
|
|
580
|
+
if (error instanceof SessionNotFoundError) throw new Error("Nothing to export yet - start a conversation first");
|
|
581
|
+
throw error;
|
|
582
|
+
}
|
|
583
|
+
return outputPath;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Export session file to HTML (standalone, without AgentState).
|
|
587
|
+
* Used by CLI for exporting arbitrary session files.
|
|
588
|
+
*/
|
|
589
|
+
async function exportFromFile(inputPath, options) {
|
|
590
|
+
const opts = typeof options === "string" ? { outputPath: options } : options || {};
|
|
591
|
+
const resolvedInputPath = resolvePath(inputPath);
|
|
592
|
+
if (!existsSync(resolvedInputPath)) throw new Error(`File not found: ${resolvedInputPath}`);
|
|
593
|
+
const sm = await SessionManager.open(resolvedInputPath);
|
|
594
|
+
let outputPath = opts.outputPath ? normalizePath(opts.outputPath) : void 0;
|
|
595
|
+
if (!outputPath) {
|
|
596
|
+
const inputBasename = basename(resolvedInputPath, ".jsonl");
|
|
597
|
+
outputPath = `${APP_NAME}-session-${inputBasename}.html`;
|
|
598
|
+
}
|
|
599
|
+
try {
|
|
600
|
+
return await writeSessionHtml(sm, void 0, {
|
|
601
|
+
...opts,
|
|
602
|
+
outputPath
|
|
603
|
+
}, true);
|
|
604
|
+
} finally {
|
|
605
|
+
await sm.getSessionStore().close();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
export { exportFromFile, exportSessionToHtml };
|
|
609
|
+
|
|
610
|
+
//# sourceMappingURL=index.code.js.map
|
|
611
|
+
// __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
|
|
612
|
+
// demand that fails in a process an in-place update left running says to restart.
|
|
613
|
+
function __atomicOnDemandFailed(error, feature) {
|
|
614
|
+
return (async () => {
|
|
615
|
+
const root = new URL("../../", import.meta.url);
|
|
616
|
+
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
617
|
+
const key = `${root.href}#0.10.5-alpha.1`;
|
|
618
|
+
let release = releases.get(key);
|
|
619
|
+
if (release === undefined) {
|
|
620
|
+
const current = (async () => {
|
|
621
|
+
for (const path of ["modes/interactive/interactive-mode-deps.js","_shared/chunk-CDOYTDYM.js","_shared/p0-cli-GUFK7TPN.js"]) {
|
|
622
|
+
try {
|
|
623
|
+
const held = await import(new URL(path, root).href);
|
|
624
|
+
if (typeof held.VERSION === "string") return { version: held.VERSION, name: held.APP_NAME };
|
|
625
|
+
} catch {
|
|
626
|
+
// Not a file this process can load: the next.
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return undefined;
|
|
630
|
+
})().then((found) => {
|
|
631
|
+
if (found === undefined && releases.get(key) === current) releases.delete(key);
|
|
632
|
+
return found;
|
|
633
|
+
});
|
|
634
|
+
releases.set(key, current);
|
|
635
|
+
release = current;
|
|
636
|
+
}
|
|
637
|
+
const running = await release;
|
|
638
|
+
let installed;
|
|
639
|
+
try {
|
|
640
|
+
const { readFile } = process.getBuiltinModule("node:fs/promises");
|
|
641
|
+
installed = JSON.parse(await readFile(new URL("../package.json", root), "utf8")).version;
|
|
642
|
+
} catch {
|
|
643
|
+
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
644
|
+
}
|
|
645
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.5-alpha.1" ? installed : running !== undefined && running.version !== "0.10.5-alpha.1" ? "0.10.5-alpha.1" : undefined;
|
|
646
|
+
if (updatedTo === undefined) throw error;
|
|
647
|
+
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
648
|
+
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|
|
649
|
+
cause: error,
|
|
650
|
+
});
|
|
651
|
+
restart.name = "UpdatedInstallError";
|
|
652
|
+
restart[Symbol.for("atomic.on-demand-restart.v1")] = { application, updatedTo, feature };
|
|
653
|
+
throw restart;
|
|
654
|
+
})();
|
|
655
|
+
}
|