@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,535 +0,0 @@
|
|
|
1
|
-
import { Mistral } from "@mistralai/mistralai";
|
|
2
|
-
import { getEnvApiKey } from "../env-api-keys.js";
|
|
3
|
-
import { calculateCost, clampThinkingLevel } from "../models.js";
|
|
4
|
-
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
5
|
-
import { shortHash } from "../utils/hash.js";
|
|
6
|
-
import { parseStreamingJson } from "../utils/json-parse.js";
|
|
7
|
-
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
8
|
-
import { buildBaseOptions } from "./simple-options.js";
|
|
9
|
-
import { transformMessages } from "./transform-messages.js";
|
|
10
|
-
const MISTRAL_TOOL_CALL_ID_LENGTH = 9;
|
|
11
|
-
const MAX_MISTRAL_ERROR_BODY_CHARS = 4000;
|
|
12
|
-
/**
|
|
13
|
-
* Stream responses from Mistral using `chat.stream`.
|
|
14
|
-
*/
|
|
15
|
-
export const streamMistral = (model, context, options) => {
|
|
16
|
-
const stream = new AssistantMessageEventStream();
|
|
17
|
-
(async () => {
|
|
18
|
-
const output = createOutput(model);
|
|
19
|
-
try {
|
|
20
|
-
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
|
21
|
-
if (!apiKey) {
|
|
22
|
-
throw new Error(`No API key for provider: ${model.provider}`);
|
|
23
|
-
}
|
|
24
|
-
// Intentionally per-request: avoids shared SDK mutable state across concurrent consumers.
|
|
25
|
-
const mistral = new Mistral({
|
|
26
|
-
apiKey,
|
|
27
|
-
serverURL: model.baseUrl,
|
|
28
|
-
});
|
|
29
|
-
const normalizeMistralToolCallId = createMistralToolCallIdNormalizer();
|
|
30
|
-
const transformedMessages = transformMessages(context.messages, model, (id) => normalizeMistralToolCallId(id));
|
|
31
|
-
let payload = buildChatPayload(model, context, transformedMessages, options);
|
|
32
|
-
const nextPayload = await options?.onPayload?.(payload, model);
|
|
33
|
-
if (nextPayload !== undefined) {
|
|
34
|
-
payload = nextPayload;
|
|
35
|
-
}
|
|
36
|
-
const mistralStream = await mistral.chat.stream(payload, buildRequestOptions(model, options));
|
|
37
|
-
stream.push({ type: "start", partial: output });
|
|
38
|
-
await consumeChatStream(model, output, stream, mistralStream);
|
|
39
|
-
if (options?.signal?.aborted) {
|
|
40
|
-
throw new Error("Request was aborted");
|
|
41
|
-
}
|
|
42
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") {
|
|
43
|
-
throw new Error("An unknown error occurred");
|
|
44
|
-
}
|
|
45
|
-
stream.push({ type: "done", reason: output.stopReason, message: output });
|
|
46
|
-
stream.end();
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
for (const block of output.content) {
|
|
50
|
-
// partialArgs is only a streaming scratch buffer; never persist it.
|
|
51
|
-
delete block.partialArgs;
|
|
52
|
-
}
|
|
53
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
54
|
-
output.errorMessage = formatMistralError(error);
|
|
55
|
-
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
56
|
-
stream.end();
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
return stream;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Maps provider-agnostic `SimpleStreamOptions` to Mistral options.
|
|
63
|
-
*/
|
|
64
|
-
export const streamSimpleMistral = (model, context, options) => {
|
|
65
|
-
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
|
66
|
-
if (!apiKey) {
|
|
67
|
-
throw new Error(`No API key for provider: ${model.provider}`);
|
|
68
|
-
}
|
|
69
|
-
const base = buildBaseOptions(model, options, apiKey);
|
|
70
|
-
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : undefined;
|
|
71
|
-
const reasoning = clampedReasoning === "off" ? undefined : clampedReasoning;
|
|
72
|
-
const shouldUseReasoning = model.reasoning && reasoning !== undefined;
|
|
73
|
-
return streamMistral(model, context, {
|
|
74
|
-
...base,
|
|
75
|
-
promptMode: shouldUseReasoning && usesPromptModeReasoning(model) ? "reasoning" : undefined,
|
|
76
|
-
reasoningEffort: shouldUseReasoning && usesReasoningEffort(model) ? mapReasoningEffort(model, reasoning) : undefined,
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
function createOutput(model) {
|
|
80
|
-
return {
|
|
81
|
-
role: "assistant",
|
|
82
|
-
content: [],
|
|
83
|
-
api: model.api,
|
|
84
|
-
provider: model.provider,
|
|
85
|
-
model: model.id,
|
|
86
|
-
usage: {
|
|
87
|
-
input: 0,
|
|
88
|
-
output: 0,
|
|
89
|
-
cacheRead: 0,
|
|
90
|
-
cacheWrite: 0,
|
|
91
|
-
totalTokens: 0,
|
|
92
|
-
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
93
|
-
},
|
|
94
|
-
stopReason: "stop",
|
|
95
|
-
timestamp: Date.now(),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function createMistralToolCallIdNormalizer() {
|
|
99
|
-
const idMap = new Map();
|
|
100
|
-
const reverseMap = new Map();
|
|
101
|
-
return (id) => {
|
|
102
|
-
const existing = idMap.get(id);
|
|
103
|
-
if (existing)
|
|
104
|
-
return existing;
|
|
105
|
-
let attempt = 0;
|
|
106
|
-
while (true) {
|
|
107
|
-
const candidate = deriveMistralToolCallId(id, attempt);
|
|
108
|
-
const owner = reverseMap.get(candidate);
|
|
109
|
-
if (!owner || owner === id) {
|
|
110
|
-
idMap.set(id, candidate);
|
|
111
|
-
reverseMap.set(candidate, id);
|
|
112
|
-
return candidate;
|
|
113
|
-
}
|
|
114
|
-
attempt++;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function deriveMistralToolCallId(id, attempt) {
|
|
119
|
-
const normalized = id.replace(/[^a-zA-Z0-9]/g, "");
|
|
120
|
-
if (attempt === 0 && normalized.length === MISTRAL_TOOL_CALL_ID_LENGTH)
|
|
121
|
-
return normalized;
|
|
122
|
-
const seedBase = normalized || id;
|
|
123
|
-
const seed = attempt === 0 ? seedBase : `${seedBase}:${attempt}`;
|
|
124
|
-
return shortHash(seed)
|
|
125
|
-
.replace(/[^a-zA-Z0-9]/g, "")
|
|
126
|
-
.slice(0, MISTRAL_TOOL_CALL_ID_LENGTH);
|
|
127
|
-
}
|
|
128
|
-
function formatMistralError(error) {
|
|
129
|
-
if (error instanceof Error) {
|
|
130
|
-
const sdkError = error;
|
|
131
|
-
const statusCode = typeof sdkError.statusCode === "number" ? sdkError.statusCode : undefined;
|
|
132
|
-
const bodyText = typeof sdkError.body === "string" ? sdkError.body.trim() : undefined;
|
|
133
|
-
if (statusCode !== undefined && bodyText) {
|
|
134
|
-
return `Mistral API error (${statusCode}): ${truncateErrorText(bodyText, MAX_MISTRAL_ERROR_BODY_CHARS)}`;
|
|
135
|
-
}
|
|
136
|
-
if (statusCode !== undefined)
|
|
137
|
-
return `Mistral API error (${statusCode}): ${error.message}`;
|
|
138
|
-
return error.message;
|
|
139
|
-
}
|
|
140
|
-
return safeJsonStringify(error);
|
|
141
|
-
}
|
|
142
|
-
function truncateErrorText(text, maxChars) {
|
|
143
|
-
if (text.length <= maxChars)
|
|
144
|
-
return text;
|
|
145
|
-
return `${text.slice(0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
146
|
-
}
|
|
147
|
-
function safeJsonStringify(value) {
|
|
148
|
-
try {
|
|
149
|
-
const serialized = JSON.stringify(value);
|
|
150
|
-
return serialized === undefined ? String(value) : serialized;
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
return String(value);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function buildRequestOptions(model, options) {
|
|
157
|
-
const requestOptions = {
|
|
158
|
-
retries: { strategy: "none" },
|
|
159
|
-
};
|
|
160
|
-
if (options?.signal)
|
|
161
|
-
requestOptions.signal = options.signal;
|
|
162
|
-
const headers = {};
|
|
163
|
-
if (model.headers)
|
|
164
|
-
Object.assign(headers, model.headers);
|
|
165
|
-
if (options?.headers)
|
|
166
|
-
Object.assign(headers, options.headers);
|
|
167
|
-
// Mistral infrastructure uses `x-affinity` for KV-cache reuse (prefix caching).
|
|
168
|
-
// Respect explicit caller-provided header values.
|
|
169
|
-
if (options?.sessionId && !headers["x-affinity"]) {
|
|
170
|
-
headers["x-affinity"] = options.sessionId;
|
|
171
|
-
}
|
|
172
|
-
if (Object.keys(headers).length > 0) {
|
|
173
|
-
requestOptions.headers = headers;
|
|
174
|
-
}
|
|
175
|
-
return requestOptions;
|
|
176
|
-
}
|
|
177
|
-
function buildChatPayload(model, context, messages, options) {
|
|
178
|
-
const payload = {
|
|
179
|
-
model: model.id,
|
|
180
|
-
stream: true,
|
|
181
|
-
messages: toChatMessages(messages, model.input.includes("image")),
|
|
182
|
-
};
|
|
183
|
-
if (context.tools?.length)
|
|
184
|
-
payload.tools = toFunctionTools(context.tools);
|
|
185
|
-
if (options?.temperature !== undefined)
|
|
186
|
-
payload.temperature = options.temperature;
|
|
187
|
-
if (options?.maxTokens !== undefined)
|
|
188
|
-
payload.maxTokens = options.maxTokens;
|
|
189
|
-
if (options?.toolChoice)
|
|
190
|
-
payload.toolChoice = mapToolChoice(options.toolChoice);
|
|
191
|
-
if (options?.promptMode)
|
|
192
|
-
payload.promptMode = options.promptMode;
|
|
193
|
-
if (options?.reasoningEffort)
|
|
194
|
-
payload.reasoningEffort = options.reasoningEffort;
|
|
195
|
-
if (context.systemPrompt) {
|
|
196
|
-
payload.messages.unshift({
|
|
197
|
-
role: "system",
|
|
198
|
-
content: sanitizeSurrogates(context.systemPrompt),
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
return payload;
|
|
202
|
-
}
|
|
203
|
-
async function consumeChatStream(model, output, stream, mistralStream) {
|
|
204
|
-
let currentBlock = null;
|
|
205
|
-
const blocks = output.content;
|
|
206
|
-
const blockIndex = () => blocks.length - 1;
|
|
207
|
-
const toolBlocksByKey = new Map();
|
|
208
|
-
const finishCurrentBlock = (block) => {
|
|
209
|
-
if (!block)
|
|
210
|
-
return;
|
|
211
|
-
if (block.type === "text") {
|
|
212
|
-
stream.push({
|
|
213
|
-
type: "text_end",
|
|
214
|
-
contentIndex: blockIndex(),
|
|
215
|
-
content: block.text,
|
|
216
|
-
partial: output,
|
|
217
|
-
});
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (block.type === "thinking") {
|
|
221
|
-
stream.push({
|
|
222
|
-
type: "thinking_end",
|
|
223
|
-
contentIndex: blockIndex(),
|
|
224
|
-
content: block.thinking,
|
|
225
|
-
partial: output,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
for await (const event of mistralStream) {
|
|
230
|
-
const chunk = event.data;
|
|
231
|
-
// Mistral's streamed CompletionChunk carries an id field. Keep the first non-empty one,
|
|
232
|
-
// mirroring how OpenAI-style streaming exposes a stable response identifier per stream.
|
|
233
|
-
output.responseId ||= chunk.id;
|
|
234
|
-
if (chunk.usage) {
|
|
235
|
-
output.usage.input = chunk.usage.promptTokens || 0;
|
|
236
|
-
output.usage.output = chunk.usage.completionTokens || 0;
|
|
237
|
-
output.usage.cacheRead = 0;
|
|
238
|
-
output.usage.cacheWrite = 0;
|
|
239
|
-
output.usage.totalTokens = chunk.usage.totalTokens || output.usage.input + output.usage.output;
|
|
240
|
-
calculateCost(model, output.usage);
|
|
241
|
-
}
|
|
242
|
-
const choice = chunk.choices[0];
|
|
243
|
-
if (!choice)
|
|
244
|
-
continue;
|
|
245
|
-
if (choice.finishReason) {
|
|
246
|
-
output.stopReason = mapChatStopReason(choice.finishReason);
|
|
247
|
-
}
|
|
248
|
-
const delta = choice.delta;
|
|
249
|
-
if (delta.content !== null && delta.content !== undefined) {
|
|
250
|
-
const contentItems = typeof delta.content === "string" ? [delta.content] : delta.content;
|
|
251
|
-
for (const item of contentItems) {
|
|
252
|
-
if (typeof item === "string") {
|
|
253
|
-
const textDelta = sanitizeSurrogates(item);
|
|
254
|
-
if (!currentBlock || currentBlock.type !== "text") {
|
|
255
|
-
finishCurrentBlock(currentBlock);
|
|
256
|
-
currentBlock = { type: "text", text: "" };
|
|
257
|
-
output.content.push(currentBlock);
|
|
258
|
-
stream.push({ type: "text_start", contentIndex: blockIndex(), partial: output });
|
|
259
|
-
}
|
|
260
|
-
currentBlock.text += textDelta;
|
|
261
|
-
stream.push({
|
|
262
|
-
type: "text_delta",
|
|
263
|
-
contentIndex: blockIndex(),
|
|
264
|
-
delta: textDelta,
|
|
265
|
-
partial: output,
|
|
266
|
-
});
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
if (item.type === "thinking") {
|
|
270
|
-
const deltaText = item.thinking
|
|
271
|
-
.map((part) => ("text" in part ? part.text : ""))
|
|
272
|
-
.filter((text) => text.length > 0)
|
|
273
|
-
.join("");
|
|
274
|
-
const thinkingDelta = sanitizeSurrogates(deltaText);
|
|
275
|
-
if (!thinkingDelta)
|
|
276
|
-
continue;
|
|
277
|
-
if (!currentBlock || currentBlock.type !== "thinking") {
|
|
278
|
-
finishCurrentBlock(currentBlock);
|
|
279
|
-
currentBlock = { type: "thinking", thinking: "" };
|
|
280
|
-
output.content.push(currentBlock);
|
|
281
|
-
stream.push({ type: "thinking_start", contentIndex: blockIndex(), partial: output });
|
|
282
|
-
}
|
|
283
|
-
currentBlock.thinking += thinkingDelta;
|
|
284
|
-
stream.push({
|
|
285
|
-
type: "thinking_delta",
|
|
286
|
-
contentIndex: blockIndex(),
|
|
287
|
-
delta: thinkingDelta,
|
|
288
|
-
partial: output,
|
|
289
|
-
});
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
if (item.type === "text") {
|
|
293
|
-
const textDelta = sanitizeSurrogates(item.text);
|
|
294
|
-
if (!currentBlock || currentBlock.type !== "text") {
|
|
295
|
-
finishCurrentBlock(currentBlock);
|
|
296
|
-
currentBlock = { type: "text", text: "" };
|
|
297
|
-
output.content.push(currentBlock);
|
|
298
|
-
stream.push({ type: "text_start", contentIndex: blockIndex(), partial: output });
|
|
299
|
-
}
|
|
300
|
-
currentBlock.text += textDelta;
|
|
301
|
-
stream.push({
|
|
302
|
-
type: "text_delta",
|
|
303
|
-
contentIndex: blockIndex(),
|
|
304
|
-
delta: textDelta,
|
|
305
|
-
partial: output,
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
const toolCalls = delta.toolCalls || [];
|
|
311
|
-
for (const toolCall of toolCalls) {
|
|
312
|
-
if (currentBlock) {
|
|
313
|
-
finishCurrentBlock(currentBlock);
|
|
314
|
-
currentBlock = null;
|
|
315
|
-
}
|
|
316
|
-
const callId = toolCall.id && toolCall.id !== "null"
|
|
317
|
-
? toolCall.id
|
|
318
|
-
: deriveMistralToolCallId(`toolcall:${toolCall.index ?? 0}`, 0);
|
|
319
|
-
const key = `${callId}:${toolCall.index || 0}`;
|
|
320
|
-
const existingIndex = toolBlocksByKey.get(key);
|
|
321
|
-
let block;
|
|
322
|
-
if (existingIndex !== undefined) {
|
|
323
|
-
const existing = output.content[existingIndex];
|
|
324
|
-
if (existing?.type === "toolCall") {
|
|
325
|
-
block = existing;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (!block) {
|
|
329
|
-
block = {
|
|
330
|
-
type: "toolCall",
|
|
331
|
-
id: callId,
|
|
332
|
-
name: toolCall.function.name,
|
|
333
|
-
arguments: {},
|
|
334
|
-
partialArgs: "",
|
|
335
|
-
};
|
|
336
|
-
output.content.push(block);
|
|
337
|
-
toolBlocksByKey.set(key, output.content.length - 1);
|
|
338
|
-
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
339
|
-
}
|
|
340
|
-
const argsDelta = typeof toolCall.function.arguments === "string"
|
|
341
|
-
? toolCall.function.arguments
|
|
342
|
-
: JSON.stringify(toolCall.function.arguments || {});
|
|
343
|
-
block.partialArgs = (block.partialArgs || "") + argsDelta;
|
|
344
|
-
block.arguments = parseStreamingJson(block.partialArgs);
|
|
345
|
-
stream.push({
|
|
346
|
-
type: "toolcall_delta",
|
|
347
|
-
contentIndex: toolBlocksByKey.get(key),
|
|
348
|
-
delta: argsDelta,
|
|
349
|
-
partial: output,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
finishCurrentBlock(currentBlock);
|
|
354
|
-
for (const index of toolBlocksByKey.values()) {
|
|
355
|
-
const block = output.content[index];
|
|
356
|
-
if (block.type !== "toolCall")
|
|
357
|
-
continue;
|
|
358
|
-
const toolBlock = block;
|
|
359
|
-
toolBlock.arguments = parseStreamingJson(toolBlock.partialArgs);
|
|
360
|
-
// Finalize in-place and strip the scratch buffer so replay only
|
|
361
|
-
// carries parsed arguments.
|
|
362
|
-
delete toolBlock.partialArgs;
|
|
363
|
-
stream.push({
|
|
364
|
-
type: "toolcall_end",
|
|
365
|
-
contentIndex: index,
|
|
366
|
-
toolCall: toolBlock,
|
|
367
|
-
partial: output,
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
function toFunctionTools(tools) {
|
|
372
|
-
return tools.map((tool) => ({
|
|
373
|
-
type: "function",
|
|
374
|
-
function: {
|
|
375
|
-
name: tool.name,
|
|
376
|
-
description: tool.description,
|
|
377
|
-
parameters: stripSymbolKeys(tool.parameters),
|
|
378
|
-
strict: false,
|
|
379
|
-
},
|
|
380
|
-
}));
|
|
381
|
-
}
|
|
382
|
-
function stripSymbolKeys(value) {
|
|
383
|
-
if (Array.isArray(value)) {
|
|
384
|
-
return value.map((item) => stripSymbolKeys(item));
|
|
385
|
-
}
|
|
386
|
-
if (value && typeof value === "object") {
|
|
387
|
-
const result = {};
|
|
388
|
-
for (const [key, entry] of Object.entries(value)) {
|
|
389
|
-
result[key] = stripSymbolKeys(entry);
|
|
390
|
-
}
|
|
391
|
-
return result;
|
|
392
|
-
}
|
|
393
|
-
return value;
|
|
394
|
-
}
|
|
395
|
-
function toChatMessages(messages, supportsImages) {
|
|
396
|
-
const result = [];
|
|
397
|
-
for (const msg of messages) {
|
|
398
|
-
if (msg.role === "user") {
|
|
399
|
-
if (typeof msg.content === "string") {
|
|
400
|
-
result.push({ role: "user", content: sanitizeSurrogates(msg.content) });
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
const hadImages = msg.content.some((item) => item.type === "image");
|
|
404
|
-
const content = msg.content
|
|
405
|
-
.filter((item) => item.type === "text" || supportsImages)
|
|
406
|
-
.map((item) => {
|
|
407
|
-
if (item.type === "text")
|
|
408
|
-
return { type: "text", text: sanitizeSurrogates(item.text) };
|
|
409
|
-
return { type: "image_url", imageUrl: `data:${item.mimeType};base64,${item.data}` };
|
|
410
|
-
});
|
|
411
|
-
if (content.length > 0) {
|
|
412
|
-
result.push({ role: "user", content });
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (hadImages && !supportsImages) {
|
|
416
|
-
result.push({ role: "user", content: "(image omitted: model does not support images)" });
|
|
417
|
-
}
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
if (msg.role === "assistant") {
|
|
421
|
-
const contentParts = [];
|
|
422
|
-
const toolCalls = [];
|
|
423
|
-
for (const block of msg.content) {
|
|
424
|
-
if (block.type === "text") {
|
|
425
|
-
if (block.text.trim().length > 0) {
|
|
426
|
-
contentParts.push({ type: "text", text: sanitizeSurrogates(block.text) });
|
|
427
|
-
}
|
|
428
|
-
continue;
|
|
429
|
-
}
|
|
430
|
-
if (block.type === "thinking") {
|
|
431
|
-
if (block.thinking.trim().length > 0) {
|
|
432
|
-
contentParts.push({
|
|
433
|
-
type: "thinking",
|
|
434
|
-
thinking: [{ type: "text", text: sanitizeSurrogates(block.thinking) }],
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
continue;
|
|
438
|
-
}
|
|
439
|
-
toolCalls.push({
|
|
440
|
-
id: block.id,
|
|
441
|
-
type: "function",
|
|
442
|
-
function: { name: block.name, arguments: JSON.stringify(block.arguments || {}) },
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
const assistantMessage = { role: "assistant" };
|
|
446
|
-
if (contentParts.length > 0)
|
|
447
|
-
assistantMessage.content = contentParts;
|
|
448
|
-
if (toolCalls.length > 0)
|
|
449
|
-
assistantMessage.toolCalls = toolCalls;
|
|
450
|
-
if (contentParts.length > 0 || toolCalls.length > 0)
|
|
451
|
-
result.push(assistantMessage);
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
const toolContent = [];
|
|
455
|
-
const textResult = msg.content
|
|
456
|
-
.filter((part) => part.type === "text")
|
|
457
|
-
.map((part) => (part.type === "text" ? sanitizeSurrogates(part.text) : ""))
|
|
458
|
-
.join("\n");
|
|
459
|
-
const hasImages = msg.content.some((part) => part.type === "image");
|
|
460
|
-
const toolText = buildToolResultText(textResult, hasImages, supportsImages, msg.isError);
|
|
461
|
-
toolContent.push({ type: "text", text: toolText });
|
|
462
|
-
for (const part of msg.content) {
|
|
463
|
-
if (!supportsImages)
|
|
464
|
-
continue;
|
|
465
|
-
if (part.type !== "image")
|
|
466
|
-
continue;
|
|
467
|
-
toolContent.push({
|
|
468
|
-
type: "image_url",
|
|
469
|
-
imageUrl: `data:${part.mimeType};base64,${part.data}`,
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
result.push({
|
|
473
|
-
role: "tool",
|
|
474
|
-
toolCallId: msg.toolCallId,
|
|
475
|
-
name: msg.toolName,
|
|
476
|
-
content: toolContent,
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
return result;
|
|
480
|
-
}
|
|
481
|
-
function buildToolResultText(text, hasImages, supportsImages, isError) {
|
|
482
|
-
const trimmed = text.trim();
|
|
483
|
-
const errorPrefix = isError ? "[tool error] " : "";
|
|
484
|
-
if (trimmed.length > 0) {
|
|
485
|
-
const imageSuffix = hasImages && !supportsImages ? "\n[tool image omitted: model does not support images]" : "";
|
|
486
|
-
return `${errorPrefix}${trimmed}${imageSuffix}`;
|
|
487
|
-
}
|
|
488
|
-
if (hasImages) {
|
|
489
|
-
if (supportsImages) {
|
|
490
|
-
return isError ? "[tool error] (see attached image)" : "(see attached image)";
|
|
491
|
-
}
|
|
492
|
-
return isError
|
|
493
|
-
? "[tool error] (image omitted: model does not support images)"
|
|
494
|
-
: "(image omitted: model does not support images)";
|
|
495
|
-
}
|
|
496
|
-
return isError ? "[tool error] (no tool output)" : "(no tool output)";
|
|
497
|
-
}
|
|
498
|
-
function usesReasoningEffort(model) {
|
|
499
|
-
return model.id === "mistral-small-2603" || model.id === "mistral-small-latest" || model.id === "mistral-medium-3.5";
|
|
500
|
-
}
|
|
501
|
-
function usesPromptModeReasoning(model) {
|
|
502
|
-
return model.reasoning && !usesReasoningEffort(model);
|
|
503
|
-
}
|
|
504
|
-
function mapReasoningEffort(model, level) {
|
|
505
|
-
return (model.thinkingLevelMap?.[level] ?? "high");
|
|
506
|
-
}
|
|
507
|
-
function mapToolChoice(choice) {
|
|
508
|
-
if (!choice)
|
|
509
|
-
return undefined;
|
|
510
|
-
if (choice === "auto" || choice === "none" || choice === "any" || choice === "required") {
|
|
511
|
-
return choice;
|
|
512
|
-
}
|
|
513
|
-
return {
|
|
514
|
-
type: "function",
|
|
515
|
-
function: { name: choice.function.name },
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
function mapChatStopReason(reason) {
|
|
519
|
-
if (reason === null)
|
|
520
|
-
return "stop";
|
|
521
|
-
switch (reason) {
|
|
522
|
-
case "stop":
|
|
523
|
-
return "stop";
|
|
524
|
-
case "length":
|
|
525
|
-
case "model_length":
|
|
526
|
-
return "length";
|
|
527
|
-
case "tool_calls":
|
|
528
|
-
return "toolUse";
|
|
529
|
-
case "error":
|
|
530
|
-
return "error";
|
|
531
|
-
default:
|
|
532
|
-
return "stop";
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
//# sourceMappingURL=mistral.js.map
|