@fleetagent/pi-coding-agent 0.0.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 +4518 -0
- package/README.md +660 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +9 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +13 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +32 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +56 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +356 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +83 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +95 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +418 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +600 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2505 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +141 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +442 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +32 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +111 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +88 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +243 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +625 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +226 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1848 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +484 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +160 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +824 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1175 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +45 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +52 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +310 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +21 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +48 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +353 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +295 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +150 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +729 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +110 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +495 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +59 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +204 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2021 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/pi-agent.d.ts +191 -0
- package/dist/core/pi-agent.d.ts.map +1 -0
- package/dist/core/pi-agent.js +655 -0
- package/dist/core/pi-agent.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +52 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +238 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +33 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +23 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +126 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +194 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +734 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/session/constants.d.ts +2 -0
- package/dist/core/session/constants.d.ts.map +1 -0
- package/dist/core/session/constants.js +2 -0
- package/dist/core/session/constants.js.map +1 -0
- package/dist/core/session/context.d.ts +9 -0
- package/dist/core/session/context.d.ts.map +1 -0
- package/dist/core/session/context.js +94 -0
- package/dist/core/session/context.js.map +1 -0
- package/dist/core/session/ids.d.ts +6 -0
- package/dist/core/session/ids.d.ts.map +1 -0
- package/dist/core/session/ids.js +15 -0
- package/dist/core/session/ids.js.map +1 -0
- package/dist/core/session/in-memory-session-manager.d.ts +17 -0
- package/dist/core/session/in-memory-session-manager.d.ts.map +1 -0
- package/dist/core/session/in-memory-session-manager.js +42 -0
- package/dist/core/session/in-memory-session-manager.js.map +1 -0
- package/dist/core/session/in-memory-session.d.ts +5 -0
- package/dist/core/session/in-memory-session.d.ts.map +1 -0
- package/dist/core/session/in-memory-session.js +8 -0
- package/dist/core/session/in-memory-session.js.map +1 -0
- package/dist/core/session/index.d.ts +16 -0
- package/dist/core/session/index.d.ts.map +1 -0
- package/dist/core/session/index.js +13 -0
- package/dist/core/session/index.js.map +1 -0
- package/dist/core/session/jsonl-helpers.d.ts +13 -0
- package/dist/core/session/jsonl-helpers.d.ts.map +1 -0
- package/dist/core/session/jsonl-helpers.js +18 -0
- package/dist/core/session/jsonl-helpers.js.map +1 -0
- package/dist/core/session/local-session-manager.d.ts +22 -0
- package/dist/core/session/local-session-manager.d.ts.map +1 -0
- package/dist/core/session/local-session-manager.js +102 -0
- package/dist/core/session/local-session-manager.js.map +1 -0
- package/dist/core/session/local-session.d.ts +5 -0
- package/dist/core/session/local-session.d.ts.map +1 -0
- package/dist/core/session/local-session.js +8 -0
- package/dist/core/session/local-session.js.map +1 -0
- package/dist/core/session/migrations.d.ts +11 -0
- package/dist/core/session/migrations.d.ts.map +1 -0
- package/dist/core/session/migrations.js +78 -0
- package/dist/core/session/migrations.js.map +1 -0
- package/dist/core/session/remote-session-client.d.ts +73 -0
- package/dist/core/session/remote-session-client.d.ts.map +1 -0
- package/dist/core/session/remote-session-client.js +69 -0
- package/dist/core/session/remote-session-client.js.map +1 -0
- package/dist/core/session/remote-session-manager.d.ts +32 -0
- package/dist/core/session/remote-session-manager.d.ts.map +1 -0
- package/dist/core/session/remote-session-manager.js +91 -0
- package/dist/core/session/remote-session-manager.js.map +1 -0
- package/dist/core/session/remote-session.d.ts +17 -0
- package/dist/core/session/remote-session.d.ts.map +1 -0
- package/dist/core/session/remote-session.js +30 -0
- package/dist/core/session/remote-session.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +17 -0
- package/dist/core/session/session-manager.d.ts.map +1 -0
- package/dist/core/session/session-manager.js +2 -0
- package/dist/core/session/session-manager.js.map +1 -0
- package/dist/core/session/session.d.ts +135 -0
- package/dist/core/session/session.d.ts.map +1 -0
- package/dist/core/session/session.js +380 -0
- package/dist/core/session/session.js.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts +51 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.js +199 -0
- package/dist/core/session/stores/in-memory-session-store.js.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts +30 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.js +380 -0
- package/dist/core/session/stores/jsonl-session-store.js.map +1 -0
- package/dist/core/session/stores/remote-session-store.d.ts +43 -0
- package/dist/core/session/stores/remote-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/remote-session-store.js +124 -0
- package/dist/core/session/stores/remote-session-store.js.map +1 -0
- package/dist/core/session/stores/session-store.d.ts +48 -0
- package/dist/core/session/stores/session-store.d.ts.map +1 -0
- package/dist/core/session/stores/session-store.js +2 -0
- package/dist/core/session/stores/session-store.js.map +1 -0
- package/dist/core/session/types.d.ts +138 -0
- package/dist/core/session/types.d.ts.map +1 -0
- package/dist/core/session/types.js +2 -0
- package/dist/core/session/types.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +2 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +2 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +264 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +795 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +60 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +387 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +25 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +123 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +8 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +31 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +68 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +342 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +87 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +345 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +51 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +325 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +37 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +35 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +298 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +37 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +304 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +40 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +112 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +37 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +169 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +62 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +289 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +21 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +49 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +26 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +213 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +532 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +281 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +333 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +20 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +121 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +175 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +54 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +506 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +70 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +79 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +119 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +83 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +27 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +201 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +54 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +180 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +278 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +165 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +290 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +96 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +861 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +69 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +390 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +39 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +50 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +51 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +295 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1093 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +114 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +10 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +29 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +370 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +4653 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +100 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1024 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +131 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +234 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +418 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +603 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +420 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +515 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +15 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +88 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +245 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +8 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +117 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +163 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +39 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +137 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +69 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +92 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +30 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +195 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +328 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +15 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +82 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +394 -0
- package/docs/custom-provider.md +701 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +148 -0
- package/docs/extensions.md +2596 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +80 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +197 -0
- package/docs/models.md +474 -0
- package/docs/packages.md +225 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +243 -0
- package/docs/quickstart.md +164 -0
- package/docs/rpc.md +1407 -0
- package/docs/sdk.md +257 -0
- package/docs/session-format.md +412 -0
- package/docs/sessions.md +137 -0
- package/docs/settings.md +277 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +106 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +918 -0
- package/docs/usage.md +279 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +208 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +127 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1379 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +430 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +122 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1009 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +206 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +141 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +27 -0
- package/examples/sdk/02-custom-model.ts +54 -0
- package/examples/sdk/03-custom-prompt.ts +76 -0
- package/examples/sdk/04-skills.ts +60 -0
- package/examples/sdk/05-tools.ts +51 -0
- package/examples/sdk/06-extensions.ts +94 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +56 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +46 -0
- package/examples/sdk/10-settings.ts +57 -0
- package/examples/sdk/11-sessions.ts +54 -0
- package/examples/sdk/12-full-control.ts +78 -0
- package/examples/sdk/13-session-runtime.ts +49 -0
- package/examples/sdk/README.md +95 -0
- package/npm-shrinkwrap.json +1789 -0
- package/package.json +98 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { formatRemoteSessionReference } from "./remote-session-client.js";
|
|
2
|
+
import { Session } from "./session.js";
|
|
3
|
+
import { RemoteSessionStore } from "./stores/remote-session-store.js";
|
|
4
|
+
export class RemoteSession extends Session {
|
|
5
|
+
remoteStore;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
const reference = options.reference ??
|
|
8
|
+
options.snapshot?.reference ??
|
|
9
|
+
(options.snapshot ? formatRemoteSessionReference(options.snapshot.id) : undefined);
|
|
10
|
+
const store = new RemoteSessionStore({
|
|
11
|
+
client: options.client,
|
|
12
|
+
reference,
|
|
13
|
+
snapshot: options.snapshot,
|
|
14
|
+
});
|
|
15
|
+
super(options.cwd, "", reference, store);
|
|
16
|
+
this.remoteStore = store;
|
|
17
|
+
}
|
|
18
|
+
newSession(options) {
|
|
19
|
+
const reference = super.newSession(options);
|
|
20
|
+
this.remoteStore?.saveSnapshot();
|
|
21
|
+
return reference;
|
|
22
|
+
}
|
|
23
|
+
flushPendingSync() {
|
|
24
|
+
return this.remoteStore?.flushPendingSync() ?? Promise.resolve();
|
|
25
|
+
}
|
|
26
|
+
getLastSyncError() {
|
|
27
|
+
return this.remoteStore?.getLastSyncError();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=remote-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-session.js","sourceRoot":"","sources":["../../../src/core/session/remote-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAUtE,MAAM,OAAO,aAAc,SAAQ,OAAO;IACjC,WAAW,CAAiC;IAEpD,YAAY,OAA6B,EAAE;QAC1C,MAAM,SAAS,GACd,OAAO,CAAC,SAAS;YACjB,OAAO,CAAC,QAAQ,EAAE,SAAS;YAC3B,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACpF,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC;YACpC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS;YACT,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC1B,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAAA,CACzB;IAEQ,UAAU,CAAC,OAA2B,EAAsB;QACpE,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IAAA,CACjB;IAED,gBAAgB,GAAkB;QACjC,OAAO,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAAA,CACjE;IAED,gBAAgB,GAAY;QAC3B,OAAO,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAAA,CAC5C;CACD","sourcesContent":["import type { RemoteSessionClient, RemoteSessionSnapshot } from \"./remote-session-client.ts\";\nimport { formatRemoteSessionReference } from \"./remote-session-client.ts\";\nimport { Session } from \"./session.ts\";\nimport { RemoteSessionStore } from \"./stores/remote-session-store.ts\";\nimport type { NewSessionOptions } from \"./types.ts\";\n\nexport interface RemoteSessionOptions {\n\tclient: RemoteSessionClient;\n\tcwd: string;\n\treference?: string;\n\tsnapshot?: RemoteSessionSnapshot;\n}\n\nexport class RemoteSession extends Session {\n\tprivate remoteStore: RemoteSessionStore | undefined;\n\n\tconstructor(options: RemoteSessionOptions) {\n\t\tconst reference =\n\t\t\toptions.reference ??\n\t\t\toptions.snapshot?.reference ??\n\t\t\t(options.snapshot ? formatRemoteSessionReference(options.snapshot.id) : undefined);\n\t\tconst store = new RemoteSessionStore({\n\t\t\tclient: options.client,\n\t\t\treference,\n\t\t\tsnapshot: options.snapshot,\n\t\t});\n\t\tsuper(options.cwd, \"\", reference, store);\n\t\tthis.remoteStore = store;\n\t}\n\n\toverride newSession(options?: NewSessionOptions): string | undefined {\n\t\tconst reference = super.newSession(options);\n\t\tthis.remoteStore?.saveSnapshot();\n\t\treturn reference;\n\t}\n\n\tflushPendingSync(): Promise<void> {\n\t\treturn this.remoteStore?.flushPendingSync() ?? Promise.resolve();\n\t}\n\n\tgetLastSyncError(): unknown {\n\t\treturn this.remoteStore?.getLastSyncError();\n\t}\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Session } from "./session.ts";
|
|
2
|
+
import type { NewSessionOptions, SessionInfo, SessionListProgress } from "./types.ts";
|
|
3
|
+
export type SessionResult = Session | Promise<Session>;
|
|
4
|
+
export interface OpenSessionOptions {
|
|
5
|
+
cwdOverride?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SessionManager {
|
|
8
|
+
create(options?: NewSessionOptions): SessionResult;
|
|
9
|
+
openReference(reference: string, options?: OpenSessionOptions): SessionResult;
|
|
10
|
+
continueRecent(): SessionResult;
|
|
11
|
+
forkFrom(reference: string): SessionResult;
|
|
12
|
+
forkSession(source: Session, targetLeafId: string | null): SessionResult;
|
|
13
|
+
importJsonl(inputPath: string, options?: OpenSessionOptions): SessionResult;
|
|
14
|
+
list(onProgress?: SessionListProgress): Promise<SessionInfo[]>;
|
|
15
|
+
listAll(onProgress?: SessionListProgress): Promise<SessionInfo[]>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/core/session/session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC;IACnD,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAC;IAC9E,cAAc,IAAI,aAAa,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC;IAC3C,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,CAAC;IACzE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAAC;IAC5E,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/D,OAAO,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAClE","sourcesContent":["import type { Session } from \"./session.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport type SessionResult = Session | Promise<Session>;\n\nexport interface OpenSessionOptions {\n\tcwdOverride?: string;\n}\n\nexport interface SessionManager {\n\tcreate(options?: NewSessionOptions): SessionResult;\n\topenReference(reference: string, options?: OpenSessionOptions): SessionResult;\n\tcontinueRecent(): SessionResult;\n\tforkFrom(reference: string): SessionResult;\n\tforkSession(source: Session, targetLeafId: string | null): SessionResult;\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): SessionResult;\n\tlist(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n\tlistAll(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../../src/core/session/session-manager.ts"],"names":[],"mappings":"","sourcesContent":["import type { Session } from \"./session.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport type SessionResult = Session | Promise<Session>;\n\nexport interface OpenSessionOptions {\n\tcwdOverride?: string;\n}\n\nexport interface SessionManager {\n\tcreate(options?: NewSessionOptions): SessionResult;\n\topenReference(reference: string, options?: OpenSessionOptions): SessionResult;\n\tcontinueRecent(): SessionResult;\n\tforkFrom(reference: string): SessionResult;\n\tforkSession(source: Session, targetLeafId: string | null): SessionResult;\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): SessionResult;\n\tlist(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n\tlistAll(onProgress?: SessionListProgress): Promise<SessionInfo[]>;\n}\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ImageContent, Message, TextContent } from "@fleetagent/pi-ai";
|
|
2
|
+
import type { BashExecutionMessage, CustomMessage } from "../messages.ts";
|
|
3
|
+
import type { SessionStore } from "./stores/session-store.ts";
|
|
4
|
+
import type { NewSessionOptions, SessionContext, SessionEntry, SessionHeader, SessionTreeNode } from "./types.ts";
|
|
5
|
+
export { CURRENT_SESSION_VERSION } from "./constants.ts";
|
|
6
|
+
export { buildSessionContext, getLatestCompactionEntry } from "./context.ts";
|
|
7
|
+
export { migrateSessionEntries, parseSessionEntries } from "./migrations.ts";
|
|
8
|
+
export type { BranchSummaryEntry, CompactionEntry, CustomEntry, CustomMessageEntry, FileEntry, LabelEntry, ModelChangeEntry, NewSessionOptions, SessionContext, SessionEntry, SessionEntryBase, SessionHeader, SessionInfo, SessionInfoEntry, SessionListProgress, SessionMessageEntry, SessionTreeNode, ThinkingLevelChangeEntry, } from "./types.ts";
|
|
9
|
+
export type ReadonlySessionManager = Pick<Session, "getCwd" | "getSessionDir" | "getSessionId" | "getSessionReference" | "getLeafId" | "getLeafEntry" | "getEntry" | "getLabel" | "getBranch" | "getHeader" | "getEntries" | "getTree" | "getSessionName">;
|
|
10
|
+
export { findMostRecentSession, getDefaultSessionDir, loadEntriesFromFile } from "./jsonl-helpers.ts";
|
|
11
|
+
/**
|
|
12
|
+
* Manages conversation sessions as append-only trees stored in JSONL files.
|
|
13
|
+
*
|
|
14
|
+
* Each session entry has an id and parentId forming a tree structure. The "leaf"
|
|
15
|
+
* pointer tracks the current position. Appending creates a child of the current leaf.
|
|
16
|
+
* Branching moves the leaf to an earlier entry, allowing new branches without
|
|
17
|
+
* modifying history.
|
|
18
|
+
*
|
|
19
|
+
* Use buildSessionContext() to get the resolved message list for the LLM, which
|
|
20
|
+
* handles compaction summaries and follows the path from root to current leaf.
|
|
21
|
+
*/
|
|
22
|
+
export declare abstract class Session {
|
|
23
|
+
private sessionId;
|
|
24
|
+
private sessionDir;
|
|
25
|
+
private cwd;
|
|
26
|
+
private store;
|
|
27
|
+
protected constructor(cwd: string, sessionDir: string, sessionReference: string | undefined, store: SessionStore);
|
|
28
|
+
/** Switch to a different session reference (used for resume and branching). */
|
|
29
|
+
setSessionReference(sessionReference: string): void;
|
|
30
|
+
newSession(options?: NewSessionOptions): string | undefined;
|
|
31
|
+
isPersisted(): boolean;
|
|
32
|
+
getCwd(): string;
|
|
33
|
+
getSessionDir(): string;
|
|
34
|
+
getSessionId(): string;
|
|
35
|
+
getSessionReference(): string | undefined;
|
|
36
|
+
private _appendEntry;
|
|
37
|
+
/** Append a message as child of current leaf, then advance leaf. Returns entry id.
|
|
38
|
+
* Does not allow writing CompactionSummaryMessage and BranchSummaryMessage directly.
|
|
39
|
+
* Reason: we want these to be top-level entries in the session, not message session entries,
|
|
40
|
+
* so it is easier to find them.
|
|
41
|
+
* These need to be appended via appendCompaction() and appendBranchSummary() methods.
|
|
42
|
+
*/
|
|
43
|
+
appendMessage(message: Message | CustomMessage | BashExecutionMessage): string;
|
|
44
|
+
/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
|
|
45
|
+
appendThinkingLevelChange(thinkingLevel: string): string;
|
|
46
|
+
/** Append a model change as child of current leaf, then advance leaf. Returns entry id. */
|
|
47
|
+
appendModelChange(provider: string, modelId: string): string;
|
|
48
|
+
/** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */
|
|
49
|
+
appendCompaction<T = unknown>(summary: string, firstKeptEntryId: string, tokensBefore: number, details?: T, fromHook?: boolean): string;
|
|
50
|
+
/** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */
|
|
51
|
+
appendCustomEntry(customType: string, data?: unknown): string;
|
|
52
|
+
/** Append a session info entry (e.g., display name). Returns entry id. */
|
|
53
|
+
appendSessionInfo(name: string): string;
|
|
54
|
+
/** Get the current session name from the latest session_info entry, if any. */
|
|
55
|
+
getSessionName(): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Append a custom message entry (for extensions) that participates in LLM context.
|
|
58
|
+
* @param customType Extension identifier for filtering on reload
|
|
59
|
+
* @param content Message content (string or TextContent/ImageContent array)
|
|
60
|
+
* @param display Whether to show in TUI (true = styled display, false = hidden)
|
|
61
|
+
* @param details Optional extension-specific metadata (not sent to LLM)
|
|
62
|
+
* @returns Entry id
|
|
63
|
+
*/
|
|
64
|
+
appendCustomMessageEntry<T = unknown>(customType: string, content: string | (TextContent | ImageContent)[], display: boolean, details?: T): string;
|
|
65
|
+
getLeafId(): string | null;
|
|
66
|
+
getLeafEntry(): SessionEntry | undefined;
|
|
67
|
+
getEntry(id: string): SessionEntry | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Get all direct children of an entry.
|
|
70
|
+
*/
|
|
71
|
+
getChildren(parentId: string): SessionEntry[];
|
|
72
|
+
/**
|
|
73
|
+
* Get the label for an entry, if any.
|
|
74
|
+
*/
|
|
75
|
+
getLabel(id: string): string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Set or clear a label on an entry.
|
|
78
|
+
* Labels are user-defined markers for bookmarking/navigation.
|
|
79
|
+
* Pass undefined or empty string to clear the label.
|
|
80
|
+
*/
|
|
81
|
+
appendLabelChange(targetId: string, label: string | undefined): string;
|
|
82
|
+
/**
|
|
83
|
+
* Walk from entry to root, returning all entries in path order.
|
|
84
|
+
* Includes all entry types (messages, compaction, model changes, etc.).
|
|
85
|
+
* Use buildSessionContext() to get the resolved messages for the LLM.
|
|
86
|
+
*/
|
|
87
|
+
getBranch(fromId?: string): SessionEntry[];
|
|
88
|
+
/**
|
|
89
|
+
* Build the session context (what gets sent to the LLM).
|
|
90
|
+
* Uses tree traversal from current leaf.
|
|
91
|
+
*/
|
|
92
|
+
buildSessionContext(): SessionContext;
|
|
93
|
+
/**
|
|
94
|
+
* Get session header.
|
|
95
|
+
*/
|
|
96
|
+
getHeader(): SessionHeader | null;
|
|
97
|
+
/**
|
|
98
|
+
* Get all session entries (excludes header). Returns a shallow copy.
|
|
99
|
+
* The session is append-only: use appendXXX() to add entries, branch() to
|
|
100
|
+
* change the leaf pointer. Entries cannot be modified or deleted.
|
|
101
|
+
*/
|
|
102
|
+
getEntries(): SessionEntry[];
|
|
103
|
+
/**
|
|
104
|
+
* Get the session as a tree structure. Returns a shallow defensive copy of all entries.
|
|
105
|
+
* A well-formed session has exactly one root (first entry with parentId === null).
|
|
106
|
+
* Orphaned entries (broken parent chain) are also returned as roots.
|
|
107
|
+
*/
|
|
108
|
+
getTree(): SessionTreeNode[];
|
|
109
|
+
/**
|
|
110
|
+
* Start a new branch from an earlier entry.
|
|
111
|
+
* Moves the leaf pointer to the specified entry. The next appendXXX() call
|
|
112
|
+
* will create a child of that entry, forming a new branch. Existing entries
|
|
113
|
+
* are not modified or deleted.
|
|
114
|
+
*/
|
|
115
|
+
branch(branchFromId: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* Reset the leaf pointer to null (before any entries).
|
|
118
|
+
* The next appendXXX() call will create a new root entry (parentId = null).
|
|
119
|
+
* Use this when navigating to re-edit the first user message.
|
|
120
|
+
*/
|
|
121
|
+
resetLeaf(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Start a new branch with a summary of the abandoned path.
|
|
124
|
+
* Same as branch(), but also appends a branch_summary entry that captures
|
|
125
|
+
* context from the abandoned conversation path.
|
|
126
|
+
*/
|
|
127
|
+
branchWithSummary(branchFromId: string | null, summary: string, details?: unknown, fromHook?: boolean): string;
|
|
128
|
+
/**
|
|
129
|
+
* Create a new session reference containing only the path from root to the specified leaf.
|
|
130
|
+
* Useful for extracting a single conversation path from a branched session.
|
|
131
|
+
* Returns the new session reference, or undefined if the store does not expose one.
|
|
132
|
+
*/
|
|
133
|
+
createBranchedSession(leafId: string): string | undefined;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/core/session/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAOX,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,aAAa,EAGb,eAAe,EAEf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,YAAY,EACX,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,GACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,OAAO,EACL,QAAQ,GACR,eAAe,GACf,cAAc,GACd,qBAAqB,GACrB,WAAW,GACX,cAAc,GACd,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,YAAY,GACZ,SAAS,GACT,gBAAgB,CAClB,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEtG;;;;;;;;;;GAUG;AACH,8BAAsB,OAAO;IAC5B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,KAAK,CAAe;IAE5B,SAAS,aAAa,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,EAa/G;IAED,+EAA+E;IAC/E,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAyBlD;IAED,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAa1D;IAED,WAAW,IAAI,OAAO,CAErB;IAED,MAAM,IAAI,MAAM,CAEf;IAED,aAAa,IAAI,MAAM,CAEtB;IAED,YAAY,IAAI,MAAM,CAErB;IAED,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExC;IAED,OAAO,CAAC,YAAY;IAIpB;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,oBAAoB,GAAG,MAAM,CAU7E;IAED,oGAAoG;IACpG,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAUvD;IAED,2FAA2F;IAC3F,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAW3D;IAED,iGAAiG;IACjG,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAC3B,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,CAAC,EACX,QAAQ,CAAC,EAAE,OAAO,GAChB,MAAM,CAcR;IAED,4GAA4G;IAC5G,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAW5D;IAED,0EAA0E;IAC1E,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUtC;IAED,+EAA+E;IAC/E,cAAc,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,CAAC,GAAG,OAAO,EACnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,CAAC,GACT,MAAM,CAaR;IAMD,SAAS,IAAI,MAAM,GAAG,IAAI,CAEzB;IAED,YAAY,IAAI,YAAY,GAAG,SAAS,CAEvC;IAED,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE7C;IAED;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,CAE5C;IAED;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAcrE;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE,CAEzC;IAED;;;OAGG;IACH,mBAAmB,IAAI,cAAc,CAEpC;IAED;;OAEG;IACH,SAAS,IAAI,aAAa,GAAG,IAAI,CAEhC;IAED;;;;OAIG;IACH,UAAU,IAAI,YAAY,EAAE,CAE3B;IAED;;;;OAIG;IACH,OAAO,IAAI,eAAe,EAAE,CAE3B;IAMD;;;;;OAKG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAKjC;IAED;;;;OAIG;IACH,SAAS,IAAI,IAAI,CAEhB;IAED;;;;OAIG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAiB7G;IAED;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA8CxD;CACD","sourcesContent":["import type { ImageContent, Message, TextContent } from \"@fleetagent/pi-ai\";\nimport type { BashExecutionMessage, CustomMessage } from \"../messages.ts\";\nimport { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { buildSessionContext } from \"./context.ts\";\nimport { createSessionId, generateId } from \"./ids.ts\";\nimport { migrateToCurrentVersion } from \"./migrations.ts\";\nimport type { SessionStore } from \"./stores/session-store.ts\";\nimport type {\n\tBranchSummaryEntry,\n\tCompactionEntry,\n\tCustomEntry,\n\tCustomMessageEntry,\n\tLabelEntry,\n\tModelChangeEntry,\n\tNewSessionOptions,\n\tSessionContext,\n\tSessionEntry,\n\tSessionHeader,\n\tSessionInfoEntry,\n\tSessionMessageEntry,\n\tSessionTreeNode,\n\tThinkingLevelChangeEntry,\n} from \"./types.ts\";\n\nexport { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nexport { buildSessionContext, getLatestCompactionEntry } from \"./context.ts\";\nexport { migrateSessionEntries, parseSessionEntries } from \"./migrations.ts\";\n\nexport type {\n\tBranchSummaryEntry,\n\tCompactionEntry,\n\tCustomEntry,\n\tCustomMessageEntry,\n\tFileEntry,\n\tLabelEntry,\n\tModelChangeEntry,\n\tNewSessionOptions,\n\tSessionContext,\n\tSessionEntry,\n\tSessionEntryBase,\n\tSessionHeader,\n\tSessionInfo,\n\tSessionInfoEntry,\n\tSessionListProgress,\n\tSessionMessageEntry,\n\tSessionTreeNode,\n\tThinkingLevelChangeEntry,\n} from \"./types.ts\";\n\nexport type ReadonlySessionManager = Pick<\n\tSession,\n\t| \"getCwd\"\n\t| \"getSessionDir\"\n\t| \"getSessionId\"\n\t| \"getSessionReference\"\n\t| \"getLeafId\"\n\t| \"getLeafEntry\"\n\t| \"getEntry\"\n\t| \"getLabel\"\n\t| \"getBranch\"\n\t| \"getHeader\"\n\t| \"getEntries\"\n\t| \"getTree\"\n\t| \"getSessionName\"\n>;\n\nexport { findMostRecentSession, getDefaultSessionDir, loadEntriesFromFile } from \"./jsonl-helpers.ts\";\n\n/**\n * Manages conversation sessions as append-only trees stored in JSONL files.\n *\n * Each session entry has an id and parentId forming a tree structure. The \"leaf\"\n * pointer tracks the current position. Appending creates a child of the current leaf.\n * Branching moves the leaf to an earlier entry, allowing new branches without\n * modifying history.\n *\n * Use buildSessionContext() to get the resolved message list for the LLM, which\n * handles compaction summaries and follows the path from root to current leaf.\n */\nexport abstract class Session {\n\tprivate sessionId: string = \"\";\n\tprivate sessionDir: string;\n\tprivate cwd: string;\n\tprivate store: SessionStore;\n\n\tprotected constructor(cwd: string, sessionDir: string, sessionReference: string | undefined, store: SessionStore) {\n\t\tthis.cwd = cwd;\n\t\tthis.sessionDir = sessionDir;\n\t\tthis.store = store;\n\t\tif (sessionDir) {\n\t\t\tthis.store.ensureDir(sessionDir);\n\t\t}\n\n\t\tif (sessionReference) {\n\t\t\tthis.setSessionReference(sessionReference);\n\t\t} else {\n\t\t\tthis.newSession();\n\t\t}\n\t}\n\n\t/** Switch to a different session reference (used for resume and branching). */\n\tsetSessionReference(sessionReference: string): void {\n\t\tconst opened = this.store.openSession(sessionReference);\n\t\tif (opened.exists) {\n\t\t\tthis.store.setEntries(opened.entries);\n\n\t\t\t// If the opened session has no valid header, start fresh to avoid\n\t\t\t// appending messages without a session header.\n\t\t\tif (this.store.getFileEntries().length === 0) {\n\t\t\t\tthis.newSession();\n\t\t\t\tthis.store.setSessionReference(opened.reference);\n\t\t\t\tthis.store.saveSnapshot();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst header = this.store.getHeader();\n\t\t\tthis.sessionId = header?.id ?? createSessionId();\n\n\t\t\tif (migrateToCurrentVersion(this.store.getFileEntries())) {\n\t\t\t\tthis.store.setEntries(this.store.getFileEntries());\n\t\t\t\tthis.store.saveSnapshot();\n\t\t\t}\n\t\t} else {\n\t\t\tthis.newSession();\n\t\t\tthis.store.setSessionReference(opened.reference); // preserve explicit path from --session flag\n\t\t}\n\t}\n\n\tnewSession(options?: NewSessionOptions): string | undefined {\n\t\tthis.sessionId = options?.id ?? createSessionId();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: this.sessionId,\n\t\t\ttimestamp,\n\t\t\tcwd: this.cwd,\n\t\t\tparentSession: options?.parentSession,\n\t\t};\n\t\tthis.store.setEntries([header]);\n\t\treturn this.store.prepareSessionReference(this.getSessionDir(), this.sessionId, timestamp);\n\t}\n\n\tisPersisted(): boolean {\n\t\treturn this.store.isPersisted();\n\t}\n\n\tgetCwd(): string {\n\t\treturn this.cwd;\n\t}\n\n\tgetSessionDir(): string {\n\t\treturn this.sessionDir;\n\t}\n\n\tgetSessionId(): string {\n\t\treturn this.sessionId;\n\t}\n\n\tgetSessionReference(): string | undefined {\n\t\treturn this.store.getSessionReference();\n\t}\n\n\tprivate _appendEntry(entry: SessionEntry): void {\n\t\tthis.store.appendEntry(entry);\n\t}\n\n\t/** Append a message as child of current leaf, then advance leaf. Returns entry id.\n\t * Does not allow writing CompactionSummaryMessage and BranchSummaryMessage directly.\n\t * Reason: we want these to be top-level entries in the session, not message session entries,\n\t * so it is easier to find them.\n\t * These need to be appended via appendCompaction() and appendBranchSummary() methods.\n\t */\n\tappendMessage(message: Message | CustomMessage | BashExecutionMessage): string {\n\t\tconst entry: SessionMessageEntry = {\n\t\t\ttype: \"message\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tmessage,\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */\n\tappendThinkingLevelChange(thinkingLevel: string): string {\n\t\tconst entry: ThinkingLevelChangeEntry = {\n\t\t\ttype: \"thinking_level_change\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tthinkingLevel,\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/** Append a model change as child of current leaf, then advance leaf. Returns entry id. */\n\tappendModelChange(provider: string, modelId: string): string {\n\t\tconst entry: ModelChangeEntry = {\n\t\t\ttype: \"model_change\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tprovider,\n\t\t\tmodelId,\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */\n\tappendCompaction<T = unknown>(\n\t\tsummary: string,\n\t\tfirstKeptEntryId: string,\n\t\ttokensBefore: number,\n\t\tdetails?: T,\n\t\tfromHook?: boolean,\n\t): string {\n\t\tconst entry: CompactionEntry<T> = {\n\t\t\ttype: \"compaction\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tsummary,\n\t\t\tfirstKeptEntryId,\n\t\t\ttokensBefore,\n\t\t\tdetails,\n\t\t\tfromHook,\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */\n\tappendCustomEntry(customType: string, data?: unknown): string {\n\t\tconst entry: CustomEntry = {\n\t\t\ttype: \"custom\",\n\t\t\tcustomType,\n\t\t\tdata,\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/** Append a session info entry (e.g., display name). Returns entry id. */\n\tappendSessionInfo(name: string): string {\n\t\tconst entry: SessionInfoEntry = {\n\t\t\ttype: \"session_info\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tname: name.trim(),\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/** Get the current session name from the latest session_info entry, if any. */\n\tgetSessionName(): string | undefined {\n\t\treturn this.store.getSessionName();\n\t}\n\n\t/**\n\t * Append a custom message entry (for extensions) that participates in LLM context.\n\t * @param customType Extension identifier for filtering on reload\n\t * @param content Message content (string or TextContent/ImageContent array)\n\t * @param display Whether to show in TUI (true = styled display, false = hidden)\n\t * @param details Optional extension-specific metadata (not sent to LLM)\n\t * @returns Entry id\n\t */\n\tappendCustomMessageEntry<T = unknown>(\n\t\tcustomType: string,\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\tdisplay: boolean,\n\t\tdetails?: T,\n\t): string {\n\t\tconst entry: CustomMessageEntry<T> = {\n\t\t\ttype: \"custom_message\",\n\t\t\tcustomType,\n\t\t\tcontent,\n\t\t\tdisplay,\n\t\t\tdetails,\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t// =========================================================================\n\t// Tree Traversal\n\t// =========================================================================\n\n\tgetLeafId(): string | null {\n\t\treturn this.store.getLeafId();\n\t}\n\n\tgetLeafEntry(): SessionEntry | undefined {\n\t\treturn this.store.getLeafEntry();\n\t}\n\n\tgetEntry(id: string): SessionEntry | undefined {\n\t\treturn this.store.getEntry(id);\n\t}\n\n\t/**\n\t * Get all direct children of an entry.\n\t */\n\tgetChildren(parentId: string): SessionEntry[] {\n\t\treturn this.store.getChildren(parentId);\n\t}\n\n\t/**\n\t * Get the label for an entry, if any.\n\t */\n\tgetLabel(id: string): string | undefined {\n\t\treturn this.store.getLabel(id);\n\t}\n\n\t/**\n\t * Set or clear a label on an entry.\n\t * Labels are user-defined markers for bookmarking/navigation.\n\t * Pass undefined or empty string to clear the label.\n\t */\n\tappendLabelChange(targetId: string, label: string | undefined): string {\n\t\tif (!this.store.has(targetId)) {\n\t\t\tthrow new Error(`Entry ${targetId} not found`);\n\t\t}\n\t\tconst entry: LabelEntry = {\n\t\t\ttype: \"label\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: this.store.getLeafId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId,\n\t\t\tlabel,\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/**\n\t * Walk from entry to root, returning all entries in path order.\n\t * Includes all entry types (messages, compaction, model changes, etc.).\n\t * Use buildSessionContext() to get the resolved messages for the LLM.\n\t */\n\tgetBranch(fromId?: string): SessionEntry[] {\n\t\treturn this.store.getBranch(fromId);\n\t}\n\n\t/**\n\t * Build the session context (what gets sent to the LLM).\n\t * Uses tree traversal from current leaf.\n\t */\n\tbuildSessionContext(): SessionContext {\n\t\treturn buildSessionContext(this.getEntries(), this.store.getLeafId(), this.store.getEntryIndex());\n\t}\n\n\t/**\n\t * Get session header.\n\t */\n\tgetHeader(): SessionHeader | null {\n\t\treturn this.store.getHeader();\n\t}\n\n\t/**\n\t * Get all session entries (excludes header). Returns a shallow copy.\n\t * The session is append-only: use appendXXX() to add entries, branch() to\n\t * change the leaf pointer. Entries cannot be modified or deleted.\n\t */\n\tgetEntries(): SessionEntry[] {\n\t\treturn this.store.getEntries();\n\t}\n\n\t/**\n\t * Get the session as a tree structure. Returns a shallow defensive copy of all entries.\n\t * A well-formed session has exactly one root (first entry with parentId === null).\n\t * Orphaned entries (broken parent chain) are also returned as roots.\n\t */\n\tgetTree(): SessionTreeNode[] {\n\t\treturn this.store.getTree();\n\t}\n\n\t// =========================================================================\n\t// Branching\n\t// =========================================================================\n\n\t/**\n\t * Start a new branch from an earlier entry.\n\t * Moves the leaf pointer to the specified entry. The next appendXXX() call\n\t * will create a child of that entry, forming a new branch. Existing entries\n\t * are not modified or deleted.\n\t */\n\tbranch(branchFromId: string): void {\n\t\tif (!this.store.has(branchFromId)) {\n\t\t\tthrow new Error(`Entry ${branchFromId} not found`);\n\t\t}\n\t\tthis.store.setLeafId(branchFromId);\n\t}\n\n\t/**\n\t * Reset the leaf pointer to null (before any entries).\n\t * The next appendXXX() call will create a new root entry (parentId = null).\n\t * Use this when navigating to re-edit the first user message.\n\t */\n\tresetLeaf(): void {\n\t\tthis.store.setLeafId(null);\n\t}\n\n\t/**\n\t * Start a new branch with a summary of the abandoned path.\n\t * Same as branch(), but also appends a branch_summary entry that captures\n\t * context from the abandoned conversation path.\n\t */\n\tbranchWithSummary(branchFromId: string | null, summary: string, details?: unknown, fromHook?: boolean): string {\n\t\tif (branchFromId !== null && !this.store.has(branchFromId)) {\n\t\t\tthrow new Error(`Entry ${branchFromId} not found`);\n\t\t}\n\t\tthis.store.setLeafId(branchFromId);\n\t\tconst entry: BranchSummaryEntry = {\n\t\t\ttype: \"branch_summary\",\n\t\t\tid: generateId(this.store),\n\t\t\tparentId: branchFromId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tfromId: branchFromId ?? \"root\",\n\t\t\tsummary,\n\t\t\tdetails,\n\t\t\tfromHook,\n\t\t};\n\t\tthis._appendEntry(entry);\n\t\treturn entry.id;\n\t}\n\n\t/**\n\t * Create a new session reference containing only the path from root to the specified leaf.\n\t * Useful for extracting a single conversation path from a branched session.\n\t * Returns the new session reference, or undefined if the store does not expose one.\n\t */\n\tcreateBranchedSession(leafId: string): string | undefined {\n\t\tconst parentSession = this.store.getParentSessionReference();\n\t\tconst path = this.getBranch(leafId);\n\t\tif (path.length === 0) {\n\t\t\tthrow new Error(`Entry ${leafId} not found`);\n\t\t}\n\n\t\t// Filter out LabelEntry from path - we'll recreate them from the resolved map\n\t\tconst pathWithoutLabels = path.filter((e) => e.type !== \"label\");\n\n\t\tconst newSessionId = createSessionId();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst newSessionReference = this.store.prepareSessionReference(this.getSessionDir(), newSessionId, timestamp);\n\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: newSessionId,\n\t\t\ttimestamp,\n\t\t\tcwd: this.cwd,\n\t\t\tparentSession,\n\t\t};\n\n\t\t// Collect labels for entries in the path\n\t\tconst pathEntryIds = new Set(pathWithoutLabels.map((e) => e.id));\n\t\tconst labelsToWrite = this.store.getLabelsForEntryIds(pathEntryIds);\n\n\t\tconst labelEntries: LabelEntry[] = [];\n\t\tlet parentId = pathWithoutLabels[pathWithoutLabels.length - 1]?.id || null;\n\t\tfor (const { targetId, label, timestamp: labelTimestamp } of labelsToWrite) {\n\t\t\tconst labelEntry: LabelEntry = {\n\t\t\t\ttype: \"label\",\n\t\t\t\tid: generateId(new Set([...pathEntryIds, ...labelEntries.map((e) => e.id)])),\n\t\t\t\tparentId,\n\t\t\t\ttimestamp: labelTimestamp,\n\t\t\t\ttargetId,\n\t\t\t\tlabel,\n\t\t\t};\n\t\t\tpathEntryIds.add(labelEntry.id);\n\t\t\tlabelEntries.push(labelEntry);\n\t\t\tparentId = labelEntry.id;\n\t\t}\n\t\tthis.store.setEntries([header, ...pathWithoutLabels, ...labelEntries]);\n\t\tthis.sessionId = newSessionId;\n\t\tthis.store.commitSnapshot();\n\t\treturn newSessionReference;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { CURRENT_SESSION_VERSION } from "./constants.js";
|
|
2
|
+
import { buildSessionContext } from "./context.js";
|
|
3
|
+
import { createSessionId, generateId } from "./ids.js";
|
|
4
|
+
import { migrateToCurrentVersion } from "./migrations.js";
|
|
5
|
+
export { CURRENT_SESSION_VERSION } from "./constants.js";
|
|
6
|
+
export { buildSessionContext, getLatestCompactionEntry } from "./context.js";
|
|
7
|
+
export { migrateSessionEntries, parseSessionEntries } from "./migrations.js";
|
|
8
|
+
export { findMostRecentSession, getDefaultSessionDir, loadEntriesFromFile } from "./jsonl-helpers.js";
|
|
9
|
+
/**
|
|
10
|
+
* Manages conversation sessions as append-only trees stored in JSONL files.
|
|
11
|
+
*
|
|
12
|
+
* Each session entry has an id and parentId forming a tree structure. The "leaf"
|
|
13
|
+
* pointer tracks the current position. Appending creates a child of the current leaf.
|
|
14
|
+
* Branching moves the leaf to an earlier entry, allowing new branches without
|
|
15
|
+
* modifying history.
|
|
16
|
+
*
|
|
17
|
+
* Use buildSessionContext() to get the resolved message list for the LLM, which
|
|
18
|
+
* handles compaction summaries and follows the path from root to current leaf.
|
|
19
|
+
*/
|
|
20
|
+
export class Session {
|
|
21
|
+
sessionId = "";
|
|
22
|
+
sessionDir;
|
|
23
|
+
cwd;
|
|
24
|
+
store;
|
|
25
|
+
constructor(cwd, sessionDir, sessionReference, store) {
|
|
26
|
+
this.cwd = cwd;
|
|
27
|
+
this.sessionDir = sessionDir;
|
|
28
|
+
this.store = store;
|
|
29
|
+
if (sessionDir) {
|
|
30
|
+
this.store.ensureDir(sessionDir);
|
|
31
|
+
}
|
|
32
|
+
if (sessionReference) {
|
|
33
|
+
this.setSessionReference(sessionReference);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.newSession();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Switch to a different session reference (used for resume and branching). */
|
|
40
|
+
setSessionReference(sessionReference) {
|
|
41
|
+
const opened = this.store.openSession(sessionReference);
|
|
42
|
+
if (opened.exists) {
|
|
43
|
+
this.store.setEntries(opened.entries);
|
|
44
|
+
// If the opened session has no valid header, start fresh to avoid
|
|
45
|
+
// appending messages without a session header.
|
|
46
|
+
if (this.store.getFileEntries().length === 0) {
|
|
47
|
+
this.newSession();
|
|
48
|
+
this.store.setSessionReference(opened.reference);
|
|
49
|
+
this.store.saveSnapshot();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const header = this.store.getHeader();
|
|
53
|
+
this.sessionId = header?.id ?? createSessionId();
|
|
54
|
+
if (migrateToCurrentVersion(this.store.getFileEntries())) {
|
|
55
|
+
this.store.setEntries(this.store.getFileEntries());
|
|
56
|
+
this.store.saveSnapshot();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.newSession();
|
|
61
|
+
this.store.setSessionReference(opened.reference); // preserve explicit path from --session flag
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
newSession(options) {
|
|
65
|
+
this.sessionId = options?.id ?? createSessionId();
|
|
66
|
+
const timestamp = new Date().toISOString();
|
|
67
|
+
const header = {
|
|
68
|
+
type: "session",
|
|
69
|
+
version: CURRENT_SESSION_VERSION,
|
|
70
|
+
id: this.sessionId,
|
|
71
|
+
timestamp,
|
|
72
|
+
cwd: this.cwd,
|
|
73
|
+
parentSession: options?.parentSession,
|
|
74
|
+
};
|
|
75
|
+
this.store.setEntries([header]);
|
|
76
|
+
return this.store.prepareSessionReference(this.getSessionDir(), this.sessionId, timestamp);
|
|
77
|
+
}
|
|
78
|
+
isPersisted() {
|
|
79
|
+
return this.store.isPersisted();
|
|
80
|
+
}
|
|
81
|
+
getCwd() {
|
|
82
|
+
return this.cwd;
|
|
83
|
+
}
|
|
84
|
+
getSessionDir() {
|
|
85
|
+
return this.sessionDir;
|
|
86
|
+
}
|
|
87
|
+
getSessionId() {
|
|
88
|
+
return this.sessionId;
|
|
89
|
+
}
|
|
90
|
+
getSessionReference() {
|
|
91
|
+
return this.store.getSessionReference();
|
|
92
|
+
}
|
|
93
|
+
_appendEntry(entry) {
|
|
94
|
+
this.store.appendEntry(entry);
|
|
95
|
+
}
|
|
96
|
+
/** Append a message as child of current leaf, then advance leaf. Returns entry id.
|
|
97
|
+
* Does not allow writing CompactionSummaryMessage and BranchSummaryMessage directly.
|
|
98
|
+
* Reason: we want these to be top-level entries in the session, not message session entries,
|
|
99
|
+
* so it is easier to find them.
|
|
100
|
+
* These need to be appended via appendCompaction() and appendBranchSummary() methods.
|
|
101
|
+
*/
|
|
102
|
+
appendMessage(message) {
|
|
103
|
+
const entry = {
|
|
104
|
+
type: "message",
|
|
105
|
+
id: generateId(this.store),
|
|
106
|
+
parentId: this.store.getLeafId(),
|
|
107
|
+
timestamp: new Date().toISOString(),
|
|
108
|
+
message,
|
|
109
|
+
};
|
|
110
|
+
this._appendEntry(entry);
|
|
111
|
+
return entry.id;
|
|
112
|
+
}
|
|
113
|
+
/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
|
|
114
|
+
appendThinkingLevelChange(thinkingLevel) {
|
|
115
|
+
const entry = {
|
|
116
|
+
type: "thinking_level_change",
|
|
117
|
+
id: generateId(this.store),
|
|
118
|
+
parentId: this.store.getLeafId(),
|
|
119
|
+
timestamp: new Date().toISOString(),
|
|
120
|
+
thinkingLevel,
|
|
121
|
+
};
|
|
122
|
+
this._appendEntry(entry);
|
|
123
|
+
return entry.id;
|
|
124
|
+
}
|
|
125
|
+
/** Append a model change as child of current leaf, then advance leaf. Returns entry id. */
|
|
126
|
+
appendModelChange(provider, modelId) {
|
|
127
|
+
const entry = {
|
|
128
|
+
type: "model_change",
|
|
129
|
+
id: generateId(this.store),
|
|
130
|
+
parentId: this.store.getLeafId(),
|
|
131
|
+
timestamp: new Date().toISOString(),
|
|
132
|
+
provider,
|
|
133
|
+
modelId,
|
|
134
|
+
};
|
|
135
|
+
this._appendEntry(entry);
|
|
136
|
+
return entry.id;
|
|
137
|
+
}
|
|
138
|
+
/** Append a compaction summary as child of current leaf, then advance leaf. Returns entry id. */
|
|
139
|
+
appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromHook) {
|
|
140
|
+
const entry = {
|
|
141
|
+
type: "compaction",
|
|
142
|
+
id: generateId(this.store),
|
|
143
|
+
parentId: this.store.getLeafId(),
|
|
144
|
+
timestamp: new Date().toISOString(),
|
|
145
|
+
summary,
|
|
146
|
+
firstKeptEntryId,
|
|
147
|
+
tokensBefore,
|
|
148
|
+
details,
|
|
149
|
+
fromHook,
|
|
150
|
+
};
|
|
151
|
+
this._appendEntry(entry);
|
|
152
|
+
return entry.id;
|
|
153
|
+
}
|
|
154
|
+
/** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */
|
|
155
|
+
appendCustomEntry(customType, data) {
|
|
156
|
+
const entry = {
|
|
157
|
+
type: "custom",
|
|
158
|
+
customType,
|
|
159
|
+
data,
|
|
160
|
+
id: generateId(this.store),
|
|
161
|
+
parentId: this.store.getLeafId(),
|
|
162
|
+
timestamp: new Date().toISOString(),
|
|
163
|
+
};
|
|
164
|
+
this._appendEntry(entry);
|
|
165
|
+
return entry.id;
|
|
166
|
+
}
|
|
167
|
+
/** Append a session info entry (e.g., display name). Returns entry id. */
|
|
168
|
+
appendSessionInfo(name) {
|
|
169
|
+
const entry = {
|
|
170
|
+
type: "session_info",
|
|
171
|
+
id: generateId(this.store),
|
|
172
|
+
parentId: this.store.getLeafId(),
|
|
173
|
+
timestamp: new Date().toISOString(),
|
|
174
|
+
name: name.trim(),
|
|
175
|
+
};
|
|
176
|
+
this._appendEntry(entry);
|
|
177
|
+
return entry.id;
|
|
178
|
+
}
|
|
179
|
+
/** Get the current session name from the latest session_info entry, if any. */
|
|
180
|
+
getSessionName() {
|
|
181
|
+
return this.store.getSessionName();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Append a custom message entry (for extensions) that participates in LLM context.
|
|
185
|
+
* @param customType Extension identifier for filtering on reload
|
|
186
|
+
* @param content Message content (string or TextContent/ImageContent array)
|
|
187
|
+
* @param display Whether to show in TUI (true = styled display, false = hidden)
|
|
188
|
+
* @param details Optional extension-specific metadata (not sent to LLM)
|
|
189
|
+
* @returns Entry id
|
|
190
|
+
*/
|
|
191
|
+
appendCustomMessageEntry(customType, content, display, details) {
|
|
192
|
+
const entry = {
|
|
193
|
+
type: "custom_message",
|
|
194
|
+
customType,
|
|
195
|
+
content,
|
|
196
|
+
display,
|
|
197
|
+
details,
|
|
198
|
+
id: generateId(this.store),
|
|
199
|
+
parentId: this.store.getLeafId(),
|
|
200
|
+
timestamp: new Date().toISOString(),
|
|
201
|
+
};
|
|
202
|
+
this._appendEntry(entry);
|
|
203
|
+
return entry.id;
|
|
204
|
+
}
|
|
205
|
+
// =========================================================================
|
|
206
|
+
// Tree Traversal
|
|
207
|
+
// =========================================================================
|
|
208
|
+
getLeafId() {
|
|
209
|
+
return this.store.getLeafId();
|
|
210
|
+
}
|
|
211
|
+
getLeafEntry() {
|
|
212
|
+
return this.store.getLeafEntry();
|
|
213
|
+
}
|
|
214
|
+
getEntry(id) {
|
|
215
|
+
return this.store.getEntry(id);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get all direct children of an entry.
|
|
219
|
+
*/
|
|
220
|
+
getChildren(parentId) {
|
|
221
|
+
return this.store.getChildren(parentId);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get the label for an entry, if any.
|
|
225
|
+
*/
|
|
226
|
+
getLabel(id) {
|
|
227
|
+
return this.store.getLabel(id);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Set or clear a label on an entry.
|
|
231
|
+
* Labels are user-defined markers for bookmarking/navigation.
|
|
232
|
+
* Pass undefined or empty string to clear the label.
|
|
233
|
+
*/
|
|
234
|
+
appendLabelChange(targetId, label) {
|
|
235
|
+
if (!this.store.has(targetId)) {
|
|
236
|
+
throw new Error(`Entry ${targetId} not found`);
|
|
237
|
+
}
|
|
238
|
+
const entry = {
|
|
239
|
+
type: "label",
|
|
240
|
+
id: generateId(this.store),
|
|
241
|
+
parentId: this.store.getLeafId(),
|
|
242
|
+
timestamp: new Date().toISOString(),
|
|
243
|
+
targetId,
|
|
244
|
+
label,
|
|
245
|
+
};
|
|
246
|
+
this._appendEntry(entry);
|
|
247
|
+
return entry.id;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Walk from entry to root, returning all entries in path order.
|
|
251
|
+
* Includes all entry types (messages, compaction, model changes, etc.).
|
|
252
|
+
* Use buildSessionContext() to get the resolved messages for the LLM.
|
|
253
|
+
*/
|
|
254
|
+
getBranch(fromId) {
|
|
255
|
+
return this.store.getBranch(fromId);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Build the session context (what gets sent to the LLM).
|
|
259
|
+
* Uses tree traversal from current leaf.
|
|
260
|
+
*/
|
|
261
|
+
buildSessionContext() {
|
|
262
|
+
return buildSessionContext(this.getEntries(), this.store.getLeafId(), this.store.getEntryIndex());
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get session header.
|
|
266
|
+
*/
|
|
267
|
+
getHeader() {
|
|
268
|
+
return this.store.getHeader();
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Get all session entries (excludes header). Returns a shallow copy.
|
|
272
|
+
* The session is append-only: use appendXXX() to add entries, branch() to
|
|
273
|
+
* change the leaf pointer. Entries cannot be modified or deleted.
|
|
274
|
+
*/
|
|
275
|
+
getEntries() {
|
|
276
|
+
return this.store.getEntries();
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get the session as a tree structure. Returns a shallow defensive copy of all entries.
|
|
280
|
+
* A well-formed session has exactly one root (first entry with parentId === null).
|
|
281
|
+
* Orphaned entries (broken parent chain) are also returned as roots.
|
|
282
|
+
*/
|
|
283
|
+
getTree() {
|
|
284
|
+
return this.store.getTree();
|
|
285
|
+
}
|
|
286
|
+
// =========================================================================
|
|
287
|
+
// Branching
|
|
288
|
+
// =========================================================================
|
|
289
|
+
/**
|
|
290
|
+
* Start a new branch from an earlier entry.
|
|
291
|
+
* Moves the leaf pointer to the specified entry. The next appendXXX() call
|
|
292
|
+
* will create a child of that entry, forming a new branch. Existing entries
|
|
293
|
+
* are not modified or deleted.
|
|
294
|
+
*/
|
|
295
|
+
branch(branchFromId) {
|
|
296
|
+
if (!this.store.has(branchFromId)) {
|
|
297
|
+
throw new Error(`Entry ${branchFromId} not found`);
|
|
298
|
+
}
|
|
299
|
+
this.store.setLeafId(branchFromId);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Reset the leaf pointer to null (before any entries).
|
|
303
|
+
* The next appendXXX() call will create a new root entry (parentId = null).
|
|
304
|
+
* Use this when navigating to re-edit the first user message.
|
|
305
|
+
*/
|
|
306
|
+
resetLeaf() {
|
|
307
|
+
this.store.setLeafId(null);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Start a new branch with a summary of the abandoned path.
|
|
311
|
+
* Same as branch(), but also appends a branch_summary entry that captures
|
|
312
|
+
* context from the abandoned conversation path.
|
|
313
|
+
*/
|
|
314
|
+
branchWithSummary(branchFromId, summary, details, fromHook) {
|
|
315
|
+
if (branchFromId !== null && !this.store.has(branchFromId)) {
|
|
316
|
+
throw new Error(`Entry ${branchFromId} not found`);
|
|
317
|
+
}
|
|
318
|
+
this.store.setLeafId(branchFromId);
|
|
319
|
+
const entry = {
|
|
320
|
+
type: "branch_summary",
|
|
321
|
+
id: generateId(this.store),
|
|
322
|
+
parentId: branchFromId,
|
|
323
|
+
timestamp: new Date().toISOString(),
|
|
324
|
+
fromId: branchFromId ?? "root",
|
|
325
|
+
summary,
|
|
326
|
+
details,
|
|
327
|
+
fromHook,
|
|
328
|
+
};
|
|
329
|
+
this._appendEntry(entry);
|
|
330
|
+
return entry.id;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Create a new session reference containing only the path from root to the specified leaf.
|
|
334
|
+
* Useful for extracting a single conversation path from a branched session.
|
|
335
|
+
* Returns the new session reference, or undefined if the store does not expose one.
|
|
336
|
+
*/
|
|
337
|
+
createBranchedSession(leafId) {
|
|
338
|
+
const parentSession = this.store.getParentSessionReference();
|
|
339
|
+
const path = this.getBranch(leafId);
|
|
340
|
+
if (path.length === 0) {
|
|
341
|
+
throw new Error(`Entry ${leafId} not found`);
|
|
342
|
+
}
|
|
343
|
+
// Filter out LabelEntry from path - we'll recreate them from the resolved map
|
|
344
|
+
const pathWithoutLabels = path.filter((e) => e.type !== "label");
|
|
345
|
+
const newSessionId = createSessionId();
|
|
346
|
+
const timestamp = new Date().toISOString();
|
|
347
|
+
const newSessionReference = this.store.prepareSessionReference(this.getSessionDir(), newSessionId, timestamp);
|
|
348
|
+
const header = {
|
|
349
|
+
type: "session",
|
|
350
|
+
version: CURRENT_SESSION_VERSION,
|
|
351
|
+
id: newSessionId,
|
|
352
|
+
timestamp,
|
|
353
|
+
cwd: this.cwd,
|
|
354
|
+
parentSession,
|
|
355
|
+
};
|
|
356
|
+
// Collect labels for entries in the path
|
|
357
|
+
const pathEntryIds = new Set(pathWithoutLabels.map((e) => e.id));
|
|
358
|
+
const labelsToWrite = this.store.getLabelsForEntryIds(pathEntryIds);
|
|
359
|
+
const labelEntries = [];
|
|
360
|
+
let parentId = pathWithoutLabels[pathWithoutLabels.length - 1]?.id || null;
|
|
361
|
+
for (const { targetId, label, timestamp: labelTimestamp } of labelsToWrite) {
|
|
362
|
+
const labelEntry = {
|
|
363
|
+
type: "label",
|
|
364
|
+
id: generateId(new Set([...pathEntryIds, ...labelEntries.map((e) => e.id)])),
|
|
365
|
+
parentId,
|
|
366
|
+
timestamp: labelTimestamp,
|
|
367
|
+
targetId,
|
|
368
|
+
label,
|
|
369
|
+
};
|
|
370
|
+
pathEntryIds.add(labelEntry.id);
|
|
371
|
+
labelEntries.push(labelEntry);
|
|
372
|
+
parentId = labelEntry.id;
|
|
373
|
+
}
|
|
374
|
+
this.store.setEntries([header, ...pathWithoutLabels, ...labelEntries]);
|
|
375
|
+
this.sessionId = newSessionId;
|
|
376
|
+
this.store.commitSnapshot();
|
|
377
|
+
return newSessionReference;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=session.js.map
|