@psnext/slingcli 2.4.20260507-2 → 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 +56 -14
- 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/strnum/CHANGELOG.md +3 -0
- package/node_modules/strnum/package.json +3 -2
- package/node_modules/strnum/strnum.js +12 -10
- package/node_modules/xml-naming/README.md +189 -0
- package/node_modules/xml-naming/package.json +54 -0
- package/node_modules/xml-naming/src/index.d.ts +74 -0
- package/node_modules/xml-naming/src/index.js +270 -0
- package/package.json +6 -6
- package/sling-default-packages.json +2 -1
- package/slingshot/index.js +442 -23
- package/node_modules/@mariozechner/jiti/dist/babel.cjs +0 -246
- package/node_modules/@mariozechner/jiti/dist/jiti.cjs +0 -1
- package/node_modules/@mariozechner/jiti/package.json +0 -96
- package/node_modules/@mariozechner/pi-agent-core/dist/index.js +0 -9
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/cli.js +0 -116
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/env-api-keys.js +0 -166
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/index.js +0 -15
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/models.generated.js +0 -16568
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/amazon-bedrock.js +0 -753
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/openai-codex-responses.js +0 -909
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses-shared.js +0 -479
- package/node_modules/@mariozechner/pi-agent-core/node_modules/@mariozechner/pi-ai/dist/utils/oauth/openai-codex.js +0 -374
- package/node_modules/@mariozechner/pi-ai/dist/api-registry.js +0 -44
- package/node_modules/@mariozechner/pi-ai/dist/bedrock-provider.js +0 -6
- package/node_modules/@mariozechner/pi-ai/dist/models.js +0 -71
- package/node_modules/@mariozechner/pi-ai/dist/oauth.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +0 -951
- package/node_modules/@mariozechner/pi-ai/dist/providers/azure-openai-responses.js +0 -208
- package/node_modules/@mariozechner/pi-ai/dist/providers/cloudflare.js +0 -26
- package/node_modules/@mariozechner/pi-ai/dist/providers/faux.js +0 -368
- package/node_modules/@mariozechner/pi-ai/dist/providers/github-copilot-headers.js +0 -29
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-shared.js +0 -329
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +0 -442
- package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +0 -400
- package/node_modules/@mariozechner/pi-ai/dist/providers/mistral.js +0 -535
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +0 -908
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses.js +0 -220
- package/node_modules/@mariozechner/pi-ai/dist/providers/register-builtins.js +0 -243
- package/node_modules/@mariozechner/pi-ai/dist/providers/simple-options.js +0 -39
- package/node_modules/@mariozechner/pi-ai/dist/providers/transform-messages.js +0 -184
- package/node_modules/@mariozechner/pi-ai/dist/stream.js +0 -27
- package/node_modules/@mariozechner/pi-ai/dist/types.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/event-stream.js +0 -81
- package/node_modules/@mariozechner/pi-ai/dist/utils/hash.js +0 -14
- package/node_modules/@mariozechner/pi-ai/dist/utils/headers.js +0 -8
- package/node_modules/@mariozechner/pi-ai/dist/utils/json-parse.js +0 -113
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/anthropic.js +0 -335
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/github-copilot.js +0 -292
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/index.js +0 -121
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/oauth-page.js +0 -105
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/pkce.js +0 -31
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/types.js +0 -2
- package/node_modules/@mariozechner/pi-ai/dist/utils/overflow.js +0 -146
- package/node_modules/@mariozechner/pi-ai/dist/utils/sanitize-unicode.js +0 -26
- package/node_modules/@mariozechner/pi-ai/dist/utils/typebox-helpers.js +0 -21
- package/node_modules/@mariozechner/pi-ai/dist/utils/validation.js +0 -281
- package/node_modules/@mariozechner/pi-ai/package.json +0 -108
- package/node_modules/@mariozechner/pi-coding-agent/dist/bun/register-bedrock.js +0 -4
- package/node_modules/@mariozechner/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js +0 -22
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/agent-loop.js +0 -458
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/agent.js +0 -398
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/index.js +0 -9
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/proxy.js +0 -278
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/dist/types.js +0 -2
- package/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-agent-core/package.json +0 -45
- package/node_modules/socks/.claude/settings.local.json +0 -26
- package/node_modules/std-env/LICENCE +0 -22
- package/node_modules/std-env/README.md +0 -118
- package/node_modules/std-env/dist/index.cjs +0 -1
- package/node_modules/std-env/dist/index.d.cts +0 -92
- package/node_modules/std-env/dist/index.d.mts +0 -92
- package/node_modules/std-env/dist/index.d.ts +0 -92
- package/node_modules/std-env/dist/index.mjs +0 -1
- package/node_modules/std-env/package.json +0 -46
- package/node_modules/yoctocolors/base.d.ts +0 -47
- package/node_modules/yoctocolors/base.js +0 -94
- package/node_modules/yoctocolors/index.d.ts +0 -2
- package/node_modules/yoctocolors/index.js +0 -2
- package/node_modules/yoctocolors/license +0 -9
- package/node_modules/yoctocolors/package.json +0 -69
- package/node_modules/yoctocolors/readme.md +0 -138
- /package/node_modules/{@mariozechner/pi-coding-agent/dist/core → @earendil-works/pi-agent-core/dist/harness}/compaction/utils.js +0 -0
- /package/node_modules/{@mariozechner/pi-coding-agent/dist/core/tools → @earendil-works/pi-agent-core/dist/harness/utils}/truncate.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-agent-core/dist/types.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/api-registry.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/bedrock-provider.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/models.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/oauth.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/providers/amazon-bedrock.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/anthropic.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/azure-openai-responses.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/cloudflare.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/faux.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/github-copilot-headers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google-shared.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google-vertex.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/google.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/mistral.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/openai-responses.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/register-builtins.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/simple-options.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/providers/transform-messages.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/session-resources.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/stream.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-ai/dist/utils/diagnostics.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/event-stream.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/hash.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/headers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/json-parse.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/anthropic.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/github-copilot.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/index.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/oauth-page.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/pkce.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/oauth/types.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/sanitize-unicode.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/typebox-helpers.js +0 -0
- /package/node_modules/{@mariozechner/pi-agent-core/node_modules/@mariozechner → @earendil-works}/pi-ai/dist/utils/validation.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/bun/cli.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/bun/restore-sandbox-env.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/file-processor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli/initial-message.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/cli.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session-runtime.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/agent-session-services.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/auth-guidance.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/bash-executor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/compaction/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/defaults.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/diagnostics.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/event-bus.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/exec.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/ansi-to-html.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/template.html +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/tool-renderer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/vendor/highlight.min.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/export-html/vendor/marked.min.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/runner.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/extensions/wrapper.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/footer-data-provider.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/messages.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/output-guard.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/prompt-templates.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/resolve-config-value.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/resource-loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/session-cwd.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/session-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/settings-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/skills.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/slash-commands.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/source-info.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/system-prompt.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/telemetry.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/timings.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/edit-diff.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/file-mutation-queue.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/output-accumulator.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/path-utils.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/core/tools/tool-definition-wrapper.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/assets/clankolas.png +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/armin.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/daxnuts.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/diff.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/components/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/interactive/theme/theme-schema.json +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/print-mode.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/jsonl.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-client.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-mode.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/modes/rpc/rpc-types.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/changelog.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/child-process.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard-image.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/clipboard-native.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/exif-orientation.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/frontmatter.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/fs-watch.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/git.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/image-convert.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/image-resize.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/mime.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/photon.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/pi-user-agent.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/shell.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/sleep.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-coding-agent/dist/utils/tools-manager.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/autocomplete.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/box.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/cancellable-loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/editor.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/input.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/loader.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/select-list.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/settings-list.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/spacer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/text.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/components/truncated-text.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/editor-component.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/fuzzy.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/index.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/keybindings.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/keys.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/kill-ring.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/stdin-buffer.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/terminal.js +0 -0
- /package/node_modules/{@mariozechner → @earendil-works}/pi-tui/dist/undo-stack.js +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/LICENSE +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-cli.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-hooks.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-native.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-register.d.mts +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti-register.mjs +0 -0
- /package/node_modules/{@mariozechner/jiti/lib/jiti.mjs → jiti/lib/jiti-static.mjs} +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.cjs +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.d.cts +0 -0
- /package/node_modules/{@mariozechner/jiti → jiti}/lib/jiti.d.mts +0 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { Agent } from "../agent.js";
|
|
3
|
+
import { collectEntriesForBranchSummary, generateBranchSummary } from "./compaction/branch-summarization.js";
|
|
4
|
+
import { compact, DEFAULT_COMPACTION_SETTINGS, prepareCompaction } from "./compaction/compaction.js";
|
|
5
|
+
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
6
|
+
import { expandSkillCommand } from "./skills.js";
|
|
7
|
+
function createUserMessage(text, images) {
|
|
8
|
+
const content = [{ type: "text", text }];
|
|
9
|
+
if (images)
|
|
10
|
+
content.push(...images);
|
|
11
|
+
return { role: "user", content, timestamp: Date.now() };
|
|
12
|
+
}
|
|
13
|
+
export class AgentHarness {
|
|
14
|
+
agent;
|
|
15
|
+
env;
|
|
16
|
+
conversation;
|
|
17
|
+
operation;
|
|
18
|
+
session;
|
|
19
|
+
resourcesInput;
|
|
20
|
+
systemPrompt;
|
|
21
|
+
requestAuth;
|
|
22
|
+
toolRegistry = new Map();
|
|
23
|
+
listeners = new Set();
|
|
24
|
+
hooks = new Map();
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.agent = new Agent({
|
|
27
|
+
initialState: {
|
|
28
|
+
model: options.model,
|
|
29
|
+
thinkingLevel: options.thinkingLevel,
|
|
30
|
+
tools: options.tools ?? [],
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
this.env = options.env;
|
|
34
|
+
this.session = options.session;
|
|
35
|
+
this.resourcesInput = options.resources;
|
|
36
|
+
this.systemPrompt = options.systemPrompt;
|
|
37
|
+
this.requestAuth = options.requestAuth;
|
|
38
|
+
for (const tool of this.agent.state.tools) {
|
|
39
|
+
this.toolRegistry.set(tool.name, tool);
|
|
40
|
+
}
|
|
41
|
+
this.conversation = {
|
|
42
|
+
session: options.session,
|
|
43
|
+
model: options.model,
|
|
44
|
+
thinkingLevel: options.thinkingLevel ?? this.agent.state.thinkingLevel,
|
|
45
|
+
activeToolNames: options.activeToolNames ?? this.agent.state.tools.map((tool) => tool.name),
|
|
46
|
+
nextTurnQueue: [],
|
|
47
|
+
};
|
|
48
|
+
this.agent.state.model = this.conversation.model;
|
|
49
|
+
this.agent.state.thinkingLevel = this.conversation.thinkingLevel;
|
|
50
|
+
this.agent.getApiKey = async (provider) => {
|
|
51
|
+
const model = this.conversation.model;
|
|
52
|
+
if (!this.requestAuth || model.provider !== provider)
|
|
53
|
+
return undefined;
|
|
54
|
+
return (await this.requestAuth(model))?.apiKey;
|
|
55
|
+
};
|
|
56
|
+
this.operation = {
|
|
57
|
+
idle: true,
|
|
58
|
+
abortRequested: false,
|
|
59
|
+
steerQueue: [],
|
|
60
|
+
followUpQueue: [],
|
|
61
|
+
pendingMutations: {
|
|
62
|
+
appendMessages: [],
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
this.agent.transformContext = async (messages, signal) => {
|
|
66
|
+
const result = await this.emitHook("context", { type: "context", messages: [...messages] }, signal);
|
|
67
|
+
return result?.messages ?? messages;
|
|
68
|
+
};
|
|
69
|
+
this.agent.beforeToolCall = async ({ toolCall, args }, signal) => {
|
|
70
|
+
const result = await this.emitHook("tool_call", {
|
|
71
|
+
type: "tool_call",
|
|
72
|
+
toolCallId: toolCall.id,
|
|
73
|
+
toolName: toolCall.name,
|
|
74
|
+
input: args,
|
|
75
|
+
}, signal);
|
|
76
|
+
return result ? { block: result.block, reason: result.reason } : undefined;
|
|
77
|
+
};
|
|
78
|
+
this.agent.afterToolCall = async ({ toolCall, args, result, isError }, signal) => {
|
|
79
|
+
const patch = await this.emitHook("tool_result", {
|
|
80
|
+
type: "tool_result",
|
|
81
|
+
toolCallId: toolCall.id,
|
|
82
|
+
toolName: toolCall.name,
|
|
83
|
+
input: args,
|
|
84
|
+
content: result.content,
|
|
85
|
+
details: result.details,
|
|
86
|
+
isError,
|
|
87
|
+
}, signal);
|
|
88
|
+
return patch
|
|
89
|
+
? { content: patch.content, details: patch.details, isError: patch.isError, terminate: patch.terminate }
|
|
90
|
+
: undefined;
|
|
91
|
+
};
|
|
92
|
+
this.agent.onPayload = async (payload) => {
|
|
93
|
+
const result = await this.emitHook("before_provider_request", { type: "before_provider_request", payload });
|
|
94
|
+
return result?.payload ?? payload;
|
|
95
|
+
};
|
|
96
|
+
this.agent.onResponse = async (response) => {
|
|
97
|
+
const headers = { ...response.headers };
|
|
98
|
+
await this.emitOwn({ type: "after_provider_response", status: response.status, headers }, this.agent.signal);
|
|
99
|
+
};
|
|
100
|
+
this.agent.subscribe(async (event, signal) => {
|
|
101
|
+
await this.handleAgentEvent(event, signal);
|
|
102
|
+
});
|
|
103
|
+
void this.syncFromTree();
|
|
104
|
+
}
|
|
105
|
+
createContext(signal) {
|
|
106
|
+
return {
|
|
107
|
+
env: this.env,
|
|
108
|
+
conversation: this.conversation,
|
|
109
|
+
operation: this.operation,
|
|
110
|
+
abortSignal: signal,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async resolveResources(signal) {
|
|
114
|
+
return typeof this.resourcesInput === "function"
|
|
115
|
+
? await this.resourcesInput(this.createContext(signal))
|
|
116
|
+
: (this.resourcesInput ?? {});
|
|
117
|
+
}
|
|
118
|
+
getActiveTools() {
|
|
119
|
+
return this.conversation.activeToolNames
|
|
120
|
+
.map((name) => this.toolRegistry.get(name))
|
|
121
|
+
.filter((tool) => tool !== undefined);
|
|
122
|
+
}
|
|
123
|
+
async resolveSystemPrompt(resources) {
|
|
124
|
+
if (!this.systemPrompt)
|
|
125
|
+
return "You are a helpful assistant.";
|
|
126
|
+
if (typeof this.systemPrompt === "string")
|
|
127
|
+
return this.systemPrompt;
|
|
128
|
+
return await this.systemPrompt({
|
|
129
|
+
env: this.env,
|
|
130
|
+
session: this.session,
|
|
131
|
+
model: this.conversation.model,
|
|
132
|
+
thinkingLevel: this.conversation.thinkingLevel,
|
|
133
|
+
activeTools: this.getActiveTools(),
|
|
134
|
+
resources,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async emitOwn(event, signal) {
|
|
138
|
+
for (const listener of this.listeners) {
|
|
139
|
+
await listener(event, signal);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async emitAny(event, signal) {
|
|
143
|
+
for (const listener of this.listeners) {
|
|
144
|
+
await listener(event, signal);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async emitHook(type, event, signal) {
|
|
148
|
+
const handlers = this.hooks.get(type);
|
|
149
|
+
if (!handlers || handlers.size === 0)
|
|
150
|
+
return undefined;
|
|
151
|
+
let lastResult;
|
|
152
|
+
for (const handler of handlers) {
|
|
153
|
+
const result = await handler(event, this.createContext(signal));
|
|
154
|
+
if (result !== undefined) {
|
|
155
|
+
lastResult = result;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return lastResult;
|
|
159
|
+
}
|
|
160
|
+
async emitQueueUpdate() {
|
|
161
|
+
await this.emitOwn({
|
|
162
|
+
type: "queue_update",
|
|
163
|
+
steer: [...this.operation.steerQueue],
|
|
164
|
+
followUp: [...this.operation.followUpQueue],
|
|
165
|
+
nextTurn: [...this.conversation.nextTurnQueue],
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async syncFromTree() {
|
|
169
|
+
const context = await this.session.buildContext();
|
|
170
|
+
this.agent.state.messages = context.messages;
|
|
171
|
+
if (context.model && this.conversation.model) {
|
|
172
|
+
// leave active model untouched; harness-level model is source of truth
|
|
173
|
+
}
|
|
174
|
+
this.agent.state.systemPrompt = await this.resolveSystemPrompt(await this.resolveResources());
|
|
175
|
+
}
|
|
176
|
+
async applyPendingMutations() {
|
|
177
|
+
for (const message of this.operation.pendingMutations.appendMessages) {
|
|
178
|
+
await this.session.appendMessage(message);
|
|
179
|
+
}
|
|
180
|
+
this.operation.pendingMutations.appendMessages = [];
|
|
181
|
+
if (this.operation.pendingMutations.model) {
|
|
182
|
+
const model = this.operation.pendingMutations.model;
|
|
183
|
+
const previousModel = this.conversation.model;
|
|
184
|
+
this.conversation.model = model;
|
|
185
|
+
this.agent.state.model = model;
|
|
186
|
+
await this.session.appendModelChange(model.provider, model.id);
|
|
187
|
+
await this.emitOwn({ type: "model_select", model, previousModel, source: "set" });
|
|
188
|
+
this.operation.pendingMutations.model = undefined;
|
|
189
|
+
}
|
|
190
|
+
if (this.operation.pendingMutations.thinkingLevel !== undefined) {
|
|
191
|
+
const level = this.operation.pendingMutations.thinkingLevel;
|
|
192
|
+
const previousLevel = this.conversation.thinkingLevel;
|
|
193
|
+
this.conversation.thinkingLevel = level;
|
|
194
|
+
this.agent.state.thinkingLevel = level;
|
|
195
|
+
await this.session.appendThinkingLevelChange(level);
|
|
196
|
+
await this.emitOwn({ type: "thinking_level_select", level, previousLevel });
|
|
197
|
+
this.operation.pendingMutations.thinkingLevel = undefined;
|
|
198
|
+
}
|
|
199
|
+
if (this.operation.pendingMutations.activeToolNames) {
|
|
200
|
+
this.conversation.activeToolNames = [...this.operation.pendingMutations.activeToolNames];
|
|
201
|
+
this.agent.state.tools = this.conversation.activeToolNames
|
|
202
|
+
.map((name) => this.toolRegistry.get(name))
|
|
203
|
+
.filter((tool) => tool !== undefined);
|
|
204
|
+
this.operation.pendingMutations.activeToolNames = undefined;
|
|
205
|
+
}
|
|
206
|
+
await this.syncFromTree();
|
|
207
|
+
}
|
|
208
|
+
async handleAgentEvent(event, signal) {
|
|
209
|
+
await this.emitAny(event, signal);
|
|
210
|
+
if (event.type === "message_start") {
|
|
211
|
+
const steerIndex = this.operation.steerQueue.indexOf(event.message);
|
|
212
|
+
if (steerIndex !== -1) {
|
|
213
|
+
this.operation.steerQueue.splice(steerIndex, 1);
|
|
214
|
+
await this.emitQueueUpdate();
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const followUpIndex = this.operation.followUpQueue.indexOf(event.message);
|
|
218
|
+
if (followUpIndex !== -1) {
|
|
219
|
+
this.operation.followUpQueue.splice(followUpIndex, 1);
|
|
220
|
+
await this.emitQueueUpdate();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (event.type === "message_end") {
|
|
225
|
+
await this.session.appendMessage(event.message);
|
|
226
|
+
}
|
|
227
|
+
if (event.type === "turn_end") {
|
|
228
|
+
const hadPendingMutations = this.operation.pendingMutations.appendMessages.length > 0 ||
|
|
229
|
+
this.operation.pendingMutations.model !== undefined ||
|
|
230
|
+
this.operation.pendingMutations.thinkingLevel !== undefined ||
|
|
231
|
+
this.operation.pendingMutations.activeToolNames !== undefined;
|
|
232
|
+
await this.emitOwn({ type: "save_point", liveOperationId: this.operation.liveOperationId ?? "unknown", hadPendingMutations }, signal);
|
|
233
|
+
if (hadPendingMutations) {
|
|
234
|
+
await this.applyPendingMutations();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (event.type === "agent_end") {
|
|
238
|
+
this.operation.idle = true;
|
|
239
|
+
this.operation.liveOperationId = undefined;
|
|
240
|
+
this.operation.abortRequested = false;
|
|
241
|
+
await this.syncFromTree();
|
|
242
|
+
await this.emitOwn({ type: "settled", nextTurnCount: this.conversation.nextTurnQueue.length }, signal);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async prompt(text, options) {
|
|
246
|
+
if (!this.operation.idle)
|
|
247
|
+
throw new Error("AgentHarness is busy");
|
|
248
|
+
const beforeLength = this.agent.state.messages.length;
|
|
249
|
+
this.operation.idle = false;
|
|
250
|
+
this.operation.liveOperationId = randomUUID();
|
|
251
|
+
const resources = await this.resolveResources(this.agent.signal);
|
|
252
|
+
let messages = [createUserMessage(text, options?.images)];
|
|
253
|
+
if (this.conversation.nextTurnQueue.length > 0) {
|
|
254
|
+
messages = [messages[0], ...this.conversation.nextTurnQueue];
|
|
255
|
+
this.conversation.nextTurnQueue = [];
|
|
256
|
+
await this.emitQueueUpdate();
|
|
257
|
+
}
|
|
258
|
+
this.agent.state.systemPrompt = await this.resolveSystemPrompt(resources);
|
|
259
|
+
const beforeResult = await this.emitHook("before_agent_start", {
|
|
260
|
+
type: "before_agent_start",
|
|
261
|
+
prompt: text,
|
|
262
|
+
images: options?.images,
|
|
263
|
+
systemPrompt: this.agent.state.systemPrompt,
|
|
264
|
+
resources,
|
|
265
|
+
}, this.agent.signal);
|
|
266
|
+
if (beforeResult?.messages)
|
|
267
|
+
messages = [...beforeResult.messages, ...messages];
|
|
268
|
+
if (beforeResult?.systemPrompt)
|
|
269
|
+
this.agent.state.systemPrompt = beforeResult.systemPrompt;
|
|
270
|
+
await this.agent.prompt(messages);
|
|
271
|
+
let response;
|
|
272
|
+
const newMessages = this.agent.state.messages.slice(beforeLength);
|
|
273
|
+
for (let i = newMessages.length - 1; i >= 0; i--) {
|
|
274
|
+
const message = newMessages[i];
|
|
275
|
+
if (message.role === "assistant") {
|
|
276
|
+
response = message;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (!response)
|
|
281
|
+
throw new Error("AgentHarness prompt completed without an assistant message");
|
|
282
|
+
return response;
|
|
283
|
+
}
|
|
284
|
+
async skill(name, additionalInstructions) {
|
|
285
|
+
const resources = await this.resolveResources();
|
|
286
|
+
const skill = (resources.skills ?? []).find((candidate) => candidate.name === name);
|
|
287
|
+
if (!skill)
|
|
288
|
+
throw new Error(`Unknown skill: ${name}`);
|
|
289
|
+
return await this.prompt(expandSkillCommand(skill, additionalInstructions));
|
|
290
|
+
}
|
|
291
|
+
async promptFromTemplate(name, args = []) {
|
|
292
|
+
const resources = await this.resolveResources();
|
|
293
|
+
const template = (resources.promptTemplates ?? []).find((candidate) => candidate.name === name);
|
|
294
|
+
if (!template)
|
|
295
|
+
throw new Error(`Unknown prompt template: ${name}`);
|
|
296
|
+
return await this.prompt(expandPromptTemplate(template, args));
|
|
297
|
+
}
|
|
298
|
+
steer(message) {
|
|
299
|
+
if (this.operation.idle)
|
|
300
|
+
throw new Error("Cannot steer while idle");
|
|
301
|
+
this.operation.steerQueue.push(message);
|
|
302
|
+
this.agent.steer(message);
|
|
303
|
+
void this.emitQueueUpdate();
|
|
304
|
+
}
|
|
305
|
+
followUp(message) {
|
|
306
|
+
if (this.operation.idle)
|
|
307
|
+
throw new Error("Cannot follow up while idle");
|
|
308
|
+
this.operation.followUpQueue.push(message);
|
|
309
|
+
this.agent.followUp(message);
|
|
310
|
+
void this.emitQueueUpdate();
|
|
311
|
+
}
|
|
312
|
+
nextTurn(message) {
|
|
313
|
+
this.conversation.nextTurnQueue.push(message);
|
|
314
|
+
void this.emitQueueUpdate();
|
|
315
|
+
}
|
|
316
|
+
async appendMessage(message) {
|
|
317
|
+
if (this.operation.idle) {
|
|
318
|
+
await this.session.appendMessage(message);
|
|
319
|
+
await this.syncFromTree();
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
this.operation.pendingMutations.appendMessages.push(message);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async shell(command, options) {
|
|
326
|
+
return await this.env.exec(command, options);
|
|
327
|
+
}
|
|
328
|
+
async compact(customInstructions) {
|
|
329
|
+
if (!this.operation.idle)
|
|
330
|
+
throw new Error("compact() requires idle harness");
|
|
331
|
+
const model = this.conversation.model;
|
|
332
|
+
if (!model)
|
|
333
|
+
throw new Error("No model set for compaction");
|
|
334
|
+
const auth = await this.requestAuth?.(model);
|
|
335
|
+
if (!auth)
|
|
336
|
+
throw new Error("No auth available for compaction");
|
|
337
|
+
const branchEntries = await this.session.getBranch();
|
|
338
|
+
const preparation = prepareCompaction(branchEntries, DEFAULT_COMPACTION_SETTINGS);
|
|
339
|
+
if (!preparation)
|
|
340
|
+
throw new Error("Nothing to compact");
|
|
341
|
+
const hookResult = await this.emitHook("session_before_compact", {
|
|
342
|
+
type: "session_before_compact",
|
|
343
|
+
preparation,
|
|
344
|
+
branchEntries,
|
|
345
|
+
customInstructions,
|
|
346
|
+
signal: new AbortController().signal,
|
|
347
|
+
});
|
|
348
|
+
if (hookResult?.cancel)
|
|
349
|
+
throw new Error("Compaction cancelled");
|
|
350
|
+
const provided = hookResult?.compaction;
|
|
351
|
+
const result = provided ??
|
|
352
|
+
(await compact(preparation, model, auth.apiKey, auth.headers, customInstructions, undefined, this.conversation.thinkingLevel));
|
|
353
|
+
const entryId = await this.session.appendCompaction(result.summary, result.firstKeptEntryId, result.tokensBefore, result.details, provided !== undefined);
|
|
354
|
+
const entry = await this.session.getEntry(entryId);
|
|
355
|
+
await this.syncFromTree();
|
|
356
|
+
if (entry?.type === "compaction") {
|
|
357
|
+
await this.emitOwn({ type: "session_compact", compactionEntry: entry, fromHook: provided !== undefined });
|
|
358
|
+
}
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
async navigateTree(targetId, options) {
|
|
362
|
+
if (!this.operation.idle)
|
|
363
|
+
throw new Error("navigateTree() requires idle harness");
|
|
364
|
+
const oldLeafId = await this.session.getLeafId();
|
|
365
|
+
if (oldLeafId === targetId)
|
|
366
|
+
return { cancelled: false };
|
|
367
|
+
const targetEntry = await this.session.getEntry(targetId);
|
|
368
|
+
if (!targetEntry)
|
|
369
|
+
throw new Error(`Entry ${targetId} not found`);
|
|
370
|
+
const { entries, commonAncestorId } = await collectEntriesForBranchSummary(this.session, oldLeafId, targetId);
|
|
371
|
+
const preparation = {
|
|
372
|
+
targetId,
|
|
373
|
+
oldLeafId,
|
|
374
|
+
commonAncestorId,
|
|
375
|
+
entriesToSummarize: entries,
|
|
376
|
+
userWantsSummary: options?.summarize ?? false,
|
|
377
|
+
customInstructions: options?.customInstructions,
|
|
378
|
+
replaceInstructions: options?.replaceInstructions,
|
|
379
|
+
label: options?.label,
|
|
380
|
+
};
|
|
381
|
+
const signal = new AbortController().signal;
|
|
382
|
+
const hookResult = await this.emitHook("session_before_tree", {
|
|
383
|
+
type: "session_before_tree",
|
|
384
|
+
preparation,
|
|
385
|
+
signal,
|
|
386
|
+
});
|
|
387
|
+
if (hookResult?.cancel)
|
|
388
|
+
return { cancelled: true };
|
|
389
|
+
let summaryEntry;
|
|
390
|
+
let summaryText = hookResult?.summary?.summary;
|
|
391
|
+
let summaryDetails = hookResult?.summary?.details;
|
|
392
|
+
if (!summaryText && options?.summarize && entries.length > 0) {
|
|
393
|
+
const model = this.conversation.model;
|
|
394
|
+
if (!model)
|
|
395
|
+
throw new Error("No model set for branch summary");
|
|
396
|
+
const auth = await this.requestAuth?.(model);
|
|
397
|
+
if (!auth)
|
|
398
|
+
throw new Error("No auth available for branch summary");
|
|
399
|
+
const branchSummary = await generateBranchSummary(entries, {
|
|
400
|
+
model,
|
|
401
|
+
apiKey: auth.apiKey,
|
|
402
|
+
headers: auth.headers,
|
|
403
|
+
signal: new AbortController().signal,
|
|
404
|
+
customInstructions: hookResult?.customInstructions ?? options?.customInstructions,
|
|
405
|
+
replaceInstructions: hookResult?.replaceInstructions ?? options?.replaceInstructions,
|
|
406
|
+
});
|
|
407
|
+
if (branchSummary.aborted)
|
|
408
|
+
return { cancelled: true };
|
|
409
|
+
if (branchSummary.error)
|
|
410
|
+
throw new Error(branchSummary.error);
|
|
411
|
+
summaryText = branchSummary.summary;
|
|
412
|
+
summaryDetails = {
|
|
413
|
+
readFiles: branchSummary.readFiles ?? [],
|
|
414
|
+
modifiedFiles: branchSummary.modifiedFiles ?? [],
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
let editorText;
|
|
418
|
+
let newLeafId;
|
|
419
|
+
if (targetEntry.type === "message" && targetEntry.message.role === "user") {
|
|
420
|
+
newLeafId = targetEntry.parentId;
|
|
421
|
+
const content = targetEntry.message.content;
|
|
422
|
+
editorText =
|
|
423
|
+
typeof content === "string"
|
|
424
|
+
? content
|
|
425
|
+
: content
|
|
426
|
+
.filter((c) => c.type === "text")
|
|
427
|
+
.map((c) => c.text)
|
|
428
|
+
.join("");
|
|
429
|
+
}
|
|
430
|
+
else if (targetEntry.type === "custom_message") {
|
|
431
|
+
newLeafId = targetEntry.parentId;
|
|
432
|
+
editorText =
|
|
433
|
+
typeof targetEntry.content === "string"
|
|
434
|
+
? targetEntry.content
|
|
435
|
+
: targetEntry.content
|
|
436
|
+
.filter((c) => c.type === "text")
|
|
437
|
+
.map((c) => c.text)
|
|
438
|
+
.join("");
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
newLeafId = targetId;
|
|
442
|
+
}
|
|
443
|
+
const summaryId = await this.session.moveTo(newLeafId, summaryText
|
|
444
|
+
? {
|
|
445
|
+
summary: summaryText,
|
|
446
|
+
details: summaryDetails,
|
|
447
|
+
fromHook: hookResult?.summary !== undefined,
|
|
448
|
+
}
|
|
449
|
+
: undefined);
|
|
450
|
+
if (summaryId) {
|
|
451
|
+
summaryEntry = await this.session.getEntry(summaryId);
|
|
452
|
+
}
|
|
453
|
+
await this.syncFromTree();
|
|
454
|
+
await this.emitOwn({
|
|
455
|
+
type: "session_tree",
|
|
456
|
+
newLeafId: await this.session.getLeafId(),
|
|
457
|
+
oldLeafId,
|
|
458
|
+
summaryEntry,
|
|
459
|
+
fromHook: hookResult?.summary !== undefined,
|
|
460
|
+
});
|
|
461
|
+
return { cancelled: false, editorText, summaryEntry };
|
|
462
|
+
}
|
|
463
|
+
async setModel(model) {
|
|
464
|
+
if (this.operation.idle) {
|
|
465
|
+
const previousModel = this.conversation.model;
|
|
466
|
+
this.conversation.model = model;
|
|
467
|
+
this.agent.state.model = model;
|
|
468
|
+
await this.session.appendModelChange(model.provider, model.id);
|
|
469
|
+
await this.emitOwn({ type: "model_select", model, previousModel, source: "set" });
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
this.operation.pendingMutations.model = model;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
async setThinkingLevel(level) {
|
|
476
|
+
if (this.operation.idle) {
|
|
477
|
+
const previousLevel = this.conversation.thinkingLevel;
|
|
478
|
+
this.conversation.thinkingLevel = level;
|
|
479
|
+
this.agent.state.thinkingLevel = level;
|
|
480
|
+
await this.session.appendThinkingLevelChange(level);
|
|
481
|
+
await this.emitOwn({ type: "thinking_level_select", level, previousLevel });
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
this.operation.pendingMutations.thinkingLevel = level;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async setActiveTools(toolNames) {
|
|
488
|
+
if (this.operation.idle) {
|
|
489
|
+
this.conversation.activeToolNames = [...toolNames];
|
|
490
|
+
this.agent.state.tools = this.getActiveTools();
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
this.operation.pendingMutations.activeToolNames = [...toolNames];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async abort() {
|
|
497
|
+
this.operation.abortRequested = true;
|
|
498
|
+
const clearedSteer = [...this.operation.steerQueue];
|
|
499
|
+
const clearedFollowUp = [...this.operation.followUpQueue];
|
|
500
|
+
this.operation.steerQueue = [];
|
|
501
|
+
this.operation.followUpQueue = [];
|
|
502
|
+
this.agent.clearAllQueues();
|
|
503
|
+
await this.emitQueueUpdate();
|
|
504
|
+
this.agent.abort();
|
|
505
|
+
await this.agent.waitForIdle();
|
|
506
|
+
await this.emitOwn({ type: "abort", clearedSteer, clearedFollowUp });
|
|
507
|
+
return { clearedSteer, clearedFollowUp };
|
|
508
|
+
}
|
|
509
|
+
async waitForIdle() {
|
|
510
|
+
await this.agent.waitForIdle();
|
|
511
|
+
}
|
|
512
|
+
subscribe(listener) {
|
|
513
|
+
this.listeners.add(listener);
|
|
514
|
+
return () => this.listeners.delete(listener);
|
|
515
|
+
}
|
|
516
|
+
on(type, handler) {
|
|
517
|
+
let handlers = this.hooks.get(type);
|
|
518
|
+
if (!handlers) {
|
|
519
|
+
handlers = new Set();
|
|
520
|
+
this.hooks.set(type, handlers);
|
|
521
|
+
}
|
|
522
|
+
handlers.add(handler);
|
|
523
|
+
return () => handlers.delete(handler);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
//# sourceMappingURL=agent-harness.js.map
|