@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
package/dist/task-cwd.d.ts
CHANGED
|
@@ -87,8 +87,13 @@ export declare function parseAdditionalDirectories(raw: unknown): string[] | und
|
|
|
87
87
|
* per-session choice always wins;
|
|
88
88
|
* 2. the TRUSTED `ctx.parentCwd` (core threads the PARENT task's working root via `RunInternals` when this
|
|
89
89
|
* task is a delegated child — never a TaskSpec field), UNLESS the child asked for `isolation:"worktree"`
|
|
90
|
-
* (
|
|
90
|
+
* (an isolated fan-out child must not share the parent's mutable dir) — then `undefined`;
|
|
91
91
|
* 3. undefined → the factory's ephemeral per-task dir (top-level task with no registered cwd).
|
|
92
|
+
* The `isolation:"worktree"` ⇒ `undefined` rule is this function's own and holds by itself (the child never inherits the
|
|
93
|
+
* parent's dir). It is NOT what answers a worktree ask on the host lane: `boot/execution-env.ts` never reaches here with one —
|
|
94
|
+
* the worktree wrapper (one layer out) mints the tree and does not call the base factory, and without the wrapper the base
|
|
95
|
+
* factory REFUSES (`isolation.unavailable`) instead of minting the empty ephemeral dir rule 3 would give. That refusal arm is
|
|
96
|
+
* revoked when engine 7.61.0 refuses by itself; this function's rule then goes on keeping the child off the parent's dir.
|
|
92
97
|
* CC parity: a Task sub-agent inherits the main session's cwd. Trust: `parentCwd` comes from core's trusted
|
|
93
98
|
* run-internals channel (same posture as `isolation`), so no tenancy gate is needed here — but the HOST lane
|
|
94
99
|
* itself is single-user by deployment shape, and container lanes (k8s/e2b/local-docker) never consult this.
|
package/dist/task-mcp.d.ts
CHANGED
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { type CompliancePosture, type EngineNotice, type LockedKey, type McpInjectionDropReason, type McpServerSpec } from "@sema-agent/core";
|
|
26
26
|
import { type McpIdentityHeadersIssue, type RequestMcpServerSpec } from "./mcp-assertion-header.js";
|
|
27
|
-
import { type
|
|
27
|
+
import { type McpDraft, type PeerDesk, type PeerLease } from "./peer-seat.js";
|
|
28
|
+
import { type DeclarationKeyIssue, type DeclarationRefusal } from "./request-declaration-refusal.js";
|
|
28
29
|
import type { StoredToolAxesRereadM19 } from "./stored-request-tool-axes-m19.js";
|
|
29
30
|
/** Bound on caller-supplied servers (anti-DoS; a real local `.mcp.json` has a handful). */
|
|
30
31
|
export declare const MAX_REQUEST_MCP_SERVERS = 32;
|
|
@@ -52,11 +53,11 @@ export declare const MAX_REQUEST_MCP_DROP_NAMES = 32;
|
|
|
52
53
|
* 再写一份就是一份手抄投影([ref]:任何仓第一排查点),而两份哪天分岔,窄的那一份会把**合法**的键当成
|
|
53
54
|
* 拼写错误 400 掉。
|
|
54
55
|
*
|
|
55
|
-
* ## 🔴
|
|
56
|
-
*
|
|
57
|
-
* ⇒
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* ## 🔴 两向钉在请求面条目形上(不是手抄)
|
|
57
|
+
* 条目层:下面四道编译期门两向钉在请求面条目形 {@link RequestMcpServerSpec}(条目层 = 引擎 `McpServerSpec` 的条目层)上:型上多一个键而表没跟 ⇒ 红;表里写一个型上没有的词
|
|
58
|
+
* (改名 / 拼错 / 删键后的残条目)⇒ 也红。传输层:两张键表**就是**两臂处置表的键(`mcp-assertion-header.ts` 的 {@link MCP_STDIO_TRANSPORT_DISPOSITION} /
|
|
59
|
+
* {@link MCP_HTTP_TRANSPORT_DISPOSITION}),处置表对契约包的请求传输形两向钉、对引擎的传输形再钉两道 —— 一张表同时说「收哪些键」与「每个键去哪」。
|
|
60
|
+
* 于是这几张表是从型**派生**出来的数据,而不是谁记得去同步的清单。
|
|
60
61
|
*
|
|
61
62
|
* ## 一个回答者,两扇门;读器另算
|
|
62
63
|
* 「这份声明能不能原样用」只有 {@link requestMcpDeclarationRefusal} 一只回答者:词表外的键(条目层 / 本形 `transport` 层)⇒ `400 request.body_shape` 带 `unknownKeys`,
|
|
@@ -66,12 +67,11 @@ export declare const MAX_REQUEST_MCP_DROP_NAMES = 32;
|
|
|
66
67
|
* ## 受理键的判官表也钉在这张表上
|
|
67
68
|
* 逐键判官表 {@link ENTRY_KEY_JUDGES} 是 `{ [K in 本表的键]: 判官 }` 的映射型 —— 本表多一个键而没写判官 ⇒ 编译红,不会出现「这个键写坏了却被悄悄受理」的新键。
|
|
68
69
|
*/
|
|
69
|
-
export declare const MCP_SERVER_ENTRY_KEYS: readonly ["allowTools", "contentOrigin", "elicitation", "name", "source", "startupTimeoutMs", "toolAxes", "toolFaces", "transport"];
|
|
70
|
-
/** `transport.kind:"stdio"` 的键闭集(
|
|
71
|
-
export declare const STDIO_MCP_TRANSPORT_KEYS: readonly
|
|
72
|
-
/** `transport.kind:"http"` 的键闭集(
|
|
73
|
-
|
|
74
|
-
export declare const HTTP_MCP_TRANSPORT_KEYS: readonly ["assertionHeader", "headers", "kind", "principalHeader", "url"];
|
|
70
|
+
export declare const MCP_SERVER_ENTRY_KEYS: readonly ["allowTools", "contentOrigin", "elicitation", "name", "sessionMetaKey", "source", "startupTimeoutMs", "toolAxes", "toolFaces", "transport"];
|
|
71
|
+
/** `transport.kind:"stdio"` 的键闭集 = stdio 臂处置表的键(`env` 是件,其余进声明)。 */
|
|
72
|
+
export declare const STDIO_MCP_TRANSPORT_KEYS: readonly ("env" | "kind" | "args" | "command")[];
|
|
73
|
+
/** `transport.kind:"http"` 的键闭集 = http 臂处置表的键(`headers` 是件,`assertionHeader` 承载不发送,其余进声明)。 */
|
|
74
|
+
export declare const HTTP_MCP_TRANSPORT_KEYS: readonly ("headers" | "kind" | "principalHeader" | "url" | "assertionHeader")[];
|
|
75
75
|
/**
|
|
76
76
|
* Does THIS deployment honor caller-supplied per-request MCP servers? TRUE for a SINGLE-USER deployment
|
|
77
77
|
* (deployment-shape row `multiTenant` does not hold) — the requester is the super-admin of their own worker, so their `.mcp.json` is
|
|
@@ -157,9 +157,10 @@ export declare function requestEntryIdentityIssue(entry: unknown): McpIdentityHe
|
|
|
157
157
|
* `startupTimeoutMs` = 引擎根导出的 `mcpStartupTimeoutMs`(坏值抛 `config.mcp_startup_timeout_invalid`,本门把那一句作原因句);`contentOrigin` = `isContentOriginWord`;`source` = `isMcpSourceLabel`;
|
|
158
158
|
* `name` = `isUsableWireName`;`allowTools` / `transport.args` = {@link isStringArray};`transport.env` / `headers` = 契约包读器 {@link readRequestMcpTransport} 的纯数据记录读法;`elicitation` = {@link isElicitationFlag};
|
|
159
159
|
* `transport` 的硬字段(`kind` / `command` / `url`)与软字段(`args` / `env` / `headers` / `principalHeader`)= {@link readRequestMcpTransport}(读器投影 transport 的那一只函数,门读它报的 `lost`;读器在契约包,本仓只据 `lost[0]` 拒、据 `lost` 在重放腿逐处点名);
|
|
160
|
-
* 读器交回的 http `url` 再问「带不带凭据」= 契约包根的 `findUrlCredential`([ref];拒体另带机读 `field` + `reason`,见 {@link transportUrlCredentialIssue})
|
|
160
|
+
* 读器交回的 http `url` 再问「带不带凭据」= 契约包根的 `findUrlCredential`([ref];拒体另带机读 `field` + `reason`,见 {@link transportUrlCredentialIssue});
|
|
161
|
+
* http `principalHeader` 再问「这个名有没有别的属主」= 引擎包根的 `headerOwnershipCollision`(见 {@link principalHeaderOwnershipIssue})。
|
|
161
162
|
* 于是判官受理的条目,读器({@link normalizeServer})交回的就是申报本身(只差判官自己的合法归一:空容器 / `skillScopeEligible:false` 折成缺席、`toolAxes` 取引擎的拷贝)——
|
|
162
|
-
* 探测口拨的那一份因此就是提交腿会挂的那一份,不另比一遍(另比就是第二只回答者)。唯一按门分的后果是「声明了 `assertionHeader`」这一个事实(
|
|
163
|
+
* 探测口拨的那一份因此就是提交腿会挂的那一份,不另比一遍(另比就是第二只回答者)。唯一按门分的后果是「声明了 `assertionHeader`」这一个事实(本部署不发送断言,
|
|
163
164
|
* 承载、不发送):新提交照挂 + 运维 info,探测口整条拒 —— 判据是同一只谓词 `specWithholdsMcpAssertionHeader`(开关 `MCP_ASSERTION_HEADER_SENT` 假时「声明了」即「被扣下」),不是第二份判法(见 `readMcpProbeBody`)。
|
|
164
165
|
*
|
|
165
166
|
* ## 射程
|
|
@@ -184,6 +185,14 @@ export declare function requestMcpDeclarationRefusal(list: unknown): Declaration
|
|
|
184
185
|
* 交出去的剔掉 `__proto__` 名成员),server 照挂,运维 warn `mcp_transport_members_dropped` 逐处点名 —— 续跑重放腿不静默丢声明。
|
|
185
186
|
*/
|
|
186
187
|
export declare function assertRequestMcpEntries(bodyMcp: unknown): void;
|
|
188
|
+
/**
|
|
189
|
+
* `principalHeader` 的**名**有没有别的属主:判官是引擎包根的 `headerOwnershipCollision`(拨号时判同一条的那一只;这里只问身份头这一个名,件头名由引擎在发送时判)——
|
|
190
|
+
* 名(任何大小写)是这一协议的传输自己写的头(MCP:`mcp-session-id` · `mcp-protocol-version` · `content-type` · `accept` · `last-event-id`;A2A 没有),或是引擎的断言头
|
|
191
|
+
* (`connector-assertion`)⇒ 这一台拨号时必被拒,新提交在门上按名拒。原因句只点名**属主的拼写**(引擎固定表里的规范化小写头名),不回显调用方写的原串 / 大小写形(调用方写的恰是小写时,句里的名与所写相同)。
|
|
192
|
+
* 新提交腿上按名 400(MCP 门表的 `transport`、A2A 判官表的 `principalHeader`)。续跑重放腿不 4xx:MCP 的读器不问它 —— 存量体里这一形照挂,由引擎在拨号时拒那一台、兄弟照挂;
|
|
193
|
+
* A2A 的读器问同一张判官表 —— 这一条对端整条不进、`a2a_injection_dropped` 点名原因(引擎物化时同样拒那一台;结局同,原因说在本仓这一行)。
|
|
194
|
+
*/
|
|
195
|
+
export declare function principalHeaderOwnershipIssue(principalHeader: string | undefined, protocol: "mcp" | "a2a", path: string): DeclarationKeyIssue | undefined;
|
|
187
196
|
/**
|
|
188
197
|
* The ONE predicate for "this MCP server name belongs to the deployment": the scenario baseline (what mounted for
|
|
189
198
|
* this scenario) ∪ every name the deployment DECLARED (`CenterMcp.reservedNames` — mounted or not, any scenario).
|
|
@@ -194,12 +203,14 @@ export declare function assertRequestMcpEntries(bodyMcp: unknown): void;
|
|
|
194
203
|
*/
|
|
195
204
|
export declare function deploymentClosedMcpNames(baseline: McpServerSpec[] | undefined, reservedNames: readonly string[]): ReadonlySet<string>;
|
|
196
205
|
/**
|
|
197
|
-
* Merge GATED per-request MCP
|
|
198
|
-
* ({@link deploymentClosedMcpNames}) are dropped from `
|
|
199
|
-
*
|
|
200
|
-
*
|
|
206
|
+
* Merge GATED per-request MCP drafts OVER the deployment baseline (center/config): **select first, then mint**. Names closed by the deployment
|
|
207
|
+
* ({@link deploymentClosedMcpNames}) are dropped from `drafts` before anything is registered — a draft that loses to the deployment never
|
|
208
|
+
* reaches the desk; each winner is minted once on `desk` under `lease` (`peer-seat.ts` `mintDeclaration`: the reference on its transport, zero
|
|
209
|
+
* piece values). `desk` / `lease` = the process's peer desk and this leg's host lease (`boot/resolve-spec.ts` passes `peerDesk` and `opts.lease`).
|
|
210
|
+
* `reservedNames` has NO default: a security predicate's input is never implied — a caller with no deployment declaration passes `[]` and says so.
|
|
211
|
+
* Returns the baseline unchanged when nothing is added.
|
|
201
212
|
*/
|
|
202
|
-
export declare function mergeRequestMcp(baseline: McpServerSpec[] | undefined,
|
|
213
|
+
export declare function mergeRequestMcp(baseline: McpServerSpec[] | undefined, drafts: readonly McpDraft[], reservedNames: readonly string[], desk: Pick<PeerDesk, "declare">, lease: PeerLease): McpServerSpec[] | undefined;
|
|
203
214
|
/**
|
|
204
215
|
* The single entry point the spec-builder calls: compute the effective `TaskSpec.mcp` = deployment baseline + the
|
|
205
216
|
* caller's gated per-request servers. Off the honored lane (or with no caller servers) returns the baseline
|
|
@@ -216,7 +227,9 @@ export declare function resolveRequestMcp(baseline: McpServerSpec[] | undefined,
|
|
|
216
227
|
mcpServers?: {
|
|
217
228
|
reservedNames: readonly string[];
|
|
218
229
|
};
|
|
219
|
-
},
|
|
230
|
+
},
|
|
231
|
+
/** 对端座的 desk 与本腿的宿主租约(必填):胜出草稿在它下面铸成带引用的声明 —— 一条腿交给引擎的请求面声明只经它带引用。 */
|
|
232
|
+
desk: Pick<PeerDesk, "declare">, lease: PeerLease, logger?: {
|
|
220
233
|
info?(m: string, meta?: unknown): void;
|
|
221
234
|
warn(m: string, meta?: unknown): void;
|
|
222
235
|
},
|
package/dist/task-mcp.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { mcpInjectionDroppedNotice, mcpStartupTimeoutMs, readToolFaces, resolveComplianceDenies } from "@sema-agent/core";
|
|
1
|
+
import { MCP_ASSERTION_HEADER, headerOwnershipCollision, judgeSessionMetaKey, mcpInjectionDroppedNotice, mcpStartupTimeoutMs, readToolFaces, resolveComplianceDenies } from "@sema-agent/core";
|
|
2
2
|
import { MCP_CONTENT_ORIGINS, describeBadContentOrigin, describeNotStringArray, describeValueShape, findUrlCredential, isContentOriginWord, isStringArray, isUsableWireName, readRequestMcpTransport, stripControlAndBidi, } from "@sema-agent/settings-schema";
|
|
3
3
|
import { HttpError } from "./security.js";
|
|
4
4
|
import { GOVERNANCE_HTTP_STATUS } from "./governance-http-status.js";
|
|
5
5
|
import { DEPLOYMENT_SHAPE_PREDICATES } from "./deployment-shape.js";
|
|
6
6
|
import { MCP_SOURCE_LABEL_MAX, isMcpSourceLabel, readMcpSourceLabel } from "./mcp-source-label.js";
|
|
7
|
-
import { describeMcpAssertionHeaderNotAString, describeMcpIdentityHeadersConflict, mcpIdentityHeadersIssue, noteMcpAssertionHeaderIgnored, noteMcpAssertionHeaderNotSent, specWithholdsMcpAssertionHeader,
|
|
7
|
+
import { MCP_HTTP_TRANSPORT_DISPOSITION, MCP_STDIO_TRANSPORT_DISPOSITION, describeMcpAssertionHeaderNotAString, describeMcpIdentityHeadersConflict, mcpIdentityHeadersIssue, noteMcpAssertionHeaderIgnored, noteMcpAssertionHeaderNotSent, specWithholdsMcpAssertionHeader, toMcpDraft, } from "./mcp-assertion-header.js";
|
|
8
|
+
import { declarationKeys } from "./plain-string-record.js";
|
|
9
|
+
import { mintDeclaration, peerSentence } from "./peer-seat.js";
|
|
8
10
|
import { MAX_KEY_ECHO, echoKeyName, keyClosureClause, scanKeyClosure } from "./request-key-closure.js";
|
|
9
11
|
import { readRequestToolAxes } from "./request-tool-axes.js";
|
|
10
12
|
import { urlCredentialHeaderExit, urlCredentialRefusalReason } from "./url-credential-refusal.js";
|
|
11
13
|
import { MALFORMED_NAME, declarationFieldRefusal, declarationNameIssue, declaredName, judgeDeclarationKeys, requestDeclarationRefusal, throwDeclarationRefusal, } from "./request-declaration-refusal.js";
|
|
12
14
|
export const MAX_REQUEST_MCP_SERVERS = 32;
|
|
13
15
|
export const MAX_REQUEST_MCP_DROP_NAMES = MAX_REQUEST_MCP_SERVERS;
|
|
14
|
-
export const MCP_SERVER_ENTRY_KEYS = ["allowTools", "contentOrigin", "elicitation", "name", "source", "startupTimeoutMs", "toolAxes", "toolFaces", "transport"];
|
|
15
|
-
export const STDIO_MCP_TRANSPORT_KEYS =
|
|
16
|
-
export const HTTP_MCP_TRANSPORT_KEYS =
|
|
16
|
+
export const MCP_SERVER_ENTRY_KEYS = ["allowTools", "contentOrigin", "elicitation", "name", "sessionMetaKey", "source", "startupTimeoutMs", "toolAxes", "toolFaces", "transport"];
|
|
17
|
+
export const STDIO_MCP_TRANSPORT_KEYS = declarationKeys(MCP_STDIO_TRANSPORT_DISPOSITION);
|
|
18
|
+
export const HTTP_MCP_TRANSPORT_KEYS = declarationKeys(MCP_HTTP_TRANSPORT_DISPOSITION);
|
|
17
19
|
export function mcpInjectionHonored(config) {
|
|
18
20
|
if (config.lockedConfigKeys?.includes("mcp") === true)
|
|
19
21
|
return false;
|
|
@@ -52,7 +54,7 @@ function normalizeServer(e, noteBadOrigin, storedToolAxes) {
|
|
|
52
54
|
const again = readRequestToolAxes(storedToolAxes.mcp(o.toolAxes), "mcp");
|
|
53
55
|
if (again.ok) {
|
|
54
56
|
judged = again;
|
|
55
|
-
toolAxesReread = stripControlAndBidi(axes.problem);
|
|
57
|
+
toolAxesReread = peerSentence(stripControlAndBidi(axes.problem));
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
if (!judged.ok)
|
|
@@ -73,6 +75,11 @@ function normalizeServer(e, noteBadOrigin, storedToolAxes) {
|
|
|
73
75
|
return bad("toolFaces");
|
|
74
76
|
if (faces.faces !== undefined)
|
|
75
77
|
spec.toolFaces = faces.faces;
|
|
78
|
+
const metaKey = judgeSessionMetaKey(o.sessionMetaKey);
|
|
79
|
+
if ("problem" in metaKey)
|
|
80
|
+
return bad("sessionMetaKey");
|
|
81
|
+
if (metaKey.key !== undefined)
|
|
82
|
+
spec.sessionMetaKey = metaKey.key;
|
|
76
83
|
return { ok: true, spec, ...(toolAxesReread !== undefined ? { toolAxesReread } : {}), transportLost: read.lost };
|
|
77
84
|
}
|
|
78
85
|
export function validateRequestMcp(raw) {
|
|
@@ -92,7 +99,7 @@ function validateRequestMcpEntries(raw, storedToolAxes) {
|
|
|
92
99
|
if (v.ok) {
|
|
93
100
|
ok.push(v.spec);
|
|
94
101
|
if (v.toolAxesReread !== undefined)
|
|
95
|
-
toolAxesReread.push({ server: v.spec.name,
|
|
102
|
+
toolAxesReread.push({ server: v.spec.name, sentence: v.toolAxesReread });
|
|
96
103
|
if (v.transportLost.length > 0)
|
|
97
104
|
transportLost.push({ server: v.spec.name, lost: v.transportLost.map((i) => i.path) });
|
|
98
105
|
}
|
|
@@ -164,6 +171,17 @@ function transportUrlCredentialIssue(url) {
|
|
|
164
171
|
return undefined;
|
|
165
172
|
return { path: "transport.url", reason: urlCredentialRefusalReason(found, urlCredentialHeaderExit("transport.headers")), credential: found };
|
|
166
173
|
}
|
|
174
|
+
export function principalHeaderOwnershipIssue(principalHeader, protocol, path) {
|
|
175
|
+
if (principalHeader === undefined)
|
|
176
|
+
return undefined;
|
|
177
|
+
const collision = headerOwnershipCollision({ principalHeader }, protocol);
|
|
178
|
+
if (collision === undefined)
|
|
179
|
+
return undefined;
|
|
180
|
+
return {
|
|
181
|
+
path,
|
|
182
|
+
reason: `names the header "${collision.first}" (header names are case-insensitive), which is not the principal header's to own — it is ${protocol === "mcp" && collision.first !== MCP_ASSERTION_HEADER ? "a header the MCP transport writes itself" : "the engine's connector assertion header"}; name the principal header something of its own`,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
167
185
|
const ENTRY_KEY_JUDGES = {
|
|
168
186
|
allowTools: (o) => o.allowTools === undefined || isStringArray(o.allowTools)
|
|
169
187
|
? undefined
|
|
@@ -177,6 +195,10 @@ const ENTRY_KEY_JUDGES = {
|
|
|
177
195
|
},
|
|
178
196
|
elicitation: (o) => (o.elicitation === undefined || isElicitationFlag(o.elicitation) ? undefined : { path: "elicitation", reason: `must be a boolean — got ${describeValueShape(o.elicitation)}` }),
|
|
179
197
|
name: declarationNameIssue,
|
|
198
|
+
sessionMetaKey: (o) => {
|
|
199
|
+
const read = judgeSessionMetaKey(o.sessionMetaKey);
|
|
200
|
+
return "problem" in read ? { path: "sessionMetaKey", reason: peerSentence(read.problem) } : undefined;
|
|
201
|
+
},
|
|
180
202
|
source: (o) => o.source === undefined || isMcpSourceLabel(o.source)
|
|
181
203
|
? undefined
|
|
182
204
|
: { path: "source", reason: `must be a non-empty string of at most ${MCP_SOURCE_LABEL_MAX} characters (a display label) — got ${describeValueShape(o.source)}` },
|
|
@@ -190,16 +212,16 @@ const ENTRY_KEY_JUDGES = {
|
|
|
190
212
|
catch (e) {
|
|
191
213
|
if (e.code !== "config.mcp_startup_timeout_invalid")
|
|
192
214
|
throw e;
|
|
193
|
-
return { path: "startupTimeoutMs", reason: e instanceof Error ? e.message : String(e) };
|
|
215
|
+
return { path: "startupTimeoutMs", reason: peerSentence(e instanceof Error ? e.message : String(e)) };
|
|
194
216
|
}
|
|
195
217
|
},
|
|
196
218
|
toolAxes: (o) => {
|
|
197
219
|
const read = readRequestToolAxes(o.toolAxes, "mcp");
|
|
198
|
-
return read.ok ? undefined : { path: "toolAxes", reason: read.problem };
|
|
220
|
+
return read.ok ? undefined : { path: "toolAxes", reason: peerSentence(read.problem) };
|
|
199
221
|
},
|
|
200
222
|
toolFaces: (o) => {
|
|
201
223
|
const read = readToolFaces(o.toolFaces);
|
|
202
|
-
return read.ok ? undefined : { path: "toolFaces", reason: read.problem };
|
|
224
|
+
return read.ok ? undefined : { path: "toolFaces", reason: peerSentence(read.problem) };
|
|
203
225
|
},
|
|
204
226
|
transport: (o) => {
|
|
205
227
|
const read = readRequestMcpTransport(o.transport);
|
|
@@ -207,7 +229,9 @@ const ENTRY_KEY_JUDGES = {
|
|
|
207
229
|
return read.issue;
|
|
208
230
|
if (read.lost[0] !== undefined)
|
|
209
231
|
return read.lost[0];
|
|
210
|
-
|
|
232
|
+
if (read.transport.kind !== "http")
|
|
233
|
+
return undefined;
|
|
234
|
+
return transportUrlCredentialIssue(read.transport.url) ?? principalHeaderOwnershipIssue(read.transport.principalHeader, "mcp", "transport.principalHeader");
|
|
211
235
|
},
|
|
212
236
|
};
|
|
213
237
|
function requestEntryRefusal(entry, at) {
|
|
@@ -229,27 +253,27 @@ function requestEntryRefusal(entry, at) {
|
|
|
229
253
|
export function deploymentClosedMcpNames(baseline, reservedNames) {
|
|
230
254
|
return new Set([...(baseline ?? []).map((s) => s.name), ...reservedNames]);
|
|
231
255
|
}
|
|
232
|
-
export function mergeRequestMcp(baseline,
|
|
233
|
-
if (
|
|
256
|
+
export function mergeRequestMcp(baseline, drafts, reservedNames, desk, lease) {
|
|
257
|
+
if (drafts.length === 0)
|
|
234
258
|
return baseline;
|
|
235
259
|
const closed = deploymentClosedMcpNames(baseline, reservedNames);
|
|
236
|
-
const
|
|
237
|
-
return
|
|
260
|
+
const winners = drafts.filter((d) => !closed.has(d.spec.name));
|
|
261
|
+
return winners.length === 0 ? baseline : [...(baseline ?? []), ...winners.map((d) => mintDeclaration(desk, d, lease))];
|
|
238
262
|
}
|
|
239
|
-
export function resolveRequestMcp(baseline, bodyMcp, config, logger, notice, storedToolAxes) {
|
|
263
|
+
export function resolveRequestMcp(baseline, bodyMcp, config, desk, lease, logger, notice, storedToolAxes) {
|
|
240
264
|
if (bodyMcp === undefined || bodyMcp === null)
|
|
241
265
|
return baseline;
|
|
242
|
-
const { mcp, drops } = classifyRequestMcp(baseline, bodyMcp, config, logger, storedToolAxes);
|
|
266
|
+
const { mcp, drops } = classifyRequestMcp(baseline, bodyMcp, config, desk, lease, logger, storedToolAxes);
|
|
243
267
|
mintInjectionDropNotices(drops, notice);
|
|
244
268
|
return mcp;
|
|
245
269
|
}
|
|
246
|
-
function classifyRequestMcp(baseline, bodyMcp, config, logger, storedToolAxes) {
|
|
270
|
+
function classifyRequestMcp(baseline, bodyMcp, config, desk, lease, logger, storedToolAxes) {
|
|
247
271
|
if (bodyMcp !== undefined && bodyMcp !== null && !Array.isArray(bodyMcp)) {
|
|
248
272
|
logger?.warn("mcp_injection_ignored", { reason: "mcpServers not an array" });
|
|
249
273
|
return { mcp: baseline, drops: [] };
|
|
250
274
|
}
|
|
251
275
|
const entries = Array.isArray(bodyMcp) ? bodyMcp : [];
|
|
252
|
-
const outcome = mcpInjectionHonored(config) ? classifyHonored(baseline, entries, config, logger, storedToolAxes) : classifyGateClosed(baseline, entries);
|
|
276
|
+
const outcome = mcpInjectionHonored(config) ? classifyHonored(baseline, entries, config, desk, lease, logger, storedToolAxes) : classifyGateClosed(baseline, entries);
|
|
253
277
|
if (outcome.drops.length > 0)
|
|
254
278
|
logger?.warn("mcp_injection_dropped", { dropped: outcome.drops, droppedTotal: outcome.droppedTotal });
|
|
255
279
|
return { mcp: outcome.mcp, drops: outcome.drops };
|
|
@@ -261,7 +285,7 @@ function classifyGateClosed(baseline, entries) {
|
|
|
261
285
|
droppedTotal: entries.length,
|
|
262
286
|
};
|
|
263
287
|
}
|
|
264
|
-
function classifyHonored(baseline, entries, config, logger, storedToolAxes) {
|
|
288
|
+
function classifyHonored(baseline, entries, config, desk, lease, logger, storedToolAxes) {
|
|
265
289
|
const v = validateRequestMcpEntries(entries, storedToolAxes);
|
|
266
290
|
if (v.badContentOrigin.length > 0) {
|
|
267
291
|
logger?.warn("mcp_content_class_dropped", {
|
|
@@ -288,7 +312,7 @@ function classifyHonored(baseline, entries, config, logger, storedToolAxes) {
|
|
|
288
312
|
logger?.warn("mcp_tool_axes_read_as_before_upgrade", {
|
|
289
313
|
server: r.server,
|
|
290
314
|
migration: "M19",
|
|
291
|
-
problem: r.
|
|
315
|
+
problem: r.sentence,
|
|
292
316
|
note: "this replayed request was stored before the upgrade and its toolAxes declaration does not pass the engine's reader; while one-time migration M19 is open it is read the way the pre-upgrade server read it (members that did not fit are dropped, a declaration that is not an object counts as none) and the server stays mounted — once the window closes the same request leaves this server unmounted",
|
|
293
317
|
});
|
|
294
318
|
}
|
|
@@ -305,7 +329,7 @@ function classifyHonored(baseline, entries, config, logger, storedToolAxes) {
|
|
|
305
329
|
});
|
|
306
330
|
}
|
|
307
331
|
return {
|
|
308
|
-
mcp: mergeRequestMcp(baseline, v.ok.map(
|
|
332
|
+
mcp: mergeRequestMcp(baseline, v.ok.map(toMcpDraft), reservedNames, desk, lease),
|
|
309
333
|
drops: [...v.dropped, ...blocked.map((server) => ({ server, reason: "name_reserved_by_deployment" }))],
|
|
310
334
|
droppedTotal: v.droppedTotal + blocked.length,
|
|
311
335
|
};
|
package/dist/tool-approval.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExecutionLane } from "./execution-lane-caps.js";
|
|
1
2
|
import { type ApprovalDecidedBy, type HostSettledBy, type RetiredDecisionKeyFacts } from "./host-decision.js";
|
|
2
3
|
import type { IncomingMessage } from "node:http";
|
|
3
4
|
import { type AskClass, type AskRequest, type AskOutcome, type PermissionResult, type CheckpointGate, type PendingAction, type PersistedRuleMandate, type ReadRootGrantCandidate, type RuleOffer, type AutoModeFallbackCause, type BoundGrantAbsence, type BoundSkillGrants, type ToolApprovalCard, type ReopenReason } from "@sema-agent/core";
|
|
@@ -10,8 +11,9 @@ import { type AskRowEndingCause, type SettleCause, type SettleOutcome } from "./
|
|
|
10
11
|
import type { ParkCommitWatch } from "./plugins/park-commit-watch.js";
|
|
11
12
|
import { type GovernanceAskMarks } from "./governance-ask-marks.js";
|
|
12
13
|
import { type GovernancePosture } from "./runtime-governance.js";
|
|
13
|
-
import { type GrantBinding, type
|
|
14
|
+
import { type GrantBinding, type StandingAnswerCard } from "./standing-answer-grant.js";
|
|
14
15
|
import { type ApprovalExemptionStore } from "./plugins/approval-exemption-store.js";
|
|
16
|
+
import { type ExtensionRequesterFace } from "./trace/extension-call-face.js";
|
|
15
17
|
/** {@link ToolApprovalCoordinator.adoptOpenAsks} 的读数(装配点进启动日志)。 */
|
|
16
18
|
interface OpenAskAdoption {
|
|
17
19
|
/** 本次接管进活集合的问数。 */
|
|
@@ -214,10 +216,10 @@ export declare function carriesDeploymentListQuestion(deploymentListAsks: boolea
|
|
|
214
216
|
* (`task-settings.ts`,`false`)—— 它们在交出这一问之前先读按工具名记的耐久豁免店(「本会话不再询问」在本层兑现,继承链上的同一问才够得着;审批席依约不退役
|
|
215
217
|
* 继承问),而**能不能读**与审批席 / 回决写侧是同一只判据({@link standingAnswerDurablyRecordable}):记得下的才代答,记不下的(带授予绑定的问 ……)不代答,
|
|
216
218
|
* 存量行也不例外 —— 一事一读。事实取自**这一问本身**:类集经 core 包根唯一的类派生 `classifyAsk`({@link noGateFacts},调用坐标取 `req`);`requiresRealApproval` /
|
|
217
|
-
* `mandated` 读这一问自报的成员;治理位恒假(本层不是治理层)
|
|
218
|
-
* `
|
|
219
|
+
* `mandated` 读这一问自报的成员;治理位恒假(本层不是治理层);授予绑定读**请求上引擎的词**(core 7.59.0 起 Runner 交给策略的 `ToolCallRequest`
|
|
220
|
+
* 带与卡同一组词;宿主不经 Runner 自建的请求两者都不说 ⇒ `unreadable` ⇒ 不读店,fail-closed —— 见 `standing-answer-grant.ts` 头注)。
|
|
219
221
|
*/
|
|
220
|
-
export declare function policyAskStandingAnswerFacts(req:
|
|
222
|
+
export declare function policyAskStandingAnswerFacts(req: StandingAnswerCard & {
|
|
221
223
|
readonly toolCallId: string;
|
|
222
224
|
readonly toolName: string;
|
|
223
225
|
}, ask: Extract<PermissionResult, {
|
|
@@ -242,8 +244,8 @@ export interface StandingAnswerFacts {
|
|
|
242
244
|
readonly mandated: boolean;
|
|
243
245
|
/** 这一问的应答**授不授予**这一次调用之外的东西、授予的话绑定是什么(批准引擎的 `Skill` = 激活技能 + 本 run 内清单免问)。
|
|
244
246
|
* `bound` ⇒ 站着的答案按「工具 + 绑定」记、只代答绑定相同的问(core 7.43.0 [ref] / [ref]:活的问与停驻行同带 `boundGrantDigest`);
|
|
245
|
-
* `unreadable` ⇒ 不可记、不被代答(fail-closed)。读者一律经 `standing-answer-grant.ts`
|
|
246
|
-
*
|
|
247
|
+
* `unreadable` ⇒ 不可记、不被代答(fail-closed)。读者一律经 `standing-answer-grant.ts` 的唯一读口 `grantBindingOf` 折这一位:只读载体上引擎的词,
|
|
248
|
+
* 载体不论(卡、停驻行、队列行、策略层的请求)。 */
|
|
247
249
|
readonly grantBinding: GrantBinding;
|
|
248
250
|
/** 引擎盖在这一问上的**类集**(`AskRequest.classes` / 停驻行孪生座;经 core 的屏 `screenAskClassMembers` 读)。`undefined` = 卡上没有类
|
|
249
251
|
* (老引擎 / 不盖类的站)或屏拒 —— 读不出的类不是「无类」。 */
|
|
@@ -474,6 +476,14 @@ export interface ToolApprovalFrame {
|
|
|
474
476
|
* ask」,治理策略产的与普通策略产的在这一个词上同形 ⇒ 顶替不了(逐字论证见 `governance-ask-marks.ts` 顶注)。
|
|
475
477
|
*/
|
|
476
478
|
origin?: string;
|
|
479
|
+
/**
|
|
480
|
+
* **ADDITIVE,`"tool_approval"` only** —— 这一问的调用是**一张扩展注册自己发起**的(`$.tool.call`,core 7.56.0 `AskRequest.requestedBy`):
|
|
481
|
+
* `{ kind: "extension", name }`,卡上「扩展 X 想跑 …」那一行的出处。模型消息带来的调用上缺席。display 事实,不是裁决输入。
|
|
482
|
+
* 读法与 `tool_start` / `tool_end` 上的同名键是同一只(`trace/extension-call-face.ts`:注册名过注册方文本的出口纪律,与 `wiring_manifest.mods[]` 的 `name`
|
|
483
|
+
* 逐字节同;形不对 ⇒ 丢 + 计一次)。呈卡腿上它是 `approval_request` 顶层的卡外座之一(`APPROVAL_REQUEST_LIVE_FACT_KEYS`,同一只帧对象的值);
|
|
484
|
+
* ⚠️ `card_json` 卡面不带本键(卡的键集属主在契约包),断连重放帧上它恒缺席(与其余卡外座同)。
|
|
485
|
+
*/
|
|
486
|
+
requestedBy?: ExtensionRequesterFace;
|
|
477
487
|
/**
|
|
478
488
|
* **[ref] ②(core 7.37.0 [ref];ADDITIVE,`"tool_approval"` only)** —— 这一问的**类**:`classes` 的首员(core `ASK_CLASSES` 序),
|
|
479
489
|
* `MODE_ARBITRATION` 的行键(权限模式读的就是它 / 它们)。引擎在每一个铸 `origin` 的站盖章(策略自报的值在盖章处被替换),本仓经
|
|
@@ -499,7 +509,7 @@ export interface ToolApprovalFrame {
|
|
|
499
509
|
/** [ref](core 7.51.0 [ref],**ADDITIVE**,`"tool_approval"` only):这张卡为什么没有 {@link boundGrantDigest} —— 引擎铸的每张卡恰带两者之一:
|
|
500
510
|
* `not_bindable`(这一问不是引擎 `Skill` 工具的激活,不绑任何授予 ⇒ 应答可按工具记)/ `unreadable`(绑着却读不出;活卡上引擎恒给摘要,这一词
|
|
501
511
|
* 只出现在读存量行的面上)。闭集经 `readClosedWordSeat(req, "boundGrantAbsence")` 窄读(筛 = core `BOUND_GRANT_ABSENCES`),集外 ⇒ 缺席 + 计一次。
|
|
502
|
-
* 与停驻行 / 运维队列行 / inbox
|
|
512
|
+
* 与停驻行 / 运维队列行 / inbox 行的同名位同值;站着的答案的授予绑定读它(`standing-answer-grant.ts` `grantBindingOf`,问是谁的都同读)。display。 */
|
|
503
513
|
boundGrantAbsence?: BoundGrantAbsence;
|
|
504
514
|
/** core 7.43.0 [ref]:分类器没给判词的成因词(`error` / `timeout` / `parse_error`;只在类 `classifier_no_ruling` 的卡上)。闭集经 core 的
|
|
505
515
|
* `readClosedWordSeat(req, "classifierNoRuling")` 窄读(筛 = core `isAutoModeFallbackCause`),集外 ⇒ 缺席 + 计一次。display:本仓不按它裁决。 */
|
|
@@ -863,6 +873,8 @@ interface ToolApprovalRunContextBase {
|
|
|
863
873
|
taskId: string;
|
|
864
874
|
sessionId?: string;
|
|
865
875
|
owner: string | null;
|
|
876
|
+
/** 这条腿的执行车道 —— 装配点写所在边界执行上下文的 `ctx.lane`(`http/execution-context.ts`)。出处带车道:这只席造的问在铸行时记下它。 */
|
|
877
|
+
executionLane: ExecutionLane;
|
|
866
878
|
abortSignal?: AbortSignal;
|
|
867
879
|
/** [ref]([ref] §3.1 askId 派生的腿轴;车3 刀 3a 换轴:原 `leg?: number` → `legKey?: string`)。
|
|
868
880
|
* = `sha256(resume checkpoint token)` 的 hex,**首腿缺席折空串**(空串是首腿的真值,不是「未知」)。
|
|
@@ -1601,7 +1613,7 @@ export declare class ToolApprovalCoordinator {
|
|
|
1601
1613
|
* ⇒ 截一个字就恒 `rule_not_offered`,所以**绝不截**;真超尺(= core 放宽了自己的 512 或本仓与 core
|
|
1602
1614
|
* 版本不同步)⇒ **整条车道撤回**(返回 `undefined`),与本文件既有的治理撤回 / 漂移撤回逐字同形:
|
|
1603
1615
|
* 少渲一格是安全方向,渲一格按不动的才是 wire 谎言。今天这条臂不可达(每个座都是解析器产物),
|
|
1604
|
-
* 它守的是版本不同步那一形 —— 与 `
|
|
1616
|
+
* 它守的是版本不同步那一形 —— 与 `isCommandRuleMatch` 的运行期 `default` 同族。
|
|
1605
1617
|
*
|
|
1606
1618
|
* 位置在**素材铸点**(与基数帽同一处):两族帧 + `card_json` + 回决口的等式左边从此拿的是**同一份**
|
|
1607
1619
|
* 已截素材,而不是两处各截一遍。
|
|
@@ -1611,7 +1623,22 @@ export declare class ToolApprovalCoordinator {
|
|
|
1611
1623
|
private static ruleOfferTextsOverSize;
|
|
1612
1624
|
/** codex r1 [high]([ref]):offer 的自称座与 `parseRuleText(rule, "allow")` 派生的三元组逐字一致?(理由见调用点) */
|
|
1613
1625
|
private static ruleOfferDerivedFactsAgree;
|
|
1626
|
+
/**
|
|
1627
|
+
* 一只 single 候选的工具与它的匹配词对得上吗(卡上的 single 只有两族):命令形(exact / prefix / wildcard / pattern)⇒ 规则是 shell 的;
|
|
1628
|
+
* 整工具(`tool`,core 7.57.0:没有规则词替它说话的工具的卡铸「这只工具不再问」)⇒ 工具必须是一键整工具同意落得下的那一族
|
|
1629
|
+
* ({@link cardTakesWholeToolConsent}:没有自己的规则文法、不在 shell 面上 —— 一张 shell 卡上的整工具候选 = 一键放行每一个程序,引擎不铸,兑付时也兑不动)。
|
|
1630
|
+
* 其余匹配词(路径 / 名字 / 主机)不是本服务卡面的 single 候选 ⇒ 丢(那些卡今天没有本服务的规则车道)。穷举 `switch`:core 给匹配词加员时这里编译红。
|
|
1631
|
+
*/
|
|
1632
|
+
private static singleOfferToolAgrees;
|
|
1614
1633
|
private static boundRuleOfferTexts;
|
|
1634
|
+
/**
|
|
1635
|
+
* 这张卡的**绑定值**(`prepareCardApproval` 的 `command`,也是耐久行的 `rule_command`)= 引擎为这张卡铸的候选所说的那一形(core 只按卡的规则形铸候选):
|
|
1636
|
+
* · 候选全是整工具候选(`match: "tool"`,core 7.57.0;至少一只)⇒ `""` —— 整只工具不绑任何值;core 恰在 `command` 是 `""` 时为这类工具铸卡;
|
|
1637
|
+
* · 其余(命令形候选,或读者把候选丢光了)⇒ 被裁决的命令原字节 `args.command`(非空串;读不出 ⇒ 没有素材)。空候选表不说「整工具」:
|
|
1638
|
+
* 它什么形都没说,绑定值回到调用自己的命令(编辑面兑的就是它)。
|
|
1639
|
+
* 两形混在一张卡上 = 不是 core 铸得出的卡 ⇒ 没有素材(整条车道撤回,与本文件其余撤回臂同形)。`req.args` 窄读,禁裸 as-cast。
|
|
1640
|
+
*/
|
|
1641
|
+
private static cardBindingOf;
|
|
1615
1642
|
private buildRuleLaneMaterial;
|
|
1616
1643
|
/** [ref]([ref]/[ref] 双属主裁定):把某 wire run 的**流内未决 ask** 立即转 durable park——断连支专用。
|
|
1617
1644
|
* 匹配键=`ctxTaskId`(wire run id)。该字段的顶注说它「不是清扫判据」——那是因为清扫要判**连接**的
|
|
@@ -1746,6 +1773,7 @@ export declare class ToolApprovalCoordinator {
|
|
|
1746
1773
|
owner: string | null;
|
|
1747
1774
|
taskId: string;
|
|
1748
1775
|
sessionId?: string;
|
|
1776
|
+
executionLane: ExecutionLane;
|
|
1749
1777
|
}, why: LegUnattended) => ((req: AskRequest) => Promise<AskOutcome>);
|
|
1750
1778
|
/**
|
|
1751
1779
|
* 🔴 session grant 短路前的**持久出处复核**([ref] 的 codex R1-[high] 补丁;[ref] 换判据;[ref] / SN-C1 换读口)。
|
|
@@ -1944,6 +1972,8 @@ export declare class ToolApprovalCoordinator {
|
|
|
1944
1972
|
/** [ref] 车3 刀 3b(§7.3):本腿的 walltime deadline —— 与 `legKey` 同源同理由,随**出处**走
|
|
1945
1973
|
* (子代经继承链拿到的是宿主腿的闭包,窗必须按宿主腿的剩余 walltime 算)。 */
|
|
1946
1974
|
legDeadlineMonotonic?: number;
|
|
1975
|
+
/** 宿主腿的执行车道(装配点写执行上下文的 `ctx.lane`);子代经继承链冻同一闭包 ⇒ 子代的问记宿主腿的车道。 */
|
|
1976
|
+
executionLane: ExecutionLane;
|
|
1947
1977
|
}) => ((req: AskRequest, signal?: AbortSignal) => Promise<AskOutcome>);
|
|
1948
1978
|
/** 广播版裁决路径——`ask()`(ALS,恒单元素数组)与 `boundAsk`([ref]四多活集合,可能多元素)共用。
|
|
1949
1979
|
* 全体 `ctxs` 保证同一 (owner, sessionId)(streamKey 分组不变式;单元素数组平凡成立)。
|