dal-code 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/PRIVACY.md +18 -11
- package/dal-docs/extensions.md +16 -4
- package/dist/core/extensions/engine-specifiers.js +1 -0
- package/dist/core/extensions/errors.d.ts +12 -0
- package/dist/core/extensions/errors.js +1 -0
- package/dist/core/extensions/index.d.ts +1 -0
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/runner.d.ts +1 -1
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.js +1 -1
- package/dist/dal/manifest.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/modes/index.d.ts +2 -2
- package/dist/modes/index.js +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +13 -1
- package/dist/modes/rpc/rpc-client.js +3 -3
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +14 -0
- package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-codeindex/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +4 -4
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +5 -5
- package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-router/package.json +6 -5
- package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +1 -0
- package/dist/node_modules/@dalcode/dal-router/src/config.js +2 -2
- package/dist/node_modules/@dalcode/dal-router/src/roles/index.js +7 -7
- package/dist/node_modules/@dalcode/dal-router/src/roles/planner.js +5 -4
- package/dist/node_modules/@dalcode/dal-router/src/roles/prompts.js +21 -12
- package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-sync/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-sync/package.json +35 -0
- package/dist/node_modules/@dalcode/dal-sync/src/client.js +1 -0
- package/dist/node_modules/@dalcode/dal-sync/src/core.js +2 -0
- package/dist/node_modules/@dalcode/dal-sync/src/index.js +4 -0
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +4 -3
- package/dist/node_modules/@dalcode/dal-telemetry/src/config.js +3 -3
- package/dist/node_modules/@dalcode/dal-telemetry/src/failure-queue.js +3 -3
- package/dist/node_modules/@dalcode/dal-telemetry/src/failure-reporting.js +3 -5
- package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +3 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair-hook.js +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/repair.js +2 -2
- package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.d.ts +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/version.js +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/bun/register-bedrock.js +0 -1
- package/dist/cli/experimental/auth.js +0 -1
- package/dist/cli/experimental/cli.js +0 -1
- package/dist/cli/experimental/command-options.js +0 -1
- package/dist/cli/experimental/command.js +0 -1
- package/dist/cli/experimental/commands/client.js +0 -1
- package/dist/cli/experimental/commands/pi.js +0 -1
- package/dist/cli/experimental/commands/server.js +0 -1
- package/dist/cli/experimental/transport-address.js +0 -1
- package/dist/client/index.js +0 -1
- package/dist/client/remote-session.js +0 -1
- package/dist/client/transcript.js +0 -1
- package/dist/core/provider-attribution.js +0 -1
- package/dist/modes/interactive/components/daxnuts.js +0 -1
- package/dist/modes/interactive/theme/theme-json.js +0 -12
- package/dist/modes/interactive/theme/theme-schema.json +0 -356
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +0 -37
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +0 -104
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js +0 -16
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/config.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +0 -10
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/assistant.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/tools.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +0 -17
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bash.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/bounded.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/chord.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/context.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/harness.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/hooks.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/jsonl.js +0 -4
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/collapse.js +0 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/entries.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/frames.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/generation.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/job.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/plugin.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/post-tools.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/task-api.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/kinds/tool.js +0 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/membrane.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/memory.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/scheduler.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/session.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/system.js +0 -8
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/types.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/pico3/view.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js +0 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/boundary.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/checkpoint.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/deferred.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/generation.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/reconcile.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/recovery.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/response.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/retry.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/structural.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/terminal.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tool-placement.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive/tools.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/drive.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/progress.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/restore.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/transcript.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/in-memory-storage-state.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/fork.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/io.js +0 -3
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/legacy-v3.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.js +0 -8
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/datasets.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/session-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/benchmark/storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/session-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance/storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/gating-storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/instrumented-storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/storage-decorator.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/types.js +0 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js +0 -10
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js +0 -2
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.js +0 -12
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit-diff.js +0 -16
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/file-mutation-queue.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/image.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/path-utils.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.js +0 -14
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js +0 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/adaptive-publisher.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.js +0 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.js +0 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/usage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/node.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/index.js +0 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js +0 -74
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-images.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js +0 -1
- package/dist/server/create-harness.js +0 -1
- package/dist/utils/clipboard-native.js +0 -1
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Pi Coding Agent Theme",
|
|
4
|
-
"description": "Theme schema for Pi coding agent",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"required": ["name", "colors"],
|
|
7
|
-
"properties": {
|
|
8
|
-
"$schema": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"description": "JSON schema reference"
|
|
11
|
-
},
|
|
12
|
-
"name": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"pattern": "^[^/]+$",
|
|
15
|
-
"description": "Theme name. Must not contain '/' because it is reserved for automatic light/dark theme settings."
|
|
16
|
-
},
|
|
17
|
-
"vars": {
|
|
18
|
-
"type": "object",
|
|
19
|
-
"description": "Reusable color variables",
|
|
20
|
-
"additionalProperties": {
|
|
21
|
-
"oneOf": [
|
|
22
|
-
{
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "Hex color (#RRGGBB), variable reference, or empty string for terminal default"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"type": "integer",
|
|
28
|
-
"minimum": 0,
|
|
29
|
-
"maximum": 255,
|
|
30
|
-
"description": "256-color palette index (0-255)"
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"colors": {
|
|
36
|
-
"type": "object",
|
|
37
|
-
"description": "Theme color definitions (scrollbar, thinkingMax, and search highlight colors are optional and use compatible fallbacks)",
|
|
38
|
-
"required": [
|
|
39
|
-
"accent",
|
|
40
|
-
"border",
|
|
41
|
-
"borderAccent",
|
|
42
|
-
"borderMuted",
|
|
43
|
-
"success",
|
|
44
|
-
"error",
|
|
45
|
-
"warning",
|
|
46
|
-
"muted",
|
|
47
|
-
"dim",
|
|
48
|
-
"text",
|
|
49
|
-
"thinkingText",
|
|
50
|
-
"selectedBg",
|
|
51
|
-
"userMessageBg",
|
|
52
|
-
"userMessageText",
|
|
53
|
-
"customMessageBg",
|
|
54
|
-
"customMessageText",
|
|
55
|
-
"customMessageLabel",
|
|
56
|
-
"toolPendingBg",
|
|
57
|
-
"toolSuccessBg",
|
|
58
|
-
"toolErrorBg",
|
|
59
|
-
"toolTitle",
|
|
60
|
-
"toolOutput",
|
|
61
|
-
"mdHeading",
|
|
62
|
-
"mdLink",
|
|
63
|
-
"mdLinkUrl",
|
|
64
|
-
"mdCode",
|
|
65
|
-
"mdCodeBlock",
|
|
66
|
-
"mdCodeBlockBorder",
|
|
67
|
-
"mdQuote",
|
|
68
|
-
"mdQuoteBorder",
|
|
69
|
-
"mdHr",
|
|
70
|
-
"mdListBullet",
|
|
71
|
-
"toolDiffAdded",
|
|
72
|
-
"toolDiffRemoved",
|
|
73
|
-
"toolDiffContext",
|
|
74
|
-
"syntaxComment",
|
|
75
|
-
"syntaxKeyword",
|
|
76
|
-
"syntaxFunction",
|
|
77
|
-
"syntaxVariable",
|
|
78
|
-
"syntaxString",
|
|
79
|
-
"syntaxNumber",
|
|
80
|
-
"syntaxType",
|
|
81
|
-
"syntaxOperator",
|
|
82
|
-
"syntaxPunctuation",
|
|
83
|
-
"thinkingOff",
|
|
84
|
-
"thinkingMinimal",
|
|
85
|
-
"thinkingLow",
|
|
86
|
-
"thinkingMedium",
|
|
87
|
-
"thinkingHigh",
|
|
88
|
-
"thinkingXhigh",
|
|
89
|
-
"bashMode"
|
|
90
|
-
],
|
|
91
|
-
"properties": {
|
|
92
|
-
"accent": {
|
|
93
|
-
"$ref": "#/$defs/colorValue",
|
|
94
|
-
"description": "Primary accent color (logo, selected items, cursor)"
|
|
95
|
-
},
|
|
96
|
-
"border": {
|
|
97
|
-
"$ref": "#/$defs/colorValue",
|
|
98
|
-
"description": "Normal borders"
|
|
99
|
-
},
|
|
100
|
-
"borderAccent": {
|
|
101
|
-
"$ref": "#/$defs/colorValue",
|
|
102
|
-
"description": "Highlighted borders"
|
|
103
|
-
},
|
|
104
|
-
"borderMuted": {
|
|
105
|
-
"$ref": "#/$defs/colorValue",
|
|
106
|
-
"description": "Subtle borders"
|
|
107
|
-
},
|
|
108
|
-
"success": {
|
|
109
|
-
"$ref": "#/$defs/colorValue",
|
|
110
|
-
"description": "Success states"
|
|
111
|
-
},
|
|
112
|
-
"error": {
|
|
113
|
-
"$ref": "#/$defs/colorValue",
|
|
114
|
-
"description": "Error states"
|
|
115
|
-
},
|
|
116
|
-
"warning": {
|
|
117
|
-
"$ref": "#/$defs/colorValue",
|
|
118
|
-
"description": "Warning states"
|
|
119
|
-
},
|
|
120
|
-
"muted": {
|
|
121
|
-
"$ref": "#/$defs/colorValue",
|
|
122
|
-
"description": "Secondary/dimmed text"
|
|
123
|
-
},
|
|
124
|
-
"dim": {
|
|
125
|
-
"$ref": "#/$defs/colorValue",
|
|
126
|
-
"description": "Very dimmed text (more subtle than muted)"
|
|
127
|
-
},
|
|
128
|
-
"text": {
|
|
129
|
-
"$ref": "#/$defs/colorValue",
|
|
130
|
-
"description": "Default text color (usually empty string)"
|
|
131
|
-
},
|
|
132
|
-
"thinkingText": {
|
|
133
|
-
"$ref": "#/$defs/colorValue",
|
|
134
|
-
"description": "Thinking block text color"
|
|
135
|
-
},
|
|
136
|
-
"selectedBg": {
|
|
137
|
-
"$ref": "#/$defs/colorValue",
|
|
138
|
-
"description": "Selected item background"
|
|
139
|
-
},
|
|
140
|
-
"scrollbarTrack": {
|
|
141
|
-
"$ref": "#/$defs/colorValue",
|
|
142
|
-
"description": "Fullscreen scrollbar track foreground (falls back to muted when omitted)"
|
|
143
|
-
},
|
|
144
|
-
"scrollbarThumb": {
|
|
145
|
-
"$ref": "#/$defs/colorValue",
|
|
146
|
-
"description": "Fullscreen scrollbar thumb foreground (falls back to text when omitted)"
|
|
147
|
-
},
|
|
148
|
-
"searchMatchBg": {
|
|
149
|
-
"$ref": "#/$defs/colorValue",
|
|
150
|
-
"description": "Transcript search match background and current-match text (falls back to selectedBg when omitted)"
|
|
151
|
-
},
|
|
152
|
-
"searchMatchText": {
|
|
153
|
-
"$ref": "#/$defs/colorValue",
|
|
154
|
-
"description": "Transcript search match text and current-match background (falls back to text when omitted)"
|
|
155
|
-
},
|
|
156
|
-
"userMessageBg": {
|
|
157
|
-
"$ref": "#/$defs/colorValue",
|
|
158
|
-
"description": "User message background"
|
|
159
|
-
},
|
|
160
|
-
"userMessageText": {
|
|
161
|
-
"$ref": "#/$defs/colorValue",
|
|
162
|
-
"description": "User message text color"
|
|
163
|
-
},
|
|
164
|
-
"customMessageBg": {
|
|
165
|
-
"$ref": "#/$defs/colorValue",
|
|
166
|
-
"description": "Custom message background (hook-injected messages)"
|
|
167
|
-
},
|
|
168
|
-
"customMessageText": {
|
|
169
|
-
"$ref": "#/$defs/colorValue",
|
|
170
|
-
"description": "Custom message text color"
|
|
171
|
-
},
|
|
172
|
-
"customMessageLabel": {
|
|
173
|
-
"$ref": "#/$defs/colorValue",
|
|
174
|
-
"description": "Custom message type label color"
|
|
175
|
-
},
|
|
176
|
-
"toolPendingBg": {
|
|
177
|
-
"$ref": "#/$defs/colorValue",
|
|
178
|
-
"description": "Tool execution box (pending state)"
|
|
179
|
-
},
|
|
180
|
-
"toolSuccessBg": {
|
|
181
|
-
"$ref": "#/$defs/colorValue",
|
|
182
|
-
"description": "Tool execution box (success state)"
|
|
183
|
-
},
|
|
184
|
-
"toolErrorBg": {
|
|
185
|
-
"$ref": "#/$defs/colorValue",
|
|
186
|
-
"description": "Tool execution box (error state)"
|
|
187
|
-
},
|
|
188
|
-
"toolTitle": {
|
|
189
|
-
"$ref": "#/$defs/colorValue",
|
|
190
|
-
"description": "Tool execution box title color"
|
|
191
|
-
},
|
|
192
|
-
"toolOutput": {
|
|
193
|
-
"$ref": "#/$defs/colorValue",
|
|
194
|
-
"description": "Tool execution box output text color"
|
|
195
|
-
},
|
|
196
|
-
"mdHeading": {
|
|
197
|
-
"$ref": "#/$defs/colorValue",
|
|
198
|
-
"description": "Markdown heading text"
|
|
199
|
-
},
|
|
200
|
-
"mdLink": {
|
|
201
|
-
"$ref": "#/$defs/colorValue",
|
|
202
|
-
"description": "Markdown link text"
|
|
203
|
-
},
|
|
204
|
-
"mdLinkUrl": {
|
|
205
|
-
"$ref": "#/$defs/colorValue",
|
|
206
|
-
"description": "Markdown link URL"
|
|
207
|
-
},
|
|
208
|
-
"mdCode": {
|
|
209
|
-
"$ref": "#/$defs/colorValue",
|
|
210
|
-
"description": "Markdown inline code"
|
|
211
|
-
},
|
|
212
|
-
"mdCodeBlock": {
|
|
213
|
-
"$ref": "#/$defs/colorValue",
|
|
214
|
-
"description": "Markdown code block content"
|
|
215
|
-
},
|
|
216
|
-
"mdCodeBlockBorder": {
|
|
217
|
-
"$ref": "#/$defs/colorValue",
|
|
218
|
-
"description": "Markdown code block fences"
|
|
219
|
-
},
|
|
220
|
-
"mdQuote": {
|
|
221
|
-
"$ref": "#/$defs/colorValue",
|
|
222
|
-
"description": "Markdown blockquote text"
|
|
223
|
-
},
|
|
224
|
-
"mdQuoteBorder": {
|
|
225
|
-
"$ref": "#/$defs/colorValue",
|
|
226
|
-
"description": "Markdown blockquote border"
|
|
227
|
-
},
|
|
228
|
-
"mdHr": {
|
|
229
|
-
"$ref": "#/$defs/colorValue",
|
|
230
|
-
"description": "Markdown horizontal rule"
|
|
231
|
-
},
|
|
232
|
-
"mdListBullet": {
|
|
233
|
-
"$ref": "#/$defs/colorValue",
|
|
234
|
-
"description": "Markdown list bullets/numbers"
|
|
235
|
-
},
|
|
236
|
-
"toolDiffAdded": {
|
|
237
|
-
"$ref": "#/$defs/colorValue",
|
|
238
|
-
"description": "Added lines in tool diffs"
|
|
239
|
-
},
|
|
240
|
-
"toolDiffRemoved": {
|
|
241
|
-
"$ref": "#/$defs/colorValue",
|
|
242
|
-
"description": "Removed lines in tool diffs"
|
|
243
|
-
},
|
|
244
|
-
"toolDiffContext": {
|
|
245
|
-
"$ref": "#/$defs/colorValue",
|
|
246
|
-
"description": "Context lines in tool diffs"
|
|
247
|
-
},
|
|
248
|
-
"syntaxComment": {
|
|
249
|
-
"$ref": "#/$defs/colorValue",
|
|
250
|
-
"description": "Syntax highlighting: comments"
|
|
251
|
-
},
|
|
252
|
-
"syntaxKeyword": {
|
|
253
|
-
"$ref": "#/$defs/colorValue",
|
|
254
|
-
"description": "Syntax highlighting: keywords"
|
|
255
|
-
},
|
|
256
|
-
"syntaxFunction": {
|
|
257
|
-
"$ref": "#/$defs/colorValue",
|
|
258
|
-
"description": "Syntax highlighting: function names"
|
|
259
|
-
},
|
|
260
|
-
"syntaxVariable": {
|
|
261
|
-
"$ref": "#/$defs/colorValue",
|
|
262
|
-
"description": "Syntax highlighting: variable names"
|
|
263
|
-
},
|
|
264
|
-
"syntaxString": {
|
|
265
|
-
"$ref": "#/$defs/colorValue",
|
|
266
|
-
"description": "Syntax highlighting: string literals"
|
|
267
|
-
},
|
|
268
|
-
"syntaxNumber": {
|
|
269
|
-
"$ref": "#/$defs/colorValue",
|
|
270
|
-
"description": "Syntax highlighting: number literals"
|
|
271
|
-
},
|
|
272
|
-
"syntaxType": {
|
|
273
|
-
"$ref": "#/$defs/colorValue",
|
|
274
|
-
"description": "Syntax highlighting: type names"
|
|
275
|
-
},
|
|
276
|
-
"syntaxOperator": {
|
|
277
|
-
"$ref": "#/$defs/colorValue",
|
|
278
|
-
"description": "Syntax highlighting: operators"
|
|
279
|
-
},
|
|
280
|
-
"syntaxPunctuation": {
|
|
281
|
-
"$ref": "#/$defs/colorValue",
|
|
282
|
-
"description": "Syntax highlighting: punctuation"
|
|
283
|
-
},
|
|
284
|
-
"thinkingOff": {
|
|
285
|
-
"$ref": "#/$defs/colorValue",
|
|
286
|
-
"description": "Thinking level border: off"
|
|
287
|
-
},
|
|
288
|
-
"thinkingMinimal": {
|
|
289
|
-
"$ref": "#/$defs/colorValue",
|
|
290
|
-
"description": "Thinking level border: minimal"
|
|
291
|
-
},
|
|
292
|
-
"thinkingLow": {
|
|
293
|
-
"$ref": "#/$defs/colorValue",
|
|
294
|
-
"description": "Thinking level border: low"
|
|
295
|
-
},
|
|
296
|
-
"thinkingMedium": {
|
|
297
|
-
"$ref": "#/$defs/colorValue",
|
|
298
|
-
"description": "Thinking level border: medium"
|
|
299
|
-
},
|
|
300
|
-
"thinkingHigh": {
|
|
301
|
-
"$ref": "#/$defs/colorValue",
|
|
302
|
-
"description": "Thinking level border: high"
|
|
303
|
-
},
|
|
304
|
-
"thinkingXhigh": {
|
|
305
|
-
"$ref": "#/$defs/colorValue",
|
|
306
|
-
"description": "Thinking level border: xhigh"
|
|
307
|
-
},
|
|
308
|
-
"thinkingMax": {
|
|
309
|
-
"$ref": "#/$defs/colorValue",
|
|
310
|
-
"description": "Thinking level border: max (falls back to thinkingXhigh when omitted)"
|
|
311
|
-
},
|
|
312
|
-
"bashMode": {
|
|
313
|
-
"$ref": "#/$defs/colorValue",
|
|
314
|
-
"description": "Editor border color in bash mode"
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
"additionalProperties": false
|
|
318
|
-
},
|
|
319
|
-
"export": {
|
|
320
|
-
"type": "object",
|
|
321
|
-
"description": "Optional colors for HTML export (defaults derived from userMessageBg if not specified)",
|
|
322
|
-
"properties": {
|
|
323
|
-
"pageBg": {
|
|
324
|
-
"$ref": "#/$defs/colorValue",
|
|
325
|
-
"description": "Page background color"
|
|
326
|
-
},
|
|
327
|
-
"cardBg": {
|
|
328
|
-
"$ref": "#/$defs/colorValue",
|
|
329
|
-
"description": "Card/container background color"
|
|
330
|
-
},
|
|
331
|
-
"infoBg": {
|
|
332
|
-
"$ref": "#/$defs/colorValue",
|
|
333
|
-
"description": "Info sections background (system prompt, notices)"
|
|
334
|
-
}
|
|
335
|
-
},
|
|
336
|
-
"additionalProperties": false
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
"additionalProperties": false,
|
|
340
|
-
"$defs": {
|
|
341
|
-
"colorValue": {
|
|
342
|
-
"oneOf": [
|
|
343
|
-
{
|
|
344
|
-
"type": "string",
|
|
345
|
-
"description": "Hex color (#RRGGBB), variable reference, or empty string for terminal default"
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
"type": "integer",
|
|
349
|
-
"minimum": 0,
|
|
350
|
-
"maximum": 255,
|
|
351
|
-
"description": "256-color palette index (0-255)"
|
|
352
|
-
}
|
|
353
|
-
]
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Closed as r,HarnessClosed as s,HarnessFault as i,InvalidLane as l,InvalidMessage as m,InvalidNavigation as p,LaneBusy as c,NoActiveOperation as g,NoActiveRun as d,NothingToCompact as v,NothingToResume as N,OperationMismatch as k,UnknownSkill as u,UnknownTarget as A,UnknownTemplate as H}from"./result.js";import{SliceNotImplemented as T}from"./runtime/types.js";import{createAgentHarness as e}from"./runtime/harness.js";const o={create:e};export{o as AgentHarness,r as Closed,s as HarnessClosed,i as HarnessFault,l as InvalidLane,m as InvalidMessage,p as InvalidNavigation,c as LaneBusy,g as NoActiveOperation,d as NoActiveRun,v as NothingToCompact,N as NothingToResume,k as OperationMismatch,T as SliceNotImplemented,u as UnknownSkill,A as UnknownTarget,H as UnknownTemplate};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var S=Object.defineProperty;var p=(e,a)=>S(e,"name",{value:a,configurable:!0});import{contentText as F}from"@earendil-works/pi-ai";import{convertToLlm as b,createBranchSummaryMessage as R,createCompactionSummaryMessage as k}from"../messages.js";import{BranchSummaryError as w,err as x,ok as A}from"../types.js";import{completeSimpleWithRetries as T,createSummaryRequestOptions as B,estimateTokens as E,SUMMARIZATION_SYSTEM_PROMPT as P}from"./compaction.js";import{computeFileLists as v,createFileOps as I,extractFileOpsFromMessage as O,formatFileOperations as _,serializeConversation as C}from"./utils.js";async function K(e,a,i,c,r){if(!i)return{entries:[],commonAncestorId:null};const t=new Set((await e.findEntries({start:i},r)).map(n=>n.id)),s=await e.findEntries({start:c},r);let o=null;for(const n of s)if(t.has(n.id)){o=n.id;break}const m=[];let u=i;for(;u&&u!==o;){const n=await a.getEntry(u,r);if(!n)throw new Error(`Corrupt session: entry ${u} not found`);m.push(n),u=n.parentId}return m.reverse(),{entries:m,commonAncestorId:o}}p(K,"collectEntriesForBranchSummary");function W(e){switch(e.type){case"message":return e.message.role==="toolResult"?void 0:e.message;case"branch_summary":return R(e.summary,e.fromId,e.timestamp);case"compaction":return k(e.summary,e.tokensBefore,e.timestamp);case"custom":return}}p(W,"getMessageFromEntry");function N(e,a=0){const i=[],c=I();let r=0;for(const t of e)if(!(t.type!=="branch_summary"||typeof t.details!="object"||t.details===null||Array.isArray(t.details))){if(Array.isArray(t.details.readFiles))for(const s of t.details.readFiles)typeof s=="string"&&c.read.add(s);if(Array.isArray(t.details.modifiedFiles))for(const s of t.details.modifiedFiles)typeof s=="string"&&c.edited.add(s)}for(let t=e.length-1;t>=0;t--){const s=e[t],o=W(s);if(!o)continue;O(o,c);const m=E(o);if(a>0&&r+m>a){(s.type==="compaction"||s.type==="branch_summary")&&r<a*.9&&(i.unshift(o),r+=m);break}i.unshift(o),r+=m}return{messages:i,fileOps:c,totalTokens:r}}p(N,"prepareBranchEntries");const $=`The user explored a different conversation branch before returning here.
|
|
2
|
-
Summary of that exploration:
|
|
3
|
-
|
|
4
|
-
`,M=`Create a structured summary of this conversation branch for context when returning later.
|
|
5
|
-
|
|
6
|
-
Use this EXACT format:
|
|
7
|
-
|
|
8
|
-
## Goal
|
|
9
|
-
[What was the user trying to accomplish in this branch?]
|
|
10
|
-
|
|
11
|
-
## Constraints & Preferences
|
|
12
|
-
- [Any constraints, preferences, or requirements mentioned]
|
|
13
|
-
- [Or "(none)" if none were mentioned]
|
|
14
|
-
|
|
15
|
-
## Progress
|
|
16
|
-
### Done
|
|
17
|
-
- [x] [Completed tasks/changes]
|
|
18
|
-
|
|
19
|
-
### In Progress
|
|
20
|
-
- [ ] [Work that was started but not finished]
|
|
21
|
-
|
|
22
|
-
### Blocked
|
|
23
|
-
- [Issues preventing progress, if any]
|
|
24
|
-
|
|
25
|
-
## Key Decisions
|
|
26
|
-
- **[Decision]**: [Brief rationale]
|
|
27
|
-
|
|
28
|
-
## Next Steps
|
|
29
|
-
1. [What should happen next to continue this work]
|
|
30
|
-
|
|
31
|
-
Keep each section concise. Preserve exact file paths, function names, and error messages.`;function j(e,a,i){const{models:c,model:r,customInstructions:t,replaceInstructions:s,reserveTokens:o=16384,retry:m,callbacks:u}=a,n=r.contextWindow||128e3,h=N(e,n-o);return U(h,{customInstructions:t,replaceInstructions:s},(d,f,l)=>T(c,r,d,f,m,u,l),i)}p(j,"generateBranchSummary");async function U(e,a,i,c){const{customInstructions:r,replaceInstructions:t}=a,{messages:s,fileOps:o}=e;if(s.length===0)return A({summary:"No content to summarize",readFiles:[],modifiedFiles:[]});const m=b(s),u=C(m);let n;t&&r?n=r:r?n=`${M}
|
|
32
|
-
|
|
33
|
-
Additional focus: ${r}`:n=M;const d=[{role:"user",content:[{type:"text",text:`<conversation>
|
|
34
|
-
${u}
|
|
35
|
-
</conversation>
|
|
36
|
-
|
|
37
|
-
${n}`}],timestamp:Date.now()}],f=await i({systemPrompt:P,messages:d},B({maxTokens:2048},c),c);if(f.stopReason==="aborted")return x(new w("aborted",f.errorMessage||"Branch summary aborted"));if(f.stopReason==="error")return x(new w("summarization_failed",`Branch summary failed: ${f.errorMessage||"Unknown error"}`));let l=F(f.content);l=$+l;const{readFiles:y,modifiedFiles:g}=v(o);return l+=_(y,g),A({summary:l||"No summary generated",usage:f.usage,readFiles:y,modifiedFiles:g})}p(U,"generateBranchSummaryWithRequest");export{K as collectEntriesForBranchSummary,j as generateBranchSummary,U as generateBranchSummaryWithRequest,N as prepareBranchEntries};
|
package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
var K=Object.defineProperty;var m=(e,t)=>K(e,"name",{value:t,configurable:!0});import{contentText as E,retryAssistantCall as B,uuidv7 as L}from"@earendil-works/pi-ai";import{getTelemetryContext as W}from"../context.js";import{convertToLlm as O,createBranchSummaryMessage as q,createCompactionSummaryMessage as Y}from"../messages.js";import{buildContextEntries as V,sessionEntryToContextMessages as X}from"../session/context.js";import{CompactionError as b,err as x,ok as k}from"../types.js";import{addUsage as G}from"../utils/usage.js";import{computeFileLists as Z,createFileOps as J,extractFileOpsFromMessage as U,formatFileOperations as j,serializeConversation as F}from"./utils.js";function H(e){try{return JSON.stringify(e)??"undefined"}catch{return"[unserializable]"}}m(H,"safeJsonStringify");function Q(e,t,r){const s=J();if(r>=0){const n=t[r];if(typeof n.details=="object"&&n.details!==null&&!Array.isArray(n.details)){if(Array.isArray(n.details.readFiles))for(const o of n.details.readFiles)typeof o=="string"&&s.read.add(o);if(Array.isArray(n.details.modifiedFiles))for(const o of n.details.modifiedFiles)typeof o=="string"&&s.edited.add(o)}}for(const n of e)U(n,s);return s}m(Q,"extractFileOperations");function ee(e){if(e.type==="message")return e.message;if(e.type==="branch_summary")return q(e.summary,e.fromId,e.timestamp);if(e.type==="compaction")return Y(e.summary,e.tokensBefore,e.timestamp)}m(ee,"getMessageFromEntry");function P(e){if(e.type!=="compaction")return ee(e)}m(P,"getMessageFromEntryForCompaction");function w(e,t){return{...e,signal:t.abortSignal,telemetryContext:W(t),cacheRetention:"none",sessionId:e.sessionId??L()}}m(w,"createSummaryRequestOptions");async function N(e,t,r,s,n,o,c){const i=w(s,c);return B(()=>e.completeSimple(t,r,i),n,i.signal,o)}m(N,"completeSimpleWithRetries");const Se={enabled:!0,reserveTokens:16384,keepRecentTokens:2e4};function _(e){return e.totalTokens||e.input+e.output+e.cacheRead+e.cacheWrite}m(_,"calculateContextTokens");function D(e){if(e.role==="assistant"&&"usage"in e){const t=e;if(t.stopReason!=="aborted"&&t.stopReason!=="error"&&t.usage&&_(t.usage)>0)return t.usage}}m(D,"getAssistantUsage");function Ie(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r.type==="message"){const s=D(r.message);if(s)return s}}}m(Ie,"getLastAssistantUsage");function te(e){for(let t=e.length-1;t>=0;t--){const r=D(e[t]);if(r)return{usage:r,index:t}}}m(te,"getLastAssistantUsageInfo");function ne(e){const t=te(e);if(!t){let n=0;for(const o of e)n+=C(o);return{tokens:n,usageTokens:0,trailingTokens:n,lastUsageIndex:null}}const r=_(t.usage);let s=0;for(let n=t.index+1;n<e.length;n++)s+=C(e[n]);return{tokens:r+s,usageTokens:r,trailingTokens:s,lastUsageIndex:t.index}}m(ne,"estimateContextTokens");function be(e,t,r){return r.enabled?e>t-r.reserveTokens:!1}m(be,"shouldCompact");const se=4800;function z(e){if(typeof e=="string")return e.length;let t=0;for(const r of e)r.type==="text"&&r.text?t+=r.text.length:r.type==="image"&&(t+=se);return t}m(z,"estimateTextAndImageContentChars");function C(e){let t=0;switch(e.role){case"user":return t=z(e.content),Math.ceil(t/4);case"assistant":{const r=e;for(const s of r.content)s.type==="text"?t+=s.text.length:s.type==="thinking"?t+=s.thinking.length:s.type==="toolCall"&&(t+=s.name.length+H(s.arguments).length);return Math.ceil(t/4)}case"custom":case"toolResult":return t=z(e.content),Math.ceil(t/4);case"bashExecution":return t=e.command.length+e.output.length,Math.ceil(t/4);case"branchSummary":case"compactionSummary":return t=e.summary.length,Math.ceil(t/4)}return 0}m(C,"estimateTokens");function re(e,t,r){const s=[];for(let n=t;n<r;n++){const o=e[n];switch(o.type){case"message":{switch(o.message.role){case"bashExecution":case"custom":case"branchSummary":case"compactionSummary":case"user":case"assistant":s.push(n);break;case"toolResult":break}break}case"compaction":case"branch_summary":case"custom":break}o.type==="branch_summary"&&s.push(n)}return s}m(re,"findValidCutPoints");function oe(e,t,r){for(let s=t;s>=r;s--){const n=e[s];if(n.type==="branch_summary")return s;if(n.type==="message"){const o=n.message.role;if(o==="user"||o==="bashExecution")return s}}return-1}m(oe,"findTurnStartIndex");function ae(e,t,r,s){const n=re(e,t,r);if(n.length===0)return{firstKeptEntryIndex:t,turnStartIndex:-1,isSplitTurn:!1};let o=0,c=n[0];for(let u=r-1;u>=t;u--){const h=e[u];if(h.type!=="message")continue;const p=C(h.message);if(o+=p,o>=s){for(let a=0;a<n.length;a++)if(n[a]>=u){c=n[a];break}break}}for(;c>t;){const u=e[c-1];if(u.type==="compaction"||u.type==="message")break;c--}const i=e[c],l=i.type==="message"&&i.message.role==="user",f=l?-1:oe(e,c,t);return{firstKeptEntryIndex:c,turnStartIndex:f,isSplitTurn:!l&&f!==-1}}m(ae,"findCutPoint");const $=`You are a context summarization assistant. Your task is to read a conversation between a user and an AI assistant, then produce a structured summary following the exact format specified.
|
|
2
|
-
|
|
3
|
-
Do NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`,ie=`The messages above are a conversation to summarize. Create a structured context checkpoint summary that another LLM will use to continue the work.
|
|
4
|
-
|
|
5
|
-
Use this EXACT format:
|
|
6
|
-
|
|
7
|
-
## Goal
|
|
8
|
-
[What is the user trying to accomplish? Can be multiple items if the session covers different tasks.]
|
|
9
|
-
|
|
10
|
-
## Constraints & Preferences
|
|
11
|
-
- [Any constraints, preferences, or requirements mentioned by user]
|
|
12
|
-
- [Or "(none)" if none were mentioned]
|
|
13
|
-
|
|
14
|
-
## Progress
|
|
15
|
-
### Done
|
|
16
|
-
- [x] [Completed tasks/changes]
|
|
17
|
-
|
|
18
|
-
### In Progress
|
|
19
|
-
- [ ] [Current work]
|
|
20
|
-
|
|
21
|
-
### Blocked
|
|
22
|
-
- [Issues preventing progress, if any]
|
|
23
|
-
|
|
24
|
-
## Key Decisions
|
|
25
|
-
- **[Decision]**: [Brief rationale]
|
|
26
|
-
|
|
27
|
-
## Next Steps
|
|
28
|
-
1. [Ordered list of what should happen next]
|
|
29
|
-
|
|
30
|
-
## Critical Context
|
|
31
|
-
- [Any data, examples, or references needed to continue]
|
|
32
|
-
- [Or "(none)" if not applicable]
|
|
33
|
-
|
|
34
|
-
Keep each section concise. Preserve exact file paths, function names, and error messages.`,ce=`The messages above are NEW conversation messages to incorporate into the existing summary provided in <previous-summary> tags.
|
|
35
|
-
|
|
36
|
-
Update the existing structured summary with new information. RULES:
|
|
37
|
-
- PRESERVE all existing information from the previous summary
|
|
38
|
-
- ADD new progress, decisions, and context from the new messages
|
|
39
|
-
- UPDATE the Progress section: move items from "In Progress" to "Done" when completed
|
|
40
|
-
- UPDATE "Next Steps" based on what was accomplished
|
|
41
|
-
- PRESERVE exact file paths, function names, and error messages
|
|
42
|
-
- If something is no longer relevant, you may remove it
|
|
43
|
-
|
|
44
|
-
Use this EXACT format:
|
|
45
|
-
|
|
46
|
-
## Goal
|
|
47
|
-
[Preserve existing goals, add new ones if the task expanded]
|
|
48
|
-
|
|
49
|
-
## Constraints & Preferences
|
|
50
|
-
- [Preserve existing, add new ones discovered]
|
|
51
|
-
|
|
52
|
-
## Progress
|
|
53
|
-
### Done
|
|
54
|
-
- [x] [Include previously done items AND newly completed items]
|
|
55
|
-
|
|
56
|
-
### In Progress
|
|
57
|
-
- [ ] [Current work - update based on progress]
|
|
58
|
-
|
|
59
|
-
### Blocked
|
|
60
|
-
- [Current blockers - remove if resolved]
|
|
61
|
-
|
|
62
|
-
## Key Decisions
|
|
63
|
-
- **[Decision]**: [Brief rationale] (preserve all previous, add new)
|
|
64
|
-
|
|
65
|
-
## Next Steps
|
|
66
|
-
1. [Update based on current state]
|
|
67
|
-
|
|
68
|
-
## Critical Context
|
|
69
|
-
- [Preserve important context, add new if needed]
|
|
70
|
-
|
|
71
|
-
Keep each section concise. Preserve exact file paths, function names, and error messages.`;async function Me(e,t,r,s,n,o,c,i,l,f){const u=await ue(e,t,r,s,n,o,c,i,l,f);return u.ok?k(u.value.text):x(u.error)}m(Me,"generateSummary");function ue(e,t,r,s,n,o,c,i,l,f){return R(e,{model:r,reserveTokens:s,customInstructions:n,previousSummary:o,thinkingLevel:c},(u,h,p)=>N(t,r,u,h,i,l,p),f)}m(ue,"generateSummaryWithUsage");async function R(e,t,r,s){const{model:n,reserveTokens:o,customInstructions:c,previousSummary:i,thinkingLevel:l}=t,f=Math.min(Math.floor(.8*o),n.maxTokens>0?n.maxTokens:Number.POSITIVE_INFINITY);let u=i?ce:ie;c&&(u=`${u}
|
|
72
|
-
|
|
73
|
-
Additional focus: ${c}`);const h=O(e);let a=`<conversation>
|
|
74
|
-
${F(h)}
|
|
75
|
-
</conversation>
|
|
76
|
-
|
|
77
|
-
`;i&&(a+=`<previous-summary>
|
|
78
|
-
${i}
|
|
79
|
-
</previous-summary>
|
|
80
|
-
|
|
81
|
-
`),a+=u;const d=[{role:"user",content:[{type:"text",text:a}],timestamp:Date.now()}],y=n.reasoning&&l&&l!=="off"?{maxTokens:f,reasoning:l}:{maxTokens:f},g=await r({systemPrompt:$,messages:d},w(y,s),s);if(g.stopReason==="aborted")return x(new b("aborted",g.errorMessage||"Summarization aborted"));if(g.stopReason==="error")return x(new b("summarization_failed",`Summarization failed: ${g.errorMessage||"Unknown error"}`));const S=E(g.content);return k({text:S,usage:g.usage})}m(R,"generateSummaryWithRequest");function Pe(e,t){if(e.length===0||e[e.length-1].type==="compaction")return k(void 0);let r=-1;for(let a=e.length-1;a>=0;a--)if(e[a].type==="compaction"){r=a;break}let s,n=e;if(r>=0){const a=e[r];s=a.summary,n=[...a.retainedTail.map((y,g)=>({type:"message",id:`${a.id}:retained:${g}`,parentId:g===0?a.id:`${a.id}:retained:${g-1}`,seq:a.seq,timestamp:y.timestamp,message:y})),...e.slice(r+1)]}const o=n.length,c=ne(V(e).flatMap(X)).tokens,i=ae(n,0,o,t.keepRecentTokens),l=i.isSplitTurn?i.turnStartIndex:i.firstKeptEntryIndex,f=[];for(let a=0;a<l;a++){const d=P(n[a]);d&&f.push(d)}const u=[];if(i.isSplitTurn)for(let a=i.turnStartIndex;a<i.firstKeptEntryIndex;a++){const d=P(n[a]);d&&u.push(d)}const h=[];for(let a=i.firstKeptEntryIndex;a<o;a++){const d=P(n[a]);d&&h.push(d)}const p=Q(f,e,r);if(i.isSplitTurn)for(const a of u)U(a,p);return k({messagesToSummarize:f,turnPrefixMessages:u,retainedTail:h,isSplitTurn:i.isSplitTurn,tokensBefore:c,previousSummary:s,fileOps:p,settings:t})}m(Pe,"prepareCompaction");const me=`This is the PREFIX of a turn that was too large to keep. The SUFFIX (recent work) is retained.
|
|
82
|
-
|
|
83
|
-
Summarize the prefix to provide context for the retained suffix:
|
|
84
|
-
|
|
85
|
-
## Original Request
|
|
86
|
-
[What did the user ask for in this turn?]
|
|
87
|
-
|
|
88
|
-
## Early Progress
|
|
89
|
-
- [Key decisions and work done in the prefix]
|
|
90
|
-
|
|
91
|
-
## Context for Suffix
|
|
92
|
-
- [Information needed to understand the retained recent work]
|
|
93
|
-
|
|
94
|
-
Be concise. Focus on what's needed to understand the kept suffix.`;import{serializeConversation as Ae}from"./utils.js";function we(e,t,r,s,n,o,c,i){return le(e,{model:r,customInstructions:s,thinkingLevel:n},(l,f,u)=>N(t,r,l,f,o,c,u),i)}m(we,"compact");async function le(e,t,r,s){const{model:n,customInstructions:o,thinkingLevel:c}=t,{messagesToSummarize:i,turnPrefixMessages:l,retainedTail:f,isSplitTurn:u,tokensBefore:h,previousSummary:p,fileOps:a,settings:d}=e;let y,g;if(u&&l.length>0){let T="No prior history.",M;if(i.length>0){const I=await R(i,{model:n,reserveTokens:d.reserveTokens,customInstructions:o,previousSummary:p,thinkingLevel:c},r,s);if(!I.ok)return x(I.error);T=I.value.text,M=I.value.usage}const v=await fe(l,n,d.reserveTokens,c,r,s);if(!v.ok)return x(v.error);y=`${T}
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
**Turn Context (split turn):**
|
|
99
|
-
|
|
100
|
-
${v.value.text}`,g=M?G(M,v.value.usage):v.value.usage}else{const T=await R(i,{model:n,reserveTokens:d.reserveTokens,customInstructions:o,previousSummary:p,thinkingLevel:c},r,s);if(!T.ok)return x(T.error);y=T.value.text,g=T.value.usage}const{readFiles:S,modifiedFiles:A}=Z(a);return y+=j(S,A),k({summary:y,tokensBefore:h,usage:g,retainedTail:f,details:{readFiles:S,modifiedFiles:A}})}m(le,"compactWithRequest");async function fe(e,t,r,s,n,o){const c=Math.min(Math.floor(.5*r),t.maxTokens>0?t.maxTokens:Number.POSITIVE_INFINITY),i=O(e),u=[{role:"user",content:[{type:"text",text:`<conversation>
|
|
101
|
-
${F(i)}
|
|
102
|
-
</conversation>
|
|
103
|
-
|
|
104
|
-
${me}`}],timestamp:Date.now()}],h=t.reasoning&&s&&s!=="off"?{maxTokens:c,reasoning:s}:{maxTokens:c},p=await n({systemPrompt:$,messages:u},w(h,o),o);return p.stopReason==="aborted"?x(new b("aborted",p.errorMessage||"Turn prefix summarization aborted")):p.stopReason==="error"?x(new b("summarization_failed",`Turn prefix summarization failed: ${p.errorMessage||"Unknown error"}`)):k({text:E(p.content),usage:p.usage})}m(fe,"generateTurnPrefixSummary");export{Se as DEFAULT_COMPACTION_SETTINGS,$ as SUMMARIZATION_SYSTEM_PROMPT,_ as calculateContextTokens,we as compact,le as compactWithRequest,N as completeSimpleWithRetries,w as createSummaryRequestOptions,ne as estimateContextTokens,C as estimateTokens,ae as findCutPoint,oe as findTurnStartIndex,Me as generateSummary,R as generateSummaryWithRequest,ue as generateSummaryWithUsage,Ie as getLastAssistantUsage,Pe as prepareCompaction,Ae as serializeConversation,be as shouldCompact};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var r=(t,e)=>d(t,"name",{value:e,configurable:!0});import{contentText as c}from"@earendil-works/pi-ai";function $(){return{read:new Set,written:new Set,edited:new Set}}r($,"createFileOps");function S(t,e){if(t.role==="assistant"&&!(!("content"in t)||!Array.isArray(t.content)))for(const n of t.content){if(typeof n!="object"||n===null||!("type"in n)||n.type!=="toolCall"||!("arguments"in n)||!("name"in n))continue;const o=n.arguments;if(!o)continue;const i=typeof o.path=="string"?o.path:void 0;if(i)switch(n.name){case"read":e.read.add(i);break;case"write":e.written.add(i);break;case"edit":e.edited.add(i);break}}}r(S,"extractFileOpsFromMessage");function j(t){const e=new Set([...t.edited,...t.written]),n=[...t.read].filter(i=>!e.has(i)).sort(),o=[...e].sort();return{readFiles:n,modifiedFiles:o}}r(j,"computeFileLists");function k(t,e){const n=[];return t.length>0&&n.push(`<read-files>
|
|
2
|
-
${t.join(`
|
|
3
|
-
`)}
|
|
4
|
-
</read-files>`),e.length>0&&n.push(`<modified-files>
|
|
5
|
-
${e.join(`
|
|
6
|
-
`)}
|
|
7
|
-
</modified-files>`),n.length===0?"":`
|
|
8
|
-
|
|
9
|
-
${n.join(`
|
|
10
|
-
|
|
11
|
-
`)}`}r(k,"formatFileOperations");const p=2e3;function h(t){try{return JSON.stringify(t)??"undefined"}catch{return"[unserializable]"}}r(h,"safeJsonStringify");function g(t,e){if(t.length<=e)return t;const n=t.length-e;return`${t.slice(0,e)}
|
|
12
|
-
|
|
13
|
-
[... ${n} more characters truncated]`}r(g,"truncateForSummary");function w(t){const e=[];for(const n of t)if(n.role==="user"){const o=c(n.content,"");o&&e.push(`[User]: ${o}`)}else if(n.role==="assistant"){const o=[],i=[];for(const s of n.content)if(s.type==="thinking")o.push(s.thinking);else if(s.type==="toolCall"){const a=s.arguments,f=Object.entries(a).map(([u,l])=>`${u}=${h(l)}`).join(", ");i.push(`${s.name}(${f})`)}o.length>0&&e.push(`[Assistant thinking]: ${o.join(`
|
|
14
|
-
`)}`),n.content.some(s=>s.type==="text")&&e.push(`[Assistant]: ${c(n.content)}`),i.length>0&&e.push(`[Assistant tool calls]: ${i.join("; ")}`)}else if(n.role==="toolResult"){const o=c(n.content,"");o&&e.push(`[Tool result]: ${g(o,p)}`)}return e.join(`
|
|
15
|
-
|
|
16
|
-
`)}r(w,"serializeConversation");export{j as computeFileLists,$ as createFileOps,S as extractFileOpsFromMessage,k as formatFileOperations,w as serializeConversation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var r=Object.defineProperty;var a=(e,n)=>r(e,"name",{value:n,configurable:!0});import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS as s}from"@earendil-works/pi-ai";const m={enabled:!0,maxRetries:3,baseDelayMs:1e3,maxAgentDelayMs:s};function f(e){const n=new Set;for(const t of e){if(n.has(t.name))throw new TypeError(`Duplicate tool name: ${JSON.stringify(t.name)}`);n.add(t.name)}}a(f,"validateToolNames");function u(e){if(!Number.isSafeInteger(e.maxRetries)||e.maxRetries<0||e.maxRetries===Number.MAX_SAFE_INTEGER||!Number.isSafeInteger(e.baseDelayMs)||e.baseDelayMs<0||e.maxAgentDelayMs!==void 0&&(!Number.isSafeInteger(e.maxAgentDelayMs)||e.maxAgentDelayMs<0))throw new RangeError("Retry policy values must be finite non-negative safe integers")}a(u,"validateRetryPolicy");function R(e){if(!Number.isSafeInteger(e.reserveTokens)||e.reserveTokens<0||!Number.isSafeInteger(e.keepRecentTokens)||e.keepRecentTokens<0)throw new RangeError("Compaction token counts must be finite non-negative safe integers")}a(R,"validateCompactionSettings");export{m as DEFAULT_RETRY_POLICY,R as validateCompactionSettings,u as validateRetryPolicy,f as validateToolNames};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var o=(t,e)=>i(t,"name",{value:e,configurable:!0});import{awaitWithContext as C,BACKGROUND_CONTEXT as E,createContextKey as r,TODO_CONTEXT as x,withAbortSignal as O,withCancel as a,withContextValue as n,withoutAbortSignal as l}from"@earendil-works/chord/context";import{NOOP_TELEMETRY_CONTEXT as m}from"@earendil-works/pi-telemetry";const T=r("pi.telemetryContext");function w(t){return t.value(T)??m}o(w,"getTelemetryContext");function N(t,e){return n(T,t,e)}o(N,"withTelemetryContext");export{E as BACKGROUND_CONTEXT,x as TODO_CONTEXT,C as awaitWithContext,r as createContextKey,w as getTelemetryContext,O as withAbortSignal,a as withCancel,n as withContextValue,N as withTelemetryContext,l as withoutAbortSignal};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var de=Object.defineProperty;var o=(i,r)=>de(i,"name",{value:r,configurable:!0});import{spawn as z}from"node:child_process";import{randomUUID as le}from"node:crypto";import{constants as Y,createWriteStream as fe}from"node:fs";import{access as J,appendFile as he,lstat as Z,mkdir as H,mkdtemp as me,open as we,readdir as pe,readFile as ee,realpath as be,rename as ye,rm as ge,writeFile as te}from"node:fs/promises";import{homedir as re,constants as ve,tmpdir as Se}from"node:os";import{basename as Ee,isAbsolute as xe,join as $,resolve as B}from"node:path";import{fileURLToPath as Te}from"node:url";import{ExecutionError as y,err as u,FileError as T,ok as d,toError as D}from"../types.js";import{OutputCapture as Pe}from"../utils/output-capture.js";const ne=2147483647,Le=ne/1e3,_e=100,ke=8*1024*1024;function Fe(i){if(i===void 0)return d(void 0);if(!Number.isFinite(i)||i<=0)return u(new y("timeout","Invalid timeout: must be a finite number of seconds"));const r=i*1e3;return r>ne?u(new y("timeout",`Invalid timeout: maximum is ${Le} seconds`)):d(r)}o(Fe,"resolveTimeoutMs");function b(i,r){let e=r;if(e==="~")e=re();else if(e.startsWith("~/")||process.platform==="win32"&&e.startsWith("~\\"))e=$(re(),e.slice(2));else if(e.startsWith("file://"))try{e=Te(e)}catch{}return xe(e)?B(e):B(i,e)}o(b,"resolvePath");function Ce(i){if(i.isFile())return"file";if(i.isDirectory())return"directory";if(i.isSymbolicLink())return"symlink"}o(Ce,"fileKindFromStats");function ie(i,r){const e=Ce(r);return e?d({name:Ee(i),path:i,kind:e,size:r.size,mtimeMs:r.mtimeMs}):u(new T("invalid","Unsupported file type",i))}o(ie,"fileInfoFromStats");function Ie(i){return i instanceof Error&&"code"in i}o(Ie,"isNodeError");function p(i,r){if(i instanceof T)return i;const e=D(i),n=Ie(i)?i:void 0,t=typeof n?.path=="string"?n.path:r;if(n){const s=n.message;switch(n.code){case"ABORT_ERR":return new T("aborted",s,t,e);case"ENOENT":return new T("not_found",s,t,e);case"EACCES":case"EPERM":return new T("permission_denied",s,t,e);case"ENOTDIR":return new T("not_directory",s,t,e);case"EISDIR":return new T("is_directory",s,t,e);case"EINVAL":return new T("invalid",s,t,e)}}return new T("unknown",e.message,t,e)}o(p,"toFileError");function m(i,r){return i?.aborted?u(new T("aborted","aborted",r)):void 0}o(m,"abortResult");async function W(i){try{return await J(i,Y.F_OK),!0}catch{return!1}}o(W,"pathExists");async function se(i,r,e){return await new Promise(n=>{let t="",s;try{s=z(i,r,{stdio:["ignore","pipe","ignore"],windowsHide:!0})}catch{n({stdout:"",status:null});return}const a=setTimeout(()=>{s.pid&&K(s.pid)},e);s.stdout?.setEncoding("utf8"),s.stdout?.on("data",l=>{t+=l}),s.on("error",()=>{clearTimeout(a),n({stdout:"",status:null})}),s.on("close",l=>{clearTimeout(a),n({stdout:t,status:l})})})}o(se,"runCommand");async function ae(){const i=process.platform==="win32"?await se("where",["bash.exe"],5e3):await se("which",["bash"],5e3);if(i.status!==0||!i.stdout)return null;const r=i.stdout.trim().split(/\r?\n/)[0];return r&&await W(r)?r:null}o(ae,"findBashOnPath");function Ae(i){const r=i.replace(/\//g,"\\").toLowerCase();return/^[a-z]:\\windows\\(?:system32|sysnative)\\bash\.exe$/.test(r)}o(Ae,"isLegacyWslBashPath");function N(i){return Ae(i)?{shell:i,args:["-s"],commandTransport:"stdin"}:{shell:i,args:["-c"]}}o(N,"getBashShellConfig");async function Oe(i){if(i)return await W(i)?d(N(i)):u(new y("shell_unavailable",`Custom shell path not found: ${i}`));if(process.platform==="win32"){const e=[],n=process.env.ProgramFiles;n&&e.push(`${n}\\Git\\bin\\bash.exe`);const t=process.env["ProgramFiles(x86)"];t&&e.push(`${t}\\Git\\bin\\bash.exe`);for(const a of e)if(await W(a))return d(N(a));const s=await ae();return s?d(N(s)):u(new y("shell_unavailable",`No bash shell found. Options:
|
|
2
|
-
1. Install Git for Windows: https://git-scm.com/download/win
|
|
3
|
-
2. Add your bash to PATH (Cygwin, MSYS2, etc.)
|
|
4
|
-
3. Configure an explicit shellPath
|
|
5
|
-
|
|
6
|
-
Searched Git Bash in:
|
|
7
|
-
${e.map(a=>` ${a}`).join(`
|
|
8
|
-
`)}`))}if(await W("/bin/bash"))return d(N("/bin/bash"));const r=await ae();return r?d(N(r)):d({shell:"sh",args:["-c"]})}o(Oe,"getShellConfig");function Me(i,r,e=!0){return e?{...process.env,...i,...r}:{...r}}o(Me,"getShellEnv");function K(i){if(process.platform==="win32"){try{z($(process.env.SystemRoot??"C:\\Windows","System32","taskkill.exe"),["/F","/T","/PID",String(i)],{stdio:"ignore",detached:!0,windowsHide:!0}).once("error",()=>{})}catch{}return}try{process.kill(-i,"SIGKILL")}catch{try{process.kill(i,"SIGKILL")}catch{}}}o(K,"killProcessTree");function Re(i,r){return new Promise((e,n)=>{let t=!1,s=!1,a=null,l=null,w,P=i.stdout===null,v=i.stderr===null;const S=o(()=>{w&&clearTimeout(w),i.removeListener("error",R),i.removeListener("exit",A),i.removeListener("close",x),i.stdout?.removeListener("end",M),i.stderr?.removeListener("end",I),i.stdout?.removeListener("data",C),i.stderr?.removeListener("data",C)},"cleanup"),_=o(()=>{t||(t=!0,S(),i.stdout?.destroy(),i.stderr?.destroy(),e({code:a,signal:l}))},"finalize"),E=o(()=>{s&&P&&v&&_()},"maybeFinalizeAfterExit"),h=o(()=>{w&&clearTimeout(w),w=setTimeout(()=>{r()?h():_()},_e)},"armIdleTimer"),C=o(()=>{s&&!t&&h()},"onData"),M=o(()=>{P=!0,E()},"onStdoutEnd"),I=o(()=>{v=!0,E()},"onStderrEnd"),R=o(g=>{t||(t=!0,S(),n(g))},"onError"),A=o((g,L)=>{s=!0,a=g,l=L,E(),t||h()},"onExit"),x=o((g,L)=>{a=g,l=L,_()},"onClose");i.stdout?.once("end",M),i.stderr?.once("end",I),i.stdout?.on("data",C),i.stderr?.on("data",C),i.once("error",R),i.once("exit",A),i.once("close",x)})}o(Re,"waitForChildProcess");class De{static{o(this,"NodeTextLineReader")}file;path;decoder=new TextDecoder;chunk=new Uint8Array(64*1024);byteOffset=0;buffered="";ended=!1;closed=!1;constructor(r,e){this.file=r,this.path=e}async readLine(r){const e=m(r.abortSignal,this.path);if(e)return e;if(this.closed)return u(new T("invalid","Text line reader is closed",this.path));try{for(;;){const n=this.buffered.indexOf(`
|
|
9
|
-
`);if(n!==-1){const a=this.buffered.slice(0,n);return this.buffered=this.buffered.slice(n+1),d({text:a,terminated:!0})}if(this.ended){if(this.buffered.length===0)return d(void 0);const a=this.buffered;return this.buffered="",d({text:a,terminated:!1})}const{bytesRead:t}=await this.file.read(this.chunk,0,this.chunk.length,this.byteOffset),s=m(r.abortSignal,this.path);if(s)return s;this.byteOffset+=t,t===0?(this.buffered+=this.decoder.decode(),this.ended=!0):this.buffered+=this.decoder.decode(this.chunk.subarray(0,t),{stream:!0})}}catch(n){return u(p(n,this.path))}}async close(r){if(!this.closed){this.closed=!0,this.buffered="";try{await this.file.close()}catch{}}}}class je{static{o(this,"NodeExecutionEnv")}cwd;shellPath;shellEnv;activeChildPids=new Set;constructor(r){this.cwd=r.cwd,this.shellPath=r.shellPath,this.shellEnv=r.shellEnv}async absolutePath(r,e){return d(b(this.cwd,r))}async joinPath(r,e){return d($(...r))}async exec(r,e,n){const t=n.abortSignal;if(t?.aborted)return u(new y("aborted","aborted"));const s=Fe(e?.timeout);if(!s.ok)return u(s.error);const a=s.value,l=e?.cwd?b(this.cwd,e.cwd):this.cwd,w=await Oe(this.shellPath);if(!w.ok)return w;try{await J(l,Y.F_OK)}catch(P){const v=D(P);return u(new y("spawn_error",`Working directory does not exist: ${l}
|
|
10
|
-
Cannot execute bash commands.`,v))}return await new Promise(P=>{let v=!1,S=!1,_,E,h,C;const M=[];let I;const R=[];let A,x,g=!1;const L=o(()=>{h?.pid&&K(h.pid)},"onAbort"),U=o(c=>{if(_!==void 0)return;const f=D(c);_=new y("callback_error",f.message,f),L()},"failCallback");let k;try{k=new Pe(e?.capture,n,{onUpdate:e?.onUpdate,onError:U})}catch(c){const f=D(c);P(u(new y("unknown",f.message,f)));return}const O=o(c=>{v||(v=!0,C&&clearTimeout(C),t&&t.removeEventListener("abort",L),h?.pid&&this.activeChildPids.delete(h.pid),k.dispose(),P(c))},"settle"),X=o(()=>{h?.stdout?.pause(),h?.stderr?.pause()},"pauseOutput"),j=o(()=>{_||E||S||t?.aborted||g||(h?.stdout?.resume(),h?.stderr?.resume())},"resumeOutput"),q=o(c=>{if(E!==void 0)return;const f=D(c);E=new y("unknown",`Failed to preserve complete shell output: ${f.message}`,f),g=!1,L()},"failSpill"),Q=o(c=>{x===void 0||c.length===0||x.write(c)||g||(g=!0,X(),x.once("drain",()=>{g=!1,j()}))},"writeSpill"),G=o(c=>{if(x!==void 0){Q(c);return}R.push(c),A===void 0&&(X(),A=(async()=>{const f=await this.createTempFile({prefix:"pi-output-",suffix:".log"},n);if(!f.ok)throw f.error;I=f.value,k.setSpillPath(I),x=fe(I,{flags:"a",highWaterMark:ke}),x.on("error",q);for(const F of R)Q(F);R.length=0})().catch(q).finally(j))},"startSpill"),oe=o(async()=>{await A;const c=x;c===void 0||E!==void 0||c.destroyed||await new Promise(f=>{c.once("error",()=>f()),c.once("finish",f),c.end()})},"finishSpill");try{const c=w.value.commandTransport==="stdin";h=z(w.value.shell,c?w.value.args:[...w.value.args,r],{cwd:l,detached:process.platform!=="win32",env:Me(this.shellEnv,e?.env,e?.inheritEnv),stdio:[c?"pipe":"ignore","pipe","pipe"],windowsHide:!0}),h.pid&&this.activeChildPids.add(h.pid),c&&(h.stdin?.on("error",()=>{}),h.stdin?.end(r))}catch(c){const f=D(c);O(u(new y("spawn_error",f.message,f)));return}C=a===void 0?void 0:setTimeout(()=>{S=!0,L()},a),t&&(t.aborted?L():t.addEventListener("abort",L,{once:!0}));const V=o(c=>{try{const f=k.truncated;if(k.push(c),!e?.capture?.spill||c.length===0)return;if(I!==void 0||f)G(c);else if(k.truncated){for(const F of M)G(F);M.length=0,G(c)}else M.push(c)}catch(f){U(f)}},"feed");h.stdout?.on("data",V),h.stderr?.on("data",V),Re(h,()=>E===void 0&&A!==void 0&&(x===void 0||g)).then(async({code:c,signal:f})=>{await oe();try{k.finish(),k.flush()}catch(ue){U(ue)}if(_){O(u(_));return}if(S){O(u(new y("timeout",`timeout:${e?.timeout}`)));return}if(t?.aborted){O(u(new y("aborted","aborted")));return}if(E){O(u(E));return}const F=k.snapshot(),ce=c??(f?128+(ve.signals[f]??0):1);O(d({exitCode:ce,truncation:F.truncation,...F.spillPath===void 0?{}:{spillPath:F.spillPath},...F.lastLineBytes===void 0?{}:{lastLineBytes:F.lastLineBytes}}))},c=>O(u(new y("spawn_error",c.message,c))))})}async openTextLineReader(r,e){const n=b(this.cwd,r),t=m(e.abortSignal,n);if(t)return t;try{const s=await we(n,"r"),a=m(e.abortSignal,n);return a?(await s.close().catch(()=>{}),a):d(new De(s,n))}catch(s){return u(p(s,n))}}async readTextFile(r,e){const n=b(this.cwd,r),t=e.abortSignal,s=m(t,n);if(s)return s;try{return d(await ee(n,{encoding:"utf8",signal:t}))}catch(a){return u(p(a,n))}}async readTextLines(r,e,n){if(e?.maxLines!==void 0&&e.maxLines<=0)return d([]);const t=await this.openTextLineReader(r,n);if(!t.ok)return t;const s=[];try{for(;e?.maxLines===void 0||s.length<e.maxLines;){const a=await t.value.readLine(n);if(!a.ok)return a;if(a.value===void 0)break;s.push(a.value.text)}return d(s)}finally{await t.value.close(n)}}async readBinaryFile(r,e){const n=b(this.cwd,r),t=e.abortSignal,s=m(t,n);if(s)return s;try{return d(await ee(n,{signal:t}))}catch(a){return u(p(a,n))}}async writeFile(r,e,n){const t=b(this.cwd,r),s=n.abortSignal,a=m(s,t);if(a)return a;try{await H(B(t,".."),{recursive:!0});const l=m(s,t);return l||(await te(t,e,{signal:s}),d(void 0))}catch(l){return u(p(l,t))}}async appendFile(r,e,n){const t=b(this.cwd,r),s=n.abortSignal,a=m(s,t);if(a)return a;try{await H(B(t,".."),{recursive:!0});const l=m(s,t);return l||(await he(t,e),m(s,t)??d(void 0))}catch(l){return u(p(l,t))}}async renameFile(r,e,n){const t=b(this.cwd,r),s=b(this.cwd,e),a=m(n.abortSignal,s);if(a)return a;try{return await ye(t,s),d(void 0)}catch(l){return u(p(l,t))}}async fileInfo(r,e){const n=b(this.cwd,r),t=m(e.abortSignal,n);if(t)return t;try{return ie(n,await Z(n))}catch(s){return u(p(s,n))}}async listDir(r,e){const n=b(this.cwd,r),t=e.abortSignal,s=m(t,n);if(s)return s;try{const a=await pe(n,{withFileTypes:!0}),l=[];for(const w of a){const P=m(t,n);if(P)return P;const v=B(n,w.name);try{const S=ie(v,await Z(v));S.ok&&l.push(S.value)}catch(S){return u(p(S,v))}}return d(l)}catch(a){return u(p(a,n))}}async canonicalPath(r,e){const n=b(this.cwd,r),t=m(e.abortSignal,n);if(t)return t;try{return d(await be(n))}catch(s){return u(p(s,n))}}async exists(r,e){const n=await this.fileInfo(r,e);return n.ok?d(!0):n.error.code==="not_found"?d(!1):u(n.error)}async createDir(r,e,n){const t=b(this.cwd,r),s=m(n.abortSignal,t);if(s)return s;try{return await H(t,{recursive:e?.recursive??!0}),d(void 0)}catch(a){return u(p(a,t))}}async remove(r,e,n){const t=b(this.cwd,r),s=m(n.abortSignal,t);if(s)return s;try{return await ge(t,{recursive:e?.recursive??!1,force:e?.force??!1}),d(void 0)}catch(a){return u(p(a,t))}}async createTempDir(r,e){const n=m(e.abortSignal);if(n)return n;try{return r??="tmp-",d(await me($(Se(),r)))}catch(t){return u(p(t))}}async createTempFile(r,e){const n=await this.createTempDir("tmp-",e);if(!n.ok)return n;const t=$(n.value,`${r?.prefix??""}${le()}${r?.suffix??""}`);try{return await te(t,""),d(t)}catch(s){return u(p(s,t))}}async cleanup(r){for(const e of this.activeChildPids)K(e);this.activeChildPids.clear()}}export{je as NodeExecutionEnv};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=Object.defineProperty;var c=(d,e)=>f(d,"name",{value:e,configurable:!0});class w{static{c(this,"HarnessEventBus")}listeners=new Map;watchListeners=new Set;deliveryTail=Promise.resolve();closedError;on(e,s){if(this.closedError!==void 0)throw this.closedError;const r=c((n,i)=>s(n,i),"wrapped");let t=this.listeners.get(e);return t===void 0&&(t=new Set,this.listeners.set(e,t)),t.add(r),()=>t?.delete(r)}emit(e,s){return this.emitBatch([e],s)}emitBatch(e,s){if(this.closedError!==void 0||e.length===0)return Promise.resolve();const r=e.map(n=>{const i=structuredClone(n);return{payload:i,recipients:this.snapshotRecipients(i)}}),t=this.deliveryTail.then(async()=>{for(const{payload:n,recipients:i}of r)await this.deliver(n,i,!0,s)});return this.deliveryTail=t.catch(()=>{}),t}watch(e,s,r,t){if(this.closedError!==void 0)throw this.closedError;return this.installWatcher(e,s,t)}async watchFromSnapshot(e,s,r){if(this.closedError!==void 0)throw this.closedError;const t=this.installWatcher(void 0,s,async(n,i)=>{const a=await e(n);return i(),a});try{return t.setSnapshot(await e(r)),t}catch(n){throw t.unsubscribe(),n}}close(e){this.closedError??=e,this.deliveryTail.finally(()=>{this.listeners.clear(),this.watchListeners.clear()})}installWatcher(e,s,r){let t;const n=r===void 0?void 0:async a=>{let h=!1;const o=await r(a,()=>{if(h)throw new Error("Resnapshot boundary was already marked");h=!0,this.enqueueBarrier(()=>t.markResnapshotBoundary())});if(!h)throw new Error("Resnapshot capture did not mark its boundary");return o};t=new p(e,n,async(a,h,o)=>{if(h.type==="handler_error")return;const l=a instanceof Error?a:new Error(String(a)),u="lane"in h&&typeof h.lane=="string"?h.lane:void 0;await this.emit({type:"handler_error",kind:"event",event:h.type,error:l.message,...l.stack===void 0?{}:{stack:l.stack},...u===void 0?{}:{lane:u}},o)});const i=c((a,h)=>{s(a)&&t.push(a,h)},"watchListener");return this.watchListeners.add(i),t.setUnsubscribe(()=>this.watchListeners.delete(i)),t}enqueueBarrier(e){const s=this.deliveryTail.then(e);this.deliveryTail=s.catch(()=>{})}snapshotRecipients(e){return[...this.listeners.get(e.type)??[],...this.watchListeners]}async deliver(e,s,r,t){for(const n of s)try{await n(structuredClone(e),t)}catch(i){if(!r||e.type==="handler_error")continue;const a=i instanceof Error?i:new Error(String(i)),h="lane"in e&&typeof e.lane=="string"?e.lane:void 0,o={type:"handler_error",kind:"event",event:e.type,error:a.message,...a.stack===void 0?{}:{stack:a.stack},...h===void 0?{}:{lane:h}};await this.deliver(o,this.snapshotRecipients(o),!1,t)}}}class p{static{c(this,"BufferedEventWatcher")}snapshot;resnapshotCallback;onError;buffer=[];listener;unsubscribeCallback;deliveryTail=Promise.resolve();epoch=0;resnapshotState;state="buffering";constructor(e,s,r){this.snapshot=e,this.resnapshotCallback=s,this.onError=r}setSnapshot(e){this.snapshot=e}start(e){if(this.state!=="buffering")throw new Error("WatchHandle.start() may be called only once");this.state="started",this.listener=e;const s=this.buffer;this.buffer=[];for(const r of s)this.enqueue(r.event,r.context,r.epoch)}async resnapshot(e){if(this.state==="unsubscribed")throw new Error("WatchHandle is unsubscribed");if(this.resnapshotCallback===void 0)throw new Error("WatchHandle does not support resnapshot");if(this.resnapshotState!==void 0)throw new Error("WatchHandle resnapshot is already in progress");let s;const r=new Promise(n=>{s=n}),t={phase:"dropping",held:[],reached:r,resolveReached:s};this.epoch++,this.resnapshotState=t;try{const n=await this.resnapshotCallback(e);await r,this.snapshot=n,this.resnapshotState=void 0;for(const i of t.held)this.push(i.event,i.context);return n}catch(n){this.resnapshotState=void 0;for(const i of t.held)this.push(i.event,i.context);throw n}}markResnapshotBoundary(){const e=this.resnapshotState;e===void 0||e.phase!=="dropping"||(e.phase="holding",e.resolveReached())}unsubscribe(){this.state!=="unsubscribed"&&(this.state="unsubscribed",this.buffer=[],this.listener=void 0,this.unsubscribeCallback?.(),this.unsubscribeCallback=void 0)}push(e,s){if(this.state!=="unsubscribed"&&this.resnapshotState?.phase!=="dropping"){if(this.resnapshotState?.phase==="holding"){this.resnapshotState.held.push({event:e,context:s});return}if(this.state==="buffering"){this.buffer.push({event:e,context:s,epoch:this.epoch});return}this.enqueue(e,s,this.epoch)}}setUnsubscribe(e){this.unsubscribeCallback=e}enqueue(e,s,r){const t=this.listener;t!==void 0&&(this.deliveryTail=this.deliveryTail.then(async()=>{this.state==="started"&&r===this.epoch&&await t(e,s)}).catch(async n=>{try{await this.onError(n,e,s)}catch{}}))}}export{w as HarnessEventBus};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=Object.defineProperty;var m=(s,t)=>u(s,"name",{value:t,configurable:!0});import{getTelemetryContext as f}from"../context.js";import{AbortRequested as y}from"./effect-gate.js";function w(s,t,r){const e=s.streamOptions;return{transport:e.transport,timeoutMs:e.timeoutMs,maxRetries:e.maxRetries,maxRetryDelayMs:e.maxRetryDelayMs,headers:e.headers,metadata:e.metadata,cacheRetention:e.cacheRetention,deferred:e.deferred,...s.thinkingLevel==="off"?{}:{reasoning:s.thinkingLevel},signal:r.abortSignal,telemetryContext:f(r),onPayload:s.beforePayload===void 0?void 0:(n,o)=>s.beforePayload?.(n,o,r),onResponse:m(n=>{t({status:n.status,headers:n.headers})},"onResponse")}}m(w,"createRequestOptions");function h(s){return s.type!=="start"&&s.type!=="done"&&s.type!=="error"}m(h,"isUpdateEvent");async function R(s,t,r,e){let n=!1;for await(const a of s)if(a.type==="start"){if(n)throw new Error("Assistant message stream emitted more than one start event");n=!0,await t.start({...a.partial},a,e)}else if(h(a)){if(!n)throw new Error(`Assistant message stream emitted ${a.type} before start`);await t.update({...a.partial},a,e)}else if(a.type==="done"&&!n)throw new Error("Assistant message stream emitted done before start");const o=await s.result();let i=o;if(r!==void 0)try{i=await r(o,e)}catch(a){if(!(a instanceof y))throw a;await a.cancellation}return await t.end(i,e),i}m(R,"consumeAssistantStream");async function C(s,t,r){let e={messages:s.slice(),systemPrompt:t.systemPrompt};t.transformContext&&(e=await t.transformContext(e,r));const n=await t.toProviderMessages(e.messages,r),o={systemPrompt:e.systemPrompt,messages:n,tools:t.tools};let i={};const a=await t.request(o,w(t,d=>{i=d},r),r),l=t.afterResponse;return R(a,t.observer,l===void 0?void 0:(d,p)=>l(d,i,p),r)}m(C,"streamHarnessAssistant");export{R as consumeAssistantStream,C as streamHarnessAssistant};
|
package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a=Object.defineProperty;var o=(t,e)=>a(t,"name",{value:e,configurable:!0});class s extends Error{static{o(this,"AbortRequested")}cancellation;constructor(e){super("Abort requested"),this.name="AbortRequested",this.cancellation=e}}function c(){let t={status:"open"};const e=new AbortController,n=o(()=>{if(t.status==="aborting")throw new s(t.cancellation);if(t.status==="closed")throw t.error},"check");return{gate:{admit(r){return n(),r()},signal:e.signal},control:{beginAbort(r){t.status==="open"&&(t={status:"aborting",cancellation:r})},signalAbort(){t.status!=="aborting"||e.signal.aborted||e.abort(new s(t.cancellation))},close(r){t.status!=="closed"&&(t={status:"closed",error:r},e.signal.aborted||e.abort(r))}}}}o(c,"createGate");export{s as AbortRequested,c as createGate};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var E=Object.defineProperty;var n=(t,e)=>E(t,"name",{value:e,configurable:!0});import{validateToolArguments as m}from"@earendil-works/pi-ai";import{withAbortSignal as c}from"../context.js";function f(t){return{content:[{type:"text",text:t}],details:void 0}}n(f,"createErrorToolResult");function l(t,e,r=!1){return{kind:"immediate",toolCall:t,result:f(e),isError:!0,terminate:r}}n(l,"immediateError");function A(t,e){const r=e.find(o=>o.name===t.name);if(!r)return l(t,`Tool ${JSON.stringify(t.name)} is unavailable`);try{const o=r.prepareArguments?r.prepareArguments(t.arguments):t.arguments,i=o===t.arguments?t:{...t,arguments:o},u=m(r,i);return{toolCall:t,tool:r,args:u}}catch(o){return l(t,o instanceof Error?o.message:String(o))}}n(A,"prepareToolCall");function S(t,e){if(e?.block)return l(t.toolCall,e.block.reason,e.block.terminate===!0);if(!e?.args)return{toolCall:t.toolCall,tool:t.tool,args:t.args};try{const r=m(t.tool,{...t.toolCall,arguments:e.args});return{toolCall:t.toolCall,tool:t.tool,args:r}}catch(r){return l(t.toolCall,r instanceof Error?r.message:String(r))}}n(S,"applyBeforeToolDecision");function x(t,e,r,o,i,u){let a=!0;return e.admit(async()=>{const g=c(e.signal,u);g.abortSignal?.throwIfAborted();try{return{result:await t.tool.execute(t.toolCall.id,t.args,(d,C)=>{a&&r(d,C)},o,i,g),isError:!1}}catch(s){return{result:f(s instanceof Error?s.message:String(s)),isError:!0}}finally{a=!1}})}n(x,"executeToolCall");function k(t,e,r){const o=r?{...e.result,content:r.content===void 0?e.result.content:r.content,details:r.details===void 0?e.result.details:r.details,usage:r.usage===void 0?e.result.usage:r.usage,terminate:r.terminate===void 0?e.result.terminate:r.terminate}:e.result;return{toolCall:t.toolCall,result:o,isError:r?.isError??e.isError,terminate:o.terminate===!0}}n(k,"finalizeToolCall");function w(t,e){return{content:t.content,details:t.details,...t.usage===void 0?{}:{usage:t.usage},...e?{terminate:!0}:{}}}n(w,"toolResultFromMessage");function R(t){return{role:"toolResult",toolCallId:t.toolCall.id,toolName:t.toolCall.name,content:t.result.content??[],...t.result.details===void 0?{}:{details:t.result.details},...t.result.usage===void 0?{}:{usage:t.result.usage},isError:t.isError,timestamp:Date.now()}}n(R,"createToolResultMessage");export{S as applyBeforeToolDecision,R as createToolResultMessage,x as executeToolCall,k as finalizeToolCall,A as prepareToolCall,w as toolResultFromMessage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var c=Object.defineProperty;var d=(a,e)=>c(a,"name",{value:e,configurable:!0});import{withAbortSignal as f}from"./context.js";import{startHarnessSpan as u}from"./telemetry.js";class b{static{d(this,"HookRegistry")}registrations=new Map;reportError;closedError;constructor(e){this.reportError=e}on(e,o,r={}){if(this.closedError!==void 0)throw this.closedError;const s=this.registrations.get(e)??[],i={...r.id===void 0?{}:{id:r.id},handler:d((t,n)=>o(t,n),"handler")};return s.push(i),this.registrations.set(e,s),()=>{const t=s.indexOf(i);t!==-1&&s.splice(t,1)}}has(e){return(this.registrations.get(e)?.length??0)!==0}runWithGate(e,o,r,s){return r.admit(()=>{const i=f(r.signal,s);return i.abortSignal?.throwIfAborted(),this.runAdmitted(e,o,i)})}runToolWithGate(e,o,r,s){return r.admit(()=>{const i=f(r.signal,s);return i.abortSignal?.throwIfAborted(),e==="before_tool"?this.beforeTool(o,i):this.afterTool(o,i)})}close(e){this.closedError??=e}async runAdmitted(e,o,r){if(this.closedError!==void 0)throw this.closedError;return await this.aggregate(e,o,r)}async aggregate(e,o,r){switch(e){case"before_run":return this.beforeRun(o,r);case"before_drive":await this.invokeAllFailClosed(e,o,r);return;case"before_run_end":{let s;return await this.invokeAll(e,o,i=>{const t=i;t?.followUp!==void 0&&(s=t.followUp)},r),s===void 0?void 0:{followUp:s}}case"transform_context":return this.transformContext(o,r);case"before_request":return this.beforeRequest(o,r);case"before_payload":return this.beforePayload(o,r);case"after_response":return this.afterResponse(o,r);case"before_tool":return this.beforeTool(o,r);case"after_tool":return this.afterTool(o,r);case"before_compaction":return this.firstStructural(e,o,"compaction",r);case"before_navigation":return this.firstStructural(e,o,"summary",r)}}async beforeRun(e,o){let r=e.prompt,s=[];for(const i of this.registrationsFor("before_run"))try{const t=await i.handler({...e,prompt:r},o);t?.messages!==void 0&&(s=[...s,...t.messages],r=[...r,...t.messages])}catch(t){await this.reportError(t instanceof Error?t:new Error(String(t)),"before_run",e.lane,o)}return s.length===0?void 0:{messages:s}}async beforeTool(e,o){let r=e.args,s;for(const i of this.registrationsFor("before_tool"))try{const t=await this.invokeToolRegistration("before_tool",i,{...e,args:r},o);if(t?.args!==void 0&&(r=t.args),t?.block!==void 0){s=t.block;break}}catch(t){const n=t instanceof Error?t:new Error(String(t));await this.reportError(n,"before_tool",e.lane,o),s={reason:n.message};break}return{...r===e.args?{}:{args:r},...s===void 0?{}:{block:s}}}async transformContext(e,o){let r=e.messages,s=e.systemPrompt;for(const i of this.registrationsFor("transform_context"))try{const t=await i.handler({...e,messages:r,systemPrompt:s},o);t?.messages!==void 0&&(r=t.messages),t?.systemPrompt!==void 0&&(s=t.systemPrompt)}catch(t){await this.reportError(t instanceof Error?t:new Error(String(t)),"transform_context",e.lane,o)}return{messages:r,systemPrompt:s}}async beforeRequest(e,o){let r=e.streamOptions,s=!1;for(const i of this.registrationsFor("before_request"))try{const t=await i.handler({...e,streamOptions:r},o);t?.streamOptions!==void 0&&(r=h(r,t.streamOptions),s=!0)}catch(t){await this.reportError(t instanceof Error?t:new Error(String(t)),"before_request",e.lane,o)}return s?{streamOptions:g(e.streamOptions,r)}:void 0}async beforePayload(e,o){let r=e.payload;for(const s of this.registrationsFor("before_payload"))try{const i=await s.handler({...e,payload:r},o);i?.payload!==void 0&&(r=i.payload)}catch(i){await this.reportError(i instanceof Error?i:new Error(String(i)),"before_payload",e.lane,o)}return{payload:r}}async afterResponse(e,o){let r=e.message;for(const s of this.registrationsFor("after_response"))try{const i=await s.handler({...e,message:r},o);i?.message!==void 0&&(r=i.message)}catch(i){await this.reportError(i instanceof Error?i:new Error(String(i)),"after_response",e.lane,o)}return{message:r}}async afterTool(e,o){let r={content:e.content,details:e.details,isError:e.isError,usage:e.usage};const s={};for(const i of this.registrationsFor("after_tool"))try{const t=await this.invokeToolRegistration("after_tool",i,{...e,...r},o);if(t===void 0)continue;t.content!==void 0&&(s.content=t.content),t.details!==void 0&&(s.details=t.details),t.isError!==void 0&&(s.isError=t.isError),t.usage!==void 0&&(s.usage=t.usage),t.terminate!==void 0&&(s.terminate=t.terminate),r={content:t.content===void 0?r.content:t.content,details:t.details===void 0?r.details:t.details,isError:t.isError===void 0?r.isError:t.isError,usage:t.usage===void 0?r.usage:t.usage}}catch(t){await this.reportError(t instanceof Error?t:new Error(String(t)),"after_tool",e.lane,o)}return Object.keys(s).length===0?void 0:s}async firstStructural(e,o,r,s){for(const i of this.registrationsFor(e))try{const t=await i.handler(o,s);if(t==null||typeof t!="object")continue;const n=t;if(n.decline===!0&&n[r]!==void 0){await this.reportError(new Error(`${e} hook cannot return both decline and ${r}`),e,o.lane,s);continue}if(n.decline===!0||n[r]!==void 0)return t}catch(t){await this.reportError(t instanceof Error?t:new Error(String(t)),e,o.lane,s)}}invokeToolRegistration(e,o,r,s){return u("pi.harness.hook",{"pi.lane.name":r.lane,"pi.operation.id":r.runId,"pi.hook.name":e,...o.id===void 0?{}:{"pi.hook.registration_id":o.id}},async(i,t)=>{try{const n=await o.handler(r,t),l=e==="before_tool"&&n!==null&&typeof n=="object"&&"block"in n&&n.block!==void 0;return i.setAttributes({"pi.hook.outcome":l?"blocked":"completed"}),n}catch(n){throw i.setAttributes({"pi.hook.outcome":"failed"}),i.setStatus({status:"error"}),n}},s)}registrationsFor(e){return[...this.registrations.get(e)??[]]}async invokeAllFailClosed(e,o,r){for(const s of this.registrationsFor(e))try{await s.handler(o,r)}catch(i){const t=i instanceof Error?i:new Error(String(i));throw await this.reportError(t,e,o.lane,r),t}}async invokeAll(e,o,r,s){for(const i of this.registrationsFor(e))try{r(await i.handler(o,s))}catch(t){await this.reportError(t instanceof Error?t:new Error(String(t)),e,o.lane,s)}}}function h(a,e){const o={...a};for(const r of["transport","timeoutMs","maxRetries","maxRetryDelayMs","cacheRetention","deferred"]){if(!(r in e))continue;const s=e[r];s===void 0?delete o[r]:Object.assign(o,{[r]:s})}if("headers"in e)if(e.headers===void 0)delete o.headers;else{const r={...o.headers};for(const[s,i]of Object.entries(e.headers))i===void 0?delete r[s]:r[s]=i;o.headers=r}if("metadata"in e)if(e.metadata===void 0)delete o.metadata;else{const r={...o.metadata};for(const[s,i]of Object.entries(e.metadata))i===void 0?delete r[s]:r[s]=i;o.metadata=r}return o}d(h,"applyStreamOptionsPatch");function g(a,e){const o={};for(const r of["transport","timeoutMs","maxRetries","maxRetryDelayMs","cacheRetention","deferred"])a[r]!==e[r]&&Object.assign(o,{[r]:e[r]});if(a.headers!==e.headers)if(e.headers===void 0)o.headers=void 0;else{const r={};for(const s of Object.keys(a.headers??{}))s in e.headers||(r[s]=void 0);for(const[s,i]of Object.entries(e.headers))a.headers?.[s]!==i&&(r[s]=i);a.headers===void 0&&Object.keys(r).length===0?o.headers={}:Object.keys(r).length!==0&&(o.headers=r)}if(a.metadata!==e.metadata)if(e.metadata===void 0)o.metadata=void 0;else{const r={};for(const s of Object.keys(a.metadata??{}))s in e.metadata||(r[s]=void 0);for(const[s,i]of Object.entries(e.metadata))a.metadata?.[s]!==i&&(r[s]=i);a.metadata===void 0&&Object.keys(r).length===0?o.metadata={}:Object.keys(r).length!==0&&(o.metadata=r)}return o}d(g,"createStreamOptionsPatch");export{b as HookRegistry,h as applyStreamOptionsPatch};
|