@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,770 @@
|
|
|
1
|
+
import { resolveAgentCoreCompleteFn, } from "../loop/runtime-deps.js";
|
|
2
|
+
import { asAgentMessage, convertToLlm, createCompactionSummaryMessage, createCustomMessage, } from "../harness/messages.js";
|
|
3
|
+
import { buildSessionContext } from "../session/session.js";
|
|
4
|
+
import { CompactionError, err, ok, } from "../harness/types.js";
|
|
5
|
+
import { computeFileLists, createFileOps, extractFileOpsFromMessage, formatFileOperations, serializeConversation, stripFileOperationsFooter, } from "./utils.js";
|
|
6
|
+
function safeJsonStringify(value) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.stringify(value) ?? "undefined";
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return "[unserializable]";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function extractFileOperations(messages, entries, prevCompactionIndex) {
|
|
15
|
+
const fileOps = createFileOps();
|
|
16
|
+
if (prevCompactionIndex >= 0) {
|
|
17
|
+
const prevCompaction = entries[prevCompactionIndex];
|
|
18
|
+
if (!prevCompaction.fromHook && prevCompaction.details) {
|
|
19
|
+
const details = prevCompaction.details;
|
|
20
|
+
if (Array.isArray(details.readFiles)) {
|
|
21
|
+
for (const f of details.readFiles) {
|
|
22
|
+
fileOps.read.add(f);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(details.modifiedFiles)) {
|
|
26
|
+
for (const f of details.modifiedFiles) {
|
|
27
|
+
fileOps.edited.add(f);
|
|
28
|
+
}
|
|
29
|
+
const prevRecency = details.modifiedFilesByRecency;
|
|
30
|
+
if (Array.isArray(prevRecency)) {
|
|
31
|
+
for (const f of prevRecency.toReversed()) {
|
|
32
|
+
fileOps.modifiedOrder.add(f);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const msg of messages) {
|
|
39
|
+
extractFileOpsFromMessage(msg, fileOps);
|
|
40
|
+
}
|
|
41
|
+
return fileOps;
|
|
42
|
+
}
|
|
43
|
+
function getMessageFromEntry(entry) {
|
|
44
|
+
if (entry.type === "message") {
|
|
45
|
+
return entry.message;
|
|
46
|
+
}
|
|
47
|
+
if (entry.type === "custom_message") {
|
|
48
|
+
return asAgentMessage(createCustomMessage(entry.customType, entry.content, entry.display, entry.details, entry.timestamp));
|
|
49
|
+
}
|
|
50
|
+
if (entry.type === "compaction") {
|
|
51
|
+
return asAgentMessage(createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp));
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
function getMessageFromEntryForCompaction(entry) {
|
|
56
|
+
if (entry.type === "compaction") {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return getMessageFromEntry(entry);
|
|
60
|
+
}
|
|
61
|
+
export const DEFAULT_COMPACTION_SETTINGS = {
|
|
62
|
+
enabled: true,
|
|
63
|
+
reserveTokens: 16384,
|
|
64
|
+
keepRecentTokens: 20000,
|
|
65
|
+
};
|
|
66
|
+
export const DEFAULT_CHARS_PER_TOKEN = 4;
|
|
67
|
+
const IMAGE_TOKEN_ESTIMATE = 2000;
|
|
68
|
+
export function calculateContextTokens(usage) {
|
|
69
|
+
return usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
70
|
+
}
|
|
71
|
+
function getAssistantUsage(msg) {
|
|
72
|
+
if (msg.role === "assistant" && "usage" in msg) {
|
|
73
|
+
const assistantMsg = msg;
|
|
74
|
+
if (assistantMsg.stopReason !== "aborted" &&
|
|
75
|
+
assistantMsg.usage &&
|
|
76
|
+
calculateContextTokens(assistantMsg.usage) > 0) {
|
|
77
|
+
return assistantMsg.usage;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
export function getLastAssistantUsage(entries) {
|
|
83
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
84
|
+
const entry = entries[i];
|
|
85
|
+
if (entry.type === "message") {
|
|
86
|
+
const usage = getAssistantUsage(entry.message);
|
|
87
|
+
if (usage) {
|
|
88
|
+
return usage;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
function getLastAssistantUsageInfo(messages) {
|
|
95
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
96
|
+
const usage = getAssistantUsage(messages[i]);
|
|
97
|
+
if (usage) {
|
|
98
|
+
return { usage, index: i };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
export function estimateContextTokens(messages, charsPerToken = DEFAULT_CHARS_PER_TOKEN) {
|
|
104
|
+
const usageInfo = getLastAssistantUsageInfo(messages);
|
|
105
|
+
if (!usageInfo) {
|
|
106
|
+
let estimated = 0;
|
|
107
|
+
for (const message of messages) {
|
|
108
|
+
estimated += estimateTokens(message, charsPerToken);
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
tokens: estimated,
|
|
112
|
+
usageTokens: 0,
|
|
113
|
+
trailingTokens: estimated,
|
|
114
|
+
lastUsageIndex: null,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const usageTokens = calculateContextTokens(usageInfo.usage);
|
|
118
|
+
let trailingTokens = 0;
|
|
119
|
+
for (let i = usageInfo.index + 1; i < messages.length; i++) {
|
|
120
|
+
trailingTokens += estimateTokens(messages[i], charsPerToken);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
tokens: usageTokens + trailingTokens,
|
|
124
|
+
usageTokens,
|
|
125
|
+
trailingTokens,
|
|
126
|
+
lastUsageIndex: usageInfo.index,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export function shouldCompact(contextTokens, contextWindow, settings) {
|
|
130
|
+
if (!settings.enabled) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return contextTokens > contextWindow - settings.reserveTokens;
|
|
134
|
+
}
|
|
135
|
+
export function estimateTokens(message, charsPerToken = DEFAULT_CHARS_PER_TOKEN) {
|
|
136
|
+
let chars = 0;
|
|
137
|
+
const harnessMessage = message;
|
|
138
|
+
switch (harnessMessage.role) {
|
|
139
|
+
case "user": {
|
|
140
|
+
const content = harnessMessage.content;
|
|
141
|
+
let imageTokens = 0;
|
|
142
|
+
if (typeof content === "string") {
|
|
143
|
+
chars = content.length;
|
|
144
|
+
}
|
|
145
|
+
else if (Array.isArray(content)) {
|
|
146
|
+
for (const block of content) {
|
|
147
|
+
if (block.type === "text" && block.text) {
|
|
148
|
+
chars += block.text.length;
|
|
149
|
+
}
|
|
150
|
+
if (block.type === "image") {
|
|
151
|
+
imageTokens += IMAGE_TOKEN_ESTIMATE;
|
|
152
|
+
}
|
|
153
|
+
if (block.type === "document" && typeof block.data === "string") {
|
|
154
|
+
imageTokens += Math.max(IMAGE_TOKEN_ESTIMATE, Math.ceil(block.data.length / 36));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return Math.ceil(chars / charsPerToken) + imageTokens;
|
|
159
|
+
}
|
|
160
|
+
case "assistant": {
|
|
161
|
+
const assistant = harnessMessage;
|
|
162
|
+
for (const block of assistant.content) {
|
|
163
|
+
if (block.type === "text") {
|
|
164
|
+
chars += block.text.length;
|
|
165
|
+
}
|
|
166
|
+
else if (block.type === "thinking") {
|
|
167
|
+
chars += block.thinking.length + (block.thinkingSignature?.length ?? 0);
|
|
168
|
+
}
|
|
169
|
+
else if (block.type === "toolCall") {
|
|
170
|
+
chars += block.name.length + safeJsonStringify(block.arguments).length;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return Math.ceil(chars / charsPerToken);
|
|
174
|
+
}
|
|
175
|
+
case "custom":
|
|
176
|
+
case "toolResult": {
|
|
177
|
+
let imageTokens = 0;
|
|
178
|
+
if (typeof harnessMessage.content === "string") {
|
|
179
|
+
chars = harnessMessage.content.length;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
for (const block of harnessMessage.content) {
|
|
183
|
+
if (block.type === "text" && block.text) {
|
|
184
|
+
chars += block.text.length;
|
|
185
|
+
}
|
|
186
|
+
if (block.type === "image") {
|
|
187
|
+
imageTokens += IMAGE_TOKEN_ESTIMATE;
|
|
188
|
+
}
|
|
189
|
+
if (block.type === "document" && typeof block.data === "string") {
|
|
190
|
+
imageTokens += Math.max(IMAGE_TOKEN_ESTIMATE, Math.ceil(block.data.length / 36));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return Math.ceil(chars / charsPerToken) + imageTokens;
|
|
195
|
+
}
|
|
196
|
+
case "bashExecution": {
|
|
197
|
+
chars = harnessMessage.command.length + harnessMessage.output.length;
|
|
198
|
+
return Math.ceil(chars / charsPerToken);
|
|
199
|
+
}
|
|
200
|
+
case "compactionSummary": {
|
|
201
|
+
chars = harnessMessage.summary.length;
|
|
202
|
+
return Math.ceil(chars / charsPerToken);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
function findValidCutPoints(entries, startIndex, endIndex) {
|
|
208
|
+
const cutPoints = [];
|
|
209
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
210
|
+
const entry = entries[i];
|
|
211
|
+
switch (entry.type) {
|
|
212
|
+
case "message": {
|
|
213
|
+
const role = entry.message.role;
|
|
214
|
+
switch (role) {
|
|
215
|
+
case "bashExecution":
|
|
216
|
+
case "custom":
|
|
217
|
+
case "compactionSummary":
|
|
218
|
+
case "user":
|
|
219
|
+
case "assistant":
|
|
220
|
+
cutPoints.push(i);
|
|
221
|
+
break;
|
|
222
|
+
case "toolResult":
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case "custom_message":
|
|
228
|
+
cutPoints.push(i);
|
|
229
|
+
break;
|
|
230
|
+
case "thinking_level_change":
|
|
231
|
+
case "model_change":
|
|
232
|
+
case "compaction":
|
|
233
|
+
case "custom":
|
|
234
|
+
case "label":
|
|
235
|
+
case "session_info":
|
|
236
|
+
case "leaf":
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return cutPoints;
|
|
241
|
+
}
|
|
242
|
+
export function findTurnStartIndex(entries, entryIndex, startIndex) {
|
|
243
|
+
for (let i = entryIndex; i >= startIndex; i--) {
|
|
244
|
+
const entry = entries[i];
|
|
245
|
+
if (entry.type === "custom_message") {
|
|
246
|
+
return i;
|
|
247
|
+
}
|
|
248
|
+
if (entry.type === "message") {
|
|
249
|
+
const role = entry.message.role;
|
|
250
|
+
if (role === "user" || role === "bashExecution") {
|
|
251
|
+
return i;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return -1;
|
|
256
|
+
}
|
|
257
|
+
export function findCutPoint(entries, startIndex, endIndex, keepRecentTokens, charsPerToken = DEFAULT_CHARS_PER_TOKEN) {
|
|
258
|
+
const cutPoints = findValidCutPoints(entries, startIndex, endIndex);
|
|
259
|
+
if (cutPoints.length === 0) {
|
|
260
|
+
return { firstKeptEntryIndex: startIndex, turnStartIndex: -1, isSplitTurn: false };
|
|
261
|
+
}
|
|
262
|
+
let accumulatedTokens = 0;
|
|
263
|
+
let cutIndex = cutPoints[0];
|
|
264
|
+
for (let i = endIndex - 1; i >= startIndex; i--) {
|
|
265
|
+
const entry = entries[i];
|
|
266
|
+
if (entry.type !== "message") {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const messageTokens = estimateTokens(entry.message, charsPerToken);
|
|
270
|
+
accumulatedTokens += messageTokens;
|
|
271
|
+
if (accumulatedTokens >= keepRecentTokens) {
|
|
272
|
+
let found = false;
|
|
273
|
+
for (const cutPoint of cutPoints) {
|
|
274
|
+
if (cutPoint >= i) {
|
|
275
|
+
cutIndex = cutPoint;
|
|
276
|
+
found = true;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (!found) {
|
|
281
|
+
for (let c = cutPoints.length - 1; c >= 0; c--) {
|
|
282
|
+
if (cutPoints[c] <= i) {
|
|
283
|
+
cutIndex = cutPoints[c];
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
while (cutIndex > startIndex) {
|
|
292
|
+
const prevEntry = entries[cutIndex - 1];
|
|
293
|
+
if (prevEntry.type === "compaction") {
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
if (prevEntry.type === "message") {
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
cutIndex--;
|
|
300
|
+
}
|
|
301
|
+
const cutEntry = entries[cutIndex];
|
|
302
|
+
const isUserMessage = cutEntry.type === "message" && cutEntry.message.role === "user";
|
|
303
|
+
const turnStartIndex = isUserMessage ? -1 : findTurnStartIndex(entries, cutIndex, startIndex);
|
|
304
|
+
return {
|
|
305
|
+
firstKeptEntryIndex: cutIndex,
|
|
306
|
+
turnStartIndex,
|
|
307
|
+
isSplitTurn: !isUserMessage && turnStartIndex !== -1,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
export const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and an AI coding assistant, then produce a structured summary following the exact format specified.
|
|
311
|
+
|
|
312
|
+
Do NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`;
|
|
313
|
+
const SUMMARIZATION_PROMPT = `The messages above are a conversation to summarize. Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
|
314
|
+
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context. Another LLM will use it to continue the work.
|
|
315
|
+
|
|
316
|
+
Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. This analysis is scratch work — it will be stripped and NOT kept, so it is only to help you write a faithful summary. In your analysis process:
|
|
317
|
+
|
|
318
|
+
1. Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
|
|
319
|
+
- The user's explicit requests and intents
|
|
320
|
+
- Your approach to addressing the user's requests
|
|
321
|
+
- Key decisions, technical concepts and code patterns
|
|
322
|
+
- Specific details like:
|
|
323
|
+
- file names
|
|
324
|
+
- full code snippets
|
|
325
|
+
- function signatures
|
|
326
|
+
- file edits
|
|
327
|
+
- Errors that you ran into and how you fixed them
|
|
328
|
+
- Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
329
|
+
- Note any security-relevant instructions or constraints the user stated (e.g., sensitive files or data to avoid, operations that must not be performed, credential or secret handling rules). These MUST be preserved verbatim in the summary so they continue to apply after compaction.
|
|
330
|
+
2. Double-check for technical accuracy and completeness, addressing each required element thoroughly.
|
|
331
|
+
|
|
332
|
+
Then, after </analysis>, write the summary. Your summary should include the following sections:
|
|
333
|
+
|
|
334
|
+
1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
|
|
335
|
+
2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
|
|
336
|
+
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
337
|
+
4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
338
|
+
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
339
|
+
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction.
|
|
340
|
+
7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
|
|
341
|
+
8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
|
342
|
+
9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
|
|
343
|
+
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
|
|
344
|
+
|
|
345
|
+
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
|
|
346
|
+
|
|
347
|
+
Keep each section concise. Preserve exact file paths, function names, and error messages.`;
|
|
348
|
+
const UPDATE_SUMMARIZATION_PROMPT = `The messages above are NEW conversation messages to incorporate into the existing summary provided in <previous-summary> tags.
|
|
349
|
+
|
|
350
|
+
Update the existing structured summary with new information. RULES:
|
|
351
|
+
- PRESERVE all existing information from the previous summary
|
|
352
|
+
- ADD new progress, decisions, and context from the new messages
|
|
353
|
+
- UPDATE "Pending Tasks" and "Current Work" based on what was accomplished
|
|
354
|
+
- UPDATE "Optional Next Step" based on the most recent work
|
|
355
|
+
- PRESERVE exact file paths, function names, and error messages
|
|
356
|
+
- Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction
|
|
357
|
+
- If something is no longer relevant, you may remove it
|
|
358
|
+
|
|
359
|
+
First, inside an <analysis>...</analysis> block, note what is new since the previous summary and what must change. This analysis is scratch work — it will be stripped and NOT kept. Then, after </analysis>, write the updated summary with the following sections:
|
|
360
|
+
|
|
361
|
+
1. Primary Request and Intent: [Preserve existing requests and intents, add new ones if the task expanded]
|
|
362
|
+
2. Key Technical Concepts: [Preserve existing, add newly discussed concepts, technologies, and frameworks]
|
|
363
|
+
3. Files and Code Sections: [Preserve entries still relevant; add newly examined, modified, or created files with full code snippets where applicable]
|
|
364
|
+
4. Errors and fixes: [Preserve previous errors and fixes and add new ones; keep any user correction or "change of approach" feedback verbatim.]
|
|
365
|
+
5. Problem Solving: [Update problems solved and any ongoing troubleshooting efforts]
|
|
366
|
+
6. All user messages: [Preserve previously-recorded user messages VERBATIM and append any new ones that are not tool results, in order. To bound growth across repeated compactions, keep roughly the most recent 20 messages verbatim; older ones beyond that may be condensed to a single line each — but NEVER drop or paraphrase a user correction or change of direction. The exact words of recent messages are the strongest anti-drift signal. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction.]
|
|
367
|
+
7. Pending Tasks: [Update based on progress — remove completed tasks, add newly requested ones]
|
|
368
|
+
8. Current Work: [Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant]
|
|
369
|
+
9. Optional Next Step: [Update based on current state. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request — include a direct verbatim quote of that request. Do not start on tangential requests or really old requests that were already completed.]
|
|
370
|
+
|
|
371
|
+
Keep each section concise. Preserve exact file paths, function names, and error messages.`;
|
|
372
|
+
function createSummarizationOptions(model, maxTokens, apiKey, headers, signal, thinkingLevel) {
|
|
373
|
+
const options = { maxTokens, signal, apiKey, headers };
|
|
374
|
+
if (model.reasoning && thinkingLevel && thinkingLevel !== "off") {
|
|
375
|
+
options.reasoning = thinkingLevel;
|
|
376
|
+
}
|
|
377
|
+
return options;
|
|
378
|
+
}
|
|
379
|
+
async function completeSummarization(model, context, options, streamFn, runtime) {
|
|
380
|
+
if (streamFn) {
|
|
381
|
+
return (await streamFn(model, context, options)).result();
|
|
382
|
+
}
|
|
383
|
+
return await resolveAgentCoreCompleteFn(runtime)(model, context, options);
|
|
384
|
+
}
|
|
385
|
+
const SUMMARY_REASONING_FLOOR = 2048;
|
|
386
|
+
const SUMMARY_MAX_ESCALATIONS = 2;
|
|
387
|
+
const SUMMARY_WINDOW_MARGIN = 256;
|
|
388
|
+
function estimateSummarizationInputTokens(context, charsPerToken) {
|
|
389
|
+
let chars = context.systemPrompt?.length ?? 0;
|
|
390
|
+
for (const m of context.messages) {
|
|
391
|
+
const content = m.content;
|
|
392
|
+
if (typeof content === "string") {
|
|
393
|
+
chars += content.length;
|
|
394
|
+
}
|
|
395
|
+
else if (Array.isArray(content)) {
|
|
396
|
+
for (const c of content) {
|
|
397
|
+
chars += c.text?.length ?? 0;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return Math.ceil(chars / charsPerToken);
|
|
402
|
+
}
|
|
403
|
+
const SUMMARY_INPUT_HEAD_RATIO = 0.25;
|
|
404
|
+
const SUMMARY_INPUT_MIN_KEEP_CHARS = 1024;
|
|
405
|
+
const SUMMARY_INPUT_MARKER_RESERVE = 200;
|
|
406
|
+
function clampSummarizationConversation(conversationText, model, charsPerToken, fixedPromptChars, baseMaxTokens, budgetCapChars) {
|
|
407
|
+
let budgetChars = Number.POSITIVE_INFINITY;
|
|
408
|
+
if (model.contextWindow > 0) {
|
|
409
|
+
const outputReserve = Math.max(baseMaxTokens, SUMMARY_REASONING_FLOOR);
|
|
410
|
+
budgetChars =
|
|
411
|
+
(model.contextWindow - outputReserve - 2 * SUMMARY_WINDOW_MARGIN) * charsPerToken - fixedPromptChars;
|
|
412
|
+
}
|
|
413
|
+
if (budgetCapChars !== undefined) {
|
|
414
|
+
budgetChars = Math.min(budgetChars, budgetCapChars);
|
|
415
|
+
}
|
|
416
|
+
if (!Number.isFinite(budgetChars) || conversationText.length <= budgetChars) {
|
|
417
|
+
return { text: conversationText, droppedChars: 0, keptChars: conversationText.length };
|
|
418
|
+
}
|
|
419
|
+
const keep = Math.max(budgetChars - SUMMARY_INPUT_MARKER_RESERVE, SUMMARY_INPUT_MIN_KEEP_CHARS);
|
|
420
|
+
const headChars = Math.floor(keep * SUMMARY_INPUT_HEAD_RATIO);
|
|
421
|
+
const tailChars = keep - headChars;
|
|
422
|
+
const elided = conversationText.length - headChars - tailChars;
|
|
423
|
+
const text = conversationText.slice(0, headChars) +
|
|
424
|
+
`\n\n[... ${elided} characters of the conversation elided so the summarization request fits the compaction model's context window ...]\n\n` +
|
|
425
|
+
conversationText.slice(conversationText.length - tailChars);
|
|
426
|
+
return { text, droppedChars: elided, keptChars: headChars + tailChars };
|
|
427
|
+
}
|
|
428
|
+
const COMPACTION_PTL_MAX_RETRIES = 3;
|
|
429
|
+
export const COMPACTION_PTL_RETRY_MARKER = "[earlier conversation truncated for compaction retry]";
|
|
430
|
+
const PTL_NO_GAP_DROP_FRACTION = 0.2;
|
|
431
|
+
const PTL_GAP_SAFETY = 1.2;
|
|
432
|
+
const PTL_CC_GAP_RE = /prompt is too long[^0-9]*(\d+) tokens? > (\d+)/i;
|
|
433
|
+
const PTL_OPENAI_GAP_RE = /maximum context length is (\d+) tokens?[^0-9]*?(\d+) tokens?/i;
|
|
434
|
+
const PTL_CLASS_RE = /prompt is too long|too many tokens|input is too long|context[ _-]?length|context window|exceeds? the (?:model'?s? )?context/i;
|
|
435
|
+
const PTL_DENY_RE = /internal (?:server )?error|http 5\d\d|status(?: code)?[: ]5\d\d|invalid (?:api key|request)|configuration|unauthorized|permission/i;
|
|
436
|
+
function parsePromptTooLong(message) {
|
|
437
|
+
if (!message) {
|
|
438
|
+
return { isPtl: false };
|
|
439
|
+
}
|
|
440
|
+
const cc = PTL_CC_GAP_RE.exec(message);
|
|
441
|
+
if (cc) {
|
|
442
|
+
const actual = Number(cc[1]);
|
|
443
|
+
const limit = Number(cc[2]);
|
|
444
|
+
return { isPtl: true, ...(actual > limit ? { gapTokens: actual - limit } : {}) };
|
|
445
|
+
}
|
|
446
|
+
const oa = PTL_OPENAI_GAP_RE.exec(message);
|
|
447
|
+
if (oa) {
|
|
448
|
+
const limit = Number(oa[1]);
|
|
449
|
+
const requested = Number(oa[2]);
|
|
450
|
+
return { isPtl: true, ...(requested > limit ? { gapTokens: requested - limit } : {}) };
|
|
451
|
+
}
|
|
452
|
+
return { isPtl: PTL_CLASS_RE.test(message) && !PTL_DENY_RE.test(message) };
|
|
453
|
+
}
|
|
454
|
+
function splitMessageGroups(messages) {
|
|
455
|
+
const groups = [];
|
|
456
|
+
let current = [];
|
|
457
|
+
let sawAssistant = false;
|
|
458
|
+
for (const m of messages) {
|
|
459
|
+
if (sawAssistant && m.role !== "toolResult") {
|
|
460
|
+
groups.push(current);
|
|
461
|
+
current = [];
|
|
462
|
+
sawAssistant = false;
|
|
463
|
+
}
|
|
464
|
+
current.push(m);
|
|
465
|
+
if (m.role === "assistant") {
|
|
466
|
+
sawAssistant = true;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (current.length > 0) {
|
|
470
|
+
groups.push(current);
|
|
471
|
+
}
|
|
472
|
+
return groups;
|
|
473
|
+
}
|
|
474
|
+
async function summarizeWithPtlRetry(req) {
|
|
475
|
+
const disclose = (droppedChars, keptChars) => {
|
|
476
|
+
if (droppedChars <= 0) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
try {
|
|
480
|
+
req.onInputTruncated?.({ label: req.truncationLabel, droppedChars, keptChars });
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
let groups = splitMessageGroups(req.llmMessages);
|
|
486
|
+
let droppedForRetry = false;
|
|
487
|
+
let budgetCapChars;
|
|
488
|
+
for (let retry = 0;; retry++) {
|
|
489
|
+
const serialized = serializeConversation(groups.flat());
|
|
490
|
+
const conversationText = droppedForRetry
|
|
491
|
+
? `${COMPACTION_PTL_RETRY_MARKER}\n\n${serialized}`
|
|
492
|
+
: serialized;
|
|
493
|
+
const clamped = clampSummarizationConversation(conversationText, req.model, req.cpt, req.fixedPromptChars, req.baseMaxTokens, budgetCapChars);
|
|
494
|
+
disclose(clamped.droppedChars, clamped.keptChars);
|
|
495
|
+
const context = {
|
|
496
|
+
systemPrompt: SUMMARIZATION_SYSTEM_PROMPT,
|
|
497
|
+
messages: [
|
|
498
|
+
{
|
|
499
|
+
role: "user",
|
|
500
|
+
content: [{ type: "text", text: req.buildPromptText(clamped.text) }],
|
|
501
|
+
timestamp: Date.now(),
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
};
|
|
505
|
+
let result;
|
|
506
|
+
let thrown;
|
|
507
|
+
let didThrow = false;
|
|
508
|
+
try {
|
|
509
|
+
result = await summarizeWithLengthRecovery(req.label, req.model, context, req.baseMaxTokens, req.apiKey, req.headers, req.signal, req.thinkingLevel, req.streamFn, req.runtime, req.charsPerToken);
|
|
510
|
+
}
|
|
511
|
+
catch (e) {
|
|
512
|
+
didThrow = true;
|
|
513
|
+
thrown = e;
|
|
514
|
+
}
|
|
515
|
+
if (!didThrow && result && result.ok) {
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
518
|
+
const failureMessage = didThrow
|
|
519
|
+
? thrown instanceof Error
|
|
520
|
+
? thrown.message
|
|
521
|
+
: String(thrown)
|
|
522
|
+
: result && !result.ok
|
|
523
|
+
? result.error.message
|
|
524
|
+
: "";
|
|
525
|
+
const ptl = parsePromptTooLong(failureMessage);
|
|
526
|
+
if (!ptl.isPtl || retry >= COMPACTION_PTL_MAX_RETRIES || req.signal?.aborted) {
|
|
527
|
+
if (didThrow) {
|
|
528
|
+
throw thrown;
|
|
529
|
+
}
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
const sentChars = clamped.text.length;
|
|
533
|
+
const gapChars = ptl.gapTokens !== undefined
|
|
534
|
+
? Math.ceil(ptl.gapTokens * req.cpt * PTL_GAP_SAFETY)
|
|
535
|
+
: Math.ceil(sentChars * PTL_NO_GAP_DROP_FRACTION);
|
|
536
|
+
budgetCapChars = Math.max(SUMMARY_INPUT_MIN_KEEP_CHARS, sentChars - Math.max(gapChars, 1));
|
|
537
|
+
const beforeChars = serialized.length;
|
|
538
|
+
const rollbackTargetChars = Math.max(SUMMARY_INPUT_MIN_KEEP_CHARS, beforeChars - Math.max(gapChars, 1));
|
|
539
|
+
let remainingChars = beforeChars;
|
|
540
|
+
while (groups.length > 1 && remainingChars > rollbackTargetChars) {
|
|
541
|
+
const dropped = groups.shift();
|
|
542
|
+
remainingChars -= serializeConversation(dropped).length + 2;
|
|
543
|
+
}
|
|
544
|
+
droppedForRetry = true;
|
|
545
|
+
disclose(beforeChars - Math.max(remainingChars, 0), Math.max(remainingChars, 0));
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function stripAnalysisScratch(text, lengthTruncated) {
|
|
549
|
+
let out = text.replace(/<analysis>[\s\S]*?<\/analysis>\s*/gi, "");
|
|
550
|
+
if (lengthTruncated) {
|
|
551
|
+
out = out.replace(/(?:^|\n)<analysis>[\s\S]*$/i, "");
|
|
552
|
+
}
|
|
553
|
+
return out;
|
|
554
|
+
}
|
|
555
|
+
async function summarizeWithLengthRecovery(label, model, context, baseMaxTokens, apiKey, headers, signal, thinkingLevel, streamFn, runtime, charsPerToken) {
|
|
556
|
+
const cpt = charsPerToken ?? model.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN;
|
|
557
|
+
const modelCap = model.maxTokens > 0 ? model.maxTokens : Number.POSITIVE_INFINITY;
|
|
558
|
+
const windowCap = model.contextWindow > 0
|
|
559
|
+
? Math.max(baseMaxTokens, model.contextWindow - estimateSummarizationInputTokens(context, cpt) - SUMMARY_WINDOW_MARGIN)
|
|
560
|
+
: Number.POSITIVE_INFINITY;
|
|
561
|
+
const cap = Math.min(modelCap, windowCap);
|
|
562
|
+
let maxTokens = Math.min(cap, model.reasoning ? Math.max(baseMaxTokens, SUMMARY_REASONING_FLOOR) : baseMaxTokens);
|
|
563
|
+
for (let attempt = 0;; attempt++) {
|
|
564
|
+
const canEscalate = attempt < SUMMARY_MAX_ESCALATIONS && maxTokens < cap;
|
|
565
|
+
const response = await completeSummarization(model, context, createSummarizationOptions(model, maxTokens, apiKey, headers, signal, thinkingLevel), streamFn, runtime);
|
|
566
|
+
if (response.stopReason === "aborted") {
|
|
567
|
+
return err(new CompactionError("aborted", response.errorMessage || `${label} aborted`));
|
|
568
|
+
}
|
|
569
|
+
if (response.stopReason === "error") {
|
|
570
|
+
if (response.errorKind === "length_empty") {
|
|
571
|
+
if (canEscalate) {
|
|
572
|
+
maxTokens = Math.min(cap, Math.max(maxTokens * 2, SUMMARY_REASONING_FLOOR));
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
return err(new CompactionError("summarization_failed", `${label} produced an empty summary (stopReason=error, max_tokens exhausted by reasoning ` +
|
|
576
|
+
`after ${attempt + 1} attempt(s): ${response.errorMessage || "no detail"})`));
|
|
577
|
+
}
|
|
578
|
+
return err(new CompactionError("summarization_failed", `${label} failed: ${response.errorMessage || "Unknown error"}`));
|
|
579
|
+
}
|
|
580
|
+
const lengthTruncated = response.stopReason === "length";
|
|
581
|
+
const raw = response.content
|
|
582
|
+
.filter((c) => c.type === "text")
|
|
583
|
+
.map((c) => c.text)
|
|
584
|
+
.join("\n");
|
|
585
|
+
const usable = stripAnalysisScratch(raw, lengthTruncated);
|
|
586
|
+
if (usable.trim() !== "") {
|
|
587
|
+
return ok(lengthTruncated ? usable : raw);
|
|
588
|
+
}
|
|
589
|
+
if (lengthTruncated && canEscalate) {
|
|
590
|
+
maxTokens = Math.min(cap, Math.max(maxTokens * 2, SUMMARY_REASONING_FLOOR));
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
return err(new CompactionError("summarization_failed", `${label} produced an empty summary (stopReason=${response.stopReason}` +
|
|
594
|
+
`${lengthTruncated ? ", the output was analysis scratch cut at max_tokens" : ""})`));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
export async function generateSummary(currentMessages, model, reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, runtime, charsPerToken, onInputTruncated) {
|
|
598
|
+
let basePrompt = previousSummary ? UPDATE_SUMMARIZATION_PROMPT : SUMMARIZATION_PROMPT;
|
|
599
|
+
if (customInstructions) {
|
|
600
|
+
basePrompt = `${basePrompt}\n\nAdditional Instructions:\n${customInstructions}`;
|
|
601
|
+
}
|
|
602
|
+
const llmMessages = convertToLlm(currentMessages);
|
|
603
|
+
return summarizeWithPtlRetry({
|
|
604
|
+
label: "Summarization",
|
|
605
|
+
truncationLabel: "history",
|
|
606
|
+
llmMessages,
|
|
607
|
+
buildPromptText: (conversationText) => {
|
|
608
|
+
let promptText = `<conversation>\n${conversationText}\n</conversation>\n\n`;
|
|
609
|
+
if (previousSummary) {
|
|
610
|
+
promptText += `<previous-summary>\n${previousSummary}\n</previous-summary>\n\n`;
|
|
611
|
+
}
|
|
612
|
+
promptText += basePrompt;
|
|
613
|
+
return promptText;
|
|
614
|
+
},
|
|
615
|
+
model,
|
|
616
|
+
cpt: charsPerToken ?? model.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN,
|
|
617
|
+
fixedPromptChars: SUMMARIZATION_SYSTEM_PROMPT.length + basePrompt.length + (previousSummary?.length ?? 0) + 128,
|
|
618
|
+
baseMaxTokens: Math.floor(0.8 * reserveTokens),
|
|
619
|
+
apiKey,
|
|
620
|
+
headers,
|
|
621
|
+
signal,
|
|
622
|
+
thinkingLevel,
|
|
623
|
+
streamFn,
|
|
624
|
+
runtime,
|
|
625
|
+
charsPerToken,
|
|
626
|
+
onInputTruncated,
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
export function prepareCompaction(pathEntries, settings, charsPerToken = DEFAULT_CHARS_PER_TOKEN) {
|
|
630
|
+
if (pathEntries.length === 0 || pathEntries[pathEntries.length - 1].type === "compaction") {
|
|
631
|
+
return ok(undefined);
|
|
632
|
+
}
|
|
633
|
+
let prevCompactionIndex = -1;
|
|
634
|
+
for (let i = pathEntries.length - 1; i >= 0; i--) {
|
|
635
|
+
if (pathEntries[i].type === "compaction") {
|
|
636
|
+
prevCompactionIndex = i;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
let previousSummary;
|
|
641
|
+
let boundaryStart = 0;
|
|
642
|
+
if (prevCompactionIndex >= 0) {
|
|
643
|
+
const prevCompaction = pathEntries[prevCompactionIndex];
|
|
644
|
+
previousSummary = prevCompaction.summary;
|
|
645
|
+
const firstKeptEntryIndex = pathEntries.findIndex((entry) => entry.id === prevCompaction.firstKeptEntryId);
|
|
646
|
+
boundaryStart = firstKeptEntryIndex >= 0 ? firstKeptEntryIndex : prevCompactionIndex + 1;
|
|
647
|
+
}
|
|
648
|
+
const boundaryEnd = pathEntries.length;
|
|
649
|
+
const tokensBefore = estimateContextTokens(buildSessionContext(pathEntries).messages, charsPerToken).tokens;
|
|
650
|
+
const cutPoint = findCutPoint(pathEntries, boundaryStart, boundaryEnd, settings.keepRecentTokens, charsPerToken);
|
|
651
|
+
const firstKeptEntry = pathEntries[cutPoint.firstKeptEntryIndex];
|
|
652
|
+
if (!firstKeptEntry?.id) {
|
|
653
|
+
return err(new CompactionError("invalid_session", "First kept entry has no UUID - session may need migration"));
|
|
654
|
+
}
|
|
655
|
+
const firstKeptEntryId = firstKeptEntry.id;
|
|
656
|
+
const historyEnd = cutPoint.isSplitTurn ? cutPoint.turnStartIndex : cutPoint.firstKeptEntryIndex;
|
|
657
|
+
const messagesToSummarize = [];
|
|
658
|
+
for (let i = boundaryStart; i < historyEnd; i++) {
|
|
659
|
+
const msg = getMessageFromEntryForCompaction(pathEntries[i]);
|
|
660
|
+
if (msg) {
|
|
661
|
+
messagesToSummarize.push(msg);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
const turnPrefixMessages = [];
|
|
665
|
+
if (cutPoint.isSplitTurn) {
|
|
666
|
+
for (let i = cutPoint.turnStartIndex; i < cutPoint.firstKeptEntryIndex; i++) {
|
|
667
|
+
const msg = getMessageFromEntryForCompaction(pathEntries[i]);
|
|
668
|
+
if (msg) {
|
|
669
|
+
turnPrefixMessages.push(msg);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
if (messagesToSummarize.length === 0 && (!cutPoint.isSplitTurn || turnPrefixMessages.length === 0)) {
|
|
674
|
+
return ok(undefined);
|
|
675
|
+
}
|
|
676
|
+
const fileOps = extractFileOperations(messagesToSummarize, pathEntries, prevCompactionIndex);
|
|
677
|
+
if (cutPoint.isSplitTurn) {
|
|
678
|
+
for (const msg of turnPrefixMessages) {
|
|
679
|
+
extractFileOpsFromMessage(msg, fileOps);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return ok({
|
|
683
|
+
firstKeptEntryId,
|
|
684
|
+
messagesToSummarize,
|
|
685
|
+
turnPrefixMessages,
|
|
686
|
+
isSplitTurn: cutPoint.isSplitTurn,
|
|
687
|
+
tokensBefore,
|
|
688
|
+
previousSummary,
|
|
689
|
+
fileOps,
|
|
690
|
+
settings,
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
const TURN_PREFIX_SUMMARIZATION_PROMPT = `This is the PREFIX of a turn that was too large to keep. The SUFFIX (recent work) is retained.
|
|
694
|
+
|
|
695
|
+
Summarize the prefix to provide context for the retained suffix:
|
|
696
|
+
|
|
697
|
+
## Original Request
|
|
698
|
+
[What did the user ask for in this turn?]
|
|
699
|
+
|
|
700
|
+
## Early Progress
|
|
701
|
+
- [Key decisions and work done in the prefix]
|
|
702
|
+
|
|
703
|
+
## Context for Suffix
|
|
704
|
+
- [Information needed to understand the retained recent work]
|
|
705
|
+
|
|
706
|
+
Be concise. Focus on what's needed to understand the kept suffix.`;
|
|
707
|
+
export { computeFileLists, serializeConversation } from "./utils.js";
|
|
708
|
+
export async function compact(preparation, model, apiKey, headers, customInstructions, signal, thinkingLevel, streamFn, runtime, charsPerToken, onInputTruncated) {
|
|
709
|
+
const { firstKeptEntryId, messagesToSummarize, turnPrefixMessages, isSplitTurn, tokensBefore, previousSummary, fileOps, settings, } = preparation;
|
|
710
|
+
if (!firstKeptEntryId) {
|
|
711
|
+
return err(new CompactionError("invalid_session", "First kept entry has no UUID - session may need migration"));
|
|
712
|
+
}
|
|
713
|
+
if (messagesToSummarize.length === 0 && (!isSplitTurn || turnPrefixMessages.length === 0)) {
|
|
714
|
+
return err(new CompactionError("summarization_failed", "Nothing to summarize (empty preparation)"));
|
|
715
|
+
}
|
|
716
|
+
let summary;
|
|
717
|
+
if (isSplitTurn && turnPrefixMessages.length > 0) {
|
|
718
|
+
const [historyResult, turnPrefixResult] = await Promise.all([
|
|
719
|
+
messagesToSummarize.length > 0
|
|
720
|
+
? generateSummary(messagesToSummarize, model, settings.reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, runtime, charsPerToken, onInputTruncated)
|
|
721
|
+
:
|
|
722
|
+
Promise.resolve(ok(previousSummary ? stripFileOperationsFooter(previousSummary) : "No prior history.")),
|
|
723
|
+
generateTurnPrefixSummary(turnPrefixMessages, model, settings.reserveTokens, apiKey, headers, signal, thinkingLevel, streamFn, runtime, charsPerToken, onInputTruncated),
|
|
724
|
+
]);
|
|
725
|
+
if (!historyResult.ok) {
|
|
726
|
+
return err(historyResult.error);
|
|
727
|
+
}
|
|
728
|
+
if (!turnPrefixResult.ok) {
|
|
729
|
+
return err(turnPrefixResult.error);
|
|
730
|
+
}
|
|
731
|
+
summary = `${historyResult.value}\n\n---\n\n**Turn Context (split turn):**\n\n${turnPrefixResult.value}`;
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
const summaryResult = await generateSummary(messagesToSummarize, model, settings.reserveTokens, apiKey, headers, signal, customInstructions, previousSummary, thinkingLevel, streamFn, runtime, charsPerToken, onInputTruncated);
|
|
735
|
+
if (!summaryResult.ok) {
|
|
736
|
+
return err(summaryResult.error);
|
|
737
|
+
}
|
|
738
|
+
summary = summaryResult.value;
|
|
739
|
+
}
|
|
740
|
+
const { readFiles, modifiedFiles, modifiedFilesByRecency } = computeFileLists(fileOps);
|
|
741
|
+
summary += formatFileOperations(readFiles, modifiedFiles);
|
|
742
|
+
return ok({
|
|
743
|
+
summary,
|
|
744
|
+
firstKeptEntryId,
|
|
745
|
+
tokensBefore,
|
|
746
|
+
details: { readFiles, modifiedFiles, modifiedFilesByRecency },
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
async function generateTurnPrefixSummary(messages, model, reserveTokens, apiKey, headers, signal, thinkingLevel, streamFn, runtime, charsPerToken, onInputTruncated) {
|
|
750
|
+
const llmMessages = convertToLlm(messages);
|
|
751
|
+
return summarizeWithPtlRetry({
|
|
752
|
+
label: "Turn prefix summarization",
|
|
753
|
+
truncationLabel: "turn_prefix",
|
|
754
|
+
llmMessages,
|
|
755
|
+
buildPromptText: (conversationText) => `<conversation>\n${conversationText}\n</conversation>\n\n${TURN_PREFIX_SUMMARIZATION_PROMPT}`,
|
|
756
|
+
model,
|
|
757
|
+
cpt: charsPerToken ?? model.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN,
|
|
758
|
+
fixedPromptChars: SUMMARIZATION_SYSTEM_PROMPT.length + TURN_PREFIX_SUMMARIZATION_PROMPT.length + 128,
|
|
759
|
+
baseMaxTokens: Math.floor(0.5 * reserveTokens),
|
|
760
|
+
apiKey,
|
|
761
|
+
headers,
|
|
762
|
+
signal,
|
|
763
|
+
thinkingLevel,
|
|
764
|
+
streamFn,
|
|
765
|
+
runtime,
|
|
766
|
+
charsPerToken,
|
|
767
|
+
onInputTruncated,
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
//# sourceMappingURL=compaction.js.map
|