@sema-agent/core 7.61.0 → 7.63.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 +840 -0
- package/dist/agents/cascade.d.ts +11 -3
- package/dist/agents/cascade.js +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-session-drain.js +13 -3
- package/dist/agents/subagent-transcript-placement.d.ts +23 -0
- package/dist/agents/subagent-transcript-placement.js +14 -0
- package/dist/agents/subagent.d.ts +6 -1
- package/dist/agents/subagent.js +143 -58
- package/dist/agents/suspend-guard.d.ts +38 -16
- package/dist/agents/suspend-guard.js +9 -4
- package/dist/agents/verify.js +4 -3
- package/dist/brain/route-adjudicator.js +9 -4
- package/dist/core/approval-object.js +1 -1
- package/dist/core/arg-summary.js +1 -1
- package/dist/core/ask-question.d.ts +2 -2
- package/dist/core/canonical-json.d.ts +23 -13
- package/dist/core/canonical-json.js +4 -4
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-queries.d.ts +47 -4
- package/dist/core/checkpoint-queries.js +36 -16
- package/dist/core/checkpoint-requirements.d.ts +12 -5
- package/dist/core/checkpoint-requirements.js +11 -5
- package/dist/core/checkpoint-row-verdict.d.ts +110 -0
- package/dist/core/checkpoint-row-verdict.js +245 -0
- package/dist/core/checkpoint-store.d.ts +76 -753
- package/dist/core/checkpoint-store.js +83 -144
- package/dist/core/compliance.d.ts +6 -2
- package/dist/core/compliance.js +3 -3
- package/dist/core/engine-attestation.d.ts +1 -1
- package/dist/core/engine-notice.d.ts +38 -7
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/gate-fold.js +2 -2
- package/dist/core/git-worktree-env.d.ts +62 -3
- package/dist/core/git-worktree-env.js +91 -30
- package/dist/core/governance-codes.d.ts +9 -3
- package/dist/core/governance-codes.js +16 -3
- package/dist/core/hooks.d.ts +13 -0
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +1 -1
- package/dist/core/locked-config.d.ts +2 -2
- package/dist/core/mcp-host-seat.js +6 -1
- package/dist/core/memory-engine/consolidation-driver.d.ts +33 -18
- package/dist/core/memory-engine/consolidation-driver.js +99 -98
- package/dist/core/memory-engine/consolidation.d.ts +73 -10
- package/dist/core/memory-engine/consolidation.js +167 -11
- package/dist/core/memory-engine/data-plane.d.ts +8 -4
- package/dist/core/memory-engine/data-plane.js +11 -6
- package/dist/core/memory-engine/delegation-settlement.d.ts +37 -35
- package/dist/core/memory-engine/delegation-settlement.js +53 -59
- package/dist/core/memory-engine/dual-root.d.ts +12 -6
- package/dist/core/memory-engine/dual-root.js +9 -5
- package/dist/core/memory-engine/engine.d.ts +98 -35
- package/dist/core/memory-engine/engine.js +477 -380
- package/dist/core/memory-engine/entry-scan.d.ts +8 -0
- package/dist/core/memory-engine/entry-scan.js +3 -0
- package/dist/core/memory-engine/file-backend.d.ts +29 -3
- package/dist/core/memory-engine/file-backend.js +66 -35
- package/dist/core/memory-engine/index.d.ts +7 -7
- package/dist/core/memory-engine/index.js +6 -6
- package/dist/core/memory-engine/landing-admission.d.ts +5 -3
- package/dist/core/memory-engine/landing-admission.js +3 -3
- package/dist/core/memory-engine/layout.d.ts +121 -45
- package/dist/core/memory-engine/layout.js +252 -102
- package/dist/core/memory-engine/memory-backend-contract.d.ts +19 -1
- package/dist/core/memory-engine/memory-backend-contract.js +320 -0
- package/dist/core/memory-engine/memory-deployment.d.ts +31 -8
- package/dist/core/memory-engine/memory-deployment.js +26 -12
- package/dist/core/memory-engine/scope-contract.d.ts +52 -11
- package/dist/core/memory-engine/scope-contract.js +68 -19
- package/dist/core/memory-engine/session-write-home.d.ts +3 -1
- package/dist/core/memory-engine/session-write-home.js +1 -1
- package/dist/core/memory-engine/sync-client.d.ts +3 -1
- package/dist/core/memory-engine/sync-client.js +7 -0
- package/dist/core/memory-engine/sync-report.d.ts +3 -2
- package/dist/core/memory-engine/sync-report.js +6 -2
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.js +10 -10
- package/dist/core/memory-engine/types.d.ts +118 -19
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/memory.js +15 -6
- package/dist/core/mode-policy.js +1 -1
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +32 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/kernel/events.d.ts +11 -3
- package/dist/core/mods/kernel/events.js +13 -10
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +4 -1
- package/dist/core/mods/session-append.js +7 -0
- package/dist/core/mods/session-receive.js +12 -15
- package/dist/core/mods/stations.d.ts +70 -6
- package/dist/core/mods/stations.js +144 -1
- package/dist/core/own-property-receipt.d.ts +7 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/park-selfcheck.js +2 -2
- package/dist/core/pause-registry.d.ts +2 -0
- package/dist/core/pause-registry.js +3 -0
- package/dist/core/permission-rule-consent.d.ts +10 -3
- package/dist/core/permission-rule-consent.js +37 -24
- package/dist/core/permission-rule-store.d.ts +35 -1
- package/dist/core/permission-rule-store.js +27 -8
- package/dist/core/read-only-shell.js +3 -2
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/redaction-marks.d.ts +8 -0
- package/dist/core/redaction-marks.js +6 -0
- package/dist/core/remote-env.d.ts +12 -1
- package/dist/core/remote-env.js +3 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/runner/child-tree.d.ts +29 -3
- package/dist/core/runner/child-tree.js +39 -16
- package/dist/core/runner/compact-session.js +5 -2
- package/dist/core/runner/contracts.d.ts +36 -17
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/gate-exit.js +2 -2
- package/dist/core/runner/inherited-ask-grants.js +1 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/memory-consolidation-driver.d.ts +6 -3
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/memory-consolidation-write-judge.d.ts +2 -1
- package/dist/core/runner/memory-consolidation-write-judge.js +3 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +2 -1
- package/dist/core/runner/permission-rule-lanes.js +2 -2
- package/dist/core/runner/person-path-rows.d.ts +23 -3
- package/dist/core/runner/person-path-rows.js +31 -4
- package/dist/core/runner/placement-fence.d.ts +12 -0
- package/dist/core/runner/placement-fence.js +20 -6
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +3 -4
- package/dist/core/runner/prepare-execution-env.js +17 -6
- package/dist/core/runner/prepare-hands-readface.d.ts +3 -2
- package/dist/core/runner/prepare-hands-readface.js +32 -10
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -8
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -4
- package/dist/core/runner/prepare-memory-engine-session.js +4 -4
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +28 -20
- package/dist/core/runner/prepare-park-ask.js +4 -3
- package/dist/core/runner/prepare-task.js +22 -16
- package/dist/core/runner/prepare-workspace-restore.js +3 -6
- package/dist/core/runner/resume-admission.d.ts +3 -3
- package/dist/core/runner/resume-admission.js +6 -3
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +11 -4
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +4 -1
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +3 -2
- package/dist/core/runner/run-leg.js +25 -8
- package/dist/core/runner/run-settle-and-teardown.js +6 -4
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-turn-boundary.js +7 -4
- package/dist/core/runner/runtask.js +6 -6
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-steer-verb.js +8 -0
- package/dist/core/runner/terminal-account.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/turn-attachments.d.ts +5 -0
- package/dist/core/runner/turn-attachments.js +1 -1
- package/dist/core/runner-deps.d.ts +8 -4
- package/dist/core/secret-env.d.ts +9 -6
- package/dist/core/secret-env.js +41 -22
- package/dist/core/session-checkout.d.ts +108 -0
- package/dist/core/session-checkout.js +485 -0
- package/dist/core/session-store.d.ts +13 -5
- package/dist/core/session-store.js +28 -4
- package/dist/core/session.d.ts +29 -5
- package/dist/core/session.js +3 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +6 -12
- package/dist/core/store-contracts/checkpoint-store-contract.js +73 -6
- package/dist/core/store-contracts/session-store-contract.js +61 -8
- package/dist/core/task-event.d.ts +28 -1
- package/dist/core/task-notification.d.ts +9 -1
- package/dist/core/task-notification.js +8 -1
- package/dist/core/task-registry-agent.d.ts +40 -8
- package/dist/core/task-registry-agent.js +57 -24
- package/dist/core/task-registry-shared.d.ts +33 -11
- package/dist/core/task-registry-workflow.js +4 -3
- package/dist/core/task-registry.d.ts +27 -10
- package/dist/core/task-registry.js +19 -13
- package/dist/core/task-result.d.ts +5 -5
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +21 -1
- package/dist/core/terminal-cause.d.ts +6 -6
- package/dist/core/tool-face.d.ts +6 -2
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-policy.d.ts +16 -13
- package/dist/core/tool-policy.js +11 -10
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +42 -19
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +15 -4
- package/dist/core/untrusted-egress.js +23 -22
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +3 -0
- package/dist/engine/execution-env/node-execution-env.js +12 -5
- package/dist/engine/harness/types.d.ts +77 -1
- package/dist/engine/harness/types.js +108 -0
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.d.ts +24 -1
- package/dist/engine/session/session.js +46 -2
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/index.d.ts +16 -12
- package/dist/index.js +11 -8
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/orchestration/run-workflow-tool.d.ts +7 -1
- package/dist/orchestration/run-workflow-tool.js +28 -11
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow.d.ts +6 -0
- package/dist/orchestration/workflow.js +5 -8
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +7 -6
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +2 -9
- package/dist/stores/file/index.js +2 -4
- package/dist/stores/file/session-store.d.ts +13 -7
- package/dist/stores/file/session-store.js +42 -18
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +10 -10
- package/dist/tools/fs/program-read-model.d.ts +34 -10
- package/dist/tools/fs/program-read-model.js +37 -7
- package/dist/tools/fs/program-read-model.rows.js +13 -2
- package/dist/tools/fs/read-deny.d.ts +13 -1
- package/dist/tools/fs/read-deny.js +10 -2
- package/dist/tools/fs/removal-targets.js +5 -5
- package/dist/tools/fs/safety.d.ts +2 -0
- package/dist/tools/fs/safety.js +1 -1
- package/dist/tools/fs/shell-read-argv.d.ts +11 -2
- package/dist/tools/fs/shell-read-argv.js +45 -29
- package/dist/tools/fs/shell-read-bindings.d.ts +20 -2
- package/dist/tools/fs/shell-read-bindings.js +153 -69
- package/dist/tools/fs/shell-read-brace.d.ts +18 -0
- package/dist/tools/fs/shell-read-brace.js +79 -0
- package/dist/tools/fs/shell-read-check.js +29 -11
- package/dist/tools/fs/shell-read-establish.js +43 -22
- package/dist/tools/fs/shell-read-functions.js +2 -2
- package/dist/tools/fs/shell-read-judge.d.ts +11 -0
- package/dist/tools/fs/shell-read-judge.js +3 -3
- package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +18 -0
- package/dist/tools/fs/shell-read-plan.js +217 -104
- package/dist/tools/fs/shell-read-start.d.ts +76 -13
- package/dist/tools/fs/shell-read-start.js +97 -17
- package/dist/tools/fs/shell-read-word.d.ts +10 -0
- package/dist/tools/fs/shell-read-word.js +9 -5
- package/dist/tools/fs/shell-read-workdir.d.ts +54 -14
- package/dist/tools/fs/shell-read-workdir.js +103 -19
- package/dist/tools/fs/shell-read-write-targets.js +13 -8
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +7 -35
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +93 -43
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core-stores-sql@7.63.0.json +30 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/core@7.63.0.json +3523 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/mods-kernel@7.63.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/wire-changes/primitives@7.63.0.json +445 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/credential-vocabulary.d.ts +0 -176
- package/dist/core/credential-vocabulary.js +0 -190
- package/dist/core/redaction-passes.d.ts +0 -82
- package/dist/core/redaction-passes.js +0 -377
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { ConsolidationGateRow, ConsolidationIntentCredentialRow, ConsolidationPlanFile, ConsolidationPlanRead } from "./consolidation.js";
|
|
2
|
+
import type { ConsolidationDriverRunRow } from "./consolidation-driver.js";
|
|
3
|
+
import type { LlmConsolidationPlan } from "./distiller.js";
|
|
1
4
|
/**
|
|
2
5
|
* design/336 §2.1 — the closed `cause` vocabulary of {@link MemoryEntryOrigin}. Mechanical facts
|
|
3
6
|
* only (no free text, no tool names, no session ids — those stay on the control plane):
|
|
@@ -89,8 +92,9 @@ export interface MemoryEntryFrontmatter {
|
|
|
89
92
|
description?: string;
|
|
90
93
|
/** CC `metadata.type`: user | feedback | project | reference (unknown strings degrade, design/65). */
|
|
91
94
|
type?: string;
|
|
92
|
-
/** design/138 §2.4
|
|
93
|
-
*
|
|
95
|
+
/** design/138 §2.4 — the frontmatter tombstone: `deleted: true` reads as the entry's deletion (the
|
|
96
|
+
* sync channel and the inclusion ladder carry deletions in this form). On the harvest's write face
|
|
97
|
+
* it is one of two spellings of the same delete — the other is removing the file. */
|
|
94
98
|
deleted?: boolean;
|
|
95
99
|
/**
|
|
96
100
|
* design-A C-5 (AGENTS.md×ingest, [A1]) — TYPED provenance for entries an INGEST producer minted
|
|
@@ -409,7 +413,99 @@ export interface MemoryBackend {
|
|
|
409
413
|
/** design/84 Seam B cursor pair, migrated verbatim onto the entry-id plane (S2 rewires consolidation). */
|
|
410
414
|
getConsolidationCursor(scope: string): Promise<string | undefined>;
|
|
411
415
|
setConsolidationCursor(scope: string, cursor: string): Promise<void>;
|
|
416
|
+
/** The consolidation state's store (gate rows, plan workbook, intent credentials, driver run account, mint archive):
|
|
417
|
+
* present ⇒ the engine keeps that state here, beside this backend's entries; absent ⇒ the engine keeps it in the
|
|
418
|
+
* replica's own control plane (`fileGovernanceStore` over it). The File backend always carries it, over its own
|
|
419
|
+
* control plane, byte for byte what the files were. Whether the state a consolidation reads survives the replica
|
|
420
|
+
* is answered by `memoryGovernanceDurability`, never by probing this member. */
|
|
421
|
+
readonly governance?: MemoryGovernanceStore;
|
|
412
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* One transaction over the consolidation gate rows (every scope's row — one document) and the plan workbook: `fn`
|
|
425
|
+
* runs once, synchronously, over the rows and the plans named in `planIds` as they stood when the transaction took
|
|
426
|
+
* its serialization; its plan writes and — when it answers `writeGate: true` — its row changes are written after it
|
|
427
|
+
* returns, plans first, then the rows (a throw inside `fn` writes nothing and propagates unchanged). A failure while
|
|
428
|
+
* those writes land is not rolled back: the File store leaves the plans already written, as 7.62.0 did, and the
|
|
429
|
+
* engine never asks one transaction for a plan write and a row write together (each of its plan writes is its own
|
|
430
|
+
* transaction), so no reader meets half of one. Nobody else's transaction lands between the reads it saw and its
|
|
431
|
+
* writes: the plan owner fence (read the applier, then write the plan) relies on it.
|
|
432
|
+
*/
|
|
433
|
+
export interface ConsolidationTx {
|
|
434
|
+
/** Every scope's gate row, mutable in place (a row added here is written when the transaction answers `writeGate`). */
|
|
435
|
+
readonly scopes: Record<string, ConsolidationGateRow>;
|
|
436
|
+
/** A plan named in the transaction's `planIds` as it stood (a plan not named ⇒ throws: it was not read under the transaction). */
|
|
437
|
+
plan(planId: string): ConsolidationPlanRead;
|
|
438
|
+
/** Stage a plan write; committed with the transaction. */
|
|
439
|
+
writePlan(plan: ConsolidationPlanFile): void;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* The consolidation state's store contract ({@link MemoryBackend.governance}). Every read of a malformed record throws
|
|
443
|
+
* `ControlPlaneCorruptError` (fail-closed); a record that was never written reads as absent / empty — a missing row is
|
|
444
|
+
* never a corrupt one, and a corrupt one is never read as missing. `memoryGovernanceStoreContract` (the kit) states
|
|
445
|
+
* each clause as a case.
|
|
446
|
+
*/
|
|
447
|
+
export interface MemoryGovernanceStore {
|
|
448
|
+
/** See {@link ConsolidationTx}. */
|
|
449
|
+
transact<T>(planIds: readonly string[], fn: (tx: ConsolidationTx) => {
|
|
450
|
+
writeGate: boolean;
|
|
451
|
+
result: T;
|
|
452
|
+
}): Promise<T>;
|
|
453
|
+
/** Every scope's gate row as last committed. */
|
|
454
|
+
readGate(): Promise<Record<string, ConsolidationGateRow>>;
|
|
455
|
+
/** A plan as last committed (`corrupt` carries the reason; an id outside the plan-id grammar reads `absent`). The one
|
|
456
|
+
* dual-form read: a store that answers synchronously (the File store) lets the engine confirm the plan's holder
|
|
457
|
+
* under a landing-admitting backend's lock, before each commit; a Promise answer has each patch applied alone, the
|
|
458
|
+
* holder read before each. */
|
|
459
|
+
readPlan(planId: string): ConsolidationPlanRead | Promise<ConsolidationPlanRead>;
|
|
460
|
+
/** The workbook's plan ids (custody copies excluded). */
|
|
461
|
+
listPlanIds(): Promise<string[]>;
|
|
462
|
+
/** Move a plan the valve discards aside, never deleting its bytes; answers the custody name, `undefined` when there was nothing to move. */
|
|
463
|
+
quarantinePlan(planId: string): Promise<string | undefined>;
|
|
464
|
+
/** Record intent credentials, idempotent on requestId (a standing row wins); answers the requestIds written. */
|
|
465
|
+
recordIntents(rows: readonly ConsolidationIntentCredentialRow[]): Promise<string[]>;
|
|
466
|
+
readIntents(): Promise<Record<string, ConsolidationIntentCredentialRow>>;
|
|
467
|
+
/** The run claim, one compare-and-set: a pending run of the scope is resumed (its `attempt` bumped — the writer
|
|
468
|
+
* takeover), otherwise `fresh()` opens a new one. */
|
|
469
|
+
claimRun(scope: string, fresh: () => ConsolidationDriverRunRow): Promise<{
|
|
470
|
+
row: ConsolidationDriverRunRow;
|
|
471
|
+
resumed: boolean;
|
|
472
|
+
}>;
|
|
473
|
+
readRun(scope: string): Promise<ConsolidationDriverRunRow | undefined>;
|
|
474
|
+
/** Write a run row only while the scope's standing claim is this row's `(runId, attempt)`; a newer claim refuses
|
|
475
|
+
* `memory.consolidation_driver_superseded` and writes nothing. */
|
|
476
|
+
writeRun(row: ConsolidationDriverRunRow): Promise<void>;
|
|
477
|
+
/** Archive one mint (what the model was shown and answered, verbatim) under the claim's name; answers the name. */
|
|
478
|
+
archiveMint(runId: string, attempt: number, plan: LlmConsolidationPlan): Promise<string>;
|
|
479
|
+
/** A mint archive by name (`undefined` when there is none). */
|
|
480
|
+
readMint(name: string): Promise<LlmConsolidationPlan | undefined>;
|
|
481
|
+
/** Erase a mint archive (its bytes gone, not moved); answers whether one was there. */
|
|
482
|
+
eraseMint(name: string): Promise<boolean>;
|
|
483
|
+
/** A governance document ({@link MEMORY_GOVERNANCE_DOC_NAMES}) as last committed, parsed but not judged: `undefined`
|
|
484
|
+
* when it was never written; a document that cannot be read or parsed throws `ControlPlaneCorruptError` — never
|
|
485
|
+
* read as missing. The engine judges the shape (each document's one reader lives in core). */
|
|
486
|
+
readDoc(name: MemoryGovernanceDocName): Promise<unknown>;
|
|
487
|
+
/** One serialized read-modify-write of a governance document: `coerce` judges what was committed (`undefined` when
|
|
488
|
+
* never written; it throws `ControlPlaneCorruptError` on a shape it refuses), `fn` runs once, synchronously, over
|
|
489
|
+
* that value, and `next` — when it answers one — is written before the call settles. A throw in `coerce` or `fn`
|
|
490
|
+
* writes nothing and propagates unchanged. Nobody else's update of the same document lands between the read `fn`
|
|
491
|
+
* saw and its write; a store that retries a serialization failure runs `coerce` and `fn` again over a fresh read. */
|
|
492
|
+
updateDoc<S, T>(name: MemoryGovernanceDocName, coerce: (raw: unknown) => S, fn: (current: S) => {
|
|
493
|
+
next?: S;
|
|
494
|
+
result: T;
|
|
495
|
+
}): Promise<T>;
|
|
496
|
+
}
|
|
497
|
+
/** The governance documents a {@link MemoryGovernanceStore} keeps (closed set): the harvest lineage ledger, the challenge
|
|
498
|
+
* ledger, the delegation-settlement ledger, the session-account ledger and the memory announcement queue (the notices
|
|
499
|
+
* a session's first injection reads, one bounded queue per scope — {@link import("./layout.js").enqueueMemoryAnnouncement}).
|
|
500
|
+
* One law for all five: the store refuses what it cannot read; what a document means, the queue's leniency over a
|
|
501
|
+
* malformed record included, is core's. The instruction-hold ledger is not one of them: a hold row and its captured
|
|
502
|
+
* bytes are one record, the bytes are files in the engine's control plane, so the row stays beside them there (on
|
|
503
|
+
* several replicas the holds are each replica's own). */
|
|
504
|
+
export declare const MEMORY_GOVERNANCE_DOC_NAMES: readonly ["lineage", "challenges", "settlements", "session-accounts", "announcements"];
|
|
505
|
+
/** One of {@link MEMORY_GOVERNANCE_DOC_NAMES}. */
|
|
506
|
+
export type MemoryGovernanceDocName = (typeof MEMORY_GOVERNANCE_DOC_NAMES)[number];
|
|
507
|
+
/** The part of a {@link MemoryGovernanceStore} the governance documents are kept through. */
|
|
508
|
+
export type MemoryGovernanceDocs = Pick<MemoryGovernanceStore, "readDoc" | "updateDoc">;
|
|
413
509
|
/** One file the engine materialized into the session memory directory. */
|
|
414
510
|
export interface MaterializedFile {
|
|
415
511
|
/** Absolute canonical path of the projected file. */
|
|
@@ -482,8 +578,6 @@ export interface MemorySessionHandle {
|
|
|
482
578
|
* scopes have a key; the tool faces derive their own LIVE answer per call, so a stale snapshot
|
|
483
579
|
* can mis-report a number, never mis-serve an entry. */
|
|
484
580
|
shadowedByScope?: ReadonlyMap<string, number>;
|
|
485
|
-
/** Lines of the derived MEMORY.md at materialize time (the index-cleared fuse baseline). */
|
|
486
|
-
indexBaselineLines: number;
|
|
487
581
|
/** 评审 M6 — the derived index TEXT as of materialize. `inject` reads THIS when no on-disk
|
|
488
582
|
* MEMORY.md exists (a read-only layering never writes one), so first-session read-only injection
|
|
489
583
|
* works without a disk round-trip. */
|
|
@@ -577,9 +671,9 @@ export interface ScanFinding {
|
|
|
577
671
|
}
|
|
578
672
|
/**
|
|
579
673
|
* design/138 S2-B — one queued memory-change announcement, drained into the NEXT session's first
|
|
580
|
-
* injection (时机① only; there is no in-run delivery lane — O-F2/C-F4 裁撤). Queued
|
|
581
|
-
*
|
|
582
|
-
* concurrent writers never overwrite each other (O-F6/C-F5).
|
|
674
|
+
* injection (时机① only; there is no in-run delivery lane — O-F2/C-F4 裁撤). Queued in the governance
|
|
675
|
+
* store's `announcements` document ({@link import("./layout.js").enqueueMemoryAnnouncement}, one
|
|
676
|
+
* serialized update) so concurrent writers never overwrite each other (O-F6/C-F5).
|
|
583
677
|
*/
|
|
584
678
|
export interface MemoryAnnouncement {
|
|
585
679
|
/** `gate` = engine gate/harvest events (rejections, quarantine, incidents, restores, conflicts,
|
|
@@ -606,7 +700,7 @@ export interface MemoryAnnouncement {
|
|
|
606
700
|
*
|
|
607
701
|
* STRUCTURE-ONLY, deliberately: {@link import("./engine.js").renderAnnouncements} does not read
|
|
608
702
|
* it, so the model-visible block is byte-for-byte what it always was. The consumer is a host
|
|
609
|
-
* reading the queue (`drainMemoryAnnouncements` / `peekMemoryAnnouncements`), which can now join
|
|
703
|
+
* reading the queue (`drainMemoryAnnouncements` / `peekMemoryAnnouncements` over the governance store that keeps it), which can now join
|
|
610
704
|
* a queued line to the `memory.harvest_quarantined` / `memory.hold_*` notices of the same
|
|
611
705
|
* harvest instead of guessing from counts.
|
|
612
706
|
*
|
|
@@ -673,7 +767,7 @@ export interface HarvestReport {
|
|
|
673
767
|
/** Set when a fuse tripped (§2.4 删除防线 / B3 fail-closed): the harvest is refused wholesale, NO
|
|
674
768
|
* patches (especially no deletes) are produced, and the report is surfaced as an alert. */
|
|
675
769
|
incident?: {
|
|
676
|
-
kind: "mass_deletion" | "
|
|
770
|
+
kind: "mass_deletion" | "dir_missing" | "sidecar_corrupt";
|
|
677
771
|
detail: string;
|
|
678
772
|
};
|
|
679
773
|
/** Patch counts actually APPLIED by the backend. */
|
|
@@ -701,17 +795,22 @@ export interface HarvestReport {
|
|
|
701
795
|
contained: boolean;
|
|
702
796
|
detail: string;
|
|
703
797
|
}>;
|
|
704
|
-
/** Materialized files
|
|
705
|
-
*
|
|
706
|
-
*
|
|
798
|
+
/** Materialized files gone at harvest — absent, or blank (a blank file holds no entry). On the write
|
|
799
|
+
* face each is this session's removal of that entry, which the harvest commits as a delete (the
|
|
800
|
+
* deletion right is the write right) unless the deletion fuse refuses the whole harvest or a
|
|
801
|
+
* containment arm withholds it; on a read-only layer it is only listed — the session holds no
|
|
802
|
+
* write right there, so it is no delete and the entry stays committed. Files whose entry id
|
|
803
|
+
* re-appears at another path (a RENAME) are NOT counted here
|
|
804
|
+
* (验收 M1 — a rename is an id-keyed update, never a removal, and never feeds the deletion fuse). */
|
|
707
805
|
missing: string[];
|
|
708
|
-
/**
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
* the
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
806
|
+
/** Files RESTORED onto disk from the committed copy (backend/shadow), disclosed here (the restore is
|
|
807
|
+
* an engine action, never silent): a read-only layer's edited files, and the write-face
|
|
808
|
+
* removals a containment arm withheld (a session that commits nothing; an instruction-form entry
|
|
809
|
+
* under the hard gate). Restored paths also appear in {@link missing} (the honest record of what
|
|
810
|
+
* vanished) — EXCEPT the design/336 §4 hold arm: an UPDATE-form instruction hold captures the
|
|
811
|
+
* session's edit and restores the committed bytes onto the plane seat it vacated (zero-copy: the
|
|
812
|
+
* file is the storage), so those paths appear here beside {@link containment}.heldInstruction,
|
|
813
|
+
* never in `missing` (the file never vanished — its edit is in custody). */
|
|
715
814
|
restored: string[];
|
|
716
815
|
/** The other outcome of the same restore: a path whose committed baseline was NOT written back, because
|
|
717
816
|
* another writer held the file when the restore reached it. The newer bytes stand, the baseline is
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const MEMORY_ORIGIN_CAUSES = Object.freeze(["observed", "derived", "static", "unattributed"]);
|
|
2
|
+
export const MEMORY_GOVERNANCE_DOC_NAMES = Object.freeze(["lineage", "challenges", "settlements", "session-accounts", "announcements"]);
|
|
2
3
|
export function writableRootOf(handle) {
|
|
3
4
|
if (handle.writableRoot === null)
|
|
4
5
|
throw new Error("memory session handle has no write face (writeScope is null) — writableRoot is not available");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* design/81 Slice 5 — the shared distance primitives for the consolidation `searchScored` retrieval, extracted
|
|
3
3
|
* BYTE-IDENTICAL from the original PgMemoryStore implementation so the File (portable/TOC) and Pg (native/TOB)
|
|
4
|
-
* backends rank on ONE source of truth and can't drift. The
|
|
4
|
+
* backends rank on ONE source of truth and can't drift. The consolidation
|
|
5
5
|
* band `{0.05, 0.3}` is defined on this cosine-distance scale; the lexical `1 - Jaccard ∈ [0,1] ⊂ [0,2]` is the
|
|
6
6
|
* same-zero-point stand-in used when no embedding vector is present (fail-open per row).
|
|
7
7
|
*
|
package/dist/core/memory.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ScoredMemory {
|
|
|
16
16
|
/** design/84 Seam B (前置 BLOCKER): true when this note was CREATED by a consolidation ADD (not the
|
|
17
17
|
* `remember` tool / a caller). Periodic/incremental consolidation EXCLUDES these from its candidate set so
|
|
18
18
|
* it never re-consolidates its own output (infinite re-merge). Stores that don't track it leave it absent
|
|
19
|
-
* (treated as not-generated — back-compat, RL-1654-
|
|
19
|
+
* (treated as not-generated — back-compat, RL-1654-store-family: the inline task-end path already excludes this-task notes by id). */
|
|
20
20
|
consolidationGenerated?: boolean;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -86,7 +86,7 @@ export interface MemoryStore {
|
|
|
86
86
|
*/
|
|
87
87
|
searchScored?(scope: string, query: string, limit?: number): Promise<ScoredMemory[]> | ScoredMemory[];
|
|
88
88
|
/** The vector-ranking rung this store achieves (design/81 Slice 5). Absent ⇒ treated as `"lexical"`
|
|
89
|
-
* (back-compat, RL-1654-
|
|
89
|
+
* (back-compat, RL-1654-store-family). A runtime observable — a deployment reads it to decide index/metrics, NOT to decide
|
|
90
90
|
* whether to inject an embedder (injection is config-driven; this is the RESULT). See {@link MemoryVectorMode}. */
|
|
91
91
|
readonly vectorMode?: MemoryVectorMode;
|
|
92
92
|
/** Optional: replace a note's text by id (consolidation UPDATE). The id stays stable. Must be safe
|
|
@@ -125,8 +125,8 @@ export interface MemoryStore {
|
|
|
125
125
|
*/
|
|
126
126
|
appendPromotable?(scope: string, note: StructuredNoteInput, utilityVerdict: unknown): Promise<string> | string;
|
|
127
127
|
/**
|
|
128
|
-
* **INTERNAL consolidation-only door** for the design/84 Seam B marker.
|
|
129
|
-
* it
|
|
128
|
+
* **INTERNAL consolidation-only door** for the design/84 Seam B marker. A consolidation pass (and ONLY
|
|
129
|
+
* it; none ships in the package any more) calls this to materialize a merged "add" decision tagged
|
|
130
130
|
* `consolidationGenerated:true`, so a later periodic/incremental pass EXCLUDES its own output from the
|
|
131
131
|
* candidate set (no infinite re-merge). It is the COUNTERPART to the {@link guardedMemoryStore} boundary
|
|
132
132
|
* defense: the public {@link appendStructured} STRIPS a caller-supplied `consolidationGenerated` (an
|
|
@@ -146,13 +146,13 @@ export interface MemoryStore {
|
|
|
146
146
|
* reference stores it is a note **id** (uuidv7 — lexicographically time-sortable), so "after the cursor"
|
|
147
147
|
* is a simple string `>` comparison. Returns `undefined` when no pass has run yet (⇒ the WHOLE scope is
|
|
148
148
|
* pending — the first pass sweeps it all). PAIR with {@link setConsolidationCursor}: a store implements
|
|
149
|
-
* BOTH or NEITHER ({@link supportsPeriodicConsolidation});
|
|
150
|
-
*
|
|
149
|
+
* BOTH or NEITHER ({@link supportsPeriodicConsolidation}); the package no longer ships the pass that read it
|
|
150
|
+
* (the store family that keeps it is on RL-1654-store-family).
|
|
151
151
|
*/
|
|
152
152
|
getConsolidationCursor?(scope: string): Promise<string | undefined> | string | undefined;
|
|
153
153
|
/**
|
|
154
154
|
* design/84 Seam B — persist the periodic/incremental consolidation cursor for `scope` (decision 3). Called
|
|
155
|
-
* by
|
|
155
|
+
* by a consolidation pass ONLY after it succeeds in full, advancing the cursor to the max ordering
|
|
156
156
|
* marker the pass observed (seen note ids ∪ added ids). Must be durable (a later pass reads it back). PAIR
|
|
157
157
|
* with {@link getConsolidationCursor}.
|
|
158
158
|
*/
|
|
@@ -183,7 +183,7 @@ export interface StructuredNoteInput {
|
|
|
183
183
|
outcomeStats?: unknown;
|
|
184
184
|
/**
|
|
185
185
|
* design/84 Seam B (前置 BLOCKER): mark a note as CREATED BY A CONSOLIDATION ADD. Set ONLY by
|
|
186
|
-
*
|
|
186
|
+
* a consolidation pass (none ships in the package any more) when it materializes a merged
|
|
187
187
|
* "add" decision — never by the `remember` tool or a normal caller. A store persists it (and surfaces it on
|
|
188
188
|
* {@link ScoredMemory}/{@link MemoryNoteHeader}) so periodic/incremental consolidation can EXCLUDE these
|
|
189
189
|
* notes from its candidate set and not re-consolidate its own output forever. It does NOT affect the
|
|
@@ -245,7 +245,7 @@ export type PeriodicConsolidationCapableStore = MemoryStore & Required<Pick<Memo
|
|
|
245
245
|
/**
|
|
246
246
|
* True when a store implements the design/84 Seam B cursor PAIR
|
|
247
247
|
* ({@link MemoryStore.getConsolidationCursor}/{@link MemoryStore.setConsolidationCursor}). Periodic/incremental
|
|
248
|
-
* consolidation (
|
|
248
|
+
* consolidation (a pass the package no longer ships) GATES on this: a store missing
|
|
249
249
|
* either method makes a periodic pass a safe **NO-OP** (never a silent full re-consolidation of the whole
|
|
250
250
|
* scope, which would re-merge already-consolidated notes forever). Both-or-neither — a store implementing
|
|
251
251
|
* only one is treated as unsupported. Independent of {@link supportsConsolidation} (the id-addressable trio),
|
|
@@ -437,7 +437,7 @@ export declare function expandLexicalTerms(term: string): string[];
|
|
|
437
437
|
* Matching rule: tokenize `text` on word boundaries, then for each whitespace-separated `query` term the
|
|
438
438
|
* text must match AT LEAST ONE of that term's {@link expandLexicalTerms} variants (OR within a term), and
|
|
439
439
|
* EVERY query term must match (AND across terms). The ORIGINAL query term keeps its pre-Slice-2b SUBSTRING
|
|
440
|
-
* semantics (back-compat, RL-1654-
|
|
440
|
+
* semantics (back-compat, RL-1654-store-family); the EXPANDED synonym/stem variants are matched on WORD BOUNDARIES (set membership
|
|
441
441
|
* over the text's token set) so a short injected synonym like "key"/"db" cannot substring-match an unrelated
|
|
442
442
|
* word ("keyboard"/"double"). An empty/whitespace-only query never matches.
|
|
443
443
|
*/
|
package/dist/core/memory.js
CHANGED
|
@@ -4,7 +4,7 @@ import { termSet } from "./memory-vector.js";
|
|
|
4
4
|
import { attrEscape } from "./task-notification.js";
|
|
5
5
|
import { sanitizeUntrustedText, ENGINE_AUTHORITY_ENVELOPE_TAGS } from "./untrusted-text.js";
|
|
6
6
|
import { thrownText } from "./thrown-value.js";
|
|
7
|
-
import { CREDENTIAL_VOCABULARY,
|
|
7
|
+
import { CREDENTIAL_VOCABULARY, scanSecrets } from "@sema-agent/primitives";
|
|
8
8
|
export function supportsConsolidation(store) {
|
|
9
9
|
return (typeof store.searchScored === "function" &&
|
|
10
10
|
typeof store.update === "function" &&
|
|
@@ -39,14 +39,23 @@ export class MemoryProjectionError extends Error {
|
|
|
39
39
|
function hasPromotableMarker(note) {
|
|
40
40
|
return note.outcomeStats !== undefined;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const REFUSE_WRITE_POLICY = Object.freeze({
|
|
43
|
+
grade: "strict",
|
|
44
|
+
readings: Object.freeze([Object.freeze({ kind: "raw" })]),
|
|
45
|
+
urlUserinfo: "keep-username",
|
|
46
|
+
onUnresolvedReading: "secret",
|
|
47
|
+
});
|
|
48
|
+
const refuseLabel = (id) => id.replaceAll("-", "_");
|
|
43
49
|
export function detectSecret(text) {
|
|
44
50
|
if (!text)
|
|
45
51
|
return null;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
const scan = scanSecrets(text, REFUSE_WRITE_POLICY);
|
|
53
|
+
if (scan.outcome === "whole")
|
|
54
|
+
return refuseLabel(scan.reason);
|
|
55
|
+
const found = new Set(scan.spans.map((s) => s.family));
|
|
56
|
+
for (const row of CREDENTIAL_VOCABULARY.values)
|
|
57
|
+
if (row.strict !== undefined && found.has(row.id))
|
|
58
|
+
return refuseLabel(row.id);
|
|
50
59
|
return null;
|
|
51
60
|
}
|
|
52
61
|
export function enforceSecretWriteGate(body) {
|
package/dist/core/mode-policy.js
CHANGED
|
@@ -8,7 +8,7 @@ import { clampPermissionMode, isPermissionMode, PERMISSION_MODES } from "./ask-o
|
|
|
8
8
|
import { argvOf, lexShellText } from "../shell/lex.js";
|
|
9
9
|
import { COMMAND_RULE_TOOL } from "./permission-rule-model.js";
|
|
10
10
|
import { createSafeNotifier } from "./safe-notify.js";
|
|
11
|
-
import { CheckpointError, isCheckpointConfigRefusalCode } from "./checkpoint-
|
|
11
|
+
import { CheckpointError, isCheckpointConfigRefusalCode } from "./checkpoint-features.js";
|
|
12
12
|
export const PERMISSION_MODE_FOLD_REASONS = Object.freeze(["operator_deny", "face_absent", "inherited_ceiling"]);
|
|
13
13
|
export const ACCEPT_EDITS_FILE_COMMANDS = Object.freeze(["mkdir", "touch", "rm", "rmdir", "mv", "cp", "sed"]);
|
|
14
14
|
const MODE_POLICY_TABLE = {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* registration form types a handler by it. Its keys are the event table's `classic.*` rows that carry a station — the key
|
|
5
5
|
* set is held to that table.
|
|
6
6
|
*/
|
|
7
|
-
import type { PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, StopEvent, StopFailureEvent, StopHookResult, SubagentStartEvent, SubagentStartResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
|
|
7
|
+
import type { PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, SessionEndEvent, SessionStartEvent, StopEvent, StopFailureEvent, StopHookResult, SubagentStartEvent, SubagentStartResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
|
|
8
8
|
import type { MappedOn, ModRegistration } from "./kernel/index.js";
|
|
9
9
|
import type { EngineDollar } from "./dollar.js";
|
|
10
10
|
/** The answer of an event whose station reads none (an observation event): a chain handler passes `next(e)`'s on. */
|
|
@@ -31,6 +31,14 @@ export type ClassicEventMap = {
|
|
|
31
31
|
readonly e: UserPromptSubmitEvent;
|
|
32
32
|
readonly answer: UserPromptSubmitResult;
|
|
33
33
|
};
|
|
34
|
+
readonly "classic.SessionStart": {
|
|
35
|
+
readonly e: SessionStartEvent;
|
|
36
|
+
readonly answer: ObservedAnswer;
|
|
37
|
+
};
|
|
38
|
+
readonly "classic.SessionEnd": {
|
|
39
|
+
readonly e: SessionEndEvent;
|
|
40
|
+
readonly answer: ObservedAnswer;
|
|
41
|
+
};
|
|
34
42
|
readonly "classic.SubagentStart": {
|
|
35
43
|
readonly e: SubagentStartEvent;
|
|
36
44
|
readonly answer: SubagentStartResult;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
* event over it. Every method's bottom is a seat the engine already has; each method's limits are part of
|
|
4
4
|
* its contract and are checked here (a refused input is the caller's throw, "(host check)").
|
|
5
5
|
*/
|
|
6
|
-
import type { ExecutionEnv } from "../../internal/harness-types.js";
|
|
6
|
+
import type { AgentMessage, ExecutionEnv } from "../../internal/harness-types.js";
|
|
7
7
|
import type { Context, Message, Usage } from "../../internal/llm.js";
|
|
8
8
|
import type { CompactOutcome } from "../task-event.js";
|
|
9
9
|
import type { ModDollarBase, ModMethodBottoms } from "./kernel/index.js";
|
|
10
|
+
import type { ContextOccupancy } from "./lifecycle-stations.js";
|
|
10
11
|
/** `$.process.run`'s default command timeout (CC). */
|
|
11
12
|
export declare const PROCESS_RUN_DEFAULT_TIMEOUT_MS = 30000;
|
|
12
13
|
/** `$.process.run`'s largest command timeout (CC). */
|
|
@@ -55,13 +56,30 @@ export interface ModSeatView {
|
|
|
55
56
|
cwd(): string;
|
|
56
57
|
root(): string;
|
|
57
58
|
model(): string;
|
|
59
|
+
/** The leg's messages as the model last saw them. */
|
|
58
60
|
messages(): readonly Message[];
|
|
61
|
+
/** A subagent's stored transcript rows, read through the leg's own task list row for it; rejects with the reason when the
|
|
62
|
+
* leg reaches no such row, the row has no session, or the session cannot be read. */
|
|
63
|
+
agentMessages(agentId: string): Promise<readonly AgentMessage[]>;
|
|
64
|
+
/** How many prompts the session's transcript holds from its people (`promptCountOf`, `session-append.ts`). */
|
|
65
|
+
turns(): Promise<number>;
|
|
66
|
+
usage(): SessionUsage;
|
|
67
|
+
version(): SessionVersion;
|
|
59
68
|
};
|
|
60
69
|
/** The deployment clock (`RunnerDeps.now`). */
|
|
61
70
|
now(): number;
|
|
62
71
|
tools(): readonly string[];
|
|
63
72
|
agents(): readonly string[];
|
|
64
73
|
}
|
|
74
|
+
/** `$.session.usage()`: the leg's latest turn-boundary measurement — the context occupancy the boundary's `context_usage`
|
|
75
|
+
* frame carries, absent before the leg's first boundary (a session-level pass measures none). */
|
|
76
|
+
export interface SessionUsage {
|
|
77
|
+
readonly context?: ContextOccupancy;
|
|
78
|
+
}
|
|
79
|
+
/** `$.session.version()`: the engine's package version. */
|
|
80
|
+
export interface SessionVersion {
|
|
81
|
+
readonly version: string;
|
|
82
|
+
}
|
|
65
83
|
export interface ProcessRunResult {
|
|
66
84
|
readonly stdout: string;
|
|
67
85
|
readonly stderr: string;
|
|
@@ -91,7 +109,20 @@ export interface EngineDollar extends ModDollarBase {
|
|
|
91
109
|
cwd(): Promise<string>;
|
|
92
110
|
root(): Promise<string>;
|
|
93
111
|
model(): Promise<string>;
|
|
112
|
+
/** The leg's messages as the model last saw them (the newest {@link SESSION_MESSAGES_MAX}, copies). */
|
|
94
113
|
messages(): Promise<readonly Message[]>;
|
|
114
|
+
/** `$.session.messages({ agentId })`: a subagent's stored transcript rows (the newest {@link SESSION_MESSAGES_MAX}, copies),
|
|
115
|
+
* read through this leg's own task list row for that agent; rejects with the reason when this leg reaches no such row, the
|
|
116
|
+
* row has no session, or the session cannot be read. */
|
|
117
|
+
messages(args: {
|
|
118
|
+
readonly agentId: string;
|
|
119
|
+
}): Promise<readonly AgentMessage[]>;
|
|
120
|
+
/** `$.session.turns()`: how many prompts the session's transcript holds from its people (a steer is not one). */
|
|
121
|
+
turns(): Promise<number>;
|
|
122
|
+
/** `$.session.usage()`: the leg's latest turn-boundary measurement. */
|
|
123
|
+
usage(): Promise<SessionUsage>;
|
|
124
|
+
/** `$.session.version()`: the engine's package version. */
|
|
125
|
+
version(): Promise<SessionVersion>;
|
|
95
126
|
/** `$.session.append({ message: { role: "user", content }, agentId? })`: an extension's own note, admitted at the
|
|
96
127
|
* `session.append` station (`session-append.ts`). */
|
|
97
128
|
append(args: {
|
package/dist/core/mods/dollar.js
CHANGED
|
@@ -132,6 +132,15 @@ function detachedMessage(m) {
|
|
|
132
132
|
throw refuse("session.messages", "a session message could not be copied; the history is not handed out live");
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
function sessionMessages(view, args) {
|
|
136
|
+
only(args, "session.messages", ["agentId"]);
|
|
137
|
+
const agentId = args["agentId"];
|
|
138
|
+
if (agentId === undefined)
|
|
139
|
+
return Object.freeze(view.session.messages().slice(-SESSION_MESSAGES_MAX).map(detachedMessage));
|
|
140
|
+
if (typeof agentId !== "string" || agentId === "")
|
|
141
|
+
throw refuse("session.messages", `takes agentId, a non-empty string (got ${typeof agentId === "string" ? "an empty string" : typeof agentId})`);
|
|
142
|
+
return view.session.agentMessages(agentId).then((rows) => Object.freeze(rows.slice(-SESSION_MESSAGES_MAX).map(detachedMessage)));
|
|
143
|
+
}
|
|
135
144
|
const read = (event, f) => (args) => {
|
|
136
145
|
only(args, event, []);
|
|
137
146
|
return f();
|
|
@@ -145,7 +154,10 @@ export function engineMethodBottoms(view) {
|
|
|
145
154
|
"session.cwd": run(read("session.cwd", () => view.session.cwd())),
|
|
146
155
|
"session.root": run(read("session.root", () => view.session.root())),
|
|
147
156
|
"session.model": run(read("session.model", () => view.session.model())),
|
|
148
|
-
"session.messages": run(
|
|
157
|
+
"session.messages": run((args) => sessionMessages(view, args)),
|
|
158
|
+
"session.turns": run(read("session.turns", () => view.session.turns())),
|
|
159
|
+
"session.usage": run(read("session.usage", () => view.session.usage())),
|
|
160
|
+
"session.version": run(read("session.version", () => view.session.version())),
|
|
149
161
|
"clock.now": run(read("clock.now", () => view.now())),
|
|
150
162
|
"clock.sleep": run((args, ctx) => sleep(args, ctx)),
|
|
151
163
|
"tool.list": run(read("tool.list", () => Object.freeze([...view.tools()]))),
|
|
@@ -33,8 +33,13 @@
|
|
|
33
33
|
* 7: `session.receive` (a frame arriving for the model), `session.append` (a row entering the conversation), `session.send` (a
|
|
34
34
|
* message the leg sends) and `session.compact` (a compaction about to run) have stations; `agent.spawn` has a `call` column,
|
|
35
35
|
* and so do `session.append`, `session.send` and `session.compact` — a `$` call of each reaches the host's entry.
|
|
36
|
+
* 8: the closed set is the reference's 145 names (`session.identity`, `ui.view`, `prompt.change` named, not raised);
|
|
37
|
+
* `session.start` (a leg opened), `session.measure` (the leg's context occupancy moved), `turn.start` (a model turn began),
|
|
38
|
+
* `prompt.submit` (a person's input entering the leg — rewritable, droppable, refused on a failure), `classic.SessionStart` and
|
|
39
|
+
* `classic.SessionEnd` have stations, the two classic ones raised in the bottoms of `session.start` and `session.end`; the
|
|
40
|
+
* methods `session.turns`, `session.usage` and `session.version` have bottoms, and `session.messages` takes `{ agentId }`.
|
|
36
41
|
*/
|
|
37
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
42
|
+
export declare const KERNEL_CONTRACT_VERSION = 8;
|
|
38
43
|
/** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
|
|
39
44
|
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
40
45
|
export type ModTier = (typeof MOD_TIERS)[number];
|
|
@@ -111,8 +116,8 @@ export interface ModEventRow {
|
|
|
111
116
|
readonly station?: ModStation;
|
|
112
117
|
}
|
|
113
118
|
/**
|
|
114
|
-
* Every event the kernel knows: the reference's closed set of
|
|
115
|
-
* its
|
|
119
|
+
* Every event the kernel knows: the reference's closed set of 145 names (CC 2.1.309 `_De` (cli309.js:253322) — its 33 `classic.*` names,
|
|
120
|
+
* its 47 engine events and its 65 `$` methods, in its own order). The shell's names (`ui.*`, `command.*`,
|
|
116
121
|
* `config.*`, `audio.*`, the prompt-box events and `prompt.read`) carry `side: "surface"`: one table serves both
|
|
117
122
|
* buses, and the shell's stations are its rows here, raised by the shell where their chain bottoms are. A row with a
|
|
118
123
|
* station is raised on its side in this version; a name with none is named, not raised, and a registration that
|
|
@@ -169,6 +174,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
|
|
|
169
174
|
"prompt.fill": ModEventRow;
|
|
170
175
|
"prompt.suggest": ModEventRow;
|
|
171
176
|
"prompt.edit": ModEventRow;
|
|
177
|
+
"prompt.change": ModEventRow;
|
|
172
178
|
"prompt.autocomplete": ModEventRow;
|
|
173
179
|
"prompt.section": ModEventRow;
|
|
174
180
|
"prompt.context": ModEventRow;
|
|
@@ -218,6 +224,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
|
|
|
218
224
|
"session.surface": ModEventRow;
|
|
219
225
|
"session.surfaces": ModEventRow;
|
|
220
226
|
"session.authorize": ModEventRow;
|
|
227
|
+
"session.identity": ModEventRow;
|
|
221
228
|
"session.usage": ModEventRow;
|
|
222
229
|
"session.version": ModEventRow;
|
|
223
230
|
"turn.abort": ModEventRow;
|
|
@@ -240,6 +247,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
|
|
|
240
247
|
"ui.panes": ModEventRow;
|
|
241
248
|
"ui.selection": ModEventRow;
|
|
242
249
|
"ui.copy": ModEventRow;
|
|
250
|
+
"ui.view": ModEventRow;
|
|
243
251
|
"ui.notify": ModEventRow;
|
|
244
252
|
"ui.blit": ModEventRow;
|
|
245
253
|
"fs.read": ModEventRow;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 8;
|
|
2
2
|
export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
|
|
3
3
|
export const MOD_SEATS = Object.freeze(["deployment", "task"]);
|
|
4
4
|
export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
|
|
@@ -55,8 +55,8 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
55
55
|
"classic.Notification": engine(),
|
|
56
56
|
"classic.UserPromptSubmit": engine(station("refuse", "immediate", ["source", "inputId", "actor", "prompt"])),
|
|
57
57
|
"classic.UserPromptExpansion": engine(),
|
|
58
|
-
"classic.SessionStart": engine(),
|
|
59
|
-
"classic.SessionEnd": engine(),
|
|
58
|
+
"classic.SessionStart": engine(station("skip", "grace")),
|
|
59
|
+
"classic.SessionEnd": engine(station("skip", "grace")),
|
|
60
60
|
"classic.Stop": engine(station("skip", "immediate")),
|
|
61
61
|
"classic.StopFailure": engine(station("skip", "grace")),
|
|
62
62
|
"classic.SubagentStart": engine(station("skip", "immediate", ["agentId", "agentType"])),
|
|
@@ -94,10 +94,11 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
94
94
|
"ui.focus": surface(station("skip", "grace", ["component", "requestId", "plugin", "origin", "element"], { call: true })),
|
|
95
95
|
"agent.offer": engine(station("skip", "grace", ["agent", "provider"])),
|
|
96
96
|
"agent.spawn": engine(station("refuse_until_run", "immediate", AGENT_SPAWN_PINNED, { call: true })),
|
|
97
|
-
"prompt.submit": engine(),
|
|
97
|
+
"prompt.submit": engine(station("refuse", "immediate", ["source", "inputId", "actor"])),
|
|
98
98
|
"prompt.fill": surface(station("skip", "grace", ["origin", "mode"], { call: true })),
|
|
99
99
|
"prompt.suggest": surface(station("skip", "grace", ["origin"], { call: true })),
|
|
100
100
|
"prompt.edit": surface(station("skip", "grace", ["origin", "key"], { budgetMs: PROMPT_EDIT_BUDGET_MS })),
|
|
101
|
+
"prompt.change": surface(),
|
|
101
102
|
"prompt.autocomplete": surface(),
|
|
102
103
|
"prompt.section": engine(station("skip", "grace", ["name", "key", "mountedTools"])),
|
|
103
104
|
"prompt.context": engine(),
|
|
@@ -113,17 +114,17 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
113
114
|
"telemetry.mark": engine(),
|
|
114
115
|
"skill.prompt": engine(),
|
|
115
116
|
"attribution.text": engine(),
|
|
116
|
-
"session.start": engine(),
|
|
117
|
+
"session.start": engine(station("skip", "grace", ["cwd", "sessionId", "agentId"])),
|
|
117
118
|
"session.receive": engine(station("refuse", "immediate", ["origin", "event", "agentId"])),
|
|
118
119
|
"session.append": engine(station("skip", "grace", ["door", "origin", "agentId"], { call: true })),
|
|
119
120
|
"session.send": engine(station("refuse_until_run", "immediate", ["origin", "agentId", "to", "text"], { call: true })),
|
|
120
121
|
"session.compact": engine(station("refuse_until_run", "immediate", ["trigger", "agentId", "instructions"], { call: true })),
|
|
121
122
|
"session.attach": engine(),
|
|
122
123
|
"session.detach": engine(),
|
|
123
|
-
"session.measure": engine(),
|
|
124
|
+
"session.measure": engine(station("skip", "grace", ["context", "changed", "agentId"])),
|
|
124
125
|
"session.end": engine(station("skip", "grace", ["reason", "sessionId", "agentId"])),
|
|
125
126
|
"plugin.register": Object.freeze({ side: "both", station: station("refuse", "immediate", ["name", "seat", "tier", "uses"]) }),
|
|
126
|
-
"turn.start": engine(),
|
|
127
|
+
"turn.start": engine(station("skip", "grace", ["turn", "agentId"])),
|
|
127
128
|
"turn.step": engine(),
|
|
128
129
|
"turn.complete": engine(station("skip", "grace", ["answer", "agentId", "turn"])),
|
|
129
130
|
"engine.create": engine(),
|
|
@@ -137,15 +138,16 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
137
138
|
"session.cwd": engine(method(true)),
|
|
138
139
|
"session.root": engine(method(true)),
|
|
139
140
|
"session.model": engine(method(true)),
|
|
140
|
-
"session.turns": engine(),
|
|
141
|
+
"session.turns": engine(method(true)),
|
|
141
142
|
"session.id": engine(method(true)),
|
|
142
143
|
"session.messages": engine(method(true)),
|
|
143
144
|
"session.repo": engine(),
|
|
144
145
|
"session.surface": engine(),
|
|
145
146
|
"session.surfaces": engine(),
|
|
146
147
|
"session.authorize": engine(),
|
|
147
|
-
"session.
|
|
148
|
-
"session.
|
|
148
|
+
"session.identity": engine(),
|
|
149
|
+
"session.usage": engine(method(true)),
|
|
150
|
+
"session.version": engine(method(true)),
|
|
149
151
|
"turn.abort": engine(),
|
|
150
152
|
"prompt.read": surface(method(true)),
|
|
151
153
|
"flag.value": engine(),
|
|
@@ -166,6 +168,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
166
168
|
"ui.panes": surface(),
|
|
167
169
|
"ui.selection": surface(method(true)),
|
|
168
170
|
"ui.copy": surface(method(true)),
|
|
171
|
+
"ui.view": surface(),
|
|
169
172
|
"ui.notify": surface(),
|
|
170
173
|
"ui.blit": surface(),
|
|
171
174
|
"fs.read": engine(),
|