@sema-agent/core 5.20.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 +9 -0
- 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/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/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 +107 -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 +292 -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 +608 -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/mcp.d.ts +381 -0
- 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 +33 -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 +12 -11
- package/dist/core/runner/prompt-suggestions.d.ts +7 -0
- package/dist/core/runner/runtask.d.ts +304 -3
- 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-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-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/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 +16 -1
- package/dist/index.js +0 -1
- 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-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/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/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/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/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/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
|
@@ -1,46 +1,153 @@
|
|
|
1
1
|
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
2
|
+
/** Directories never worth crawling (design/64 §10.3) — dependency/build/cache trees, PLUS the VCS
|
|
3
|
+
* metadata directories CC names explicitly (RB-200 F1, 220 @368402: `Ok_ = [".git",".svn",".hg",
|
|
4
|
+
* ".bzr",".jj",".sl"]` — git/svn/mercurial/bazaar/jujutsu/sapling). `.bzr`/`.jj`/`.sl` are additive here
|
|
5
|
+
* (the other three VCS dirs already lived in this list for the build/cache reason above; they're
|
|
6
|
+
* identical either way). See {@link buildIgnore}'s own comment for why this list is now the ENTIRE
|
|
7
|
+
* directory-skip story — the blanket "any dot-prefixed name is invisible" rule this list used to sit
|
|
8
|
+
* beside is gone. */
|
|
2
9
|
export declare const DEFAULT_IGNORE_DIRS: ReadonlySet<string>;
|
|
3
10
|
export interface GrepParams {
|
|
11
|
+
/** Regular expression (ripgrep semantics) — CC 2.1.209 parity: the pattern is ALWAYS a regex; the
|
|
12
|
+
* old `regex?: boolean` literal-by-default switch is retired (a legacy `regex` argument sent by an
|
|
13
|
+
* old caller is tolerated and ignored at the tool layer, never a failure). */
|
|
4
14
|
pattern: string;
|
|
15
|
+
/** Restrict the search to this sub-path (relative to root, or absolute within root). */
|
|
5
16
|
path?: string;
|
|
17
|
+
/** Only search files matching this glob (e.g. `*.ts`, `*.{ts,tsx}`). 批④ #6 (CC parity): a
|
|
18
|
+
* comma/whitespace-separated list (`"*.ts,*.tsx"`) is split into multiple globs (brace globs kept whole). */
|
|
6
19
|
glob?: string;
|
|
20
|
+
/** 批④ #5 (CC 2.1.201 `-o`): print only the matched (non-empty) parts of each matching line, one match
|
|
21
|
+
* per output line (rg -o / --only-matching). content mode only; ignored otherwise (CC parity).
|
|
22
|
+
* 1.253: with `multiline` the JS fallback emits the matched SEGMENT's lines (rg -U -o shape). */
|
|
7
23
|
only_matching?: boolean;
|
|
24
|
+
/** content: `path:line:text`. files_with_matches (default, CC 2.1.209): `path`. count: `path:count`. */
|
|
8
25
|
output_mode?: "content" | "files_with_matches" | "count";
|
|
26
|
+
/** Lines of context around a match (content mode only) — CC's `-C`. */
|
|
9
27
|
context?: number;
|
|
28
|
+
/** Lines of context BEFORE each match (content mode) — CC's `-B`. Wins over `context` for the before-window. */
|
|
10
29
|
context_before?: number;
|
|
30
|
+
/** Lines of context AFTER each match (content mode) — CC's `-A`. Wins over `context` for the after-window. */
|
|
11
31
|
context_after?: number;
|
|
32
|
+
/** File type filter — CC's `type` (rg `--type`): "js", "py", "rust", "go", "ts", … The rg path uses rg's
|
|
33
|
+
* built-in type table; the JS fallback maps common types to globs (unknown types are ignored with a note). */
|
|
12
34
|
type?: string;
|
|
35
|
+
/** Case-insensitive match — CC's `-i`. */
|
|
13
36
|
ignore_case?: boolean;
|
|
37
|
+
/** Match across line boundaries — CC's multiline `-U`. JS fallback approximates per-file. */
|
|
14
38
|
multiline?: boolean;
|
|
39
|
+
/** Cap the number of output items (default 250) — CC's `head_limit`. */
|
|
15
40
|
head_limit?: number;
|
|
41
|
+
/** Skip the first N output lines — CC's `offset` (pagination partner of head_limit). */
|
|
16
42
|
offset?: number;
|
|
17
43
|
}
|
|
44
|
+
/** 批④ #6 (CC 2.1.198 Grep call, bundle :333383-333390): split the `glob` param into individual glob
|
|
45
|
+
* tokens — whitespace-separated first; a token WITHOUT braces is further split on commas
|
|
46
|
+
* (`"*.ts,*.tsx"` → two globs), while a brace token (`*.{ts,tsx}`) is kept whole (its commas are
|
|
47
|
+
* alternation syntax, not separators). CC-verbatim splitting rules. */
|
|
18
48
|
export declare function splitGlobParam(glob: string): string[];
|
|
49
|
+
/** 批④ #8 (CC 2.1.198 RWp, bundle :332987): decompose an ABSOLUTE glob pattern into a base directory +
|
|
50
|
+
* relative pattern — cut at the last separator before the first glob metachar (`* ? [ {`); a pattern
|
|
51
|
+
* with no metachar splits dirname/basename. Returns undefined for a relative pattern (caller keeps it
|
|
52
|
+
* as-is) or when no usable base can be derived. */
|
|
19
53
|
export declare function splitAbsoluteGlobPattern(pattern: string): {
|
|
20
54
|
baseDir: string;
|
|
21
55
|
relativePattern: string;
|
|
22
56
|
} | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* POSIX-safe single-quote so an arbitrary model-supplied string can't break out of the shell command that
|
|
59
|
+
* runs ripgrep. Wraps in single quotes (inside which the shell expands nothing — no `$()`, backtick, `;`, or
|
|
60
|
+
* glob) and escapes any embedded single quote via the `'\''` idiom (close, escaped-quote, reopen). Exported
|
|
61
|
+
* for direct injection testing (council [R145]). Renamed from `shq` for legibility.
|
|
62
|
+
*/
|
|
23
63
|
export declare function shellQuote(s: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* RB-284 ③ (成批, CC 220 `xGg`/`MCu` @240961-240967 亲核) — the tokens of a `glob` argument that this
|
|
66
|
+
* engine CANNOT compile as glob syntax, i.e. the ones whose metacharacter would silently degrade to a
|
|
67
|
+
* literal match.
|
|
68
|
+
*
|
|
69
|
+
* The harm this closes is specific and asymmetric. An unknown `type` degrades to searching EVERY file —
|
|
70
|
+
* a SUPERSET of what was asked, wrong but self-evidently over-broad, and sema already discloses it with
|
|
71
|
+
* a `[note: unknown type …]` line. An unparseable `glob` degrades the other way: `src/[ab.ts` stops
|
|
72
|
+
* being a character class and becomes a request for a file literally NAMED `src/[ab.ts`, so the filter
|
|
73
|
+
* silently narrows to (almost always) nothing and the search answers a clean "No matches." — a
|
|
74
|
+
* false negative wearing the exact shape of a successful exhaustive search. That is the RB-264 G2
|
|
75
|
+
* failure class, and this repo's standing verdict on it is: no real data ⇒ isError, never a degraded
|
|
76
|
+
* answer.
|
|
77
|
+
*
|
|
78
|
+
* CC hard-errors on the same input class rather than searching at all — its ripgrep stderr matcher
|
|
79
|
+
* `xGg` covers `error parsing glob` (alongside regex-parse / unrecognized-file-type / flag-parse
|
|
80
|
+
* errors) and raises `Search failed — ripgrep rejected the pattern, glob, or file type without
|
|
81
|
+
* searching`. sema rejects at the INPUT level instead of waiting for a stderr string, because sema has
|
|
82
|
+
* two search engines (rg + the JS fallback) and only the rg one would ever produce that stderr: a
|
|
83
|
+
* rejection that fires only when ripgrep happens to be installed is not a contract. The `type` leg
|
|
84
|
+
* deliberately does NOT get this treatment (see the `typeNote` site) — over-broad-with-a-note is an
|
|
85
|
+
* honest answer, silently-narrowed is not.
|
|
86
|
+
*/
|
|
24
87
|
export declare function invalidGlobTokens(glob: string): string[];
|
|
88
|
+
/** Lightweight `.gitignore` matcher (handles comments, negation, dir-only `/`, anchoring, `*`/`?`). */
|
|
25
89
|
export declare function gitignoreMatcher(content: string): (rel: string, isDir: boolean) => boolean;
|
|
90
|
+
/** Build the combined ignore predicate (ignore-set ∪ .gitignore) for a JS-fallback walk.
|
|
91
|
+
* Exported so repo-map (design/72 §1) walks with the SAME ignore semantics as grep/glob.
|
|
92
|
+
*
|
|
93
|
+
* RB-200 F1(形态一,CC 220 语料证实,@368590-368592 Grep `T=["--hidden"]; for(N of Ok_) T.push("--glob",
|
|
94
|
+
* "!"+N)`,@367957/367959-367965 Glob `CLAUDE_CODE_GLOB_HIDDEN` 默认 true 同样带 `--hidden`): CC's own
|
|
95
|
+
* "keep it quiet" posture is NOT "every dot-prefixed name is invisible" — it's `--hidden` (show
|
|
96
|
+
* everything dot-prefixed) plus an explicit VCS-directory exclusion list ({@link DEFAULT_IGNORE_DIRS}).
|
|
97
|
+
* The blanket rule this function used to apply here (`base.startsWith(".")`) instead made EVERY hidden
|
|
98
|
+
* file/dir invisible with no caveat — `.github/`, `.claude/`, `.env.example` never existed as far as
|
|
99
|
+
* Grep/Glob/repo-map were concerned, not even as an honest "search skipped this" note (A-8 posture: an
|
|
100
|
+
* unflagged gap reads as exhaustive). Removed; {@link DEFAULT_IGNORE_DIRS} (dependency/build/cache trees
|
|
101
|
+
* + the 6 VCS metadata dirs) and `.gitignore` are now the entire directory-skip story, matching CC. */
|
|
26
102
|
export declare function buildIgnore(env: ExecutionEnv, root: string, signal?: AbortSignal): Promise<(rel: string, isDir: boolean) => boolean>;
|
|
103
|
+
/** What a bounded walk actually saw — so consumers can be HONEST about incompleteness (A-4 class sweep:
|
|
104
|
+
* silently bounded results must never read as exhaustive). */
|
|
27
105
|
export interface WalkResult {
|
|
106
|
+
/** Greppable text files (binary-extension and oversize files excluded). */
|
|
28
107
|
files: string[];
|
|
108
|
+
/** Name-only entries: binary-extension + over-{@link FILE_MAX_BYTES} files. Content search skips them
|
|
109
|
+
* (grep semantics / memory bound), but globbing matches NAMES — these must still be visible to it
|
|
110
|
+
* (previously `glob *.png` could never match anything). */
|
|
29
111
|
nameOnly: string[];
|
|
112
|
+
/** True when the walk hit its file-count or depth ceiling — results MAY be missing files. (Ceiling
|
|
113
|
+
* ONLY; unreadable-dir and abort incompleteness live on their own fields below — use
|
|
114
|
+
* {@link walkIsPartial} for the any-cause check.) */
|
|
30
115
|
incomplete: boolean;
|
|
116
|
+
/** Non-binary files skipped by content search for being over {@link FILE_MAX_BYTES} (also in
|
|
117
|
+
* `nameOnly`). Surfaced by grep so "No matches." can't silently mean "didn't look". */
|
|
31
118
|
skippedLarge: number;
|
|
119
|
+
/** fidelity-sweep F2: directories whose listing FAILED (EACCES, transient I/O) — whole subtrees the
|
|
120
|
+
* walk never saw. */
|
|
32
121
|
skippedUnreadable: number;
|
|
122
|
+
/** F2: the walk was cut short by an abort — the result is a prefix, not a survey. */
|
|
33
123
|
aborted: boolean;
|
|
124
|
+
/** CC 2.1.209 Glob parity (batch A2): modification time (ms epoch) per walked path (files AND
|
|
125
|
+
* name-only entries), captured from the listing that discovered them — so glob can sort by mtime
|
|
126
|
+
* without a second stat pass. An env whose listings carry no numeric `mtimeMs` simply leaves
|
|
127
|
+
* entries out of this map (consumers fall back to name order). */
|
|
34
128
|
mtimes: Map<string, number>;
|
|
35
129
|
}
|
|
130
|
+
/** F2: any-cause incompleteness — a result built on this walk must not present itself as exhaustive. */
|
|
36
131
|
export declare function walkIsPartial(w: WalkResult): boolean;
|
|
132
|
+
/** Bounded, ignore-aware recursive walk. Returns absolute file paths under `start`. Exported for
|
|
133
|
+
* repo-map (design/72 §1) — same bounded/ignore-aware traversal as grep/glob, one source of truth. */
|
|
37
134
|
export declare function walk(env: ExecutionEnv, root: string, start: string, ignore: (rel: string, isDir: boolean) => boolean, signal?: AbortSignal): Promise<WalkResult>;
|
|
135
|
+
/** Injectable execution boundaries for the JS-fallback scan (tests shrink them; callers use defaults). */
|
|
38
136
|
export interface JsGrepGuards {
|
|
137
|
+
/** Wall-clock budget (ms) for matching a SINGLE file before the scan stops with a diagnosable error. */
|
|
39
138
|
budgetMs?: number;
|
|
139
|
+
/** Longest line/content (chars) a gray-zone pattern may be matched against. */
|
|
40
140
|
longLineLimit?: number;
|
|
41
141
|
}
|
|
142
|
+
/** JS-fallback grep: ignore-aware walk + per-line scan, honoring output_mode / context / head_limit. */
|
|
42
143
|
export declare function jsGrep(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal, guards?: JsGrepGuards): Promise<string>;
|
|
144
|
+
/** Detect ripgrep once per env (cached). */
|
|
43
145
|
export declare function detectRipgrep(env: ExecutionEnv): Promise<boolean>;
|
|
146
|
+
/** How a grep result was produced when the ripgrep leg could not complete normally. Either the
|
|
147
|
+
* delivered text IS ripgrep's own partial output (`partial: true`), or ripgrep produced nothing
|
|
148
|
+
* usable and the results came from the JS fallback scanner (`fallback: "js-scan"`). Absent on a
|
|
149
|
+
* clean run (and on rg-less envs, where the JS scanner is the designed primary path, not a
|
|
150
|
+
* degradation). */
|
|
44
151
|
export type GrepDegradation = {
|
|
45
152
|
partial: true;
|
|
46
153
|
reason: string;
|
|
@@ -48,17 +155,41 @@ export type GrepDegradation = {
|
|
|
48
155
|
fallback: "js-scan";
|
|
49
156
|
reason: string;
|
|
50
157
|
};
|
|
158
|
+
/** Structured grep result: the model-facing text plus the degradation facts, so the tool layer can
|
|
159
|
+
* ship them on the structured frame instead of leaving them prose-only. */
|
|
51
160
|
export interface GrepRunResult {
|
|
52
161
|
text: string;
|
|
53
162
|
degraded?: GrepDegradation;
|
|
54
163
|
}
|
|
164
|
+
/** ripgrep grep: build flags from params, run, normalize to the same output as {@link jsGrep}.
|
|
165
|
+
* Result-fidelity contract: output ripgrep DID produce is never silently replaced by a fallback
|
|
166
|
+
* rescan — partial results ship with a caveat; only a zero-output failure degrades to
|
|
167
|
+
* {@link jsGrep}, and that degradation is declared in both text and structure. An external abort
|
|
168
|
+
* propagates as the interruption it is (no fallback rerun). */
|
|
55
169
|
export declare function rgGrepDetailed(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal): Promise<GrepRunResult>;
|
|
170
|
+
/** grep dispatch: ripgrep when the env has it, else the hardened JS fallback (design/64 §10.3).
|
|
171
|
+
* Returns the degradation facts alongside the text so the tool layer can surface them structurally. */
|
|
56
172
|
export declare function runGrepDetailed(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal): Promise<GrepRunResult>;
|
|
173
|
+
/** Text-only wrapper of {@link runGrepDetailed}. */
|
|
57
174
|
export declare function runGrep(env: ExecutionEnv, root: string, p: GrepParams, signal?: AbortSignal): Promise<string>;
|
|
175
|
+
/** glob: find files by name pattern, with optional sub-path scoping; returns RELATIVE paths (design/64 §10.4). */
|
|
58
176
|
export declare function runGlob(env: ExecutionEnv, root: string, pattern: string, opts?: {
|
|
59
177
|
path?: string;
|
|
60
178
|
max?: number;
|
|
61
179
|
}, signal?: AbortSignal): Promise<string>;
|
|
180
|
+
/** Structured sibling of {@link runGlob} (design/116 W3): same walk/match, plus the CC-shaped facts a
|
|
181
|
+
* shell renders (`filenames`/`numFiles`/`truncated`/`durationMs`/`totalMatches`/`countIsComplete`)
|
|
182
|
+
* without re-parsing the text.
|
|
183
|
+
*
|
|
184
|
+
* CC207 backlog P2-2 (CC 2.1.206:397761-398004 = 2.1.207:342454-342633, node-sliced verbatim):
|
|
185
|
+
* · `totalMatches` — "Total number of matching files before truncation. A lower bound when
|
|
186
|
+
* countIsComplete is false." (CC: `totalMatches: g.length`)
|
|
187
|
+
* · `countIsComplete` — "Whether totalMatches is the exact total (true) or a floor because the
|
|
188
|
+
* underlying search truncated its own output (false)." (CC: `countIsComplete: !m`, m = the rg
|
|
189
|
+
* enumeration cut its own output; sema equivalent = the bounded walk hit its file/depth ceiling)
|
|
190
|
+
* · `numFiles` — "Number of file paths returned (after any truncation)" (CC: `numFiles: u.length`
|
|
191
|
+
* post-slice; was matchedAll.length here — pre-truncation total — fixed to the CC contract)
|
|
192
|
+
* · `truncated` — CC: `y = m || g.length > n + r` (underlying-incomplete OR over the result cap). */
|
|
62
193
|
export declare function runGlobDetailed(env: ExecutionEnv, root: string, pattern: string, opts?: {
|
|
63
194
|
path?: string;
|
|
64
195
|
max?: number;
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
export interface AutonomousLoopPromptOptions {
|
|
2
|
+
/**
|
|
3
|
+
* True on the FIRST resolved tick of a session: the tick instructions are preceded by the
|
|
4
|
+
* `# Autonomous loop check` preamble (separated by `\n\n---\n\n`, CC P6c shape). The caller
|
|
5
|
+
* owns the latch (CC keeps it in process state; core is stateless). Default false.
|
|
6
|
+
*/
|
|
2
7
|
firstTick?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Selects CC's `tengu_kairos_loop_persistent` variant (default false = the steward-framed
|
|
10
|
+
* preamble + "third straight tick" convergence wording — CC's gate default): true = the
|
|
11
|
+
* persistence-framed preamble ("Persistence is the point of autonomous mode") and the
|
|
12
|
+
* ending-the-loop wording without the third-tick clause.
|
|
13
|
+
*/
|
|
3
14
|
persistentVariant?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Appends the PushNotification ping guidance (CC `FFr`, gated by `tengu_kairos_push_notifications`
|
|
17
|
+
* — default false). core ships no PushNotification tool; only a deployment that mounts one under
|
|
18
|
+
* that name should set this, or the appendix becomes a hallucination source.
|
|
19
|
+
*/
|
|
4
20
|
pushNotification?: boolean;
|
|
5
21
|
}
|
|
22
|
+
/** CC `FFi` (:205310) — first-tick preamble, DEFAULT variant (steward framing). Verbatim. */
|
|
6
23
|
export declare const AUTONOMOUS_LOOP_PREAMBLE = "# Autonomous loop check\n\nYou're being invoked on a timer while the user is away or occupied. The point is to keep work moving forward without the user driving every step \u2014 finishing things they started, maintaining PRs they're building, catching problems before they come back to find them. You're a steward, not an initiator. The user set you loose on their work, and the value you provide comes from reliably advancing things they've already set in motion, not from finding new things to do.\n\nThe key tension to navigate: the user trusts you enough to run autonomously, but that trust is easily lost. Acting on what the conversation already established is safe and valuable. Inventing new work or making irreversible changes without clear authorization erodes trust fast. When you're unsure whether something falls into \"continuing established work\" or \"inventing new work,\" lean toward the former only when the transcript provides clear evidence the user wanted it done. If you find yourself reaching for justifications about why a push is probably fine, that's a signal to wait.\n\n## What to act on\n\nThe current conversation is your highest-signal source \u2014 re-read the transcript above, since everything there is something the user was actively engaged with. The strongest signal is an in-progress PR you've been building together: review comments to address and resolve, failing CI checks to diagnose (and re-enqueue if they're flakes), merge conflicts to fix. The goal is to get the PR into a state where it's ready to merge pending only human review \u2014 the user shouldn't come back to find a PR blocked on things you could have handled. After that, look for unfinished implementation where the last exchange left something half-done, and explicit \"I'll also...\" or \"next I'll...\" commitments the conversation made and didn't honor. Weaker but still real: dangling questions you could now answer, verification steps that were skipped, edge cases that were mentioned but not handled, and natural continuations that don't require new decisions.\n\nIf you find anything in this category, act on it \u2014 actually do the work, don't describe what could be done. Run the tests, don't say \"you could run the tests.\" The whole point of autonomous operation is that work gets done while the user is away.\n\nWhen the conversation transcript has nothing left, the current branch's pull/merge request on the user's SCM is the next-best place to look. This is maintenance work \u2014 valuable, but lower priority than continuing the user's active work. Find the PR/MR for the current branch via the SCM's CLI, then check three things: CI status, unresolved review threads, and whether the branch has fallen behind the base. For failing CI, pull the failing job's logs and diagnose before acting \u2014 flaky-shaped failures (timeout, runner died, transient network) can be re-enqueued; real failures need a reproduction and a minimal fix. For unresolved review threads, fetch the comment, address the feedback, push, and resolve the thread via, for example, the GitHub GraphQL `resolveReviewThread` mutation (or the equivalent for whichever SCM the project uses). Before pushing anything, check whether someone else has pushed to the branch while you were working \u2014 if so, rebase (don't merge) to keep history clean.\n\nWhen CI is green, threads are clear, and there's idle time, sweeping the branch for issues is a good use of that time \u2014 bug-hunt or simplification passes catch problems before reviewers do, saving everyone a round-trip.\n\nIf everything is genuinely quiet \u2014 no conversation work, no PR maintenance \u2014 say so in one sentence and stop. No summary of what you checked, no list of what you might do later. The user will see your message in the transcript when they come back; three consecutive \"nothing to do\" results means you should scale back to a quick CI check and stop, not narrate.\n\n## Repeated invocations\n\nIf you see earlier autonomous checks in this conversation, adjust your scope accordingly. If a previous check left a question the user hasn't answered, the cost of acting depends on reversibility: for reversible actions (local edits, running tests), make your best call and proceed; for irreversible ones (pushing, deleting, sending), keep waiting \u2014 the cost of acting wrongly on something irreversible is much higher than the cost of waiting one more cycle. If three or more consecutive checks have found nothing actionable, things are quiet \u2014 do one quick CI/threads check and stop in a single line. Repeated \"nothing to do\" messages clutter the transcript and waste the user's attention when they come back to review.\n\nRead and analyze freely \u2014 understanding the state of things has no blast radius. Make edits and run tests when you're confident they continue established work. Commit and push only when you're clearly continuing something the user authorized, or when the work pattern makes the intent obvious \u2014 like fixing CI on a PR you've been building together.\n";
|
|
24
|
+
/** CC `w6c` (:205335) — first-tick preamble, PERSISTENT variant. Verbatim. */
|
|
7
25
|
export declare const AUTONOMOUS_LOOP_PREAMBLE_PERSISTENT = "# Autonomous loop check\n\nYou're being invoked on a timer while the user is away or occupied. The point is to keep work moving forward without the user driving every step \u2014 finishing things they started, maintaining PRs they're building, catching problems before they come back to find them, and following through on the *spirit* of the task they gave you, not just its literal scope. The user set you loose on their work, and the value you provide comes from reliably advancing things they've already set in motion.\n\nThe key tension to navigate: the user trusts you enough to run autonomously, but that trust is easily lost. Acting on what the conversation already established is safe and valuable. For irreversible actions (push, delete, send), require clear authorization in the transcript or use a reversible alternative (a draft, a local commit, a queued message). For reversible actions (edits, tests, drafts, exploration), bias toward acting \u2014 the cost of an unneeded local edit is near zero, and the cost of a stalled loop is high. When you're unsure whether something falls into \"continuing established work\" or \"inventing new work,\" lean toward continuing whenever the transcript gives you any reasonable thread to pull on.\n\n## What to act on\n\nThe current conversation is your highest-signal source \u2014 re-read the transcript above, since everything there is something the user was actively engaged with. The strongest signal is an in-progress PR you've been building together: review comments to address and resolve, failing CI checks to diagnose (and re-enqueue if they're flakes), merge conflicts to fix. The goal is to get the PR into a state where it's ready to merge pending only human review \u2014 the user shouldn't come back to find a PR blocked on things you could have handled. After that, look for unfinished implementation where the last exchange left something half-done, and explicit \"I'll also...\" or \"next I'll...\" commitments the conversation made and didn't honor. Weaker but still real: dangling questions you could now answer, verification steps that were skipped, edge cases that were mentioned but not handled, and natural continuations that don't require new decisions.\n\nIf you find anything in this category, act on it \u2014 actually do the work, don't describe what could be done. Run the tests, don't say \"you could run the tests.\" The whole point of autonomous operation is that work gets done while the user is away.\n\nWhen the conversation transcript has nothing left, the current branch's pull/merge request on the user's SCM is the next-best place to look. This is maintenance work \u2014 valuable, but lower priority than continuing the user's active work. Find the PR/MR for the current branch via the SCM's CLI, then check three things: CI status, unresolved review threads, and whether the branch has fallen behind the base. For failing CI, pull the failing job's logs and diagnose before acting \u2014 flaky-shaped failures (timeout, runner died, transient network) can be re-enqueued; real failures need a reproduction and a minimal fix. For unresolved review threads, fetch the comment, address the feedback, push, and resolve the thread via, for example, the GitHub GraphQL `resolveReviewThread` mutation (or the equivalent for whichever SCM the project uses). Before pushing anything, check whether someone else has pushed to the branch while you were working \u2014 if so, rebase (don't merge) to keep history clean.\n\nWhen CI is green, threads are clear, and there's idle time, sweeping the branch for issues is a good use of that time \u2014 bug-hunt or simplification passes catch problems before reviewers do, saving everyone a round-trip.\n\nIf everything is genuinely quiet \u2014 no conversation work, no PR maintenance \u2014 say so in one sentence and keep the loop alive. Before stopping, broaden once: re-read the original task framing, check whether earlier ticks deferred anything (\"I'll wait for X\"), and look at sibling PRs/branches the user owns. Persistence is the point of autonomous mode. Only stop if the original task is provably complete or the user said to stop. (Pacing \u2014 how long to wait before the next tick \u2014 is handled by the per-mode reminder appended to this preamble; don't try to manage delay from here.)\n\n## Repeated invocations\n\nIf you see earlier autonomous checks in this conversation, adjust your scope accordingly. If a previous check left a question the user hasn't answered, the cost of acting depends on reversibility: for reversible actions (local edits, running tests), make your best call and proceed; for irreversible ones (pushing, deleting, sending), keep waiting \u2014 the cost of acting wrongly on something irreversible is much higher than the cost of waiting one more cycle. If three or more consecutive checks have found nothing actionable, broaden scope once before considering stopping \u2014 re-read the original task, check sibling work, look for verification or polish steps that were skipped. A loop that quits the moment work goes quiet is less useful than one that waits.\n\nRead and analyze freely \u2014 understanding the state of things has no blast radius. Make edits and run tests when you're confident they continue established work. Commit and push only when you're clearly continuing something the user authorized, or when the work pattern makes the intent obvious \u2014 like fixing CI on a PR you've been building together.\n";
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a fire-time prompt: if it is one of the two autonomous-loop sentinels, return the tick
|
|
28
|
+
* instructions the model should actually receive (CC `P6c`); otherwise return `null` — the caller
|
|
29
|
+
* enqueues the prompt verbatim. Stateless: the first-tick preamble latch and the decision to
|
|
30
|
+
* resolve at all belong to the calling scheduler runtime.
|
|
31
|
+
*/
|
|
8
32
|
export declare function resolveAutonomousLoopPrompt(prompt: string, opts?: AutonomousLoopPromptOptions): string | null;
|
package/dist/tools/monitor.d.ts
CHANGED
|
@@ -1,22 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/135 G2 (审计 [485]① 🔴) — the `Monitor` tool: run a shell command in the background and watch its
|
|
3
|
+
* stdout as a stream of NOTIFICATION EVENTS (the自主循环 core piece: "watch this and tell me when something
|
|
4
|
+
* happens" without burning poll turns).
|
|
5
|
+
*
|
|
6
|
+
* CC-parity semantics (live-harness schema, the archived ground truth):
|
|
7
|
+
* ① every stdout LINE becomes one event; ② lines within the 200ms batch window coalesce into ONE
|
|
8
|
+
* notification; ③ process exit ends the watch (exit code reported); ④ non-persistent watches are killed at
|
|
9
|
+
* `timeout_ms` (default 5min, max 60min); ⑤ stderr never notifies but is spooled (TaskOutput-readable);
|
|
10
|
+
* ⑥ an event storm is SUPPRESSED first and auto-stops the monitor only if it persists (RB-334, CC `PCo`
|
|
11
|
+
* 220:403278-403321 two-level control — the suppressed count and the overload duration are disclosed
|
|
12
|
+
* on both the suppression frame and the stop notification).
|
|
13
|
+
*
|
|
14
|
+
* Wiring: the process runs through the SAME ExecutionEnv background seam as Bash(run_in_background)
|
|
15
|
+
* (`spawnBackground` — remote envs included); the watcher/batching/timeout machinery lives in
|
|
16
|
+
* {@link TaskRegistry.registerMonitor} (background_bash G2b watcher's near kin); events ride the
|
|
17
|
+
* TaskNotificationPayload lane at "later" priority (delivered at the next turn boundary like every
|
|
18
|
+
* notification — ruled 2026-08-05; consecutive frames drain as one boundary batch, and a backlog past
|
|
19
|
+
* the engine-note cap parks per session, so a chatty watcher cannot monopolize the run's boundaries).
|
|
20
|
+
* 飞轮 [492]② (1.257): events born BETWEEN turns (run torn down / harness idle — the long-watch main case)
|
|
21
|
+
* are no longer lost: the Runner parks them per session (bounded, drop-disclosing) and the session's next
|
|
22
|
+
* run redelivers them through the same notification lane at its first turn boundary.
|
|
23
|
+
* 飞轮 [511]③ (CC parity): a monitor's lifetime = min(timeout_ms, process exit, TaskStop); a `persistent`
|
|
24
|
+
* one is SESSION-anchored (reaped at session release). NEITHER is run-anchored: the run teardown leaves an
|
|
25
|
+
* in-window non-persistent watch alive (process on the dispose except-list, watcher ticking, row kept), so
|
|
26
|
+
* cross-turn watching — CC's main Monitor use case — works with the default persistent:false too; its
|
|
27
|
+
* between-turns events AND its timeout/exit terminal ride the same pending lane.
|
|
28
|
+
* The handle is a first-class m* registry task: TaskOutput serves the re-readable spool, TaskStop stops the
|
|
29
|
+
* watch (design/134 stoppedBy attribution applies automatically).
|
|
30
|
+
*
|
|
31
|
+
* Security posture: `command` is an arbitrary shell script ⇒ effect:"write", same as Bash, and prepare-task
|
|
32
|
+
* folds Monitor into the SAME shellGate tighten (irreversibility tier + reversibility probe on the same
|
|
33
|
+
* `command` arg) — Monitor is never a policy side-door around a gated Bash.
|
|
34
|
+
*
|
|
35
|
+
* 深对比残差 M17 CLOSED (2026-07-09 live-CC probe, docs/cc-probe-198/live-schema-monitor-worktree-2026-07-09.json):
|
|
36
|
+
* the deep-dive bundle showed a `command? + ws?:{url,protocols}` dual-mode schema; the LIVE current-CC schema is
|
|
37
|
+
* shell-single-mode ({command, description, persistent, timeout_ms} — no ws branch anywhere in desc or schema).
|
|
38
|
+
* sema's shell-single-mode Monitor is therefore aligned with current CC — do NOT port a WebSocket event-source
|
|
39
|
+
* branch off the stale bundle. (Full-desc density diff vs the live guidance card remains P1, a separate item.)
|
|
40
|
+
*/
|
|
1
41
|
import type { AgentTool, ExecutionEnv } from "../internal/harness-types.js";
|
|
2
42
|
import { type MonitorTimers, type TaskRegistry } from "../core/task-registry.js";
|
|
3
43
|
import type { TaskNotificationPayload } from "../core/task-notification.js";
|
|
4
44
|
import type { ToolResultStore } from "../core/tool-result-store.js";
|
|
5
45
|
export interface MonitorToolOptions {
|
|
6
46
|
registry: TaskRegistry;
|
|
47
|
+
/** Fallbacks when the runtime ctx carries no identity (direct mounts) — same posture as createBashTool. */
|
|
7
48
|
owner?: string;
|
|
8
49
|
scope?: string;
|
|
50
|
+
/** design/129: the session id — a `persistent` monitor registers session-scoped under it (outlives the
|
|
51
|
+
* turn; reaped by the deployment's session release via `reapSessionBackground`). */
|
|
9
52
|
sessionId?: string;
|
|
53
|
+
/** The notification sink (the run-local task-notification lane). Without it the monitor still runs and
|
|
54
|
+
* spools — readable via TaskOutput — but no events reach the model (the tool reply says so honestly). */
|
|
10
55
|
onTaskNotification?: (n: TaskNotificationPayload, opts?: {
|
|
11
56
|
priority?: "now" | "next" | "later";
|
|
12
57
|
}) => void;
|
|
58
|
+
/** The tracked logical cwd (shared with the hands band) — the monitor spawns there, like Bash. */
|
|
13
59
|
cwdRef?: {
|
|
14
60
|
current: string;
|
|
15
61
|
};
|
|
62
|
+
/** design/87: injectable timers/clock for the watcher (tests drive ticks manually; default real timers). */
|
|
16
63
|
timers?: MonitorTimers;
|
|
64
|
+
/** Test/deployment knobs (defaults: 200ms window, 50 batches/min). */
|
|
17
65
|
batchWindowMs?: number;
|
|
18
66
|
maxBatchesPerMinute?: number;
|
|
67
|
+
/** design/158 S2 (RB-364 半): the offload store a rolled-off spool middle spills to (see
|
|
68
|
+
* task-registry-monitor.ts's spill helper). Absent ⇒ legal degrade, byte-identical rolling (no spill,
|
|
69
|
+
* same loss shape as before this design). */
|
|
19
70
|
toolResultStore?: ToolResultStore;
|
|
71
|
+
/** RB-465-b (HRD-PTL-3 残件): spec-level retain (`TaskSpec.retainBackgroundProcesses`) — the SECOND
|
|
72
|
+
* retain lane, OR-composed with the env capability at the teardown sweep. Without this bit the mount
|
|
73
|
+
* could only see the env lane, so a deployment retaining per spec still got the "session ends it"
|
|
74
|
+
* wording in the persistent-watch receipt. Purely a RECEIPT input — enforcement stays at the sweep. */
|
|
20
75
|
retainBackgroundProcesses?: boolean;
|
|
21
76
|
}
|
|
22
77
|
export declare function createMonitorTool(env: ExecutionEnv, opts: MonitorToolOptions): AgentTool;
|
|
@@ -1,14 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* design/105 — Scheduler 工具壳(CronCreate / CronDelete / CronList + ScheduleWakeup)。模型可调,把未来意图交给注入的
|
|
3
|
+
* daemon backend(`env` 实现 {@link SchedulerCapability})。**core 薄壳**:工具只做 ① cron expr 白名单校验
|
|
4
|
+
* ② 组装 `intent`(模型面) + `SchedulerContext`(Runner-held,闭包捕获 principal/scope/sessionId) ③ 调
|
|
5
|
+
* `env.schedule/cancel/list`。持久化/触发/起新 task 全在 daemon。
|
|
6
|
+
* design/136 §2.2(BREAKING 去超集批):`Sleep` 工具已撤除(CC 无此工具;等待抽象=Monitor/后台通知,定时再醒
|
|
7
|
+
* =CronCreate delay/at——纯语法糖零缺口)。旧名调用=通用响亮 roster miss(RB-476-A 墓碑已清);daemon 已排的 `label:"sleep"`
|
|
8
|
+
* delayed intent 照常触发(daemon 只存 prompt+when,零迁移)。
|
|
9
|
+
*
|
|
10
|
+
* [c209-D2] 同名工具消歧(durable 分层激活批 2026-07-16,防后人混淆):**我方 CronCreate = 持久 daemon 形**
|
|
11
|
+
* (对标上游产品 /schedule 的云端持久语义);**上游同名工具是会话级易失体**({cron: 5字段串, prompt,
|
|
12
|
+
* recurring: bool, durable: 死字段}——会话结束即消失);壳仓 vendored 的 ScheduleCronTool 是上游原生实现,
|
|
13
|
+
* 与本工具无关。两形调用在此汇流:上游生态 skill 平移过来的 CC 形调用(`cron` 字符串,`durable` 缺省 false)
|
|
14
|
+
* 落 **session 生存期**(会话终结随会话 reap,绝不落成永生任务);我方 `schedule` 对象形保持持久语义零回归,
|
|
15
|
+
* `durable: true` 显式亦持久。session 生存期需要 backend 能力位(supportsSessionLifetime),缺失时诚实拒绝
|
|
16
|
+
* 引导 `durable: true`——绝不静默升级语义。
|
|
17
|
+
*
|
|
18
|
+
* 挂载:prepare-task 在 `hasScheduler(executionEnv)` 时调 {@link createSchedulerTools}(需 Runner-held 上下文,故不在
|
|
19
|
+
* `createHandsToolkit` —— 与 present_plan/AskUserQuestion 同:这些工具都在 prepare-task 单独挂,那里有 spec.principal)。
|
|
20
|
+
*/
|
|
1
21
|
import type { AgentTool, ExecutionEnv } from "../internal/harness-types.js";
|
|
2
22
|
export declare const SCHEDULE_WAKEUP_TOOL_NAME = "ScheduleWakeup";
|
|
23
|
+
/** CronCreate-based autonomous-loop 哨兵(CC `Ldt`)。loop runtime(部署侧)在 fire 时解析回 autonomous-loop 指令。 */
|
|
3
24
|
export declare const AUTONOMOUS_LOOP_SENTINEL = "<<autonomous-loop>>";
|
|
25
|
+
/** ScheduleWakeup(dynamic-pacing)哨兵(CC `ePe`)——ScheduleWakeup 一律用 `-dynamic` 变体。 */
|
|
4
26
|
export declare const AUTONOMOUS_LOOP_DYNAMIC_SENTINEL = "<<autonomous-loop-dynamic>>";
|
|
27
|
+
/** Runner-held 上下文 + run-stop 出口,工具工厂闭包捕获(模型触不到)。 */
|
|
5
28
|
export interface SchedulerToolContext {
|
|
29
|
+
/**
|
|
30
|
+
* **会话腿**的越权隔离键(Runner 填 sessionId ?? principal ?? taskId)。durable 腿不用这条链——它的键由
|
|
31
|
+
* {@link durableScopeOf} 从 principal 独立铸(ruled 2026-08-03,见该函数注释)。
|
|
32
|
+
*/
|
|
6
33
|
scope: string;
|
|
7
34
|
principal?: string;
|
|
8
35
|
sessionId?: string;
|
|
9
36
|
taskConfig?: unknown;
|
|
37
|
+
/** `ctx.requestStopAfterTurn`(干净结束本 run 的 runner 原语出口)。design/136 §2.2:Sleep 撤除后本槽位
|
|
38
|
+
* 保留(human-suspend saga 等共用同一 runner 原语;prepare-task 仍注入)——当前 scheduler 三件不消费。 */
|
|
10
39
|
requestStopAfterTurn?: () => void;
|
|
11
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* cron 深校验(CC CronCreateTool.validateInput parity):arity(RB-438 D4)+ 数值域(如 `61 * * * *` 分钟越域)
|
|
43
|
+
* + 永不触发(如 `31 2 30 2 *` 二月 30 日)。返回给模型自纠的错误句;合法返回 null。
|
|
44
|
+
*
|
|
45
|
+
* RB-438 D4 — **只收 5 字段**。带秒的 6 段此前收单成功并回执「Scheduled.」,而兑现腿(常驻 daemon)按标准
|
|
46
|
+
* 5 字段解析:6 段记录算不出 next-run,首次 tick 即被当作坏记录丢弃 ⇒ 任务永不触发,且没有任何回执说过它
|
|
47
|
+
* 没排上。收单 arity 必须等于开火 arity,差额只能用响亮拒绝补,不能用静默丢弃补。seam 上没有「秒粒度」
|
|
48
|
+
* 能力位可判({@link SchedulerCapability} 只有 supported / 上下限 / 两个 session 位),故取保守形:一律拒。
|
|
49
|
+
* 将来若真出现支持秒的 backend,加一个 additive 能力位在此开口(缺省仍拒),不要悄悄放行。
|
|
50
|
+
*
|
|
51
|
+
* 永不触发判定:标准 cron OR 语义(CC utils/cron.ts:150-158)—— dom 与 dow **都**受限时任一匹配即触发,而任何受限
|
|
52
|
+
* dow 每周都出现 → 必触发。所以唯一永不触发形态 = dom 受限 + dow 通配 + dom 值全部超出所有排程月份的天数上限。
|
|
53
|
+
*/
|
|
12
54
|
export declare function cronScheduleError(expr: string): string | null;
|
|
55
|
+
/**
|
|
56
|
+
* cron → 人话(CC utils/cron.ts cronToHuman:218-308 类比,收窄到常见形态):"star/N * * * *"→"every N minutes"、
|
|
57
|
+
* "M star/N * * *"→"every N hours"、`M H * * *`→"daily at H:MM"、`M H * * D`→"weekly on <day> at H:MM"、
|
|
58
|
+
* `M H * * 1-5`→"weekdays at H:MM";其余原样返回(调用方以 `human !== expr` 判断是否可译)。
|
|
59
|
+
* 收 backend 的 `cron <expr>` 显示串(见 {@link cronExprFromSummary});6 段带秒不译(D4 已在收单面拒收)。
|
|
60
|
+
*/
|
|
13
61
|
export declare function cronToHuman(expr: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* 构建三个 scheduler 工具(仅当 `env` 暴露 {@link SchedulerCapability} 且 `supported:true`)。否则返回 `[]`(INERT)。
|
|
64
|
+
*/
|
|
14
65
|
export declare function createSchedulerTools(env: ExecutionEnv, ctx: SchedulerToolContext): AgentTool[];
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency-free `query` adapters for common DB drivers, to plug into createSqlTool.
|
|
3
|
+
*
|
|
4
|
+
* These are structurally typed: you pass an already-created (ideally READ-ONLY) client/pool.
|
|
5
|
+
* No driver is a dependency of this package — install whichever you use in your app.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import pg from "pg";
|
|
9
|
+
* const pool = new pg.Pool({ connectionString: READONLY_URL });
|
|
10
|
+
* const tool = createSqlTool({ query: pgQuery(pool), allowTables: ["orders"] });
|
|
11
|
+
*/
|
|
12
|
+
/** node-postgres (`pg`) Pool/Client. */
|
|
1
13
|
export declare function pgQuery(pool: {
|
|
2
14
|
query: (text: string) => Promise<{
|
|
3
15
|
rows: unknown[];
|
|
4
16
|
}>;
|
|
5
17
|
}): (sql: string) => Promise<unknown[]>;
|
|
18
|
+
/**
|
|
19
|
+
* `mysql2/promise` connection or pool.
|
|
20
|
+
* Also use this for **TiDB** (MySQL wire-compatible): create a read-only `mysql2` pool
|
|
21
|
+
* pointed at your TiDB endpoint and pass it here.
|
|
22
|
+
*/
|
|
6
23
|
export declare function mysqlQuery(conn: {
|
|
7
24
|
query: (sql: string) => Promise<[unknown, unknown]>;
|
|
8
25
|
}): (sql: string) => Promise<unknown[]>;
|
|
26
|
+
/** `better-sqlite3` database (synchronous). */
|
|
9
27
|
export declare function sqliteQuery(db: {
|
|
10
28
|
prepare: (sql: string) => {
|
|
11
29
|
all: () => unknown[];
|
package/dist/tools/sql.d.ts
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
import type { ToolSpec } from "../core/types.js";
|
|
2
2
|
export interface SqlToolOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Execute a query that has already passed read-only validation, returning rows.
|
|
5
|
+
* IMPORTANT: back this with **read-only database credentials** — the validation here is
|
|
6
|
+
* defense-in-depth, not the primary guarantee.
|
|
7
|
+
*/
|
|
3
8
|
query: (sql: string) => Promise<unknown[]>;
|
|
9
|
+
/**
|
|
10
|
+
* If set, the query may only reference these tables (case-insensitive). **Best-effort, NOT a hard
|
|
11
|
+
* isolation boundary.** Table extraction is regex-based; to stay sound it FAILS CLOSED — comma-joins
|
|
12
|
+
* (`FROM a, b`), sub-queries in FROM/JOIN, and set operations (UNION/INTERSECT/EXCEPT) are REJECTED
|
|
13
|
+
* (their full table set can't be reliably enumerated). Even so, do **NOT** rely on this alone for
|
|
14
|
+
* multi-tenant / cross-tenant isolation: back it with **read-only DB credentials scoped to the tenant +
|
|
15
|
+
* DB-level GRANTs**. The allowlist is a usability guardrail and defense-in-depth, not the security
|
|
16
|
+
* boundary. (Full AST-parser coverage is deferred to preserve the zero-extra-dependency posture.)
|
|
17
|
+
*/
|
|
4
18
|
allowTables?: string[];
|
|
19
|
+
/** Maximum rows returned to the model. Default 100. */
|
|
5
20
|
maxRows?: number;
|
|
21
|
+
/** Tool name exposed to the model. Default "query_sql". */
|
|
6
22
|
name?: string;
|
|
23
|
+
/** Description override. */
|
|
7
24
|
description?: string;
|
|
8
25
|
}
|
|
26
|
+
/** Validate that `sql` is a single, read-only SELECT/CTE query within the allowlist. */
|
|
9
27
|
export declare function validateReadOnlySql(sql: string, allowTables?: string[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Build a safe, read-only `query_sql` tool.
|
|
30
|
+
*
|
|
31
|
+
* Layers of defense: (1) read-only DB credentials supplied by the caller's `query`,
|
|
32
|
+
* (2) static validation (single SELECT/WITH only, no DML/DDL, no comments/multi-statement),
|
|
33
|
+
* (3) optional table allowlist, (4) a row cap on what is returned to the model.
|
|
34
|
+
*/
|
|
10
35
|
export declare function createSqlTool(opts: SqlToolOptions): ToolSpec;
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import type { ToolSpec } from "../core/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* design/119 (CC 2.1.198 parity) — the structured task-list tool family: `TaskCreate` / `TaskGet` /
|
|
4
|
+
* `TaskUpdate` / `TaskList`. CC 198's upgrade path over TodoWrite: individual tasks with stable ids,
|
|
5
|
+
* status transitions, dependencies (blocks/blockedBy), an optional owner, and free metadata — instead
|
|
6
|
+
* of TodoWrite's replace-the-whole-list. CC209 对齐批B B3: the two families are MUTUALLY EXCLUSIVE and
|
|
7
|
+
* this one is the DEFAULT — TodoWrite mounts only when the task list is explicitly off (the CC 209
|
|
8
|
+
* shape: TodoWrite isEnabled = !taskList; see `scenarios/full-body.ts`).
|
|
9
|
+
*
|
|
10
|
+
* State default: like TodoWrite, the default store lives in this factory's closure — FRESH per task
|
|
11
|
+
* and torn down with it; nothing durable, no deps, no egress (the model's own scratch, projected to
|
|
12
|
+
* observers only through each call's tool result / `details`). Descriptions follow CC 2.1.198
|
|
13
|
+
* (product-specific lines — teammate assignment, spinner/UI wording — trimmed or generalized).
|
|
14
|
+
*
|
|
15
|
+
* design/147 §6 D2 (CC 2.1.216 shared team task list): pass a {@link TaskListStore} to share ONE
|
|
16
|
+
* task list across several agents — CC 216's team coordination artifact ("Check the task list
|
|
17
|
+
* periodically. Create new tasks when work should be divided. Mark tasks resolved when complete.")
|
|
18
|
+
* is a task-list file under the team directory; the sema equivalent is this storage seam. A
|
|
19
|
+
* deployment mounts the SAME store instance into each teammate's tool bundle (same session = same
|
|
20
|
+
* trust domain — the list is model scratch either way, sharing adds no egress). The `owner` field's
|
|
21
|
+
* teammate-assignment semantics (trimmed in the 198 port) come back through this seam.
|
|
22
|
+
*/
|
|
2
23
|
export interface TaskListItem {
|
|
3
24
|
id: string;
|
|
4
25
|
subject: string;
|
|
@@ -10,16 +31,72 @@ export interface TaskListItem {
|
|
|
10
31
|
blockedBy: string[];
|
|
11
32
|
metadata?: Record<string, unknown>;
|
|
12
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* design/147 §6 D2 — the task-list persistence seam (storage-tier abstraction, same family as
|
|
36
|
+
* `RosterStore`/checkpoint store: core bundles a memory implementation; a deployment plugs pg/file
|
|
37
|
+
* behind the same interface and hands ONE instance to every teammate's tool bundle).
|
|
38
|
+
*
|
|
39
|
+
* Contract:
|
|
40
|
+
* - Methods MAY be async (a pg-backed store is); the bundled memory store is synchronous.
|
|
41
|
+
* - Each single method call must be atomic in the store. Multi-step read-modify-write sequences
|
|
42
|
+
* (update, delete-with-pruning) are serialized PER STORE by the tools themselves within this
|
|
43
|
+
* process ({@link createTaskListTools} keeps a per-store promise chain) — a store shared across
|
|
44
|
+
* PROCESSES additionally needs its own transactional guarantees for those sequences, which is the
|
|
45
|
+
* deployment's half (documented, not solved here; CC's file-backed team list has the same window).
|
|
46
|
+
* - `allocateId` is store-owned so concurrent teammates never mint colliding ids.
|
|
47
|
+
* - Value semantics: `get`/`list` return detached copies; `set` stores a detached copy. Callers
|
|
48
|
+
* mutate their copy and write it back — a live-reference store would alias already-emitted events.
|
|
49
|
+
* - RB-274: `list` is ordered by ID (numeric ascending), not by write order. The tool lane always
|
|
50
|
+
* allocates before it sets, so the two coincide there — but a store shared with an OUTSIDE writer
|
|
51
|
+
* (a real CC instance on the same directory) can set an id out of order, and then the backends
|
|
52
|
+
* disagreed: memory replayed its Map's insertion order while file/cc read the id order back off
|
|
53
|
+
* disk. Ordering is part of the contract, not each backend's incidental iteration order.
|
|
54
|
+
*/
|
|
13
55
|
export interface TaskListStore {
|
|
14
56
|
get(id: string): TaskListItem | undefined | Promise<TaskListItem | undefined>;
|
|
15
57
|
set(id: string, item: TaskListItem): void | Promise<void>;
|
|
16
58
|
delete(id: string): boolean | Promise<boolean>;
|
|
17
59
|
list(): TaskListItem[] | Promise<TaskListItem[]>;
|
|
18
60
|
allocateId(): string | Promise<string>;
|
|
61
|
+
/** codex S4 F2 — the transaction boundary for adapters whose backend outlives one wrapper
|
|
62
|
+
* instance (pg, shared files): when present, the tools run EVERY read-modify-write sequence
|
|
63
|
+
* inside `mutate` and the adapter supplies sequence-level atomicity (a DB transaction, an
|
|
64
|
+
* advisory lock keyed on the backend — not on this object). Absent ⇒ the tools fall back to the
|
|
65
|
+
* in-process per-store promise chain, which is exactly right for the bundled memory store (its
|
|
66
|
+
* backend IS this object) and wrong for anything shared wider — implement `mutate` there. */
|
|
19
67
|
mutate?<T>(fn: (tx: TaskListStore) => Promise<T>): Promise<T>;
|
|
20
68
|
}
|
|
69
|
+
/** codex S4 r2-F3 — the clone policy behind the detached-copy contract: metadata must be JSON-shaped
|
|
70
|
+
* (structuredClone would accept — and SHARE — SharedArrayBuffer backing memory, and throws opaquely
|
|
71
|
+
* on functions/proxies; the tool lane is always JSON, so this guards DIRECT store users). */
|
|
72
|
+
/**
|
|
73
|
+
* RB-168 — the dependency arrays are STRUCTURAL, and a store must refuse a row that lacks them.
|
|
74
|
+
*
|
|
75
|
+
* The in-memory store rejected such a row incidentally: its snapshot helper spreads `t.blocks`, so a
|
|
76
|
+
* missing array threw "blocks is not iterable" at write. The file store had no such accident and wrote the
|
|
77
|
+
* row to disk, where it survived until `TaskUpdate` reached `t.blocks.includes(...)` — a poisoned row that
|
|
78
|
+
* passes the write and detonates at an unrelated later call, in a different session, with no trace of where
|
|
79
|
+
* it came from. Two backends disagreeing about what a valid row is means a test written against one has
|
|
80
|
+
* different semantics on the other.
|
|
81
|
+
*
|
|
82
|
+
* NORMALIZE rather than reject: the harm is a stored row that EXPLODES AT READ, not an incomplete one.
|
|
83
|
+
* Defaulting the arrays removes the harm without inventing a new failure mode for callers that legitimately
|
|
84
|
+
* write a partial row (a task with no dependencies has empty arrays — that is what the absence meant).
|
|
85
|
+
* Rejecting instead would have been a behaviour change dressed as a fix: the first attempt did exactly that
|
|
86
|
+
* and broke an in-tree test whose subject was id allocation, not row shape.
|
|
87
|
+
*/
|
|
21
88
|
export declare function normalizeTaskShape<T>(item: T): T;
|
|
22
89
|
export declare function assertJsonMetadata(value: unknown, path?: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* RB-274 — the contract's `list` order, mirroring the CC-compat backend's `orderIds`
|
|
92
|
+
* (`stores/cc/task-list-store.ts`): numeric ids ascending (CC's own task order), any non-numeric id
|
|
93
|
+
* after them, lexicographically. Ties broken lexicographically so the comparator is total (and the
|
|
94
|
+
* order therefore stable across repeated calls, which the contract also requires).
|
|
95
|
+
*/
|
|
23
96
|
export declare function compareTaskIds(a: string, b: string): number;
|
|
97
|
+
/** The bundled in-memory {@link TaskListStore} — detached copies both ways (see interface contract). */
|
|
24
98
|
export declare function createMemoryTaskListStore(): TaskListStore;
|
|
99
|
+
/** Build the four task-list tools sharing one task list. Mount all four together.
|
|
100
|
+
* No `store` ⇒ a fresh private in-memory list (the design/119 per-run scratch shape, unchanged).
|
|
101
|
+
* With `store` ⇒ the shared team task list (design/147 §6 D2) — mount the same instance everywhere. */
|
|
25
102
|
export declare function createTaskListTools(store?: TaskListStore): ToolSpec[];
|
package/dist/tools/todo.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { ToolSpec } from "../core/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* design/102 (K-8 CC full-body) — TodoWrite parity (CONTEXT leg). A private, in-task plan the model rewrites to
|
|
4
|
+
* track multi-step work. State lives in this factory's closure — FRESH per task (each `assembleCodeTools` call
|
|
5
|
+
* makes its own) and torn down with the task; nothing durable, no deps, no egress. `effect:"idempotent"` because
|
|
6
|
+
* re-sending the whole list is repeat-safe. Distinct from `present_plan` (that SUSPENDS for human review); this is
|
|
7
|
+
* the model's own scratch. Returns a RAW {@link ToolSpec} pushed via `spec.tools` (prepare-task defines it) — NOT
|
|
8
|
+
* mounted default-on, so it stays INERT for non-full-body runs. (A later slice may project the list to the wire.)
|
|
9
|
+
*/
|
|
2
10
|
export declare function createTodoWriteTool(): ToolSpec;
|