@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] 件二+件三 —— **装配自证**域:启动期静态自检(拒启判据)与 operator 诊断读面
|
|
3
3
|
* (`GET /v1/diagnostics/wiring`)。
|
|
4
4
|
*
|
|
5
5
|
* 🔴 两件为什么同住一个模块:它们回答的是同一个问题(「这台 worker 到底接了什么线」),只是一个在 boot
|
|
@@ -81,7 +81,7 @@ export declare function assertStaticWiringConsistent(facts: StaticWiringFacts, l
|
|
|
81
81
|
warn: (msg: string, meta?: Record<string, unknown>) => void;
|
|
82
82
|
} | undefined): StaticWiringAudit;
|
|
83
83
|
/**
|
|
84
|
-
* [
|
|
84
|
+
* [ref]③ clay 裁 (b)(2026-08-12,core [ref]④ + cli [ref]① 双背书):**零凭证 turnkey 形**的
|
|
85
85
|
* loopback 来源门判据(单一属主,端点与测试同吃)。
|
|
86
86
|
*
|
|
87
87
|
* 只在「operator 名单空 ∧ 非多租户 ∧ 全局 service-credential 门也不在场(没配 SERVICE_AUTH_TOKEN /
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— sandbox-image-pool 控制面(IMAGE-API-DESIGN.md)。
|
|
3
3
|
*
|
|
4
4
|
* 路由:P2 bake 作业面 `/v1/images/bakes*`(提交/列表/详情/事件 SSE/取消/claim/ingest)与 P1 镜像索引
|
|
5
5
|
* `/v1/images*`(digests/profile/select)。**bakes 段必须排在 images 段之前**——P1 的单段 profile 正则会把
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— v2 leader 端点([ref])。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`POST /v1/leader`(异步,形同 `/v1/runs`)· `GET /v1/leader/:id`。整域由 `deps.leaderEndpoint`
|
|
5
5
|
* 的存在与否开关;身份层与 `/v1/runs` 同款(BL-4:此前整条路跳过 authorize/requirePrincipal 且不记 owner,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* `importMemoryBundle`,
|
|
2
|
+
* [ref] v2-c —— **治理携出 bundle 的 operator 面**(core 5.40.0 `MemoryEngine.exportMemoryScopes` /
|
|
3
|
+
* `importMemoryBundle`,[ref] v2-c;判据帖 [ref] G1/G2/G3)。
|
|
4
4
|
*
|
|
5
5
|
* · `POST /v1/memory/export` —— 请求 `{scopes: string[]}`,回**治理完备包**(bundle 原样);
|
|
6
6
|
* · `POST /v1/memory/import` —— 请求 `{bundle}`,回 `MemoryImportReport` 的白名单投影。
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
* SQL 孪生补齐两面是上游/本仓 store 层的独立工单(消费台账 debt 行)。
|
|
38
38
|
*
|
|
39
39
|
* ── 验型的分权:server 验**形**,core 验**义** ─────────────────────────────────────────────────
|
|
40
|
-
* 本层只用 zod 校 JSON **结构**(宪法 [
|
|
40
|
+
* 本层只用 zod 校 JSON **结构**(宪法 [ref]:边界必 schema、禁裸 as-cast)。scopes 的「非空/去重/
|
|
41
41
|
* 元素非空」与 bundle 的整包判决(section hash 键集、逐条目 rev 重算、批内唯一性、scope 授权信封)
|
|
42
42
|
* **全部**归 core —— 在本层抄一遍等于第二真源:core 收紧一格我方不会跟着动,而两边都"绿"。
|
|
43
43
|
* 于是 `{scopes:["a","a"]}` 这种**形对义错**的请求会走到引擎并带回 `config.memory_export_request`。
|
|
44
44
|
*
|
|
45
|
-
* ── 披露的传导([
|
|
45
|
+
* ── 披露的传导([ref] 权威句;打分帖 [ref] 扣点① 的 server 半场)────────────────────────────
|
|
46
46
|
* bundle 体里的 `doc: string[]` 是**铸包方的治理披露**(自由串字面的租户隔离界限等),core 铸包时恒
|
|
47
47
|
* 写入。本面把它**原样透传**:不剥离、不复述、不另铸 `disclosure` 键。理由是单一属主 —— 复述会随
|
|
48
48
|
* core 版本漂移,而转发即真话。端点文档(openapi 段 + docs/ASSISTANT-WIRE-CONTRACT.md)负责告诉消费方
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* `eraseMemoryEntries`,
|
|
2
|
+
* [ref] 件③ —— **出处 / 抹除合规面的 operator 两口**(core 5.57.0 `MemoryEngine.provenanceOf` /
|
|
3
|
+
* `eraseMemoryEntries`,[ref] v2-a / v2-b)。
|
|
4
4
|
*
|
|
5
5
|
* · `GET /v1/memory/entries/:entryId/provenance` —— 回 `EntryProvenanceAccount` 原样;
|
|
6
6
|
* · `POST /v1/memory/erase` —— 请求 `{requestId, select, allowUnevidenced?}`,回
|
|
7
7
|
* `MemoryErasureAttestation` 原样。
|
|
8
8
|
*
|
|
9
9
|
* ── 为什么是 operator-only ─────────────────────────────────────────────────────────────────────
|
|
10
|
-
* 与
|
|
10
|
+
* 与 [ref] 的 bundle 两口同族(memory-bundle.ts 的同名段):
|
|
11
11
|
* · erase 是**治理写面**,而且是本族里爆炸半径最大的一口 —— 整 scope / 整会话删除是**合法**选择子,
|
|
12
12
|
* 而 core 的大规模删除熔丝对它**显式不适用**(engine.d.ts:684 逐字:那道熔丝守的是「文件在 harvest
|
|
13
13
|
* 时悄悄不见了」的事故形,一次显式授权的抹除靠在收执里逐 id 列举来自证);
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
* 一次**人的**授权表态(「我接受没有证据的删除」),中间层替他勾上就是替他签字。
|
|
64
64
|
*
|
|
65
65
|
* ── 验型的分权:server 验**形**,core 验**义**(同 memory-bundle.ts)────────────────────────────
|
|
66
|
-
* 本层只用 zod 校 JSON **结构**(宪法 [
|
|
66
|
+
* 本层只用 zod 校 JSON **结构**(宪法 [ref]:边界必 schema、禁裸 as-cast)。三选一选择子的判决
|
|
67
67
|
* (恰好一个 ids/scope/sessionId、ids 非空去重、allowUnevidenced 是布尔…)**全部**归 core 的
|
|
68
68
|
* `erasureRequestInvalid` —— 在本层抄一遍等于第二真源。于是 `{ids:[…], scope:…}` 这种**形对义错**的请求
|
|
69
69
|
* 会走到引擎并带回 `config.memory_erasure_request`。
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
* memory-bundle 同族,申明在 test/billable-route-declaration.test.ts)。
|
|
73
73
|
*
|
|
74
74
|
* ── 改写门(`isCredentialGatedRewrite`):**两口都进** ──────────────────────────────────────────
|
|
75
|
-
* 该门自
|
|
75
|
+
* 该门自 [ref] 起的判据是「持久改写 **或** 授权唯一输入是 principal 头、且**没有属主门兜底**的治理面」:
|
|
76
76
|
* · `POST /v1/memory/erase` 落在**前**一项上,而且是最深的一种:它把条目从本店**删掉**。自造一个在册
|
|
77
77
|
* operator 头即可对任一租户执行一次不可撤销的删除 —— 无凭证部署上缺的正是「上游会验这个头」这个前提。
|
|
78
|
-
* · `GET …/:entryId/provenance` 落在**后**一项上。🔴 这一条**推翻了
|
|
78
|
+
* · `GET …/:entryId/provenance` 落在**后**一项上。🔴 这一条**推翻了 [ref] §3 的原始裁定**
|
|
79
79
|
* (稿子把它豁免在门外,理由是「爆炸半径=一条」);codex 交叉复审 [high] 指出该理由站不住,亲验后采信:
|
|
80
80
|
* ⑴ 稿子援引来类比的两条豁免读(`GET /v1/adoption/:id` / `GET /v1/rules`)在门外的**真正**原因是
|
|
81
81
|
* 它们各有**属主门**兜底,不是「读得少」;本口的授权判据就只有 `explicitOperatorOk`,过了就直接答;
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
* 先例逐字同源:`POST /v1/memory/export` 当初也「按原措辞本不该进」,同一条论证把它收了进来
|
|
86
86
|
* ——「把它留在门外只为守住一句措辞,是把措辞看得比它要保护的东西更重」。
|
|
87
87
|
* 🔴 判据里**刻意不写**「本口 side-effect-free」:那不是这道门的判据。该门拦的是「授权的唯一输入是
|
|
88
|
-
* 一个可自造的头」这件事 —— 用「没有副作用」当豁免理由,正是
|
|
88
|
+
* 一个可自造的头」这件事 —— 用「没有副作用」当豁免理由,正是 [ref] 那次把 `POST /v1/memory/export`
|
|
89
89
|
* (纯读、跨租户全库)漏在门外的那句话。
|
|
90
90
|
* ⚠️ 代价与补偿如实成文:无凭证部署上两口都答 503 `auth.service_token_required`。补偿是**既有旋钮、
|
|
91
91
|
* 零新增** —— 配 `SERVICE_AUTH_TOKEN`(正路),或本地开发显式 `ALLOW_UNAUTHED_WRITES=true`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] D2/D3(316 车C)—— 记忆 **consolidation 阀门**的 operator 两口:
|
|
3
3
|
*
|
|
4
4
|
* · `POST /v1/admin/memory/consolidation/run` —— 跑(或**续跑**)一轮,同步回一份收执**摘要投影**;
|
|
5
5
|
* · `GET /v1/admin/memory/consolidation` —— D3 状态投影(阀门、座位、scope 表、上一轮的账)。
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* `listOriginClearances` / `clearEntryOrigin`,
|
|
2
|
+
* [ref] 件② —— **外源标记人面的 operator 三口**(core 5.59.0 `MemoryEngine.listExternalOriginEntries` /
|
|
3
|
+
* `listOriginClearances` / `clearEntryOrigin`,[ref] §13-4①②)。
|
|
4
4
|
*
|
|
5
5
|
* · `GET /v1/memory/origin/external?scopes=a,b` —— 点名 scope 里每一条带外源标记的条目 + 出处账;
|
|
6
6
|
* · `GET /v1/memory/origin/clearances` —— 清标审计账(**白名单投影**,见下);
|
|
7
7
|
* · `POST /v1/memory/origin/entries/:entryId/clear` `{requestId, reason}` —— 审计化的 UN-MARK 阀门。
|
|
8
8
|
*
|
|
9
9
|
* ── 为什么是 operator-only ─────────────────────────────────────────────────────────────────────
|
|
10
|
-
* 与件③(memory-compliance.ts)
|
|
10
|
+
* 与件③(memory-compliance.ts)、[ref] 的 bundle 两口同族:
|
|
11
11
|
* · 前两口是**跨租户治理读**:一次调用取回任意 scope 的条目 + 每条的完整出处账(贡献会话 id、污染
|
|
12
12
|
* 理由、托管链事件),按定义超出任何单个 principal 的自助边界;
|
|
13
13
|
* · clear 是**治理写面**,而且是记忆域里语义最重的一次表态 —— 它把「这条记忆来自外部、用前先核」
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* compliance 两族刻意不同字,因为要查的旋钮不是同一个(那两族自己的头注就吃过复用文案的亏)。
|
|
27
27
|
*
|
|
28
28
|
* ── `scopes` 为什么必须由调用方给(F-13 的诚实形)──────────────────────────────────────────────
|
|
29
|
-
* 🔴 本仓**今天没有任何 scope 枚举读面**。core 5.59.0 长出了 `listMemoryScopes`(
|
|
29
|
+
* 🔴 本仓**今天没有任何 scope 枚举读面**。core 5.59.0 长出了 `listMemoryScopes`([ref]③:File 腿在场、
|
|
30
30
|
* SQL 腿是 core 候升件,且带「backend 是否支持枚举」判别位——不支持**永不读作零**),但本仓尚未接线。
|
|
31
31
|
* 于是 v1 的形是:scope 名**显式提供**,缺参 400 并**指路来源**。
|
|
32
32
|
* 为什么不给一个默认名单(比如「本部署配过的那些」):污染审计的价值全在**发现链闭合**,而不完备是
|
|
@@ -45,23 +45,23 @@
|
|
|
45
45
|
* = `entryText`,逐字写理由):core 加一个键 ⇒ TS2344 ⇒ 由人处置,而不是悄悄上 wire 或悄悄漏掉。
|
|
46
46
|
* 🔴 白名单是**深**的,不是只做一层(codex 交叉复审 [high] 抓的第一版病):嵌套的 `origin` 也逐键投影
|
|
47
47
|
* —— 一层白名单 + 一个整只透传的嵌套对象,等于给这条排除留了一个旁路,全文见 {@link buildOriginWire}。
|
|
48
|
-
* 🔴 **剥了不等于不说**:投影补一个 `custodyBytes`(托管字节数)。这是
|
|
48
|
+
* 🔴 **剥了不等于不说**:投影补一个 `custodyBytes`(托管字节数)。这是 [ref] absence-reports-not-silent-green
|
|
49
49
|
* 在本口的落法 —— operator 判「这个 pending 行还揣着一条记忆吗」只需要这一位;悄悄把整个托管概念从
|
|
50
50
|
* 审计面上抹掉,会让一个**必须由人处置**的崩溃恢复席看上去不存在。
|
|
51
51
|
*
|
|
52
|
-
* ── 拒因族:**闭集逐码 switch**(
|
|
53
|
-
* 见 {@link sentClearCode} 的头注(逐码状态与理由、以及 core 真形与
|
|
52
|
+
* ── 拒因族:**闭集逐码 switch**([ref] 码族)────────────────────────────────────────────────────
|
|
53
|
+
* 见 {@link sentClearCode} 的头注(逐码状态与理由、以及 core 真形与 [ref] 稿面的**一处偏差**)。
|
|
54
54
|
*
|
|
55
55
|
* 计费/lane:三口都是**部署级治理动作**,零模型工作 ⇒ `billable=false`(与 adoption / retention-ops /
|
|
56
56
|
* memory-bundle / memory-compliance 同族,申明在 test/billable-route-declaration.test.ts)。
|
|
57
57
|
*
|
|
58
58
|
* ── 改写门(`isCredentialGatedRewrite`):**三口全进** ──────────────────────────────────────────
|
|
59
|
-
* 该门自
|
|
59
|
+
* 该门自 [ref] 起的判据是「持久改写 **或** 授权唯一输入是 principal 头的跨租户治理读」:
|
|
60
60
|
* · `POST …/clear` 落在**前**一项:它把一条条目的外源披露**永久摘掉**(墓碑 + 同 id 重录),自造一个
|
|
61
61
|
* 在册 operator 头即可让任意租户的一条外来记忆看上去是本店自产的 —— 而记忆是模型每次挂载都读的面;
|
|
62
62
|
* · `GET …/external` 落在**后**一项,而且是这一族里爆炸半径最大的读:一次调用取回**任意 scope**的
|
|
63
63
|
* 条目 + 每条的完整出处账(贡献会话 id、污染理由、仓内 ingest 路径与内容哈希、托管链事件)。判据与
|
|
64
|
-
* `POST /v1/memory/export`(
|
|
64
|
+
* `POST /v1/memory/export`([ref] 收进门的那条纯读)逐字同构:它没有属主门兜底,operator 头过了就直接答。
|
|
65
65
|
* · `GET …/clearances` —— 🔴 **本车第一版把它留在门外,codex 交叉复审 [high] 推翻,亲验后采信**。
|
|
66
66
|
* 那一版的理由是「投影后不含条目正文,爆炸半径差一个量级」,而这个理由**用错了基准**:本门的判据
|
|
67
67
|
* 从来不是「含不含正文」,而是「授权的**唯一**输入是 principal 头」∧「没有属主门兜底」。按那条判据,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— memory 导出/同步 + 只读策略面。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`GET /v1/memory/export`、`POST /v1/memory/sync/:scope`、`GET /v1/policy`。
|
|
5
5
|
* owner 门 = 「本人 user scope / 显式 operator / `org:` 键的目录成员」(见 {@link gateMemoryScope}),
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
9
9
|
import type { RouteCtx } from "../route-ctx.js";
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* [ref] 件3([ref] A2 车立的欠账,[ref] 我方认领)—— `GET /v1/memory/export` 的 keyset 分页上限。
|
|
12
12
|
*
|
|
13
|
-
* 在此之前本面是**整盘导出**:一个几千条目的盘就是一个几 MB 的响应体,壳侧(sema-web 只读页)
|
|
13
|
+
* 在此之前本面是**整盘导出**:一个几千条目的盘就是一个几 MB 的响应体,壳侧(sema-web-admin 只读页)
|
|
14
14
|
* 无从分次要 —— 那是它真实撞到的天花板。分页是 **additive** 的:`?limit=` 缺席 ⇒ 旧契约逐字不变
|
|
15
15
|
* (全量数组、响应键一个不多),所以现行消费端零破坏;要分页的调用方自己带 `limit` 进来。
|
|
16
16
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— 会话外事件注入 / 唤醒([ref] §2 §3)。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`POST /v1/sessions/:id/notify`(external-notification-bridge 的 HTTP 入站门:live 走 core
|
|
5
5
|
* `TaskStream.notify()`,idle 走 inbox park,下次开流 drain)、`POST /v1/sessions/:id/wake`(对 task_done
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] 车2 —— **托管留存的 operator 治理面**(设计稿 `docs/DESIGN-270-retention-lane.md` §5/§6)。
|
|
3
3
|
*
|
|
4
4
|
* · `PUT /v1/ops/retention/holds/:domain` —— 放置 legal hold;
|
|
5
5
|
* · `DELETE /v1/ops/retention/holds/:domain` —— 解除;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] 车二 + [ref] §2 —— **规则车道的 wire 面**([ref] §7 的导入半场 + [ref] 的撤销半场)。
|
|
3
3
|
*
|
|
4
4
|
* POST /v1/rules/cc-import/prepare → 预览 + 一张**一次性、principal 绑定、有期、载荷绑定**的票
|
|
5
5
|
* POST /v1/rules/cc-import/redeem → 原子消费票 → confirm → 批量兑付进店
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* 因此**导入两口**只认已验明的 principal,连 `explicitOperatorOk` 的旁路都不给:一个 operator 想给
|
|
12
12
|
* 自己导规则,用他自己的 principal 走同一条路即可(那时他就是租户)。
|
|
13
13
|
*
|
|
14
|
-
* 🔴 **撤销面两口多一条 operator 超范围域,而这不是上面那句话的例外,是它的对偶**(
|
|
14
|
+
* 🔴 **撤销面两口多一条 operator 超范围域,而这不是上面那句话的例外,是它的对偶**([ref] §2 设计题
|
|
15
15
|
* 一裁定):`?principal=` / body 里的 `principal` 让 operator 读**或收回**任一租户的规则。方向决定授权:
|
|
16
16
|
* 收回是**收紧**(core 的 `removePersistedRule` 头注逐字:「a host may narrow on a user's behalf, it may
|
|
17
17
|
* not widen」),而多租户管理员能回收权限正是撤销面的本义。读那一半同样只开给 operator ——
|
|
@@ -29,7 +29,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
29
29
|
import type { RouteCtx } from "../route-ctx.js";
|
|
30
30
|
export declare const RULES_CC_IMPORT_PREPARE_PATH = "/v1/rules/cc-import/prepare";
|
|
31
31
|
export declare const RULES_CC_IMPORT_REDEEM_PATH = "/v1/rules/cc-import/redeem";
|
|
32
|
-
/**
|
|
32
|
+
/** [ref] A7:File 规则直通票口两条(与 cc-import 两口并列,票语义分家见 `rules-consent.ts` 的 A7 段)。 */
|
|
33
33
|
export declare const RULES_LOCAL_IMPORT_PREPARE_PATH = "/v1/rules/local-import/prepare";
|
|
34
34
|
export declare const RULES_LOCAL_IMPORT_REDEEM_PATH = "/v1/rules/local-import/redeem";
|
|
35
35
|
/** 撤销面两口共用的字面路径(GET 列举 / DELETE 撤销)。 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] §2.1 / §3.4 S-8①(server [ref];[ref] 认领)—— **中途翻转 verb** 的 wire 面:
|
|
3
3
|
*
|
|
4
4
|
* `POST /v1/runs/:id/memory/capture-optout` body `{ reason?: string }`
|
|
5
5
|
* → 200 `{ taskId, sessionId, outcome: "created" | "existed" }`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— 异步 run 面与它的全部动词。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`POST /v1/runs`(异步提交)· `GET /v1/runs/:id[/events]`(轮询 / 可恢复 SSE)· 运行期动词
|
|
5
5
|
* `cancel` / `steer` / `compact` / `detach` · 子代理面 `subagents/:target/{steer,resume,output,stream}` ·
|
|
@@ -22,8 +22,8 @@ export declare const RUN_DETACH_RE: RegExp;
|
|
|
22
22
|
export declare const RUN_COMPACT_RE: RegExp;
|
|
23
23
|
export declare const RUN_INTERRUPT_RE: RegExp;
|
|
24
24
|
/** PAIR-REVIEW F-10:runs 面 404 文案统一富形——a\* 形 id(background-agent registry 句柄,`a`+hex 短形)
|
|
25
|
-
* 是「结构性不在 run 店」的常客([
|
|
26
|
-
* 非 a\* 形保通用富文案(cancel 腿 [
|
|
25
|
+
* 是「结构性不在 run 店」的常客([ref]⑤ 记档裁量:不改路由,只给引导)。识别句法形即补引导;
|
|
26
|
+
* 非 a\* 形保通用富文案(cancel 腿 [ref]① 同款)。 */
|
|
27
27
|
export declare const ELICIT_RESPOND_RE: RegExp;
|
|
28
28
|
export declare const QUESTION_RESPOND_RE: RegExp;
|
|
29
29
|
export declare const TOOL_APPROVAL_RESPOND_RE: RegExp;
|
package/dist/http/routes/runs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { uuidv7, mintCheckpointToken, CheckpointError, validatePendingSteer } from "@sema-agent/core";
|
|
3
3
|
import { isTerminalRunStatus, isParkedRunStatus } from "../../plugins/store-contracts.js";
|
|
4
|
+
import { LIVE_RUN_GATE_KINDS, TERMINAL_PARK_GATE_KINDS } from "../../plugins/checkpoint-store-sql.js";
|
|
4
5
|
import { redactSecrets } from "../../trace/redact.js";
|
|
5
6
|
import { HttpError, verifiedPrincipal, isUuidV7, encodeCheckpointScope } from "../../security.js";
|
|
6
7
|
import { runInBackground } from "../../runs.js";
|
|
@@ -286,7 +287,7 @@ async function handleRunsBody(req, res, url, ctx, miss) {
|
|
|
286
287
|
const cs = deps.checkpointStore;
|
|
287
288
|
let note = "cancelled while suspended (pending approval settled)";
|
|
288
289
|
if (cs) {
|
|
289
|
-
const token = await cs.findPendingTokenBySession(run.sessionId);
|
|
290
|
+
const token = await cs.findPendingTokenBySession(run.sessionId, undefined, { gateKinds: LIVE_RUN_GATE_KINDS });
|
|
290
291
|
if (token) {
|
|
291
292
|
const cp = await cs.get(token);
|
|
292
293
|
const won = cp ? await cs.expire(token, cp.scope) : false;
|
|
@@ -459,10 +460,11 @@ async function handleRunsBody(req, res, url, ctx, miss) {
|
|
|
459
460
|
const cs = deps.checkpointStore;
|
|
460
461
|
if (!cs)
|
|
461
462
|
return "no-store";
|
|
462
|
-
const
|
|
463
|
+
const parkBinding = { gateKinds: LIVE_RUN_GATE_KINDS };
|
|
464
|
+
const scope = await cs.peekPendingScope(run.sessionId, parkBinding);
|
|
463
465
|
if (scope === null || scope === undefined)
|
|
464
466
|
return "no-checkpoint";
|
|
465
|
-
const token = await cs.findPendingTokenBySession(run.sessionId, scope);
|
|
467
|
+
const token = await cs.findPendingTokenBySession(run.sessionId, scope, parkBinding);
|
|
466
468
|
if (!token)
|
|
467
469
|
return "no-checkpoint";
|
|
468
470
|
try {
|
|
@@ -627,7 +629,7 @@ async function handleRunsBody(req, res, url, ctx, miss) {
|
|
|
627
629
|
mintResult.noResumeCtx = true;
|
|
628
630
|
return;
|
|
629
631
|
}
|
|
630
|
-
const winner = await cs.findPendingTokenBySession(run.sessionId).catch(() => null);
|
|
632
|
+
const winner = await cs.findPendingTokenBySession(run.sessionId, undefined, { gateKinds: TERMINAL_PARK_GATE_KINDS, pick: "oldest" }).catch(() => null);
|
|
631
633
|
if (winner !== null && winner !== wakeToken) {
|
|
632
634
|
await cs.expire(wakeToken, cpScope).catch(() => undefined);
|
|
633
635
|
await parkOnce(winner, cpScope);
|
|
@@ -1347,11 +1349,8 @@ async function handleRunVerbsBody(req, res, url, ctx, miss) {
|
|
|
1347
1349
|
return true;
|
|
1348
1350
|
if (deps.toolApproval?.editedDecisionInFlight(row.askId) === true)
|
|
1349
1351
|
return true;
|
|
1350
|
-
const settled = deps.toolApproval?.notifyExternalDecision(row.askId, row.decision === "approve");
|
|
1352
|
+
const settled = deps.toolApproval?.notifyExternalDecision(row.askId, row.decision === "approve", row.updatedInput);
|
|
1351
1353
|
observedSettled.set(row.askId, settled?.settled ?? 0);
|
|
1352
|
-
if (row.decision === "approve" && (settled?.settled ?? 0) > 0) {
|
|
1353
|
-
recordFailOpen("server.hitl.row-derived-approve-drops-updated-input", "runs:sync-live-from-decided-row");
|
|
1354
|
-
}
|
|
1355
1354
|
return true;
|
|
1356
1355
|
};
|
|
1357
1356
|
const decisionNoteEcho = (row) => (row.decisionNote === null ? {} : { decisionNote: row.decisionNote });
|
|
@@ -1431,11 +1430,6 @@ async function handleRunVerbsBody(req, res, url, ctx, miss) {
|
|
|
1431
1430
|
sendTerminal(row0);
|
|
1432
1431
|
return;
|
|
1433
1432
|
}
|
|
1434
|
-
if (body.decision === "approve" && hasUpdatedInput && (deps.toolApproval?.liveConsumerCount(askId) ?? 0) === 0) {
|
|
1435
|
-
deps.logger?.warn?.("ask_decision_edit_undeliverable", { taskId, askId });
|
|
1436
|
-
sendError(res, 409, "conflict.ask_edit_undeliverable", "this decision carries an edited input but no live approval waiter for this ask exists on THIS replica — the edit cannot be bound to the decision (the durable ask row has no field for it), so committing would run the ORIGINAL input instead. Nothing was decided: re-send without updatedInput to approve the original as-is, or send the decision to the replica holding this ask (the live POST /v1/tool-approvals/:approvalId/respond leg is always same-replica)");
|
|
1437
|
-
return;
|
|
1438
|
-
}
|
|
1439
1433
|
let outcome;
|
|
1440
1434
|
const releaseEditMark = body.decision === "approve" && hasUpdatedInput ? deps.toolApproval?.markEditedDecisionInFlight(askId) : undefined;
|
|
1441
1435
|
try {
|
|
@@ -1444,6 +1438,7 @@ async function handleRunVerbsBody(req, res, url, ctx, miss) {
|
|
|
1444
1438
|
decisionActor: actor,
|
|
1445
1439
|
decisionNote: body.note ?? null,
|
|
1446
1440
|
idempotencyKey: body.idempotencyKey ?? null,
|
|
1441
|
+
...(body.decision === "approve" && hasUpdatedInput ? { updatedInput: body.updatedInput } : {}),
|
|
1447
1442
|
});
|
|
1448
1443
|
}
|
|
1449
1444
|
catch (err) {
|
|
@@ -1464,7 +1459,7 @@ async function handleRunVerbsBody(req, res, url, ctx, miss) {
|
|
|
1464
1459
|
confirmed.decision === body.decision &&
|
|
1465
1460
|
confirmed.idempotencyKey === body.idempotencyKey &&
|
|
1466
1461
|
!confirmed.provisional) {
|
|
1467
|
-
const settledNow = deps.toolApproval.notifyExternalDecision(askId, confirmed.decision === "approve",
|
|
1462
|
+
const settledNow = deps.toolApproval.notifyExternalDecision(askId, confirmed.decision === "approve", confirmed.updatedInput).settled;
|
|
1468
1463
|
deps.logger?.warn?.("ask_decision_edit_settled_after_ambiguous_commit", { taskId, askId, settled: settledNow });
|
|
1469
1464
|
}
|
|
1470
1465
|
}
|
|
@@ -1503,12 +1498,12 @@ async function handleRunVerbsBody(req, res, url, ctx, miss) {
|
|
|
1503
1498
|
return;
|
|
1504
1499
|
if (outcome.row.decision !== body.decision) {
|
|
1505
1500
|
deps.logger?.error?.("ask_decision_row_diverged", { taskId, askId, requested: body.decision, stored: outcome.row.decision });
|
|
1506
|
-
deps.toolApproval?.notifyExternalDecision(outcome.row.askId, outcome.row.decision === "approve");
|
|
1501
|
+
deps.toolApproval?.notifyExternalDecision(outcome.row.askId, outcome.row.decision === "approve", outcome.row.updatedInput);
|
|
1507
1502
|
sendError(res, 500, "internal.error", "the ask row was rewritten between commit and read-back — the decision that stands is not the one this request submitted; re-read the ask before acting on it");
|
|
1508
1503
|
return;
|
|
1509
1504
|
}
|
|
1510
|
-
const settled = deps.toolApproval?.notifyExternalDecision(outcome.row.askId, outcome.row.decision === "approve",
|
|
1511
|
-
const forwarded = outcome.row.decision === "approve" &&
|
|
1505
|
+
const settled = deps.toolApproval?.notifyExternalDecision(outcome.row.askId, outcome.row.decision === "approve", outcome.row.updatedInput).settled ?? 0;
|
|
1506
|
+
const forwarded = outcome.row.decision === "approve" && outcome.row.updatedInput !== undefined && settled > 0;
|
|
1512
1507
|
sendJson(res, 200, {
|
|
1513
1508
|
askId: outcome.row.askId,
|
|
1514
1509
|
taskId: outcome.row.taskId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— 2c session-sync 面(sema-internal server/docs/DESIGN-session-sync.md §15 + §5–§10)。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`/v1/sessions/:id/sync/{manifest,entries,import,plan,blobs,snapshots/:k/blobs/:b,import/:staging/entries}`。
|
|
5
5
|
* 每条都像 fork/delete 一样 owner-gated;无持久 session store 时 501(能力面与路由解析同真值)。
|
|
@@ -17,7 +17,7 @@ export type PendingStaging = {
|
|
|
17
17
|
owner: string | null;
|
|
18
18
|
resolution?: "overwrite-dst";
|
|
19
19
|
operatorOk: boolean;
|
|
20
|
-
/**
|
|
20
|
+
/** [ref]: the session's file-history envelope (or null — no history travelled). Replaces the E19 per-key manifests. */
|
|
21
21
|
fileHistory: FileHistoryExport | null;
|
|
22
22
|
policy: SessionRulesRecord[];
|
|
23
23
|
anchors: Array<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— 单会话面。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`/v1/sessions/:id` 的 init / settings / mcp / head / events(SSE)/ fork / DELETE / policy / workspace,
|
|
5
5
|
* 外加同段的 `deps.sessionAudit` 只读审计面。
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* `sse.sseConnections` / `sse.sseOwnerLookups`——`let` 无法跨模块共享自增。判据/时机/配对释放逐字未动。
|
|
13
13
|
*/
|
|
14
14
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
15
|
+
import { type SessionMemoryStatus } from "@sema-agent/core";
|
|
15
16
|
import type { RouteCtx } from "../route-ctx.js";
|
|
16
17
|
/** 单域独占状态。每个 server 实例一份——模块级会把连接坑/缓存跨实例串味。 */
|
|
17
18
|
export interface SessionsLocal {
|
|
@@ -36,6 +37,13 @@ export interface SessionsLocal {
|
|
|
36
37
|
degraded?: boolean;
|
|
37
38
|
}>;
|
|
38
39
|
}>;
|
|
40
|
+
/** [ref]①:memory-status 读面的短 TTL single-flight 缓存(理由见 `MEMORY_STATUS_TTL_MS` 注)。
|
|
41
|
+
* 键 = sessionId **裸键**(答案与调用方无关 —— 属主门在缓存读**之前**跑,外人到不了这张表;
|
|
42
|
+
* mcp/a2a 按 (scenario, principal) 分键是因为它们的面按人裁,这张面不按人裁,分键只会白扩表)。 */
|
|
43
|
+
memoryStatusCache: Map<string, {
|
|
44
|
+
at: number;
|
|
45
|
+
status: Promise<SessionMemoryStatus>;
|
|
46
|
+
}>;
|
|
39
47
|
}
|
|
40
48
|
export declare function createSessionsLocal(): SessionsLocal;
|
|
41
49
|
export declare function handleSessions(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
@@ -10,6 +10,7 @@ const MCP_STATUS_TTL_MS = 5_000;
|
|
|
10
10
|
const MCP_MATERIALIZE_TIMEOUT_MS = 10_000;
|
|
11
11
|
const A2A_STATUS_TTL_MS = 5_000;
|
|
12
12
|
const A2A_MATERIALIZE_TIMEOUT_MS = 10_000;
|
|
13
|
+
const MEMORY_STATUS_TTL_MS = 5_000;
|
|
13
14
|
const A2A_PANEL_MAX_TOOL_NAMES = 200;
|
|
14
15
|
export function createSessionsLocal() {
|
|
15
16
|
return {
|
|
@@ -17,6 +18,7 @@ export function createSessionsLocal() {
|
|
|
17
18
|
sseOwnerLookups: 0,
|
|
18
19
|
mcpStatusCache: new Map(),
|
|
19
20
|
a2aStatusCache: new Map(),
|
|
21
|
+
memoryStatusCache: new Map(),
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
export async function handleSessions(req, res, url, ctx) {
|
|
@@ -469,6 +471,64 @@ async function handleSessionsBody(req, res, url, ctx, miss) {
|
|
|
469
471
|
return;
|
|
470
472
|
}
|
|
471
473
|
}
|
|
474
|
+
{
|
|
475
|
+
const msm = req.method === "GET" ? /^\/v1\/sessions\/([^/]+)\/memory-status$/.exec(url) : null;
|
|
476
|
+
if (msm) {
|
|
477
|
+
const sessionId = safeDecode(msm[1]);
|
|
478
|
+
if (sessionId === null) {
|
|
479
|
+
sendError(res, 400, "request.path_malformed", "session id segment is not valid percent-encoding");
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (deps.config.requirePrincipal && !gatedPrincipal(req, deps.config)) {
|
|
483
|
+
sendError(res, 401, "auth.principal_required", `missing principal header '${deps.config.principalHeader}'`);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (!deps.sessionAudit) {
|
|
487
|
+
sendError(res, 501, "capability.memory_engine_required", "session memory status is not available on this deployment — it requires a wired memory engine (MEMORY_ENGINE=on) whose backend owns the engine control plane (controlPlaneRoot); the file memory backend does, the pg/tidb memory backends do not (their control plane would land on a replica's local disk)");
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const audit = await deps.sessionAudit(sessionId);
|
|
491
|
+
if (!audit) {
|
|
492
|
+
sendError(res, 404, "not_found.session", "session not found");
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (!runOwnerOk(req, res, audit.owner, "session"))
|
|
496
|
+
return;
|
|
497
|
+
const face = deps.sessionMemoryStatus;
|
|
498
|
+
if (face === undefined) {
|
|
499
|
+
sendError(res, 501, "capability.memory_engine_required", "session memory status is not available on this deployment — it requires a wired memory engine (MEMORY_ENGINE=on) whose backend owns the engine control plane (controlPlaneRoot); the file memory backend does, the pg/tidb memory backends do not (their control plane would land on a replica's local disk)");
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
try {
|
|
503
|
+
const { memoryStatusCache } = ctx.local.sessions;
|
|
504
|
+
let entry = memoryStatusCache.get(sessionId);
|
|
505
|
+
if (!entry || Date.now() - entry.at > MEMORY_STATUS_TTL_MS) {
|
|
506
|
+
if (memoryStatusCache.size > 1024)
|
|
507
|
+
memoryStatusCache.clear();
|
|
508
|
+
const status = face.status(sessionId);
|
|
509
|
+
const fresh = { at: Date.now(), status };
|
|
510
|
+
memoryStatusCache.set(sessionId, fresh);
|
|
511
|
+
status.catch(() => { if (memoryStatusCache.get(sessionId) === fresh)
|
|
512
|
+
memoryStatusCache.delete(sessionId); });
|
|
513
|
+
entry = fresh;
|
|
514
|
+
}
|
|
515
|
+
const s = await entry.status;
|
|
516
|
+
sendJson(res, 200, {
|
|
517
|
+
sessionId,
|
|
518
|
+
...(s.captureOptedOut !== undefined ? { captureOptedOut: s.captureOptedOut } : {}),
|
|
519
|
+
...(s.committedCount !== undefined ? { committedCount: s.committedCount } : {}),
|
|
520
|
+
...(s.foldedCount !== undefined ? { foldedCount: s.foldedCount } : {}),
|
|
521
|
+
...(s.optOutSource !== undefined ? { optOutSource: s.optOutSource } : {}),
|
|
522
|
+
...(s.lastCaptureAt !== undefined ? { lastCaptureAt: s.lastCaptureAt } : {}),
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
catch (err) {
|
|
526
|
+
deps.logger?.warn?.("session_memory_status_failed", { sessionId, err: String(err) });
|
|
527
|
+
sendError(res, 500, "internal.error", "session memory status read failed");
|
|
528
|
+
}
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
472
532
|
if (deps.sessionAudit && req.method === "GET") {
|
|
473
533
|
const sm = /^\/v1\/sessions\/([^/]+)$/.exec(url);
|
|
474
534
|
if (sm) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— sideQuery 一次性问答面([ref],core 1.361)。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`POST /v1/side-query` —— 无 session / 无工具执行 / 无 policy gate / 无引擎侧记账 / 无流式的
|
|
5
5
|
* 一次性 brain 路由问答(v1 刻意面 = core 规格 side-query.d.ts)。cli 壳侧十几个 utility(标题/摘要/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— 同步提交面 `POST /v1/tasks` / `POST /v1/tasks/stream`(+ [ref] B3 三腿具名化)。
|
|
3
3
|
*
|
|
4
4
|
* 一条路由两条腿:`/v1/tasks/stream` = SSE 活流(单次尝试,verify/cascade 在此 400);`/v1/tasks` = 同步等结果
|
|
5
5
|
* (verify / cascade / plain 三选一)。两腿共享同一个 Idempotency-Key 包装:先 `peek` 重放(含 IN-FLIGHT 的
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— Task Trace 只读面 + 用量统计面。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`GET /v1/tasks/source-summary`(跨租户 door 汇总,ops-only)、`GET /v1/tasks[/:id/{turns,stream,artifacts}]`
|
|
5
5
|
* (S1 Task Trace API)、`GET /v1/usage/{summary,series,breakdown}`(web P4 / registry AnalyticsSource)。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 域模块 —— S8 自编排 workflow 面([ref]/98)。
|
|
3
3
|
*
|
|
4
4
|
* 路由:`GET /v1/workflows`(列表)· `GET /v1/workflows/:id[/journal]`(详情)· `GET /v1/workflows/:id/stream`
|
|
5
5
|
* (在进程内 live SSE)· `POST /v1/workflows/:id/agents/:label/steer`(SVC-5:给 workflow 里某个仍在跑的
|
package/dist/http/run-meta.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 装配缝的一片小叶子 —— 提交路径共用的两个纯函数(run 行元数据 + cascade 配置)。
|
|
3
3
|
*
|
|
4
4
|
* 为什么单独成文件:`runMeta` 被 tasks 与 runs **两个**域模块调用,`cascadeConfig` 同理(还被测试直接引)。
|
|
5
5
|
* 挂在任一域模块上都会造出 routes/* 互相值 import 的第二条边;它们又是纯函数(只依赖入参 + redact 叶子),
|
package/dist/http/send.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* [ref] A9 seam — response senders, extracted VERBATIM out of `http/server.ts` so the per-domain route
|
|
3
3
|
* modules under `http/routes/` can call them without a value edge back into `server.ts` (that edge would close
|
|
4
4
|
* a runtime import cycle — see `test/module-cycle-gate.test.ts`).
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { ServerResponse } from "node:http";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* [ref](黑板 [ref]②)—— 一条响应「是 SSE 流」的**在场标记**。
|
|
13
13
|
*
|
|
14
14
|
* 引擎附着租约把**打开着的 SSE 流**当作壳的附着租约来数,于是 `handle()` 需要判「这条响应是不是流」。
|
|
15
15
|
* 🔴 **不能靠读回 content-type**(本机 node v24.2.0 实测):`res.writeHead(status, headersObject)` 直接
|
|
@@ -27,7 +27,7 @@ export declare function sseHeaders(res: ServerResponse, extra?: Record<string, s
|
|
|
27
27
|
* 一条 SSE 连接的墙钟上限。到点发一帧 `error`/`STREAM_MAX_DURATION`(**不是**静默关闭 —— 客户端分不出
|
|
28
28
|
* 「到帽了请重连」和「跑完了」)然后收流。
|
|
29
29
|
*
|
|
30
|
-
* 🔴 为什么共享(2026-08-08
|
|
30
|
+
* 🔴 为什么共享(2026-08-08,[ref] 二轮扫描 finding):这个数与下面的心跳间隔此前在**三处**各手抄一份
|
|
31
31
|
* —— `http/sse-log.ts`(task_run + image_bake 共用的那台泵)、`http/routes/trace-usage.ts`、
|
|
32
32
|
* `http/routes/approvals-assistant.ts`(它的顶注还自称「parity with streamTaskTrace」)。三处各自有测试
|
|
33
33
|
* 钉着**自己那一份**,没有任何跨副本的一致性钉 ⇒ 单边调帽后「parity」只剩注释里那句话。
|
|
@@ -40,14 +40,14 @@ export declare const SSE_MAX_STREAM_MS: number;
|
|
|
40
40
|
* 长时间无事件时的心跳间隔(防中继的 idle timeout 掐流)。与 {@link SSE_MAX_STREAM_MS} 同批收口。
|
|
41
41
|
*
|
|
42
42
|
* ⚠️ 收口的只有**间隔**,**不含帧形**:`sse-log` / `trace-usage` 发 `data: {}`,`approvals-assistant`
|
|
43
|
-
* 发 `data: {"type":"heartbeat"}`。这是真分歧不是笔误 —— trace-usage 自己的 meta 帧还引着 [
|
|
43
|
+
* 发 `data: {"type":"heartbeat"}`。这是真分歧不是笔误 —— trace-usage 自己的 meta 帧还引着 [ref]C-12
|
|
44
44
|
* 「每个 data payload 都带 type」的约定,而它的心跳帧没有 type(probe-sse-1 的注释把这条记成「按
|
|
45
45
|
* data.type 分派的客户端会拿到 undefined」)。统一帧形是**行为面**改动(要么给两处加 type=多发一个键,
|
|
46
46
|
* 要么给 approvals 减 type=消费端破坏),属候裁,不在本批的零行为码范围内。
|
|
47
47
|
*/
|
|
48
48
|
export declare const SSE_HEARTBEAT_IDLE_MS = 15000;
|
|
49
49
|
export declare function sendJson(res: ServerResponse, status: number, body: unknown): void;
|
|
50
|
-
/** A6(
|
|
50
|
+
/** A6([ref] lens1 §C3/lens3 §C3a): canonical error-response sender for sites that already carry a
|
|
51
51
|
* machine `errorCode` — `errorCode` is a required positional arg (not optional-bag) so a call site
|
|
52
52
|
* cannot regress to the "code but no errorCode" shape the error-code-key-gate forbids. Body shape is
|
|
53
53
|
* `{ error: message, errorCode, ...extra }`; a site that used to ALSO emit a legacy `code` key keeps it
|
|
@@ -56,7 +56,7 @@ export declare function sendJson(res: ServerResponse, status: number, body: unkn
|
|
|
56
56
|
* where `error`/`errorCode` aren't cleanly separable from the rest of the body, are left on raw
|
|
57
57
|
* `sendJson` (see the A6 migration notes for the callers still doing that on purpose). */
|
|
58
58
|
export declare function sendError(res: ServerResponse, status: number, errorCode: string, message: string, extra?: Record<string, unknown>): void;
|
|
59
|
-
/** B7(
|
|
59
|
+
/** B7([ref] lens1 §C3):`HttpError` 的兜底 catch-all 站点没有自己的语义分支——`err.code` 在 42 个
|
|
60
60
|
* throw 点里只有 3 个带。为了让「errorCode 恒在」在这些站点也成立(而不是靠豁免表放行),按**状态码**
|
|
61
61
|
* 给一个诚实的粗码:它只声明「这类拒绝」,不冒充比 throw 点更细的语义。带 `code` 的 throw 点原样优先。 */
|
|
62
62
|
export declare function httpErrorCode(status: number, code?: string): string;
|