@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
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import { streamSimple, } from "@mariozechner/pi-ai";
|
|
2
|
-
import { runAgentLoop, runAgentLoopContinue } from "./agent-loop.js";
|
|
3
|
-
function defaultConvertToLlm(messages) {
|
|
4
|
-
return messages.filter((message) => message.role === "user" || message.role === "assistant" || message.role === "toolResult");
|
|
5
|
-
}
|
|
6
|
-
const EMPTY_USAGE = {
|
|
7
|
-
input: 0,
|
|
8
|
-
output: 0,
|
|
9
|
-
cacheRead: 0,
|
|
10
|
-
cacheWrite: 0,
|
|
11
|
-
totalTokens: 0,
|
|
12
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
13
|
-
};
|
|
14
|
-
const DEFAULT_MODEL = {
|
|
15
|
-
id: "unknown",
|
|
16
|
-
name: "unknown",
|
|
17
|
-
api: "unknown",
|
|
18
|
-
provider: "unknown",
|
|
19
|
-
baseUrl: "",
|
|
20
|
-
reasoning: false,
|
|
21
|
-
input: [],
|
|
22
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
23
|
-
contextWindow: 0,
|
|
24
|
-
maxTokens: 0,
|
|
25
|
-
};
|
|
26
|
-
function createMutableAgentState(initialState) {
|
|
27
|
-
let tools = initialState?.tools?.slice() ?? [];
|
|
28
|
-
let messages = initialState?.messages?.slice() ?? [];
|
|
29
|
-
return {
|
|
30
|
-
systemPrompt: initialState?.systemPrompt ?? "",
|
|
31
|
-
model: initialState?.model ?? DEFAULT_MODEL,
|
|
32
|
-
thinkingLevel: initialState?.thinkingLevel ?? "off",
|
|
33
|
-
get tools() {
|
|
34
|
-
return tools;
|
|
35
|
-
},
|
|
36
|
-
set tools(nextTools) {
|
|
37
|
-
tools = nextTools.slice();
|
|
38
|
-
},
|
|
39
|
-
get messages() {
|
|
40
|
-
return messages;
|
|
41
|
-
},
|
|
42
|
-
set messages(nextMessages) {
|
|
43
|
-
messages = nextMessages.slice();
|
|
44
|
-
},
|
|
45
|
-
isStreaming: false,
|
|
46
|
-
streamingMessage: undefined,
|
|
47
|
-
pendingToolCalls: new Set(),
|
|
48
|
-
errorMessage: undefined,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
class PendingMessageQueue {
|
|
52
|
-
mode;
|
|
53
|
-
messages = [];
|
|
54
|
-
constructor(mode) {
|
|
55
|
-
this.mode = mode;
|
|
56
|
-
}
|
|
57
|
-
enqueue(message) {
|
|
58
|
-
this.messages.push(message);
|
|
59
|
-
}
|
|
60
|
-
hasItems() {
|
|
61
|
-
return this.messages.length > 0;
|
|
62
|
-
}
|
|
63
|
-
drain() {
|
|
64
|
-
if (this.mode === "all") {
|
|
65
|
-
const drained = this.messages.slice();
|
|
66
|
-
this.messages = [];
|
|
67
|
-
return drained;
|
|
68
|
-
}
|
|
69
|
-
const first = this.messages[0];
|
|
70
|
-
if (!first) {
|
|
71
|
-
return [];
|
|
72
|
-
}
|
|
73
|
-
this.messages = this.messages.slice(1);
|
|
74
|
-
return [first];
|
|
75
|
-
}
|
|
76
|
-
clear() {
|
|
77
|
-
this.messages = [];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Stateful wrapper around the low-level agent loop.
|
|
82
|
-
*
|
|
83
|
-
* `Agent` owns the current transcript, emits lifecycle events, executes tools,
|
|
84
|
-
* and exposes queueing APIs for steering and follow-up messages.
|
|
85
|
-
*/
|
|
86
|
-
export class Agent {
|
|
87
|
-
_state;
|
|
88
|
-
listeners = new Set();
|
|
89
|
-
steeringQueue;
|
|
90
|
-
followUpQueue;
|
|
91
|
-
convertToLlm;
|
|
92
|
-
transformContext;
|
|
93
|
-
streamFn;
|
|
94
|
-
getApiKey;
|
|
95
|
-
onPayload;
|
|
96
|
-
onResponse;
|
|
97
|
-
beforeToolCall;
|
|
98
|
-
afterToolCall;
|
|
99
|
-
activeRun;
|
|
100
|
-
/** Session identifier forwarded to providers for cache-aware backends. */
|
|
101
|
-
sessionId;
|
|
102
|
-
/** Optional per-level thinking token budgets forwarded to the stream function. */
|
|
103
|
-
thinkingBudgets;
|
|
104
|
-
/** Preferred transport forwarded to the stream function. */
|
|
105
|
-
transport;
|
|
106
|
-
/** Optional cap for provider-requested retry delays. */
|
|
107
|
-
maxRetryDelayMs;
|
|
108
|
-
/** Tool execution strategy for assistant messages that contain multiple tool calls. */
|
|
109
|
-
toolExecution;
|
|
110
|
-
constructor(options = {}) {
|
|
111
|
-
this._state = createMutableAgentState(options.initialState);
|
|
112
|
-
this.convertToLlm = options.convertToLlm ?? defaultConvertToLlm;
|
|
113
|
-
this.transformContext = options.transformContext;
|
|
114
|
-
this.streamFn = options.streamFn ?? streamSimple;
|
|
115
|
-
this.getApiKey = options.getApiKey;
|
|
116
|
-
this.onPayload = options.onPayload;
|
|
117
|
-
this.onResponse = options.onResponse;
|
|
118
|
-
this.beforeToolCall = options.beforeToolCall;
|
|
119
|
-
this.afterToolCall = options.afterToolCall;
|
|
120
|
-
this.steeringQueue = new PendingMessageQueue(options.steeringMode ?? "one-at-a-time");
|
|
121
|
-
this.followUpQueue = new PendingMessageQueue(options.followUpMode ?? "one-at-a-time");
|
|
122
|
-
this.sessionId = options.sessionId;
|
|
123
|
-
this.thinkingBudgets = options.thinkingBudgets;
|
|
124
|
-
this.transport = options.transport ?? "auto";
|
|
125
|
-
this.maxRetryDelayMs = options.maxRetryDelayMs;
|
|
126
|
-
this.toolExecution = options.toolExecution ?? "parallel";
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Subscribe to agent lifecycle events.
|
|
130
|
-
*
|
|
131
|
-
* Listener promises are awaited in subscription order and are included in
|
|
132
|
-
* the current run's settlement. Listeners also receive the active abort
|
|
133
|
-
* signal for the current run.
|
|
134
|
-
*
|
|
135
|
-
* `agent_end` is the final emitted event for a run, but the agent does not
|
|
136
|
-
* become idle until all awaited listeners for that event have settled.
|
|
137
|
-
*/
|
|
138
|
-
subscribe(listener) {
|
|
139
|
-
this.listeners.add(listener);
|
|
140
|
-
return () => this.listeners.delete(listener);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Current agent state.
|
|
144
|
-
*
|
|
145
|
-
* Assigning `state.tools` or `state.messages` copies the provided top-level array.
|
|
146
|
-
*/
|
|
147
|
-
get state() {
|
|
148
|
-
return this._state;
|
|
149
|
-
}
|
|
150
|
-
/** Controls how queued steering messages are drained. */
|
|
151
|
-
set steeringMode(mode) {
|
|
152
|
-
this.steeringQueue.mode = mode;
|
|
153
|
-
}
|
|
154
|
-
get steeringMode() {
|
|
155
|
-
return this.steeringQueue.mode;
|
|
156
|
-
}
|
|
157
|
-
/** Controls how queued follow-up messages are drained. */
|
|
158
|
-
set followUpMode(mode) {
|
|
159
|
-
this.followUpQueue.mode = mode;
|
|
160
|
-
}
|
|
161
|
-
get followUpMode() {
|
|
162
|
-
return this.followUpQueue.mode;
|
|
163
|
-
}
|
|
164
|
-
/** Queue a message to be injected after the current assistant turn finishes. */
|
|
165
|
-
steer(message) {
|
|
166
|
-
this.steeringQueue.enqueue(message);
|
|
167
|
-
}
|
|
168
|
-
/** Queue a message to run only after the agent would otherwise stop. */
|
|
169
|
-
followUp(message) {
|
|
170
|
-
this.followUpQueue.enqueue(message);
|
|
171
|
-
}
|
|
172
|
-
/** Remove all queued steering messages. */
|
|
173
|
-
clearSteeringQueue() {
|
|
174
|
-
this.steeringQueue.clear();
|
|
175
|
-
}
|
|
176
|
-
/** Remove all queued follow-up messages. */
|
|
177
|
-
clearFollowUpQueue() {
|
|
178
|
-
this.followUpQueue.clear();
|
|
179
|
-
}
|
|
180
|
-
/** Remove all queued steering and follow-up messages. */
|
|
181
|
-
clearAllQueues() {
|
|
182
|
-
this.clearSteeringQueue();
|
|
183
|
-
this.clearFollowUpQueue();
|
|
184
|
-
}
|
|
185
|
-
/** Returns true when either queue still contains pending messages. */
|
|
186
|
-
hasQueuedMessages() {
|
|
187
|
-
return this.steeringQueue.hasItems() || this.followUpQueue.hasItems();
|
|
188
|
-
}
|
|
189
|
-
/** Active abort signal for the current run, if any. */
|
|
190
|
-
get signal() {
|
|
191
|
-
return this.activeRun?.abortController.signal;
|
|
192
|
-
}
|
|
193
|
-
/** Abort the current run, if one is active. */
|
|
194
|
-
abort() {
|
|
195
|
-
this.activeRun?.abortController.abort();
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Resolve when the current run and all awaited event listeners have finished.
|
|
199
|
-
*
|
|
200
|
-
* This resolves after `agent_end` listeners settle.
|
|
201
|
-
*/
|
|
202
|
-
waitForIdle() {
|
|
203
|
-
return this.activeRun?.promise ?? Promise.resolve();
|
|
204
|
-
}
|
|
205
|
-
/** Clear transcript state, runtime state, and queued messages. */
|
|
206
|
-
reset() {
|
|
207
|
-
this._state.messages = [];
|
|
208
|
-
this._state.isStreaming = false;
|
|
209
|
-
this._state.streamingMessage = undefined;
|
|
210
|
-
this._state.pendingToolCalls = new Set();
|
|
211
|
-
this._state.errorMessage = undefined;
|
|
212
|
-
this.clearFollowUpQueue();
|
|
213
|
-
this.clearSteeringQueue();
|
|
214
|
-
}
|
|
215
|
-
async prompt(input, images) {
|
|
216
|
-
if (this.activeRun) {
|
|
217
|
-
throw new Error("Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.");
|
|
218
|
-
}
|
|
219
|
-
const messages = this.normalizePromptInput(input, images);
|
|
220
|
-
await this.runPromptMessages(messages);
|
|
221
|
-
}
|
|
222
|
-
/** Continue from the current transcript. The last message must be a user or tool-result message. */
|
|
223
|
-
async continue() {
|
|
224
|
-
if (this.activeRun) {
|
|
225
|
-
throw new Error("Agent is already processing. Wait for completion before continuing.");
|
|
226
|
-
}
|
|
227
|
-
const lastMessage = this._state.messages[this._state.messages.length - 1];
|
|
228
|
-
if (!lastMessage) {
|
|
229
|
-
throw new Error("No messages to continue from");
|
|
230
|
-
}
|
|
231
|
-
if (lastMessage.role === "assistant") {
|
|
232
|
-
const queuedSteering = this.steeringQueue.drain();
|
|
233
|
-
if (queuedSteering.length > 0) {
|
|
234
|
-
await this.runPromptMessages(queuedSteering, { skipInitialSteeringPoll: true });
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
const queuedFollowUps = this.followUpQueue.drain();
|
|
238
|
-
if (queuedFollowUps.length > 0) {
|
|
239
|
-
await this.runPromptMessages(queuedFollowUps);
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
throw new Error("Cannot continue from message role: assistant");
|
|
243
|
-
}
|
|
244
|
-
await this.runContinuation();
|
|
245
|
-
}
|
|
246
|
-
normalizePromptInput(input, images) {
|
|
247
|
-
if (Array.isArray(input)) {
|
|
248
|
-
return input;
|
|
249
|
-
}
|
|
250
|
-
if (typeof input !== "string") {
|
|
251
|
-
return [input];
|
|
252
|
-
}
|
|
253
|
-
const content = [{ type: "text", text: input }];
|
|
254
|
-
if (images && images.length > 0) {
|
|
255
|
-
content.push(...images);
|
|
256
|
-
}
|
|
257
|
-
return [{ role: "user", content, timestamp: Date.now() }];
|
|
258
|
-
}
|
|
259
|
-
async runPromptMessages(messages, options = {}) {
|
|
260
|
-
await this.runWithLifecycle(async (signal) => {
|
|
261
|
-
await runAgentLoop(messages, this.createContextSnapshot(), this.createLoopConfig(options), (event) => this.processEvents(event), signal, this.streamFn);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
async runContinuation() {
|
|
265
|
-
await this.runWithLifecycle(async (signal) => {
|
|
266
|
-
await runAgentLoopContinue(this.createContextSnapshot(), this.createLoopConfig(), (event) => this.processEvents(event), signal, this.streamFn);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
createContextSnapshot() {
|
|
270
|
-
return {
|
|
271
|
-
systemPrompt: this._state.systemPrompt,
|
|
272
|
-
messages: this._state.messages.slice(),
|
|
273
|
-
tools: this._state.tools.slice(),
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
createLoopConfig(options = {}) {
|
|
277
|
-
let skipInitialSteeringPoll = options.skipInitialSteeringPoll === true;
|
|
278
|
-
return {
|
|
279
|
-
model: this._state.model,
|
|
280
|
-
reasoning: this._state.thinkingLevel === "off" ? undefined : this._state.thinkingLevel,
|
|
281
|
-
sessionId: this.sessionId,
|
|
282
|
-
onPayload: this.onPayload,
|
|
283
|
-
onResponse: this.onResponse,
|
|
284
|
-
transport: this.transport,
|
|
285
|
-
thinkingBudgets: this.thinkingBudgets,
|
|
286
|
-
maxRetryDelayMs: this.maxRetryDelayMs,
|
|
287
|
-
toolExecution: this.toolExecution,
|
|
288
|
-
beforeToolCall: this.beforeToolCall,
|
|
289
|
-
afterToolCall: this.afterToolCall,
|
|
290
|
-
convertToLlm: this.convertToLlm,
|
|
291
|
-
transformContext: this.transformContext,
|
|
292
|
-
getApiKey: this.getApiKey,
|
|
293
|
-
getSteeringMessages: async () => {
|
|
294
|
-
if (skipInitialSteeringPoll) {
|
|
295
|
-
skipInitialSteeringPoll = false;
|
|
296
|
-
return [];
|
|
297
|
-
}
|
|
298
|
-
return this.steeringQueue.drain();
|
|
299
|
-
},
|
|
300
|
-
getFollowUpMessages: async () => this.followUpQueue.drain(),
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
async runWithLifecycle(executor) {
|
|
304
|
-
if (this.activeRun) {
|
|
305
|
-
throw new Error("Agent is already processing.");
|
|
306
|
-
}
|
|
307
|
-
const abortController = new AbortController();
|
|
308
|
-
let resolvePromise = () => { };
|
|
309
|
-
const promise = new Promise((resolve) => {
|
|
310
|
-
resolvePromise = resolve;
|
|
311
|
-
});
|
|
312
|
-
this.activeRun = { promise, resolve: resolvePromise, abortController };
|
|
313
|
-
this._state.isStreaming = true;
|
|
314
|
-
this._state.streamingMessage = undefined;
|
|
315
|
-
this._state.errorMessage = undefined;
|
|
316
|
-
try {
|
|
317
|
-
await executor(abortController.signal);
|
|
318
|
-
}
|
|
319
|
-
catch (error) {
|
|
320
|
-
await this.handleRunFailure(error, abortController.signal.aborted);
|
|
321
|
-
}
|
|
322
|
-
finally {
|
|
323
|
-
this.finishRun();
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
async handleRunFailure(error, aborted) {
|
|
327
|
-
const failureMessage = {
|
|
328
|
-
role: "assistant",
|
|
329
|
-
content: [{ type: "text", text: "" }],
|
|
330
|
-
api: this._state.model.api,
|
|
331
|
-
provider: this._state.model.provider,
|
|
332
|
-
model: this._state.model.id,
|
|
333
|
-
usage: EMPTY_USAGE,
|
|
334
|
-
stopReason: aborted ? "aborted" : "error",
|
|
335
|
-
errorMessage: error instanceof Error ? error.message : String(error),
|
|
336
|
-
timestamp: Date.now(),
|
|
337
|
-
};
|
|
338
|
-
this._state.messages.push(failureMessage);
|
|
339
|
-
this._state.errorMessage = failureMessage.errorMessage;
|
|
340
|
-
await this.processEvents({ type: "agent_end", messages: [failureMessage] });
|
|
341
|
-
}
|
|
342
|
-
finishRun() {
|
|
343
|
-
this._state.isStreaming = false;
|
|
344
|
-
this._state.streamingMessage = undefined;
|
|
345
|
-
this._state.pendingToolCalls = new Set();
|
|
346
|
-
this.activeRun?.resolve();
|
|
347
|
-
this.activeRun = undefined;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Reduce internal state for a loop event, then await listeners.
|
|
351
|
-
*
|
|
352
|
-
* `agent_end` only means no further loop events will be emitted. The run is
|
|
353
|
-
* considered idle later, after all awaited listeners for `agent_end` finish
|
|
354
|
-
* and `finishRun()` clears runtime-owned state.
|
|
355
|
-
*/
|
|
356
|
-
async processEvents(event) {
|
|
357
|
-
switch (event.type) {
|
|
358
|
-
case "message_start":
|
|
359
|
-
this._state.streamingMessage = event.message;
|
|
360
|
-
break;
|
|
361
|
-
case "message_update":
|
|
362
|
-
this._state.streamingMessage = event.message;
|
|
363
|
-
break;
|
|
364
|
-
case "message_end":
|
|
365
|
-
this._state.streamingMessage = undefined;
|
|
366
|
-
this._state.messages.push(event.message);
|
|
367
|
-
break;
|
|
368
|
-
case "tool_execution_start": {
|
|
369
|
-
const pendingToolCalls = new Set(this._state.pendingToolCalls);
|
|
370
|
-
pendingToolCalls.add(event.toolCallId);
|
|
371
|
-
this._state.pendingToolCalls = pendingToolCalls;
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
case "tool_execution_end": {
|
|
375
|
-
const pendingToolCalls = new Set(this._state.pendingToolCalls);
|
|
376
|
-
pendingToolCalls.delete(event.toolCallId);
|
|
377
|
-
this._state.pendingToolCalls = pendingToolCalls;
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
case "turn_end":
|
|
381
|
-
if (event.message.role === "assistant" && event.message.errorMessage) {
|
|
382
|
-
this._state.errorMessage = event.message.errorMessage;
|
|
383
|
-
}
|
|
384
|
-
break;
|
|
385
|
-
case "agent_end":
|
|
386
|
-
this._state.streamingMessage = undefined;
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
const signal = this.activeRun?.abortController.signal;
|
|
390
|
-
if (!signal) {
|
|
391
|
-
throw new Error("Agent listener invoked outside active run");
|
|
392
|
-
}
|
|
393
|
-
for (const listener of this.listeners) {
|
|
394
|
-
await listener(event, signal);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
//# sourceMappingURL=agent.js.map
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Proxy stream function for apps that route LLM calls through a server.
|
|
3
|
-
* The server manages auth and proxies requests to LLM providers.
|
|
4
|
-
*/
|
|
5
|
-
// Internal import for JSON parsing utility
|
|
6
|
-
import { EventStream, parseStreamingJson, } from "@mariozechner/pi-ai";
|
|
7
|
-
// Create stream class matching ProxyMessageEventStream
|
|
8
|
-
class ProxyMessageEventStream extends EventStream {
|
|
9
|
-
constructor() {
|
|
10
|
-
super((event) => event.type === "done" || event.type === "error", (event) => {
|
|
11
|
-
if (event.type === "done")
|
|
12
|
-
return event.message;
|
|
13
|
-
if (event.type === "error")
|
|
14
|
-
return event.error;
|
|
15
|
-
throw new Error("Unexpected event type");
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Stream function that proxies through a server instead of calling LLM providers directly.
|
|
21
|
-
* The server strips the partial field from delta events to reduce bandwidth.
|
|
22
|
-
* We reconstruct the partial message client-side.
|
|
23
|
-
*
|
|
24
|
-
* Use this as the `streamFn` option when creating an Agent that needs to go through a proxy.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const agent = new Agent({
|
|
29
|
-
* streamFn: (model, context, options) =>
|
|
30
|
-
* streamProxy(model, context, {
|
|
31
|
-
* ...options,
|
|
32
|
-
* authToken: await getAuthToken(),
|
|
33
|
-
* proxyUrl: "https://genai.example.com",
|
|
34
|
-
* }),
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
function buildProxyRequestOptions(options) {
|
|
39
|
-
return {
|
|
40
|
-
temperature: options.temperature,
|
|
41
|
-
maxTokens: options.maxTokens,
|
|
42
|
-
reasoning: options.reasoning,
|
|
43
|
-
cacheRetention: options.cacheRetention,
|
|
44
|
-
sessionId: options.sessionId,
|
|
45
|
-
headers: options.headers,
|
|
46
|
-
metadata: options.metadata,
|
|
47
|
-
transport: options.transport,
|
|
48
|
-
thinkingBudgets: options.thinkingBudgets,
|
|
49
|
-
maxRetryDelayMs: options.maxRetryDelayMs,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export function streamProxy(model, context, options) {
|
|
53
|
-
const stream = new ProxyMessageEventStream();
|
|
54
|
-
(async () => {
|
|
55
|
-
// Initialize the partial message that we'll build up from events
|
|
56
|
-
const partial = {
|
|
57
|
-
role: "assistant",
|
|
58
|
-
stopReason: "stop",
|
|
59
|
-
content: [],
|
|
60
|
-
api: model.api,
|
|
61
|
-
provider: model.provider,
|
|
62
|
-
model: model.id,
|
|
63
|
-
usage: {
|
|
64
|
-
input: 0,
|
|
65
|
-
output: 0,
|
|
66
|
-
cacheRead: 0,
|
|
67
|
-
cacheWrite: 0,
|
|
68
|
-
totalTokens: 0,
|
|
69
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
70
|
-
},
|
|
71
|
-
timestamp: Date.now(),
|
|
72
|
-
};
|
|
73
|
-
let reader;
|
|
74
|
-
const abortHandler = () => {
|
|
75
|
-
if (reader) {
|
|
76
|
-
reader.cancel("Request aborted by user").catch(() => { });
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
if (options.signal) {
|
|
80
|
-
options.signal.addEventListener("abort", abortHandler);
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
const response = await fetch(`${options.proxyUrl}/api/stream`, {
|
|
84
|
-
method: "POST",
|
|
85
|
-
headers: {
|
|
86
|
-
Authorization: `Bearer ${options.authToken}`,
|
|
87
|
-
"Content-Type": "application/json",
|
|
88
|
-
},
|
|
89
|
-
body: JSON.stringify({
|
|
90
|
-
model,
|
|
91
|
-
context,
|
|
92
|
-
options: buildProxyRequestOptions(options),
|
|
93
|
-
}),
|
|
94
|
-
signal: options.signal,
|
|
95
|
-
});
|
|
96
|
-
if (!response.ok) {
|
|
97
|
-
let errorMessage = `Proxy error: ${response.status} ${response.statusText}`;
|
|
98
|
-
try {
|
|
99
|
-
const errorData = (await response.json());
|
|
100
|
-
if (errorData.error) {
|
|
101
|
-
errorMessage = `Proxy error: ${errorData.error}`;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
// Couldn't parse error response
|
|
106
|
-
}
|
|
107
|
-
throw new Error(errorMessage);
|
|
108
|
-
}
|
|
109
|
-
reader = response.body.getReader();
|
|
110
|
-
const decoder = new TextDecoder();
|
|
111
|
-
let buffer = "";
|
|
112
|
-
while (true) {
|
|
113
|
-
const { done, value } = await reader.read();
|
|
114
|
-
if (done)
|
|
115
|
-
break;
|
|
116
|
-
if (options.signal?.aborted) {
|
|
117
|
-
throw new Error("Request aborted by user");
|
|
118
|
-
}
|
|
119
|
-
buffer += decoder.decode(value, { stream: true });
|
|
120
|
-
const lines = buffer.split("\n");
|
|
121
|
-
buffer = lines.pop() || "";
|
|
122
|
-
for (const line of lines) {
|
|
123
|
-
if (line.startsWith("data: ")) {
|
|
124
|
-
const data = line.slice(6).trim();
|
|
125
|
-
if (data) {
|
|
126
|
-
const proxyEvent = JSON.parse(data);
|
|
127
|
-
const event = processProxyEvent(proxyEvent, partial);
|
|
128
|
-
if (event) {
|
|
129
|
-
stream.push(event);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (options.signal?.aborted) {
|
|
136
|
-
throw new Error("Request aborted by user");
|
|
137
|
-
}
|
|
138
|
-
stream.end();
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
142
|
-
const reason = options.signal?.aborted ? "aborted" : "error";
|
|
143
|
-
partial.stopReason = reason;
|
|
144
|
-
partial.errorMessage = errorMessage;
|
|
145
|
-
stream.push({
|
|
146
|
-
type: "error",
|
|
147
|
-
reason,
|
|
148
|
-
error: partial,
|
|
149
|
-
});
|
|
150
|
-
stream.end();
|
|
151
|
-
}
|
|
152
|
-
finally {
|
|
153
|
-
if (options.signal) {
|
|
154
|
-
options.signal.removeEventListener("abort", abortHandler);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
})();
|
|
158
|
-
return stream;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Process a proxy event and update the partial message.
|
|
162
|
-
*/
|
|
163
|
-
function processProxyEvent(proxyEvent, partial) {
|
|
164
|
-
switch (proxyEvent.type) {
|
|
165
|
-
case "start":
|
|
166
|
-
return { type: "start", partial };
|
|
167
|
-
case "text_start":
|
|
168
|
-
partial.content[proxyEvent.contentIndex] = { type: "text", text: "" };
|
|
169
|
-
return { type: "text_start", contentIndex: proxyEvent.contentIndex, partial };
|
|
170
|
-
case "text_delta": {
|
|
171
|
-
const content = partial.content[proxyEvent.contentIndex];
|
|
172
|
-
if (content?.type === "text") {
|
|
173
|
-
content.text += proxyEvent.delta;
|
|
174
|
-
return {
|
|
175
|
-
type: "text_delta",
|
|
176
|
-
contentIndex: proxyEvent.contentIndex,
|
|
177
|
-
delta: proxyEvent.delta,
|
|
178
|
-
partial,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
throw new Error("Received text_delta for non-text content");
|
|
182
|
-
}
|
|
183
|
-
case "text_end": {
|
|
184
|
-
const content = partial.content[proxyEvent.contentIndex];
|
|
185
|
-
if (content?.type === "text") {
|
|
186
|
-
content.textSignature = proxyEvent.contentSignature;
|
|
187
|
-
return {
|
|
188
|
-
type: "text_end",
|
|
189
|
-
contentIndex: proxyEvent.contentIndex,
|
|
190
|
-
content: content.text,
|
|
191
|
-
partial,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
throw new Error("Received text_end for non-text content");
|
|
195
|
-
}
|
|
196
|
-
case "thinking_start":
|
|
197
|
-
partial.content[proxyEvent.contentIndex] = { type: "thinking", thinking: "" };
|
|
198
|
-
return { type: "thinking_start", contentIndex: proxyEvent.contentIndex, partial };
|
|
199
|
-
case "thinking_delta": {
|
|
200
|
-
const content = partial.content[proxyEvent.contentIndex];
|
|
201
|
-
if (content?.type === "thinking") {
|
|
202
|
-
content.thinking += proxyEvent.delta;
|
|
203
|
-
return {
|
|
204
|
-
type: "thinking_delta",
|
|
205
|
-
contentIndex: proxyEvent.contentIndex,
|
|
206
|
-
delta: proxyEvent.delta,
|
|
207
|
-
partial,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
throw new Error("Received thinking_delta for non-thinking content");
|
|
211
|
-
}
|
|
212
|
-
case "thinking_end": {
|
|
213
|
-
const content = partial.content[proxyEvent.contentIndex];
|
|
214
|
-
if (content?.type === "thinking") {
|
|
215
|
-
content.thinkingSignature = proxyEvent.contentSignature;
|
|
216
|
-
return {
|
|
217
|
-
type: "thinking_end",
|
|
218
|
-
contentIndex: proxyEvent.contentIndex,
|
|
219
|
-
content: content.thinking,
|
|
220
|
-
partial,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
throw new Error("Received thinking_end for non-thinking content");
|
|
224
|
-
}
|
|
225
|
-
case "toolcall_start":
|
|
226
|
-
partial.content[proxyEvent.contentIndex] = {
|
|
227
|
-
type: "toolCall",
|
|
228
|
-
id: proxyEvent.id,
|
|
229
|
-
name: proxyEvent.toolName,
|
|
230
|
-
arguments: {},
|
|
231
|
-
partialJson: "",
|
|
232
|
-
};
|
|
233
|
-
return { type: "toolcall_start", contentIndex: proxyEvent.contentIndex, partial };
|
|
234
|
-
case "toolcall_delta": {
|
|
235
|
-
const content = partial.content[proxyEvent.contentIndex];
|
|
236
|
-
if (content?.type === "toolCall") {
|
|
237
|
-
content.partialJson += proxyEvent.delta;
|
|
238
|
-
content.arguments = parseStreamingJson(content.partialJson) || {};
|
|
239
|
-
partial.content[proxyEvent.contentIndex] = { ...content }; // Trigger reactivity
|
|
240
|
-
return {
|
|
241
|
-
type: "toolcall_delta",
|
|
242
|
-
contentIndex: proxyEvent.contentIndex,
|
|
243
|
-
delta: proxyEvent.delta,
|
|
244
|
-
partial,
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
throw new Error("Received toolcall_delta for non-toolCall content");
|
|
248
|
-
}
|
|
249
|
-
case "toolcall_end": {
|
|
250
|
-
const content = partial.content[proxyEvent.contentIndex];
|
|
251
|
-
if (content?.type === "toolCall") {
|
|
252
|
-
delete content.partialJson;
|
|
253
|
-
return {
|
|
254
|
-
type: "toolcall_end",
|
|
255
|
-
contentIndex: proxyEvent.contentIndex,
|
|
256
|
-
toolCall: content,
|
|
257
|
-
partial,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
return undefined;
|
|
261
|
-
}
|
|
262
|
-
case "done":
|
|
263
|
-
partial.stopReason = proxyEvent.reason;
|
|
264
|
-
partial.usage = proxyEvent.usage;
|
|
265
|
-
return { type: "done", reason: proxyEvent.reason, message: partial };
|
|
266
|
-
case "error":
|
|
267
|
-
partial.stopReason = proxyEvent.reason;
|
|
268
|
-
partial.errorMessage = proxyEvent.errorMessage;
|
|
269
|
-
partial.usage = proxyEvent.usage;
|
|
270
|
-
return { type: "error", reason: proxyEvent.reason, error: partial };
|
|
271
|
-
default: {
|
|
272
|
-
const _exhaustiveCheck = proxyEvent;
|
|
273
|
-
console.warn(`Unhandled proxy event type: ${proxyEvent.type}`);
|
|
274
|
-
return undefined;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
//# sourceMappingURL=proxy.js.map
|