@tekmidian/pai 0.5.6 → 0.6.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/ARCHITECTURE.md +72 -1
- package/README.md +107 -3
- package/dist/{auto-route-BG6I_4B1.mjs → auto-route-C-DrW6BL.mjs} +3 -3
- package/dist/{auto-route-BG6I_4B1.mjs.map → auto-route-C-DrW6BL.mjs.map} +1 -1
- package/dist/cli/index.mjs +1897 -1569
- package/dist/cli/index.mjs.map +1 -1
- package/dist/clusters-JIDQW65f.mjs +201 -0
- package/dist/clusters-JIDQW65f.mjs.map +1 -0
- package/dist/{config-Cf92lGX_.mjs → config-BuhHWyOK.mjs} +21 -6
- package/dist/config-BuhHWyOK.mjs.map +1 -0
- package/dist/daemon/index.mjs +12 -9
- package/dist/daemon/index.mjs.map +1 -1
- package/dist/{daemon-D9evGlgR.mjs → daemon-D3hYb5_C.mjs} +670 -219
- package/dist/daemon-D3hYb5_C.mjs.map +1 -0
- package/dist/daemon-mcp/index.mjs +4597 -4
- package/dist/daemon-mcp/index.mjs.map +1 -1
- package/dist/{db-4lSqLFb8.mjs → db-BtuN768f.mjs} +9 -2
- package/dist/db-BtuN768f.mjs.map +1 -0
- package/dist/db-DdUperSl.mjs +110 -0
- package/dist/db-DdUperSl.mjs.map +1 -0
- package/dist/{detect-BU3Nx_2L.mjs → detect-CdaA48EI.mjs} +1 -1
- package/dist/{detect-BU3Nx_2L.mjs.map → detect-CdaA48EI.mjs.map} +1 -1
- package/dist/{detector-Bp-2SM3x.mjs → detector-jGBuYQJM.mjs} +2 -2
- package/dist/{detector-Bp-2SM3x.mjs.map → detector-jGBuYQJM.mjs.map} +1 -1
- package/dist/{factory-Bzcy70G9.mjs → factory-Ygqe_bVZ.mjs} +7 -5
- package/dist/{factory-Bzcy70G9.mjs.map → factory-Ygqe_bVZ.mjs.map} +1 -1
- package/dist/helpers-BEST-4Gx.mjs +420 -0
- package/dist/helpers-BEST-4Gx.mjs.map +1 -0
- package/dist/hooks/capture-all-events.mjs +19 -4
- package/dist/hooks/capture-all-events.mjs.map +4 -4
- package/dist/hooks/capture-session-summary.mjs +38 -0
- package/dist/hooks/capture-session-summary.mjs.map +3 -3
- package/dist/hooks/cleanup-session-files.mjs +6 -12
- package/dist/hooks/cleanup-session-files.mjs.map +4 -4
- package/dist/hooks/context-compression-hook.mjs +105 -111
- package/dist/hooks/context-compression-hook.mjs.map +4 -4
- package/dist/hooks/initialize-session.mjs +26 -17
- package/dist/hooks/initialize-session.mjs.map +4 -4
- package/dist/hooks/inject-observations.mjs +220 -0
- package/dist/hooks/inject-observations.mjs.map +7 -0
- package/dist/hooks/load-core-context.mjs +18 -2
- package/dist/hooks/load-core-context.mjs.map +4 -4
- package/dist/hooks/load-project-context.mjs +102 -97
- package/dist/hooks/load-project-context.mjs.map +4 -4
- package/dist/hooks/observe.mjs +354 -0
- package/dist/hooks/observe.mjs.map +7 -0
- package/dist/hooks/stop-hook.mjs +174 -90
- package/dist/hooks/stop-hook.mjs.map +4 -4
- package/dist/hooks/sync-todo-to-md.mjs +31 -33
- package/dist/hooks/sync-todo-to-md.mjs.map +4 -4
- package/dist/index.d.mts +32 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -9
- package/dist/indexer-D53l5d1U.mjs +1 -0
- package/dist/{indexer-backend-CIMXedqk.mjs → indexer-backend-jcJFsmB4.mjs} +37 -127
- package/dist/indexer-backend-jcJFsmB4.mjs.map +1 -0
- package/dist/{ipc-client-Bjg_a1dc.mjs → ipc-client-CoyUHPod.mjs} +2 -7
- package/dist/{ipc-client-Bjg_a1dc.mjs.map → ipc-client-CoyUHPod.mjs.map} +1 -1
- package/dist/latent-ideas-bTJo6Omd.mjs +191 -0
- package/dist/latent-ideas-bTJo6Omd.mjs.map +1 -0
- package/dist/neighborhood-BYYbEkUJ.mjs +135 -0
- package/dist/neighborhood-BYYbEkUJ.mjs.map +1 -0
- package/dist/note-context-BK24bX8Y.mjs +126 -0
- package/dist/note-context-BK24bX8Y.mjs.map +1 -0
- package/dist/postgres-CKf-EDtS.mjs +846 -0
- package/dist/postgres-CKf-EDtS.mjs.map +1 -0
- package/dist/{reranker-D7bRAHi6.mjs → reranker-CMNZcfVx.mjs} +1 -1
- package/dist/{reranker-D7bRAHi6.mjs.map → reranker-CMNZcfVx.mjs.map} +1 -1
- package/dist/{search-_oHfguA5.mjs → search-DC1qhkKn.mjs} +2 -58
- package/dist/search-DC1qhkKn.mjs.map +1 -0
- package/dist/{sqlite-WWBq7_2C.mjs → sqlite-l-s9xPjY.mjs} +160 -3
- package/dist/sqlite-l-s9xPjY.mjs.map +1 -0
- package/dist/state-C6_vqz7w.mjs +102 -0
- package/dist/state-C6_vqz7w.mjs.map +1 -0
- package/dist/stop-words-BaMEGVeY.mjs +326 -0
- package/dist/stop-words-BaMEGVeY.mjs.map +1 -0
- package/dist/{indexer-CMPOiY1r.mjs → sync-BOsnEj2-.mjs} +14 -216
- package/dist/sync-BOsnEj2-.mjs.map +1 -0
- package/dist/themes-BvYF0W8T.mjs +148 -0
- package/dist/themes-BvYF0W8T.mjs.map +1 -0
- package/dist/{tools-DV_lsiCc.mjs → tools-DcaJlYDN.mjs} +162 -273
- package/dist/tools-DcaJlYDN.mjs.map +1 -0
- package/dist/trace-CRx9lPuc.mjs +137 -0
- package/dist/trace-CRx9lPuc.mjs.map +1 -0
- package/dist/{vault-indexer-DXWs9pDn.mjs → vault-indexer-Bi2cRmn7.mjs} +174 -138
- package/dist/vault-indexer-Bi2cRmn7.mjs.map +1 -0
- package/dist/zettelkasten-cdajbnPr.mjs +708 -0
- package/dist/zettelkasten-cdajbnPr.mjs.map +1 -0
- package/package.json +1 -2
- package/src/hooks/ts/capture-all-events.ts +6 -0
- package/src/hooks/ts/lib/project-utils/index.ts +50 -0
- package/src/hooks/ts/lib/project-utils/notify.ts +75 -0
- package/src/hooks/ts/lib/project-utils/paths.ts +218 -0
- package/src/hooks/ts/lib/project-utils/session-notes.ts +363 -0
- package/src/hooks/ts/lib/project-utils/todo.ts +178 -0
- package/src/hooks/ts/lib/project-utils/tokens.ts +39 -0
- package/src/hooks/ts/lib/project-utils.ts +40 -999
- package/src/hooks/ts/post-tool-use/observe.ts +327 -0
- package/src/hooks/ts/pre-compact/context-compression-hook.ts +6 -0
- package/src/hooks/ts/session-end/capture-session-summary.ts +41 -0
- package/src/hooks/ts/session-start/initialize-session.ts +7 -1
- package/src/hooks/ts/session-start/inject-observations.ts +254 -0
- package/src/hooks/ts/session-start/load-core-context.ts +7 -0
- package/src/hooks/ts/session-start/load-project-context.ts +8 -1
- package/src/hooks/ts/stop/stop-hook.ts +28 -0
- package/templates/claude-md.template.md +7 -74
- package/templates/skills/user/.gitkeep +0 -0
- package/dist/chunker-CbnBe0s0.mjs +0 -191
- package/dist/chunker-CbnBe0s0.mjs.map +0 -1
- package/dist/config-Cf92lGX_.mjs.map +0 -1
- package/dist/daemon-D9evGlgR.mjs.map +0 -1
- package/dist/db-4lSqLFb8.mjs.map +0 -1
- package/dist/db-Dp8VXIMR.mjs +0 -212
- package/dist/db-Dp8VXIMR.mjs.map +0 -1
- package/dist/indexer-CMPOiY1r.mjs.map +0 -1
- package/dist/indexer-backend-CIMXedqk.mjs.map +0 -1
- package/dist/mcp/index.d.mts +0 -1
- package/dist/mcp/index.mjs +0 -500
- package/dist/mcp/index.mjs.map +0 -1
- package/dist/postgres-FXrHDPcE.mjs +0 -358
- package/dist/postgres-FXrHDPcE.mjs.map +0 -1
- package/dist/schemas-BFIgGntb.mjs +0 -3405
- package/dist/schemas-BFIgGntb.mjs.map +0 -1
- package/dist/search-_oHfguA5.mjs.map +0 -1
- package/dist/sqlite-WWBq7_2C.mjs.map +0 -1
- package/dist/tools-DV_lsiCc.mjs.map +0 -1
- package/dist/vault-indexer-DXWs9pDn.mjs.map +0 -1
- package/dist/zettelkasten-e-a4rW_6.mjs +0 -901
- package/dist/zettelkasten-e-a4rW_6.mjs.map +0 -1
- package/templates/README.md +0 -181
- package/templates/skills/createskill-skill.template.md +0 -78
- package/templates/skills/history-system.template.md +0 -371
- package/templates/skills/hook-system.template.md +0 -913
- package/templates/skills/sessions-skill.template.md +0 -102
- package/templates/skills/skill-system.template.md +0 -214
- package/templates/skills/terminal-tabs.template.md +0 -120
- package/templates/templates.md +0 -20
|
@@ -1,10 +1,4550 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { o as loadConfig } from "../config-
|
|
4
|
-
import { t as PaiClient } from "../ipc-client-Bjg_a1dc.mjs";
|
|
2
|
+
import { t as PaiClient } from "../ipc-client-CoyUHPod.mjs";
|
|
3
|
+
import { o as loadConfig } from "../config-BuhHWyOK.mjs";
|
|
5
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
6
|
|
|
7
|
+
//#region node_modules/zod/v4/core/core.js
|
|
8
|
+
/** A special constant with type `never` */
|
|
9
|
+
const NEVER = Object.freeze({ status: "aborted" });
|
|
10
|
+
function $constructor(name, initializer, params) {
|
|
11
|
+
function init(inst, def) {
|
|
12
|
+
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
13
|
+
value: {
|
|
14
|
+
def,
|
|
15
|
+
constr: _,
|
|
16
|
+
traits: /* @__PURE__ */ new Set()
|
|
17
|
+
},
|
|
18
|
+
enumerable: false
|
|
19
|
+
});
|
|
20
|
+
if (inst._zod.traits.has(name)) return;
|
|
21
|
+
inst._zod.traits.add(name);
|
|
22
|
+
initializer(inst, def);
|
|
23
|
+
const proto = _.prototype;
|
|
24
|
+
const keys = Object.keys(proto);
|
|
25
|
+
for (let i = 0; i < keys.length; i++) {
|
|
26
|
+
const k = keys[i];
|
|
27
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const Parent = params?.Parent ?? Object;
|
|
31
|
+
class Definition extends Parent {}
|
|
32
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
33
|
+
function _(def) {
|
|
34
|
+
var _a;
|
|
35
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
36
|
+
init(inst, def);
|
|
37
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
38
|
+
for (const fn of inst._zod.deferred) fn();
|
|
39
|
+
return inst;
|
|
40
|
+
}
|
|
41
|
+
Object.defineProperty(_, "init", { value: init });
|
|
42
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
43
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
44
|
+
return inst?._zod?.traits?.has(name);
|
|
45
|
+
} });
|
|
46
|
+
Object.defineProperty(_, "name", { value: name });
|
|
47
|
+
return _;
|
|
48
|
+
}
|
|
49
|
+
var $ZodAsyncError = class extends Error {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var $ZodEncodeError = class extends Error {
|
|
55
|
+
constructor(name) {
|
|
56
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
57
|
+
this.name = "ZodEncodeError";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const globalConfig = {};
|
|
61
|
+
function config(newConfig) {
|
|
62
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
63
|
+
return globalConfig;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region node_modules/zod/v4/core/util.js
|
|
68
|
+
function getEnumValues(entries) {
|
|
69
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
70
|
+
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
71
|
+
}
|
|
72
|
+
function jsonStringifyReplacer(_, value) {
|
|
73
|
+
if (typeof value === "bigint") return value.toString();
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
function cached(getter) {
|
|
77
|
+
return { get value() {
|
|
78
|
+
{
|
|
79
|
+
const value = getter();
|
|
80
|
+
Object.defineProperty(this, "value", { value });
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
throw new Error("cached value already set");
|
|
84
|
+
} };
|
|
85
|
+
}
|
|
86
|
+
function nullish(input) {
|
|
87
|
+
return input === null || input === void 0;
|
|
88
|
+
}
|
|
89
|
+
function cleanRegex(source) {
|
|
90
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
91
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
92
|
+
return source.slice(start, end);
|
|
93
|
+
}
|
|
94
|
+
function floatSafeRemainder(val, step) {
|
|
95
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
96
|
+
const stepString = step.toString();
|
|
97
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
98
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
99
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
100
|
+
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
101
|
+
}
|
|
102
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
103
|
+
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
104
|
+
}
|
|
105
|
+
const EVALUATING = Symbol("evaluating");
|
|
106
|
+
function defineLazy(object, key, getter) {
|
|
107
|
+
let value = void 0;
|
|
108
|
+
Object.defineProperty(object, key, {
|
|
109
|
+
get() {
|
|
110
|
+
if (value === EVALUATING) return;
|
|
111
|
+
if (value === void 0) {
|
|
112
|
+
value = EVALUATING;
|
|
113
|
+
value = getter();
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
},
|
|
117
|
+
set(v) {
|
|
118
|
+
Object.defineProperty(object, key, { value: v });
|
|
119
|
+
},
|
|
120
|
+
configurable: true
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function mergeDefs(...defs) {
|
|
124
|
+
const mergedDescriptors = {};
|
|
125
|
+
for (const def of defs) {
|
|
126
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
127
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
128
|
+
}
|
|
129
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
130
|
+
}
|
|
131
|
+
function slugify(input) {
|
|
132
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
133
|
+
}
|
|
134
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
135
|
+
function isObject(data) {
|
|
136
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
137
|
+
}
|
|
138
|
+
const allowsEval = cached(() => {
|
|
139
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
140
|
+
try {
|
|
141
|
+
new Function("");
|
|
142
|
+
return true;
|
|
143
|
+
} catch (_) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
function isPlainObject(o) {
|
|
148
|
+
if (isObject(o) === false) return false;
|
|
149
|
+
const ctor = o.constructor;
|
|
150
|
+
if (ctor === void 0) return true;
|
|
151
|
+
if (typeof ctor !== "function") return true;
|
|
152
|
+
const prot = ctor.prototype;
|
|
153
|
+
if (isObject(prot) === false) return false;
|
|
154
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
function shallowClone(o) {
|
|
158
|
+
if (isPlainObject(o)) return { ...o };
|
|
159
|
+
if (Array.isArray(o)) return [...o];
|
|
160
|
+
return o;
|
|
161
|
+
}
|
|
162
|
+
const propertyKeyTypes = new Set([
|
|
163
|
+
"string",
|
|
164
|
+
"number",
|
|
165
|
+
"symbol"
|
|
166
|
+
]);
|
|
167
|
+
function escapeRegex(str) {
|
|
168
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
169
|
+
}
|
|
170
|
+
function clone(inst, def, params) {
|
|
171
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
172
|
+
if (!def || params?.parent) cl._zod.parent = inst;
|
|
173
|
+
return cl;
|
|
174
|
+
}
|
|
175
|
+
function normalizeParams(_params) {
|
|
176
|
+
const params = _params;
|
|
177
|
+
if (!params) return {};
|
|
178
|
+
if (typeof params === "string") return { error: () => params };
|
|
179
|
+
if (params?.message !== void 0) {
|
|
180
|
+
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
181
|
+
params.error = params.message;
|
|
182
|
+
}
|
|
183
|
+
delete params.message;
|
|
184
|
+
if (typeof params.error === "string") return {
|
|
185
|
+
...params,
|
|
186
|
+
error: () => params.error
|
|
187
|
+
};
|
|
188
|
+
return params;
|
|
189
|
+
}
|
|
190
|
+
const NUMBER_FORMAT_RANGES = {
|
|
191
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
192
|
+
int32: [-2147483648, 2147483647],
|
|
193
|
+
uint32: [0, 4294967295],
|
|
194
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
195
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
196
|
+
};
|
|
197
|
+
function aborted(x, startIndex = 0) {
|
|
198
|
+
if (x.aborted === true) return true;
|
|
199
|
+
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
function prefixIssues(path, issues) {
|
|
203
|
+
return issues.map((iss) => {
|
|
204
|
+
var _a;
|
|
205
|
+
(_a = iss).path ?? (_a.path = []);
|
|
206
|
+
iss.path.unshift(path);
|
|
207
|
+
return iss;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function unwrapMessage(message) {
|
|
211
|
+
return typeof message === "string" ? message : message?.message;
|
|
212
|
+
}
|
|
213
|
+
function finalizeIssue(iss, ctx, config) {
|
|
214
|
+
const full = {
|
|
215
|
+
...iss,
|
|
216
|
+
path: iss.path ?? []
|
|
217
|
+
};
|
|
218
|
+
if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
219
|
+
delete full.inst;
|
|
220
|
+
delete full.continue;
|
|
221
|
+
if (!ctx?.reportInput) delete full.input;
|
|
222
|
+
return full;
|
|
223
|
+
}
|
|
224
|
+
function getLengthableOrigin(input) {
|
|
225
|
+
if (Array.isArray(input)) return "array";
|
|
226
|
+
if (typeof input === "string") return "string";
|
|
227
|
+
return "unknown";
|
|
228
|
+
}
|
|
229
|
+
function issue(...args) {
|
|
230
|
+
const [iss, input, inst] = args;
|
|
231
|
+
if (typeof iss === "string") return {
|
|
232
|
+
message: iss,
|
|
233
|
+
code: "custom",
|
|
234
|
+
input,
|
|
235
|
+
inst
|
|
236
|
+
};
|
|
237
|
+
return { ...iss };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region node_modules/zod/v4/core/errors.js
|
|
242
|
+
const initializer$1 = (inst, def) => {
|
|
243
|
+
inst.name = "$ZodError";
|
|
244
|
+
Object.defineProperty(inst, "_zod", {
|
|
245
|
+
value: inst._zod,
|
|
246
|
+
enumerable: false
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(inst, "issues", {
|
|
249
|
+
value: def,
|
|
250
|
+
enumerable: false
|
|
251
|
+
});
|
|
252
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
253
|
+
Object.defineProperty(inst, "toString", {
|
|
254
|
+
value: () => inst.message,
|
|
255
|
+
enumerable: false
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
259
|
+
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
260
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
261
|
+
const fieldErrors = {};
|
|
262
|
+
const formErrors = [];
|
|
263
|
+
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
264
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
265
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
266
|
+
} else formErrors.push(mapper(sub));
|
|
267
|
+
return {
|
|
268
|
+
formErrors,
|
|
269
|
+
fieldErrors
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
273
|
+
const fieldErrors = { _errors: [] };
|
|
274
|
+
const processError = (error) => {
|
|
275
|
+
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
|
|
276
|
+
else if (issue.code === "invalid_key") processError({ issues: issue.issues });
|
|
277
|
+
else if (issue.code === "invalid_element") processError({ issues: issue.issues });
|
|
278
|
+
else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
279
|
+
else {
|
|
280
|
+
let curr = fieldErrors;
|
|
281
|
+
let i = 0;
|
|
282
|
+
while (i < issue.path.length) {
|
|
283
|
+
const el = issue.path[i];
|
|
284
|
+
if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
|
|
285
|
+
else {
|
|
286
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
287
|
+
curr[el]._errors.push(mapper(issue));
|
|
288
|
+
}
|
|
289
|
+
curr = curr[el];
|
|
290
|
+
i++;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
processError(error);
|
|
295
|
+
return fieldErrors;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region node_modules/zod/v4/core/parse.js
|
|
300
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
301
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
302
|
+
const result = schema._zod.run({
|
|
303
|
+
value,
|
|
304
|
+
issues: []
|
|
305
|
+
}, ctx);
|
|
306
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
307
|
+
if (result.issues.length) {
|
|
308
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
309
|
+
captureStackTrace(e, _params?.callee);
|
|
310
|
+
throw e;
|
|
311
|
+
}
|
|
312
|
+
return result.value;
|
|
313
|
+
};
|
|
314
|
+
const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
|
|
315
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
316
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
317
|
+
let result = schema._zod.run({
|
|
318
|
+
value,
|
|
319
|
+
issues: []
|
|
320
|
+
}, ctx);
|
|
321
|
+
if (result instanceof Promise) result = await result;
|
|
322
|
+
if (result.issues.length) {
|
|
323
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
324
|
+
captureStackTrace(e, params?.callee);
|
|
325
|
+
throw e;
|
|
326
|
+
}
|
|
327
|
+
return result.value;
|
|
328
|
+
};
|
|
329
|
+
const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
330
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
331
|
+
const ctx = _ctx ? {
|
|
332
|
+
..._ctx,
|
|
333
|
+
async: false
|
|
334
|
+
} : { async: false };
|
|
335
|
+
const result = schema._zod.run({
|
|
336
|
+
value,
|
|
337
|
+
issues: []
|
|
338
|
+
}, ctx);
|
|
339
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
340
|
+
return result.issues.length ? {
|
|
341
|
+
success: false,
|
|
342
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
343
|
+
} : {
|
|
344
|
+
success: true,
|
|
345
|
+
data: result.value
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
349
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
350
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
351
|
+
let result = schema._zod.run({
|
|
352
|
+
value,
|
|
353
|
+
issues: []
|
|
354
|
+
}, ctx);
|
|
355
|
+
if (result instanceof Promise) result = await result;
|
|
356
|
+
return result.issues.length ? {
|
|
357
|
+
success: false,
|
|
358
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
359
|
+
} : {
|
|
360
|
+
success: true,
|
|
361
|
+
data: result.value
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
365
|
+
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
366
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
367
|
+
return _parse(_Err)(schema, value, ctx);
|
|
368
|
+
};
|
|
369
|
+
const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
|
|
370
|
+
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
371
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
372
|
+
};
|
|
373
|
+
const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
|
|
374
|
+
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
375
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
376
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
377
|
+
};
|
|
378
|
+
const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
379
|
+
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
380
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
381
|
+
};
|
|
382
|
+
const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
383
|
+
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
384
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
385
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
386
|
+
};
|
|
387
|
+
const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
388
|
+
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
389
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
390
|
+
};
|
|
391
|
+
const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
392
|
+
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
393
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
394
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
395
|
+
};
|
|
396
|
+
const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
397
|
+
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
398
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
399
|
+
};
|
|
400
|
+
const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
401
|
+
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region node_modules/zod/v4/core/regexes.js
|
|
404
|
+
const cuid = /^[cC][^\s-]{8,}$/;
|
|
405
|
+
const cuid2 = /^[0-9a-z]+$/;
|
|
406
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
407
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
|
408
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
409
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
410
|
+
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
411
|
+
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
412
|
+
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
413
|
+
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
414
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
415
|
+
*
|
|
416
|
+
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
417
|
+
const uuid = (version) => {
|
|
418
|
+
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
419
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
420
|
+
};
|
|
421
|
+
/** Practical email validation */
|
|
422
|
+
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
423
|
+
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
424
|
+
function emoji() {
|
|
425
|
+
return new RegExp(_emoji$1, "u");
|
|
426
|
+
}
|
|
427
|
+
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
428
|
+
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
429
|
+
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
430
|
+
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
431
|
+
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
432
|
+
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
433
|
+
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
434
|
+
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
435
|
+
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
436
|
+
function timeSource(args) {
|
|
437
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
438
|
+
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
439
|
+
}
|
|
440
|
+
function time$1(args) {
|
|
441
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
442
|
+
}
|
|
443
|
+
function datetime$1(args) {
|
|
444
|
+
const time = timeSource({ precision: args.precision });
|
|
445
|
+
const opts = ["Z"];
|
|
446
|
+
if (args.local) opts.push("");
|
|
447
|
+
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
448
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
449
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
450
|
+
}
|
|
451
|
+
const string$1 = (params) => {
|
|
452
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
453
|
+
return new RegExp(`^${regex}$`);
|
|
454
|
+
};
|
|
455
|
+
const integer = /^-?\d+$/;
|
|
456
|
+
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
457
|
+
const boolean$1 = /^(?:true|false)$/i;
|
|
458
|
+
const lowercase = /^[^A-Z]*$/;
|
|
459
|
+
const uppercase = /^[^a-z]*$/;
|
|
460
|
+
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region node_modules/zod/v4/core/checks.js
|
|
463
|
+
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
464
|
+
var _a;
|
|
465
|
+
inst._zod ?? (inst._zod = {});
|
|
466
|
+
inst._zod.def = def;
|
|
467
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
468
|
+
});
|
|
469
|
+
const numericOriginMap = {
|
|
470
|
+
number: "number",
|
|
471
|
+
bigint: "bigint",
|
|
472
|
+
object: "date"
|
|
473
|
+
};
|
|
474
|
+
const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
475
|
+
$ZodCheck.init(inst, def);
|
|
476
|
+
const origin = numericOriginMap[typeof def.value];
|
|
477
|
+
inst._zod.onattach.push((inst) => {
|
|
478
|
+
const bag = inst._zod.bag;
|
|
479
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
480
|
+
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
481
|
+
else bag.exclusiveMaximum = def.value;
|
|
482
|
+
});
|
|
483
|
+
inst._zod.check = (payload) => {
|
|
484
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
485
|
+
payload.issues.push({
|
|
486
|
+
origin,
|
|
487
|
+
code: "too_big",
|
|
488
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
489
|
+
input: payload.value,
|
|
490
|
+
inclusive: def.inclusive,
|
|
491
|
+
inst,
|
|
492
|
+
continue: !def.abort
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
});
|
|
496
|
+
const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
497
|
+
$ZodCheck.init(inst, def);
|
|
498
|
+
const origin = numericOriginMap[typeof def.value];
|
|
499
|
+
inst._zod.onattach.push((inst) => {
|
|
500
|
+
const bag = inst._zod.bag;
|
|
501
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
502
|
+
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
503
|
+
else bag.exclusiveMinimum = def.value;
|
|
504
|
+
});
|
|
505
|
+
inst._zod.check = (payload) => {
|
|
506
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
507
|
+
payload.issues.push({
|
|
508
|
+
origin,
|
|
509
|
+
code: "too_small",
|
|
510
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
511
|
+
input: payload.value,
|
|
512
|
+
inclusive: def.inclusive,
|
|
513
|
+
inst,
|
|
514
|
+
continue: !def.abort
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
});
|
|
518
|
+
const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
519
|
+
$ZodCheck.init(inst, def);
|
|
520
|
+
inst._zod.onattach.push((inst) => {
|
|
521
|
+
var _a;
|
|
522
|
+
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
523
|
+
});
|
|
524
|
+
inst._zod.check = (payload) => {
|
|
525
|
+
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
526
|
+
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
527
|
+
payload.issues.push({
|
|
528
|
+
origin: typeof payload.value,
|
|
529
|
+
code: "not_multiple_of",
|
|
530
|
+
divisor: def.value,
|
|
531
|
+
input: payload.value,
|
|
532
|
+
inst,
|
|
533
|
+
continue: !def.abort
|
|
534
|
+
});
|
|
535
|
+
};
|
|
536
|
+
});
|
|
537
|
+
const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
538
|
+
$ZodCheck.init(inst, def);
|
|
539
|
+
def.format = def.format || "float64";
|
|
540
|
+
const isInt = def.format?.includes("int");
|
|
541
|
+
const origin = isInt ? "int" : "number";
|
|
542
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
543
|
+
inst._zod.onattach.push((inst) => {
|
|
544
|
+
const bag = inst._zod.bag;
|
|
545
|
+
bag.format = def.format;
|
|
546
|
+
bag.minimum = minimum;
|
|
547
|
+
bag.maximum = maximum;
|
|
548
|
+
if (isInt) bag.pattern = integer;
|
|
549
|
+
});
|
|
550
|
+
inst._zod.check = (payload) => {
|
|
551
|
+
const input = payload.value;
|
|
552
|
+
if (isInt) {
|
|
553
|
+
if (!Number.isInteger(input)) {
|
|
554
|
+
payload.issues.push({
|
|
555
|
+
expected: origin,
|
|
556
|
+
format: def.format,
|
|
557
|
+
code: "invalid_type",
|
|
558
|
+
continue: false,
|
|
559
|
+
input,
|
|
560
|
+
inst
|
|
561
|
+
});
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (!Number.isSafeInteger(input)) {
|
|
565
|
+
if (input > 0) payload.issues.push({
|
|
566
|
+
input,
|
|
567
|
+
code: "too_big",
|
|
568
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
569
|
+
note: "Integers must be within the safe integer range.",
|
|
570
|
+
inst,
|
|
571
|
+
origin,
|
|
572
|
+
inclusive: true,
|
|
573
|
+
continue: !def.abort
|
|
574
|
+
});
|
|
575
|
+
else payload.issues.push({
|
|
576
|
+
input,
|
|
577
|
+
code: "too_small",
|
|
578
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
579
|
+
note: "Integers must be within the safe integer range.",
|
|
580
|
+
inst,
|
|
581
|
+
origin,
|
|
582
|
+
inclusive: true,
|
|
583
|
+
continue: !def.abort
|
|
584
|
+
});
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (input < minimum) payload.issues.push({
|
|
589
|
+
origin: "number",
|
|
590
|
+
input,
|
|
591
|
+
code: "too_small",
|
|
592
|
+
minimum,
|
|
593
|
+
inclusive: true,
|
|
594
|
+
inst,
|
|
595
|
+
continue: !def.abort
|
|
596
|
+
});
|
|
597
|
+
if (input > maximum) payload.issues.push({
|
|
598
|
+
origin: "number",
|
|
599
|
+
input,
|
|
600
|
+
code: "too_big",
|
|
601
|
+
maximum,
|
|
602
|
+
inclusive: true,
|
|
603
|
+
inst,
|
|
604
|
+
continue: !def.abort
|
|
605
|
+
});
|
|
606
|
+
};
|
|
607
|
+
});
|
|
608
|
+
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
609
|
+
var _a;
|
|
610
|
+
$ZodCheck.init(inst, def);
|
|
611
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
612
|
+
const val = payload.value;
|
|
613
|
+
return !nullish(val) && val.length !== void 0;
|
|
614
|
+
});
|
|
615
|
+
inst._zod.onattach.push((inst) => {
|
|
616
|
+
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
617
|
+
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
618
|
+
});
|
|
619
|
+
inst._zod.check = (payload) => {
|
|
620
|
+
const input = payload.value;
|
|
621
|
+
if (input.length <= def.maximum) return;
|
|
622
|
+
const origin = getLengthableOrigin(input);
|
|
623
|
+
payload.issues.push({
|
|
624
|
+
origin,
|
|
625
|
+
code: "too_big",
|
|
626
|
+
maximum: def.maximum,
|
|
627
|
+
inclusive: true,
|
|
628
|
+
input,
|
|
629
|
+
inst,
|
|
630
|
+
continue: !def.abort
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
635
|
+
var _a;
|
|
636
|
+
$ZodCheck.init(inst, def);
|
|
637
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
638
|
+
const val = payload.value;
|
|
639
|
+
return !nullish(val) && val.length !== void 0;
|
|
640
|
+
});
|
|
641
|
+
inst._zod.onattach.push((inst) => {
|
|
642
|
+
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
643
|
+
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
644
|
+
});
|
|
645
|
+
inst._zod.check = (payload) => {
|
|
646
|
+
const input = payload.value;
|
|
647
|
+
if (input.length >= def.minimum) return;
|
|
648
|
+
const origin = getLengthableOrigin(input);
|
|
649
|
+
payload.issues.push({
|
|
650
|
+
origin,
|
|
651
|
+
code: "too_small",
|
|
652
|
+
minimum: def.minimum,
|
|
653
|
+
inclusive: true,
|
|
654
|
+
input,
|
|
655
|
+
inst,
|
|
656
|
+
continue: !def.abort
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
});
|
|
660
|
+
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
661
|
+
var _a;
|
|
662
|
+
$ZodCheck.init(inst, def);
|
|
663
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
664
|
+
const val = payload.value;
|
|
665
|
+
return !nullish(val) && val.length !== void 0;
|
|
666
|
+
});
|
|
667
|
+
inst._zod.onattach.push((inst) => {
|
|
668
|
+
const bag = inst._zod.bag;
|
|
669
|
+
bag.minimum = def.length;
|
|
670
|
+
bag.maximum = def.length;
|
|
671
|
+
bag.length = def.length;
|
|
672
|
+
});
|
|
673
|
+
inst._zod.check = (payload) => {
|
|
674
|
+
const input = payload.value;
|
|
675
|
+
const length = input.length;
|
|
676
|
+
if (length === def.length) return;
|
|
677
|
+
const origin = getLengthableOrigin(input);
|
|
678
|
+
const tooBig = length > def.length;
|
|
679
|
+
payload.issues.push({
|
|
680
|
+
origin,
|
|
681
|
+
...tooBig ? {
|
|
682
|
+
code: "too_big",
|
|
683
|
+
maximum: def.length
|
|
684
|
+
} : {
|
|
685
|
+
code: "too_small",
|
|
686
|
+
minimum: def.length
|
|
687
|
+
},
|
|
688
|
+
inclusive: true,
|
|
689
|
+
exact: true,
|
|
690
|
+
input: payload.value,
|
|
691
|
+
inst,
|
|
692
|
+
continue: !def.abort
|
|
693
|
+
});
|
|
694
|
+
};
|
|
695
|
+
});
|
|
696
|
+
const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
697
|
+
var _a, _b;
|
|
698
|
+
$ZodCheck.init(inst, def);
|
|
699
|
+
inst._zod.onattach.push((inst) => {
|
|
700
|
+
const bag = inst._zod.bag;
|
|
701
|
+
bag.format = def.format;
|
|
702
|
+
if (def.pattern) {
|
|
703
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
704
|
+
bag.patterns.add(def.pattern);
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
708
|
+
def.pattern.lastIndex = 0;
|
|
709
|
+
if (def.pattern.test(payload.value)) return;
|
|
710
|
+
payload.issues.push({
|
|
711
|
+
origin: "string",
|
|
712
|
+
code: "invalid_format",
|
|
713
|
+
format: def.format,
|
|
714
|
+
input: payload.value,
|
|
715
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
716
|
+
inst,
|
|
717
|
+
continue: !def.abort
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
721
|
+
});
|
|
722
|
+
const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
723
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
724
|
+
inst._zod.check = (payload) => {
|
|
725
|
+
def.pattern.lastIndex = 0;
|
|
726
|
+
if (def.pattern.test(payload.value)) return;
|
|
727
|
+
payload.issues.push({
|
|
728
|
+
origin: "string",
|
|
729
|
+
code: "invalid_format",
|
|
730
|
+
format: "regex",
|
|
731
|
+
input: payload.value,
|
|
732
|
+
pattern: def.pattern.toString(),
|
|
733
|
+
inst,
|
|
734
|
+
continue: !def.abort
|
|
735
|
+
});
|
|
736
|
+
};
|
|
737
|
+
});
|
|
738
|
+
const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
739
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
740
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
741
|
+
});
|
|
742
|
+
const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
743
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
744
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
745
|
+
});
|
|
746
|
+
const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
747
|
+
$ZodCheck.init(inst, def);
|
|
748
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
749
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
750
|
+
def.pattern = pattern;
|
|
751
|
+
inst._zod.onattach.push((inst) => {
|
|
752
|
+
const bag = inst._zod.bag;
|
|
753
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
754
|
+
bag.patterns.add(pattern);
|
|
755
|
+
});
|
|
756
|
+
inst._zod.check = (payload) => {
|
|
757
|
+
if (payload.value.includes(def.includes, def.position)) return;
|
|
758
|
+
payload.issues.push({
|
|
759
|
+
origin: "string",
|
|
760
|
+
code: "invalid_format",
|
|
761
|
+
format: "includes",
|
|
762
|
+
includes: def.includes,
|
|
763
|
+
input: payload.value,
|
|
764
|
+
inst,
|
|
765
|
+
continue: !def.abort
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
});
|
|
769
|
+
const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
770
|
+
$ZodCheck.init(inst, def);
|
|
771
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
772
|
+
def.pattern ?? (def.pattern = pattern);
|
|
773
|
+
inst._zod.onattach.push((inst) => {
|
|
774
|
+
const bag = inst._zod.bag;
|
|
775
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
776
|
+
bag.patterns.add(pattern);
|
|
777
|
+
});
|
|
778
|
+
inst._zod.check = (payload) => {
|
|
779
|
+
if (payload.value.startsWith(def.prefix)) return;
|
|
780
|
+
payload.issues.push({
|
|
781
|
+
origin: "string",
|
|
782
|
+
code: "invalid_format",
|
|
783
|
+
format: "starts_with",
|
|
784
|
+
prefix: def.prefix,
|
|
785
|
+
input: payload.value,
|
|
786
|
+
inst,
|
|
787
|
+
continue: !def.abort
|
|
788
|
+
});
|
|
789
|
+
};
|
|
790
|
+
});
|
|
791
|
+
const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
792
|
+
$ZodCheck.init(inst, def);
|
|
793
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
794
|
+
def.pattern ?? (def.pattern = pattern);
|
|
795
|
+
inst._zod.onattach.push((inst) => {
|
|
796
|
+
const bag = inst._zod.bag;
|
|
797
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
798
|
+
bag.patterns.add(pattern);
|
|
799
|
+
});
|
|
800
|
+
inst._zod.check = (payload) => {
|
|
801
|
+
if (payload.value.endsWith(def.suffix)) return;
|
|
802
|
+
payload.issues.push({
|
|
803
|
+
origin: "string",
|
|
804
|
+
code: "invalid_format",
|
|
805
|
+
format: "ends_with",
|
|
806
|
+
suffix: def.suffix,
|
|
807
|
+
input: payload.value,
|
|
808
|
+
inst,
|
|
809
|
+
continue: !def.abort
|
|
810
|
+
});
|
|
811
|
+
};
|
|
812
|
+
});
|
|
813
|
+
const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
814
|
+
$ZodCheck.init(inst, def);
|
|
815
|
+
inst._zod.check = (payload) => {
|
|
816
|
+
payload.value = def.tx(payload.value);
|
|
817
|
+
};
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
//#endregion
|
|
821
|
+
//#region node_modules/zod/v4/core/versions.js
|
|
822
|
+
const version = {
|
|
823
|
+
major: 4,
|
|
824
|
+
minor: 3,
|
|
825
|
+
patch: 6
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region node_modules/zod/v4/core/schemas.js
|
|
830
|
+
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
831
|
+
var _a;
|
|
832
|
+
inst ?? (inst = {});
|
|
833
|
+
inst._zod.def = def;
|
|
834
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
835
|
+
inst._zod.version = version;
|
|
836
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
837
|
+
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
838
|
+
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
839
|
+
if (checks.length === 0) {
|
|
840
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
841
|
+
inst._zod.deferred?.push(() => {
|
|
842
|
+
inst._zod.run = inst._zod.parse;
|
|
843
|
+
});
|
|
844
|
+
} else {
|
|
845
|
+
const runChecks = (payload, checks, ctx) => {
|
|
846
|
+
let isAborted = aborted(payload);
|
|
847
|
+
let asyncResult;
|
|
848
|
+
for (const ch of checks) {
|
|
849
|
+
if (ch._zod.def.when) {
|
|
850
|
+
if (!ch._zod.def.when(payload)) continue;
|
|
851
|
+
} else if (isAborted) continue;
|
|
852
|
+
const currLen = payload.issues.length;
|
|
853
|
+
const _ = ch._zod.check(payload);
|
|
854
|
+
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
855
|
+
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
856
|
+
await _;
|
|
857
|
+
if (payload.issues.length === currLen) return;
|
|
858
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
859
|
+
});
|
|
860
|
+
else {
|
|
861
|
+
if (payload.issues.length === currLen) continue;
|
|
862
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (asyncResult) return asyncResult.then(() => {
|
|
866
|
+
return payload;
|
|
867
|
+
});
|
|
868
|
+
return payload;
|
|
869
|
+
};
|
|
870
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
871
|
+
if (aborted(canary)) {
|
|
872
|
+
canary.aborted = true;
|
|
873
|
+
return canary;
|
|
874
|
+
}
|
|
875
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
876
|
+
if (checkResult instanceof Promise) {
|
|
877
|
+
if (ctx.async === false) throw new $ZodAsyncError();
|
|
878
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
879
|
+
}
|
|
880
|
+
return inst._zod.parse(checkResult, ctx);
|
|
881
|
+
};
|
|
882
|
+
inst._zod.run = (payload, ctx) => {
|
|
883
|
+
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
|
|
884
|
+
if (ctx.direction === "backward") {
|
|
885
|
+
const canary = inst._zod.parse({
|
|
886
|
+
value: payload.value,
|
|
887
|
+
issues: []
|
|
888
|
+
}, {
|
|
889
|
+
...ctx,
|
|
890
|
+
skipChecks: true
|
|
891
|
+
});
|
|
892
|
+
if (canary instanceof Promise) return canary.then((canary) => {
|
|
893
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
894
|
+
});
|
|
895
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
896
|
+
}
|
|
897
|
+
const result = inst._zod.parse(payload, ctx);
|
|
898
|
+
if (result instanceof Promise) {
|
|
899
|
+
if (ctx.async === false) throw new $ZodAsyncError();
|
|
900
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
901
|
+
}
|
|
902
|
+
return runChecks(result, checks, ctx);
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
defineLazy(inst, "~standard", () => ({
|
|
906
|
+
validate: (value) => {
|
|
907
|
+
try {
|
|
908
|
+
const r = safeParse$1(inst, value);
|
|
909
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
910
|
+
} catch (_) {
|
|
911
|
+
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
vendor: "zod",
|
|
915
|
+
version: 1
|
|
916
|
+
}));
|
|
917
|
+
});
|
|
918
|
+
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
919
|
+
$ZodType.init(inst, def);
|
|
920
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
921
|
+
inst._zod.parse = (payload, _) => {
|
|
922
|
+
if (def.coerce) try {
|
|
923
|
+
payload.value = String(payload.value);
|
|
924
|
+
} catch (_) {}
|
|
925
|
+
if (typeof payload.value === "string") return payload;
|
|
926
|
+
payload.issues.push({
|
|
927
|
+
expected: "string",
|
|
928
|
+
code: "invalid_type",
|
|
929
|
+
input: payload.value,
|
|
930
|
+
inst
|
|
931
|
+
});
|
|
932
|
+
return payload;
|
|
933
|
+
};
|
|
934
|
+
});
|
|
935
|
+
const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
936
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
937
|
+
$ZodString.init(inst, def);
|
|
938
|
+
});
|
|
939
|
+
const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
940
|
+
def.pattern ?? (def.pattern = guid);
|
|
941
|
+
$ZodStringFormat.init(inst, def);
|
|
942
|
+
});
|
|
943
|
+
const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
944
|
+
if (def.version) {
|
|
945
|
+
const v = {
|
|
946
|
+
v1: 1,
|
|
947
|
+
v2: 2,
|
|
948
|
+
v3: 3,
|
|
949
|
+
v4: 4,
|
|
950
|
+
v5: 5,
|
|
951
|
+
v6: 6,
|
|
952
|
+
v7: 7,
|
|
953
|
+
v8: 8
|
|
954
|
+
}[def.version];
|
|
955
|
+
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
956
|
+
def.pattern ?? (def.pattern = uuid(v));
|
|
957
|
+
} else def.pattern ?? (def.pattern = uuid());
|
|
958
|
+
$ZodStringFormat.init(inst, def);
|
|
959
|
+
});
|
|
960
|
+
const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
961
|
+
def.pattern ?? (def.pattern = email);
|
|
962
|
+
$ZodStringFormat.init(inst, def);
|
|
963
|
+
});
|
|
964
|
+
const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
965
|
+
$ZodStringFormat.init(inst, def);
|
|
966
|
+
inst._zod.check = (payload) => {
|
|
967
|
+
try {
|
|
968
|
+
const trimmed = payload.value.trim();
|
|
969
|
+
const url = new URL(trimmed);
|
|
970
|
+
if (def.hostname) {
|
|
971
|
+
def.hostname.lastIndex = 0;
|
|
972
|
+
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
973
|
+
code: "invalid_format",
|
|
974
|
+
format: "url",
|
|
975
|
+
note: "Invalid hostname",
|
|
976
|
+
pattern: def.hostname.source,
|
|
977
|
+
input: payload.value,
|
|
978
|
+
inst,
|
|
979
|
+
continue: !def.abort
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
if (def.protocol) {
|
|
983
|
+
def.protocol.lastIndex = 0;
|
|
984
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
985
|
+
code: "invalid_format",
|
|
986
|
+
format: "url",
|
|
987
|
+
note: "Invalid protocol",
|
|
988
|
+
pattern: def.protocol.source,
|
|
989
|
+
input: payload.value,
|
|
990
|
+
inst,
|
|
991
|
+
continue: !def.abort
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
if (def.normalize) payload.value = url.href;
|
|
995
|
+
else payload.value = trimmed;
|
|
996
|
+
return;
|
|
997
|
+
} catch (_) {
|
|
998
|
+
payload.issues.push({
|
|
999
|
+
code: "invalid_format",
|
|
1000
|
+
format: "url",
|
|
1001
|
+
input: payload.value,
|
|
1002
|
+
inst,
|
|
1003
|
+
continue: !def.abort
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
});
|
|
1008
|
+
const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
1009
|
+
def.pattern ?? (def.pattern = emoji());
|
|
1010
|
+
$ZodStringFormat.init(inst, def);
|
|
1011
|
+
});
|
|
1012
|
+
const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1013
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
1014
|
+
$ZodStringFormat.init(inst, def);
|
|
1015
|
+
});
|
|
1016
|
+
const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
1017
|
+
def.pattern ?? (def.pattern = cuid);
|
|
1018
|
+
$ZodStringFormat.init(inst, def);
|
|
1019
|
+
});
|
|
1020
|
+
const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
1021
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
1022
|
+
$ZodStringFormat.init(inst, def);
|
|
1023
|
+
});
|
|
1024
|
+
const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
1025
|
+
def.pattern ?? (def.pattern = ulid);
|
|
1026
|
+
$ZodStringFormat.init(inst, def);
|
|
1027
|
+
});
|
|
1028
|
+
const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
1029
|
+
def.pattern ?? (def.pattern = xid);
|
|
1030
|
+
$ZodStringFormat.init(inst, def);
|
|
1031
|
+
});
|
|
1032
|
+
const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
1033
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
1034
|
+
$ZodStringFormat.init(inst, def);
|
|
1035
|
+
});
|
|
1036
|
+
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1037
|
+
def.pattern ?? (def.pattern = datetime$1(def));
|
|
1038
|
+
$ZodStringFormat.init(inst, def);
|
|
1039
|
+
});
|
|
1040
|
+
const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1041
|
+
def.pattern ?? (def.pattern = date$1);
|
|
1042
|
+
$ZodStringFormat.init(inst, def);
|
|
1043
|
+
});
|
|
1044
|
+
const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1045
|
+
def.pattern ?? (def.pattern = time$1(def));
|
|
1046
|
+
$ZodStringFormat.init(inst, def);
|
|
1047
|
+
});
|
|
1048
|
+
const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1049
|
+
def.pattern ?? (def.pattern = duration$1);
|
|
1050
|
+
$ZodStringFormat.init(inst, def);
|
|
1051
|
+
});
|
|
1052
|
+
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1053
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
1054
|
+
$ZodStringFormat.init(inst, def);
|
|
1055
|
+
inst._zod.bag.format = `ipv4`;
|
|
1056
|
+
});
|
|
1057
|
+
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1058
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
1059
|
+
$ZodStringFormat.init(inst, def);
|
|
1060
|
+
inst._zod.bag.format = `ipv6`;
|
|
1061
|
+
inst._zod.check = (payload) => {
|
|
1062
|
+
try {
|
|
1063
|
+
new URL(`http://[${payload.value}]`);
|
|
1064
|
+
} catch {
|
|
1065
|
+
payload.issues.push({
|
|
1066
|
+
code: "invalid_format",
|
|
1067
|
+
format: "ipv6",
|
|
1068
|
+
input: payload.value,
|
|
1069
|
+
inst,
|
|
1070
|
+
continue: !def.abort
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
});
|
|
1075
|
+
const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1076
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
1077
|
+
$ZodStringFormat.init(inst, def);
|
|
1078
|
+
});
|
|
1079
|
+
const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1080
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
1081
|
+
$ZodStringFormat.init(inst, def);
|
|
1082
|
+
inst._zod.check = (payload) => {
|
|
1083
|
+
const parts = payload.value.split("/");
|
|
1084
|
+
try {
|
|
1085
|
+
if (parts.length !== 2) throw new Error();
|
|
1086
|
+
const [address, prefix] = parts;
|
|
1087
|
+
if (!prefix) throw new Error();
|
|
1088
|
+
const prefixNum = Number(prefix);
|
|
1089
|
+
if (`${prefixNum}` !== prefix) throw new Error();
|
|
1090
|
+
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1091
|
+
new URL(`http://[${address}]`);
|
|
1092
|
+
} catch {
|
|
1093
|
+
payload.issues.push({
|
|
1094
|
+
code: "invalid_format",
|
|
1095
|
+
format: "cidrv6",
|
|
1096
|
+
input: payload.value,
|
|
1097
|
+
inst,
|
|
1098
|
+
continue: !def.abort
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
});
|
|
1103
|
+
function isValidBase64(data) {
|
|
1104
|
+
if (data === "") return true;
|
|
1105
|
+
if (data.length % 4 !== 0) return false;
|
|
1106
|
+
try {
|
|
1107
|
+
atob(data);
|
|
1108
|
+
return true;
|
|
1109
|
+
} catch {
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1114
|
+
def.pattern ?? (def.pattern = base64);
|
|
1115
|
+
$ZodStringFormat.init(inst, def);
|
|
1116
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
1117
|
+
inst._zod.check = (payload) => {
|
|
1118
|
+
if (isValidBase64(payload.value)) return;
|
|
1119
|
+
payload.issues.push({
|
|
1120
|
+
code: "invalid_format",
|
|
1121
|
+
format: "base64",
|
|
1122
|
+
input: payload.value,
|
|
1123
|
+
inst,
|
|
1124
|
+
continue: !def.abort
|
|
1125
|
+
});
|
|
1126
|
+
};
|
|
1127
|
+
});
|
|
1128
|
+
function isValidBase64URL(data) {
|
|
1129
|
+
if (!base64url.test(data)) return false;
|
|
1130
|
+
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1131
|
+
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
1132
|
+
}
|
|
1133
|
+
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1134
|
+
def.pattern ?? (def.pattern = base64url);
|
|
1135
|
+
$ZodStringFormat.init(inst, def);
|
|
1136
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
1137
|
+
inst._zod.check = (payload) => {
|
|
1138
|
+
if (isValidBase64URL(payload.value)) return;
|
|
1139
|
+
payload.issues.push({
|
|
1140
|
+
code: "invalid_format",
|
|
1141
|
+
format: "base64url",
|
|
1142
|
+
input: payload.value,
|
|
1143
|
+
inst,
|
|
1144
|
+
continue: !def.abort
|
|
1145
|
+
});
|
|
1146
|
+
};
|
|
1147
|
+
});
|
|
1148
|
+
const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
1149
|
+
def.pattern ?? (def.pattern = e164);
|
|
1150
|
+
$ZodStringFormat.init(inst, def);
|
|
1151
|
+
});
|
|
1152
|
+
function isValidJWT(token, algorithm = null) {
|
|
1153
|
+
try {
|
|
1154
|
+
const tokensParts = token.split(".");
|
|
1155
|
+
if (tokensParts.length !== 3) return false;
|
|
1156
|
+
const [header] = tokensParts;
|
|
1157
|
+
if (!header) return false;
|
|
1158
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1159
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1160
|
+
if (!parsedHeader.alg) return false;
|
|
1161
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1162
|
+
return true;
|
|
1163
|
+
} catch {
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
1168
|
+
$ZodStringFormat.init(inst, def);
|
|
1169
|
+
inst._zod.check = (payload) => {
|
|
1170
|
+
if (isValidJWT(payload.value, def.alg)) return;
|
|
1171
|
+
payload.issues.push({
|
|
1172
|
+
code: "invalid_format",
|
|
1173
|
+
format: "jwt",
|
|
1174
|
+
input: payload.value,
|
|
1175
|
+
inst,
|
|
1176
|
+
continue: !def.abort
|
|
1177
|
+
});
|
|
1178
|
+
};
|
|
1179
|
+
});
|
|
1180
|
+
const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
1181
|
+
$ZodType.init(inst, def);
|
|
1182
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
|
|
1183
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1184
|
+
if (def.coerce) try {
|
|
1185
|
+
payload.value = Number(payload.value);
|
|
1186
|
+
} catch (_) {}
|
|
1187
|
+
const input = payload.value;
|
|
1188
|
+
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1189
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
|
|
1190
|
+
payload.issues.push({
|
|
1191
|
+
expected: "number",
|
|
1192
|
+
code: "invalid_type",
|
|
1193
|
+
input,
|
|
1194
|
+
inst,
|
|
1195
|
+
...received ? { received } : {}
|
|
1196
|
+
});
|
|
1197
|
+
return payload;
|
|
1198
|
+
};
|
|
1199
|
+
});
|
|
1200
|
+
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
1201
|
+
$ZodCheckNumberFormat.init(inst, def);
|
|
1202
|
+
$ZodNumber.init(inst, def);
|
|
1203
|
+
});
|
|
1204
|
+
const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
1205
|
+
$ZodType.init(inst, def);
|
|
1206
|
+
inst._zod.pattern = boolean$1;
|
|
1207
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1208
|
+
if (def.coerce) try {
|
|
1209
|
+
payload.value = Boolean(payload.value);
|
|
1210
|
+
} catch (_) {}
|
|
1211
|
+
const input = payload.value;
|
|
1212
|
+
if (typeof input === "boolean") return payload;
|
|
1213
|
+
payload.issues.push({
|
|
1214
|
+
expected: "boolean",
|
|
1215
|
+
code: "invalid_type",
|
|
1216
|
+
input,
|
|
1217
|
+
inst
|
|
1218
|
+
});
|
|
1219
|
+
return payload;
|
|
1220
|
+
};
|
|
1221
|
+
});
|
|
1222
|
+
function handleArrayResult(result, final, index) {
|
|
1223
|
+
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1224
|
+
final.value[index] = result.value;
|
|
1225
|
+
}
|
|
1226
|
+
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1227
|
+
$ZodType.init(inst, def);
|
|
1228
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1229
|
+
const input = payload.value;
|
|
1230
|
+
if (!Array.isArray(input)) {
|
|
1231
|
+
payload.issues.push({
|
|
1232
|
+
expected: "array",
|
|
1233
|
+
code: "invalid_type",
|
|
1234
|
+
input,
|
|
1235
|
+
inst
|
|
1236
|
+
});
|
|
1237
|
+
return payload;
|
|
1238
|
+
}
|
|
1239
|
+
payload.value = Array(input.length);
|
|
1240
|
+
const proms = [];
|
|
1241
|
+
for (let i = 0; i < input.length; i++) {
|
|
1242
|
+
const item = input[i];
|
|
1243
|
+
const result = def.element._zod.run({
|
|
1244
|
+
value: item,
|
|
1245
|
+
issues: []
|
|
1246
|
+
}, ctx);
|
|
1247
|
+
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1248
|
+
else handleArrayResult(result, payload, i);
|
|
1249
|
+
}
|
|
1250
|
+
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1251
|
+
return payload;
|
|
1252
|
+
};
|
|
1253
|
+
});
|
|
1254
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
1255
|
+
for (const result of results) if (result.issues.length === 0) {
|
|
1256
|
+
final.value = result.value;
|
|
1257
|
+
return final;
|
|
1258
|
+
}
|
|
1259
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
1260
|
+
if (nonaborted.length === 1) {
|
|
1261
|
+
final.value = nonaborted[0].value;
|
|
1262
|
+
return nonaborted[0];
|
|
1263
|
+
}
|
|
1264
|
+
final.issues.push({
|
|
1265
|
+
code: "invalid_union",
|
|
1266
|
+
input: final.value,
|
|
1267
|
+
inst,
|
|
1268
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1269
|
+
});
|
|
1270
|
+
return final;
|
|
1271
|
+
}
|
|
1272
|
+
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
1273
|
+
$ZodType.init(inst, def);
|
|
1274
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
1275
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
1276
|
+
defineLazy(inst._zod, "values", () => {
|
|
1277
|
+
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1278
|
+
});
|
|
1279
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1280
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
1281
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
1282
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
const single = def.options.length === 1;
|
|
1286
|
+
const first = def.options[0]._zod.run;
|
|
1287
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1288
|
+
if (single) return first(payload, ctx);
|
|
1289
|
+
let async = false;
|
|
1290
|
+
const results = [];
|
|
1291
|
+
for (const option of def.options) {
|
|
1292
|
+
const result = option._zod.run({
|
|
1293
|
+
value: payload.value,
|
|
1294
|
+
issues: []
|
|
1295
|
+
}, ctx);
|
|
1296
|
+
if (result instanceof Promise) {
|
|
1297
|
+
results.push(result);
|
|
1298
|
+
async = true;
|
|
1299
|
+
} else {
|
|
1300
|
+
if (result.issues.length === 0) return result;
|
|
1301
|
+
results.push(result);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
1305
|
+
return Promise.all(results).then((results) => {
|
|
1306
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
1307
|
+
});
|
|
1308
|
+
};
|
|
1309
|
+
});
|
|
1310
|
+
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
1311
|
+
$ZodType.init(inst, def);
|
|
1312
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1313
|
+
const input = payload.value;
|
|
1314
|
+
const left = def.left._zod.run({
|
|
1315
|
+
value: input,
|
|
1316
|
+
issues: []
|
|
1317
|
+
}, ctx);
|
|
1318
|
+
const right = def.right._zod.run({
|
|
1319
|
+
value: input,
|
|
1320
|
+
issues: []
|
|
1321
|
+
}, ctx);
|
|
1322
|
+
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
|
|
1323
|
+
return handleIntersectionResults(payload, left, right);
|
|
1324
|
+
});
|
|
1325
|
+
return handleIntersectionResults(payload, left, right);
|
|
1326
|
+
};
|
|
1327
|
+
});
|
|
1328
|
+
function mergeValues(a, b) {
|
|
1329
|
+
if (a === b) return {
|
|
1330
|
+
valid: true,
|
|
1331
|
+
data: a
|
|
1332
|
+
};
|
|
1333
|
+
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
|
1334
|
+
valid: true,
|
|
1335
|
+
data: a
|
|
1336
|
+
};
|
|
1337
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
1338
|
+
const bKeys = Object.keys(b);
|
|
1339
|
+
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
1340
|
+
const newObj = {
|
|
1341
|
+
...a,
|
|
1342
|
+
...b
|
|
1343
|
+
};
|
|
1344
|
+
for (const key of sharedKeys) {
|
|
1345
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
|
1346
|
+
if (!sharedValue.valid) return {
|
|
1347
|
+
valid: false,
|
|
1348
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
1349
|
+
};
|
|
1350
|
+
newObj[key] = sharedValue.data;
|
|
1351
|
+
}
|
|
1352
|
+
return {
|
|
1353
|
+
valid: true,
|
|
1354
|
+
data: newObj
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1358
|
+
if (a.length !== b.length) return {
|
|
1359
|
+
valid: false,
|
|
1360
|
+
mergeErrorPath: []
|
|
1361
|
+
};
|
|
1362
|
+
const newArray = [];
|
|
1363
|
+
for (let index = 0; index < a.length; index++) {
|
|
1364
|
+
const itemA = a[index];
|
|
1365
|
+
const itemB = b[index];
|
|
1366
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
1367
|
+
if (!sharedValue.valid) return {
|
|
1368
|
+
valid: false,
|
|
1369
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
1370
|
+
};
|
|
1371
|
+
newArray.push(sharedValue.data);
|
|
1372
|
+
}
|
|
1373
|
+
return {
|
|
1374
|
+
valid: true,
|
|
1375
|
+
data: newArray
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
return {
|
|
1379
|
+
valid: false,
|
|
1380
|
+
mergeErrorPath: []
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
function handleIntersectionResults(result, left, right) {
|
|
1384
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1385
|
+
let unrecIssue;
|
|
1386
|
+
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
1387
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
1388
|
+
for (const k of iss.keys) {
|
|
1389
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1390
|
+
unrecKeys.get(k).l = true;
|
|
1391
|
+
}
|
|
1392
|
+
} else result.issues.push(iss);
|
|
1393
|
+
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
1394
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1395
|
+
unrecKeys.get(k).r = true;
|
|
1396
|
+
}
|
|
1397
|
+
else result.issues.push(iss);
|
|
1398
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1399
|
+
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
1400
|
+
...unrecIssue,
|
|
1401
|
+
keys: bothKeys
|
|
1402
|
+
});
|
|
1403
|
+
if (aborted(result)) return result;
|
|
1404
|
+
const merged = mergeValues(left.value, right.value);
|
|
1405
|
+
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
1406
|
+
result.value = merged.data;
|
|
1407
|
+
return result;
|
|
1408
|
+
}
|
|
1409
|
+
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
1410
|
+
$ZodType.init(inst, def);
|
|
1411
|
+
const values = getEnumValues(def.entries);
|
|
1412
|
+
const valuesSet = new Set(values);
|
|
1413
|
+
inst._zod.values = valuesSet;
|
|
1414
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
1415
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1416
|
+
const input = payload.value;
|
|
1417
|
+
if (valuesSet.has(input)) return payload;
|
|
1418
|
+
payload.issues.push({
|
|
1419
|
+
code: "invalid_value",
|
|
1420
|
+
values,
|
|
1421
|
+
input,
|
|
1422
|
+
inst
|
|
1423
|
+
});
|
|
1424
|
+
return payload;
|
|
1425
|
+
};
|
|
1426
|
+
});
|
|
1427
|
+
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
1428
|
+
$ZodType.init(inst, def);
|
|
1429
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1430
|
+
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
1431
|
+
const _out = def.transform(payload.value, payload);
|
|
1432
|
+
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
1433
|
+
payload.value = output;
|
|
1434
|
+
return payload;
|
|
1435
|
+
});
|
|
1436
|
+
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
1437
|
+
payload.value = _out;
|
|
1438
|
+
return payload;
|
|
1439
|
+
};
|
|
1440
|
+
});
|
|
1441
|
+
function handleOptionalResult(result, input) {
|
|
1442
|
+
if (result.issues.length && input === void 0) return {
|
|
1443
|
+
issues: [],
|
|
1444
|
+
value: void 0
|
|
1445
|
+
};
|
|
1446
|
+
return result;
|
|
1447
|
+
}
|
|
1448
|
+
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
1449
|
+
$ZodType.init(inst, def);
|
|
1450
|
+
inst._zod.optin = "optional";
|
|
1451
|
+
inst._zod.optout = "optional";
|
|
1452
|
+
defineLazy(inst._zod, "values", () => {
|
|
1453
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1454
|
+
});
|
|
1455
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1456
|
+
const pattern = def.innerType._zod.pattern;
|
|
1457
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1458
|
+
});
|
|
1459
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1460
|
+
if (def.innerType._zod.optin === "optional") {
|
|
1461
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1462
|
+
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
|
|
1463
|
+
return handleOptionalResult(result, payload.value);
|
|
1464
|
+
}
|
|
1465
|
+
if (payload.value === void 0) return payload;
|
|
1466
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1467
|
+
};
|
|
1468
|
+
});
|
|
1469
|
+
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
1470
|
+
$ZodOptional.init(inst, def);
|
|
1471
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1472
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
1473
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1474
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1475
|
+
};
|
|
1476
|
+
});
|
|
1477
|
+
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
1478
|
+
$ZodType.init(inst, def);
|
|
1479
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1480
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1481
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
1482
|
+
const pattern = def.innerType._zod.pattern;
|
|
1483
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1484
|
+
});
|
|
1485
|
+
defineLazy(inst._zod, "values", () => {
|
|
1486
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1487
|
+
});
|
|
1488
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1489
|
+
if (payload.value === null) return payload;
|
|
1490
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1491
|
+
};
|
|
1492
|
+
});
|
|
1493
|
+
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
1494
|
+
$ZodType.init(inst, def);
|
|
1495
|
+
inst._zod.optin = "optional";
|
|
1496
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1497
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1498
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1499
|
+
if (payload.value === void 0) {
|
|
1500
|
+
payload.value = def.defaultValue;
|
|
1501
|
+
/**
|
|
1502
|
+
* $ZodDefault returns the default value immediately in forward direction.
|
|
1503
|
+
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
1504
|
+
return payload;
|
|
1505
|
+
}
|
|
1506
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1507
|
+
if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
|
|
1508
|
+
return handleDefaultResult(result, def);
|
|
1509
|
+
};
|
|
1510
|
+
});
|
|
1511
|
+
function handleDefaultResult(payload, def) {
|
|
1512
|
+
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1513
|
+
return payload;
|
|
1514
|
+
}
|
|
1515
|
+
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
1516
|
+
$ZodType.init(inst, def);
|
|
1517
|
+
inst._zod.optin = "optional";
|
|
1518
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1519
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1520
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1521
|
+
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
1522
|
+
return def.innerType._zod.run(payload, ctx);
|
|
1523
|
+
};
|
|
1524
|
+
});
|
|
1525
|
+
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
1526
|
+
$ZodType.init(inst, def);
|
|
1527
|
+
defineLazy(inst._zod, "values", () => {
|
|
1528
|
+
const v = def.innerType._zod.values;
|
|
1529
|
+
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
1530
|
+
});
|
|
1531
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1532
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1533
|
+
if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
|
|
1534
|
+
return handleNonOptionalResult(result, inst);
|
|
1535
|
+
};
|
|
1536
|
+
});
|
|
1537
|
+
function handleNonOptionalResult(payload, inst) {
|
|
1538
|
+
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
1539
|
+
code: "invalid_type",
|
|
1540
|
+
expected: "nonoptional",
|
|
1541
|
+
input: payload.value,
|
|
1542
|
+
inst
|
|
1543
|
+
});
|
|
1544
|
+
return payload;
|
|
1545
|
+
}
|
|
1546
|
+
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
1547
|
+
$ZodType.init(inst, def);
|
|
1548
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
1549
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
1550
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1551
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1552
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1553
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1554
|
+
if (result instanceof Promise) return result.then((result) => {
|
|
1555
|
+
payload.value = result.value;
|
|
1556
|
+
if (result.issues.length) {
|
|
1557
|
+
payload.value = def.catchValue({
|
|
1558
|
+
...payload,
|
|
1559
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1560
|
+
input: payload.value
|
|
1561
|
+
});
|
|
1562
|
+
payload.issues = [];
|
|
1563
|
+
}
|
|
1564
|
+
return payload;
|
|
1565
|
+
});
|
|
1566
|
+
payload.value = result.value;
|
|
1567
|
+
if (result.issues.length) {
|
|
1568
|
+
payload.value = def.catchValue({
|
|
1569
|
+
...payload,
|
|
1570
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
1571
|
+
input: payload.value
|
|
1572
|
+
});
|
|
1573
|
+
payload.issues = [];
|
|
1574
|
+
}
|
|
1575
|
+
return payload;
|
|
1576
|
+
};
|
|
1577
|
+
});
|
|
1578
|
+
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
1579
|
+
$ZodType.init(inst, def);
|
|
1580
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
1581
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
1582
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
1583
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
1584
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1585
|
+
if (ctx.direction === "backward") {
|
|
1586
|
+
const right = def.out._zod.run(payload, ctx);
|
|
1587
|
+
if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
1588
|
+
return handlePipeResult(right, def.in, ctx);
|
|
1589
|
+
}
|
|
1590
|
+
const left = def.in._zod.run(payload, ctx);
|
|
1591
|
+
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
1592
|
+
return handlePipeResult(left, def.out, ctx);
|
|
1593
|
+
};
|
|
1594
|
+
});
|
|
1595
|
+
function handlePipeResult(left, next, ctx) {
|
|
1596
|
+
if (left.issues.length) {
|
|
1597
|
+
left.aborted = true;
|
|
1598
|
+
return left;
|
|
1599
|
+
}
|
|
1600
|
+
return next._zod.run({
|
|
1601
|
+
value: left.value,
|
|
1602
|
+
issues: left.issues
|
|
1603
|
+
}, ctx);
|
|
1604
|
+
}
|
|
1605
|
+
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
1606
|
+
$ZodType.init(inst, def);
|
|
1607
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
1608
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
1609
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
1610
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
1611
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1612
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
1613
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
1614
|
+
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
1615
|
+
return handleReadonlyResult(result);
|
|
1616
|
+
};
|
|
1617
|
+
});
|
|
1618
|
+
function handleReadonlyResult(payload) {
|
|
1619
|
+
payload.value = Object.freeze(payload.value);
|
|
1620
|
+
return payload;
|
|
1621
|
+
}
|
|
1622
|
+
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
1623
|
+
$ZodCheck.init(inst, def);
|
|
1624
|
+
$ZodType.init(inst, def);
|
|
1625
|
+
inst._zod.parse = (payload, _) => {
|
|
1626
|
+
return payload;
|
|
1627
|
+
};
|
|
1628
|
+
inst._zod.check = (payload) => {
|
|
1629
|
+
const input = payload.value;
|
|
1630
|
+
const r = def.fn(input);
|
|
1631
|
+
if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
1632
|
+
handleRefineResult(r, payload, input, inst);
|
|
1633
|
+
};
|
|
1634
|
+
});
|
|
1635
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
1636
|
+
if (!result) {
|
|
1637
|
+
const _iss = {
|
|
1638
|
+
code: "custom",
|
|
1639
|
+
input,
|
|
1640
|
+
inst,
|
|
1641
|
+
path: [...inst._zod.def.path ?? []],
|
|
1642
|
+
continue: !inst._zod.def.abort
|
|
1643
|
+
};
|
|
1644
|
+
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
1645
|
+
payload.issues.push(issue(_iss));
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
//#endregion
|
|
1650
|
+
//#region node_modules/zod/v4/core/registries.js
|
|
1651
|
+
var _a;
|
|
1652
|
+
var $ZodRegistry = class {
|
|
1653
|
+
constructor() {
|
|
1654
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
1655
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
1656
|
+
}
|
|
1657
|
+
add(schema, ..._meta) {
|
|
1658
|
+
const meta = _meta[0];
|
|
1659
|
+
this._map.set(schema, meta);
|
|
1660
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
1661
|
+
return this;
|
|
1662
|
+
}
|
|
1663
|
+
clear() {
|
|
1664
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
1665
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
1666
|
+
return this;
|
|
1667
|
+
}
|
|
1668
|
+
remove(schema) {
|
|
1669
|
+
const meta = this._map.get(schema);
|
|
1670
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
1671
|
+
this._map.delete(schema);
|
|
1672
|
+
return this;
|
|
1673
|
+
}
|
|
1674
|
+
get(schema) {
|
|
1675
|
+
const p = schema._zod.parent;
|
|
1676
|
+
if (p) {
|
|
1677
|
+
const pm = { ...this.get(p) ?? {} };
|
|
1678
|
+
delete pm.id;
|
|
1679
|
+
const f = {
|
|
1680
|
+
...pm,
|
|
1681
|
+
...this._map.get(schema)
|
|
1682
|
+
};
|
|
1683
|
+
return Object.keys(f).length ? f : void 0;
|
|
1684
|
+
}
|
|
1685
|
+
return this._map.get(schema);
|
|
1686
|
+
}
|
|
1687
|
+
has(schema) {
|
|
1688
|
+
return this._map.has(schema);
|
|
1689
|
+
}
|
|
1690
|
+
};
|
|
1691
|
+
function registry() {
|
|
1692
|
+
return new $ZodRegistry();
|
|
1693
|
+
}
|
|
1694
|
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
1695
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
1696
|
+
|
|
1697
|
+
//#endregion
|
|
1698
|
+
//#region node_modules/zod/v4/core/api.js
|
|
1699
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1700
|
+
function _string(Class, params) {
|
|
1701
|
+
return new Class({
|
|
1702
|
+
type: "string",
|
|
1703
|
+
...normalizeParams(params)
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1707
|
+
function _email(Class, params) {
|
|
1708
|
+
return new Class({
|
|
1709
|
+
type: "string",
|
|
1710
|
+
format: "email",
|
|
1711
|
+
check: "string_format",
|
|
1712
|
+
abort: false,
|
|
1713
|
+
...normalizeParams(params)
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1717
|
+
function _guid(Class, params) {
|
|
1718
|
+
return new Class({
|
|
1719
|
+
type: "string",
|
|
1720
|
+
format: "guid",
|
|
1721
|
+
check: "string_format",
|
|
1722
|
+
abort: false,
|
|
1723
|
+
...normalizeParams(params)
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1727
|
+
function _uuid(Class, params) {
|
|
1728
|
+
return new Class({
|
|
1729
|
+
type: "string",
|
|
1730
|
+
format: "uuid",
|
|
1731
|
+
check: "string_format",
|
|
1732
|
+
abort: false,
|
|
1733
|
+
...normalizeParams(params)
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1737
|
+
function _uuidv4(Class, params) {
|
|
1738
|
+
return new Class({
|
|
1739
|
+
type: "string",
|
|
1740
|
+
format: "uuid",
|
|
1741
|
+
check: "string_format",
|
|
1742
|
+
abort: false,
|
|
1743
|
+
version: "v4",
|
|
1744
|
+
...normalizeParams(params)
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1748
|
+
function _uuidv6(Class, params) {
|
|
1749
|
+
return new Class({
|
|
1750
|
+
type: "string",
|
|
1751
|
+
format: "uuid",
|
|
1752
|
+
check: "string_format",
|
|
1753
|
+
abort: false,
|
|
1754
|
+
version: "v6",
|
|
1755
|
+
...normalizeParams(params)
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1759
|
+
function _uuidv7(Class, params) {
|
|
1760
|
+
return new Class({
|
|
1761
|
+
type: "string",
|
|
1762
|
+
format: "uuid",
|
|
1763
|
+
check: "string_format",
|
|
1764
|
+
abort: false,
|
|
1765
|
+
version: "v7",
|
|
1766
|
+
...normalizeParams(params)
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1770
|
+
function _url(Class, params) {
|
|
1771
|
+
return new Class({
|
|
1772
|
+
type: "string",
|
|
1773
|
+
format: "url",
|
|
1774
|
+
check: "string_format",
|
|
1775
|
+
abort: false,
|
|
1776
|
+
...normalizeParams(params)
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1780
|
+
function _emoji(Class, params) {
|
|
1781
|
+
return new Class({
|
|
1782
|
+
type: "string",
|
|
1783
|
+
format: "emoji",
|
|
1784
|
+
check: "string_format",
|
|
1785
|
+
abort: false,
|
|
1786
|
+
...normalizeParams(params)
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1790
|
+
function _nanoid(Class, params) {
|
|
1791
|
+
return new Class({
|
|
1792
|
+
type: "string",
|
|
1793
|
+
format: "nanoid",
|
|
1794
|
+
check: "string_format",
|
|
1795
|
+
abort: false,
|
|
1796
|
+
...normalizeParams(params)
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1800
|
+
function _cuid(Class, params) {
|
|
1801
|
+
return new Class({
|
|
1802
|
+
type: "string",
|
|
1803
|
+
format: "cuid",
|
|
1804
|
+
check: "string_format",
|
|
1805
|
+
abort: false,
|
|
1806
|
+
...normalizeParams(params)
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1810
|
+
function _cuid2(Class, params) {
|
|
1811
|
+
return new Class({
|
|
1812
|
+
type: "string",
|
|
1813
|
+
format: "cuid2",
|
|
1814
|
+
check: "string_format",
|
|
1815
|
+
abort: false,
|
|
1816
|
+
...normalizeParams(params)
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1820
|
+
function _ulid(Class, params) {
|
|
1821
|
+
return new Class({
|
|
1822
|
+
type: "string",
|
|
1823
|
+
format: "ulid",
|
|
1824
|
+
check: "string_format",
|
|
1825
|
+
abort: false,
|
|
1826
|
+
...normalizeParams(params)
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1830
|
+
function _xid(Class, params) {
|
|
1831
|
+
return new Class({
|
|
1832
|
+
type: "string",
|
|
1833
|
+
format: "xid",
|
|
1834
|
+
check: "string_format",
|
|
1835
|
+
abort: false,
|
|
1836
|
+
...normalizeParams(params)
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1840
|
+
function _ksuid(Class, params) {
|
|
1841
|
+
return new Class({
|
|
1842
|
+
type: "string",
|
|
1843
|
+
format: "ksuid",
|
|
1844
|
+
check: "string_format",
|
|
1845
|
+
abort: false,
|
|
1846
|
+
...normalizeParams(params)
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1850
|
+
function _ipv4(Class, params) {
|
|
1851
|
+
return new Class({
|
|
1852
|
+
type: "string",
|
|
1853
|
+
format: "ipv4",
|
|
1854
|
+
check: "string_format",
|
|
1855
|
+
abort: false,
|
|
1856
|
+
...normalizeParams(params)
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1860
|
+
function _ipv6(Class, params) {
|
|
1861
|
+
return new Class({
|
|
1862
|
+
type: "string",
|
|
1863
|
+
format: "ipv6",
|
|
1864
|
+
check: "string_format",
|
|
1865
|
+
abort: false,
|
|
1866
|
+
...normalizeParams(params)
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1870
|
+
function _cidrv4(Class, params) {
|
|
1871
|
+
return new Class({
|
|
1872
|
+
type: "string",
|
|
1873
|
+
format: "cidrv4",
|
|
1874
|
+
check: "string_format",
|
|
1875
|
+
abort: false,
|
|
1876
|
+
...normalizeParams(params)
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1880
|
+
function _cidrv6(Class, params) {
|
|
1881
|
+
return new Class({
|
|
1882
|
+
type: "string",
|
|
1883
|
+
format: "cidrv6",
|
|
1884
|
+
check: "string_format",
|
|
1885
|
+
abort: false,
|
|
1886
|
+
...normalizeParams(params)
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1890
|
+
function _base64(Class, params) {
|
|
1891
|
+
return new Class({
|
|
1892
|
+
type: "string",
|
|
1893
|
+
format: "base64",
|
|
1894
|
+
check: "string_format",
|
|
1895
|
+
abort: false,
|
|
1896
|
+
...normalizeParams(params)
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1900
|
+
function _base64url(Class, params) {
|
|
1901
|
+
return new Class({
|
|
1902
|
+
type: "string",
|
|
1903
|
+
format: "base64url",
|
|
1904
|
+
check: "string_format",
|
|
1905
|
+
abort: false,
|
|
1906
|
+
...normalizeParams(params)
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1910
|
+
function _e164(Class, params) {
|
|
1911
|
+
return new Class({
|
|
1912
|
+
type: "string",
|
|
1913
|
+
format: "e164",
|
|
1914
|
+
check: "string_format",
|
|
1915
|
+
abort: false,
|
|
1916
|
+
...normalizeParams(params)
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1920
|
+
function _jwt(Class, params) {
|
|
1921
|
+
return new Class({
|
|
1922
|
+
type: "string",
|
|
1923
|
+
format: "jwt",
|
|
1924
|
+
check: "string_format",
|
|
1925
|
+
abort: false,
|
|
1926
|
+
...normalizeParams(params)
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1930
|
+
function _isoDateTime(Class, params) {
|
|
1931
|
+
return new Class({
|
|
1932
|
+
type: "string",
|
|
1933
|
+
format: "datetime",
|
|
1934
|
+
check: "string_format",
|
|
1935
|
+
offset: false,
|
|
1936
|
+
local: false,
|
|
1937
|
+
precision: null,
|
|
1938
|
+
...normalizeParams(params)
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1942
|
+
function _isoDate(Class, params) {
|
|
1943
|
+
return new Class({
|
|
1944
|
+
type: "string",
|
|
1945
|
+
format: "date",
|
|
1946
|
+
check: "string_format",
|
|
1947
|
+
...normalizeParams(params)
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1951
|
+
function _isoTime(Class, params) {
|
|
1952
|
+
return new Class({
|
|
1953
|
+
type: "string",
|
|
1954
|
+
format: "time",
|
|
1955
|
+
check: "string_format",
|
|
1956
|
+
precision: null,
|
|
1957
|
+
...normalizeParams(params)
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1961
|
+
function _isoDuration(Class, params) {
|
|
1962
|
+
return new Class({
|
|
1963
|
+
type: "string",
|
|
1964
|
+
format: "duration",
|
|
1965
|
+
check: "string_format",
|
|
1966
|
+
...normalizeParams(params)
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1970
|
+
function _number(Class, params) {
|
|
1971
|
+
return new Class({
|
|
1972
|
+
type: "number",
|
|
1973
|
+
checks: [],
|
|
1974
|
+
...normalizeParams(params)
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1978
|
+
function _int(Class, params) {
|
|
1979
|
+
return new Class({
|
|
1980
|
+
type: "number",
|
|
1981
|
+
check: "number_format",
|
|
1982
|
+
abort: false,
|
|
1983
|
+
format: "safeint",
|
|
1984
|
+
...normalizeParams(params)
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1988
|
+
function _boolean(Class, params) {
|
|
1989
|
+
return new Class({
|
|
1990
|
+
type: "boolean",
|
|
1991
|
+
...normalizeParams(params)
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
1995
|
+
function _lt(value, params) {
|
|
1996
|
+
return new $ZodCheckLessThan({
|
|
1997
|
+
check: "less_than",
|
|
1998
|
+
...normalizeParams(params),
|
|
1999
|
+
value,
|
|
2000
|
+
inclusive: false
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2004
|
+
function _lte(value, params) {
|
|
2005
|
+
return new $ZodCheckLessThan({
|
|
2006
|
+
check: "less_than",
|
|
2007
|
+
...normalizeParams(params),
|
|
2008
|
+
value,
|
|
2009
|
+
inclusive: true
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2013
|
+
function _gt(value, params) {
|
|
2014
|
+
return new $ZodCheckGreaterThan({
|
|
2015
|
+
check: "greater_than",
|
|
2016
|
+
...normalizeParams(params),
|
|
2017
|
+
value,
|
|
2018
|
+
inclusive: false
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2022
|
+
function _gte(value, params) {
|
|
2023
|
+
return new $ZodCheckGreaterThan({
|
|
2024
|
+
check: "greater_than",
|
|
2025
|
+
...normalizeParams(params),
|
|
2026
|
+
value,
|
|
2027
|
+
inclusive: true
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2031
|
+
function _multipleOf(value, params) {
|
|
2032
|
+
return new $ZodCheckMultipleOf({
|
|
2033
|
+
check: "multiple_of",
|
|
2034
|
+
...normalizeParams(params),
|
|
2035
|
+
value
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2039
|
+
function _maxLength(maximum, params) {
|
|
2040
|
+
return new $ZodCheckMaxLength({
|
|
2041
|
+
check: "max_length",
|
|
2042
|
+
...normalizeParams(params),
|
|
2043
|
+
maximum
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2047
|
+
function _minLength(minimum, params) {
|
|
2048
|
+
return new $ZodCheckMinLength({
|
|
2049
|
+
check: "min_length",
|
|
2050
|
+
...normalizeParams(params),
|
|
2051
|
+
minimum
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2055
|
+
function _length(length, params) {
|
|
2056
|
+
return new $ZodCheckLengthEquals({
|
|
2057
|
+
check: "length_equals",
|
|
2058
|
+
...normalizeParams(params),
|
|
2059
|
+
length
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2063
|
+
function _regex(pattern, params) {
|
|
2064
|
+
return new $ZodCheckRegex({
|
|
2065
|
+
check: "string_format",
|
|
2066
|
+
format: "regex",
|
|
2067
|
+
...normalizeParams(params),
|
|
2068
|
+
pattern
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2072
|
+
function _lowercase(params) {
|
|
2073
|
+
return new $ZodCheckLowerCase({
|
|
2074
|
+
check: "string_format",
|
|
2075
|
+
format: "lowercase",
|
|
2076
|
+
...normalizeParams(params)
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2080
|
+
function _uppercase(params) {
|
|
2081
|
+
return new $ZodCheckUpperCase({
|
|
2082
|
+
check: "string_format",
|
|
2083
|
+
format: "uppercase",
|
|
2084
|
+
...normalizeParams(params)
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2088
|
+
function _includes(includes, params) {
|
|
2089
|
+
return new $ZodCheckIncludes({
|
|
2090
|
+
check: "string_format",
|
|
2091
|
+
format: "includes",
|
|
2092
|
+
...normalizeParams(params),
|
|
2093
|
+
includes
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2097
|
+
function _startsWith(prefix, params) {
|
|
2098
|
+
return new $ZodCheckStartsWith({
|
|
2099
|
+
check: "string_format",
|
|
2100
|
+
format: "starts_with",
|
|
2101
|
+
...normalizeParams(params),
|
|
2102
|
+
prefix
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2106
|
+
function _endsWith(suffix, params) {
|
|
2107
|
+
return new $ZodCheckEndsWith({
|
|
2108
|
+
check: "string_format",
|
|
2109
|
+
format: "ends_with",
|
|
2110
|
+
...normalizeParams(params),
|
|
2111
|
+
suffix
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2115
|
+
function _overwrite(tx) {
|
|
2116
|
+
return new $ZodCheckOverwrite({
|
|
2117
|
+
check: "overwrite",
|
|
2118
|
+
tx
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2122
|
+
function _normalize(form) {
|
|
2123
|
+
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
2124
|
+
}
|
|
2125
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2126
|
+
function _trim() {
|
|
2127
|
+
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
2128
|
+
}
|
|
2129
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2130
|
+
function _toLowerCase() {
|
|
2131
|
+
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
2132
|
+
}
|
|
2133
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2134
|
+
function _toUpperCase() {
|
|
2135
|
+
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
2136
|
+
}
|
|
2137
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2138
|
+
function _slugify() {
|
|
2139
|
+
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
2140
|
+
}
|
|
2141
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2142
|
+
function _array(Class, element, params) {
|
|
2143
|
+
return new Class({
|
|
2144
|
+
type: "array",
|
|
2145
|
+
element,
|
|
2146
|
+
...normalizeParams(params)
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2150
|
+
function _refine(Class, fn, _params) {
|
|
2151
|
+
return new Class({
|
|
2152
|
+
type: "custom",
|
|
2153
|
+
check: "custom",
|
|
2154
|
+
fn,
|
|
2155
|
+
...normalizeParams(_params)
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2159
|
+
function _superRefine(fn) {
|
|
2160
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
2161
|
+
payload.addIssue = (issue$2) => {
|
|
2162
|
+
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
2163
|
+
else {
|
|
2164
|
+
const _issue = issue$2;
|
|
2165
|
+
if (_issue.fatal) _issue.continue = false;
|
|
2166
|
+
_issue.code ?? (_issue.code = "custom");
|
|
2167
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
2168
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
2169
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2170
|
+
payload.issues.push(issue(_issue));
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
return fn(payload.value, payload);
|
|
2174
|
+
});
|
|
2175
|
+
return ch;
|
|
2176
|
+
}
|
|
2177
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2178
|
+
function _check(fn, params) {
|
|
2179
|
+
const ch = new $ZodCheck({
|
|
2180
|
+
check: "custom",
|
|
2181
|
+
...normalizeParams(params)
|
|
2182
|
+
});
|
|
2183
|
+
ch._zod.check = fn;
|
|
2184
|
+
return ch;
|
|
2185
|
+
}
|
|
2186
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2187
|
+
function describe$1(description) {
|
|
2188
|
+
const ch = new $ZodCheck({ check: "describe" });
|
|
2189
|
+
ch._zod.onattach = [(inst) => {
|
|
2190
|
+
const existing = globalRegistry.get(inst) ?? {};
|
|
2191
|
+
globalRegistry.add(inst, {
|
|
2192
|
+
...existing,
|
|
2193
|
+
description
|
|
2194
|
+
});
|
|
2195
|
+
}];
|
|
2196
|
+
ch._zod.check = () => {};
|
|
2197
|
+
return ch;
|
|
2198
|
+
}
|
|
2199
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2200
|
+
function meta$1(metadata) {
|
|
2201
|
+
const ch = new $ZodCheck({ check: "meta" });
|
|
2202
|
+
ch._zod.onattach = [(inst) => {
|
|
2203
|
+
const existing = globalRegistry.get(inst) ?? {};
|
|
2204
|
+
globalRegistry.add(inst, {
|
|
2205
|
+
...existing,
|
|
2206
|
+
...metadata
|
|
2207
|
+
});
|
|
2208
|
+
}];
|
|
2209
|
+
ch._zod.check = () => {};
|
|
2210
|
+
return ch;
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
//#endregion
|
|
2214
|
+
//#region node_modules/zod/v4/core/to-json-schema.js
|
|
2215
|
+
function initializeContext(params) {
|
|
2216
|
+
let target = params?.target ?? "draft-2020-12";
|
|
2217
|
+
if (target === "draft-4") target = "draft-04";
|
|
2218
|
+
if (target === "draft-7") target = "draft-07";
|
|
2219
|
+
return {
|
|
2220
|
+
processors: params.processors ?? {},
|
|
2221
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
2222
|
+
target,
|
|
2223
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
2224
|
+
override: params?.override ?? (() => {}),
|
|
2225
|
+
io: params?.io ?? "output",
|
|
2226
|
+
counter: 0,
|
|
2227
|
+
seen: /* @__PURE__ */ new Map(),
|
|
2228
|
+
cycles: params?.cycles ?? "ref",
|
|
2229
|
+
reused: params?.reused ?? "inline",
|
|
2230
|
+
external: params?.external ?? void 0
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
function process$1(schema, ctx, _params = {
|
|
2234
|
+
path: [],
|
|
2235
|
+
schemaPath: []
|
|
2236
|
+
}) {
|
|
2237
|
+
var _a;
|
|
2238
|
+
const def = schema._zod.def;
|
|
2239
|
+
const seen = ctx.seen.get(schema);
|
|
2240
|
+
if (seen) {
|
|
2241
|
+
seen.count++;
|
|
2242
|
+
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
2243
|
+
return seen.schema;
|
|
2244
|
+
}
|
|
2245
|
+
const result = {
|
|
2246
|
+
schema: {},
|
|
2247
|
+
count: 1,
|
|
2248
|
+
cycle: void 0,
|
|
2249
|
+
path: _params.path
|
|
2250
|
+
};
|
|
2251
|
+
ctx.seen.set(schema, result);
|
|
2252
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2253
|
+
if (overrideSchema) result.schema = overrideSchema;
|
|
2254
|
+
else {
|
|
2255
|
+
const params = {
|
|
2256
|
+
..._params,
|
|
2257
|
+
schemaPath: [..._params.schemaPath, schema],
|
|
2258
|
+
path: _params.path
|
|
2259
|
+
};
|
|
2260
|
+
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
2261
|
+
else {
|
|
2262
|
+
const _json = result.schema;
|
|
2263
|
+
const processor = ctx.processors[def.type];
|
|
2264
|
+
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
2265
|
+
processor(schema, ctx, _json, params);
|
|
2266
|
+
}
|
|
2267
|
+
const parent = schema._zod.parent;
|
|
2268
|
+
if (parent) {
|
|
2269
|
+
if (!result.ref) result.ref = parent;
|
|
2270
|
+
process$1(parent, ctx, params);
|
|
2271
|
+
ctx.seen.get(parent).isParent = true;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
const meta = ctx.metadataRegistry.get(schema);
|
|
2275
|
+
if (meta) Object.assign(result.schema, meta);
|
|
2276
|
+
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2277
|
+
delete result.schema.examples;
|
|
2278
|
+
delete result.schema.default;
|
|
2279
|
+
}
|
|
2280
|
+
if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
2281
|
+
delete result.schema._prefault;
|
|
2282
|
+
return ctx.seen.get(schema).schema;
|
|
2283
|
+
}
|
|
2284
|
+
function extractDefs(ctx, schema) {
|
|
2285
|
+
const root = ctx.seen.get(schema);
|
|
2286
|
+
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2287
|
+
const idToSchema = /* @__PURE__ */ new Map();
|
|
2288
|
+
for (const entry of ctx.seen.entries()) {
|
|
2289
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
2290
|
+
if (id) {
|
|
2291
|
+
const existing = idToSchema.get(id);
|
|
2292
|
+
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
2293
|
+
idToSchema.set(id, entry[0]);
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
const makeURI = (entry) => {
|
|
2297
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
2298
|
+
if (ctx.external) {
|
|
2299
|
+
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
2300
|
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
2301
|
+
if (externalId) return { ref: uriGenerator(externalId) };
|
|
2302
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
2303
|
+
entry[1].defId = id;
|
|
2304
|
+
return {
|
|
2305
|
+
defId: id,
|
|
2306
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
if (entry[1] === root) return { ref: "#" };
|
|
2310
|
+
const defUriPrefix = `#/${defsSegment}/`;
|
|
2311
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2312
|
+
return {
|
|
2313
|
+
defId,
|
|
2314
|
+
ref: defUriPrefix + defId
|
|
2315
|
+
};
|
|
2316
|
+
};
|
|
2317
|
+
const extractToDef = (entry) => {
|
|
2318
|
+
if (entry[1].schema.$ref) return;
|
|
2319
|
+
const seen = entry[1];
|
|
2320
|
+
const { ref, defId } = makeURI(entry);
|
|
2321
|
+
seen.def = { ...seen.schema };
|
|
2322
|
+
if (defId) seen.defId = defId;
|
|
2323
|
+
const schema = seen.schema;
|
|
2324
|
+
for (const key in schema) delete schema[key];
|
|
2325
|
+
schema.$ref = ref;
|
|
2326
|
+
};
|
|
2327
|
+
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
2328
|
+
const seen = entry[1];
|
|
2329
|
+
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
2330
|
+
|
|
2331
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
2332
|
+
}
|
|
2333
|
+
for (const entry of ctx.seen.entries()) {
|
|
2334
|
+
const seen = entry[1];
|
|
2335
|
+
if (schema === entry[0]) {
|
|
2336
|
+
extractToDef(entry);
|
|
2337
|
+
continue;
|
|
2338
|
+
}
|
|
2339
|
+
if (ctx.external) {
|
|
2340
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
2341
|
+
if (schema !== entry[0] && ext) {
|
|
2342
|
+
extractToDef(entry);
|
|
2343
|
+
continue;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
2347
|
+
extractToDef(entry);
|
|
2348
|
+
continue;
|
|
2349
|
+
}
|
|
2350
|
+
if (seen.cycle) {
|
|
2351
|
+
extractToDef(entry);
|
|
2352
|
+
continue;
|
|
2353
|
+
}
|
|
2354
|
+
if (seen.count > 1) {
|
|
2355
|
+
if (ctx.reused === "ref") {
|
|
2356
|
+
extractToDef(entry);
|
|
2357
|
+
continue;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
function finalize(ctx, schema) {
|
|
2363
|
+
const root = ctx.seen.get(schema);
|
|
2364
|
+
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2365
|
+
const flattenRef = (zodSchema) => {
|
|
2366
|
+
const seen = ctx.seen.get(zodSchema);
|
|
2367
|
+
if (seen.ref === null) return;
|
|
2368
|
+
const schema = seen.def ?? seen.schema;
|
|
2369
|
+
const _cached = { ...schema };
|
|
2370
|
+
const ref = seen.ref;
|
|
2371
|
+
seen.ref = null;
|
|
2372
|
+
if (ref) {
|
|
2373
|
+
flattenRef(ref);
|
|
2374
|
+
const refSeen = ctx.seen.get(ref);
|
|
2375
|
+
const refSchema = refSeen.schema;
|
|
2376
|
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2377
|
+
schema.allOf = schema.allOf ?? [];
|
|
2378
|
+
schema.allOf.push(refSchema);
|
|
2379
|
+
} else Object.assign(schema, refSchema);
|
|
2380
|
+
Object.assign(schema, _cached);
|
|
2381
|
+
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
2382
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
2383
|
+
if (!(key in _cached)) delete schema[key];
|
|
2384
|
+
}
|
|
2385
|
+
if (refSchema.$ref && refSeen.def) for (const key in schema) {
|
|
2386
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
2387
|
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
const parent = zodSchema._zod.parent;
|
|
2391
|
+
if (parent && parent !== ref) {
|
|
2392
|
+
flattenRef(parent);
|
|
2393
|
+
const parentSeen = ctx.seen.get(parent);
|
|
2394
|
+
if (parentSeen?.schema.$ref) {
|
|
2395
|
+
schema.$ref = parentSeen.schema.$ref;
|
|
2396
|
+
if (parentSeen.def) for (const key in schema) {
|
|
2397
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
2398
|
+
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
ctx.override({
|
|
2403
|
+
zodSchema,
|
|
2404
|
+
jsonSchema: schema,
|
|
2405
|
+
path: seen.path ?? []
|
|
2406
|
+
});
|
|
2407
|
+
};
|
|
2408
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
2409
|
+
const result = {};
|
|
2410
|
+
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
2411
|
+
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
2412
|
+
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
2413
|
+
else if (ctx.target === "openapi-3.0") {}
|
|
2414
|
+
if (ctx.external?.uri) {
|
|
2415
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
2416
|
+
if (!id) throw new Error("Schema is missing an `id` property");
|
|
2417
|
+
result.$id = ctx.external.uri(id);
|
|
2418
|
+
}
|
|
2419
|
+
Object.assign(result, root.def ?? root.schema);
|
|
2420
|
+
const defs = ctx.external?.defs ?? {};
|
|
2421
|
+
for (const entry of ctx.seen.entries()) {
|
|
2422
|
+
const seen = entry[1];
|
|
2423
|
+
if (seen.def && seen.defId) defs[seen.defId] = seen.def;
|
|
2424
|
+
}
|
|
2425
|
+
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
2426
|
+
else result.definitions = defs;
|
|
2427
|
+
try {
|
|
2428
|
+
const finalized = JSON.parse(JSON.stringify(result));
|
|
2429
|
+
Object.defineProperty(finalized, "~standard", {
|
|
2430
|
+
value: {
|
|
2431
|
+
...schema["~standard"],
|
|
2432
|
+
jsonSchema: {
|
|
2433
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
2434
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
2435
|
+
}
|
|
2436
|
+
},
|
|
2437
|
+
enumerable: false,
|
|
2438
|
+
writable: false
|
|
2439
|
+
});
|
|
2440
|
+
return finalized;
|
|
2441
|
+
} catch (_err) {
|
|
2442
|
+
throw new Error("Error converting schema to JSON.");
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
function isTransforming(_schema, _ctx) {
|
|
2446
|
+
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
2447
|
+
if (ctx.seen.has(_schema)) return false;
|
|
2448
|
+
ctx.seen.add(_schema);
|
|
2449
|
+
const def = _schema._zod.def;
|
|
2450
|
+
if (def.type === "transform") return true;
|
|
2451
|
+
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
2452
|
+
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
2453
|
+
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
2454
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
2455
|
+
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
2456
|
+
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
2457
|
+
if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
2458
|
+
if (def.type === "object") {
|
|
2459
|
+
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
2460
|
+
return false;
|
|
2461
|
+
}
|
|
2462
|
+
if (def.type === "union") {
|
|
2463
|
+
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
2464
|
+
return false;
|
|
2465
|
+
}
|
|
2466
|
+
if (def.type === "tuple") {
|
|
2467
|
+
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
2468
|
+
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
2469
|
+
return false;
|
|
2470
|
+
}
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
/**
|
|
2474
|
+
* Creates a toJSONSchema method for a schema instance.
|
|
2475
|
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
2476
|
+
*/
|
|
2477
|
+
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
2478
|
+
const ctx = initializeContext({
|
|
2479
|
+
...params,
|
|
2480
|
+
processors
|
|
2481
|
+
});
|
|
2482
|
+
process$1(schema, ctx);
|
|
2483
|
+
extractDefs(ctx, schema);
|
|
2484
|
+
return finalize(ctx, schema);
|
|
2485
|
+
};
|
|
2486
|
+
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
2487
|
+
const { libraryOptions, target } = params ?? {};
|
|
2488
|
+
const ctx = initializeContext({
|
|
2489
|
+
...libraryOptions ?? {},
|
|
2490
|
+
target,
|
|
2491
|
+
io,
|
|
2492
|
+
processors
|
|
2493
|
+
});
|
|
2494
|
+
process$1(schema, ctx);
|
|
2495
|
+
extractDefs(ctx, schema);
|
|
2496
|
+
return finalize(ctx, schema);
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2499
|
+
//#endregion
|
|
2500
|
+
//#region node_modules/zod/v4/core/json-schema-processors.js
|
|
2501
|
+
const formatMap = {
|
|
2502
|
+
guid: "uuid",
|
|
2503
|
+
url: "uri",
|
|
2504
|
+
datetime: "date-time",
|
|
2505
|
+
json_string: "json-string",
|
|
2506
|
+
regex: ""
|
|
2507
|
+
};
|
|
2508
|
+
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
2509
|
+
const json = _json;
|
|
2510
|
+
json.type = "string";
|
|
2511
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
2512
|
+
if (typeof minimum === "number") json.minLength = minimum;
|
|
2513
|
+
if (typeof maximum === "number") json.maxLength = maximum;
|
|
2514
|
+
if (format) {
|
|
2515
|
+
json.format = formatMap[format] ?? format;
|
|
2516
|
+
if (json.format === "") delete json.format;
|
|
2517
|
+
if (format === "time") delete json.format;
|
|
2518
|
+
}
|
|
2519
|
+
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
2520
|
+
if (patterns && patterns.size > 0) {
|
|
2521
|
+
const regexes = [...patterns];
|
|
2522
|
+
if (regexes.length === 1) json.pattern = regexes[0].source;
|
|
2523
|
+
else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
|
|
2524
|
+
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
2525
|
+
pattern: regex.source
|
|
2526
|
+
}))];
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
2530
|
+
const json = _json;
|
|
2531
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
2532
|
+
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
2533
|
+
else json.type = "number";
|
|
2534
|
+
if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
2535
|
+
json.minimum = exclusiveMinimum;
|
|
2536
|
+
json.exclusiveMinimum = true;
|
|
2537
|
+
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
2538
|
+
if (typeof minimum === "number") {
|
|
2539
|
+
json.minimum = minimum;
|
|
2540
|
+
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
2541
|
+
else delete json.exclusiveMinimum;
|
|
2542
|
+
}
|
|
2543
|
+
if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
2544
|
+
json.maximum = exclusiveMaximum;
|
|
2545
|
+
json.exclusiveMaximum = true;
|
|
2546
|
+
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
2547
|
+
if (typeof maximum === "number") {
|
|
2548
|
+
json.maximum = maximum;
|
|
2549
|
+
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
2550
|
+
else delete json.exclusiveMaximum;
|
|
2551
|
+
}
|
|
2552
|
+
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
2553
|
+
};
|
|
2554
|
+
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
2555
|
+
json.type = "boolean";
|
|
2556
|
+
};
|
|
2557
|
+
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
2558
|
+
const def = schema._zod.def;
|
|
2559
|
+
const values = getEnumValues(def.entries);
|
|
2560
|
+
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
2561
|
+
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
2562
|
+
json.enum = values;
|
|
2563
|
+
};
|
|
2564
|
+
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
2565
|
+
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
2566
|
+
};
|
|
2567
|
+
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
2568
|
+
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
2569
|
+
};
|
|
2570
|
+
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
2571
|
+
const json = _json;
|
|
2572
|
+
const def = schema._zod.def;
|
|
2573
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
2574
|
+
if (typeof minimum === "number") json.minItems = minimum;
|
|
2575
|
+
if (typeof maximum === "number") json.maxItems = maximum;
|
|
2576
|
+
json.type = "array";
|
|
2577
|
+
json.items = process$1(def.element, ctx, {
|
|
2578
|
+
...params,
|
|
2579
|
+
path: [...params.path, "items"]
|
|
2580
|
+
});
|
|
2581
|
+
};
|
|
2582
|
+
const unionProcessor = (schema, ctx, json, params) => {
|
|
2583
|
+
const def = schema._zod.def;
|
|
2584
|
+
const isExclusive = def.inclusive === false;
|
|
2585
|
+
const options = def.options.map((x, i) => process$1(x, ctx, {
|
|
2586
|
+
...params,
|
|
2587
|
+
path: [
|
|
2588
|
+
...params.path,
|
|
2589
|
+
isExclusive ? "oneOf" : "anyOf",
|
|
2590
|
+
i
|
|
2591
|
+
]
|
|
2592
|
+
}));
|
|
2593
|
+
if (isExclusive) json.oneOf = options;
|
|
2594
|
+
else json.anyOf = options;
|
|
2595
|
+
};
|
|
2596
|
+
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
2597
|
+
const def = schema._zod.def;
|
|
2598
|
+
const a = process$1(def.left, ctx, {
|
|
2599
|
+
...params,
|
|
2600
|
+
path: [
|
|
2601
|
+
...params.path,
|
|
2602
|
+
"allOf",
|
|
2603
|
+
0
|
|
2604
|
+
]
|
|
2605
|
+
});
|
|
2606
|
+
const b = process$1(def.right, ctx, {
|
|
2607
|
+
...params,
|
|
2608
|
+
path: [
|
|
2609
|
+
...params.path,
|
|
2610
|
+
"allOf",
|
|
2611
|
+
1
|
|
2612
|
+
]
|
|
2613
|
+
});
|
|
2614
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
2615
|
+
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
2616
|
+
};
|
|
2617
|
+
const nullableProcessor = (schema, ctx, json, params) => {
|
|
2618
|
+
const def = schema._zod.def;
|
|
2619
|
+
const inner = process$1(def.innerType, ctx, params);
|
|
2620
|
+
const seen = ctx.seen.get(schema);
|
|
2621
|
+
if (ctx.target === "openapi-3.0") {
|
|
2622
|
+
seen.ref = def.innerType;
|
|
2623
|
+
json.nullable = true;
|
|
2624
|
+
} else json.anyOf = [inner, { type: "null" }];
|
|
2625
|
+
};
|
|
2626
|
+
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
2627
|
+
const def = schema._zod.def;
|
|
2628
|
+
process$1(def.innerType, ctx, params);
|
|
2629
|
+
const seen = ctx.seen.get(schema);
|
|
2630
|
+
seen.ref = def.innerType;
|
|
2631
|
+
};
|
|
2632
|
+
const defaultProcessor = (schema, ctx, json, params) => {
|
|
2633
|
+
const def = schema._zod.def;
|
|
2634
|
+
process$1(def.innerType, ctx, params);
|
|
2635
|
+
const seen = ctx.seen.get(schema);
|
|
2636
|
+
seen.ref = def.innerType;
|
|
2637
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
2638
|
+
};
|
|
2639
|
+
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
2640
|
+
const def = schema._zod.def;
|
|
2641
|
+
process$1(def.innerType, ctx, params);
|
|
2642
|
+
const seen = ctx.seen.get(schema);
|
|
2643
|
+
seen.ref = def.innerType;
|
|
2644
|
+
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
2645
|
+
};
|
|
2646
|
+
const catchProcessor = (schema, ctx, json, params) => {
|
|
2647
|
+
const def = schema._zod.def;
|
|
2648
|
+
process$1(def.innerType, ctx, params);
|
|
2649
|
+
const seen = ctx.seen.get(schema);
|
|
2650
|
+
seen.ref = def.innerType;
|
|
2651
|
+
let catchValue;
|
|
2652
|
+
try {
|
|
2653
|
+
catchValue = def.catchValue(void 0);
|
|
2654
|
+
} catch {
|
|
2655
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
2656
|
+
}
|
|
2657
|
+
json.default = catchValue;
|
|
2658
|
+
};
|
|
2659
|
+
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
2660
|
+
const def = schema._zod.def;
|
|
2661
|
+
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
2662
|
+
process$1(innerType, ctx, params);
|
|
2663
|
+
const seen = ctx.seen.get(schema);
|
|
2664
|
+
seen.ref = innerType;
|
|
2665
|
+
};
|
|
2666
|
+
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
2667
|
+
const def = schema._zod.def;
|
|
2668
|
+
process$1(def.innerType, ctx, params);
|
|
2669
|
+
const seen = ctx.seen.get(schema);
|
|
2670
|
+
seen.ref = def.innerType;
|
|
2671
|
+
json.readOnly = true;
|
|
2672
|
+
};
|
|
2673
|
+
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
2674
|
+
const def = schema._zod.def;
|
|
2675
|
+
process$1(def.innerType, ctx, params);
|
|
2676
|
+
const seen = ctx.seen.get(schema);
|
|
2677
|
+
seen.ref = def.innerType;
|
|
2678
|
+
};
|
|
2679
|
+
|
|
2680
|
+
//#endregion
|
|
2681
|
+
//#region node_modules/zod/v4/classic/iso.js
|
|
2682
|
+
const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
2683
|
+
$ZodISODateTime.init(inst, def);
|
|
2684
|
+
ZodStringFormat.init(inst, def);
|
|
2685
|
+
});
|
|
2686
|
+
function datetime(params) {
|
|
2687
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
2688
|
+
}
|
|
2689
|
+
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
2690
|
+
$ZodISODate.init(inst, def);
|
|
2691
|
+
ZodStringFormat.init(inst, def);
|
|
2692
|
+
});
|
|
2693
|
+
function date(params) {
|
|
2694
|
+
return _isoDate(ZodISODate, params);
|
|
2695
|
+
}
|
|
2696
|
+
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
2697
|
+
$ZodISOTime.init(inst, def);
|
|
2698
|
+
ZodStringFormat.init(inst, def);
|
|
2699
|
+
});
|
|
2700
|
+
function time(params) {
|
|
2701
|
+
return _isoTime(ZodISOTime, params);
|
|
2702
|
+
}
|
|
2703
|
+
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
2704
|
+
$ZodISODuration.init(inst, def);
|
|
2705
|
+
ZodStringFormat.init(inst, def);
|
|
2706
|
+
});
|
|
2707
|
+
function duration(params) {
|
|
2708
|
+
return _isoDuration(ZodISODuration, params);
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
//#endregion
|
|
2712
|
+
//#region node_modules/zod/v4/classic/errors.js
|
|
2713
|
+
const initializer = (inst, issues) => {
|
|
2714
|
+
$ZodError.init(inst, issues);
|
|
2715
|
+
inst.name = "ZodError";
|
|
2716
|
+
Object.defineProperties(inst, {
|
|
2717
|
+
format: { value: (mapper) => formatError(inst, mapper) },
|
|
2718
|
+
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
2719
|
+
addIssue: { value: (issue) => {
|
|
2720
|
+
inst.issues.push(issue);
|
|
2721
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2722
|
+
} },
|
|
2723
|
+
addIssues: { value: (issues) => {
|
|
2724
|
+
inst.issues.push(...issues);
|
|
2725
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2726
|
+
} },
|
|
2727
|
+
isEmpty: { get() {
|
|
2728
|
+
return inst.issues.length === 0;
|
|
2729
|
+
} }
|
|
2730
|
+
});
|
|
2731
|
+
};
|
|
2732
|
+
const ZodError = $constructor("ZodError", initializer);
|
|
2733
|
+
const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
2734
|
+
|
|
2735
|
+
//#endregion
|
|
2736
|
+
//#region node_modules/zod/v4/classic/parse.js
|
|
2737
|
+
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
2738
|
+
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
2739
|
+
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
2740
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
2741
|
+
const encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
2742
|
+
const decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
2743
|
+
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
2744
|
+
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
2745
|
+
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
2746
|
+
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
2747
|
+
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
2748
|
+
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
2749
|
+
|
|
2750
|
+
//#endregion
|
|
2751
|
+
//#region node_modules/zod/v4/classic/schemas.js
|
|
2752
|
+
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
2753
|
+
$ZodType.init(inst, def);
|
|
2754
|
+
Object.assign(inst["~standard"], { jsonSchema: {
|
|
2755
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
2756
|
+
output: createStandardJSONSchemaMethod(inst, "output")
|
|
2757
|
+
} });
|
|
2758
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
2759
|
+
inst.def = def;
|
|
2760
|
+
inst.type = def.type;
|
|
2761
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
2762
|
+
inst.check = (...checks) => {
|
|
2763
|
+
return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
2764
|
+
check: ch,
|
|
2765
|
+
def: { check: "custom" },
|
|
2766
|
+
onattach: []
|
|
2767
|
+
} } : ch)] }), { parent: true });
|
|
2768
|
+
};
|
|
2769
|
+
inst.with = inst.check;
|
|
2770
|
+
inst.clone = (def, params) => clone(inst, def, params);
|
|
2771
|
+
inst.brand = () => inst;
|
|
2772
|
+
inst.register = ((reg, meta) => {
|
|
2773
|
+
reg.add(inst, meta);
|
|
2774
|
+
return inst;
|
|
2775
|
+
});
|
|
2776
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
2777
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
2778
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
2779
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
2780
|
+
inst.spa = inst.safeParseAsync;
|
|
2781
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
2782
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
2783
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
2784
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
2785
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
2786
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
2787
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
2788
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
2789
|
+
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
2790
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
2791
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
2792
|
+
inst.optional = () => optional(inst);
|
|
2793
|
+
inst.exactOptional = () => exactOptional(inst);
|
|
2794
|
+
inst.nullable = () => nullable(inst);
|
|
2795
|
+
inst.nullish = () => optional(nullable(inst));
|
|
2796
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
2797
|
+
inst.array = () => array(inst);
|
|
2798
|
+
inst.or = (arg) => union([inst, arg]);
|
|
2799
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
2800
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
2801
|
+
inst.default = (def) => _default(inst, def);
|
|
2802
|
+
inst.prefault = (def) => prefault(inst, def);
|
|
2803
|
+
inst.catch = (params) => _catch(inst, params);
|
|
2804
|
+
inst.pipe = (target) => pipe(inst, target);
|
|
2805
|
+
inst.readonly = () => readonly(inst);
|
|
2806
|
+
inst.describe = (description) => {
|
|
2807
|
+
const cl = inst.clone();
|
|
2808
|
+
globalRegistry.add(cl, { description });
|
|
2809
|
+
return cl;
|
|
2810
|
+
};
|
|
2811
|
+
Object.defineProperty(inst, "description", {
|
|
2812
|
+
get() {
|
|
2813
|
+
return globalRegistry.get(inst)?.description;
|
|
2814
|
+
},
|
|
2815
|
+
configurable: true
|
|
2816
|
+
});
|
|
2817
|
+
inst.meta = (...args) => {
|
|
2818
|
+
if (args.length === 0) return globalRegistry.get(inst);
|
|
2819
|
+
const cl = inst.clone();
|
|
2820
|
+
globalRegistry.add(cl, args[0]);
|
|
2821
|
+
return cl;
|
|
2822
|
+
};
|
|
2823
|
+
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
2824
|
+
inst.isNullable = () => inst.safeParse(null).success;
|
|
2825
|
+
inst.apply = (fn) => fn(inst);
|
|
2826
|
+
return inst;
|
|
2827
|
+
});
|
|
2828
|
+
/** @internal */
|
|
2829
|
+
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
2830
|
+
$ZodString.init(inst, def);
|
|
2831
|
+
ZodType.init(inst, def);
|
|
2832
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
2833
|
+
const bag = inst._zod.bag;
|
|
2834
|
+
inst.format = bag.format ?? null;
|
|
2835
|
+
inst.minLength = bag.minimum ?? null;
|
|
2836
|
+
inst.maxLength = bag.maximum ?? null;
|
|
2837
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
2838
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
2839
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
2840
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
2841
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
2842
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
2843
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
2844
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
2845
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
2846
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
2847
|
+
inst.trim = () => inst.check(_trim());
|
|
2848
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
2849
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
2850
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
2851
|
+
inst.slugify = () => inst.check(_slugify());
|
|
2852
|
+
});
|
|
2853
|
+
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
2854
|
+
$ZodString.init(inst, def);
|
|
2855
|
+
_ZodString.init(inst, def);
|
|
2856
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
2857
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
2858
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
2859
|
+
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
2860
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2861
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
2862
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
2863
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
2864
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
2865
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
2866
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2867
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
2868
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
2869
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
2870
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
2871
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
2872
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
2873
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
2874
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
2875
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
2876
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
2877
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
2878
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
2879
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
2880
|
+
inst.date = (params) => inst.check(date(params));
|
|
2881
|
+
inst.time = (params) => inst.check(time(params));
|
|
2882
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
2883
|
+
});
|
|
2884
|
+
function string(params) {
|
|
2885
|
+
return _string(ZodString, params);
|
|
2886
|
+
}
|
|
2887
|
+
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
2888
|
+
$ZodStringFormat.init(inst, def);
|
|
2889
|
+
_ZodString.init(inst, def);
|
|
2890
|
+
});
|
|
2891
|
+
const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
2892
|
+
$ZodEmail.init(inst, def);
|
|
2893
|
+
ZodStringFormat.init(inst, def);
|
|
2894
|
+
});
|
|
2895
|
+
const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
2896
|
+
$ZodGUID.init(inst, def);
|
|
2897
|
+
ZodStringFormat.init(inst, def);
|
|
2898
|
+
});
|
|
2899
|
+
const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
2900
|
+
$ZodUUID.init(inst, def);
|
|
2901
|
+
ZodStringFormat.init(inst, def);
|
|
2902
|
+
});
|
|
2903
|
+
const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
2904
|
+
$ZodURL.init(inst, def);
|
|
2905
|
+
ZodStringFormat.init(inst, def);
|
|
2906
|
+
});
|
|
2907
|
+
const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
2908
|
+
$ZodEmoji.init(inst, def);
|
|
2909
|
+
ZodStringFormat.init(inst, def);
|
|
2910
|
+
});
|
|
2911
|
+
const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
2912
|
+
$ZodNanoID.init(inst, def);
|
|
2913
|
+
ZodStringFormat.init(inst, def);
|
|
2914
|
+
});
|
|
2915
|
+
const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
2916
|
+
$ZodCUID.init(inst, def);
|
|
2917
|
+
ZodStringFormat.init(inst, def);
|
|
2918
|
+
});
|
|
2919
|
+
const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
2920
|
+
$ZodCUID2.init(inst, def);
|
|
2921
|
+
ZodStringFormat.init(inst, def);
|
|
2922
|
+
});
|
|
2923
|
+
const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
2924
|
+
$ZodULID.init(inst, def);
|
|
2925
|
+
ZodStringFormat.init(inst, def);
|
|
2926
|
+
});
|
|
2927
|
+
const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
2928
|
+
$ZodXID.init(inst, def);
|
|
2929
|
+
ZodStringFormat.init(inst, def);
|
|
2930
|
+
});
|
|
2931
|
+
const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
2932
|
+
$ZodKSUID.init(inst, def);
|
|
2933
|
+
ZodStringFormat.init(inst, def);
|
|
2934
|
+
});
|
|
2935
|
+
const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
2936
|
+
$ZodIPv4.init(inst, def);
|
|
2937
|
+
ZodStringFormat.init(inst, def);
|
|
2938
|
+
});
|
|
2939
|
+
const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
2940
|
+
$ZodIPv6.init(inst, def);
|
|
2941
|
+
ZodStringFormat.init(inst, def);
|
|
2942
|
+
});
|
|
2943
|
+
const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
2944
|
+
$ZodCIDRv4.init(inst, def);
|
|
2945
|
+
ZodStringFormat.init(inst, def);
|
|
2946
|
+
});
|
|
2947
|
+
const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
2948
|
+
$ZodCIDRv6.init(inst, def);
|
|
2949
|
+
ZodStringFormat.init(inst, def);
|
|
2950
|
+
});
|
|
2951
|
+
const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
2952
|
+
$ZodBase64.init(inst, def);
|
|
2953
|
+
ZodStringFormat.init(inst, def);
|
|
2954
|
+
});
|
|
2955
|
+
const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
2956
|
+
$ZodBase64URL.init(inst, def);
|
|
2957
|
+
ZodStringFormat.init(inst, def);
|
|
2958
|
+
});
|
|
2959
|
+
const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
2960
|
+
$ZodE164.init(inst, def);
|
|
2961
|
+
ZodStringFormat.init(inst, def);
|
|
2962
|
+
});
|
|
2963
|
+
const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
2964
|
+
$ZodJWT.init(inst, def);
|
|
2965
|
+
ZodStringFormat.init(inst, def);
|
|
2966
|
+
});
|
|
2967
|
+
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
2968
|
+
$ZodNumber.init(inst, def);
|
|
2969
|
+
ZodType.init(inst, def);
|
|
2970
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
2971
|
+
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
2972
|
+
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
2973
|
+
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
2974
|
+
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
2975
|
+
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
2976
|
+
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
2977
|
+
inst.int = (params) => inst.check(int(params));
|
|
2978
|
+
inst.safe = (params) => inst.check(int(params));
|
|
2979
|
+
inst.positive = (params) => inst.check(_gt(0, params));
|
|
2980
|
+
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
2981
|
+
inst.negative = (params) => inst.check(_lt(0, params));
|
|
2982
|
+
inst.nonpositive = (params) => inst.check(_lte(0, params));
|
|
2983
|
+
inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
|
|
2984
|
+
inst.step = (value, params) => inst.check(_multipleOf(value, params));
|
|
2985
|
+
inst.finite = () => inst;
|
|
2986
|
+
const bag = inst._zod.bag;
|
|
2987
|
+
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
2988
|
+
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
2989
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
2990
|
+
inst.isFinite = true;
|
|
2991
|
+
inst.format = bag.format ?? null;
|
|
2992
|
+
});
|
|
2993
|
+
function number(params) {
|
|
2994
|
+
return _number(ZodNumber, params);
|
|
2995
|
+
}
|
|
2996
|
+
const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
2997
|
+
$ZodNumberFormat.init(inst, def);
|
|
2998
|
+
ZodNumber.init(inst, def);
|
|
2999
|
+
});
|
|
3000
|
+
function int(params) {
|
|
3001
|
+
return _int(ZodNumberFormat, params);
|
|
3002
|
+
}
|
|
3003
|
+
const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
3004
|
+
$ZodBoolean.init(inst, def);
|
|
3005
|
+
ZodType.init(inst, def);
|
|
3006
|
+
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
3007
|
+
});
|
|
3008
|
+
function boolean(params) {
|
|
3009
|
+
return _boolean(ZodBoolean, params);
|
|
3010
|
+
}
|
|
3011
|
+
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
3012
|
+
$ZodArray.init(inst, def);
|
|
3013
|
+
ZodType.init(inst, def);
|
|
3014
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
3015
|
+
inst.element = def.element;
|
|
3016
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
3017
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
3018
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
3019
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
3020
|
+
inst.unwrap = () => inst.element;
|
|
3021
|
+
});
|
|
3022
|
+
function array(element, params) {
|
|
3023
|
+
return _array(ZodArray, element, params);
|
|
3024
|
+
}
|
|
3025
|
+
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
3026
|
+
$ZodUnion.init(inst, def);
|
|
3027
|
+
ZodType.init(inst, def);
|
|
3028
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
3029
|
+
inst.options = def.options;
|
|
3030
|
+
});
|
|
3031
|
+
function union(options, params) {
|
|
3032
|
+
return new ZodUnion({
|
|
3033
|
+
type: "union",
|
|
3034
|
+
options,
|
|
3035
|
+
...normalizeParams(params)
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
3039
|
+
$ZodIntersection.init(inst, def);
|
|
3040
|
+
ZodType.init(inst, def);
|
|
3041
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
3042
|
+
});
|
|
3043
|
+
function intersection(left, right) {
|
|
3044
|
+
return new ZodIntersection({
|
|
3045
|
+
type: "intersection",
|
|
3046
|
+
left,
|
|
3047
|
+
right
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
3050
|
+
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
3051
|
+
$ZodEnum.init(inst, def);
|
|
3052
|
+
ZodType.init(inst, def);
|
|
3053
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
3054
|
+
inst.enum = def.entries;
|
|
3055
|
+
inst.options = Object.values(def.entries);
|
|
3056
|
+
const keys = new Set(Object.keys(def.entries));
|
|
3057
|
+
inst.extract = (values, params) => {
|
|
3058
|
+
const newEntries = {};
|
|
3059
|
+
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
3060
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
3061
|
+
return new ZodEnum({
|
|
3062
|
+
...def,
|
|
3063
|
+
checks: [],
|
|
3064
|
+
...normalizeParams(params),
|
|
3065
|
+
entries: newEntries
|
|
3066
|
+
});
|
|
3067
|
+
};
|
|
3068
|
+
inst.exclude = (values, params) => {
|
|
3069
|
+
const newEntries = { ...def.entries };
|
|
3070
|
+
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
3071
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
3072
|
+
return new ZodEnum({
|
|
3073
|
+
...def,
|
|
3074
|
+
checks: [],
|
|
3075
|
+
...normalizeParams(params),
|
|
3076
|
+
entries: newEntries
|
|
3077
|
+
});
|
|
3078
|
+
};
|
|
3079
|
+
});
|
|
3080
|
+
function _enum(values, params) {
|
|
3081
|
+
return new ZodEnum({
|
|
3082
|
+
type: "enum",
|
|
3083
|
+
entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
|
|
3084
|
+
...normalizeParams(params)
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
3088
|
+
$ZodTransform.init(inst, def);
|
|
3089
|
+
ZodType.init(inst, def);
|
|
3090
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
3091
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
3092
|
+
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
3093
|
+
payload.addIssue = (issue$1) => {
|
|
3094
|
+
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
3095
|
+
else {
|
|
3096
|
+
const _issue = issue$1;
|
|
3097
|
+
if (_issue.fatal) _issue.continue = false;
|
|
3098
|
+
_issue.code ?? (_issue.code = "custom");
|
|
3099
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
3100
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
3101
|
+
payload.issues.push(issue(_issue));
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
const output = def.transform(payload.value, payload);
|
|
3105
|
+
if (output instanceof Promise) return output.then((output) => {
|
|
3106
|
+
payload.value = output;
|
|
3107
|
+
return payload;
|
|
3108
|
+
});
|
|
3109
|
+
payload.value = output;
|
|
3110
|
+
return payload;
|
|
3111
|
+
};
|
|
3112
|
+
});
|
|
3113
|
+
function transform(fn) {
|
|
3114
|
+
return new ZodTransform({
|
|
3115
|
+
type: "transform",
|
|
3116
|
+
transform: fn
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
3120
|
+
$ZodOptional.init(inst, def);
|
|
3121
|
+
ZodType.init(inst, def);
|
|
3122
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3123
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3124
|
+
});
|
|
3125
|
+
function optional(innerType) {
|
|
3126
|
+
return new ZodOptional({
|
|
3127
|
+
type: "optional",
|
|
3128
|
+
innerType
|
|
3129
|
+
});
|
|
3130
|
+
}
|
|
3131
|
+
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
3132
|
+
$ZodExactOptional.init(inst, def);
|
|
3133
|
+
ZodType.init(inst, def);
|
|
3134
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
3135
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3136
|
+
});
|
|
3137
|
+
function exactOptional(innerType) {
|
|
3138
|
+
return new ZodExactOptional({
|
|
3139
|
+
type: "optional",
|
|
3140
|
+
innerType
|
|
3141
|
+
});
|
|
3142
|
+
}
|
|
3143
|
+
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
3144
|
+
$ZodNullable.init(inst, def);
|
|
3145
|
+
ZodType.init(inst, def);
|
|
3146
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
3147
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3148
|
+
});
|
|
3149
|
+
function nullable(innerType) {
|
|
3150
|
+
return new ZodNullable({
|
|
3151
|
+
type: "nullable",
|
|
3152
|
+
innerType
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3155
|
+
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
3156
|
+
$ZodDefault.init(inst, def);
|
|
3157
|
+
ZodType.init(inst, def);
|
|
3158
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
3159
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3160
|
+
inst.removeDefault = inst.unwrap;
|
|
3161
|
+
});
|
|
3162
|
+
function _default(innerType, defaultValue) {
|
|
3163
|
+
return new ZodDefault({
|
|
3164
|
+
type: "default",
|
|
3165
|
+
innerType,
|
|
3166
|
+
get defaultValue() {
|
|
3167
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3168
|
+
}
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
3172
|
+
$ZodPrefault.init(inst, def);
|
|
3173
|
+
ZodType.init(inst, def);
|
|
3174
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
3175
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3176
|
+
});
|
|
3177
|
+
function prefault(innerType, defaultValue) {
|
|
3178
|
+
return new ZodPrefault({
|
|
3179
|
+
type: "prefault",
|
|
3180
|
+
innerType,
|
|
3181
|
+
get defaultValue() {
|
|
3182
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
3183
|
+
}
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
3186
|
+
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
3187
|
+
$ZodNonOptional.init(inst, def);
|
|
3188
|
+
ZodType.init(inst, def);
|
|
3189
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
3190
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3191
|
+
});
|
|
3192
|
+
function nonoptional(innerType, params) {
|
|
3193
|
+
return new ZodNonOptional({
|
|
3194
|
+
type: "nonoptional",
|
|
3195
|
+
innerType,
|
|
3196
|
+
...normalizeParams(params)
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
3200
|
+
$ZodCatch.init(inst, def);
|
|
3201
|
+
ZodType.init(inst, def);
|
|
3202
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
3203
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3204
|
+
inst.removeCatch = inst.unwrap;
|
|
3205
|
+
});
|
|
3206
|
+
function _catch(innerType, catchValue) {
|
|
3207
|
+
return new ZodCatch({
|
|
3208
|
+
type: "catch",
|
|
3209
|
+
innerType,
|
|
3210
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
3211
|
+
});
|
|
3212
|
+
}
|
|
3213
|
+
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
3214
|
+
$ZodPipe.init(inst, def);
|
|
3215
|
+
ZodType.init(inst, def);
|
|
3216
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
3217
|
+
inst.in = def.in;
|
|
3218
|
+
inst.out = def.out;
|
|
3219
|
+
});
|
|
3220
|
+
function pipe(in_, out) {
|
|
3221
|
+
return new ZodPipe({
|
|
3222
|
+
type: "pipe",
|
|
3223
|
+
in: in_,
|
|
3224
|
+
out
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3228
|
+
$ZodReadonly.init(inst, def);
|
|
3229
|
+
ZodType.init(inst, def);
|
|
3230
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
3231
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3232
|
+
});
|
|
3233
|
+
function readonly(innerType) {
|
|
3234
|
+
return new ZodReadonly({
|
|
3235
|
+
type: "readonly",
|
|
3236
|
+
innerType
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
3240
|
+
$ZodCustom.init(inst, def);
|
|
3241
|
+
ZodType.init(inst, def);
|
|
3242
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
3243
|
+
});
|
|
3244
|
+
function refine(fn, _params = {}) {
|
|
3245
|
+
return _refine(ZodCustom, fn, _params);
|
|
3246
|
+
}
|
|
3247
|
+
function superRefine(fn) {
|
|
3248
|
+
return _superRefine(fn);
|
|
3249
|
+
}
|
|
3250
|
+
const describe = describe$1;
|
|
3251
|
+
const meta = meta$1;
|
|
3252
|
+
|
|
3253
|
+
//#endregion
|
|
3254
|
+
//#region src/daemon-mcp/instructions.ts
|
|
3255
|
+
const PAI_INSTRUCTIONS = `## PAI — Personal AI Infrastructure
|
|
3256
|
+
|
|
3257
|
+
Federated memory, project registry, session management, and skill workflows.
|
|
3258
|
+
|
|
3259
|
+
### PAI-First Search Protocol
|
|
3260
|
+
|
|
3261
|
+
Before answering questions about past work, decisions, people, or project status:
|
|
3262
|
+
use memory_search. Use project_detect at session start to identify the current project.
|
|
3263
|
+
|
|
3264
|
+
### Session Commands
|
|
3265
|
+
|
|
3266
|
+
- go / continue / weiter → read TODO.md, look for ## Continue section, resume from there
|
|
3267
|
+
- pause session → summarize state, update TODO.md with ## Continue section at top, stop
|
|
3268
|
+
- end session → pause procedure + rename session note (NEVER leave as "New Session")
|
|
3269
|
+
- cpp → git add . && git commit -m "type: ..." && git push (no AI signatures)
|
|
3270
|
+
|
|
3271
|
+
### Response Modes
|
|
3272
|
+
|
|
3273
|
+
Classify every request before responding:
|
|
3274
|
+
- MINIMAL: greetings, acks, simple yes/no → 1-3 sentences, no structure
|
|
3275
|
+
- STANDARD: single-step tasks, quick lookups → direct answer only
|
|
3276
|
+
- FULL: multi-step work, research, implementation → SUMMARY / ANALYSIS / ACTIONS / RESULTS / STATUS / NEXT / COMPLETED
|
|
3277
|
+
|
|
3278
|
+
### Skill Routing
|
|
3279
|
+
|
|
3280
|
+
Fetch the full skill instructions with: prompts/get { name: "<skill-name>" }
|
|
3281
|
+
|
|
3282
|
+
| When user says | Fetch prompt |
|
|
3283
|
+
|----------------|--------------|
|
|
3284
|
+
| review, weekly review, what did I do, recap | review |
|
|
3285
|
+
| journal, note to self, capture this thought | journal |
|
|
3286
|
+
| plan, what should I focus on, priorities | plan |
|
|
3287
|
+
| share on linkedin, post about, tweet this | share |
|
|
3288
|
+
| list sessions, where was I working | sessions |
|
|
3289
|
+
| route, what project is this | route |
|
|
3290
|
+
| search history, find past, when did we | search-history |
|
|
3291
|
+
| /name, name this session | name |
|
|
3292
|
+
| observability, monitor agents, show dashboard | observability |
|
|
3293
|
+
| research, extract wisdom, analyze content | research |
|
|
3294
|
+
| visualize, create diagram, flowchart, image | art |
|
|
3295
|
+
| create skill, validate skill, update skill | createskill |
|
|
3296
|
+
| /story, story explanation, explain as story | story-explanation |
|
|
3297
|
+
| load vault context, morning briefing | vault-context |
|
|
3298
|
+
| connect X and Y, how does X relate to Y | vault-connect |
|
|
3299
|
+
| what's emerging, find patterns in vault | vault-emerge |
|
|
3300
|
+
| find orphans, orphaned notes | vault-orphans |
|
|
3301
|
+
| trace idea, how did X evolve | vault-trace |
|
|
3302
|
+
|
|
3303
|
+
### Reference Resources
|
|
3304
|
+
|
|
3305
|
+
Fetch with: resources/read { uri: "pai://<name>" }
|
|
3306
|
+
|
|
3307
|
+
| Resource | URI |
|
|
3308
|
+
|----------|-----|
|
|
3309
|
+
| Aesthetic guide (visual style) | pai://aesthetic |
|
|
3310
|
+
| Constitution (philosophy, architecture, directory structure) | pai://constitution |
|
|
3311
|
+
| Prompt engineering standards | pai://prompting |
|
|
3312
|
+
| Voice prosody guide | pai://prosody-guide |
|
|
3313
|
+
| Prosody agent template | pai://prosody-agent-template |
|
|
3314
|
+
| Voice system reference | pai://voice |
|
|
3315
|
+
| Skill system spec (TitleCase, SKILL.md structure) | pai://skill-system |
|
|
3316
|
+
| Hook system reference (events, patterns) | pai://hook-system |
|
|
3317
|
+
| History system — UOCS (capture, directories) | pai://history-system |
|
|
3318
|
+
| Terminal tab title system | pai://terminal-tabs |
|
|
3319
|
+
| MCP development guide (three-tier architecture) | pai://mcp-dev-guide |
|
|
3320
|
+
|
|
3321
|
+
### Core Rules
|
|
3322
|
+
|
|
3323
|
+
- Git commits: NO AI signatures, NO Co-Authored-By lines, format: type: description
|
|
3324
|
+
- Stack: TypeScript > Python, bun for JS/TS, uv for Python
|
|
3325
|
+
- Security: run git remote -v before every push; never commit private data
|
|
3326
|
+
- Fact-checking: mark unverified AI claims with ⚠️ Unverified
|
|
3327
|
+
- History lookup: search \${PAI_DIR}/History/ before answering about past work
|
|
3328
|
+
- WhatsApp routing: [Whazaa] prefix → reply via whatsapp_send; [Whazaa:voice] → whatsapp_tts
|
|
3329
|
+
`;
|
|
3330
|
+
|
|
3331
|
+
//#endregion
|
|
3332
|
+
//#region src/daemon-mcp/prompts/review.ts
|
|
3333
|
+
const review = {
|
|
3334
|
+
description: "Weekly/daily/monthly review of work accomplished",
|
|
3335
|
+
content: `## Review Skill
|
|
3336
|
+
|
|
3337
|
+
USE WHEN user says 'review', 'what did I do', 'this week', 'weekly review', 'daily review', 'monthly review', 'what have we achieved', 'reflect', 'retrospective', 'recap', '/review', OR asks about accomplishments over a time period.
|
|
3338
|
+
|
|
3339
|
+
### Commands
|
|
3340
|
+
|
|
3341
|
+
| Subcommand | Period |
|
|
3342
|
+
|------------|--------|
|
|
3343
|
+
| /review today | Today |
|
|
3344
|
+
| /review week | Current week (Mon-Sun), DEFAULT if no period |
|
|
3345
|
+
| /review month | Current calendar month |
|
|
3346
|
+
| /review year | Current calendar year |
|
|
3347
|
+
|
|
3348
|
+
### Data Sources
|
|
3349
|
+
|
|
3350
|
+
Session notes (\`~/.claude/projects/*/Notes/\`), git commits, completed TODO items \`[x]\`, journal entries (\`\${PAI_DIR}/Journal/\`), SeriousLetter jobs (if available), Todoist completed tasks (if available), calendar events (if available).
|
|
3351
|
+
|
|
3352
|
+
### Output Format
|
|
3353
|
+
|
|
3354
|
+
Group by THEME not chronology. Sections: project themes, job search, personal, key decisions, numbers (sessions/commits/tasks). Second-person voice ('You built...', 'You applied to...'). Highlight completed and shipped items.
|
|
3355
|
+
|
|
3356
|
+
**WhatsApp:** Condensed, bold headers, under 2000 chars. Voice: 30-60 sec conversational summary, top 3-5 achievements.`
|
|
3357
|
+
};
|
|
3358
|
+
|
|
3359
|
+
//#endregion
|
|
3360
|
+
//#region src/daemon-mcp/prompts/journal.ts
|
|
3361
|
+
const journal = {
|
|
3362
|
+
description: "Create, read, or search personal journal entries",
|
|
3363
|
+
content: `## Journal Skill
|
|
3364
|
+
|
|
3365
|
+
USE WHEN user says 'journal', 'note to self', 'capture this thought', 'journal entry', 'I want to write down', 'reflect on', 'yaja', '/journal', OR wants to record a freeform observation, insight, or personal note.
|
|
3366
|
+
|
|
3367
|
+
### Commands
|
|
3368
|
+
|
|
3369
|
+
| Command | Action |
|
|
3370
|
+
|---------|--------|
|
|
3371
|
+
| /journal | Create new entry |
|
|
3372
|
+
| /journal read | Read today's entries |
|
|
3373
|
+
| /journal search <query> | Search past entries |
|
|
3374
|
+
|
|
3375
|
+
### Storage
|
|
3376
|
+
|
|
3377
|
+
\`\${PAI_DIR}/Journal/YYYY/MM/YYYY-MM-DD.md\` — one file per day, entries appended with \`---\` separators.
|
|
3378
|
+
|
|
3379
|
+
### Entry Format
|
|
3380
|
+
|
|
3381
|
+
\`**HH:MM** — [content]\\n\\n#tags\`
|
|
3382
|
+
|
|
3383
|
+
### Auto-Tagging
|
|
3384
|
+
|
|
3385
|
+
Active project → \`#project-name\`, work → \`#work\`, mood → \`#reflection\`, idea → \`#idea\`, person → \`#people\`.
|
|
3386
|
+
|
|
3387
|
+
### Rules
|
|
3388
|
+
|
|
3389
|
+
Append-only. Never edit or delete existing entries. Preserve the user's voice — do not paraphrase. Voice entries via WhatsApp: clean up filler words, confirm with \`whatsapp_tts\`.`
|
|
3390
|
+
};
|
|
3391
|
+
|
|
3392
|
+
//#endregion
|
|
3393
|
+
//#region src/daemon-mcp/prompts/plan.ts
|
|
3394
|
+
const plan = {
|
|
3395
|
+
description: "Plan tomorrow, the week, or the month based on open tasks and calendar",
|
|
3396
|
+
content: `## Plan Skill
|
|
3397
|
+
|
|
3398
|
+
USE WHEN user says 'plan', 'what should I focus on', 'plan tomorrow', 'plan my week', 'what\\'s next', 'priorities', 'focus areas', '/plan', OR asks about upcoming work priorities or wants to set intentions for a time period.
|
|
3399
|
+
|
|
3400
|
+
### Commands
|
|
3401
|
+
|
|
3402
|
+
| Subcommand | Scope |
|
|
3403
|
+
|------------|-------|
|
|
3404
|
+
| /plan tomorrow | Next day, DEFAULT |
|
|
3405
|
+
| /plan week | Next 7 days |
|
|
3406
|
+
| /plan month | Next 30 days |
|
|
3407
|
+
|
|
3408
|
+
### Data Sources
|
|
3409
|
+
|
|
3410
|
+
Open TODO items \`[ ]\`, in-progress items \`[~]\`, calendar events, recent review data, journal insights tagged \`#idea\`, SeriousLetter pipeline.
|
|
3411
|
+
|
|
3412
|
+
### Output Format
|
|
3413
|
+
|
|
3414
|
+
Must Do / Should Do / Could Do (3-5 focus items max). Calendar constraints. Energy note from journal. Second-person, specific ('Add journal table to federation.db', NOT 'work on PAI').
|
|
3415
|
+
|
|
3416
|
+
### Rules
|
|
3417
|
+
|
|
3418
|
+
Never more than 7 focus items. Never plan without checking calendar first. Offer to save plan to journal.`
|
|
3419
|
+
};
|
|
3420
|
+
|
|
3421
|
+
//#endregion
|
|
3422
|
+
//#region src/daemon-mcp/prompts/share.ts
|
|
3423
|
+
const share = {
|
|
3424
|
+
description: "Generate LinkedIn, X/Twitter, or Bluesky posts about completed work",
|
|
3425
|
+
content: `## Share Skill
|
|
3426
|
+
|
|
3427
|
+
USE WHEN user says 'share on linkedin', 'post about', 'write a tweet about', '/share', 'linkedin post', 'tweet this', 'publish to X', 'bluesky post', 'post to bluesky', OR wants to create social media content about their work.
|
|
3428
|
+
|
|
3429
|
+
### Commands
|
|
3430
|
+
|
|
3431
|
+
| Subcommand | Platform | Period |
|
|
3432
|
+
|------------|----------|--------|
|
|
3433
|
+
| /share linkedin week | LinkedIn | Current week |
|
|
3434
|
+
| /share linkedin today | LinkedIn | Today |
|
|
3435
|
+
| /share linkedin "topic" | LinkedIn | Topic-filtered |
|
|
3436
|
+
| /share x | X/Twitter | Today |
|
|
3437
|
+
| /share x "topic" | X/Twitter | Topic-filtered |
|
|
3438
|
+
| /share bluesky | Bluesky | Today |
|
|
3439
|
+
|
|
3440
|
+
### LinkedIn Rules
|
|
3441
|
+
|
|
3442
|
+
1000-2000 chars, first-person builder voice, concrete hook opener, 3-5 hashtags at end. NEVER: 'leverage', 'synergy', 'excited to share'. YES: specific versions, numbers, performance deltas.
|
|
3443
|
+
|
|
3444
|
+
### X/Twitter Rules
|
|
3445
|
+
|
|
3446
|
+
Max 280 chars, 0-2 hashtags, lead with the interesting thing. Thread format: 3-5 tweets numbered '1/' '2/' etc. Offer to post via \`mcp__x__send_tweet\` — ALWAYS ask before posting.
|
|
3447
|
+
|
|
3448
|
+
### Bluesky Rules
|
|
3449
|
+
|
|
3450
|
+
Max 300 chars, no hashtags needed, warmer than X but still technical. Copy-paste only.
|
|
3451
|
+
|
|
3452
|
+
### Content Rule
|
|
3453
|
+
|
|
3454
|
+
Always gather real data first. If no interesting content found, say so rather than inflate.`
|
|
3455
|
+
};
|
|
3456
|
+
|
|
3457
|
+
//#endregion
|
|
3458
|
+
//#region src/daemon-mcp/prompts/sessions.ts
|
|
3459
|
+
const sessions = {
|
|
3460
|
+
description: "Navigate sessions, projects, and switch working context",
|
|
3461
|
+
content: `## Sessions Skill
|
|
3462
|
+
|
|
3463
|
+
USE WHEN user says 'list sessions', 'where was I working', 'show my sessions', 'find session', 'continue work from', 'switch to project', 'open project', 'name project', 'work on X', 'show me what we did on X', OR asks about past sessions, previous work, or project navigation.
|
|
3464
|
+
|
|
3465
|
+
### Key Commands
|
|
3466
|
+
|
|
3467
|
+
| Command | Action |
|
|
3468
|
+
|---------|--------|
|
|
3469
|
+
| pai session active | Show currently open Claude Code sessions |
|
|
3470
|
+
| pai session list | Full session list |
|
|
3471
|
+
| pai search "keyword" | Find sessions by keyword |
|
|
3472
|
+
| pai route <project> | Route notes to a project |
|
|
3473
|
+
| pai route | Show current routing |
|
|
3474
|
+
| pai route clear | Stop routing |
|
|
3475
|
+
| pai open <project> --claude | Open project in new tab |
|
|
3476
|
+
| pai name "Name" | Name current project |
|
|
3477
|
+
|
|
3478
|
+
### Intent Routing
|
|
3479
|
+
|
|
3480
|
+
- 'Work on X' / 'Start working on kioskpilot' → \`pai route <project>\`, then read that project's TODO.md
|
|
3481
|
+
- 'Show me sessions for PAI' / 'What did we do on X?' → \`pai search <project>\`
|
|
3482
|
+
- 'List sessions' → run \`pai session active\` FIRST (show active tabs prominently), then \`pai session list\`
|
|
3483
|
+
- 'Where are my notes going?' → \`pai route\` (no args)`
|
|
3484
|
+
};
|
|
3485
|
+
|
|
3486
|
+
//#endregion
|
|
3487
|
+
//#region src/daemon-mcp/prompts/route.ts
|
|
3488
|
+
const route = {
|
|
3489
|
+
description: "Detect which PAI project the current session belongs to",
|
|
3490
|
+
content: `## Route Skill
|
|
3491
|
+
|
|
3492
|
+
USE WHEN user says 'route', 'what project is this', 'tag this session', 'where does this belong', 'categorize this session', OR starting work in an unfamiliar directory needing to connect to a PAI project.
|
|
3493
|
+
|
|
3494
|
+
Detects current session context, searches PAI memory semantically and by keyword, and suggests which PAI project to route the session to.
|
|
3495
|
+
|
|
3496
|
+
### Workflow
|
|
3497
|
+
|
|
3498
|
+
Read CWD + project markers → search PAI memory → present top 3-5 matching projects with confidence → user picks → route and tag session.`
|
|
3499
|
+
};
|
|
3500
|
+
|
|
3501
|
+
//#endregion
|
|
3502
|
+
//#region src/daemon-mcp/prompts/search-history.ts
|
|
3503
|
+
const searchHistory = {
|
|
3504
|
+
description: "Search past sessions, history, and previous work by keyword",
|
|
3505
|
+
content: `## SearchHistory Skill
|
|
3506
|
+
|
|
3507
|
+
USE WHEN user says 'search history', 'find past', 'what did we do', 'when did we', OR asks about previous sessions, past work, or historical context.
|
|
3508
|
+
|
|
3509
|
+
### Search Commands
|
|
3510
|
+
|
|
3511
|
+
\`\`\`bash
|
|
3512
|
+
# Keyword search across all history and project notes
|
|
3513
|
+
rg -i -l "$QUERY" ~/.claude/History/ ~/.claude/projects/*/Notes/
|
|
3514
|
+
|
|
3515
|
+
# Recent files (last 7 days)
|
|
3516
|
+
find ~/.claude/projects/*/Notes -name "*.md" -mtime -7 | xargs ls -lt | head -10
|
|
3517
|
+
|
|
3518
|
+
# Search prompts (what did I ask about X?)
|
|
3519
|
+
rg -i '"prompt":.*KEYWORD' ~/.claude/History/raw-outputs/
|
|
3520
|
+
\`\`\`
|
|
3521
|
+
|
|
3522
|
+
### Locations
|
|
3523
|
+
|
|
3524
|
+
| Content | Location |
|
|
3525
|
+
|---------|----------|
|
|
3526
|
+
| Session notes | \`~/.claude/projects/*/Notes/*.md\` |
|
|
3527
|
+
| History sessions | \`~/.claude/History/sessions/YYYY-MM/\` |
|
|
3528
|
+
| Learnings | \`~/.claude/History/Learnings/YYYY-MM/\` |
|
|
3529
|
+
| Decisions | \`~/.claude/History/Decisions/YYYY-MM/\` |
|
|
3530
|
+
| All prompts | \`~/.claude/History/raw-outputs/YYYY-MM/*_all-events.jsonl\` |`
|
|
3531
|
+
};
|
|
3532
|
+
|
|
3533
|
+
//#endregion
|
|
3534
|
+
//#region src/daemon-mcp/prompts/name.ts
|
|
3535
|
+
const name = {
|
|
3536
|
+
description: "Name or rename the current session",
|
|
3537
|
+
content: `## Name Skill
|
|
3538
|
+
|
|
3539
|
+
USE WHEN user says '/name', 'name this session', 'rename session', OR wants to label what they're working on.
|
|
3540
|
+
|
|
3541
|
+
Call \`aibroker_rename\` with the provided name. Updates: AIBroker session registry, iTerm2 tab title, statusline display.
|
|
3542
|
+
|
|
3543
|
+
Usage: \`/name <new name>\` — immediately call \`aibroker_rename\`, no confirmation needed.`
|
|
3544
|
+
};
|
|
3545
|
+
|
|
3546
|
+
//#endregion
|
|
3547
|
+
//#region src/daemon-mcp/prompts/observability.ts
|
|
3548
|
+
const observability = {
|
|
3549
|
+
description: "Start, stop, or check the multi-agent observability dashboard",
|
|
3550
|
+
content: `## Observability Skill
|
|
3551
|
+
|
|
3552
|
+
USE WHEN user says 'start observability', 'stop dashboard', 'restart observability', 'monitor agents', 'show agent activity', or needs to debug multi-agent workflows.
|
|
3553
|
+
|
|
3554
|
+
### Commands
|
|
3555
|
+
|
|
3556
|
+
\`\`\`bash
|
|
3557
|
+
~/.claude/Skills/observability/manage.sh start # Start server + dashboard
|
|
3558
|
+
~/.claude/Skills/observability/manage.sh stop # Stop everything
|
|
3559
|
+
~/.claude/Skills/observability/manage.sh restart # Restart both
|
|
3560
|
+
~/.claude/Skills/observability/manage.sh status # Check status
|
|
3561
|
+
\`\`\`
|
|
3562
|
+
|
|
3563
|
+
### Access
|
|
3564
|
+
|
|
3565
|
+
Dashboard UI: http://localhost:5172 | Server API: http://localhost:4000
|
|
3566
|
+
|
|
3567
|
+
### What It Monitors
|
|
3568
|
+
|
|
3569
|
+
Agent session starts/ends, tool calls across all agents, hook event execution, session timelines. Data source: \`~/.claude/History/raw-outputs/YYYY-MM/YYYY-MM-DD_all-events.jsonl\`.`
|
|
3570
|
+
};
|
|
3571
|
+
|
|
3572
|
+
//#endregion
|
|
3573
|
+
//#region src/daemon-mcp/prompts/research.ts
|
|
3574
|
+
const research = {
|
|
3575
|
+
description: "Web research, content extraction, and wisdom analysis via parallel agents",
|
|
3576
|
+
content: `## Research Skill
|
|
3577
|
+
|
|
3578
|
+
USE WHEN user says 'do research', 'extract wisdom', 'analyze content', 'find information about', or requests web/content research.
|
|
3579
|
+
|
|
3580
|
+
### Research Modes
|
|
3581
|
+
|
|
3582
|
+
- Quick: 1 agent per type, 2 min timeout
|
|
3583
|
+
- Standard (default): 3 agents per type, 3 min timeout
|
|
3584
|
+
- Extensive: 8 agents per type, 10 min timeout
|
|
3585
|
+
|
|
3586
|
+
### Available Agents
|
|
3587
|
+
|
|
3588
|
+
\`claude-researcher\` (free, WebSearch), \`perplexity-researcher\` (PERPLEXITY_API_KEY), \`gemini-researcher\` (GOOGLE_API_KEY).
|
|
3589
|
+
|
|
3590
|
+
### Workflow Routing
|
|
3591
|
+
|
|
3592
|
+
- Parallel research → read \`\${PAI_DIR}/Skills/research/workflows/conduct.md\`
|
|
3593
|
+
- Claude research (free) → \`workflows/claude-research.md\`
|
|
3594
|
+
- Blocked content / CAPTCHA → escalate: WebFetch → BrightData → Apify
|
|
3595
|
+
- YouTube URL → \`fabric -y <URL>\` then pattern
|
|
3596
|
+
- Fabric patterns → 242+ patterns including: \`extract_wisdom\`, \`summarize\`, \`create_threat_model\`, \`analyze_claims\`, \`improve_writing\`
|
|
3597
|
+
|
|
3598
|
+
### Fabric Usage
|
|
3599
|
+
|
|
3600
|
+
\`fabric [input] -p [pattern]\` or \`fabric -u "URL" -p [pattern]\` or \`fabric -y "YOUTUBE_URL" -p [pattern]\``
|
|
3601
|
+
};
|
|
3602
|
+
|
|
3603
|
+
//#endregion
|
|
3604
|
+
//#region src/daemon-mcp/prompts/art.ts
|
|
3605
|
+
const art = {
|
|
3606
|
+
description: "Create visual content, diagrams, flowcharts, and AI-generated images",
|
|
3607
|
+
content: `## Art Skill
|
|
3608
|
+
|
|
3609
|
+
USE WHEN user wants to create visual content, illustrations, diagrams, art, header images, visualizations, mermaid charts, flowcharts, or any visual request.
|
|
3610
|
+
|
|
3611
|
+
### Aesthetic
|
|
3612
|
+
|
|
3613
|
+
Tron-meets-Excalidraw — dark slate backgrounds, neon orange + cyan accents, hand-drawn sketch lines, subtle glows. Full details: fetch resource \`pai://aesthetic\`.
|
|
3614
|
+
|
|
3615
|
+
### Workflow Routing by Content Type
|
|
3616
|
+
|
|
3617
|
+
| Request | Workflow |
|
|
3618
|
+
|---------|----------|
|
|
3619
|
+
| Unsure which format | \`workflows/visualize.md\` (adaptive orchestrator) |
|
|
3620
|
+
| Blog header / editorial | \`workflows/workflow.md\` |
|
|
3621
|
+
| Flowchart / sequence / state | \`workflows/mermaid.md\` |
|
|
3622
|
+
| Architecture / system diagram | \`workflows/technical-diagrams.md\` |
|
|
3623
|
+
| Classification grid | \`workflows/taxonomies.md\` |
|
|
3624
|
+
| Timeline / chronological | \`workflows/timelines.md\` |
|
|
3625
|
+
| 2x2 matrix / framework | \`workflows/frameworks.md\` |
|
|
3626
|
+
| X vs Y comparison | \`workflows/comparisons.md\` |
|
|
3627
|
+
| Annotated screenshot | \`workflows/annotated-screenshots.md\` |
|
|
3628
|
+
| Quote card | \`workflows/aphorisms.md\` |
|
|
3629
|
+
| Stats / big number | \`workflows/stats.md\` |
|
|
3630
|
+
|
|
3631
|
+
### Image Generation
|
|
3632
|
+
|
|
3633
|
+
\`bun run \${PAI_DIR}/Skills/art/tools/generate-ulart-image.ts --model nano-banana-pro --prompt "[PROMPT]" --size 2K\``
|
|
3634
|
+
};
|
|
3635
|
+
|
|
3636
|
+
//#endregion
|
|
3637
|
+
//#region src/daemon-mcp/prompts/createskill.ts
|
|
3638
|
+
const createskill = {
|
|
3639
|
+
description: "Create, validate, update, or canonicalize a PAI skill",
|
|
3640
|
+
content: `## Createskill Skill
|
|
3641
|
+
|
|
3642
|
+
USE WHEN user wants to create, validate, update, or canonicalize a skill, OR mentions skill creation, new skill, build skill, skill compliance, or skill structure.
|
|
3643
|
+
|
|
3644
|
+
Before creating any skill, READ the skill system spec: fetch resource \`pai://skill-system\`.
|
|
3645
|
+
|
|
3646
|
+
### Naming Convention
|
|
3647
|
+
|
|
3648
|
+
All skill directories and workflow files use TitleCase (PascalCase). NEVER: \`createskill\`, \`create-skill\`, \`create.md\`.
|
|
3649
|
+
|
|
3650
|
+
### Workflow Routing
|
|
3651
|
+
|
|
3652
|
+
| Trigger | Workflow |
|
|
3653
|
+
|---------|----------|
|
|
3654
|
+
| 'create a new skill' | \`workflows/CreateSkill.md\` |
|
|
3655
|
+
| 'validate skill', 'check skill' | \`workflows/ValidateSkill.md\` |
|
|
3656
|
+
| 'update skill', 'add workflow' | \`workflows/UpdateSkill.md\` |
|
|
3657
|
+
| 'canonicalize', 'fix skill structure' | \`workflows/CanonicalizeSkill.md\` |`
|
|
3658
|
+
};
|
|
3659
|
+
|
|
3660
|
+
//#endregion
|
|
3661
|
+
//#region src/daemon-mcp/prompts/story-explanation.ts
|
|
3662
|
+
const storyExplanation = {
|
|
3663
|
+
description: "Create numbered narrative story explanations of any content",
|
|
3664
|
+
content: `## StoryExplanation Skill
|
|
3665
|
+
|
|
3666
|
+
USE WHEN user explicitly says '/story', 'create story explanation', 'run CSE', 'explain this as a story', 'story with links', 'deep story'. Do NOT activate on vague mentions of 'story'.
|
|
3667
|
+
|
|
3668
|
+
### Commands
|
|
3669
|
+
|
|
3670
|
+
| Command | Output |
|
|
3671
|
+
|---------|--------|
|
|
3672
|
+
| /story [content] | 8 numbered narrative points (default) |
|
|
3673
|
+
| /story [N] [content] | N numbered points (3-50) |
|
|
3674
|
+
| /story deep [content] | 20+ points deep dive |
|
|
3675
|
+
| /story links [content] | N points with inline links |
|
|
3676
|
+
|
|
3677
|
+
### Input Sources
|
|
3678
|
+
|
|
3679
|
+
URL (WebFetch), YouTube URL (\`fabric -y <URL>\`), file path (Read), pasted text (direct).`
|
|
3680
|
+
};
|
|
3681
|
+
|
|
3682
|
+
//#endregion
|
|
3683
|
+
//#region src/daemon-mcp/prompts/vault-context.ts
|
|
3684
|
+
const vaultContext = {
|
|
3685
|
+
description: "Load Obsidian vault context for a morning briefing",
|
|
3686
|
+
content: `## VaultContext Skill
|
|
3687
|
+
|
|
3688
|
+
USE WHEN user says 'load vault context', 'brief me from Obsidian', 'morning briefing', '/vault-context', 'what am I working on', 'what\\'s in my vault'.
|
|
3689
|
+
|
|
3690
|
+
Reads: daily note → open TODOs → PAI index (active projects) → HOME.md (focus areas) → recent insights. Synthesizes into morning briefing with Suggested First Action.
|
|
3691
|
+
|
|
3692
|
+
All vault skills work with the vault configured in \`~/.config/pai/config.json\` (\`vaultPath\` key).`
|
|
3693
|
+
};
|
|
3694
|
+
|
|
3695
|
+
//#endregion
|
|
3696
|
+
//#region src/daemon-mcp/prompts/vault-connect.ts
|
|
3697
|
+
const vaultConnect = {
|
|
3698
|
+
description: "Find connections between two topics in the Obsidian vault",
|
|
3699
|
+
content: `## VaultConnect Skill
|
|
3700
|
+
|
|
3701
|
+
USE WHEN user says 'connect X and Y', 'how does X relate to Y', 'find path between', 'bridge topics', '/vault-connect', OR asks how two ideas are connected in the vault.
|
|
3702
|
+
|
|
3703
|
+
Finds connections between two topics via the wikilink graph: direct links → 1-hop bridges → 2-hop paths. If no path found, offers to create a bridge note.`
|
|
3704
|
+
};
|
|
3705
|
+
|
|
3706
|
+
//#endregion
|
|
3707
|
+
//#region src/daemon-mcp/prompts/vault-emerge.ts
|
|
3708
|
+
const vaultEmerge = {
|
|
3709
|
+
description: "Surface emerging themes and clusters forming in the vault",
|
|
3710
|
+
content: `## VaultEmerge Skill
|
|
3711
|
+
|
|
3712
|
+
USE WHEN user says 'what\\'s emerging', 'find patterns', 'emerging clusters', 'themes in vault', '/vault-emerge', 'new projects forming', 'what am I thinking about', 'recent themes'.
|
|
3713
|
+
|
|
3714
|
+
Finds notes modified in last 90 days sharing keywords but not yet linked to each other. Surfaces top 8-10 emerging clusters with note counts and folder diversity. Offers to create MOC (Map of Content) index notes for top clusters.`
|
|
3715
|
+
};
|
|
3716
|
+
|
|
3717
|
+
//#endregion
|
|
3718
|
+
//#region src/daemon-mcp/prompts/vault-orphans.ts
|
|
3719
|
+
const vaultOrphans = {
|
|
3720
|
+
description: "Find and reconnect orphaned notes with zero inbound links",
|
|
3721
|
+
content: `## VaultOrphans Skill
|
|
3722
|
+
|
|
3723
|
+
USE WHEN user says 'find orphans', 'orphaned notes', 'unlinked notes', 'vault orphans', '/vault-orphans', 'clean up vault graph', 'disconnected notes'.
|
|
3724
|
+
|
|
3725
|
+
Finds notes with zero inbound wikilinks. Groups by top-level folder. Excludes expected orphan folders (PAI/, Daily Notes/). For each orphan, suggests connections to existing notes and drafts specific wikilink text.`
|
|
3726
|
+
};
|
|
3727
|
+
|
|
3728
|
+
//#endregion
|
|
3729
|
+
//#region src/daemon-mcp/prompts/vault-trace.ts
|
|
3730
|
+
const vaultTrace = {
|
|
3731
|
+
description: "Trace the evolution of an idea across vault notes over time",
|
|
3732
|
+
content: `## VaultTrace Skill
|
|
3733
|
+
|
|
3734
|
+
USE WHEN user says 'trace idea', 'how did X evolve', 'history of X in notes', 'when did I first write about', '/vault-trace', 'timeline of X', 'track idea evolution', 'idea history'.
|
|
3735
|
+
|
|
3736
|
+
Builds a chronological timeline of how an idea first appeared and evolved across vault notes. Extracts relevant excerpts. Identifies inflection points where framing shifted. Summarizes the evolution arc (first appearance → development → current state).`
|
|
3737
|
+
};
|
|
3738
|
+
|
|
3739
|
+
//#endregion
|
|
3740
|
+
//#region src/daemon-mcp/resources/aesthetic.ts
|
|
3741
|
+
const aesthetic = {
|
|
3742
|
+
name: "aesthetic",
|
|
3743
|
+
uri: "pai://aesthetic",
|
|
3744
|
+
description: "PAI visual aesthetic guide — Tron-meets-Excalidraw style system",
|
|
3745
|
+
content: `# PAI Visual Aesthetic System
|
|
3746
|
+
|
|
3747
|
+
A modern digital aesthetic combining Tron-inspired neon elements, Anthropic's warm color palette, and Excalidraw's hand-drawn charm.
|
|
3748
|
+
|
|
3749
|
+
## Core Concept: Digital Warmth
|
|
3750
|
+
|
|
3751
|
+
Every visualization balances futuristic precision with human imperfection — clean digital aesthetics rendered with hand-drawn, sketchy energy.
|
|
3752
|
+
|
|
3753
|
+
**The Philosophy:** Technology with humanity.
|
|
3754
|
+
|
|
3755
|
+
## Color System
|
|
3756
|
+
|
|
3757
|
+
### Backgrounds
|
|
3758
|
+
- Deep Slate: #1A202C (primary)
|
|
3759
|
+
- Pure Black: #000000 (alternative)
|
|
3760
|
+
|
|
3761
|
+
### Accent Colors
|
|
3762
|
+
- Neon Orange: #FF6B35 (Anthropic warmth — primary accent)
|
|
3763
|
+
- Neon Coral: #FF8C61 (softer warmth variant)
|
|
3764
|
+
- Cyan Glow: #00D9FF (Tron digital accent — use sparingly)
|
|
3765
|
+
- Electric Blue: #0099FF (secondary digital accent)
|
|
3766
|
+
|
|
3767
|
+
## Absolute Rules
|
|
3768
|
+
|
|
3769
|
+
1. HAND-DRAWN SKETCH STYLE — Rough, imperfect, Excalidraw aesthetic
|
|
3770
|
+
2. DARK BACKGROUNDS — Deep slate or black for contrast
|
|
3771
|
+
3. WHITE PRIMARY LINES — Dominant sketch linework
|
|
3772
|
+
4. ORANGE MAIN ACCENT — Anthropic warmth, approachability
|
|
3773
|
+
5. CYAN SECONDARY ACCENT — Digital/technical elements (Tron)
|
|
3774
|
+
6. SUBTLE GLOWS — Strategic, not overwhelming
|
|
3775
|
+
7. MINIMAL ELEMENTS — 2-4 components maximum
|
|
3776
|
+
8. GENEROUS SPACE — 40-50% negative space
|
|
3777
|
+
9. NO PERFECTION — Embrace the sketchy, hand-drawn quality
|
|
3778
|
+
|
|
3779
|
+
## AI Generation Positive Signals
|
|
3780
|
+
|
|
3781
|
+
"hand-drawn sketch style", "Excalidraw whiteboard aesthetic", "rough wobbly lines",
|
|
3782
|
+
"dark background slate or black", "neon orange accents", "subtle cyan glow",
|
|
3783
|
+
"Tron-inspired neon highlights", "minimal composition", "generous negative space"
|
|
3784
|
+
`
|
|
3785
|
+
};
|
|
3786
|
+
|
|
3787
|
+
//#endregion
|
|
3788
|
+
//#region src/daemon-mcp/resources/constitution.ts
|
|
3789
|
+
const constitution = {
|
|
3790
|
+
name: "constitution",
|
|
3791
|
+
uri: "pai://constitution",
|
|
3792
|
+
description: "PAI system constitution — founding principles, architecture, and directory structure",
|
|
3793
|
+
content: `# PAI System Constitution — Summary
|
|
3794
|
+
|
|
3795
|
+
The foundational philosophy, architecture, and operations of PAI (Personal AI Infrastructure).
|
|
3796
|
+
|
|
3797
|
+
## Eight Founding Principles
|
|
3798
|
+
|
|
3799
|
+
1. **Scaffolding > Model** — System architecture matters more than the underlying model. Build the scaffolding first.
|
|
3800
|
+
2. **As Deterministic as Possible** — Favor predictable, repeatable outcomes. CLI tools over ad-hoc prompting.
|
|
3801
|
+
3. **Progressive Disclosure** — Show what's needed, when it's needed. Routing tables in instructions; full content in prompts.
|
|
3802
|
+
4. **Skills as Containers** — Each skill is a self-contained unit with SKILL.md, workflows/, and tools/.
|
|
3803
|
+
5. **CLI-First** — Every capability should be accessible from the command line before being wrapped in prompts.
|
|
3804
|
+
6. **Two-Tier MCP** — Thin routing shim (daemon-mcp) + full capability daemon. Never merge them.
|
|
3805
|
+
7. **History as Memory** — All work is captured automatically to \${PAI_DIR}/History/. Work normally, docs handle themselves.
|
|
3806
|
+
8. **Fail Gracefully** — Hooks and automations must never block the AI. Always exit 0.
|
|
3807
|
+
|
|
3808
|
+
## Architecture Layers
|
|
3809
|
+
|
|
3810
|
+
\`\`\`
|
|
3811
|
+
User
|
|
3812
|
+
└── Claude Code (+ PAI MCP shim)
|
|
3813
|
+
└── PAI Daemon (IPC socket)
|
|
3814
|
+
├── federation.db (SQLite — memory, projects, sessions, vault)
|
|
3815
|
+
├── Embedding model (singleton)
|
|
3816
|
+
└── Project registry
|
|
3817
|
+
\`\`\`
|
|
3818
|
+
|
|
3819
|
+
## The Four Primitives
|
|
3820
|
+
|
|
3821
|
+
| Primitive | Location | Purpose |
|
|
3822
|
+
|-----------|----------|---------|
|
|
3823
|
+
| Memory | \${PAI_DIR}/projects/*/Notes/ | Session notes, todos |
|
|
3824
|
+
| Skills | ~/.claude/Skills/ | Workflow instructions |
|
|
3825
|
+
| History | \${PAI_DIR}/History/ | Automated capture |
|
|
3826
|
+
| Config | ~/.config/pai/ | Agent preferences, voices |
|
|
3827
|
+
|
|
3828
|
+
## Two-Tier MCP Strategy
|
|
3829
|
+
|
|
3830
|
+
- **daemon-mcp (shim)**: Thin proxy. Handles tool routing via IPC. Serves prompts and resources.
|
|
3831
|
+
- **daemon**: Full capability server. Holds DB connections, embedding model, search engine.
|
|
3832
|
+
|
|
3833
|
+
## Directory Structure
|
|
3834
|
+
|
|
3835
|
+
\`\`\`
|
|
3836
|
+
~/.claude/
|
|
3837
|
+
├── Skills/
|
|
3838
|
+
│ ├── CORE/ # PAI core skill (auto-loaded at session start)
|
|
3839
|
+
│ └── user/ # Personal custom skills (gitignored)
|
|
3840
|
+
├── Hooks/ # Event-driven automation scripts
|
|
3841
|
+
├── History/ # Universal Output Capture System
|
|
3842
|
+
│ ├── Sessions/
|
|
3843
|
+
│ ├── Learnings/
|
|
3844
|
+
│ ├── Research/
|
|
3845
|
+
│ ├── Decisions/
|
|
3846
|
+
│ └── Execution/
|
|
3847
|
+
└── projects/ # Claude Code session data
|
|
3848
|
+
\`\`\`
|
|
3849
|
+
|
|
3850
|
+
## Security Model
|
|
3851
|
+
|
|
3852
|
+
- PRIVATE PAI (\${PAI_DIR}/): Contains all personal data. Never make public.
|
|
3853
|
+
- PUBLIC PAI (~/Projects/PAI/): Sanitized code only. Reviewed before every commit.
|
|
3854
|
+
- Rule: Run \`git remote -v\` before every push.
|
|
3855
|
+
`
|
|
3856
|
+
};
|
|
3857
|
+
|
|
3858
|
+
//#endregion
|
|
3859
|
+
//#region src/daemon-mcp/resources/prompting.ts
|
|
3860
|
+
const prompting = {
|
|
3861
|
+
name: "prompting",
|
|
3862
|
+
uri: "pai://prompting",
|
|
3863
|
+
description: "Prompt engineering standards — context engineering, signal-to-noise, anti-patterns",
|
|
3864
|
+
content: `# Prompt Engineering Standards
|
|
3865
|
+
|
|
3866
|
+
Based on Anthropic's context engineering principles and Daniel Miessler's Fabric system.
|
|
3867
|
+
|
|
3868
|
+
## Core Philosophy
|
|
3869
|
+
|
|
3870
|
+
Context engineering: the set of strategies for curating and maintaining the optimal set of tokens during LLM inference.
|
|
3871
|
+
|
|
3872
|
+
Primary goal: Find the smallest possible set of high-signal tokens that maximize the likelihood of desired outcomes.
|
|
3873
|
+
|
|
3874
|
+
## Key Principles
|
|
3875
|
+
|
|
3876
|
+
### 1. Context is a Finite Resource
|
|
3877
|
+
|
|
3878
|
+
- LLMs have a limited attention budget
|
|
3879
|
+
- Every token depletes attention capacity
|
|
3880
|
+
- Treat context as precious and finite
|
|
3881
|
+
|
|
3882
|
+
### 2. Optimize for Signal-to-Noise Ratio
|
|
3883
|
+
|
|
3884
|
+
- Prefer clear, direct language over verbose explanations
|
|
3885
|
+
- Remove redundant or overlapping information
|
|
3886
|
+
- Focus on high-value tokens that drive desired outcomes
|
|
3887
|
+
|
|
3888
|
+
### 3. Progressive Information Discovery
|
|
3889
|
+
|
|
3890
|
+
- Use lightweight identifiers rather than full data dumps
|
|
3891
|
+
- Load detailed information dynamically when needed
|
|
3892
|
+
- Allow agents to discover information just-in-time
|
|
3893
|
+
|
|
3894
|
+
## Markdown Structure Standards
|
|
3895
|
+
|
|
3896
|
+
Organize prompts into distinct semantic sections:
|
|
3897
|
+
|
|
3898
|
+
\`\`\`markdown
|
|
3899
|
+
## Background Information
|
|
3900
|
+
Essential context about the domain
|
|
3901
|
+
|
|
3902
|
+
## Instructions
|
|
3903
|
+
Clear, actionable directives
|
|
3904
|
+
|
|
3905
|
+
## Examples
|
|
3906
|
+
Concrete examples (1-3 optimal)
|
|
3907
|
+
|
|
3908
|
+
## Constraints
|
|
3909
|
+
Boundaries, limitations, requirements
|
|
3910
|
+
|
|
3911
|
+
## Output Format
|
|
3912
|
+
Explicit specification of desired response structure
|
|
3913
|
+
\`\`\`
|
|
3914
|
+
|
|
3915
|
+
## Writing Style
|
|
3916
|
+
|
|
3917
|
+
**Clarity over completeness:**
|
|
3918
|
+
- Good: "Validate user input before processing"
|
|
3919
|
+
- Bad: "You should always make sure to validate the user's input..."
|
|
3920
|
+
|
|
3921
|
+
**Be direct and specific:**
|
|
3922
|
+
- Good: "Use the calculate_tax tool with amount and jurisdiction parameters"
|
|
3923
|
+
- Bad: "You might want to consider using the calculate_tax tool if you need..."
|
|
3924
|
+
|
|
3925
|
+
## Anti-Patterns
|
|
3926
|
+
|
|
3927
|
+
- Verbose explanations instead of direct instructions
|
|
3928
|
+
- Historical context dumping (how we got here)
|
|
3929
|
+
- Overlapping tool definitions
|
|
3930
|
+
- Premature information loading
|
|
3931
|
+
- Vague hedging: "might", "could", "should consider"
|
|
3932
|
+
|
|
3933
|
+
## Context Management Strategies
|
|
3934
|
+
|
|
3935
|
+
1. **Just-in-time loading** — Provide SKU/ID, not full data dumps
|
|
3936
|
+
2. **Sub-agent architectures** — Delegate subtasks, each agent gets minimal context
|
|
3937
|
+
3. **Structured note-taking** — Persist important information outside context window
|
|
3938
|
+
4. **Compaction** — Summarize older conversation segments, preserve critical state
|
|
3939
|
+
|
|
3940
|
+
## Evolution
|
|
3941
|
+
|
|
3942
|
+
1. Start minimal
|
|
3943
|
+
2. Measure performance
|
|
3944
|
+
3. Identify gaps
|
|
3945
|
+
4. Add strategically
|
|
3946
|
+
5. Prune regularly
|
|
3947
|
+
6. Iterate
|
|
3948
|
+
|
|
3949
|
+
Source: Anthropic "Effective Context Engineering for AI Agents", Daniel Miessler Fabric (2024)
|
|
3950
|
+
`
|
|
3951
|
+
};
|
|
3952
|
+
|
|
3953
|
+
//#endregion
|
|
3954
|
+
//#region src/daemon-mcp/resources/prosody-guide.ts
|
|
3955
|
+
const prosodyGuide = {
|
|
3956
|
+
name: "prosody-guide",
|
|
3957
|
+
uri: "pai://prosody-guide",
|
|
3958
|
+
description: "Voice prosody system — emotional markers and markdown pacing",
|
|
3959
|
+
content: `# Voice Prosody System
|
|
3960
|
+
|
|
3961
|
+
Controls emotional delivery and pacing across PAI agents.
|
|
3962
|
+
|
|
3963
|
+
## Emotional Intelligence Markers
|
|
3964
|
+
|
|
3965
|
+
| Marker | When to Use |
|
|
3966
|
+
|--------|-------------|
|
|
3967
|
+
| [excited] | Breakthroughs, discoveries, exciting results |
|
|
3968
|
+
| [success] | Completions, wins, achievements |
|
|
3969
|
+
| [caution] | Warnings, partial success, needs review |
|
|
3970
|
+
| [urgent] | Critical issues, immediate action needed |
|
|
3971
|
+
|
|
3972
|
+
## Markdown Prosody
|
|
3973
|
+
|
|
3974
|
+
- **bold** — Emphasize key words (Found the **actual** bug)
|
|
3975
|
+
- ... — Dramatic pause (Wait... I found something)
|
|
3976
|
+
- -- — Thoughtful break (Complete -- all systems operational)
|
|
3977
|
+
- ! — Energy and excitement
|
|
3978
|
+
|
|
3979
|
+
## Agent Archetypes
|
|
3980
|
+
|
|
3981
|
+
- Enthusiasts (fast, excited): More ellipses, exclamations, [excited] marker
|
|
3982
|
+
- Professionals (balanced): Emphasis on actions, measured pauses, [success] marker
|
|
3983
|
+
- Analysts (confident): Bold findings, authoritative, minimal markers
|
|
3984
|
+
- Wise Leaders (deliberate): Em-dashes, minimal exclamations, measured
|
|
3985
|
+
|
|
3986
|
+
## COMPLETED Line Format
|
|
3987
|
+
|
|
3988
|
+
\`\`\`
|
|
3989
|
+
COMPLETED: [AGENT:type] [optional marker] message with **emphasis**... and pauses!
|
|
3990
|
+
\`\`\`
|
|
3991
|
+
|
|
3992
|
+
Maximum 12 words. End with punctuation.
|
|
3993
|
+
`
|
|
3994
|
+
};
|
|
3995
|
+
|
|
3996
|
+
//#endregion
|
|
3997
|
+
//#region src/daemon-mcp/resources/prosody-agent-template.ts
|
|
3998
|
+
const prosodyAgentTemplate = {
|
|
3999
|
+
name: "prosody-agent-template",
|
|
4000
|
+
uri: "pai://prosody-agent-template",
|
|
4001
|
+
description: "Template for adding prosody requirements to agent definitions",
|
|
4002
|
+
content: `# Agent Prosody Template
|
|
4003
|
+
|
|
4004
|
+
Universal prosody section to add to agent definition files.
|
|
4005
|
+
|
|
4006
|
+
## Voice Prosody Requirements
|
|
4007
|
+
|
|
4008
|
+
Your voice delivery is controlled by prosody markers in your COMPLETED lines.
|
|
4009
|
+
|
|
4010
|
+
### Emotional Intelligence Markers
|
|
4011
|
+
|
|
4012
|
+
- [excited] — Breakthroughs, discoveries, exciting results
|
|
4013
|
+
- [success] — Completions, wins, achievements
|
|
4014
|
+
- [caution] — Warnings, partial success, needs review
|
|
4015
|
+
- [urgent] — Critical issues, immediate action needed
|
|
4016
|
+
|
|
4017
|
+
### Markdown Prosody
|
|
4018
|
+
|
|
4019
|
+
- **bold** — Emphasize key words
|
|
4020
|
+
- ... — Dramatic pauses
|
|
4021
|
+
- -- — Thoughtful breaks
|
|
4022
|
+
- ! — Energy and excitement
|
|
4023
|
+
|
|
4024
|
+
### Quick Reference
|
|
4025
|
+
|
|
4026
|
+
\`\`\`
|
|
4027
|
+
COMPLETED: [AGENT:your-type] [optional marker] message with **emphasis**... and pauses!
|
|
4028
|
+
\`\`\`
|
|
4029
|
+
|
|
4030
|
+
Full Guide: fetch resource pai://prosody-guide
|
|
4031
|
+
`
|
|
4032
|
+
};
|
|
4033
|
+
|
|
4034
|
+
//#endregion
|
|
4035
|
+
//#region src/daemon-mcp/resources/voice.ts
|
|
4036
|
+
const voice = {
|
|
4037
|
+
name: "voice",
|
|
4038
|
+
uri: "pai://voice",
|
|
4039
|
+
description: "Voice system reference — server management and voice IDs",
|
|
4040
|
+
content: `# Voice System Reference
|
|
4041
|
+
|
|
4042
|
+
## Voice Server Quick Reference
|
|
4043
|
+
|
|
4044
|
+
Start: \${PAI_DIR}/voice-server/start.sh
|
|
4045
|
+
Status: \${PAI_DIR}/voice-server/status.sh
|
|
4046
|
+
Restart: \${PAI_DIR}/voice-server/restart.sh
|
|
4047
|
+
Stop: \${PAI_DIR}/voice-server/stop.sh
|
|
4048
|
+
|
|
4049
|
+
Test:
|
|
4050
|
+
\`\`\`bash
|
|
4051
|
+
curl -X POST http://localhost:8888/notify \\
|
|
4052
|
+
-H "Content-Type: application/json" \\
|
|
4053
|
+
-d '{"message":"Test message","voice_enabled":true}'
|
|
4054
|
+
\`\`\`
|
|
4055
|
+
|
|
4056
|
+
## Agent Voice IDs (ElevenLabs)
|
|
4057
|
+
|
|
4058
|
+
| Agent | Description |
|
|
4059
|
+
|-------|-------------|
|
|
4060
|
+
| PAI (Main) | UK Male - Professional |
|
|
4061
|
+
| Researcher | US Female - Analytical |
|
|
4062
|
+
| Engineer | US Female - Steady |
|
|
4063
|
+
| Architect | UK Female - Strategic |
|
|
4064
|
+
| Designer | Indian Female - Creative |
|
|
4065
|
+
| Pentester | UK Male - Technical |
|
|
4066
|
+
|
|
4067
|
+
See \${PAI_DIR}/voice-server/README.md for complete voice list and IDs.
|
|
4068
|
+
|
|
4069
|
+
## Important
|
|
4070
|
+
|
|
4071
|
+
The voice-server directory is the canonical source for all voice system documentation.
|
|
4072
|
+
Always refer to and update voice-server documentation directly.
|
|
4073
|
+
`
|
|
4074
|
+
};
|
|
4075
|
+
|
|
4076
|
+
//#endregion
|
|
4077
|
+
//#region src/daemon-mcp/resources/skill-system.ts
|
|
4078
|
+
const skillSystem = {
|
|
4079
|
+
name: "skill-system",
|
|
4080
|
+
uri: "pai://skill-system",
|
|
4081
|
+
description: "Custom skill system specification — TitleCase naming, SKILL.md structure",
|
|
4082
|
+
content: `# Custom Skill System
|
|
4083
|
+
|
|
4084
|
+
The MANDATORY configuration system for ALL PAI skills.
|
|
4085
|
+
|
|
4086
|
+
## TitleCase Naming Convention (MANDATORY)
|
|
4087
|
+
|
|
4088
|
+
| Component | Wrong | Correct |
|
|
4089
|
+
|-----------|-------|---------|
|
|
4090
|
+
| Skill directory | createskill, create-skill | Createskill |
|
|
4091
|
+
| Workflow files | create.md, update-info.md | Create.md, UpdateInfo.md |
|
|
4092
|
+
| Reference docs | prosody-guide.md | ProsodyGuide.md |
|
|
4093
|
+
| YAML name | name: create-skill | name: Createskill |
|
|
4094
|
+
|
|
4095
|
+
Exception: SKILL.md is always uppercase.
|
|
4096
|
+
|
|
4097
|
+
## Required Structure
|
|
4098
|
+
|
|
4099
|
+
Every SKILL.md has two parts:
|
|
4100
|
+
|
|
4101
|
+
### 1. YAML Frontmatter
|
|
4102
|
+
|
|
4103
|
+
\`\`\`yaml
|
|
4104
|
+
---
|
|
4105
|
+
name: SkillName
|
|
4106
|
+
description: [What it does]. USE WHEN [intent triggers using OR]. [Capabilities].
|
|
4107
|
+
---
|
|
4108
|
+
\`\`\`
|
|
4109
|
+
|
|
4110
|
+
Rules:
|
|
4111
|
+
- name uses TitleCase
|
|
4112
|
+
- description is a single line (not multi-line with |)
|
|
4113
|
+
- USE WHEN keyword is MANDATORY (Claude Code parses this for skill activation)
|
|
4114
|
+
- Use intent-based triggers with OR for multiple conditions
|
|
4115
|
+
- Max 1024 characters (Anthropic hard limit)
|
|
4116
|
+
|
|
4117
|
+
### 2. Markdown Body
|
|
4118
|
+
|
|
4119
|
+
\`\`\`markdown
|
|
4120
|
+
# SkillName
|
|
4121
|
+
|
|
4122
|
+
[Brief description]
|
|
4123
|
+
|
|
4124
|
+
## Workflow Routing
|
|
4125
|
+
|
|
4126
|
+
| Workflow | Trigger | File |
|
|
4127
|
+
|----------|---------|------|
|
|
4128
|
+
| **WorkflowOne** | "trigger phrase" | workflows/WorkflowOne.md |
|
|
4129
|
+
|
|
4130
|
+
## Examples
|
|
4131
|
+
|
|
4132
|
+
**Example 1: [Common use case]**
|
|
4133
|
+
User: "[Typical user request]"
|
|
4134
|
+
→ Invokes WorkflowOne workflow
|
|
4135
|
+
→ [What skill does]
|
|
4136
|
+
\`\`\`
|
|
4137
|
+
|
|
4138
|
+
## Complete Checklist
|
|
4139
|
+
|
|
4140
|
+
- [ ] Skill directory uses TitleCase
|
|
4141
|
+
- [ ] All workflow files use TitleCase
|
|
4142
|
+
- [ ] YAML name: uses TitleCase
|
|
4143
|
+
- [ ] Single-line description with embedded USE WHEN clause
|
|
4144
|
+
- [ ] Description under 1024 characters
|
|
4145
|
+
- [ ] Workflow Routing section with table format
|
|
4146
|
+
- [ ] Examples section with 2-3 concrete patterns
|
|
4147
|
+
- [ ] tools/ directory exists (even if empty)
|
|
4148
|
+
- [ ] No backups/ directory inside skill
|
|
4149
|
+
`
|
|
4150
|
+
};
|
|
4151
|
+
|
|
4152
|
+
//#endregion
|
|
4153
|
+
//#region src/daemon-mcp/resources/hook-system.ts
|
|
4154
|
+
const hookSystem = {
|
|
4155
|
+
name: "hook-system",
|
|
4156
|
+
uri: "pai://hook-system",
|
|
4157
|
+
description: "Hook system reference — event-driven automation infrastructure",
|
|
4158
|
+
content: `# Hook System
|
|
4159
|
+
|
|
4160
|
+
Event-Driven Automation Infrastructure.
|
|
4161
|
+
|
|
4162
|
+
## Available Hook Types
|
|
4163
|
+
|
|
4164
|
+
| Event | When | Primary Use |
|
|
4165
|
+
|-------|------|-------------|
|
|
4166
|
+
| SessionStart | Session begins | Load PAI context |
|
|
4167
|
+
| SessionEnd | Session terminates | Generate summaries |
|
|
4168
|
+
| UserPromptSubmit | User submits prompt | Update tab titles |
|
|
4169
|
+
| Stop | Main agent completes | Voice notifications, history capture |
|
|
4170
|
+
| SubagentStop | Subagent completes | Agent-specific voice, history |
|
|
4171
|
+
| PreToolUse | Before any tool | Analytics |
|
|
4172
|
+
| PostToolUse | After any tool | Capture outputs, metrics |
|
|
4173
|
+
| PreCompact | Before context compaction | Preserve state |
|
|
4174
|
+
|
|
4175
|
+
## Voice Notification Pattern
|
|
4176
|
+
|
|
4177
|
+
\`\`\`typescript
|
|
4178
|
+
const payload = {
|
|
4179
|
+
title: 'PAI',
|
|
4180
|
+
message: completionMessage,
|
|
4181
|
+
voice_enabled: true,
|
|
4182
|
+
voice_id: 'YOUR_VOICE_ID'
|
|
4183
|
+
};
|
|
4184
|
+
await fetch('http://localhost:8888/notify', {
|
|
4185
|
+
method: 'POST',
|
|
4186
|
+
headers: { 'Content-Type': 'application/json' },
|
|
4187
|
+
body: JSON.stringify(payload)
|
|
4188
|
+
});
|
|
4189
|
+
\`\`\`
|
|
4190
|
+
|
|
4191
|
+
## Hook Development Rules
|
|
4192
|
+
|
|
4193
|
+
1. Fast execution — hooks must complete in < 500ms
|
|
4194
|
+
2. Graceful failure — always wrap in try/catch, always exit 0
|
|
4195
|
+
3. Non-blocking — use background processes for slow work
|
|
4196
|
+
4. Never block Claude Code
|
|
4197
|
+
|
|
4198
|
+
## Adding a Hook
|
|
4199
|
+
|
|
4200
|
+
1. Create hook script at \${PAI_DIR}/Hooks/my-hook.ts
|
|
4201
|
+
2. Make executable: chmod +x
|
|
4202
|
+
3. Add to settings.json under "hooks"
|
|
4203
|
+
4. Restart Claude Code
|
|
4204
|
+
|
|
4205
|
+
Configuration file: \${PAI_DIR}/settings.json
|
|
4206
|
+
`
|
|
4207
|
+
};
|
|
4208
|
+
|
|
4209
|
+
//#endregion
|
|
4210
|
+
//#region src/daemon-mcp/resources/history-system.ts
|
|
4211
|
+
const historySystem = {
|
|
4212
|
+
name: "history-system",
|
|
4213
|
+
uri: "pai://history-system",
|
|
4214
|
+
description: "UOCS history system — automated documentation and capture patterns",
|
|
4215
|
+
content: `# Universal Output Capture System (UOCS) — History System
|
|
4216
|
+
|
|
4217
|
+
Automated documentation of ALL work performed by PAI and specialized agents.
|
|
4218
|
+
|
|
4219
|
+
## Directory Structure
|
|
4220
|
+
|
|
4221
|
+
\`\`\`
|
|
4222
|
+
\${PAI_DIR}/History/
|
|
4223
|
+
├── Sessions/YYYY-MM/ # Session summaries
|
|
4224
|
+
├── Learnings/YYYY-MM/ # Problem-solving narratives
|
|
4225
|
+
├── Research/YYYY-MM/ # Investigation reports
|
|
4226
|
+
├── Decisions/YYYY-MM/ # Architectural decisions
|
|
4227
|
+
├── Execution/
|
|
4228
|
+
│ ├── Features/YYYY-MM/ # Feature implementations
|
|
4229
|
+
│ ├── Bugs/YYYY-MM/ # Bug fixes
|
|
4230
|
+
│ └── Refactors/YYYY-MM/ # Code improvements
|
|
4231
|
+
└── Raw-Outputs/YYYY-MM/ # JSONL logs
|
|
4232
|
+
\`\`\`
|
|
4233
|
+
|
|
4234
|
+
## File Naming Convention
|
|
4235
|
+
|
|
4236
|
+
\`\`\`
|
|
4237
|
+
YYYY-MM-DD-HHMMSS_[PROJECT]_[TYPE]_[HIERARCHY]_[DESCRIPTION].md
|
|
4238
|
+
\`\`\`
|
|
4239
|
+
|
|
4240
|
+
## Hook Integration
|
|
4241
|
+
|
|
4242
|
+
- PostToolUse → raw JSONL logs in Raw-Outputs/
|
|
4243
|
+
- Stop → Learnings/ or Sessions/ based on content analysis
|
|
4244
|
+
- SubagentStop → categorized by agent type
|
|
4245
|
+
- SessionEnd → session summary in Sessions/
|
|
4246
|
+
|
|
4247
|
+
## Search Commands
|
|
4248
|
+
|
|
4249
|
+
\`\`\`bash
|
|
4250
|
+
# Quick keyword search
|
|
4251
|
+
rg -i "keyword" \${PAI_DIR}/History/
|
|
4252
|
+
|
|
4253
|
+
# Search sessions
|
|
4254
|
+
rg -i "keyword" \${PAI_DIR}/History/sessions/
|
|
4255
|
+
|
|
4256
|
+
# Recent files
|
|
4257
|
+
ls -lt \${PAI_DIR}/History/sessions/\$(date +%Y-%m)/ | head -20
|
|
4258
|
+
\`\`\`
|
|
4259
|
+
`
|
|
4260
|
+
};
|
|
4261
|
+
|
|
4262
|
+
//#endregion
|
|
4263
|
+
//#region src/daemon-mcp/resources/terminal-tabs.ts
|
|
4264
|
+
const terminalTabs = {
|
|
4265
|
+
name: "terminal-tabs",
|
|
4266
|
+
uri: "pai://terminal-tabs",
|
|
4267
|
+
description: "Terminal tab title system — automatic 4-word task summaries",
|
|
4268
|
+
content: `# Terminal Tab Title System
|
|
4269
|
+
|
|
4270
|
+
## Overview
|
|
4271
|
+
|
|
4272
|
+
PAI automatically updates your terminal tab title with a 4-word summary of what was done after each task completion.
|
|
4273
|
+
|
|
4274
|
+
## How It Works
|
|
4275
|
+
|
|
4276
|
+
The stop-hook.ts hook runs after every task completion and:
|
|
4277
|
+
1. Extracts the task summary from the COMPLETED line
|
|
4278
|
+
2. Generates a 4-word title summarizing what was accomplished
|
|
4279
|
+
3. Updates your terminal tab using ANSI escape sequences
|
|
4280
|
+
|
|
4281
|
+
## Escape Sequences
|
|
4282
|
+
|
|
4283
|
+
\`\`\`bash
|
|
4284
|
+
# OSC 0 — Sets icon and window title
|
|
4285
|
+
printf '\\033]0;Title Here\\007'
|
|
4286
|
+
|
|
4287
|
+
# OSC 30 — Kitty-specific tab title
|
|
4288
|
+
printf '\\033]30;Title Here\\007'
|
|
4289
|
+
\`\`\`
|
|
4290
|
+
|
|
4291
|
+
## Terminal Compatibility
|
|
4292
|
+
|
|
4293
|
+
Kitty, iTerm2, Terminal.app, Alacritty, VS Code Terminal — all supported.
|
|
4294
|
+
|
|
4295
|
+
## Implementation
|
|
4296
|
+
|
|
4297
|
+
Location: \${PAI_DIR}/Hooks/stop-hook.ts
|
|
4298
|
+
|
|
4299
|
+
Key functions:
|
|
4300
|
+
- generateTabTitle(prompt, completedLine) — Creates the 4-word summary
|
|
4301
|
+
- setKittyTabTitle(title) — Sends escape sequences to update the tab
|
|
4302
|
+
`
|
|
4303
|
+
};
|
|
4304
|
+
|
|
4305
|
+
//#endregion
|
|
4306
|
+
//#region src/daemon-mcp/resources/mcp-dev-guide.ts
|
|
4307
|
+
const mcpDevGuide = {
|
|
4308
|
+
name: "mcp-dev-guide",
|
|
4309
|
+
uri: "pai://mcp-dev-guide",
|
|
4310
|
+
description: "MCP skill delivery guide — three-tier architecture best practices",
|
|
4311
|
+
content: `# MCP Skill Delivery Guide
|
|
4312
|
+
|
|
4313
|
+
How to structure MCP server instructions, prompts, and resources for optimal context efficiency.
|
|
4314
|
+
|
|
4315
|
+
## The Three-Tier Architecture
|
|
4316
|
+
|
|
4317
|
+
MCP provides three mechanisms for delivering content to Claude. Use each for its intended purpose.
|
|
4318
|
+
|
|
4319
|
+
### Tier 1: instructions (Always Loaded)
|
|
4320
|
+
|
|
4321
|
+
The instructions field is loaded into EVERY message's context for the lifetime of the MCP connection. Keep it thin.
|
|
4322
|
+
|
|
4323
|
+
**What belongs here:**
|
|
4324
|
+
- Brief description of the MCP server (1-2 sentences)
|
|
4325
|
+
- Routing table: "When user says X → fetch prompt Y"
|
|
4326
|
+
- Core behavioral rules that apply to every interaction
|
|
4327
|
+
- Resource directory: "Fetch pai://name for full guide on X"
|
|
4328
|
+
|
|
4329
|
+
**What does NOT belong here:**
|
|
4330
|
+
- Full skill descriptions and workflow steps
|
|
4331
|
+
- Reference documentation (aesthetic guides, API docs)
|
|
4332
|
+
- Examples and tutorials
|
|
4333
|
+
- Anything that changes rarely and is only needed sometimes
|
|
4334
|
+
|
|
4335
|
+
**Target size:** Under 2KB. If it exceeds this, you are doing it wrong.
|
|
4336
|
+
|
|
4337
|
+
### Tier 2: prompts (On-Demand Workflows)
|
|
4338
|
+
|
|
4339
|
+
Prompts are fetched by Claude when a specific skill is triggered. The user does not see these directly — they are instructions for Claude.
|
|
4340
|
+
|
|
4341
|
+
**What belongs here:**
|
|
4342
|
+
- Complete skill workflow instructions
|
|
4343
|
+
- USE WHEN trigger conditions
|
|
4344
|
+
- Step-by-step workflow routing tables
|
|
4345
|
+
- Platform-specific rules (LinkedIn vs X vs Bluesky)
|
|
4346
|
+
- Command tables and data source lists
|
|
4347
|
+
|
|
4348
|
+
**Registration:**
|
|
4349
|
+
|
|
4350
|
+
\`\`\`typescript
|
|
4351
|
+
server.prompt(
|
|
4352
|
+
"review",
|
|
4353
|
+
"Weekly/daily/monthly review of work accomplished",
|
|
4354
|
+
() => ({
|
|
4355
|
+
messages: [{
|
|
4356
|
+
role: "user" as const,
|
|
4357
|
+
content: {
|
|
4358
|
+
type: "text" as const,
|
|
4359
|
+
text: reviewSkillContent,
|
|
4360
|
+
},
|
|
4361
|
+
}],
|
|
4362
|
+
})
|
|
4363
|
+
);
|
|
4364
|
+
\`\`\`
|
|
4365
|
+
|
|
4366
|
+
**Naming:** lowercase-kebab. Examples: "review", "share", "vault-context".
|
|
4367
|
+
|
|
4368
|
+
### Tier 3: resources (Reference Documentation)
|
|
4369
|
+
|
|
4370
|
+
Resources are reference documents that Claude reads when it needs detailed information. Unlike prompts, they are not workflow instructions — they are reference material.
|
|
4371
|
+
|
|
4372
|
+
**What belongs here:**
|
|
4373
|
+
- Style guides (aesthetic, voice, prosody)
|
|
4374
|
+
- Constitutional documents (philosophy, architecture)
|
|
4375
|
+
- API reference documentation
|
|
4376
|
+
- Configuration schemas
|
|
4377
|
+
- Technical specifications
|
|
4378
|
+
|
|
4379
|
+
**Registration:**
|
|
4380
|
+
|
|
4381
|
+
\`\`\`typescript
|
|
4382
|
+
server.resource(
|
|
4383
|
+
"aesthetic",
|
|
4384
|
+
"pai://aesthetic",
|
|
4385
|
+
{ mimeType: "text/markdown" },
|
|
4386
|
+
async () => ({
|
|
4387
|
+
contents: [{
|
|
4388
|
+
uri: "pai://aesthetic",
|
|
4389
|
+
mimeType: "text/markdown",
|
|
4390
|
+
text: aestheticGuideContent,
|
|
4391
|
+
}],
|
|
4392
|
+
})
|
|
4393
|
+
);
|
|
4394
|
+
\`\`\`
|
|
4395
|
+
|
|
4396
|
+
**URI convention:** Use a consistent scheme like \`pai://name\` or \`mcp://server-name/resource\`.
|
|
4397
|
+
|
|
4398
|
+
## Decision Matrix
|
|
4399
|
+
|
|
4400
|
+
| Content Type | Tier | Reasoning |
|
|
4401
|
+
|--------------|------|-----------|
|
|
4402
|
+
| "When user says X, fetch prompt Y" | instructions | Routes to the right skill |
|
|
4403
|
+
| Full skill workflow (20+ lines) | prompt | Only needed when skill triggers |
|
|
4404
|
+
| Aesthetic style guide | resource | Reference, not workflow |
|
|
4405
|
+
| Core operating rules | instructions | Applies to every interaction |
|
|
4406
|
+
| Platform-specific post formatting | prompt | Part of share skill workflow |
|
|
4407
|
+
| Voice prosody guide | resource | Reference, rarely needed |
|
|
4408
|
+
| Session lifecycle commands | instructions | Always applicable |
|
|
4409
|
+
|
|
4410
|
+
## Anti-Patterns
|
|
4411
|
+
|
|
4412
|
+
### Anti-Pattern 1: Stuffing everything into instructions
|
|
4413
|
+
|
|
4414
|
+
\`\`\`
|
|
4415
|
+
// WRONG — 20 full skill descriptions in instructions
|
|
4416
|
+
const PAI_INSTRUCTIONS = \`
|
|
4417
|
+
## Review Skill
|
|
4418
|
+
USE WHEN user says 'review'...
|
|
4419
|
+
[200 lines of workflow details]
|
|
4420
|
+
|
|
4421
|
+
## Journal Skill
|
|
4422
|
+
USE WHEN user says 'journal'...
|
|
4423
|
+
[150 lines of workflow details]
|
|
4424
|
+
|
|
4425
|
+
[18 more skills...]
|
|
4426
|
+
\`;
|
|
4427
|
+
\`\`\`
|
|
4428
|
+
|
|
4429
|
+
**Problem:** Consumes 8-15KB of context on every message. Most of this content is irrelevant 95% of the time.
|
|
4430
|
+
|
|
4431
|
+
**Fix:** One-line routing table in instructions. Full content in prompts.
|
|
4432
|
+
|
|
4433
|
+
### Anti-Pattern 2: File path references in instructions
|
|
4434
|
+
|
|
4435
|
+
\`\`\`
|
|
4436
|
+
// WRONG — hardcoded personal paths
|
|
4437
|
+
"Read ~/.claude/Skills/Share/SKILL.md for social media instructions"
|
|
4438
|
+
\`\`\`
|
|
4439
|
+
|
|
4440
|
+
**Problem:** Paths are personal, not portable. The file may not exist. Reading a file wastes a tool call.
|
|
4441
|
+
|
|
4442
|
+
**Fix:** Embed content directly in prompts/resources. No file paths needed.
|
|
4443
|
+
|
|
4444
|
+
### Anti-Pattern 3: Personal data in instructions
|
|
4445
|
+
|
|
4446
|
+
\`\`\`
|
|
4447
|
+
// WRONG — names and personal identifiers
|
|
4448
|
+
"You are assisting John Smith at Acme Corp..."
|
|
4449
|
+
\`\`\`
|
|
4450
|
+
|
|
4451
|
+
**Problem:** Instructions ship with the MCP server. If the server is shared or open-source, personal data leaks.
|
|
4452
|
+
|
|
4453
|
+
**Fix:** Use placeholders (\${USER_NAME}) or keep personal data out of instructions entirely.
|
|
4454
|
+
|
|
4455
|
+
### Anti-Pattern 4: Duplicating content across tiers
|
|
4456
|
+
|
|
4457
|
+
\`\`\`
|
|
4458
|
+
// WRONG — routing table in instructions AND full skill in instructions
|
|
4459
|
+
instructions: "When user says 'share', use Share skill. Share skill rules: 1000-2000 chars..."
|
|
4460
|
+
\`\`\`
|
|
4461
|
+
|
|
4462
|
+
**Fix:** Routing table in instructions, full skill in prompt. Never both.
|
|
4463
|
+
|
|
4464
|
+
## How to Add a New Skill
|
|
4465
|
+
|
|
4466
|
+
1. Write the full skill content (workflow steps, trigger conditions, examples)
|
|
4467
|
+
2. Add a one-line entry to the routing table in instructions
|
|
4468
|
+
3. Register as a prompt with server.prompt()
|
|
4469
|
+
4. Test that the routing table correctly identifies trigger phrases
|
|
4470
|
+
|
|
4471
|
+
\`\`\`typescript
|
|
4472
|
+
// Step 2: Add to routing table in instructions
|
|
4473
|
+
"| When user says 'deploy' or 'push to production' | Fetch prompt: deploy |"
|
|
4474
|
+
|
|
4475
|
+
// Step 3: Register the prompt
|
|
4476
|
+
server.prompt(
|
|
4477
|
+
"deploy",
|
|
4478
|
+
"Deploy to staging or production environments",
|
|
4479
|
+
() => ({
|
|
4480
|
+
messages: [{
|
|
4481
|
+
role: "user" as const,
|
|
4482
|
+
content: {
|
|
4483
|
+
type: "text" as const,
|
|
4484
|
+
text: deploySkillContent, // Full workflow here
|
|
4485
|
+
},
|
|
4486
|
+
}],
|
|
4487
|
+
})
|
|
4488
|
+
);
|
|
4489
|
+
\`\`\`
|
|
4490
|
+
|
|
4491
|
+
## How to Add a New Resource
|
|
4492
|
+
|
|
4493
|
+
1. Write the reference content (guide, spec, configuration schema)
|
|
4494
|
+
2. Add an entry to the resource directory in instructions
|
|
4495
|
+
3. Register with server.resource()
|
|
4496
|
+
|
|
4497
|
+
\`\`\`typescript
|
|
4498
|
+
// Step 2: Add to resource directory in instructions
|
|
4499
|
+
"| API reference | pai://api-reference |"
|
|
4500
|
+
|
|
4501
|
+
// Step 3: Register the resource
|
|
4502
|
+
server.resource(
|
|
4503
|
+
"api-reference",
|
|
4504
|
+
"pai://api-reference",
|
|
4505
|
+
{ mimeType: "text/markdown" },
|
|
4506
|
+
async () => ({
|
|
4507
|
+
contents: [{
|
|
4508
|
+
uri: "pai://api-reference",
|
|
4509
|
+
mimeType: "text/markdown",
|
|
4510
|
+
text: apiReferenceContent,
|
|
4511
|
+
}],
|
|
4512
|
+
})
|
|
4513
|
+
);
|
|
4514
|
+
\`\`\`
|
|
4515
|
+
|
|
4516
|
+
## Testing Checklist
|
|
4517
|
+
|
|
4518
|
+
Before shipping a refactored MCP server:
|
|
4519
|
+
|
|
4520
|
+
- [ ] instructions field is under 2KB
|
|
4521
|
+
- [ ] instructions contains ONLY routing table + core rules
|
|
4522
|
+
- [ ] Each skill has a registered prompt (server.prompt)
|
|
4523
|
+
- [ ] Each reference doc has a registered resource (server.resource)
|
|
4524
|
+
- [ ] No full skill descriptions in instructions
|
|
4525
|
+
- [ ] No hardcoded personal paths in instructions
|
|
4526
|
+
- [ ] No personal data (names, emails) in instructions
|
|
4527
|
+
- [ ] Prompts are fetchable: prompts/list returns all expected prompts
|
|
4528
|
+
- [ ] Resources are readable: resources/list returns all expected resources
|
|
4529
|
+
- [ ] Tools are unchanged (only instructions/prompts/resources changed)
|
|
4530
|
+
- [ ] Build succeeds: npm run build
|
|
4531
|
+
|
|
4532
|
+
## Context Size Impact
|
|
4533
|
+
|
|
4534
|
+
Example: PAI MCP before and after refactor
|
|
4535
|
+
|
|
4536
|
+
| Metric | Before | After |
|
|
4537
|
+
|--------|--------|-------|
|
|
4538
|
+
| instructions size | ~8KB (20 skills) | ~1.5KB (routing table) |
|
|
4539
|
+
| Context loaded per message | ~8KB | ~1.5KB |
|
|
4540
|
+
| Full skill content when needed | ~8KB | ~0.5KB (one skill) |
|
|
4541
|
+
| Context savings (typical session) | — | ~6.5KB per message |
|
|
4542
|
+
|
|
4543
|
+
At 200 message sessions, that is 1.3MB of context saved — equivalent to 5-10 extra tool calls worth of context.
|
|
4544
|
+
`
|
|
4545
|
+
};
|
|
4546
|
+
|
|
4547
|
+
//#endregion
|
|
8
4548
|
//#region src/daemon-mcp/index.ts
|
|
9
4549
|
/**
|
|
10
4550
|
* PAI Daemon MCP Shim
|
|
@@ -21,6 +4561,11 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
21
4561
|
* If the daemon is not running, tool calls return a helpful error message
|
|
22
4562
|
* rather than crashing — this allows the legacy direct MCP (dist/mcp/index.mjs)
|
|
23
4563
|
* to serve as fallback.
|
|
4564
|
+
*
|
|
4565
|
+
* Architecture:
|
|
4566
|
+
* instructions — thin routing table (~1KB). Always in context.
|
|
4567
|
+
* prompts — full skill workflows fetched on demand (20 skills).
|
|
4568
|
+
* resources — reference docs read when needed (guides, constitution).
|
|
24
4569
|
*/
|
|
25
4570
|
let _client = null;
|
|
26
4571
|
function getClient() {
|
|
@@ -51,7 +4596,55 @@ async function startShim() {
|
|
|
51
4596
|
const server = new McpServer({
|
|
52
4597
|
name: "pai",
|
|
53
4598
|
version: "0.1.0"
|
|
54
|
-
});
|
|
4599
|
+
}, { instructions: PAI_INSTRUCTIONS });
|
|
4600
|
+
const SKILL_PROMPTS = {
|
|
4601
|
+
"review": review,
|
|
4602
|
+
"journal": journal,
|
|
4603
|
+
"plan": plan,
|
|
4604
|
+
"share": share,
|
|
4605
|
+
"sessions": sessions,
|
|
4606
|
+
"route": route,
|
|
4607
|
+
"search-history": searchHistory,
|
|
4608
|
+
"name": name,
|
|
4609
|
+
"observability": observability,
|
|
4610
|
+
"research": research,
|
|
4611
|
+
"art": art,
|
|
4612
|
+
"createskill": createskill,
|
|
4613
|
+
"story-explanation": storyExplanation,
|
|
4614
|
+
"vault-context": vaultContext,
|
|
4615
|
+
"vault-connect": vaultConnect,
|
|
4616
|
+
"vault-emerge": vaultEmerge,
|
|
4617
|
+
"vault-orphans": vaultOrphans,
|
|
4618
|
+
"vault-trace": vaultTrace
|
|
4619
|
+
};
|
|
4620
|
+
for (const [promptName, skill] of Object.entries(SKILL_PROMPTS)) server.prompt(promptName, skill.description, () => ({ messages: [{
|
|
4621
|
+
role: "user",
|
|
4622
|
+
content: {
|
|
4623
|
+
type: "text",
|
|
4624
|
+
text: skill.content
|
|
4625
|
+
}
|
|
4626
|
+
}] }));
|
|
4627
|
+
const resources = [
|
|
4628
|
+
aesthetic,
|
|
4629
|
+
prosodyGuide,
|
|
4630
|
+
prosodyAgentTemplate,
|
|
4631
|
+
voice,
|
|
4632
|
+
skillSystem,
|
|
4633
|
+
hookSystem,
|
|
4634
|
+
historySystem,
|
|
4635
|
+
terminalTabs,
|
|
4636
|
+
mcpDevGuide,
|
|
4637
|
+
constitution,
|
|
4638
|
+
prompting
|
|
4639
|
+
];
|
|
4640
|
+
for (const resource of resources) server.resource(resource.name, resource.uri, {
|
|
4641
|
+
mimeType: "text/markdown",
|
|
4642
|
+
description: resource.description
|
|
4643
|
+
}, async () => ({ contents: [{
|
|
4644
|
+
uri: resource.uri,
|
|
4645
|
+
mimeType: "text/markdown",
|
|
4646
|
+
text: resource.content
|
|
4647
|
+
}] }));
|
|
55
4648
|
server.tool("memory_search", [
|
|
56
4649
|
"Search PAI federated memory using BM25 full-text ranking, semantic similarity, or a hybrid of both.",
|
|
57
4650
|
"",
|