@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,372 @@
|
|
|
1
|
+
import type { PolykvOptions } from "@cerebriline/llms";
|
|
2
|
+
import { type OpencotiAllocation, type OpencotiKvSnapshot, type PolykvCapacity } from "@cerebriline/llms";
|
|
3
|
+
import { type BasicLogger } from "@cerebriline/shared";
|
|
4
|
+
/**
|
|
5
|
+
* The conversation's KV pool, on the engine that owns the cells.
|
|
6
|
+
*
|
|
7
|
+
* opencoti-llamafile keeps a tree of pools; a pool owns `[D, L)` and shares
|
|
8
|
+
* everything before `D` with its parent. The part of an agent's context that
|
|
9
|
+
* never changes -- system prompt and tool schemas -- can therefore be prefilled
|
|
10
|
+
* once, pinned, and attached by every later request instead of re-sent.
|
|
11
|
+
*
|
|
12
|
+
* That prefix is not a rounding error here. Measured on the Ollama path in this
|
|
13
|
+
* fork: 12,859 tokens of system prompt and tool definitions on every single
|
|
14
|
+
* request, and one turn whose prefill ran past undici's five-minute header
|
|
15
|
+
* timeout and killed the session.
|
|
16
|
+
*
|
|
17
|
+
* Two rules from the engine's own design are load-bearing and are why this
|
|
18
|
+
* module exists rather than a couple of inline calls:
|
|
19
|
+
*
|
|
20
|
+
* - **Compaction is a prompt rewrite, never an in-place KV op.** Compacted text
|
|
21
|
+
* is new text and cannot match the old cells, so a re-root is
|
|
22
|
+
* `fork(root, D_sys, new suffix)` followed by releasing the old subtree.
|
|
23
|
+
* - **A pin left on an abandoned subtree is a leak.** Unpin after migrating,
|
|
24
|
+
* every time, including on the failure paths.
|
|
25
|
+
*
|
|
26
|
+
* Nothing here may fail a turn. A pool that cannot be created or read means the
|
|
27
|
+
* session runs exactly as it did before any of this existed: the whole prompt
|
|
28
|
+
* on every request, and the estimate-based compaction trigger deciding when to
|
|
29
|
+
* compact. Every entry point returns `undefined` rather than throwing.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* How close to full the engine has to say the pool is before this compacts.
|
|
33
|
+
*
|
|
34
|
+
* Below the estimate-based trigger's own ratio on purpose. This number is
|
|
35
|
+
* measured by the thing holding the cells, where every other signal in the
|
|
36
|
+
* compaction path is an estimate -- and the estimates were wrong in both
|
|
37
|
+
* directions inside a single session: a chars-per-token ratio that swung 3.16
|
|
38
|
+
* to 5.42, an overhead term that read 53,323 tokens for a 12,700-token payload.
|
|
39
|
+
* When the engine says it is nearly out, it is nearly out.
|
|
40
|
+
*/
|
|
41
|
+
export declare const POLYKV_COMPACTION_PRESSURE = 0.85;
|
|
42
|
+
export interface PolykvProviderConfig {
|
|
43
|
+
providerId?: string;
|
|
44
|
+
baseUrl?: string;
|
|
45
|
+
/** The model, where the provider pools per model (xOllama). */
|
|
46
|
+
modelId?: string;
|
|
47
|
+
/** The provider's key, which a keyed xOllama wants on its engine routes. */
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
/** The profile's PolyKV section. Absent means "never configured". */
|
|
52
|
+
polykv?: PolykvOptions;
|
|
53
|
+
/**
|
|
54
|
+
* Set on a swarm agent's config: its pools belong to the swarm's tree
|
|
55
|
+
* (`polykv-swarm.ts`), so the lead-conversation pool logic here stands down
|
|
56
|
+
* rather than building a second, private tree for every agent.
|
|
57
|
+
*/
|
|
58
|
+
polykvWorker?: unknown;
|
|
59
|
+
/** Set on a delegated agent's config: the engine session its turns carry. */
|
|
60
|
+
engineSessionId?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether this session runs on an engine that has a pool tree, and wants it.
|
|
64
|
+
*
|
|
65
|
+
* `enabled` is read as off only when it says so. A profile written before the
|
|
66
|
+
* section existed carries nothing, and treating that as "disabled" would take
|
|
67
|
+
* pooling away from every session that already had it -- a silent regression
|
|
68
|
+
* dressed up as a default.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isPolykvProvider(config: PolykvProviderConfig | undefined): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether this server really has a pool tree, asked of the server.
|
|
73
|
+
*
|
|
74
|
+
* {@link isPolykvProvider} answers a question about the *profile* -- opencoti,
|
|
75
|
+
* a base URL, pooling not switched off -- which is as much as most of this
|
|
76
|
+
* module needs, because every pool call it makes degrades to "no pool" on its
|
|
77
|
+
* own. Offering a tool is different: the schema is paid for out of the context
|
|
78
|
+
* window before anything is called, and a swarm on a server booted without
|
|
79
|
+
* `--polykv-max-pools` -- the default -- fails on its first pool call having
|
|
80
|
+
* already spent it.
|
|
81
|
+
*
|
|
82
|
+
* So this one waits for `/props`. The read is cached per server for the life of
|
|
83
|
+
* the process, and an unreachable server answers `false`: "cannot ask" is not
|
|
84
|
+
* "yes", which is the same reading the slot limit takes.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* Whether a delegated agent on this profile runs as a swarm worker: opencoti
|
|
88
|
+
* with pooling on (see {@link isPolykvProvider}), or xOllama.
|
|
89
|
+
*
|
|
90
|
+
* xOllama is decided per model, and at the provider: a plain model with seats
|
|
91
|
+
* for client pools on a server that negotiates windows pools the agent through
|
|
92
|
+
* the model's engine, and any other model -- a council, one without seats --
|
|
93
|
+
* runs it as the plain chat it would have been. Only the worker is widened:
|
|
94
|
+
* the lead-session pool code in this module speaks to an opencoti root and has
|
|
95
|
+
* none on xOllama, where the provider builds the lead's pool itself.
|
|
96
|
+
*/
|
|
97
|
+
export declare function isPolykvWorkerProvider(config: PolykvProviderConfig | undefined): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The engine this config's PolyKV calls go to, as an opencoti-shaped config:
|
|
100
|
+
* opencoti's own, or on xOllama the selected model's engine behind
|
|
101
|
+
* `/api/engine` -- where the model is plain, keeps seats for clients and the
|
|
102
|
+
* server negotiates windows. `undefined` where there is no engine to drive.
|
|
103
|
+
*
|
|
104
|
+
* For the readers and the control plane only (`/kv`, `/capacity`, resizes,
|
|
105
|
+
* pools, session close): a chat still goes through the provider, whose own
|
|
106
|
+
* fetch speaks xOllama. So the result is never handed to a model factory.
|
|
107
|
+
*/
|
|
108
|
+
export declare function resolvePolykvEngineConfig(config: PolykvProviderConfig | undefined): Promise<PolykvProviderConfig | undefined>;
|
|
109
|
+
export declare function polykvPoolsConfirmed(config: PolykvProviderConfig | undefined): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* The messages whose templated tokens make up the shared prefix.
|
|
112
|
+
*
|
|
113
|
+
* Returned as a chat body rather than a string, because the string is not ours
|
|
114
|
+
* to write. The engine prefills whatever its own chat template produced, and a
|
|
115
|
+
* prefix assembled here -- the system prompt, a newline, `JSON.stringify` of
|
|
116
|
+
* the tool schemas -- is a different token sequence from the one that gets
|
|
117
|
+
* prefilled. The pool is then created, pinned and attached, and shares nothing,
|
|
118
|
+
* on every turn, with nothing reporting it. Only the server knows which
|
|
119
|
+
* template it loaded and how that template renders tools.
|
|
120
|
+
*
|
|
121
|
+
* The prefix does not have to be exactly right, only honest: the engine
|
|
122
|
+
* computes the shared length itself as the longest exact token match (auto-P),
|
|
123
|
+
* and an explicit hint may only cap that, never raise it. So a prefix running
|
|
124
|
+
* slightly past the true boundary shares less, rather than failing.
|
|
125
|
+
*/
|
|
126
|
+
export declare function renderPolykvPrefixMessages(options: {
|
|
127
|
+
systemPrompt?: string;
|
|
128
|
+
tools?: readonly unknown[];
|
|
129
|
+
}): {
|
|
130
|
+
messages: readonly unknown[];
|
|
131
|
+
tools?: readonly unknown[];
|
|
132
|
+
} | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* End the pinned prefix at a token boundary.
|
|
135
|
+
*
|
|
136
|
+
* A prefix ending in a trailing space merges with the first word of whatever
|
|
137
|
+
* follows into a single token, so the child's `[0, branch_pos)` no longer
|
|
138
|
+
* matches the parent's and the contiguous-prefix check answers 400. A newline
|
|
139
|
+
* is the boundary every chat template already ends its blocks on.
|
|
140
|
+
*/
|
|
141
|
+
export declare function endAtTokenBoundary(prompt: string): string;
|
|
142
|
+
/**
|
|
143
|
+
* Create and pin the session's root pool, once.
|
|
144
|
+
*
|
|
145
|
+
* Idempotent: a session that already has one keeps it. The pin is what stops
|
|
146
|
+
* the engine reclaiming the prefix between turns, and is released by
|
|
147
|
+
* `releasePolykvSession`.
|
|
148
|
+
*/
|
|
149
|
+
export declare function ensurePolykvPool(options: {
|
|
150
|
+
sessionId: string | undefined;
|
|
151
|
+
providerConfig: PolykvProviderConfig;
|
|
152
|
+
systemPrompt?: string;
|
|
153
|
+
tools?: readonly unknown[];
|
|
154
|
+
logger?: BasicLogger;
|
|
155
|
+
}): Promise<string | undefined>;
|
|
156
|
+
/**
|
|
157
|
+
* How often one session may ask the engine for its room.
|
|
158
|
+
*
|
|
159
|
+
* `GET /capacity` is not a read on the published c7 engine: every GET folds the
|
|
160
|
+
* settle and bias EWMAs the admission projection is built from. The fold is
|
|
161
|
+
* what the enforced gate does on an admission, once per gated request -- and a
|
|
162
|
+
* client that also asks on its own cadence adds folds the engine never made,
|
|
163
|
+
* from moments that were not admissions, and then acts on the projection it
|
|
164
|
+
* skewed.
|
|
165
|
+
*
|
|
166
|
+
* Two callers want the answer: the compaction check, once a turn, and the
|
|
167
|
+
* delegation admission gate, once a round. Bounding here rather than in either
|
|
168
|
+
* of them is deliberate -- it holds however many callers appear later, and it
|
|
169
|
+
* cannot be forgotten at a new call site.
|
|
170
|
+
*
|
|
171
|
+
* (c8 makes the plain GET read-only and moves the fold behind `?fold=1`. This
|
|
172
|
+
* bound then stops being load-bearing, and is still the right manners.)
|
|
173
|
+
*/
|
|
174
|
+
export declare const POLYKV_CAPACITY_MIN_INTERVAL_MS = 5000;
|
|
175
|
+
/** Forget a session's last capacity answer. Test seam, and release path. */
|
|
176
|
+
export declare function clearPolykvCapacityCache(sessionId?: string): void;
|
|
177
|
+
/**
|
|
178
|
+
* What the engine says about this pool's room, or `undefined` if it will not say.
|
|
179
|
+
*
|
|
180
|
+
* `expectedTokens` is the turn about to be sent, so the answer accounts for the
|
|
181
|
+
* request rather than describing the pool at rest.
|
|
182
|
+
*
|
|
183
|
+
* Answered from the last read when one is recent enough -- see
|
|
184
|
+
* {@link POLYKV_CAPACITY_MIN_INTERVAL_MS} for why that is a correctness
|
|
185
|
+
* property on c7 and not a performance one.
|
|
186
|
+
*/
|
|
187
|
+
export declare function readPolykvCapacity(options: {
|
|
188
|
+
sessionId: string | undefined;
|
|
189
|
+
providerConfig: PolykvProviderConfig;
|
|
190
|
+
expectedTokens?: number;
|
|
191
|
+
logger?: BasicLogger;
|
|
192
|
+
}): Promise<PolykvCapacity | undefined>;
|
|
193
|
+
/** Forget the cached allocations. Test seam. */
|
|
194
|
+
export declare function clearPolykvAllocationCache(): void;
|
|
195
|
+
/**
|
|
196
|
+
* This session's row of `GET /kv`'s `allocations[]`, or `undefined`.
|
|
197
|
+
*
|
|
198
|
+
* The compaction trigger's preferred signal (P4): `pressure` there is the RAW
|
|
199
|
+
* `used/window` of the window the session booked, the number the user's
|
|
200
|
+
* threshold is written against. Unlike a pool's `/capacity` it needs no pool --
|
|
201
|
+
* a session can book a window with pooling off -- so it is asked for on its
|
|
202
|
+
* own, and only where the server offers the route (`kv_status_v1`).
|
|
203
|
+
*
|
|
204
|
+
* **A delegated agent reads the booking it lives in.** A worker whose turns
|
|
205
|
+
* are pooled books nothing -- the engine charges its suffix to the owner the
|
|
206
|
+
* swarm assigned it (the lead's own session on priority 0) -- so the owner's
|
|
207
|
+
* row is its pressure. A worker whose last turn went out unpooled runs as a
|
|
208
|
+
* session of its own, and its own row is. Each falls back to the other when
|
|
209
|
+
* its row is not listed. Turning every worker away here, as this once did,
|
|
210
|
+
* left no delegated agent on a PolyKV node able to compact on engine pressure.
|
|
211
|
+
*
|
|
212
|
+
* Bounded by {@link POLYKV_CAPACITY_MIN_INTERVAL_MS}, the same manners as the
|
|
213
|
+
* capacity read, and a failed read is cached too.
|
|
214
|
+
*/
|
|
215
|
+
export declare function readPolykvAllocation(options: {
|
|
216
|
+
sessionId: string | undefined;
|
|
217
|
+
providerConfig: PolykvProviderConfig;
|
|
218
|
+
logger?: BasicLogger;
|
|
219
|
+
}): Promise<OpencotiAllocation | undefined>;
|
|
220
|
+
/**
|
|
221
|
+
* This session's last `GET /kv` read: every allocation row, and the server's
|
|
222
|
+
* `pressure` where it states one (`kv_pressure_v1`).
|
|
223
|
+
*
|
|
224
|
+
* The one read behind both the compaction trigger's row
|
|
225
|
+
* ({@link readPolykvAllocation}) and the pressure policy (`kv-pressure.ts`),
|
|
226
|
+
* so a turn asks `/kv` once. Bounded by
|
|
227
|
+
* {@link POLYKV_CAPACITY_MIN_INTERVAL_MS} per session, and a failed read is
|
|
228
|
+
* cached too.
|
|
229
|
+
*/
|
|
230
|
+
export declare function readPolykvKvSnapshot(options: {
|
|
231
|
+
sessionId: string | undefined;
|
|
232
|
+
providerConfig: PolykvProviderConfig;
|
|
233
|
+
logger?: BasicLogger;
|
|
234
|
+
}): Promise<OpencotiKvSnapshot | undefined>;
|
|
235
|
+
/**
|
|
236
|
+
* Whether the engine's own measurement says it is time to compact.
|
|
237
|
+
*
|
|
238
|
+
* The RAW ratio decides (P4, ruled): this session's `pressure` from `GET /kv`
|
|
239
|
+
* first, then the pool's own raw `pressure` (`session_pressure_v1`), and only
|
|
240
|
+
* where neither is stated the older `compaction_pressure` -- a 0.70..1.0 ramp
|
|
241
|
+
* that stops matching the threshold the user set the moment it is compared
|
|
242
|
+
* against one.
|
|
243
|
+
*
|
|
244
|
+
* A pool still settling reports pressure that describes a state it is leaving,
|
|
245
|
+
* so it is not asked to decide anything. The allocation is the booked window's
|
|
246
|
+
* own ledger and is not subject to that.
|
|
247
|
+
*/
|
|
248
|
+
export declare function polykvSaysCompact(capacity: PolykvCapacity | undefined, threshold?: number, allocation?: Pick<OpencotiAllocation, "pressure">): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* The window compaction must size against: the granted one, when it is known
|
|
251
|
+
* and smaller than the configured one.
|
|
252
|
+
*
|
|
253
|
+
* A conversation negotiated down to 160k of a configured 256k is a 160k
|
|
254
|
+
* conversation for its whole life -- the server holds that and nothing more --
|
|
255
|
+
* so a trigger computed against 256k fires after the window has already
|
|
256
|
+
* overflowed. The effective grant counts a shared prefix riding above a
|
|
257
|
+
* private budget. Larger than configured is not a reason to size up: the
|
|
258
|
+
* configured window is what the rest of the session (the output cap, the
|
|
259
|
+
* prompt) was built for.
|
|
260
|
+
*/
|
|
261
|
+
export declare function resolveGrantedContextWindow(sessionId: string | undefined, providerId: string | undefined, configuredWindow: number | undefined): number | undefined;
|
|
262
|
+
/**
|
|
263
|
+
* After a compaction: the session goes on from its prefix pool plus the replay.
|
|
264
|
+
*
|
|
265
|
+
* The conversation still opens with the system prompt and tools the session's
|
|
266
|
+
* pool (its own root, or its place in the lead tree) already covers, so there
|
|
267
|
+
* is nothing to fork: the next request attaches to that pool and prefills the
|
|
268
|
+
* replay after it. What is left to do is give back the cells the session's
|
|
269
|
+
* slot still holds for the transcript the replay replaced -- unless the
|
|
270
|
+
* compaction already did (`continuation-compaction.ts` releases them before
|
|
271
|
+
* the synthesizer runs).
|
|
272
|
+
*
|
|
273
|
+
* Only where a pool covers the head: a session whose prefix lives in its slot
|
|
274
|
+
* alone would pay for it again. A held booking keeps its window -- the
|
|
275
|
+
* conversation goes on in it -- and only the slot is erased; a session with no
|
|
276
|
+
* booking is closed, which drops the slot and books nothing. A borrowed pool
|
|
277
|
+
* (a swarm worker) is left exactly as it is.
|
|
278
|
+
*
|
|
279
|
+
* Returns the pool the session stays on, or `undefined` when it has none.
|
|
280
|
+
*/
|
|
281
|
+
export declare function repointPolykvAfterCompaction(options: {
|
|
282
|
+
sessionId: string | undefined;
|
|
283
|
+
providerConfig: PolykvProviderConfig;
|
|
284
|
+
/** The compaction already dropped the session's slot cells. */
|
|
285
|
+
sessionCellsReleased?: boolean;
|
|
286
|
+
logger?: BasicLogger;
|
|
287
|
+
}): Promise<string | undefined>;
|
|
288
|
+
/**
|
|
289
|
+
* End a session: release its pool, then give its window back.
|
|
290
|
+
*
|
|
291
|
+
* The one call that stops a leak, and it now stops two of them. The pool half
|
|
292
|
+
* is unpin-then-release, which is what keeps a pinned prefix from blocking
|
|
293
|
+
* reclaim forever. The window half is `POST /sessions/{id}/close`, and without
|
|
294
|
+
* it a guaranteed allocation stays booked for the server's idle TTL -- five
|
|
295
|
+
* minutes on the build this was written against -- so a user who ends one 256k
|
|
296
|
+
* conversation and opens another waits out their own last session.
|
|
297
|
+
*
|
|
298
|
+
* **The window is released even when there was never a pool.** A session can
|
|
299
|
+
* book a window with pooling off, or before a pool has been built, and gating
|
|
300
|
+
* the close on pool state would leak exactly those -- which are the expensive
|
|
301
|
+
* ones, since the whole allocation is held rather than a prefix.
|
|
302
|
+
*/
|
|
303
|
+
export declare function releasePolykvSession(options: {
|
|
304
|
+
sessionId: string | undefined;
|
|
305
|
+
providerConfig: PolykvProviderConfig;
|
|
306
|
+
logger?: BasicLogger;
|
|
307
|
+
}): Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* Snapshot a session's live context into a pool the workers can share.
|
|
310
|
+
*
|
|
311
|
+
* `from_session` first: the engine takes the prefix from the slot's own token
|
|
312
|
+
* history, so no tokens cross the wire and the failure class this module was
|
|
313
|
+
* written to fix -- a client-tokenised prefix that does not match the prefilled
|
|
314
|
+
* one -- cannot arise on that path at all.
|
|
315
|
+
*
|
|
316
|
+
* **When this runs matters as much as what it does.** The host prompt cache
|
|
317
|
+
* saves and clears idle slots the moment any new task launches, so the snapshot
|
|
318
|
+
* has to be taken at the end of the lead's turn, before any worker starts. Taken
|
|
319
|
+
* late it captures a slot that has already been cleared.
|
|
320
|
+
*
|
|
321
|
+
* `ephemeral` so the engine's own sweep can reclaim it if this process dies
|
|
322
|
+
* mid-round. That is the crash net; {@link releasePolykvPool} is the plan.
|
|
323
|
+
*
|
|
324
|
+
* **And it is refused often.** The engine's own soak against the shipped
|
|
325
|
+
* bytes saw `400` on 331 of 715 `from_session` creates. That is correct
|
|
326
|
+
* behaviour rather than a fault: the snapshot comes from the cache resident in
|
|
327
|
+
* the session's LAST slot, and once that slot has been bound to someone else
|
|
328
|
+
* the session has no affinity left -- refusing beats building this session's
|
|
329
|
+
* pool out of another session's context. The rate rises exactly when a swarm is
|
|
330
|
+
* most worth running, because it tracks how hard the slots are churning.
|
|
331
|
+
*
|
|
332
|
+
* So a refusal falls back to **borrowing the session's own root pool**, which
|
|
333
|
+
* is still pinned and still holds the system prompt and the tool schemas --
|
|
334
|
+
* about a third of the window by measurement. The workers share most of what
|
|
335
|
+
* matters instead of re-prefilling the lead's entire context each.
|
|
336
|
+
*
|
|
337
|
+
* A borrowed pool is marked, and **the caller must not release it**: it belongs
|
|
338
|
+
* to the lead and is serving the conversation. Dropping it at the end of a
|
|
339
|
+
* round would unpin the prefix the lead is still using, which is worse than the
|
|
340
|
+
* unpooled round this fallback exists to avoid.
|
|
341
|
+
*
|
|
342
|
+
* `undefined` only when there is nothing to borrow either, which lets the
|
|
343
|
+
* caller run the round unpooled rather than fail it.
|
|
344
|
+
*/
|
|
345
|
+
export declare function snapshotPolykvSession(options: {
|
|
346
|
+
sessionId: string | undefined;
|
|
347
|
+
providerConfig: PolykvProviderConfig;
|
|
348
|
+
logger?: BasicLogger;
|
|
349
|
+
}): Promise<PolykvSnapshot | undefined>;
|
|
350
|
+
export interface PolykvSnapshot {
|
|
351
|
+
poolId: string;
|
|
352
|
+
prefixTokens: number;
|
|
353
|
+
/**
|
|
354
|
+
* This pool was not created for the round and is not the round's to drop.
|
|
355
|
+
*
|
|
356
|
+
* It is the lead's root pool, pinned and serving the conversation. A caller
|
|
357
|
+
* that releases it unpins the prefix the lead is still using.
|
|
358
|
+
*/
|
|
359
|
+
borrowed?: boolean;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Release a pool this process created, whatever happened to the work on it.
|
|
363
|
+
*
|
|
364
|
+
* Unpin first, always. The engine will not reclaim a pinned pool, and a pin
|
|
365
|
+
* left on an abandoned subtree blocks reclaim forever -- which is the leak the
|
|
366
|
+
* whole of this module's release discipline exists to prevent.
|
|
367
|
+
*/
|
|
368
|
+
export declare function releasePolykvPool(options: {
|
|
369
|
+
poolId: string;
|
|
370
|
+
providerConfig: PolykvProviderConfig;
|
|
371
|
+
logger?: BasicLogger;
|
|
372
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compaction for the strategy that keeps the last messages.
|
|
3
|
+
*
|
|
4
|
+
* The existing prompt asks for a hand-over note, and a note is the wrong
|
|
5
|
+
* artifact here. When a recency tail is kept, the summary is **prepended to
|
|
6
|
+
* messages that are still in the transcript** — the model reads it and then
|
|
7
|
+
* reads its own last few turns. A note changes voice mid-stream: the model
|
|
8
|
+
* goes from being told *about* a conversation, in the third person and the
|
|
9
|
+
* past tense, straight into its own first-person turns. The seam is visible
|
|
10
|
+
* and the model writes from the wrong side of it.
|
|
11
|
+
*
|
|
12
|
+
* So this prompt asks for a replay instead: the same voice as the messages it
|
|
13
|
+
* will sit in front of, first person, **in the present tense**. The model is
|
|
14
|
+
* not reporting on a session, it is re-telling its own.
|
|
15
|
+
*
|
|
16
|
+
* The tense is load-bearing and was wrong. A replay written in the past tense
|
|
17
|
+
* reads as history -- "The user asked me to fix the collision", "the editor
|
|
18
|
+
* then warned me the line numbers had shifted" -- and a model reading that in
|
|
19
|
+
* front of its own live turns treats the facts as old and possibly stale. It
|
|
20
|
+
* re-reads files it already knows, re-derives conclusions it already has, and
|
|
21
|
+
* discounts a warning that is still in force. Reported from a 29-minute
|
|
22
|
+
* pandorum run where the model kept working but stopped being efficient.
|
|
23
|
+
*
|
|
24
|
+
* Present tense makes the same sentences current: "The user is asking me",
|
|
25
|
+
* "Let me start by", "the editor is warning me this change shifted the line
|
|
26
|
+
* numbers by +11". Nothing about the content changes; only whether the model
|
|
27
|
+
* reads it as the state of play or as a story about one.
|
|
28
|
+
*
|
|
29
|
+
* Asking was not enough on its own, and the two reasons it was not are both
|
|
30
|
+
* in this file's history. The instruction was carried by a two-column table
|
|
31
|
+
* whose left half printed the phrasings it forbade, and a pandorum summary
|
|
32
|
+
* came back with that column nearly verbatim -- "I started by running the
|
|
33
|
+
* diagnostic" against a row reading "I started by reading the file". A
|
|
34
|
+
* negative exemplar is still an exemplar. And the prompt labelled five of its
|
|
35
|
+
* own sections in the past tense -- "What you were asked", "What you did",
|
|
36
|
+
* "Where you had got to" -- while demanding the present in its second
|
|
37
|
+
* paragraph. What came back was a present-tense opening and closing around a
|
|
38
|
+
* wholly past-tense body, which is the shape of a prompt disagreeing with
|
|
39
|
+
* itself. Only the column that shows what to write is left, and the labels
|
|
40
|
+
* are in the tense they ask for.
|
|
41
|
+
*
|
|
42
|
+
* Two things the replay must carry that a note gets away with omitting:
|
|
43
|
+
*
|
|
44
|
+
* - **The user's own words, verbatim.** A paraphrased instruction is the one
|
|
45
|
+
* loss that cannot be recovered from anywhere else — the files are on disk
|
|
46
|
+
* and the tool record is rebuilt by the harness, but what was asked exists
|
|
47
|
+
* only in the transcript being discarded.
|
|
48
|
+
* - **Its tool calls, with what came back.** Trimmed, because a model asked to
|
|
49
|
+
* replay its work pastes whole file bodies back, which is precisely what
|
|
50
|
+
* compaction exists to remove arriving inside the thing meant to remove it.
|
|
51
|
+
* `trimReplayOverflow` is the backstop for when it does that anyway.
|
|
52
|
+
*
|
|
53
|
+
* The harness places the tool ledger between this replay and the retained
|
|
54
|
+
* messages, so the model's own account and the measured one sit side by side
|
|
55
|
+
* and any disagreement is visible rather than silent.
|
|
56
|
+
*/
|
|
57
|
+
/** The instruction, when the recency tail is kept. */
|
|
58
|
+
export declare const DEFAULT_REPLAY_COMPACTION_PROMPT = "Your transcript has grown too long and the earlier part of it is about to be discarded. Write the replay that takes its place.\n\nYour replay will be **prepended directly to the messages that remain** \u2014 your own most recent turns, which are still there and which you will read immediately after this. Write it so that seam is invisible.\n\nWrite in the **first person, present continuous tense**, in your own voice, in the same prose as the turns it sits in front of. You are not reporting on a session to someone else and you are not recounting something finished: you are picking the work back up, and everything in the replay is the situation as it stands right now.\n\nWrite **every step** as the step itself, then what came back. The opening of a\nstep is what you are about to do; the outcome is its own short sentence after\nit. These are the shapes \u2014 reuse them:\n\n- \"The user is asking me to fix the collision.\"\n- \"Let me start by reading the file.\"\n- \"Let me read a large chunk of the file.\" \u2014 then what it showed.\n- \"Let me try reconstructing the script section. It failed: `check_file` reports an unterminated regular expression at line 274.\"\n- \"Now the editor is warning me this change shifted the line numbers by +11.\"\n- \"The file parses now, so what is left is the collision check.\"\n\nThis holds for the middle of the replay and not only its first and last\nsentences. A step that opens by reporting itself has changed voice, and the\nseam this replay exists to remove is back.\n\nWritten in the past tense the replay reads as history, and history is something you are entitled to doubt: you will re-read files you already know, re-derive what you have already settled, and treat a warning that is still in force as something that merely once happened. Written in the present it is the state of play, which is what it actually is. Every sentence, not only the first and the last.\n\nCarry all of this:\n\n- **What you are asked to do, verbatim.** Quote the instructions you have been given word for word. Everything else here can be rebuilt from the files or from the record below your replay; what was asked exists nowhere else once these messages are gone.\n- **What you have done, in order.** Narrate it, and **cite the calls instead of writing them out.** Every call you made, with its arguments and what it returned, is numbered in the record below. Where a call belongs in your account, put its number in square brackets with a `#`, and carry on:\n\n \"Let me run the checker. [#3] It reports a `SyntaxError` at line 90.\"\n\n The harness puts call 3 in at that point, exactly as it happened. Writing the call out yourself instead would spend your budget copying a record that is already exact, and yours would be the less accurate of the two. Cite each call once, in the order you made them. Where a run of calls in sequence belongs at the same point \u2014 the same check repeated, a read and the edit that followed it \u2014 cite the span as `[#2-5]` rather than one at a time; the harness puts all of them in there. A number you leave out is not lost \u2014 it is added at the end \u2014 but then it sits away from the step it belongs to.\n\n **The record is complete and closed.** Every call you have made is in it, and nothing else is. The highest number in it is the last call you made, so there is no `[#N]` past the end to cite \u2014 if you find yourself reaching for one, the step you are about to describe is a step you have not taken yet, and it does not belong in an account of what you have done. Cite only a number that is actually in the record, and leave a step with no call behind it uncited rather than attaching it to a number that names someone else's work.\n- **What is coming back wrong**, and what you are doing about it. A call that was refused or returned an error is the most important kind to keep \u2014 without it you will simply make it again.\n- **What you have concluded**, including anything you have ruled out and why. An approach that failed, omitted here, is an approach you will try again.\n- **Where you are now**, and what you are about to do next.\n\nDo not invent anything you are not sure of. In particular, do not report a result you cannot see: a call whose output is not in front of you is a call whose outcome you do not know, and writing that it succeeded is the one error here that the next turn cannot recover from.\n\nDo not write instructions to yourself to rewrite or restore content that this replay does not itself contain \u2014 you would be reconstructing from memory something that is still on disk, and producing a worse version of it.\n\nWrite the replay and stop. Do not continue the transcript that follows these instructions, and do not copy any part of it back: it is what you are replacing.";
|
|
59
|
+
export interface CutTranscript {
|
|
60
|
+
text: string;
|
|
61
|
+
/** How much of the summary was the request, copied back. */
|
|
62
|
+
cutChars: number;
|
|
63
|
+
}
|
|
64
|
+
export declare function cutEchoedTranscript(text: string): CutTranscript;
|
|
65
|
+
export interface ReplayBlockLimits {
|
|
66
|
+
/** Longest a fenced block may be before the harness elides its middle. */
|
|
67
|
+
maxBlockChars: number;
|
|
68
|
+
}
|
|
69
|
+
export declare const REPLAY_BLOCK_LIMITS: ReplayBlockLimits;
|
|
70
|
+
export interface TrimmedReplay {
|
|
71
|
+
text: string;
|
|
72
|
+
/** How many blocks the harness had to cut because the model did not. */
|
|
73
|
+
trimmedBlocks: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Cut the payloads the model was asked to trim and did not.
|
|
77
|
+
*
|
|
78
|
+
* Only fenced blocks are touched. A length rule that cannot tell a pasted file
|
|
79
|
+
* from the prose around it would cut the summary itself, and the prose *is*
|
|
80
|
+
* the artifact — a long replay of a long session is correct. So the prose is
|
|
81
|
+
* never trimmed here however long it runs; the request budget is what bounds
|
|
82
|
+
* that, and it bounds it by asking again rather than by silently deleting the
|
|
83
|
+
* middle of a sentence.
|
|
84
|
+
*
|
|
85
|
+
* An unterminated fence is treated as running to the end of the text. A model
|
|
86
|
+
* that exhausts its budget mid-block leaves one open, and the summary is still
|
|
87
|
+
* the only record of that stretch — dropping it to punish the malformed fence
|
|
88
|
+
* would discard the very thing being preserved.
|
|
89
|
+
*/
|
|
90
|
+
export declare function trimReplayOverflow(text: string, limits?: Partial<ReplayBlockLimits>): TrimmedReplay;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the tools did, for a transcript that is about to be discarded.
|
|
3
|
+
*
|
|
4
|
+
* Both compaction strategies need this and neither can get it from the model.
|
|
5
|
+
* A summary is the model's account of its own work, and the one thing it is
|
|
6
|
+
* measurably worst at is remembering which calls it actually made: it
|
|
7
|
+
* reconstructs plausible ones, drops the refused ones, and repeats work it has
|
|
8
|
+
* already done because nothing in the summary said it had. The ledger is the
|
|
9
|
+
* harness's account of the same stretch, taken from the messages rather than
|
|
10
|
+
* from the model, and it is appended to the summary rather than requested
|
|
11
|
+
* inside it.
|
|
12
|
+
*
|
|
13
|
+
* Three problems shape the format.
|
|
14
|
+
*
|
|
15
|
+
* **Size.** A whole-file write is the largest single thing in any transcript
|
|
16
|
+
* and the least worth reproducing, because the file is still on disk. So a
|
|
17
|
+
* long field is never copied — it is measured, and where a revision log is
|
|
18
|
+
* available the entry names the revision that holds it. That is the trade the
|
|
19
|
+
* file-revision store already exists to make: an address instead of a body.
|
|
20
|
+
*
|
|
21
|
+
* **Repetition.** A stuck run calls the same thing over and over; that is the
|
|
22
|
+
* behaviour the corpus shows ending runs. Listing forty identical `read_files`
|
|
23
|
+
* calls buries the four that matter, so identical calls collapse — unless the
|
|
24
|
+
* *result* changed, which is the one case where the repeat is the story rather
|
|
25
|
+
* than the noise.
|
|
26
|
+
*
|
|
27
|
+
* **Legibility.** The reader is a small model that has just lost its memory.
|
|
28
|
+
* One line per call, the failures marked, no JSON it has to parse.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Any message with a content array, in either of the two block shapes this
|
|
32
|
+
* repository carries — see {@link normaliseCall}.
|
|
33
|
+
*/
|
|
34
|
+
export interface ToolLedgerMessage {
|
|
35
|
+
content?: unknown;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A file the folded stretch touched, and the revisions holding its earlier
|
|
39
|
+
* content.
|
|
40
|
+
*
|
|
41
|
+
* Stated per file rather than per call, and that is a correction. The ledger
|
|
42
|
+
* used to print `path: #1 → #2` on a call's own line, which reads as a claim
|
|
43
|
+
* about *that call* -- and the revision log cannot support one: it records
|
|
44
|
+
* revisions in order with the tool that made each, not which call made which,
|
|
45
|
+
* and the correspondence breaks exactly where it matters (identical calls are
|
|
46
|
+
* collapsed into one entry, a refused call makes no revision, and an opaque
|
|
47
|
+
* writer can make several). A wrong revision number is worse than none,
|
|
48
|
+
* because the model acts on it by trying to restore it.
|
|
49
|
+
*
|
|
50
|
+
* The span is true however the calls line up, and it is what the model needs
|
|
51
|
+
* anyway: not "what did this call do" -- the result line says that -- but
|
|
52
|
+
* "where can I get this file's earlier content".
|
|
53
|
+
*/
|
|
54
|
+
export interface ToolLedgerFileHistory {
|
|
55
|
+
path: string;
|
|
56
|
+
/** The revisions that exist, e.g. `#1–#7`, or `#1` when there is one. */
|
|
57
|
+
span: string;
|
|
58
|
+
}
|
|
59
|
+
export interface ToolLedgerEntry {
|
|
60
|
+
/** 1-based, in the order the calls were made. */
|
|
61
|
+
index: number;
|
|
62
|
+
toolName: string;
|
|
63
|
+
/** The arguments, trimmed and on one line where they fit. */
|
|
64
|
+
input: string;
|
|
65
|
+
/** What came back, trimmed. */
|
|
66
|
+
result: string;
|
|
67
|
+
/** The call reported an error, or returned a refusal. */
|
|
68
|
+
failed: boolean;
|
|
69
|
+
/** How many identical calls this entry stands for. 1 is the common case. */
|
|
70
|
+
repeated: number;
|
|
71
|
+
/**
|
|
72
|
+
* The paths this call named, in the order its arguments gave them.
|
|
73
|
+
*
|
|
74
|
+
* Recorded unconditionally, because a path is a fact about the call rather
|
|
75
|
+
* than a claim about the file. What is held for those paths is answered
|
|
76
|
+
* once per file by {@link collectFileHistories}.
|
|
77
|
+
*/
|
|
78
|
+
files: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface ToolLedgerLimits {
|
|
81
|
+
/** Longest a single scalar field may be before it is elided. */
|
|
82
|
+
maxFieldChars: number;
|
|
83
|
+
/** Longest the rendered arguments may be, all fields together. */
|
|
84
|
+
maxInputChars: number;
|
|
85
|
+
/** Longest a result may be. */
|
|
86
|
+
maxResultChars: number;
|
|
87
|
+
/** A string with at least this many lines is reported as a size. */
|
|
88
|
+
multilineLineFloor: number;
|
|
89
|
+
}
|
|
90
|
+
export declare const DEFAULT_TOOL_LEDGER_LIMITS: ToolLedgerLimits;
|
|
91
|
+
export interface ToolLedgerOptions {
|
|
92
|
+
limits?: Partial<ToolLedgerLimits>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The revisions held for one file, as a span like `#1–#7`.
|
|
96
|
+
*
|
|
97
|
+
* Supplied by the caller because the ledger is pure: it reads messages, and
|
|
98
|
+
* the revision log lives with the session. Nothing for a file the log does not
|
|
99
|
+
* track, which is most of them — an untracked file simply does not appear.
|
|
100
|
+
*/
|
|
101
|
+
export type RevisionSpanLookup = (path: string) => string | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Pair the calls in a stretch of messages with their results.
|
|
104
|
+
*
|
|
105
|
+
* Paired by call id, never by position: a turn can issue several calls and
|
|
106
|
+
* their results arrive in one message, so counting on order puts the wrong
|
|
107
|
+
* answer against the wrong call — which reads as a tool that returned
|
|
108
|
+
* something it never returned.
|
|
109
|
+
*/
|
|
110
|
+
export declare function buildToolLedger(messages: readonly ToolLedgerMessage[], options?: ToolLedgerOptions): ToolLedgerEntry[];
|
|
111
|
+
/**
|
|
112
|
+
* Concatenate a carried ledger with this compaction's own, as one run.
|
|
113
|
+
*
|
|
114
|
+
* The seam is where the repeat rule matters most: a checker run just before a
|
|
115
|
+
* compaction and again just after is one fact reported twice, and it is the
|
|
116
|
+
* call most likely to repeat because it follows every edit. So the same rule
|
|
117
|
+
* `buildToolLedger` applies within a stretch is applied across the join —
|
|
118
|
+
* same tool, same arguments, same answer collapses; a changed answer does not,
|
|
119
|
+
* because a changed answer is the most informative pair in the record.
|
|
120
|
+
*/
|
|
121
|
+
export declare function mergeToolLedger(previous: readonly ToolLedgerEntry[], next: readonly ToolLedgerEntry[]): ToolLedgerEntry[];
|
|
122
|
+
/**
|
|
123
|
+
* Bring a carried ledger back under budget, losing the recoverable calls
|
|
124
|
+
* first.
|
|
125
|
+
*
|
|
126
|
+
* Three tiers, oldest first within each: successful non-verdict calls, then
|
|
127
|
+
* failed non-verdict calls, then anything that returned a verdict. A refused
|
|
128
|
+
* read outranks a successful one because the summary is measurably worst at
|
|
129
|
+
* keeping refusals, and without it the model simply makes the call again.
|
|
130
|
+
*
|
|
131
|
+
* Eviction rather than truncation, because a ledger is a record: half an entry
|
|
132
|
+
* says something that did not happen, where a missing entry only fails to say
|
|
133
|
+
* something that did.
|
|
134
|
+
*/
|
|
135
|
+
export declare function evictToolLedger(entries: readonly ToolLedgerEntry[], budgetChars: number): ToolLedgerEntry[];
|
|
136
|
+
/**
|
|
137
|
+
* The ledger as the model will read it.
|
|
138
|
+
*
|
|
139
|
+
* One line per call, the marks where the eye lands rather than at the end of a
|
|
140
|
+
* long line: a reader scanning for what went wrong should not have to finish
|
|
141
|
+
* every line to find out.
|
|
142
|
+
*/
|
|
143
|
+
/** One entry, as it prints in the ledger and inline in a replay. */
|
|
144
|
+
export declare function renderToolLedgerEntry(entry: ToolLedgerEntry): string;
|
|
145
|
+
/**
|
|
146
|
+
* The numbering key the replay cites against: which call is which, and
|
|
147
|
+
* nothing else.
|
|
148
|
+
*
|
|
149
|
+
* Deliberately without the results. The writer needs to know that call 7 is
|
|
150
|
+
* the checker run, not what the checker said -- it has the conversation for
|
|
151
|
+
* that, and the results are the bulk of the ledger. Sending them would also
|
|
152
|
+
* undo a budget decision made elsewhere: a long tool result is truncated on
|
|
153
|
+
* its way into the transcript, while the ledger elides the middle and keeps
|
|
154
|
+
* the tail, so the full ledger hands back a fragment the transcript had
|
|
155
|
+
* deliberately cut.
|
|
156
|
+
*/
|
|
157
|
+
export declare function renderToolLedgerKey(entries: readonly ToolLedgerEntry[]): string;
|
|
158
|
+
export interface LedgerSpliceResult {
|
|
159
|
+
text: string;
|
|
160
|
+
/** Entries the replay placed itself, in the order it placed them. */
|
|
161
|
+
cited: number[];
|
|
162
|
+
/** Entries it did not, appended after the prose so nothing is lost. */
|
|
163
|
+
uncited: number[];
|
|
164
|
+
/**
|
|
165
|
+
* Citations naming a call that does not exist, or naming one twice.
|
|
166
|
+
*
|
|
167
|
+
* Dropped from the text, counted here. Measured on pandorum: a replay
|
|
168
|
+
* citing `[#31]`–`[#33]` against a 30-entry ledger, which is the model
|
|
169
|
+
* narrating steps it did not take — the bad number is discarded but the
|
|
170
|
+
* invented sentence around it stays, so this is the only signal that the
|
|
171
|
+
* prose has run past the record.
|
|
172
|
+
*/
|
|
173
|
+
invalid: number[];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Put each call where the replay says it happened.
|
|
177
|
+
*
|
|
178
|
+
* The replay narrates the work and the ledger records the calls, in the same
|
|
179
|
+
* order, so the writer is asked for a citation rather than a transcription:
|
|
180
|
+
* `[#7]` costs it four tokens where writing the call out cost four hundred.
|
|
181
|
+
* Measured before this existed, tool transcription took 69% of a small model's
|
|
182
|
+
* whole output budget and the prose was cut off mid-sentence.
|
|
183
|
+
*
|
|
184
|
+
* Every way this can go wrong degrades to what it replaced. A citation naming
|
|
185
|
+
* an entry that does not exist, or one already used, is dropped; an entry the
|
|
186
|
+
* replay never cites is appended at the end. The worst case is a ledger block
|
|
187
|
+
* after the prose, which is where the ledger sat anyway.
|
|
188
|
+
*/
|
|
189
|
+
export declare function spliceLedgerCitations(replay: string, entries: readonly ToolLedgerEntry[]): LedgerSpliceResult;
|
|
190
|
+
export declare function renderToolLedger(entries: readonly ToolLedgerEntry[], histories?: readonly ToolLedgerFileHistory[]): string;
|
|
191
|
+
/**
|
|
192
|
+
* The files the ledger touched that the revision log still holds, once each.
|
|
193
|
+
*
|
|
194
|
+
* First-touched order rather than sorted: the ledger is read top to bottom and
|
|
195
|
+
* a file's place in that order is the reader's way back to the calls it
|
|
196
|
+
* belongs to.
|
|
197
|
+
*/
|
|
198
|
+
export declare function collectFileHistories(entries: readonly ToolLedgerEntry[], spanFor: RevisionSpanLookup | undefined): ToolLedgerFileHistory[];
|