@sema-agent/settings-schema 28.0.0 → 30.0.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/CHANGELOG.md +431 -0
- package/README.md +94 -14
- package/conformance/VERSION +1 -1
- package/conformance/cases/c01-entry-salvage-then-typo/expected.json +2 -2
- package/conformance/cases/c02-hosts-clamp-stacked/expected.json +1 -1
- package/conformance/cases/c03-literal-dotted-top-key/expected.json +1 -1
- package/conformance/cases/c04-all-bad-collection-not-salvaged/expected.json +1 -1
- package/conformance/cases/c07-hooks-is-not-a-config-domain/expected.json +1 -1
- package/conformance/cases/c08-limits-unknown-carried-64/expected.json +1 -1
- package/conformance/cases/c09-limits-unknown-carried-65/expected.json +1 -1
- package/conformance/cases/c10-record-key-secret-redacted-twice/expected.json +1 -1
- package/conformance/cases/c11-unicode-unknown-keys/expected.json +1 -1
- package/conformance/cases/c12-prototype-name-top-keys/expected.json +1 -1
- package/conformance/cases/c13-models-field-null/expected.json +1 -1
- package/conformance/cases/c14-models-field-empty-array/expected.json +1 -1
- package/conformance/cases/c15-models-field-number/expected.json +1 -1
- package/conformance/cases/c18-wire-envelope-not-an-object/expected.json +1 -1
- package/conformance/cases/c19-wire-envelope-no-version/expected.json +1 -1
- package/conformance/cases/c21-governance-empty-object-wins/expected.json +1 -1
- package/conformance/cases/c23-mixed-validity-models/expected.json +1 -1
- package/conformance/cases/c24-valid-entries-with-unknown-keys/expected.json +1 -1
- package/conformance/cases/c25-published-roundtrip-zero-warnings/expected.json +1 -1
- package/conformance/cases/c26-hosts-array-1024/expected.json +1 -1
- package/conformance/cases/c27-hosts-array-1025/expected.json +1 -1
- package/conformance/cases/c28-large-document-over-1mb/expected.json +1 -1
- package/conformance/cases/c29-salvage-then-domain-refine-fails/expected.json +1 -1
- package/conformance/cases/c30-version-triple-a-first/expected.json +1 -1
- package/conformance/cases/c31-version-triple-b-changed/expected.json +1 -1
- package/conformance/cases/c32-version-triple-a-restored/expected.json +1 -1
- package/conformance/cases/c33-limits-nested-carried-key/expected.json +1 -1
- package/conformance/cases/c34-skills-content-vs-manifest/expected.json +1 -1
- package/conformance/cases/c36-skills-entry-without-content/expected.json +1 -1
- package/conformance/cases/c38-remote-exec-is-a-non-domain-file/expected.json +1 -1
- package/conformance/cases/c39-hidden-file-in-config-d/expected.json +1 -1
- package/conformance/cases/c40-s712-identity-only-what-reads-out/expected.json +1 -1
- package/conformance/cases/c41-s792-encoded-pem-identity/expected.json +1 -1
- package/conformance/cases/c42-s792-unknown-key-secret-redacted/expected.json +1 -1
- package/conformance/cases/c43-s792-form-and-deep-encoded-pem/expected.json +1 -1
- package/conformance/cases/c44-s792-utf8-escape-glued-token/expected.json +1 -1
- package/conformance/cases/c45-s792-identity-bounds-and-decode-depth/expected.json +1 -1
- package/conformance/cases/c46-s811-host-name-url-userinfo-withheld/expected.json +1 -1
- package/conformance/cases/c47-s811-roles-key-url-userinfo-withheld/expected.json +1 -1
- package/conformance/cases/c48-s935-model-headers-transported/expected.json +1 -1
- package/conformance/cases/c49-s935-model-headers-secret-entry-dropped/expected.json +1 -1
- package/conformance/cases/c50-s784-lane-host-legal/expected.json +1 -1
- package/conformance/cases/c51-s784-lane-e2b-legal/expected.json +1 -1
- package/conformance/cases/c52-s784-lane-k8s-legal/expected.json +1 -1
- package/conformance/cases/c53-s784-lane-ssh-legal/expected.json +1 -1
- package/conformance/cases/c54-s784-lane-adb-legal/expected.json +1 -1
- package/conformance/cases/c55-s784-lane-local-docker-legal/expected.json +1 -1
- package/conformance/cases/c56-s784-lane-device-legal/expected.json +1 -1
- package/conformance/cases/c57-s784-g1-enabled-no-lane/expected.json +3 -3
- package/conformance/cases/c58-s784-g2-multitenant-host/expected.json +3 -3
- package/conformance/cases/c59-s784-g3-k8s-missing-image/expected.json +3 -3
- package/conformance/cases/c60-s784-g3-e2b-missing-key/expected.json +3 -3
- package/conformance/cases/c61-s784-g3-other-lane-key/expected.json +3 -3
- package/conformance/cases/c62-s784-g7a-session-tidb/expected.json +3 -3
- package/conformance/cases/c63-s784-host-two-replicas/expected.json +3 -3
- package/conformance/cases/c64-s784-multitenant-local-store/expected.json +3 -3
- package/conformance/cases/c65-s784-pg-without-db/expected.json +3 -3
- package/conformance/cases/c66-s784-memory-backend-mismatch/expected.json +3 -3
- package/conformance/cases/c67-s784-retired-field-loud/expected.json +3 -3
- package/conformance/cases/c68-s784-device-local-store/expected.json +3 -3
- package/conformance/cases/c69-deep-encoded-token-past-every-reading/expected.json +1 -1
- package/conformance/cases/c70-rewritten-token-in-front-of-encoded-pem-header/expected.json +1 -1
- package/conformance/cases/c71-one-scanner-write-reads-display-forms/expected.json +1 -1
- package/conformance/cases/c72-dangling-reference-write-seat-refuses/expected.json +1 -1
- package/conformance/cases/c73-projects-extended-registration-reads/expected.json +1 -1
- package/conformance/cases/c74-projects-over-bound-refused/expected.json +3 -72
- package/conformance/cases/c75-projects-patch-remote-uniqueness/expected.json +3 -72
- package/conformance/cases/c76-projects-entry-salvage-nested/expected.json +2 -2
- package/conformance/cases/c77-prompts-center-artifact-carried/expected.json +1 -1
- package/conformance/cases/c78-prompts-empty-bindings-refused/expected.json +2 -2
- package/conformance/cases/c78-prompts-empty-bindings-refused/meta.json +1 -1
- package/conformance/cases/c79-prompts-bad-worker-artifact-not-salvaged/expected.json +1 -1
- package/conformance/cases/c80-prompts-wire-v2-verbatim/expected.json +1 -1
- package/conformance/cases/c81-prompts-declaration-bindings-refused/expected.json +2 -2
- package/conformance/cases/c82-prompts-v1-catalog-refused/expected.json +2 -2
- package/conformance/cases/c83-prompts-bad-overlay-not-salvaged/expected.json +1 -1
- package/conformance/cases/c84-sandbox-git-block-carried-verbatim/expected.json +1 -1
- package/conformance/cases/c85-sandbox-git-refused-block-still-carried/expected.json +1 -1
- package/conformance/cases/c86-a2a-peers-legal/expected.json +1 -1
- package/conformance/cases/c87-a2a-credential-refs-not-partially-salvaged/expected.json +1 -1
- package/conformance/cases/c88-projects-content-attestation-carried/expected.json +1 -1
- package/conformance/cases/c89-projects-content-attestation-malformed/expected.json +1 -1
- package/conformance/cases/c90-mcp-assertion-credential-carried/expected.json +143 -0
- package/conformance/cases/c90-mcp-assertion-credential-carried/input.json +30 -0
- package/conformance/cases/c90-mcp-assertion-credential-carried/meta.json +6 -0
- package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/expected.json +105 -0
- package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/input.json +27 -0
- package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/meta.json +6 -0
- package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/expected.json +105 -0
- package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/input.json +31 -0
- package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/meta.json +6 -0
- package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/expected.json +105 -0
- package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/input.json +33 -0
- package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/meta.json +6 -0
- package/conformance/cases/c94-mcp-credentials-env-kind-dropped/expected.json +105 -0
- package/conformance/cases/c94-mcp-credentials-env-kind-dropped/input.json +32 -0
- package/conformance/cases/c94-mcp-credentials-env-kind-dropped/meta.json +6 -0
- package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/expected.json +105 -0
- package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/input.json +30 -0
- package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/meta.json +6 -0
- package/conformance/cases/c96-mcp-credentials-extra-member-dropped/expected.json +105 -0
- package/conformance/cases/c96-mcp-credentials-extra-member-dropped/input.json +31 -0
- package/conformance/cases/c96-mcp-credentials-extra-member-dropped/meta.json +6 -0
- package/conformance/cases/cc01-mcp-toolfaces-non-object/expected.json +1 -1
- package/conformance/cases/cc02-mcp-source-key-is-transported/expected.json +1 -1
- package/conformance/cases/cc03-model-compat-unknown-subkey/expected.json +1 -1
- package/conformance/cases/cli01-model-name-nfc-vs-nfd/expected.json +1 -1
- package/conformance/cases/cli02-control-and-zero-width-chars/expected.json +1 -1
- package/conformance/cases/cli03-credential-pasted-into-unknown-key/expected.json +1 -1
- package/conformance/cases/cli04-env-value-with-newline/expected.json +1 -1
- package/conformance/cases/cli04-env-value-with-newline/meta.json +1 -1
- package/conformance/cases/cli05-long-and-prefix-colliding-names/expected.json +1 -1
- package/conformance/cases/t01-absent-domain-key-not-null/expected.json +1 -1
- package/conformance/cases/t01-absent-domain-key-not-null/meta.json +1 -1
- package/conformance/cases/t03-prototype-name-key-not-swallowed/expected.json +1 -1
- package/conformance/cases/t04-secret-literal-never-in-warning-value/expected.json +1 -1
- package/conformance/cases/t04-secret-literal-never-in-warning-value/meta.json +1 -1
- package/conformance/cases/z01-every-domain-empty-object/expected.json +1 -1
- package/conformance/cases/z01-every-domain-empty-object/meta.json +1 -1
- package/conformance/cases/z02-every-domain-unknown-key/expected.json +1 -1
- package/dist/api/credentials.js +5 -7
- package/dist/api/lifecycle-events.d.ts +266 -0
- package/dist/api/lifecycle-events.js +169 -0
- package/dist/api/wire-scalars.d.ts +13 -0
- package/dist/api/wire-scalars.js +15 -0
- package/dist/atomic-write.d.ts +4 -0
- package/dist/atomic-write.js +26 -3
- package/dist/config-d-file.d.ts +1 -1
- package/dist/config-document-refusal.d.ts +4 -4
- package/dist/config-fns.d.ts +4 -2
- package/dist/config-fns.js +1 -1
- package/dist/config-root-documents.d.ts +1 -1
- package/dist/config-root-node.js +2 -1
- package/dist/conformance/corpus.d.ts +1 -1
- package/dist/conformance/derive.d.ts +13 -5
- package/dist/conformance/derive.js +37 -21
- package/dist/conformance/index.d.ts +1 -1
- package/dist/conformance/index.js +1 -1
- package/dist/conformance/run.js +8 -9
- package/dist/connector-authorize-url.d.ts +23 -0
- package/dist/connector-authorize-url.js +129 -0
- package/dist/connector-id.d.ts +23 -0
- package/dist/connector-id.js +27 -0
- package/dist/file-edit.d.ts +44 -0
- package/dist/file-edit.js +70 -1
- package/dist/file-store.d.ts +12 -7
- package/dist/file-store.js +72 -59
- package/dist/hooks.d.ts +15 -5
- package/dist/hooks.js +13 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -1
- package/dist/mcp-entry-credential.d.ts +47 -0
- package/dist/mcp-entry-credential.js +73 -0
- package/dist/mcp-request-entry.d.ts +32 -13
- package/dist/mcp-request-entry.js +104 -58
- package/dist/migration-receipt.d.ts +2 -2
- package/dist/migration-receipt.js +2 -2
- package/dist/one-time-migrations.d.ts +1 -1
- package/dist/one-time-migrations.js +68 -91
- package/dist/portable-domains.d.ts +18 -12
- package/dist/portable-domains.js +17 -12
- package/dist/retired-role-words.d.ts +1 -1
- package/dist/retired-role-words.js +4 -6
- package/dist/scheduler-store-node.d.ts +5 -2
- package/dist/scheduler-store-node.js +8 -5
- package/dist/sha256.d.ts +5 -0
- package/dist/sha256.js +7 -0
- package/dist/skills-manifest.js +2 -2
- package/dist/types.d.ts +80 -10
- package/dist/types.js +37 -44
- package/docs/API-SURFACE.md +47 -7
- package/docs/CONFORMANCE.md +6 -4
- package/docs/CONSUMER-INTEGRATION.md +147 -4
- package/llms-full.txt +45 -24
- package/llms.txt +27 -14
- package/package.json +3 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置面 MCP http 条目的凭据引用 `transport.credentials`(29.0.0)—— 纯函数、零 I/O、浏览器安全。
|
|
3
|
+
*
|
|
4
|
+
* ## 律(一条)
|
|
5
|
+
* **一条托管连接器条目「它是什么形」只有一个事实:`transport.credentials`。** 引用的合法性只有一只判官 —— 引擎原语包的 `readCredentialRef`
|
|
6
|
+
* (本包不自带第二份读法:读一次,沿用它交回的冻结副本);本包在它之上只加两格自己的事实:准入的种类(闭集 {@link MCP_ENTRY_CREDENTIAL_KINDS},
|
|
7
|
+
* 今天只有 `assertion`)与 `audience` 的取值域(连接器 id,`./connector-id`)。断言的头名归引擎(`MCP_ASSERTION_HEADER`),条目不说它。
|
|
8
|
+
*
|
|
9
|
+
* ## `audience` 的义
|
|
10
|
+
* 条目引用里的 `audience` 就是连接器 id,原样作断言的受众:铸断言的一方把它原样写进断言,托管连接器以同一个 id 启动(它做严格的串比较),
|
|
11
|
+
* 两边对的是同一个只有一种拼法的值。发往哪里归 `url`(必填,不变)。
|
|
12
|
+
*
|
|
13
|
+
* ## 拒句
|
|
14
|
+
* 按问题说形,不回显值:引用里的串(audience、成员名、种类词)都是调用方写的;句子只点名本包与原语包自己的词(种类闭集里的词、成员名表里的名)。
|
|
15
|
+
*/
|
|
16
|
+
import { readCredentialRef } from "@sema-agent/primitives";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
import { CONNECTOR_ID_RULE, isConnectorId } from "./connector-id.js";
|
|
19
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
20
|
+
import { buildQuotedIssue, fixed } from "./quoted-issue.js";
|
|
21
|
+
/** 配置面 MCP http 条目准入的凭据引用种类(闭集;原语包种类表的子集)。 */
|
|
22
|
+
export const MCP_ENTRY_CREDENTIAL_KINDS = deepFreeze(["assertion"]);
|
|
23
|
+
/** 原语包读法的一处问题 → 句子(只点名原语包自己的成员名与种类词;调用方写的种类 / 多余成员名不回显)。穷举:原语包加一个问题词而这里不补 ⇒ 编译红。 */
|
|
24
|
+
function problemSentence(p) {
|
|
25
|
+
switch (p.reason) {
|
|
26
|
+
case "not_a_record":
|
|
27
|
+
return 'must be a credential reference: a plain object with a "kind" member';
|
|
28
|
+
case "unknown_kind":
|
|
29
|
+
return 'names a "kind" that is not a credential reference kind';
|
|
30
|
+
case "missing_field":
|
|
31
|
+
return `is missing its "${p.field}" member${p.kind === undefined ? "" : ` (a "${p.kind}" reference)`}`;
|
|
32
|
+
case "extra_field":
|
|
33
|
+
return `carries a member a "${p.kind}" reference does not have`;
|
|
34
|
+
case "bad_value":
|
|
35
|
+
return `has a "${p.field}" member of the wrong form (a non-empty data string, no control characters, no leading or trailing whitespace)`;
|
|
36
|
+
default: {
|
|
37
|
+
const unhandled = p;
|
|
38
|
+
throw new Error(`problemSentence: unhandled credential reference problem ${String(unhandled.reason)}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const isAdmittedKind = (kind) => MCP_ENTRY_CREDENTIAL_KINDS.includes(kind);
|
|
43
|
+
/**
|
|
44
|
+
* 读一只条目凭据引用:原语包读一次,种类过准入闭集,断言臂的 `audience` 过连接器 id 判官;交回的是原语包的冻结副本。从不抛。
|
|
45
|
+
* 拒句经 `buildQuotedIssue` 铸(包内 custom issue 的唯一铸点):句子里的每个词都是本包与原语包自己的(种类词、成员名、规则句),整句进模板、没有值位;调用方写的值一个不进句子。
|
|
46
|
+
*/
|
|
47
|
+
function readMcpEntryCredential(value) {
|
|
48
|
+
const read = readCredentialRef(value);
|
|
49
|
+
if (!read.ok)
|
|
50
|
+
return { ok: false, issue: buildQuotedIssue `transport.credentials ${fixed(problemSentence(read.problem))}` };
|
|
51
|
+
const ref = read.ref;
|
|
52
|
+
if (!isAdmittedKind(ref.kind)) {
|
|
53
|
+
const admitted = MCP_ENTRY_CREDENTIAL_KINDS.map((k) => `"${k}"`).join(", ");
|
|
54
|
+
return { ok: false, issue: buildQuotedIssue `transport.credentials of kind "${fixed(ref.kind)}" is not admitted on an MCP http entry — the admitted kind is ${fixed(admitted)}` };
|
|
55
|
+
}
|
|
56
|
+
const credential = ref;
|
|
57
|
+
if (!isConnectorId(credential.audience))
|
|
58
|
+
return { ok: false, issue: buildQuotedIssue `transport.credentials.audience ${fixed(CONNECTOR_ID_RULE)}` };
|
|
59
|
+
return { ok: true, credential };
|
|
60
|
+
}
|
|
61
|
+
/** `transport.credentials` 的输入位:不跑任何检查的类型化 any(输入与产物同型 {@link McpEntryCredential});判法全在它后面的 transform(原语包读一次)。 */
|
|
62
|
+
const CREDENTIAL_INPUT = z.any();
|
|
63
|
+
/**
|
|
64
|
+
* `transport.credentials` 的 zod 形:输入与产物都是 {@link McpEntryCredential};判法就是 {@link readMcpEntryCredential}(原语包读一次 + 准入种类 + 连接器 id),
|
|
65
|
+
* 产物是原语包交回的冻结副本(不是调用方的对象)。
|
|
66
|
+
*/
|
|
67
|
+
export const McpEntryCredential = CREDENTIAL_INPUT.transform((value, ctx) => {
|
|
68
|
+
const read = readMcpEntryCredential(value);
|
|
69
|
+
if (read.ok)
|
|
70
|
+
return read.credential;
|
|
71
|
+
ctx.addIssue({ code: "custom", ...read.issue });
|
|
72
|
+
return z.NEVER;
|
|
73
|
+
});
|
|
@@ -44,20 +44,23 @@ export declare function isContentOriginWord(v: unknown): v is McpContentOrigin;
|
|
|
44
44
|
/** 坏内容出处值的**可打印**摘要:串 ⇒ 引号形的回显({@link quotedCallerText}:剥控制与双向字符、截 64 字);非串只说种类。 */
|
|
45
45
|
export declare function describeBadContentOrigin(v: unknown): string;
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
* `assertionHeader`
|
|
47
|
+
* 请求面读器**点名拒**的键的**原因词**(闭集,29.0.0)—— 与「表外未知键」分得开的那一类:读器认得这把键,知道它为什么不在请求面上。
|
|
48
|
+
* · `key_retired`:`transport.assertionHeader`(http)—— 29.0.0 退役:托管连接器的断言是部署的声明(配置面的 `transport.credentials`),头名归引擎,请求不说它;
|
|
49
|
+
* · `credentials_not_carried`:`transport.credentials`(两种传输)—— 请求面不承载凭据引用:引擎原语包的准入表(`CREDENTIAL_REF_TRUST`)对请求面拒 `env` / `handle` / `assertion`,
|
|
50
|
+
* 其余种类本版请求面也没有座位;引用是部署一侧的声明。
|
|
51
|
+
* 读到这两把键之一(自有键、值不是 `undefined`)⇒ 硬坏形({@link RequestMcpTransportRead} 的 `ok:false`),`issue.refusal` = 这里的词、`issue.path` 点名那把键、`issue.reason` 是原因句(不回显值)。
|
|
52
|
+
* 只靠继承可见 ⇒ 不读、不拒,进 `lost` 点名 —— 与身份头同一条律({@link axisKeyOf})。
|
|
53
|
+
* 判序 = 读序:`kind` 之后先读这两把键(其余键一个都还没读)—— 一条带着点名拒的键的条目,不论别处坏不坏、读不读得出,都读成这一类;两把都在 ⇒ `assertionHeader` 先。
|
|
54
|
+
* 消费方按词分派、不读句子;多一个词而穷尽 `switch` 不补 ⇒ 编译红。
|
|
49
55
|
*/
|
|
50
|
-
export declare
|
|
51
|
-
|
|
52
|
-
assertionHeader?: string;
|
|
53
|
-
};
|
|
56
|
+
export declare const MCP_REQUEST_KEY_REFUSALS: readonly ["key_retired", "credentials_not_carried"];
|
|
57
|
+
export type McpRequestKeyRefusal = (typeof MCP_REQUEST_KEY_REFUSALS)[number];
|
|
54
58
|
/**
|
|
55
59
|
* 请求面一条 MCP 条目的传输形。与引擎传输形的关系逐键一句(处置表,对拍 = 上游漂移门 ⑧):
|
|
56
60
|
* · `kind` / `command` / `args` / `url` / `principalHeader` —— 与引擎同键同型;
|
|
57
61
|
* · `env` / `headers` —— 请求带来的**字面件**:引擎的声明不带值(一台服务器的凭据头 / 子进程环境由部署的对端座每次发送时答),
|
|
58
62
|
* 所以这两把键交给引擎之前由消费方从声明里拿走、按它自己的对端座答;
|
|
59
|
-
* · `
|
|
60
|
-
* · 引擎的 `credentials`(不透明的凭据引用)—— 请求面不收:读器不读它。
|
|
63
|
+
* · 引擎的 `credentials`(不透明的凭据引用)—— 请求面不承载:在场 ⇒ 读器点名拒(`credentials_not_carried`,{@link MCP_REQUEST_KEY_REFUSALS})。
|
|
61
64
|
*/
|
|
62
65
|
export type RequestMcpTransport = {
|
|
63
66
|
kind: "stdio";
|
|
@@ -69,7 +72,6 @@ export type RequestMcpTransport = {
|
|
|
69
72
|
url: string;
|
|
70
73
|
headers?: Record<string, string>;
|
|
71
74
|
principalHeader?: string;
|
|
72
|
-
assertionHeader?: string;
|
|
73
75
|
};
|
|
74
76
|
/**
|
|
75
77
|
* 条目内一处坏形:`path` = 条目内的键路径(`transport.url`),`reason` = 判官的原因句(只说形与词表,不回显值)。
|
|
@@ -80,14 +82,17 @@ export type RequestMcpTransport = {
|
|
|
80
82
|
* · `member_name_reserved`:有成员叫保留名({@link RESERVED_MEMBER_NAMES}:`__proto__` / `constructor` / `prototype`)。值是串 ⇒ 只剔它、其余照交,每个一条、`path` 是成员级(`transport.env.__proto__`);
|
|
81
83
|
* 成员的值也不是串(或读不出)⇒ 整张记录不交,`path` 是键级,句子一次说全两件事 —— 名坏优先、值坏并列,所以词仍是 `member_name_reserved`。
|
|
82
84
|
* `member` 是成员名的**回显形**(剥控制与双向字符、截 64 字加 `…`),可直接进日志与句子,不是回查原对象的键。其余的坏形(`args` / `url` / `principalHeader` / ……)两格都不带。
|
|
85
|
+
*
|
|
86
|
+
* `refusal` 只在**点名拒**的硬坏形上(闭集词 {@link MCP_REQUEST_KEY_REFUSALS}):读器认得这把键、知道它为什么不在请求面上 —— 消费方据它把「已退役 / 不承载的键」与「表外未知键」分开处置。
|
|
83
87
|
*/
|
|
84
88
|
export interface McpEntryKeyIssue {
|
|
85
89
|
readonly path: string;
|
|
86
90
|
readonly reason: string;
|
|
87
91
|
readonly member?: string;
|
|
88
92
|
readonly fault?: PlainStringRecordFault;
|
|
93
|
+
readonly refusal?: McpRequestKeyRefusal;
|
|
89
94
|
}
|
|
90
|
-
/** {@link readRequestMcpTransport} 的结果:`ok:false` = 硬坏形(这条 server
|
|
95
|
+
/** {@link readRequestMcpTransport} 的结果:`ok:false` = 硬坏形(这条 server 无从挂载;`issue.refusal` 在场 = 读器点名拒的键,见 {@link MCP_REQUEST_KEY_REFUSALS});`ok:true` 的 `lost` = 读器**丢掉**的可选子键(server 照挂、少一个声明)。 */
|
|
91
96
|
export type RequestMcpTransportRead = {
|
|
92
97
|
ok: true;
|
|
93
98
|
transport: RequestMcpTransport;
|
|
@@ -98,12 +103,12 @@ export type RequestMcpTransportRead = {
|
|
|
98
103
|
};
|
|
99
104
|
/**
|
|
100
105
|
* 请求面 `transport` 的**唯一读器**:读器投影 transport 用它,发送前 / 受理时的判形读它报的 `lost` —— 同一只函数两个消费点,「读器丢了什么」与「门拒什么」不可能分岔。
|
|
101
|
-
* · 硬坏形(`transport` 不是对象 / `kind` 出闭集 / stdio 缺 `command` / http 的 `url` 不是 http(s))⇒ `ok:false`,`path` 是读器点名的键路径;
|
|
106
|
+
* · 硬坏形(`transport` 不是对象 / `kind` 出闭集 / 点名拒的键在场({@link MCP_REQUEST_KEY_REFUSALS},先于其余键判)/ stdio 缺 `command` / http 的 `url` 不是 http(s))⇒ `ok:false`,`path` 是读器点名的键路径;
|
|
102
107
|
* · 软坏形(`args` 不是串数组 / `env` `headers` 不是纯数据的串记录 / `principalHeader` 非串)⇒ 读器**丢这个键**(重放存量提交体时的升级前读法),并把它记进 `lost`
|
|
103
|
-
* (受理新提交的门据它响亮拒)
|
|
108
|
+
* (受理新提交的门据它响亮拒);身份 / 凭据轴上的键({@link AXIS_KEYS}:`principalHeader` / `assertionHeader` / `credentials`)只靠继承可见 ⇒ 不读值、不拒、进 `lost` 点名;
|
|
104
109
|
* · `env` / `headers` 只收**纯数据**的记录({@link readPlainStringRecord}):必须是朴素 JSON 对象(`./plain-json-object` 的判据;`Map`、`Set`、类实例整张不收),每个自有成员的值都是串;
|
|
105
110
|
* 交出的是**副本**(不是调用方的对象,改原对象不影响读后的形)。名叫保留名({@link RESERVED_MEMBER_NAMES})的成员不进副本、每个单独记进 `lost`。
|
|
106
|
-
* 坏形的 `lost` 条目带机读位(见 {@link McpEntryKeyIssue})
|
|
111
|
+
* 坏形的 `lost` 条目带机读位(见 {@link McpEntryKeyIssue})。这两键的读法与诊断就是公开读口 {@link readRequestStringRecord} 以 `transport.env` / `transport.headers` 为坐标的读数。
|
|
107
112
|
* url 的拒句不回显值:它常规地带凭据(userinfo)。
|
|
108
113
|
*/
|
|
109
114
|
export declare function readRequestMcpTransport(t: unknown): RequestMcpTransportRead;
|
|
@@ -137,3 +142,17 @@ export type PlainStringRecordRead = {
|
|
|
137
142
|
* 名叫保留名而值也坏的成员,句子一次说全两件事(名坏在前、值坏并列):调用方照值改完再撞第二条是两步才改对。
|
|
138
143
|
*/
|
|
139
144
|
export declare function readPlainStringRecord(v: unknown): PlainStringRecordRead;
|
|
145
|
+
/** {@link readRequestStringRecord} 的读数:`record` = 交出去的纯数据副本(缺席或不交 ⇒ `undefined`);`issues` = 这份记录在坐标上的诊断(零条或多条,形见 {@link McpEntryKeyIssue})。 */
|
|
146
|
+
export interface RequestStringRecordRead {
|
|
147
|
+
readonly record: Record<string, string> | undefined;
|
|
148
|
+
readonly issues: readonly McpEntryKeyIssue[];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 请求面一份「名 → 串」记录的**带坐标读法** —— 公开读口:传输读器读 `transport.env` / `transport.headers` 就是它的两次调用;消费方读自己的「名 → 串」记录
|
|
152
|
+
* (A2A 对端的 `headers` 一类)调同一只,诊断与 MCP 传输同形同句,不另拼原因句。`path` = 这份记录在调用方载荷里的坐标(原样进诊断,不解析)。从不抛。
|
|
153
|
+
* · 缺席(`undefined`)⇒ 不交、零条;
|
|
154
|
+
* · 记录不交({@link readPlainStringRecord} 答 `ok:false`)⇒ 恰一条,`path` 是坐标本身,`reason` = `must be a plain object of string values — ` + 读数的 `detail`,
|
|
155
|
+
* `fault` 与(坏在某个成员时)`member` 取自读数;
|
|
156
|
+
* · 交 ⇒ 纯数据副本;名叫保留名({@link RESERVED_MEMBER_NAMES})的成员不进副本,每个一条:`path` = `<坐标>.<名>`、`member` = 名、`fault` = `member_name_reserved`。
|
|
157
|
+
*/
|
|
158
|
+
export declare function readRequestStringRecord(path: string, raw: unknown): RequestStringRecordRead;
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* · 申报名的线长界 {@link TOOL_WIRE_NAME_MAX_CHARS} = 引擎同名常量(值级对拍:上游漂移门 ⑧);
|
|
17
17
|
* · 请求面传输形 {@link RequestMcpTransport} 对引擎 MCP 条目的传输形是一张处置表,两边每个键恰好一行(编译期两向对拍:门 ⑧)——
|
|
18
18
|
* `kind` / `command` / `args` / `url` / `principalHeader` 与引擎同键同型;`env` / `headers` 是请求带来的字面件(引擎的声明不带值);
|
|
19
|
-
* `
|
|
19
|
+
* 引擎的 `credentials`(不透明的凭据引用)请求面不承载 —— 在场 ⇒ 读器点名拒({@link MCP_REQUEST_KEY_REFUSALS} 的 `credentials_not_carried`);
|
|
20
|
+
* · 请求面点名拒的键(本包一份判法,消费方只做处置):`assertionHeader`(29.0.0 退役)与 `credentials`,见 {@link MCP_REQUEST_KEY_REFUSALS};
|
|
20
21
|
* · 内容出处词表 = {@link MCP_CONTENT_ORIGINS}(已有的镜像,门 ⑥);
|
|
21
22
|
* · url 前缀守卫 = `./url-shape` 的 `startsWithHttpScheme`(本包判 URL 的正则只在那一个模块)。它只看前缀,不是形判官 —— 同一个串两口可以答得不同,两张分歧表与收口形(S-2106)写在 `./url-shape` 头注「第二个答案」。
|
|
22
23
|
*
|
|
@@ -34,6 +35,8 @@ import { startsWithHttpScheme } from "./url-shape.js";
|
|
|
34
35
|
import { TOOL_WIRE_NAME_MAX_CHARS, hasEdgeWhitespace, isUsableWireName } from "./wire-name.js";
|
|
35
36
|
import { isReservedMemberName } from "./reserved-member-name.js";
|
|
36
37
|
import { deepFreeze } from "./deep-freeze.js";
|
|
38
|
+
import { CREDENTIAL_REF_TRUST, readCredentialRef } from "@sema-agent/primitives";
|
|
39
|
+
import { retiredFormSentence } from "./retired-form.js";
|
|
37
40
|
// ── 值的种类描述(拒句只说「你写的是什么形」,不回显值:值可能带凭据、可能任意长)──────────────────────────────────────
|
|
38
41
|
/** 值的**种类词**(不回显值本身):`null` / `array` / `typeof` 词(`object` / `function` / `string` …);读不出的对象 ⇒ 全包唯一的那一句。形状只问座位(总,不抛):两只坏值描述器共用这一只。 */
|
|
39
42
|
function describeKindWord(v) {
|
|
@@ -160,61 +163,73 @@ export function isContentOriginWord(v) {
|
|
|
160
163
|
export function describeBadContentOrigin(v) {
|
|
161
164
|
return typeof v === "string" ? quotedCallerText(v) : describeKindWord(v);
|
|
162
165
|
}
|
|
163
|
-
// ──
|
|
166
|
+
// ── 身份 / 凭据轴上的键 ─────────────────────────────────────────────────────────────────────────────
|
|
164
167
|
/**
|
|
165
|
-
*
|
|
166
|
-
* `
|
|
168
|
+
* 传输上**身份 / 凭据轴**的键(闭集;也是 `lost` 里点名它们的次序):身份头 `principalHeader`,与点名拒的两把键 `assertionHeader` / `credentials`({@link MCP_REQUEST_KEY_REFUSALS})。
|
|
169
|
+
* 一条律、一只读法({@link axisKeyOf}):只认自有键;只靠继承可见 ⇒ 不读、进 `lost` 点名({@link inheritedAxisKeyIssue})。
|
|
167
170
|
*/
|
|
168
|
-
|
|
169
|
-
const ids = identityFieldsOf(transport);
|
|
170
|
-
if (!ids.ok)
|
|
171
|
-
return {}; // 读不出 ⇒ 身份头整体读不出(传输读器对同样的输入是整只不交)
|
|
172
|
-
const { principalHeader, assertionHeader } = ids.value;
|
|
173
|
-
return {
|
|
174
|
-
...(typeof principalHeader === "string" ? { principalHeader } : {}),
|
|
175
|
-
...(typeof assertionHeader === "string" ? { assertionHeader } : {}),
|
|
176
|
-
};
|
|
177
|
-
}
|
|
171
|
+
const AXIS_KEYS = ["principalHeader", "assertionHeader", "credentials"];
|
|
178
172
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* **只读自有键**(身份只认自有键):键只靠继承可见(含 `Object.prototype` 被污染成数据值)⇒ 不读它的值、当缺席,但**记下**(`principalInherited` / `assertionInherited`)—— 传输读器据此点名,
|
|
182
|
-
* 身份轴上不静默;公开读者没有 `lost` 通道,只读值。
|
|
173
|
+
* 轴上键({@link AXIS_KEYS})的**唯一读法**:**只读自有键**(身份与凭据只认自有键);键只靠继承可见(含 `Object.prototype` 被污染成数据值)⇒ 不读它的值、当缺席,
|
|
174
|
+
* 但**记下**(`inherited`)—— 传输读器据此点名,这条轴上不静默。读不出 ⇒ 整体读不出(`ok:false`,向上传),不折成 `undefined`。
|
|
183
175
|
*/
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
176
|
+
function axisKeyOf(record, key) {
|
|
177
|
+
const read = readKey(record, key);
|
|
178
|
+
if (read.presence === "unreadable")
|
|
187
179
|
return { ok: false, sentence: UNINSPECTABLE };
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
return { ok: true, value: { value: read.presence === "own" ? read.value : undefined, inherited: read.presence === "inherited" } };
|
|
181
|
+
}
|
|
182
|
+
// ── 请求面点名拒的键 ────────────────────────────────────────────────────────────────────────────────────
|
|
183
|
+
/**
|
|
184
|
+
* 请求面读器**点名拒**的键的**原因词**(闭集,29.0.0)—— 与「表外未知键」分得开的那一类:读器认得这把键,知道它为什么不在请求面上。
|
|
185
|
+
* · `key_retired`:`transport.assertionHeader`(http)—— 29.0.0 退役:托管连接器的断言是部署的声明(配置面的 `transport.credentials`),头名归引擎,请求不说它;
|
|
186
|
+
* · `credentials_not_carried`:`transport.credentials`(两种传输)—— 请求面不承载凭据引用:引擎原语包的准入表(`CREDENTIAL_REF_TRUST`)对请求面拒 `env` / `handle` / `assertion`,
|
|
187
|
+
* 其余种类本版请求面也没有座位;引用是部署一侧的声明。
|
|
188
|
+
* 读到这两把键之一(自有键、值不是 `undefined`)⇒ 硬坏形({@link RequestMcpTransportRead} 的 `ok:false`),`issue.refusal` = 这里的词、`issue.path` 点名那把键、`issue.reason` 是原因句(不回显值)。
|
|
189
|
+
* 只靠继承可见 ⇒ 不读、不拒,进 `lost` 点名 —— 与身份头同一条律({@link axisKeyOf})。
|
|
190
|
+
* 判序 = 读序:`kind` 之后先读这两把键(其余键一个都还没读)—— 一条带着点名拒的键的条目,不论别处坏不坏、读不读得出,都读成这一类;两把都在 ⇒ `assertionHeader` 先。
|
|
191
|
+
* 消费方按词分派、不读句子;多一个词而穷尽 `switch` 不补 ⇒ 编译红。
|
|
192
|
+
*/
|
|
193
|
+
export const MCP_REQUEST_KEY_REFUSALS = deepFreeze(["key_retired", "credentials_not_carried"]);
|
|
194
|
+
/** `assertionHeader` 在请求面的退役句(退役形的唯一模板 `retiredFormSentence`)。 */
|
|
195
|
+
const ASSERTION_HEADER_RETIRED_ON_REQUEST = retiredFormSentence("transport.assertionHeader", {
|
|
196
|
+
retiredIn: "29.0.0",
|
|
197
|
+
now: "no request names it: a hosted connector's assertion is declared by the deployment (transport.credentials in its settings) and its header is the engine's — remove the key from the request",
|
|
198
|
+
});
|
|
199
|
+
/** 请求里出现的 `credentials` 为什么不收:原语包读得出且准入表对请求面拒这个种类 ⇒ 点名种类(闭集词);否则 ⇒ 请求面没有凭据引用的座位。两句都不回显值。 */
|
|
200
|
+
function credentialsNotCarriedReason(raw) {
|
|
201
|
+
const read = readCredentialRef(raw);
|
|
202
|
+
if (read.ok && CREDENTIAL_REF_TRUST[read.ref.kind].request === "refused") {
|
|
203
|
+
return `a credential reference of kind "${read.ref.kind}" is never taken from a request (the deployment declares it for this server) — remove transport.credentials from the request`;
|
|
190
204
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
};
|
|
205
|
+
return "a request carries no credential reference (the request surface has no seat for one; the deployment declares it) — remove transport.credentials from the request";
|
|
206
|
+
}
|
|
207
|
+
/** 点名拒的硬坏形(机读词在 `refusal`)。 */
|
|
208
|
+
const keyRefused = (path, reason, refusal) => ({ ok: false, issue: { path, reason, refusal } });
|
|
209
|
+
/** 点名拒的第一把键(判序见 {@link MCP_REQUEST_KEY_REFUSALS});没有 ⇒ `undefined`。入参是已读出的自有值(stdio 没有 `assertionHeader` 这一格:调用方传 `undefined`)。 */
|
|
210
|
+
function refusedKeyOf(assertionHeader, credentials) {
|
|
211
|
+
if (assertionHeader !== undefined)
|
|
212
|
+
return keyRefused("transport.assertionHeader", ASSERTION_HEADER_RETIRED_ON_REQUEST, "key_retired");
|
|
213
|
+
if (credentials !== undefined)
|
|
214
|
+
return keyRefused("transport.credentials", credentialsNotCarriedReason(credentials), "credentials_not_carried");
|
|
215
|
+
return undefined;
|
|
203
216
|
}
|
|
204
217
|
const transportBad = (path, reason) => ({ ok: false, issue: { path, reason } });
|
|
205
|
-
/**
|
|
206
|
-
const
|
|
218
|
+
/** 轴上键({@link AXIS_KEYS})只靠继承可见时的 `lost` 条目:不读它的值,但点名(这条轴不静默;三把键一句,句子不回显值)。机读位不带(`fault` 的闭集不为它加词)。 */
|
|
219
|
+
const inheritedAxisKeyIssue = (key) => ({
|
|
207
220
|
path: `transport.${key}`,
|
|
208
|
-
reason: "inherited key ignored (the key is visible only through the prototype chain; a transport's identity headers are read from its own keys)",
|
|
221
|
+
reason: "inherited key ignored (the key is visible only through the prototype chain; a transport's identity headers and credential reference are read from its own keys)",
|
|
209
222
|
});
|
|
223
|
+
/** 一次快照里只靠继承可见的轴上键 ⇒ `lost` 条目,按 {@link AXIS_KEYS} 的次序。 */
|
|
224
|
+
const inheritedAxisKeyIssues = (inherited) => AXIS_KEYS.filter((key) => inherited.has(key)).map(inheritedAxisKeyIssue);
|
|
210
225
|
/**
|
|
211
226
|
* 请求面 `transport` 的**唯一读器**:读器投影 transport 用它,发送前 / 受理时的判形读它报的 `lost` —— 同一只函数两个消费点,「读器丢了什么」与「门拒什么」不可能分岔。
|
|
212
|
-
* · 硬坏形(`transport` 不是对象 / `kind` 出闭集 / stdio 缺 `command` / http 的 `url` 不是 http(s))⇒ `ok:false`,`path` 是读器点名的键路径;
|
|
227
|
+
* · 硬坏形(`transport` 不是对象 / `kind` 出闭集 / 点名拒的键在场({@link MCP_REQUEST_KEY_REFUSALS},先于其余键判)/ stdio 缺 `command` / http 的 `url` 不是 http(s))⇒ `ok:false`,`path` 是读器点名的键路径;
|
|
213
228
|
* · 软坏形(`args` 不是串数组 / `env` `headers` 不是纯数据的串记录 / `principalHeader` 非串)⇒ 读器**丢这个键**(重放存量提交体时的升级前读法),并把它记进 `lost`
|
|
214
|
-
* (受理新提交的门据它响亮拒)
|
|
229
|
+
* (受理新提交的门据它响亮拒);身份 / 凭据轴上的键({@link AXIS_KEYS}:`principalHeader` / `assertionHeader` / `credentials`)只靠继承可见 ⇒ 不读值、不拒、进 `lost` 点名;
|
|
215
230
|
* · `env` / `headers` 只收**纯数据**的记录({@link readPlainStringRecord}):必须是朴素 JSON 对象(`./plain-json-object` 的判据;`Map`、`Set`、类实例整张不收),每个自有成员的值都是串;
|
|
216
231
|
* 交出的是**副本**(不是调用方的对象,改原对象不影响读后的形)。名叫保留名({@link RESERVED_MEMBER_NAMES})的成员不进副本、每个单独记进 `lost`。
|
|
217
|
-
* 坏形的 `lost` 条目带机读位(见 {@link McpEntryKeyIssue})
|
|
232
|
+
* 坏形的 `lost` 条目带机读位(见 {@link McpEntryKeyIssue})。这两键的读法与诊断就是公开读口 {@link readRequestStringRecord} 以 `transport.env` / `transport.headers` 为坐标的读数。
|
|
218
233
|
* url 的拒句不回显值:它常规地带凭据(userinfo)。
|
|
219
234
|
*/
|
|
220
235
|
export function readRequestMcpTransport(t) {
|
|
@@ -244,13 +259,15 @@ export function readRequestMcpTransport(t) {
|
|
|
244
259
|
const snap = snapshotRead.value;
|
|
245
260
|
// `lost` 不用 `push` 累加(`push` 是 [[Set]],会被 `Object.prototype` 上继承的数字键 setter 吞掉 / 读成污染值):每处诊断是一个值或 `undefined`,由 `issuesOf` 一次铸成数组(定义语义)
|
|
246
261
|
switch (snap.kind) {
|
|
262
|
+
case "refused":
|
|
263
|
+
return snap.read;
|
|
247
264
|
case "stdio": {
|
|
248
265
|
if (typeof snap.command !== "string" || snap.command.length === 0)
|
|
249
266
|
return transportBad("transport.command", `must be a non-empty string (the command to run) — got ${describeValueShape(snap.command)}`);
|
|
250
267
|
const rawArgs = snap.args; // 交出去的是副本(不是调用方数组的原引用),稀疏 / 读不出的数组整键丢、进 `lost`
|
|
251
268
|
const args = rawArgs === undefined ? undefined : captureStringArray(rawArgs, "wide");
|
|
252
269
|
const argsIssue = rawArgs !== undefined && args === undefined ? { path: "transport.args", reason: `must be an array of strings — got ${describeNotStringArray(rawArgs)}` } : undefined;
|
|
253
|
-
const env =
|
|
270
|
+
const env = readRequestStringRecord("transport.env", snap.env);
|
|
254
271
|
return {
|
|
255
272
|
ok: true,
|
|
256
273
|
transport: {
|
|
@@ -259,16 +276,16 @@ export function readRequestMcpTransport(t) {
|
|
|
259
276
|
...(args !== undefined ? { args } : {}),
|
|
260
277
|
...(env.record !== undefined ? { env: env.record } : {}),
|
|
261
278
|
},
|
|
262
|
-
lost: issuesOf(argsIssue, ...env.issues),
|
|
279
|
+
lost: issuesOf(argsIssue, ...env.issues, ...inheritedAxisKeyIssues(snap.inherited)),
|
|
263
280
|
};
|
|
264
281
|
}
|
|
265
282
|
case "http": {
|
|
266
283
|
// http(s) only — never file://, never a bare host (a syntactic guard, not the URL shape judge: it also lets a bare `https://` through, see ./url-shape).
|
|
267
284
|
if (typeof snap.url !== "string" || !startsWithHttpScheme(snap.url))
|
|
268
285
|
return transportBad("transport.url", "must be an absolute http(s) URL (put credentials in transport.headers, never in the URL)");
|
|
269
|
-
const
|
|
270
|
-
const headers =
|
|
271
|
-
const principalIssue = snap.principalHeader !== undefined &&
|
|
286
|
+
const principalHeader = typeof snap.principalHeader === "string" ? snap.principalHeader : undefined;
|
|
287
|
+
const headers = readRequestStringRecord("transport.headers", snap.headers);
|
|
288
|
+
const principalIssue = snap.principalHeader !== undefined && principalHeader === undefined
|
|
272
289
|
? { path: "transport.principalHeader", reason: `must be a string (the HTTP header NAME the end-user principal is injected into) — got ${describeValueShape(snap.principalHeader)}` }
|
|
273
290
|
: undefined;
|
|
274
291
|
return {
|
|
@@ -277,9 +294,9 @@ export function readRequestMcpTransport(t) {
|
|
|
277
294
|
kind: "http",
|
|
278
295
|
url: snap.url,
|
|
279
296
|
...(headers.record !== undefined ? { headers: headers.record } : {}),
|
|
280
|
-
...
|
|
297
|
+
...(principalHeader !== undefined ? { principalHeader } : {}),
|
|
281
298
|
},
|
|
282
|
-
lost: issuesOf(...headers.issues, principalIssue,
|
|
299
|
+
lost: issuesOf(...headers.issues, principalIssue, ...inheritedAxisKeyIssues(snap.inherited)),
|
|
283
300
|
};
|
|
284
301
|
}
|
|
285
302
|
case "other":
|
|
@@ -291,25 +308,50 @@ export function readRequestMcpTransport(t) {
|
|
|
291
308
|
}
|
|
292
309
|
}
|
|
293
310
|
function snapshotTransport(tr) {
|
|
294
|
-
//
|
|
295
|
-
// 任何一个字段读不出 ⇒ 整只读不出(第一个读不出的就停,后面的一个不读)
|
|
311
|
+
// 字段一律只读**自有**属性(一条律):JSON 解析只铸自有键,JSON 面不变;原型链上被污染的值 / 会抛的 getter 不触发,注入的值进不来。
|
|
312
|
+
// 任何一个字段读不出 ⇒ 整只读不出(第一个读不出的就停,后面的一个不读)。身份 / 凭据轴上的键(`AXIS_KEYS`)经 `axisKeyOf`:只靠继承可见 ⇒ 记进 `inherited`、由读器点名;
|
|
313
|
+
// 点名拒的键(`assertionHeader` / `credentials`)在 `kind` 之后先读,自有且在场即停。
|
|
296
314
|
const kind = ownValueOf(tr, "kind");
|
|
297
315
|
if (!kind.ok)
|
|
298
316
|
return kind;
|
|
317
|
+
const inherited = new Set();
|
|
318
|
+
const axis = (key) => {
|
|
319
|
+
const read = axisKeyOf(tr, key);
|
|
320
|
+
if (!read.ok)
|
|
321
|
+
return read;
|
|
322
|
+
if (read.value.inherited)
|
|
323
|
+
inherited.add(key);
|
|
324
|
+
return { ok: true, value: read.value.value };
|
|
325
|
+
};
|
|
299
326
|
if (kind.value === "stdio") {
|
|
327
|
+
const credentials = axis("credentials");
|
|
328
|
+
if (!credentials.ok)
|
|
329
|
+
return credentials;
|
|
330
|
+
const refused = refusedKeyOf(undefined, credentials.value);
|
|
331
|
+
if (refused !== undefined)
|
|
332
|
+
return { ok: true, value: { kind: "refused", read: refused } };
|
|
300
333
|
const fields = ownFieldsOf(tr, ["command", "args", "env"]);
|
|
301
334
|
if (!fields.ok)
|
|
302
335
|
return fields;
|
|
303
|
-
return { ok: true, value: { kind: "stdio", command: fields.value.command, args: fields.value.args, env: fields.value.env } };
|
|
336
|
+
return { ok: true, value: { kind: "stdio", command: fields.value.command, args: fields.value.args, env: fields.value.env, inherited } };
|
|
304
337
|
}
|
|
305
338
|
if (kind.value === "http") {
|
|
339
|
+
const assertionHeader = axis("assertionHeader");
|
|
340
|
+
if (!assertionHeader.ok)
|
|
341
|
+
return assertionHeader;
|
|
342
|
+
const credentials = axis("credentials");
|
|
343
|
+
if (!credentials.ok)
|
|
344
|
+
return credentials;
|
|
345
|
+
const refused = refusedKeyOf(assertionHeader.value, credentials.value);
|
|
346
|
+
if (refused !== undefined)
|
|
347
|
+
return { ok: true, value: { kind: "refused", read: refused } };
|
|
306
348
|
const fields = ownFieldsOf(tr, ["url", "headers"]);
|
|
307
349
|
if (!fields.ok)
|
|
308
350
|
return fields;
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
311
|
-
return
|
|
312
|
-
return { ok: true, value: { kind: "http", url: fields.value.url, headers: fields.value.headers, principalHeader:
|
|
351
|
+
const principalHeader = axis("principalHeader");
|
|
352
|
+
if (!principalHeader.ok)
|
|
353
|
+
return principalHeader;
|
|
354
|
+
return { ok: true, value: { kind: "http", url: fields.value.url, headers: fields.value.headers, principalHeader: principalHeader.value, inherited } };
|
|
313
355
|
}
|
|
314
356
|
return { ok: true, value: { kind: "other", value: kind.value } };
|
|
315
357
|
}
|
|
@@ -389,10 +431,14 @@ export function readPlainStringRecord(v) {
|
|
|
389
431
|
/** 把诊断条目铸成数组:`undefined`(这一处没有诊断)略去。`filter` 的结果走 `CreateDataProperty`,不走 `[[Set]]` —— `lost` 是「门拒什么」的读数,不能被继承的数字键 setter 吞掉。 */
|
|
390
432
|
const issuesOf = (...candidates) => candidates.filter((c) => c !== undefined);
|
|
391
433
|
/**
|
|
392
|
-
* `transport.env` / `transport.headers`
|
|
393
|
-
*
|
|
434
|
+
* 请求面一份「名 → 串」记录的**带坐标读法** —— 公开读口:传输读器读 `transport.env` / `transport.headers` 就是它的两次调用;消费方读自己的「名 → 串」记录
|
|
435
|
+
* (A2A 对端的 `headers` 一类)调同一只,诊断与 MCP 传输同形同句,不另拼原因句。`path` = 这份记录在调用方载荷里的坐标(原样进诊断,不解析)。从不抛。
|
|
436
|
+
* · 缺席(`undefined`)⇒ 不交、零条;
|
|
437
|
+
* · 记录不交({@link readPlainStringRecord} 答 `ok:false`)⇒ 恰一条,`path` 是坐标本身,`reason` = `must be a plain object of string values — ` + 读数的 `detail`,
|
|
438
|
+
* `fault` 与(坏在某个成员时)`member` 取自读数;
|
|
439
|
+
* · 交 ⇒ 纯数据副本;名叫保留名({@link RESERVED_MEMBER_NAMES})的成员不进副本,每个一条:`path` = `<坐标>.<名>`、`member` = 名、`fault` = `member_name_reserved`。
|
|
394
440
|
*/
|
|
395
|
-
function
|
|
441
|
+
export function readRequestStringRecord(path, raw) {
|
|
396
442
|
if (raw === undefined)
|
|
397
443
|
return { record: undefined, issues: [] };
|
|
398
444
|
const read = readPlainStringRecord(raw);
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
import type { ENV_MODELS_DOCUMENT } from "./config-root-documents.js";
|
|
7
7
|
import type { DomainName } from "./types.js";
|
|
8
8
|
/** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
|
|
9
|
-
export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-
|
|
9
|
+
export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M11", "SS-M12", "SS-M13"];
|
|
10
10
|
export type OneTimeMigrationId = (typeof ONE_TIME_MIGRATION_IDS)[number];
|
|
11
11
|
/**
|
|
12
12
|
* 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
|
|
13
13
|
* - `moved` — 值搬到新位(`to`),义不变;
|
|
14
14
|
* - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
|
|
15
|
-
* - `dropped-inert` — 删掉;今天的读法本就不让它生效(
|
|
15
|
+
* - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:不声明那条车道的行上的车道键、mcp 条目上从没有读者的 `authForm` / `entryKind`);
|
|
16
16
|
* - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
|
|
17
17
|
* - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
|
|
18
18
|
* 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { deepFreeze } from "./deep-freeze.js";
|
|
2
2
|
/** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
|
|
3
|
-
export const ONE_TIME_MIGRATION_IDS = deepFreeze(["SS-
|
|
3
|
+
export const ONE_TIME_MIGRATION_IDS = deepFreeze(["SS-M11", "SS-M12", "SS-M13"]);
|
|
4
4
|
/**
|
|
5
5
|
* 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
|
|
6
6
|
* - `moved` — 值搬到新位(`to`),义不变;
|
|
7
7
|
* - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
|
|
8
|
-
* - `dropped-inert` — 删掉;今天的读法本就不让它生效(
|
|
8
|
+
* - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:不声明那条车道的行上的车道键、mcp 条目上从没有读者的 `authForm` / `entryKind`);
|
|
9
9
|
* - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
|
|
10
10
|
* - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
|
|
11
11
|
* 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
|
|
@@ -32,7 +32,7 @@ export type StoredDocuments = Readonly<Partial<Record<DomainName | RetiredDomain
|
|
|
32
32
|
export interface StoredDocumentsMigration {
|
|
33
33
|
/** 迁移后的文档集:没改的文档是**同一引用**;被移除的不在、新建的在(26.0.0 起没有一步移除或新建文档)。 */
|
|
34
34
|
readonly docs: Readonly<Record<string, unknown>>;
|
|
35
|
-
/** 逐条收据(步序 SS-
|
|
35
|
+
/** 逐条收据(步序 SS-M13〔mcp 条目〕→ workers 行步〔SS-M12 改写 → 一次终判〕:纯改写步在前,用新 schema 终判的 workers 行步最后;步内按坐标)。
|
|
36
36
|
* 只有 `refused` 的收据 = 什么都没改。 */
|
|
37
37
|
readonly receipts: readonly MigrationReceipt[];
|
|
38
38
|
}
|