@sema-agent/server 7.137.0 → 7.139.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/MIGRATION.md +600 -142
- package/README.md +7 -3
- package/README.zh-CN.md +6 -3
- package/USAGE.md +132 -41
- package/deploy/sema-up/README.md +1 -1
- package/deploy/sema-up/lib/lanes.json +3 -2
- package/dist/adoption/wire.d.ts +3 -3
- package/dist/approval-card.d.ts +23 -16
- package/dist/approval-card.js +1 -0
- package/dist/audit.js +1 -0
- package/dist/background-agent-name.d.ts +5 -0
- package/dist/background-agent-name.js +5 -0
- package/dist/bench/s1/arms.d.ts +1 -1
- package/dist/bench/s1/arms.js +1 -3
- package/dist/bench/s1/run-firm.js +2 -2
- package/dist/boot/budget-tracing.d.ts +1 -12
- package/dist/boot/deployment-mods.d.ts +46 -16
- package/dist/boot/deployment-mods.js +82 -6
- package/dist/boot/device-lane.d.ts +8 -3
- package/dist/boot/device-lane.js +7 -2
- package/dist/boot/execution-env.d.ts +4 -2
- package/dist/boot/execution-env.js +16 -24
- package/dist/boot/execution-lane.d.ts +1 -1
- package/dist/boot/governance-seams.d.ts +12 -18
- package/dist/boot/governance-seams.js +10 -24
- package/dist/boot/leader.d.ts +3 -0
- package/dist/boot/leader.js +1 -0
- package/dist/boot/memory-consolidation.js +2 -2
- package/dist/boot/org-delivery.js +15 -2
- package/dist/boot/resolve-spec.d.ts +4 -1
- package/dist/boot/resolve-spec.js +29 -19
- package/dist/boot/retention-lane.d.ts +14 -8
- package/dist/boot/retention-lane.js +2 -8
- package/dist/boot/runner-deps.d.ts +10 -4
- package/dist/boot/runner-deps.js +2 -0
- package/dist/boot/session-faces.d.ts +0 -3
- package/dist/boot/session-faces.js +15 -8
- package/dist/boot/stage-02-web-admin-pull.js +2 -2
- package/dist/boot/stage-04-stores.d.ts +1 -12
- package/dist/boot/stage-05-execution-env.d.ts +3 -12
- package/dist/boot/stage-05-execution-env.js +8 -5
- package/dist/boot/stage-06-runners.d.ts +3 -12
- package/dist/boot/stage-06-runners.js +5 -3
- package/dist/boot/stage-07-capability-layer.d.ts +3 -12
- package/dist/boot/stage-07-capability-layer.js +2 -2
- package/dist/boot/stage-08-reapers.d.ts +3 -12
- package/dist/boot/stage-09-leader.d.ts +3 -12
- package/dist/boot/stage-09-leader.js +2 -3
- package/dist/boot/stage-10-http-server.d.ts +3 -12
- package/dist/boot/stage-10-http-server.js +5 -3
- package/dist/boot/stores.js +4 -4
- package/dist/boot/web-admin.d.ts +5 -2
- package/dist/boot/web-admin.js +5 -5
- package/dist/brain.js +5 -5
- package/dist/budget.d.ts +17 -15
- package/dist/budget.js +2 -2
- package/dist/capabilities/mcp-probe.d.ts +36 -11
- package/dist/capabilities/mcp-probe.js +44 -5
- package/dist/capabilities/scenarios.d.ts +1 -1
- package/dist/capability-facts.d.ts +21 -7
- package/dist/capability-facts.js +13 -3
- package/dist/checkpoint-identity.d.ts +13 -6
- package/dist/config-catalog.js +14 -8
- package/dist/config-invariants.d.ts +23 -3
- package/dist/config-invariants.js +42 -0
- package/dist/config-provider.d.ts +19 -24
- package/dist/config-provider.js +27 -12
- package/dist/config-types.d.ts +25 -12
- package/dist/config.d.ts +33 -0
- package/dist/config.js +52 -20
- package/dist/delegated-session-owner.d.ts +2 -2
- package/dist/deployment-shape.d.ts +7 -7
- package/dist/device-enrollment.d.ts +41 -2
- package/dist/device-enrollment.js +27 -12
- package/dist/device-store.d.ts +58 -85
- package/dist/device-store.js +19 -49
- package/dist/device-ws-hub.js +2 -1
- package/dist/env-name-allowlist-knobs.d.ts +5 -4
- package/dist/exec-cut.d.ts +60 -0
- package/dist/exec-cut.js +36 -0
- package/dist/execution-lane-caps.d.ts +19 -0
- package/dist/execution-lane-caps.js +10 -0
- package/dist/execution-placement.d.ts +259 -0
- package/dist/execution-placement.js +199 -0
- package/dist/field-conflict.d.ts +3 -2
- package/dist/field-conflict.js +1 -0
- package/dist/gate-settlement.d.ts +71 -0
- package/dist/gate-settlement.js +40 -0
- package/dist/hooks/classic-stations.d.ts +1 -0
- package/dist/hooks/classic-stations.js +1 -0
- package/dist/hooks/command-spawn.d.ts +2 -2
- package/dist/hooks/hook-runner.js +14 -14
- package/dist/hosted-posture.d.ts +2 -2
- package/dist/http/admission.js +10 -19
- package/dist/http/checkpoint-ctx.d.ts +21 -12
- package/dist/http/checkpoint-ctx.js +4 -2
- package/dist/http/claimed-run.d.ts +1 -1
- package/dist/http/dispatch.d.ts +4 -0
- package/dist/http/dispatch.js +3 -0
- package/dist/http/durable-run-leg.js +12 -6
- package/dist/http/execution-context.d.ts +218 -0
- package/dist/http/execution-context.js +330 -0
- package/dist/http/memory-compliance-failure-reply.js +3 -0
- package/dist/http/resume-legs.d.ts +5 -11
- package/dist/http/resume-legs.js +179 -104
- package/dist/http/route-ctx.d.ts +44 -59
- package/dist/http/route-ctx.js +2 -5
- package/dist/http/routes/a2a-serve.js +10 -4
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +5 -1
- package/dist/http/routes/approvals-assistant.js +6 -6
- package/dist/http/routes/background.d.ts +29 -1
- package/dist/http/routes/background.js +29 -2
- package/dist/http/routes/capabilities.js +12 -10
- package/dist/http/routes/devices.d.ts +13 -19
- package/dist/http/routes/devices.js +21 -26
- package/dist/http/routes/mcp-reconnect.d.ts +3 -2
- package/dist/http/routes/mcp-reconnect.js +7 -5
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/rules.js +3 -3
- package/dist/http/routes/runs.js +11 -7
- package/dist/http/routes/session-sync.js +110 -15
- package/dist/http/routes/sessions.d.ts +6 -0
- package/dist/http/routes/sessions.js +119 -13
- package/dist/http/routes/side-query.d.ts +12 -4
- package/dist/http/routes/side-query.js +6 -8
- package/dist/http/routes/tasks.js +800 -782
- package/dist/http/server.d.ts +61 -39
- package/dist/http/server.js +11 -0
- package/dist/http/session-inherit-env.d.ts +3 -4
- package/dist/http/session-inherit-env.js +1 -1
- package/dist/http/wire-types.d.ts +22 -18
- package/dist/identity-source.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/leader/wire.d.ts +7 -0
- package/dist/leader/wire.js +5 -4
- package/dist/mcp-assertion-header.d.ts +51 -40
- package/dist/mcp-assertion-header.js +10 -11
- package/dist/mcp-authorization-face.d.ts +27 -0
- package/dist/mcp-authorization-face.js +15 -0
- package/dist/memory-operator-faces.d.ts +13 -4
- package/dist/memory-operator-faces.js +1 -17
- package/dist/memory-sync-client.d.ts +53 -14
- package/dist/memory-sync-client.js +187 -92
- package/dist/memory-sync.d.ts +1 -1
- package/dist/memory-sync.js +3 -2
- package/dist/model-route-gap.d.ts +6 -22
- package/dist/model-route-gap.js +7 -5
- package/dist/mods-declaration.d.ts +110 -0
- package/dist/mods-declaration.js +109 -0
- package/dist/observability/cost-taxonomy.d.ts +2 -2
- package/dist/observability/err-text.d.ts +5 -0
- package/dist/observability/err-text.js +9 -0
- package/dist/observability/fail-open.d.ts +17 -1
- package/dist/observability/fail-open.js +17 -1
- package/dist/observability/run-terminal.js +0 -1
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/orchestration/workflow-notify-journal.js +4 -4
- package/dist/org-memory-admission.d.ts +4 -3
- package/dist/org-memory-admission.js +6 -6
- package/dist/parked-decide.d.ts +49 -11
- package/dist/parked-decide.js +25 -26
- package/dist/parked-revive-surface.d.ts +12 -15
- package/dist/parked-revive-surface.js +3 -6
- package/dist/peer-seat.d.ts +156 -0
- package/dist/peer-seat.js +273 -0
- package/dist/permission-rule-vocab.d.ts +7 -7
- package/dist/permission-rule-vocab.js +3 -3
- package/dist/plain-string-record.d.ts +38 -0
- package/dist/plain-string-record.js +38 -0
- package/dist/plugins/approval-ask-store-file.d.ts +7 -0
- package/dist/plugins/approval-ask-store-file.js +11 -0
- package/dist/plugins/approval-ask-store-memory.d.ts +6 -0
- package/dist/plugins/approval-ask-store-memory.js +12 -0
- package/dist/plugins/approval-ask-store-sql.d.ts +22 -5
- package/dist/plugins/approval-ask-store-sql.js +30 -12
- package/dist/plugins/background-agent-store-sql.js +6 -3
- package/dist/plugins/caching-session-store.d.ts +11 -2
- package/dist/plugins/caching-session-store.js +15 -3
- package/dist/plugins/checkpoint-store-sql.d.ts +21 -25
- package/dist/plugins/checkpoint-store-sql.js +13 -15
- package/dist/plugins/device-store-sql.d.ts +25 -51
- package/dist/plugins/device-store-sql.js +49 -103
- package/dist/plugins/execution-placement-sql.d.ts +151 -0
- package/dist/plugins/execution-placement-sql.js +223 -0
- package/dist/plugins/file-history-store-sql.d.ts +7 -6
- package/dist/plugins/file-history-store-sql.js +8 -7
- package/dist/plugins/file-run-store.d.ts +6 -1
- package/dist/plugins/file-run-store.js +4 -0
- package/dist/plugins/fork-routing-session-store.d.ts +6 -0
- package/dist/plugins/fork-routing-session-store.js +16 -0
- package/dist/plugins/k8s-pod-reaper.d.ts +2 -8
- package/dist/plugins/k8s-pod-reaper.js +3 -3
- package/dist/plugins/local-checkpoint-store.d.ts +1 -11
- package/dist/plugins/local-checkpoint-store.js +0 -1
- package/dist/plugins/local-session-store.d.ts +183 -45
- package/dist/plugins/local-session-store.js +412 -105
- package/dist/plugins/mailbox-store-sql.d.ts +11 -3
- package/dist/plugins/mailbox-store-sql.js +103 -15
- package/dist/plugins/memory-key-guards.d.ts +4 -0
- package/dist/plugins/memory-key-guards.js +1 -0
- package/dist/plugins/memory-run-store.d.ts +1 -1
- package/dist/plugins/memory-sync-store-pg.d.ts +16 -5
- package/dist/plugins/memory-sync-store-tidb.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +117 -6
- package/dist/plugins/one-time-migrations.js +383 -14
- package/dist/plugins/outcome-ledger-sql.d.ts +2 -2
- package/dist/plugins/permission-rule-store-sql.d.ts +13 -15
- package/dist/plugins/permission-rule-store-sql.js +34 -29
- package/dist/plugins/pg-pool.d.ts +7 -3
- package/dist/plugins/pg-session-storage.d.ts +41 -22
- package/dist/plugins/pg-session-storage.js +136 -55
- package/dist/plugins/remote-env-adb.d.ts +22 -4
- package/dist/plugins/remote-env-adb.js +70 -62
- package/dist/plugins/remote-env-device.d.ts +32 -12
- package/dist/plugins/remote-env-device.js +18 -17
- package/dist/plugins/remote-env-e2b.d.ts +19 -3
- package/dist/plugins/remote-env-e2b.js +41 -42
- package/dist/plugins/remote-env-file-error.d.ts +2 -0
- package/dist/plugins/remote-env-file-error.js +1 -1
- package/dist/plugins/remote-env-host.d.ts +23 -8
- package/dist/plugins/remote-env-host.js +66 -70
- package/dist/plugins/remote-env-k8s.d.ts +13 -16
- package/dist/plugins/remote-env-k8s.js +61 -54
- package/dist/plugins/remote-env-local-docker.d.ts +30 -5
- package/dist/plugins/remote-env-local-docker.js +46 -59
- package/dist/plugins/remote-env-ssh.d.ts +18 -4
- package/dist/plugins/remote-env-ssh.js +72 -56
- package/dist/plugins/remote-shell.d.ts +100 -3
- package/dist/plugins/remote-shell.js +166 -2
- package/dist/plugins/retention-store-sql.d.ts +23 -8
- package/dist/plugins/retention-store-sql.js +13 -1
- package/dist/plugins/run-store-sql.d.ts +13 -3
- package/dist/plugins/run-store-sql.js +5 -0
- package/dist/plugins/schema-consistency.d.ts +15 -5
- package/dist/plugins/schema-consistency.js +14 -8
- package/dist/plugins/schema-drift-sentence.d.ts +27 -0
- package/dist/plugins/schema-drift-sentence.js +38 -0
- package/dist/plugins/session-fork.d.ts +63 -12
- package/dist/plugins/session-fork.js +38 -21
- package/dist/plugins/session-ownership.d.ts +7 -0
- package/dist/plugins/session-ownership.js +5 -0
- package/dist/plugins/session-row-sql.d.ts +22 -0
- package/dist/plugins/session-row-sql.js +81 -0
- package/dist/plugins/session-store.d.ts +1 -1
- package/dist/plugins/session-workspace-cell.d.ts +17 -0
- package/dist/plugins/session-workspace-cell.js +38 -0
- package/dist/plugins/store-backend.d.ts +1 -1
- package/dist/plugins/store-backend.js +26 -14
- package/dist/plugins/store-contracts.d.ts +25 -5
- package/dist/plugins/tidb-pool.d.ts +12 -7
- package/dist/plugins/tidb-pool.js +15 -3
- package/dist/plugins/tidb-session-store.d.ts +74 -28
- package/dist/plugins/tidb-session-store.js +132 -53
- package/dist/plugins/tool-result-store-sql.d.ts +16 -8
- package/dist/plugins/tool-result-store-sql.js +26 -17
- package/dist/plugins/worktree-isolation.d.ts +3 -2
- package/dist/plugins/worktree-isolation.js +1 -7
- package/dist/project-identity.d.ts +1 -14
- package/dist/project-identity.js +0 -4
- package/dist/project-memory.d.ts +9 -15
- package/dist/project-memory.js +5 -4
- package/dist/request-key-closure.js +1 -1
- package/dist/request-value-closure.d.ts +6 -7
- package/dist/request-value-closure.js +1 -3
- package/dist/rules-consent.js +6 -4
- package/dist/run-local.d.ts +6 -0
- package/dist/run-local.js +36 -26
- package/dist/runs.d.ts +9 -2
- package/dist/runs.js +9 -2
- package/dist/sandbox-git-plane.d.ts +2 -2
- package/dist/security.d.ts +38 -12
- package/dist/security.js +8 -2
- package/dist/server-secret-env.d.ts +15 -8
- package/dist/server-secret-env.js +4 -2
- package/dist/session-children-retire.d.ts +27 -9
- package/dist/session-children-retire.js +9 -5
- package/dist/session-incarnation.d.ts +19 -10
- package/dist/session-incarnation.js +5 -3
- package/dist/session-row.d.ts +114 -5
- package/dist/session-row.js +55 -5
- package/dist/session-titler.d.ts +2 -2
- package/dist/session-workspace.d.ts +130 -0
- package/dist/session-workspace.js +83 -0
- package/dist/spec-fields.d.ts +1 -1
- package/dist/standing-answer-grant.d.ts +2 -13
- package/dist/standing-answer-grant.js +0 -7
- package/dist/task-a2a.d.ts +44 -14
- package/dist/task-a2a.js +46 -20
- package/dist/task-cwd.d.ts +6 -1
- package/dist/task-mcp.d.ts +33 -20
- package/dist/task-mcp.js +46 -22
- package/dist/tool-approval.d.ts +38 -8
- package/dist/tool-approval.js +57 -13
- package/dist/trace/core-keyset-guard.d.ts +33 -18
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +20 -1
- package/dist/trace/exit-seat.js +3 -0
- package/dist/trace/extension-call-face.d.ts +33 -0
- package/dist/trace/extension-call-face.js +39 -0
- package/dist/trace/project.d.ts +26 -7
- package/dist/trace/project.js +30 -3
- package/dist/trace/redact.js +42 -13
- package/dist/trace/self-minted-wire.d.ts +240 -12
- package/dist/trace/self-minted-wire.js +100 -4
- package/dist/trace/wire-projection-faces.d.ts +6 -6
- package/dist/trace/wire-projection-faces.js +6 -5
- package/dist/url-refusal.d.ts +1 -1
- package/dist/user-authored-text.d.ts +2 -2
- package/dist/user-authored-text.js +16 -1
- package/dist/web-admin-client/apply-effective.d.ts +17 -3
- package/dist/web-admin-client/apply-effective.js +20 -10
- package/dist/web-admin-client/center-request.d.ts +3 -2
- package/dist/web-admin-client/center-request.js +2 -3
- package/dist/web-admin-client/skills-mcp.d.ts +8 -4
- package/dist/web-admin-client/skills-mcp.js +32 -18
- package/dist/web-admin-client/types.d.ts +11 -0
- package/package.json +3 -3
- package/wire-changes/server@7.138.0.json +446 -0
- package/wire-changes/server@7.139.0.json +348 -0
- package/dist/http/device-placement.d.ts +0 -175
- package/dist/http/device-placement.js +0 -145
- package/dist/http/mcp-remote-text.d.ts +0 -5
- package/dist/http/mcp-remote-text.js +0 -7
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* http 传输的 `assertionHeader` —— 托管连接器「断言头」的**头名**(settings-schema ≥12.2.0 的 `McpTransport` http 形键)。
|
|
2
|
+
* 请求面一条 MCP 条目的形与它交给引擎之前的拆法({@link toMcpDraft}),以及 http 传输的 `assertionHeader` —— 托管连接器「断言头」的**头名**(settings-schema ≥12.2.0 的 `McpTransport` http 形键)。
|
|
3
3
|
*
|
|
4
|
-
* ##
|
|
4
|
+
* ## 请求面条目 → 草稿(一张按传输分臂的处置表)
|
|
5
|
+
* 请求面条目的形 = 契约包的请求传输形({@link RequestMcpServerSpec}:stdio 带 `env`、http 带 `headers` / `principalHeader` / `assertionHeader`),wire 上的形由它说。
|
|
6
|
+
* 交给引擎的声明不带件值:引擎的声明收据对带 `headers` / `env` 的声明整条拒,件由部署的对端座在发送时作答。所以每条条目按它那一臂的处置表
|
|
7
|
+
* ({@link MCP_STDIO_TRANSPORT_DISPOSITION} / {@link MCP_HTTP_TRANSPORT_DISPOSITION})拆成草稿:`env` / `headers` 进草稿的件,`assertionHeader` 承载不发送,其余进声明。
|
|
8
|
+
* 拆法只有 `plain-string-record.ts` 的 `splitDeclaration` 一只、键的去处只有表一处说;两张表各带三道编译格(请求臂加 / 减键、引擎臂加键、引擎臂删键都编译红)。
|
|
9
|
+
* 草稿只有胜出者(部署同名者赢,`task-mcp.ts` 的 `mergeRequestMcp`)才经对端座的唯一铸点(`peer-seat.ts` 的 `mintDeclaration`)登记,登记换来的引用放进声明的传输臂。
|
|
10
|
+
*
|
|
11
|
+
* ## `assertionHeader`:一条律,一个键一种读法
|
|
5
12
|
* 两个面收下这个键,读法是同一个:
|
|
6
13
|
* · **settings 面**(部署声明:中心下发 + 本地 `config.d`)—— 契约包在**解析期**受理它,并判它与 `principalHeader` 互斥
|
|
7
14
|
* (同设 = 两个答案:「这台 http 服务器的请求上用哪个头送身份」);本仓这一面只承载,铸 spec 在 `resolveMcpServers`;
|
|
8
15
|
* · **请求面**(任务提交体 `mcpServers[].transport`;探测口 `…/mcp/probe` 读同一张键表)—— 本仓在**受理期**兑现同一条规则:
|
|
9
|
-
* 受理 = 字符串才收;互斥 =
|
|
16
|
+
* 受理 = 字符串才收;互斥 = 同设即拒;去处 = 处置表的 `withheld`(声明与件两边都不进)。
|
|
10
17
|
* 同一条规则、两处执行者(契约包解析期 / 请求面受理期);判据 {@link mcpIdentityHeadersIssue} 与互斥拒句
|
|
11
18
|
* {@link describeMcpIdentityHeadersConflict} 对契约包的原判官**逐字**对齐 —— 不是靠这句注释,而是
|
|
12
19
|
* `test/task-mcp.test.ts` 的 [ref] 组把两边对拍(格子差分 + 拒句逐字相等),契约包改一个字那一组当场红。
|
|
@@ -18,38 +25,52 @@
|
|
|
18
25
|
* 所以读器(契约包的 `readMcpIdentityHeaders`,`normalizeServer` 的 http 传输读两个身份头用它)的处置是**降级到升级前的读法**:`principalHeader` 胜(照挂,与升级前逐字相同),`assertionHeader` 不生效;
|
|
19
26
|
* 不静默 —— 真挂上的这类条目由 {@link noteMcpAssertionHeaderIgnored} 说一行 warn(部署声明面没有这一格:配置不是被重放的存量任务,契约包解析期那一刀直接丢这一条)。
|
|
20
27
|
*
|
|
21
|
-
* ##
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{@link
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
结构上不可能同时成立,消费方按位分支、位真时不再看到任何披露句;发送座到货的那天翻的就是这一行(与下面的退役门同批)。
|
|
29
|
-
|
|
30
|
-
## 退役(编译期自动逼,零人工记忆)
|
|
31
|
-
* 引擎的 http 传输一旦长出同名座,{@link _CoreHasNoAssertionSeat} 当场编译红:届时删本文件里的 {@link RequestMcpServerSpec}
|
|
32
|
-
* 扩展与 {@link toCoreMcpServerSpec} 的剥键、两处 info,把键直接投进引擎规格(发送由引擎座兑现)。
|
|
28
|
+
* ## 断言不发送 —— 「发不发」只有一处说
|
|
29
|
+
* 引擎的断言头是**固定的名**(引擎包根的 `MCP_ASSERTION_HEADER`),值由部署的对端座对 `assertion` 种类的引用作答;本部署没有断言来源,对端座对这一种恒拒
|
|
30
|
+
* (`peer-seat.ts` 的拒因 `kind_assertion`)。所以请求面写的这个头名**承载、不发送**:处置表那一格是 `withheld`,开关 {@link MCP_ASSERTION_HEADER_SENT} 从表那一格读出(恒假),
|
|
31
|
+
* 读它的地方全经 {@link withholdsMcpAssertionHeader} 这一只谓词(能力位 `GET /v1/capabilities` 的 `mcpAssertionHeaderSent` 直读开关本人):一行 info(请求面与 settings 面)、探测口整条拒、能力位;
|
|
32
|
+
* 两面铸声明时都不投这个键(请求面经处置表,settings 面不写它)。
|
|
33
|
+
* 声明在、发送未接 = 运维要知道的事实,不是兜底 —— server 照常挂载、不带断言头,要求断言的托管连接器会拒这些调用,运维据 {@link noteMcpAssertionHeaderNotSent} 那一行知道原因在哪。
|
|
34
|
+
* 退役门押在座上({@link _SeatRefusesAssertion}):对端座哪天开始对 `assertion` 作答,那一格当场编译红,届时重判这一格的去处(键本身随契约包删键一起退役)。
|
|
33
35
|
*/
|
|
34
36
|
import type { McpServerSpec } from "@sema-agent/core";
|
|
35
|
-
type
|
|
36
|
-
type
|
|
37
|
+
import type { RequestMcpTransport } from "@sema-agent/settings-schema";
|
|
38
|
+
import type { McpDraft } from "./peer-seat.js";
|
|
39
|
+
/** 请求面 stdio 传输的形(契约包):引擎的 stdio 传输去掉凭据引用位、加上 `env`(件)。 */
|
|
40
|
+
export type RequestStdioMcpTransport = Extract<RequestMcpTransport, {
|
|
37
41
|
kind: "stdio";
|
|
38
42
|
}>;
|
|
39
|
-
|
|
43
|
+
/** 请求面 http 传输的形(契约包):引擎的 http 传输去掉凭据引用位、加上 `headers`(件)与承载不发送的 `assertionHeader`。 */
|
|
44
|
+
export type RequestHttpMcpTransport = Extract<RequestMcpTransport, {
|
|
40
45
|
kind: "http";
|
|
41
46
|
}>;
|
|
42
|
-
/** 请求面 http 传输的形:引擎的 http 传输 + 本仓承载的 `assertionHeader`(引擎无座,见头注)。 */
|
|
43
|
-
export type RequestHttpMcpTransport = CoreHttpTransport & {
|
|
44
|
-
assertionHeader?: string;
|
|
45
|
-
};
|
|
46
47
|
/**
|
|
47
48
|
* 请求面一条 `mcpServers[]` 条目在 wire 上的形(= `TaskRequestBody.mcpServers` 的元素型,也是 `normalizeServer` 的产物):
|
|
48
|
-
* 引擎的 {@link McpServerSpec}
|
|
49
|
+
* 引擎的 {@link McpServerSpec} 条目层 + 契约包的请求传输形。交给引擎之前一律经 {@link toMcpDraft} 拆成草稿。
|
|
49
50
|
*/
|
|
50
51
|
export type RequestMcpServerSpec = Omit<McpServerSpec, "transport"> & {
|
|
51
|
-
transport:
|
|
52
|
+
transport: RequestMcpTransport;
|
|
53
|
+
};
|
|
54
|
+
/** stdio 臂的处置表(键序 = 键闭集序):`env` 是件,其余进声明。 */
|
|
55
|
+
export declare const MCP_STDIO_TRANSPORT_DISPOSITION: {
|
|
56
|
+
readonly args: "engine";
|
|
57
|
+
readonly command: "engine";
|
|
58
|
+
readonly env: "seat";
|
|
59
|
+
readonly kind: "engine";
|
|
52
60
|
};
|
|
61
|
+
/** http 臂的处置表(键序 = 键闭集序):`headers` 是件,`assertionHeader` 承载不发送(见头注),其余进声明。 */
|
|
62
|
+
export declare const MCP_HTTP_TRANSPORT_DISPOSITION: {
|
|
63
|
+
readonly assertionHeader: "withheld";
|
|
64
|
+
readonly headers: "seat";
|
|
65
|
+
readonly kind: "engine";
|
|
66
|
+
readonly principalHeader: "engine";
|
|
67
|
+
readonly url: "engine";
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* 请求面条目 → 草稿:传输按它那一臂的处置表拆(`env` / `headers` 进件,`assertionHeader` 两边都不进,其余进声明);条目层的键原样进声明。件缺席或空 ⇒ 草稿不带件(登记时什么都不留)。
|
|
71
|
+
* 纯函数:不登记、不读部署状态;被扣下的 `assertionHeader` 由调用方另说一行 info。
|
|
72
|
+
*/
|
|
73
|
+
export declare function toMcpDraft(spec: RequestMcpServerSpec): McpDraft;
|
|
53
74
|
/** 一份原始 http 传输上两个身份头的问题类:`both_set` = 同设了 `principalHeader` 与 `assertionHeader`;`not_a_string` = `assertionHeader` 在场但不是字符串。 */
|
|
54
75
|
export type McpIdentityHeadersIssue = "both_set" | "not_a_string";
|
|
55
76
|
/**
|
|
@@ -64,27 +85,18 @@ export declare function describeMcpIdentityHeadersConflict(server: string): stri
|
|
|
64
85
|
/** `assertionHeader` 值不是字符串的**原因句**(不带条目名与键路径:点名由请求面统一的拒形 `entryFieldRefusal` 负责;值的形状只说种类,不回显值本身:它是一个调用方写的头名位置,可能是任何东西)。 */
|
|
65
86
|
export declare function describeMcpAssertionHeaderNotAString(value: unknown): string;
|
|
66
87
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
88
|
+
* 本部署发不发请求面声明的断言头 —— **全仓唯一的开关**,从 http 臂处置表的那一格读出(`withheld` ⇒ 假;依据见头注「断言不发送」与退役门)。
|
|
89
|
+
* 读它的地方全经 {@link withholdsMcpAssertionHeader} / 本常量(一行 info、探测口拒、能力位 `mcpAssertionHeaderSent`),所以表那一格与开关不可能脱钩。
|
|
90
|
+
* 声明成 `boolean` 而不是字面 `false`:谓词里的真臂是活代码(单测传 `sent=true` 钉它),不是被收窄掉的死分支。
|
|
70
91
|
*/
|
|
71
92
|
export declare const MCP_ASSERTION_HEADER_SENT: boolean;
|
|
72
93
|
/**
|
|
73
|
-
* 这一份 `assertionHeader` 声明是不是「被扣下」的那一类(
|
|
74
|
-
*
|
|
94
|
+
* 这一份 `assertionHeader` 声明是不是「被扣下」的那一类(需要说一行 info、探测口要拒的那一类)—— 即**声明了,而本部署不发送**。
|
|
95
|
+
* 披露(请求面与 settings 面)/ 探测口拒共读这一只;`sent` 缺省读开关,单测传显式值钉另一臂。
|
|
75
96
|
*/
|
|
76
97
|
export declare function withholdsMcpAssertionHeader(assertionHeader: unknown, sent?: boolean): boolean;
|
|
77
98
|
/** {@link withholdsMcpAssertionHeader} 在请求面条目上的读法:只有 http 传输有这个键(stdio 形上它不存在)。 */
|
|
78
99
|
export declare function specWithholdsMcpAssertionHeader(spec: RequestMcpServerSpec): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* settings 面铸 spec 时「这个键投不投进引擎规格」:发送座在(`sent` 真)且声明了字符串 ⇒ 投,否则整键缺席。今天恒为空对象(开关假);
|
|
81
|
-
* 开关翻真的那天 settings 面因此自动跟着投,不会出现「位说发了、部署声明面却没投」。
|
|
82
|
-
*/
|
|
83
|
-
export declare function sentMcpAssertionHeaderMember(assertionHeader: unknown, sent?: boolean): {
|
|
84
|
-
assertionHeader?: string;
|
|
85
|
-
};
|
|
86
|
-
/** 请求面条目 → 交给引擎的规格:被扣下的 `assertionHeader` 剥掉(引擎无座);其余逐字不动。被扣下的条目由调用方另说一行 info。 */
|
|
87
|
-
export declare function toCoreMcpServerSpec(spec: RequestMcpServerSpec): McpServerSpec;
|
|
88
100
|
/** `noteMcpAssertionHeaderNotSent` 的日志行名(运维 grep 用;请求面与 settings 面同一个名字)。 */
|
|
89
101
|
export declare const MCP_ASSERTION_HEADER_NOT_SENT = "mcp_assertion_header_not_sent";
|
|
90
102
|
/** `noteMcpAssertionHeaderIgnored` 的日志行名。 */
|
|
@@ -93,10 +105,9 @@ export declare const MCP_ASSERTION_HEADER_IGNORED = "mcp_assertion_header_ignore
|
|
|
93
105
|
export declare function noteMcpAssertionHeaderIgnored(logger: {
|
|
94
106
|
warn?(msg: string, meta?: unknown): void;
|
|
95
107
|
} | undefined, server: string, reason: McpIdentityHeadersIssue): void;
|
|
96
|
-
/** 说出「这台 server 声明了 `assertionHeader
|
|
108
|
+
/** 说出「这台 server 声明了 `assertionHeader`,本部署不发送」—— 一台一行 info。两个铸 spec 点(请求面 `classifyHonored`、
|
|
97
109
|
* settings 面 `resolveMcpServers`)共用这一只,所以行名与措辞只有一份。 */
|
|
98
110
|
export declare function noteMcpAssertionHeaderNotSent(logger: {
|
|
99
111
|
info?(msg: string, meta?: unknown): void;
|
|
100
112
|
} | undefined, server: string): void;
|
|
101
|
-
export {};
|
|
102
113
|
//# sourceMappingURL=mcp-assertion-header.d.ts.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { splitDeclaration } from "./plain-string-record.js";
|
|
2
|
+
export const MCP_STDIO_TRANSPORT_DISPOSITION = { args: "engine", command: "engine", env: "seat", kind: "engine" };
|
|
3
|
+
export const MCP_HTTP_TRANSPORT_DISPOSITION = { assertionHeader: "withheld", headers: "seat", kind: "engine", principalHeader: "engine", url: "engine" };
|
|
4
|
+
export function toMcpDraft(spec) {
|
|
5
|
+
const { transport, ...entry } = spec;
|
|
6
|
+
const split = transport.kind === "http" ? splitDeclaration(transport, MCP_HTTP_TRANSPORT_DISPOSITION) : splitDeclaration(transport, MCP_STDIO_TRANSPORT_DISPOSITION);
|
|
7
|
+
return { spec: { ...entry, transport: split.engine }, ...(split.pieces === undefined ? {} : { pieces: split.pieces }) };
|
|
8
|
+
}
|
|
1
9
|
export function mcpIdentityHeadersIssue(transport) {
|
|
2
10
|
if (transport.kind !== "http")
|
|
3
11
|
return undefined;
|
|
@@ -14,22 +22,13 @@ export function describeMcpAssertionHeaderNotAString(value) {
|
|
|
14
22
|
const kind = value === null ? "null" : Array.isArray(value) ? "an array" : `a ${typeof value}`;
|
|
15
23
|
return `must be a string (the HTTP header NAME the connector assertion travels in) — got ${kind}; omit the key to send no assertion header`;
|
|
16
24
|
}
|
|
17
|
-
export const MCP_ASSERTION_HEADER_SENT =
|
|
25
|
+
export const MCP_ASSERTION_HEADER_SENT = MCP_HTTP_TRANSPORT_DISPOSITION.assertionHeader !== "withheld";
|
|
18
26
|
export function withholdsMcpAssertionHeader(assertionHeader, sent = MCP_ASSERTION_HEADER_SENT) {
|
|
19
27
|
return !sent && assertionHeader !== undefined;
|
|
20
28
|
}
|
|
21
29
|
export function specWithholdsMcpAssertionHeader(spec) {
|
|
22
30
|
return spec.transport.kind === "http" && withholdsMcpAssertionHeader(spec.transport.assertionHeader);
|
|
23
31
|
}
|
|
24
|
-
export function sentMcpAssertionHeaderMember(assertionHeader, sent = MCP_ASSERTION_HEADER_SENT) {
|
|
25
|
-
return sent && typeof assertionHeader === "string" ? { assertionHeader } : {};
|
|
26
|
-
}
|
|
27
|
-
export function toCoreMcpServerSpec(spec) {
|
|
28
|
-
if (spec.transport.kind !== "http" || !withholdsMcpAssertionHeader(spec.transport.assertionHeader))
|
|
29
|
-
return spec;
|
|
30
|
-
const { assertionHeader: _declaredNotSent, ...transport } = spec.transport;
|
|
31
|
-
return { ...spec, transport };
|
|
32
|
-
}
|
|
33
32
|
export const MCP_ASSERTION_HEADER_NOT_SENT = "mcp_assertion_header_not_sent";
|
|
34
33
|
export const MCP_ASSERTION_HEADER_IGNORED = "mcp_assertion_header_ignored";
|
|
35
34
|
export function noteMcpAssertionHeaderIgnored(logger, server, reason) {
|
|
@@ -44,7 +43,7 @@ export function noteMcpAssertionHeaderIgnored(logger, server, reason) {
|
|
|
44
43
|
export function noteMcpAssertionHeaderNotSent(logger, server) {
|
|
45
44
|
logger?.info?.(MCP_ASSERTION_HEADER_NOT_SENT, {
|
|
46
45
|
server,
|
|
47
|
-
note: "declaration KEPT but NOT SENT — the engine
|
|
46
|
+
note: "declaration KEPT but NOT SENT — the engine sends a connector assertion only under its own fixed header name, answered by the deployment's peer seat, and this deployment has no assertion source; this server mounts WITHOUT one (a hosted connector that requires the assertion will refuse its calls)",
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
//# sourceMappingURL=mcp-assertion-header.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP 授权事实(core 7.59.0 `McpAuthorization`:`{ reason, authorizeUrl?, resourceMetadataUrl? }`,与 `errorCode: "unauthorized"` 同行)的**出门投影** ——
|
|
3
|
+
* 本仓三张面(`wiring_manifest.mcp[]` 行、重拨回执的 `status`、`//mcp` 面板的 `servers[]`)同读这一只。
|
|
4
|
+
*
|
|
5
|
+
* 只投闭集词 `reason`(`rejected` = 端点答 401 且授权座的重问没给出能过的凭据 / `scope` = 403 `insufficient_scope` / `none` = 授权座答「未授权」):
|
|
6
|
+
* 判据直读引擎的 `MCP_AUTHORIZATION_REASONS`(不抄词表);词出闭集、非串、整只不是对象 ⇒ 整格缺席(最弱断言,不铸词)。
|
|
7
|
+
* 两只地址**不出门**:`authorizeUrl` 只来自部署的授权座,本部署今天没有授权座;`resourceMetadataUrl` 是远端在挑战头里自报的地址,不可信 —— 两只地址的去向
|
|
8
|
+
* (授权座 + 出口座)是授权记录面的设计,不在本投影里放行。用户面的「去授权」由会话通告 `mcp.authorization_required` 承载。
|
|
9
|
+
*/
|
|
10
|
+
import { type McpAuthorizationReason } from "@sema-agent/core";
|
|
11
|
+
/** 授权记录的处置表(三面同读;`core-keyset-guard.ts` 读表 —— 门与投影一个写者):`reason` 认得才出门(闭集词;在场而认不得 ⇒ 丢并计一次),两只地址本面不出现。 */
|
|
12
|
+
export declare const MCP_AUTHORIZATION_DISPOSITIONS: {
|
|
13
|
+
readonly reason: {
|
|
14
|
+
readonly forward: (w: unknown) => w is McpAuthorizationReason;
|
|
15
|
+
};
|
|
16
|
+
readonly authorizeUrl: "strip";
|
|
17
|
+
readonly resourceMetadataUrl: "strip";
|
|
18
|
+
};
|
|
19
|
+
/** 处置表一格的放行谓词所窄化到的型(`forward: (w: unknown) => w is T` ⇒ `T`):表放行什么,出门值就是什么型。 */
|
|
20
|
+
type ForwardedAs<F> = F extends (w: unknown) => w is infer T ? T : never;
|
|
21
|
+
/** 本投影的产物 = 表里 `reason` 一格放行后的型。词的型只有表这一个写者,出口不再判第二遍。 */
|
|
22
|
+
export type McpAuthorizationFace = {
|
|
23
|
+
readonly reason: ForwardedAs<(typeof MCP_AUTHORIZATION_DISPOSITIONS)["reason"]["forward"]>;
|
|
24
|
+
};
|
|
25
|
+
export declare function projectMcpAuthorization(v: unknown): McpAuthorizationFace | undefined;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=mcp-authorization-face.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MCP_AUTHORIZATION_REASONS } from "@sema-agent/core";
|
|
2
|
+
import { projectByTable } from "./trace/projection-table.js";
|
|
3
|
+
const isAuthorizationReason = (w) => typeof w === "string" && MCP_AUTHORIZATION_REASONS.includes(w);
|
|
4
|
+
export const MCP_AUTHORIZATION_DISPOSITIONS = {
|
|
5
|
+
reason: { forward: isAuthorizationReason },
|
|
6
|
+
authorizeUrl: "strip",
|
|
7
|
+
resourceMetadataUrl: "strip",
|
|
8
|
+
};
|
|
9
|
+
export function projectMcpAuthorization(v) {
|
|
10
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
11
|
+
return undefined;
|
|
12
|
+
const { reason } = projectByTable("mcp.authorization", MCP_AUTHORIZATION_DISPOSITIONS, v, undefined);
|
|
13
|
+
return reason !== undefined ? { reason } : undefined;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=mcp-authorization-face.js.map
|
|
@@ -63,11 +63,20 @@ export interface MemoryComplianceFaces {
|
|
|
63
63
|
* 抹除。入参 `unknown`:调用方递交的是未校验的对象,三选一选择子的整体判决归 core
|
|
64
64
|
* (`erasureRequestInvalid` 是它的单一属主面)—— 在本层抄一遍就是第二真源。
|
|
65
65
|
*
|
|
66
|
-
* `
|
|
66
|
+
* ## 授权座只有一只:引擎的 `EraseMemoryEntriesInput.expectedScopes`
|
|
67
|
+
*
|
|
68
|
+
* 「这个调用方能删哪些 scope」由引擎判:在场 ⇒ 选择子自己的 scope(地点选择子,读店之前判)与**每个解析出的 id 的绑定 scope**
|
|
69
|
+
* 都得是集内成员,判在解析之后、店锁之内;违者整单拒 `config.memory_erasure_scope`,拒句不带数、不带 id、不带 scope(集外 id
|
|
70
|
+
* 与从没存在过的 id 同句,不是存在性神谕)。本层不另设信封:一只只读得到 `{ scope }` 选择子字面量的信封判不了 `ids` /
|
|
71
|
+
* `sessionId` 两腿、只能整拒,而且让「哪些 scope 能删」有两个答者。集随**入参**走(与 `requestId` / `select` 同一个对象),
|
|
72
|
+
* 本面没有第二个形参。
|
|
73
|
+
*
|
|
74
|
+
* 今天谁传集:operator 面原样递交调用方的体(调用方自己写的 `expectedScopes` = 它自己收窄自己);路由不替 operator 铸集 ——
|
|
75
|
+
* 本仓没有任何授权源能对一个 operator 说「你只能动这些 scope」(`routes/memory-policy.ts` 的 `gateMemoryScope`:operator 支在查
|
|
76
|
+
* 目录之前就 allow;`org-memory-admission.ts`:v1 不中央收窄 operator 声明的 scope)。拿 org 目录的 grant 集去凑一个集就是在本层
|
|
77
|
+
* 发明第二套授权语义,与 `gateMemoryScope` 对同一个身份给出相反答案。会话自助面的选择子由路径铸,不带集。
|
|
67
78
|
*/
|
|
68
|
-
erase: (input: unknown
|
|
69
|
-
allowedScopes?: readonly string[];
|
|
70
|
-
}) => Promise<MemoryErasureAttestation>;
|
|
79
|
+
erase: (input: unknown) => Promise<MemoryErasureAttestation>;
|
|
71
80
|
}
|
|
72
81
|
/**
|
|
73
82
|
* **选择子替身**的拦截谓词(codex 交叉复审 [critical],亲验复现后修 —— 复现器与结论逐条在
|
|
@@ -24,19 +24,6 @@ export function erasureInputSmugglesPrototypeKey(input) {
|
|
|
24
24
|
}
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
|
-
function erasureEnvelopeRefusal(input, allowedScopes) {
|
|
28
|
-
if (allowedScopes === undefined)
|
|
29
|
-
return undefined;
|
|
30
|
-
const select = typeof input === "object" && input !== null ? input.select : undefined;
|
|
31
|
-
const scope = typeof select === "object" && select !== null ? select.scope : undefined;
|
|
32
|
-
if (typeof scope === "string" && allowedScopes.includes(scope))
|
|
33
|
-
return undefined;
|
|
34
|
-
const e = new Error(typeof scope === "string"
|
|
35
|
-
? `memory erasure refused: scope ${JSON.stringify(scope)} is outside this caller's erasure envelope`
|
|
36
|
-
: "memory erasure refused: this request's selector is not scope-addressable, and an envelope that cannot judge a selector must not admit it");
|
|
37
|
-
e.code = "memory.erasure_scope_forbidden";
|
|
38
|
-
return e;
|
|
39
|
-
}
|
|
40
27
|
export function createMemoryComplianceFaces(store, opts) {
|
|
41
28
|
if (!backendOwnsControlPlane(store.backend))
|
|
42
29
|
return undefined;
|
|
@@ -48,15 +35,12 @@ export function createMemoryComplianceFaces(store, opts) {
|
|
|
48
35
|
});
|
|
49
36
|
return {
|
|
50
37
|
provenanceOf: (entryId) => engine.provenanceOf(entryId),
|
|
51
|
-
erase: (input
|
|
38
|
+
erase: (input) => {
|
|
52
39
|
if (erasureInputSmugglesPrototypeKey(input)) {
|
|
53
40
|
const e = new Error("memory erasure refused: the request carries a key that rewrites an object's prototype — such a key is not a selector, and core's selector dispatch would read it in preference to the declared one");
|
|
54
41
|
e.code = "memory.erasure_selector_unsafe";
|
|
55
42
|
return Promise.reject(e);
|
|
56
43
|
}
|
|
57
|
-
const refusal = erasureEnvelopeRefusal(input, opts?.allowedScopes);
|
|
58
|
-
if (refusal !== undefined)
|
|
59
|
-
return Promise.reject(refusal);
|
|
60
44
|
return engine.eraseMemoryEntries(input);
|
|
61
45
|
},
|
|
62
46
|
};
|
|
@@ -1,29 +1,68 @@
|
|
|
1
1
|
import { type MemoryBackend, type MemorySyncClientResult, type MemorySyncTransport } from "@sema-agent/core";
|
|
2
|
+
import { type OneTimeMigrationWindow } from "./plugins/one-time-migrations.js";
|
|
2
3
|
/** 结构化日志面(src/observability/logger.ts Logger 的结构子集——测试可注入捕获器)。 */
|
|
3
4
|
export interface MemorySyncLog {
|
|
4
5
|
info(msg: string, fields?: Record<string, unknown>): void;
|
|
5
6
|
warn(msg: string, fields?: Record<string, unknown>): void;
|
|
6
7
|
}
|
|
7
|
-
/** 缺省对端名(core `syncMemoryScope` 同款缺省;cursor 按 (scope,peer) 分区)。 */
|
|
8
|
-
export declare const DEFAULT_MEMORY_SYNC_PEER = "central";
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* 中心基址 → 同步对端的身份(规范化基址)。本仓唯一的铸点:`config.ts` 读 env 时调它拒启(引擎关着也拒),transport 建时再调它铸身份 —— 同一只纯函数,同一个答案。
|
|
10
|
+
* 两道判,各归各的属主,本函数不另写规则:
|
|
11
|
+
* ① 地址的形 —— 这只地址是「后面要拼路径的基址」座位(post 把同步路径拼在它后面),判官与拒句就是那一座位的那一只({@link pathBaseUrlRefusal}:层级式 http(s),
|
|
12
|
+
* 不带 userinfo / query / fragment;拒句只点名规则、值只到 origin);
|
|
13
|
+
* ② 身份里有没有凭据 —— 判官是引擎包根的 `carriesCredential`(引擎同步客户端判 `transport.peer` 的同一只:任何 userinfo,或同主体出口脱敏会遮掉的任何一段,
|
|
14
|
+
* 例如路径段里的令牌形),判的就是规范化之后的身份 —— 引擎第一轮判的那个值。身份随每个请求体与落盘游标走,所以带凭据的地址拒而不清洗
|
|
15
|
+
* (清洗过的身份是另一个身份;令牌只走 `MEMORY_SYNC_TOKEN`);拒句不引地址的任何部分。
|
|
16
|
+
* 规范化 = WHATWG URL 的 `origin`(协议与主机小写、缺省端口省掉)+ 路径去尾斜杠;规范化之后装不进中心侧 `peer` 列({@link MEMORY_SYNC_PEER_COLUMN_CHARS},
|
|
17
|
+
* 每一轮都会被中心拒)⇒ 同样拒。
|
|
18
|
+
*/
|
|
19
|
+
export declare function memorySyncPeerOf(url: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* 起服日志行 `memory_sync_enabled` 的字段(两处起服 —— `boot/stores.ts` 与 `run-local.ts` —— 同读这一只)。`peer` 是运维改绑游标时要抄的那个值:
|
|
22
|
+
* 它已过 {@link memorySyncPeerOf} 的两道判(带凭据的身份起不来);仍过展示铸点({@link buildDisplaySafeUrl}),日志里的 URL 值一律经它 —— 两只判官
|
|
23
|
+
* (引擎的出口脱敏与本仓的展示形状律)不是同一份实现,本仓的那一只若遮了引擎放行的一段,这一行带遮记号而不是逐字(响亮,不漏)。
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildMemorySyncEnabledFields(peer: string, scope: string, cursorPath: string): {
|
|
26
|
+
readonly peer: string;
|
|
27
|
+
readonly scope: string;
|
|
28
|
+
readonly cursorPath: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* fetch transport(core `MemorySyncTransport` 的部署实现)。`peer` = {@link memorySyncPeerOf}(`url`)(建时铸一次;拒的地址在这里抛,一个请求都不发),
|
|
32
|
+
* `post` 打 `${peer}${path}`(core 传来的 path 以 `/` 开头);`token` 走 Authorization: Bearer(与中心侧 gatedPrincipal 的 verified-principal 门对齐)。
|
|
33
|
+
* 非 2xx throw(status + body 前 200 字节——中心 4xx/5xx 的 typed error body 就是最好的诊断线索);2xx 返回解码后的 JSON(形状校验在 core
|
|
34
|
+
* parseMemorySyncResponse,职责不重复)。`timeoutMs`(缺省 60s,AbortSignal.timeout)是活性保护:fire-and-forget 轮挂死会把 inflight 节流永久卡住
|
|
35
|
+
* (undici 默认 headers 超时 300s 太钝)。
|
|
16
36
|
*/
|
|
17
37
|
export declare function createMemorySyncTransport(opts: {
|
|
18
38
|
url: string;
|
|
19
39
|
token: string;
|
|
20
40
|
timeoutMs?: number;
|
|
21
|
-
|
|
41
|
+
/** The one call shape this transport makes (`fetch` itself fits it). */
|
|
42
|
+
fetchImpl?: (url: string, init: RequestInit) => Promise<Response>;
|
|
22
43
|
}): MemorySyncTransport;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
/** 一层的游标文件路径:`memoryRoot`(= RunnerDeps.memoryEngineDir 的 resolved config root)下 `sync-cursors/<scope 摘要>.json`。一层一只,不随对端变。
|
|
45
|
+
* 落在子目录里:与更早的根下一层文件名 `sync-cursor-<peer>.json` 的空间不相交。 */
|
|
46
|
+
export declare function memorySyncCursorPath(memoryRoot: string, scope: string): string;
|
|
47
|
+
/** M31 一次的读数(测试按它断言)。`window: "closed"` ⇒ 一行都没读。 */
|
|
48
|
+
export interface SyncCursorRelocationM31Report {
|
|
49
|
+
readonly window: "open" | "closed";
|
|
50
|
+
readonly moved: number;
|
|
51
|
+
readonly left: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* ⑤ 一次性迁移 M31:把升级前的游标搬到各自那一层的路径(`rename`,字节不变;只搬不改,判归引擎)。`today` = UTC 日历日;窗关 ⇒ 不搬。
|
|
55
|
+
* · 上一版的分区目录 `sync-cursors/central/<scope 摘要>.json` ⇒ `sync-cursors/<同名>`(两种布局的文件名是同一只 scope 摘要);搬空的目录删掉;
|
|
56
|
+
* 名字不是摘要形的(写游标的 staging 残片)原地不动。
|
|
57
|
+
* · 更早的 `sync-cursor-central.json` ⇒ 它记的那一层的路径;读不成对象 / 没有 scope ⇒ 原地不动、一行 warn(没法说它是哪一层的基线)。
|
|
58
|
+
* · 目标路径上已有游标 ⇒ 不搬、不删,一行 warn(这一层用路径上的那一份;留下的那只没有读者)。
|
|
59
|
+
* 与同一数据根上并跑的另一个进程(server + run-local)同搬:源已被对方搬走(`ENOENT`)⇒ 跳过。残余(如实):先查目标再 `rename` 之间若有写者在目标路径上
|
|
60
|
+
* 落下游标,会被盖掉 —— 写者只有本模块的 runner,而 runner 写任何游标之前先跑完本步。别的读写错 ⇒ 抛(这一轮整轮失败、下一轮再搬)。
|
|
61
|
+
*/
|
|
62
|
+
export declare function relocateSyncCursorsM31(memoryRoot: string, log: MemorySyncLog, opts: {
|
|
63
|
+
readonly today: string;
|
|
64
|
+
readonly window?: Pick<OneTimeMigrationWindow, "removableAfter">;
|
|
65
|
+
}): Promise<SyncCursorRelocationM31Report>;
|
|
27
66
|
/** 一轮里一层的结果。 */
|
|
28
67
|
export interface MemorySyncLayerResult {
|
|
29
68
|
readonly scope: string;
|
|
@@ -59,9 +98,9 @@ export declare function createMemorySyncRunner(opts: {
|
|
|
59
98
|
/** 同步层(`config.memorySync.scope`);它同属主的项目层随它一起同步。 */
|
|
60
99
|
scope: string;
|
|
61
100
|
memoryRoot: string;
|
|
101
|
+
/** 对端 = 它的 `peer`(这一轮的对端只有这一个来源;游标绑的对端由引擎对它判)。 */
|
|
62
102
|
transport: MemorySyncTransport;
|
|
63
103
|
log: MemorySyncLog;
|
|
64
|
-
peer?: string;
|
|
65
104
|
now?: () => number;
|
|
66
105
|
/** S2.5 分批(core 1.284 两 seam):push 集/pull 集单轮上限。未设=不分批(wire 字节不变)。 */
|
|
67
106
|
maxPushEntries?: number;
|