@sema-agent/core 5.19.0 → 5.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +102 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-transcript-tool.d.ts +30 -0
- package/dist/agents/builtin-agents.d.ts +60 -0
- package/dist/agents/cascade.d.ts +107 -0
- package/dist/agents/cumulative-stats.d.ts +56 -0
- package/dist/agents/observer.d.ts +162 -0
- package/dist/agents/peer-admission.d.ts +95 -0
- package/dist/agents/repair-loop.d.ts +226 -0
- package/dist/agents/retain-ledger.d.ts +141 -0
- package/dist/agents/roster-store.d.ts +105 -0
- package/dist/agents/roster-store.js +3 -0
- package/dist/agents/send-message-tool.d.ts +92 -0
- package/dist/agents/session-util.d.ts +5 -0
- package/dist/agents/subagent-steps.d.ts +66 -0
- package/dist/agents/subagent.d.ts +600 -0
- package/dist/agents/suspend-guard.d.ts +29 -0
- package/dist/agents/teacher.d.ts +75 -0
- package/dist/agents/team.d.ts +120 -1
- package/dist/agents/tool-filter.d.ts +34 -0
- package/dist/agents/verify.d.ts +198 -0
- package/dist/bench/metrics.d.ts +455 -0
- package/dist/brain/anthropic.d.ts +30 -0
- package/dist/brain/circuit-breaker.d.ts +33 -0
- package/dist/brain/circuit-breaker.js +14 -3
- package/dist/brain/context-overflow.d.ts +60 -3
- package/dist/brain/degrading.d.ts +67 -0
- package/dist/brain/errors.d.ts +42 -0
- package/dist/brain/failover.d.ts +15 -0
- package/dist/brain/media-degrade.d.ts +39 -0
- package/dist/brain/model-presets.d.ts +31 -0
- package/dist/brain/open-responses.d.ts +19 -0
- package/dist/brain/openai.d.ts +46 -0
- package/dist/brain/reasoning.d.ts +106 -1
- package/dist/brain/repetition.d.ts +83 -0
- package/dist/brain/request-params.d.ts +56 -0
- package/dist/brain/retry.d.ts +46 -0
- package/dist/brain/routing.d.ts +12 -0
- package/dist/brain/status-sink.d.ts +30 -1
- package/dist/brain/stream-engine.d.ts +147 -0
- package/dist/brain/stream-shared.d.ts +34 -0
- package/dist/brain/terminal-cause.d.ts +31 -0
- package/dist/brain/timeout.d.ts +108 -0
- package/dist/brain/timeout.js +11 -0
- package/dist/brain/tool-call-id.d.ts +20 -0
- package/dist/brain/tool-call-repair.d.ts +13 -0
- package/dist/config/catalog.d.ts +47 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/core/a2a-task-state.d.ts +53 -0
- package/dist/core/a2a.d.ts +51 -0
- package/dist/core/arg-summary.d.ts +62 -0
- package/dist/core/ask-question.d.ts +272 -2
- package/dist/core/auto-compaction.d.ts +467 -0
- package/dist/core/auto-compaction.js +20 -6
- package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
- package/dist/core/auto-mode-prompt.d.ts +27 -0
- package/dist/core/auto-mode.d.ts +54 -3
- package/dist/core/auto-promote.d.ts +100 -0
- package/dist/core/background-agent-store.d.ts +293 -0
- package/dist/core/background-agent-store.js +5 -0
- package/dist/core/background-shell.d.ts +110 -0
- package/dist/core/cache-break-detector.d.ts +34 -0
- package/dist/core/canonical-json.d.ts +57 -0
- package/dist/core/checkpoint-store.d.ts +1574 -16
- package/dist/core/compliance.d.ts +30 -0
- package/dist/core/consolidate-scope.d.ts +75 -0
- package/dist/core/context-edit.d.ts +99 -0
- package/dist/core/context-guard.d.ts +46 -0
- package/dist/core/exec-gate.d.ts +44 -0
- package/dist/core/exec-output-tail.d.ts +61 -0
- package/dist/core/file-snapshot-store.d.ts +104 -0
- package/dist/core/fs-write-gate-policy.d.ts +36 -0
- package/dist/core/git-worktree-env.d.ts +31 -0
- package/dist/core/governance-codes.d.ts +19 -0
- package/dist/core/hooks.d.ts +609 -1
- package/dist/core/human-input-projection.d.ts +37 -0
- package/dist/core/human-input-projection.js +13 -0
- package/dist/core/image-downsample.d.ts +74 -0
- package/dist/core/locked-config.d.ts +37 -0
- package/dist/core/lsp-diagnostics.d.ts +77 -0
- package/dist/core/lsp-protocol.d.ts +29 -0
- package/dist/core/lsp-session.d.ts +60 -1
- package/dist/core/lsp.d.ts +150 -1
- package/dist/core/mailbox-store.d.ts +57 -0
- package/dist/core/mailbox-store.js +2 -0
- package/dist/core/mcp.d.ts +385 -0
- package/dist/core/mcp.js +58 -11
- package/dist/core/media-byte-cap.d.ts +21 -0
- package/dist/core/memory-admission.d.ts +71 -0
- package/dist/core/memory-engine/content-origin.d.ts +64 -0
- package/dist/core/memory-engine/data-plane.d.ts +43 -0
- package/dist/core/memory-engine/dual-root.d.ts +24 -0
- package/dist/core/memory-engine/engine.d.ts +230 -0
- package/dist/core/memory-engine/engine.js +103 -35
- package/dist/core/memory-engine/file-backend.d.ts +155 -0
- package/dist/core/memory-engine/frontmatter.d.ts +16 -0
- package/dist/core/memory-engine/layout.d.ts +217 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
- package/dist/core/memory-engine/migrate.d.ts +9 -0
- package/dist/core/memory-engine/scan.d.ts +12 -0
- package/dist/core/memory-engine/scope-contract.d.ts +61 -1
- package/dist/core/memory-engine/sync-client.d.ts +87 -0
- package/dist/core/memory-engine/sync.d.ts +60 -0
- package/dist/core/memory-engine/tools.d.ts +41 -0
- package/dist/core/memory-engine/types.d.ts +188 -0
- package/dist/core/memory-recall.d.ts +141 -0
- package/dist/core/memory-vector.d.ts +20 -0
- package/dist/core/memory.d.ts +458 -0
- package/dist/core/message-utils.d.ts +6 -0
- package/dist/core/oracle-isolation.d.ts +69 -0
- package/dist/core/permission-rule-consent.d.ts +138 -0
- package/dist/core/permission-rule-model.d.ts +122 -0
- package/dist/core/permission-rule-store.d.ts +119 -3
- package/dist/core/permission-rules.d.ts +87 -1
- package/dist/core/present-plan-tool.d.ts +20 -0
- package/dist/core/pricing.d.ts +26 -0
- package/dist/core/property-harness.d.ts +86 -0
- package/dist/core/protocol-naming.d.ts +38 -0
- package/dist/core/protocol-table.d.ts +61 -0
- package/dist/core/push-queue.d.ts +1 -0
- package/dist/core/remote-env.d.ts +383 -1
- package/dist/core/retention-policy.d.ts +40 -0
- package/dist/core/retention-policy.js +21 -0
- package/dist/core/retention.d.ts +51 -0
- package/dist/core/roles.d.ts +59 -0
- package/dist/core/runner/active-skill-scope.d.ts +34 -0
- package/dist/core/runner/assemble-result.d.ts +134 -0
- package/dist/core/runner/compaction-call-options.d.ts +97 -1
- package/dist/core/runner/grounding-signal.d.ts +10 -0
- package/dist/core/runner/image.d.ts +17 -0
- package/dist/core/runner/image.js +29 -15
- package/dist/core/runner/memory-consolidation.d.ts +60 -0
- package/dist/core/runner/prepare-memory.d.ts +59 -0
- package/dist/core/runner/prepare-task.d.ts +1011 -2
- package/dist/core/runner/prepare-task.js +51 -14
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- package/dist/core/runner/runtask.js +17 -2
- package/dist/core/runner/session-file-state-replay.d.ts +49 -0
- package/dist/core/runner/session-rule-policy.d.ts +58 -0
- package/dist/core/runner/strict-output-schema.d.ts +18 -3
- package/dist/core/runner/synthetic-tools.d.ts +113 -0
- package/dist/core/runner/teardown-bounded.d.ts +34 -0
- package/dist/core/runner/tool-disclosure.d.ts +227 -0
- package/dist/core/runner/tool-output-projection.d.ts +6 -0
- package/dist/core/runner/turn-attachments.d.ts +634 -0
- package/dist/core/runner/usage-accounting.d.ts +32 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/safe-notify.d.ts +64 -0
- package/dist/core/safety-axis-vocab.d.ts +23 -0
- package/dist/core/safety-merge-corpus.d.ts +37 -0
- package/dist/core/scheduler.d.ts +121 -0
- package/dist/core/secret-env.d.ts +32 -0
- package/dist/core/select-model.d.ts +15 -0
- package/dist/core/sensitive-path-policy.d.ts +42 -0
- package/dist/core/session-policy-store.d.ts +94 -0
- package/dist/core/session-reconcile.d.ts +80 -0
- package/dist/core/session-store.d.ts +85 -0
- package/dist/core/session.d.ts +153 -0
- package/dist/core/shared-memory/contract.d.ts +22 -0
- package/dist/core/shared-memory/normalize.d.ts +123 -2
- package/dist/core/shared-memory/tools.d.ts +14 -0
- package/dist/core/shared-memory/types.d.ts +105 -0
- package/dist/core/shutdown-debug.d.ts +6 -0
- package/dist/core/side-query.d.ts +38 -0
- package/dist/core/side-query.js +6 -1
- package/dist/core/skill-tool-specifier.d.ts +72 -0
- package/dist/core/skills-directory.d.ts +100 -1
- package/dist/core/spec-contract.d.ts +89 -0
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
- package/dist/core/store-contracts/contract-harness.d.ts +20 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
- package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
- package/dist/core/strategy-store.d.ts +37 -0
- package/dist/core/stub-env.d.ts +7 -0
- package/dist/core/surrogate-safe-slice.d.ts +35 -0
- package/dist/core/task-notification.d.ts +202 -0
- package/dist/core/task-outcome.d.ts +53 -0
- package/dist/core/task-registry-agent.d.ts +337 -1
- package/dist/core/task-registry-agent.js +2 -0
- package/dist/core/task-registry-monitor.d.ts +12 -0
- package/dist/core/task-registry-shared.d.ts +540 -0
- package/dist/core/task-registry.d.ts +343 -0
- package/dist/core/task-registry.js +13 -2
- package/dist/core/task-tool-shape.d.ts +44 -0
- package/dist/core/tighten-task-spec.d.ts +21 -0
- package/dist/core/tool-detach.d.ts +21 -0
- package/dist/core/tool-errors.d.ts +131 -0
- package/dist/core/tool-errors.js +4 -0
- package/dist/core/tool-name-aliases.d.ts +27 -0
- package/dist/core/tool-policy.d.ts +555 -0
- package/dist/core/tool-policy.js +3 -0
- package/dist/core/tool-result-budget.d.ts +32 -0
- package/dist/core/tool-result-store.d.ts +174 -1
- package/dist/core/tools.d.ts +45 -0
- package/dist/core/trace.d.ts +323 -0
- package/dist/core/types.d.ts +3859 -2
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-text.d.ts +156 -0
- package/dist/core/usage-window-store.d.ts +95 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/warm-resume.d.ts +17 -0
- package/dist/core/wiring-manifest.d.ts +169 -0
- package/dist/core/with-retry.d.ts +24 -0
- package/dist/core/workflow-journal-store.d.ts +160 -0
- package/dist/core/workflow-run-store-contract.d.ts +25 -0
- package/dist/core/workflow-run-store.d.ts +119 -0
- package/dist/core/workflow-run-store.js +2 -0
- package/dist/engine/compaction/compaction.d.ts +256 -1
- package/dist/engine/compaction/utils.d.ts +94 -0
- package/dist/engine/execution-env/kill-tree.d.ts +29 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
- package/dist/engine/harness/agent-harness.d.ts +116 -0
- package/dist/engine/harness/agent-harness.js +3 -14
- package/dist/engine/harness/messages.d.ts +15 -0
- package/dist/engine/harness/types.d.ts +464 -2
- package/dist/engine/llm/diagnostics.d.ts +4 -0
- package/dist/engine/llm/event-stream.d.ts +3 -0
- package/dist/engine/llm/index.d.ts +7 -0
- package/dist/engine/llm/types.d.ts +500 -3
- package/dist/engine/llm/validation.d.ts +3 -0
- package/dist/engine/loop/agent-loop.d.ts +87 -2
- package/dist/engine/loop/runtime-deps.d.ts +7 -0
- package/dist/engine/loop/types.d.ts +424 -0
- package/dist/engine/lsp/frame-decoder.d.ts +13 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
- package/dist/engine/session/import-validate.d.ts +27 -0
- package/dist/engine/session/log-digest.d.ts +93 -0
- package/dist/engine/session/memory-repo.d.ts +6 -0
- package/dist/engine/session/memory-storage.d.ts +2 -0
- package/dist/engine/session/session.d.ts +75 -0
- package/dist/engine/session/storage-base.d.ts +8 -0
- package/dist/fixtures/index.d.ts +36 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +1 -2
- package/dist/internal/harness-types.d.ts +6 -0
- package/dist/internal/harness.d.ts +11 -0
- package/dist/internal/llm.d.ts +6 -0
- package/dist/orchestration/builtin-workflows.d.ts +53 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
- package/dist/orchestration/goal.d.ts +57 -0
- package/dist/orchestration/goal.js +3 -0
- package/dist/orchestration/run-spec.d.ts +42 -0
- package/dist/orchestration/run-spec.js +4 -0
- package/dist/orchestration/run-workflow-tool.d.ts +169 -0
- package/dist/orchestration/workflow-governance.d.ts +61 -0
- package/dist/orchestration/workflow-meta.d.ts +28 -0
- package/dist/orchestration/workflow-observe.d.ts +60 -0
- package/dist/orchestration/workflow-primitives.d.ts +23 -1
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
- package/dist/orchestration/workflow-script-runner.d.ts +88 -0
- package/dist/orchestration/workflow-script-store.d.ts +98 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
- package/dist/orchestration/workflow-types.d.ts +169 -2
- package/dist/orchestration/workflow.d.ts +358 -0
- package/dist/orchestration/workflow.js +13 -2
- package/dist/prompt-assembly/artifact-store.d.ts +33 -0
- package/dist/prompt-assembly/artifact.d.ts +25 -0
- package/dist/prompt-assembly/assemble.d.ts +20 -0
- package/dist/prompt-assembly/composer.d.ts +29 -0
- package/dist/prompt-assembly/epoch.d.ts +55 -1
- package/dist/prompt-assembly/event-registry.d.ts +35 -0
- package/dist/prompt-assembly/explain.d.ts +12 -0
- package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
- package/dist/prompt-assembly/types.d.ts +115 -0
- package/dist/prompts/coordinator.d.ts +27 -0
- package/dist/prompts/default.d.ts +539 -0
- package/dist/prompts/simple-sections.d.ts +45 -0
- package/dist/prompts/supervisor.d.ts +66 -0
- package/dist/scenarios/env.d.ts +28 -0
- package/dist/scenarios/full-body.d.ts +50 -0
- package/dist/scenarios/scenario-registry.d.ts +60 -0
- package/dist/scenarios/teacher-quickstart.d.ts +27 -0
- package/dist/server/http.d.ts +17 -0
- package/dist/stores/cc/lockfile.d.ts +6 -0
- package/dist/stores/cc/mailbox-store.d.ts +8 -0
- package/dist/stores/cc/roster-adapter.d.ts +4 -0
- package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
- package/dist/stores/file/background-agent-store.d.ts +24 -0
- package/dist/stores/file/background-agent-store.js +2 -1
- package/dist/stores/file/checkpoint-store.d.ts +38 -0
- package/dist/stores/file/file-snapshot-store.d.ts +25 -0
- package/dist/stores/file/fs-atomic.d.ts +155 -0
- package/dist/stores/file/index.d.ts +89 -0
- package/dist/stores/file/mailbox-store.d.ts +36 -0
- package/dist/stores/file/mailbox-store.js +2 -0
- package/dist/stores/file/memory-store.d.ts +82 -0
- package/dist/stores/file/permission-rule-store.d.ts +79 -0
- package/dist/stores/file/session-policy-store.d.ts +28 -0
- package/dist/stores/file/session-store.d.ts +40 -0
- package/dist/stores/file/shared-ledger.d.ts +83 -0
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/usage-window-store.d.ts +18 -0
- package/dist/stores/file/workflow-journal-store.d.ts +100 -0
- package/dist/stores/file/workflow-run-store.d.ts +11 -0
- package/dist/stores/file/workflow-run-store.js +2 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
- package/dist/tools/fs/encoding.d.ts +60 -0
- package/dist/tools/fs/fs-bash.d.ts +133 -0
- package/dist/tools/fs/fs-pdf.d.ts +28 -0
- package/dist/tools/fs/fs-search-tools.d.ts +5 -0
- package/dist/tools/fs/fs-shared.d.ts +360 -0
- package/dist/tools/fs/fs-write.d.ts +16 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
- package/dist/tools/fs/index.d.ts +79 -0
- package/dist/tools/fs/notebook.d.ts +56 -0
- package/dist/tools/fs/pdf.d.ts +70 -0
- package/dist/tools/fs/pdf.js +8 -2
- package/dist/tools/fs/repo-map.d.ts +10 -0
- package/dist/tools/fs/safety.d.ts +376 -0
- package/dist/tools/fs/search.d.ts +131 -0
- package/dist/tools/loop-tick.d.ts +24 -0
- package/dist/tools/monitor.d.ts +55 -0
- package/dist/tools/scheduler-tools.d.ts +51 -0
- package/dist/tools/sql-adapters.d.ts +18 -0
- package/dist/tools/sql.d.ts +25 -0
- package/dist/tools/task-list.d.ts +77 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/web.d.ts +184 -0
- package/dist/tools/web.js +32 -5
- package/dist/tools/worktree.d.ts +81 -0
- package/package.json +2 -2
- package/dist/tools/gitea-issue.d.ts +0 -13
- package/dist/tools/gitea-issue.js +0 -75
package/dist/core/lsp.d.ts
CHANGED
|
@@ -1,21 +1,68 @@
|
|
|
1
1
|
import type { AgentTool, ExecutionEnv } from "../internal/harness-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* LSP code-intelligence tool (design/64 §13.1) — the app-dev命门 (go-to-def / find-refs / hover across
|
|
4
|
+
* Dart/Kotlin/TS). A single `lsp` tool with a 9-operation enum, built over a pluggable {@link LspServerManager}.
|
|
5
|
+
*
|
|
6
|
+
* **Seam note (core verifying the design against real code):** the design assumed core spawns a language
|
|
7
|
+
* server inside the ExecutionEnv via `execStream`, but `execStream` is OUTPUT-only — it has no stdin, so the
|
|
8
|
+
* base seam can't drive a persistent stdio language server generically. So core ships the **tool + manager
|
|
9
|
+
* seam + graceful degrade + git-ignore filter + formatters**; the *real* in-env manager (E2B LSP sidecar, or
|
|
10
|
+
* a future bidirectional-process seam) is deployment-provided via {@link RunnerDeps.lspManager}. When no
|
|
11
|
+
* server is available for a file's language the tool **degrades gracefully** ("fall back to Grep/Read")
|
|
12
|
+
* rather than erroring — the design's hard constraint for remote portability.
|
|
13
|
+
*/
|
|
2
14
|
export type LspOperation = "goToDefinition" | "findReferences" | "hover" | "documentSymbol" | "workspaceSymbol" | "goToImplementation" | "prepareCallHierarchy" | "incomingCalls" | "outgoingCalls";
|
|
3
15
|
export declare const LSP_OPERATIONS: readonly LspOperation[];
|
|
16
|
+
/**
|
|
17
|
+
* A source location (a definition/reference/implementation hit). `uri` is a file path or file:// URI.
|
|
18
|
+
*
|
|
19
|
+
* Base convention (the seam's factual contract, service[64] flag①): `line` is **1-based**, `character`
|
|
20
|
+
* is **0-based** — the tool-schema convention the model is taught. Core passes positions through
|
|
21
|
+
* VERBATIM in both directions; the `LspServerManager` implementation owns the conversion to/from the
|
|
22
|
+
* LSP wire protocol (which is 0-based for BOTH) — e.g. request line−1 on the way in, result line+1 on
|
|
23
|
+
* the way out, call-hierarchy items relayed as wire values it already converted.
|
|
24
|
+
*/
|
|
4
25
|
export interface LspLocation {
|
|
5
26
|
uri: string;
|
|
27
|
+
/** 1-based (tool convention — manager converts to the 0-based LSP wire). */
|
|
6
28
|
line: number;
|
|
29
|
+
/** 0-based (matches the LSP wire). */
|
|
7
30
|
character: number;
|
|
31
|
+
/** Optional one-line preview of the matched line. */
|
|
8
32
|
preview?: string;
|
|
9
33
|
}
|
|
34
|
+
/** A symbol (document/workspace symbol, call-hierarchy item). Same base convention as {@link LspLocation}. */
|
|
10
35
|
export interface LspSymbolInfo {
|
|
11
36
|
name: string;
|
|
12
37
|
kind?: string;
|
|
13
38
|
uri: string;
|
|
39
|
+
/** 1-based (tool convention — manager converts to the 0-based LSP wire). */
|
|
14
40
|
line: number;
|
|
41
|
+
/** 0-based (matches the LSP wire). */
|
|
15
42
|
character: number;
|
|
43
|
+
/**
|
|
44
|
+
* HRD-LSP-18: the server supplied NO range for this symbol — `line`/`character` are placeholders, not a
|
|
45
|
+
* location. LSP allows exactly this for an unresolved `WorkspaceSymbol` (`{ name, kind, location: { uri } }`,
|
|
46
|
+
* resolved later via `workspaceSymbol/resolve`), and the coercion below used to substitute `{0,0}` silently,
|
|
47
|
+
* which the tool then rendered as a precise-looking `uri:1:1` the server never said. Set ⇒ the renderer
|
|
48
|
+
* prints the file WITHOUT coordinates.
|
|
49
|
+
*/
|
|
16
50
|
positionUnknown?: boolean;
|
|
17
51
|
}
|
|
18
|
-
|
|
52
|
+
/**
|
|
53
|
+
* RB-232(黑板 [1937]): WHY a "none" result was "none". Absent `reason` = a GENUINE empty answer (the server
|
|
54
|
+
* answered null/[] — today's behavior byte-for-byte, and what an external manager returning bare
|
|
55
|
+
* `{kind:"none"}` keeps getting). The failure reasons exist because one literal "No results." used to cover
|
|
56
|
+
* both real emptiness and every transport-level fault — a findReferences that TIMED OUT read as "no
|
|
57
|
+
* references, safe to delete" (CC 2.1.220 keeps these apart: `Error performing ${operation}: ...` vs the
|
|
58
|
+
* plain empty-result strings, pretty220.js ~474840).
|
|
59
|
+
*/
|
|
60
|
+
export type LspNoneReason = "unsupported_operation" | "server_error" | "timeout" | "cancelled" | "server_terminated" | "no_call_hierarchy_item"
|
|
61
|
+
/** HRD-LSP-7: the QUERIED file could not be read for the didOpen/didChange re-sync (deleted between the
|
|
62
|
+
* tool's precheck and the op, EACCES, non-regular, over the size cap, a symlinked over-cap target). The
|
|
63
|
+
* session used to swallow that and query the server anyway, so the resulting `null`/`[]` was
|
|
64
|
+
* indistinguishable from a confirmed-empty answer — the exact confusion the reason set exists to end. */
|
|
65
|
+
| "file_sync_failed";
|
|
19
66
|
export type LspResult = {
|
|
20
67
|
kind: "locations";
|
|
21
68
|
locations: LspLocation[];
|
|
@@ -30,48 +77,150 @@ export type LspResult = {
|
|
|
30
77
|
reason?: LspNoneReason;
|
|
31
78
|
detail?: string;
|
|
32
79
|
};
|
|
80
|
+
/** The property {@link brandLspFailure} sets — a STRING property, not a class: the brand must survive a
|
|
81
|
+
* dual ESM/CJS build and duplicated module instances, where `instanceof` does not (same structural-
|
|
82
|
+
* detection philosophy as {@link pathToUri}'s form detection — never key on identity you don't control). */
|
|
33
83
|
export declare const LSP_FAILURE_BRAND = "lspFailureReason";
|
|
84
|
+
/** Brand a transport-layer error with its {@link LspNoneReason} at the THROW site — the throw site is the
|
|
85
|
+
* only place that still holds the discriminator (e.g. the JSON-RPC error CODE, which message-regex
|
|
86
|
+
* classification cannot recover, and which differs textually across transports). */
|
|
34
87
|
export declare function brandLspFailure<E extends Error>(e: E, reason: LspNoneReason, detail?: string): E;
|
|
88
|
+
/** Duck-typed read of {@link brandLspFailure}'s brand (membership-checked — an arbitrary string-valued
|
|
89
|
+
* property of the same name on a third-party error never becomes a reason we didn't define). */
|
|
35
90
|
export declare function lspFailureOf(e: unknown): {
|
|
36
91
|
reason: LspNoneReason;
|
|
37
92
|
detail?: string;
|
|
38
93
|
} | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* The abort signal for work shared by several callers: it fires only once EVERY registered caller has
|
|
96
|
+
* abandoned it, so one caller's cancellation can never cancel another caller's work. A joiner that
|
|
97
|
+
* passes no signal never abandons (the job then runs to completion regardless of the others).
|
|
98
|
+
*
|
|
99
|
+
* The scope is single-use: once it has aborted, the owner must NOT let a new caller join it (the job it
|
|
100
|
+
* guards is already dying) — check {@link signal}`.aborted` before reusing an in-flight entry.
|
|
101
|
+
*/
|
|
39
102
|
export declare class SharedAbortScope {
|
|
40
103
|
private readonly controller;
|
|
41
104
|
private joiners;
|
|
42
105
|
private abandoned;
|
|
43
106
|
get signal(): AbortSignal;
|
|
107
|
+
/** Register one caller (its `signal` may be absent = it never abandons). */
|
|
44
108
|
join(signal?: AbortSignal): void;
|
|
45
109
|
private abandon;
|
|
46
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Give ONE caller its own settle on a shared job: the caller's `signal` resolves it with `onAbort()`
|
|
113
|
+
* without disturbing the job (which other callers may still need). The job's own settle is always
|
|
114
|
+
* observed, so a later rejection can never surface as an unhandled rejection.
|
|
115
|
+
*/
|
|
47
116
|
export declare function settleOnAbort<T>(job: Promise<T>, signal: AbortSignal | undefined, onAbort: () => T): Promise<T>;
|
|
117
|
+
/**
|
|
118
|
+
* HRD-LSP-5: resolve a model-supplied `filePath` against the TASK's cwd, once, for every leg.
|
|
119
|
+
*
|
|
120
|
+
* The tool used to join a relative path to `env.cwd` for the existence/size PRECHECK only and hand the
|
|
121
|
+
* ORIGINAL string to `sessionFor` → `readText`/`pathToUri`, which resolve against the HOST process cwd.
|
|
122
|
+
* With a task cwd that is not the host cwd (worktree/sandbox/service worker — i.e. every non-trivial
|
|
123
|
+
* deployment) the two legs then addressed two different files: the precheck passed on the real file
|
|
124
|
+
* while the server was handed `file:///<host-cwd>/<rel>`, and the model got a confident "No results."
|
|
125
|
+
* for a file that was never analyzed.
|
|
126
|
+
*
|
|
127
|
+
* Absolute-form input (either family) passes the join; "no cwd known" keeps the caller's spelling.
|
|
128
|
+
*
|
|
129
|
+
* REF-C3 — the result is dot-folded, which is what makes this function THE key-minting seam: every URI
|
|
130
|
+
* for a file (didOpen, publishDiagnostics, the diagnostics registry's `fileEdited` clear, buildRequest)
|
|
131
|
+
* comes from here, and `pathToUri`'s POSIX branch is a hand-assembled per-segment encode that keeps a
|
|
132
|
+
* `.` segment verbatim. Without the fold, `./src/a.ts` and `src/a.ts` minted two keys for one file:
|
|
133
|
+
* delivered diagnostics never cleared, and the server held a duplicate document. The edit-nudge leg in
|
|
134
|
+
* prepare-task.ts had grown its own copy of the fold for exactly this reason; it now calls this instead,
|
|
135
|
+
* so "one file, one key" is a property of the code rather than of two spellings staying in step.
|
|
136
|
+
*/
|
|
48
137
|
export declare function resolveLspPath(filePath: string, cwd?: string): string;
|
|
138
|
+
/** Request positions use the same base convention as {@link LspLocation}: line 1-based, character 0-based. */
|
|
49
139
|
export interface LspRequestParams {
|
|
50
140
|
filePath: string;
|
|
141
|
+
/** 1-based (tool convention) — the manager converts to the 0-based LSP wire (line−1). */
|
|
51
142
|
line?: number;
|
|
143
|
+
/** 0-based (matches the LSP wire). */
|
|
52
144
|
character?: number;
|
|
145
|
+
/** For workspaceSymbol: the symbol query string. */
|
|
53
146
|
symbol?: string;
|
|
54
147
|
}
|
|
148
|
+
/** An active language-server session for one language, scoped to a workspace. */
|
|
55
149
|
export interface LspSession {
|
|
56
150
|
request(op: LspOperation, params: LspRequestParams, signal?: AbortSignal): Promise<LspResult>;
|
|
57
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* A JSON-RPC transport to ONE language server, POST-`initialize`. The DEPLOYMENT provides the concrete
|
|
154
|
+
* transport; the protocol logic ({@link buildRequest}/`parseResult`, `TransportLspSession`) drives the LSP
|
|
155
|
+
* over this single seam, so the two lanes can't drift:
|
|
156
|
+
* - **TOC** = {@link StdioLspTransport} (spawn the server LOCALLY; Content-Length JSON-RPC over its stdio — a
|
|
157
|
+
* faithful copy of CC's `services/lsp/LSPClient`);
|
|
158
|
+
* - **TOB** = a WS bridge (the server runs INSIDE a remote sandbox, reached over a WebSocket — service's
|
|
159
|
+
* `ws-transport`, because `execStream` is output-only so the base seam can't drive a stdio server remotely).
|
|
160
|
+
*/
|
|
58
161
|
export interface LspTransport {
|
|
162
|
+
/** A JSON-RPC request; resolves the `result` (or rejects on a JSON-RPC error / timeout / abort). */
|
|
59
163
|
request(method: string, params: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
164
|
+
/** A JSON-RPC notification (no response) — e.g. `textDocument/didOpen`. */
|
|
60
165
|
notify(method: string, params: unknown): void;
|
|
166
|
+
/**
|
|
167
|
+
* design/121: subscribe to server→client NOTIFICATIONS (a message with a `method` and no `id` —
|
|
168
|
+
* `textDocument/publishDiagnostics`, `window/logMessage`, …). Returns an unsubscribe. Optional and
|
|
169
|
+
* ADDITIVE: a transport without it — or with no subscriber — behaves exactly as before (notifications
|
|
170
|
+
* dropped). The transport must swallow a throwing handler (a bad consumer must never kill the read loop).
|
|
171
|
+
*/
|
|
61
172
|
onNotification?(handler: (method: string, params: unknown) => void): () => void;
|
|
62
173
|
close(): Promise<void>;
|
|
174
|
+
/** True once the underlying connection is gone (closed/errored) — the manager evicts + reopens. Optional so
|
|
175
|
+
* a test mock stays minimal. */
|
|
63
176
|
readonly closed?: boolean;
|
|
64
177
|
}
|
|
178
|
+
/** Reads a workspace file's CURRENT text for the session's didOpen/didChange re-sync. TOC = local fs; TOB =
|
|
179
|
+
* the sandbox ExecutionEnv. */
|
|
65
180
|
export type LspReadText = (filePath: string, signal?: AbortSignal) => Promise<string>;
|
|
181
|
+
/** CC 2.1.220's LSP file cap (10MB — `File too large for LSP analysis`, pretty220.js ~474745). Single-sourced
|
|
182
|
+
* in core: the TOOL-layer check in {@link createLspTool} (the model-visible enforcement, CC-parity) and the
|
|
183
|
+
* defense-in-depth throw in the engine's `defaultLspReadText` must agree on one number. */
|
|
66
184
|
export declare const MAX_LSP_FILE_BYTES: number;
|
|
185
|
+
/**
|
|
186
|
+
* Resolves a language server session for a file. Returns `undefined` when no server is available for the
|
|
187
|
+
* file's language — the tool then degrades gracefully (design/64 §13.1 remote-portability constraint).
|
|
188
|
+
*/
|
|
67
189
|
export interface LspServerManager {
|
|
190
|
+
/**
|
|
191
|
+
* Resolve a session for `filePath`'s language, or `undefined` to degrade. `env` is the task's
|
|
192
|
+
* ExecutionEnv (the SAME sandbox the agent runs in) — core passes it because a real in-env language
|
|
193
|
+
* server must run inside that sandbox, and core already holds the per-task env at mount time. Supplying
|
|
194
|
+
* it here means a manager can be **stateless** (it doesn't need a sessionId→env registry). It is
|
|
195
|
+
* optional/last for back-compat: a manager that resolves the env another way (e.g. a sessionId registry
|
|
196
|
+
* keyed off `executionEnvFactory`) may ignore it.
|
|
197
|
+
*/
|
|
68
198
|
sessionFor(filePath: string, signal?: AbortSignal, env?: ExecutionEnv): Promise<LspSession | undefined>;
|
|
199
|
+
/**
|
|
200
|
+
* HRD-LSP-14 — OPTIONAL: why the last {@link sessionFor} for this file returned `undefined`, as a phrase
|
|
201
|
+
* for the model-facing degrade line ("no language server for its language in this environment" is used
|
|
202
|
+
* when absent). `undefined` ⇒ nothing more specific to say. ADDITIVE: a manager without it behaves
|
|
203
|
+
* exactly as before. Exists because `undefined` collapses "this language has no server configured",
|
|
204
|
+
* "the binary is not installed" and "the server is installed and fails to start" into one sentence that
|
|
205
|
+
* is only true for the first — and the operator can only act on the third if someone says it.
|
|
206
|
+
*/
|
|
69
207
|
unavailableReason?(filePath: string, env?: ExecutionEnv): string | undefined;
|
|
208
|
+
/** design/121: the manager's workspace diagnostics registry, when the deployment's manager supports
|
|
209
|
+
* pushed diagnostics (NodeLspManager always does). The Runner drains it at turn boundaries to inject
|
|
210
|
+
* `<new-diagnostics>` + emit the structured `diagnostics` frame. Absent ⇒ no diagnostics lane. */
|
|
70
211
|
readonly diagnostics?: import("./lsp-diagnostics.js").LspDiagnosticsRegistry;
|
|
71
212
|
}
|
|
72
213
|
export interface LspToolOptions {
|
|
214
|
+
/** Drop results in files ignored by git (CC parity, design/64 §16/§17). Default: keep all. */
|
|
73
215
|
isPathIgnored?: (uri: string) => boolean | Promise<boolean>;
|
|
216
|
+
/** The task's ExecutionEnv, passed through to {@link LspServerManager.sessionFor} (the agent's sandbox —
|
|
217
|
+
* where an in-env language server must run). The Runner wires this from the per-task env. */
|
|
74
218
|
env?: ExecutionEnv;
|
|
75
219
|
}
|
|
220
|
+
/** Build the `lsp` tool over a {@link LspServerManager}. Mounted only when a manager is wired (opt-in). */
|
|
76
221
|
export declare function createLspTool(manager: LspServerManager, opts?: LspToolOptions): AgentTool;
|
|
222
|
+
/**
|
|
223
|
+
* A git-check-ignore-based path filter for {@link LspToolOptions.isPathIgnored} (CC parity). Best-effort:
|
|
224
|
+
* if git isn't available or the check fails, nothing is treated as ignored (keep all). Caches per path.
|
|
225
|
+
*/
|
|
77
226
|
export declare function gitCheckIgnoreFilter(env: ExecutionEnv, root: string): (uri: string) => Promise<boolean>;
|
|
@@ -1,32 +1,89 @@
|
|
|
1
|
+
/** One parked message. `seq` is minted by the store, monotonic per (scope, handle), stable across
|
|
2
|
+
* lease/expiry cycles (a re-leased message keeps its number — dedup/ordering key). */
|
|
1
3
|
export interface MailboxMessage {
|
|
2
4
|
seq: number;
|
|
5
|
+
/** Sender display name, when the sender had one (SendMessage `senderName` — display only). */
|
|
3
6
|
from?: string;
|
|
4
7
|
content: string;
|
|
5
8
|
sentAt: number;
|
|
9
|
+
/** design/176 — the peer-message forwarding chain (engine-minted hop tokens; typed side channel,
|
|
10
|
+
* never model-facing text). Presence — even an empty array — marks the record as written through
|
|
11
|
+
* the sema send gate; an absent field means a pre-176 or FOREIGN-engine record (a shared CC inbox
|
|
12
|
+
* has other writers): such records deliver with an empty chain and are never retro-admitted —
|
|
13
|
+
* cross-engine records sit outside the guard's promise domain by ruling. */
|
|
6
14
|
hopChain?: string[];
|
|
7
15
|
}
|
|
16
|
+
/** A leased batch: the messages a claim winner owns for delivery, plus the ack cursor. */
|
|
8
17
|
export interface MailboxLease {
|
|
9
18
|
messages: MailboxMessage[];
|
|
19
|
+
/** Ack everything ≤ this seq once the revived cycle has durably received the batch. */
|
|
10
20
|
maxSeq: number;
|
|
11
21
|
}
|
|
22
|
+
/** REF-D18: one appended mailbox message — the SINGLE shape the interface method and both the
|
|
23
|
+
* In-Memory and File implementations reference. */
|
|
12
24
|
export interface MailboxAppendMessage {
|
|
13
25
|
from?: string;
|
|
14
26
|
content: string;
|
|
15
27
|
sentAt: number;
|
|
28
|
+
/** design/176 — see {@link MailboxMessage.hopChain}. */
|
|
16
29
|
hopChain?: string[];
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The pluggable mailbox seam (design/151 §7.1). Contract notes for implementations (file/pg):
|
|
33
|
+
* - `append` is durable-first (a returned seq means the message survives a crash); seq is monotonic
|
|
34
|
+
* per (scope, handle) and never reused WITHIN a box's lifetime (across lease/ack cycles the
|
|
35
|
+
* high-water mark persists). `drop` ENDS the lifetime — a later rebuild restarts at 1 (server[1523]
|
|
36
|
+
* 定谳: the row died with the box, dedup keys carry the handle, and a* handles are 64-bit-random).
|
|
37
|
+
* RB-90 (2026-07-25, red probe) SPLITS `reap` back out of that sentence: the two were grouped, but
|
|
38
|
+
* only `drop` is preceded by the row's death. `reap` is an age-based sweep that runs while the
|
|
39
|
+
* recipient is alive and may hold a lease, so restarting seq there let a stale ack (up to the
|
|
40
|
+
* pre-sweep high-water) delete a brand-new message no consumer had ever been shown — the "a parked
|
|
41
|
+
* message is never lost" promise at the top of this file, broken silently. `reap` therefore CLEARS a
|
|
42
|
+
* box and KEEPS its high-water mark; both bundled impls do so.
|
|
43
|
+
* - `claimLease` atomically marks every currently-visible (unleased or lease-expired) message as
|
|
44
|
+
* leased by `owner` until `now + ttlMs`, returning them in seq order. Empty mailbox → null.
|
|
45
|
+
* A second claim by a DIFFERENT owner while a live lease exists returns null (single consumer
|
|
46
|
+
* per window — the row claim-CAS already guarantees one revival winner; this is the belt); the
|
|
47
|
+
* SAME owner re-claiming RENEWS the lease and picks up any newer messages (the crash-retry form
|
|
48
|
+
* — server[1523] 定谳: both bundled impls behave so, the contract follows the implementations).
|
|
49
|
+
* - `ack` deletes every message with seq ≤ upToSeq (the winner calls it at ATTACH success, never
|
|
50
|
+
* before — §7.1: ack-late is what makes a crashed revival lossless).
|
|
51
|
+
* - `releaseLease` (best-effort) returns a lease early (spawn preflight failed before delivery).
|
|
52
|
+
* - `reap` ages out whole mailboxes by newest-message age (explicit policy). It is the BACKSTOP, not
|
|
53
|
+
* the only reclaim path: the winning-delete arm of `reapDurableAgents` calls {@link MailboxStore.drop}
|
|
54
|
+
* for the row it deletes, in the same sweep (F-13 — the row's mailbox dies with the row). That call
|
|
55
|
+
* is ADVISORY: a drop fault never blocks the reap, and a box orphaned that way still ages out here.
|
|
56
|
+
* `drop` therefore has a real caller — an implementation that stubs it strands mailboxes until the
|
|
57
|
+
* age policy catches them.
|
|
58
|
+
*/
|
|
18
59
|
export interface MailboxStore {
|
|
19
60
|
append(scope: string, handle: string, msg: MailboxAppendMessage): Promise<number>;
|
|
20
61
|
claimLease(scope: string, handle: string, owner: string, ttlMs: number, now?: number): Promise<MailboxLease | null>;
|
|
21
62
|
ack(scope: string, handle: string, owner: string, upToSeq: number): Promise<void>;
|
|
22
63
|
releaseLease(scope: string, handle: string, owner: string): Promise<void>;
|
|
64
|
+
/** Observation face (the "N pending" receipt figure) — count of currently-visible messages. */
|
|
23
65
|
peekCount(scope: string, handle: string): Promise<number>;
|
|
66
|
+
/** Drop the WHOLE mailbox for (scope, handle) — the row-deletion companion (F-13). */
|
|
24
67
|
drop(scope: string, handle: string): Promise<void>;
|
|
68
|
+
/** Age out mailboxes whose newest message BY `sentAt` (not by array/insertion order — RB-250②)
|
|
69
|
+
* is older than maxAgeMs. Returns mailboxes dropped. */
|
|
25
70
|
reap(scope: string, now: number, opts?: {
|
|
26
71
|
maxAgeMs?: number;
|
|
27
72
|
}): Promise<number>;
|
|
28
73
|
}
|
|
74
|
+
/** RB-250② (2026-07-28, 黑板 [1937]) class fix — the box age for `reap` is the MAX `sentAt`, not the
|
|
75
|
+
* last array element: `sentAt` is caller-supplied, so append order need not be time order, and taking
|
|
76
|
+
* the tail let a box whose freshest message was mid-array be swept — both bundled backends discarded
|
|
77
|
+
* a brand-new message while the CC adapter (stores/cc/mailbox-store.ts, the in-package reference)
|
|
78
|
+
* already reduces over MAX. Non-finite `sentAt` ⇒ undefined ("unknown age ⇒ never reaped", the CC
|
|
79
|
+
* adapter's documented posture — treating it as very old would let a malformed row delete a live
|
|
80
|
+
* box). Module-level export only; NOT re-exported from src/index.ts. */
|
|
29
81
|
export declare function newestSentAt(messages: readonly MailboxMessage[]): number | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* In-process reference implementation (single-instance / tests). Same posture as
|
|
84
|
+
* {@link import("./background-agent-store.js").InMemoryBackgroundAgentStore}: not default-mounted,
|
|
85
|
+
* detached copies at both boundaries, single-event-loop atomicity.
|
|
86
|
+
*/
|
|
30
87
|
export declare class InMemoryMailboxStore implements MailboxStore {
|
|
31
88
|
private boxes;
|
|
32
89
|
private key;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertRetentionPolicy } from "./retention-policy.js";
|
|
1
2
|
export function newestSentAt(messages) {
|
|
2
3
|
let newest;
|
|
3
4
|
for (const m of messages) {
|
|
@@ -65,6 +66,7 @@ export class InMemoryMailboxStore {
|
|
|
65
66
|
this.boxes.delete(this.key(scope, handle));
|
|
66
67
|
}
|
|
67
68
|
async reap(scope, now, opts) {
|
|
69
|
+
assertRetentionPolicy("MailboxStore.reap", opts);
|
|
68
70
|
if (opts?.maxAgeMs === undefined)
|
|
69
71
|
return 0;
|
|
70
72
|
let dropped = 0;
|