@cerebriline/core 4.100.240
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 +201 -0
- package/README.md +16 -0
- package/assets/office-oxide/LICENSE-APACHE +176 -0
- package/assets/office-oxide/LICENSE-MIT +25 -0
- package/assets/office-oxide/office_oxide_bg.wasm +0 -0
- package/assets/prompt-templates/claude.md +516 -0
- package/assets/prompt-templates/deepseek.md +331 -0
- package/assets/prompt-templates/default.md +386 -0
- package/assets/prompt-templates/gemma.md +352 -0
- package/assets/prompt-templates/glm.md +334 -0
- package/assets/prompt-templates/kimi-k3.md +408 -0
- package/assets/prompt-templates/kimi.md +402 -0
- package/assets/prompt-templates/minimax.md +473 -0
- package/assets/prompt-templates/nemotron.md +358 -0
- package/assets/prompt-templates/qwen.md +612 -0
- package/dist/ClineCore.d.ts +365 -0
- package/dist/account/cline-account-service.d.ts +41 -0
- package/dist/account/index.d.ts +3 -0
- package/dist/account/rpc.d.ts +40 -0
- package/dist/account/types.d.ts +122 -0
- package/dist/auth/bounded-ttl-cache.d.ts +13 -0
- package/dist/auth/client.d.ts +30 -0
- package/dist/auth/cline.d.ts +71 -0
- package/dist/auth/codex.d.ts +40 -0
- package/dist/auth/oca.d.ts +21 -0
- package/dist/auth/provider-auth-registry.d.ts +52 -0
- package/dist/auth/server.d.ts +54 -0
- package/dist/auth/types.d.ts +103 -0
- package/dist/auth/utils.d.ts +31 -0
- package/dist/cline-core/automation.d.ts +34 -0
- package/dist/cline-core/runtime-services.d.ts +5 -0
- package/dist/cline-core/start-input.d.ts +10 -0
- package/dist/cline-core/telemetry.d.ts +10 -0
- package/dist/cline-core/types.d.ts +236 -0
- package/dist/cron/events/cron-event-ingress.d.ts +37 -0
- package/dist/cron/reports/cron-report-writer.d.ts +42 -0
- package/dist/cron/runner/cron-materializer.d.ts +35 -0
- package/dist/cron/runner/cron-runner.d.ts +60 -0
- package/dist/cron/runner/resource-limiter.d.ts +8 -0
- package/dist/cron/schedule/scheduler.d.ts +12 -0
- package/dist/cron/service/cron-service.d.ts +56 -0
- package/dist/cron/service/schedule-command-service.d.ts +14 -0
- package/dist/cron/service/schedule-service.d.ts +116 -0
- package/dist/cron/service/schedule-tool.d.ts +81 -0
- package/dist/cron/specs/cron-reconciler.d.ts +61 -0
- package/dist/cron/specs/cron-spec-parser.d.ts +26 -0
- package/dist/cron/specs/cron-watcher.d.ts +22 -0
- package/dist/cron/store/cron-schema.d.ts +2 -0
- package/dist/cron/store/sqlite-cron-store.d.ts +261 -0
- package/dist/extensions/agent-plugin/agent-skill.d.ts +21 -0
- package/dist/extensions/agent-plugin/index.d.ts +4 -0
- package/dist/extensions/agent-plugin/loader.d.ts +10 -0
- package/dist/extensions/agent-plugin/types.d.ts +67 -0
- package/dist/extensions/complexity/grammars.d.ts +92 -0
- package/dist/extensions/complexity/walker.d.ts +115 -0
- package/dist/extensions/config/builtin-templates.d.ts +10 -0
- package/dist/extensions/config/builtin-templates.generated.d.ts +5 -0
- package/dist/extensions/config/index.d.ts +15 -0
- package/dist/extensions/config/prompt-template-compaction.d.ts +92 -0
- package/dist/extensions/config/prompt-template-delta.d.ts +107 -0
- package/dist/extensions/config/prompt-template-hooks.d.ts +47 -0
- package/dist/extensions/config/prompt-template-loader.d.ts +79 -0
- package/dist/extensions/config/prompt-template-parser.d.ts +56 -0
- package/dist/extensions/config/prompt-template-review.d.ts +327 -0
- package/dist/extensions/config/prompt-template-session.d.ts +46 -0
- package/dist/extensions/config/runtime-commands.d.ts +23 -0
- package/dist/extensions/config/shipped-tool-signatures.d.ts +36 -0
- package/dist/extensions/config/skill-frontmatter-toggle.d.ts +11 -0
- package/dist/extensions/config/unified-config-file-watcher.d.ts +77 -0
- package/dist/extensions/config/user-instruction-config-loader.d.ts +77 -0
- package/dist/extensions/config/user-instruction-plugin.d.ts +26 -0
- package/dist/extensions/config/user-instruction-service.d.ts +31 -0
- package/dist/extensions/context/agentic-compaction.d.ts +129 -0
- package/dist/extensions/context/basic-compaction.d.ts +19 -0
- package/dist/extensions/context/budget-projection/index.d.ts +2 -0
- package/dist/extensions/context/budget-projection/project.d.ts +4 -0
- package/dist/extensions/context/budget-projection/types.d.ts +58 -0
- package/dist/extensions/context/capped-thinking.d.ts +195 -0
- package/dist/extensions/context/compaction-cause.d.ts +27 -0
- package/dist/extensions/context/compaction-journal.d.ts +65 -0
- package/dist/extensions/context/compaction-revisions.d.ts +72 -0
- package/dist/extensions/context/compaction-shared.d.ts +608 -0
- package/dist/extensions/context/compaction.d.ts +161 -0
- package/dist/extensions/context/context-minimum-warning.d.ts +27 -0
- package/dist/extensions/context/continuation-compaction.d.ts +260 -0
- package/dist/extensions/context/council-compaction.d.ts +262 -0
- package/dist/extensions/context/full-compaction.d.ts +44 -0
- package/dist/extensions/context/kv-pressure.d.ts +258 -0
- package/dist/extensions/context/polykv-session.d.ts +372 -0
- package/dist/extensions/context/replay-compaction.d.ts +90 -0
- package/dist/extensions/context/tool-ledger.d.ts +198 -0
- package/dist/extensions/context/work-digest.d.ts +92 -0
- package/dist/extensions/index.d.ts +7 -0
- package/dist/extensions/mcp/client.d.ts +28 -0
- package/dist/extensions/mcp/config-loader.d.ts +102 -0
- package/dist/extensions/mcp/index.d.ts +15 -0
- package/dist/extensions/mcp/manager.d.ts +23 -0
- package/dist/extensions/mcp/name-transform.d.ts +2 -0
- package/dist/extensions/mcp/oauth.d.ts +68 -0
- package/dist/extensions/mcp/plugin-server-registration.d.ts +18 -0
- package/dist/extensions/mcp/policies.d.ts +14 -0
- package/dist/extensions/mcp/remote-proxy.d.ts +9 -0
- package/dist/extensions/mcp/timeout.d.ts +2 -0
- package/dist/extensions/mcp/tools.d.ts +3 -0
- package/dist/extensions/mcp/types.d.ts +133 -0
- package/dist/extensions/plugin/plugin-config-loader.d.ts +44 -0
- package/dist/extensions/plugin/plugin-load-report.d.ts +18 -0
- package/dist/extensions/plugin/plugin-loader.d.ts +23 -0
- package/dist/extensions/plugin/plugin-module-import.d.ts +4 -0
- package/dist/extensions/plugin/plugin-sandbox.d.ts +82 -0
- package/dist/extensions/plugin/plugin-targeting.d.ts +6 -0
- package/dist/extensions/plugin-sandbox-bootstrap.js +1 -0
- package/dist/extensions/tools/ask-lsp.d.ts +150 -0
- package/dist/extensions/tools/audio-tools.d.ts +156 -0
- package/dist/extensions/tools/browser.d.ts +137 -0
- package/dist/extensions/tools/check-file.d.ts +218 -0
- package/dist/extensions/tools/check-on-failure.d.ts +49 -0
- package/dist/extensions/tools/code-intel.d.ts +131 -0
- package/dist/extensions/tools/command-guard-extension.d.ts +22 -0
- package/dist/extensions/tools/command-guard.d.ts +29 -0
- package/dist/extensions/tools/constants.d.ts +28 -0
- package/dist/extensions/tools/definitions.d.ts +178 -0
- package/dist/extensions/tools/delimiter-balance.d.ts +121 -0
- package/dist/extensions/tools/edit-verification.d.ts +86 -0
- package/dist/extensions/tools/error-locations.d.ts +53 -0
- package/dist/extensions/tools/executors/apply-patch-parser.d.ts +68 -0
- package/dist/extensions/tools/executors/apply-patch.d.ts +48 -0
- package/dist/extensions/tools/executors/awk-parser.d.ts +163 -0
- package/dist/extensions/tools/executors/awk.d.ts +41 -0
- package/dist/extensions/tools/executors/bash.d.ts +119 -0
- package/dist/extensions/tools/executors/document/assets.d.ts +22 -0
- package/dist/extensions/tools/executors/document/ebook.d.ts +11 -0
- package/dist/extensions/tools/executors/document/formats.d.ts +83 -0
- package/dist/extensions/tools/executors/document/images.d.ts +73 -0
- package/dist/extensions/tools/executors/document/legacy.d.ts +20 -0
- package/dist/extensions/tools/executors/document/ocr.d.ts +67 -0
- package/dist/extensions/tools/executors/document/office-oxide.d.ts +19 -0
- package/dist/extensions/tools/executors/document/office-oxide.generated.d.ts +82 -0
- package/dist/extensions/tools/executors/document/office.d.ts +10 -0
- package/dist/extensions/tools/executors/document/pdf.d.ts +6 -0
- package/dist/extensions/tools/executors/document/pdfjs.d.ts +30 -0
- package/dist/extensions/tools/executors/document/range.d.ts +18 -0
- package/dist/extensions/tools/executors/document/recognition.d.ts +67 -0
- package/dist/extensions/tools/executors/document-extract.d.ts +55 -0
- package/dist/extensions/tools/executors/editor.d.ts +68 -0
- package/dist/extensions/tools/executors/file-locks.d.ts +41 -0
- package/dist/extensions/tools/executors/file-read.d.ts +136 -0
- package/dist/extensions/tools/executors/grep.d.ts +35 -0
- package/dist/extensions/tools/executors/index.d.ts +97 -0
- package/dist/extensions/tools/executors/line-endings.d.ts +23 -0
- package/dist/extensions/tools/executors/output-limits.d.ts +58 -0
- package/dist/extensions/tools/executors/overlay-receipts.d.ts +25 -0
- package/dist/extensions/tools/executors/posix-regex.d.ts +52 -0
- package/dist/extensions/tools/executors/read-receipts.d.ts +93 -0
- package/dist/extensions/tools/executors/run-command-execution-controller.d.ts +16 -0
- package/dist/extensions/tools/executors/search.d.ts +50 -0
- package/dist/extensions/tools/executors/sed.d.ts +92 -0
- package/dist/extensions/tools/executors/unchanged-reads.d.ts +55 -0
- package/dist/extensions/tools/executors/web-fetch.d.ts +58 -0
- package/dist/extensions/tools/helpers.d.ts +59 -0
- package/dist/extensions/tools/image-edit.d.ts +76 -0
- package/dist/extensions/tools/image-generation.d.ts +183 -0
- package/dist/extensions/tools/index.d.ts +68 -0
- package/dist/extensions/tools/jev.d.ts +336 -0
- package/dist/extensions/tools/list-files.d.ts +128 -0
- package/dist/extensions/tools/media-endpoint.d.ts +160 -0
- package/dist/extensions/tools/media-tools.d.ts +140 -0
- package/dist/extensions/tools/model-tool-routing.d.ts +33 -0
- package/dist/extensions/tools/presets.d.ts +154 -0
- package/dist/extensions/tools/qa-credentials.d.ts +133 -0
- package/dist/extensions/tools/runtime.d.ts +39 -0
- package/dist/extensions/tools/schemas.d.ts +845 -0
- package/dist/extensions/tools/task-progress.d.ts +217 -0
- package/dist/extensions/tools/team/agent-admission.d.ts +127 -0
- package/dist/extensions/tools/team/agent-check.d.ts +152 -0
- package/dist/extensions/tools/team/agent-controls.d.ts +55 -0
- package/dist/extensions/tools/team/agent-file.d.ts +28 -0
- package/dist/extensions/tools/team/agent-iteration-cap.d.ts +328 -0
- package/dist/extensions/tools/team/agent-names.d.ts +29 -0
- package/dist/extensions/tools/team/agent-node-placement.d.ts +160 -0
- package/dist/extensions/tools/team/agent-placement-queue.d.ts +199 -0
- package/dist/extensions/tools/team/agent-placement.d.ts +118 -0
- package/dist/extensions/tools/team/agent-reports.d.ts +53 -0
- package/dist/extensions/tools/team/agent-rounds.d.ts +666 -0
- package/dist/extensions/tools/team/agent-sandbox-executors.d.ts +79 -0
- package/dist/extensions/tools/team/agent-slot-gate.d.ts +186 -0
- package/dist/extensions/tools/team/agent-status.d.ts +84 -0
- package/dist/extensions/tools/team/agent-trouble.d.ts +91 -0
- package/dist/extensions/tools/team/background-delegations.d.ts +106 -0
- package/dist/extensions/tools/team/batch-report.d.ts +151 -0
- package/dist/extensions/tools/team/configured-agent-config.d.ts +37 -0
- package/dist/extensions/tools/team/configured-agent-tool.d.ts +135 -0
- package/dist/extensions/tools/team/create-agent-tool.d.ts +45 -0
- package/dist/extensions/tools/team/delegate-to-agent.d.ts +105 -0
- package/dist/extensions/tools/team/delegated-agent.d.ts +272 -0
- package/dist/extensions/tools/team/delegated-sandboxes.d.ts +125 -0
- package/dist/extensions/tools/team/delegated-tools.d.ts +40 -0
- package/dist/extensions/tools/team/delegation-call-hooks.d.ts +30 -0
- package/dist/extensions/tools/team/engine-evictions.d.ts +38 -0
- package/dist/extensions/tools/team/index.d.ts +20 -0
- package/dist/extensions/tools/team/lead-agent-tools.d.ts +92 -0
- package/dist/extensions/tools/team/multi-agent.d.ts +364 -0
- package/dist/extensions/tools/team/node-reachability.d.ts +53 -0
- package/dist/extensions/tools/team/node-throughput.d.ts +40 -0
- package/dist/extensions/tools/team/placed-run.d.ts +114 -0
- package/dist/extensions/tools/team/projections.d.ts +8 -0
- package/dist/extensions/tools/team/runtime.d.ts +6 -0
- package/dist/extensions/tools/team/session-window-retry.d.ts +28 -0
- package/dist/extensions/tools/team/spawn-agent-tool.d.ts +450 -0
- package/dist/extensions/tools/team/spawn-sampling.d.ts +188 -0
- package/dist/extensions/tools/team/spawn-swarm-tool.d.ts +330 -0
- package/dist/extensions/tools/team/subagent-cancellation.d.ts +188 -0
- package/dist/extensions/tools/team/subagent-layout.d.ts +90 -0
- package/dist/extensions/tools/team/subagent-output.d.ts +73 -0
- package/dist/extensions/tools/team/subagent-progress.d.ts +211 -0
- package/dist/extensions/tools/team/subagent-prompts.d.ts +3 -0
- package/dist/extensions/tools/team/team-state-dates.d.ts +10 -0
- package/dist/extensions/tools/team/team-tools.d.ts +56 -0
- package/dist/extensions/tools/team/teammates-off.d.ts +14 -0
- package/dist/extensions/tools/team/token-split.d.ts +28 -0
- package/dist/extensions/tools/team/turn-fault-recovery.d.ts +71 -0
- package/dist/extensions/tools/types.d.ts +410 -0
- package/dist/extensions/tools/video-generation.d.ts +94 -0
- package/dist/hooks/checkpoint-hooks.d.ts +39 -0
- package/dist/hooks/hook-extension.d.ts +2 -0
- package/dist/hooks/hook-file-config.d.ts +24 -0
- package/dist/hooks/hook-file-hooks.d.ts +22 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/subprocess-runner.d.ts +21 -0
- package/dist/hooks/subprocess.d.ts +74 -0
- package/dist/hub/client/connect.d.ts +14 -0
- package/dist/hub/client/index.d.ts +146 -0
- package/dist/hub/client/managed-hub-build-watcher.d.ts +62 -0
- package/dist/hub/client/session-client.d.ts +138 -0
- package/dist/hub/client/ui-client.d.ts +52 -0
- package/dist/hub/daemon/entry.d.ts +15 -0
- package/dist/hub/daemon/entry.js +2033 -0
- package/dist/hub/daemon/index.d.ts +125 -0
- package/dist/hub/daemon/runtime-handlers.d.ts +12 -0
- package/dist/hub/daemon/shutdown-coordinator.d.ts +31 -0
- package/dist/hub/daemon/start-shared-server.d.ts +18 -0
- package/dist/hub/daemon/telemetry.d.ts +19 -0
- package/dist/hub/discovery/defaults.d.ts +16 -0
- package/dist/hub/discovery/index.d.ts +139 -0
- package/dist/hub/discovery/instance-lock.d.ts +51 -0
- package/dist/hub/discovery/workspace.d.ts +13 -0
- package/dist/hub/index.d.ts +38 -0
- package/dist/hub/index.js +2023 -0
- package/dist/hub/runtime-host/hub-runtime-host.d.ts +83 -0
- package/dist/hub/runtime-host/remote-runtime-host.d.ts +9 -0
- package/dist/hub/server/browser-websocket.d.ts +22 -0
- package/dist/hub/server/command-transport.d.ts +29 -0
- package/dist/hub/server/handlers/approval-handlers.d.ts +24 -0
- package/dist/hub/server/handlers/capability-handlers.d.ts +12 -0
- package/dist/hub/server/handlers/client-handlers.d.ts +6 -0
- package/dist/hub/server/handlers/connector-handlers.d.ts +20 -0
- package/dist/hub/server/handlers/context.d.ts +98 -0
- package/dist/hub/server/handlers/run-handlers.d.ts +6 -0
- package/dist/hub/server/handlers/run-queue-handlers.d.ts +33 -0
- package/dist/hub/server/handlers/session-event-projector.d.ts +7 -0
- package/dist/hub/server/handlers/session-handlers.d.ts +30 -0
- package/dist/hub/server/hub-client-contributions.d.ts +19 -0
- package/dist/hub/server/hub-event-log.d.ts +57 -0
- package/dist/hub/server/hub-notifications.d.ts +7 -0
- package/dist/hub/server/hub-run-queue.d.ts +82 -0
- package/dist/hub/server/hub-schedule-events.d.ts +2 -0
- package/dist/hub/server/hub-server-logging.d.ts +2 -0
- package/dist/hub/server/hub-server-options.d.ts +94 -0
- package/dist/hub/server/hub-server-transport.d.ts +71 -0
- package/dist/hub/server/hub-session-records.d.ts +9 -0
- package/dist/hub/server/hub-websocket-server.d.ts +12 -0
- package/dist/hub/server/index.d.ts +4 -0
- package/dist/hub/server/native-transport.d.ts +25 -0
- package/dist/hub/server/task-command-service.d.ts +11 -0
- package/dist/index.d.ts +172 -0
- package/dist/index.js +5435 -0
- package/dist/logging/early-logger.d.ts +37 -0
- package/dist/remote-config/integration.d.ts +17 -0
- package/dist/runtime/atomic/base-revision-reads.d.ts +106 -0
- package/dist/runtime/atomic/base-revision.d.ts +77 -0
- package/dist/runtime/atomic/check-first-edits.d.ts +79 -0
- package/dist/runtime/atomic/file-revisions.d.ts +268 -0
- package/dist/runtime/atomic/oracle.d.ts +178 -0
- package/dist/runtime/atomic/page-check.d.ts +39 -0
- package/dist/runtime/atomic/plan-capture.d.ts +40 -0
- package/dist/runtime/atomic/plan-text.d.ts +33 -0
- package/dist/runtime/atomic/plan-tool.d.ts +159 -0
- package/dist/runtime/atomic/proposal.d.ts +112 -0
- package/dist/runtime/atomic/propose-check-tool.d.ts +76 -0
- package/dist/runtime/atomic/protocol.d.ts +233 -0
- package/dist/runtime/atomic/restore-file-tool.d.ts +196 -0
- package/dist/runtime/atomic/revision-capture.d.ts +75 -0
- package/dist/runtime/atomic/run-check-tool.d.ts +64 -0
- package/dist/runtime/atomic/session-protocol.d.ts +304 -0
- package/dist/runtime/atomic/session-revisions.d.ts +77 -0
- package/dist/runtime/atomic/snapshot.d.ts +77 -0
- package/dist/runtime/atomic/stalled-checks.d.ts +106 -0
- package/dist/runtime/atomic/submit-transaction-tool.d.ts +50 -0
- package/dist/runtime/atomic/tool-activity.d.ts +15 -0
- package/dist/runtime/atomic/transaction-controller.d.ts +364 -0
- package/dist/runtime/atomic/unparseable-change.d.ts +35 -0
- package/dist/runtime/capabilities/index.d.ts +2 -0
- package/dist/runtime/capabilities/normalize-runtime-capabilities.d.ts +2 -0
- package/dist/runtime/capabilities/runtime-capabilities.d.ts +18 -0
- package/dist/runtime/config/agent-message-codec.d.ts +6 -0
- package/dist/runtime/config/agent-runtime-config-builder.d.ts +93 -0
- package/dist/runtime/config/connection-update.d.ts +40 -0
- package/dist/runtime/escalation/a2a.d.ts +109 -0
- package/dist/runtime/escalation/assessment.d.ts +54 -0
- package/dist/runtime/escalation/brief.d.ts +70 -0
- package/dist/runtime/escalation/escalate-tool.d.ts +93 -0
- package/dist/runtime/escalation/escalation-controller.d.ts +62 -0
- package/dist/runtime/escalation/escalation-session.d.ts +241 -0
- package/dist/runtime/escalation/expert-failure.d.ts +20 -0
- package/dist/runtime/escalation/expert-guards.d.ts +46 -0
- package/dist/runtime/escalation/expert-mailbox.d.ts +34 -0
- package/dist/runtime/escalation/expert-notes.d.ts +115 -0
- package/dist/runtime/escalation/expert-prompt.d.ts +29 -0
- package/dist/runtime/escalation/expert-revisions.d.ts +62 -0
- package/dist/runtime/escalation/expert-session.d.ts +164 -0
- package/dist/runtime/escalation/expert-transcript.d.ts +32 -0
- package/dist/runtime/escalation/forced-escalation.d.ts +58 -0
- package/dist/runtime/escalation/stand-down.d.ts +66 -0
- package/dist/runtime/escalation/struggle-offer.d.ts +100 -0
- package/dist/runtime/escalation/watch-tool.d.ts +34 -0
- package/dist/runtime/host/history.d.ts +19 -0
- package/dist/runtime/host/host.d.ts +7 -0
- package/dist/runtime/host/local/agent-event-bridge.d.ts +50 -0
- package/dist/runtime/host/local/session-record.d.ts +6 -0
- package/dist/runtime/host/local/session-service-invoker.d.ts +4 -0
- package/dist/runtime/host/local/spawn-tool.d.ts +57 -0
- package/dist/runtime/host/local/user-files.d.ts +1 -0
- package/dist/runtime/host/local-runtime-host.d.ts +298 -0
- package/dist/runtime/host/runtime-host-support.d.ts +39 -0
- package/dist/runtime/host/runtime-host.d.ts +280 -0
- package/dist/runtime/host/steer-side-turn.d.ts +119 -0
- package/dist/runtime/orchestration/runtime-builder.d.ts +14 -0
- package/dist/runtime/orchestration/runtime-event-adapter.d.ts +104 -0
- package/dist/runtime/orchestration/runtime-oauth-token-manager.d.ts +28 -0
- package/dist/runtime/orchestration/session-runtime-orchestrator.d.ts +339 -0
- package/dist/runtime/orchestration/session-runtime.d.ts +118 -0
- package/dist/runtime/orchestration/user-input-builder.d.ts +15 -0
- package/dist/runtime/process-start-token.d.ts +23 -0
- package/dist/runtime/safety/loop-detection.d.ts +160 -0
- package/dist/runtime/safety/mistake-tracker.d.ts +84 -0
- package/dist/runtime/safety/rules.d.ts +6 -0
- package/dist/runtime/safety/struggle-detector.d.ts +414 -0
- package/dist/runtime/safety/worker-struggle-stop.d.ts +20 -0
- package/dist/runtime/safety/worker-struggle.d.ts +166 -0
- package/dist/runtime/sandbox/agent-sandbox.d.ts +111 -0
- package/dist/runtime/sandbox/overlay-fs.d.ts +71 -0
- package/dist/runtime/sandbox/sandbox-binaries.d.ts +10 -0
- package/dist/runtime/tools/subprocess-sandbox-lifecycle.d.ts +9 -0
- package/dist/runtime/tools/subprocess-sandbox.d.ts +62 -0
- package/dist/runtime/tools/tool-approval.d.ts +9 -0
- package/dist/runtime/turn-queue/harness-notes.d.ts +18 -0
- package/dist/runtime/turn-queue/pending-prompt-service.d.ts +117 -0
- package/dist/services/agent-events.d.ts +59 -0
- package/dist/services/config.d.ts +2 -0
- package/dist/services/connectors/active-connectors.d.ts +2 -0
- package/dist/services/connectors/connector-autostart.d.ts +33 -0
- package/dist/services/connectors/connector-child-env.d.ts +14 -0
- package/dist/services/connectors/connector-cleanup.d.ts +20 -0
- package/dist/services/connectors/connector-supervisor.d.ts +134 -0
- package/dist/services/connectors/daemon-connector-reconnect.d.ts +15 -0
- package/dist/services/feature-flags/FeatureFlagsService.d.ts +49 -0
- package/dist/services/feature-flags/index.d.ts +2 -0
- package/dist/services/feature-flags/posthog.d.ts +24 -0
- package/dist/services/feature-flags/posthog.js +1 -0
- package/dist/services/feature-flags/providers.d.ts +7 -0
- package/dist/services/global-settings.d.ts +113 -0
- package/dist/services/llms/apihandler-agent-model-adapter.d.ts +26 -0
- package/dist/services/llms/cline-recommended-models.d.ts +62 -0
- package/dist/services/llms/configured-provider-registry.d.ts +27 -0
- package/dist/services/llms/handler-factory.d.ts +23 -0
- package/dist/services/llms/provider-defaults.d.ts +36 -0
- package/dist/services/llms/provider-settings.d.ts +420 -0
- package/dist/services/llms/runtime-config.d.ts +3 -0
- package/dist/services/llms/runtime-registry.d.ts +19 -0
- package/dist/services/llms/runtime-types.d.ts +84 -0
- package/dist/services/llms/session-budget.d.ts +88 -0
- package/dist/services/local-runtime-bootstrap.d.ts +62 -0
- package/dist/services/marketplace.d.ts +41 -0
- package/dist/services/mcp-install.d.ts +35 -0
- package/dist/services/plugin-install.d.ts +52 -0
- package/dist/services/plugin-mcp-settings.d.ts +31 -0
- package/dist/services/plugin-tools.d.ts +40 -0
- package/dist/services/plugin-uninstall.d.ts +13 -0
- package/dist/services/providers/local-provider-registry.d.ts +354 -0
- package/dist/services/providers/local-provider-service.d.ts +101 -0
- package/dist/services/providers/model-source.d.ts +3 -0
- package/dist/services/providers/provider-config-fields.d.ts +37 -0
- package/dist/services/providers/provider-readiness.d.ts +10 -0
- package/dist/services/session-artifacts.d.ts +18 -0
- package/dist/services/session-data.d.ts +61 -0
- package/dist/services/session-import/claude-code.d.ts +16 -0
- package/dist/services/session-import/codex.d.ts +34 -0
- package/dist/services/session-import/index.d.ts +6 -0
- package/dist/services/session-import/opencode.d.ts +25 -0
- package/dist/services/session-import/sanitize.d.ts +16 -0
- package/dist/services/session-import/service.d.ts +31 -0
- package/dist/services/session-import/types.d.ts +87 -0
- package/dist/services/session-telemetry.d.ts +15 -0
- package/dist/services/storage/file-team-store.d.ts +32 -0
- package/dist/services/storage/provider-settings-legacy-migration.d.ts +38 -0
- package/dist/services/storage/provider-settings-manager.d.ts +31 -0
- package/dist/services/storage/sqlite-session-store.d.ts +35 -0
- package/dist/services/storage/sqlite-team-store.d.ts +42 -0
- package/dist/services/storage/team-events-retention.d.ts +25 -0
- package/dist/services/storage/team-store.d.ts +16 -0
- package/dist/services/telemetry/ITelemetryAdapter.d.ts +54 -0
- package/dist/services/telemetry/OpenTelemetryAdapter.d.ts +43 -0
- package/dist/services/telemetry/OpenTelemetryProvider.d.ts +99 -0
- package/dist/services/telemetry/TelemetryLoggerSink.d.ts +27 -0
- package/dist/services/telemetry/TelemetryService.d.ts +40 -0
- package/dist/services/telemetry/core-events.d.ts +396 -0
- package/dist/services/telemetry/distinct-id.d.ts +2 -0
- package/dist/services/telemetry/index.d.ts +4 -0
- package/dist/services/telemetry/index.js +1 -0
- package/dist/services/usage.d.ts +19 -0
- package/dist/services/workspace/agent-schedules-workspace.d.ts +8 -0
- package/dist/services/workspace/chat-workspace.d.ts +9 -0
- package/dist/services/workspace/file-indexer.d.ts +5 -0
- package/dist/services/workspace/index.d.ts +6 -0
- package/dist/services/workspace/mention-enricher.d.ts +13 -0
- package/dist/services/workspace/workspace-manager.d.ts +27 -0
- package/dist/services/workspace/workspace-manifest.d.ts +42 -0
- package/dist/services/workspace/workspace-telemetry.d.ts +18 -0
- package/dist/session/checkpoint-diff.d.ts +25 -0
- package/dist/session/checkpoint-restore.d.ts +34 -0
- package/dist/session/display-messages.d.ts +28 -0
- package/dist/session/history-origin.d.ts +19 -0
- package/dist/session/models/session-compaction.d.ts +22 -0
- package/dist/session/models/session-graph.d.ts +15 -0
- package/dist/session/models/session-manifest.d.ts +32 -0
- package/dist/session/models/session-row.d.ts +107 -0
- package/dist/session/persisted-tool-result-content.d.ts +8 -0
- package/dist/session/search/index.d.ts +1 -0
- package/dist/session/search/session-history-search.d.ts +51 -0
- package/dist/session/services/file-session-service.d.ts +10 -0
- package/dist/session/services/message-builder.d.ts +208 -0
- package/dist/session/services/persistence-service.d.ts +92 -0
- package/dist/session/services/read-overlap.d.ts +40 -0
- package/dist/session/services/session-service.d.ts +15 -0
- package/dist/session/session-snapshot.d.ts +59 -0
- package/dist/session/session-versioning-service.d.ts +50 -0
- package/dist/session/stores/atomic-file.d.ts +1 -0
- package/dist/session/stores/conversation-store.d.ts +29 -0
- package/dist/session/stores/session-manifest-store.d.ts +49 -0
- package/dist/session/stores/team-persistence-store.d.ts +23 -0
- package/dist/session/team/index.d.ts +2 -0
- package/dist/session/team/team-child-session-manager.d.ts +35 -0
- package/dist/session/team/team-session-coordinator.d.ts +13 -0
- package/dist/session/user-run-messages.d.ts +20 -0
- package/dist/settings/index.d.ts +2 -0
- package/dist/settings/settings-service.d.ts +8 -0
- package/dist/settings/types.d.ts +83 -0
- package/dist/tasks/agenda-task-api.d.ts +20 -0
- package/dist/tasks/agenda-task-manager.d.ts +109 -0
- package/dist/tasks/agenda-task-tool.d.ts +94 -0
- package/dist/tasks/index.d.ts +9 -0
- package/dist/tasks/specs/task-spec-file-store.d.ts +38 -0
- package/dist/tasks/specs/task-spec-parser.d.ts +65 -0
- package/dist/tasks/store/sqlite-task-store.d.ts +73 -0
- package/dist/tasks/store/task-schema.d.ts +2 -0
- package/dist/tasks/task-location.d.ts +14 -0
- package/dist/tasks/task-tool.d.ts +143 -0
- package/dist/types/chat-schema.d.ts +194 -0
- package/dist/types/common.d.ts +35 -0
- package/dist/types/config.d.ts +994 -0
- package/dist/types/events.d.ts +102 -0
- package/dist/types/provider-settings.d.ts +29 -0
- package/dist/types/session.d.ts +187 -0
- package/dist/types/sessions.d.ts +42 -0
- package/dist/types/storage.d.ts +36 -0
- package/dist/types.d.ts +34 -0
- package/dist/version.d.ts +1 -0
- package/package.json +98 -0
- package/scripts/document-reader-assets.mjs +161 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session `SessionRuntime` orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Owns all cross-turn state for one logical agent session:
|
|
5
|
+
*
|
|
6
|
+
* - `ConversationStore` — message transcript + session-started gate
|
|
7
|
+
* - `MistakeTracker` — per-session consecutive-mistake counter
|
|
8
|
+
* - `LoopDetectionTracker` — per-session repeated-tool-call detector
|
|
9
|
+
* - `MessageBuilder` — provider-message assembly cache
|
|
10
|
+
* - `AgentRuntimeHooks` — runtime-native hooks from config/extensions
|
|
11
|
+
* - `RuntimeEventAdapter` — per-run stateful `AgentRuntimeEvent`
|
|
12
|
+
* → legacy `AgentEvent` translator
|
|
13
|
+
* - listener registry — host subscribers see legacy `AgentEvent`s
|
|
14
|
+
* - pending tool set, abort — per-run lifecycle housekeeping
|
|
15
|
+
*
|
|
16
|
+
* A fresh `AgentRuntime` is instantiated per run via
|
|
17
|
+
* `createAgentRuntime(createAgentRuntimeConfig({...}))`. All
|
|
18
|
+
* session-level state outlives any one `AgentRuntime`, making
|
|
19
|
+
* OAuth-retry and run replay feasible.
|
|
20
|
+
*/
|
|
21
|
+
import type { AgentRuntime } from "@cerebriline/agents";
|
|
22
|
+
import { createAgentRuntime } from "@cerebriline/agents";
|
|
23
|
+
import { type AgentConfig, type AgentEvent, type AgentExtensionRegistry, type AgentResult, type AgentTool, type BasicLogger, type ITelemetryService, type Message, type MessageWithMetadata } from "@cerebriline/shared";
|
|
24
|
+
import { MessageBuilder } from "../../session/services/message-builder";
|
|
25
|
+
import { type ConnectionUpdate } from "../config/connection-update";
|
|
26
|
+
export declare const SESSION_RUN_IN_PROGRESS_ERROR_CODE = "session_run_in_progress";
|
|
27
|
+
/**
|
|
28
|
+
* A session was asked to shut down while one of its runs was still in flight and
|
|
29
|
+
* no abort had been requested.
|
|
30
|
+
*
|
|
31
|
+
* Carries a code so callers can recognise it structurally after it crosses the
|
|
32
|
+
* hub's JSON boundary, where an `Error` arrives as a bare message. Connectors use
|
|
33
|
+
* it to tell "this thread's session is unusable" apart from a genuine run failure,
|
|
34
|
+
* and to recover by starting a fresh session instead of wedging the thread.
|
|
35
|
+
*/
|
|
36
|
+
export declare class SessionRunInProgressError extends Error {
|
|
37
|
+
readonly agentId?: string | undefined;
|
|
38
|
+
readonly code = "session_run_in_progress";
|
|
39
|
+
constructor(agentId?: string | undefined);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether a tool result reports that it made things worse.
|
|
43
|
+
*
|
|
44
|
+
* Failure is not the only way a call gets nowhere. An edit can land, report
|
|
45
|
+
* `success: true`, and leave the file with diagnostics it did not have before —
|
|
46
|
+
* which the host marks on the result as `regressed`. Measured on a live
|
|
47
|
+
* session: eight consecutive `editor` calls, every one successful, the file's
|
|
48
|
+
* diagnostics 2 → 20, and the class under repair written into the file three
|
|
49
|
+
* times over. Read as eight productive calls, the barren-repeat counter was
|
|
50
|
+
* reset on each and the loop stop could never fire.
|
|
51
|
+
*
|
|
52
|
+
* Same conservative reading as `allOperationsFailed`: only an explicit `true`
|
|
53
|
+
* counts, so an unrecognised shape can never end a task that was working.
|
|
54
|
+
*
|
|
55
|
+
* Exported for tests: it is the whole of the new loop signal, and driving a
|
|
56
|
+
* full runtime to assert one boolean would test the harness instead.
|
|
57
|
+
*/
|
|
58
|
+
export declare function introducedRegression(output: unknown): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether a tool result says the call asked for nothing.
|
|
61
|
+
*
|
|
62
|
+
* This is a different animal from ordinary failure. An edit can fail for a
|
|
63
|
+
* reason that will not hold next time — a range that had moved, a read that had
|
|
64
|
+
* gone stale — and retrying it is reasonable. A "No change" refusal is the
|
|
65
|
+
* tool reporting that it compared the payload against the file and they were
|
|
66
|
+
* already identical, so an identical retry is answerable in advance.
|
|
67
|
+
*
|
|
68
|
+
* Measured: the same `editor` call, lines 94-96 and the same 1,336 characters,
|
|
69
|
+
* sent seven times against six of these refusals, with the whole file re-read
|
|
70
|
+
* between four of them. Twenty-four minutes, no edit, and the run ended on the
|
|
71
|
+
* loop stop regardless.
|
|
72
|
+
*
|
|
73
|
+
* Matches on the marker the message is built from rather than a copied string,
|
|
74
|
+
* and only where the envelope reports failure — a file whose contents happen to
|
|
75
|
+
* mention "No change" cannot trip it.
|
|
76
|
+
*
|
|
77
|
+
* Exported for tests, like `introducedRegression`: it is one boolean, and
|
|
78
|
+
* driving a full runtime to assert it would test the harness instead.
|
|
79
|
+
*/
|
|
80
|
+
export declare function declaredNoOp(output: unknown): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Listener invoked for every legacy `AgentEvent` produced by the
|
|
83
|
+
* session runtime. Use `subscribeEvents(listener)` — it returns an
|
|
84
|
+
* `unsubscribe` function.
|
|
85
|
+
*/
|
|
86
|
+
export type SessionEventListener = (event: AgentEvent) => void;
|
|
87
|
+
/** Subset of host-side deps needed by the session orchestrator. */
|
|
88
|
+
export interface SessionRuntimeOrchestratorDeps {
|
|
89
|
+
readonly logger?: BasicLogger;
|
|
90
|
+
readonly telemetry?: ITelemetryService;
|
|
91
|
+
/**
|
|
92
|
+
* Test hook: override the `AgentRuntime` factory. Production
|
|
93
|
+
* callers leave this undefined and get the real `createAgentRuntime`.
|
|
94
|
+
*/
|
|
95
|
+
readonly createAgentRuntimeImpl?: (config: Parameters<typeof createAgentRuntime>[0]) => AgentRuntime;
|
|
96
|
+
}
|
|
97
|
+
/** Connection overrides applied via `updateConnection`. */
|
|
98
|
+
export type ConnectionOverrides = ConnectionUpdate;
|
|
99
|
+
/**
|
|
100
|
+
* Per-session orchestrator. Construct once per agent session; call
|
|
101
|
+
* `run` / `continue` repeatedly. The class matches the subset of
|
|
102
|
+
* runtime-facing session surface.
|
|
103
|
+
*/
|
|
104
|
+
export declare class SessionRuntime {
|
|
105
|
+
private config;
|
|
106
|
+
private readonly agentId;
|
|
107
|
+
private readonly parentAgentId?;
|
|
108
|
+
private readonly logger?;
|
|
109
|
+
readonly telemetry?: ITelemetryService;
|
|
110
|
+
private readonly conversation;
|
|
111
|
+
private readonly mistakeTracker;
|
|
112
|
+
private readonly loopTracker;
|
|
113
|
+
/** Loop-guard warnings awaiting the tool result they belong to. */
|
|
114
|
+
private readonly pendingLoopWarnings;
|
|
115
|
+
/**
|
|
116
|
+
* Hard loop verdicts seen in this session, counted across tool names rather
|
|
117
|
+
* than per call signature. A run that works its way out of one loop and into
|
|
118
|
+
* another has not recovered, and the second one gets no second warning.
|
|
119
|
+
*/
|
|
120
|
+
private loopHardEscalations;
|
|
121
|
+
/**
|
|
122
|
+
* The calls already inspected in the current assistant message, by
|
|
123
|
+
* signature, and the ids of the identical siblings that were not.
|
|
124
|
+
*
|
|
125
|
+
* An identical call in the same message is not a repeat: no answer came
|
|
126
|
+
* back between them, so there is nothing the model failed to learn from.
|
|
127
|
+
* Counted as consecutive attempts, a fan-out of fifteen identical agents
|
|
128
|
+
* -- what the user asked for on pandorum 2026-09-23 (6djrz) -- tripped the
|
|
129
|
+
* last warning at the fifth and stopped the run at the sixth, failing all
|
|
130
|
+
* 75 calls of the message. The batch counts once; the next message's
|
|
131
|
+
* repeat is still a repeat.
|
|
132
|
+
*/
|
|
133
|
+
private loopBatchIteration;
|
|
134
|
+
private readonly loopBatchKeys;
|
|
135
|
+
private readonly loopBatchSiblings;
|
|
136
|
+
/**
|
|
137
|
+
* True when `execution.loopDetection === false` at construction
|
|
138
|
+
* time. Loop inspection is skipped entirely — the tracker still
|
|
139
|
+
* exists for API compatibility but is never fed.
|
|
140
|
+
*/
|
|
141
|
+
private readonly loopDetectionDisabled;
|
|
142
|
+
readonly messageBuilder: MessageBuilder;
|
|
143
|
+
/**
|
|
144
|
+
* Contribution registry that hosts extension-provided tools,
|
|
145
|
+
* commands, message builders, and providers. Lazily initialized
|
|
146
|
+
* on first run (parity with legacy `Agent.ensureExtensionsInitialized`
|
|
147
|
+
* at `packages/agents/src/agent.ts:1122-1147`).
|
|
148
|
+
*/
|
|
149
|
+
private readonly contributionRegistry;
|
|
150
|
+
private extensionsInitialized;
|
|
151
|
+
private readonly listeners;
|
|
152
|
+
private readonly createAgentRuntimeImpl;
|
|
153
|
+
/** Stable run id for the active run. */
|
|
154
|
+
private activeRunId;
|
|
155
|
+
/** True while a run is in flight. `canStartRun()` is the negation. */
|
|
156
|
+
private running;
|
|
157
|
+
/** True once `abort()` has been requested for the active run. */
|
|
158
|
+
private abortRequested;
|
|
159
|
+
/** Last abort reason requested for the active run. */
|
|
160
|
+
private abortReason;
|
|
161
|
+
/** Set by {@link requestCompaction}, taken by the next prepared turn. */
|
|
162
|
+
private compactionRequested;
|
|
163
|
+
/** Reference to the current run's `AgentRuntime` so `abort` can forward. */
|
|
164
|
+
private activeRuntime;
|
|
165
|
+
/** Promise returned from the current run so shutdown can await its drain. */
|
|
166
|
+
private activeRunPromise;
|
|
167
|
+
/** Per-run `Agent → AgentEvent` adapter; `reset()` each run. */
|
|
168
|
+
private readonly eventAdapter;
|
|
169
|
+
/** Session-shutdown gate — rejects late runs. */
|
|
170
|
+
private shutdownCalled;
|
|
171
|
+
/** Running tally of tool-call records for `AgentResult.toolCalls`. */
|
|
172
|
+
private currentRunToolCalls;
|
|
173
|
+
/** Aggregated usage across the current run. */
|
|
174
|
+
private currentRunUsage;
|
|
175
|
+
/** Tool-start timestamps for `ToolCallRecord.durationMs`. */
|
|
176
|
+
private toolStartedAt;
|
|
177
|
+
/** Tool-call input snapshot for `ToolCallRecord.input`. */
|
|
178
|
+
private toolInputs;
|
|
179
|
+
/**
|
|
180
|
+
* Per-turn tool outcome counters used by the MistakeTracker wiring.
|
|
181
|
+
* Reset on every `turn-started` event; consumed on `turn-finished`
|
|
182
|
+
* to feed `mistakeTracker.record` when every tool call erred and no
|
|
183
|
+
* successful call landed. Matches legacy `agent.ts` tool-failure
|
|
184
|
+
* mistake-feed path (§3.4.6 + pre-Step-9 oracle lines 972-997).
|
|
185
|
+
*/
|
|
186
|
+
private currentTurnSuccessfulTools;
|
|
187
|
+
private currentTurnFailedTools;
|
|
188
|
+
private currentTurnFailureDetails;
|
|
189
|
+
/**
|
|
190
|
+
* Serial queue for `MistakeTracker.record(...)` + loop-detection
|
|
191
|
+
* side-effects fired from the sync `handleRuntimeEvent` stream. The
|
|
192
|
+
* tracker's `record()` is async but the runtime event stream is
|
|
193
|
+
* synchronous, so we chain tracker work onto a promise and await it
|
|
194
|
+
* in `executeRun` before returning the `AgentResult`.
|
|
195
|
+
*/
|
|
196
|
+
private activeTrackerWork;
|
|
197
|
+
/** True when tracker logic has issued an abort for the active run. */
|
|
198
|
+
/**
|
|
199
|
+
* Set once a model has refused an image. Session-scoped: capabilities do not
|
|
200
|
+
* change mid-run, and re-attaching after a refusal only repeats it.
|
|
201
|
+
*/
|
|
202
|
+
private imageInputRefused;
|
|
203
|
+
private trackerAbortInFlight;
|
|
204
|
+
private readonly handleExternalAbort;
|
|
205
|
+
constructor(config: AgentConfig, deps?: SessionRuntimeOrchestratorDeps);
|
|
206
|
+
getAgentId(): string;
|
|
207
|
+
getConversationId(): string;
|
|
208
|
+
getMessages(): MessageWithMetadata[];
|
|
209
|
+
/** True when no run is currently active and the session is not shut down. */
|
|
210
|
+
canStartRun(): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Snapshot of the contribution registry (tools, commands, and other
|
|
213
|
+
* extension contributions).
|
|
214
|
+
*
|
|
215
|
+
* Before the first run, the registry is in the `validate` phase:
|
|
216
|
+
* extensions are validated but their `setup()` callbacks have not
|
|
217
|
+
* run yet, so the snapshot only reflects eagerly-declared
|
|
218
|
+
* contributions. After the first `run()`/`continue()`, the
|
|
219
|
+
* registry is initialized (§`ensureExtensionsInitialized`), and
|
|
220
|
+
* the snapshot reflects everything extensions registered via
|
|
221
|
+
* `api.registerTool` / `registerCommand` / `registerMessageBuilder`
|
|
222
|
+
* / `registerProvider` / `registerAutomationEventType`.
|
|
223
|
+
*/
|
|
224
|
+
getExtensionRegistry(): AgentExtensionRegistry<AgentTool, Message[]>;
|
|
225
|
+
/** Append additional tools to every subsequent turn's runtime config. */
|
|
226
|
+
addTools(tools: AgentTool[]): void;
|
|
227
|
+
/** Mutate provider / reasoning fields for subsequent runs. */
|
|
228
|
+
updateConnection(overrides: ConnectionOverrides): void;
|
|
229
|
+
/**
|
|
230
|
+
* The turn cap for the next run or continuation. `undefined` is no cap.
|
|
231
|
+
*
|
|
232
|
+
* A delegated agent stopped at its cap is continued, not restarted: the
|
|
233
|
+
* lead raises the cap and the same conversation goes on from its last turn.
|
|
234
|
+
* Each run counts its turns from zero, so this is the allowance for that
|
|
235
|
+
* one continuation.
|
|
236
|
+
*/
|
|
237
|
+
setMaxIterations(maxIterations: number | undefined): void;
|
|
238
|
+
getMaxIterations(): number | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Compact before the next model request, as a manual compaction. For the
|
|
241
|
+
* lead's `compact_agents`: frees the agent's KV cells without stopping it.
|
|
242
|
+
* Takes effect at the agent's next turn; a run that has ended does it on
|
|
243
|
+
* its next continuation.
|
|
244
|
+
*/
|
|
245
|
+
requestCompaction(): void;
|
|
246
|
+
/** Whether a compaction was asked for and not yet begun, for status. */
|
|
247
|
+
hasCompactionRequest(): boolean;
|
|
248
|
+
private takeCompactionRequest;
|
|
249
|
+
clearHistory(): void;
|
|
250
|
+
restore(messages: readonly MessageWithMetadata[]): void;
|
|
251
|
+
private resetConversationBoundaryTrackers;
|
|
252
|
+
/**
|
|
253
|
+
* Subscribe to **legacy** `AgentEvent`s. The session runtime
|
|
254
|
+
* translates the new `AgentRuntimeEvent` stream via
|
|
255
|
+
* `RuntimeEventAdapter` before fanout, so consumers see the
|
|
256
|
+
* pre-swap shape.
|
|
257
|
+
*/
|
|
258
|
+
subscribeEvents(listener: SessionEventListener): () => void;
|
|
259
|
+
abort(reason?: unknown): void;
|
|
260
|
+
/** Shut the session down after any active run drains. */
|
|
261
|
+
shutdown(_reason?: string, _timeoutMs?: number): Promise<void>;
|
|
262
|
+
run(userMessage: string, userImages?: string[], userFiles?: string[]): Promise<AgentResult>;
|
|
263
|
+
/**
|
|
264
|
+
* Start a run whose conversation opens with `head`, then the task.
|
|
265
|
+
*
|
|
266
|
+
* The head is user turns that precede the task verbatim -- a sub-agent's
|
|
267
|
+
* shared knowledge and role. Seeded as their own turns rather than folded
|
|
268
|
+
* into the task, because on a KV pool each is a layer several agents share,
|
|
269
|
+
* and it only shares if it is its own turn, byte for byte.
|
|
270
|
+
*/
|
|
271
|
+
runWithHead(head: readonly string[], userMessage: string): Promise<AgentResult>;
|
|
272
|
+
continue(userMessage?: string, userImages?: string[], userFiles?: string[]): Promise<AgentResult>;
|
|
273
|
+
private composeSystemPrompt;
|
|
274
|
+
private executeRun;
|
|
275
|
+
/**
|
|
276
|
+
* Retry a run once when it failed with an auth-like error and the host
|
|
277
|
+
* refreshed credentials via `config.onAuthError`. The failed attempt's
|
|
278
|
+
* trail is already persisted to the conversation store, so the retry
|
|
279
|
+
* continues from where the stream died instead of replaying the run.
|
|
280
|
+
*/
|
|
281
|
+
private executeRunWithAuthRetry;
|
|
282
|
+
private executeRunInternal;
|
|
283
|
+
/**
|
|
284
|
+
* Initialize the contribution registry once per session. Runs
|
|
285
|
+
* extension `setup()` callbacks so they can `registerTool`,
|
|
286
|
+
* `registerCommand`, `registerMessageBuilder`, and
|
|
287
|
+
* `registerProvider`. Matches legacy `Agent.ensureExtensionsInitialized`
|
|
288
|
+
* at pre-Step-9 `agent.ts:1122-1147`:
|
|
289
|
+
*
|
|
290
|
+
* - on `hookErrorMode === "throw"`, setup failures propagate;
|
|
291
|
+
* - otherwise setup failures emit a recoverable `error` event
|
|
292
|
+
* via the legacy event channel and leave the registry
|
|
293
|
+
* partially initialized.
|
|
294
|
+
*
|
|
295
|
+
* Idempotent: subsequent calls are no-ops once the registry has
|
|
296
|
+
* been activated.
|
|
297
|
+
*/
|
|
298
|
+
private ensureExtensionsInitialized;
|
|
299
|
+
private createRuntimeHooks;
|
|
300
|
+
private createRuntimePrepareTurn;
|
|
301
|
+
private prepareMessagesForModelRequest;
|
|
302
|
+
private prepareProviderMessagesForApi;
|
|
303
|
+
private handleRuntimeEvent;
|
|
304
|
+
private syncConversationFromRuntimeMessage;
|
|
305
|
+
private emitLegacyEvent;
|
|
306
|
+
private stampIdentity;
|
|
307
|
+
/**
|
|
308
|
+
* Feed the `LoopDetectionTracker` with a tool-call and react to
|
|
309
|
+
* the returned verdict. Parity with pre-Step-9 agent.ts L917-954:
|
|
310
|
+
*
|
|
311
|
+
* - `"soft"` → append a recovery notice telling the model to
|
|
312
|
+
* change approach;
|
|
313
|
+
* - `"hard"` → feed `MistakeTracker.record` with
|
|
314
|
+
* `forceAtLimit:true`. When the tracker returns
|
|
315
|
+
* `action: "stop"`, append the stop notice and
|
|
316
|
+
* abort the active runtime.
|
|
317
|
+
*/
|
|
318
|
+
/**
|
|
319
|
+
* Report a finished tool call's outcome to the loop tracker, so a repeat
|
|
320
|
+
* that keeps failing can be told apart from one that keeps working.
|
|
321
|
+
*/
|
|
322
|
+
private noteLoopOutcome;
|
|
323
|
+
private inspectLoopForToolCall;
|
|
324
|
+
/**
|
|
325
|
+
* Enqueue a mistake-record onto the serial tracker work chain. The
|
|
326
|
+
* runtime event stream is synchronous but `MistakeTracker.record`
|
|
327
|
+
* is async — chaining onto a shared promise preserves ordering
|
|
328
|
+
* (legacy parity) and lets `executeRun` await draining before
|
|
329
|
+
* returning the `AgentResult`.
|
|
330
|
+
*
|
|
331
|
+
* When the tracker returns `action: "stop"`, append the stop notice
|
|
332
|
+
* to the conversation and abort the active runtime so the run ends
|
|
333
|
+
* with `finishReason: "aborted"`.
|
|
334
|
+
*/
|
|
335
|
+
/** Clear the tracker in order with any records already queued. */
|
|
336
|
+
private enqueueMistakeReset;
|
|
337
|
+
private enqueueMistakeRecord;
|
|
338
|
+
private buildLegacyResult;
|
|
339
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { AgentConfig, AgentEvent, AgentHooks, AgentResult, AgentTool, BasicLogger, ITelemetryService, ModelTool, RuntimeConfigExtensionKind, ToolApprovalRequest, ToolApprovalResult } from "@cerebriline/shared";
|
|
2
|
+
import type { AgentPluginPackageMcpServer, AgentPluginPackageSkill } from "../../extensions/agent-plugin";
|
|
3
|
+
import type { UserInstructionConfigService } from "../../extensions/config";
|
|
4
|
+
import type { ReadReceipts, RunCommandExecutionController, ToolExecutors } from "../../extensions/tools";
|
|
5
|
+
import type { AgentTeamsRuntime, DelegatedAgentConfigProvider, DelegatedPrepareTurnTarget, SubAgentEndContext, SubAgentStartContext, TeamEvent } from "../../extensions/tools/team";
|
|
6
|
+
import type { ConfiguredAgentConfig } from "../../extensions/tools/team/configured-agent-config";
|
|
7
|
+
import type { DelegatedSandboxes } from "../../extensions/tools/team/delegated-sandboxes";
|
|
8
|
+
import type { SpawnToolOptions } from "../../extensions/tools/team/spawn-agent-tool";
|
|
9
|
+
import type { WorkspaceManager } from "../../services/workspace/workspace-manager";
|
|
10
|
+
import type { CoreSessionConfig } from "../../types/config";
|
|
11
|
+
/**
|
|
12
|
+
* Internal structural alias for the lead-agent handle that
|
|
13
|
+
* {@link BuiltRuntime.registerLeadAgent} hands off to
|
|
14
|
+
* `runtime-builder.ts`. Narrowed to only the `.addTools()` surface the
|
|
15
|
+
* callback exercises; avoids depending on `@cerebriline/agents`' `Agent`
|
|
16
|
+
* class during the PLAN.md §3.6 Step 5 type-only migration. When
|
|
17
|
+
* SessionRuntime is rebuilt in Step 6, this field is expected to be
|
|
18
|
+
* dropped entirely per §3.5 row #2.
|
|
19
|
+
*/
|
|
20
|
+
type LeadAgentHandle = {
|
|
21
|
+
addTools(tools: AgentTool[]): unknown;
|
|
22
|
+
};
|
|
23
|
+
export interface BuiltRuntime {
|
|
24
|
+
tools: AgentTool[];
|
|
25
|
+
modelTools?: ModelTool[];
|
|
26
|
+
hooks?: AgentHooks;
|
|
27
|
+
logger?: BasicLogger;
|
|
28
|
+
telemetry?: ITelemetryService;
|
|
29
|
+
teamRuntime?: AgentTeamsRuntime;
|
|
30
|
+
teamRestoredFromPersistence?: boolean;
|
|
31
|
+
delegatedAgentConfigProvider?: DelegatedAgentConfigProvider;
|
|
32
|
+
/**
|
|
33
|
+
* The agent files this session loaded, kept so a host can list them and
|
|
34
|
+
* delegate to one on the user's say-so rather than the model's. The tools
|
|
35
|
+
* built from them are in `tools`; this is the mapping back to what the user
|
|
36
|
+
* wrote and named.
|
|
37
|
+
*/
|
|
38
|
+
configuredAgents?: readonly ConfiguredAgentConfig[];
|
|
39
|
+
extensions?: AgentConfig["extensions"];
|
|
40
|
+
completionPolicy?: AgentConfig["completionPolicy"];
|
|
41
|
+
registerLeadAgent?: (agent: LeadAgentHandle) => void;
|
|
42
|
+
shutdown: (reason: string) => Promise<void> | void;
|
|
43
|
+
}
|
|
44
|
+
export interface RuntimeBuilderInput {
|
|
45
|
+
config: CoreSessionConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Host-resolved stable end-user identity, forwarded so delegated agents
|
|
48
|
+
* (sub-agents / teammates) emit the same telemetry `userId` as the lead.
|
|
49
|
+
*/
|
|
50
|
+
distinctId?: string;
|
|
51
|
+
hooks?: AgentHooks;
|
|
52
|
+
extensions?: AgentConfig["extensions"];
|
|
53
|
+
onTeamEvent?: (event: TeamEvent) => void;
|
|
54
|
+
onSubAgentEvent?: (event: AgentEvent) => void;
|
|
55
|
+
onSubAgentStart?: (context: SubAgentStartContext) => void | Promise<void>;
|
|
56
|
+
onSubAgentEnd?: (context: SubAgentEndContext) => void | Promise<void>;
|
|
57
|
+
createSpawnTool?: (options?: SpawnToolOptions) => AgentTool;
|
|
58
|
+
/** `spawn_swarm`, when the host can build one. See `local/spawn-tool.ts`. */
|
|
59
|
+
createSwarmTool?: () => AgentTool;
|
|
60
|
+
/**
|
|
61
|
+
* The session's delegated-agent workspaces. Configured agents and
|
|
62
|
+
* teammates -- the delegated paths the runtime builder runs itself -- each
|
|
63
|
+
* open one, so their writes land in a private overlay and come back to the
|
|
64
|
+
* lead as revisions. Absent, they keep the lead's executors and get no
|
|
65
|
+
* shell.
|
|
66
|
+
*/
|
|
67
|
+
delegatedSandboxes?: () => DelegatedSandboxes;
|
|
68
|
+
onTeamRestored?: () => void;
|
|
69
|
+
userInstructionService?: UserInstructionConfigService;
|
|
70
|
+
pluginSkillDirectories?: ReadonlyArray<string>;
|
|
71
|
+
agentPluginSkills?: ReadonlyArray<AgentPluginPackageSkill>;
|
|
72
|
+
agentPluginMcpServers?: ReadonlyArray<AgentPluginPackageMcpServer>;
|
|
73
|
+
configExtensions?: RuntimeConfigExtensionKind[];
|
|
74
|
+
toolExecutors?: Partial<ToolExecutors>;
|
|
75
|
+
readReceipts?: ReadReceipts;
|
|
76
|
+
runCommandExecutionController?: RunCommandExecutionController;
|
|
77
|
+
toolPolicies?: CoreSessionConfig["toolPolicies"];
|
|
78
|
+
workspaceManager?: WorkspaceManager;
|
|
79
|
+
logger?: BasicLogger;
|
|
80
|
+
telemetry?: ITelemetryService;
|
|
81
|
+
requestToolApproval?: (request: ToolApprovalRequest) => Promise<ToolApprovalResult> | ToolApprovalResult;
|
|
82
|
+
/**
|
|
83
|
+
* Builds a context pipeline for one delegated agent -- a sub-agent or a
|
|
84
|
+
* teammate -- called once per agent so each gets its own.
|
|
85
|
+
*
|
|
86
|
+
* The lead's pipeline cannot be shared: it is closed over this session's
|
|
87
|
+
* compaction sidecar, so handing the same function to a delegated agent
|
|
88
|
+
* would project the lead's summary onto the delegate's transcript and then
|
|
89
|
+
* overwrite the lead's state with one computed from the delegate's
|
|
90
|
+
* messages. A factory is what lets every agent compact against its own
|
|
91
|
+
* history while still using the session's strategy, summarizer and window.
|
|
92
|
+
*
|
|
93
|
+
* Omitted means delegated agents run with no context pipeline at all, which
|
|
94
|
+
* is neither bounded nor visible: their transcripts grow past the model's
|
|
95
|
+
* window and the only sign is the provider quietly truncating the prompt.
|
|
96
|
+
*/
|
|
97
|
+
createDelegatedPrepareTurn?: (agent?: DelegatedPrepareTurnTarget) => AgentConfig["prepareTurn"];
|
|
98
|
+
/**
|
|
99
|
+
* The other half of that pipeline, for the same agents.
|
|
100
|
+
*
|
|
101
|
+
* Stateless -- it writes a note about reasoning that is already being
|
|
102
|
+
* discarded -- so unlike the pipeline above it is shared, not rebuilt.
|
|
103
|
+
*/
|
|
104
|
+
condenseDiscardedReasoning?: AgentConfig["condenseDiscardedReasoning"];
|
|
105
|
+
}
|
|
106
|
+
export interface RuntimeBuilder {
|
|
107
|
+
build(input: RuntimeBuilderInput): Promise<BuiltRuntime> | BuiltRuntime;
|
|
108
|
+
}
|
|
109
|
+
export interface SessionRuntime {
|
|
110
|
+
start(config: CoreSessionConfig): Promise<{
|
|
111
|
+
sessionId: string;
|
|
112
|
+
}>;
|
|
113
|
+
send(sessionId: string, prompt: string): Promise<AgentResult | undefined>;
|
|
114
|
+
abort(sessionId: string, reason?: unknown): Promise<void>;
|
|
115
|
+
stop(sessionId: string): Promise<void>;
|
|
116
|
+
poll(): Promise<string[]>;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-input / first-turn content assembler.
|
|
3
|
+
*
|
|
4
|
+
* Opens the first user content array for a turn, loading user file contents via
|
|
5
|
+
* the injected `userFileContentLoader`.
|
|
6
|
+
*/
|
|
7
|
+
import type * as LlmsProviders from "@cerebriline/llms";
|
|
8
|
+
export declare function buildInitialUserContent(userMessage: string, userImages?: string[], userFiles?: string[], userFileContentLoader?: (path: string) => Promise<string>): Promise<string | LlmsProviders.ContentBlock[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Normalize a user message shape into a plain string when possible.
|
|
11
|
+
*
|
|
12
|
+
* Accepts either a string or a LlmsProviders.Message; returns the best-effort
|
|
13
|
+
* concatenated plain-text body. Non-text content is ignored.
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeUserMessage(input: string | LlmsProviders.Message | undefined): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ProcessStartTokenProbeResult = {
|
|
2
|
+
status: "found";
|
|
3
|
+
token: string;
|
|
4
|
+
} | {
|
|
5
|
+
status: "missing";
|
|
6
|
+
} | {
|
|
7
|
+
status: "unavailable";
|
|
8
|
+
};
|
|
9
|
+
export declare function parseLinuxProcessStartToken(stat: string, bootId: string): string | undefined;
|
|
10
|
+
/** Distinguishes an absent process from an unavailable identity probe. */
|
|
11
|
+
export declare function probeProcessStartToken(pid: number): ProcessStartTokenProbeResult;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a token for one generation of a process ID.
|
|
14
|
+
*
|
|
15
|
+
* A PID alone is not an identity because the operating system can reuse it
|
|
16
|
+
* after a process exits. The token is derived from the kernel-reported process
|
|
17
|
+
* start time so callers can distinguish a live process from a later process
|
|
18
|
+
* that inherited the same PID.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getProcessStartToken(pid: number): string | undefined;
|
|
21
|
+
/** Non-blocking probe for latency-sensitive runtime paths. */
|
|
22
|
+
export declare function probeProcessStartTokenAsync(pid: number): Promise<ProcessStartTokenProbeResult>;
|
|
23
|
+
export declare function getProcessStartTokenAsync(pid: number): Promise<string | undefined>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeated tool-call loop detection.
|
|
3
|
+
*
|
|
4
|
+
* @see PLAN.md §3.1 — helpers moved from `packages/agents/src/context/loop-detection.ts`.
|
|
5
|
+
* @see PLAN.md §3.2.3 — public surface of `LoopDetectionTracker`.
|
|
6
|
+
*
|
|
7
|
+
* The pure helpers (`createLoopDetectionState`, `resetLoopDetectionState`,
|
|
8
|
+
* `toolCallSignature`, `checkRepeatedToolCall`) are ported verbatim. The
|
|
9
|
+
* `LoopDetectionTracker` class is a thin wrapper that owns a
|
|
10
|
+
* `LoopDetectionState` and exposes the `inspect()` / `reset()` surface that
|
|
11
|
+
* `SessionRuntime` installs as a `beforeTool` hook per §3.2.3.
|
|
12
|
+
*/
|
|
13
|
+
import type { LoopDetectionConfig } from "@cerebriline/shared";
|
|
14
|
+
export interface LoopDetectionState {
|
|
15
|
+
lastToolName: string;
|
|
16
|
+
lastToolSignature: string;
|
|
17
|
+
consecutiveIdenticalCount: number;
|
|
18
|
+
/** Per `name:signature`, how many times it has been tried and failed. */
|
|
19
|
+
barrenCounts: Map<string, number>;
|
|
20
|
+
/**
|
|
21
|
+
* Signatures the tool has declared no-ops. Separate from `barrenCounts`
|
|
22
|
+
* because this is not a tally: one such outcome is already conclusive.
|
|
23
|
+
*/
|
|
24
|
+
futileKeys: Set<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Signatures that have succeeded at least once this session.
|
|
27
|
+
*
|
|
28
|
+
* A repeat of one of these is a different situation from a repeat that has
|
|
29
|
+
* only ever failed: the work is done and the model has not registered it.
|
|
30
|
+
*/
|
|
31
|
+
appliedKeys: Set<string>;
|
|
32
|
+
/** Signatures already told once that their work had landed. */
|
|
33
|
+
settledKeys: Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Per futile signature, how many strikes it has spent.
|
|
36
|
+
*
|
|
37
|
+
* Kept apart from `barrenCounts` because a futile call is refused before it
|
|
38
|
+
* runs, so it never reaches `noteOutcome` to be tallied there.
|
|
39
|
+
*/
|
|
40
|
+
futileStrikes: Map<string, number>;
|
|
41
|
+
/** The call awaiting its outcome, so the result can be attributed. */
|
|
42
|
+
pendingKey: string;
|
|
43
|
+
/**
|
|
44
|
+
* Per signature, the last answer it got and how many times in a row that
|
|
45
|
+
* same answer came back. The no-progress half of the detector: a call whose
|
|
46
|
+
* result never changes is not advancing the task, however far apart its
|
|
47
|
+
* repeats are.
|
|
48
|
+
*/
|
|
49
|
+
resultCycles: Map<string, {
|
|
50
|
+
signature: string;
|
|
51
|
+
repeats: number;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
export declare function createLoopDetectionState(): LoopDetectionState;
|
|
55
|
+
export declare function resetLoopDetectionState(state: LoopDetectionState): void;
|
|
56
|
+
export declare function toolCallSignature(input: unknown): string;
|
|
57
|
+
/**
|
|
58
|
+
* A repeated call as someone who did not make it can read it: the tool and
|
|
59
|
+
* its arguments, each string cut short.
|
|
60
|
+
*
|
|
61
|
+
* For the lead, whose "LOOPING" notice about a delegated agent used to say
|
|
62
|
+
* only that the loop guard fired. The agent knows what it was repeating; the
|
|
63
|
+
* lead deciding whether to resume it with other instructions did not, so it
|
|
64
|
+
* could only say "stop repeating" (pandorum h0o2o, 2026-09-28).
|
|
65
|
+
*/
|
|
66
|
+
export declare function describeRepeatedCall(name: string, input: unknown): string;
|
|
67
|
+
/**
|
|
68
|
+
* The tools that change the workspace.
|
|
69
|
+
*
|
|
70
|
+
* Named rather than inferred: there is no flag on `AgentTool` saying a tool
|
|
71
|
+
* writes, and guessing from the name would count `read_files` the day someone
|
|
72
|
+
* adds `read_files_and_fix`. A tool this does not know about counts as an
|
|
73
|
+
* ordinary call, which is the safe direction -- it withholds a stop rather than
|
|
74
|
+
* inventing one.
|
|
75
|
+
*
|
|
76
|
+
* `restore_file` is one of them. It is the only tool here that writes by
|
|
77
|
+
* *removing* work, and a run that keeps calling it is the specific loop this
|
|
78
|
+
* set was extended for.
|
|
79
|
+
*/
|
|
80
|
+
export declare const WRITE_CLASS_TOOL_NAMES: ReadonlySet<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Tools that report on something that moves by itself, so the same call can
|
|
83
|
+
* rightly be sent again and again: a lead waiting on its agents polls
|
|
84
|
+
* `agents_status`, and each answer is a later picture of them. The guard's
|
|
85
|
+
* premise -- "the arguments have not changed, so neither will the result" --
|
|
86
|
+
* does not hold for them. Measured on pandorum 2026-09-26: a lead in a side
|
|
87
|
+
* turn polled `agents_status` six times with no arguments while its swarm ran,
|
|
88
|
+
* and the guard stopped it.
|
|
89
|
+
*/
|
|
90
|
+
export declare const POLLING_TOOL_NAMES: ReadonlySet<string>;
|
|
91
|
+
/**
|
|
92
|
+
* The answer a tool gave, with the part that cannot repeat taken out.
|
|
93
|
+
*
|
|
94
|
+
* `editor` and `restore_file` both end their message with the revision the file
|
|
95
|
+
* is now at, and that ordinal goes up on every write. So two answers that are
|
|
96
|
+
* otherwise byte-identical are never equal, and a detector comparing answers
|
|
97
|
+
* sees a fresh one every time.
|
|
98
|
+
*
|
|
99
|
+
* Measured on pandorum 2026-09-18, session `1789748860618_ya4ps`: ten rounds of
|
|
100
|
+
* `restore_file` → `read_files` → `editor` with byte-identical arguments, and
|
|
101
|
+
* the two editor answers differed in three characters --
|
|
102
|
+
* `is now revision #13` against `is now revision #15`. The cycle counter reset
|
|
103
|
+
* to one on every round and no warning was ever produced. The number that makes
|
|
104
|
+
* the message useful to the model is the number that made the loop invisible to
|
|
105
|
+
* the guard, so it is removed here and nowhere else: the model still reads the
|
|
106
|
+
* real revision.
|
|
107
|
+
*/
|
|
108
|
+
export declare function loopResultSignature(output: unknown): string;
|
|
109
|
+
export interface LoopCheckResult {
|
|
110
|
+
softWarning: boolean;
|
|
111
|
+
hardEscalation: boolean;
|
|
112
|
+
}
|
|
113
|
+
export declare function checkRepeatedToolCall(state: LoopDetectionState, toolName: string, signature: string, config: LoopDetectionConfig): LoopCheckResult;
|
|
114
|
+
/**
|
|
115
|
+
* Verdict returned by {@link LoopDetectionTracker.inspect}.
|
|
116
|
+
*
|
|
117
|
+
* - `"ok"` — no repeated call detected.
|
|
118
|
+
* - `"soft"` — soft-warning threshold reached; SessionRuntime may surface a
|
|
119
|
+
* recovery notice but should not block the call.
|
|
120
|
+
* - `"hard"` — hard-escalation threshold reached; SessionRuntime decides what
|
|
121
|
+
* follows from it.
|
|
122
|
+
*
|
|
123
|
+
* `message` is the diagnosis only, never the consequence. What happens next is
|
|
124
|
+
* the consumer's to decide and to word: the first hard verdict is delivered to
|
|
125
|
+
* the model as a last warning and the run continues, so a message that ended
|
|
126
|
+
* "stopping to avoid a loop" would have described something that did not
|
|
127
|
+
* happen. See `inspectLoopForToolCall` in the session orchestrator.
|
|
128
|
+
*/
|
|
129
|
+
export interface LoopDetectionVerdict {
|
|
130
|
+
kind: "ok" | "soft" | "hard";
|
|
131
|
+
message?: string;
|
|
132
|
+
}
|
|
133
|
+
/** Minimal call shape the tracker needs; matches `AgentToolCallPart` subset. */
|
|
134
|
+
export interface LoopDetectionCall {
|
|
135
|
+
name: string;
|
|
136
|
+
input: unknown;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Per-session repeated-tool-call detector.
|
|
140
|
+
*
|
|
141
|
+
* `SessionRuntime` owns the instance and installs a `beforeTool` hook
|
|
142
|
+
* (see `AgentRuntimeHooks.beforeTool`) that calls `inspect()` to decide
|
|
143
|
+
* whether to return `{ skip, stop, reason }`.
|
|
144
|
+
*/
|
|
145
|
+
export declare class LoopDetectionTracker {
|
|
146
|
+
private readonly config;
|
|
147
|
+
private readonly state;
|
|
148
|
+
constructor(config?: Partial<LoopDetectionConfig>);
|
|
149
|
+
inspect(call: LoopDetectionCall): LoopDetectionVerdict;
|
|
150
|
+
/**
|
|
151
|
+
* Attribute an outcome to the call `inspect()` last saw.
|
|
152
|
+
*
|
|
153
|
+
* A productive call clears its own tally rather than merely not adding to
|
|
154
|
+
* it: a command that works, stops working, then works again is a normal
|
|
155
|
+
* edit-test cycle, and it should not inherit a count from the failures in
|
|
156
|
+
* between.
|
|
157
|
+
*/
|
|
158
|
+
noteOutcome(productive: boolean, futile?: boolean, resultSignature?: string): void;
|
|
159
|
+
reset(): void;
|
|
160
|
+
}
|