@deepmaid/maid-veil 0.0.0-stage → 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kenyonxu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # 空 patch 层:本包挂载在 preset 声明树(Q3 拍板,2026-10-28 规格 §2);bundle 层仅承载包身份与面板元数据,toggle 对本包为无操作。
2
+ # 空层以顶层 `[]` 承载(修复轮 2 勘正):comment-only 会 parse 为 null,dsh-app-boot parsePatchList 即 throw,整包进 skippedBundles。
3
+ []
package/lib/index.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ //#region src/config.d.ts
2
+ /**
3
+ * maid-veil 配置与 boundary pack 解析(M3d,规格 §3.1-3.3):输入是 preset veil 行
4
+ * config 与 maid-identity resolvePack 产物。校验风格照 maid-voice pack.ts——局部
5
+ * 助手、坏值 warn 跳过、未知键 warn 不静默。
6
+ *
7
+ * 插值面保护:text 含 `{{` 一律整包弃——PromptLayer interpolate 把 {{…}} 当变量
8
+ * 引用,坏引用在装配期直接 throw(铁律 3 反例的编译期拦截)。
9
+ */
10
+ declare const DEFAULT_VEIL_ORDER = 4100;
11
+ interface VeilSelection {
12
+ pack?: string;
13
+ byModel: Record<string, string>;
14
+ order: number;
15
+ }
16
+ interface BoundaryPack {
17
+ id: string;
18
+ name?: string;
19
+ text: string;
20
+ }
21
+ type Warn = (message: string) => void;
22
+ declare function parseVeilConfig(raw: unknown, warn: Warn): VeilSelection;
23
+ declare function parseBoundaryPack(raw: Record<string, unknown> | undefined, where: string, warn: Warn): BoundaryPack | undefined;
24
+ //#endregion
25
+ //#region src/index.d.ts
26
+ declare const name = "maid-veil";
27
+ /**
28
+ * maid-veil(M3d 面纱与边界):boundary pack 装载 + 静态 systemPrompt 段注册。
29
+ * preset 行挂载(agent scope,anchor/gestures 同层)——config 即选择器:
30
+ * pack: 默认集 id;byModel: provider/model 复合键 → 集 id;order: 段位(缺省 4100)。
31
+ *
32
+ * 生命周期(规格 §1):构造期一次读入、会话内零求值(铁律 3);cron 会话与 IM 会话
33
+ * 同享(挂女仆本体非会话类型);maid:veil 不产生 durable 事件——system prompt 本身
34
+ * durable,即铁律 4 的满足形态。
35
+ *
36
+ * 全 fail-open:config 无 pack → 合法零段;maidIdentity 缺席/pack 缺失或坏 →
37
+ * one-shot warn + 零段(绝不炸装配);agentDefaultModel 缺席 → byModel 不可用,
38
+ * 用默认集 + one-shot warn(规格 §7 风险 6 降级路径)。
39
+ */
40
+ declare const inject: string[];
41
+ declare const apply: (ctx: any, config: unknown) => (() => void);
42
+ //#endregion
43
+ export { type BoundaryPack, DEFAULT_VEIL_ORDER, type VeilSelection, apply, inject, name, parseBoundaryPack, parseVeilConfig };
package/lib/index.js ADDED
@@ -0,0 +1,163 @@
1
+ //#region src/config.ts
2
+ /**
3
+ * maid-veil 配置与 boundary pack 解析(M3d,规格 §3.1-3.3):输入是 preset veil 行
4
+ * config 与 maid-identity resolvePack 产物。校验风格照 maid-voice pack.ts——局部
5
+ * 助手、坏值 warn 跳过、未知键 warn 不静默。
6
+ *
7
+ * 插值面保护:text 含 `{{` 一律整包弃——PromptLayer interpolate 把 {{…}} 当变量
8
+ * 引用,坏引用在装配期直接 throw(铁律 3 反例的编译期拦截)。
9
+ */
10
+ const DEFAULT_VEIL_ORDER = 4100;
11
+ const KNOWN_CONFIG_KEYS = /* @__PURE__ */ new Set([
12
+ "pack",
13
+ "byModel",
14
+ "order"
15
+ ]);
16
+ const KNOWN_PACK_KEYS = /* @__PURE__ */ new Set([
17
+ "id",
18
+ "kind",
19
+ "name",
20
+ "text"
21
+ ]);
22
+ function isMapping(value) {
23
+ return typeof value === "object" && value !== null && !Array.isArray(value);
24
+ }
25
+ function parseVeilConfig(raw, warn) {
26
+ const out = {
27
+ byModel: {},
28
+ order: DEFAULT_VEIL_ORDER
29
+ };
30
+ if (raw === void 0) return out;
31
+ if (!isMapping(raw)) {
32
+ warn("maid-veil: config must be a mapping, treated as empty");
33
+ return out;
34
+ }
35
+ for (const key of Object.keys(raw)) if (!KNOWN_CONFIG_KEYS.has(key)) warn(`maid-veil: unknown config field '${key}'`);
36
+ const { pack, byModel, order } = raw;
37
+ if (pack !== void 0) {
38
+ if (typeof pack !== "string" || pack === "") warn("maid-veil: pack must be a non-empty string, ignored");
39
+ else out.pack = pack;
40
+ }
41
+ if (byModel !== void 0) {
42
+ if (!isMapping(byModel)) warn("maid-veil: byModel must be a mapping of model-key → pack-id, ignored");
43
+ else {
44
+ const clean = {};
45
+ for (const [k, v] of Object.entries(byModel)) if (typeof v !== "string" || v === "") warn(`maid-veil: byModel['${k}'] must be a non-empty string, entry ignored`);
46
+ else clean[k] = v;
47
+ out.byModel = clean;
48
+ }
49
+ }
50
+ if (order !== void 0) {
51
+ if (typeof order !== "number" || !Number.isFinite(order)) warn(`maid-veil: order must be a finite number (got ${String(order)}), using default ${DEFAULT_VEIL_ORDER}`);
52
+ else out.order = order;
53
+ }
54
+ return out;
55
+ }
56
+ function parseBoundaryPack(raw, where, warn) {
57
+ if (raw === void 0) return void 0;
58
+ if (!isMapping(raw)) {
59
+ warn(`${where}: pack must be a mapping, skipped`);
60
+ return;
61
+ }
62
+ for (const key of Object.keys(raw)) if (!KNOWN_PACK_KEYS.has(key)) warn(`${where}: unknown field '${key}'`);
63
+ const { id, kind, name, text } = raw;
64
+ if (kind !== "boundary") {
65
+ warn(`${where}: kind must be boundary (got ${String(kind)}), skipped`);
66
+ return;
67
+ }
68
+ if (typeof id !== "string" || id === "") {
69
+ warn(`${where}: requires non-empty id, skipped`);
70
+ return;
71
+ }
72
+ if (typeof text !== "string" || text.trim() === "") {
73
+ warn(`${where}: requires non-empty text, skipped`);
74
+ return;
75
+ }
76
+ if (text.includes("{{")) {
77
+ warn(`${where}: text must not contain '{{' (prompt-variable interpolation face), skipped`);
78
+ return;
79
+ }
80
+ const out = {
81
+ id,
82
+ text
83
+ };
84
+ if (name !== void 0) {
85
+ if (typeof name !== "string" || name === "") warn(`${where}: name must be a non-empty string, ignored`);
86
+ else out.name = name;
87
+ }
88
+ return out;
89
+ }
90
+ //#endregion
91
+ //#region src/index.ts
92
+ const name = "maid-veil";
93
+ /**
94
+ * maid-veil(M3d 面纱与边界):boundary pack 装载 + 静态 systemPrompt 段注册。
95
+ * preset 行挂载(agent scope,anchor/gestures 同层)——config 即选择器:
96
+ * pack: 默认集 id;byModel: provider/model 复合键 → 集 id;order: 段位(缺省 4100)。
97
+ *
98
+ * 生命周期(规格 §1):构造期一次读入、会话内零求值(铁律 3);cron 会话与 IM 会话
99
+ * 同享(挂女仆本体非会话类型);maid:veil 不产生 durable 事件——system prompt 本身
100
+ * durable,即铁律 4 的满足形态。
101
+ *
102
+ * 全 fail-open:config 无 pack → 合法零段;maidIdentity 缺席/pack 缺失或坏 →
103
+ * one-shot warn + 零段(绝不炸装配);agentDefaultModel 缺席 → byModel 不可用,
104
+ * 用默认集 + one-shot warn(规格 §7 风险 6 降级路径)。
105
+ */
106
+ const inject = ["systemPrompt"];
107
+ const apply = (ctx, config) => {
108
+ const logger = ctx.logger?.("maid-veil") ?? console;
109
+ const warn = (message) => {
110
+ logger.warn(message);
111
+ };
112
+ const warned = /* @__PURE__ */ new Set();
113
+ const warnOnce = (key, message) => {
114
+ if (warned.has(key)) return;
115
+ warned.add(key);
116
+ warn(message);
117
+ };
118
+ const selection = parseVeilConfig(config, warn);
119
+ if (selection.pack === void 0) return () => {};
120
+ const identityOf = () => {
121
+ const service = ctx.reflect?.get?.("maidIdentity", false);
122
+ return typeof service?.resolvePack === "function" ? service : void 0;
123
+ };
124
+ const identity = identityOf();
125
+ if (identity === void 0) {
126
+ warnOnce("no-identity", "maid-veil: maidIdentity 服务不在,零段挂载(fail-open)");
127
+ return () => {};
128
+ }
129
+ let packId = selection.pack;
130
+ const model = ctx.reflect?.get?.("agentDefaultModel", false);
131
+ if (model !== void 0 && typeof model.currentSelection === "function") try {
132
+ const current = model.currentSelection();
133
+ const key = `${current.provider}/${current.model}`;
134
+ if (typeof selection.byModel[key] === "string") packId = selection.byModel[key];
135
+ } catch (error) {
136
+ warnOnce("model-throw", `maid-veil: agentDefaultModel.currentSelection 抛错(${error.message}),用默认集`);
137
+ }
138
+ else warnOnce("no-model", "maid-veil: agentDefaultModel 服务不在,byModel 不可用,用默认集");
139
+ let raw;
140
+ try {
141
+ raw = identity.resolvePack(packId);
142
+ } catch (error) {
143
+ warnOnce(`resolve-throw:${packId}`, `maid-veil: resolvePack('${packId}') 抛错(${error.message}),零段挂载`);
144
+ return () => {};
145
+ }
146
+ const pack = parseBoundaryPack(raw, `maid-veil: pack '${packId}'`, warn);
147
+ if (pack === void 0) {
148
+ warnOnce(`bad-pack:${packId}`, `maid-veil: boundary pack '${packId}' 缺失或未过校验,零段挂载`);
149
+ return () => {};
150
+ }
151
+ const dispose = ctx.systemPrompt.section({
152
+ name: "maid:veil",
153
+ order: selection.order,
154
+ text: pack.text
155
+ });
156
+ return () => {
157
+ try {
158
+ dispose();
159
+ } catch {}
160
+ };
161
+ };
162
+ //#endregion
163
+ export { DEFAULT_VEIL_ORDER, apply, inject, name, parseBoundaryPack, parseVeilConfig };
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@deepmaid/maid-veil",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "lib",
16
+ "cordis.patch.yml"
17
+ ],
18
+ "dsh": {
19
+ "engines": {
20
+ "dsh": ">=0.2.1-rc.2 <0.3"
21
+ },
22
+ "bundle": {
23
+ "patch": "./cordis.patch.yml"
24
+ },
25
+ "meta": {
26
+ "title": "Maid Veil",
27
+ "description": "面纱与边界 seam:boundary pack 装载 + 静态 maid:veil 段(按模型映射;产品默认 disabled,启用=删 disabled+真实集)。关闭=maid:veil 边界段不注入(即默认关闭形态,L1/L2 立场失为无声明)。"
28
+ }
29
+ },
30
+ "devDependencies": {
31
+ "tsdown": "0.22.14",
32
+ "typescript": "6.0.3"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "tsdown"
39
+ }
6
40
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.