@sema-agent/settings-schema 33.1.0 → 34.1.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 +664 -0
- package/README.md +138 -19
- package/conformance/VERSION +1 -1
- package/dist/api/credentials.d.ts +94 -14
- package/dist/api/credentials.js +33 -8
- package/dist/atomic-write.d.ts +68 -3
- package/dist/atomic-write.js +314 -4
- package/dist/cli.d.ts +5 -2
- package/dist/cli.js +15 -3
- package/dist/config-d-file.d.ts +0 -3
- package/dist/config-d-file.js +1 -6
- package/dist/config-dir-migration.d.ts +2 -1
- package/dist/config-dir-migration.js +34 -20
- package/dist/config-fns.d.ts +60 -14
- package/dist/config-fns.js +48 -13
- package/dist/conformance/index.d.ts +1 -0
- package/dist/conformance/index.js +2 -0
- package/dist/conformance/warnings.d.ts +1 -1
- package/dist/conformance/warnings.js +3 -3
- package/dist/conformance/web-admin-credential-lock.d.ts +17 -0
- package/dist/conformance/web-admin-credential-lock.js +347 -0
- package/dist/hooks-config.d.ts +12 -4
- package/dist/hooks-config.js +28 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/local-load.d.ts +66 -1
- package/dist/local-load.js +123 -39
- package/dist/mcp-request-entry.d.ts +43 -5
- package/dist/mcp-request-entry.js +60 -18
- package/dist/node.d.ts +1 -0
- package/dist/node.js +2 -0
- package/dist/plugin-id-segment.d.ts +15 -0
- package/dist/plugin-id-segment.js +15 -0
- package/dist/plugin-settings.d.ts +61 -0
- package/dist/plugin-settings.js +111 -0
- package/dist/read-sentences.d.ts +14 -3
- package/dist/read-sentences.js +32 -11
- package/dist/safety-merge-spec.d.ts +7 -7
- package/dist/safety-merge-spec.js +5 -3
- package/dist/settings-units.d.ts +35 -1
- package/dist/settings-units.js +51 -16
- package/dist/types.d.ts +13 -6
- package/dist/types.js +37 -11
- package/dist/ui-language.d.ts +3 -1
- package/dist/ui-language.js +3 -1
- package/dist/web-admin-credential.d.ts +14 -1
- package/dist/web-admin-credential.js +15 -1
- package/docs/API-SURFACE.md +60 -5
- package/docs/CONFORMANCE.md +19 -2
- package/docs/CONSUMER-INTEGRATION.md +165 -11
- package/llms-full.txt +51 -16
- package/llms.txt +18 -8
- package/package.json +5 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件设置的三只纯读法:设置里 `enabledPlugins` 一个键的**值**怎么读({@link readEnabledPluginsValue})、插件 id `<名>@<市场>` 怎么拆({@link readPluginId})、
|
|
3
|
+
* id 市场位上的哨兵词是哪几个({@link PLUGIN_MARKETPLACE_SENTINELS} / {@link isPluginMarketplaceSentinel})。纯函数、零 `node:` 依赖、浏览器安全。
|
|
4
|
+
*
|
|
5
|
+
* ## 为什么在这里
|
|
6
|
+
* 插件创建面(共用库、终端)要读参照形的 `enabledPlugins` 值与插件 id,各宿主此前各写一份 —— 一个事实多个读者各自判。三只读法就是那一份:**只读值,不定合并**。
|
|
7
|
+
*
|
|
8
|
+
* ## 分工(消费方读法,不是新规则)
|
|
9
|
+
* - 中心层 `plugins[].enabled` 是部署层的供给闸;设置层的 `enabledPlugins` 是各设置源每一层各自的开关。**两层怎么组合不在本包。**
|
|
10
|
+
* 下面这句是给宿主的现行做法,不是本模块的行为(本模块不实现、不校验它,也不回答「最终启用与否」):
|
|
11
|
+
* 组合读法到货之前,同时读中心 `plugins` 与本机设置文件的宿主**只照中心层答**,不自己拼 —— 自己拼出来的是第二个来源。
|
|
12
|
+
* - 本模块不读任何文档、不碰合并顺序、不定缺席时的缺省(缺席的键根本到不了这里:读法的入参是一个值)。
|
|
13
|
+
* - 托管策略表(`strictKnownMarketplaces` / `blockedMarketplaces`)与它的哨兵臂、`pluginConfigs` / `extraKnownMarketplaces` 的条目形,都不在本模块;
|
|
14
|
+
* 策略读不出时的处置、`unreadable` / `undefined` 之后怎么办,也都是宿主的事。
|
|
15
|
+
*
|
|
16
|
+
* ## 参照
|
|
17
|
+
* 三只读法的形取自参照(CC 的设置读法)。那是**读自解出语料的线索、没有对真实二进制核**;每一条下面标了参照到哪一步。
|
|
18
|
+
* 参照读到哪一步、哪里没核,逐只写在各导出的 JSDoc 里。
|
|
19
|
+
*/
|
|
20
|
+
import { captureStringArray } from "./own-key-read.js";
|
|
21
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
22
|
+
import { PLUGIN_ID_SEGMENT_REGEX } from "./plugin-id-segment.js";
|
|
23
|
+
// ── 市场位上的哨兵词 ────────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
/**
|
|
25
|
+
* 插件 id `<名>@<市场>` 的**市场位**上四个哨兵词(闭集):这些「市场」不是真有一份市场目录,而是标出这个插件**从哪儿来**。
|
|
26
|
+
* - `inline` —— 命令行指定目录载入的插件;
|
|
27
|
+
* - `skills-dir` —— 技能目录里的插件;
|
|
28
|
+
* - `synced` —— 从云端同步来的插件;
|
|
29
|
+
* - `builtin` —— 内置插件。
|
|
30
|
+
* `<名>@skills-dir` 是**合法 id**(名段、市场段都过名段文法,{@link readPluginId} 照常读出)。
|
|
31
|
+
* 参照读到哪一步:四词与「逐字严格相等比较」都读自参照(读码);词表不加不减。
|
|
32
|
+
* 注意:参照的托管策略表里另有一个同名的 `skills-dir` 策略哨兵 —— 那是**另一处**的词(策略来源的种类),不在本表、本版不读。
|
|
33
|
+
*/
|
|
34
|
+
export const PLUGIN_MARKETPLACE_SENTINELS = deepFreeze(["inline", "skills-dir", "synced", "builtin"]);
|
|
35
|
+
/** 一个值是不是四个哨兵词之一。逐字严格相等(区分大小写,不裁剪、不规范化);非串一律 `false`,不抛。 */
|
|
36
|
+
export function isPluginMarketplaceSentinel(v) {
|
|
37
|
+
return typeof v === "string" && PLUGIN_MARKETPLACE_SENTINELS.includes(v);
|
|
38
|
+
}
|
|
39
|
+
/** 来源类市场名里的 `npm`:id 市场位上是它时,名位可以是带 scope 的 npm 包名(见 {@link readPluginId})。它不是哨兵词,不在 {@link PLUGIN_MARKETPLACE_SENTINELS} 里。 */
|
|
40
|
+
const NPM_MARKETPLACE = "npm";
|
|
41
|
+
const NPM_ID_SUFFIX = `@${NPM_MARKETPLACE}`;
|
|
42
|
+
/** 一个名段是不是**全小写**的名段(npm 包名只收小写:名段文法本身不分大小写,这里再要求没有大写字母)。 */
|
|
43
|
+
const isLowercaseSegment = (part) => PLUGIN_ID_SEGMENT_REGEX.test(part) && part === part.toLowerCase();
|
|
44
|
+
/**
|
|
45
|
+
* 是不是**带 scope 的** npm 包名 `@<scope>/<名>`:`@`,一个全小写名段(scope),恰一个 `/`,一个全小写名段(包名);整串不含 `..`。
|
|
46
|
+
* 不带 scope 的 npm 包名没有单列:它本身就是一个名段,走 {@link readPluginId} 的一般文法(同一个答案)。
|
|
47
|
+
*/
|
|
48
|
+
function isScopedNpmPackageName(s) {
|
|
49
|
+
if (!s.startsWith("@") || s.includes(".."))
|
|
50
|
+
return false;
|
|
51
|
+
const slash = s.indexOf("/");
|
|
52
|
+
if (slash < 0 || s.indexOf("/", slash + 1) >= 0)
|
|
53
|
+
return false;
|
|
54
|
+
return isLowercaseSegment(s.slice(1, slash)) && isLowercaseSegment(s.slice(slash + 1));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 读一个插件 id。两条文法,答同一只形 `{ name, marketplace }`:
|
|
58
|
+
* ① **`<名>@<市场>`**:恰一个 `@`,两半各过名段文法 `PLUGIN_ID_SEGMENT_REGEX`(定义在包内私有的零 import 叶 `./plugin-id-segment`,`./types` 与包根原名转出;`PluginSpec.name` 与 `PluginSource` 的市场名读的是同一只对象);
|
|
59
|
+
* ② **`@<scope>/<包名>@npm`**(带 scope 的 npm 来源 id):名 = 整个带 scope 的包名(含开头的 `@` 与 `/`),市场 = `npm`。包名两段各是**全小写**名段、恰一个 `/`、整串不含 `..`。
|
|
60
|
+
* 不带 scope 的 npm 来源 id(`pkg@npm`)就是 ① 的一例(同一个答案),没有单列。
|
|
61
|
+
* 非串 / 两条文法都不过 ⇒ `undefined`(总:不抛,撤销的 Proxy 一类也只是非串)。不裁剪、不规范化(`@npm` 区分大小写)。
|
|
62
|
+
* 答案是**新造的、深冻的**。市场位上的哨兵词(`<名>@skills-dir` 等)照常读出,要不要当哨兵由调用方再问 {@link isPluginMarketplaceSentinel}。
|
|
63
|
+
*
|
|
64
|
+
* 参照读到哪一步(读自解出的语料 cli321.js 第 276223 行,行内列号为字符偏移,读码;没有对真实二进制核):
|
|
65
|
+
* - 参照的 id 判官 = 「`^ar@ar$` 或 `<npm 包名>@npm`」(列 56648 起);`ar` = `[A-Za-z0-9][-A-Za-z0-9._]*`,与 `PLUGIN_ID_SEGMENT_REGEX` 同一字符集;
|
|
66
|
+
* - npm 包名判官(列 24754 起):整串不含 `..` 与 `//`,且是带 scope 的 `@<小写名段>/<小写名段>` 或不带 scope 的 `<小写名段>`(小写名段 = `[a-z0-9][a-z0-9-._]*`);「`<npm 包名>@npm`」= 以 `@npm` 结尾且前半过它(`Cb = "npm"`,列 6859);
|
|
67
|
+
* - 参照把这样的 id 拆成 名 = 最后一个 `@` 之前的整段、市场 = `npm`(列 63291);
|
|
68
|
+
* - 本读法的 ② 与它逐格同判:不带 scope 的那一形被 ① 收下(答案一样),`//` 被「恰一个 `/`」挡掉。参照里 `pkg@pip` / `@github` 一类其他来源类市场名按 ① 读,不特判。
|
|
69
|
+
* 另:参照自己读 `enabledPlugins` 的键时不因 id 形坏而丢条目,本读法比参照读键更严 —— 读不出的 id 怎么处置由宿主定。
|
|
70
|
+
*/
|
|
71
|
+
export function readPluginId(v) {
|
|
72
|
+
if (typeof v !== "string")
|
|
73
|
+
return undefined;
|
|
74
|
+
if (v.endsWith(NPM_ID_SUFFIX)) {
|
|
75
|
+
const packageName = v.slice(0, v.length - NPM_ID_SUFFIX.length);
|
|
76
|
+
if (isScopedNpmPackageName(packageName))
|
|
77
|
+
return deepFreeze({ name: packageName, marketplace: NPM_MARKETPLACE });
|
|
78
|
+
}
|
|
79
|
+
const at = v.indexOf("@");
|
|
80
|
+
if (at < 0 || v.indexOf("@", at + 1) >= 0)
|
|
81
|
+
return undefined;
|
|
82
|
+
const name = v.slice(0, at);
|
|
83
|
+
const marketplace = v.slice(at + 1);
|
|
84
|
+
if (!PLUGIN_ID_SEGMENT_REGEX.test(name) || !PLUGIN_ID_SEGMENT_REGEX.test(marketplace))
|
|
85
|
+
return undefined;
|
|
86
|
+
return deepFreeze({ name, marketplace });
|
|
87
|
+
}
|
|
88
|
+
// ── `enabledPlugins` 的值 ──────────────────────────────────────────────────────────────────────────
|
|
89
|
+
/** {@link EnabledPluginsValue} 的判别词(闭集,四臂):`on` · `off` · `versions` · `unreadable`。 */
|
|
90
|
+
export const ENABLED_PLUGINS_VALUE_KINDS = deepFreeze(["on", "off", "versions", "unreadable"]);
|
|
91
|
+
/**
|
|
92
|
+
* 读 `enabledPlugins` 里**一个键的值**(键本身是 {@link readPluginId} 的事):
|
|
93
|
+
* - `true` ⇒ `{ kind: "on" }`;`false` ⇒ `{ kind: "off" }`;
|
|
94
|
+
* - 字符串数组 ⇒ `{ kind: "versions", constraints }`(`constraints` 是**新造的冻结副本**,事后改入参不影响答案);
|
|
95
|
+
* - 其余一切(串 `"true"`、`null`、`undefined`、数、对象、含非串元素的数组、读不出的对象 —— 撤销的 Proxy、访问器下标、稀疏数组)⇒ `{ kind: "unreadable" }`。
|
|
96
|
+
* 总(不抛),答案每次新造、深冻。**不定**与中心层 `plugins[].enabled` 的组合,**不定**缺席时的缺省 —— 入参就是一个值,缺席的键到不了这里。
|
|
97
|
+
*
|
|
98
|
+
* 参照读到哪一步:`true` / `false` / 字符串数组三形读自参照(读码;「数组」「字符串」两个构造器的身份按邻近用法推断,没有逐个追到定义)。参照的 schema 层对数组
|
|
99
|
+
* **不细判元素**:空数组、空串元素都收,不判每条是不是合法的版本范围。**本读法同读法** —— 数组只问「是不是字符串数组」,
|
|
100
|
+
* 每条约束怎么解释(范围 / 标签 / 精确版本)与「空数组算不算启用」是消费方的事;参照的更细判法(下游怎么用这些串)未核。
|
|
101
|
+
*/
|
|
102
|
+
export function readEnabledPluginsValue(v) {
|
|
103
|
+
if (v === true)
|
|
104
|
+
return deepFreeze({ kind: "on" });
|
|
105
|
+
if (v === false)
|
|
106
|
+
return deepFreeze({ kind: "off" });
|
|
107
|
+
const constraints = captureStringArray(v, "strict");
|
|
108
|
+
if (constraints !== undefined)
|
|
109
|
+
return deepFreeze({ kind: "versions", constraints });
|
|
110
|
+
return deepFreeze({ kind: "unreadable" });
|
|
111
|
+
}
|
package/dist/read-sentences.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 读腿读不进一份文档(或一条条目)时的**诊断句措辞** —— 包内私有(不进主桶),纯字符串函数,只 import 两只零 import 的叶(形状座位、一行回显的剥除集),所以谁都能调、不成环;句子**不含换行与双向控制符**(回显进来的键名 / 值 / 别人的句子都过 `stripControlAndBidi`)。
|
|
3
3
|
*
|
|
4
|
-
* 在这里铸的(照实)
|
|
4
|
+
* 在这里铸的(照实):读腿两条告警与域读拒的一句话({@link droppedEntrySentence} / {@link defaultedDomainSentence} / {@link refusedDomainSentence})、issue 的一句话({@link issueSentence})、
|
|
5
5
|
* 条目身份与原因的小段字,以及「读腿会怎么处置一份读不进的域文档」的后果句({@link readConsequenceSentence} —— 命令行 `migrate` 对在场文档的拒句取它)。
|
|
6
6
|
* 不在这里铸的:retired 域的墓碑句与它的出路(`./retired-form`,读写两面同一句)、命令行 `migrate` 拒句里 retired 域 / `remote-exec` 的后果、
|
|
7
7
|
* 「在 `<文件>` 里手改」那一截与整份 `why`(`./config-dir-migration`)。句子**一句一行**(不含换行):它们被日志、终端、网页端、管理台逐字渲染,
|
|
@@ -23,10 +23,13 @@ export interface IssueLike {
|
|
|
23
23
|
readonly message: string;
|
|
24
24
|
readonly code?: string;
|
|
25
25
|
readonly errors?: unknown;
|
|
26
|
+
readonly issues?: unknown;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
* 一条 zod issue 的**一句话**(不含换行)
|
|
29
|
-
*
|
|
29
|
+
* 一条 zod issue 的**一句话**(不含换行):zod 把真正的拒句嵌在 issue 里面,外层自己只说一句泛话 —— 联合(`invalid_union`)说 `Invalid input`、真正的拒句在各选项的 issue 里
|
|
30
|
+
* (取各选项第一条的句子,去重,至多三条,用 ` / ` 连);记录的坏键(`invalid_key`)说 `Invalid key in record`、键自己那张 schema 的拒句在它的 `issues` 里(同样读进去:
|
|
31
|
+
* 所有条目的坏键都在这里读,命令行 `migrate` 的拒因、读腿告警、域读拒与逐条丢弃那条告警里「坏键」说的是同一句);`invalid_element` 同形。
|
|
32
|
+
* 别的 issue 就是它自己的 `message`(换行折成空格)。出门前这些句子已经过本包唯一的脱敏器(`sanitizeZodError` 递归进这三处嵌套),这里只读不改。
|
|
30
33
|
*/
|
|
31
34
|
export declare function issueSentence(issue: IssueLike, depth?: number): string;
|
|
32
35
|
/** 一条 issue 的坐标(出门形的串,空串 = 在文档 / 条目的根上)与它的一句话。 */
|
|
@@ -62,6 +65,14 @@ export declare function defaultedDomainSentence(a: {
|
|
|
62
65
|
readonly cause: string;
|
|
63
66
|
readonly culprit: string | undefined;
|
|
64
67
|
}): string;
|
|
68
|
+
/**
|
|
69
|
+
* 域读拒(`DomainReadRefusedError`)的一句话:哪个域读不进 · 为什么(触发的坐标与原因,每条 `<坐标>: <句子>`)。`cause` 是 {@link causeText} 的答案(与上面两句同一只原因段);读不出原因 ⇒ 只剩点名域的前半句。
|
|
70
|
+
* 句子只有这一行:坐标在原因段的开头、紧跟点名域的前半句 —— 下游把一行截到定长(运维行的 `err` 字段)时,坐标留在被保留的那一头(原拒的 JSON 文本里坐标排在很后面)。
|
|
71
|
+
*/
|
|
72
|
+
export declare function refusedDomainSentence(a: {
|
|
73
|
+
readonly domain: string;
|
|
74
|
+
readonly cause: string;
|
|
75
|
+
}): string;
|
|
65
76
|
/** 读腿对「这个域的文档读不进」的处置,一句话(不含换行;`domain` 是闭集里的域名)。两张表各答一半、各自穷举:`fallback` 说整域读不进时怎么办,
|
|
66
77
|
* `salvage` 说先不先丢那一条 —— 两半拼成一句,四种组合各有自己的话(「整域拒 + 逐条丢」的域两半都说)。 */
|
|
67
78
|
export declare function readConsequenceSentence(domain: string, stance: ReadStanceWords): string;
|
package/dist/read-sentences.js
CHANGED
|
@@ -3,20 +3,34 @@ import { isJsonArray } from "./plain-json-object.js"; // 形状只问座位:这
|
|
|
3
3
|
/** 一行:空白(含换行、制表)的每一段折成一个空格,再剥掉一行回显的剥除集({@link stripControlAndBidi}:C0、DEL、双向控制符),两端去空白。句子里回显的任何一串(键名、值、别人的句子)都经它,一个换行伪造不出第二行。 */
|
|
4
4
|
const oneLine = (text) => stripControlAndBidi(text.replace(/\s+/g, " ")).trim();
|
|
5
5
|
/**
|
|
6
|
-
* 一条 zod issue 的**一句话**(不含换行)
|
|
7
|
-
*
|
|
6
|
+
* 一条 zod issue 的**一句话**(不含换行):zod 把真正的拒句嵌在 issue 里面,外层自己只说一句泛话 —— 联合(`invalid_union`)说 `Invalid input`、真正的拒句在各选项的 issue 里
|
|
7
|
+
* (取各选项第一条的句子,去重,至多三条,用 ` / ` 连);记录的坏键(`invalid_key`)说 `Invalid key in record`、键自己那张 schema 的拒句在它的 `issues` 里(同样读进去:
|
|
8
|
+
* 所有条目的坏键都在这里读,命令行 `migrate` 的拒因、读腿告警、域读拒与逐条丢弃那条告警里「坏键」说的是同一句);`invalid_element` 同形。
|
|
9
|
+
* 别的 issue 就是它自己的 `message`(换行折成空格)。出门前这些句子已经过本包唯一的脱敏器(`sanitizeZodError` 递归进这三处嵌套),这里只读不改。
|
|
8
10
|
*/
|
|
9
11
|
export function issueSentence(issue, depth = 0) {
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (depth < 4) {
|
|
13
|
+
if (issue.code === "invalid_union" && isJsonArray(issue.errors)) {
|
|
14
|
+
const branches = [];
|
|
15
|
+
for (const branch of issue.errors) {
|
|
16
|
+
const first = isJsonArray(branch) ? branch[0] : undefined;
|
|
17
|
+
if (first !== undefined && typeof first.message === "string")
|
|
18
|
+
branches.push(issueSentence(first, depth + 1));
|
|
19
|
+
}
|
|
20
|
+
const distinct = [...new Set(branches)].slice(0, 3);
|
|
21
|
+
if (distinct.length > 0)
|
|
22
|
+
return distinct.join(" / ");
|
|
23
|
+
}
|
|
24
|
+
if ((issue.code === "invalid_key" || issue.code === "invalid_element") && isJsonArray(issue.issues)) {
|
|
25
|
+
const nested = [];
|
|
26
|
+
for (const inner of issue.issues) {
|
|
27
|
+
const found = inner;
|
|
28
|
+
if (found !== undefined && found !== null && typeof found.message === "string")
|
|
29
|
+
nested.push({ path: "", sentence: issueSentence(found, depth + 1) });
|
|
30
|
+
}
|
|
31
|
+
if (nested.length > 0)
|
|
32
|
+
return causeText(nested);
|
|
16
33
|
}
|
|
17
|
-
const distinct = [...new Set(branches)].slice(0, 3);
|
|
18
|
-
if (distinct.length > 0)
|
|
19
|
-
return distinct.join(" / ");
|
|
20
34
|
}
|
|
21
35
|
return oneLine(issue.message);
|
|
22
36
|
}
|
|
@@ -57,6 +71,13 @@ export function defaultedDomainSentence(a) {
|
|
|
57
71
|
const tail = a.culprit === undefined ? "" : ` (${a.culprit})`;
|
|
58
72
|
return oneLine(`the whole "${a.domain}" domain is read as its default: ${a.cause === "" ? "it does not read" : a.cause}${tail}; fix it in the "${a.domain}" document by hand`);
|
|
59
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* 域读拒(`DomainReadRefusedError`)的一句话:哪个域读不进 · 为什么(触发的坐标与原因,每条 `<坐标>: <句子>`)。`cause` 是 {@link causeText} 的答案(与上面两句同一只原因段);读不出原因 ⇒ 只剩点名域的前半句。
|
|
76
|
+
* 句子只有这一行:坐标在原因段的开头、紧跟点名域的前半句 —— 下游把一行截到定长(运维行的 `err` 字段)时,坐标留在被保留的那一头(原拒的 JSON 文本里坐标排在很后面)。
|
|
77
|
+
*/
|
|
78
|
+
export function refusedDomainSentence(a) {
|
|
79
|
+
return oneLine(`config domain "${a.domain}" could not be read${a.cause === "" ? "" : `: ${a.cause}`}`);
|
|
80
|
+
}
|
|
60
81
|
/** 读腿对「这个域的文档读不进」的处置,一句话(不含换行;`domain` 是闭集里的域名)。两张表各答一半、各自穷举:`fallback` 说整域读不进时怎么办,
|
|
61
82
|
* `salvage` 说先不先丢那一条 —— 两半拼成一句,四种组合各有自己的话(「整域拒 + 逐条丢」的域两半都说)。 */
|
|
62
83
|
export function readConsequenceSentence(domain, stance) {
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* author is settings-core, web-admin maintains the formalized artifact here (this package), the axis VALUE domains
|
|
6
6
|
* are core's (@sema-agent/core SAFETY_AXIS_VOCABULARY — validated by a dev-only conformance test, never a runtime
|
|
7
7
|
* import). The settings-document UNIT table — which keys of a settings file carry a merge contract, where each sits,
|
|
8
|
-
* which category below it maps into,
|
|
8
|
+
* which category below it maps into, how its raw value reads, and who reads it — is published by this package too, as
|
|
9
9
|
* `SETTINGS_UNITS` (`./settings-units.ts`, 14.6.0): a consumer reads it instead of keeping a key→category map of its
|
|
10
|
-
* own for those
|
|
10
|
+
* own for those units. Not every row here has a unit: for example the http-hook allowlist keys (`./http-hook-allowlists` keys and
|
|
11
11
|
* reads them itself, with its own malformed-value reading) and the `webSearch` section (30.1.0; its key is published by
|
|
12
12
|
* `./web-search-section` as `WEB_SEARCH_SECTION_KEYS`, and this package has no reading of its shape) — see the `./settings-units`
|
|
13
13
|
* header. THIS file is the category spec every unit cites — no second copy of the law.
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
import { z } from "zod";
|
|
69
69
|
/** How values from different layers/principals combine for a category. */
|
|
70
70
|
export declare const MergeShape: z.ZodEnum<{
|
|
71
|
-
replace: "replace";
|
|
72
71
|
concat: "concat";
|
|
72
|
+
replace: "replace";
|
|
73
73
|
denyFirst: "denyFirst";
|
|
74
74
|
runAll: "runAll";
|
|
75
75
|
overrideByName: "overrideByName";
|
|
@@ -186,8 +186,8 @@ export interface ResolvedMemberAdmission {
|
|
|
186
186
|
/** WHERE the category is enforced (STRENGTH) — MUST stay in lockstep with `EffectiveKey.enforcement` (types.ts).
|
|
187
187
|
* gate=data-plane engine, server=control-plane/TOB boundary, resolver=merger correctness, client=UI only. */
|
|
188
188
|
export declare const SpecEnforcement: z.ZodEnum<{
|
|
189
|
-
gate: "gate";
|
|
190
189
|
server: "server";
|
|
190
|
+
gate: "gate";
|
|
191
191
|
resolver: "resolver";
|
|
192
192
|
client: "client";
|
|
193
193
|
}>;
|
|
@@ -262,8 +262,8 @@ export type TightenVerdict = (typeof TIGHTEN_VERDICTS)[number];
|
|
|
262
262
|
export declare function tightenVerdict(rule: TightenRule, existing: unknown, candidate: unknown): TightenVerdict;
|
|
263
263
|
export declare const MergeCategorySpec: z.ZodObject<{
|
|
264
264
|
mergeShape: z.ZodEnum<{
|
|
265
|
-
replace: "replace";
|
|
266
265
|
concat: "concat";
|
|
266
|
+
replace: "replace";
|
|
267
267
|
denyFirst: "denyFirst";
|
|
268
268
|
runAll: "runAll";
|
|
269
269
|
overrideByName: "overrideByName";
|
|
@@ -294,8 +294,8 @@ export declare const MergeCategorySpec: z.ZodObject<{
|
|
|
294
294
|
rule: z.ZodLiteral<"numericLower">;
|
|
295
295
|
}, z.core.$strip>], "rule">;
|
|
296
296
|
enforcement: z.ZodEnum<{
|
|
297
|
-
gate: "gate";
|
|
298
297
|
server: "server";
|
|
298
|
+
gate: "gate";
|
|
299
299
|
resolver: "resolver";
|
|
300
300
|
client: "client";
|
|
301
301
|
}>;
|
|
@@ -607,7 +607,7 @@ export declare const SAFETY_MERGE_SPEC: {
|
|
|
607
607
|
};
|
|
608
608
|
readonly enforcement: "client";
|
|
609
609
|
readonly fail: "open";
|
|
610
|
-
readonly seam: "
|
|
610
|
+
readonly seam: "host-written preferences (theme / keybindings / statusLine / output style / UI language) — whether a key reaches the engine is its SETTINGS_UNITS row's `reader`, not this row";
|
|
611
611
|
};
|
|
612
612
|
readonly org: {
|
|
613
613
|
readonly mergeShape: "replace";
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* author is settings-core, web-admin maintains the formalized artifact here (this package), the axis VALUE domains
|
|
6
6
|
* are core's (@sema-agent/core SAFETY_AXIS_VOCABULARY — validated by a dev-only conformance test, never a runtime
|
|
7
7
|
* import). The settings-document UNIT table — which keys of a settings file carry a merge contract, where each sits,
|
|
8
|
-
* which category below it maps into,
|
|
8
|
+
* which category below it maps into, how its raw value reads, and who reads it — is published by this package too, as
|
|
9
9
|
* `SETTINGS_UNITS` (`./settings-units.ts`, 14.6.0): a consumer reads it instead of keeping a key→category map of its
|
|
10
|
-
* own for those
|
|
10
|
+
* own for those units. Not every row here has a unit: for example the http-hook allowlist keys (`./http-hook-allowlists` keys and
|
|
11
11
|
* reads them itself, with its own malformed-value reading) and the `webSearch` section (30.1.0; its key is published by
|
|
12
12
|
* `./web-search-section` as `WEB_SEARCH_SECTION_KEYS`, and this package has no reading of its shape) — see the `./settings-units`
|
|
13
13
|
* header. THIS file is the category spec every unit cites — no second copy of the law.
|
|
@@ -436,7 +436,9 @@ export const SAFETY_MERGE_SPEC = deepFreeze({
|
|
|
436
436
|
envSecret: { mergeShape: "replace", minTrust: "global", tighten: { rule: "none" }, enforcement: "resolver", fail: "closed", seam: "§7 secret-ref resolution" },
|
|
437
437
|
memoryScopes: { mergeShape: "concat", minTrust: "global", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "MemoryEngine" },
|
|
438
438
|
autoCompaction: { mergeShape: "replace", minTrust: "session", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "compaction config" },
|
|
439
|
-
|
|
439
|
+
// Display string only. Whether a key of this category reaches the engine is that key's fact, not the category's (`outputStyle` is folded into
|
|
440
|
+
// the engine's system prompt, `semaUiLanguage` never leaves the host) — it is the `reader` of the key's SETTINGS_UNITS row, and the seam points there.
|
|
441
|
+
ui: { mergeShape: "replace", minTrust: "local", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "host-written preferences (theme / keybindings / statusLine / output style / UI language) — whether a key reaches the engine is its SETTINGS_UNITS row's `reader`, not this row" },
|
|
440
442
|
org: { mergeShape: "replace", minTrust: "managed", tighten: { rule: "none" }, enforcement: "server", fail: "closed", seam: "web-admin → governanceBaseline (SSO/SCIM/audit/budget, TOB-only)" },
|
|
441
443
|
// 13.0.0 (U3 [10538]) — the http hook allowlists `allowedHttpHookUrls` / `httpHookAllowedEnvVars`. Every ADMITTED layer's list must
|
|
442
444
|
// pass (layers INTERSECT: a lower layer can only narrow, never add a URL the managed list lacks — CC concatenates, which lets it);
|
package/dist/settings-units.d.ts
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import { type TightenRule } from "./safety-merge-spec.js";
|
|
2
|
-
/**
|
|
2
|
+
/** Who reads a unit — the closed set of the `reader` word every unit row carries (the file header defines each word). Declaration order is not a rank. */
|
|
3
|
+
export declare const SETTINGS_UNIT_READERS: readonly ["shell", "engine"];
|
|
4
|
+
export type SettingsUnitReader = (typeof SETTINGS_UNIT_READERS)[number];
|
|
5
|
+
/** The settings-document units (see the file header). `path` is the unit's place in a settings document; `reader` is who reads it; `sources` are the settings sources that carry it. */
|
|
3
6
|
export declare const SETTINGS_UNITS: {
|
|
4
7
|
readonly permissions: {
|
|
5
8
|
readonly path: readonly ["permissions"];
|
|
6
9
|
readonly category: "permissions";
|
|
7
10
|
readonly reads: "members";
|
|
11
|
+
readonly reader: "engine";
|
|
12
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
8
13
|
};
|
|
9
14
|
readonly permissionMode: {
|
|
10
15
|
readonly path: readonly ["permissions", "defaultMode"];
|
|
11
16
|
readonly category: "permissionMode";
|
|
12
17
|
readonly reads: "whole";
|
|
13
18
|
readonly reading: "permissionMode";
|
|
19
|
+
readonly reader: "engine";
|
|
20
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
14
21
|
};
|
|
15
22
|
readonly additionalDirectories: {
|
|
16
23
|
readonly path: readonly ["permissions", "additionalDirectories"];
|
|
17
24
|
readonly category: "sandboxNetwork";
|
|
18
25
|
readonly reads: "whole";
|
|
19
26
|
readonly reading: "stringList";
|
|
27
|
+
readonly reader: "engine";
|
|
28
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
20
29
|
};
|
|
21
30
|
readonly sandbox: {
|
|
22
31
|
readonly path: readonly ["sandbox"];
|
|
23
32
|
readonly category: "sandboxNetwork";
|
|
24
33
|
readonly reads: "members";
|
|
34
|
+
readonly reader: "engine";
|
|
35
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
25
36
|
};
|
|
26
37
|
readonly disableBypassPermissionsMode: {
|
|
27
38
|
readonly path: readonly ["permissions", "disableBypassPermissionsMode"];
|
|
@@ -29,6 +40,8 @@ export declare const SETTINGS_UNITS: {
|
|
|
29
40
|
readonly reads: "member";
|
|
30
41
|
readonly member: "disableBypassPermissionsMode";
|
|
31
42
|
readonly reading: "killSwitch";
|
|
43
|
+
readonly reader: "engine";
|
|
44
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
32
45
|
};
|
|
33
46
|
readonly disableAutoMode: {
|
|
34
47
|
readonly path: readonly ["permissions", "disableAutoMode"];
|
|
@@ -36,30 +49,48 @@ export declare const SETTINGS_UNITS: {
|
|
|
36
49
|
readonly reads: "member";
|
|
37
50
|
readonly member: "disableAutoMode";
|
|
38
51
|
readonly reading: "killSwitch";
|
|
52
|
+
readonly reader: "engine";
|
|
53
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
39
54
|
};
|
|
40
55
|
readonly hooks: {
|
|
41
56
|
readonly path: readonly ["hooks"];
|
|
42
57
|
readonly category: "hooks";
|
|
43
58
|
readonly reads: "whole";
|
|
44
59
|
readonly reading: "hooks";
|
|
60
|
+
readonly reader: "engine";
|
|
61
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
45
62
|
};
|
|
46
63
|
readonly env: {
|
|
47
64
|
readonly path: readonly ["env"];
|
|
48
65
|
readonly category: "env";
|
|
49
66
|
readonly reads: "whole";
|
|
50
67
|
readonly reading: "envMap";
|
|
68
|
+
readonly reader: "engine";
|
|
69
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
51
70
|
};
|
|
52
71
|
readonly model: {
|
|
53
72
|
readonly path: readonly ["model"];
|
|
54
73
|
readonly category: "model";
|
|
55
74
|
readonly reads: "whole";
|
|
56
75
|
readonly reading: "nonEmptyString";
|
|
76
|
+
readonly reader: "engine";
|
|
77
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
57
78
|
};
|
|
58
79
|
readonly outputStyle: {
|
|
59
80
|
readonly path: readonly ["outputStyle"];
|
|
60
81
|
readonly category: "ui";
|
|
61
82
|
readonly reads: "whole";
|
|
62
83
|
readonly reading: "nonEmptyString";
|
|
84
|
+
readonly reader: "engine";
|
|
85
|
+
readonly sources: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
86
|
+
};
|
|
87
|
+
readonly semaUiLanguage: {
|
|
88
|
+
readonly path: readonly ["semaUiLanguage"];
|
|
89
|
+
readonly category: "ui";
|
|
90
|
+
readonly reads: "whole";
|
|
91
|
+
readonly reading: "uiLanguage";
|
|
92
|
+
readonly reader: "shell";
|
|
93
|
+
readonly sources: readonly ["userSettings"];
|
|
63
94
|
};
|
|
64
95
|
};
|
|
65
96
|
export type SettingsUnitName = keyof typeof SETTINGS_UNITS;
|
|
@@ -75,6 +106,9 @@ export declare function unitTighten(unit: SettingsUnitName, member?: string): Ti
|
|
|
75
106
|
* are `"manual"` ⇒ `"default"` (permissionMode) and `"disable"` ⇒ `true` (kill-switches); `"bypassPermissions"` is `launch_only`.
|
|
76
107
|
* The last step of every reading is the unit comparator's own domain: whatever reads, compares (file header).
|
|
77
108
|
* Addressing is {@link unitTighten}'s (same RangeErrors: a `members` unit needs a declared member, …).
|
|
109
|
+
* A WRITER judges the value it is about to write with this same call, and reads the written layer back with it: the refusal word is the reading's
|
|
110
|
+
* `reason` (a UI language outside its closed set ⇒ `unreadable`), so a host's inbound gate and this package answer with one word. This package writes
|
|
111
|
+
* no settings file; the write itself, its receipt and where the layer lives are the host's.
|
|
78
112
|
* `unreadable` on a `member` / `members` unit is NOT absence, and the reading carries no direction: what the caller does with it depends on the member's
|
|
79
113
|
* `memberAdmission(category, member).direction` (`loosen` ⇒ may be dropped, loudly; `tighten` ⇒ must be kept and answered strictest on its own surface) —
|
|
80
114
|
* see WHEN A MEMBER DOES NOT READ in the file header.
|
package/dist/settings-units.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SETTINGS UNITS (14.6.0) — the settings-document unit table: which keys of a settings file carry a merge contract, where each
|
|
3
|
-
* sits in the document, which {@link SAFETY_MERGE_SPEC} category it maps into,
|
|
4
|
-
* settings
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* sits in the document, which {@link SAFETY_MERGE_SPEC} category it maps into, how its raw value READS, who reads it (`reader`) and
|
|
4
|
+
* which settings sources carry it (`sources`).
|
|
5
|
+
* Every resolver of a settings file (the shell reads it for each of its sources; a profile loader is a second projection) and every
|
|
6
|
+
* writer of one reads THIS table instead of keeping a key→category map, a value judge or a reader list of its own for these units.
|
|
7
|
+
* Unit names: the shell's established ten, then `semaUiLanguage` — the UI-language key, named by its key and placed by its declaration
|
|
8
|
+
* (`UI_LANGUAGE_SETTING` in `./ui-language`: the row's `path`, `category` and `sources` are read from there, not written twice). The two
|
|
9
|
+
* permission-mode kill-switches map to their own `killSwitches` member rows (the table has no managed-only floor for them).
|
|
10
|
+
*
|
|
11
|
+
* Who reads a unit (`reader`, on every row; the closed set {@link SETTINGS_UNIT_READERS}):
|
|
12
|
+
* · `shell` — the value changes only the host's own interface and never reaches the engine, wherever the engine runs — so a writer
|
|
13
|
+
* of a write set made only of `shell` units needs no question about the engine at all;
|
|
14
|
+
* · `engine` — the conservative answer for everything else: the value can change what the engine does (the engine reads it, or a host
|
|
15
|
+
* folds it into the engine's request — a model, a permission rule, an output style folded into the system prompt). Whether
|
|
16
|
+
* a write to one particular settings file reaches one particular engine depends on how that host feeds its engine (a host
|
|
17
|
+
* may read the local file and forward the value to an engine that runs elsewhere): ask the host, not this table.
|
|
18
|
+
* It is a fact about each KEY, never about a category: `outputStyle` and `semaUiLanguage` share the `ui` category and have different
|
|
19
|
+
* readers. A unit has one reader for all of its value: a `members` unit's members share it, and `hooks` is `engine` although some of its
|
|
20
|
+
* events run in the shell — which event belongs to whom is `HOOK_EVENT_OWNER` (`./hooks`), the finer reading, not a second reader here.
|
|
21
|
+
*
|
|
22
|
+
* Which settings sources carry a unit (`sources`, on every row; words of `SETTINGS_SOURCES`): a unit is read only from the sources its row
|
|
23
|
+
* lists — a value of the unit in any other source is not read (neither admitted nor refused: that source does not carry the key) — and inside
|
|
24
|
+
* them `layerAdmission(source, workspace, category, …)` answers as for every category. Every unit the shell established is carried by every source
|
|
25
|
+
* (their `sources` IS `SETTINGS_SOURCES`); `semaUiLanguage` only by `UI_LANGUAGE_SETTING.source` (the user's settings), read from there.
|
|
7
26
|
*
|
|
8
27
|
* NOT in this table: the two http-hook allowlist keys (`allowedHttpHookUrls` / `httpHookAllowedEnvVars`). They carry a merge contract
|
|
9
28
|
* too (the `httpHookAllowlists` category of {@link SAFETY_MERGE_SPEC}) but are keyed and read by `./http-hook-allowlists` on its own
|
|
@@ -32,6 +51,8 @@
|
|
|
32
51
|
* · `hooks` — what the one hooks judge (`classifyHooksConfig`) classifies as `loaded`;
|
|
33
52
|
* · `envMap` — a plain object whose keys are non-empty and whose values are all strings;
|
|
34
53
|
* · `nonEmptyString` — a non-empty string;
|
|
54
|
+
* · `uiLanguage` — a word of `UI_LANGUAGE_VALUES`, exactly as written: no case folding, no locale-tag folding (`"zh-CN"`, `"EN"`, `" en"`
|
|
55
|
+
* are `unreadable`). The one judge is `readUiLanguage` (`./ui-language`); this reading delegates to it;
|
|
35
56
|
* and a member's value class: `boolPole` ⇒ a boolean, `list` ⇒ the `stringList` reading.
|
|
36
57
|
* Everything else is `unreadable` — no default arm. Two laws for every unit: `undefined` and JSON `null` are `unreadable` (absence
|
|
37
58
|
* is not a value; "an absent landing spot takes the write" is the loader's business, before it calls the reader), and the reader
|
|
@@ -55,7 +76,7 @@
|
|
|
55
76
|
* the contract cannot tell what it was meant to forbid, and the strictest answer is the only one that cannot be looser than what the author meant.
|
|
56
77
|
* The package enforces nothing here (the surfaces are the consumers'); what it pins is that both inputs exist for every such member and that every
|
|
57
78
|
* out-of-domain value reads `unreadable` without throwing. Not covered, and not settled here: the `whole` units (`permissionMode`, `additionalDirectories`,
|
|
58
|
-
* `hooks`, `env`, `model`, `outputStyle`) have no direction column; whether "unreadable = absent" closes for them depends on the order of the
|
|
79
|
+
* `hooks`, `env`, `model`, `outputStyle`, `semaUiLanguage`) have no direction column; whether "unreadable = absent" closes for them depends on the order of the
|
|
59
80
|
* unit's own value domain, which is a design question of its own.
|
|
60
81
|
* The env DOCUMENT's literal grammar (boolean words, csv + empty-set sentinel, a "≤ 0 means off" cap) is not here: it belongs to
|
|
61
82
|
* the engine's env catalog, whose one implementation is the server's.
|
|
@@ -65,18 +86,24 @@ import { captureJson, captureStringArray, ownEntriesOf } from "./own-key-read.js
|
|
|
65
86
|
import { isPlainJsonObject } from "./plain-json-object.js";
|
|
66
87
|
import { SAFETY_MERGE_SPEC, resolveMemberTighten, tightenVerdict } from "./safety-merge-spec.js";
|
|
67
88
|
import { deepFreeze } from "./deep-freeze.js";
|
|
68
|
-
|
|
89
|
+
import { SETTINGS_SOURCES } from "./settings-sources.js";
|
|
90
|
+
import { UI_LANGUAGE_SETTING, readUiLanguage } from "./ui-language.js";
|
|
91
|
+
/** Who reads a unit — the closed set of the `reader` word every unit row carries (the file header defines each word). Declaration order is not a rank. */
|
|
92
|
+
export const SETTINGS_UNIT_READERS = deepFreeze(["shell", "engine"]);
|
|
93
|
+
/** The settings-document units (see the file header). `path` is the unit's place in a settings document; `reader` is who reads it; `sources` are the settings sources that carry it. */
|
|
69
94
|
export const SETTINGS_UNITS = deepFreeze({
|
|
70
|
-
permissions: { path: ["permissions"], category: "permissions", reads: "members" },
|
|
71
|
-
permissionMode: { path: ["permissions", "defaultMode"], category: "permissionMode", reads: "whole", reading: "permissionMode" },
|
|
72
|
-
additionalDirectories: { path: ["permissions", "additionalDirectories"], category: "sandboxNetwork", reads: "whole", reading: "stringList" },
|
|
73
|
-
sandbox: { path: ["sandbox"], category: "sandboxNetwork", reads: "members" },
|
|
74
|
-
disableBypassPermissionsMode: { path: ["permissions", "disableBypassPermissionsMode"], category: "killSwitches", reads: "member", member: "disableBypassPermissionsMode", reading: "killSwitch" },
|
|
75
|
-
disableAutoMode: { path: ["permissions", "disableAutoMode"], category: "killSwitches", reads: "member", member: "disableAutoMode", reading: "killSwitch" },
|
|
76
|
-
hooks: { path: ["hooks"], category: "hooks", reads: "whole", reading: "hooks" },
|
|
77
|
-
env: { path: ["env"], category: "env", reads: "whole", reading: "envMap" },
|
|
78
|
-
model: { path: ["model"], category: "model", reads: "whole", reading: "nonEmptyString" },
|
|
79
|
-
outputStyle: { path: ["outputStyle"], category: "ui", reads: "whole", reading: "nonEmptyString" },
|
|
95
|
+
permissions: { path: ["permissions"], category: "permissions", reads: "members", reader: "engine", sources: SETTINGS_SOURCES },
|
|
96
|
+
permissionMode: { path: ["permissions", "defaultMode"], category: "permissionMode", reads: "whole", reading: "permissionMode", reader: "engine", sources: SETTINGS_SOURCES },
|
|
97
|
+
additionalDirectories: { path: ["permissions", "additionalDirectories"], category: "sandboxNetwork", reads: "whole", reading: "stringList", reader: "engine", sources: SETTINGS_SOURCES },
|
|
98
|
+
sandbox: { path: ["sandbox"], category: "sandboxNetwork", reads: "members", reader: "engine", sources: SETTINGS_SOURCES },
|
|
99
|
+
disableBypassPermissionsMode: { path: ["permissions", "disableBypassPermissionsMode"], category: "killSwitches", reads: "member", member: "disableBypassPermissionsMode", reading: "killSwitch", reader: "engine", sources: SETTINGS_SOURCES },
|
|
100
|
+
disableAutoMode: { path: ["permissions", "disableAutoMode"], category: "killSwitches", reads: "member", member: "disableAutoMode", reading: "killSwitch", reader: "engine", sources: SETTINGS_SOURCES },
|
|
101
|
+
hooks: { path: ["hooks"], category: "hooks", reads: "whole", reading: "hooks", reader: "engine", sources: SETTINGS_SOURCES },
|
|
102
|
+
env: { path: ["env"], category: "env", reads: "whole", reading: "envMap", reader: "engine", sources: SETTINGS_SOURCES },
|
|
103
|
+
model: { path: ["model"], category: "model", reads: "whole", reading: "nonEmptyString", reader: "engine", sources: SETTINGS_SOURCES },
|
|
104
|
+
outputStyle: { path: ["outputStyle"], category: "ui", reads: "whole", reading: "nonEmptyString", reader: "engine", sources: SETTINGS_SOURCES },
|
|
105
|
+
// the key, its category and the one source that carries it are the declaration's (`UI_LANGUAGE_SETTING`); the computed key keeps the literal type
|
|
106
|
+
[UI_LANGUAGE_SETTING.key]: { path: [UI_LANGUAGE_SETTING.key], category: UI_LANGUAGE_SETTING.category, reads: "whole", reading: "uiLanguage", reader: "shell", sources: [UI_LANGUAGE_SETTING.source] },
|
|
80
107
|
});
|
|
81
108
|
/** The one place a unit + optional member resolves to what is being asked about — the row and its comparator. Fail-closed
|
|
82
109
|
* and loud on every misaddressing: an unknown unit (own-property lookup — `"__proto__"` is unknown, not Object.prototype),
|
|
@@ -172,6 +199,11 @@ function shapedReading(unit, row, rule, raw) {
|
|
|
172
199
|
return isEnvMap(raw) ? { ok: true, value: raw } : UNREADABLE;
|
|
173
200
|
case "nonEmptyString":
|
|
174
201
|
return typeof raw === "string" && raw.length > 0 ? { ok: true, value: raw } : UNREADABLE;
|
|
202
|
+
case "uiLanguage": {
|
|
203
|
+
// the one judge of the closed set is the declaration's reader; `undefined` / `null` never get here (absence is refused before the shape half)
|
|
204
|
+
const layer = readUiLanguage(raw);
|
|
205
|
+
return layer.ok && layer.value !== undefined ? { ok: true, value: raw } : UNREADABLE;
|
|
206
|
+
}
|
|
175
207
|
default: {
|
|
176
208
|
const unknown = row.reading;
|
|
177
209
|
throw new RangeError(`SETTINGS_UNITS: unit '${unit}' has an unknown reading '${String(unknown)}'`);
|
|
@@ -185,6 +217,9 @@ function shapedReading(unit, row, rule, raw) {
|
|
|
185
217
|
* are `"manual"` ⇒ `"default"` (permissionMode) and `"disable"` ⇒ `true` (kill-switches); `"bypassPermissions"` is `launch_only`.
|
|
186
218
|
* The last step of every reading is the unit comparator's own domain: whatever reads, compares (file header).
|
|
187
219
|
* Addressing is {@link unitTighten}'s (same RangeErrors: a `members` unit needs a declared member, …).
|
|
220
|
+
* A WRITER judges the value it is about to write with this same call, and reads the written layer back with it: the refusal word is the reading's
|
|
221
|
+
* `reason` (a UI language outside its closed set ⇒ `unreadable`), so a host's inbound gate and this package answer with one word. This package writes
|
|
222
|
+
* no settings file; the write itself, its receipt and where the layer lives are the host's.
|
|
188
223
|
* `unreadable` on a `member` / `members` unit is NOT absence, and the reading carries no direction: what the caller does with it depends on the member's
|
|
189
224
|
* `memberAdmission(category, member).direction` (`loosen` ⇒ may be dropped, loudly; `tighten` ⇒ must be kept and answered strictest on its own surface) —
|
|
190
225
|
* see WHEN A MEMBER DOES NOT READ in the file header.
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* `ENV_NAME` schema (regex) on every `*Env` field — a pasted secret value is rejected, not just discouraged.
|
|
18
18
|
*/
|
|
19
19
|
import { z } from "zod";
|
|
20
|
+
import { PLUGIN_ID_SEGMENT_REGEX } from "./plugin-id-segment.js";
|
|
20
21
|
/** A private-key PEM header (`-----BEGIN [RSA |EC |OPENSSH |ENCRYPTED ]PRIVATE KEY`), unanchored — the ONE definition
|
|
21
22
|
* of that shape, read ANYWHERE in a string by BOTH sides of the one scanner: the validation detector {@link containsSecretToken}
|
|
22
23
|
* (`scanForSecret`, 10.0.0) and the display redactor `redactSecrets` (config-fns) — on the same normalized forms since 11.0.0. {@link SECRET_LITERAL_RE} is also composed from it (anchored, as one of its branches — the exported per-token
|
|
@@ -1322,6 +1323,8 @@ export declare const ProjectRegistration: z.ZodObject<{
|
|
|
1322
1323
|
color: z.ZodOptional<z.ZodString>;
|
|
1323
1324
|
}, z.core.$strip>;
|
|
1324
1325
|
export type ProjectRegistration = z.infer<typeof ProjectRegistration>;
|
|
1326
|
+
/** 项目登记簿。`projects` 记录的**条目序是契约事实**:它就是登记簿的展示序,唯一来源 = 文档里的条目次序;写者必须保序({@link applyProjectPatch} 已保序)。
|
|
1327
|
+
* 已知分工:今天的内容版本(`configDVersionOf`(`./config-d-file`))按排序后的键计算,只调换条目次序不会换版本号;内容版本自下一个大版本起看得见条目序。 */
|
|
1325
1328
|
export declare const ProjectsConfig: z.ZodObject<{
|
|
1326
1329
|
projects: z.ZodPrefault<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1327
1330
|
displayName: z.ZodString;
|
|
@@ -1413,8 +1416,8 @@ export declare const CollabTopology: z.ZodEnum<{
|
|
|
1413
1416
|
}>;
|
|
1414
1417
|
export type CollabTopology = z.infer<typeof CollabTopology>;
|
|
1415
1418
|
export declare const CollabFinalizerType: z.ZodEnum<{
|
|
1416
|
-
summarize: "summarize";
|
|
1417
1419
|
none: "none";
|
|
1420
|
+
summarize: "summarize";
|
|
1418
1421
|
judge: "judge";
|
|
1419
1422
|
vote: "vote";
|
|
1420
1423
|
fuse: "fuse";
|
|
@@ -1469,8 +1472,8 @@ declare const CollabTemplate: z.ZodObject<{
|
|
|
1469
1472
|
}, z.core.$strip>;
|
|
1470
1473
|
finalizer: z.ZodObject<{
|
|
1471
1474
|
type: z.ZodEnum<{
|
|
1472
|
-
summarize: "summarize";
|
|
1473
1475
|
none: "none";
|
|
1476
|
+
summarize: "summarize";
|
|
1474
1477
|
judge: "judge";
|
|
1475
1478
|
vote: "vote";
|
|
1476
1479
|
fuse: "fuse";
|
|
@@ -1530,8 +1533,8 @@ export declare const CollabConfig: z.ZodObject<{
|
|
|
1530
1533
|
}, z.core.$strip>;
|
|
1531
1534
|
finalizer: z.ZodObject<{
|
|
1532
1535
|
type: z.ZodEnum<{
|
|
1533
|
-
summarize: "summarize";
|
|
1534
1536
|
none: "none";
|
|
1537
|
+
summarize: "summarize";
|
|
1535
1538
|
judge: "judge";
|
|
1536
1539
|
vote: "vote";
|
|
1537
1540
|
fuse: "fuse";
|
|
@@ -2008,8 +2011,8 @@ export interface SkillsManifest {
|
|
|
2008
2011
|
* legal hash scheme. */
|
|
2009
2012
|
export declare const SkillsManifestSchema: z.ZodObject<{
|
|
2010
2013
|
skills: z.ZodPrefault<z.ZodArray<z.ZodObject<{
|
|
2011
|
-
name: z.ZodString;
|
|
2012
2014
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
2015
|
+
name: z.ZodString;
|
|
2013
2016
|
notes: z.ZodOptional<z.ZodString>;
|
|
2014
2017
|
description: z.ZodDefault<z.ZodString>;
|
|
2015
2018
|
rosters: z.ZodPrefault<z.ZodArray<z.ZodString>>;
|
|
@@ -2201,6 +2204,10 @@ export declare const PLUGIN_ORIGIN: z.ZodString;
|
|
|
2201
2204
|
/** A full 40-hex git commit SHA — the ONLY pin form the supply-side treats as 钉死 (a branch/tag `version`
|
|
2202
2205
|
* is a moving ref; only a commit pin makes the materialized bytes reproducible). */
|
|
2203
2206
|
export declare const GIT_COMMIT_SHA: z.ZodString;
|
|
2207
|
+
/** The grammar of ONE segment of a plugin id (`<name>@<marketplace>`): a letter or digit first, then letters / digits / `.` / `_` / `-`, case-insensitive.
|
|
2208
|
+
* Re-exported here under its own name; the ONE definition is the zero-import leaf `./plugin-id-segment` — the `<name>` half (`PluginSpec.name`), the
|
|
2209
|
+
* `<marketplace>` half (the marketplace arm of `PluginSource`) and the id reader `readPluginId` (`./plugin-settings`) all read that same object. */
|
|
2210
|
+
export { PLUGIN_ID_SEGMENT_REGEX };
|
|
2204
2211
|
/** WHERE a plugin comes from — two forms (产品拍板: git URL 与 marketplace ref 两形态):
|
|
2205
2212
|
* - `git`: the plugin lives at a git URL directly (repo root = plugin root).
|
|
2206
2213
|
* - `marketplace`: the plugin is `<name>@<marketplace>` in a plugin marketplace; `marketplace` is the
|
|
@@ -2958,8 +2965,8 @@ export declare const DOMAIN_SCHEMAS: {
|
|
|
2958
2965
|
}, z.core.$strip>;
|
|
2959
2966
|
finalizer: z.ZodObject<{
|
|
2960
2967
|
type: z.ZodEnum<{
|
|
2961
|
-
summarize: "summarize";
|
|
2962
2968
|
none: "none";
|
|
2969
|
+
summarize: "summarize";
|
|
2963
2970
|
judge: "judge";
|
|
2964
2971
|
vote: "vote";
|
|
2965
2972
|
fuse: "fuse";
|
|
@@ -3619,8 +3626,8 @@ export declare const EffectiveKey: z.ZodObject<{
|
|
|
3619
3626
|
}, z.core.$strip>], "axis">;
|
|
3620
3627
|
locked: z.ZodBoolean;
|
|
3621
3628
|
enforcement: z.ZodEnum<{
|
|
3622
|
-
gate: "gate";
|
|
3623
3629
|
server: "server";
|
|
3630
|
+
gate: "gate";
|
|
3624
3631
|
resolver: "resolver";
|
|
3625
3632
|
client: "client";
|
|
3626
3633
|
}>;
|