@taco-ai/pi-harness 0.0.0-stage → 0.1.0
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 +26 -0
- package/LICENSE.upstream +21 -0
- package/README.md +170 -2
- package/README.zh-CN.md +165 -0
- package/dist/agent-loop.d.ts +49 -0
- package/dist/agent-loop.d.ts.map +1 -0
- package/dist/agent-loop.js +667 -0
- package/dist/agent-loop.js.map +1 -0
- package/dist/agent.d.ts +137 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +437 -0
- package/dist/agent.js.map +1 -0
- package/dist/harness/agent-harness.d.ts +717 -0
- package/dist/harness/agent-harness.d.ts.map +1 -0
- package/dist/harness/agent-harness.js +6 -0
- package/dist/harness/agent-harness.js.map +1 -0
- package/dist/harness/compaction/branch-summarization.d.ts +68 -0
- package/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/harness/compaction/branch-summarization.js +176 -0
- package/dist/harness/compaction/branch-summarization.js.map +1 -0
- package/dist/harness/compaction/compaction.d.ts +126 -0
- package/dist/harness/compaction/compaction.d.ts.map +1 -0
- package/dist/harness/compaction/compaction.js +560 -0
- package/dist/harness/compaction/compaction.js.map +1 -0
- package/dist/harness/compaction/utils.d.ts +25 -0
- package/dist/harness/compaction/utils.d.ts.map +1 -0
- package/dist/harness/compaction/utils.js +120 -0
- package/dist/harness/compaction/utils.js.map +1 -0
- package/dist/harness/config.d.ts +9 -0
- package/dist/harness/config.d.ts.map +1 -0
- package/dist/harness/config.js +35 -0
- package/dist/harness/config.js.map +1 -0
- package/dist/harness/context.d.ts +9 -0
- package/dist/harness/context.d.ts.map +1 -0
- package/dist/harness/context.js +13 -0
- package/dist/harness/context.js.map +1 -0
- package/dist/harness/env/nodejs.d.ts +43 -0
- package/dist/harness/env/nodejs.d.ts.map +1 -0
- package/dist/harness/env/nodejs.js +865 -0
- package/dist/harness/env/nodejs.js.map +1 -0
- package/dist/harness/events.d.ts +25 -0
- package/dist/harness/events.d.ts.map +1 -0
- package/dist/harness/events.js +250 -0
- package/dist/harness/events.js.map +1 -0
- package/dist/harness/execution/assistant.d.ts +42 -0
- package/dist/harness/execution/assistant.d.ts.map +1 -0
- package/dist/harness/execution/assistant.js +82 -0
- package/dist/harness/execution/assistant.js.map +1 -0
- package/dist/harness/execution/effect-gate.d.ts +22 -0
- package/dist/harness/execution/effect-gate.d.ts.map +1 -0
- package/dist/harness/execution/effect-gate.js +49 -0
- package/dist/harness/execution/effect-gate.js.map +1 -0
- package/dist/harness/execution/tools.d.ts +67 -0
- package/dist/harness/execution/tools.d.ts.map +1 -0
- package/dist/harness/execution/tools.js +119 -0
- package/dist/harness/execution/tools.js.map +1 -0
- package/dist/harness/hooks.d.ts +38 -0
- package/dist/harness/hooks.d.ts.map +1 -0
- package/dist/harness/hooks.js +406 -0
- package/dist/harness/hooks.js.map +1 -0
- package/dist/harness/messages.d.ts +51 -0
- package/dist/harness/messages.d.ts.map +1 -0
- package/dist/harness/messages.js +103 -0
- package/dist/harness/messages.js.map +1 -0
- package/dist/harness/pico3/bash.d.ts +10 -0
- package/dist/harness/pico3/bash.d.ts.map +1 -0
- package/dist/harness/pico3/bash.js +25 -0
- package/dist/harness/pico3/bash.js.map +1 -0
- package/dist/harness/pico3/bounded.d.ts +21 -0
- package/dist/harness/pico3/bounded.d.ts.map +1 -0
- package/dist/harness/pico3/bounded.js +98 -0
- package/dist/harness/pico3/bounded.js.map +1 -0
- package/dist/harness/pico3/chord.d.ts +41 -0
- package/dist/harness/pico3/chord.d.ts.map +1 -0
- package/dist/harness/pico3/chord.js +147 -0
- package/dist/harness/pico3/chord.js.map +1 -0
- package/dist/harness/pico3/context.d.ts +16 -0
- package/dist/harness/pico3/context.d.ts.map +1 -0
- package/dist/harness/pico3/context.js +88 -0
- package/dist/harness/pico3/context.js.map +1 -0
- package/dist/harness/pico3/harness.d.ts +198 -0
- package/dist/harness/pico3/harness.d.ts.map +1 -0
- package/dist/harness/pico3/harness.js +654 -0
- package/dist/harness/pico3/harness.js.map +1 -0
- package/dist/harness/pico3/hooks.d.ts +10 -0
- package/dist/harness/pico3/hooks.d.ts.map +1 -0
- package/dist/harness/pico3/hooks.js +33 -0
- package/dist/harness/pico3/hooks.js.map +1 -0
- package/dist/harness/pico3/index.d.ts +19 -0
- package/dist/harness/pico3/index.d.ts.map +1 -0
- package/dist/harness/pico3/index.js +15 -0
- package/dist/harness/pico3/index.js.map +1 -0
- package/dist/harness/pico3/jsonl.d.ts +58 -0
- package/dist/harness/pico3/jsonl.d.ts.map +1 -0
- package/dist/harness/pico3/jsonl.js +325 -0
- package/dist/harness/pico3/jsonl.js.map +1 -0
- package/dist/harness/pico3/kinds/collapse.d.ts +49 -0
- package/dist/harness/pico3/kinds/collapse.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/collapse.js +191 -0
- package/dist/harness/pico3/kinds/collapse.js.map +1 -0
- package/dist/harness/pico3/kinds/entries.d.ts +78 -0
- package/dist/harness/pico3/kinds/entries.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/entries.js +13 -0
- package/dist/harness/pico3/kinds/entries.js.map +1 -0
- package/dist/harness/pico3/kinds/frames.d.ts +11 -0
- package/dist/harness/pico3/kinds/frames.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/frames.js +76 -0
- package/dist/harness/pico3/kinds/frames.js.map +1 -0
- package/dist/harness/pico3/kinds/generation.d.ts +94 -0
- package/dist/harness/pico3/kinds/generation.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/generation.js +505 -0
- package/dist/harness/pico3/kinds/generation.js.map +1 -0
- package/dist/harness/pico3/kinds/job.d.ts +44 -0
- package/dist/harness/pico3/kinds/job.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/job.js +143 -0
- package/dist/harness/pico3/kinds/job.js.map +1 -0
- package/dist/harness/pico3/kinds/plugin.d.ts +15 -0
- package/dist/harness/pico3/kinds/plugin.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/plugin.js +35 -0
- package/dist/harness/pico3/kinds/plugin.js.map +1 -0
- package/dist/harness/pico3/kinds/post-tools.d.ts +22 -0
- package/dist/harness/pico3/kinds/post-tools.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/post-tools.js +145 -0
- package/dist/harness/pico3/kinds/post-tools.js.map +1 -0
- package/dist/harness/pico3/kinds/task-api.d.ts +3 -0
- package/dist/harness/pico3/kinds/task-api.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/task-api.js +45 -0
- package/dist/harness/pico3/kinds/task-api.js.map +1 -0
- package/dist/harness/pico3/kinds/tool.d.ts +43 -0
- package/dist/harness/pico3/kinds/tool.d.ts.map +1 -0
- package/dist/harness/pico3/kinds/tool.js +373 -0
- package/dist/harness/pico3/kinds/tool.js.map +1 -0
- package/dist/harness/pico3/legacy-tracker.d.ts +11 -0
- package/dist/harness/pico3/legacy-tracker.d.ts.map +1 -0
- package/dist/harness/pico3/legacy-tracker.js +41 -0
- package/dist/harness/pico3/legacy-tracker.js.map +1 -0
- package/dist/harness/pico3/membrane.d.ts +23 -0
- package/dist/harness/pico3/membrane.d.ts.map +1 -0
- package/dist/harness/pico3/membrane.js +141 -0
- package/dist/harness/pico3/membrane.js.map +1 -0
- package/dist/harness/pico3/memory.d.ts +53 -0
- package/dist/harness/pico3/memory.d.ts.map +1 -0
- package/dist/harness/pico3/memory.js +264 -0
- package/dist/harness/pico3/memory.js.map +1 -0
- package/dist/harness/pico3/scheduler.d.ts +49 -0
- package/dist/harness/pico3/scheduler.d.ts.map +1 -0
- package/dist/harness/pico3/scheduler.js +438 -0
- package/dist/harness/pico3/scheduler.js.map +1 -0
- package/dist/harness/pico3/session.d.ts +264 -0
- package/dist/harness/pico3/session.d.ts.map +1 -0
- package/dist/harness/pico3/session.js +1348 -0
- package/dist/harness/pico3/session.js.map +1 -0
- package/dist/harness/pico3/system.d.ts +126 -0
- package/dist/harness/pico3/system.d.ts.map +1 -0
- package/dist/harness/pico3/system.js +244 -0
- package/dist/harness/pico3/system.js.map +1 -0
- package/dist/harness/pico3/types.d.ts +973 -0
- package/dist/harness/pico3/types.d.ts.map +1 -0
- package/dist/harness/pico3/types.js +96 -0
- package/dist/harness/pico3/types.js.map +1 -0
- package/dist/harness/pico3/view.d.ts +34 -0
- package/dist/harness/pico3/view.d.ts.map +1 -0
- package/dist/harness/pico3/view.js +411 -0
- package/dist/harness/pico3/view.js.map +1 -0
- package/dist/harness/prompt-templates.d.ts +49 -0
- package/dist/harness/prompt-templates.d.ts.map +1 -0
- package/dist/harness/prompt-templates.js +225 -0
- package/dist/harness/prompt-templates.js.map +1 -0
- package/dist/harness/result.d.ts +133 -0
- package/dist/harness/result.d.ts.map +1 -0
- package/dist/harness/result.js +81 -0
- package/dist/harness/result.js.map +1 -0
- package/dist/harness/runtime/drive/boundary.d.ts +28 -0
- package/dist/harness/runtime/drive/boundary.d.ts.map +1 -0
- package/dist/harness/runtime/drive/boundary.js +173 -0
- package/dist/harness/runtime/drive/boundary.js.map +1 -0
- package/dist/harness/runtime/drive/checkpoint.d.ts +8 -0
- package/dist/harness/runtime/drive/checkpoint.d.ts.map +1 -0
- package/dist/harness/runtime/drive/checkpoint.js +133 -0
- package/dist/harness/runtime/drive/checkpoint.js.map +1 -0
- package/dist/harness/runtime/drive/deferred.d.ts +15 -0
- package/dist/harness/runtime/drive/deferred.d.ts.map +1 -0
- package/dist/harness/runtime/drive/deferred.js +179 -0
- package/dist/harness/runtime/drive/deferred.js.map +1 -0
- package/dist/harness/runtime/drive/generation.d.ts +8 -0
- package/dist/harness/runtime/drive/generation.d.ts.map +1 -0
- package/dist/harness/runtime/drive/generation.js +205 -0
- package/dist/harness/runtime/drive/generation.js.map +1 -0
- package/dist/harness/runtime/drive/reconcile.d.ts +5 -0
- package/dist/harness/runtime/drive/reconcile.d.ts.map +1 -0
- package/dist/harness/runtime/drive/reconcile.js +140 -0
- package/dist/harness/runtime/drive/reconcile.js.map +1 -0
- package/dist/harness/runtime/drive/recovery.d.ts +8 -0
- package/dist/harness/runtime/drive/recovery.d.ts.map +1 -0
- package/dist/harness/runtime/drive/recovery.js +85 -0
- package/dist/harness/runtime/drive/recovery.js.map +1 -0
- package/dist/harness/runtime/drive/response.d.ts +23 -0
- package/dist/harness/runtime/drive/response.d.ts.map +1 -0
- package/dist/harness/runtime/drive/response.js +395 -0
- package/dist/harness/runtime/drive/response.js.map +1 -0
- package/dist/harness/runtime/drive/retry.d.ts +4 -0
- package/dist/harness/runtime/drive/retry.d.ts.map +1 -0
- package/dist/harness/runtime/drive/retry.js +34 -0
- package/dist/harness/runtime/drive/retry.js.map +1 -0
- package/dist/harness/runtime/drive/structural.d.ts +32 -0
- package/dist/harness/runtime/drive/structural.d.ts.map +1 -0
- package/dist/harness/runtime/drive/structural.js +929 -0
- package/dist/harness/runtime/drive/structural.js.map +1 -0
- package/dist/harness/runtime/drive/terminal.d.ts +7 -0
- package/dist/harness/runtime/drive/terminal.d.ts.map +1 -0
- package/dist/harness/runtime/drive/terminal.js +49 -0
- package/dist/harness/runtime/drive/terminal.js.map +1 -0
- package/dist/harness/runtime/drive/tool-placement.d.ts +14 -0
- package/dist/harness/runtime/drive/tool-placement.d.ts.map +1 -0
- package/dist/harness/runtime/drive/tool-placement.js +219 -0
- package/dist/harness/runtime/drive/tool-placement.js.map +1 -0
- package/dist/harness/runtime/drive/tools.d.ts +6 -0
- package/dist/harness/runtime/drive/tools.d.ts.map +1 -0
- package/dist/harness/runtime/drive/tools.js +449 -0
- package/dist/harness/runtime/drive/tools.js.map +1 -0
- package/dist/harness/runtime/drive.d.ts +6 -0
- package/dist/harness/runtime/drive.d.ts.map +1 -0
- package/dist/harness/runtime/drive.js +93 -0
- package/dist/harness/runtime/drive.js.map +1 -0
- package/dist/harness/runtime/harness.d.ts +59 -0
- package/dist/harness/runtime/harness.d.ts.map +1 -0
- package/dist/harness/runtime/harness.js +311 -0
- package/dist/harness/runtime/harness.js.map +1 -0
- package/dist/harness/runtime/index.d.ts +2 -0
- package/dist/harness/runtime/index.d.ts.map +1 -0
- package/dist/harness/runtime/index.js +2 -0
- package/dist/harness/runtime/index.js.map +1 -0
- package/dist/harness/runtime/lane.d.ts +118 -0
- package/dist/harness/runtime/lane.d.ts.map +1 -0
- package/dist/harness/runtime/lane.js +1576 -0
- package/dist/harness/runtime/lane.js.map +1 -0
- package/dist/harness/runtime/progress.d.ts +15 -0
- package/dist/harness/runtime/progress.d.ts.map +1 -0
- package/dist/harness/runtime/progress.js +66 -0
- package/dist/harness/runtime/progress.js.map +1 -0
- package/dist/harness/runtime/reducer.d.ts +5 -0
- package/dist/harness/runtime/reducer.d.ts.map +1 -0
- package/dist/harness/runtime/reducer.js +240 -0
- package/dist/harness/runtime/reducer.js.map +1 -0
- package/dist/harness/runtime/restore.d.ts +24 -0
- package/dist/harness/runtime/restore.d.ts.map +1 -0
- package/dist/harness/runtime/restore.js +117 -0
- package/dist/harness/runtime/restore.js.map +1 -0
- package/dist/harness/runtime/transcript.d.ts +21 -0
- package/dist/harness/runtime/transcript.d.ts.map +1 -0
- package/dist/harness/runtime/transcript.js +72 -0
- package/dist/harness/runtime/transcript.js.map +1 -0
- package/dist/harness/runtime/types.d.ts +105 -0
- package/dist/harness/runtime/types.d.ts.map +1 -0
- package/dist/harness/runtime/types.js +61 -0
- package/dist/harness/runtime/types.js.map +1 -0
- package/dist/harness/session/commit.d.ts +53 -0
- package/dist/harness/session/commit.d.ts.map +1 -0
- package/dist/harness/session/commit.js +57 -0
- package/dist/harness/session/commit.js.map +1 -0
- package/dist/harness/session/context.d.ts +10 -0
- package/dist/harness/session/context.d.ts.map +1 -0
- package/dist/harness/session/context.js +49 -0
- package/dist/harness/session/context.js.map +1 -0
- package/dist/harness/session/fork-policy.d.ts +21 -0
- package/dist/harness/session/fork-policy.d.ts.map +1 -0
- package/dist/harness/session/fork-policy.js +55 -0
- package/dist/harness/session/fork-policy.js.map +1 -0
- package/dist/harness/session/fork.d.ts +16 -0
- package/dist/harness/session/fork.d.ts.map +1 -0
- package/dist/harness/session/fork.js +79 -0
- package/dist/harness/session/fork.js.map +1 -0
- package/dist/harness/session/in-memory-storage-state.d.ts +39 -0
- package/dist/harness/session/in-memory-storage-state.d.ts.map +1 -0
- package/dist/harness/session/in-memory-storage-state.js +276 -0
- package/dist/harness/session/in-memory-storage-state.js.map +1 -0
- package/dist/harness/session/index.d.ts +11 -0
- package/dist/harness/session/index.d.ts.map +1 -0
- package/dist/harness/session/index.js +9 -0
- package/dist/harness/session/index.js.map +1 -0
- package/dist/harness/session/jsonl/codec.d.ts +21 -0
- package/dist/harness/session/jsonl/codec.d.ts.map +1 -0
- package/dist/harness/session/jsonl/codec.js +45 -0
- package/dist/harness/session/jsonl/codec.js.map +1 -0
- package/dist/harness/session/jsonl/fork.d.ts +38 -0
- package/dist/harness/session/jsonl/fork.d.ts.map +1 -0
- package/dist/harness/session/jsonl/fork.js +264 -0
- package/dist/harness/session/jsonl/fork.js.map +1 -0
- package/dist/harness/session/jsonl/index.d.ts +4 -0
- package/dist/harness/session/jsonl/index.d.ts.map +1 -0
- package/dist/harness/session/jsonl/index.js +4 -0
- package/dist/harness/session/jsonl/index.js.map +1 -0
- package/dist/harness/session/jsonl/io.d.ts +14 -0
- package/dist/harness/session/jsonl/io.d.ts.map +1 -0
- package/dist/harness/session/jsonl/io.js +86 -0
- package/dist/harness/session/jsonl/io.js.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts +44 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.js +462 -0
- package/dist/harness/session/jsonl/legacy-v3.js.map +1 -0
- package/dist/harness/session/jsonl/repo.d.ts +35 -0
- package/dist/harness/session/jsonl/repo.d.ts.map +1 -0
- package/dist/harness/session/jsonl/repo.js +301 -0
- package/dist/harness/session/jsonl/repo.js.map +1 -0
- package/dist/harness/session/jsonl/storage.d.ts +41 -0
- package/dist/harness/session/jsonl/storage.d.ts.map +1 -0
- package/dist/harness/session/jsonl/storage.js +200 -0
- package/dist/harness/session/jsonl/storage.js.map +1 -0
- package/dist/harness/session/jsonl/types.d.ts +39 -0
- package/dist/harness/session/jsonl/types.d.ts.map +1 -0
- package/dist/harness/session/jsonl/types.js +3 -0
- package/dist/harness/session/jsonl/types.js.map +1 -0
- package/dist/harness/session/memory.d.ts +48 -0
- package/dist/harness/session/memory.d.ts.map +1 -0
- package/dist/harness/session/memory.js +369 -0
- package/dist/harness/session/memory.js.map +1 -0
- package/dist/harness/session/mutation-line.d.ts +8 -0
- package/dist/harness/session/mutation-line.d.ts.map +1 -0
- package/dist/harness/session/mutation-line.js +21 -0
- package/dist/harness/session/mutation-line.js.map +1 -0
- package/dist/harness/session/session.d.ts +82 -0
- package/dist/harness/session/session.d.ts.map +1 -0
- package/dist/harness/session/session.js +361 -0
- package/dist/harness/session/session.js.map +1 -0
- package/dist/harness/session/testing/benchmark/datasets.d.ts +12 -0
- package/dist/harness/session/testing/benchmark/datasets.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/datasets.js +24 -0
- package/dist/harness/session/testing/benchmark/datasets.js.map +1 -0
- package/dist/harness/session/testing/benchmark/session-repo.d.ts +42 -0
- package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/session-repo.js +127 -0
- package/dist/harness/session/testing/benchmark/session-repo.js.map +1 -0
- package/dist/harness/session/testing/benchmark/storage.d.ts +25 -0
- package/dist/harness/session/testing/benchmark/storage.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/storage.js +114 -0
- package/dist/harness/session/testing/benchmark/storage.js.map +1 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts +23 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts.map +1 -0
- package/dist/harness/session/testing/conformance/session-repo.js +809 -0
- package/dist/harness/session/testing/conformance/session-repo.js.map +1 -0
- package/dist/harness/session/testing/conformance/storage.d.ts +4 -0
- package/dist/harness/session/testing/conformance/storage.d.ts.map +1 -0
- package/dist/harness/session/testing/conformance/storage.js +600 -0
- package/dist/harness/session/testing/conformance/storage.js.map +1 -0
- package/dist/harness/session/testing/gating-storage.d.ts +26 -0
- package/dist/harness/session/testing/gating-storage.d.ts.map +1 -0
- package/dist/harness/session/testing/gating-storage.js +100 -0
- package/dist/harness/session/testing/gating-storage.js.map +1 -0
- package/dist/harness/session/testing/index.d.ts +10 -0
- package/dist/harness/session/testing/index.d.ts.map +1 -0
- package/dist/harness/session/testing/index.js +9 -0
- package/dist/harness/session/testing/index.js.map +1 -0
- package/dist/harness/session/testing/instrumented-storage.d.ts +11 -0
- package/dist/harness/session/testing/instrumented-storage.d.ts.map +1 -0
- package/dist/harness/session/testing/instrumented-storage.js +16 -0
- package/dist/harness/session/testing/instrumented-storage.js.map +1 -0
- package/dist/harness/session/testing/storage-decorator.d.ts +20 -0
- package/dist/harness/session/testing/storage-decorator.d.ts.map +1 -0
- package/dist/harness/session/testing/storage-decorator.js +41 -0
- package/dist/harness/session/testing/storage-decorator.js.map +1 -0
- package/dist/harness/session/testing/types.d.ts +12 -0
- package/dist/harness/session/testing/types.d.ts.map +1 -0
- package/dist/harness/session/testing/types.js +2 -0
- package/dist/harness/session/testing/types.js.map +1 -0
- package/dist/harness/session/types.d.ts +512 -0
- package/dist/harness/session/types.d.ts.map +1 -0
- package/dist/harness/session/types.js +9 -0
- package/dist/harness/session/types.js.map +1 -0
- package/dist/harness/session/values.d.ts +95 -0
- package/dist/harness/session/values.d.ts.map +1 -0
- package/dist/harness/session/values.js +81 -0
- package/dist/harness/session/values.js.map +1 -0
- package/dist/harness/skills.d.ts +46 -0
- package/dist/harness/skills.d.ts.map +1 -0
- package/dist/harness/skills.js +326 -0
- package/dist/harness/skills.js.map +1 -0
- package/dist/harness/system-prompt.d.ts +3 -0
- package/dist/harness/system-prompt.d.ts.map +1 -0
- package/dist/harness/system-prompt.js +30 -0
- package/dist/harness/system-prompt.js.map +1 -0
- package/dist/harness/telemetry.d.ts +1242 -0
- package/dist/harness/telemetry.d.ts.map +1 -0
- package/dist/harness/telemetry.js +527 -0
- package/dist/harness/telemetry.js.map +1 -0
- package/dist/harness/tools/bash.d.ts +27 -0
- package/dist/harness/tools/bash.d.ts.map +1 -0
- package/dist/harness/tools/bash.js +105 -0
- package/dist/harness/tools/bash.js.map +1 -0
- package/dist/harness/tools/edit-diff.d.ts +89 -0
- package/dist/harness/tools/edit-diff.d.ts.map +1 -0
- package/dist/harness/tools/edit-diff.js +386 -0
- package/dist/harness/tools/edit-diff.js.map +1 -0
- package/dist/harness/tools/edit.d.ts +19 -0
- package/dist/harness/tools/edit.d.ts.map +1 -0
- package/dist/harness/tools/edit.js +108 -0
- package/dist/harness/tools/edit.js.map +1 -0
- package/dist/harness/tools/file-mutation-queue.d.ts +5 -0
- package/dist/harness/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/harness/tools/file-mutation-queue.js +46 -0
- package/dist/harness/tools/file-mutation-queue.js.map +1 -0
- package/dist/harness/tools/image.d.ts +3 -0
- package/dist/harness/tools/image.d.ts.map +1 -0
- package/dist/harness/tools/image.js +106 -0
- package/dist/harness/tools/image.js.map +1 -0
- package/dist/harness/tools/index.d.ts +6 -0
- package/dist/harness/tools/index.d.ts.map +1 -0
- package/dist/harness/tools/index.js +5 -0
- package/dist/harness/tools/index.js.map +1 -0
- package/dist/harness/tools/path-utils.d.ts +5 -0
- package/dist/harness/tools/path-utils.d.ts.map +1 -0
- package/dist/harness/tools/path-utils.js +26 -0
- package/dist/harness/tools/path-utils.js.map +1 -0
- package/dist/harness/tools/read.d.ts +35 -0
- package/dist/harness/tools/read.d.ts.map +1 -0
- package/dist/harness/tools/read.js +108 -0
- package/dist/harness/tools/read.js.map +1 -0
- package/dist/harness/tools/tool-context.d.ts +6 -0
- package/dist/harness/tools/tool-context.d.ts.map +1 -0
- package/dist/harness/tools/tool-context.js +2 -0
- package/dist/harness/tools/tool-context.js.map +1 -0
- package/dist/harness/tools/write.d.ts +11 -0
- package/dist/harness/tools/write.d.ts.map +1 -0
- package/dist/harness/tools/write.js +31 -0
- package/dist/harness/tools/write.js.map +1 -0
- package/dist/harness/types.d.ts +305 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +75 -0
- package/dist/harness/types.js.map +1 -0
- package/dist/harness/utils/adaptive-publisher.d.ts +24 -0
- package/dist/harness/utils/adaptive-publisher.d.ts.map +1 -0
- package/dist/harness/utils/adaptive-publisher.js +79 -0
- package/dist/harness/utils/adaptive-publisher.js.map +1 -0
- package/dist/harness/utils/output-capture.d.ts +31 -0
- package/dist/harness/utils/output-capture.d.ts.map +1 -0
- package/dist/harness/utils/output-capture.js +217 -0
- package/dist/harness/utils/output-capture.js.map +1 -0
- package/dist/harness/utils/shell-output.d.ts +29 -0
- package/dist/harness/utils/shell-output.d.ts.map +1 -0
- package/dist/harness/utils/shell-output.js +71 -0
- package/dist/harness/utils/shell-output.js.map +1 -0
- package/dist/harness/utils/truncate.d.ts +71 -0
- package/dist/harness/utils/truncate.d.ts.map +1 -0
- package/dist/harness/utils/truncate.js +296 -0
- package/dist/harness/utils/truncate.js.map +1 -0
- package/dist/harness/utils/usage.d.ts +4 -0
- package/dist/harness/utils/usage.d.ts.map +1 -0
- package/dist/harness/utils/usage.js +33 -0
- package/dist/harness/utils/usage.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/proxy.d.ts +72 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +310 -0
- package/dist/proxy.js.map +1 -0
- package/dist/search/index.d.ts +29 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +2 -0
- package/dist/search/index.js.map +1 -0
- package/dist/shims/assistant-message-frame.d.ts +101 -0
- package/dist/shims/assistant-message-frame.d.ts.map +1 -0
- package/dist/shims/assistant-message-frame.js +425 -0
- package/dist/shims/assistant-message-frame.js.map +1 -0
- package/dist/shims/define-service.d.ts +46 -0
- package/dist/shims/define-service.d.ts.map +1 -0
- package/dist/shims/define-service.js +39 -0
- package/dist/shims/define-service.js.map +1 -0
- package/dist/stream-fn.d.ts +10 -0
- package/dist/stream-fn.d.ts.map +1 -0
- package/dist/stream-fn.js +17 -0
- package/dist/stream-fn.js.map +1 -0
- package/dist/types.d.ts +489 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docs/telemetry-schema.md +383 -0
- package/package.json +99 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mario Zechner
|
|
4
|
+
Copyright (c) 2026 NiumAgents
|
|
5
|
+
|
|
6
|
+
This package contains code extracted from Earendil Works `pi`
|
|
7
|
+
(`@earendil-works/pi-agent-core` 0.99.2). The upstream license is
|
|
8
|
+
reproduced in `LICENSE.upstream`.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
package/LICENSE.upstream
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mario Zechner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,171 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @taco-ai/pi-harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
The experimental **AgentHarness** that Pi 1.0 deleted from `@earendil-works/pi-agent-core`,
|
|
6
|
+
extracted into its own package so consumers can keep the 0.99.2 harness and JSONL session
|
|
7
|
+
line while running on the **latest** pi base packages.
|
|
8
|
+
|
|
9
|
+
> **This is not an official Earendil Works package.**
|
|
10
|
+
|
|
11
|
+
## Why this package exists
|
|
12
|
+
|
|
13
|
+
Pi 1.0 deleted the harness and replaced it with `@earendil-works/pi-durable`. But `pi-durable`
|
|
14
|
+
is still marked unstable — its API can and does change between releases. So an application
|
|
15
|
+
that wants to leave the 0.99.2 harness line has nothing stable to move to *yet*.
|
|
16
|
+
|
|
17
|
+
This package is the bridge for that gap. It keeps the old surface running on **current** base
|
|
18
|
+
packages, so migrating to `pi-durable` is a step you schedule, not a step you are forced into
|
|
19
|
+
by an upstream deletion. Until `pi-durable` drops its unstable marker and becomes a stable API,
|
|
20
|
+
this package is maintained: broken builds against new base packages get fixed, and the session
|
|
21
|
+
format stays byte-compatible so nothing on disk has to be rewritten.
|
|
22
|
+
|
|
23
|
+
**This package is expected to be retired once `pi-durable` is stable.** It is a compatibility
|
|
24
|
+
line with a sunset condition, not a long-term fork. When `pi-durable` settles, consumers should
|
|
25
|
+
move to it, and this package should stop taking new work.
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
Requires Node.js **22.19+**. The package is ESM-only, and the pi base packages are peers, so
|
|
30
|
+
your application must provide them. Once the first release is published:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @taco-ai/pi-harness
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Until then, build it from a checkout and consume it as a workspace or path dependency:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm install
|
|
40
|
+
pnpm build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Switching over is an import rewrite. The harness takes a pi-ai `Models` instance and a model:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { createModels } from "@earendil-works/pi-ai"; // register your provider(s) here
|
|
47
|
+
import { AgentHarness, BACKGROUND_CONTEXT } from "@taco-ai/pi-harness";
|
|
48
|
+
import { NodeExecutionEnv } from "@taco-ai/pi-harness/harness/env/nodejs";
|
|
49
|
+
import { JsonlSessionRepo } from "@taco-ai/pi-harness/harness/session";
|
|
50
|
+
|
|
51
|
+
const models = createModels(); // your app's configured Models instance
|
|
52
|
+
const model = models.getModel("anthropic", "claude-opus-4-7");
|
|
53
|
+
if (!model) throw new Error("configure a provider and model first");
|
|
54
|
+
|
|
55
|
+
const fileSystem = new NodeExecutionEnv({ cwd: process.cwd() });
|
|
56
|
+
const repo = new JsonlSessionRepo({ fileSystem, sessionsRoot: ".sessions" });
|
|
57
|
+
const session = await repo.create({ cwd: process.cwd() }, BACKGROUND_CONTEXT);
|
|
58
|
+
|
|
59
|
+
const { harness } = await AgentHarness.create({ session, models, model }, BACKGROUND_CONTEXT);
|
|
60
|
+
const lane = await harness.lane("main", BACKGROUND_CONTEXT);
|
|
61
|
+
await lane.prompt("Hello", undefined, BACKGROUND_CONTEXT);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Provenance
|
|
65
|
+
|
|
66
|
+
Extracted from [`earendil-works/pi`](https://github.com/earendil-works/pi) at **tag `v0.99.2`**,
|
|
67
|
+
package `@earendil-works/pi-agent-core` (`packages/agent`). Upstream is MIT, © Mario Zechner —
|
|
68
|
+
see `LICENSE.upstream`. The vendored shims are marked in `src/shims/`.
|
|
69
|
+
|
|
70
|
+
Pi 1.0 removed `AgentHarness`, the session/storage layer, compaction, skills, prompt templates
|
|
71
|
+
and the whole `./harness/*` surface from `pi-agent-core`, replacing them with `pi-durable`.
|
|
72
|
+
This package keeps the old surface alive without depending on a dead version.
|
|
73
|
+
|
|
74
|
+
## What is in scope
|
|
75
|
+
|
|
76
|
+
| Content | In this package |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `AgentHarness`, agent loop, lanes, hooks | yes |
|
|
79
|
+
| `JsonlSessionRepo` and the session/storage layer | yes |
|
|
80
|
+
| Compaction, branch summarization | yes |
|
|
81
|
+
| Skills, prompt templates, tools (`read`/`write`/`edit`) | yes |
|
|
82
|
+
| Telemetry spans and schemas — see [`docs/telemetry-schema.md`](./docs/telemetry-schema.md) | yes |
|
|
83
|
+
| `NodeExecutionEnv` and the other execution envs | yes |
|
|
84
|
+
| pico3 (the experimental harness) | yes |
|
|
85
|
+
| Your own session/permission/protocol layer | no — keep it in your app |
|
|
86
|
+
|
|
87
|
+
The export map mirrors the old `pi-agent-core` subpaths one-for-one (`.`, `./node`,
|
|
88
|
+
`./harness/context`, `./harness/session`, `./harness/env/nodejs`,
|
|
89
|
+
`./harness/runtime/reducer`, `./harness/session/testing`, `./experimental/pico3`) so switching
|
|
90
|
+
over is an import rewrite, not a redesign.
|
|
91
|
+
|
|
92
|
+
## Dependencies
|
|
93
|
+
|
|
94
|
+
The pi base packages are **peer** dependencies, pinned to the latest line:
|
|
95
|
+
|
|
96
|
+
```jsonc
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"@earendil-works/pi-ai": "^1.3.0",
|
|
99
|
+
"@earendil-works/chord": "^1.3.0",
|
|
100
|
+
"@earendil-works/pi-telemetry": "^1.3.0"
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
There is deliberately **no** dependency on `@earendil-works/pi-agent-core` (any version — 1.x
|
|
105
|
+
has no harness) and none on `@earendil-works/pi-durable` (a separate migration track).
|
|
106
|
+
|
|
107
|
+
What is frozen here is the **harness/session API and the JSONL format**. The **model stack
|
|
108
|
+
tracks upstream**, so new models, auth fixes and provider fixes arrive by bumping the peers.
|
|
109
|
+
|
|
110
|
+
## Vendored shims
|
|
111
|
+
|
|
112
|
+
Two upstream APIs this harness needs were removed from the base packages. Both are vendored
|
|
113
|
+
under `src/shims/` — verbatim except for their imports — rather than pinning the package to an
|
|
114
|
+
old base version:
|
|
115
|
+
|
|
116
|
+
| Shim | Removed from | Why it is safe to vendor |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| `assistant-message-frame.ts` | `pi-ai@1.3.0` | `AssistantMessageFrame`, `AssistantMessageFrameEncoder` and `reduceAssistantMessageFrames` were removed as "unused" *because* the harness was being deleted. The frames are part of the on-disk session format, so reimplementing them would break session compatibility. Frozen on purpose. |
|
|
119
|
+
| `define-service.ts` | `chord@1.x` | Chord dropped the whole facet/service subsystem. `defineService` was a frozen identity descriptor (`Object.freeze({ id, local })`) with no runtime coupling to the chord kernel, and nothing in this package hands a descriptor to a chord host. The new `Service` in `chord/object` is a different concept and is not a drop-in replacement. |
|
|
120
|
+
|
|
121
|
+
Both shims are marked with the upstream version they came from and a note not to "fix them up".
|
|
122
|
+
|
|
123
|
+
## Session compatibility
|
|
124
|
+
|
|
125
|
+
The JSONL session format is **byte-compatible with 0.99.2**. Existing session directories open
|
|
126
|
+
and continue without migration. `test/harness/memory-conformance.test.ts` is the conformance
|
|
127
|
+
gate; run it with:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pnpm run test:session:conformance
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Maintenance rules
|
|
134
|
+
|
|
135
|
+
- **Fix breakage, do not chase features.** Compile and runtime fixes against new base-package
|
|
136
|
+
versions are in scope. Porting harness features from `pi-durable` is not.
|
|
137
|
+
- **Do not unfreeze the shims.** Session compatibility depends on them.
|
|
138
|
+
- **Sunset condition:** maintain until `@earendil-works/pi-durable` removes its unstable marker
|
|
139
|
+
and becomes a stable API. After that this line takes no new work — the migration target has
|
|
140
|
+
arrived and consumers should be on it.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pnpm install
|
|
146
|
+
pnpm build # tsc -p tsconfig.build.json
|
|
147
|
+
pnpm test # full suite (878 tests)
|
|
148
|
+
pnpm test:harness # harness suite (788 tests)
|
|
149
|
+
pnpm run test:session:conformance # JSONL conformance gate
|
|
150
|
+
pnpm docs:telemetry # regenerate docs/telemetry-schema.md
|
|
151
|
+
pnpm docs:telemetry:check # fail if the generated doc is stale
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Tests resolve `@earendil-works/pi-ai`, `chord` and `pi-telemetry` from `node_modules` — the
|
|
155
|
+
published 1.x builds, not sibling monorepo source. That is the point of the package: the suite
|
|
156
|
+
is the evidence that the frozen harness runs against the latest base packages.
|
|
157
|
+
|
|
158
|
+
`docs/telemetry-schema.md` is generated from the exported telemetry schemas. Regenerate it with
|
|
159
|
+
`pnpm docs:telemetry` instead of editing it by hand; `docs:telemetry:check` verifies that the
|
|
160
|
+
checked-in copy is current. `docs/` ships in the published tarball.
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT. See `LICENSE` (this package) and `LICENSE.upstream` (the original Earendil Works terms).
|
|
165
|
+
|
|
166
|
+
[`earendil-works/pi`](https://github.com/earendil-works/pi) is MIT © Mario Zechner.
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
Security-sensitive reports are best sent privately to `niuma1024@outlook.com`. Everything
|
|
171
|
+
else — bugs, ideas, questions — is welcome as a GitHub issue.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @taco-ai/pi-harness
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
把 Pi 1.0 从 `@earendil-works/pi-agent-core` 中删除的实验性 **AgentHarness** 抽取为独立包,
|
|
6
|
+
让使用方在运行 **最新版** pi 基础包的同时,保留 0.99.2 的 harness 与 JSONL 会话线。
|
|
7
|
+
|
|
8
|
+
> **本包不是 Earendil Works 官方包。**
|
|
9
|
+
|
|
10
|
+
## 为什么需要这个包
|
|
11
|
+
|
|
12
|
+
Pi 1.0 删掉了 harness,改由 `@earendil-works/pi-durable` 取代。但 `pi-durable` 目前仍标记为
|
|
13
|
+
不稳定 —— 它的 API 会在版本之间发生变动。想要离开 0.99.2 harness 线的应用,眼下**没有**
|
|
14
|
+
一个稳定的目标可以迁移过去。
|
|
15
|
+
|
|
16
|
+
本包就是为这段空窗期准备的过渡层:让旧接口继续跑在**当前**基础包上,使迁移到
|
|
17
|
+
`pi-durable` 成为一件你可以排期去做的事,而不是被上游删除逼着立刻做的事。在
|
|
18
|
+
`pi-durable` 去掉不稳定标记、转为稳定 API 之前,本包会持续维护:针对新基础包的构建失败
|
|
19
|
+
会被修复,会话格式保持逐字节兼容,磁盘上的会话不需要重写。
|
|
20
|
+
|
|
21
|
+
**预期在 `pi-durable` 稳定之后本包即行退出。** 这是一条带退出条件的兼容性线,而不是一个
|
|
22
|
+
长期 fork。当 `pi-durable` 稳定下来,使用方应当迁移过去,本包也应停止接受新工作。
|
|
23
|
+
|
|
24
|
+
## 快速开始
|
|
25
|
+
|
|
26
|
+
需要 Node.js **22.19+**。本包仅支持 ESM;pi 基础包是 peer 依赖,需要由你的应用提供。
|
|
27
|
+
首个版本发布后可直接安装:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm add @taco-ai/pi-harness
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
在此之前,请在本地检出并构建,再以 workspace 或 path 依赖的方式引入:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pnpm install
|
|
37
|
+
pnpm build
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
切换过来本质上只是改 import。harness 接收 pi-ai `Models` 实例和模型:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { createModels } from "@earendil-works/pi-ai"; // 在这里注册你的 provider
|
|
44
|
+
import { AgentHarness, BACKGROUND_CONTEXT } from "@taco-ai/pi-harness";
|
|
45
|
+
import { NodeExecutionEnv } from "@taco-ai/pi-harness/harness/env/nodejs";
|
|
46
|
+
import { JsonlSessionRepo } from "@taco-ai/pi-harness/harness/session";
|
|
47
|
+
|
|
48
|
+
const models = createModels(); // 你应用里已配置好的 Models 实例
|
|
49
|
+
const model = models.getModel("anthropic", "claude-opus-4-7");
|
|
50
|
+
if (!model) throw new Error("请先配置 provider 与模型");
|
|
51
|
+
|
|
52
|
+
const fileSystem = new NodeExecutionEnv({ cwd: process.cwd() });
|
|
53
|
+
const repo = new JsonlSessionRepo({ fileSystem, sessionsRoot: ".sessions" });
|
|
54
|
+
const session = await repo.create({ cwd: process.cwd() }, BACKGROUND_CONTEXT);
|
|
55
|
+
|
|
56
|
+
const { harness } = await AgentHarness.create({ session, models, model }, BACKGROUND_CONTEXT);
|
|
57
|
+
const lane = await harness.lane("main", BACKGROUND_CONTEXT);
|
|
58
|
+
await lane.prompt("Hello", undefined, BACKGROUND_CONTEXT);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 来源
|
|
62
|
+
|
|
63
|
+
抽取自 [`earendil-works/pi`](https://github.com/earendil-works/pi) 的 **`v0.99.2`** 标签,
|
|
64
|
+
对应包为 `@earendil-works/pi-agent-core`(`packages/agent`)。上游为 MIT,© Mario Zechner ——
|
|
65
|
+
见 `LICENSE.upstream`。内置的 shim 在 `src/shims/` 中有标注。
|
|
66
|
+
|
|
67
|
+
Pi 1.0 从 `pi-agent-core` 中移除了 `AgentHarness`、session/storage 层、compaction、skills、
|
|
68
|
+
prompt templates 以及整个 `./harness/*` 接口,改由 `pi-durable` 取代。本包在不依赖已停更
|
|
69
|
+
版本的前提下,让旧接口继续可用。
|
|
70
|
+
|
|
71
|
+
## 收录范围
|
|
72
|
+
|
|
73
|
+
| 内容 | 是否在本包中 |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `AgentHarness`、agent loop、lanes、hooks | 是 |
|
|
76
|
+
| `JsonlSessionRepo` 及 session/storage 层 | 是 |
|
|
77
|
+
| Compaction、branch summarization | 是 |
|
|
78
|
+
| Skills、prompt templates、工具(`read`/`write`/`edit`) | 是 |
|
|
79
|
+
| Telemetry span 与 schema —— 见 [`docs/telemetry-schema.md`](./docs/telemetry-schema.md) | 是 |
|
|
80
|
+
| `NodeExecutionEnv` 及其他 execution env | 是 |
|
|
81
|
+
| pico3(实验性 harness) | 是 |
|
|
82
|
+
| 你自己的 session/permission/protocol 层 | 否 —— 留在你的应用里 |
|
|
83
|
+
|
|
84
|
+
导出映射与旧 `pi-agent-core` 的子路径一一对应(`.`、`./node`、`./harness/context`、
|
|
85
|
+
`./harness/session`、`./harness/env/nodejs`、`./harness/runtime/reducer`、
|
|
86
|
+
`./harness/session/testing`、`./experimental/pico3`),因此切换过来只是改 import,
|
|
87
|
+
不需要重新设计。
|
|
88
|
+
|
|
89
|
+
## 依赖
|
|
90
|
+
|
|
91
|
+
pi 基础包是 **peer** 依赖,固定在最新版本线上:
|
|
92
|
+
|
|
93
|
+
```jsonc
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@earendil-works/pi-ai": "^1.3.0",
|
|
96
|
+
"@earendil-works/chord": "^1.3.0",
|
|
97
|
+
"@earendil-works/pi-telemetry": "^1.3.0"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
刻意**不**依赖 `@earendil-works/pi-agent-core`(任何版本都不依赖 —— 1.x 已无 harness),
|
|
102
|
+
也**不**依赖 `@earendil-works/pi-durable`(那是另一条迁移路线)。
|
|
103
|
+
|
|
104
|
+
这里冻结的是 **harness/session API 与 JSONL 格式**。**模型栈跟随上游**,所以新模型、
|
|
105
|
+
鉴权修复和 provider 修复通过升级 peer 即可获得。
|
|
106
|
+
|
|
107
|
+
## 内置 shim
|
|
108
|
+
|
|
109
|
+
harness 需要的两个上游 API 已从基础包中移除。两者都内置在 `src/shims/` 下 —— 除 import
|
|
110
|
+
外保持原样 —— 而不是把整个包固定在旧的基础包版本上:
|
|
111
|
+
|
|
112
|
+
| Shim | 移除自 | 为什么内置是安全的 |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| `assistant-message-frame.ts` | `pi-ai@1.3.0` | `AssistantMessageFrame`、`AssistantMessageFrameEncoder` 和 `reduceAssistantMessageFrames` 被以「未使用」为由移除 —— 原因正是 harness 正在被删除。这些 frame 是磁盘会话格式的一部分,重新实现会破坏会话兼容性。属于有意冻结。 |
|
|
115
|
+
| `define-service.ts` | `chord@1.x` | Chord 整个丢弃了 facet/service 子系统。`defineService` 原是一个冻结的身份描述符(`Object.freeze({ id, local })`),与 chord 内核没有运行时耦合,本包也没有任何地方把描述符交给 chord host。`chord/object` 中的新 `Service` 是另一个概念,不能作为直接替代。 |
|
|
116
|
+
|
|
117
|
+
两个 shim 都标注了它们来自哪个上游版本,并注明不要「顺手修好」它们。
|
|
118
|
+
|
|
119
|
+
## 会话兼容性
|
|
120
|
+
|
|
121
|
+
JSONL 会话格式与 0.99.2 **逐字节兼容**。既有会话目录可直接打开并继续使用,无需迁移。
|
|
122
|
+
`test/harness/memory-conformance.test.ts` 是一致性校验,运行方式:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pnpm run test:session:conformance
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 维护规则
|
|
129
|
+
|
|
130
|
+
- **只修破坏性问题,不追新功能。** 针对新基础包版本的编译与运行时修复在范围内;
|
|
131
|
+
从 `pi-durable` 移植 harness 功能不在范围内。
|
|
132
|
+
- **不要解冻 shim。** 会话兼容性依赖它们。
|
|
133
|
+
- **退出条件:** 维护到 `@earendil-works/pi-durable` 去掉不稳定标记、API 转为稳定为止。
|
|
134
|
+
之后这条线不再接受新工作 —— 迁移目标已经就位,使用方应当迁移过去。
|
|
135
|
+
|
|
136
|
+
## 开发
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
pnpm install
|
|
140
|
+
pnpm build # tsc -p tsconfig.build.json
|
|
141
|
+
pnpm test # 全量测试(878 个)
|
|
142
|
+
pnpm test:harness # harness 测试(788 个)
|
|
143
|
+
pnpm run test:session:conformance # JSONL 一致性校验
|
|
144
|
+
pnpm docs:telemetry # 重新生成 docs/telemetry-schema.md
|
|
145
|
+
pnpm docs:telemetry:check # 检查生成文档是否已过期
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
测试从 `node_modules` 解析 `@earendil-works/pi-ai`、`chord` 和 `pi-telemetry` ——
|
|
149
|
+
用的是已发布的 1.x 构建,而不是同仓库 monorepo 的源码。这正是本包的要点:
|
|
150
|
+
测试套件就是「冻结的 harness 能跑在最新基础包上」的证据。
|
|
151
|
+
|
|
152
|
+
`docs/telemetry-schema.md` 由导出的 telemetry schema 生成,请用 `pnpm docs:telemetry`
|
|
153
|
+
重新生成,不要手工编辑;`docs:telemetry:check` 会校验仓库内的副本是否最新。`docs/` 会随
|
|
154
|
+
npm 包一起分发。
|
|
155
|
+
|
|
156
|
+
## 许可证
|
|
157
|
+
|
|
158
|
+
MIT。见 `LICENSE`(本包)与 `LICENSE.upstream`(Earendil Works 原始条款)。
|
|
159
|
+
|
|
160
|
+
[`earendil-works/pi`](https://github.com/earendil-works/pi) 为 MIT © Mario Zechner。
|
|
161
|
+
|
|
162
|
+
## 参与贡献
|
|
163
|
+
|
|
164
|
+
安全相关的报告,建议私下发送至 `niuma1024@outlook.com`。其余问题 —— bug、想法、
|
|
165
|
+
疑问 —— 欢迎提 GitHub issue。
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent loop that works with AgentMessage throughout.
|
|
3
|
+
* Transforms to Message[] only at the LLM call boundary.
|
|
4
|
+
*/
|
|
5
|
+
import { type AssistantMessage, EventStream } from "@earendil-works/pi-ai";
|
|
6
|
+
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, AgentTool, AgentToolCall, AgentToolCallOutcome, AgentToolResult, StreamFn } from "./types.ts";
|
|
7
|
+
export type AgentEventSink = (event: AgentEvent) => Promise<void> | void;
|
|
8
|
+
/**
|
|
9
|
+
* Start an agent loop with a new prompt message.
|
|
10
|
+
* The prompt is added to the context and events are emitted for it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function agentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, signal: AbortSignal | undefined, streamFn: StreamFn): EventStream<AgentEvent, AgentMessage[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Continue an agent loop from the current context without adding a new message.
|
|
15
|
+
* Used for retries - context already has user message or tool results.
|
|
16
|
+
*
|
|
17
|
+
* **Important:** The last message in context must convert to a `user` or `toolResult` message
|
|
18
|
+
* via `convertToLlm`. If it doesn't, the LLM provider will reject the request.
|
|
19
|
+
* This cannot be validated here since `convertToLlm` is only called once per turn.
|
|
20
|
+
*/
|
|
21
|
+
export declare function agentLoopContinue(context: AgentContext, config: AgentLoopConfig, signal: AbortSignal | undefined, streamFn: StreamFn): EventStream<AgentEvent, AgentMessage[]>;
|
|
22
|
+
export declare function runAgentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, emit: AgentEventSink, signal: AbortSignal | undefined, streamFn: StreamFn): Promise<AgentMessage[]>;
|
|
23
|
+
export declare function runAgentLoopContinue(context: AgentContext, config: AgentLoopConfig, emit: AgentEventSink, signal: AbortSignal | undefined, streamFn: StreamFn): Promise<AgentMessage[]>;
|
|
24
|
+
/** The `beforeToolCall` and `afterToolCall` hooks of {@link AgentLoopConfig}. */
|
|
25
|
+
export type ToolCallHooks = Pick<AgentLoopConfig, "beforeToolCall" | "afterToolCall">;
|
|
26
|
+
type ToolUpdateSink = (partialResult: AgentToolResult<any>) => Promise<void> | void;
|
|
27
|
+
/** Options for {@link runToolCall}. */
|
|
28
|
+
export interface RunToolCallOptions extends ToolCallHooks {
|
|
29
|
+
/** Tools the call resolves against. */
|
|
30
|
+
tools: readonly AgentTool<any>[];
|
|
31
|
+
/** Passed to the hooks as the message that issued the call. */
|
|
32
|
+
assistantMessage: AssistantMessage;
|
|
33
|
+
/** Passed to the hooks as the current agent context. */
|
|
34
|
+
context: AgentContext;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
onUpdate?: ToolUpdateSink;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Run one tool call through the same steps as a model-issued call: argument preparation, schema
|
|
40
|
+
* validation, `beforeToolCall`, execution, and `afterToolCall`. Emits no events and adds no
|
|
41
|
+
* messages. Tools that call other tools use this so the hooks (for example permission checks)
|
|
42
|
+
* apply to those calls too.
|
|
43
|
+
*
|
|
44
|
+
* Never rejects for tool failures: unknown tools, validation errors, blocked calls, and thrown
|
|
45
|
+
* errors come back as `isError: true`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function runToolCall(toolCall: AgentToolCall, options: RunToolCallOptions): Promise<AgentToolCallOutcome>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=agent-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../src/agent-loop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,gBAAgB,EACrB,WAAW,EASX,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,YAAY,EACZ,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,eAAe,EAEf,QAAQ,EACR,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,SAAS,CACxB,OAAO,EAAE,YAAY,EAAE,EACvB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,EAAE,QAAQ,GAChB,WAAW,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,CAiBzC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,EAAE,QAAQ,GAChB,WAAW,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,CAwBzC;AAED,wBAAsB,YAAY,CACjC,OAAO,EAAE,YAAY,EAAE,EACvB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAiBzB;AAED,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAiBzB;AAmhBD,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,EAAE,gBAAgB,GAAG,eAAe,CAAC,CAAC;AAEtF,KAAK,cAAc,GAAG,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAwGpF,uCAAuC;AACvC,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACxD,uCAAuC;IACvC,KAAK,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IACjC,+DAA+D;IAC/D,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,wDAAwD;IACxD,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAQrH"}
|