@psnext/slingcli 2.4.20260507-3 → 2.4.20260509-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/LICENSE +1 -1
- package/README.md +1 -1
- package/bin/sling.js +12 -12
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/agent-loop.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/agent.js +4 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +526 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +243 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +616 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +348 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/execution-env.js +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/factory.js +9 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +102 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +194 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/jsonl.js +92 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/memory.js +42 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/shared.js +31 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +196 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/jsonl.js +170 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/memory.js +90 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +258 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +30 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +16 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +97 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/index.js +26 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/proxy.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/package.json +7 -5
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/cli.js +6 -6
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/env-api-keys.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +307 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.js +23 -0
- package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js +22 -0
- package/node_modules/@earendil-works/pi-ai/dist/images.js +14 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/index.js +4 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/models.generated.js +427 -122
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js +129 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +34 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-codex-responses.js +1 -1
- package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-completions.js +150 -122
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-responses-shared.js +14 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/openai-codex.js +25 -14
- package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/overflow.js +3 -0
- package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/package.json +5 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/bun/register-bedrock.js +4 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/args.js +1 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/config-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/list-models.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/session-picker.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/config.js +52 -30
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/auth-storage.js +2 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/branch-summarization.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/compaction.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/utils.js +153 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.css +45 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.js +68 -4
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/loader.js +26 -12
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/keybindings.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/model-registry.js +3 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/model-resolver.js +2 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/package-manager.js +22 -5
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/provider-display-names.js +1 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/sdk.js +3 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/bash.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/edit.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/find.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/grep.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/ls.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/read.js +3 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/render-utils.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js +205 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/write.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/main.js +2 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/migrations.js +3 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/bash-execution.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/config-selector.js +25 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/custom-editor.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/custom-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/earendil-announcement.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/extension-input.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/extension-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/footer.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +4 -3
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/model-selector.js +2 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/session-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +4 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/theme-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/tree-selector.js +3 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/user-message.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/visual-truncate.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/interactive-mode.js +47 -32
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/dark.json +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/light.json +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/theme.js +1 -1
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/package-manager-cli.js +42 -39
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard.js +9 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/paths.js +16 -0
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/version-check.js +9 -2
- package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/package.json +9 -8
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/image.js +14 -7
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/markdown.js +24 -84
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/terminal-image.js +10 -4
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/tui.js +73 -4
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/utils.js +33 -7
- package/node_modules/{@mariozechner → @earendil-works}/pi-tui/package.json +3 -3
- package/node_modules/@mariozechner/clipboard/README.md +58 -0
- package/node_modules/@mariozechner/clipboard/index.d.ts +23 -0
- package/node_modules/@mariozechner/clipboard-linux-x64-gnu/README.md +3 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/http2.d.ts +4 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/stream/web.d.ts +4 -0
- package/node_modules/brace-expansion/dist/commonjs/index.js +1 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/fast-xml-builder/CHANGELOG.md +4 -0
- package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +91 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -1
- package/node_modules/fast-xml-builder/package.json +3 -2
- package/node_modules/fast-xml-builder/src/fxb.d.ts +92 -3
- package/node_modules/fast-xml-builder/src/fxb.js +92 -31
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +87 -33
- package/node_modules/get-east-asian-width/lookup-data.js +15 -12
- package/node_modules/get-east-asian-width/lookup.js +25 -22
- package/node_modules/get-east-asian-width/package.json +1 -1
- package/node_modules/jiti/README.md +258 -0
- package/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/jiti/package.json +146 -0
- package/node_modules/protobufjs/dist/light/protobuf.js +5 -3
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/protobuf.js +5 -3
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +1 -1
- package/node_modules/protobufjs/src/namespace.js +3 -1
- package/node_modules/semver/README.md +19 -4
- package/node_modules/semver/bin/semver.js +14 -10
- package/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/semver/index.js +2 -0
- package/node_modules/semver/internal/re.js +1 -1
- package/node_modules/semver/package.json +3 -3
- package/node_modules/semver/range.bnf +5 -4
- package/node_modules/socks/package.json +2 -2
- package/node_modules/xml-naming/README.md +189 -0
- package/node_modules/xml-naming/package.json +54 -0
- package/node_modules/xml-naming/src/index.d.ts +74 -0
- package/node_modules/xml-naming/src/index.js +270 -0
- package/package.json +6 -6
- package/sling-default-packages.json +2 -1
- package/slingshot/index.js +442 -23
- package/node_modules/@mariozechner/jiti/dist/babel.cjs +0 -246
- package/node_modules/@mariozechner/jiti/dist/jiti.cjs +0 -1
- package/node_modules/@mariozechner/jiti/package.json +0 -96
- package/node_modules/@mariozechner/pi-agent-core/dist/index.js +0 -9
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/cli.js +0 -116
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/env-api-keys.js +0 -166
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/index.js +0 -15
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/models.generated.js +0 -16568
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/amazon-bedrock.js +0 -753
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/openai-codex-responses.js +0 -909
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses-shared.js +0 -479
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/utils/oauth/openai-codex.js +0 -374
- package/node_modules/@mariozechner/pi-ai/dist/api-registry.js +0 -44
- package/node_modules/@mariozechner/pi-ai/dist/bedrock-provider.js +0 -6
- package/node_modules/@mariozechner/pi-ai/dist/models.js +0 -71
- package/node_modules/@mariozechner/pi-ai/dist/oauth.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +0 -951
- package/node_modules/@mariozechner/pi-ai/dist/providers/azure-openai-responses.js +0 -208
- package/node_modules/@mariozechner/pi-ai/dist/providers/cloudflare.js +0 -26
- package/node_modules/@mariozechner/pi-ai/dist/providers/faux.js +0 -368
- package/node_modules/@mariozechner/pi-ai/dist/providers/github-copilot-headers.js +0 -29
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-shared.js +0 -329
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +0 -442
- package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +0 -400
- package/node_modules/@mariozechner/pi-ai/dist/providers/mistral.js +0 -535
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +0 -908
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses.js +0 -220
- package/node_modules/@mariozechner/pi-ai/dist/providers/register-builtins.js +0 -243
- package/node_modules/@mariozechner/pi-ai/dist/providers/simple-options.js +0 -39
- package/node_modules/@mariozechner/pi-ai/dist/providers/transform-messages.js +0 -184
- package/node_modules/@mariozechner/pi-ai/dist/stream.js +0 -27
- package/node_modules/@mariozechner/pi-ai/dist/types.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/event-stream.js +0 -81
- package/node_modules/@mariozechner/pi-ai/dist/utils/hash.js +0 -14
- package/node_modules/@mariozechner/pi-ai/dist/utils/headers.js +0 -8
- package/node_modules/@mariozechner/pi-ai/dist/utils/json-parse.js +0 -113
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +0 -335
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/github-copilot.js +0 -292
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/index.js +0 -121
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/oauth-page.js +0 -105
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/pkce.js +0 -31
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/types.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/overflow.js +0 -146
- package/node_modules/@mariozechner/pi-ai/dist/utils/sanitize-unicode.js +0 -26
- package/node_modules/@mariozechner/pi-ai/dist/utils/typebox-helpers.js +0 -21
- package/node_modules/@mariozechner/pi-ai/dist/utils/validation.js +0 -281
- package/node_modules/@mariozechner/pi-ai/package.json +0 -108
- package/node_modules/@mariozechner/pi-coding-agent/dist/bun/register-bedrock.js +0 -4
- package/node_modules/@mariozechner/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +0 -22
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/agent-loop.js +0 -458
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/agent.js +0 -398
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/index.js +0 -9
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/proxy.js +0 -278
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/types.js +0 -2
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/package.json +0 -45
- package/node_modules/socks/.claude/settings.local.json +0 -26
- package/node_modules/std-env/LICENCE +0 -22
- package/node_modules/std-env/README.md +0 -118
- package/node_modules/std-env/dist/index.cjs +0 -1
- package/node_modules/std-env/dist/index.d.cts +0 -92
- package/node_modules/std-env/dist/index.d.mts +0 -92
- package/node_modules/std-env/dist/index.d.ts +0 -92
- package/node_modules/std-env/dist/index.mjs +0 -1
- package/node_modules/std-env/package.json +0 -46
- package/node_modules/yoctocolors/base.d.ts +0 -47
- package/node_modules/yoctocolors/base.js +0 -94
- package/node_modules/yoctocolors/index.d.ts +0 -2
- package/node_modules/yoctocolors/index.js +0 -2
- package/node_modules/yoctocolors/license +0 -9
- package/node_modules/yoctocolors/package.json +0 -69
- package/node_modules/yoctocolors/readme.md +0 -138
- /package/node_modules/{@mariozechner/pi-coding-agent/dist/core → @earendil-works/pi-agent-core/dist/harness}/compaction/utils.js +0 -0
- /package/node_modules/{@mariozechner/pi-coding-agent/dist/core/tools → @earendil-works/pi-agent-core/dist/harness/utils}/truncate.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/types.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/api-registry.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/bedrock-provider.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/models.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/oauth.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/amazon-bedrock.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/anthropic.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/azure-openai-responses.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/cloudflare.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/faux.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/github-copilot-headers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google-shared.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google-vertex.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/mistral.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-responses.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/register-builtins.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/simple-options.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/transform-messages.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/session-resources.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/stream.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/utils/diagnostics.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/event-stream.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/hash.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/headers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/json-parse.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/anthropic.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/github-copilot.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/index.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/oauth-page.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/pkce.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/types.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/sanitize-unicode.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/typebox-helpers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/validation.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/bun/cli.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/bun/restore-sandbox-env.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/file-processor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/initial-message.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session-runtime.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session-services.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/auth-guidance.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/bash-executor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/defaults.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/diagnostics.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/event-bus.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/exec.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/ansi-to-html.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.html +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/tool-renderer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/vendor/highlight.min.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/vendor/marked.min.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/runner.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/wrapper.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/footer-data-provider.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/messages.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/output-guard.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/prompt-templates.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/resolve-config-value.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/resource-loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/session-cwd.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/session-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/settings-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/skills.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/slash-commands.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/source-info.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/system-prompt.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/telemetry.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/timings.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/edit-diff.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/file-mutation-queue.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/output-accumulator.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/path-utils.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/tool-definition-wrapper.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/assets/clankolas.png +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/armin.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/diff.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/print-mode.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/jsonl.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-client.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-mode.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/changelog.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/child-process.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard-image.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard-native.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/exif-orientation.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/frontmatter.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/fs-watch.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/git.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/image-convert.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/image-resize.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/mime.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/photon.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/pi-user-agent.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/shell.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/sleep.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/tools-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/autocomplete.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/box.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/cancellable-loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/editor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/input.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/select-list.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/settings-list.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/spacer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/text.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/truncated-text.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/editor-component.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/fuzzy.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/keybindings.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/keys.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/kill-ring.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/stdin-buffer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/terminal.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/undo-stack.js +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/LICENSE +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-cli.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-hooks.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-native.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-register.d.mts +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-register.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti/lib/jiti.mjs → jiti/lib/jiti-static.mjs} +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.cjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.d.cts +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.d.mts +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { access, mkdir, readdir, rm } from "node:fs/promises";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { JsonlSessionStorage, loadJsonlSessionMetadata } from "../storage/jsonl.js";
|
|
5
|
+
import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./shared.js";
|
|
6
|
+
async function exists(path) {
|
|
7
|
+
try {
|
|
8
|
+
await access(path, constants.F_OK);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function encodeCwd(cwd) {
|
|
16
|
+
return `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
17
|
+
}
|
|
18
|
+
export class JsonlSessionRepo {
|
|
19
|
+
sessionsRoot;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.sessionsRoot = resolve(options.sessionsRoot);
|
|
22
|
+
}
|
|
23
|
+
getSessionDir(cwd) {
|
|
24
|
+
return join(this.sessionsRoot, encodeCwd(cwd));
|
|
25
|
+
}
|
|
26
|
+
createSessionFilePath(cwd, sessionId, timestamp) {
|
|
27
|
+
return join(this.getSessionDir(cwd), `${timestamp.replace(/[:.]/g, "-")}_${sessionId}.jsonl`);
|
|
28
|
+
}
|
|
29
|
+
async create(options) {
|
|
30
|
+
await mkdir(this.sessionsRoot, { recursive: true });
|
|
31
|
+
const id = options.id ?? createSessionId();
|
|
32
|
+
const createdAt = createTimestamp();
|
|
33
|
+
const filePath = this.createSessionFilePath(options.cwd, id, createdAt);
|
|
34
|
+
const storage = await JsonlSessionStorage.create(filePath, {
|
|
35
|
+
cwd: options.cwd,
|
|
36
|
+
sessionId: id,
|
|
37
|
+
parentSessionPath: options.parentSessionPath,
|
|
38
|
+
});
|
|
39
|
+
return toSession(storage);
|
|
40
|
+
}
|
|
41
|
+
async open(metadata) {
|
|
42
|
+
if (!(await exists(metadata.path))) {
|
|
43
|
+
throw new Error(`Session not found: ${metadata.path}`);
|
|
44
|
+
}
|
|
45
|
+
const storage = await JsonlSessionStorage.open(metadata.path);
|
|
46
|
+
return toSession(storage);
|
|
47
|
+
}
|
|
48
|
+
async list(options = {}) {
|
|
49
|
+
const dirs = options.cwd ? [this.getSessionDir(options.cwd)] : await this.listSessionDirs();
|
|
50
|
+
const sessions = [];
|
|
51
|
+
for (const dir of dirs) {
|
|
52
|
+
if (!(await exists(dir)))
|
|
53
|
+
continue;
|
|
54
|
+
const files = (await readdir(dir)).filter((file) => file.endsWith(".jsonl")).map((file) => join(dir, file));
|
|
55
|
+
for (const filePath of files) {
|
|
56
|
+
try {
|
|
57
|
+
sessions.push(await loadJsonlSessionMetadata(filePath));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Ignore invalid session files when listing a directory.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
sessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
65
|
+
return sessions;
|
|
66
|
+
}
|
|
67
|
+
async delete(metadata) {
|
|
68
|
+
await rm(metadata.path, { force: true });
|
|
69
|
+
}
|
|
70
|
+
async fork(sourceMetadata, options) {
|
|
71
|
+
const source = await this.open(sourceMetadata);
|
|
72
|
+
const forkedEntries = await getEntriesToFork(source.getStorage(), options);
|
|
73
|
+
const id = options.id ?? createSessionId();
|
|
74
|
+
const createdAt = createTimestamp();
|
|
75
|
+
const storage = await JsonlSessionStorage.create(this.createSessionFilePath(options.cwd, id, createdAt), {
|
|
76
|
+
cwd: options.cwd,
|
|
77
|
+
sessionId: id,
|
|
78
|
+
parentSessionPath: options.parentSessionPath ?? sourceMetadata.path,
|
|
79
|
+
});
|
|
80
|
+
for (const entry of forkedEntries) {
|
|
81
|
+
await storage.appendEntry(entry);
|
|
82
|
+
}
|
|
83
|
+
return toSession(storage);
|
|
84
|
+
}
|
|
85
|
+
async listSessionDirs() {
|
|
86
|
+
if (!(await exists(this.sessionsRoot)))
|
|
87
|
+
return [];
|
|
88
|
+
const entries = await readdir(this.sessionsRoot, { withFileTypes: true });
|
|
89
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => join(this.sessionsRoot, entry.name));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=jsonl.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InMemorySessionStorage } from "../storage/memory.js";
|
|
2
|
+
import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./shared.js";
|
|
3
|
+
export class InMemorySessionRepo {
|
|
4
|
+
sessions = new Map();
|
|
5
|
+
async create(options = {}) {
|
|
6
|
+
const metadata = {
|
|
7
|
+
id: options.id ?? createSessionId(),
|
|
8
|
+
createdAt: createTimestamp(),
|
|
9
|
+
};
|
|
10
|
+
const storage = new InMemorySessionStorage({ metadata });
|
|
11
|
+
const session = toSession(storage);
|
|
12
|
+
this.sessions.set(metadata.id, session);
|
|
13
|
+
return session;
|
|
14
|
+
}
|
|
15
|
+
async open(metadata) {
|
|
16
|
+
const session = this.sessions.get(metadata.id);
|
|
17
|
+
if (!session) {
|
|
18
|
+
throw new Error(`Session not found: ${metadata.id}`);
|
|
19
|
+
}
|
|
20
|
+
return session;
|
|
21
|
+
}
|
|
22
|
+
async list() {
|
|
23
|
+
return Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));
|
|
24
|
+
}
|
|
25
|
+
async delete(metadata) {
|
|
26
|
+
this.sessions.delete(metadata.id);
|
|
27
|
+
}
|
|
28
|
+
async fork(sourceMetadata, options) {
|
|
29
|
+
const source = await this.open(sourceMetadata);
|
|
30
|
+
const forkedEntries = await getEntriesToFork(source.getStorage(), options);
|
|
31
|
+
const metadata = {
|
|
32
|
+
id: options.id ?? createSessionId(),
|
|
33
|
+
createdAt: createTimestamp(),
|
|
34
|
+
};
|
|
35
|
+
const leafId = forkedEntries[forkedEntries.length - 1]?.id ?? null;
|
|
36
|
+
const storage = new InMemorySessionStorage({ metadata, entries: forkedEntries, leafId });
|
|
37
|
+
const session = toSession(storage);
|
|
38
|
+
this.sessions.set(metadata.id, session);
|
|
39
|
+
return session;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { v7 as uuidv7 } from "uuid";
|
|
2
|
+
import { Session } from "../session.js";
|
|
3
|
+
export function createSessionId() {
|
|
4
|
+
return uuidv7();
|
|
5
|
+
}
|
|
6
|
+
export function createTimestamp() {
|
|
7
|
+
return new Date().toISOString();
|
|
8
|
+
}
|
|
9
|
+
export function toSession(storage) {
|
|
10
|
+
return new Session(storage);
|
|
11
|
+
}
|
|
12
|
+
export async function getEntriesToFork(storage, options) {
|
|
13
|
+
if (!options.entryId)
|
|
14
|
+
return storage.getEntries();
|
|
15
|
+
const target = await storage.getEntry(options.entryId);
|
|
16
|
+
if (!target) {
|
|
17
|
+
throw new Error(`Entry ${options.entryId} not found`);
|
|
18
|
+
}
|
|
19
|
+
let effectiveLeafId;
|
|
20
|
+
if ((options.position ?? "before") === "at") {
|
|
21
|
+
effectiveLeafId = target.id;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (target.type !== "message" || target.message.role !== "user") {
|
|
25
|
+
throw new Error(`Entry ${options.entryId} is not a user message`);
|
|
26
|
+
}
|
|
27
|
+
effectiveLeafId = target.parentId;
|
|
28
|
+
}
|
|
29
|
+
return storage.getPathToRoot(effectiveLeafId);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage } from "../messages.js";
|
|
2
|
+
export function buildSessionContext(pathEntries) {
|
|
3
|
+
let thinkingLevel = "off";
|
|
4
|
+
let model = null;
|
|
5
|
+
let compaction = null;
|
|
6
|
+
for (const entry of pathEntries) {
|
|
7
|
+
if (entry.type === "thinking_level_change") {
|
|
8
|
+
thinkingLevel = entry.thinkingLevel;
|
|
9
|
+
}
|
|
10
|
+
else if (entry.type === "model_change") {
|
|
11
|
+
model = { provider: entry.provider, modelId: entry.modelId };
|
|
12
|
+
}
|
|
13
|
+
else if (entry.type === "message" && entry.message.role === "assistant") {
|
|
14
|
+
model = { provider: entry.message.provider, modelId: entry.message.model };
|
|
15
|
+
}
|
|
16
|
+
else if (entry.type === "compaction") {
|
|
17
|
+
compaction = entry;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const messages = [];
|
|
21
|
+
const appendMessage = (entry) => {
|
|
22
|
+
if (entry.type === "message") {
|
|
23
|
+
messages.push(entry.message);
|
|
24
|
+
}
|
|
25
|
+
else if (entry.type === "custom_message") {
|
|
26
|
+
messages.push(createCustomMessage(entry.customType, entry.content, entry.display, entry.details, entry.timestamp));
|
|
27
|
+
}
|
|
28
|
+
else if (entry.type === "branch_summary" && entry.summary) {
|
|
29
|
+
messages.push(createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (compaction) {
|
|
33
|
+
messages.push(createCompactionSummaryMessage(compaction.summary, compaction.tokensBefore, compaction.timestamp));
|
|
34
|
+
const compactionIdx = pathEntries.findIndex((e) => e.type === "compaction" && e.id === compaction.id);
|
|
35
|
+
let foundFirstKept = false;
|
|
36
|
+
for (let i = 0; i < compactionIdx; i++) {
|
|
37
|
+
const entry = pathEntries[i];
|
|
38
|
+
if (entry.id === compaction.firstKeptEntryId)
|
|
39
|
+
foundFirstKept = true;
|
|
40
|
+
if (foundFirstKept)
|
|
41
|
+
appendMessage(entry);
|
|
42
|
+
}
|
|
43
|
+
for (let i = compactionIdx + 1; i < pathEntries.length; i++) {
|
|
44
|
+
appendMessage(pathEntries[i]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
for (const entry of pathEntries) {
|
|
49
|
+
appendMessage(entry);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { messages, thinkingLevel, model };
|
|
53
|
+
}
|
|
54
|
+
export class Session {
|
|
55
|
+
storage;
|
|
56
|
+
constructor(storage) {
|
|
57
|
+
this.storage = storage;
|
|
58
|
+
}
|
|
59
|
+
getMetadata() {
|
|
60
|
+
return this.storage.getMetadata();
|
|
61
|
+
}
|
|
62
|
+
getStorage() {
|
|
63
|
+
return this.storage;
|
|
64
|
+
}
|
|
65
|
+
getLeafId() {
|
|
66
|
+
return this.storage.getLeafId();
|
|
67
|
+
}
|
|
68
|
+
getEntry(id) {
|
|
69
|
+
return this.storage.getEntry(id);
|
|
70
|
+
}
|
|
71
|
+
getEntries() {
|
|
72
|
+
return this.storage.getEntries();
|
|
73
|
+
}
|
|
74
|
+
async getBranch(fromId) {
|
|
75
|
+
const leafId = fromId ?? (await this.storage.getLeafId());
|
|
76
|
+
return this.storage.getPathToRoot(leafId);
|
|
77
|
+
}
|
|
78
|
+
async buildContext() {
|
|
79
|
+
return buildSessionContext(await this.getBranch());
|
|
80
|
+
}
|
|
81
|
+
getLabel(id) {
|
|
82
|
+
return this.storage.getLabel(id);
|
|
83
|
+
}
|
|
84
|
+
async getSessionName() {
|
|
85
|
+
const entries = await this.storage.findEntries("session_info");
|
|
86
|
+
return entries[entries.length - 1]?.name?.trim() || undefined;
|
|
87
|
+
}
|
|
88
|
+
async appendTypedEntry(entry) {
|
|
89
|
+
await this.storage.appendEntry(entry);
|
|
90
|
+
return entry.id;
|
|
91
|
+
}
|
|
92
|
+
async appendMessage(message) {
|
|
93
|
+
return this.appendTypedEntry({
|
|
94
|
+
type: "message",
|
|
95
|
+
id: await this.storage.createEntryId(),
|
|
96
|
+
parentId: await this.storage.getLeafId(),
|
|
97
|
+
timestamp: new Date().toISOString(),
|
|
98
|
+
message,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async appendThinkingLevelChange(thinkingLevel) {
|
|
102
|
+
return this.appendTypedEntry({
|
|
103
|
+
type: "thinking_level_change",
|
|
104
|
+
id: await this.storage.createEntryId(),
|
|
105
|
+
parentId: await this.storage.getLeafId(),
|
|
106
|
+
timestamp: new Date().toISOString(),
|
|
107
|
+
thinkingLevel,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async appendModelChange(provider, modelId) {
|
|
111
|
+
return this.appendTypedEntry({
|
|
112
|
+
type: "model_change",
|
|
113
|
+
id: await this.storage.createEntryId(),
|
|
114
|
+
parentId: await this.storage.getLeafId(),
|
|
115
|
+
timestamp: new Date().toISOString(),
|
|
116
|
+
provider,
|
|
117
|
+
modelId,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromHook) {
|
|
121
|
+
return this.appendTypedEntry({
|
|
122
|
+
type: "compaction",
|
|
123
|
+
id: await this.storage.createEntryId(),
|
|
124
|
+
parentId: await this.storage.getLeafId(),
|
|
125
|
+
timestamp: new Date().toISOString(),
|
|
126
|
+
summary,
|
|
127
|
+
firstKeptEntryId,
|
|
128
|
+
tokensBefore,
|
|
129
|
+
details,
|
|
130
|
+
fromHook,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async appendCustomEntry(customType, data) {
|
|
134
|
+
return this.appendTypedEntry({
|
|
135
|
+
type: "custom",
|
|
136
|
+
id: await this.storage.createEntryId(),
|
|
137
|
+
parentId: await this.storage.getLeafId(),
|
|
138
|
+
timestamp: new Date().toISOString(),
|
|
139
|
+
customType,
|
|
140
|
+
data,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async appendCustomMessageEntry(customType, content, display, details) {
|
|
144
|
+
return this.appendTypedEntry({
|
|
145
|
+
type: "custom_message",
|
|
146
|
+
id: await this.storage.createEntryId(),
|
|
147
|
+
parentId: await this.storage.getLeafId(),
|
|
148
|
+
timestamp: new Date().toISOString(),
|
|
149
|
+
customType,
|
|
150
|
+
content,
|
|
151
|
+
display,
|
|
152
|
+
details,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async appendLabel(targetId, label) {
|
|
156
|
+
if (!(await this.storage.getEntry(targetId))) {
|
|
157
|
+
throw new Error(`Entry ${targetId} not found`);
|
|
158
|
+
}
|
|
159
|
+
return this.appendTypedEntry({
|
|
160
|
+
type: "label",
|
|
161
|
+
id: await this.storage.createEntryId(),
|
|
162
|
+
parentId: await this.storage.getLeafId(),
|
|
163
|
+
timestamp: new Date().toISOString(),
|
|
164
|
+
targetId,
|
|
165
|
+
label,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async appendSessionName(name) {
|
|
169
|
+
return this.appendTypedEntry({
|
|
170
|
+
type: "session_info",
|
|
171
|
+
id: await this.storage.createEntryId(),
|
|
172
|
+
parentId: await this.storage.getLeafId(),
|
|
173
|
+
timestamp: new Date().toISOString(),
|
|
174
|
+
name: name.trim(),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
async moveTo(entryId, summary) {
|
|
178
|
+
if (entryId !== null && !(await this.storage.getEntry(entryId))) {
|
|
179
|
+
throw new Error(`Entry ${entryId} not found`);
|
|
180
|
+
}
|
|
181
|
+
await this.storage.setLeafId(entryId);
|
|
182
|
+
if (!summary)
|
|
183
|
+
return undefined;
|
|
184
|
+
return this.appendTypedEntry({
|
|
185
|
+
type: "branch_summary",
|
|
186
|
+
id: await this.storage.createEntryId(),
|
|
187
|
+
parentId: entryId,
|
|
188
|
+
timestamp: new Date().toISOString(),
|
|
189
|
+
fromId: entryId ?? "root",
|
|
190
|
+
summary: summary.summary,
|
|
191
|
+
details: summary.details,
|
|
192
|
+
fromHook: summary.fromHook,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { createInterface } from "node:readline";
|
|
6
|
+
function updateLabelCache(labelsById, entry) {
|
|
7
|
+
if (entry.type !== "label")
|
|
8
|
+
return;
|
|
9
|
+
const label = entry.label?.trim();
|
|
10
|
+
if (label) {
|
|
11
|
+
labelsById.set(entry.targetId, label);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
labelsById.delete(entry.targetId);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function buildLabelsById(entries) {
|
|
18
|
+
const labelsById = new Map();
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
updateLabelCache(labelsById, entry);
|
|
21
|
+
}
|
|
22
|
+
return labelsById;
|
|
23
|
+
}
|
|
24
|
+
function generateEntryId(byId) {
|
|
25
|
+
for (let i = 0; i < 100; i++) {
|
|
26
|
+
const id = randomUUID().slice(0, 8);
|
|
27
|
+
if (!byId.has(id))
|
|
28
|
+
return id;
|
|
29
|
+
}
|
|
30
|
+
return randomUUID();
|
|
31
|
+
}
|
|
32
|
+
function headerToSessionMetadata(header, path) {
|
|
33
|
+
return {
|
|
34
|
+
id: header.id,
|
|
35
|
+
createdAt: header.timestamp,
|
|
36
|
+
cwd: header.cwd,
|
|
37
|
+
path,
|
|
38
|
+
parentSessionPath: header.parentSession,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function loadJsonlSessionMetadata(filePath) {
|
|
42
|
+
const stream = createReadStream(filePath, { encoding: "utf8" });
|
|
43
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
44
|
+
try {
|
|
45
|
+
for await (const line of lines) {
|
|
46
|
+
if (!line.trim())
|
|
47
|
+
break;
|
|
48
|
+
try {
|
|
49
|
+
const header = JSON.parse(line);
|
|
50
|
+
return headerToSessionMetadata(header, resolve(filePath));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new Error(`Invalid JSONL session file ${filePath}: first line is not a valid session header`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Invalid JSONL session file ${filePath}: missing session header`);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
lines.close();
|
|
60
|
+
stream.destroy();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function loadJsonlStorage(filePath) {
|
|
64
|
+
const content = await readFile(filePath, "utf8");
|
|
65
|
+
const lines = content.split("\n").filter((line) => line.trim());
|
|
66
|
+
if (lines.length === 0) {
|
|
67
|
+
throw new Error(`Invalid JSONL session file ${filePath}: missing session header`);
|
|
68
|
+
}
|
|
69
|
+
let header;
|
|
70
|
+
try {
|
|
71
|
+
header = JSON.parse(lines[0]);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
throw new Error(`Invalid JSONL session file ${filePath}: first line is not a valid session header`);
|
|
75
|
+
}
|
|
76
|
+
const entries = [];
|
|
77
|
+
let leafId = null;
|
|
78
|
+
for (const line of lines.slice(1)) {
|
|
79
|
+
try {
|
|
80
|
+
const entry = JSON.parse(line);
|
|
81
|
+
entries.push(entry);
|
|
82
|
+
leafId = entry.id;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// ignore malformed entry lines
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return { header, entries, leafId };
|
|
89
|
+
}
|
|
90
|
+
export class JsonlSessionStorage {
|
|
91
|
+
filePath;
|
|
92
|
+
metadata;
|
|
93
|
+
entries;
|
|
94
|
+
byId;
|
|
95
|
+
labelsById;
|
|
96
|
+
currentLeafId;
|
|
97
|
+
constructor(filePath, header, entries, leafId) {
|
|
98
|
+
this.filePath = resolve(filePath);
|
|
99
|
+
this.metadata = headerToSessionMetadata(header, this.filePath);
|
|
100
|
+
this.entries = entries;
|
|
101
|
+
this.byId = new Map(entries.map((entry) => [entry.id, entry]));
|
|
102
|
+
this.labelsById = buildLabelsById(entries);
|
|
103
|
+
this.currentLeafId = leafId;
|
|
104
|
+
}
|
|
105
|
+
static async open(filePath) {
|
|
106
|
+
const resolvedPath = resolve(filePath);
|
|
107
|
+
const loaded = await loadJsonlStorage(resolvedPath);
|
|
108
|
+
return new JsonlSessionStorage(resolvedPath, loaded.header, loaded.entries, loaded.leafId);
|
|
109
|
+
}
|
|
110
|
+
static async create(filePath, options) {
|
|
111
|
+
const resolvedPath = resolve(filePath);
|
|
112
|
+
const header = {
|
|
113
|
+
type: "session",
|
|
114
|
+
version: 3,
|
|
115
|
+
id: options.sessionId,
|
|
116
|
+
timestamp: new Date().toISOString(),
|
|
117
|
+
cwd: options.cwd,
|
|
118
|
+
parentSession: options.parentSessionPath,
|
|
119
|
+
};
|
|
120
|
+
await mkdir(dirname(resolvedPath), { recursive: true });
|
|
121
|
+
await writeFile(resolvedPath, `${JSON.stringify(header)}\n`);
|
|
122
|
+
return new JsonlSessionStorage(resolvedPath, header, [], null);
|
|
123
|
+
}
|
|
124
|
+
async getMetadata() {
|
|
125
|
+
return this.metadata;
|
|
126
|
+
}
|
|
127
|
+
async getLeafId() {
|
|
128
|
+
return this.currentLeafId;
|
|
129
|
+
}
|
|
130
|
+
async setLeafId(leafId) {
|
|
131
|
+
if (leafId !== null && !this.byId.has(leafId)) {
|
|
132
|
+
throw new Error(`Entry ${leafId} not found`);
|
|
133
|
+
}
|
|
134
|
+
this.currentLeafId = leafId;
|
|
135
|
+
}
|
|
136
|
+
async createEntryId() {
|
|
137
|
+
return generateEntryId(this.byId);
|
|
138
|
+
}
|
|
139
|
+
async appendEntry(entry) {
|
|
140
|
+
await appendFile(this.filePath, `${JSON.stringify(entry)}\n`);
|
|
141
|
+
this.entries.push(entry);
|
|
142
|
+
this.byId.set(entry.id, entry);
|
|
143
|
+
updateLabelCache(this.labelsById, entry);
|
|
144
|
+
this.currentLeafId = entry.id;
|
|
145
|
+
}
|
|
146
|
+
async getEntry(id) {
|
|
147
|
+
return this.byId.get(id);
|
|
148
|
+
}
|
|
149
|
+
async findEntries(type) {
|
|
150
|
+
return this.entries.filter((entry) => entry.type === type);
|
|
151
|
+
}
|
|
152
|
+
async getLabel(id) {
|
|
153
|
+
return this.labelsById.get(id);
|
|
154
|
+
}
|
|
155
|
+
async getPathToRoot(leafId) {
|
|
156
|
+
if (leafId === null)
|
|
157
|
+
return [];
|
|
158
|
+
const path = [];
|
|
159
|
+
let current = this.byId.get(leafId);
|
|
160
|
+
while (current) {
|
|
161
|
+
path.unshift(current);
|
|
162
|
+
current = current.parentId ? this.byId.get(current.parentId) : undefined;
|
|
163
|
+
}
|
|
164
|
+
return path;
|
|
165
|
+
}
|
|
166
|
+
async getEntries() {
|
|
167
|
+
return [...this.entries];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=jsonl.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { v7 as uuidv7 } from "uuid";
|
|
3
|
+
function updateLabelCache(labelsById, entry) {
|
|
4
|
+
if (entry.type !== "label")
|
|
5
|
+
return;
|
|
6
|
+
const label = entry.label?.trim();
|
|
7
|
+
if (label) {
|
|
8
|
+
labelsById.set(entry.targetId, label);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
labelsById.delete(entry.targetId);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function buildLabelsById(entries) {
|
|
15
|
+
const labelsById = new Map();
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
updateLabelCache(labelsById, entry);
|
|
18
|
+
}
|
|
19
|
+
return labelsById;
|
|
20
|
+
}
|
|
21
|
+
function generateEntryId(byId) {
|
|
22
|
+
for (let i = 0; i < 100; i++) {
|
|
23
|
+
const id = randomUUID().slice(0, 8);
|
|
24
|
+
if (!byId.has(id))
|
|
25
|
+
return id;
|
|
26
|
+
}
|
|
27
|
+
return randomUUID();
|
|
28
|
+
}
|
|
29
|
+
export class InMemorySessionStorage {
|
|
30
|
+
metadata;
|
|
31
|
+
entries;
|
|
32
|
+
byId;
|
|
33
|
+
labelsById;
|
|
34
|
+
leafId;
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.entries = options?.entries ? [...options.entries] : [];
|
|
37
|
+
this.byId = new Map(this.entries.map((entry) => [entry.id, entry]));
|
|
38
|
+
this.labelsById = buildLabelsById(this.entries);
|
|
39
|
+
this.leafId = options?.leafId ?? this.entries[this.entries.length - 1]?.id ?? null;
|
|
40
|
+
if (this.leafId !== null && !this.byId.has(this.leafId)) {
|
|
41
|
+
throw new Error(`Entry ${this.leafId} not found`);
|
|
42
|
+
}
|
|
43
|
+
this.metadata = options?.metadata ?? { id: uuidv7(), createdAt: new Date().toISOString() };
|
|
44
|
+
}
|
|
45
|
+
async getMetadata() {
|
|
46
|
+
return this.metadata;
|
|
47
|
+
}
|
|
48
|
+
async getLeafId() {
|
|
49
|
+
return this.leafId;
|
|
50
|
+
}
|
|
51
|
+
async setLeafId(leafId) {
|
|
52
|
+
if (leafId !== null && !this.byId.has(leafId)) {
|
|
53
|
+
throw new Error(`Entry ${leafId} not found`);
|
|
54
|
+
}
|
|
55
|
+
this.leafId = leafId;
|
|
56
|
+
}
|
|
57
|
+
async createEntryId() {
|
|
58
|
+
return generateEntryId(this.byId);
|
|
59
|
+
}
|
|
60
|
+
async appendEntry(entry) {
|
|
61
|
+
this.entries.push(entry);
|
|
62
|
+
this.byId.set(entry.id, entry);
|
|
63
|
+
updateLabelCache(this.labelsById, entry);
|
|
64
|
+
this.leafId = entry.id;
|
|
65
|
+
}
|
|
66
|
+
async getEntry(id) {
|
|
67
|
+
return this.byId.get(id);
|
|
68
|
+
}
|
|
69
|
+
async findEntries(type) {
|
|
70
|
+
return this.entries.filter((entry) => entry.type === type);
|
|
71
|
+
}
|
|
72
|
+
async getLabel(id) {
|
|
73
|
+
return this.labelsById.get(id);
|
|
74
|
+
}
|
|
75
|
+
async getPathToRoot(leafId) {
|
|
76
|
+
if (leafId === null)
|
|
77
|
+
return [];
|
|
78
|
+
const path = [];
|
|
79
|
+
let current = this.byId.get(leafId);
|
|
80
|
+
while (current) {
|
|
81
|
+
path.unshift(current);
|
|
82
|
+
current = current.parentId ? this.byId.get(current.parentId) : undefined;
|
|
83
|
+
}
|
|
84
|
+
return path;
|
|
85
|
+
}
|
|
86
|
+
async getEntries() {
|
|
87
|
+
return [...this.entries];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=memory.js.map
|