@sema-agent/server 7.52.1 → 7.53.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/USAGE.md +2 -1
- package/dist/adoption/plan.d.ts +3 -3
- package/dist/adoption/quiesce.d.ts +1 -1
- package/dist/adoption/sql.d.ts +2 -2
- package/dist/adoption/wire.d.ts +1 -1
- package/dist/approval-ask-machine.d.ts +2 -2
- package/dist/approval-card.d.ts +18 -18
- package/dist/approval-deny-reasons.d.ts +1 -1
- package/dist/approval-hmac.d.ts +2 -2
- package/dist/approval-reconciler.d.ts +14 -14
- package/dist/approval.d.ts +2 -2
- package/dist/audit.d.ts +4 -4
- package/dist/auth-keys.d.ts +6 -6
- package/dist/bench/l8/artifact.d.ts +6 -1
- package/dist/bench/l8/artifact.js +2 -27
- package/dist/bench/l8/escape.d.ts +3 -3
- package/dist/bench/l8/index.d.ts +1 -1
- package/dist/bench/s1/arms.d.ts +3 -3
- package/dist/bench/s1/oracle.d.ts +2 -2
- package/dist/bench/s1/reviewer.d.ts +1 -1
- package/dist/bench/s1/row.d.ts +5 -5
- package/dist/bench/s1/runner-ctx.d.ts +3 -3
- package/dist/boot/config-center.d.ts +14 -7
- package/dist/boot/config-center.js +2 -0
- package/dist/boot/coordinators.d.ts +4 -4
- package/dist/boot/crash-last.d.ts +1 -1
- package/dist/boot/device-lane.d.ts +3 -3
- package/dist/boot/engine-lease.d.ts +4 -4
- package/dist/boot/governance-seams.d.ts +5 -5
- package/dist/boot/leader.d.ts +5 -5
- package/dist/boot/limit-sync.d.ts +1 -1
- package/dist/boot/memory-boundary.d.ts +5 -5
- package/dist/boot/memory-consolidation.d.ts +8 -2
- package/dist/boot/memory-consolidation.js +1 -0
- package/dist/boot/org-memory.d.ts +5 -5
- package/dist/boot/parked-revive-gate.d.ts +6 -6
- package/dist/boot/permission-rules-audit.d.ts +2 -2
- package/dist/boot/reapers.d.ts +8 -8
- package/dist/boot/resolve-spec.d.ts +4 -4
- package/dist/boot/retention-lane.d.ts +1 -1
- package/dist/boot/runner-deps.d.ts +33 -27
- package/dist/boot/runner-deps.js +2 -1
- package/dist/boot/runtime-caps.d.ts +4 -4
- package/dist/boot/session-faces.d.ts +1 -1
- package/dist/boot/shutdown.d.ts +10 -10
- package/dist/boot/side-query-lane.d.ts +14 -14
- package/dist/boot/stores.js +5 -0
- package/dist/boot/task-list-lane.d.ts +3 -3
- package/dist/boot/webfetch-summarize-lane.d.ts +9 -9
- package/dist/boot/workflow-orchestration.d.ts +1 -1
- package/dist/bounded-session-map.d.ts +1 -1
- package/dist/brain.d.ts +3 -3
- package/dist/budget.d.ts +3 -3
- package/dist/canonical-json.d.ts +53 -0
- package/dist/canonical-json.js +48 -0
- package/dist/capabilities/center-prompts.d.ts +13 -13
- package/dist/capabilities/collab-workflows.d.ts +1 -1
- package/dist/capabilities/hands-lane.d.ts +4 -4
- package/dist/capabilities/memory-notice.d.ts +4 -4
- package/dist/capabilities/prompt.d.ts +2 -2
- package/dist/capabilities/sandbox-file-send.d.ts +2 -2
- package/dist/capabilities/scenarios.d.ts +16 -16
- package/dist/capabilities/skills.d.ts +1 -1
- package/dist/capabilities/team.d.ts +3 -3
- package/dist/capabilities/tool-defer.d.ts +6 -6
- package/dist/config-catalog.d.ts +139 -0
- package/dist/config-catalog.js +556 -0
- package/dist/config-center/apply-effective.d.ts +20 -7
- package/dist/config-center/apply-effective.js +45 -0
- package/dist/config-center/apply-ledger.d.ts +6 -6
- package/dist/config-center/facade.d.ts +3 -2
- package/dist/config-center/hot-keys-registry.d.ts +2 -2
- package/dist/config-center/http-client.d.ts +5 -5
- package/dist/config-center/mcp-revocation.d.ts +6 -4
- package/dist/config-center/mcp-revocation.js +2 -12
- package/dist/config-center/restart-signal.d.ts +11 -1
- package/dist/config-center/restart-signal.js +1 -1
- package/dist/config-center/skills-mcp.d.ts +2 -2
- package/dist/config-center/stage-limits.d.ts +3 -3
- package/dist/config-center/types.d.ts +23 -19
- package/dist/config-invariants.d.ts +1 -1
- package/dist/config-provider.d.ts +2 -2
- package/dist/config-types.d.ts +140 -132
- package/dist/config.d.ts +22 -22
- package/dist/config.js +2 -1
- package/dist/degenerate-instrument.d.ts +1 -1
- package/dist/deployment-governance.d.ts +13 -13
- package/dist/device-store.d.ts +2 -2
- package/dist/device-ws-hub.d.ts +3 -3
- package/dist/device-ws-protocol.d.ts +3 -3
- package/dist/digest-form.d.ts +1 -1
- package/dist/elicitation.d.ts +1 -1
- package/dist/env-facts.d.ts +7 -7
- package/dist/execution-lane-caps.d.ts +5 -5
- package/dist/fleet/fleet-bus.d.ts +53 -53
- package/dist/fleet/fleet-reconciler.d.ts +2 -2
- package/dist/fleet/fleet-terminal-window.d.ts +1 -1
- package/dist/fleet/subagent-tail-bus.d.ts +3 -3
- package/dist/fleet-client.d.ts +3 -3
- package/dist/fleet-lease.d.ts +1 -1
- package/dist/hooks/branch-transcript.d.ts +2 -2
- package/dist/hooks/cc-agent-hook-prompt.d.ts +2 -2
- package/dist/hooks/cc-stop-prompt.d.ts +2 -2
- package/dist/hooks/hook-llm.d.ts +1 -1
- package/dist/hooks/hook-runner.d.ts +5 -5
- package/dist/http/active-run-conflict.d.ts +31 -33
- package/dist/http/active-run-conflict.js +4 -2
- package/dist/http/route-ctx.d.ts +22 -22
- package/dist/http/routes/a2a-serve.d.ts +2 -2
- package/dist/http/routes/admin-config-refresh.d.ts +1 -1
- package/dist/http/routes/admin-drain.d.ts +4 -4
- package/dist/http/routes/admin-memory-optout.d.ts +5 -5
- package/dist/http/routes/adoption.d.ts +1 -1
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/approvals-assistant.d.ts +6 -6
- package/dist/http/routes/approvals-assistant.js +4 -1
- package/dist/http/routes/capabilities.d.ts +1 -1
- package/dist/http/routes/capabilities.js +1 -0
- package/dist/http/routes/config-catalog.d.ts +28 -0
- package/dist/http/routes/config-catalog.js +42 -0
- package/dist/http/routes/diagnostics.d.ts +2 -2
- package/dist/http/routes/fleet.d.ts +1 -1
- package/dist/http/routes/images.d.ts +1 -1
- package/dist/http/routes/leader.d.ts +1 -1
- package/dist/http/routes/memory-bundle.d.ts +4 -4
- package/dist/http/routes/memory-compliance.d.ts +7 -7
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +9 -9
- package/dist/http/routes/memory-policy.d.ts +3 -3
- package/dist/http/routes/notify-wake.d.ts +1 -1
- package/dist/http/routes/observability.d.ts +1 -1
- package/dist/http/routes/retention-ops.d.ts +1 -1
- package/dist/http/routes/rules.d.ts +3 -3
- package/dist/http/routes/run-memory-capture.d.ts +1 -1
- package/dist/http/routes/runs.d.ts +3 -3
- package/dist/http/routes/runs.js +12 -17
- package/dist/http/routes/session-sync.d.ts +2 -2
- package/dist/http/routes/sessions-list.d.ts +1 -1
- package/dist/http/routes/sessions.d.ts +9 -1
- package/dist/http/routes/sessions.js +60 -0
- package/dist/http/routes/shared-memory.d.ts +1 -1
- package/dist/http/routes/side-query.d.ts +1 -1
- package/dist/http/routes/tasks.d.ts +1 -1
- package/dist/http/routes/trace-usage.d.ts +1 -1
- package/dist/http/routes/workflows.d.ts +1 -1
- package/dist/http/run-meta.d.ts +1 -1
- package/dist/http/send.d.ts +6 -6
- package/dist/http/server.d.ts +84 -67
- package/dist/http/server.js +20 -10
- package/dist/http/sse-lifecycle.d.ts +1 -1
- package/dist/http/sse-log.d.ts +6 -6
- package/dist/http/verify-rounds.d.ts +3 -3
- package/dist/http/wire-gate.d.ts +2 -2
- package/dist/http/wire-types.d.ts +38 -38
- package/dist/key-resolver.d.ts +1 -1
- package/dist/leader/diffout.d.ts +2 -2
- package/dist/leader/diffup.d.ts +1 -1
- package/dist/leader/endpoint.d.ts +1 -1
- package/dist/leader/fanout.d.ts +6 -6
- package/dist/leader/grader-env-factory.d.ts +1 -1
- package/dist/leader/leader.d.ts +12 -12
- package/dist/leader/merge.d.ts +3 -3
- package/dist/leader/planner.d.ts +5 -5
- package/dist/leader/repair-oracle.d.ts +1 -1
- package/dist/leader/wire.d.ts +9 -9
- package/dist/lsp/manager.d.ts +2 -2
- package/dist/lsp/types.d.ts +1 -1
- package/dist/lsp/ws-transport.d.ts +2 -2
- package/dist/main.js +12 -2
- package/dist/mcp-content-origin.d.ts +1 -1
- package/dist/memory-bundle-engine.d.ts +5 -3
- package/dist/memory-bundle-engine.js +2 -2
- package/dist/memory-operator-faces.d.ts +41 -11
- package/dist/memory-operator-faces.js +12 -0
- package/dist/memory-origin-fence.d.ts +1 -1
- package/dist/memory-origin-fence.js +2 -13
- package/dist/memory-posture.d.ts +6 -6
- package/dist/memory-scope.d.ts +7 -7
- package/dist/model-select.d.ts +5 -5
- package/dist/observability/cost-quota.d.ts +6 -6
- package/dist/observability/cost-taxonomy.d.ts +2 -2
- package/dist/observability/fail-open.d.ts +1 -5
- package/dist/observability/fail-open.js +0 -4
- package/dist/observability/metrics.d.ts +1 -1
- package/dist/observability/prompt-manifest.d.ts +8 -8
- package/dist/observability/rate-limit.d.ts +2 -2
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/tool-trace.d.ts +1 -1
- package/dist/orchestration/hardened-vm-runner.d.ts +6 -6
- package/dist/orchestration/hardened-vm-worker-runner.d.ts +1 -1
- package/dist/orchestration/subagent-steer.d.ts +3 -3
- package/dist/orchestration/workflow-agent-steer.d.ts +1 -1
- package/dist/orchestration/workflow-completion-inbox.d.ts +6 -6
- package/dist/orchestration/workflow-notify-journal.d.ts +6 -6
- package/dist/parent-watch.d.ts +1 -1
- package/dist/parked-decide.d.ts +11 -11
- package/dist/plan-cache-probe.d.ts +1 -1
- package/dist/plugins/adoption-log-sql.d.ts +4 -4
- package/dist/plugins/approval-ask-store-memory.d.ts +1 -1
- package/dist/plugins/approval-ask-store-memory.js +12 -0
- package/dist/plugins/approval-ask-store-sql.d.ts +39 -17
- package/dist/plugins/approval-ask-store-sql.js +23 -6
- package/dist/plugins/approval-payload-fingerprint.d.ts +23 -0
- package/dist/plugins/approval-payload-fingerprint.js +23 -0
- package/dist/plugins/background-agent-store-sql.d.ts +8 -8
- package/dist/plugins/background-shell-support.d.ts +12 -12
- package/dist/plugins/blob-backend.d.ts +3 -3
- package/dist/plugins/breaker-state-sql.d.ts +3 -3
- package/dist/plugins/caching-session-store.d.ts +6 -6
- package/dist/plugins/checkpoint-store-sql.d.ts +162 -66
- package/dist/plugins/checkpoint-store-sql.js +76 -33
- package/dist/plugins/device-store-sql.d.ts +4 -3
- package/dist/plugins/e2b-orphan-reclaim.d.ts +3 -3
- package/dist/plugins/file-history-store-sql.d.ts +9 -8
- package/dist/plugins/file-run-store.d.ts +27 -27
- package/dist/plugins/fork-routing-session-store.d.ts +9 -9
- package/dist/plugins/image-bake-store-sql.d.ts +1 -1
- package/dist/plugins/image-index-sql.d.ts +2 -2
- package/dist/plugins/k8s-bg-scripts.d.ts +1 -1
- package/dist/plugins/k8s-exec-protocol.d.ts +1 -1
- package/dist/plugins/leader-run-store-sql.d.ts +1 -1
- package/dist/plugins/local-checkpoint-store.d.ts +26 -17
- package/dist/plugins/local-checkpoint-store.js +21 -11
- package/dist/plugins/local-session-store.d.ts +5 -5
- package/dist/plugins/mailbox-store-sql.d.ts +6 -6
- package/dist/plugins/memory-embedder-fingerprint.d.ts +2 -2
- package/dist/plugins/memory-engine-pg.d.ts +1 -1
- package/dist/plugins/memory-engine-tidb.d.ts +1 -1
- package/dist/plugins/memory-key-guards.d.ts +3 -3
- package/dist/plugins/memory-optout-grant-store-sql.d.ts +10 -10
- package/dist/plugins/memory-origin-law.d.ts +13 -13
- package/dist/plugins/memory-run-store.d.ts +12 -12
- package/dist/plugins/outcome-ledger-sql.d.ts +3 -3
- package/dist/plugins/permission-rule-store-file.d.ts +3 -3
- package/dist/plugins/permission-rule-store-sql.d.ts +38 -33
- package/dist/plugins/permission-rule-store-sql.js +7 -12
- package/dist/plugins/pg-cost-quota.d.ts +2 -2
- package/dist/plugins/pg-pool.js +5 -0
- package/dist/plugins/pg-query.d.ts +1 -1
- package/dist/plugins/pg-rate-limiter.d.ts +2 -2
- package/dist/plugins/pg-session-storage.d.ts +9 -9
- package/dist/plugins/remote-env-adb.d.ts +1 -1
- package/dist/plugins/remote-env-device.d.ts +2 -2
- package/dist/plugins/remote-env-e2b.d.ts +11 -11
- package/dist/plugins/remote-env-file-error.d.ts +2 -2
- package/dist/plugins/remote-env-host.d.ts +10 -10
- package/dist/plugins/remote-env-k8s.d.ts +7 -7
- package/dist/plugins/remote-env-local-docker.d.ts +1 -1
- package/dist/plugins/remote-env-ssh.d.ts +9 -9
- package/dist/plugins/remote-scratchpad.d.ts +1 -1
- package/dist/plugins/resume-anchor-store-sql.d.ts +1 -1
- package/dist/plugins/retention-lane-store-sql.d.ts +2 -2
- package/dist/plugins/retention-store-sql.d.ts +11 -11
- package/dist/plugins/roster-store-sql.d.ts +5 -5
- package/dist/plugins/run-store-sql.d.ts +12 -12
- package/dist/plugins/scheduler-support.d.ts +1 -1
- package/dist/plugins/send-user-file.d.ts +1 -1
- package/dist/plugins/session-capture-record-store-sql.d.ts +99 -0
- package/dist/plugins/session-capture-record-store-sql.js +110 -0
- package/dist/plugins/session-placement.d.ts +1 -1
- package/dist/plugins/session-policy-store-sql.d.ts +2 -2
- package/dist/plugins/session-store.d.ts +3 -3
- package/dist/plugins/shared-memory-store-sql.d.ts +5 -5
- package/dist/plugins/sql-driver.d.ts +7 -7
- package/dist/plugins/sql-errors.d.ts +2 -2
- package/dist/plugins/sql-escape.d.ts +1 -1
- package/dist/plugins/sql-row-helpers.d.ts +1 -1
- package/dist/plugins/store-backend.d.ts +32 -19
- package/dist/plugins/store-backend.js +4 -0
- package/dist/plugins/store-contracts.d.ts +9 -9
- package/dist/plugins/task-list-store-sql.d.ts +3 -3
- package/dist/plugins/tidb-cost-quota.d.ts +3 -3
- package/dist/plugins/tidb-pool.js +9 -0
- package/dist/plugins/tidb-rate-limiter.d.ts +2 -2
- package/dist/plugins/tidb-session-storage.d.ts +2 -2
- package/dist/plugins/tidb-session-store.d.ts +11 -11
- package/dist/plugins/tool-result-store-sql.d.ts +8 -8
- package/dist/plugins/usage-window-store-sql.d.ts +3 -3
- package/dist/plugins/web-search.d.ts +7 -7
- package/dist/plugins/workflow-journal-store-sql.d.ts +6 -6
- package/dist/plugins/workflow-run-store-sql.d.ts +1 -1
- package/dist/plugins/write-behind-counter.d.ts +6 -6
- package/dist/principal-jwt.d.ts +2 -2
- package/dist/project-memory.d.ts +1 -1
- package/dist/prompts-domain-validate.d.ts +8 -8
- package/dist/question.d.ts +3 -3
- package/dist/resource-suspend.d.ts +4 -4
- package/dist/resource-window.d.ts +3 -3
- package/dist/router/route-orchestration.d.ts +1 -1
- package/dist/rules-consent.d.ts +48 -40
- package/dist/run-local.d.ts +5 -5
- package/dist/runs.d.ts +19 -19
- package/dist/runtime-caps-resolver.d.ts +6 -6
- package/dist/runtime-governance.d.ts +7 -7
- package/dist/security.d.ts +13 -13
- package/dist/session-leaf-bus.d.ts +1 -1
- package/dist/session-sync-content.d.ts +4 -4
- package/dist/session-sync-kernel.d.ts +2 -2
- package/dist/session-sync.d.ts +13 -13
- package/dist/session-titler.d.ts +1 -1
- package/dist/session-watch.d.ts +3 -3
- package/dist/shared-memory-scope-authorizer.d.ts +4 -4
- package/dist/sighup-idle.d.ts +1 -1
- package/dist/spec-fields.d.ts +20 -20
- package/dist/ssh-host-key.d.ts +5 -5
- package/dist/store-live-probe.d.ts +2 -2
- package/dist/task-cwd.d.ts +11 -11
- package/dist/task-mcp.d.ts +5 -5
- package/dist/task-settings.d.ts +35 -35
- package/dist/task-workflow.d.ts +3 -3
- package/dist/text-bidi.d.ts +1 -1
- package/dist/tool-approval.d.ts +171 -160
- package/dist/tool-approval.js +33 -28
- package/dist/trace/core-keyset-guard.d.ts +19 -5
- package/dist/trace/engine-notice-wire.d.ts +6 -6
- package/dist/trace/injection-tier.d.ts +2 -2
- package/dist/trace/ledger-events.d.ts +3 -3
- package/dist/trace/ledger-sink.d.ts +7 -7
- package/dist/trace/project.d.ts +30 -30
- package/dist/turn-activity.d.ts +4 -4
- package/dist/usage-analytics.d.ts +1 -1
- package/dist/wall-clock-jump-guard.d.ts +3 -3
- package/package.json +5 -5
package/dist/leader/leader.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* v2 MVP M4 — the leader orchestrator (
|
|
2
|
+
* v2 MVP M4 — the leader orchestrator ([ref] §3, V2-MVP-PLAN.md). Composes the proven pieces into one
|
|
3
3
|
* callable API: Planner → fanOut (M1) → diff-out (M2) → merge(b) (M3) → Coordinator push.
|
|
4
4
|
*
|
|
5
|
-
* Worker-env model (
|
|
5
|
+
* Worker-env model ([ref] §8 F2(a)): preferred = FACTORY env (runner-owned lifecycle; durable suspend only
|
|
6
6
|
* yields a complete ownedEnv on this path) + diff-out via the worker's mandatory SELF-UPLOAD last step
|
|
7
7
|
* (`fetchDiff`, diffup.ts). Compat = the original static env the leader owns: provision up-front, pull each
|
|
8
8
|
* branch's diff OUT of the still-alive env (pullDiff), destroy every env in a `finally`.
|
|
@@ -16,7 +16,7 @@ import { type RunnerLike, type WorkerReport } from "./fanout.js";
|
|
|
16
16
|
import { type ExecStreamLike } from "./diffout.js";
|
|
17
17
|
import { type MergeDeps, type MergeResult } from "./merge.js";
|
|
18
18
|
import { type TaskSpec, type VerifyConfig, type CheckpointToken, type ToolSpec, type RepairTerminal, type OracleTier, type RepairResult } from "@sema-agent/core";
|
|
19
|
-
/**
|
|
19
|
+
/** [ref] Slice 6: drive a worker's resource-suspend auto-resume to a terminal (or bound) state. Exported
|
|
20
20
|
* for unit tests. Loops `resume(token, slice)` WHILE the result carries a `resource_limit` checkpoint gate —
|
|
21
21
|
* NOT by status (the verify wrapper may surface a suspend as failed-with-token). Exits on: a terminal result
|
|
22
22
|
* (completed/failed → no gate), an exhausted budget (core fails the resume fast → no token/gate), a
|
|
@@ -44,16 +44,16 @@ export interface ProvisionedWorker {
|
|
|
44
44
|
branch: string;
|
|
45
45
|
/** base commit of THIS worker's env (drives `git format-patch <baseSha>..<branch>` diff-out). */
|
|
46
46
|
baseSha: string;
|
|
47
|
-
/** runs the worker agent on this worker's env (static `executionEnv` or a factory —
|
|
47
|
+
/** runs the worker agent on this worker's env (static `executionEnv` or a factory — [ref] F2(a)). */
|
|
48
48
|
runner: RunnerLike;
|
|
49
49
|
/** Static-env mode (M2 compat): pull the worker's branch diff OUT of its (post-task, still-alive) env. */
|
|
50
50
|
diffEnv?: ExecStreamLike;
|
|
51
|
-
/** Factory-env mode (
|
|
51
|
+
/** Factory-env mode ([ref] F2(a), preferred when set): fetch the diff the worker SELF-UPLOADED as its
|
|
52
52
|
* mandatory last task step (presigned MinIO object) — the env is runner-owned and already gone. */
|
|
53
53
|
fetchDiff?: () => Promise<import("./diffout.js").PullDiffResult>;
|
|
54
54
|
/** Static-env mode only: the leader owns + destroys the env. Factory envs omit this — the runner's factory
|
|
55
55
|
* lifecycle destroys them, and a SUSPENDED worker's paused env is thereby exempt from the leader's reap
|
|
56
|
-
* (
|
|
56
|
+
* ([ref] row4/C4: destroying a suspended worker's env = expiring its resume token). */
|
|
57
57
|
destroy?: () => Promise<void>;
|
|
58
58
|
spec: Omit<TaskSpec, "sessionId" | "signal">;
|
|
59
59
|
/** Optional read-effect PROBE tools for the L3 verifier (verifyWorker path). The default verifierTools = the
|
|
@@ -71,7 +71,7 @@ export interface LeaderDeps {
|
|
|
71
71
|
push: MergeDeps["push"];
|
|
72
72
|
/** Integration test command (the merge gate) + repo dir inside the sandbox. */
|
|
73
73
|
testCmd: string;
|
|
74
|
-
/** Optional truecorrect MEASURE (
|
|
74
|
+
/** Optional truecorrect MEASURE ([ref]): a thorough hidden-oracle command run IN the integration sandbox
|
|
75
75
|
* after the gate passes (NOT a gate) — offloads the measure from the control plane. Result in result.merge.measure. */
|
|
76
76
|
measureCmd?: string;
|
|
77
77
|
repoDir?: string;
|
|
@@ -80,7 +80,7 @@ export interface LeaderDeps {
|
|
|
80
80
|
/** fan-out deadline + concurrency cap. */
|
|
81
81
|
timeoutMs: number;
|
|
82
82
|
maxConcurrency: number;
|
|
83
|
-
/**
|
|
83
|
+
/** [ref] L3a — optional per-module sub-gate + bounded repair, run AFTER fan-out, BEFORE merge. For each
|
|
84
84
|
* completed worker: judge its module (diff) vs its sub-objective; on fail, re-run that ONE worker with the
|
|
85
85
|
* judge's feedback (bounded by maxRepairs, default 1) on its own still-alive env, then re-judge. A module that
|
|
86
86
|
* still fails is marked `failed` (merge quarantines it). Catches per-module escapes the end-integration test
|
|
@@ -93,12 +93,12 @@ export interface LeaderDeps {
|
|
|
93
93
|
repairObjective: (sub: SubtaskSpec, reason: string) => string;
|
|
94
94
|
maxRepairs?: number;
|
|
95
95
|
};
|
|
96
|
-
/** core 1.72 native L3a (
|
|
96
|
+
/** core 1.72 native L3a ([ref] §4): when set, each worker runs via `runWithVerification` (run the module +
|
|
97
97
|
* an INDEPENDENT DECORRELATED verifier tries to break it reading the diff/workspace + a bounded fix-loop)
|
|
98
98
|
* instead of plain fan-out. The worker runner's `models` catalog MUST carry the heterogeneous `verifierModel`
|
|
99
99
|
* (decorrelation = deployment contract). Mutually exclusive with `moduleGate` (this IS the native version). */
|
|
100
100
|
verifyWorker?: VerifyConfig;
|
|
101
|
-
/** Replan-lite (
|
|
101
|
+
/** Replan-lite ([ref] §6): bounded, DETERMINISTIC reactions — no runtime DAG surgery. When set:
|
|
102
102
|
* worker failed → redispatch ×1 on a FRESH env (clean base; a crashed worker's half-written workspace is
|
|
103
103
|
* never reused) → still failed = collapse-remainder-to-single; verify FAIL (repair already bounded inside
|
|
104
104
|
* the verify loop) → collapse; structural merge conflict → collapse + record; budgetUsd exceeded → stop
|
|
@@ -151,7 +151,7 @@ export interface LeaderResult {
|
|
|
151
151
|
route?: "single" | "fanout";
|
|
152
152
|
/** Set when planning/provisioning failed before fan-out. */
|
|
153
153
|
error?: string;
|
|
154
|
-
/** Replan-lite (
|
|
154
|
+
/** Replan-lite ([ref] §6): which trigger won arbitration + what was done. */
|
|
155
155
|
replan?: {
|
|
156
156
|
trigger: "suspended" | "budget" | "merge-conflict" | "verify-fail" | "worker-failed";
|
|
157
157
|
redispatched?: string[];
|
|
@@ -163,7 +163,7 @@ export interface LeaderResult {
|
|
|
163
163
|
workerId: string;
|
|
164
164
|
sessionId: string;
|
|
165
165
|
}>;
|
|
166
|
-
/**
|
|
166
|
+
/** [ref] Slice 6 / task#16: the diff (uncommitted work auto-committed by the belt, then diff-out) of
|
|
167
167
|
* workers that did NOT merge (failed / still-suspended). Their progress is otherwise lost — the merge only
|
|
168
168
|
* integrates COMPLETED workers — so surface it here for review/cherry-pick instead of silently dropping it
|
|
169
169
|
* (the migration-run loss: a network-failed worker's 4 commits vanished). Best-effort + non-empty only. */
|
package/dist/leader/merge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* v2 MVP M3 — merge(b), the hard bone (
|
|
2
|
+
* v2 MVP M3 — merge(b), the hard bone ([ref] §7, V2-MVP-PLAN.md, search [25]/[26], council round-1).
|
|
3
3
|
*
|
|
4
4
|
* The deterministic Coordinator integrates N completed workers' branches under FULL isolation:
|
|
5
5
|
* 1. pull each worker's patch OUT of its container (M2 `pullDiff` — no creds go in).
|
|
@@ -65,7 +65,7 @@ export interface IntegrationRepair {
|
|
|
65
65
|
* then VERIFIES no marker/.rej remains before continuing, and the downstream test gate still guards correctness.
|
|
66
66
|
* Wired by the caller (provisionIntegrationSandbox); when unset, an apply conflict stays terminal exactly as before
|
|
67
67
|
* (zero behaviour change). Reuses the IntegrationRepair sandbox + hands pattern → no new core/env seam (the seam
|
|
68
|
-
*
|
|
68
|
+
* [ref] §8 feared for "adopting N half-done workspaces" is unnecessary for the conflict case).
|
|
69
69
|
*/
|
|
70
70
|
export interface ConflictResolver {
|
|
71
71
|
/** Max resolution attempts before giving up (each = one agent run + one marker/.rej re-check). */
|
|
@@ -112,7 +112,7 @@ export interface MergeDeps {
|
|
|
112
112
|
repoDir?: string;
|
|
113
113
|
/** Full test command run in the sandbox (the merge gate). */
|
|
114
114
|
testCmd: string;
|
|
115
|
-
/** Optional truecorrect MEASURE (
|
|
115
|
+
/** Optional truecorrect MEASURE ([ref]): a thorough hidden-oracle command run IN the integration sandbox
|
|
116
116
|
* (E2B) right after the gate passes — offloads the measure from the CPU-contended control plane (the
|
|
117
117
|
* frontier-multi oracle-timeout fix). NOT a gate (does not affect `ok`); the result lands in MergeResult.measure
|
|
118
118
|
* for the caller to read as the objective truly-correct signal. Same place + env as the gate, just a thornier test. */
|
package/dist/leader/planner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* v2 MVP — LLM Planner (
|
|
2
|
+
* v2 MVP — LLM Planner ([ref] §3: leader = LLM-planner that splits a DAG + deterministic Coordinator).
|
|
3
3
|
* Decomposes an objective into N **disjoint-file** sub-tasks via one model completion, then VALIDATES the plan
|
|
4
4
|
* deterministically (the trust boundary: an LLM proposes, the Coordinator enforces — service[19] leaderless-
|
|
5
5
|
* leader). Disjoint file-ownership is the invariant that lets workers run in parallel + merge without conflict.
|
|
@@ -14,17 +14,17 @@ export interface PlanOptions {
|
|
|
14
14
|
maxSubtasks?: number;
|
|
15
15
|
/** Extra repo/context guidance appended to the prompt (e.g. file layout, conventions). */
|
|
16
16
|
context?: string;
|
|
17
|
-
/** Deployment knob (
|
|
17
|
+
/** Deployment knob ([ref] §11 A6, correctness-first): `false` = never fan out — `routePlan` skips the
|
|
18
18
|
* router model call entirely and returns the deterministic single route (zero routing cost, zero risk of a
|
|
19
19
|
* false fan-out). Default (undefined/true) = the router decides. */
|
|
20
20
|
fanoutEnabled?: boolean;
|
|
21
|
-
/** Economic guard threshold (
|
|
21
|
+
/** Economic guard threshold ([ref] §7, search[83] ruling): an objective SHORTER than this never reaches
|
|
22
22
|
* the router — deterministic single (a small task can't be economically decomposable; false-single is the
|
|
23
23
|
* cheap error side). Default 64 — deliberately below the route corpus's smallest fan-out case. */
|
|
24
24
|
minFanoutChars?: number;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Deterministic economic 防灾 guard (
|
|
27
|
+
* Deterministic economic 防灾 guard ([ref] §7 / §11 D2, search [83] ruling (b)): the asymmetry is that a
|
|
28
28
|
* false fan-out is the -98% disaster while a false single merely runs slower — so every case decidable WITHOUT
|
|
29
29
|
* the model resolves to single, for free. Pure function (unit-testable); the semantic judgments (sequential/
|
|
30
30
|
* coupled/uncertain) stay with the router LLM, and "估不准回 single" is the collapse fallback (B3).
|
|
@@ -65,7 +65,7 @@ export declare function routePrompt(objective: string, opts?: PlanOptions): stri
|
|
|
65
65
|
* validated by `parsePlan` (the same disjointness/shape invariants the Coordinator depends on). */
|
|
66
66
|
export declare function routePlan(objective: string, runRoute: (prompt: string) => Promise<string>, opts?: PlanOptions): Promise<SubtaskSpec[]>;
|
|
67
67
|
/**
|
|
68
|
-
* Decomposer quality gate (
|
|
68
|
+
* Decomposer quality gate ([ref] §5/§11 B1-B3): run the router, and on a rejected/unparseable plan retry
|
|
69
69
|
* the LLM AT MOST ONCE, then COLLAPSE TO SINGLE (never fail the task on a bad plan — single is almost always
|
|
70
70
|
* the right fallback, and a false fan-out is the -98% disaster; a plan failure must not be louder than that).
|
|
71
71
|
* `collapsed` carries the reason (observability: a collapse is a router-quality signal, not silent).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The PROFILE-injected `RepairOracle` closure for the leader's single-agent self-repair loop
|
|
3
|
-
* (`runRepairLoop`, core
|
|
3
|
+
* (`runRepairLoop`, core [ref] / D1). See `sema-internal server/docs/LEADER-REPAIRLOOP-INTEGRATION.md` (§3.1 + the authoritative
|
|
4
4
|
* §10 corrected layer). The closure GRADES a worker's candidate in an ISOLATED grader env (the reused
|
|
5
5
|
* integration sandbox, distinct from the worker env) and maps the result to a core `OracleResult`. core only
|
|
6
6
|
* fixes the `OracleResult` shape + the read-only/identity contract; the composition lives HERE so the core type
|
package/dist/leader/wire.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ import type { LeaderRequestBody } from "./endpoint.js";
|
|
|
5
5
|
export interface LeaderWireConfig {
|
|
6
6
|
/** Static-env compat mode (E2B only): the leader provisions/owns each env. Required when `envFactory` unset. */
|
|
7
7
|
e2bApiKey?: string;
|
|
8
|
-
/**
|
|
8
|
+
/** [ref] F2(a) + k8s lane: the per-task execution-env factory the service main already built for
|
|
9
9
|
* REMOTE_EXEC (e2b or k8s/Kata) — workers and the integration sandbox run on envs from THIS factory.
|
|
10
10
|
* Requires `s3` (diff-out is the worker's self-upload; there is no leader-held env to pull from). */
|
|
11
11
|
envFactory?: ExecutionEnvFactory;
|
|
12
|
-
/** Durable suspend/resume for SUB-WORKERS (
|
|
12
|
+
/** Durable suspend/resume for SUB-WORKERS ([ref] C4): when set, each worker task carries the durable
|
|
13
13
|
* question/ask policy + checkpoint store, so a gated ask/AskUserQuestion SUSPENDS the worker (checkpoint +
|
|
14
14
|
* paused env) instead of failing — the trigger replan-lite C4 arbitrates on. Mirrors main.ts's per-task
|
|
15
15
|
* durable wiring; ctx is seeded at provision so the surfaced token is resumable on the single-agent path. */
|
|
@@ -31,7 +31,7 @@ export interface LeaderWireConfig {
|
|
|
31
31
|
* the resume dies with SessionError "Entry <leafId> not found" (found live: drill c3 deny path). */
|
|
32
32
|
sessionStore?: SessionStore;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* [ref] 件B/C/D([ref],codex R2-F1)—— 部署治理三座席,**原样递给本车道的每一只 Runner**。
|
|
35
35
|
* 主车道的 `boot/governance-seams.ts` 是唯一属主(判据、拒启、解析全在那里),本字段只是把它的产物
|
|
36
36
|
* 搬过来:一个进程里「这台部署禁哪些能力、锁了哪些键」只能有一个答案。缺席 = 与接线前逐字相同。
|
|
37
37
|
*/
|
|
@@ -48,7 +48,7 @@ export interface LeaderWireConfig {
|
|
|
48
48
|
name: string;
|
|
49
49
|
email: string;
|
|
50
50
|
};
|
|
51
|
-
/**
|
|
51
|
+
/** [ref] A6 knob: false = router never fans out (deterministic single route, zero router cost). */
|
|
52
52
|
fanoutEnabled?: boolean;
|
|
53
53
|
/** The model (a catalog name) the ROUTER/planner call runs on. The route is a trivial single-vs-fanout
|
|
54
54
|
* classification; running it on a heavy reasoning model (deepseek-v4-pro + reasoning) returns an EMPTY
|
|
@@ -65,7 +65,7 @@ export interface LeaderWireConfig {
|
|
|
65
65
|
* Env override: LEADER_CONFLICT_ROUNDS. Resolves the conflict in-place + keeps the other workers' work, instead
|
|
66
66
|
* of discarding all fan-out output and redoing single. Runs the strong (default) model with hands in the sandbox. */
|
|
67
67
|
conflictRounds?: number;
|
|
68
|
-
/**
|
|
68
|
+
/** [ref] §8 F2(a): when set, workers run on FACTORY envs (runner-owned lifecycle — the durable-suspend-
|
|
69
69
|
* complete path; a suspended worker's paused env is exempt from the leader reap by construction) and diff-out
|
|
70
70
|
* is the worker's mandatory self-upload to this MinIO/S3 store (presigned per worker; creds adapter-held).
|
|
71
71
|
* Unset = the original leader-owned static-env mode (pullDiff compat). */
|
|
@@ -85,11 +85,11 @@ export interface LeaderWireConfig {
|
|
|
85
85
|
/** The env surface wire needs (both the E2B and k8s adapters implement core's RemoteExecutionEnv). */
|
|
86
86
|
type WireEnv = Pick<RemoteExecutionEnv, "exec" | "writeFile">;
|
|
87
87
|
/**
|
|
88
|
-
* Resume-safe worker staging (the
|
|
88
|
+
* Resume-safe worker staging (the [ref] F2(a) factory-env path). Runs adapter-side before the agent's
|
|
89
89
|
* first workspace-touching call: seed the base repo at the worker branch + plant the upload script (so the
|
|
90
90
|
* presigned URL never passes through the model).
|
|
91
91
|
*
|
|
92
|
-
* 🔴 BL-1 fix (
|
|
92
|
+
* 🔴 BL-1 fix ([ref] Slice 6): on a RESOURCE-SUSPEND RESUME core re-invokes the `executionEnvFactory`,
|
|
93
93
|
* producing a FRESH `withStaging` wrapper (`staged=undefined`) whose `stage()` runs AGAIN — AFTER core's
|
|
94
94
|
* `resumeVM()` has already untar'd the snapshot onto the fresh pod (`resumeVM` is not a STAGED_METHOD, so it
|
|
95
95
|
* is NOT intercepted by the staging proxy; the agent's first `exec` is what triggers `stage()`, lazily, and
|
|
@@ -134,7 +134,7 @@ export declare function leaderResourceConfig(env?: NodeJS.ProcessEnv): {
|
|
|
134
134
|
workerBudgetUsd: number;
|
|
135
135
|
workerLimits: Partial<TaskSpec>;
|
|
136
136
|
presignTtlSec: number;
|
|
137
|
-
/**
|
|
137
|
+
/** [ref] Slice 6: opt-in (LEADER_RESOURCE_SUSPEND=true) resource-slice suspend for workers. When set, a
|
|
138
138
|
* worker SUSPENDS at the per-slice window (`sliceMaxCostUsd`) instead of failing at the budget, and the
|
|
139
139
|
* leader auto-resumes (resumeWithVerification) until the TOTAL (`totalBudgetUsd` = workerBudgetUsd) is spent
|
|
140
140
|
* — a budget overrun becomes a resumable pause, not a worker failure. ⚠️ 语义更新(core 5.11.0 B3,
|
|
@@ -160,7 +160,7 @@ export interface LeaderLoopConfig {
|
|
|
160
160
|
measureGatesOn: boolean;
|
|
161
161
|
repairLoopAttempts: number;
|
|
162
162
|
oracleFlakyK: number;
|
|
163
|
-
/** replan-lite (
|
|
163
|
+
/** replan-lite ([ref] §6) fan-out spend cap from LEADER_BUDGET_USD. Absent = replan-lite's own default
|
|
164
164
|
* (unset env stays absent — existing contract untouched; see leaderLoopConfig doc below). */
|
|
165
165
|
replanBudgetUsd?: number;
|
|
166
166
|
}
|
package/dist/lsp/manager.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface E2bLspManagerOptions {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* §DESIGN-V2 F1/F8/F9 —— 本文件曾**手抄**一份 core 的 `settleOnAbort`(注释自陈 core「un-exported」,并写下
|
|
71
|
-
* 「一旦 core 导出即 find-and-delete」的计划)。
|
|
71
|
+
* 「一旦 core 导出即 find-and-delete」的计划)。[ref]([ref])执行了那句话:core 现已从包根导出它
|
|
72
72
|
* (`index.d.ts:27`,来自 `core/lsp.js`),手抄件遂删除,本文件的两处调用直接消费 core 的实现。
|
|
73
73
|
*
|
|
74
74
|
* 它的语义(读点在 `open` 的两处调用):给**这一个**调用方一个自己的 settle —— 调用方的 `signal` 让它拿到
|
|
@@ -86,7 +86,7 @@ export declare class E2bLspManager implements LspServerManager {
|
|
|
86
86
|
private readonly log;
|
|
87
87
|
private readonly hasServerCommand;
|
|
88
88
|
private readonly metrics;
|
|
89
|
-
/**
|
|
89
|
+
/** [ref] (core 1.220, board [S] ①): the workspace diagnostics registry — WORKSPACE-scoped (survives
|
|
90
90
|
* heal/evict; diagnostics belong to files, not servers), drained by the Runner at turn boundaries. Every
|
|
91
91
|
* session feeds it from `textDocument/publishDiagnostics` (the WS transport now dispatches notifications).
|
|
92
92
|
* ⚠️ ONE registry across sandboxes on this manager instance (it is per-deployment) — same posture as
|
package/dist/lsp/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* LSP sidecar — service-side types (
|
|
2
|
+
* LSP sidecar — service-side types ([ref] §13.1). core 1.82+ ships `createLspTool(manager)`
|
|
3
3
|
* + the `LspServerManager`/`LspSession`/`LspResult` SEAM (`@sema-agent/core`); the runner mounts the tool
|
|
4
4
|
* when OUR manager is wired via `RunnerDeps.lspManager`. We re-export core's seam types — SINGLE SOURCE OF TRUTH,
|
|
5
5
|
* incl. the injectable `LspTransport` (the WS-bridge connection to the language server inside E2B) + `LspReadText`.
|
|
@@ -17,7 +17,7 @@ export declare class WsLspTransport implements LspTransport {
|
|
|
17
17
|
private isClosed;
|
|
18
18
|
private keepalive;
|
|
19
19
|
private awaitingPong;
|
|
20
|
-
/**
|
|
20
|
+
/** [ref]: server→client NOTIFICATION subscribers (publishDiagnostics etc.). */
|
|
21
21
|
private readonly notificationHandlers;
|
|
22
22
|
constructor(ws: WsLike, requestTimeoutMs?: number, keepaliveMs?: number);
|
|
23
23
|
/** Manager-visible liveness (LspTransport.closed): evict + reopen instead of reusing a dead connection. */
|
|
@@ -26,7 +26,7 @@ export declare class WsLspTransport implements LspTransport {
|
|
|
26
26
|
private failAll;
|
|
27
27
|
request(method: string, params: unknown, signal?: AbortSignal): Promise<unknown>;
|
|
28
28
|
notify(method: string, params: unknown): void;
|
|
29
|
-
/**
|
|
29
|
+
/** [ref] (core 1.220): subscribe to server→client notifications; returns unsubscribe. Additive —
|
|
30
30
|
* core's diagnostics registry is the intended consumer; with no subscriber, behavior is byte-identical. */
|
|
31
31
|
onNotification(handler: (method: string, params: unknown) => void): () => void;
|
|
32
32
|
close(): Promise<void>;
|
package/dist/main.js
CHANGED
|
@@ -32,7 +32,7 @@ import { createHttpServer, explicitOperatorOk, hasServiceAuth } from "./http/ser
|
|
|
32
32
|
import { exportMemoryScope } from "./memory-export.js";
|
|
33
33
|
import { workflowModelAllowlistFor } from "./task-workflow.js";
|
|
34
34
|
import { createMemoryBundleFaces } from "./memory-bundle-engine.js";
|
|
35
|
-
import { backendOwnsControlPlane, createMemoryComplianceFaces, createMemoryOriginFaces } from "./memory-operator-faces.js";
|
|
35
|
+
import { backendOwnsControlPlane, createMemoryComplianceFaces, createMemoryOriginFaces, createSessionMemoryStatusFace } from "./memory-operator-faces.js";
|
|
36
36
|
import { performMemorySync } from "./memory-sync.js";
|
|
37
37
|
import { startOtlpExporter } from "./observability/otel-exporter.js";
|
|
38
38
|
import { HEARTBEAT_MS, backgroundAgentOutput, taskHandleOutput, taskHandleStop } from "./runs.js";
|
|
@@ -120,17 +120,23 @@ async function main() {
|
|
|
120
120
|
await configCenter.applyLocalRemoteExec();
|
|
121
121
|
const { backend, storeBackendDegraded, memoryEngine, memorySyncCursors, rosterStore, backgroundAgentStore, taskAttachmentStore, mailboxStore, memoryExportBackend, memorySyncRunner, sessionStore, breakerState, usageWindowStore, memoryPosture, taskListLane, } = await openStores({ config, logger, metrics, localRoot });
|
|
122
122
|
const instanceId = uuidv7();
|
|
123
|
-
const
|
|
123
|
+
const sessionCaptureRecordStore = backend?.sessionCaptureRecords();
|
|
124
|
+
const memoryBundleFaces = memoryEngine ? createMemoryBundleFaces(memoryEngine, { ...(sessionCaptureRecordStore !== undefined ? { captureRecordStore: sessionCaptureRecordStore } : {}) }) : undefined;
|
|
124
125
|
const memoryComplianceFaces = memoryEngine
|
|
125
126
|
? createMemoryComplianceFaces(memoryEngine, {
|
|
126
127
|
onIncident: (err) => logger.warn("memory_compliance_incident", { code: err.code ?? null, detail: err.message }),
|
|
128
|
+
...(sessionCaptureRecordStore !== undefined ? { captureRecordStore: sessionCaptureRecordStore } : {}),
|
|
127
129
|
})
|
|
128
130
|
: undefined;
|
|
129
131
|
const memoryOriginFaces = memoryEngine
|
|
130
132
|
? createMemoryOriginFaces(memoryEngine, {
|
|
131
133
|
onIncident: (err) => logger.warn("memory_origin_incident", { code: err.code ?? null, detail: err.message }),
|
|
134
|
+
...(sessionCaptureRecordStore !== undefined ? { captureRecordStore: sessionCaptureRecordStore } : {}),
|
|
132
135
|
})
|
|
133
136
|
: undefined;
|
|
137
|
+
const sessionMemoryStatusFace = memoryEngine
|
|
138
|
+
? createSessionMemoryStatusFace(memoryEngine, { ...(sessionCaptureRecordStore !== undefined ? { captureRecordStore: sessionCaptureRecordStore } : {}) })
|
|
139
|
+
: undefined;
|
|
134
140
|
const adoptionBoot = await runAdoptionBootScan({ backend, logger });
|
|
135
141
|
if (adoptionBoot.scanned > 0 || adoptionBoot.error !== undefined) {
|
|
136
142
|
logger.info("adoption_boot_scan", { ...adoptionBoot });
|
|
@@ -211,6 +217,7 @@ async function main() {
|
|
|
211
217
|
...(config.memoryProvenance !== undefined ? { provenance: config.memoryProvenance } : {}),
|
|
212
218
|
onIncident: (err) => logger.warn("memory_consolidation_incident", { code: err.code ?? null, detail: err.message }),
|
|
213
219
|
onStopDetail: (audit) => logger.warn("memory_consolidation_stop_detail", audit),
|
|
220
|
+
...(sessionCaptureRecordStore !== undefined ? { captureRecordStore: sessionCaptureRecordStore } : {}),
|
|
214
221
|
})
|
|
215
222
|
: undefined;
|
|
216
223
|
for (const w of buildConsolidationValveAudit({
|
|
@@ -246,6 +253,7 @@ async function main() {
|
|
|
246
253
|
mcpRevocations,
|
|
247
254
|
config, logger, metrics, localRoot, promptSource: configCenter.promptSource, rosterStore, backgroundAgentStore, mailboxStore, usageWindowStore, brain,
|
|
248
255
|
pricing, tracer, outcomeSink, elicitation, question, toolApproval, sessionStore, memoryEngine,
|
|
256
|
+
sessionCaptureRecordStore,
|
|
249
257
|
memorySyncRunner, toolResultStore: runnerOffloadStore, sessionPolicyStore, runtimeCapsResolver, fileHistoryStore,
|
|
250
258
|
legacyRewindBoundaryProbe: backend?.legacyRewindBoundaryProbe ? backend.legacyRewindBoundaryProbe.bind(backend) : undefined,
|
|
251
259
|
permissionRuleStore: permissionRuleStores?.provider,
|
|
@@ -610,6 +618,7 @@ async function main() {
|
|
|
610
618
|
memoryBundleImport: memoryBundleFaces ? memoryBundleFaces.importBundle : undefined,
|
|
611
619
|
memoryCompliance: memoryComplianceFaces,
|
|
612
620
|
memoryOriginFace: memoryOriginFaces,
|
|
621
|
+
sessionMemoryStatus: sessionMemoryStatusFace,
|
|
613
622
|
memoryConsolidation: memoryConsolidationFaces,
|
|
614
623
|
memoryOptOutGrant: memoryOptOutGrantStore,
|
|
615
624
|
orgMemoryDirectory: orgMemoryAdmission.directory,
|
|
@@ -662,6 +671,7 @@ async function main() {
|
|
|
662
671
|
mcpRevocations,
|
|
663
672
|
mcpRevocationState: () => configCenter.mcpRevocationState(),
|
|
664
673
|
configRefreshNow: () => configCenter.refreshNow(),
|
|
674
|
+
configCenterManagedKeys: () => configCenter.centerManagedKeys(),
|
|
665
675
|
drainState,
|
|
666
676
|
storeDegraded: storeBackendDegraded,
|
|
667
677
|
storeLiveState: storeLiveProbe ? () => storeLiveProbe.state() : undefined,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref](core 5.60.0)—— `McpServerSpec.contentOrigin` 的**闭词表单一属主**。
|
|
3
3
|
*
|
|
4
4
|
* core 给 MCP 条目开了一个**内容出处声明**座位:一台 server 的整套工具的结果算 `"local"`(部署自己
|
|
5
5
|
* 写的)/ `"execution"`(执行环境产物,`execIsExternalContent` 仍能收紧)/ `"external"`(第三方内容,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] v2-c —— `POST /v1/memory/{export,import}` 两口的**引擎接线**(core 5.40.0 [ref] v2-c)。
|
|
3
3
|
*
|
|
4
4
|
* ## 为什么需要这个模块(而不是在 main.ts 里直接 new)
|
|
5
5
|
*
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* HTTP 面诚实 501。
|
|
30
30
|
*
|
|
31
31
|
* 🔴 首版把这件事当成**运行期**事实(照常挂载,让 core 每次抛 `memory.export_incomplete` / 422),
|
|
32
|
-
* 被 codex 交叉复审驳倒(
|
|
32
|
+
* 被 codex 交叉复审驳倒([ref] 提货批 [medium],验真后修):`typeof backend.exportSnapshotOf === "function"`
|
|
33
33
|
* 是一次**属性检查**,boot 期就判得出;而且它是**永久**缺席(换后端才会变),不是瞬时状态。照旧挂着
|
|
34
34
|
* 就成了「能力位说 yes、每一次调用都确定性失败」——本仓「says yes ⟺ route works」是结构性承诺,
|
|
35
35
|
* 一个恒假的 yes 会让壳给用户开出一条走不通的迁移流程。
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* `memory.export_incomplete` —— 那是诚实的运行期拒,附录 A 单列一条。绝不在这里回落到「用通用读面拼
|
|
42
42
|
* 一个包」:core 明写那正是它拒绝生产的形(a governance-less export is the laundering shape)。
|
|
43
43
|
*/
|
|
44
|
-
import { type MemoryBackend, type MemoryExportBundle, type MemoryImportReport } from "@sema-agent/core";
|
|
44
|
+
import { type MemoryBackend, type MemoryExportBundle, type MemoryImportReport, type SessionCaptureRecordStore } from "@sema-agent/core";
|
|
45
45
|
/** 两口 HTTP 面消费的窄能力面(`ServiceDeps.memoryBundle{Export,Import}` 的实参来源)。 */
|
|
46
46
|
export interface MemoryBundleFaces {
|
|
47
47
|
exportScopes: (scopes: readonly string[]) => Promise<MemoryExportBundle>;
|
|
@@ -60,5 +60,7 @@ export interface MemoryBundleFaces {
|
|
|
60
60
|
export declare function createMemoryBundleFaces(store: {
|
|
61
61
|
backend: MemoryBackend;
|
|
62
62
|
root: string;
|
|
63
|
+
}, opts?: {
|
|
64
|
+
captureRecordStore?: SessionCaptureRecordStore;
|
|
63
65
|
}): MemoryBundleFaces | undefined;
|
|
64
66
|
//# sourceMappingURL=memory-bundle-engine.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MemoryEngine } from "@sema-agent/core";
|
|
2
|
-
export function createMemoryBundleFaces(store) {
|
|
2
|
+
export function createMemoryBundleFaces(store, opts) {
|
|
3
3
|
const b = store.backend;
|
|
4
4
|
if (typeof b.exportSnapshotOf !== "function" || typeof b.importBundleCommit !== "function")
|
|
5
5
|
return undefined;
|
|
6
|
-
const engine = new MemoryEngine({ backend: store.backend, memoryDir: store.root });
|
|
6
|
+
const engine = new MemoryEngine({ backend: store.backend, memoryDir: store.root, ...(opts?.captureRecordStore !== undefined ? { captureRecordStore: opts.captureRecordStore } : {}) });
|
|
7
7
|
return {
|
|
8
8
|
exportScopes: (scopes) => engine.exportMemoryScopes(scopes),
|
|
9
9
|
importBundle: (bundle, opts) => engine.importMemoryBundle(bundle, opts),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* **引擎接线**(core 5.57.0 `MemoryEngine.provenanceOf` / `eraseMemoryEntries`,
|
|
2
|
+
* [ref] 件③ —— `GET /v1/memory/entries/:entryId/provenance` · `POST /v1/memory/erase` 两口的
|
|
3
|
+
* **引擎接线**(core 5.57.0 `MemoryEngine.provenanceOf` / `eraseMemoryEntries`,[ref] v2-a/v2-b)。
|
|
4
4
|
*
|
|
5
5
|
* ## 为什么是一个模块而不是 main.ts 里直接 new
|
|
6
6
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* ⇒ 裁:`controlPlaneRoot` 缺席 ⇒ 本工厂返回 **undefined**,两口整个不挂载,HTTP 面诚实 501。今天满足这一
|
|
26
26
|
* 条的只有 core 自带的 `FileMemoryEngineBackend`(它把控制面写死在 config-root 一侧);本仓两只 SQL 记忆
|
|
27
27
|
* 孪生(`plugins/memory-engine-{pg,tidb}.ts`)没有这个面 ⇒ 在那些部署上两口不挂。SQL 控制面是 core 的候升件
|
|
28
|
-
* (
|
|
28
|
+
* ([ref] §0b-4 咨询单),**绝不**在本层为它们现造一个「够用的」控制面 —— 那是把一个 core 拒绝生产的
|
|
29
29
|
* 半吊子治理面自己造出来,与 bundle 那条「a governance-less export is the laundering shape」同族。
|
|
30
30
|
*
|
|
31
31
|
* 🔴 这条判断是承重的,所以它有**机器钉**而不是只有这段注释:`test/memory-operator-faces.test.ts` 用一只
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
*
|
|
37
37
|
* 判据是一次**属性检查**、boot 期就判得出、而且是**永久**缺席(换后端才会变)——不是瞬时状态。照旧挂着
|
|
38
38
|
* 就成了「能力位说 yes、每一次调用都确定性失败」,而本仓「says yes ⟺ route works」是结构性承诺。
|
|
39
|
-
* (这条纪律是
|
|
39
|
+
* (这条纪律是 [ref] 提货批被 codex 交叉复审驳倒后立的,见 memory-bundle-engine.ts 头注。)
|
|
40
40
|
*
|
|
41
41
|
* ⚠️ **刻意不把审计/托管/证据三个可选面编进构造判定**:`committedSnapshotOf` / `custodyOf` 缺席时 core
|
|
42
42
|
* 明写要诚实答 `binding:"unknown"` / `contentState:"capability-absent"` / `custody:"capability-absent"`
|
|
43
|
-
* (
|
|
43
|
+
* ([ref] absence-reports-not-silent-green,engine.d.ts:748 逐字),那是一个**答得出话**的部署;把它们编进
|
|
44
44
|
* 构造判定会让这种部署整口消失,把 core 的诚实答案换成一句 501 谎话。`eraseWithEvidence` 同理:缺它时
|
|
45
45
|
* core 自己响亮拒(`memory.erasure_evidence_unavailable`),那是**运行期**的诚实拒,与「换部署形态才行」
|
|
46
46
|
* 不是一回事(附录 A 两条分列)。
|
|
47
47
|
*/
|
|
48
|
-
import { type EntryProvenanceAccount, type MemoryBackend, type MemoryEntryOrigin, type MemoryErasureAttestation, type OriginClearanceRow } from "@sema-agent/core";
|
|
48
|
+
import { type EntryProvenanceAccount, type MemoryBackend, type MemoryEntryOrigin, type MemoryErasureAttestation, type OriginClearanceRow, type SessionCaptureRecordStore, type SessionMemoryStatus } from "@sema-agent/core";
|
|
49
49
|
/**
|
|
50
50
|
* 控制面归属判据 —— 三个记忆操作面(合规两口 / 外源标记三口 / consolidation 阀门的 D1 拒启门)共用的
|
|
51
51
|
* **同一只**谓词:backend 的面上带**非空** `controlPlaneRoot` 才算归属在案。空串与缺席同判「不归属」:
|
|
@@ -128,6 +128,7 @@ opts?: {
|
|
|
128
128
|
onIncident?: (err: Error & {
|
|
129
129
|
code?: string;
|
|
130
130
|
}) => void;
|
|
131
|
+
captureRecordStore?: SessionCaptureRecordStore;
|
|
131
132
|
}): MemoryComplianceFaces | undefined;
|
|
132
133
|
/** 件② 三口 HTTP 面消费的窄能力面(`ServiceDeps.memoryOriginFace` 的实参来源)。 */
|
|
133
134
|
export interface MemoryOriginFaces {
|
|
@@ -135,7 +136,7 @@ export interface MemoryOriginFaces {
|
|
|
135
136
|
* §13-4① 视图面:点名 scope 里**每一条**带外源标记的条目 + 它的出处账。
|
|
136
137
|
*
|
|
137
138
|
* 🔴 `scopes` 由**调用方**给,本层不发明默认值:v1 本仓没有任何 scope 枚举读面(core 5.59.0 的
|
|
138
|
-
* `listMemoryScopes` 已到 File 腿、SQL 腿是 core 候升件
|
|
139
|
+
* `listMemoryScopes` 已到 File 腿、SQL 腿是 core 候升件 [ref]④,本仓尚未接线),而「空 scope 名单」
|
|
139
140
|
* 与「查全店」在这条路上是两件事 —— 猜一个默认名单会让审计的**不完备变成静默的**(空数组与
|
|
140
141
|
* 「这些 scope 干净」同形)。缺参时路由那侧 400 并指路,理由与文案同源于此。
|
|
141
142
|
*/
|
|
@@ -161,8 +162,8 @@ export interface MemoryOriginFaces {
|
|
|
161
162
|
}>;
|
|
162
163
|
}
|
|
163
164
|
/**
|
|
164
|
-
*
|
|
165
|
-
* `listOriginClearances` / `clearEntryOrigin`,
|
|
165
|
+
* [ref] 件② —— 外源标记人面的**引擎接线**(core 5.59.0 `MemoryEngine.listExternalOriginEntries` /
|
|
166
|
+
* `listOriginClearances` / `clearEntryOrigin`,[ref] §13-4①②)。
|
|
166
167
|
*
|
|
167
168
|
* ## 控制面归属:判据与合规两口**逐字同一条**(§1 F-9 裁),但理由更硬
|
|
168
169
|
*
|
|
@@ -182,11 +183,11 @@ export interface MemoryOriginFaces {
|
|
|
182
183
|
* 而且下一次 resume 调用大概率落到另一台副本、读不到那行 ⇒ 一条被清标的记忆连同它的托管字节一起消失。
|
|
183
184
|
* 本仓是 stateless replicas(CLAUDE.md 首段)。所以判在**构造期**:工厂返 undefined、三口整个不挂、
|
|
184
185
|
* HTTP 面诚实 501,与 `createMemoryComplianceFaces` 同形同码不同文案(要查的旋钮不是同一个)。
|
|
185
|
-
* SQL 控制面是 core 的候升件(
|
|
186
|
+
* SQL 控制面是 core 的候升件([ref] §0b-4 / [ref]④),**绝不**在本层为它现造一个。
|
|
186
187
|
*
|
|
187
188
|
* ## 刻意不做的两件事
|
|
188
189
|
*
|
|
189
|
-
* ⚠️ **不把 `listScopes` 编进构造判定**:core 5.59.0 长出了 `listMemoryScopes`(
|
|
190
|
+
* ⚠️ **不把 `listScopes` 编进构造判定**:core 5.59.0 长出了 `listMemoryScopes`([ref]③,File 腿在场、
|
|
190
191
|
* SQL 腿候升),但那是**发现链**的面,不是本族三口的执行前提 —— 把它编进来会让一个「scope 名由运维
|
|
191
192
|
* 自己拿着」的部署整口消失。发现链的不完备由 `GET …/external` 缺参时的 400 文案如实说出来。
|
|
192
193
|
* ⚠️ **不在 seam 里翻译拒因码**:core 的 origin-clear 族是**闭集**,翻译点只有一个(路由的 switch),
|
|
@@ -207,5 +208,34 @@ opts?: {
|
|
|
207
208
|
onIncident?: (err: Error & {
|
|
208
209
|
code?: string;
|
|
209
210
|
}) => void;
|
|
211
|
+
captureRecordStore?: SessionCaptureRecordStore;
|
|
210
212
|
}): MemoryOriginFaces | undefined;
|
|
213
|
+
/** [ref] seam① 的窄能力面(`ServiceDeps.sessionMemoryStatus` 的实参来源)。 */
|
|
214
|
+
export interface SessionMemoryStatusFace {
|
|
215
|
+
status: (sessionId: string) => Promise<SessionMemoryStatus>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* [ref] seam①([ref] §S-7,core 7.0.2 [ref] 件1)—— `GET /v1/sessions/:id/memory-status` 的引擎面。
|
|
219
|
+
* 命名照 CLAUDE.md 工厂律:返回带行为的活对象 ⇒ `create*`。
|
|
220
|
+
*
|
|
221
|
+
* 挂载判据与合规/清标两族**同一条 F-9 裁**(`backendOwnsControlPlane`,理由见文件头):
|
|
222
|
+
* `committedCount` / `foldedCount` / `lastCaptureAt` 读的是引擎控制面的 lineage 台账 ——
|
|
223
|
+
* 控制面归属缺席的部署上(两只 SQL 记忆孪生),core 会把控制面落到**副本本地盘**,一个「可读的空目录」
|
|
224
|
+
* 让 core 面答出 `committedCount: 0`(readLineageRecord 对空目录**不抛**,亲读 engine.js)——
|
|
225
|
+
* 那是**说谎的 0**,比缺席更坏(S-7 的诚实键律:可读零必须是真零)。⇒ 归属缺席 ⇒ 工厂返 undefined,
|
|
226
|
+
* HTTP 面诚实 501,与 erase/origin 同码同分支。
|
|
227
|
+
*
|
|
228
|
+
* `captureRecordStore` = [ref]② 的 SQL 载体(main.ts 单实例,与 Runner/其余引擎同源 —— 全站同批注入律,
|
|
229
|
+
* 机器钉 capture-optout-lane ②):`captureOptedOut` / `optOutSource` 两键经它读,多副本部署上答的才是
|
|
230
|
+
* 跨副本的真记录。缺席(local 车道)⇒ core 文件三腿,单机字节不变。
|
|
231
|
+
*
|
|
232
|
+
* 面**不抛**(core 契约:sessionMemoryStatus never throws —— 每个事实源各自 catch 折缺席键);
|
|
233
|
+
* 不接 onIncident:这条只读路径上今天零 sink 站点,而且缺席键本身就是它的披露形。
|
|
234
|
+
*/
|
|
235
|
+
export declare function createSessionMemoryStatusFace(store: {
|
|
236
|
+
backend: MemoryBackend;
|
|
237
|
+
root: string;
|
|
238
|
+
}, opts?: {
|
|
239
|
+
captureRecordStore?: SessionCaptureRecordStore;
|
|
240
|
+
}): SessionMemoryStatusFace | undefined;
|
|
211
241
|
//# sourceMappingURL=memory-operator-faces.d.ts.map
|
|
@@ -43,6 +43,7 @@ export function createMemoryComplianceFaces(store, opts) {
|
|
|
43
43
|
backend: store.backend,
|
|
44
44
|
memoryDir: store.root,
|
|
45
45
|
...(opts?.onIncident !== undefined ? { onIncident: opts.onIncident } : {}),
|
|
46
|
+
...(opts?.captureRecordStore !== undefined ? { captureRecordStore: opts.captureRecordStore } : {}),
|
|
46
47
|
});
|
|
47
48
|
return {
|
|
48
49
|
provenanceOf: (entryId) => engine.provenanceOf(entryId),
|
|
@@ -66,6 +67,7 @@ export function createMemoryOriginFaces(store, opts) {
|
|
|
66
67
|
backend: store.backend,
|
|
67
68
|
memoryDir: store.root,
|
|
68
69
|
...(opts?.onIncident !== undefined ? { onIncident: opts.onIncident } : {}),
|
|
70
|
+
...(opts?.captureRecordStore !== undefined ? { captureRecordStore: opts.captureRecordStore } : {}),
|
|
69
71
|
});
|
|
70
72
|
return {
|
|
71
73
|
listExternal: (scopes) => engine.listExternalOriginEntries(scopes),
|
|
@@ -73,4 +75,14 @@ export function createMemoryOriginFaces(store, opts) {
|
|
|
73
75
|
clear: (entryId, input) => engine.clearEntryOrigin(entryId, input),
|
|
74
76
|
};
|
|
75
77
|
}
|
|
78
|
+
export function createSessionMemoryStatusFace(store, opts) {
|
|
79
|
+
if (!backendOwnsControlPlane(store.backend))
|
|
80
|
+
return undefined;
|
|
81
|
+
const engine = new MemoryEngine({
|
|
82
|
+
backend: store.backend,
|
|
83
|
+
memoryDir: store.root,
|
|
84
|
+
...(opts?.captureRecordStore !== undefined ? { captureRecordStore: opts.captureRecordStore } : {}),
|
|
85
|
+
});
|
|
86
|
+
return { status: (sessionId) => engine.sessionMemoryStatus(sessionId) };
|
|
87
|
+
}
|
|
76
88
|
//# sourceMappingURL=memory-operator-faces.js.map
|
|
@@ -3,7 +3,7 @@ import { type MemoryExportBundle } from "@sema-agent/core";
|
|
|
3
3
|
export declare const ORIGIN_AWARE_QUERY = "originAware";
|
|
4
4
|
/** 从 `URLSearchParams` 读能力位:`originAware=1` ⇒ true;缺席/其它值 ⇒ false(老客户端假定)。 */
|
|
5
5
|
export declare function readOriginAware(params: URLSearchParams): boolean;
|
|
6
|
-
/** 「这条条目带 origin 标吗」—— 载体三形(G53 [
|
|
6
|
+
/** 「这条条目带 origin 标吗」—— 载体三形(G53 [ref] + codex R1-high 后齐):
|
|
7
7
|
* ① 顶层 `origin`(listExternal 投影行)—— own 键在场且非 undefined 即带标(不读形;typed null/坏形也算:
|
|
8
8
|
* core 读取器对 null 会抛,围栏对读不出的载体只许扣留不许放行);
|
|
9
9
|
* ② `frontmatter.origin`(core `MemoryEntry`,138 S3)—— 同 own 键判;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { committedOriginOf } from "@sema-agent/core";
|
|
3
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
3
4
|
export const ORIGIN_AWARE_QUERY = "originAware";
|
|
4
5
|
export function readOriginAware(params) {
|
|
5
6
|
return params.get(ORIGIN_AWARE_QUERY) === "1";
|
|
@@ -33,18 +34,6 @@ export function buildOriginFence(entries, originAware) {
|
|
|
33
34
|
function sha256Line(text) {
|
|
34
35
|
return createHash("sha256").update(`${text}\n`, "utf8").digest("hex");
|
|
35
36
|
}
|
|
36
|
-
function canonicalJsonStringify(value) {
|
|
37
|
-
if (Array.isArray(value))
|
|
38
|
-
return `[${value.map((v) => (v === undefined || typeof v === "function" || typeof v === "symbol" ? "null" : canonicalJsonStringify(v))).join(",")}]`;
|
|
39
|
-
if (value !== null && typeof value === "object") {
|
|
40
|
-
const rec = value;
|
|
41
|
-
const keys = Object.keys(rec)
|
|
42
|
-
.filter((k) => rec[k] !== undefined)
|
|
43
|
-
.sort();
|
|
44
|
-
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJsonStringify(rec[k])}`).join(",")}}`;
|
|
45
|
-
}
|
|
46
|
-
return JSON.stringify(value);
|
|
47
|
-
}
|
|
48
37
|
export function buildOriginFencedBundle(bundle, originAware) {
|
|
49
38
|
if (originAware)
|
|
50
39
|
return bundle;
|
|
@@ -58,7 +47,7 @@ export function buildOriginFencedBundle(bundle, originAware) {
|
|
|
58
47
|
integrity: {
|
|
59
48
|
entryCount: kept.length,
|
|
60
49
|
revs: Object.fromEntries(kept.map((e) => [e.id, e.rev])),
|
|
61
|
-
sectionHashes: { ...bundle.integrity.sectionHashes, entries: sha256Line(
|
|
50
|
+
sectionHashes: { ...bundle.integrity.sectionHashes, entries: sha256Line(canonicalJson(kept)) },
|
|
62
51
|
},
|
|
63
52
|
withheldOriginTagged: withheld,
|
|
64
53
|
};
|