@sema-agent/server 7.52.0 → 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 +22 -5
- 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/device-lane.js +2 -0
- 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 +157 -134
- package/dist/config.d.ts +32 -24
- package/dist/config.js +48 -6
- 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 +6 -4
- package/dist/device-ws-hub.js +9 -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 +56 -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 +12 -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 +23 -21
- 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-bundle.js +2 -3
- 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 +61 -1
- 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 +25 -12
- 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 +13 -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 +20 -35
- package/dist/memory-origin-fence.js +41 -1
- 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/run-local.js +28 -4
- 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 +21 -7
- 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 +35 -30
- package/dist/trace/project.js +9 -0
- 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 +6 -6
package/dist/tool-approval.js
CHANGED
|
@@ -3,6 +3,7 @@ import { uuidv7, MAX_RULE_TEXT_CHARS } from "@sema-agent/core";
|
|
|
3
3
|
import { precheckCardRuleText } from "./rules-consent.js";
|
|
4
4
|
import { redactDeep, redactSecrets } from "./trace/redact.js";
|
|
5
5
|
import { hasBidiControls } from "./text-bidi.js";
|
|
6
|
+
import { approvalPayloadFingerprint } from "./plugins/approval-payload-fingerprint.js";
|
|
6
7
|
import { createLogger } from "./observability/logger.js";
|
|
7
8
|
import { recordFailOpen } from "./observability/fail-open.js";
|
|
8
9
|
import { deriveAskId, deriveBatchId, MAX_DECISION_NOTE_CHARS } from "./approval-ask-machine.js";
|
|
@@ -194,14 +195,21 @@ function effectiveAskWindowMs(ttlMs, windowMarginMs, legDeadlineMonotonic, nowMo
|
|
|
194
195
|
return Math.min(ttlMs, Math.max(0, legRemainingMs - windowMarginMs));
|
|
195
196
|
}
|
|
196
197
|
function replayTerminalAskRow(row) {
|
|
197
|
-
if (row.state === "DECIDED")
|
|
198
|
-
|
|
198
|
+
if (row.state === "DECIDED") {
|
|
199
|
+
if (row.decision !== "approve")
|
|
200
|
+
return false;
|
|
201
|
+
return row.updatedInput !== undefined ? { allow: true, updatedInput: row.updatedInput } : true;
|
|
202
|
+
}
|
|
199
203
|
if (row.state === "PARKING" || row.state === "PARKED")
|
|
200
204
|
return "unavailable";
|
|
201
205
|
return false;
|
|
202
206
|
}
|
|
203
|
-
function
|
|
204
|
-
|
|
207
|
+
function settleArgsOf(outcome) {
|
|
208
|
+
if (outcome === "unavailable")
|
|
209
|
+
return "unavailable";
|
|
210
|
+
if (typeof outcome === "boolean")
|
|
211
|
+
return { allowed: outcome };
|
|
212
|
+
return { allowed: outcome.allow, ...(outcome.updatedInput !== undefined ? { updatedInput: outcome.updatedInput } : {}) };
|
|
205
213
|
}
|
|
206
214
|
export class ToolApprovalCoordinator {
|
|
207
215
|
als = new AsyncLocalStorage();
|
|
@@ -445,8 +453,8 @@ export class ToolApprovalCoordinator {
|
|
|
445
453
|
}
|
|
446
454
|
if (this.editedDecisionInFlight(askId))
|
|
447
455
|
return undefined;
|
|
448
|
-
const replayed = replayTerminalAskRow(row);
|
|
449
|
-
return
|
|
456
|
+
const replayed = settleArgsOf(replayTerminalAskRow(row));
|
|
457
|
+
return replayed === "unavailable" ? undefined : replayed;
|
|
450
458
|
}
|
|
451
459
|
catch (err) {
|
|
452
460
|
this.noteStoreError(err, "getAsk(expire-error-recovery)");
|
|
@@ -745,8 +753,6 @@ export class ToolApprovalCoordinator {
|
|
|
745
753
|
if (existingOrCreated.row.state !== "STREAM_PENDING") {
|
|
746
754
|
releaseAdmission();
|
|
747
755
|
const replayed = this.guardRowDerivedApprove(askId, replayTerminalAskRow(existingOrCreated.row), "ensure-ask-idempotent-replay");
|
|
748
|
-
if (replayed === true)
|
|
749
|
-
recordRowDerivedApproveReplay("ensure-ask-idempotent-replay");
|
|
750
756
|
return replayed === "unavailable" ? this.unattendedOutcome() : replayed;
|
|
751
757
|
}
|
|
752
758
|
const persistedEnvelope = ApprovalCardEnvelopeSchema.safeParse(existingOrCreated.row.cardJson);
|
|
@@ -909,14 +915,13 @@ export class ToolApprovalCoordinator {
|
|
|
909
915
|
await new Promise((r) => setTimeout(r, DURABLE_CONVERGE_BACKOFF_MS[attempt]).unref?.());
|
|
910
916
|
continue;
|
|
911
917
|
}
|
|
912
|
-
const outcome = this.guardRowDerivedApprove(pinnedAskId, replayTerminalAskRow(row), `converge:${where}`);
|
|
918
|
+
const outcome = settleArgsOf(this.guardRowDerivedApprove(pinnedAskId, replayTerminalAskRow(row), `converge:${where}`));
|
|
913
919
|
if (outcome === "unavailable") {
|
|
914
920
|
windowRouteUnavailable = true;
|
|
915
921
|
settle(false, "expired");
|
|
916
922
|
}
|
|
917
|
-
else if (outcome
|
|
918
|
-
|
|
919
|
-
settle(true, "allowed");
|
|
923
|
+
else if (outcome.allowed) {
|
|
924
|
+
settle(true, "allowed", outcome.updatedInput);
|
|
920
925
|
}
|
|
921
926
|
else {
|
|
922
927
|
settle(false, "denied");
|
|
@@ -973,9 +978,7 @@ export class ToolApprovalCoordinator {
|
|
|
973
978
|
this.noteStoreError(err, "expireAsk");
|
|
974
979
|
const decided = await this.readDecidedForRecovery(askId);
|
|
975
980
|
if (decided !== undefined && !done) {
|
|
976
|
-
|
|
977
|
-
recordRowDerivedApproveReplay("expire-error-recovery");
|
|
978
|
-
settle(decided, decided ? "allowed" : "denied");
|
|
981
|
+
settle(decided.allowed, decided.allowed ? "allowed" : "denied", decided.updatedInput);
|
|
979
982
|
return;
|
|
980
983
|
}
|
|
981
984
|
settleParkRouteIfUnsettled(hostSelfReport);
|
|
@@ -1288,9 +1291,7 @@ export class ToolApprovalCoordinator {
|
|
|
1288
1291
|
});
|
|
1289
1292
|
return this.notPending();
|
|
1290
1293
|
}
|
|
1291
|
-
|
|
1292
|
-
if (row.decision === "approve" && settled.settled > 0)
|
|
1293
|
-
recordRowDerivedApproveReplay("respond-late-replay");
|
|
1294
|
+
this.notifyExternalDecision(row.askId, row.decision === "approve", row.updatedInput);
|
|
1294
1295
|
return {
|
|
1295
1296
|
status: 200,
|
|
1296
1297
|
body: {
|
|
@@ -1559,11 +1560,13 @@ export class ToolApprovalCoordinator {
|
|
|
1559
1560
|
}
|
|
1560
1561
|
async respondWithCas(askStore, askId, batchId, id, entry, parsed, ruleEligibility) {
|
|
1561
1562
|
let decidedWon = false;
|
|
1563
|
+
let confirmedRowPayload;
|
|
1562
1564
|
let noteLanded = false;
|
|
1563
1565
|
try {
|
|
1564
1566
|
const decided = await this.withStoreDeadline(askStore.decideAsk(askId, batchId, {
|
|
1565
1567
|
decision: parsed.value === "deny" ? "deny" : "approve",
|
|
1566
1568
|
...(parsed.note !== undefined ? { decisionNote: parsed.note } : {}),
|
|
1569
|
+
...(parsed.value !== "deny" && parsed.updatedInput !== undefined ? { updatedInput: parsed.updatedInput } : {}),
|
|
1567
1570
|
}), "decideAsk", DURABLE_CALL_TIMEOUT_MS, (late) => {
|
|
1568
1571
|
if (late.ok)
|
|
1569
1572
|
this.notifyExternalDecision(askId, parsed.value !== "deny", parsed.updatedInput);
|
|
@@ -1582,6 +1585,7 @@ export class ToolApprovalCoordinator {
|
|
|
1582
1585
|
const row = await this.withStoreDeadline(askStore.getAsk(askId), "getAsk(decideAsk-confirm)", DURABLE_CONVERGE_READ_TIMEOUT_MS);
|
|
1583
1586
|
if (row?.state === "DECIDED" && row.decision === (parsed.value === "deny" ? "deny" : "approve")) {
|
|
1584
1587
|
decidedWon = true;
|
|
1588
|
+
confirmedRowPayload = { updatedInput: row.updatedInput };
|
|
1585
1589
|
noteLanded = parsed.note === undefined || row.decisionNote === parsed.note;
|
|
1586
1590
|
}
|
|
1587
1591
|
}
|
|
@@ -1592,15 +1596,20 @@ export class ToolApprovalCoordinator {
|
|
|
1592
1596
|
const wantAllowed = parsed.value !== "deny";
|
|
1593
1597
|
if (this.pending.get(id) !== entry) {
|
|
1594
1598
|
if (decidedWon)
|
|
1595
|
-
this.notifyExternalDecision(askId, wantAllowed, parsed.updatedInput);
|
|
1599
|
+
this.notifyExternalDecision(askId, wantAllowed, confirmedRowPayload !== undefined ? confirmedRowPayload.updatedInput : parsed.updatedInput);
|
|
1596
1600
|
const converged = decidedWon && entry.settledOutcome === (wantAllowed ? "allowed" : "denied");
|
|
1597
1601
|
if (!converged) {
|
|
1598
1602
|
return this.notPending();
|
|
1599
1603
|
}
|
|
1600
1604
|
return this.finishRespond(id, entry, parsed, { updatedInputDelivered: false, noteRecorded: noteLanded });
|
|
1601
1605
|
}
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1606
|
+
const payloadIsMine = confirmedRowPayload === undefined ||
|
|
1607
|
+
approvalPayloadFingerprint({ updatedInput: confirmedRowPayload.updatedInput }) === approvalPayloadFingerprint({ updatedInput: parsed.updatedInput });
|
|
1608
|
+
const result = this.finishRespond(id, entry, parsed, {
|
|
1609
|
+
noteRecorded: noteLanded,
|
|
1610
|
+
...(confirmedRowPayload !== undefined ? { settlePayload: confirmedRowPayload, updatedInputDelivered: payloadIsMine } : {}),
|
|
1611
|
+
});
|
|
1612
|
+
this.notifyExternalDecision(askId, wantAllowed, confirmedRowPayload !== undefined ? confirmedRowPayload.updatedInput : parsed.updatedInput);
|
|
1604
1613
|
return result;
|
|
1605
1614
|
}
|
|
1606
1615
|
finishRespond(id, entry, parsed, opts) {
|
|
@@ -1617,7 +1626,7 @@ export class ToolApprovalCoordinator {
|
|
|
1617
1626
|
this.allowAllSessions.add(sessionAllowKey(entry.owner, entry.sessionId, sessionAllowCategory(entry.toolName)));
|
|
1618
1627
|
}
|
|
1619
1628
|
const allowed = parsed.value !== "deny";
|
|
1620
|
-
entry.settle(allowed, allowed ? "allowed" : "denied", parsed.updatedInput, undefined, allowed ? undefined : parsed.note);
|
|
1629
|
+
entry.settle(allowed, allowed ? "allowed" : "denied", opts?.settlePayload !== undefined ? opts.settlePayload.updatedInput : parsed.updatedInput, undefined, allowed ? undefined : parsed.note);
|
|
1621
1630
|
const updatedInputDelivered = opts?.updatedInputDelivered ?? true;
|
|
1622
1631
|
const noteRecorded = opts?.noteRecorded ?? false;
|
|
1623
1632
|
return {
|
|
@@ -1687,18 +1696,14 @@ export class ToolApprovalCoordinator {
|
|
|
1687
1696
|
continue;
|
|
1688
1697
|
if (this.editedDecisionInFlight(askId))
|
|
1689
1698
|
continue;
|
|
1690
|
-
const outcome = replayTerminalAskRow(row);
|
|
1699
|
+
const outcome = settleArgsOf(replayTerminalAskRow(row));
|
|
1691
1700
|
if (outcome === "unavailable") {
|
|
1692
1701
|
const before = this.pendingByAskId.get(askId)?.size ?? 0;
|
|
1693
1702
|
this.settleSameAskIdParkRoute(askId);
|
|
1694
1703
|
settled += before;
|
|
1695
1704
|
continue;
|
|
1696
1705
|
}
|
|
1697
|
-
|
|
1698
|
-
continue;
|
|
1699
|
-
const delivered = this.notifyExternalDecision(askId, outcome).settled;
|
|
1700
|
-
if (outcome && delivered > 0)
|
|
1701
|
-
recordRowDerivedApproveReplay("poll-suspended");
|
|
1706
|
+
const delivered = this.notifyExternalDecision(askId, outcome.allowed, outcome.updatedInput).settled;
|
|
1702
1707
|
settled += delivered;
|
|
1703
1708
|
}
|
|
1704
1709
|
const backlog = Math.max(0, candidates.length - polled);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* L1 键集机器门([
|
|
2
|
+
* L1 键集机器门([ref] 方法论倡议 server 认领件;clay 令 2026-07-23「不能永远编码有限→复审补漏」)。
|
|
3
3
|
*
|
|
4
4
|
* 病族:**投影白名单剥键**——core 给源类型加 additive 新键,server 的列投影/白名单静默丢,直到穿透
|
|
5
|
-
* 审查才被人肉抓。已四案:RosterEntry.model([
|
|
6
|
-
* 四键 / BackgroundChildEvent.usage+transcriptId([
|
|
5
|
+
* 审查才被人肉抓。已四案:RosterEntry.model([ref])、task_progress.status / TaskNotificationPayload
|
|
6
|
+
* 四键 / BackgroundChildEvent.usage+transcriptId([ref] 族B)、SDK 0.0.72 fleet meta 剥键。
|
|
7
7
|
*
|
|
8
8
|
* 机制:对每个「core 源类型 → server 投影」面声明**已处置键集** = PROJECTED(真透传)∪ EXCLUDED
|
|
9
9
|
* (显式记账不透传,理由必写)。`Exclude<keyof 源, 已处置>` 约束为 never——**升 core 后源类型出新键
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
*
|
|
15
15
|
* 维护:core 新键到来时,transparently 透传的加进对应 PROJECTED 并去实现投影;有意不上 wire 的加进
|
|
16
16
|
* EXCLUDED 并写一行理由。谁改投影(project.ts / fleet-bus.ts / roster-store-sql.ts)谁同步本文件。
|
|
17
|
+
* ⑨⑩([ref],2026-08-31)把两个最大的 wire 面也纳入:TaskSpec 按「server 有无写点」记 Wired/Unwired,
|
|
18
|
+
* TaskResult 按「转发/摘除」记 Forwarded/Stripped —— 谁改 resolve-spec.ts / runs.ts 的发射点谁同步本文件。
|
|
17
19
|
*/
|
|
18
|
-
import type { TaskNotificationPayload, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, TaskEvent, TraceEvent, MailboxMessage, MailboxStore } from "@sema-agent/core";
|
|
20
|
+
import type { TaskNotificationPayload, BackgroundChildEvent, RosterEntry, AskRequest, CheckpointSummary, TaskEvent, TraceEvent, MailboxMessage, MailboxStore, TaskSpec, TaskResult } from "@sema-agent/core";
|
|
19
21
|
/** 编译期断言:T 必须收敛到 never(有残余键 = tsc 红)。 */
|
|
20
22
|
type AssertAllKeysHandled<T extends never> = T;
|
|
21
|
-
type NotificationProjected = "task_id" | "task_type" | "toolUseId" | "status" | "summary" | "result" | "output_file" | "usage" | "sessionId" | "seq" | "lines" | "stoppedBy" | "source" | "exitCode" | "partial" | "diagnostics" | "recentSteps" | "editedFiles" | "resumable" | "completionId" | "error" | "errorCode";
|
|
23
|
+
type NotificationProjected = "task_id" | "task_type" | "toolUseId" | "status" | "summary" | "result" | "output_file" | "usage" | "sessionId" | "seq" | "lines" | "stoppedBy" | "source" | "exitCode" | "partial" | "diagnostics" | "recentSteps" | "editedFiles" | "resumable" | "completionId" | "error" | "errorCode" | "apiFailure";
|
|
22
24
|
type NotificationExcluded = "peer";
|
|
23
25
|
type _GuardNotification = AssertAllKeysHandled<Exclude<keyof TaskNotificationPayload, NotificationProjected | NotificationExcluded>>;
|
|
24
26
|
type BgNotifProjected = "taskId" | "sessionId" | "seq" | "status" | "summary" | "stoppedBy" | "resumable" | "recentSteps" | "editedFiles" | "usage" | "transcriptId" | "rootSessionId" | "parentTaskId" | "parentToolCallId" | "completionId";
|
|
25
|
-
type BgNotifExcluded = "kind" | "sessionScoped" | "owner" | "scope" | "description" | "agentType" | "name" | "currentAction" | "currentTool" | "parentSessionId" | "startedAt" | "workflowRunId" | "progressTaskId" | "progressParentTaskId";
|
|
27
|
+
type BgNotifExcluded = "kind" | "sessionScoped" | "owner" | "scope" | "description" | "agentType" | "name" | "currentAction" | "currentTool" | "parentSessionId" | "startedAt" | "workflowRunId" | "progressTaskId" | "progressParentTaskId" | "model";
|
|
26
28
|
type _GuardBgNotif = AssertAllKeysHandled<Exclude<keyof BackgroundChildEvent, BgNotifProjected | BgNotifExcluded>>;
|
|
27
29
|
type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "modelFallback" | "createdAt";
|
|
28
30
|
type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
|
|
@@ -47,6 +49,14 @@ type _GuardPermissionTraceNonEmpty = AssertAllKeysHandled<AssertNonEmpty<Permiss
|
|
|
47
49
|
type SummaryProjected = "sessionId" | "scope" | "createdAt" | "gateKind" | "severity" | "spentMicroUsd" | "deadline" | "hasBidiControls";
|
|
48
50
|
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "contentKind" | "restoreMode" | "checkpointId" | "previewWithheld";
|
|
49
51
|
type _GuardInboxSummary = AssertAllKeysHandled<Exclude<keyof CheckpointSummary, SummaryProjected | SummaryExcluded>>;
|
|
52
|
+
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptProvider" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptProfile" | "toolPolicy" | "onAsk" | "onQuestion" | "hooks" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "taskId" | "signal" | "preemptSignal" | "modelRole" | "enableBlockedReport" | "maxSuspends";
|
|
53
|
+
type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "readDenyPatterns" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars";
|
|
54
|
+
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
55
|
+
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
56
|
+
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "status" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "blockedReason" | "checkpointId" | "checkpointGate" | "workspaceRestoreMode" | "remoteEnvFailures" | "errorMessage" | "errorCode" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveMemoryScopes" | "stats";
|
|
57
|
+
type TaskResultStripped = "checkpointToken";
|
|
58
|
+
type _GuardTaskResult = AssertAllKeysHandled<Exclude<keyof TaskResult, TaskResultForwarded | TaskResultStripped>>;
|
|
59
|
+
type _GuardTaskResultReverse = AssertAllKeysHandled<Exclude<TaskResultForwarded | TaskResultStripped, keyof TaskResult>>;
|
|
50
60
|
export type CoreKeysetGuards = [
|
|
51
61
|
_GuardNotification,
|
|
52
62
|
_GuardBgNotif,
|
|
@@ -58,7 +68,11 @@ export type CoreKeysetGuards = [
|
|
|
58
68
|
_GuardPermissionTrace,
|
|
59
69
|
_GuardPermissionTraceReverse,
|
|
60
70
|
_GuardPermissionTraceNonEmpty,
|
|
61
|
-
_GuardInboxSummary
|
|
71
|
+
_GuardInboxSummary,
|
|
72
|
+
_GuardTaskSpec,
|
|
73
|
+
_GuardTaskSpecReverse,
|
|
74
|
+
_GuardTaskResult,
|
|
75
|
+
_GuardTaskResultReverse
|
|
62
76
|
];
|
|
63
77
|
export {};
|
|
64
78
|
//# sourceMappingURL=core-keyset-guard.d.ts.map
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* 码数的**受门**真源=契约文档附录 D.3 的小节标题,⑥b 双向门盯着)。
|
|
5
5
|
*
|
|
6
6
|
* 起步的那六码同族:都是「这条 session 的记忆姿态」的披露,resume 之后仍然相关 ⇒ 也进 durable 账本
|
|
7
|
-
* (cli 断连补看走既有 events 重放腿,[
|
|
7
|
+
* (cli 断连补看走既有 events 重放腿,[ref](ii))。
|
|
8
8
|
*
|
|
9
|
-
* ⚠️ **自
|
|
9
|
+
* ⚠️ **自 [ref](core 5.61.0)起本表不再是单一族**:`task.turn_interrupted` 与 `task.user_*_undrained`
|
|
10
10
|
* 两族是前三条**非记忆面**的成员(前者=一次插话真的切断了在飞的 turn;后两者=用户的输入被彻底丢弃)。
|
|
11
11
|
* 判据没有变(受众 × 投递可行性 × 去重单位三条合取,见顶注),变的只是「碰巧六条都是记忆码」这个
|
|
12
12
|
* 事实——别再把「是不是记忆姿态码」当成入册的隐性第四条判据。这条隐性判据正是 `task.user_*_undrained`
|
|
13
13
|
* 两码在明拒表里陈腐多时的帮凶之一(见它们的键注)。
|
|
14
14
|
*
|
|
15
|
-
* 🔴 **表长了就得同步三处**(
|
|
15
|
+
* 🔴 **表长了就得同步三处**([ref] 实测,少一处即门红):`test/engine-notice-wire.test.ts` 的闭集 pin、
|
|
16
16
|
* 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
|
|
17
17
|
* 刚立,立完就在下一次加码时自己咬住了)。
|
|
18
18
|
*/
|
|
@@ -24,7 +24,7 @@ export declare function isEngineNoticeWireCode(code: string): code is EngineNoti
|
|
|
24
24
|
* 归属键抽取 —— `detail.sessionId` 提升为顶层(设计稿 ②:归属键一等化)。
|
|
25
25
|
*
|
|
26
26
|
* 非串 / 空串一律按**缺席**处理(不铸 `"undefined"` 这种看起来合法的假值——`compactionOutcomeEventData`
|
|
27
|
-
* 的同款缺键守卫纪律)。core [
|
|
27
|
+
* 的同款缺键守卫纪律)。core [ref] 的顶层 `EngineNotice.sessionId` 到货后,这里先读顶层再回落 detail
|
|
28
28
|
* (两处同值,additive 零 BREAKING),届时本函数是唯一改动点。
|
|
29
29
|
*/
|
|
30
30
|
export declare function engineNoticeSessionId(notice: {
|
|
@@ -37,7 +37,7 @@ export interface EngineNoticeWireRow {
|
|
|
37
37
|
code: string;
|
|
38
38
|
/**
|
|
39
39
|
* core 铸的人话行。🔴 **仅 fallback 展示,不是匹配键**:core 明写 `memory.session_polluted` 的 message
|
|
40
|
-
* 随 `memoryProvenance` 模式变文(
|
|
40
|
+
* 随 `memoryProvenance` 模式变文([ref] mode-aware),按 message 匹配必碎(5.41 合流码形退役同教训)。
|
|
41
41
|
*/
|
|
42
42
|
message: string;
|
|
43
43
|
/** 机器可读事实,逐键消毒后直透(见 {@link sanitizeNoticeDetail} 的消毒/尺寸契约)。 */
|
|
@@ -82,7 +82,7 @@ export type EngineNoticeWireSink = (row: EngineNoticeWireRow) => void;
|
|
|
82
82
|
*
|
|
83
83
|
* 🔴 跨 session 隔离靠的是 **Map 键的精确串相等**,不是任何「最近活跃」回落 —— 缺席就是缺席(G5)。
|
|
84
84
|
*
|
|
85
|
-
* 🔴 **同 session 的跨代隔离靠 legId「最新代独占」**(
|
|
85
|
+
* 🔴 **同 session 的跨代隔离靠 legId「最新代独占」**([ref] codex 交叉复审 R1-[high],验真后修)。
|
|
86
86
|
* 病(真窗,本仓每一处 in-flight 登记都为它写过 identity-guard):run 行在**流体内**就已 setTerminal /
|
|
87
87
|
* setSuspended,而本腿的注销在 `finally` —— 中间那一窗里,同一条 session 上的**下一条腿**(快速续跑 /
|
|
88
88
|
* 紧接着的新提交)已经注册好了自己的口。若按「会话内全量扇出」投,新腿的一条通告会**同时**落进:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] 注入档位(core 5.61.0)的**闭集单点**([ref])。
|
|
3
3
|
*
|
|
4
4
|
* ## 为什么本仓要自己留一份词表
|
|
5
5
|
* 理想写法是复用 core 的谓词 `isSystemInjectionPriority` / 数据表 `SYSTEM_INJECTION_PRIORITIES`。
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ## 为什么单独一个叶子模块
|
|
16
16
|
* 消费点有两个且分属两条依赖链:`trace/project.ts`(wire 投影)与
|
|
17
17
|
* `orchestration/workflow-completion-inbox.ts`(durable park 载荷)。手抄两份就是值拷贝漂移源
|
|
18
|
-
* (本仓 [
|
|
18
|
+
* (本仓 [ref] 起的老病族);把它挂在任一方又会在两条链之间拉一条没必要的边。零依赖叶子最干净。
|
|
19
19
|
*
|
|
20
20
|
* 🔴 上游哪天补了根导出:删掉本文件,两处改成一行谓词调用。
|
|
21
21
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* runs 账本(`task_run_event`)的**事件型闭集**——
|
|
2
|
+
* runs 账本(`task_run_event`)的**事件型闭集**——[ref] P1-③ / codex 交叉复审 F2。
|
|
3
3
|
*
|
|
4
4
|
* ## 为什么需要这个联合
|
|
5
5
|
* 账本行的 `type` 是消费端分流的键:`GET /v1/runs/:id/events` 裸回放照发,而 `trace/project.ts` 的
|
|
@@ -36,12 +36,12 @@ export type LedgerEventType = "reasoning" | "text" | "tool_start" | "tool_end" |
|
|
|
36
36
|
| "suspended" | "needs_review" | "done" | "failed" | "suggestions" | "model_usage" | "prompt_assembled" | "config_assembled" | "file_link"
|
|
37
37
|
/** 人在环三族的 open/close 帧对(投递面 = 本腿的 durable events tail)。 */
|
|
38
38
|
| "elicitation" | "elicitation_complete" | "question" | "question_complete" | "tool_approval" | "tool_approval_complete"
|
|
39
|
-
/**
|
|
39
|
+
/** [ref] §4.3 新协议的呈卡帧(与上面两只 tool_approval 帧同一条投递面)。 */
|
|
40
40
|
| "approval_request"
|
|
41
41
|
/** 异步 workflow 完成的入箱 drain(`emitPendingWorkflowCompletions` 两个字面型之一)。 */
|
|
42
42
|
| "workflow_complete"
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* [ref] `engine_notice` —— core `EngineNotice` 白名单三码按 `detail.sessionId` 路由到该会话的事件投影。
|
|
45
45
|
*
|
|
46
46
|
* 🔴 **是"腿自己的带外行",不是流事件投影**:它不经 `TaskStream`(`RunnerDeps.onNotice` 是 deps 级
|
|
47
47
|
* 同步 sink),所以两条 durable 腿的 `switch (ev.type)` 里**没有也不该有** `case "engine_notice"` ——
|
|
@@ -5,7 +5,7 @@ import type { LedgerEventType } from "./ledger-events.js";
|
|
|
5
5
|
* LedgerSink — the SINGLE "stream event → durable runs-ledger" projection, shared by the background leg
|
|
6
6
|
* (runs.ts `runInBackground`) and the sync `/v1/tasks/stream` detach lane (server.ts, `x-detach-on-disconnect`).
|
|
7
7
|
*
|
|
8
|
-
* [
|
|
8
|
+
* [ref]①/[ref]③: the sync leg historically persisted only createRun+setTerminal — its events ledger stayed
|
|
9
9
|
* EMPTY, so after a detach the shell could only poll the terminal row. Feeding the same sink on the detach
|
|
10
10
|
* lane makes `GET /v1/runs/:id/events` replay the full stream in the EXACT bg-leg vocabulary (the ledger
|
|
11
11
|
* consumer binds to these type/data shapes — a second copy of this switch would drift into a false ledger,
|
|
@@ -35,7 +35,7 @@ export interface LedgerSink {
|
|
|
35
35
|
type: string;
|
|
36
36
|
}): Promise<void>;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* [ref](core 5.34.0 的 `RunInternals.onStatusEvent` 第五席):**「只回结果」腿**的 `status` 行写口。
|
|
39
39
|
*
|
|
40
40
|
* 与 {@link onEvent} 的 `case "status"` 共用**同一个**白名单 builder(`brainStatusEventData`),差别只有
|
|
41
41
|
* 一处:本门**同步入链** —— 在回调进入的那一刻就占住序号槽,而不是先 `await flush()` 再入链。
|
|
@@ -58,7 +58,7 @@ export interface LedgerSink {
|
|
|
58
58
|
onForwardEvent(e: {
|
|
59
59
|
type?: string;
|
|
60
60
|
}): void;
|
|
61
|
-
/** Park event (durable F4 suspend /
|
|
61
|
+
/** Park event (durable F4 suspend / [ref] D-B review pause): ONLY the non-secret `checkpointGate` is
|
|
62
62
|
* persisted — never the capability `checkpointToken` (search [18] Q1b). */
|
|
63
63
|
appendParked(kind: "suspended" | "needs_review", result: unknown): Promise<void>;
|
|
64
64
|
/** Terminal `done` event. `result` must already be checkpoint-token-stripped (and, on the bg leg,
|
|
@@ -71,13 +71,13 @@ export interface LedgerSink {
|
|
|
71
71
|
}): Promise<void>;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
* **单写串行链**的可复用形(
|
|
74
|
+
* **单写串行链**的可复用形([ref] codex 交叉复审 R1-[high],验真后修)—— `seq` 的**分配发生在链步内**,
|
|
75
75
|
* 于是「分配序 == 发起序 == 提交序」。
|
|
76
76
|
*
|
|
77
77
|
* 病(实测形,`LedgerSink` 内部早有这条纪律的内联版、其顶注 [1.211 codex H2] 逐字记着它):裸写口
|
|
78
78
|
* (`(type, data) => rs.appendEvent(taskId, ++seq, type, data)`)在**同步分配 seq、立刻发起 insert**。
|
|
79
79
|
* 主循环 await 自己的写,所以主循环内部有序;但只要有**一个 fire-and-forget 写者**(子代 forward 帧、
|
|
80
|
-
*
|
|
80
|
+
* [ref] 的通告口),它的 N 号 insert 可能在池化 SQL 后端上晚于后发的 N+1 号提交。events tail 的读法是
|
|
81
81
|
* `getEvents(id, afterSeq)` —— 读到 N+1 就把游标推过 N,**那一行此后永远不会被投递**(重连也不会,
|
|
82
82
|
* 游标只前进)。行在库里,消费端结构性看不见。
|
|
83
83
|
*
|
|
@@ -93,11 +93,11 @@ export declare function createLedgerSink(opts: {
|
|
|
93
93
|
/** TRACE_THINKING gate: reasoning deltas are buffered (later redacted+persisted) only when true (core [R57] —
|
|
94
94
|
* persisting CoT is a deployment decision). Both legs pass the SAME config source (`config.traceThinking`). */
|
|
95
95
|
persistThinking: boolean;
|
|
96
|
-
/** task_notification dedup ledger (core [
|
|
96
|
+
/** task_notification dedup ledger (core [ref]④a seq-folded keys). The bg leg passes its per-leg instance
|
|
97
97
|
* (shared with its observer/drain arms so no arm double-appends a key another arm delivered); a leg with no
|
|
98
98
|
* other durable arms (sync detach lane) omits it and gets a private instance. */
|
|
99
99
|
notifiedKeys?: NotifiedKeys;
|
|
100
|
-
/**
|
|
100
|
+
/** [ref] S1:turn 活性打点(`recordTurnActivity(taskId)`)。打点位有两处且都必须:①`onEvent` 入口
|
|
101
101
|
* ——**text_delta/reasoning_delta 只进内存缓冲、到 flush 边界才 append**(codex S1-F1,2026-08-13:
|
|
102
102
|
* 只打 append 会让长时间流式输出被误读成「无进展」,方向与本键的设计目的正好相反);②`append`
|
|
103
103
|
* 入口——兜住不经 onEvent 的直写路径(appendParked/appendDone/onForwardEvent)。分诊提示性回调:
|