@sema-agent/core 1.279.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 +104 -0
- package/NOTICE.md +30 -0
- package/README.md +143 -0
- package/README.zh-CN.md +138 -0
- package/dist/agents/agent-definition.d.ts +3 -0
- package/dist/agents/agent-definition.d.ts.map +1 -0
- package/dist/agents/agent-definition.js +9 -0
- package/dist/agents/agent-definition.js.map +1 -0
- package/dist/agents/builtin-agents.d.ts +9 -0
- package/dist/agents/builtin-agents.d.ts.map +1 -0
- package/dist/agents/builtin-agents.js +114 -0
- package/dist/agents/builtin-agents.js.map +1 -0
- package/dist/agents/cascade.d.ts +44 -0
- package/dist/agents/cascade.d.ts.map +1 -0
- package/dist/agents/cascade.js +153 -0
- package/dist/agents/cascade.js.map +1 -0
- package/dist/agents/observer.d.ts +122 -0
- package/dist/agents/observer.d.ts.map +1 -0
- package/dist/agents/observer.js +365 -0
- package/dist/agents/observer.js.map +1 -0
- package/dist/agents/repair-loop.d.ts +49 -0
- package/dist/agents/repair-loop.d.ts.map +1 -0
- package/dist/agents/repair-loop.js +147 -0
- package/dist/agents/repair-loop.js.map +1 -0
- package/dist/agents/session-util.d.ts +3 -0
- package/dist/agents/session-util.d.ts.map +1 -0
- package/dist/agents/session-util.js +4 -0
- package/dist/agents/session-util.js.map +1 -0
- package/dist/agents/subagent-steps.d.ts +31 -0
- package/dist/agents/subagent-steps.d.ts.map +1 -0
- package/dist/agents/subagent-steps.js +167 -0
- package/dist/agents/subagent-steps.js.map +1 -0
- package/dist/agents/subagent.d.ts +152 -0
- package/dist/agents/subagent.d.ts.map +1 -0
- package/dist/agents/subagent.js +1698 -0
- package/dist/agents/subagent.js.map +1 -0
- package/dist/agents/suspend-guard.d.ts +6 -0
- package/dist/agents/suspend-guard.d.ts.map +1 -0
- package/dist/agents/suspend-guard.js +19 -0
- package/dist/agents/suspend-guard.js.map +1 -0
- package/dist/agents/teacher.d.ts +70 -0
- package/dist/agents/teacher.d.ts.map +1 -0
- package/dist/agents/teacher.js +462 -0
- package/dist/agents/teacher.js.map +1 -0
- package/dist/agents/team.d.ts +92 -0
- package/dist/agents/team.d.ts.map +1 -0
- package/dist/agents/team.js +231 -0
- package/dist/agents/team.js.map +1 -0
- package/dist/agents/tool-filter.d.ts +4 -0
- package/dist/agents/tool-filter.d.ts.map +1 -0
- package/dist/agents/tool-filter.js +18 -0
- package/dist/agents/tool-filter.js.map +1 -0
- package/dist/agents/verify.d.ts +46 -0
- package/dist/agents/verify.d.ts.map +1 -0
- package/dist/agents/verify.js +177 -0
- package/dist/agents/verify.js.map +1 -0
- package/dist/bench/metrics.d.ts +259 -0
- package/dist/bench/metrics.d.ts.map +1 -0
- package/dist/bench/metrics.js +439 -0
- package/dist/bench/metrics.js.map +1 -0
- package/dist/bin/sema-tb.d.ts +3 -0
- package/dist/bin/sema-tb.d.ts.map +1 -0
- package/dist/bin/sema-tb.js +373 -0
- package/dist/bin/sema-tb.js.map +1 -0
- package/dist/bin/tb-env.d.ts +2 -0
- package/dist/bin/tb-env.d.ts.map +1 -0
- package/dist/bin/tb-env.js +15 -0
- package/dist/bin/tb-env.js.map +1 -0
- package/dist/brain/anthropic.d.ts +16 -0
- package/dist/brain/anthropic.d.ts.map +1 -0
- package/dist/brain/anthropic.js +635 -0
- package/dist/brain/anthropic.js.map +1 -0
- package/dist/brain/circuit-breaker.d.ts +26 -0
- package/dist/brain/circuit-breaker.d.ts.map +1 -0
- package/dist/brain/circuit-breaker.js +118 -0
- package/dist/brain/circuit-breaker.js.map +1 -0
- package/dist/brain/degrading.d.ts +33 -0
- package/dist/brain/degrading.d.ts.map +1 -0
- package/dist/brain/degrading.js +175 -0
- package/dist/brain/degrading.js.map +1 -0
- package/dist/brain/errors.d.ts +14 -0
- package/dist/brain/errors.d.ts.map +1 -0
- package/dist/brain/errors.js +43 -0
- package/dist/brain/errors.js.map +1 -0
- package/dist/brain/failover.d.ts +3 -0
- package/dist/brain/failover.d.ts.map +1 -0
- package/dist/brain/failover.js +85 -0
- package/dist/brain/failover.js.map +1 -0
- package/dist/brain/model-presets.d.ts +5 -0
- package/dist/brain/model-presets.d.ts.map +1 -0
- package/dist/brain/model-presets.js +30 -0
- package/dist/brain/model-presets.js.map +1 -0
- package/dist/brain/openai.d.ts +13 -0
- package/dist/brain/openai.d.ts.map +1 -0
- package/dist/brain/openai.js +581 -0
- package/dist/brain/openai.js.map +1 -0
- package/dist/brain/reasoning.d.ts +33 -0
- package/dist/brain/reasoning.d.ts.map +1 -0
- package/dist/brain/reasoning.js +84 -0
- package/dist/brain/reasoning.js.map +1 -0
- package/dist/brain/repetition.d.ts +16 -0
- package/dist/brain/repetition.d.ts.map +1 -0
- package/dist/brain/repetition.js +96 -0
- package/dist/brain/repetition.js.map +1 -0
- package/dist/brain/request-params.d.ts +6 -0
- package/dist/brain/request-params.d.ts.map +1 -0
- package/dist/brain/request-params.js +44 -0
- package/dist/brain/request-params.js.map +1 -0
- package/dist/brain/retry.d.ts +3 -0
- package/dist/brain/retry.d.ts.map +1 -0
- package/dist/brain/retry.js +23 -0
- package/dist/brain/retry.js.map +1 -0
- package/dist/brain/routing.d.ts +7 -0
- package/dist/brain/routing.d.ts.map +1 -0
- package/dist/brain/routing.js +34 -0
- package/dist/brain/routing.js.map +1 -0
- package/dist/brain/status-sink.d.ts +27 -0
- package/dist/brain/status-sink.d.ts.map +1 -0
- package/dist/brain/status-sink.js +20 -0
- package/dist/brain/status-sink.js.map +1 -0
- package/dist/brain/stream-engine.d.ts +37 -0
- package/dist/brain/stream-engine.d.ts.map +1 -0
- package/dist/brain/stream-engine.js +295 -0
- package/dist/brain/stream-engine.js.map +1 -0
- package/dist/brain/timeout.d.ts +12 -0
- package/dist/brain/timeout.d.ts.map +1 -0
- package/dist/brain/timeout.js +34 -0
- package/dist/brain/timeout.js.map +1 -0
- package/dist/brain/tool-call-repair.d.ts +6 -0
- package/dist/brain/tool-call-repair.d.ts.map +1 -0
- package/dist/brain/tool-call-repair.js +58 -0
- package/dist/brain/tool-call-repair.js.map +1 -0
- package/dist/brain/walltime.d.ts +2 -0
- package/dist/brain/walltime.d.ts.map +1 -0
- package/dist/brain/walltime.js +2 -0
- package/dist/brain/walltime.js.map +1 -0
- package/dist/core/arg-summary.d.ts +3 -0
- package/dist/core/arg-summary.d.ts.map +1 -0
- package/dist/core/arg-summary.js +76 -0
- package/dist/core/arg-summary.js.map +1 -0
- package/dist/core/ask-question.d.ts +36 -0
- package/dist/core/ask-question.d.ts.map +1 -0
- package/dist/core/ask-question.js +171 -0
- package/dist/core/ask-question.js.map +1 -0
- package/dist/core/auto-compaction.d.ts +88 -0
- package/dist/core/auto-compaction.d.ts.map +1 -0
- package/dist/core/auto-compaction.js +253 -0
- package/dist/core/auto-compaction.js.map +1 -0
- package/dist/core/auto-mode-prompt-assets.d.ts +3 -0
- package/dist/core/auto-mode-prompt-assets.d.ts.map +1 -0
- package/dist/core/auto-mode-prompt-assets.js +3 -0
- package/dist/core/auto-mode-prompt-assets.js.map +1 -0
- package/dist/core/auto-mode-prompt.d.ts +22 -0
- package/dist/core/auto-mode-prompt.d.ts.map +1 -0
- package/dist/core/auto-mode-prompt.js +84 -0
- package/dist/core/auto-mode-prompt.js.map +1 -0
- package/dist/core/auto-mode.d.ts +35 -0
- package/dist/core/auto-mode.d.ts.map +1 -0
- package/dist/core/auto-mode.js +100 -0
- package/dist/core/auto-mode.js.map +1 -0
- package/dist/core/auto-promote.d.ts +26 -0
- package/dist/core/auto-promote.d.ts.map +1 -0
- package/dist/core/auto-promote.js +93 -0
- package/dist/core/auto-promote.js.map +1 -0
- package/dist/core/background-shell.d.ts +41 -0
- package/dist/core/background-shell.d.ts.map +1 -0
- package/dist/core/background-shell.js +21 -0
- package/dist/core/background-shell.js.map +1 -0
- package/dist/core/cache-break-detector.d.ts +29 -0
- package/dist/core/cache-break-detector.d.ts.map +1 -0
- package/dist/core/cache-break-detector.js +80 -0
- package/dist/core/cache-break-detector.js.map +1 -0
- package/dist/core/canonical-json.d.ts +3 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +68 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/checkpoint-store.d.ts +257 -0
- package/dist/core/checkpoint-store.d.ts.map +1 -0
- package/dist/core/checkpoint-store.js +292 -0
- package/dist/core/checkpoint-store.js.map +1 -0
- package/dist/core/consolidate-scope.d.ts +19 -0
- package/dist/core/consolidate-scope.d.ts.map +1 -0
- package/dist/core/consolidate-scope.js +96 -0
- package/dist/core/consolidate-scope.js.map +1 -0
- package/dist/core/context-edit.d.ts +18 -0
- package/dist/core/context-edit.d.ts.map +1 -0
- package/dist/core/context-edit.js +98 -0
- package/dist/core/context-edit.js.map +1 -0
- package/dist/core/context-guard.d.ts +14 -0
- package/dist/core/context-guard.d.ts.map +1 -0
- package/dist/core/context-guard.js +110 -0
- package/dist/core/context-guard.js.map +1 -0
- package/dist/core/dynamic-recall.d.ts +33 -0
- package/dist/core/dynamic-recall.d.ts.map +1 -0
- package/dist/core/dynamic-recall.js +77 -0
- package/dist/core/dynamic-recall.js.map +1 -0
- package/dist/core/exec-gate.d.ts +30 -0
- package/dist/core/exec-gate.d.ts.map +1 -0
- package/dist/core/exec-gate.js +106 -0
- package/dist/core/exec-gate.js.map +1 -0
- package/dist/core/exec-output-tail.d.ts +15 -0
- package/dist/core/exec-output-tail.d.ts.map +1 -0
- package/dist/core/exec-output-tail.js +39 -0
- package/dist/core/exec-output-tail.js.map +1 -0
- package/dist/core/file-snapshot-store.d.ts +53 -0
- package/dist/core/file-snapshot-store.d.ts.map +1 -0
- package/dist/core/file-snapshot-store.js +244 -0
- package/dist/core/file-snapshot-store.js.map +1 -0
- package/dist/core/git-worktree-env.d.ts +16 -0
- package/dist/core/git-worktree-env.d.ts.map +1 -0
- package/dist/core/git-worktree-env.js +40 -0
- package/dist/core/git-worktree-env.js.map +1 -0
- package/dist/core/hooks.d.ts +128 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +184 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/lsp-diagnostics.d.ts +31 -0
- package/dist/core/lsp-diagnostics.d.ts.map +1 -0
- package/dist/core/lsp-diagnostics.js +79 -0
- package/dist/core/lsp-diagnostics.js.map +1 -0
- package/dist/core/lsp-protocol.d.ts +10 -0
- package/dist/core/lsp-protocol.d.ts.map +1 -0
- package/dist/core/lsp-protocol.js +136 -0
- package/dist/core/lsp-protocol.js.map +1 -0
- package/dist/core/lsp-session.d.ts +27 -0
- package/dist/core/lsp-session.d.ts.map +1 -0
- package/dist/core/lsp-session.js +134 -0
- package/dist/core/lsp-session.js.map +1 -0
- package/dist/core/lsp.d.ts +56 -0
- package/dist/core/lsp.d.ts.map +1 -0
- package/dist/core/lsp.js +130 -0
- package/dist/core/lsp.js.map +1 -0
- package/dist/core/mcp.d.ts +108 -0
- package/dist/core/mcp.d.ts.map +1 -0
- package/dist/core/mcp.js +692 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/media-byte-cap.d.ts +13 -0
- package/dist/core/media-byte-cap.d.ts.map +1 -0
- package/dist/core/media-byte-cap.js +51 -0
- package/dist/core/media-byte-cap.js.map +1 -0
- package/dist/core/memory-engine/data-plane.d.ts +60 -0
- package/dist/core/memory-engine/data-plane.d.ts.map +1 -0
- package/dist/core/memory-engine/data-plane.js +198 -0
- package/dist/core/memory-engine/data-plane.js.map +1 -0
- package/dist/core/memory-engine/dual-root.d.ts +16 -0
- package/dist/core/memory-engine/dual-root.d.ts.map +1 -0
- package/dist/core/memory-engine/dual-root.js +75 -0
- package/dist/core/memory-engine/dual-root.js.map +1 -0
- package/dist/core/memory-engine/engine.d.ts +67 -0
- package/dist/core/memory-engine/engine.d.ts.map +1 -0
- package/dist/core/memory-engine/engine.js +828 -0
- package/dist/core/memory-engine/engine.js.map +1 -0
- package/dist/core/memory-engine/file-backend.d.ts +55 -0
- package/dist/core/memory-engine/file-backend.d.ts.map +1 -0
- package/dist/core/memory-engine/file-backend.js +752 -0
- package/dist/core/memory-engine/file-backend.js.map +1 -0
- package/dist/core/memory-engine/frontmatter.d.ts +13 -0
- package/dist/core/memory-engine/frontmatter.d.ts.map +1 -0
- package/dist/core/memory-engine/frontmatter.js +119 -0
- package/dist/core/memory-engine/frontmatter.js.map +1 -0
- package/dist/core/memory-engine/index.d.ts +13 -0
- package/dist/core/memory-engine/index.d.ts.map +1 -0
- package/dist/core/memory-engine/index.js +12 -0
- package/dist/core/memory-engine/index.js.map +1 -0
- package/dist/core/memory-engine/layout.d.ts +44 -0
- package/dist/core/memory-engine/layout.d.ts.map +1 -0
- package/dist/core/memory-engine/layout.js +459 -0
- package/dist/core/memory-engine/layout.js.map +1 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +10 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts.map +1 -0
- package/dist/core/memory-engine/memory-backend-contract.js +269 -0
- package/dist/core/memory-engine/memory-backend-contract.js.map +1 -0
- package/dist/core/memory-engine/migrate.d.ts +8 -0
- package/dist/core/memory-engine/migrate.d.ts.map +1 -0
- package/dist/core/memory-engine/migrate.js +23 -0
- package/dist/core/memory-engine/migrate.js.map +1 -0
- package/dist/core/memory-engine/scan.d.ts +8 -0
- package/dist/core/memory-engine/scan.d.ts.map +1 -0
- package/dist/core/memory-engine/scan.js +49 -0
- package/dist/core/memory-engine/scan.js.map +1 -0
- package/dist/core/memory-engine/scope-contract.d.ts +44 -0
- package/dist/core/memory-engine/scope-contract.d.ts.map +1 -0
- package/dist/core/memory-engine/scope-contract.js +205 -0
- package/dist/core/memory-engine/scope-contract.js.map +1 -0
- package/dist/core/memory-engine/sync-client.d.ts +57 -0
- package/dist/core/memory-engine/sync-client.d.ts.map +1 -0
- package/dist/core/memory-engine/sync-client.js +257 -0
- package/dist/core/memory-engine/sync-client.js.map +1 -0
- package/dist/core/memory-engine/sync.d.ts +37 -0
- package/dist/core/memory-engine/sync.d.ts.map +1 -0
- package/dist/core/memory-engine/sync.js +68 -0
- package/dist/core/memory-engine/sync.js.map +1 -0
- package/dist/core/memory-engine/types.d.ts +128 -0
- package/dist/core/memory-engine/types.d.ts.map +1 -0
- package/dist/core/memory-engine/types.js +2 -0
- package/dist/core/memory-engine/types.js.map +1 -0
- package/dist/core/memory-recall.d.ts +82 -0
- package/dist/core/memory-recall.d.ts.map +1 -0
- package/dist/core/memory-recall.js +352 -0
- package/dist/core/memory-recall.js.map +1 -0
- package/dist/core/memory-vector.d.ts +4 -0
- package/dist/core/memory-vector.d.ts.map +1 -0
- package/dist/core/memory-vector.js +31 -0
- package/dist/core/memory-vector.js.map +1 -0
- package/dist/core/memory.d.ts +112 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +512 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/message-utils.d.ts +4 -0
- package/dist/core/message-utils.d.ts.map +1 -0
- package/dist/core/message-utils.js +7 -0
- package/dist/core/message-utils.js.map +1 -0
- package/dist/core/oracle-isolation.d.ts +16 -0
- package/dist/core/oracle-isolation.d.ts.map +1 -0
- package/dist/core/oracle-isolation.js +50 -0
- package/dist/core/oracle-isolation.js.map +1 -0
- package/dist/core/permission-rules.d.ts +35 -0
- package/dist/core/permission-rules.d.ts.map +1 -0
- package/dist/core/permission-rules.js +270 -0
- package/dist/core/permission-rules.js.map +1 -0
- package/dist/core/present-plan-tool.d.ts +8 -0
- package/dist/core/present-plan-tool.d.ts.map +1 -0
- package/dist/core/present-plan-tool.js +82 -0
- package/dist/core/present-plan-tool.js.map +1 -0
- package/dist/core/pricing.d.ts +22 -0
- package/dist/core/pricing.d.ts.map +1 -0
- package/dist/core/pricing.js +23 -0
- package/dist/core/pricing.js.map +1 -0
- package/dist/core/property-harness.d.ts +40 -0
- package/dist/core/property-harness.d.ts.map +1 -0
- package/dist/core/property-harness.js +121 -0
- package/dist/core/property-harness.js.map +1 -0
- package/dist/core/push-queue.d.ts +9 -0
- package/dist/core/push-queue.d.ts.map +1 -0
- package/dist/core/push-queue.js +41 -0
- package/dist/core/push-queue.js.map +1 -0
- package/dist/core/remote-env.d.ts +105 -0
- package/dist/core/remote-env.d.ts.map +1 -0
- package/dist/core/remote-env.js +27 -0
- package/dist/core/remote-env.js.map +1 -0
- package/dist/core/roles.d.ts +35 -0
- package/dist/core/roles.d.ts.map +1 -0
- package/dist/core/roles.js +182 -0
- package/dist/core/roles.js.map +1 -0
- package/dist/core/runner/active-skill-scope.d.ts +26 -0
- package/dist/core/runner/active-skill-scope.d.ts.map +1 -0
- package/dist/core/runner/active-skill-scope.js +116 -0
- package/dist/core/runner/active-skill-scope.js.map +1 -0
- package/dist/core/runner/assemble-result.d.ts +89 -0
- package/dist/core/runner/assemble-result.d.ts.map +1 -0
- package/dist/core/runner/assemble-result.js +141 -0
- package/dist/core/runner/assemble-result.js.map +1 -0
- package/dist/core/runner/call-cap.d.ts +38 -0
- package/dist/core/runner/call-cap.d.ts.map +1 -0
- package/dist/core/runner/call-cap.js +76 -0
- package/dist/core/runner/call-cap.js.map +1 -0
- package/dist/core/runner/grounding-signal.d.ts +2 -0
- package/dist/core/runner/grounding-signal.d.ts.map +1 -0
- package/dist/core/runner/grounding-signal.js +32 -0
- package/dist/core/runner/grounding-signal.js.map +1 -0
- package/dist/core/runner/image.d.ts +6 -0
- package/dist/core/runner/image.d.ts.map +1 -0
- package/dist/core/runner/image.js +116 -0
- package/dist/core/runner/image.js.map +1 -0
- package/dist/core/runner/memory-consolidation.d.ts +52 -0
- package/dist/core/runner/memory-consolidation.d.ts.map +1 -0
- package/dist/core/runner/memory-consolidation.js +253 -0
- package/dist/core/runner/memory-consolidation.js.map +1 -0
- package/dist/core/runner/prepare-task.d.ts +219 -0
- package/dist/core/runner/prepare-task.d.ts.map +1 -0
- package/dist/core/runner/prepare-task.js +2087 -0
- package/dist/core/runner/prepare-task.js.map +1 -0
- package/dist/core/runner/prompt-suggestions.d.ts +26 -0
- package/dist/core/runner/prompt-suggestions.d.ts.map +1 -0
- package/dist/core/runner/prompt-suggestions.js +104 -0
- package/dist/core/runner/prompt-suggestions.js.map +1 -0
- package/dist/core/runner/runtask.d.ts +53 -0
- package/dist/core/runner/runtask.d.ts.map +1 -0
- package/dist/core/runner/runtask.js +2703 -0
- package/dist/core/runner/runtask.js.map +1 -0
- package/dist/core/runner/session-rule-policy.d.ts +11 -0
- package/dist/core/runner/session-rule-policy.d.ts.map +1 -0
- package/dist/core/runner/session-rule-policy.js +76 -0
- package/dist/core/runner/session-rule-policy.js.map +1 -0
- package/dist/core/runner/strict-output-schema.d.ts +21 -0
- package/dist/core/runner/strict-output-schema.d.ts.map +1 -0
- package/dist/core/runner/strict-output-schema.js +304 -0
- package/dist/core/runner/strict-output-schema.js.map +1 -0
- package/dist/core/runner/synthetic-tools.d.ts +30 -0
- package/dist/core/runner/synthetic-tools.d.ts.map +1 -0
- package/dist/core/runner/synthetic-tools.js +124 -0
- package/dist/core/runner/synthetic-tools.js.map +1 -0
- package/dist/core/runner/tool-disclosure.d.ts +46 -0
- package/dist/core/runner/tool-disclosure.d.ts.map +1 -0
- package/dist/core/runner/tool-disclosure.js +220 -0
- package/dist/core/runner/tool-disclosure.js.map +1 -0
- package/dist/core/runner/turn-attachments.d.ts +110 -0
- package/dist/core/runner/turn-attachments.d.ts.map +1 -0
- package/dist/core/runner/turn-attachments.js +334 -0
- package/dist/core/runner/turn-attachments.js.map +1 -0
- package/dist/core/runner/usage-accounting.d.ts +19 -0
- package/dist/core/runner/usage-accounting.d.ts.map +1 -0
- package/dist/core/runner/usage-accounting.js +30 -0
- package/dist/core/runner/usage-accounting.js.map +1 -0
- package/dist/core/runtime.d.ts +4 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +12 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/safety-axis-vocab.d.ts +10 -0
- package/dist/core/safety-axis-vocab.d.ts.map +1 -0
- package/dist/core/safety-axis-vocab.js +12 -0
- package/dist/core/safety-axis-vocab.js.map +1 -0
- package/dist/core/safety-merge-corpus.d.ts +11 -0
- package/dist/core/safety-merge-corpus.d.ts.map +1 -0
- package/dist/core/safety-merge-corpus.js +195 -0
- package/dist/core/safety-merge-corpus.js.map +1 -0
- package/dist/core/scheduler.d.ts +55 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +32 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/secret-env.d.ts +3 -0
- package/dist/core/secret-env.d.ts.map +1 -0
- package/dist/core/secret-env.js +13 -0
- package/dist/core/secret-env.js.map +1 -0
- package/dist/core/select-model.d.ts +11 -0
- package/dist/core/select-model.d.ts.map +1 -0
- package/dist/core/select-model.js +44 -0
- package/dist/core/select-model.js.map +1 -0
- package/dist/core/sensitive-path-policy.d.ts +9 -0
- package/dist/core/sensitive-path-policy.d.ts.map +1 -0
- package/dist/core/sensitive-path-policy.js +61 -0
- package/dist/core/sensitive-path-policy.js.map +1 -0
- package/dist/core/session-policy-store.d.ts +38 -0
- package/dist/core/session-policy-store.d.ts.map +1 -0
- package/dist/core/session-policy-store.js +112 -0
- package/dist/core/session-policy-store.js.map +1 -0
- package/dist/core/session-reconcile.d.ts +15 -0
- package/dist/core/session-reconcile.d.ts.map +1 -0
- package/dist/core/session-reconcile.js +48 -0
- package/dist/core/session-reconcile.js.map +1 -0
- package/dist/core/session-store.d.ts +36 -0
- package/dist/core/session-store.d.ts.map +1 -0
- package/dist/core/session-store.js +192 -0
- package/dist/core/session-store.js.map +1 -0
- package/dist/core/session.d.ts +44 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +27 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/spec-contract.d.ts +58 -0
- package/dist/core/spec-contract.d.ts.map +1 -0
- package/dist/core/spec-contract.js +256 -0
- package/dist/core/spec-contract.js.map +1 -0
- package/dist/core/strategy-store.d.ts +25 -0
- package/dist/core/strategy-store.d.ts.map +1 -0
- package/dist/core/strategy-store.js +81 -0
- package/dist/core/strategy-store.js.map +1 -0
- package/dist/core/stub-env.d.ts +28 -0
- package/dist/core/stub-env.d.ts.map +1 -0
- package/dist/core/stub-env.js +61 -0
- package/dist/core/stub-env.js.map +1 -0
- package/dist/core/task-notification.d.ts +56 -0
- package/dist/core/task-notification.d.ts.map +1 -0
- package/dist/core/task-notification.js +200 -0
- package/dist/core/task-notification.js.map +1 -0
- package/dist/core/task-outcome.d.ts +27 -0
- package/dist/core/task-outcome.d.ts.map +1 -0
- package/dist/core/task-outcome.js +12 -0
- package/dist/core/task-outcome.js.map +1 -0
- package/dist/core/task-registry.d.ts +188 -0
- package/dist/core/task-registry.d.ts.map +1 -0
- package/dist/core/task-registry.js +1443 -0
- package/dist/core/task-registry.js.map +1 -0
- package/dist/core/tighten-task-spec.d.ts +6 -0
- package/dist/core/tighten-task-spec.d.ts.map +1 -0
- package/dist/core/tighten-task-spec.js +50 -0
- package/dist/core/tighten-task-spec.js.map +1 -0
- package/dist/core/tool-detach.d.ts +10 -0
- package/dist/core/tool-detach.d.ts.map +1 -0
- package/dist/core/tool-detach.js +41 -0
- package/dist/core/tool-detach.js.map +1 -0
- package/dist/core/tool-errors.d.ts +8 -0
- package/dist/core/tool-errors.d.ts.map +1 -0
- package/dist/core/tool-errors.js +132 -0
- package/dist/core/tool-errors.js.map +1 -0
- package/dist/core/tool-name-aliases.d.ts +3 -0
- package/dist/core/tool-name-aliases.d.ts.map +1 -0
- package/dist/core/tool-name-aliases.js +60 -0
- package/dist/core/tool-name-aliases.js.map +1 -0
- package/dist/core/tool-policy.d.ts +75 -0
- package/dist/core/tool-policy.d.ts.map +1 -0
- package/dist/core/tool-policy.js +363 -0
- package/dist/core/tool-policy.js.map +1 -0
- package/dist/core/tool-result-budget.d.ts +17 -0
- package/dist/core/tool-result-budget.d.ts.map +1 -0
- package/dist/core/tool-result-budget.js +103 -0
- package/dist/core/tool-result-budget.js.map +1 -0
- package/dist/core/tool-result-store.d.ts +55 -0
- package/dist/core/tool-result-store.d.ts.map +1 -0
- package/dist/core/tool-result-store.js +154 -0
- package/dist/core/tool-result-store.js.map +1 -0
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +61 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/trace.d.ts +208 -0
- package/dist/core/trace.d.ts.map +1 -0
- package/dist/core/trace.js +10 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/core/types.d.ts +684 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/untrusted-egress.d.ts +7 -0
- package/dist/core/untrusted-egress.d.ts.map +1 -0
- package/dist/core/untrusted-egress.js +23 -0
- package/dist/core/untrusted-egress.js.map +1 -0
- package/dist/core/untrusted-text.d.ts +5 -0
- package/dist/core/untrusted-text.d.ts.map +1 -0
- package/dist/core/untrusted-text.js +36 -0
- package/dist/core/untrusted-text.js.map +1 -0
- package/dist/core/warm-resume.d.ts +6 -0
- package/dist/core/warm-resume.d.ts.map +1 -0
- package/dist/core/warm-resume.js +11 -0
- package/dist/core/warm-resume.js.map +1 -0
- package/dist/core/with-retry.d.ts +19 -0
- package/dist/core/with-retry.d.ts.map +1 -0
- package/dist/core/with-retry.js +36 -0
- package/dist/core/with-retry.js.map +1 -0
- package/dist/core/workflow-journal-store.d.ts +16 -0
- package/dist/core/workflow-journal-store.d.ts.map +1 -0
- package/dist/core/workflow-journal-store.js +34 -0
- package/dist/core/workflow-journal-store.js.map +1 -0
- package/dist/core/workflow-run-store-contract.d.ts +6 -0
- package/dist/core/workflow-run-store-contract.d.ts.map +1 -0
- package/dist/core/workflow-run-store-contract.js +144 -0
- package/dist/core/workflow-run-store-contract.js.map +1 -0
- package/dist/core/workflow-run-store.d.ts +54 -0
- package/dist/core/workflow-run-store.d.ts.map +1 -0
- package/dist/core/workflow-run-store.js +86 -0
- package/dist/core/workflow-run-store.js.map +1 -0
- package/dist/engine/compaction/compaction.d.ts +63 -0
- package/dist/engine/compaction/compaction.d.ts.map +1 -0
- package/dist/engine/compaction/compaction.js +770 -0
- package/dist/engine/compaction/compaction.js.map +1 -0
- package/dist/engine/compaction/utils.d.ts +19 -0
- package/dist/engine/compaction/utils.d.ts.map +1 -0
- package/dist/engine/compaction/utils.js +167 -0
- package/dist/engine/compaction/utils.js.map +1 -0
- package/dist/engine/execution-env/kill-tree.d.ts +10 -0
- package/dist/engine/execution-env/kill-tree.d.ts.map +1 -0
- package/dist/engine/execution-env/kill-tree.js +143 -0
- package/dist/engine/execution-env/kill-tree.js.map +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +98 -0
- package/dist/engine/execution-env/node-execution-env.d.ts.map +1 -0
- package/dist/engine/execution-env/node-execution-env.js +945 -0
- package/dist/engine/execution-env/node-execution-env.js.map +1 -0
- package/dist/engine/harness/agent-harness.d.ts +112 -0
- package/dist/engine/harness/agent-harness.d.ts.map +1 -0
- package/dist/engine/harness/agent-harness.js +932 -0
- package/dist/engine/harness/agent-harness.js.map +1 -0
- package/dist/engine/harness/messages.d.ts +12 -0
- package/dist/engine/harness/messages.d.ts.map +1 -0
- package/dist/engine/harness/messages.js +102 -0
- package/dist/engine/harness/messages.js.map +1 -0
- package/dist/engine/harness/types.d.ts +484 -0
- package/dist/engine/harness/types.d.ts.map +1 -0
- package/dist/engine/harness/types.js +91 -0
- package/dist/engine/harness/types.js.map +1 -0
- package/dist/engine/llm/diagnostics.d.ts +19 -0
- package/dist/engine/llm/diagnostics.d.ts.map +1 -0
- package/dist/engine/llm/diagnostics.js +28 -0
- package/dist/engine/llm/diagnostics.js.map +1 -0
- package/dist/engine/llm/event-stream.d.ts +22 -0
- package/dist/engine/llm/event-stream.d.ts.map +1 -0
- package/dist/engine/llm/event-stream.js +91 -0
- package/dist/engine/llm/event-stream.js.map +1 -0
- package/dist/engine/llm/index.d.ts +5 -0
- package/dist/engine/llm/index.d.ts.map +1 -0
- package/dist/engine/llm/index.js +5 -0
- package/dist/engine/llm/index.js.map +1 -0
- package/dist/engine/llm/types.d.ts +359 -0
- package/dist/engine/llm/types.d.ts.map +1 -0
- package/dist/engine/llm/types.js +2 -0
- package/dist/engine/llm/types.js.map +1 -0
- package/dist/engine/llm/validation.d.ts +5 -0
- package/dist/engine/llm/validation.d.ts.map +1 -0
- package/dist/engine/llm/validation.js +293 -0
- package/dist/engine/llm/validation.js.map +1 -0
- package/dist/engine/loop/agent-loop.d.ts +19 -0
- package/dist/engine/loop/agent-loop.d.ts.map +1 -0
- package/dist/engine/loop/agent-loop.js +1087 -0
- package/dist/engine/loop/agent-loop.js.map +1 -0
- package/dist/engine/loop/runtime-deps.d.ts +10 -0
- package/dist/engine/loop/runtime-deps.d.ts.map +1 -0
- package/dist/engine/loop/runtime-deps.js +19 -0
- package/dist/engine/loop/runtime-deps.js.map +1 -0
- package/dist/engine/loop/types.d.ts +209 -0
- package/dist/engine/loop/types.d.ts.map +1 -0
- package/dist/engine/loop/types.js +2 -0
- package/dist/engine/loop/types.js.map +1 -0
- package/dist/engine/lsp/frame-decoder.d.ts +3 -0
- package/dist/engine/lsp/frame-decoder.d.ts.map +1 -0
- package/dist/engine/lsp/frame-decoder.js +36 -0
- package/dist/engine/lsp/frame-decoder.js.map +1 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +49 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts.map +1 -0
- package/dist/engine/lsp/node-lsp-manager.js +267 -0
- package/dist/engine/lsp/node-lsp-manager.js.map +1 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +32 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts.map +1 -0
- package/dist/engine/lsp/stdio-lsp-transport.js +154 -0
- package/dist/engine/lsp/stdio-lsp-transport.js.map +1 -0
- package/dist/engine/session/import-validate.d.ts +13 -0
- package/dist/engine/session/import-validate.d.ts.map +1 -0
- package/dist/engine/session/import-validate.js +56 -0
- package/dist/engine/session/import-validate.js.map +1 -0
- package/dist/engine/session/memory-repo.d.ts +20 -0
- package/dist/engine/session/memory-repo.d.ts.map +1 -0
- package/dist/engine/session/memory-repo.js +54 -0
- package/dist/engine/session/memory-repo.js.map +1 -0
- package/dist/engine/session/memory-storage.d.ts +12 -0
- package/dist/engine/session/memory-storage.d.ts.map +1 -0
- package/dist/engine/session/memory-storage.js +16 -0
- package/dist/engine/session/memory-storage.js.map +1 -0
- package/dist/engine/session/repo-utils.d.ts +11 -0
- package/dist/engine/session/repo-utils.d.ts.map +1 -0
- package/dist/engine/session/repo-utils.js +40 -0
- package/dist/engine/session/repo-utils.js.map +1 -0
- package/dist/engine/session/session.d.ts +27 -0
- package/dist/engine/session/session.d.ts.map +1 -0
- package/dist/engine/session/session.js +197 -0
- package/dist/engine/session/session.js.map +1 -0
- package/dist/engine/session/storage-base.d.ts +30 -0
- package/dist/engine/session/storage-base.d.ts.map +1 -0
- package/dist/engine/session/storage-base.js +138 -0
- package/dist/engine/session/storage-base.js.map +1 -0
- package/dist/engine/session/timestamps.d.ts +3 -0
- package/dist/engine/session/timestamps.d.ts.map +1 -0
- package/dist/engine/session/timestamps.js +15 -0
- package/dist/engine/session/timestamps.js.map +1 -0
- package/dist/engine/session/uuid.d.ts +2 -0
- package/dist/engine/session/uuid.d.ts.map +1 -0
- package/dist/engine/session/uuid.js +50 -0
- package/dist/engine/session/uuid.js.map +1 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +141 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/harness.d.ts +19 -0
- package/dist/internal/harness.d.ts.map +1 -0
- package/dist/internal/harness.js +13 -0
- package/dist/internal/harness.js.map +1 -0
- package/dist/internal/llm.d.ts +3 -0
- package/dist/internal/llm.d.ts.map +1 -0
- package/dist/internal/llm.js +2 -0
- package/dist/internal/llm.js.map +1 -0
- package/dist/orchestration/builtin-workflows.d.ts +11 -0
- package/dist/orchestration/builtin-workflows.d.ts.map +1 -0
- package/dist/orchestration/builtin-workflows.js +134 -0
- package/dist/orchestration/builtin-workflows.js.map +1 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +5 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts.map +1 -0
- package/dist/orchestration/dev-vm-script-runner.js +68 -0
- package/dist/orchestration/dev-vm-script-runner.js.map +1 -0
- package/dist/orchestration/goal.d.ts +40 -0
- package/dist/orchestration/goal.d.ts.map +1 -0
- package/dist/orchestration/goal.js +190 -0
- package/dist/orchestration/goal.js.map +1 -0
- package/dist/orchestration/run-spec.d.ts +21 -0
- package/dist/orchestration/run-spec.d.ts.map +1 -0
- package/dist/orchestration/run-spec.js +201 -0
- package/dist/orchestration/run-spec.js.map +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +80 -0
- package/dist/orchestration/run-workflow-tool.d.ts.map +1 -0
- package/dist/orchestration/run-workflow-tool.js +431 -0
- package/dist/orchestration/run-workflow-tool.js.map +1 -0
- package/dist/orchestration/workflow-governance.d.ts +30 -0
- package/dist/orchestration/workflow-governance.d.ts.map +1 -0
- package/dist/orchestration/workflow-governance.js +125 -0
- package/dist/orchestration/workflow-governance.js.map +1 -0
- package/dist/orchestration/workflow-meta.d.ts +13 -0
- package/dist/orchestration/workflow-meta.d.ts.map +1 -0
- package/dist/orchestration/workflow-meta.js +367 -0
- package/dist/orchestration/workflow-meta.js.map +1 -0
- package/dist/orchestration/workflow-observe.d.ts +18 -0
- package/dist/orchestration/workflow-observe.d.ts.map +1 -0
- package/dist/orchestration/workflow-observe.js +73 -0
- package/dist/orchestration/workflow-observe.js.map +1 -0
- package/dist/orchestration/workflow-primitives.d.ts +12 -0
- package/dist/orchestration/workflow-primitives.d.ts.map +1 -0
- package/dist/orchestration/workflow-primitives.js +56 -0
- package/dist/orchestration/workflow-primitives.js.map +1 -0
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +5 -0
- package/dist/orchestration/workflow-sandbox-conformance.d.ts.map +1 -0
- package/dist/orchestration/workflow-sandbox-conformance.js +220 -0
- package/dist/orchestration/workflow-sandbox-conformance.js.map +1 -0
- package/dist/orchestration/workflow-script-runner.d.ts +39 -0
- package/dist/orchestration/workflow-script-runner.d.ts.map +1 -0
- package/dist/orchestration/workflow-script-runner.js +23 -0
- package/dist/orchestration/workflow-script-runner.js.map +1 -0
- package/dist/orchestration/workflow-script-store.d.ts +20 -0
- package/dist/orchestration/workflow-script-store.d.ts.map +1 -0
- package/dist/orchestration/workflow-script-store.js +73 -0
- package/dist/orchestration/workflow-script-store.js.map +1 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +10 -0
- package/dist/orchestration/workflow-size-guideline.d.ts.map +1 -0
- package/dist/orchestration/workflow-size-guideline.js +38 -0
- package/dist/orchestration/workflow-size-guideline.js.map +1 -0
- package/dist/orchestration/workflow.d.ts +281 -0
- package/dist/orchestration/workflow.d.ts.map +1 -0
- package/dist/orchestration/workflow.js +1095 -0
- package/dist/orchestration/workflow.js.map +1 -0
- package/dist/prompts/default.d.ts +104 -0
- package/dist/prompts/default.d.ts.map +1 -0
- package/dist/prompts/default.js +397 -0
- package/dist/prompts/default.js.map +1 -0
- package/dist/prompts/supervisor.d.ts +5 -0
- package/dist/prompts/supervisor.d.ts.map +1 -0
- package/dist/prompts/supervisor.js +107 -0
- package/dist/prompts/supervisor.js.map +1 -0
- package/dist/scenarios/env.d.ts +13 -0
- package/dist/scenarios/env.d.ts.map +1 -0
- package/dist/scenarios/env.js +40 -0
- package/dist/scenarios/env.js.map +1 -0
- package/dist/scenarios/full-body.d.ts +13 -0
- package/dist/scenarios/full-body.d.ts.map +1 -0
- package/dist/scenarios/full-body.js +20 -0
- package/dist/scenarios/full-body.js.map +1 -0
- package/dist/scenarios/scenario-registry.d.ts +47 -0
- package/dist/scenarios/scenario-registry.d.ts.map +1 -0
- package/dist/scenarios/scenario-registry.js +139 -0
- package/dist/scenarios/scenario-registry.js.map +1 -0
- package/dist/scenarios/teacher-quickstart.d.ts +14 -0
- package/dist/scenarios/teacher-quickstart.d.ts.map +1 -0
- package/dist/scenarios/teacher-quickstart.js +13 -0
- package/dist/scenarios/teacher-quickstart.js.map +1 -0
- package/dist/server/http.d.ts +19 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +115 -0
- package/dist/server/http.js.map +1 -0
- package/dist/stores/file/checkpoint-store.d.ts +40 -0
- package/dist/stores/file/checkpoint-store.d.ts.map +1 -0
- package/dist/stores/file/checkpoint-store.js +198 -0
- package/dist/stores/file/checkpoint-store.js.map +1 -0
- package/dist/stores/file/file-snapshot-store.d.ts +25 -0
- package/dist/stores/file/file-snapshot-store.d.ts.map +1 -0
- package/dist/stores/file/file-snapshot-store.js +313 -0
- package/dist/stores/file/file-snapshot-store.js.map +1 -0
- package/dist/stores/file/fs-atomic.d.ts +24 -0
- package/dist/stores/file/fs-atomic.d.ts.map +1 -0
- package/dist/stores/file/fs-atomic.js +276 -0
- package/dist/stores/file/fs-atomic.js.map +1 -0
- package/dist/stores/file/index.d.ts +45 -0
- package/dist/stores/file/index.d.ts.map +1 -0
- package/dist/stores/file/index.js +77 -0
- package/dist/stores/file/index.js.map +1 -0
- package/dist/stores/file/memory-store.d.ts +35 -0
- package/dist/stores/file/memory-store.d.ts.map +1 -0
- package/dist/stores/file/memory-store.js +300 -0
- package/dist/stores/file/memory-store.js.map +1 -0
- package/dist/stores/file/session-policy-store.d.ts +11 -0
- package/dist/stores/file/session-policy-store.d.ts.map +1 -0
- package/dist/stores/file/session-policy-store.js +96 -0
- package/dist/stores/file/session-policy-store.js.map +1 -0
- package/dist/stores/file/session-store.d.ts +24 -0
- package/dist/stores/file/session-store.d.ts.map +1 -0
- package/dist/stores/file/session-store.js +134 -0
- package/dist/stores/file/session-store.js.map +1 -0
- package/dist/stores/file/tool-result-store.d.ts +12 -0
- package/dist/stores/file/tool-result-store.d.ts.map +1 -0
- package/dist/stores/file/tool-result-store.js +44 -0
- package/dist/stores/file/tool-result-store.js.map +1 -0
- package/dist/stores/file/workflow-journal-store.d.ts +17 -0
- package/dist/stores/file/workflow-journal-store.d.ts.map +1 -0
- package/dist/stores/file/workflow-journal-store.js +104 -0
- package/dist/stores/file/workflow-journal-store.js.map +1 -0
- package/dist/stores/file/workflow-run-store.d.ts +41 -0
- package/dist/stores/file/workflow-run-store.d.ts.map +1 -0
- package/dist/stores/file/workflow-run-store.js +147 -0
- package/dist/stores/file/workflow-run-store.js.map +1 -0
- package/dist/stores/pg.d.ts +96 -0
- package/dist/stores/pg.d.ts.map +1 -0
- package/dist/stores/pg.js +451 -0
- package/dist/stores/pg.js.map +1 -0
- package/dist/tools/fs/encoding.d.ts +16 -0
- package/dist/tools/fs/encoding.d.ts.map +1 -0
- package/dist/tools/fs/encoding.js +44 -0
- package/dist/tools/fs/encoding.js.map +1 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +3 -0
- package/dist/tools/fs/gh-rate-limit.d.ts.map +1 -0
- package/dist/tools/fs/gh-rate-limit.js +16 -0
- package/dist/tools/fs/gh-rate-limit.js.map +1 -0
- package/dist/tools/fs/index.d.ts +74 -0
- package/dist/tools/fs/index.d.ts.map +1 -0
- package/dist/tools/fs/index.js +1576 -0
- package/dist/tools/fs/index.js.map +1 -0
- package/dist/tools/fs/pdf.d.ts +47 -0
- package/dist/tools/fs/pdf.d.ts.map +1 -0
- package/dist/tools/fs/pdf.js +124 -0
- package/dist/tools/fs/pdf.js.map +1 -0
- package/dist/tools/fs/repo-map.d.ts +5 -0
- package/dist/tools/fs/repo-map.d.ts.map +1 -0
- package/dist/tools/fs/repo-map.js +209 -0
- package/dist/tools/fs/repo-map.js.map +1 -0
- package/dist/tools/fs/safety.d.ts +52 -0
- package/dist/tools/fs/safety.d.ts.map +1 -0
- package/dist/tools/fs/safety.js +314 -0
- package/dist/tools/fs/safety.js.map +1 -0
- package/dist/tools/fs/search.d.ts +57 -0
- package/dist/tools/fs/search.d.ts.map +1 -0
- package/dist/tools/fs/search.js +574 -0
- package/dist/tools/fs/search.js.map +1 -0
- package/dist/tools/gitea-issue.d.ts +14 -0
- package/dist/tools/gitea-issue.d.ts.map +1 -0
- package/dist/tools/gitea-issue.js +74 -0
- package/dist/tools/gitea-issue.js.map +1 -0
- package/dist/tools/monitor.d.ts +20 -0
- package/dist/tools/monitor.d.ts.map +1 -0
- package/dist/tools/monitor.js +90 -0
- package/dist/tools/monitor.js.map +1 -0
- package/dist/tools/scheduler-tools.d.ts +15 -0
- package/dist/tools/scheduler-tools.d.ts.map +1 -0
- package/dist/tools/scheduler-tools.js +338 -0
- package/dist/tools/scheduler-tools.js.map +1 -0
- package/dist/tools/sql-adapters.d.ts +14 -0
- package/dist/tools/sql-adapters.d.ts.map +1 -0
- package/dist/tools/sql-adapters.js +13 -0
- package/dist/tools/sql-adapters.js.map +1 -0
- package/dist/tools/sql.d.ts +11 -0
- package/dist/tools/sql.d.ts.map +1 -0
- package/dist/tools/sql.js +104 -0
- package/dist/tools/sql.js.map +1 -0
- package/dist/tools/task-list.d.ts +14 -0
- package/dist/tools/task-list.d.ts.map +1 -0
- package/dist/tools/task-list.js +318 -0
- package/dist/tools/task-list.js.map +1 -0
- package/dist/tools/todo.d.ts +3 -0
- package/dist/tools/todo.d.ts.map +1 -0
- package/dist/tools/todo.js +97 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/web.d.ts +26 -0
- package/dist/tools/web.d.ts.map +1 -0
- package/dist/tools/web.js +498 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tools/worktree.d.ts +18 -0
- package/dist/tools/worktree.d.ts.map +1 -0
- package/dist/tools/worktree.js +288 -0
- package/dist/tools/worktree.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,932 @@
|
|
|
1
|
+
import { runAgentLoop } from "../loop/agent-loop.js";
|
|
2
|
+
import { resolveAgentCoreStreamFn } from "../loop/runtime-deps.js";
|
|
3
|
+
import { convertToLlm } from "./messages.js";
|
|
4
|
+
import { AgentHarnessError, CompactionError, SessionError, toError, } from "./types.js";
|
|
5
|
+
function createUserMessage(text, images) {
|
|
6
|
+
const content = [{ type: "text", text }];
|
|
7
|
+
if (images) {
|
|
8
|
+
content.push(...images);
|
|
9
|
+
}
|
|
10
|
+
return { role: "user", content, timestamp: Date.now() };
|
|
11
|
+
}
|
|
12
|
+
function createFailureMessage(model, error, aborted) {
|
|
13
|
+
return {
|
|
14
|
+
role: "assistant",
|
|
15
|
+
content: [{ type: "text", text: "" }],
|
|
16
|
+
api: model.api,
|
|
17
|
+
provider: model.provider,
|
|
18
|
+
model: model.id,
|
|
19
|
+
stopReason: aborted ? "aborted" : "error",
|
|
20
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
21
|
+
timestamp: Date.now(),
|
|
22
|
+
usage: {
|
|
23
|
+
input: 0,
|
|
24
|
+
output: 0,
|
|
25
|
+
cacheRead: 0,
|
|
26
|
+
cacheWrite: 0,
|
|
27
|
+
totalTokens: 0,
|
|
28
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function cloneStreamOptions(streamOptions) {
|
|
33
|
+
return {
|
|
34
|
+
...streamOptions,
|
|
35
|
+
headers: streamOptions?.headers ? { ...streamOptions.headers } : undefined,
|
|
36
|
+
metadata: streamOptions?.metadata ? { ...streamOptions.metadata } : undefined,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function mergeHeaders(...headers) {
|
|
40
|
+
const merged = {};
|
|
41
|
+
let hasHeaders = false;
|
|
42
|
+
for (const entry of headers) {
|
|
43
|
+
if (!entry) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
Object.assign(merged, entry);
|
|
47
|
+
hasHeaders = true;
|
|
48
|
+
}
|
|
49
|
+
return hasHeaders ? merged : undefined;
|
|
50
|
+
}
|
|
51
|
+
function applyStreamOptionsPatch(base, patch) {
|
|
52
|
+
const result = cloneStreamOptions(base);
|
|
53
|
+
if (!patch) {
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
if (Object.hasOwn(patch, "transport")) {
|
|
57
|
+
result.transport = patch.transport;
|
|
58
|
+
}
|
|
59
|
+
if (Object.hasOwn(patch, "timeoutMs")) {
|
|
60
|
+
result.timeoutMs = patch.timeoutMs;
|
|
61
|
+
}
|
|
62
|
+
if (Object.hasOwn(patch, "maxRetries")) {
|
|
63
|
+
result.maxRetries = patch.maxRetries;
|
|
64
|
+
}
|
|
65
|
+
if (Object.hasOwn(patch, "maxRetryDelayMs")) {
|
|
66
|
+
result.maxRetryDelayMs = patch.maxRetryDelayMs;
|
|
67
|
+
}
|
|
68
|
+
if (Object.hasOwn(patch, "cacheRetention")) {
|
|
69
|
+
result.cacheRetention = patch.cacheRetention;
|
|
70
|
+
}
|
|
71
|
+
if (Object.hasOwn(patch, "headers")) {
|
|
72
|
+
if (patch.headers === undefined) {
|
|
73
|
+
result.headers = undefined;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const headers = { ...result.headers };
|
|
77
|
+
for (const [key, value] of Object.entries(patch.headers)) {
|
|
78
|
+
if (value === undefined) {
|
|
79
|
+
delete headers[key];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
headers[key] = value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
result.headers = Object.keys(headers).length > 0 ? headers : undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (Object.hasOwn(patch, "metadata")) {
|
|
89
|
+
if (patch.metadata === undefined) {
|
|
90
|
+
result.metadata = undefined;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const metadata = { ...result.metadata };
|
|
94
|
+
for (const [key, value] of Object.entries(patch.metadata)) {
|
|
95
|
+
if (value === undefined) {
|
|
96
|
+
delete metadata[key];
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
metadata[key] = value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
result.metadata = Object.keys(metadata).length > 0 ? metadata : undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
const SUBSCRIBER_EVENT_TYPE = "*";
|
|
108
|
+
function normalizeHarnessError(error, fallbackCode) {
|
|
109
|
+
if (error instanceof AgentHarnessError) {
|
|
110
|
+
return error;
|
|
111
|
+
}
|
|
112
|
+
const cause = toError(error);
|
|
113
|
+
if (cause instanceof SessionError) {
|
|
114
|
+
return new AgentHarnessError("session", cause.message, cause);
|
|
115
|
+
}
|
|
116
|
+
if (cause instanceof CompactionError) {
|
|
117
|
+
return new AgentHarnessError("compaction", cause.message, cause);
|
|
118
|
+
}
|
|
119
|
+
return new AgentHarnessError(fallbackCode, cause.message, cause);
|
|
120
|
+
}
|
|
121
|
+
function normalizeHookError(error) {
|
|
122
|
+
return normalizeHarnessError(error, "hook");
|
|
123
|
+
}
|
|
124
|
+
export class AgentHarness {
|
|
125
|
+
env;
|
|
126
|
+
session;
|
|
127
|
+
phase = "idle";
|
|
128
|
+
_stopAfterTurn = false;
|
|
129
|
+
runAbortController;
|
|
130
|
+
runPromise;
|
|
131
|
+
pendingSessionWrites = [];
|
|
132
|
+
model;
|
|
133
|
+
thinkingLevel;
|
|
134
|
+
systemPrompt;
|
|
135
|
+
streamOptions;
|
|
136
|
+
getApiKeyAndHeaders;
|
|
137
|
+
runtime;
|
|
138
|
+
resources;
|
|
139
|
+
tools = new Map();
|
|
140
|
+
activeToolNames;
|
|
141
|
+
steerQueue = [];
|
|
142
|
+
steeringQueueMode;
|
|
143
|
+
maxOutputTokens;
|
|
144
|
+
maxOutputTokensPerCall;
|
|
145
|
+
callDeadlineMsPerCall;
|
|
146
|
+
loopTrace;
|
|
147
|
+
resilience;
|
|
148
|
+
maxToolConcurrency;
|
|
149
|
+
streamingToolExecution;
|
|
150
|
+
followUpQueue = [];
|
|
151
|
+
followUpQueueMode;
|
|
152
|
+
nextTurnQueue = [];
|
|
153
|
+
loopRecovery;
|
|
154
|
+
stopGate;
|
|
155
|
+
handlers = new Map();
|
|
156
|
+
constructor(options) {
|
|
157
|
+
this.env = options.env;
|
|
158
|
+
this.session = options.session;
|
|
159
|
+
this.resources = options.resources ?? {};
|
|
160
|
+
this.streamOptions = cloneStreamOptions(options.streamOptions);
|
|
161
|
+
this.systemPrompt = options.systemPrompt;
|
|
162
|
+
this.getApiKeyAndHeaders = options.getApiKeyAndHeaders;
|
|
163
|
+
this.runtime = options.runtime;
|
|
164
|
+
for (const tool of options.tools ?? []) {
|
|
165
|
+
this.tools.set(tool.name, tool);
|
|
166
|
+
}
|
|
167
|
+
this.model = options.model;
|
|
168
|
+
this.thinkingLevel = options.thinkingLevel ?? "off";
|
|
169
|
+
this.activeToolNames =
|
|
170
|
+
options.activeToolNames ?? (options.tools ?? []).map((tool) => tool.name);
|
|
171
|
+
this.steeringQueueMode = options.steeringMode ?? "one-at-a-time";
|
|
172
|
+
this.maxOutputTokens = options.maxOutputTokens;
|
|
173
|
+
this.maxOutputTokensPerCall = options.maxOutputTokensPerCall;
|
|
174
|
+
this.callDeadlineMsPerCall = options.callDeadlineMsPerCall;
|
|
175
|
+
this.loopTrace = options.loopTrace;
|
|
176
|
+
this.resilience = options.resilience;
|
|
177
|
+
this.maxToolConcurrency = options.maxToolConcurrency;
|
|
178
|
+
this.streamingToolExecution = options.streamingToolExecution;
|
|
179
|
+
this.followUpQueueMode = options.followUpMode ?? "one-at-a-time";
|
|
180
|
+
}
|
|
181
|
+
getHandlers(type) {
|
|
182
|
+
return this.handlers.get(type);
|
|
183
|
+
}
|
|
184
|
+
async emitOwn(event, signal) {
|
|
185
|
+
for (const listener of this.getHandlers(SUBSCRIBER_EVENT_TYPE) ?? []) {
|
|
186
|
+
try {
|
|
187
|
+
await listener(event, signal);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
throw normalizeHookError(error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async emitAny(event, signal) {
|
|
195
|
+
for (const listener of this.getHandlers(SUBSCRIBER_EVENT_TYPE) ?? []) {
|
|
196
|
+
try {
|
|
197
|
+
await listener(event, signal);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
throw normalizeHookError(error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async emitHook(event) {
|
|
205
|
+
const handlers = this.getHandlers(event.type);
|
|
206
|
+
if (!handlers || handlers.size === 0) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
let lastResult;
|
|
210
|
+
for (const handler of handlers) {
|
|
211
|
+
try {
|
|
212
|
+
const result = (await handler(event));
|
|
213
|
+
if (result !== undefined) {
|
|
214
|
+
lastResult = result;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
throw normalizeHookError(error);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return lastResult;
|
|
222
|
+
}
|
|
223
|
+
async emitBeforeProviderRequest(model, sessionId, streamOptions) {
|
|
224
|
+
const handlers = this.getHandlers("before_provider_request");
|
|
225
|
+
let current = cloneStreamOptions(streamOptions);
|
|
226
|
+
if (!handlers || handlers.size === 0) {
|
|
227
|
+
return current;
|
|
228
|
+
}
|
|
229
|
+
for (const handler of handlers) {
|
|
230
|
+
try {
|
|
231
|
+
const result = (await handler({
|
|
232
|
+
type: "before_provider_request",
|
|
233
|
+
model,
|
|
234
|
+
sessionId,
|
|
235
|
+
streamOptions: cloneStreamOptions(current),
|
|
236
|
+
}));
|
|
237
|
+
if (result?.streamOptions) {
|
|
238
|
+
current = applyStreamOptionsPatch(current, result.streamOptions);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
throw normalizeHookError(error);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return current;
|
|
246
|
+
}
|
|
247
|
+
async emitBeforeProviderPayload(model, payload) {
|
|
248
|
+
const handlers = this.getHandlers("before_provider_payload");
|
|
249
|
+
let current = payload;
|
|
250
|
+
if (!handlers || handlers.size === 0) {
|
|
251
|
+
return current;
|
|
252
|
+
}
|
|
253
|
+
for (const handler of handlers) {
|
|
254
|
+
try {
|
|
255
|
+
const result = (await handler({
|
|
256
|
+
type: "before_provider_payload",
|
|
257
|
+
model,
|
|
258
|
+
payload: current,
|
|
259
|
+
}));
|
|
260
|
+
if (result !== undefined) {
|
|
261
|
+
current = result.payload;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
throw normalizeHookError(error);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return current;
|
|
269
|
+
}
|
|
270
|
+
async emitQueueUpdate() {
|
|
271
|
+
await this.emitOwn({
|
|
272
|
+
type: "queue_update",
|
|
273
|
+
steer: [...this.steerQueue],
|
|
274
|
+
followUp: [...this.followUpQueue],
|
|
275
|
+
nextTurn: [...this.nextTurnQueue],
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
startRunPromise() {
|
|
279
|
+
let finish = () => { };
|
|
280
|
+
this.runPromise = new Promise((resolve) => {
|
|
281
|
+
finish = resolve;
|
|
282
|
+
});
|
|
283
|
+
return () => {
|
|
284
|
+
this.runPromise = undefined;
|
|
285
|
+
finish();
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
async createTurnState() {
|
|
289
|
+
const context = await this.session.buildContext();
|
|
290
|
+
const resources = this.getResources();
|
|
291
|
+
const sessionMetadata = await this.session.getMetadata();
|
|
292
|
+
const tools = [...this.tools.values()];
|
|
293
|
+
const activeTools = this.activeToolNames
|
|
294
|
+
.map((name) => this.tools.get(name))
|
|
295
|
+
.filter((tool) => tool !== undefined);
|
|
296
|
+
let systemPrompt = "You are a helpful assistant.";
|
|
297
|
+
if (typeof this.systemPrompt === "string") {
|
|
298
|
+
systemPrompt = this.systemPrompt;
|
|
299
|
+
}
|
|
300
|
+
else if (this.systemPrompt) {
|
|
301
|
+
systemPrompt = await this.systemPrompt({
|
|
302
|
+
env: this.env,
|
|
303
|
+
session: this.session,
|
|
304
|
+
model: this.model,
|
|
305
|
+
thinkingLevel: this.thinkingLevel,
|
|
306
|
+
activeTools,
|
|
307
|
+
resources,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
messages: context.messages,
|
|
312
|
+
resources,
|
|
313
|
+
streamOptions: cloneStreamOptions(this.streamOptions),
|
|
314
|
+
sessionId: sessionMetadata.id,
|
|
315
|
+
systemPrompt,
|
|
316
|
+
model: this.model,
|
|
317
|
+
thinkingLevel: this.thinkingLevel,
|
|
318
|
+
tools,
|
|
319
|
+
activeTools,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
createContext(turnState, systemPrompt) {
|
|
323
|
+
return {
|
|
324
|
+
systemPrompt: systemPrompt ?? turnState.systemPrompt,
|
|
325
|
+
messages: turnState.messages.slice(),
|
|
326
|
+
tools: turnState.activeTools.slice(),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
createStreamFn(getTurnState) {
|
|
330
|
+
return async (model, context, streamOptions) => {
|
|
331
|
+
const turnState = getTurnState();
|
|
332
|
+
const auth = await this.getApiKeyAndHeaders?.(model);
|
|
333
|
+
const snapshotOptions = {
|
|
334
|
+
...turnState.streamOptions,
|
|
335
|
+
headers: mergeHeaders(turnState.streamOptions.headers, auth?.headers),
|
|
336
|
+
};
|
|
337
|
+
const requestOptions = await this.emitBeforeProviderRequest(model, turnState.sessionId, snapshotOptions);
|
|
338
|
+
return resolveAgentCoreStreamFn(this.runtime)(model, context, {
|
|
339
|
+
cacheRetention: requestOptions.cacheRetention,
|
|
340
|
+
headers: requestOptions.headers,
|
|
341
|
+
maxRetries: requestOptions.maxRetries,
|
|
342
|
+
maxRetryDelayMs: requestOptions.maxRetryDelayMs,
|
|
343
|
+
metadata: requestOptions.metadata,
|
|
344
|
+
onPayload: async (payload) => await this.emitBeforeProviderPayload(model, payload),
|
|
345
|
+
onResponse: async (response) => {
|
|
346
|
+
const headers = { ...response.headers };
|
|
347
|
+
await this.emitOwn({ type: "after_provider_response", status: response.status, headers }, streamOptions?.signal);
|
|
348
|
+
},
|
|
349
|
+
reasoning: streamOptions?.reasoning,
|
|
350
|
+
maxTokens: streamOptions?.maxTokens,
|
|
351
|
+
callDeadlineMs: streamOptions?.callDeadlineMs,
|
|
352
|
+
maxTokensDynamic: streamOptions?.maxTokensDynamic,
|
|
353
|
+
staticReasoningCutDowngrade: streamOptions?.staticReasoningCutDowngrade,
|
|
354
|
+
resilience: streamOptions?.resilience,
|
|
355
|
+
signal: streamOptions?.signal,
|
|
356
|
+
sessionId: turnState.sessionId,
|
|
357
|
+
timeoutMs: requestOptions.timeoutMs,
|
|
358
|
+
transport: requestOptions.transport,
|
|
359
|
+
apiKey: auth?.apiKey,
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
async drainQueuedMessages(queue, mode) {
|
|
364
|
+
const messages = mode === "all" ? queue.splice(0) : queue.splice(0, 1);
|
|
365
|
+
if (messages.length === 0) {
|
|
366
|
+
return messages;
|
|
367
|
+
}
|
|
368
|
+
try {
|
|
369
|
+
await this.emitQueueUpdate();
|
|
370
|
+
return messages;
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
queue.unshift(...messages);
|
|
374
|
+
throw normalizeHookError(error);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
createLoopConfig(getTurnState, setTurnState) {
|
|
378
|
+
const turnState = getTurnState();
|
|
379
|
+
const self = this;
|
|
380
|
+
return {
|
|
381
|
+
model: turnState.model,
|
|
382
|
+
reasoning: turnState.thinkingLevel === "off" ? undefined : turnState.thinkingLevel,
|
|
383
|
+
...(this.maxOutputTokens !== undefined ? { maxTokens: this.maxOutputTokens } : {}),
|
|
384
|
+
...(this.maxOutputTokensPerCall !== undefined ? { maxTokensPerCall: this.maxOutputTokensPerCall } : {}),
|
|
385
|
+
...(this.callDeadlineMsPerCall !== undefined ? { callDeadlineMsPerCall: this.callDeadlineMsPerCall } : {}),
|
|
386
|
+
...(this.resilience !== undefined ? { resilience: this.resilience } : {}),
|
|
387
|
+
...(this.maxToolConcurrency !== undefined ? { maxToolConcurrency: this.maxToolConcurrency } : {}),
|
|
388
|
+
...(this.streamingToolExecution === true && (this.getHandlers("tool_call")?.size ?? 0) === 0
|
|
389
|
+
? { streamingToolExecution: true }
|
|
390
|
+
: {}),
|
|
391
|
+
convertToLlm,
|
|
392
|
+
shouldStopAfterTurn: () => this._stopAfterTurn,
|
|
393
|
+
transformContext: async (messages) => {
|
|
394
|
+
const result = await this.emitHook({ type: "context", messages: [...messages] });
|
|
395
|
+
return result?.messages ?? messages;
|
|
396
|
+
},
|
|
397
|
+
beforeToolCall: async ({ toolCall, args }) => {
|
|
398
|
+
const result = await this.emitHook({
|
|
399
|
+
type: "tool_call",
|
|
400
|
+
toolCallId: toolCall.id,
|
|
401
|
+
toolName: toolCall.name,
|
|
402
|
+
input: args,
|
|
403
|
+
});
|
|
404
|
+
return result;
|
|
405
|
+
},
|
|
406
|
+
afterToolCall: async ({ toolCall, args, result, isError }) => {
|
|
407
|
+
const patch = await this.emitHook({
|
|
408
|
+
type: "tool_result",
|
|
409
|
+
toolCallId: toolCall.id,
|
|
410
|
+
toolName: toolCall.name,
|
|
411
|
+
input: args,
|
|
412
|
+
content: result.content,
|
|
413
|
+
details: result.details,
|
|
414
|
+
isError,
|
|
415
|
+
});
|
|
416
|
+
return patch
|
|
417
|
+
? {
|
|
418
|
+
content: patch.content,
|
|
419
|
+
details: patch.details,
|
|
420
|
+
isError: patch.isError,
|
|
421
|
+
terminate: patch.terminate,
|
|
422
|
+
}
|
|
423
|
+
: undefined;
|
|
424
|
+
},
|
|
425
|
+
prepareNextTurn: async () => {
|
|
426
|
+
await this.flushPendingSessionWrites();
|
|
427
|
+
await this.emitHook({ type: "turn_boundary", model: this.model });
|
|
428
|
+
const nextTurnState = await this.createTurnState();
|
|
429
|
+
setTurnState(nextTurnState);
|
|
430
|
+
return {
|
|
431
|
+
context: this.createContext(nextTurnState),
|
|
432
|
+
model: nextTurnState.model,
|
|
433
|
+
thinkingLevel: nextTurnState.thinkingLevel,
|
|
434
|
+
};
|
|
435
|
+
},
|
|
436
|
+
getSteeringMessages: async () => this.drainQueuedMessages(this.steerQueue, this.steeringQueueMode),
|
|
437
|
+
getFollowUpMessages: async () => {
|
|
438
|
+
const queued = await this.drainQueuedMessages(this.followUpQueue, this.followUpQueueMode);
|
|
439
|
+
if (queued.length > 0)
|
|
440
|
+
return queued;
|
|
441
|
+
return this.stopGate ? await this.stopGate() : queued;
|
|
442
|
+
},
|
|
443
|
+
recovery: {
|
|
444
|
+
get truncatedOutput() {
|
|
445
|
+
return self.loopRecovery?.truncatedOutput;
|
|
446
|
+
},
|
|
447
|
+
get malformedToolUse() {
|
|
448
|
+
return self.loopRecovery?.malformedToolUse;
|
|
449
|
+
},
|
|
450
|
+
get thinkingOnly() {
|
|
451
|
+
return self.loopRecovery?.thinkingOnly;
|
|
452
|
+
},
|
|
453
|
+
get degenerateOutput() {
|
|
454
|
+
return self.loopRecovery?.degenerateOutput;
|
|
455
|
+
},
|
|
456
|
+
get walltimeCutoff() {
|
|
457
|
+
return self.loopRecovery?.walltimeCutoff;
|
|
458
|
+
},
|
|
459
|
+
get promptTooLong() {
|
|
460
|
+
const ptl = self.loopRecovery?.promptTooLong;
|
|
461
|
+
if (!ptl)
|
|
462
|
+
return undefined;
|
|
463
|
+
return {
|
|
464
|
+
detect: ptl.detect,
|
|
465
|
+
maxRetries: ptl.maxRetries,
|
|
466
|
+
withholdErrorEvents: ptl.withholdErrorEvents,
|
|
467
|
+
recover: async (_messages, attempt) => {
|
|
468
|
+
let shrank = false;
|
|
469
|
+
try {
|
|
470
|
+
shrank = await ptl.recover(attempt);
|
|
471
|
+
}
|
|
472
|
+
catch {
|
|
473
|
+
shrank = false;
|
|
474
|
+
}
|
|
475
|
+
if (!shrank)
|
|
476
|
+
return undefined;
|
|
477
|
+
const nextTurnState = await self.createTurnState();
|
|
478
|
+
setTurnState(nextTurnState);
|
|
479
|
+
return self.createContext(nextTurnState).messages;
|
|
480
|
+
},
|
|
481
|
+
};
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
setLoopRecovery(recovery) {
|
|
487
|
+
this.loopRecovery = recovery;
|
|
488
|
+
}
|
|
489
|
+
setStopGate(gate) {
|
|
490
|
+
this.stopGate = gate;
|
|
491
|
+
}
|
|
492
|
+
validateToolNames(toolNames, tools = this.tools) {
|
|
493
|
+
const missing = toolNames.filter((name) => !tools.has(name));
|
|
494
|
+
if (missing.length > 0) {
|
|
495
|
+
throw new AgentHarnessError("invalid_argument", `Unknown tool(s): ${missing.join(", ")}`);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async flushPendingSessionWrites() {
|
|
499
|
+
if (this.runAbortController?.signal.aborted) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
while (this.pendingSessionWrites.length > 0) {
|
|
503
|
+
const write = this.pendingSessionWrites[0];
|
|
504
|
+
if (write.type === "message") {
|
|
505
|
+
await this.session.appendMessage(write.message);
|
|
506
|
+
}
|
|
507
|
+
else if (write.type === "model_change") {
|
|
508
|
+
await this.session.appendModelChange(write.provider, write.modelId);
|
|
509
|
+
}
|
|
510
|
+
else if (write.type === "thinking_level_change") {
|
|
511
|
+
await this.session.appendThinkingLevelChange(write.thinkingLevel);
|
|
512
|
+
}
|
|
513
|
+
else if (write.type === "custom") {
|
|
514
|
+
await this.session.appendCustomEntry(write.customType, write.data);
|
|
515
|
+
}
|
|
516
|
+
else if (write.type === "custom_message") {
|
|
517
|
+
await this.session.appendCustomMessageEntry(write.customType, write.content, write.display, write.details);
|
|
518
|
+
}
|
|
519
|
+
else if (write.type === "label") {
|
|
520
|
+
await this.session.appendLabel(write.targetId, write.label);
|
|
521
|
+
}
|
|
522
|
+
else if (write.type === "session_info") {
|
|
523
|
+
await this.session.appendSessionName(write.name ?? "");
|
|
524
|
+
}
|
|
525
|
+
else if (write.type === "leaf") {
|
|
526
|
+
await this.session.getStorage().setLeafId(write.targetId);
|
|
527
|
+
}
|
|
528
|
+
this.pendingSessionWrites.shift();
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
async handleAgentEvent(event, signal) {
|
|
532
|
+
if (event.type === "message_end") {
|
|
533
|
+
let entryId;
|
|
534
|
+
if (!isEmptyFailureAssistant(event.message)) {
|
|
535
|
+
entryId = await this.session.appendMessage(event.message);
|
|
536
|
+
}
|
|
537
|
+
await this.emitAny(entryId !== undefined ? { ...event, entryId } : event, signal);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (event.type === "turn_end") {
|
|
541
|
+
let eventError;
|
|
542
|
+
try {
|
|
543
|
+
await this.emitAny(event, signal);
|
|
544
|
+
}
|
|
545
|
+
catch (error) {
|
|
546
|
+
eventError = error;
|
|
547
|
+
}
|
|
548
|
+
const queued = this.pendingSessionWrites.length > 0;
|
|
549
|
+
await this.flushPendingSessionWrites();
|
|
550
|
+
const hadPendingMutations = queued && this.pendingSessionWrites.length === 0;
|
|
551
|
+
if (eventError) {
|
|
552
|
+
throw toLintErrorObject(eventError, "Non-Error thrown");
|
|
553
|
+
}
|
|
554
|
+
await this.emitOwn({ type: "save_point", hadPendingMutations });
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (event.type === "agent_end") {
|
|
558
|
+
await this.flushPendingSessionWrites();
|
|
559
|
+
this.phase = "idle";
|
|
560
|
+
await this.emitAny(event, signal);
|
|
561
|
+
await this.emitOwn({ type: "settled", nextTurnCount: this.nextTurnQueue.length }, signal);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
await this.emitAny(event, signal);
|
|
565
|
+
}
|
|
566
|
+
async emitRunFailure(model, error, aborted, signal) {
|
|
567
|
+
const failureMessage = createFailureMessage(model, error, aborted);
|
|
568
|
+
await this.handleAgentEvent({ type: "message_start", message: failureMessage }, signal);
|
|
569
|
+
await this.handleAgentEvent({ type: "message_end", message: failureMessage }, signal);
|
|
570
|
+
await this.handleAgentEvent({ type: "turn_end", message: failureMessage, toolResults: [] }, signal);
|
|
571
|
+
await this.handleAgentEvent({ type: "agent_end", messages: [failureMessage] }, signal);
|
|
572
|
+
return [failureMessage];
|
|
573
|
+
}
|
|
574
|
+
async executeTurn(turnState, text, options) {
|
|
575
|
+
let activeTurnState = turnState;
|
|
576
|
+
let messages = [createUserMessage(text, options?.images)];
|
|
577
|
+
if (this.nextTurnQueue.length > 0) {
|
|
578
|
+
const queuedMessages = this.nextTurnQueue.splice(0);
|
|
579
|
+
try {
|
|
580
|
+
await this.emitQueueUpdate();
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
this.nextTurnQueue.unshift(...queuedMessages);
|
|
584
|
+
throw normalizeHookError(error);
|
|
585
|
+
}
|
|
586
|
+
messages = [...queuedMessages, messages[0]];
|
|
587
|
+
}
|
|
588
|
+
const beforeResult = await this.emitHook({
|
|
589
|
+
type: "before_agent_start",
|
|
590
|
+
prompt: text,
|
|
591
|
+
images: options?.images,
|
|
592
|
+
systemPrompt: turnState.systemPrompt,
|
|
593
|
+
resources: turnState.resources,
|
|
594
|
+
});
|
|
595
|
+
if (beforeResult?.messages) {
|
|
596
|
+
messages = [...messages, ...beforeResult.messages];
|
|
597
|
+
}
|
|
598
|
+
const abortController = new AbortController();
|
|
599
|
+
const getTurnState = () => activeTurnState;
|
|
600
|
+
const setTurnState = (nextTurnState) => {
|
|
601
|
+
activeTurnState = nextTurnState;
|
|
602
|
+
};
|
|
603
|
+
this.runAbortController = abortController;
|
|
604
|
+
const runResultPromise = (async () => {
|
|
605
|
+
try {
|
|
606
|
+
return await runAgentLoop(messages, this.createContext(turnState, beforeResult?.systemPrompt), this.createLoopConfig(getTurnState, setTurnState), (event) => this.handleAgentEvent(event, abortController.signal), abortController.signal, this.createStreamFn(getTurnState), undefined, this.loopTrace);
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
try {
|
|
610
|
+
return await this.emitRunFailure(activeTurnState.model, error, abortController.signal.aborted, abortController.signal);
|
|
611
|
+
}
|
|
612
|
+
catch (failureError) {
|
|
613
|
+
const cause = new AggregateError([toError(error), toError(failureError)], "Agent run failed and failure reporting failed");
|
|
614
|
+
throw new AgentHarnessError("unknown", cause.message, cause);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
})();
|
|
618
|
+
try {
|
|
619
|
+
const newMessages = await runResultPromise;
|
|
620
|
+
for (let i = newMessages.length - 1; i >= 0; i--) {
|
|
621
|
+
const message = newMessages[i];
|
|
622
|
+
if (message.role === "assistant") {
|
|
623
|
+
return mergeTruncatedOutputChain(newMessages, i, this.loopRecovery?.walltimeCutoff?.detect);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
throw new AgentHarnessError("invalid_state", "AgentHarness prompt completed without an assistant message");
|
|
627
|
+
}
|
|
628
|
+
finally {
|
|
629
|
+
try {
|
|
630
|
+
await this.flushPendingSessionWrites();
|
|
631
|
+
}
|
|
632
|
+
finally {
|
|
633
|
+
this.runAbortController = undefined;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
async prompt(text, options) {
|
|
638
|
+
if (this.phase !== "idle") {
|
|
639
|
+
throw new AgentHarnessError("busy", "AgentHarness is busy");
|
|
640
|
+
}
|
|
641
|
+
this._stopAfterTurn = false;
|
|
642
|
+
this.phase = "turn";
|
|
643
|
+
const finishRunPromise = this.startRunPromise();
|
|
644
|
+
try {
|
|
645
|
+
await this.flushPendingSessionWrites();
|
|
646
|
+
const turnState = await this.createTurnState();
|
|
647
|
+
return await this.executeTurn(turnState, text, options);
|
|
648
|
+
}
|
|
649
|
+
catch (error) {
|
|
650
|
+
this.phase = "idle";
|
|
651
|
+
throw normalizeHarnessError(error, "unknown");
|
|
652
|
+
}
|
|
653
|
+
finally {
|
|
654
|
+
finishRunPromise();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async steer(text, options) {
|
|
658
|
+
if (this.phase === "idle") {
|
|
659
|
+
throw new AgentHarnessError("invalid_state", "Cannot steer while idle");
|
|
660
|
+
}
|
|
661
|
+
this.steerQueue.push(createUserMessage(text, options?.images));
|
|
662
|
+
await this.emitQueueUpdate();
|
|
663
|
+
}
|
|
664
|
+
async followUp(text, options) {
|
|
665
|
+
if (this.phase === "idle") {
|
|
666
|
+
throw new AgentHarnessError("invalid_state", "Cannot follow up while idle");
|
|
667
|
+
}
|
|
668
|
+
this.followUpQueue.push(createUserMessage(text, options?.images));
|
|
669
|
+
await this.emitQueueUpdate();
|
|
670
|
+
}
|
|
671
|
+
async nextTurn(text, options) {
|
|
672
|
+
this.nextTurnQueue.push(createUserMessage(text, options?.images));
|
|
673
|
+
await this.emitQueueUpdate();
|
|
674
|
+
}
|
|
675
|
+
async appendMessage(message) {
|
|
676
|
+
try {
|
|
677
|
+
if (this.phase === "idle") {
|
|
678
|
+
await this.session.appendMessage(message);
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
this.pendingSessionWrites.push({ type: "message", message });
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
catch (error) {
|
|
685
|
+
throw normalizeHarnessError(error, "session");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
getModel() {
|
|
689
|
+
return this.model;
|
|
690
|
+
}
|
|
691
|
+
getThinkingLevel() {
|
|
692
|
+
return this.thinkingLevel;
|
|
693
|
+
}
|
|
694
|
+
async setModel(model) {
|
|
695
|
+
try {
|
|
696
|
+
const previousModel = this.model;
|
|
697
|
+
if (this.phase === "idle") {
|
|
698
|
+
await this.session.appendModelChange(model.provider, model.id);
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
this.pendingSessionWrites.push({
|
|
702
|
+
type: "model_change",
|
|
703
|
+
provider: model.provider,
|
|
704
|
+
modelId: model.id,
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
this.model = model;
|
|
708
|
+
await this.emitOwn({ type: "model_select", model, previousModel, source: "set" });
|
|
709
|
+
}
|
|
710
|
+
catch (error) {
|
|
711
|
+
throw normalizeHarnessError(error, "session");
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async setThinkingLevel(level) {
|
|
715
|
+
try {
|
|
716
|
+
const previousLevel = this.thinkingLevel;
|
|
717
|
+
if (this.phase === "idle") {
|
|
718
|
+
await this.session.appendThinkingLevelChange(level);
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
this.pendingSessionWrites.push({ type: "thinking_level_change", thinkingLevel: level });
|
|
722
|
+
}
|
|
723
|
+
this.thinkingLevel = level;
|
|
724
|
+
await this.emitOwn({ type: "thinking_level_select", level, previousLevel });
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
throw normalizeHarnessError(error, "session");
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
async setActiveTools(toolNames) {
|
|
731
|
+
try {
|
|
732
|
+
this.validateToolNames(toolNames);
|
|
733
|
+
this.activeToolNames = [...toolNames];
|
|
734
|
+
}
|
|
735
|
+
catch (error) {
|
|
736
|
+
throw normalizeHarnessError(error, "invalid_argument");
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
getSteeringMode() {
|
|
740
|
+
return this.steeringQueueMode;
|
|
741
|
+
}
|
|
742
|
+
async setSteeringMode(mode) {
|
|
743
|
+
this.steeringQueueMode = mode;
|
|
744
|
+
}
|
|
745
|
+
getFollowUpMode() {
|
|
746
|
+
return this.followUpQueueMode;
|
|
747
|
+
}
|
|
748
|
+
async setFollowUpMode(mode) {
|
|
749
|
+
this.followUpQueueMode = mode;
|
|
750
|
+
}
|
|
751
|
+
getResources() {
|
|
752
|
+
return {
|
|
753
|
+
skills: this.resources.skills?.slice(),
|
|
754
|
+
promptTemplates: this.resources.promptTemplates?.slice(),
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
async setResources(resources) {
|
|
758
|
+
const previousResources = this.getResources();
|
|
759
|
+
this.resources = {
|
|
760
|
+
skills: resources.skills?.slice(),
|
|
761
|
+
promptTemplates: resources.promptTemplates?.slice(),
|
|
762
|
+
};
|
|
763
|
+
await this.emitOwn({
|
|
764
|
+
type: "resources_update",
|
|
765
|
+
resources: this.getResources(),
|
|
766
|
+
previousResources,
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
getStreamOptions() {
|
|
770
|
+
return cloneStreamOptions(this.streamOptions);
|
|
771
|
+
}
|
|
772
|
+
async setStreamOptions(streamOptions) {
|
|
773
|
+
this.streamOptions = cloneStreamOptions(streamOptions);
|
|
774
|
+
}
|
|
775
|
+
async setTools(tools, activeToolNames) {
|
|
776
|
+
try {
|
|
777
|
+
const nextTools = new Map(tools.map((tool) => [tool.name, tool]));
|
|
778
|
+
const nextActiveToolNames = activeToolNames ? [...activeToolNames] : this.activeToolNames;
|
|
779
|
+
this.validateToolNames(nextActiveToolNames, nextTools);
|
|
780
|
+
this.tools = nextTools;
|
|
781
|
+
this.activeToolNames = [...nextActiveToolNames];
|
|
782
|
+
}
|
|
783
|
+
catch (error) {
|
|
784
|
+
throw normalizeHarnessError(error, "invalid_argument");
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
requestStopAfterTurn() {
|
|
788
|
+
this._stopAfterTurn = true;
|
|
789
|
+
}
|
|
790
|
+
async flushQueuedSessionWrites() {
|
|
791
|
+
try {
|
|
792
|
+
await this.flushPendingSessionWrites();
|
|
793
|
+
}
|
|
794
|
+
catch (error) {
|
|
795
|
+
throw normalizeHarnessError(error, "session");
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
async abort() {
|
|
799
|
+
const clearedSteer = [...this.steerQueue];
|
|
800
|
+
const clearedFollowUp = [...this.followUpQueue];
|
|
801
|
+
this.steerQueue = [];
|
|
802
|
+
this.followUpQueue = [];
|
|
803
|
+
this.runAbortController?.abort();
|
|
804
|
+
const errors = [];
|
|
805
|
+
try {
|
|
806
|
+
await this.emitQueueUpdate();
|
|
807
|
+
}
|
|
808
|
+
catch (error) {
|
|
809
|
+
errors.push(toError(error));
|
|
810
|
+
}
|
|
811
|
+
try {
|
|
812
|
+
await this.waitForIdle();
|
|
813
|
+
}
|
|
814
|
+
catch (error) {
|
|
815
|
+
errors.push(toError(error));
|
|
816
|
+
}
|
|
817
|
+
try {
|
|
818
|
+
await this.emitOwn({ type: "abort", clearedSteer, clearedFollowUp });
|
|
819
|
+
}
|
|
820
|
+
catch (error) {
|
|
821
|
+
errors.push(toError(error));
|
|
822
|
+
}
|
|
823
|
+
if (errors.length > 0) {
|
|
824
|
+
const cause = errors.length === 1 ? errors[0] : new AggregateError(errors, "Abort completed with errors");
|
|
825
|
+
throw normalizeHarnessError(cause, "hook");
|
|
826
|
+
}
|
|
827
|
+
return { clearedSteer, clearedFollowUp };
|
|
828
|
+
}
|
|
829
|
+
async waitForIdle() {
|
|
830
|
+
await this.runPromise;
|
|
831
|
+
}
|
|
832
|
+
subscribe(listener) {
|
|
833
|
+
let handlers = this.handlers.get(SUBSCRIBER_EVENT_TYPE);
|
|
834
|
+
if (!handlers) {
|
|
835
|
+
handlers = new Set();
|
|
836
|
+
this.handlers.set(SUBSCRIBER_EVENT_TYPE, handlers);
|
|
837
|
+
}
|
|
838
|
+
handlers.add(listener);
|
|
839
|
+
return () => handlers.delete(listener);
|
|
840
|
+
}
|
|
841
|
+
on(type, handler) {
|
|
842
|
+
let handlers = this.handlers.get(type);
|
|
843
|
+
if (!handlers) {
|
|
844
|
+
handlers = new Set();
|
|
845
|
+
this.handlers.set(type, handlers);
|
|
846
|
+
}
|
|
847
|
+
handlers.add(handler);
|
|
848
|
+
return () => handlers.delete(handler);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function isEmptyFailureAssistant(message) {
|
|
852
|
+
if (message.role !== "assistant")
|
|
853
|
+
return false;
|
|
854
|
+
const m = message;
|
|
855
|
+
if (m.stopReason !== "aborted" && m.stopReason !== "error")
|
|
856
|
+
return false;
|
|
857
|
+
return m.content.every((c) => c.type === "text" ? c.text.trim() === "" : c.type === "thinking" ? c.thinking.trim() === "" : false);
|
|
858
|
+
}
|
|
859
|
+
function mergeTruncatedOutputChain(messages, lastAssistantIndex, isWalltimeCutoff) {
|
|
860
|
+
const last = messages[lastAssistantIndex];
|
|
861
|
+
const lastText = last.content.map((c) => (c.type === "text" ? c.text : "")).join("");
|
|
862
|
+
const parts = [];
|
|
863
|
+
let i = lastAssistantIndex;
|
|
864
|
+
while (i - 2 >= 0) {
|
|
865
|
+
const mid = messages[i - 1];
|
|
866
|
+
const downstreamText = parts.join("") + lastText;
|
|
867
|
+
const walltimeGate = last.stopReason === "error" || downstreamText.trim() === "";
|
|
868
|
+
let head;
|
|
869
|
+
let walltimeStep = false;
|
|
870
|
+
let nextI = i - 2;
|
|
871
|
+
if (mid.role === "custom") {
|
|
872
|
+
const h = messages[i - 2];
|
|
873
|
+
if (h.role !== "assistant")
|
|
874
|
+
break;
|
|
875
|
+
const assistant = h;
|
|
876
|
+
const step = (mid.customType === "loop:truncated-output-continue" && assistant.stopReason === "length") ||
|
|
877
|
+
(mid.customType === "loop:midstream-partial-continue" && assistant.stopReason === "stop") ||
|
|
878
|
+
(mid.customType === "loop:walltime-cutoff-recovery" && assistant.stopReason === "error" && walltimeGate);
|
|
879
|
+
if (!step)
|
|
880
|
+
break;
|
|
881
|
+
head = assistant;
|
|
882
|
+
walltimeStep = mid.customType === "loop:walltime-cutoff-recovery";
|
|
883
|
+
}
|
|
884
|
+
else if (mid.role === "user" && isWalltimeCutoff) {
|
|
885
|
+
let j = i - 1;
|
|
886
|
+
while (j >= 0 && messages[j].role === "user")
|
|
887
|
+
j--;
|
|
888
|
+
if (j < 0 || j >= i - 1)
|
|
889
|
+
break;
|
|
890
|
+
const h = messages[j];
|
|
891
|
+
if (h.role !== "assistant")
|
|
892
|
+
break;
|
|
893
|
+
const assistant = h;
|
|
894
|
+
if (!(assistant.stopReason === "error" && isWalltimeCutoff(assistant) && walltimeGate))
|
|
895
|
+
break;
|
|
896
|
+
head = assistant;
|
|
897
|
+
walltimeStep = true;
|
|
898
|
+
nextI = j;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
const headText = head.content.map((c) => (c.type === "text" ? c.text : "")).join("");
|
|
904
|
+
const needsBreak = walltimeStep && downstreamText !== "" && headText !== "";
|
|
905
|
+
parts.unshift(needsBreak ? `${headText}\n\n` : headText);
|
|
906
|
+
i = nextI;
|
|
907
|
+
}
|
|
908
|
+
if (parts.length === 0) {
|
|
909
|
+
return last;
|
|
910
|
+
}
|
|
911
|
+
return {
|
|
912
|
+
...last,
|
|
913
|
+
content: [
|
|
914
|
+
{ type: "text", text: parts.join("") + lastText },
|
|
915
|
+
...last.content.filter((c) => c.type !== "text"),
|
|
916
|
+
],
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
function toLintErrorObject(value, fallbackMessage) {
|
|
920
|
+
if (value instanceof Error) {
|
|
921
|
+
return value;
|
|
922
|
+
}
|
|
923
|
+
if (typeof value === "string") {
|
|
924
|
+
return new Error(value);
|
|
925
|
+
}
|
|
926
|
+
const error = new Error(fallbackMessage, { cause: value });
|
|
927
|
+
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
|
928
|
+
Object.assign(error, value);
|
|
929
|
+
}
|
|
930
|
+
return error;
|
|
931
|
+
}
|
|
932
|
+
//# sourceMappingURL=agent-harness.js.map
|