@lambdacurry/arbor 0.24.15 → 0.24.17
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/dist/arbor.js +2341 -2123
- package/package.json +1 -1
package/dist/arbor.js
CHANGED
|
@@ -1,2041 +1,1348 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
mkdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
readdirSync,
|
|
11
|
-
rmSync,
|
|
12
|
-
statSync,
|
|
13
|
-
writeFileSync
|
|
14
|
-
} from "node:fs";
|
|
15
|
-
import { homedir } from "node:os";
|
|
16
|
-
import { dirname, join } from "node:path";
|
|
17
|
-
|
|
18
|
-
// src/errors.ts
|
|
19
|
-
var ERROR_CODES = new Set([
|
|
20
|
-
"UNAUTHORIZED",
|
|
21
|
-
"FORBIDDEN",
|
|
22
|
-
"NOT_FOUND",
|
|
23
|
-
"VALIDATION",
|
|
24
|
-
"CONFLICT",
|
|
25
|
-
"RATE_LIMITED",
|
|
26
|
-
"NETWORK",
|
|
27
|
-
"INTERNAL"
|
|
28
|
-
]);
|
|
29
|
-
function isErrorCode(value) {
|
|
30
|
-
return typeof value === "string" && ERROR_CODES.has(value);
|
|
31
|
-
}
|
|
32
|
-
function codeForStatus(status) {
|
|
33
|
-
switch (status) {
|
|
34
|
-
case 0:
|
|
35
|
-
return "NETWORK";
|
|
36
|
-
case 400:
|
|
37
|
-
case 422:
|
|
38
|
-
return "VALIDATION";
|
|
39
|
-
case 401:
|
|
40
|
-
return "UNAUTHORIZED";
|
|
41
|
-
case 403:
|
|
42
|
-
return "FORBIDDEN";
|
|
43
|
-
case 404:
|
|
44
|
-
case 410:
|
|
45
|
-
return "NOT_FOUND";
|
|
46
|
-
case 409:
|
|
47
|
-
return "CONFLICT";
|
|
48
|
-
case 429:
|
|
49
|
-
return "RATE_LIMITED";
|
|
50
|
-
default:
|
|
51
|
-
return "INTERNAL";
|
|
52
|
-
}
|
|
3
|
+
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/util.js
|
|
4
|
+
function getEnumValues(entries) {
|
|
5
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
6
|
+
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
7
|
+
return values;
|
|
53
8
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
case "VALIDATION":
|
|
57
|
-
return 2;
|
|
58
|
-
case "UNAUTHORIZED":
|
|
59
|
-
return 22;
|
|
60
|
-
default:
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
9
|
+
function joinValues(array, separator = "|") {
|
|
10
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
63
11
|
}
|
|
64
|
-
function
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
return "INTERNAL";
|
|
12
|
+
function jsonStringifyReplacer(_, value) {
|
|
13
|
+
if (typeof value === "bigint")
|
|
14
|
+
return value.toString();
|
|
15
|
+
return value;
|
|
69
16
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
details.limit = raw.limit;
|
|
81
|
-
if (typeof raw.retryable === "boolean")
|
|
82
|
-
details.retryable = raw.retryable;
|
|
83
|
-
if (typeof raw.phase === "string")
|
|
84
|
-
details.phase = raw.phase;
|
|
85
|
-
if (raw.provider && typeof raw.provider === "object" && !Array.isArray(raw.provider)) {
|
|
86
|
-
const provider = raw.provider;
|
|
87
|
-
if (typeof provider.stage === "string" && provider.stage !== "") {
|
|
88
|
-
details.provider = {
|
|
89
|
-
stage: provider.stage,
|
|
90
|
-
...typeof provider.exitCode === "number" ? { exitCode: provider.exitCode } : {},
|
|
91
|
-
...typeof provider.stdout === "string" ? { stdout: provider.stdout } : {},
|
|
92
|
-
...typeof provider.stderr === "string" ? { stderr: provider.stderr } : {},
|
|
93
|
-
...typeof provider.containerStarted === "boolean" ? { containerStarted: provider.containerStarted } : {},
|
|
94
|
-
...typeof provider.repositoryMaterialized === "boolean" ? { repositoryMaterialized: provider.repositoryMaterialized } : {}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (typeof raw.runId === "string")
|
|
99
|
-
details.runId = raw.runId;
|
|
100
|
-
if (typeof raw.operationId === "string")
|
|
101
|
-
details.operationId = raw.operationId;
|
|
102
|
-
if (typeof raw.processId === "string")
|
|
103
|
-
details.processId = raw.processId;
|
|
104
|
-
if (raw.outputRetention && typeof raw.outputRetention === "object") {
|
|
105
|
-
const retention = raw.outputRetention;
|
|
106
|
-
if (retention.state === "expired" && typeof retention.expiresAt === "string") {
|
|
107
|
-
details.outputRetention = { state: "expired", expiresAt: retention.expiresAt };
|
|
17
|
+
function cached(getter) {
|
|
18
|
+
const set = false;
|
|
19
|
+
return {
|
|
20
|
+
get value() {
|
|
21
|
+
if (!set) {
|
|
22
|
+
const value = getter();
|
|
23
|
+
Object.defineProperty(this, "value", { value });
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
throw new Error("cached value already set");
|
|
108
27
|
}
|
|
109
|
-
}
|
|
110
|
-
if (raw.commandExecution === "not-routed" || raw.commandExecution === "unknown") {
|
|
111
|
-
details.commandExecution = raw.commandExecution;
|
|
112
|
-
}
|
|
113
|
-
if (raw.mutationRetrySafety === "safe" || raw.mutationRetrySafety === "unsafe" || raw.mutationRetrySafety === "unknown") {
|
|
114
|
-
details.mutationRetrySafety = raw.mutationRetrySafety;
|
|
115
|
-
}
|
|
116
|
-
if (typeof raw.compatibilityState === "string") {
|
|
117
|
-
details.compatibilityState = raw.compatibilityState;
|
|
118
|
-
}
|
|
119
|
-
if (typeof raw.compatibilityReason === "string") {
|
|
120
|
-
details.compatibilityReason = raw.compatibilityReason;
|
|
121
|
-
}
|
|
122
|
-
if (typeof raw.suggestedAction === "string")
|
|
123
|
-
details.suggestedAction = raw.suggestedAction;
|
|
124
|
-
if (typeof raw.catalogRevision === "string")
|
|
125
|
-
details.catalogRevision = raw.catalogRevision;
|
|
126
|
-
if (typeof raw.clientCatalogRevision === "string") {
|
|
127
|
-
details.clientCatalogRevision = raw.clientCatalogRevision;
|
|
128
|
-
}
|
|
129
|
-
if (typeof raw.catalogNextStep === "string")
|
|
130
|
-
details.catalogNextStep = raw.catalogNextStep;
|
|
131
|
-
return details;
|
|
28
|
+
};
|
|
132
29
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
return;
|
|
136
|
-
return parseErrorDetails(err.details);
|
|
30
|
+
function nullish(input) {
|
|
31
|
+
return input === null || input === undefined;
|
|
137
32
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
code;
|
|
143
|
-
constructor(message, status, details) {
|
|
144
|
-
super(message);
|
|
145
|
-
this.status = status;
|
|
146
|
-
this.details = details;
|
|
147
|
-
this.name = "ApiError";
|
|
148
|
-
this.code = codeForStatus(status);
|
|
149
|
-
}
|
|
33
|
+
function cleanRegex(source) {
|
|
34
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
35
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
36
|
+
return source.slice(start, end);
|
|
150
37
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.details = details ?? { reason: "validation.invalid_value" };
|
|
159
|
-
}
|
|
38
|
+
function floatSafeRemainder(val, step) {
|
|
39
|
+
const ratio = val / step;
|
|
40
|
+
const roundedRatio = Math.round(ratio);
|
|
41
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
42
|
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
43
|
+
return 0;
|
|
44
|
+
return ratio - roundedRatio;
|
|
160
45
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
46
|
+
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
47
|
+
function defineLazy(object, key, getter) {
|
|
48
|
+
let value = undefined;
|
|
49
|
+
Object.defineProperty(object, key, {
|
|
50
|
+
get() {
|
|
51
|
+
if (value === EVALUATING) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (value === undefined) {
|
|
55
|
+
value = EVALUATING;
|
|
56
|
+
value = getter();
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
},
|
|
60
|
+
set(v) {
|
|
61
|
+
Object.defineProperty(object, key, {
|
|
62
|
+
value: v
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
configurable: true
|
|
66
|
+
});
|
|
173
67
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
68
|
+
function assignProp(target, prop, value) {
|
|
69
|
+
Object.defineProperty(target, prop, {
|
|
70
|
+
value,
|
|
71
|
+
writable: true,
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
180
75
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
76
|
+
function mergeDefs(...defs) {
|
|
77
|
+
const mergedDescriptors = {};
|
|
78
|
+
for (const def of defs) {
|
|
79
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
80
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
81
|
+
}
|
|
82
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
183
83
|
}
|
|
184
|
-
function
|
|
185
|
-
return
|
|
84
|
+
function esc(str) {
|
|
85
|
+
return JSON.stringify(str);
|
|
186
86
|
}
|
|
187
|
-
function
|
|
188
|
-
return
|
|
87
|
+
function slugify(input) {
|
|
88
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
189
89
|
}
|
|
190
|
-
|
|
191
|
-
|
|
90
|
+
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
91
|
+
function isObject(data) {
|
|
92
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
192
93
|
}
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
var LOCK_STALE_MS = 30000;
|
|
197
|
-
var LOCK_POLL_MS = 20;
|
|
198
|
-
var activeTarget;
|
|
199
|
-
function sleepSync(ms) {
|
|
200
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
201
|
-
}
|
|
202
|
-
function acquireConfigLock(configPath) {
|
|
203
|
-
const lockPath = `${configPath}.lock`;
|
|
204
|
-
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
205
|
-
for (;; ) {
|
|
206
|
-
try {
|
|
207
|
-
mkdirSync(lockPath);
|
|
208
|
-
return () => {
|
|
209
|
-
try {
|
|
210
|
-
rmSync(lockPath, { recursive: true, force: true });
|
|
211
|
-
} catch {}
|
|
212
|
-
};
|
|
213
|
-
} catch (err) {
|
|
214
|
-
if (err?.code !== "EEXIST")
|
|
215
|
-
throw err;
|
|
216
|
-
try {
|
|
217
|
-
if (Date.now() - statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
|
|
218
|
-
rmSync(lockPath, { recursive: true, force: true });
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
} catch {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (Date.now() >= deadline) {
|
|
225
|
-
throw new Error(`timed out waiting for another arbor process to finish writing ${configPath}. If none is running, remove ${lockPath}.`);
|
|
226
|
-
}
|
|
227
|
-
sleepSync(LOCK_POLL_MS);
|
|
228
|
-
}
|
|
94
|
+
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
95
|
+
if (globalConfig.jitless) {
|
|
96
|
+
return false;
|
|
229
97
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (!PROFILE_NAME.test(name)) {
|
|
233
|
-
throw new UsageError(`invalid profile name: ${JSON.stringify(name)}`, {
|
|
234
|
-
reason: "validation.invalid_value",
|
|
235
|
-
field
|
|
236
|
-
});
|
|
98
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
99
|
+
return false;
|
|
237
100
|
}
|
|
101
|
+
try {
|
|
102
|
+
const F = Function;
|
|
103
|
+
new F("");
|
|
104
|
+
return true;
|
|
105
|
+
} catch (_) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
function isPlainObject(o) {
|
|
110
|
+
if (isObject(o) === false)
|
|
111
|
+
return false;
|
|
112
|
+
const ctor = o.constructor;
|
|
113
|
+
if (ctor === undefined)
|
|
114
|
+
return true;
|
|
115
|
+
if (typeof ctor !== "function")
|
|
116
|
+
return true;
|
|
117
|
+
const prot = ctor.prototype;
|
|
118
|
+
if (isObject(prot) === false)
|
|
119
|
+
return false;
|
|
120
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
238
124
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (
|
|
245
|
-
return;
|
|
246
|
-
if (
|
|
247
|
-
|
|
125
|
+
function shallowClone(o) {
|
|
126
|
+
if (isPlainObject(o))
|
|
127
|
+
return { ...o };
|
|
128
|
+
if (Array.isArray(o))
|
|
129
|
+
return [...o];
|
|
130
|
+
if (o instanceof Map)
|
|
131
|
+
return new Map(o);
|
|
132
|
+
if (o instanceof Set)
|
|
133
|
+
return new Set(o);
|
|
134
|
+
return o;
|
|
248
135
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
253
|
-
chmodSync(dir, 448);
|
|
136
|
+
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
137
|
+
function escapeRegex(str) {
|
|
138
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
254
139
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
chmodSync(dir, 448);
|
|
140
|
+
function clone(inst, def, params) {
|
|
141
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
142
|
+
if (!def || params?.parent)
|
|
143
|
+
cl._zod.parent = inst;
|
|
144
|
+
return cl;
|
|
261
145
|
}
|
|
262
|
-
function
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
146
|
+
function normalizeParams(_params) {
|
|
147
|
+
const params = _params;
|
|
148
|
+
if (!params)
|
|
265
149
|
return {};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
} catch (err) {
|
|
273
|
-
if (err instanceof UsageError)
|
|
274
|
-
throw err;
|
|
275
|
-
throw new Error(`could not read Arbor profile registry ${path}`);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function writeRegistry(registry) {
|
|
279
|
-
ensureArborDir();
|
|
280
|
-
const path = registryPath();
|
|
281
|
-
rejectSymlink(path, "Arbor profile registry");
|
|
282
|
-
const release = acquireConfigLock(path);
|
|
283
|
-
try {
|
|
284
|
-
const safe = registry.defaultProfile ? { defaultProfile: registry.defaultProfile } : {};
|
|
285
|
-
writeFileSync(path, `${JSON.stringify(safe, null, 2)}
|
|
286
|
-
`, { mode: 384 });
|
|
287
|
-
chmodSync(path, 384);
|
|
288
|
-
} finally {
|
|
289
|
-
release();
|
|
150
|
+
if (typeof params === "string")
|
|
151
|
+
return { error: () => params };
|
|
152
|
+
if (params?.message !== undefined) {
|
|
153
|
+
if (params?.error !== undefined)
|
|
154
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
155
|
+
params.error = params.message;
|
|
290
156
|
}
|
|
157
|
+
delete params.message;
|
|
158
|
+
if (typeof params.error === "string")
|
|
159
|
+
return { ...params, error: () => params.error };
|
|
160
|
+
return params;
|
|
291
161
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (
|
|
296
|
-
return
|
|
297
|
-
|
|
298
|
-
return fsType(lstatSync(path), "isFile");
|
|
162
|
+
function stringifyPrimitive(value) {
|
|
163
|
+
if (typeof value === "bigint")
|
|
164
|
+
return value.toString() + "n";
|
|
165
|
+
if (typeof value === "string")
|
|
166
|
+
return `"${value}"`;
|
|
167
|
+
return `${value}`;
|
|
299
168
|
}
|
|
300
|
-
function
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
path: envPath ?? defaultPath,
|
|
305
|
-
defaultPath,
|
|
306
|
-
isolated: Boolean(envPath),
|
|
307
|
-
named: false,
|
|
308
|
-
explicitProfile: false
|
|
309
|
-
};
|
|
169
|
+
function optionalKeys(shape) {
|
|
170
|
+
return Object.keys(shape).filter((k) => {
|
|
171
|
+
return shape[k]._zod.optin !== undefined && shape[k]._zod.optout === "optional";
|
|
172
|
+
});
|
|
310
173
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
174
|
+
var NUMBER_FORMAT_RANGES = /* @__PURE__ */ (() => ({
|
|
175
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
176
|
+
int32: [-2147483648, 2147483647],
|
|
177
|
+
uint32: [0, 4294967295],
|
|
178
|
+
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
179
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
180
|
+
}))();
|
|
181
|
+
function pick(schema, mask) {
|
|
182
|
+
const currDef = schema._zod.def;
|
|
183
|
+
const checks = currDef.checks;
|
|
184
|
+
const hasChecks = checks && checks.length > 0;
|
|
185
|
+
if (hasChecks) {
|
|
186
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
319
187
|
}
|
|
320
|
-
|
|
321
|
-
|
|
188
|
+
const def = mergeDefs(schema._zod.def, {
|
|
189
|
+
get shape() {
|
|
190
|
+
const newShape = {};
|
|
191
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
192
|
+
if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
|
|
193
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
194
|
+
}
|
|
195
|
+
if (!mask[key])
|
|
196
|
+
continue;
|
|
197
|
+
assignProp(newShape, key, currDef.shape[key]);
|
|
198
|
+
}
|
|
199
|
+
assignProp(this, "shape", newShape);
|
|
200
|
+
return newShape;
|
|
201
|
+
},
|
|
202
|
+
checks: []
|
|
203
|
+
});
|
|
204
|
+
return clone(schema, def);
|
|
205
|
+
}
|
|
206
|
+
function omit(schema, mask) {
|
|
207
|
+
const currDef = schema._zod.def;
|
|
208
|
+
const checks = currDef.checks;
|
|
209
|
+
const hasChecks = checks && checks.length > 0;
|
|
210
|
+
if (hasChecks) {
|
|
211
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
322
212
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
213
|
+
const def = mergeDefs(schema._zod.def, {
|
|
214
|
+
get shape() {
|
|
215
|
+
const newShape = { ...schema._zod.def.shape };
|
|
216
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
217
|
+
if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
|
|
218
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
219
|
+
}
|
|
220
|
+
if (!mask[key])
|
|
221
|
+
continue;
|
|
222
|
+
delete newShape[key];
|
|
223
|
+
}
|
|
224
|
+
assignProp(this, "shape", newShape);
|
|
225
|
+
return newShape;
|
|
226
|
+
},
|
|
227
|
+
checks: []
|
|
228
|
+
});
|
|
229
|
+
return clone(schema, def);
|
|
230
|
+
}
|
|
231
|
+
function extend(schema, shape) {
|
|
232
|
+
if (!isPlainObject(shape)) {
|
|
233
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
336
234
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
function configureConfigTarget(opts) {
|
|
347
|
-
activeTarget = resolveTarget(opts);
|
|
348
|
-
}
|
|
349
|
-
function currentTarget() {
|
|
350
|
-
return activeTarget ?? resolveTarget();
|
|
351
|
-
}
|
|
352
|
-
function getConfigPath() {
|
|
353
|
-
return currentTarget().path;
|
|
354
|
-
}
|
|
355
|
-
function listProfiles() {
|
|
356
|
-
const registry = readRegistry();
|
|
357
|
-
const dir = profilesDir();
|
|
358
|
-
if (!existsSync(dir))
|
|
359
|
-
return { defaultProfile: registry.defaultProfile, profiles: [] };
|
|
360
|
-
rejectSymlink(dir, "Arbor profiles directory");
|
|
361
|
-
const profiles = readdirSync(dir).filter((entry) => entry.endsWith(".json")).map((entry) => {
|
|
362
|
-
const name = entry.slice(0, -5);
|
|
363
|
-
validateProfileName(name);
|
|
364
|
-
const path = join(dir, entry);
|
|
365
|
-
const stats = lstatSync(path);
|
|
366
|
-
if (fsType(stats, "isSymbolicLink"))
|
|
367
|
-
throw new Error(`Arbor profile ${name} must not be a symbolic link: ${path}`);
|
|
368
|
-
if (!fsType(stats, "isFile"))
|
|
369
|
-
throw new Error(`Arbor profile ${name} is not a regular file: ${path}`);
|
|
370
|
-
return { name, default: registry.defaultProfile === name };
|
|
371
|
-
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
372
|
-
return { defaultProfile: registry.defaultProfile, profiles };
|
|
373
|
-
}
|
|
374
|
-
function profileShow(name) {
|
|
375
|
-
validateProfileName(name);
|
|
376
|
-
if (!profileExists(name)) {
|
|
377
|
-
throw new UsageError(`unknown profile: ${name}`, {
|
|
378
|
-
reason: "validation.invalid_value",
|
|
379
|
-
field: "profile"
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
const registry = readRegistry();
|
|
383
|
-
const cfg = JSON.parse(readFileSync(namedConfigPath(name), "utf8"));
|
|
384
|
-
return {
|
|
385
|
-
name,
|
|
386
|
-
default: registry.defaultProfile === name,
|
|
387
|
-
apiUrl: cfg.apiUrl || PROD_API_URL
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
function setDefaultProfile(name) {
|
|
391
|
-
if (name !== null) {
|
|
392
|
-
validateProfileName(name);
|
|
393
|
-
if (!profileExists(name)) {
|
|
394
|
-
throw new UsageError(`unknown profile: ${name}`, {
|
|
395
|
-
reason: "validation.invalid_value",
|
|
396
|
-
field: "profile"
|
|
397
|
-
});
|
|
235
|
+
const checks = schema._zod.def.checks;
|
|
236
|
+
const hasChecks = checks && checks.length > 0;
|
|
237
|
+
if (hasChecks) {
|
|
238
|
+
const existingShape = schema._zod.def.shape;
|
|
239
|
+
for (const key of Reflect.ownKeys(shape)) {
|
|
240
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
|
241
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
242
|
+
}
|
|
398
243
|
}
|
|
399
244
|
}
|
|
400
|
-
|
|
245
|
+
const def = mergeDefs(schema._zod.def, {
|
|
246
|
+
get shape() {
|
|
247
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
248
|
+
assignProp(this, "shape", _shape);
|
|
249
|
+
return _shape;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return clone(schema, def);
|
|
401
253
|
}
|
|
402
|
-
function
|
|
403
|
-
|
|
254
|
+
function safeExtend(schema, shape) {
|
|
255
|
+
if (!isPlainObject(shape)) {
|
|
256
|
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
257
|
+
}
|
|
258
|
+
const def = mergeDefs(schema._zod.def, {
|
|
259
|
+
get shape() {
|
|
260
|
+
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
261
|
+
assignProp(this, "shape", _shape);
|
|
262
|
+
return _shape;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return clone(schema, def);
|
|
404
266
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (registry.defaultProfile === name) {
|
|
409
|
-
throw new UsageError(`cannot delete default profile ${name}; select another default or run profile clear-default first`, { reason: "validation.invalid_value", field: "profile" });
|
|
267
|
+
function merge(a, b) {
|
|
268
|
+
if (!b?._zod?.def) {
|
|
269
|
+
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
410
270
|
}
|
|
411
|
-
if (
|
|
412
|
-
throw new
|
|
413
|
-
reason: "validation.invalid_value",
|
|
414
|
-
field: "profile"
|
|
415
|
-
});
|
|
271
|
+
if (a._zod.def.checks?.length) {
|
|
272
|
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
416
273
|
}
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
274
|
+
const def = mergeDefs(a._zod.def, {
|
|
275
|
+
get shape() {
|
|
276
|
+
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
277
|
+
assignProp(this, "shape", _shape);
|
|
278
|
+
return _shape;
|
|
279
|
+
},
|
|
280
|
+
get catchall() {
|
|
281
|
+
return b._zod.def.catchall;
|
|
282
|
+
},
|
|
283
|
+
checks: b._zod.def.checks ?? []
|
|
284
|
+
});
|
|
285
|
+
return clone(a, def);
|
|
420
286
|
}
|
|
421
|
-
function
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
if (!existsSync(path))
|
|
428
|
-
return false;
|
|
429
|
-
try {
|
|
430
|
-
const cfg = JSON.parse(readFileSync(path, "utf8"));
|
|
431
|
-
return Boolean(cfg.token);
|
|
432
|
-
} catch {
|
|
433
|
-
return false;
|
|
287
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
288
|
+
const currDef = schema._zod.def;
|
|
289
|
+
const checks = currDef.checks;
|
|
290
|
+
const hasChecks = checks && checks.length > 0;
|
|
291
|
+
if (hasChecks) {
|
|
292
|
+
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
434
293
|
}
|
|
294
|
+
const def = mergeDefs(schema._zod.def, {
|
|
295
|
+
get shape() {
|
|
296
|
+
const oldShape = schema._zod.def.shape;
|
|
297
|
+
const shape = { ...oldShape };
|
|
298
|
+
if (mask) {
|
|
299
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
300
|
+
if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
|
|
301
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
302
|
+
}
|
|
303
|
+
if (!mask[key])
|
|
304
|
+
continue;
|
|
305
|
+
shape[key] = Class ? new Class({
|
|
306
|
+
type: "optional",
|
|
307
|
+
innerType: oldShape[key]
|
|
308
|
+
}) : oldShape[key];
|
|
309
|
+
}
|
|
310
|
+
} else {
|
|
311
|
+
for (const key of Reflect.ownKeys(oldShape)) {
|
|
312
|
+
shape[key] = Class ? new Class({
|
|
313
|
+
type: "optional",
|
|
314
|
+
innerType: oldShape[key]
|
|
315
|
+
}) : oldShape[key];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
assignProp(this, "shape", shape);
|
|
319
|
+
return shape;
|
|
320
|
+
},
|
|
321
|
+
checks: []
|
|
322
|
+
});
|
|
323
|
+
return clone(schema, def);
|
|
435
324
|
}
|
|
436
|
-
function
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
325
|
+
function required(Class, schema, mask) {
|
|
326
|
+
const def = mergeDefs(schema._zod.def, {
|
|
327
|
+
get shape() {
|
|
328
|
+
const oldShape = schema._zod.def.shape;
|
|
329
|
+
const shape = { ...oldShape };
|
|
330
|
+
if (mask) {
|
|
331
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
332
|
+
if (!Object.prototype.hasOwnProperty.call(shape, key)) {
|
|
333
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
334
|
+
}
|
|
335
|
+
if (!mask[key])
|
|
336
|
+
continue;
|
|
337
|
+
shape[key] = new Class({
|
|
338
|
+
type: "nonoptional",
|
|
339
|
+
innerType: oldShape[key]
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
for (const key of Reflect.ownKeys(oldShape)) {
|
|
344
|
+
shape[key] = new Class({
|
|
345
|
+
type: "nonoptional",
|
|
346
|
+
innerType: oldShape[key]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
assignProp(this, "shape", shape);
|
|
351
|
+
return shape;
|
|
449
352
|
}
|
|
450
|
-
}
|
|
451
|
-
return
|
|
353
|
+
});
|
|
354
|
+
return clone(schema, def);
|
|
452
355
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (
|
|
458
|
-
|
|
356
|
+
function aborted(x, startIndex = 0) {
|
|
357
|
+
if (x.aborted === true)
|
|
358
|
+
return true;
|
|
359
|
+
for (let i = startIndex;i < x.issues.length; i++) {
|
|
360
|
+
if (x.issues[i]?.continue !== true) {
|
|
361
|
+
return true;
|
|
459
362
|
}
|
|
460
|
-
writeFileSync(opts.configPath, `${JSON.stringify(opts.cfg, null, 2)}
|
|
461
|
-
`, { mode: 384 });
|
|
462
|
-
chmodSync(opts.configPath, 384);
|
|
463
|
-
} finally {
|
|
464
|
-
release();
|
|
465
363
|
}
|
|
364
|
+
return false;
|
|
466
365
|
}
|
|
467
|
-
function
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
366
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
367
|
+
if (x.aborted === true)
|
|
368
|
+
return true;
|
|
369
|
+
for (let i = startIndex;i < x.issues.length; i++) {
|
|
370
|
+
if (x.issues[i]?.continue === false) {
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
472
373
|
}
|
|
473
|
-
|
|
474
|
-
cfg,
|
|
475
|
-
configPath: target.path,
|
|
476
|
-
defaultPath: target.defaultPath,
|
|
477
|
-
isolated: target.isolated,
|
|
478
|
-
allowDefaultTokenOverwrite: opts?.allowDefaultTokenOverwrite
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
function clearToken() {
|
|
482
|
-
const cfg = loadConfig();
|
|
483
|
-
saveConfig({ apiUrl: cfg.apiUrl }, { allowDefaultTokenOverwrite: true });
|
|
374
|
+
return false;
|
|
484
375
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
var
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
["CURSOR_TRACE_ID", "Cursor"]
|
|
493
|
-
];
|
|
494
|
-
function detectSource(env = process.env) {
|
|
495
|
-
const explicit = env.ARBOR_SOURCE?.trim();
|
|
496
|
-
if (explicit)
|
|
497
|
-
return explicit;
|
|
498
|
-
for (const [envVar, tool] of SNIFF) {
|
|
499
|
-
if (env[envVar]?.trim())
|
|
500
|
-
return tool;
|
|
501
|
-
}
|
|
502
|
-
return;
|
|
376
|
+
function prefixIssues(path, issues) {
|
|
377
|
+
return issues.map((iss) => {
|
|
378
|
+
var _a;
|
|
379
|
+
(_a = iss).path ?? (_a.path = []);
|
|
380
|
+
iss.path.unshift(path);
|
|
381
|
+
return iss;
|
|
382
|
+
});
|
|
503
383
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
this.name = "NotLoggedInError";
|
|
384
|
+
function unwrapMessage(message) {
|
|
385
|
+
return typeof message === "string" ? message : message?.message;
|
|
386
|
+
}
|
|
387
|
+
function attachSchema(issues, start, inst) {
|
|
388
|
+
var _a;
|
|
389
|
+
for (let i = start;i < issues.length; i++) {
|
|
390
|
+
(_a = issues[i]).schema ?? (_a.schema = inst);
|
|
512
391
|
}
|
|
513
392
|
}
|
|
514
|
-
function
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
393
|
+
function finalizeIssue(iss, ctx, config) {
|
|
394
|
+
var _a;
|
|
395
|
+
const traits = iss.inst?._zod?.traits;
|
|
396
|
+
if (traits?.has("$ZodType")) {
|
|
397
|
+
if (traits.has("$ZodCheck"))
|
|
398
|
+
(_a = iss).schema ?? (_a.schema = iss.inst);
|
|
399
|
+
else
|
|
400
|
+
iss.schema = iss.inst;
|
|
401
|
+
}
|
|
402
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : undefined;
|
|
403
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
404
|
+
const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
|
|
405
|
+
rest.path ?? (rest.path = []);
|
|
406
|
+
rest.message = message;
|
|
407
|
+
if (ctx?.reportInput) {
|
|
408
|
+
rest.input = _input;
|
|
409
|
+
}
|
|
410
|
+
return rest;
|
|
519
411
|
}
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
method: "POST",
|
|
531
|
-
headers: {
|
|
532
|
-
"content-type": "application/json",
|
|
533
|
-
authorization,
|
|
534
|
-
...source ? { "x-arbor-source": source } : {}
|
|
535
|
-
},
|
|
536
|
-
body: JSON.stringify({ object, verb, input })
|
|
537
|
-
});
|
|
538
|
-
} catch (cause) {
|
|
539
|
-
throw new ApiError(`could not reach ${apiUrl} (${cause instanceof Error ? cause.message : String(cause)})`, 0);
|
|
412
|
+
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
413
|
+
function codePointLength(str) {
|
|
414
|
+
const units = str.length;
|
|
415
|
+
if (!highSurrogate.test(str))
|
|
416
|
+
return units;
|
|
417
|
+
let count = units;
|
|
418
|
+
for (let i = 0;i < units - 1; i++) {
|
|
419
|
+
if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
420
|
+
count--;
|
|
421
|
+
i++;
|
|
540
422
|
}
|
|
541
|
-
const body = await res.json().catch(() => ({}));
|
|
542
|
-
if (!res.ok || !body.success)
|
|
543
|
-
throw new ApiError(body.error ?? `request failed (${res.status})`, res.status, parseErrorDetails(body.errorDetails));
|
|
544
|
-
return body.data;
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
async function binaryGet(path, authenticated = true) {
|
|
548
|
-
const { authorization, apiUrl } = authHeader();
|
|
549
|
-
let response;
|
|
550
|
-
const url = new URL(path, apiUrl);
|
|
551
|
-
if (url.origin !== new URL(apiUrl).origin || !authenticated && !url.pathname.startsWith("/api/attachment-read/"))
|
|
552
|
-
throw new Error("Invalid download target");
|
|
553
|
-
try {
|
|
554
|
-
response = await fetch(url.toString(), {
|
|
555
|
-
headers: authenticated ? { authorization } : {},
|
|
556
|
-
redirect: "error"
|
|
557
|
-
});
|
|
558
|
-
} catch {
|
|
559
|
-
throw new ApiError("Binary download request failed", 0);
|
|
560
423
|
}
|
|
561
|
-
|
|
562
|
-
throw new ApiError(`Download failed (${response.status})`, response.status);
|
|
563
|
-
return response;
|
|
424
|
+
return count;
|
|
564
425
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
});
|
|
578
|
-
if (signed && !metadata?.signedRead)
|
|
579
|
-
throw new Error("Signed download is unavailable");
|
|
580
|
-
const response = await binaryGet(signed ? metadata.signedRead.url : `/api/download/${artifact ? "artifact/" : ""}${encodeURIComponent(id)}`, !signed);
|
|
581
|
-
const size = metadata?.size ?? Number(response.headers.get("x-arbor-size") ?? response.headers.get("content-length") ?? "NaN");
|
|
582
|
-
if (!Number.isSafeInteger(size) || size < 0 || !response.body)
|
|
583
|
-
throw new Error("Download has no valid size or body");
|
|
584
|
-
const suggested = basename(metadata?.filename ?? dispositionFilename(response.headers.get("content-disposition")) ?? id);
|
|
585
|
-
const destination = resolve(output ?? (suggested.startsWith(".") ? id : suggested));
|
|
586
|
-
const temporary = `${destination}.${randomUUID()}.part`;
|
|
587
|
-
const file = await open(temporary, "wx", 384);
|
|
588
|
-
const reader = response.body.getReader();
|
|
589
|
-
const hash = createHash("sha256");
|
|
590
|
-
let received = 0;
|
|
591
|
-
try {
|
|
592
|
-
for (;; ) {
|
|
593
|
-
const { done, value } = await reader.read();
|
|
594
|
-
if (done)
|
|
595
|
-
break;
|
|
596
|
-
received += value.byteLength;
|
|
597
|
-
if (received > size)
|
|
598
|
-
throw new Error("Download size mismatch");
|
|
599
|
-
hash.update(value);
|
|
600
|
-
let offset = 0;
|
|
601
|
-
while (offset < value.length) {
|
|
602
|
-
const written = await file.write(value, offset, value.length - offset);
|
|
603
|
-
offset += written.bytesWritten;
|
|
604
|
-
}
|
|
426
|
+
function getLengthableOrigin(input) {
|
|
427
|
+
if (Array.isArray(input))
|
|
428
|
+
return "array";
|
|
429
|
+
if (typeof input === "string")
|
|
430
|
+
return "string";
|
|
431
|
+
return "unknown";
|
|
432
|
+
}
|
|
433
|
+
function parsedType(data) {
|
|
434
|
+
const t = typeof data;
|
|
435
|
+
switch (t) {
|
|
436
|
+
case "number": {
|
|
437
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
605
438
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
} catch (error) {
|
|
617
|
-
if (error.code === "EEXIST")
|
|
618
|
-
throw new Error("Destination exists; use --force to replace it");
|
|
619
|
-
if (["EPERM", "ENOTSUP"].includes(error.code ?? ""))
|
|
620
|
-
throw new Error("Filesystem does not support safe no-replace downloads; choose another destination or use --force to allow replacement");
|
|
621
|
-
throw error;
|
|
439
|
+
case "object": {
|
|
440
|
+
if (data === null) {
|
|
441
|
+
return "null";
|
|
442
|
+
}
|
|
443
|
+
if (Array.isArray(data)) {
|
|
444
|
+
return "array";
|
|
445
|
+
}
|
|
446
|
+
const obj = data;
|
|
447
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
448
|
+
return obj.constructor.name;
|
|
622
449
|
}
|
|
623
|
-
await unlink(temporary);
|
|
624
450
|
}
|
|
625
|
-
return { path: destination, size: received, sha256 };
|
|
626
|
-
} catch (error) {
|
|
627
|
-
await reader.cancel().catch(() => {});
|
|
628
|
-
await file.close().catch(() => {});
|
|
629
|
-
await unlink(temporary).catch(() => {});
|
|
630
|
-
throw error;
|
|
631
|
-
} finally {
|
|
632
|
-
reader.releaseLock();
|
|
633
451
|
}
|
|
452
|
+
return t;
|
|
634
453
|
}
|
|
635
|
-
function
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
454
|
+
function issue(...args) {
|
|
455
|
+
const [iss, input, inst] = args;
|
|
456
|
+
if (typeof iss === "string") {
|
|
457
|
+
return {
|
|
458
|
+
message: iss,
|
|
459
|
+
code: "custom",
|
|
460
|
+
input,
|
|
461
|
+
inst
|
|
462
|
+
};
|
|
643
463
|
}
|
|
644
|
-
return
|
|
464
|
+
return { ...iss };
|
|
645
465
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
"cli",
|
|
655
|
-
"collaboration",
|
|
656
|
-
"mcp"
|
|
657
|
-
],
|
|
658
|
-
license: "MIT",
|
|
659
|
-
repository: {
|
|
660
|
-
type: "git",
|
|
661
|
-
url: "git+https://github.com/lambda-curry/arbor.git",
|
|
662
|
-
directory: "packages/cli"
|
|
663
|
-
},
|
|
664
|
-
bin: {
|
|
665
|
-
arbor: "./dist/arbor.js"
|
|
666
|
-
},
|
|
667
|
-
files: [
|
|
668
|
-
"dist",
|
|
669
|
-
"README.md"
|
|
670
|
-
],
|
|
671
|
-
type: "module",
|
|
672
|
-
publishConfig: {
|
|
673
|
-
access: "public"
|
|
674
|
-
},
|
|
675
|
-
scripts: {
|
|
676
|
-
arbor: "vpx src/bin.ts",
|
|
677
|
-
build: "bun build ./src/bin.ts --target=node --outfile=dist/arbor.js",
|
|
678
|
-
test: "vp test run --passWithNoTests",
|
|
679
|
-
typecheck: "tsc -b",
|
|
680
|
-
prepublishOnly: "bun run build"
|
|
681
|
-
},
|
|
682
|
-
devDependencies: {
|
|
683
|
-
"@arbor/actions": "workspace:*",
|
|
684
|
-
"@arbor/core": "workspace:*",
|
|
685
|
-
"@types/node": "^26.2.0",
|
|
686
|
-
"just-bash": "3.4.2",
|
|
687
|
-
typescript: "^5.8.0",
|
|
688
|
-
"vite-plus": "catalog:",
|
|
689
|
-
zod: "^4.4.3"
|
|
690
|
-
},
|
|
691
|
-
engines: {
|
|
692
|
-
node: ">=18"
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/util.js
|
|
697
|
-
function getEnumValues(entries) {
|
|
698
|
-
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
699
|
-
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
700
|
-
return values;
|
|
701
|
-
}
|
|
702
|
-
function joinValues(array, separator = "|") {
|
|
703
|
-
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
466
|
+
function members(proto, table) {
|
|
467
|
+
for (const key in table) {
|
|
468
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
469
|
+
if (desc.get)
|
|
470
|
+
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
471
|
+
else
|
|
472
|
+
defineBound(proto, key, desc.value);
|
|
473
|
+
}
|
|
704
474
|
}
|
|
705
|
-
function
|
|
706
|
-
|
|
707
|
-
return value.toString();
|
|
475
|
+
function own(inst, key, value, enumerable = true) {
|
|
476
|
+
Object.defineProperty(inst, key, { configurable: true, writable: true, enumerable, value });
|
|
708
477
|
return value;
|
|
709
478
|
}
|
|
710
|
-
function
|
|
711
|
-
|
|
712
|
-
return {
|
|
713
|
-
get value() {
|
|
714
|
-
if (!set) {
|
|
715
|
-
const value = getter();
|
|
716
|
-
Object.defineProperty(this, "value", { value });
|
|
717
|
-
return value;
|
|
718
|
-
}
|
|
719
|
-
throw new Error("cached value already set");
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
function nullish(input) {
|
|
724
|
-
return input === null || input === undefined;
|
|
479
|
+
function hide(inst, key, value) {
|
|
480
|
+
return own(inst, key, value, false);
|
|
725
481
|
}
|
|
726
|
-
function
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
482
|
+
function defineBound(proto, key, fn) {
|
|
483
|
+
Object.defineProperty(proto, key, {
|
|
484
|
+
configurable: true,
|
|
485
|
+
get() {
|
|
486
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
487
|
+
},
|
|
488
|
+
set(value) {
|
|
489
|
+
own(this, key, value);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
730
492
|
}
|
|
731
|
-
function
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
735
|
-
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
736
|
-
return 0;
|
|
737
|
-
return ratio - roundedRatio;
|
|
493
|
+
function claim(inst, sentinel) {
|
|
494
|
+
const proto = Object.getPrototypeOf(inst);
|
|
495
|
+
return sentinel in proto ? undefined : proto;
|
|
738
496
|
}
|
|
739
|
-
var
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
497
|
+
var installing;
|
|
498
|
+
var broke = false;
|
|
499
|
+
var breaker = {
|
|
500
|
+
configurable: true,
|
|
501
|
+
get() {
|
|
502
|
+
broke = true;
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
function defineLazyInternal(inst, key, compute) {
|
|
507
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
508
|
+
if (key in proto && installing !== inst._zod) {
|
|
509
|
+
installing = undefined;
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
installing = inst._zod;
|
|
513
|
+
Object.defineProperty(proto, key, {
|
|
514
|
+
configurable: true,
|
|
743
515
|
get() {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
value =
|
|
749
|
-
|
|
516
|
+
Object.defineProperty(this, key, breaker);
|
|
517
|
+
const outer = broke;
|
|
518
|
+
broke = false;
|
|
519
|
+
try {
|
|
520
|
+
const value = compute(this);
|
|
521
|
+
if (broke)
|
|
522
|
+
delete this[key];
|
|
523
|
+
else
|
|
524
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
525
|
+
broke = broke || outer;
|
|
526
|
+
return value;
|
|
527
|
+
} catch (err) {
|
|
528
|
+
delete this[key];
|
|
529
|
+
broke = broke || outer;
|
|
530
|
+
throw err;
|
|
750
531
|
}
|
|
751
|
-
return value;
|
|
752
|
-
},
|
|
753
|
-
set(v) {
|
|
754
|
-
Object.defineProperty(object, key, {
|
|
755
|
-
value: v
|
|
756
|
-
});
|
|
757
532
|
},
|
|
758
|
-
|
|
533
|
+
set(value) {
|
|
534
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
535
|
+
}
|
|
759
536
|
});
|
|
760
537
|
}
|
|
761
|
-
function
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
configurable: true
|
|
538
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
539
|
+
const proto = claim(inst, key);
|
|
540
|
+
if (!proto)
|
|
541
|
+
return;
|
|
542
|
+
Object.defineProperty(proto, key, {
|
|
543
|
+
configurable: true,
|
|
544
|
+
get() {
|
|
545
|
+
const desc = { configurable: true, writable: true, enumerable, value: undefined };
|
|
546
|
+
Object.defineProperty(this, key, desc);
|
|
547
|
+
desc.value = make(this);
|
|
548
|
+
Object.defineProperty(this, key, desc);
|
|
549
|
+
return desc.value;
|
|
550
|
+
},
|
|
551
|
+
set(value) {
|
|
552
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, enumerable, value });
|
|
553
|
+
}
|
|
767
554
|
});
|
|
768
555
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
return Object.defineProperties({}, mergedDescriptors);
|
|
776
|
-
}
|
|
777
|
-
function esc(str) {
|
|
778
|
-
return JSON.stringify(str);
|
|
779
|
-
}
|
|
780
|
-
function slugify(input) {
|
|
781
|
-
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
782
|
-
}
|
|
783
|
-
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
784
|
-
function isObject(data) {
|
|
785
|
-
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
556
|
+
var CONSTANT_CATCH = "~constantCatch";
|
|
557
|
+
function constantCatch(value) {
|
|
558
|
+
const fn = () => value;
|
|
559
|
+
fn[CONSTANT_CATCH] = true;
|
|
560
|
+
return fn;
|
|
786
561
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
562
|
+
|
|
563
|
+
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/core.js
|
|
564
|
+
var _a;
|
|
565
|
+
var _zodDesc = { value: undefined, enumerable: false };
|
|
566
|
+
var _E = "captureStackTrace" in Error ? Error : null;
|
|
567
|
+
function newError(Definition) {
|
|
568
|
+
const E = _E;
|
|
569
|
+
if (E) {
|
|
570
|
+
const saved = E.stackTraceLimit;
|
|
571
|
+
if (typeof saved === "number") {
|
|
572
|
+
try {
|
|
573
|
+
E.stackTraceLimit = 0;
|
|
574
|
+
} catch {
|
|
575
|
+
_E = null;
|
|
576
|
+
return new Definition;
|
|
577
|
+
}
|
|
578
|
+
try {
|
|
579
|
+
return new Definition;
|
|
580
|
+
} finally {
|
|
581
|
+
E.stackTraceLimit = saved;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
790
584
|
}
|
|
791
|
-
|
|
792
|
-
|
|
585
|
+
return new Definition;
|
|
586
|
+
}
|
|
587
|
+
function $constructor(name, initializer, proto, params) {
|
|
588
|
+
const zodProto = {};
|
|
589
|
+
function Internals(def) {
|
|
590
|
+
this.def = def;
|
|
591
|
+
this.constr = _;
|
|
592
|
+
this.traits = new Set;
|
|
793
593
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
594
|
+
Internals.prototype = zodProto;
|
|
595
|
+
const protoMembers = proto;
|
|
596
|
+
const initialized = protoMembers && new WeakSet;
|
|
597
|
+
function init(inst, def) {
|
|
598
|
+
if (!inst._zod) {
|
|
599
|
+
_zodDesc.value = new Internals(def);
|
|
600
|
+
try {
|
|
601
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
602
|
+
} finally {
|
|
603
|
+
_zodDesc.value = undefined;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (inst._zod.traits.has(name)) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
inst._zod.traits.add(name);
|
|
610
|
+
initializer(inst, def);
|
|
611
|
+
if (initialized) {
|
|
612
|
+
const own = Object.getPrototypeOf(inst);
|
|
613
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
614
|
+
let up = own;
|
|
615
|
+
while (up && up !== ctorProto)
|
|
616
|
+
up = Object.getPrototypeOf(up);
|
|
617
|
+
const target = up ?? own;
|
|
618
|
+
if (!initialized.has(target)) {
|
|
619
|
+
initialized.add(target);
|
|
620
|
+
members(target, protoMembers);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
const proto = _.prototype;
|
|
624
|
+
for (const k in proto) {
|
|
625
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k))
|
|
626
|
+
continue;
|
|
627
|
+
if (!(k in inst)) {
|
|
628
|
+
inst[k] = proto[k].bind(inst);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
800
631
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
return false;
|
|
805
|
-
const ctor = o.constructor;
|
|
806
|
-
if (ctor === undefined)
|
|
807
|
-
return true;
|
|
808
|
-
if (typeof ctor !== "function")
|
|
809
|
-
return true;
|
|
810
|
-
const prot = ctor.prototype;
|
|
811
|
-
if (isObject(prot) === false)
|
|
812
|
-
return false;
|
|
813
|
-
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
814
|
-
return false;
|
|
632
|
+
const Parent = params?.Parent ?? Object;
|
|
633
|
+
|
|
634
|
+
class Definition extends Parent {
|
|
815
635
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
636
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
637
|
+
function _(def) {
|
|
638
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
639
|
+
init(inst, def);
|
|
640
|
+
const deferred = inst._zod.deferred;
|
|
641
|
+
if (deferred) {
|
|
642
|
+
for (const fn of deferred) {
|
|
643
|
+
fn();
|
|
644
|
+
}
|
|
645
|
+
inst._zod.deferred = undefined;
|
|
646
|
+
}
|
|
647
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
648
|
+
if (pp)
|
|
649
|
+
pp(inst);
|
|
650
|
+
return inst;
|
|
651
|
+
}
|
|
652
|
+
Object.defineProperty(_, "init", { value: init });
|
|
653
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
654
|
+
value: (inst) => {
|
|
655
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
656
|
+
return true;
|
|
657
|
+
return inst?._zod?.traits?.has(name);
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
Object.defineProperty(_, "name", { value: name });
|
|
661
|
+
return _;
|
|
832
662
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
return cl;
|
|
663
|
+
class $ZodAsyncError extends Error {
|
|
664
|
+
constructor() {
|
|
665
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
666
|
+
}
|
|
838
667
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
return { error: () => params };
|
|
845
|
-
if (params?.message !== undefined) {
|
|
846
|
-
if (params?.error !== undefined)
|
|
847
|
-
throw new Error("Cannot specify both `message` and `error` params");
|
|
848
|
-
params.error = params.message;
|
|
668
|
+
|
|
669
|
+
class $ZodEncodeError extends Error {
|
|
670
|
+
constructor(name) {
|
|
671
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
672
|
+
this.name = "ZodEncodeError";
|
|
849
673
|
}
|
|
850
|
-
delete params.message;
|
|
851
|
-
if (typeof params.error === "string")
|
|
852
|
-
return { ...params, error: () => params.error };
|
|
853
|
-
return params;
|
|
854
674
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
if (
|
|
859
|
-
|
|
860
|
-
return
|
|
675
|
+
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
676
|
+
var globalConfig = globalThis.__zod_globalConfig;
|
|
677
|
+
function config(newConfig) {
|
|
678
|
+
if (newConfig)
|
|
679
|
+
Object.assign(globalConfig, newConfig);
|
|
680
|
+
return globalConfig;
|
|
861
681
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
682
|
+
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/errors.js
|
|
683
|
+
function _getMessage() {
|
|
684
|
+
const internals = this._zod;
|
|
685
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
686
|
+
return internals.message;
|
|
866
687
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
int32: [-2147483648, 2147483647],
|
|
870
|
-
uint32: [0, 4294967295],
|
|
871
|
-
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
872
|
-
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
873
|
-
}))();
|
|
874
|
-
function pick(schema, mask) {
|
|
875
|
-
const currDef = schema._zod.def;
|
|
876
|
-
const checks = currDef.checks;
|
|
877
|
-
const hasChecks = checks && checks.length > 0;
|
|
878
|
-
if (hasChecks) {
|
|
879
|
-
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
880
|
-
}
|
|
881
|
-
const def = mergeDefs(schema._zod.def, {
|
|
882
|
-
get shape() {
|
|
883
|
-
const newShape = {};
|
|
884
|
-
for (const key of Reflect.ownKeys(mask)) {
|
|
885
|
-
if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
|
|
886
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
887
|
-
}
|
|
888
|
-
if (!mask[key])
|
|
889
|
-
continue;
|
|
890
|
-
assignProp(newShape, key, currDef.shape[key]);
|
|
891
|
-
}
|
|
892
|
-
assignProp(this, "shape", newShape);
|
|
893
|
-
return newShape;
|
|
894
|
-
},
|
|
895
|
-
checks: []
|
|
896
|
-
});
|
|
897
|
-
return clone(schema, def);
|
|
688
|
+
function _setMessage(value) {
|
|
689
|
+
this._zod.message = value;
|
|
898
690
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
691
|
+
var _messageDesc = {
|
|
692
|
+
get: _getMessage,
|
|
693
|
+
set: _setMessage,
|
|
694
|
+
enumerable: true,
|
|
695
|
+
configurable: true
|
|
696
|
+
};
|
|
697
|
+
var _zodDesc2 = { value: undefined, enumerable: false };
|
|
698
|
+
var _issuesDesc = { value: undefined, enumerable: false };
|
|
699
|
+
var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
700
|
+
var initializer = (inst, def) => {
|
|
701
|
+
inst.name = "$ZodError";
|
|
702
|
+
_zodDesc2.value = inst._zod;
|
|
703
|
+
Object.defineProperty(inst, "_zod", _zodDesc2);
|
|
704
|
+
_issuesDesc.value = def;
|
|
705
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
706
|
+
_zodDesc2.value = undefined;
|
|
707
|
+
_issuesDesc.value = undefined;
|
|
708
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
709
|
+
const proto = Object.getPrototypeOf(inst);
|
|
710
|
+
if (!_installedToString.has(proto)) {
|
|
711
|
+
_installedToString.add(proto);
|
|
712
|
+
Object.defineProperty(proto, "toString", {
|
|
713
|
+
configurable: true,
|
|
714
|
+
enumerable: false,
|
|
715
|
+
get() {
|
|
716
|
+
const value = () => this.message;
|
|
717
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
718
|
+
return value;
|
|
719
|
+
},
|
|
720
|
+
set(value) {
|
|
721
|
+
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
916
722
|
}
|
|
917
|
-
|
|
918
|
-
return newShape;
|
|
919
|
-
},
|
|
920
|
-
checks: []
|
|
921
|
-
});
|
|
922
|
-
return clone(schema, def);
|
|
923
|
-
}
|
|
924
|
-
function extend(schema, shape) {
|
|
925
|
-
if (!isPlainObject(shape)) {
|
|
926
|
-
throw new Error("Invalid input to extend: expected a plain object");
|
|
723
|
+
});
|
|
927
724
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
725
|
+
};
|
|
726
|
+
var $ZodError = $constructor("$ZodError", initializer);
|
|
727
|
+
var $ZodRealError = $constructor("$ZodError", initializer, undefined, {
|
|
728
|
+
Parent: Error
|
|
729
|
+
});
|
|
730
|
+
function node(obj, key, make) {
|
|
731
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
732
|
+
if (key === "__proto__") {
|
|
733
|
+
Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
|
|
734
|
+
} else {
|
|
735
|
+
obj[key] = make();
|
|
936
736
|
}
|
|
937
737
|
}
|
|
938
|
-
|
|
939
|
-
get shape() {
|
|
940
|
-
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
941
|
-
assignProp(this, "shape", _shape);
|
|
942
|
-
return _shape;
|
|
943
|
-
}
|
|
944
|
-
});
|
|
945
|
-
return clone(schema, def);
|
|
738
|
+
return obj[key];
|
|
946
739
|
}
|
|
947
|
-
function
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
return _shape;
|
|
740
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
741
|
+
const fieldErrors = {};
|
|
742
|
+
const formErrors = [];
|
|
743
|
+
for (const sub of error.issues) {
|
|
744
|
+
if (sub.path.length > 0) {
|
|
745
|
+
node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
746
|
+
} else {
|
|
747
|
+
formErrors.push(mapper(sub));
|
|
956
748
|
}
|
|
957
|
-
});
|
|
958
|
-
return clone(schema, def);
|
|
959
|
-
}
|
|
960
|
-
function merge(a, b) {
|
|
961
|
-
if (!b?._zod?.def) {
|
|
962
|
-
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
963
|
-
}
|
|
964
|
-
if (a._zod.def.checks?.length) {
|
|
965
|
-
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
966
749
|
}
|
|
967
|
-
|
|
968
|
-
get shape() {
|
|
969
|
-
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
|
970
|
-
assignProp(this, "shape", _shape);
|
|
971
|
-
return _shape;
|
|
972
|
-
},
|
|
973
|
-
get catchall() {
|
|
974
|
-
return b._zod.def.catchall;
|
|
975
|
-
},
|
|
976
|
-
checks: b._zod.def.checks ?? []
|
|
977
|
-
});
|
|
978
|
-
return clone(a, def);
|
|
750
|
+
return { formErrors, fieldErrors };
|
|
979
751
|
}
|
|
980
|
-
function
|
|
981
|
-
const
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
const shape = { ...oldShape };
|
|
991
|
-
if (mask) {
|
|
992
|
-
for (const key of Reflect.ownKeys(mask)) {
|
|
993
|
-
if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
|
|
994
|
-
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
995
|
-
}
|
|
996
|
-
if (!mask[key])
|
|
997
|
-
continue;
|
|
998
|
-
shape[key] = Class ? new Class({
|
|
999
|
-
type: "optional",
|
|
1000
|
-
innerType: oldShape[key]
|
|
1001
|
-
}) : oldShape[key];
|
|
1002
|
-
}
|
|
752
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
753
|
+
const fieldErrors = { _errors: [] };
|
|
754
|
+
const processError = (error, path = []) => {
|
|
755
|
+
for (const issue of error.issues) {
|
|
756
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
757
|
+
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
758
|
+
} else if (issue.code === "invalid_key") {
|
|
759
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
760
|
+
} else if (issue.code === "invalid_element") {
|
|
761
|
+
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
1003
762
|
} else {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
763
|
+
const fullpath = [...path, ...issue.path];
|
|
764
|
+
if (fullpath.length === 0) {
|
|
765
|
+
fieldErrors._errors.push(mapper(issue));
|
|
766
|
+
} else {
|
|
767
|
+
let curr = fieldErrors;
|
|
768
|
+
let i = 0;
|
|
769
|
+
while (i < fullpath.length) {
|
|
770
|
+
const el = fullpath[i];
|
|
771
|
+
const terminal = i === fullpath.length - 1;
|
|
772
|
+
if (el === "_errors") {
|
|
773
|
+
if (terminal)
|
|
774
|
+
curr._errors.push(mapper(issue));
|
|
775
|
+
i++;
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) {
|
|
779
|
+
Object.defineProperty(curr, el, {
|
|
780
|
+
value: { _errors: [] },
|
|
781
|
+
enumerable: true,
|
|
782
|
+
writable: true,
|
|
783
|
+
configurable: true
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
const node = curr[el];
|
|
787
|
+
if (terminal) {
|
|
788
|
+
node._errors.push(mapper(issue));
|
|
789
|
+
}
|
|
790
|
+
curr = node;
|
|
791
|
+
i++;
|
|
1027
792
|
}
|
|
1028
|
-
if (!mask[key])
|
|
1029
|
-
continue;
|
|
1030
|
-
shape[key] = new Class({
|
|
1031
|
-
type: "nonoptional",
|
|
1032
|
-
innerType: oldShape[key]
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
} else {
|
|
1036
|
-
for (const key of Reflect.ownKeys(oldShape)) {
|
|
1037
|
-
shape[key] = new Class({
|
|
1038
|
-
type: "nonoptional",
|
|
1039
|
-
innerType: oldShape[key]
|
|
1040
|
-
});
|
|
1041
793
|
}
|
|
1042
794
|
}
|
|
1043
|
-
assignProp(this, "shape", shape);
|
|
1044
|
-
return shape;
|
|
1045
795
|
}
|
|
1046
|
-
}
|
|
1047
|
-
|
|
796
|
+
};
|
|
797
|
+
processError(error);
|
|
798
|
+
return fieldErrors;
|
|
1048
799
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
if (x.issues[i]?.continue !== true) {
|
|
1054
|
-
return true;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
return false;
|
|
800
|
+
|
|
801
|
+
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/parse.js
|
|
802
|
+
function finalizeParams(callee, params) {
|
|
803
|
+
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
1058
804
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
if (
|
|
1064
|
-
|
|
805
|
+
var _parse = (_Err) => {
|
|
806
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
807
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
808
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
809
|
+
if (result instanceof Promise) {
|
|
810
|
+
throw new $ZodAsyncError;
|
|
811
|
+
}
|
|
812
|
+
if (result.issues.length) {
|
|
813
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
814
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
815
|
+
throw e;
|
|
816
|
+
}
|
|
817
|
+
return result.value;
|
|
818
|
+
};
|
|
819
|
+
return fn;
|
|
820
|
+
};
|
|
821
|
+
var _parseAsync = (_Err) => {
|
|
822
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
823
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
824
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
825
|
+
if (result instanceof Promise)
|
|
826
|
+
result = await result;
|
|
827
|
+
if (result.issues.length) {
|
|
828
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
829
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
830
|
+
throw e;
|
|
1065
831
|
}
|
|
832
|
+
return result.value;
|
|
833
|
+
};
|
|
834
|
+
return fn;
|
|
835
|
+
};
|
|
836
|
+
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
837
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
838
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
839
|
+
if (result instanceof Promise) {
|
|
840
|
+
throw new $ZodAsyncError;
|
|
1066
841
|
}
|
|
1067
|
-
return
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
});
|
|
842
|
+
return result.issues.length ? {
|
|
843
|
+
success: false,
|
|
844
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
845
|
+
} : { success: true, data: result.value };
|
|
846
|
+
};
|
|
847
|
+
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
848
|
+
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
849
|
+
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
850
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
851
|
+
if (result instanceof Promise)
|
|
852
|
+
result = await result;
|
|
853
|
+
return result.issues.length ? {
|
|
854
|
+
success: false,
|
|
855
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
856
|
+
} : { success: true, data: result.value };
|
|
857
|
+
};
|
|
858
|
+
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
859
|
+
var _encode = (_Err) => {
|
|
860
|
+
const parse = _parse(_Err);
|
|
861
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
862
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
863
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
864
|
+
};
|
|
865
|
+
return fn;
|
|
866
|
+
};
|
|
867
|
+
var _decode = (_Err) => {
|
|
868
|
+
const parse = _parse(_Err);
|
|
869
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
870
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
871
|
+
};
|
|
872
|
+
return fn;
|
|
873
|
+
};
|
|
874
|
+
var _encodeAsync = (_Err) => {
|
|
875
|
+
const parseAsync = _parseAsync(_Err);
|
|
876
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
877
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
878
|
+
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
879
|
+
};
|
|
880
|
+
return fn;
|
|
881
|
+
};
|
|
882
|
+
var _decodeAsync = (_Err) => {
|
|
883
|
+
const parseAsync = _parseAsync(_Err);
|
|
884
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
885
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
886
|
+
};
|
|
887
|
+
return fn;
|
|
888
|
+
};
|
|
889
|
+
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
890
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
891
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
892
|
+
};
|
|
893
|
+
var _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
894
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
895
|
+
};
|
|
896
|
+
var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
897
|
+
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
898
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
899
|
+
};
|
|
900
|
+
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
901
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
902
|
+
};
|
|
903
|
+
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/regexes.js
|
|
904
|
+
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
905
|
+
var cuid2 = /^[0-9a-z]+$/;
|
|
906
|
+
var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
907
|
+
var xid = /^[0-9a-vA-V]{20}$/;
|
|
908
|
+
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
909
|
+
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
910
|
+
function nanoidOfLength(length) {
|
|
911
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
1076
912
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
913
|
+
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
914
|
+
var 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})$/;
|
|
915
|
+
var uuid = (version) => {
|
|
916
|
+
if (!version)
|
|
917
|
+
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)$/;
|
|
918
|
+
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})$`);
|
|
919
|
+
};
|
|
920
|
+
var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
921
|
+
var _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
922
|
+
function emoji() {
|
|
923
|
+
return new RegExp(_emoji, "u");
|
|
1079
924
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
925
|
+
var 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])$/;
|
|
926
|
+
var 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}|:))$/;
|
|
927
|
+
var 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])$/;
|
|
928
|
+
var cidrv6 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
929
|
+
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
930
|
+
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
931
|
+
var httpProtocol = /^https?$/;
|
|
932
|
+
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
933
|
+
var 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])))`;
|
|
934
|
+
function anchor(source) {
|
|
935
|
+
return new RegExp(`^${source}$`);
|
|
1085
936
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
(_a = iss).schema ?? (_a.schema = iss.inst);
|
|
1092
|
-
else
|
|
1093
|
-
iss.schema = iss.inst;
|
|
1094
|
-
}
|
|
1095
|
-
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : undefined;
|
|
1096
|
-
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
1097
|
-
const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
|
|
1098
|
-
rest.path ?? (rest.path = []);
|
|
1099
|
-
rest.message = message;
|
|
1100
|
-
if (ctx?.reportInput) {
|
|
1101
|
-
rest.input = _input;
|
|
1102
|
-
}
|
|
1103
|
-
return rest;
|
|
1104
|
-
}
|
|
1105
|
-
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
1106
|
-
function codePointLength(str) {
|
|
1107
|
-
const units = str.length;
|
|
1108
|
-
if (!highSurrogate.test(str))
|
|
1109
|
-
return units;
|
|
1110
|
-
let count = units;
|
|
1111
|
-
for (let i = 0;i < units - 1; i++) {
|
|
1112
|
-
if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
1113
|
-
count--;
|
|
1114
|
-
i++;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
return count;
|
|
1118
|
-
}
|
|
1119
|
-
function getLengthableOrigin(input) {
|
|
1120
|
-
if (Array.isArray(input))
|
|
1121
|
-
return "array";
|
|
1122
|
-
if (typeof input === "string")
|
|
1123
|
-
return "string";
|
|
1124
|
-
return "unknown";
|
|
1125
|
-
}
|
|
1126
|
-
function parsedType(data) {
|
|
1127
|
-
const t = typeof data;
|
|
1128
|
-
switch (t) {
|
|
1129
|
-
case "number": {
|
|
1130
|
-
return Number.isNaN(data) ? "nan" : "number";
|
|
1131
|
-
}
|
|
1132
|
-
case "object": {
|
|
1133
|
-
if (data === null) {
|
|
1134
|
-
return "null";
|
|
1135
|
-
}
|
|
1136
|
-
if (Array.isArray(data)) {
|
|
1137
|
-
return "array";
|
|
1138
|
-
}
|
|
1139
|
-
const obj = data;
|
|
1140
|
-
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
1141
|
-
return obj.constructor.name;
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
return t;
|
|
1146
|
-
}
|
|
1147
|
-
function issue(...args) {
|
|
1148
|
-
const [iss, input, inst] = args;
|
|
1149
|
-
if (typeof iss === "string") {
|
|
1150
|
-
return {
|
|
1151
|
-
message: iss,
|
|
1152
|
-
code: "custom",
|
|
1153
|
-
input,
|
|
1154
|
-
inst
|
|
1155
|
-
};
|
|
1156
|
-
}
|
|
1157
|
-
return { ...iss };
|
|
1158
|
-
}
|
|
1159
|
-
function members(proto, table) {
|
|
1160
|
-
for (const key in table) {
|
|
1161
|
-
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
1162
|
-
if (desc.get)
|
|
1163
|
-
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
1164
|
-
else
|
|
1165
|
-
defineBound(proto, key, desc.value);
|
|
1166
|
-
}
|
|
937
|
+
var date = /* @__PURE__ */ anchor(dateSource);
|
|
938
|
+
function timeSource(args) {
|
|
939
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
940
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
941
|
+
return regex;
|
|
1167
942
|
}
|
|
1168
|
-
function
|
|
1169
|
-
|
|
1170
|
-
return value;
|
|
943
|
+
function time(args) {
|
|
944
|
+
return new RegExp(`^${timeSource(args)}$`);
|
|
1171
945
|
}
|
|
1172
|
-
function
|
|
1173
|
-
|
|
946
|
+
function datetime(args) {
|
|
947
|
+
const opts = ["Z"];
|
|
948
|
+
if (args.offset)
|
|
949
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
950
|
+
const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
|
|
951
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
952
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
1174
953
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
954
|
+
var string = (params) => {
|
|
955
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
956
|
+
return new RegExp(`^${regex}$`);
|
|
957
|
+
};
|
|
958
|
+
var integer = /^-?\d+$/;
|
|
959
|
+
var number = /^-?\d+(?:\.\d+)?$/;
|
|
960
|
+
var boolean = /^(?:true|false)$/i;
|
|
961
|
+
var _null = /^null$/i;
|
|
962
|
+
var lowercase = /^[^A-Z]*$/;
|
|
963
|
+
var uppercase = /^[^a-z]*$/;
|
|
964
|
+
|
|
965
|
+
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/checks.js
|
|
966
|
+
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
967
|
+
var _a;
|
|
968
|
+
inst._zod ?? (inst._zod = {});
|
|
969
|
+
inst._zod.def = def;
|
|
970
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
971
|
+
});
|
|
972
|
+
var _whenHasLength = (payload) => {
|
|
973
|
+
const val = payload.value;
|
|
974
|
+
return !nullish(val) && val.length !== undefined;
|
|
975
|
+
};
|
|
976
|
+
var numericOriginMap = {
|
|
977
|
+
number: "number",
|
|
978
|
+
bigint: "bigint",
|
|
979
|
+
object: "date"
|
|
980
|
+
};
|
|
981
|
+
var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
982
|
+
$ZodCheck.init(inst, def);
|
|
983
|
+
const origin = numericOriginMap[typeof def.value];
|
|
984
|
+
inst._zod.onattach.push((inst) => {
|
|
985
|
+
const bag = inst._zod.bag;
|
|
986
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
987
|
+
if (def.value < curr) {
|
|
988
|
+
if (def.inclusive)
|
|
989
|
+
bag.maximum = def.value;
|
|
990
|
+
else
|
|
991
|
+
bag.exclusiveMaximum = def.value;
|
|
1183
992
|
}
|
|
1184
993
|
});
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
};
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
broke = false;
|
|
1212
|
-
try {
|
|
1213
|
-
const value = compute(this);
|
|
1214
|
-
if (broke)
|
|
1215
|
-
delete this[key];
|
|
1216
|
-
else
|
|
1217
|
-
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
1218
|
-
broke = broke || outer;
|
|
1219
|
-
return value;
|
|
1220
|
-
} catch (err) {
|
|
1221
|
-
delete this[key];
|
|
1222
|
-
broke = broke || outer;
|
|
1223
|
-
throw err;
|
|
1224
|
-
}
|
|
1225
|
-
},
|
|
1226
|
-
set(value) {
|
|
1227
|
-
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
994
|
+
inst._zod.check = (payload) => {
|
|
995
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
payload.issues.push({
|
|
999
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
1000
|
+
code: "too_big",
|
|
1001
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1002
|
+
input: payload.value,
|
|
1003
|
+
inclusive: def.inclusive,
|
|
1004
|
+
inst,
|
|
1005
|
+
continue: !def.abort
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
});
|
|
1009
|
+
var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
1010
|
+
$ZodCheck.init(inst, def);
|
|
1011
|
+
const origin = numericOriginMap[typeof def.value];
|
|
1012
|
+
inst._zod.onattach.push((inst) => {
|
|
1013
|
+
const bag = inst._zod.bag;
|
|
1014
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
1015
|
+
if (def.value > curr) {
|
|
1016
|
+
if (def.inclusive)
|
|
1017
|
+
bag.minimum = def.value;
|
|
1018
|
+
else
|
|
1019
|
+
bag.exclusiveMinimum = def.value;
|
|
1228
1020
|
}
|
|
1229
1021
|
});
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
if (!proto)
|
|
1234
|
-
return;
|
|
1235
|
-
Object.defineProperty(proto, key, {
|
|
1236
|
-
configurable: true,
|
|
1237
|
-
get() {
|
|
1238
|
-
const desc = { configurable: true, writable: true, enumerable, value: undefined };
|
|
1239
|
-
Object.defineProperty(this, key, desc);
|
|
1240
|
-
desc.value = make(this);
|
|
1241
|
-
Object.defineProperty(this, key, desc);
|
|
1242
|
-
return desc.value;
|
|
1243
|
-
},
|
|
1244
|
-
set(value) {
|
|
1245
|
-
Object.defineProperty(this, key, { configurable: true, writable: true, enumerable, value });
|
|
1022
|
+
inst._zod.check = (payload) => {
|
|
1023
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
1024
|
+
return;
|
|
1246
1025
|
}
|
|
1026
|
+
payload.issues.push({
|
|
1027
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
1028
|
+
code: "too_small",
|
|
1029
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1030
|
+
input: payload.value,
|
|
1031
|
+
inclusive: def.inclusive,
|
|
1032
|
+
inst,
|
|
1033
|
+
continue: !def.abort
|
|
1034
|
+
});
|
|
1035
|
+
};
|
|
1036
|
+
});
|
|
1037
|
+
var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
1038
|
+
$ZodCheck.init(inst, def);
|
|
1039
|
+
inst._zod.onattach.push((inst) => {
|
|
1040
|
+
var _a;
|
|
1041
|
+
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
1247
1042
|
});
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
return fn;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/core.js
|
|
1257
|
-
var _a;
|
|
1258
|
-
var _zodDesc = { value: undefined, enumerable: false };
|
|
1259
|
-
var _E = "captureStackTrace" in Error ? Error : null;
|
|
1260
|
-
function newError(Definition) {
|
|
1261
|
-
const E = _E;
|
|
1262
|
-
if (E) {
|
|
1263
|
-
const saved = E.stackTraceLimit;
|
|
1264
|
-
if (typeof saved === "number") {
|
|
1265
|
-
try {
|
|
1266
|
-
E.stackTraceLimit = 0;
|
|
1267
|
-
} catch {
|
|
1268
|
-
_E = null;
|
|
1269
|
-
return new Definition;
|
|
1270
|
-
}
|
|
1271
|
-
try {
|
|
1272
|
-
return new Definition;
|
|
1273
|
-
} finally {
|
|
1274
|
-
E.stackTraceLimit = saved;
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
return new Definition;
|
|
1279
|
-
}
|
|
1280
|
-
function $constructor(name, initializer, proto, params) {
|
|
1281
|
-
const zodProto = {};
|
|
1282
|
-
function Internals(def) {
|
|
1283
|
-
this.def = def;
|
|
1284
|
-
this.constr = _;
|
|
1285
|
-
this.traits = new Set;
|
|
1286
|
-
}
|
|
1287
|
-
Internals.prototype = zodProto;
|
|
1288
|
-
const protoMembers = proto;
|
|
1289
|
-
const initialized = protoMembers && new WeakSet;
|
|
1290
|
-
function init(inst, def) {
|
|
1291
|
-
if (!inst._zod) {
|
|
1292
|
-
_zodDesc.value = new Internals(def);
|
|
1293
|
-
try {
|
|
1294
|
-
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
1295
|
-
} finally {
|
|
1296
|
-
_zodDesc.value = undefined;
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
if (inst._zod.traits.has(name)) {
|
|
1043
|
+
inst._zod.check = (payload) => {
|
|
1044
|
+
if (typeof payload.value !== typeof def.value)
|
|
1045
|
+
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1046
|
+
const isMultiple = typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
1047
|
+
if (isMultiple)
|
|
1300
1048
|
return;
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1049
|
+
payload.issues.push({
|
|
1050
|
+
origin: typeof payload.value,
|
|
1051
|
+
code: "not_multiple_of",
|
|
1052
|
+
divisor: def.value,
|
|
1053
|
+
input: payload.value,
|
|
1054
|
+
inst,
|
|
1055
|
+
continue: !def.abort
|
|
1056
|
+
});
|
|
1057
|
+
};
|
|
1058
|
+
});
|
|
1059
|
+
var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
1060
|
+
$ZodCheck.init(inst, def);
|
|
1061
|
+
def.format = def.format || "float64";
|
|
1062
|
+
const isInt = def.format?.includes("int");
|
|
1063
|
+
const origin = isInt ? "int" : "number";
|
|
1064
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1065
|
+
inst._zod.onattach.push((inst) => {
|
|
1066
|
+
const bag = inst._zod.bag;
|
|
1067
|
+
bag.format = def.format;
|
|
1068
|
+
bag.minimum = minimum;
|
|
1069
|
+
bag.maximum = maximum;
|
|
1070
|
+
if (isInt)
|
|
1071
|
+
bag.pattern = integer;
|
|
1072
|
+
});
|
|
1073
|
+
inst._zod.check = (payload) => {
|
|
1074
|
+
const input = payload.value;
|
|
1075
|
+
if (isInt) {
|
|
1076
|
+
if (!Number.isInteger(input)) {
|
|
1077
|
+
payload.issues.push({
|
|
1078
|
+
expected: origin,
|
|
1079
|
+
format: def.format,
|
|
1080
|
+
code: "invalid_type",
|
|
1081
|
+
continue: false,
|
|
1082
|
+
input,
|
|
1083
|
+
inst
|
|
1084
|
+
});
|
|
1085
|
+
return;
|
|
1314
1086
|
}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1087
|
+
if (!Number.isSafeInteger(input)) {
|
|
1088
|
+
if (input > 0) {
|
|
1089
|
+
payload.issues.push({
|
|
1090
|
+
input,
|
|
1091
|
+
code: "too_big",
|
|
1092
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
1093
|
+
note: "Integers must be within the safe integer range.",
|
|
1094
|
+
inst,
|
|
1095
|
+
origin,
|
|
1096
|
+
inclusive: true,
|
|
1097
|
+
continue: !def.abort
|
|
1098
|
+
});
|
|
1099
|
+
} else {
|
|
1100
|
+
payload.issues.push({
|
|
1101
|
+
input,
|
|
1102
|
+
code: "too_small",
|
|
1103
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
1104
|
+
note: "Integers must be within the safe integer range.",
|
|
1105
|
+
inst,
|
|
1106
|
+
origin,
|
|
1107
|
+
inclusive: true,
|
|
1108
|
+
continue: !def.abort
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
return;
|
|
1322
1112
|
}
|
|
1323
1113
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
if (deferred) {
|
|
1335
|
-
for (const fn of deferred) {
|
|
1336
|
-
fn();
|
|
1337
|
-
}
|
|
1338
|
-
inst._zod.deferred = undefined;
|
|
1114
|
+
if (input < minimum) {
|
|
1115
|
+
payload.issues.push({
|
|
1116
|
+
origin: "number",
|
|
1117
|
+
input,
|
|
1118
|
+
code: "too_small",
|
|
1119
|
+
minimum,
|
|
1120
|
+
inclusive: true,
|
|
1121
|
+
inst,
|
|
1122
|
+
continue: !def.abort
|
|
1123
|
+
});
|
|
1339
1124
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
return inst?._zod?.traits?.has(name);
|
|
1125
|
+
if (input > maximum) {
|
|
1126
|
+
payload.issues.push({
|
|
1127
|
+
origin: "number",
|
|
1128
|
+
input,
|
|
1129
|
+
code: "too_big",
|
|
1130
|
+
maximum,
|
|
1131
|
+
inclusive: true,
|
|
1132
|
+
inst,
|
|
1133
|
+
continue: !def.abort
|
|
1134
|
+
});
|
|
1351
1135
|
}
|
|
1352
|
-
}
|
|
1353
|
-
Object.defineProperty(_, "name", { value: name });
|
|
1354
|
-
return _;
|
|
1355
|
-
}
|
|
1356
|
-
class $ZodAsyncError extends Error {
|
|
1357
|
-
constructor() {
|
|
1358
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
class $ZodEncodeError extends Error {
|
|
1363
|
-
constructor(name) {
|
|
1364
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
1365
|
-
this.name = "ZodEncodeError";
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
1369
|
-
var globalConfig = globalThis.__zod_globalConfig;
|
|
1370
|
-
function config(newConfig) {
|
|
1371
|
-
if (newConfig)
|
|
1372
|
-
Object.assign(globalConfig, newConfig);
|
|
1373
|
-
return globalConfig;
|
|
1374
|
-
}
|
|
1375
|
-
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/errors.js
|
|
1376
|
-
function _getMessage() {
|
|
1377
|
-
const internals = this._zod;
|
|
1378
|
-
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
1379
|
-
return internals.message;
|
|
1380
|
-
}
|
|
1381
|
-
function _setMessage(value) {
|
|
1382
|
-
this._zod.message = value;
|
|
1383
|
-
}
|
|
1384
|
-
var _messageDesc = {
|
|
1385
|
-
get: _getMessage,
|
|
1386
|
-
set: _setMessage,
|
|
1387
|
-
enumerable: true,
|
|
1388
|
-
configurable: true
|
|
1389
|
-
};
|
|
1390
|
-
var _zodDesc2 = { value: undefined, enumerable: false };
|
|
1391
|
-
var _issuesDesc = { value: undefined, enumerable: false };
|
|
1392
|
-
var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
1393
|
-
var initializer = (inst, def) => {
|
|
1394
|
-
inst.name = "$ZodError";
|
|
1395
|
-
_zodDesc2.value = inst._zod;
|
|
1396
|
-
Object.defineProperty(inst, "_zod", _zodDesc2);
|
|
1397
|
-
_issuesDesc.value = def;
|
|
1398
|
-
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
1399
|
-
_zodDesc2.value = undefined;
|
|
1400
|
-
_issuesDesc.value = undefined;
|
|
1401
|
-
Object.defineProperty(inst, "message", _messageDesc);
|
|
1402
|
-
const proto = Object.getPrototypeOf(inst);
|
|
1403
|
-
if (!_installedToString.has(proto)) {
|
|
1404
|
-
_installedToString.add(proto);
|
|
1405
|
-
Object.defineProperty(proto, "toString", {
|
|
1406
|
-
configurable: true,
|
|
1407
|
-
enumerable: false,
|
|
1408
|
-
get() {
|
|
1409
|
-
const value = () => this.message;
|
|
1410
|
-
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
1411
|
-
return value;
|
|
1412
|
-
},
|
|
1413
|
-
set(value) {
|
|
1414
|
-
Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
|
|
1415
|
-
}
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
var $ZodError = $constructor("$ZodError", initializer);
|
|
1420
|
-
var $ZodRealError = $constructor("$ZodError", initializer, undefined, {
|
|
1421
|
-
Parent: Error
|
|
1136
|
+
};
|
|
1422
1137
|
});
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
for (const issue of error.issues) {
|
|
1449
|
-
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
1450
|
-
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
1451
|
-
} else if (issue.code === "invalid_key") {
|
|
1452
|
-
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
1453
|
-
} else if (issue.code === "invalid_element") {
|
|
1454
|
-
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
1455
|
-
} else {
|
|
1456
|
-
const fullpath = [...path, ...issue.path];
|
|
1457
|
-
if (fullpath.length === 0) {
|
|
1458
|
-
fieldErrors._errors.push(mapper(issue));
|
|
1459
|
-
} else {
|
|
1460
|
-
let curr = fieldErrors;
|
|
1461
|
-
let i = 0;
|
|
1462
|
-
while (i < fullpath.length) {
|
|
1463
|
-
const el = fullpath[i];
|
|
1464
|
-
const terminal = i === fullpath.length - 1;
|
|
1465
|
-
if (el === "_errors") {
|
|
1466
|
-
if (terminal)
|
|
1467
|
-
curr._errors.push(mapper(issue));
|
|
1468
|
-
i++;
|
|
1469
|
-
continue;
|
|
1470
|
-
}
|
|
1471
|
-
if (!Object.prototype.hasOwnProperty.call(curr, el)) {
|
|
1472
|
-
Object.defineProperty(curr, el, {
|
|
1473
|
-
value: { _errors: [] },
|
|
1474
|
-
enumerable: true,
|
|
1475
|
-
writable: true,
|
|
1476
|
-
configurable: true
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
const node = curr[el];
|
|
1480
|
-
if (terminal) {
|
|
1481
|
-
node._errors.push(mapper(issue));
|
|
1482
|
-
}
|
|
1483
|
-
curr = node;
|
|
1484
|
-
i++;
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
};
|
|
1490
|
-
processError(error);
|
|
1491
|
-
return fieldErrors;
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/parse.js
|
|
1495
|
-
function finalizeParams(callee, params) {
|
|
1496
|
-
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
1497
|
-
}
|
|
1498
|
-
var _parse = (_Err) => {
|
|
1499
|
-
const fn = (schema, value, _ctx, _params) => {
|
|
1500
|
-
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
1501
|
-
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
1502
|
-
if (result instanceof Promise) {
|
|
1503
|
-
throw new $ZodAsyncError;
|
|
1504
|
-
}
|
|
1505
|
-
if (result.issues.length) {
|
|
1506
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1507
|
-
captureStackTrace(e, _params?.callee ?? fn);
|
|
1508
|
-
throw e;
|
|
1509
|
-
}
|
|
1510
|
-
return result.value;
|
|
1138
|
+
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1139
|
+
var _a;
|
|
1140
|
+
$ZodCheck.init(inst, def);
|
|
1141
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1142
|
+
inst._zod.onattach.push((inst) => {
|
|
1143
|
+
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1144
|
+
if (def.maximum < curr)
|
|
1145
|
+
inst._zod.bag.maximum = def.maximum;
|
|
1146
|
+
});
|
|
1147
|
+
inst._zod.check = (payload) => {
|
|
1148
|
+
const input = payload.value;
|
|
1149
|
+
const units = input.length;
|
|
1150
|
+
const length = typeof input === "string" && units > def.maximum ? codePointLength(input) : units;
|
|
1151
|
+
if (length <= def.maximum)
|
|
1152
|
+
return;
|
|
1153
|
+
const origin = getLengthableOrigin(input);
|
|
1154
|
+
payload.issues.push({
|
|
1155
|
+
origin,
|
|
1156
|
+
code: "too_big",
|
|
1157
|
+
maximum: def.maximum,
|
|
1158
|
+
inclusive: true,
|
|
1159
|
+
input,
|
|
1160
|
+
inst,
|
|
1161
|
+
continue: !def.abort
|
|
1162
|
+
});
|
|
1511
1163
|
};
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
var
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1164
|
+
});
|
|
1165
|
+
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1166
|
+
var _a;
|
|
1167
|
+
$ZodCheck.init(inst, def);
|
|
1168
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1169
|
+
inst._zod.onattach.push((inst) => {
|
|
1170
|
+
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1171
|
+
if (def.minimum > curr)
|
|
1172
|
+
inst._zod.bag.minimum = def.minimum;
|
|
1173
|
+
});
|
|
1174
|
+
inst._zod.check = (payload) => {
|
|
1175
|
+
const input = payload.value;
|
|
1176
|
+
const units = input.length;
|
|
1177
|
+
const length = typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units;
|
|
1178
|
+
if (length >= def.minimum)
|
|
1179
|
+
return;
|
|
1180
|
+
const origin = getLengthableOrigin(input);
|
|
1181
|
+
payload.issues.push({
|
|
1182
|
+
origin,
|
|
1183
|
+
code: "too_small",
|
|
1184
|
+
minimum: def.minimum,
|
|
1185
|
+
inclusive: true,
|
|
1186
|
+
input,
|
|
1187
|
+
inst,
|
|
1188
|
+
continue: !def.abort
|
|
1189
|
+
});
|
|
1526
1190
|
};
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
var
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1556
|
-
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
1191
|
+
});
|
|
1192
|
+
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1193
|
+
var _a;
|
|
1194
|
+
$ZodCheck.init(inst, def);
|
|
1195
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1196
|
+
inst._zod.onattach.push((inst) => {
|
|
1197
|
+
const bag = inst._zod.bag;
|
|
1198
|
+
bag.minimum = def.length;
|
|
1199
|
+
bag.maximum = def.length;
|
|
1200
|
+
bag.length = def.length;
|
|
1201
|
+
});
|
|
1202
|
+
inst._zod.check = (payload) => {
|
|
1203
|
+
const input = payload.value;
|
|
1204
|
+
const units = input.length;
|
|
1205
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
1206
|
+
if (length === def.length)
|
|
1207
|
+
return;
|
|
1208
|
+
const origin = getLengthableOrigin(input);
|
|
1209
|
+
const tooBig = length > def.length;
|
|
1210
|
+
payload.issues.push({
|
|
1211
|
+
origin,
|
|
1212
|
+
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
1213
|
+
inclusive: true,
|
|
1214
|
+
exact: true,
|
|
1215
|
+
input: payload.value,
|
|
1216
|
+
inst,
|
|
1217
|
+
continue: !def.abort
|
|
1218
|
+
});
|
|
1557
1219
|
};
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
var
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1220
|
+
});
|
|
1221
|
+
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1222
|
+
var _a, _b;
|
|
1223
|
+
$ZodCheck.init(inst, def);
|
|
1224
|
+
inst._zod.onattach.push((inst) => {
|
|
1225
|
+
const bag = inst._zod.bag;
|
|
1226
|
+
bag.format = def.format;
|
|
1227
|
+
if (def.pattern) {
|
|
1228
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
1229
|
+
bag.patterns.add(def.pattern);
|
|
1230
|
+
}
|
|
1231
|
+
});
|
|
1232
|
+
if (def.pattern)
|
|
1233
|
+
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1234
|
+
def.pattern.lastIndex = 0;
|
|
1235
|
+
if (def.pattern.test(payload.value))
|
|
1236
|
+
return;
|
|
1237
|
+
payload.issues.push({
|
|
1238
|
+
origin: "string",
|
|
1239
|
+
code: "invalid_format",
|
|
1240
|
+
format: def.format,
|
|
1241
|
+
input: payload.value,
|
|
1242
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
1243
|
+
inst,
|
|
1244
|
+
continue: !def.abort
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
else
|
|
1248
|
+
(_b = inst._zod).check ?? (_b.check = () => {});
|
|
1249
|
+
});
|
|
1250
|
+
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
1251
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1252
|
+
inst._zod.check = (payload) => {
|
|
1253
|
+
def.pattern.lastIndex = 0;
|
|
1254
|
+
if (def.pattern.test(payload.value))
|
|
1255
|
+
return;
|
|
1256
|
+
payload.issues.push({
|
|
1257
|
+
origin: "string",
|
|
1258
|
+
code: "invalid_format",
|
|
1259
|
+
format: "regex",
|
|
1260
|
+
input: payload.value,
|
|
1261
|
+
pattern: def.pattern.toString(),
|
|
1262
|
+
inst,
|
|
1263
|
+
continue: !def.abort
|
|
1264
|
+
});
|
|
1564
1265
|
};
|
|
1565
|
-
return fn;
|
|
1566
|
-
};
|
|
1567
|
-
var _encodeAsync = (_Err) => {
|
|
1568
|
-
const parseAsync = _parseAsync(_Err);
|
|
1569
|
-
const fn = async (schema, value, _ctx, _params) => {
|
|
1570
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1571
|
-
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
1572
|
-
};
|
|
1573
|
-
return fn;
|
|
1574
|
-
};
|
|
1575
|
-
var _decodeAsync = (_Err) => {
|
|
1576
|
-
const parseAsync = _parseAsync(_Err);
|
|
1577
|
-
const fn = async (schema, value, _ctx, _params) => {
|
|
1578
|
-
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
1579
|
-
};
|
|
1580
|
-
return fn;
|
|
1581
|
-
};
|
|
1582
|
-
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
1583
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1584
|
-
return _safeParse(_Err)(schema, value, ctx);
|
|
1585
|
-
};
|
|
1586
|
-
var _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
1587
|
-
return _safeParse(_Err)(schema, value, _ctx);
|
|
1588
|
-
};
|
|
1589
|
-
var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1590
|
-
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1591
|
-
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
1592
|
-
};
|
|
1593
|
-
var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1594
|
-
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
1595
|
-
};
|
|
1596
|
-
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/regexes.js
|
|
1597
|
-
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
1598
|
-
var cuid2 = /^[0-9a-z]+$/;
|
|
1599
|
-
var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
1600
|
-
var xid = /^[0-9a-vA-V]{20}$/;
|
|
1601
|
-
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
1602
|
-
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
1603
|
-
function nanoidOfLength(length) {
|
|
1604
|
-
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
1605
|
-
}
|
|
1606
|
-
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
1607
|
-
var 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})$/;
|
|
1608
|
-
var uuid = (version) => {
|
|
1609
|
-
if (!version)
|
|
1610
|
-
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)$/;
|
|
1611
|
-
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})$`);
|
|
1612
|
-
};
|
|
1613
|
-
var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
1614
|
-
var _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
1615
|
-
function emoji() {
|
|
1616
|
-
return new RegExp(_emoji, "u");
|
|
1617
|
-
}
|
|
1618
|
-
var 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])$/;
|
|
1619
|
-
var 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}|:))$/;
|
|
1620
|
-
var 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])$/;
|
|
1621
|
-
var cidrv6 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
1622
|
-
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
1623
|
-
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
1624
|
-
var httpProtocol = /^https?$/;
|
|
1625
|
-
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
1626
|
-
var 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])))`;
|
|
1627
|
-
function anchor(source) {
|
|
1628
|
-
return new RegExp(`^${source}$`);
|
|
1629
|
-
}
|
|
1630
|
-
var date = /* @__PURE__ */ anchor(dateSource);
|
|
1631
|
-
function timeSource(args) {
|
|
1632
|
-
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
1633
|
-
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
1634
|
-
return regex;
|
|
1635
|
-
}
|
|
1636
|
-
function time(args) {
|
|
1637
|
-
return new RegExp(`^${timeSource(args)}$`);
|
|
1638
|
-
}
|
|
1639
|
-
function datetime(args) {
|
|
1640
|
-
const opts = ["Z"];
|
|
1641
|
-
if (args.offset)
|
|
1642
|
-
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
1643
|
-
const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
|
|
1644
|
-
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
1645
|
-
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
1646
|
-
}
|
|
1647
|
-
var string = (params) => {
|
|
1648
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
1649
|
-
return new RegExp(`^${regex}$`);
|
|
1650
|
-
};
|
|
1651
|
-
var integer = /^-?\d+$/;
|
|
1652
|
-
var number = /^-?\d+(?:\.\d+)?$/;
|
|
1653
|
-
var boolean = /^(?:true|false)$/i;
|
|
1654
|
-
var _null = /^null$/i;
|
|
1655
|
-
var lowercase = /^[^A-Z]*$/;
|
|
1656
|
-
var uppercase = /^[^a-z]*$/;
|
|
1657
|
-
|
|
1658
|
-
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/core/checks.js
|
|
1659
|
-
var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
1660
|
-
var _a;
|
|
1661
|
-
inst._zod ?? (inst._zod = {});
|
|
1662
|
-
inst._zod.def = def;
|
|
1663
|
-
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
1664
1266
|
});
|
|
1665
|
-
var
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
};
|
|
1669
|
-
var
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
1267
|
+
var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
1268
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
1269
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1270
|
+
});
|
|
1271
|
+
var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
1272
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
1273
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1274
|
+
});
|
|
1275
|
+
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1675
1276
|
$ZodCheck.init(inst, def);
|
|
1676
|
-
const
|
|
1277
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
1278
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
1279
|
+
def.pattern = pattern;
|
|
1677
1280
|
inst._zod.onattach.push((inst) => {
|
|
1678
1281
|
const bag = inst._zod.bag;
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
if (def.inclusive)
|
|
1682
|
-
bag.maximum = def.value;
|
|
1683
|
-
else
|
|
1684
|
-
bag.exclusiveMaximum = def.value;
|
|
1685
|
-
}
|
|
1282
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
1283
|
+
bag.patterns.add(pattern);
|
|
1686
1284
|
});
|
|
1687
1285
|
inst._zod.check = (payload) => {
|
|
1688
|
-
if (
|
|
1286
|
+
if (payload.value.includes(def.includes, def.position))
|
|
1689
1287
|
return;
|
|
1690
|
-
}
|
|
1691
1288
|
payload.issues.push({
|
|
1692
|
-
origin:
|
|
1693
|
-
code: "
|
|
1694
|
-
|
|
1289
|
+
origin: "string",
|
|
1290
|
+
code: "invalid_format",
|
|
1291
|
+
format: "includes",
|
|
1292
|
+
includes: def.includes,
|
|
1695
1293
|
input: payload.value,
|
|
1696
|
-
inclusive: def.inclusive,
|
|
1697
1294
|
inst,
|
|
1698
1295
|
continue: !def.abort
|
|
1699
1296
|
});
|
|
1700
1297
|
};
|
|
1701
1298
|
});
|
|
1702
|
-
var $
|
|
1299
|
+
var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
1703
1300
|
$ZodCheck.init(inst, def);
|
|
1704
|
-
const
|
|
1301
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1302
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1705
1303
|
inst._zod.onattach.push((inst) => {
|
|
1706
1304
|
const bag = inst._zod.bag;
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
if (def.inclusive)
|
|
1710
|
-
bag.minimum = def.value;
|
|
1711
|
-
else
|
|
1712
|
-
bag.exclusiveMinimum = def.value;
|
|
1713
|
-
}
|
|
1305
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
1306
|
+
bag.patterns.add(pattern);
|
|
1714
1307
|
});
|
|
1715
1308
|
inst._zod.check = (payload) => {
|
|
1716
|
-
if (
|
|
1309
|
+
if (payload.value.startsWith(def.prefix))
|
|
1717
1310
|
return;
|
|
1718
|
-
}
|
|
1719
1311
|
payload.issues.push({
|
|
1720
|
-
origin:
|
|
1721
|
-
code: "
|
|
1722
|
-
|
|
1312
|
+
origin: "string",
|
|
1313
|
+
code: "invalid_format",
|
|
1314
|
+
format: "starts_with",
|
|
1315
|
+
prefix: def.prefix,
|
|
1723
1316
|
input: payload.value,
|
|
1724
|
-
inclusive: def.inclusive,
|
|
1725
1317
|
inst,
|
|
1726
1318
|
continue: !def.abort
|
|
1727
1319
|
});
|
|
1728
1320
|
};
|
|
1729
1321
|
});
|
|
1730
|
-
var $
|
|
1322
|
+
var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
1731
1323
|
$ZodCheck.init(inst, def);
|
|
1324
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1325
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1732
1326
|
inst._zod.onattach.push((inst) => {
|
|
1733
|
-
|
|
1734
|
-
|
|
1327
|
+
const bag = inst._zod.bag;
|
|
1328
|
+
bag.patterns ?? (bag.patterns = new Set);
|
|
1329
|
+
bag.patterns.add(pattern);
|
|
1735
1330
|
});
|
|
1736
1331
|
inst._zod.check = (payload) => {
|
|
1737
|
-
if (
|
|
1738
|
-
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1739
|
-
const isMultiple = typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
|
|
1740
|
-
if (isMultiple)
|
|
1332
|
+
if (payload.value.endsWith(def.suffix))
|
|
1741
1333
|
return;
|
|
1742
1334
|
payload.issues.push({
|
|
1743
|
-
origin:
|
|
1744
|
-
code: "
|
|
1745
|
-
|
|
1335
|
+
origin: "string",
|
|
1336
|
+
code: "invalid_format",
|
|
1337
|
+
format: "ends_with",
|
|
1338
|
+
suffix: def.suffix,
|
|
1746
1339
|
input: payload.value,
|
|
1747
1340
|
inst,
|
|
1748
1341
|
continue: !def.abort
|
|
1749
1342
|
});
|
|
1750
1343
|
};
|
|
1751
1344
|
});
|
|
1752
|
-
var $
|
|
1753
|
-
$ZodCheck.init(inst, def);
|
|
1754
|
-
def.format = def.format || "float64";
|
|
1755
|
-
const isInt = def.format?.includes("int");
|
|
1756
|
-
const origin = isInt ? "int" : "number";
|
|
1757
|
-
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
1758
|
-
inst._zod.onattach.push((inst) => {
|
|
1759
|
-
const bag = inst._zod.bag;
|
|
1760
|
-
bag.format = def.format;
|
|
1761
|
-
bag.minimum = minimum;
|
|
1762
|
-
bag.maximum = maximum;
|
|
1763
|
-
if (isInt)
|
|
1764
|
-
bag.pattern = integer;
|
|
1765
|
-
});
|
|
1766
|
-
inst._zod.check = (payload) => {
|
|
1767
|
-
const input = payload.value;
|
|
1768
|
-
if (isInt) {
|
|
1769
|
-
if (!Number.isInteger(input)) {
|
|
1770
|
-
payload.issues.push({
|
|
1771
|
-
expected: origin,
|
|
1772
|
-
format: def.format,
|
|
1773
|
-
code: "invalid_type",
|
|
1774
|
-
continue: false,
|
|
1775
|
-
input,
|
|
1776
|
-
inst
|
|
1777
|
-
});
|
|
1778
|
-
return;
|
|
1779
|
-
}
|
|
1780
|
-
if (!Number.isSafeInteger(input)) {
|
|
1781
|
-
if (input > 0) {
|
|
1782
|
-
payload.issues.push({
|
|
1783
|
-
input,
|
|
1784
|
-
code: "too_big",
|
|
1785
|
-
maximum: Number.MAX_SAFE_INTEGER,
|
|
1786
|
-
note: "Integers must be within the safe integer range.",
|
|
1787
|
-
inst,
|
|
1788
|
-
origin,
|
|
1789
|
-
inclusive: true,
|
|
1790
|
-
continue: !def.abort
|
|
1791
|
-
});
|
|
1792
|
-
} else {
|
|
1793
|
-
payload.issues.push({
|
|
1794
|
-
input,
|
|
1795
|
-
code: "too_small",
|
|
1796
|
-
minimum: Number.MIN_SAFE_INTEGER,
|
|
1797
|
-
note: "Integers must be within the safe integer range.",
|
|
1798
|
-
inst,
|
|
1799
|
-
origin,
|
|
1800
|
-
inclusive: true,
|
|
1801
|
-
continue: !def.abort
|
|
1802
|
-
});
|
|
1803
|
-
}
|
|
1804
|
-
return;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
if (input < minimum) {
|
|
1808
|
-
payload.issues.push({
|
|
1809
|
-
origin: "number",
|
|
1810
|
-
input,
|
|
1811
|
-
code: "too_small",
|
|
1812
|
-
minimum,
|
|
1813
|
-
inclusive: true,
|
|
1814
|
-
inst,
|
|
1815
|
-
continue: !def.abort
|
|
1816
|
-
});
|
|
1817
|
-
}
|
|
1818
|
-
if (input > maximum) {
|
|
1819
|
-
payload.issues.push({
|
|
1820
|
-
origin: "number",
|
|
1821
|
-
input,
|
|
1822
|
-
code: "too_big",
|
|
1823
|
-
maximum,
|
|
1824
|
-
inclusive: true,
|
|
1825
|
-
inst,
|
|
1826
|
-
continue: !def.abort
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
|
-
};
|
|
1830
|
-
});
|
|
1831
|
-
var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1832
|
-
var _a;
|
|
1833
|
-
$ZodCheck.init(inst, def);
|
|
1834
|
-
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1835
|
-
inst._zod.onattach.push((inst) => {
|
|
1836
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1837
|
-
if (def.maximum < curr)
|
|
1838
|
-
inst._zod.bag.maximum = def.maximum;
|
|
1839
|
-
});
|
|
1840
|
-
inst._zod.check = (payload) => {
|
|
1841
|
-
const input = payload.value;
|
|
1842
|
-
const units = input.length;
|
|
1843
|
-
const length = typeof input === "string" && units > def.maximum ? codePointLength(input) : units;
|
|
1844
|
-
if (length <= def.maximum)
|
|
1845
|
-
return;
|
|
1846
|
-
const origin = getLengthableOrigin(input);
|
|
1847
|
-
payload.issues.push({
|
|
1848
|
-
origin,
|
|
1849
|
-
code: "too_big",
|
|
1850
|
-
maximum: def.maximum,
|
|
1851
|
-
inclusive: true,
|
|
1852
|
-
input,
|
|
1853
|
-
inst,
|
|
1854
|
-
continue: !def.abort
|
|
1855
|
-
});
|
|
1856
|
-
};
|
|
1857
|
-
});
|
|
1858
|
-
var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1859
|
-
var _a;
|
|
1860
|
-
$ZodCheck.init(inst, def);
|
|
1861
|
-
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1862
|
-
inst._zod.onattach.push((inst) => {
|
|
1863
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1864
|
-
if (def.minimum > curr)
|
|
1865
|
-
inst._zod.bag.minimum = def.minimum;
|
|
1866
|
-
});
|
|
1867
|
-
inst._zod.check = (payload) => {
|
|
1868
|
-
const input = payload.value;
|
|
1869
|
-
const units = input.length;
|
|
1870
|
-
const length = typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units;
|
|
1871
|
-
if (length >= def.minimum)
|
|
1872
|
-
return;
|
|
1873
|
-
const origin = getLengthableOrigin(input);
|
|
1874
|
-
payload.issues.push({
|
|
1875
|
-
origin,
|
|
1876
|
-
code: "too_small",
|
|
1877
|
-
minimum: def.minimum,
|
|
1878
|
-
inclusive: true,
|
|
1879
|
-
input,
|
|
1880
|
-
inst,
|
|
1881
|
-
continue: !def.abort
|
|
1882
|
-
});
|
|
1883
|
-
};
|
|
1884
|
-
});
|
|
1885
|
-
var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1886
|
-
var _a;
|
|
1887
|
-
$ZodCheck.init(inst, def);
|
|
1888
|
-
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
1889
|
-
inst._zod.onattach.push((inst) => {
|
|
1890
|
-
const bag = inst._zod.bag;
|
|
1891
|
-
bag.minimum = def.length;
|
|
1892
|
-
bag.maximum = def.length;
|
|
1893
|
-
bag.length = def.length;
|
|
1894
|
-
});
|
|
1895
|
-
inst._zod.check = (payload) => {
|
|
1896
|
-
const input = payload.value;
|
|
1897
|
-
const units = input.length;
|
|
1898
|
-
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
1899
|
-
if (length === def.length)
|
|
1900
|
-
return;
|
|
1901
|
-
const origin = getLengthableOrigin(input);
|
|
1902
|
-
const tooBig = length > def.length;
|
|
1903
|
-
payload.issues.push({
|
|
1904
|
-
origin,
|
|
1905
|
-
...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
|
|
1906
|
-
inclusive: true,
|
|
1907
|
-
exact: true,
|
|
1908
|
-
input: payload.value,
|
|
1909
|
-
inst,
|
|
1910
|
-
continue: !def.abort
|
|
1911
|
-
});
|
|
1912
|
-
};
|
|
1913
|
-
});
|
|
1914
|
-
var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1915
|
-
var _a, _b;
|
|
1916
|
-
$ZodCheck.init(inst, def);
|
|
1917
|
-
inst._zod.onattach.push((inst) => {
|
|
1918
|
-
const bag = inst._zod.bag;
|
|
1919
|
-
bag.format = def.format;
|
|
1920
|
-
if (def.pattern) {
|
|
1921
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1922
|
-
bag.patterns.add(def.pattern);
|
|
1923
|
-
}
|
|
1924
|
-
});
|
|
1925
|
-
if (def.pattern)
|
|
1926
|
-
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1927
|
-
def.pattern.lastIndex = 0;
|
|
1928
|
-
if (def.pattern.test(payload.value))
|
|
1929
|
-
return;
|
|
1930
|
-
payload.issues.push({
|
|
1931
|
-
origin: "string",
|
|
1932
|
-
code: "invalid_format",
|
|
1933
|
-
format: def.format,
|
|
1934
|
-
input: payload.value,
|
|
1935
|
-
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
1936
|
-
inst,
|
|
1937
|
-
continue: !def.abort
|
|
1938
|
-
});
|
|
1939
|
-
});
|
|
1940
|
-
else
|
|
1941
|
-
(_b = inst._zod).check ?? (_b.check = () => {});
|
|
1942
|
-
});
|
|
1943
|
-
var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
1944
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1945
|
-
inst._zod.check = (payload) => {
|
|
1946
|
-
def.pattern.lastIndex = 0;
|
|
1947
|
-
if (def.pattern.test(payload.value))
|
|
1948
|
-
return;
|
|
1949
|
-
payload.issues.push({
|
|
1950
|
-
origin: "string",
|
|
1951
|
-
code: "invalid_format",
|
|
1952
|
-
format: "regex",
|
|
1953
|
-
input: payload.value,
|
|
1954
|
-
pattern: def.pattern.toString(),
|
|
1955
|
-
inst,
|
|
1956
|
-
continue: !def.abort
|
|
1957
|
-
});
|
|
1958
|
-
};
|
|
1959
|
-
});
|
|
1960
|
-
var $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
1961
|
-
def.pattern ?? (def.pattern = lowercase);
|
|
1962
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1963
|
-
});
|
|
1964
|
-
var $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
1965
|
-
def.pattern ?? (def.pattern = uppercase);
|
|
1966
|
-
$ZodCheckStringFormat.init(inst, def);
|
|
1967
|
-
});
|
|
1968
|
-
var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1969
|
-
$ZodCheck.init(inst, def);
|
|
1970
|
-
const escapedRegex = escapeRegex(def.includes);
|
|
1971
|
-
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
1972
|
-
def.pattern = pattern;
|
|
1973
|
-
inst._zod.onattach.push((inst) => {
|
|
1974
|
-
const bag = inst._zod.bag;
|
|
1975
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1976
|
-
bag.patterns.add(pattern);
|
|
1977
|
-
});
|
|
1978
|
-
inst._zod.check = (payload) => {
|
|
1979
|
-
if (payload.value.includes(def.includes, def.position))
|
|
1980
|
-
return;
|
|
1981
|
-
payload.issues.push({
|
|
1982
|
-
origin: "string",
|
|
1983
|
-
code: "invalid_format",
|
|
1984
|
-
format: "includes",
|
|
1985
|
-
includes: def.includes,
|
|
1986
|
-
input: payload.value,
|
|
1987
|
-
inst,
|
|
1988
|
-
continue: !def.abort
|
|
1989
|
-
});
|
|
1990
|
-
};
|
|
1991
|
-
});
|
|
1992
|
-
var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
1993
|
-
$ZodCheck.init(inst, def);
|
|
1994
|
-
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1995
|
-
def.pattern ?? (def.pattern = pattern);
|
|
1996
|
-
inst._zod.onattach.push((inst) => {
|
|
1997
|
-
const bag = inst._zod.bag;
|
|
1998
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
1999
|
-
bag.patterns.add(pattern);
|
|
2000
|
-
});
|
|
2001
|
-
inst._zod.check = (payload) => {
|
|
2002
|
-
if (payload.value.startsWith(def.prefix))
|
|
2003
|
-
return;
|
|
2004
|
-
payload.issues.push({
|
|
2005
|
-
origin: "string",
|
|
2006
|
-
code: "invalid_format",
|
|
2007
|
-
format: "starts_with",
|
|
2008
|
-
prefix: def.prefix,
|
|
2009
|
-
input: payload.value,
|
|
2010
|
-
inst,
|
|
2011
|
-
continue: !def.abort
|
|
2012
|
-
});
|
|
2013
|
-
};
|
|
2014
|
-
});
|
|
2015
|
-
var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
2016
|
-
$ZodCheck.init(inst, def);
|
|
2017
|
-
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
2018
|
-
def.pattern ?? (def.pattern = pattern);
|
|
2019
|
-
inst._zod.onattach.push((inst) => {
|
|
2020
|
-
const bag = inst._zod.bag;
|
|
2021
|
-
bag.patterns ?? (bag.patterns = new Set);
|
|
2022
|
-
bag.patterns.add(pattern);
|
|
2023
|
-
});
|
|
2024
|
-
inst._zod.check = (payload) => {
|
|
2025
|
-
if (payload.value.endsWith(def.suffix))
|
|
2026
|
-
return;
|
|
2027
|
-
payload.issues.push({
|
|
2028
|
-
origin: "string",
|
|
2029
|
-
code: "invalid_format",
|
|
2030
|
-
format: "ends_with",
|
|
2031
|
-
suffix: def.suffix,
|
|
2032
|
-
input: payload.value,
|
|
2033
|
-
inst,
|
|
2034
|
-
continue: !def.abort
|
|
2035
|
-
});
|
|
2036
|
-
};
|
|
2037
|
-
});
|
|
2038
|
-
var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1345
|
+
var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
2039
1346
|
$ZodCheck.init(inst, def);
|
|
2040
1347
|
inst._zod.check = (payload) => {
|
|
2041
1348
|
payload.value = def.tx(payload.value);
|
|
@@ -6338,6 +5645,14 @@ function object(shape, params) {
|
|
|
6338
5645
|
};
|
|
6339
5646
|
return new ZodObject(def);
|
|
6340
5647
|
}
|
|
5648
|
+
function strictObject(shape, params) {
|
|
5649
|
+
return new ZodObject({
|
|
5650
|
+
type: "object",
|
|
5651
|
+
shape,
|
|
5652
|
+
catchall: never(),
|
|
5653
|
+
...normalizeParams(params)
|
|
5654
|
+
});
|
|
5655
|
+
}
|
|
6341
5656
|
function looseObject(shape, params) {
|
|
6342
5657
|
return new ZodObject({
|
|
6343
5658
|
type: "object",
|
|
@@ -8342,13 +7657,16 @@ var threads = sqliteTable("threads", {
|
|
|
8342
7657
|
openQuestions: text("open_questions", { mode: "json" }).$type().notNull().default([]),
|
|
8343
7658
|
expectedOutput: text("expected_output").notNull().default(""),
|
|
8344
7659
|
number: integer2("number"),
|
|
8345
|
-
createdAt: ts("created_at").notNull()
|
|
7660
|
+
createdAt: ts("created_at").notNull(),
|
|
7661
|
+
lastActivityAt: ts("last_activity_at")
|
|
8346
7662
|
}, (t) => ({
|
|
8347
7663
|
spaceNumberUq: uniqueIndex("threads_space_number_uq").on(t.spaceId, t.number),
|
|
8348
7664
|
topicIdx: index("threads_topic_idx").on(t.topicId),
|
|
8349
7665
|
spaceIdx: index("threads_space_idx").on(t.spaceId),
|
|
8350
7666
|
lifecycleTypeIdx: index("threads_lifecycle_type_idx").on(t.lifecycleType),
|
|
8351
|
-
topicLifecycleRankIdx: index("threads_topic_lifecycle_rank_idx").on(t.topicId, t.lifecycleType, t.rank)
|
|
7667
|
+
topicLifecycleRankIdx: index("threads_topic_lifecycle_rank_idx").on(t.topicId, t.lifecycleType, t.rank),
|
|
7668
|
+
topicLabelRankIdx: index("threads_topic_label_rank_idx").on(t.topicId, t.lifecycleLabel, t.rank, t.lastActivityAt),
|
|
7669
|
+
topicActivityIdx: index("threads_topic_activity_idx").on(t.topicId, t.lastActivityAt, t.id)
|
|
8352
7670
|
}));
|
|
8353
7671
|
var computerConfigs = sqliteTable("computer_configs", {
|
|
8354
7672
|
id: text("id").primaryKey(),
|
|
@@ -8725,6 +8043,29 @@ var computerSnapshots = sqliteTable("computer_snapshots", {
|
|
|
8725
8043
|
runIdx: index("computer_snapshots_run_idx").on(t.runId, t.createdAt),
|
|
8726
8044
|
parentIdx: index("computer_snapshots_parent_idx").on(t.parentSnapshotId)
|
|
8727
8045
|
}));
|
|
8046
|
+
var computerCheckpointOperations = sqliteTable("computer_checkpoint_operations", {
|
|
8047
|
+
operationId: text("operation_id").primaryKey(),
|
|
8048
|
+
computerId: text("computer_id").notNull().references(() => threadComputers.id),
|
|
8049
|
+
payload: text("payload").notNull(),
|
|
8050
|
+
payloadDigest: text("payload_digest").notNull(),
|
|
8051
|
+
workspaceGeneration: text("workspace_generation").notNull(),
|
|
8052
|
+
captureMutationVersion: integer2("capture_mutation_version").notNull(),
|
|
8053
|
+
expectedHeadSnapshotId: text("expected_head_snapshot_id"),
|
|
8054
|
+
state: text("state").$type().notNull(),
|
|
8055
|
+
failureCode: text("failure_code"),
|
|
8056
|
+
nativeSnapshotId: text("native_snapshot_id"),
|
|
8057
|
+
capturedAt: ts("captured_at"),
|
|
8058
|
+
expiresAt: ts("expires_at"),
|
|
8059
|
+
portableProviderRef: text("portable_provider_ref"),
|
|
8060
|
+
publishedSnapshotId: text("published_snapshot_id"),
|
|
8061
|
+
restoreSessionId: text("restore_session_id"),
|
|
8062
|
+
restoreState: text("restore_state").$type(),
|
|
8063
|
+
restoredAt: ts("restored_at"),
|
|
8064
|
+
createdAt: ts("created_at").notNull(),
|
|
8065
|
+
updatedAt: ts("updated_at").notNull()
|
|
8066
|
+
}, (t) => ({
|
|
8067
|
+
computerIdx: index("computer_checkpoint_operations_computer_idx").on(t.computerId, t.createdAt)
|
|
8068
|
+
}));
|
|
8728
8069
|
var computerSnapshotEvidence = sqliteTable("computer_snapshot_evidence", {
|
|
8729
8070
|
snapshotId: text("snapshot_id").primaryKey().references(() => computerSnapshots.id),
|
|
8730
8071
|
purpose: text("purpose").$type().notNull(),
|
|
@@ -8937,6 +8278,7 @@ var contributions = sqliteTable("contributions", {
|
|
|
8937
8278
|
createdAt: ts("created_at").notNull()
|
|
8938
8279
|
}, (t) => ({
|
|
8939
8280
|
threadIdx: index("contributions_thread_idx").on(t.threadId),
|
|
8281
|
+
threadCreatedIdx: index("contributions_thread_created_idx").on(t.threadId, t.createdAt),
|
|
8940
8282
|
aboutIdx: index("contributions_about_idx").on(t.aboutType, t.aboutId),
|
|
8941
8283
|
authorIdempotencyIdx: uniqueIndex("contributions_author_idempotency_idx").on(t.authorProfileId, t.idempotencyKey)
|
|
8942
8284
|
}));
|
|
@@ -9612,6 +8954,14 @@ var notificationCursors = sqliteTable("notification_cursors", {
|
|
|
9612
8954
|
profileId: text("profile_id").primaryKey().references(() => profiles.id),
|
|
9613
8955
|
lastSeenAt: ts("last_seen_at").notNull()
|
|
9614
8956
|
});
|
|
8957
|
+
var spaceVisits = sqliteTable("space_visits", {
|
|
8958
|
+
profileId: text("profile_id").notNull().references(() => profiles.id),
|
|
8959
|
+
spaceId: text("space_id").notNull().references(() => spaces.id),
|
|
8960
|
+
lastVisitedAt: ts("last_visited_at").notNull()
|
|
8961
|
+
}, (t) => ({
|
|
8962
|
+
pk: primaryKey({ columns: [t.profileId, t.spaceId] }),
|
|
8963
|
+
spaceIdx: index("space_visits_space_idx").on(t.spaceId, t.lastVisitedAt)
|
|
8964
|
+
}));
|
|
9615
8965
|
var recallIndex = sqliteTable("recall_index", {
|
|
9616
8966
|
objectId: text("object_id").primaryKey(),
|
|
9617
8967
|
indexedAt: ts("indexed_at").notNull(),
|
|
@@ -9875,11 +9225,7 @@ var assigneeColumns = {
|
|
|
9875
9225
|
color: profiles.color,
|
|
9876
9226
|
emoji: profiles.emoji
|
|
9877
9227
|
};
|
|
9878
|
-
var
|
|
9879
|
-
(select max(${contributions.createdAt}) from ${contributions}
|
|
9880
|
-
where ${contributions.threadId} = ${threads.id}),
|
|
9881
|
-
${threads.createdAt}
|
|
9882
|
-
)`;
|
|
9228
|
+
var lastActivity = sql`${threads.lastActivityAt}`;
|
|
9883
9229
|
|
|
9884
9230
|
// ../core/src/ops/space.ts
|
|
9885
9231
|
var GUIDANCE_LIMITS = {
|
|
@@ -9994,6 +9340,10 @@ var EMOJI_RE = new RegExp("^\\p{RGI_Emoji}$", "v");
|
|
|
9994
9340
|
var BASE_MS = Date.parse("2026-07-20T15:00:00.000Z");
|
|
9995
9341
|
// ../core/src/ops/agent-pairing.ts
|
|
9996
9342
|
var PAIRING_TTL_MS = 15 * 60 * 1000;
|
|
9343
|
+
// ../core/src/ops/space-visit.ts
|
|
9344
|
+
var VISIT_THROTTLE_MS = 5 * 60 * 1000;
|
|
9345
|
+
// ../core/src/ops/computer-checkpoint-operations.ts
|
|
9346
|
+
var CHECKPOINT_OPERATION_TTL_SECONDS = 7 * 24 * 60 * 60;
|
|
9997
9347
|
// ../core/src/ops/package-cache.ts
|
|
9998
9348
|
var PACKAGE_CACHE_PENDING_TTL_MS = 15 * 60 * 1000;
|
|
9999
9349
|
var PACKAGE_CACHE_FINAL_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
@@ -10139,6 +9489,13 @@ function recordExternalReadDefaults(operation, defaults) {
|
|
|
10139
9489
|
}
|
|
10140
9490
|
|
|
10141
9491
|
// ../actions/src/output-schemas.ts
|
|
9492
|
+
var adminCloseOutputSchema = strictObject({
|
|
9493
|
+
finishMode: literal("admin_close"),
|
|
9494
|
+
runId: string2(),
|
|
9495
|
+
status: literal("cancelled"),
|
|
9496
|
+
reasonCode: literal("run.admin_closed_abandoned"),
|
|
9497
|
+
actorProfileId: string2()
|
|
9498
|
+
});
|
|
10142
9499
|
function buildOutputSchemas() {
|
|
10143
9500
|
const id = string2();
|
|
10144
9501
|
const timestamp = string2();
|
|
@@ -11270,9 +10627,26 @@ function buildOutputSchemas() {
|
|
|
11270
10627
|
workflow: workflowSummary.optional(),
|
|
11271
10628
|
threads: array(thread).optional(),
|
|
11272
10629
|
promotedArtifacts: array(artifact).optional(),
|
|
11273
|
-
total: number2().int().min(0),
|
|
10630
|
+
total: number2().int().min(0).optional(),
|
|
11274
10631
|
nextCursor: string2().optional(),
|
|
11275
|
-
computerConfig: resolvedComputerConfig.nullable().optional()
|
|
10632
|
+
computerConfig: resolvedComputerConfig.nullable().optional(),
|
|
10633
|
+
counts: looseObject({
|
|
10634
|
+
total: number2().int().min(0),
|
|
10635
|
+
byStatus: record(string2(), number2().int().min(0)),
|
|
10636
|
+
byLabel: record(string2(), number2().int().min(0))
|
|
10637
|
+
}).optional(),
|
|
10638
|
+
canEditGuidance: boolean2().optional()
|
|
10639
|
+
}).superRefine((value, ctx) => {
|
|
10640
|
+
if (value.threads !== undefined && value.total === undefined) {
|
|
10641
|
+
ctx.addIssue({
|
|
10642
|
+
code: "custom",
|
|
10643
|
+
path: ["total"],
|
|
10644
|
+
message: "a Thread roster requires total"
|
|
10645
|
+
});
|
|
10646
|
+
}
|
|
10647
|
+
if (value.threads === undefined && value.counts === undefined) {
|
|
10648
|
+
ctx.addIssue({ code: "custom", path: ["counts"], message: "a header requires counts" });
|
|
10649
|
+
}
|
|
11276
10650
|
}),
|
|
11277
10651
|
goal: looseObject({
|
|
11278
10652
|
id: id.optional(),
|
|
@@ -11740,6 +11114,7 @@ function buildOutputSchemas() {
|
|
|
11740
11114
|
computer_run_finish: looseObject({
|
|
11741
11115
|
runId: id,
|
|
11742
11116
|
status: string2(),
|
|
11117
|
+
finishMode: literal("owner").optional(),
|
|
11743
11118
|
replayed: boolean2(),
|
|
11744
11119
|
durability: computerRunDurability,
|
|
11745
11120
|
finishAssessment: computerRunFinishAssessment.nullable(),
|
|
@@ -12142,12 +11517,84 @@ function outputSchemaFor(actionName) {
|
|
|
12142
11517
|
return outputSchemas[actionName];
|
|
12143
11518
|
}
|
|
12144
11519
|
|
|
12145
|
-
// ../actions/src/
|
|
12146
|
-
var
|
|
12147
|
-
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
};
|
|
11520
|
+
// ../actions/src/action-projection.ts
|
|
11521
|
+
var templates = new WeakMap;
|
|
11522
|
+
var origins = new WeakMap;
|
|
11523
|
+
var advertisements = new WeakMap;
|
|
11524
|
+
function variantShape(action, variant) {
|
|
11525
|
+
return Object.fromEntries(Object.entries({ ...action.inputSchema, ...variant.inputSchema }).filter(([key]) => !variant.omitInputs?.includes(key)));
|
|
11526
|
+
}
|
|
11527
|
+
function objectUnion(schemas) {
|
|
11528
|
+
const shape = {};
|
|
11529
|
+
const keys = new Set(schemas.flatMap((schema) => Object.keys(schema.shape)));
|
|
11530
|
+
for (const key of keys) {
|
|
11531
|
+
const fields = schemas.map((schema) => schema.shape[key]);
|
|
11532
|
+
const present = fields.filter((field) => field !== undefined);
|
|
11533
|
+
const field = present.length === 1 ? present[0] : union(present);
|
|
11534
|
+
shape[key] = fields.some((field) => field === undefined || field.isOptional()) ? field.optional() : field;
|
|
11535
|
+
}
|
|
11536
|
+
const union2 = union(schemas);
|
|
11537
|
+
return looseObject(shape).superRefine((value, ctx) => {
|
|
11538
|
+
const parsed = union2.safeParse(value);
|
|
11539
|
+
if (!parsed.success)
|
|
11540
|
+
for (const issue of parsed.error.issues)
|
|
11541
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
11542
|
+
});
|
|
11543
|
+
}
|
|
11544
|
+
function prepare(action) {
|
|
11545
|
+
action = origins.get(action) ?? action;
|
|
11546
|
+
const cached = templates.get(action);
|
|
11547
|
+
if (cached)
|
|
11548
|
+
return cached;
|
|
11549
|
+
const inputs = [strictObject(action.inputSchema)];
|
|
11550
|
+
const outputs = action.outputSchema ? [action.outputSchema] : [];
|
|
11551
|
+
const combined = { ...action.inputSchema };
|
|
11552
|
+
const extensions = action.privilegedVariants ?? [];
|
|
11553
|
+
for (const variant of extensions) {
|
|
11554
|
+
inputs.push(strictObject(variantShape(action, variant)));
|
|
11555
|
+
outputs.push(variant.outputSchema);
|
|
11556
|
+
for (const [key, field] of Object.entries(variant.inputSchema)) {
|
|
11557
|
+
const base = combined[key];
|
|
11558
|
+
const extension = field;
|
|
11559
|
+
combined[key] = (base ? union([base, extension]).optional() : extension.optional()).describe(extension.description ?? "");
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
Object.freeze(action.inputSchema);
|
|
11563
|
+
const advertisedOutput = objectUnion(outputs);
|
|
11564
|
+
Object.freeze(advertisedOutput.shape);
|
|
11565
|
+
const result = {
|
|
11566
|
+
tags: Object.freeze(extensions.map((variant) => variant.tag)),
|
|
11567
|
+
advertised: Object.freeze({
|
|
11568
|
+
...action,
|
|
11569
|
+
description: extensions.map((variant) => variant.description).join(" "),
|
|
11570
|
+
inputSchema: Object.freeze(combined),
|
|
11571
|
+
outputSchema: advertisedOutput
|
|
11572
|
+
}),
|
|
11573
|
+
executionInput: inputs.length === 1 ? inputs[0] : discriminatedUnion(action.variantDiscriminator, [inputs[0], ...inputs.slice(1)]),
|
|
11574
|
+
executionOutput: outputs.length > 1 ? union(outputs) : outputs[0],
|
|
11575
|
+
executionShape: combined
|
|
11576
|
+
};
|
|
11577
|
+
origins.set(result.advertised, action);
|
|
11578
|
+
templates.set(action, result);
|
|
11579
|
+
return result;
|
|
11580
|
+
}
|
|
11581
|
+
function projectActionVariants(action, tags) {
|
|
11582
|
+
action = origins.get(action) ?? action;
|
|
11583
|
+
if (!action.privilegedVariants?.length || tags.length === 0)
|
|
11584
|
+
return action;
|
|
11585
|
+
const template = prepare(action);
|
|
11586
|
+
return tags.length === template.tags.length && template.tags.every((tag) => tags.includes(tag)) ? template.advertised : action;
|
|
11587
|
+
}
|
|
11588
|
+
function canonicalInputShape(action) {
|
|
11589
|
+
return action.privilegedVariants?.length ? prepare(action).executionShape : action.inputSchema;
|
|
11590
|
+
}
|
|
11591
|
+
var manifests = new WeakMap;
|
|
11592
|
+
// ../actions/src/agent-guides.ts
|
|
11593
|
+
var AGENT_GUIDE_URLS = {
|
|
11594
|
+
tldraw: "https://arborthreads.com/docs/agents/tldraw",
|
|
11595
|
+
computer: "https://arborthreads.com/docs/agents/computer",
|
|
11596
|
+
apps: "https://arborthreads.com/docs/agents/apps"
|
|
11597
|
+
};
|
|
12151
11598
|
// ../actions/src/output-shaping.ts
|
|
12152
11599
|
function record2(value) {
|
|
12153
11600
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
@@ -12380,6 +11827,9 @@ var OUTPUT_SHAPERS = {
|
|
|
12380
11827
|
]);
|
|
12381
11828
|
},
|
|
12382
11829
|
computer_run_finish: (result) => {
|
|
11830
|
+
if (result.finishMode === "admin_close") {
|
|
11831
|
+
return selected(result, ["finishMode", "runId", "status", "reasonCode", "actorProfileId"]);
|
|
11832
|
+
}
|
|
12383
11833
|
const run = record2(result.run) ?? {};
|
|
12384
11834
|
return defined([
|
|
12385
11835
|
["runId", run.runId],
|
|
@@ -12444,7 +11894,7 @@ function shapeActionOutput(actionName, value, input = {}) {
|
|
|
12444
11894
|
if (!shaper)
|
|
12445
11895
|
return value;
|
|
12446
11896
|
const publicValue = shaper(record2(value) ?? {}, input);
|
|
12447
|
-
const schema = outputSchemaFor(actionName);
|
|
11897
|
+
const schema = actionName === "computer_run_finish" && record2(publicValue)?.finishMode === "admin_close" ? adminCloseOutputSchema : outputSchemaFor(actionName);
|
|
12448
11898
|
if (!schema)
|
|
12449
11899
|
throw new Error(`${actionName}: compact action is missing an output schema`);
|
|
12450
11900
|
const parsed = schema.safeParse(publicValue);
|
|
@@ -12618,7 +12068,7 @@ var MCP_TOOL_ANNOTATIONS = {
|
|
|
12618
12068
|
computer_run_suspend: idempotent,
|
|
12619
12069
|
computer_run_promote: idempotent,
|
|
12620
12070
|
computer_repo_work_status: readOnly,
|
|
12621
|
-
computer_run_finish:
|
|
12071
|
+
computer_run_finish: destructive,
|
|
12622
12072
|
computer_run_receipt: readOnly,
|
|
12623
12073
|
computer_run_retention: readOnly,
|
|
12624
12074
|
computer_run_keep: idempotent,
|
|
@@ -13652,7 +13102,7 @@ var ACTION_DEFINITIONS = [
|
|
|
13652
13102
|
{
|
|
13653
13103
|
name: "thread_list",
|
|
13654
13104
|
title: "List assigned threads or a Space's threads",
|
|
13655
|
-
description: "List Threads you are responsible for (default), another profile's or jointly several, unassigned in one Space/Topic, or every Thread in a Space (`assignee=any` + spaceId) — default current work; status widens; order=activity is last-activity DESC (the aggregate board). `inbox` remains what you owe.",
|
|
13105
|
+
description: "List Threads you are responsible for (default), another profile's or jointly several, unassigned in one Space/Topic, or every Thread in a Space or Topic (`assignee=any` + spaceId or one topicId) — default current work; status widens; order=activity is last-activity DESC (the aggregate board). `inbox` remains what you owe.",
|
|
13656
13106
|
inputSchema: {
|
|
13657
13107
|
assignee: union([string2(), array(string2()).min(1).max(5)]).optional().describe("`me` (default), a profile id (prof_…), a list (assigned to ALL of them), or `any` (every Thread in the required spaceId)"),
|
|
13658
13108
|
unassigned: boolean2().optional().describe("threads with no assignee — requires spaceId or topicId"),
|
|
@@ -13685,8 +13135,9 @@ var ACTION_DEFINITIONS = [
|
|
|
13685
13135
|
"archived"
|
|
13686
13136
|
])).min(1).max(8)
|
|
13687
13137
|
]).optional().describe("default current = active + needs-review + stuck; all includes backlog/standing/resolved/canceled/archived; or a list of statuses to keep (current/all only alone)"),
|
|
13688
|
-
order: _enum(["assigned", "activity"]).optional().describe("default assigned = newest assignment first; activity = last_activity_at DESC (
|
|
13689
|
-
|
|
13138
|
+
order: _enum(["assigned", "activity", "column"]).optional().describe("default assigned = newest assignment first; activity = last_activity_at DESC (default page 50); column = one Topic Board column, ranked then by recency (needs assignee=any, one topicId, lifecycleLabel)"),
|
|
13139
|
+
lifecycleLabel: string2().min(1).optional().describe("order=column only: the Board column's lifecycle label key"),
|
|
13140
|
+
limit: number2().int().min(1).max(100).optional().describe("page size (default 20; 50 for order=activity; max 100)"),
|
|
13690
13141
|
cursor: string2().optional().describe("keyset cursor from a prior page's nextCursor")
|
|
13691
13142
|
},
|
|
13692
13143
|
surfaces: ["mcp", "cli"],
|
|
@@ -13854,16 +13305,30 @@ var ACTION_DEFINITIONS = [
|
|
|
13854
13305
|
{
|
|
13855
13306
|
name: "computer_run_finish",
|
|
13856
13307
|
title: "Finish a run",
|
|
13857
|
-
description: "End
|
|
13308
|
+
description: "End your Run with a reason; suspend if you expect to return; shared finish checkpoints/stops the last Run, isolated finish needs no Git publication and may stay pending for quiescence, checkpoint, release. Owner discard=true requires failed/cancelled; shared closes only the record, isolated abandons after quiescence.",
|
|
13858
13309
|
inputSchema: {
|
|
13859
13310
|
runId: string2().describe("the runId returned by computer_run_start, run_…"),
|
|
13860
|
-
|
|
13861
|
-
|
|
13862
|
-
|
|
13863
|
-
|
|
13311
|
+
finishMode: literal("owner").optional().describe("owner finish; omission preserves existing behavior"),
|
|
13312
|
+
outcome: _enum(["finished", "failed", "cancelled"]).optional().describe("owner mode only: terminal outcome; defaults to finished"),
|
|
13313
|
+
reason: string2().trim().max(500).optional().describe("owner mode only, required for a new finish intent: accomplishments and useful outcomes or limits; exact accepted legacy retries reuse their original text or omission"),
|
|
13314
|
+
discard: boolean2().optional().describe("owner mode only: discard=true requires failed/cancelled; shared closes only the record, isolated abandons after quiescence; never overrides active or unknown execution"),
|
|
13315
|
+
save: boolean2().optional().describe("owner mode only: false closes without the final checkpoint and deletes nothing: receipt records reasonCode run.closed_without_save and save.lastDurableSnapshotId; shared or suspended Runs only; not with discard")
|
|
13864
13316
|
},
|
|
13865
13317
|
surfaces: ["computer-mcp", "computer-cli"],
|
|
13866
13318
|
toolset: "loop",
|
|
13319
|
+
variantDiscriminator: "finishMode",
|
|
13320
|
+
privilegedVariants: [
|
|
13321
|
+
{
|
|
13322
|
+
tag: "admin_close",
|
|
13323
|
+
requires: "active-org-admin",
|
|
13324
|
+
inputSchema: {
|
|
13325
|
+
finishMode: literal("admin_close").describe("active same-org owner/admin only: admin_close is record-only cancelled/run.admin_closed_abandoned for an abandoned shared Run; omit outcome/reason/discard/save; refuses unsettled processes, pending finish or isolated execution")
|
|
13326
|
+
},
|
|
13327
|
+
omitInputs: ["outcome", "reason", "discard", "save"],
|
|
13328
|
+
description: "End your Run with a reason; owner finish checkpoints/stops the last shared Run or releases isolated execution. Organization owner/admin only: finishMode=admin_close cancels only an abandoned shared record with fixed audit code and no runtime work; omit outcome/reason/discard/save.",
|
|
13329
|
+
outputSchema: adminCloseOutputSchema
|
|
13330
|
+
}
|
|
13331
|
+
],
|
|
13867
13332
|
run: forward("computer_runtime.run_finish")
|
|
13868
13333
|
},
|
|
13869
13334
|
{
|
|
@@ -15094,11 +14559,13 @@ var ACTION_DEFINITIONS = [
|
|
|
15094
14559
|
{
|
|
15095
14560
|
name: "topic_get",
|
|
15096
14561
|
title: "Read a topic",
|
|
15097
|
-
description: "Read a Topic's durable context, guidance, the room's standing ways to help (`contributionLanes`), selected workflow summary, open requests, promoted artifacts, and a paged Thread roster (default 50; `total` is the full roster size). Continue with `cursor`, or use `all=true` / `--all` only for intentional complete enumeration; for a concrete question in a large Topic, prefer Topic-scoped `recall`.",
|
|
14562
|
+
description: "Read a Topic's durable context, guidance, the room's standing ways to help (`contributionLanes`), selected workflow summary, open requests, promoted artifacts, and a paged Thread roster (default 50; `total` is the full roster size). Continue with `cursor`, or use `all=true` / `--all` only for intentional complete enumeration; for a concrete question in a large Topic, prefer Topic-scoped `recall`. `threads=none` is the header alone.",
|
|
15098
14563
|
inputSchema: {
|
|
15099
14564
|
topicId: string2().min(1).describe("the topic id"),
|
|
14565
|
+
threads: _enum(["page", "none"]).optional().describe("page (default) includes the Thread roster page; none = header only — counts by status/label, participants, open-request count (no limit/cursor/all); page its Threads with thread_list assignee=any + topicId"),
|
|
15100
14566
|
...PAGINATION_INPUT
|
|
15101
14567
|
},
|
|
14568
|
+
externalReadDefaults: { unpagedWhen: { field: "threads", value: "none" } },
|
|
15102
14569
|
surfaces: ["mcp", "cli"],
|
|
15103
14570
|
toolset: "loop",
|
|
15104
14571
|
run: forward("topic.get")
|
|
@@ -16077,224 +15544,962 @@ var ACTION_DEFINITIONS = [
|
|
|
16077
15544
|
})
|
|
16078
15545
|
}
|
|
16079
15546
|
];
|
|
16080
|
-
var ACTIONS = ACTION_DEFINITIONS.map((action) => {
|
|
16081
|
-
if (action.requiresCapability && !action.surfaces.includes("mcp")) {
|
|
16082
|
-
throw new Error(`${action.name}: requiresCapability is an MCP catalog gate`);
|
|
15547
|
+
var ACTIONS = ACTION_DEFINITIONS.map((action) => {
|
|
15548
|
+
if (action.requiresCapability && !action.surfaces.includes("mcp")) {
|
|
15549
|
+
throw new Error(`${action.name}: requiresCapability is an MCP catalog gate`);
|
|
15550
|
+
}
|
|
15551
|
+
const externalReadDefaults = action.inputSchema.limit === PAGINATION_INPUT.limit ? { ...action.externalReadDefaults, limit: EXTERNAL_DEFAULT_PAGE_SIZE } : action.externalReadDefaults;
|
|
15552
|
+
for (const operation of forwardedOperations(action.run)) {
|
|
15553
|
+
recordExternalReadDefaults(operation, externalReadDefaults);
|
|
15554
|
+
}
|
|
15555
|
+
if (!action.surfaces.some((surface) => surface === "mcp" || surface === "computer-mcp")) {
|
|
15556
|
+
return externalReadDefaults ? { ...action, externalReadDefaults } : action;
|
|
15557
|
+
}
|
|
15558
|
+
const annotations = mcpAnnotationsFor(action.name);
|
|
15559
|
+
return {
|
|
15560
|
+
...action,
|
|
15561
|
+
externalReadDefaults,
|
|
15562
|
+
get outputSchema() {
|
|
15563
|
+
const schema = outputSchemaFor(action.name);
|
|
15564
|
+
if (!schema)
|
|
15565
|
+
throw new Error(`${action.name}: MCP action is missing an output schema`);
|
|
15566
|
+
return schema;
|
|
15567
|
+
},
|
|
15568
|
+
annotations
|
|
15569
|
+
};
|
|
15570
|
+
});
|
|
15571
|
+
|
|
15572
|
+
// ../actions/src/retention-entry.ts
|
|
15573
|
+
var ARBOR_VERSION = "0.24.17";
|
|
15574
|
+
var historyPolicySchema = _enum(["full", "checkpoint"]).optional().describe("text Artifacts: future history retention policy; full retains every source snapshot, checkpoint keeps metadata for every revision and source only when explicitly retained");
|
|
15575
|
+
var retainSourceSchema = boolean2().optional().describe("edit: in checkpoint mode, retain this newly minted content revision's source");
|
|
15576
|
+
var checkpointSchema = boolean2().optional().describe("edit: retain the exact current version source without incrementing content version");
|
|
15577
|
+
var ARTIFACT_GET_PUBLIC_DESCRIPTION = "Read one Artifact as a compact card without loading its body; editable text supports its outline plus bounded startLine+limit or heading windows and explicit all=true; File Artifacts remain files and report whether bounded UTF-8 text projection is available. For text-like files use startLine+limit and nextLine; all=true and heading stay unavailable for files, binary/unsupported files use the Artifact URL/download/media surface, and editable historical reads retain exact artifactVersionId.";
|
|
15578
|
+
function artifactEditInput(input) {
|
|
15579
|
+
const patches = Array.isArray(input.patches);
|
|
15580
|
+
const hasSource = typeof input.source === "string";
|
|
15581
|
+
const checkpoint = input.checkpoint === true;
|
|
15582
|
+
const historyPolicy = input.historyPolicy === "full" || input.historyPolicy === "checkpoint";
|
|
15583
|
+
if (checkpoint && (patches || hasSource || historyPolicy)) {
|
|
15584
|
+
throw new Error("artifact edit checkpoint cannot be combined with source, patches, or historyPolicy");
|
|
15585
|
+
}
|
|
15586
|
+
if (historyPolicy && (patches || hasSource)) {
|
|
15587
|
+
throw new Error("artifact historyPolicy change cannot be combined with a content edit");
|
|
15588
|
+
}
|
|
15589
|
+
if (checkpoint)
|
|
15590
|
+
return { ...input, verb: "checkpoint" };
|
|
15591
|
+
if (historyPolicy)
|
|
15592
|
+
return { ...input, verb: "set_history_policy" };
|
|
15593
|
+
return { ...input, verb: patches ? "patch" : "replace" };
|
|
15594
|
+
}
|
|
15595
|
+
function runArtifact(ex, input) {
|
|
15596
|
+
const { verb, ...rest } = input;
|
|
15597
|
+
if (verb === "create")
|
|
15598
|
+
return ex.call("artifact.create", rest);
|
|
15599
|
+
if (verb === "edit")
|
|
15600
|
+
return ex.call("artifact.edit", artifactEditInput(rest));
|
|
15601
|
+
if (verb === "set_live_preview")
|
|
15602
|
+
return ex.call("artifact.setLivePreview", rest);
|
|
15603
|
+
if (verb === "set_snapshot")
|
|
15604
|
+
return ex.call("artifact.setSnapshot", rest);
|
|
15605
|
+
if (verb === "promote_attachment")
|
|
15606
|
+
return ex.call("attachment.promote", rest);
|
|
15607
|
+
return Promise.reject(new Error(`unknown artifact verb "${verb ?? ""}"`));
|
|
15608
|
+
}
|
|
15609
|
+
function overrideAction(action, overrides) {
|
|
15610
|
+
return Object.assign(Object.defineProperties({}, Object.getOwnPropertyDescriptors(action)), overrides);
|
|
15611
|
+
}
|
|
15612
|
+
function retentionAction(action) {
|
|
15613
|
+
if (action.name === "create_artifact") {
|
|
15614
|
+
return overrideAction(action, {
|
|
15615
|
+
description: "Create a durable Artifact; text kinds may choose historyPolicy=full (default) or checkpoint. Checkpoint mode still keeps metadata/provenance for every revision while source snapshots are retained only when explicitly checkpointed.",
|
|
15616
|
+
inputSchema: { ...action.inputSchema, historyPolicy: historyPolicySchema }
|
|
15617
|
+
});
|
|
15618
|
+
}
|
|
15619
|
+
if (action.name === "edit_artifact") {
|
|
15620
|
+
return overrideAction(action, {
|
|
15621
|
+
description: "Edit a text Artifact from the baseVersion you read, or change its future historyPolicy/checkpoint the exact current source without minting a content version. Content edits return the exact artifactVersionId; byte-identical results are idempotent no-ops that reuse the current version identity, while stale divergent edits remain structured conflicts.",
|
|
15622
|
+
inputSchema: {
|
|
15623
|
+
...action.inputSchema,
|
|
15624
|
+
historyPolicy: historyPolicySchema,
|
|
15625
|
+
checkpoint: checkpointSchema,
|
|
15626
|
+
retainSource: retainSourceSchema
|
|
15627
|
+
},
|
|
15628
|
+
run: (ex, input) => ex.call("artifact.edit", artifactEditInput(input))
|
|
15629
|
+
});
|
|
15630
|
+
}
|
|
15631
|
+
if (action.name === "get_artifact" || action.name === "artifact_get") {
|
|
15632
|
+
return overrideAction(action, { description: ARTIFACT_GET_PUBLIC_DESCRIPTION });
|
|
15633
|
+
}
|
|
15634
|
+
if (action.name === "artifact") {
|
|
15635
|
+
return overrideAction(action, {
|
|
15636
|
+
description: "Create/edit a durable Artifact with full|checkpoint retention or manage Live Preview, snapshots, and attachments. Git edits derive retry keys (omitted edits derive one); keyless creates mint per-invocation keys; stable idempotencyKey supports caller retries; never blindly repeat ambiguous creates. promote_attachment creates a file Artifact from a Contribution; exported reports use the Attachment downloadUrl; policy changes do not mint content versions.",
|
|
15637
|
+
inputSchema: {
|
|
15638
|
+
...action.inputSchema,
|
|
15639
|
+
historyPolicy: historyPolicySchema,
|
|
15640
|
+
checkpoint: checkpointSchema,
|
|
15641
|
+
retainSource: retainSourceSchema
|
|
15642
|
+
},
|
|
15643
|
+
run: runArtifact
|
|
15644
|
+
});
|
|
15645
|
+
}
|
|
15646
|
+
return action;
|
|
15647
|
+
}
|
|
15648
|
+
var ACTIONS2 = ACTIONS.map(retentionAction);
|
|
15649
|
+
|
|
15650
|
+
// ../actions/src/recovery-entry.ts
|
|
15651
|
+
var grantOutput = object({
|
|
15652
|
+
grant: object({
|
|
15653
|
+
grantId: string2(),
|
|
15654
|
+
requestId: string2(),
|
|
15655
|
+
threadId: string2(),
|
|
15656
|
+
runId: string2(),
|
|
15657
|
+
computerId: string2(),
|
|
15658
|
+
granteeProfileId: string2(),
|
|
15659
|
+
grantedByProfileId: string2(),
|
|
15660
|
+
expiresAt: string2(),
|
|
15661
|
+
createdAt: string2(),
|
|
15662
|
+
revokedAt: string2().nullable(),
|
|
15663
|
+
revokedByProfileId: string2().nullable()
|
|
15664
|
+
}),
|
|
15665
|
+
replayed: boolean2()
|
|
15666
|
+
});
|
|
15667
|
+
var diagnosticOutput = object({
|
|
15668
|
+
grant: object({
|
|
15669
|
+
grantId: string2(),
|
|
15670
|
+
requestId: string2(),
|
|
15671
|
+
expiresAt: string2()
|
|
15672
|
+
}),
|
|
15673
|
+
diagnostic: object({
|
|
15674
|
+
runId: string2(),
|
|
15675
|
+
computerId: string2(),
|
|
15676
|
+
computerGeneration: number2().int().positive(),
|
|
15677
|
+
status: _enum(["active", "finished", "failed", "cancelled"]),
|
|
15678
|
+
outcome: _enum(["finished", "failed", "cancelled"]).nullable(),
|
|
15679
|
+
reasonCode: string2().nullable(),
|
|
15680
|
+
runtimeState: _enum(["shared", "live", "suspended", "releasing", "released"]),
|
|
15681
|
+
snapshotLineage: object({
|
|
15682
|
+
baseSnapshotId: string2().nullable(),
|
|
15683
|
+
currentSnapshotId: string2().nullable()
|
|
15684
|
+
}),
|
|
15685
|
+
providerState: object({
|
|
15686
|
+
generation: number2().int().min(0).nullable(),
|
|
15687
|
+
lastPhase: string2().nullable(),
|
|
15688
|
+
lastReasonCode: string2().nullable()
|
|
15689
|
+
}),
|
|
15690
|
+
operations: array(object({
|
|
15691
|
+
operationId: string2(),
|
|
15692
|
+
execution: _enum(["foreground", "background"]),
|
|
15693
|
+
state: _enum([
|
|
15694
|
+
"starting",
|
|
15695
|
+
"running",
|
|
15696
|
+
"completed",
|
|
15697
|
+
"failed",
|
|
15698
|
+
"cancelled",
|
|
15699
|
+
"not-routed",
|
|
15700
|
+
"provider-lost",
|
|
15701
|
+
"unknown"
|
|
15702
|
+
]),
|
|
15703
|
+
mutationRetrySafety: _enum(["not-needed", "safe", "unsafe", "unknown"]),
|
|
15704
|
+
reasonCode: string2()
|
|
15705
|
+
}))
|
|
15706
|
+
}),
|
|
15707
|
+
auditEventId: string2()
|
|
15708
|
+
});
|
|
15709
|
+
var additive2 = {
|
|
15710
|
+
readOnlyHint: false,
|
|
15711
|
+
destructiveHint: false,
|
|
15712
|
+
idempotentHint: true,
|
|
15713
|
+
openWorldHint: false
|
|
15714
|
+
};
|
|
15715
|
+
var auditedRead = {
|
|
15716
|
+
readOnlyHint: false,
|
|
15717
|
+
destructiveHint: false,
|
|
15718
|
+
idempotentHint: false,
|
|
15719
|
+
openWorldHint: false
|
|
15720
|
+
};
|
|
15721
|
+
var RECOVERY_ACTIONS = [
|
|
15722
|
+
{
|
|
15723
|
+
name: "computer_recovery_grant",
|
|
15724
|
+
title: "Grant delegated Computer recovery",
|
|
15725
|
+
description: "Issue one short-lived diagnostic grant for a profile explicitly targeted by the same open Request and exact Run. This grants no execution, file, environment, Secret, Git, checkpoint, or lifecycle capability.",
|
|
15726
|
+
inputSchema: {
|
|
15727
|
+
requestId: string2().describe("the targeted open Request authorizing this recovery scope, req_…"),
|
|
15728
|
+
runId: string2().describe("the exact Run whose diagnostic state may be inspected, run_…"),
|
|
15729
|
+
granteeProfileId: string2().describe("the exact targeted profile receiving diagnostic visibility"),
|
|
15730
|
+
expiresAt: string2().describe("future ISO timestamp, at most 24 hours and never after Request expiry"),
|
|
15731
|
+
idempotencyKey: string2().min(1).max(200).describe("stable key for this one logical grant")
|
|
15732
|
+
},
|
|
15733
|
+
outputSchema: grantOutput,
|
|
15734
|
+
annotations: additive2,
|
|
15735
|
+
surfaces: ["computer-cli"],
|
|
15736
|
+
toolset: "loop",
|
|
15737
|
+
run: (ex, input) => ex.call("computer_recovery.grant", input)
|
|
15738
|
+
},
|
|
15739
|
+
{
|
|
15740
|
+
name: "computer_recovery_revoke",
|
|
15741
|
+
title: "Revoke delegated Computer recovery",
|
|
15742
|
+
description: "Revoke one previously issued delegated diagnostic grant without touching the Computer or provider. Repeating the same revoke is an idempotent no-op.",
|
|
15743
|
+
inputSchema: {
|
|
15744
|
+
grantId: string2().describe("the delegated recovery grant, crg_…")
|
|
15745
|
+
},
|
|
15746
|
+
outputSchema: grantOutput,
|
|
15747
|
+
annotations: additive2,
|
|
15748
|
+
surfaces: ["computer-cli"],
|
|
15749
|
+
toolset: "loop",
|
|
15750
|
+
run: (ex, input) => ex.call("computer_recovery.revoke", input)
|
|
15751
|
+
},
|
|
15752
|
+
{
|
|
15753
|
+
name: "computer_recovery_inspect",
|
|
15754
|
+
title: "Inspect delegated Computer recovery state",
|
|
15755
|
+
description: "Read only the sanitized diagnostic projection authorized by one live delegated grant; every successful read records an attributed Arbor audit Event. It never calls the provider or exposes repository paths/heads, command output, environment, Secrets, sessions, or mutation controls.",
|
|
15756
|
+
inputSchema: {
|
|
15757
|
+
grantId: string2().describe("the delegated recovery grant, crg_…")
|
|
15758
|
+
},
|
|
15759
|
+
outputSchema: diagnosticOutput,
|
|
15760
|
+
annotations: auditedRead,
|
|
15761
|
+
surfaces: ["computer-mcp", "computer-cli"],
|
|
15762
|
+
toolset: "loop",
|
|
15763
|
+
run: (ex, input) => ex.call("computer_recovery.inspect", input)
|
|
15764
|
+
}
|
|
15765
|
+
];
|
|
15766
|
+
var ACTIONS3 = [...ACTIONS2, ...RECOVERY_ACTIONS];
|
|
15767
|
+
|
|
15768
|
+
// src/config.ts
|
|
15769
|
+
import {
|
|
15770
|
+
chmodSync,
|
|
15771
|
+
existsSync,
|
|
15772
|
+
lstatSync,
|
|
15773
|
+
mkdirSync,
|
|
15774
|
+
readFileSync,
|
|
15775
|
+
readdirSync,
|
|
15776
|
+
rmSync,
|
|
15777
|
+
statSync,
|
|
15778
|
+
writeFileSync
|
|
15779
|
+
} from "node:fs";
|
|
15780
|
+
import { homedir } from "node:os";
|
|
15781
|
+
import { dirname, join } from "node:path";
|
|
15782
|
+
|
|
15783
|
+
// src/errors.ts
|
|
15784
|
+
var ERROR_CODES = new Set([
|
|
15785
|
+
"UNAUTHORIZED",
|
|
15786
|
+
"FORBIDDEN",
|
|
15787
|
+
"NOT_FOUND",
|
|
15788
|
+
"VALIDATION",
|
|
15789
|
+
"CONFLICT",
|
|
15790
|
+
"RATE_LIMITED",
|
|
15791
|
+
"NETWORK",
|
|
15792
|
+
"INTERNAL"
|
|
15793
|
+
]);
|
|
15794
|
+
function isErrorCode(value) {
|
|
15795
|
+
return typeof value === "string" && ERROR_CODES.has(value);
|
|
15796
|
+
}
|
|
15797
|
+
function codeForStatus(status) {
|
|
15798
|
+
switch (status) {
|
|
15799
|
+
case 0:
|
|
15800
|
+
return "NETWORK";
|
|
15801
|
+
case 400:
|
|
15802
|
+
case 422:
|
|
15803
|
+
return "VALIDATION";
|
|
15804
|
+
case 401:
|
|
15805
|
+
return "UNAUTHORIZED";
|
|
15806
|
+
case 403:
|
|
15807
|
+
return "FORBIDDEN";
|
|
15808
|
+
case 404:
|
|
15809
|
+
case 410:
|
|
15810
|
+
return "NOT_FOUND";
|
|
15811
|
+
case 409:
|
|
15812
|
+
return "CONFLICT";
|
|
15813
|
+
case 429:
|
|
15814
|
+
return "RATE_LIMITED";
|
|
15815
|
+
default:
|
|
15816
|
+
return "INTERNAL";
|
|
15817
|
+
}
|
|
15818
|
+
}
|
|
15819
|
+
function exitCodeForError(code) {
|
|
15820
|
+
switch (code) {
|
|
15821
|
+
case "VALIDATION":
|
|
15822
|
+
return 2;
|
|
15823
|
+
case "UNAUTHORIZED":
|
|
15824
|
+
return 22;
|
|
15825
|
+
default:
|
|
15826
|
+
return 1;
|
|
15827
|
+
}
|
|
15828
|
+
}
|
|
15829
|
+
function codeForError(err) {
|
|
15830
|
+
if (err && typeof err === "object" && "code" in err && isErrorCode(err.code)) {
|
|
15831
|
+
return err.code;
|
|
15832
|
+
}
|
|
15833
|
+
return "INTERNAL";
|
|
15834
|
+
}
|
|
15835
|
+
function parseErrorDetails(value) {
|
|
15836
|
+
if (!value || typeof value !== "object")
|
|
15837
|
+
return;
|
|
15838
|
+
const raw = value;
|
|
15839
|
+
if (typeof raw.reason !== "string" || raw.reason === "")
|
|
15840
|
+
return;
|
|
15841
|
+
const details = { reason: raw.reason };
|
|
15842
|
+
if (typeof raw.field === "string")
|
|
15843
|
+
details.field = raw.field;
|
|
15844
|
+
if (typeof raw.limit === "number")
|
|
15845
|
+
details.limit = raw.limit;
|
|
15846
|
+
if (typeof raw.retryable === "boolean")
|
|
15847
|
+
details.retryable = raw.retryable;
|
|
15848
|
+
if (typeof raw.phase === "string")
|
|
15849
|
+
details.phase = raw.phase;
|
|
15850
|
+
if (raw.provider && typeof raw.provider === "object" && !Array.isArray(raw.provider)) {
|
|
15851
|
+
const provider = raw.provider;
|
|
15852
|
+
if (typeof provider.stage === "string" && provider.stage !== "") {
|
|
15853
|
+
details.provider = {
|
|
15854
|
+
stage: provider.stage,
|
|
15855
|
+
...typeof provider.exitCode === "number" ? { exitCode: provider.exitCode } : {},
|
|
15856
|
+
...typeof provider.stdout === "string" ? { stdout: provider.stdout } : {},
|
|
15857
|
+
...typeof provider.stderr === "string" ? { stderr: provider.stderr } : {},
|
|
15858
|
+
...typeof provider.containerStarted === "boolean" ? { containerStarted: provider.containerStarted } : {},
|
|
15859
|
+
...typeof provider.repositoryMaterialized === "boolean" ? { repositoryMaterialized: provider.repositoryMaterialized } : {}
|
|
15860
|
+
};
|
|
15861
|
+
}
|
|
15862
|
+
}
|
|
15863
|
+
if (typeof raw.runId === "string")
|
|
15864
|
+
details.runId = raw.runId;
|
|
15865
|
+
if (typeof raw.operationId === "string")
|
|
15866
|
+
details.operationId = raw.operationId;
|
|
15867
|
+
if (typeof raw.processId === "string")
|
|
15868
|
+
details.processId = raw.processId;
|
|
15869
|
+
if (raw.outputRetention && typeof raw.outputRetention === "object") {
|
|
15870
|
+
const retention = raw.outputRetention;
|
|
15871
|
+
if (retention.state === "expired" && typeof retention.expiresAt === "string") {
|
|
15872
|
+
details.outputRetention = { state: "expired", expiresAt: retention.expiresAt };
|
|
15873
|
+
}
|
|
15874
|
+
}
|
|
15875
|
+
if (raw.commandExecution === "not-routed" || raw.commandExecution === "unknown") {
|
|
15876
|
+
details.commandExecution = raw.commandExecution;
|
|
15877
|
+
}
|
|
15878
|
+
if (raw.mutationRetrySafety === "safe" || raw.mutationRetrySafety === "unsafe" || raw.mutationRetrySafety === "unknown") {
|
|
15879
|
+
details.mutationRetrySafety = raw.mutationRetrySafety;
|
|
15880
|
+
}
|
|
15881
|
+
if (typeof raw.compatibilityState === "string") {
|
|
15882
|
+
details.compatibilityState = raw.compatibilityState;
|
|
15883
|
+
}
|
|
15884
|
+
if (typeof raw.compatibilityReason === "string") {
|
|
15885
|
+
details.compatibilityReason = raw.compatibilityReason;
|
|
15886
|
+
}
|
|
15887
|
+
if (typeof raw.suggestedAction === "string")
|
|
15888
|
+
details.suggestedAction = raw.suggestedAction;
|
|
15889
|
+
if (typeof raw.catalogRevision === "string")
|
|
15890
|
+
details.catalogRevision = raw.catalogRevision;
|
|
15891
|
+
if (typeof raw.clientCatalogRevision === "string") {
|
|
15892
|
+
details.clientCatalogRevision = raw.clientCatalogRevision;
|
|
15893
|
+
}
|
|
15894
|
+
if (typeof raw.catalogNextStep === "string")
|
|
15895
|
+
details.catalogNextStep = raw.catalogNextStep;
|
|
15896
|
+
return details;
|
|
15897
|
+
}
|
|
15898
|
+
function detailsForError(err) {
|
|
15899
|
+
if (!err || typeof err !== "object" || !("details" in err))
|
|
15900
|
+
return;
|
|
15901
|
+
return parseErrorDetails(err.details);
|
|
15902
|
+
}
|
|
15903
|
+
|
|
15904
|
+
class ApiError extends Error {
|
|
15905
|
+
status;
|
|
15906
|
+
details;
|
|
15907
|
+
code;
|
|
15908
|
+
constructor(message, status, details) {
|
|
15909
|
+
super(message);
|
|
15910
|
+
this.status = status;
|
|
15911
|
+
this.details = details;
|
|
15912
|
+
this.name = "ApiError";
|
|
15913
|
+
this.code = codeForStatus(status);
|
|
15914
|
+
}
|
|
15915
|
+
}
|
|
15916
|
+
|
|
15917
|
+
class UsageError extends Error {
|
|
15918
|
+
code = "VALIDATION";
|
|
15919
|
+
details;
|
|
15920
|
+
constructor(message, details) {
|
|
15921
|
+
super(message);
|
|
15922
|
+
this.name = "UsageError";
|
|
15923
|
+
this.details = details ?? { reason: "validation.invalid_value" };
|
|
15924
|
+
}
|
|
15925
|
+
}
|
|
15926
|
+
|
|
15927
|
+
class PartialUploadError extends Error {
|
|
15928
|
+
partialResult;
|
|
15929
|
+
code;
|
|
15930
|
+
details;
|
|
15931
|
+
constructor(message, cause, partialResult) {
|
|
15932
|
+
super(message);
|
|
15933
|
+
this.partialResult = partialResult;
|
|
15934
|
+
this.name = "PartialUploadError";
|
|
15935
|
+
this.code = codeForError(cause);
|
|
15936
|
+
this.details = detailsForError(cause);
|
|
15937
|
+
}
|
|
15938
|
+
}
|
|
15939
|
+
|
|
15940
|
+
// src/config.ts
|
|
15941
|
+
var PROD_API_URL = "https://arborthreads.com";
|
|
15942
|
+
var PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
15943
|
+
function arborDir() {
|
|
15944
|
+
return join(homedir(), ".arbor");
|
|
15945
|
+
}
|
|
15946
|
+
function defaultConfigPath() {
|
|
15947
|
+
return join(arborDir(), "config.json");
|
|
15948
|
+
}
|
|
15949
|
+
function profilesDir() {
|
|
15950
|
+
return join(arborDir(), "profiles");
|
|
15951
|
+
}
|
|
15952
|
+
function registryPath() {
|
|
15953
|
+
return join(arborDir(), "profiles.json");
|
|
15954
|
+
}
|
|
15955
|
+
function namedConfigPath(name) {
|
|
15956
|
+
return join(profilesDir(), `${name}.json`);
|
|
15957
|
+
}
|
|
15958
|
+
var CONFIG_PATH = process.env.ARBOR_CONFIG ?? join(homedir(), ".arbor", "config.json");
|
|
15959
|
+
var DEFAULT_TOKEN_OVERWRITE_REFUSAL = "refusing to overwrite ~/.arbor/config.json — a token already exists. Set ARBOR_CONFIG to an isolated path (e.g. ~/.arbor/<agent>.config.json) and retry.";
|
|
15960
|
+
var LOCK_TIMEOUT_MS = 5000;
|
|
15961
|
+
var LOCK_STALE_MS = 30000;
|
|
15962
|
+
var LOCK_POLL_MS = 20;
|
|
15963
|
+
var activeTarget;
|
|
15964
|
+
function sleepSync(ms) {
|
|
15965
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
15966
|
+
}
|
|
15967
|
+
function acquireConfigLock(configPath) {
|
|
15968
|
+
const lockPath = `${configPath}.lock`;
|
|
15969
|
+
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
15970
|
+
for (;; ) {
|
|
15971
|
+
try {
|
|
15972
|
+
mkdirSync(lockPath);
|
|
15973
|
+
return () => {
|
|
15974
|
+
try {
|
|
15975
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
15976
|
+
} catch {}
|
|
15977
|
+
};
|
|
15978
|
+
} catch (err) {
|
|
15979
|
+
if (err?.code !== "EEXIST")
|
|
15980
|
+
throw err;
|
|
15981
|
+
try {
|
|
15982
|
+
if (Date.now() - statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
|
|
15983
|
+
rmSync(lockPath, { recursive: true, force: true });
|
|
15984
|
+
continue;
|
|
15985
|
+
}
|
|
15986
|
+
} catch {
|
|
15987
|
+
continue;
|
|
15988
|
+
}
|
|
15989
|
+
if (Date.now() >= deadline) {
|
|
15990
|
+
throw new Error(`timed out waiting for another arbor process to finish writing ${configPath}. If none is running, remove ${lockPath}.`);
|
|
15991
|
+
}
|
|
15992
|
+
sleepSync(LOCK_POLL_MS);
|
|
15993
|
+
}
|
|
15994
|
+
}
|
|
15995
|
+
}
|
|
15996
|
+
function validateProfileName(name, field = "profile") {
|
|
15997
|
+
if (!PROFILE_NAME.test(name)) {
|
|
15998
|
+
throw new UsageError(`invalid profile name: ${JSON.stringify(name)}`, {
|
|
15999
|
+
reason: "validation.invalid_value",
|
|
16000
|
+
field
|
|
16001
|
+
});
|
|
16002
|
+
}
|
|
16003
|
+
}
|
|
16004
|
+
function fsType(entry, predicate) {
|
|
16005
|
+
const value = entry[predicate];
|
|
16006
|
+
return typeof value === "function" ? Boolean(value.call(entry)) : value === true;
|
|
16007
|
+
}
|
|
16008
|
+
function rejectSymlink(path, label) {
|
|
16009
|
+
if (!existsSync(path))
|
|
16010
|
+
return;
|
|
16011
|
+
if (fsType(lstatSync(path), "isSymbolicLink"))
|
|
16012
|
+
throw new Error(`${label} must not be a symbolic link: ${path}`);
|
|
16013
|
+
}
|
|
16014
|
+
function ensureArborDir() {
|
|
16015
|
+
const dir = arborDir();
|
|
16016
|
+
rejectSymlink(dir, "Arbor config directory");
|
|
16017
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
16018
|
+
chmodSync(dir, 448);
|
|
16019
|
+
}
|
|
16020
|
+
function ensureProfilesDir() {
|
|
16021
|
+
ensureArborDir();
|
|
16022
|
+
const dir = profilesDir();
|
|
16023
|
+
rejectSymlink(dir, "Arbor profiles directory");
|
|
16024
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
16025
|
+
chmodSync(dir, 448);
|
|
16026
|
+
}
|
|
16027
|
+
function readRegistry() {
|
|
16028
|
+
const path = registryPath();
|
|
16029
|
+
if (!existsSync(path))
|
|
16030
|
+
return {};
|
|
16031
|
+
rejectSymlink(path, "Arbor profile registry");
|
|
16032
|
+
try {
|
|
16033
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
16034
|
+
if (parsed.defaultProfile !== undefined)
|
|
16035
|
+
validateProfileName(parsed.defaultProfile);
|
|
16036
|
+
return { defaultProfile: parsed.defaultProfile };
|
|
16037
|
+
} catch (err) {
|
|
16038
|
+
if (err instanceof UsageError)
|
|
16039
|
+
throw err;
|
|
16040
|
+
throw new Error(`could not read Arbor profile registry ${path}`);
|
|
16041
|
+
}
|
|
16042
|
+
}
|
|
16043
|
+
function writeRegistry(registry) {
|
|
16044
|
+
ensureArborDir();
|
|
16045
|
+
const path = registryPath();
|
|
16046
|
+
rejectSymlink(path, "Arbor profile registry");
|
|
16047
|
+
const release = acquireConfigLock(path);
|
|
16048
|
+
try {
|
|
16049
|
+
const safe = registry.defaultProfile ? { defaultProfile: registry.defaultProfile } : {};
|
|
16050
|
+
writeFileSync(path, `${JSON.stringify(safe, null, 2)}
|
|
16051
|
+
`, { mode: 384 });
|
|
16052
|
+
chmodSync(path, 384);
|
|
16053
|
+
} finally {
|
|
16054
|
+
release();
|
|
16055
|
+
}
|
|
16056
|
+
}
|
|
16057
|
+
function profileExists(name, field = "profile") {
|
|
16058
|
+
validateProfileName(name, field);
|
|
16059
|
+
const path = namedConfigPath(name);
|
|
16060
|
+
if (!existsSync(path))
|
|
16061
|
+
return false;
|
|
16062
|
+
rejectSymlink(path, `Arbor profile ${name}`);
|
|
16063
|
+
return fsType(lstatSync(path), "isFile");
|
|
16064
|
+
}
|
|
16065
|
+
function legacyTarget() {
|
|
16066
|
+
const defaultPath = defaultConfigPath();
|
|
16067
|
+
const envPath = process.env.ARBOR_CONFIG;
|
|
16068
|
+
return {
|
|
16069
|
+
path: envPath ?? defaultPath,
|
|
16070
|
+
defaultPath,
|
|
16071
|
+
isolated: Boolean(envPath),
|
|
16072
|
+
named: false,
|
|
16073
|
+
explicitProfile: false
|
|
16074
|
+
};
|
|
16075
|
+
}
|
|
16076
|
+
function resolveTarget(opts) {
|
|
16077
|
+
const profileFlag = opts?.profileFlag;
|
|
16078
|
+
const envProfile = process.env.ARBOR_PROFILE;
|
|
16079
|
+
if (process.env.ARBOR_CONFIG && profileFlag !== undefined) {
|
|
16080
|
+
throw new UsageError("ARBOR_CONFIG and --profile are ambiguous; choose one credential selector", {
|
|
16081
|
+
reason: "validation.invalid_value",
|
|
16082
|
+
field: "profile"
|
|
16083
|
+
});
|
|
16084
|
+
}
|
|
16085
|
+
if (process.env.ARBOR_CONFIG && envProfile !== undefined) {
|
|
16086
|
+
throw new UsageError("ARBOR_CONFIG and ARBOR_PROFILE are ambiguous; choose one credential selector", { reason: "validation.invalid_value", field: "ARBOR_PROFILE" });
|
|
16087
|
+
}
|
|
16088
|
+
if (process.env.ARBOR_CONFIG)
|
|
16089
|
+
return legacyTarget();
|
|
16090
|
+
const registryDefault = readRegistry().defaultProfile;
|
|
16091
|
+
const selected = profileFlag ?? envProfile ?? registryDefault;
|
|
16092
|
+
if (selected === undefined)
|
|
16093
|
+
return legacyTarget();
|
|
16094
|
+
const field = profileFlag !== undefined ? "profile" : envProfile !== undefined ? "ARBOR_PROFILE" : "profile";
|
|
16095
|
+
validateProfileName(selected, field);
|
|
16096
|
+
if (!opts?.allowMissingProfile && !profileExists(selected, field)) {
|
|
16097
|
+
throw new UsageError(`unknown profile: ${selected}`, {
|
|
16098
|
+
reason: "validation.invalid_value",
|
|
16099
|
+
field
|
|
16100
|
+
});
|
|
16101
|
+
}
|
|
16102
|
+
return {
|
|
16103
|
+
path: namedConfigPath(selected),
|
|
16104
|
+
defaultPath: defaultConfigPath(),
|
|
16105
|
+
isolated: true,
|
|
16106
|
+
profile: selected,
|
|
16107
|
+
named: true,
|
|
16108
|
+
explicitProfile: profileFlag !== undefined
|
|
16109
|
+
};
|
|
16110
|
+
}
|
|
16111
|
+
function configureConfigTarget(opts) {
|
|
16112
|
+
activeTarget = resolveTarget(opts);
|
|
16113
|
+
}
|
|
16114
|
+
function currentTarget() {
|
|
16115
|
+
return activeTarget ?? resolveTarget();
|
|
16116
|
+
}
|
|
16117
|
+
function getConfigPath() {
|
|
16118
|
+
return currentTarget().path;
|
|
16119
|
+
}
|
|
16120
|
+
function listProfiles() {
|
|
16121
|
+
const registry = readRegistry();
|
|
16122
|
+
const dir = profilesDir();
|
|
16123
|
+
if (!existsSync(dir))
|
|
16124
|
+
return { defaultProfile: registry.defaultProfile, profiles: [] };
|
|
16125
|
+
rejectSymlink(dir, "Arbor profiles directory");
|
|
16126
|
+
const profiles = readdirSync(dir).filter((entry) => entry.endsWith(".json")).map((entry) => {
|
|
16127
|
+
const name = entry.slice(0, -5);
|
|
16128
|
+
validateProfileName(name);
|
|
16129
|
+
const path = join(dir, entry);
|
|
16130
|
+
const stats = lstatSync(path);
|
|
16131
|
+
if (fsType(stats, "isSymbolicLink"))
|
|
16132
|
+
throw new Error(`Arbor profile ${name} must not be a symbolic link: ${path}`);
|
|
16133
|
+
if (!fsType(stats, "isFile"))
|
|
16134
|
+
throw new Error(`Arbor profile ${name} is not a regular file: ${path}`);
|
|
16135
|
+
return { name, default: registry.defaultProfile === name };
|
|
16136
|
+
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
16137
|
+
return { defaultProfile: registry.defaultProfile, profiles };
|
|
16138
|
+
}
|
|
16139
|
+
function profileShow(name) {
|
|
16140
|
+
validateProfileName(name);
|
|
16141
|
+
if (!profileExists(name)) {
|
|
16142
|
+
throw new UsageError(`unknown profile: ${name}`, {
|
|
16143
|
+
reason: "validation.invalid_value",
|
|
16144
|
+
field: "profile"
|
|
16145
|
+
});
|
|
16146
|
+
}
|
|
16147
|
+
const registry = readRegistry();
|
|
16148
|
+
const cfg = JSON.parse(readFileSync(namedConfigPath(name), "utf8"));
|
|
16149
|
+
return {
|
|
16150
|
+
name,
|
|
16151
|
+
default: registry.defaultProfile === name,
|
|
16152
|
+
apiUrl: cfg.apiUrl || PROD_API_URL
|
|
16153
|
+
};
|
|
16154
|
+
}
|
|
16155
|
+
function setDefaultProfile(name) {
|
|
16156
|
+
if (name !== null) {
|
|
16157
|
+
validateProfileName(name);
|
|
16158
|
+
if (!profileExists(name)) {
|
|
16159
|
+
throw new UsageError(`unknown profile: ${name}`, {
|
|
16160
|
+
reason: "validation.invalid_value",
|
|
16161
|
+
field: "profile"
|
|
16162
|
+
});
|
|
16163
|
+
}
|
|
16164
|
+
}
|
|
16165
|
+
writeRegistry(name ? { defaultProfile: name } : {});
|
|
16166
|
+
}
|
|
16167
|
+
function clearDefaultProfile() {
|
|
16168
|
+
setDefaultProfile(null);
|
|
16169
|
+
}
|
|
16170
|
+
function deleteProfile(name) {
|
|
16171
|
+
validateProfileName(name);
|
|
16172
|
+
const registry = readRegistry();
|
|
16173
|
+
if (registry.defaultProfile === name) {
|
|
16174
|
+
throw new UsageError(`cannot delete default profile ${name}; select another default or run profile clear-default first`, { reason: "validation.invalid_value", field: "profile" });
|
|
16175
|
+
}
|
|
16176
|
+
if (!profileExists(name)) {
|
|
16177
|
+
throw new UsageError(`unknown profile: ${name}`, {
|
|
16178
|
+
reason: "validation.invalid_value",
|
|
16179
|
+
field: "profile"
|
|
16180
|
+
});
|
|
16181
|
+
}
|
|
16182
|
+
const path = namedConfigPath(name);
|
|
16183
|
+
rejectSymlink(path, `Arbor profile ${name}`);
|
|
16184
|
+
rmSync(path);
|
|
16185
|
+
}
|
|
16186
|
+
function defaultConfigOverwriteBlocked(opts) {
|
|
16187
|
+
const target = currentTarget();
|
|
16188
|
+
const isolated = opts?.isolated ?? target.isolated;
|
|
16189
|
+
const path = opts?.path ?? target.defaultPath;
|
|
16190
|
+
if (isolated)
|
|
16191
|
+
return false;
|
|
16192
|
+
if (!existsSync(path))
|
|
16193
|
+
return false;
|
|
16194
|
+
try {
|
|
16195
|
+
const cfg = JSON.parse(readFileSync(path, "utf8"));
|
|
16196
|
+
return Boolean(cfg.token);
|
|
16197
|
+
} catch {
|
|
16198
|
+
return false;
|
|
16199
|
+
}
|
|
16200
|
+
}
|
|
16201
|
+
function loadConfig() {
|
|
16202
|
+
const target = currentTarget();
|
|
16203
|
+
const envToken = target.explicitProfile ? undefined : process.env.ARBOR_TOKEN || undefined;
|
|
16204
|
+
const envUrl = process.env.ARBOR_API_URL || undefined;
|
|
16205
|
+
if (target.named)
|
|
16206
|
+
rejectSymlink(target.path, `Arbor profile ${target.profile}`);
|
|
16207
|
+
if (existsSync(target.path)) {
|
|
16208
|
+
try {
|
|
16209
|
+
const cfg = JSON.parse(readFileSync(target.path, "utf8"));
|
|
16210
|
+
return { apiUrl: envUrl ?? (cfg.apiUrl || PROD_API_URL), token: envToken ?? cfg.token };
|
|
16211
|
+
} catch (err) {
|
|
16212
|
+
if (err instanceof Error && /symbolic link/i.test(err.message))
|
|
16213
|
+
throw err;
|
|
16214
|
+
}
|
|
16215
|
+
}
|
|
16216
|
+
return { apiUrl: envUrl ?? PROD_API_URL, token: envToken };
|
|
16217
|
+
}
|
|
16218
|
+
function writeConfigGuarded(opts) {
|
|
16219
|
+
mkdirSync(dirname(opts.configPath), { recursive: true });
|
|
16220
|
+
const release = acquireConfigLock(opts.configPath);
|
|
16221
|
+
try {
|
|
16222
|
+
if (!opts.allowDefaultTokenOverwrite && defaultConfigOverwriteBlocked({ isolated: opts.isolated, path: opts.defaultPath })) {
|
|
16223
|
+
throw new Error(DEFAULT_TOKEN_OVERWRITE_REFUSAL);
|
|
16224
|
+
}
|
|
16225
|
+
writeFileSync(opts.configPath, `${JSON.stringify(opts.cfg, null, 2)}
|
|
16226
|
+
`, { mode: 384 });
|
|
16227
|
+
chmodSync(opts.configPath, 384);
|
|
16228
|
+
} finally {
|
|
16229
|
+
release();
|
|
16230
|
+
}
|
|
16231
|
+
}
|
|
16232
|
+
function saveConfig(cfg, opts) {
|
|
16233
|
+
const target = currentTarget();
|
|
16234
|
+
if (target.named) {
|
|
16235
|
+
ensureProfilesDir();
|
|
16236
|
+
rejectSymlink(target.path, `Arbor profile ${target.profile}`);
|
|
16237
|
+
}
|
|
16238
|
+
writeConfigGuarded({
|
|
16239
|
+
cfg,
|
|
16240
|
+
configPath: target.path,
|
|
16241
|
+
defaultPath: target.defaultPath,
|
|
16242
|
+
isolated: target.isolated,
|
|
16243
|
+
allowDefaultTokenOverwrite: opts?.allowDefaultTokenOverwrite
|
|
16244
|
+
});
|
|
16245
|
+
}
|
|
16246
|
+
function clearToken() {
|
|
16247
|
+
const cfg = loadConfig();
|
|
16248
|
+
saveConfig({ apiUrl: cfg.apiUrl }, { allowDefaultTokenOverwrite: true });
|
|
16249
|
+
}
|
|
16250
|
+
|
|
16251
|
+
// src/source.ts
|
|
16252
|
+
var SNIFF = [
|
|
16253
|
+
["CLAUDECODE", "Claude Code"],
|
|
16254
|
+
["CLAUDE_CODE_ENTRYPOINT", "Claude Code"],
|
|
16255
|
+
["OPENCLAW_HOME", "openclaw"],
|
|
16256
|
+
["CODEX_SANDBOX", "Codex"],
|
|
16257
|
+
["CURSOR_TRACE_ID", "Cursor"]
|
|
16258
|
+
];
|
|
16259
|
+
function detectSource(env = process.env) {
|
|
16260
|
+
const explicit = env.ARBOR_SOURCE?.trim();
|
|
16261
|
+
if (explicit)
|
|
16262
|
+
return explicit;
|
|
16263
|
+
for (const [envVar, tool] of SNIFF) {
|
|
16264
|
+
if (env[envVar]?.trim())
|
|
16265
|
+
return tool;
|
|
16083
16266
|
}
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16267
|
+
return;
|
|
16268
|
+
}
|
|
16269
|
+
|
|
16270
|
+
// src/client.ts
|
|
16271
|
+
class NotLoggedInError extends Error {
|
|
16272
|
+
code = "UNAUTHORIZED";
|
|
16273
|
+
details = { reason: "authorization.denied" };
|
|
16274
|
+
constructor() {
|
|
16275
|
+
super("Not logged in. Run: arbor login");
|
|
16276
|
+
this.name = "NotLoggedInError";
|
|
16087
16277
|
}
|
|
16088
|
-
|
|
16089
|
-
|
|
16278
|
+
}
|
|
16279
|
+
function authHeader() {
|
|
16280
|
+
const cfg = loadConfig();
|
|
16281
|
+
if (!cfg.token)
|
|
16282
|
+
throw new NotLoggedInError;
|
|
16283
|
+
return { authorization: `Bearer ${cfg.token}`, apiUrl: cfg.apiUrl };
|
|
16284
|
+
}
|
|
16285
|
+
var source = detectSource();
|
|
16286
|
+
async function callApi(name, input, signal) {
|
|
16287
|
+
const { authorization, apiUrl } = authHeader();
|
|
16288
|
+
const dot = name.indexOf(".");
|
|
16289
|
+
const object = dot === -1 ? name : name.slice(0, dot);
|
|
16290
|
+
const verb = dot === -1 ? "" : name.slice(dot + 1);
|
|
16291
|
+
let res;
|
|
16292
|
+
try {
|
|
16293
|
+
res = await fetch(`${apiUrl}/api`, {
|
|
16294
|
+
method: "POST",
|
|
16295
|
+
signal,
|
|
16296
|
+
headers: {
|
|
16297
|
+
"content-type": "application/json",
|
|
16298
|
+
authorization,
|
|
16299
|
+
...source ? { "x-arbor-source": source } : {}
|
|
16300
|
+
},
|
|
16301
|
+
body: JSON.stringify({ object, verb, input })
|
|
16302
|
+
});
|
|
16303
|
+
} catch (cause) {
|
|
16304
|
+
throw new ApiError(`could not reach ${apiUrl} (${cause instanceof Error ? cause.message : String(cause)})`, 0);
|
|
16090
16305
|
}
|
|
16091
|
-
const
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
|
|
16097
|
-
|
|
16098
|
-
|
|
16099
|
-
|
|
16100
|
-
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
|
|
16105
|
-
|
|
16106
|
-
|
|
16107
|
-
|
|
16108
|
-
|
|
16109
|
-
|
|
16110
|
-
const patches = Array.isArray(input.patches);
|
|
16111
|
-
const hasSource = typeof input.source === "string";
|
|
16112
|
-
const checkpoint = input.checkpoint === true;
|
|
16113
|
-
const historyPolicy = input.historyPolicy === "full" || input.historyPolicy === "checkpoint";
|
|
16114
|
-
if (checkpoint && (patches || hasSource || historyPolicy)) {
|
|
16115
|
-
throw new Error("artifact edit checkpoint cannot be combined with source, patches, or historyPolicy");
|
|
16306
|
+
const body = await res.json().catch(() => ({}));
|
|
16307
|
+
if (!res.ok || !body.success)
|
|
16308
|
+
throw new ApiError(body.error ?? `request failed (${res.status})`, res.status, parseErrorDetails(body.errorDetails));
|
|
16309
|
+
return body.data;
|
|
16310
|
+
}
|
|
16311
|
+
var httpExecutor = { call: callApi };
|
|
16312
|
+
async function binaryGet(path, authenticated = true) {
|
|
16313
|
+
const { authorization, apiUrl } = authHeader();
|
|
16314
|
+
let response;
|
|
16315
|
+
const url = new URL(path, apiUrl);
|
|
16316
|
+
if (url.origin !== new URL(apiUrl).origin || !authenticated && !url.pathname.startsWith("/api/attachment-read/"))
|
|
16317
|
+
throw new Error("Invalid download target");
|
|
16318
|
+
try {
|
|
16319
|
+
response = await fetch(url.toString(), {
|
|
16320
|
+
headers: authenticated ? { authorization } : {},
|
|
16321
|
+
redirect: "error"
|
|
16322
|
+
});
|
|
16323
|
+
} catch {
|
|
16324
|
+
throw new ApiError("Binary download request failed", 0);
|
|
16116
16325
|
}
|
|
16117
|
-
if (
|
|
16118
|
-
throw new
|
|
16326
|
+
if (!response.ok)
|
|
16327
|
+
throw new ApiError(`Download failed (${response.status})`, response.status);
|
|
16328
|
+
return response;
|
|
16329
|
+
}
|
|
16330
|
+
|
|
16331
|
+
// src/discovery.ts
|
|
16332
|
+
var HELP_DISCOVERY_TIMEOUT_MS = 1000;
|
|
16333
|
+
var baseActions = ACTIONS3.filter((action) => action.surfaces.some((surface) => surface === "cli" || surface === "computer-cli"));
|
|
16334
|
+
var BASE_HELP_NOTE = "Base help only: authenticated catalog unavailable.";
|
|
16335
|
+
async function discoverHelpActions(timeoutMs = HELP_DISCOVERY_TIMEOUT_MS) {
|
|
16336
|
+
const base = () => ({ actions: baseActions, note: BASE_HELP_NOTE });
|
|
16337
|
+
if (!loadConfig().token)
|
|
16338
|
+
return base();
|
|
16339
|
+
if (typeof AbortController !== "function" || typeof setTimeout !== "function")
|
|
16340
|
+
return base();
|
|
16341
|
+
const controller = new AbortController;
|
|
16342
|
+
let timer;
|
|
16343
|
+
try {
|
|
16344
|
+
const value = await Promise.race([
|
|
16345
|
+
callApi("tooling.catalog", {}, controller.signal),
|
|
16346
|
+
new Promise((_, reject) => {
|
|
16347
|
+
timer = setTimeout(() => {
|
|
16348
|
+
controller.abort();
|
|
16349
|
+
reject(new Error("catalog deadline"));
|
|
16350
|
+
}, timeoutMs);
|
|
16351
|
+
})
|
|
16352
|
+
]);
|
|
16353
|
+
const catalog = value;
|
|
16354
|
+
if (catalog?.serverVersion !== ARBOR_VERSION || !Array.isArray(catalog.actions))
|
|
16355
|
+
return base();
|
|
16356
|
+
const selectors = new Map;
|
|
16357
|
+
for (const item of catalog.actions) {
|
|
16358
|
+
if (!item || typeof item.name !== "string" || !Array.isArray(item.variants) || !item.variants.every((tag) => typeof tag === "string"))
|
|
16359
|
+
return base();
|
|
16360
|
+
selectors.set(item.name, item.variants);
|
|
16361
|
+
}
|
|
16362
|
+
return {
|
|
16363
|
+
actions: baseActions.map((action) => projectActionVariants(action, selectors.get(action.name) ?? []))
|
|
16364
|
+
};
|
|
16365
|
+
} catch {
|
|
16366
|
+
return base();
|
|
16367
|
+
} finally {
|
|
16368
|
+
if (timer !== undefined)
|
|
16369
|
+
clearTimeout(timer);
|
|
16370
|
+
controller.abort();
|
|
16371
|
+
}
|
|
16372
|
+
}
|
|
16373
|
+
|
|
16374
|
+
// src/attachment-download.ts
|
|
16375
|
+
async function downloadAttachment(id, output, signed = false, force = false) {
|
|
16376
|
+
const { createHash, randomUUID } = await import("node:crypto");
|
|
16377
|
+
const { open, rename, unlink, link } = await import("node:fs/promises");
|
|
16378
|
+
const { basename, resolve } = await import("node:path");
|
|
16379
|
+
if (!/^(att_|art_)[a-zA-Z0-9_-]+$/.test(id))
|
|
16380
|
+
throw new Error("Expected an Attachment or Artifact id");
|
|
16381
|
+
const artifact = id.startsWith("art_");
|
|
16382
|
+
const metadata = artifact && !signed ? null : await httpExecutor.call("attachment.get", {
|
|
16383
|
+
attachmentId: id,
|
|
16384
|
+
...signed ? { signed: true } : {}
|
|
16385
|
+
});
|
|
16386
|
+
if (signed && !metadata?.signedRead)
|
|
16387
|
+
throw new Error("Signed download is unavailable");
|
|
16388
|
+
const response = await binaryGet(signed ? metadata.signedRead.url : `/api/download/${artifact ? "artifact/" : ""}${encodeURIComponent(id)}`, !signed);
|
|
16389
|
+
const size = metadata?.size ?? Number(response.headers.get("x-arbor-size") ?? response.headers.get("content-length") ?? "NaN");
|
|
16390
|
+
if (!Number.isSafeInteger(size) || size < 0 || !response.body)
|
|
16391
|
+
throw new Error("Download has no valid size or body");
|
|
16392
|
+
const suggested = basename(metadata?.filename ?? dispositionFilename(response.headers.get("content-disposition")) ?? id);
|
|
16393
|
+
const destination = resolve(output ?? (suggested.startsWith(".") ? id : suggested));
|
|
16394
|
+
const temporary = `${destination}.${randomUUID()}.part`;
|
|
16395
|
+
const file = await open(temporary, "wx", 384);
|
|
16396
|
+
const reader = response.body.getReader();
|
|
16397
|
+
const hash = createHash("sha256");
|
|
16398
|
+
let received = 0;
|
|
16399
|
+
try {
|
|
16400
|
+
for (;; ) {
|
|
16401
|
+
const { done, value } = await reader.read();
|
|
16402
|
+
if (done)
|
|
16403
|
+
break;
|
|
16404
|
+
received += value.byteLength;
|
|
16405
|
+
if (received > size)
|
|
16406
|
+
throw new Error("Download size mismatch");
|
|
16407
|
+
hash.update(value);
|
|
16408
|
+
let offset = 0;
|
|
16409
|
+
while (offset < value.length) {
|
|
16410
|
+
const written = await file.write(value, offset, value.length - offset);
|
|
16411
|
+
offset += written.bytesWritten;
|
|
16412
|
+
}
|
|
16413
|
+
}
|
|
16414
|
+
const sha256 = hash.digest("hex");
|
|
16415
|
+
const expectedHash = metadata?.sha256 ?? response.headers.get("x-arbor-sha256");
|
|
16416
|
+
if (received !== size || expectedHash && expectedHash !== sha256)
|
|
16417
|
+
throw new Error("Download integrity mismatch");
|
|
16418
|
+
await file.close();
|
|
16419
|
+
if (force)
|
|
16420
|
+
await rename(temporary, destination);
|
|
16421
|
+
else {
|
|
16422
|
+
try {
|
|
16423
|
+
await link(temporary, destination);
|
|
16424
|
+
} catch (error) {
|
|
16425
|
+
if (error.code === "EEXIST")
|
|
16426
|
+
throw new Error("Destination exists; use --force to replace it");
|
|
16427
|
+
if (["EPERM", "ENOTSUP"].includes(error.code ?? ""))
|
|
16428
|
+
throw new Error("Filesystem does not support safe no-replace downloads; choose another destination or use --force to allow replacement");
|
|
16429
|
+
throw error;
|
|
16430
|
+
}
|
|
16431
|
+
await unlink(temporary);
|
|
16432
|
+
}
|
|
16433
|
+
return { path: destination, size: received, sha256 };
|
|
16434
|
+
} catch (error) {
|
|
16435
|
+
await reader.cancel().catch(() => {});
|
|
16436
|
+
await file.close().catch(() => {});
|
|
16437
|
+
await unlink(temporary).catch(() => {});
|
|
16438
|
+
throw error;
|
|
16439
|
+
} finally {
|
|
16440
|
+
reader.releaseLock();
|
|
16119
16441
|
}
|
|
16120
|
-
if (checkpoint)
|
|
16121
|
-
return { ...input, verb: "checkpoint" };
|
|
16122
|
-
if (historyPolicy)
|
|
16123
|
-
return { ...input, verb: "set_history_policy" };
|
|
16124
|
-
return { ...input, verb: patches ? "patch" : "replace" };
|
|
16125
|
-
}
|
|
16126
|
-
function runArtifact(ex, input) {
|
|
16127
|
-
const { verb, ...rest } = input;
|
|
16128
|
-
if (verb === "create")
|
|
16129
|
-
return ex.call("artifact.create", rest);
|
|
16130
|
-
if (verb === "edit")
|
|
16131
|
-
return ex.call("artifact.edit", artifactEditInput(rest));
|
|
16132
|
-
if (verb === "set_live_preview")
|
|
16133
|
-
return ex.call("artifact.setLivePreview", rest);
|
|
16134
|
-
if (verb === "set_snapshot")
|
|
16135
|
-
return ex.call("artifact.setSnapshot", rest);
|
|
16136
|
-
if (verb === "promote_attachment")
|
|
16137
|
-
return ex.call("attachment.promote", rest);
|
|
16138
|
-
return Promise.reject(new Error(`unknown artifact verb "${verb ?? ""}"`));
|
|
16139
|
-
}
|
|
16140
|
-
function overrideAction(action, overrides) {
|
|
16141
|
-
return Object.assign(Object.defineProperties({}, Object.getOwnPropertyDescriptors(action)), overrides);
|
|
16142
16442
|
}
|
|
16143
|
-
function
|
|
16144
|
-
if (
|
|
16145
|
-
return
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
return overrideAction(action, {
|
|
16152
|
-
description: "Edit a text Artifact from the baseVersion you read, or change its future historyPolicy/checkpoint the exact current source without minting a content version. Content edits return the exact artifactVersionId; byte-identical results are idempotent no-ops that reuse the current version identity, while stale divergent edits remain structured conflicts.",
|
|
16153
|
-
inputSchema: {
|
|
16154
|
-
...action.inputSchema,
|
|
16155
|
-
historyPolicy: historyPolicySchema,
|
|
16156
|
-
checkpoint: checkpointSchema,
|
|
16157
|
-
retainSource: retainSourceSchema
|
|
16158
|
-
},
|
|
16159
|
-
run: (ex, input) => ex.call("artifact.edit", artifactEditInput(input))
|
|
16160
|
-
});
|
|
16161
|
-
}
|
|
16162
|
-
if (action.name === "get_artifact" || action.name === "artifact_get") {
|
|
16163
|
-
return overrideAction(action, { description: ARTIFACT_GET_PUBLIC_DESCRIPTION });
|
|
16164
|
-
}
|
|
16165
|
-
if (action.name === "artifact") {
|
|
16166
|
-
return overrideAction(action, {
|
|
16167
|
-
description: "Create/edit a durable Artifact with full|checkpoint retention or manage Live Preview, snapshots, and attachments. Git edits derive retry keys (omitted edits derive one); keyless creates mint per-invocation keys; stable idempotencyKey supports caller retries; never blindly repeat ambiguous creates. promote_attachment creates a file Artifact from a Contribution; exported reports use the Attachment downloadUrl; policy changes do not mint content versions.",
|
|
16168
|
-
inputSchema: {
|
|
16169
|
-
...action.inputSchema,
|
|
16170
|
-
historyPolicy: historyPolicySchema,
|
|
16171
|
-
checkpoint: checkpointSchema,
|
|
16172
|
-
retainSource: retainSourceSchema
|
|
16173
|
-
},
|
|
16174
|
-
run: runArtifact
|
|
16175
|
-
});
|
|
16443
|
+
function dispositionFilename(value) {
|
|
16444
|
+
if (!value)
|
|
16445
|
+
return;
|
|
16446
|
+
const encoded = /filename\*=UTF-8''([^;]+)/i.exec(value)?.[1];
|
|
16447
|
+
if (encoded) {
|
|
16448
|
+
try {
|
|
16449
|
+
return decodeURIComponent(encoded);
|
|
16450
|
+
} catch {}
|
|
16176
16451
|
}
|
|
16177
|
-
return
|
|
16452
|
+
return /filename="([^"]*)"/i.exec(value)?.[1] ?? /filename=([^;\s]+)/i.exec(value)?.[1];
|
|
16178
16453
|
}
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
replayed: boolean2()
|
|
16197
|
-
});
|
|
16198
|
-
var diagnosticOutput = object({
|
|
16199
|
-
grant: object({
|
|
16200
|
-
grantId: string2(),
|
|
16201
|
-
requestId: string2(),
|
|
16202
|
-
expiresAt: string2()
|
|
16203
|
-
}),
|
|
16204
|
-
diagnostic: object({
|
|
16205
|
-
runId: string2(),
|
|
16206
|
-
computerId: string2(),
|
|
16207
|
-
computerGeneration: number2().int().positive(),
|
|
16208
|
-
status: _enum(["active", "finished", "failed", "cancelled"]),
|
|
16209
|
-
outcome: _enum(["finished", "failed", "cancelled"]).nullable(),
|
|
16210
|
-
reasonCode: string2().nullable(),
|
|
16211
|
-
runtimeState: _enum(["shared", "live", "suspended", "releasing", "released"]),
|
|
16212
|
-
snapshotLineage: object({
|
|
16213
|
-
baseSnapshotId: string2().nullable(),
|
|
16214
|
-
currentSnapshotId: string2().nullable()
|
|
16215
|
-
}),
|
|
16216
|
-
providerState: object({
|
|
16217
|
-
generation: number2().int().min(0).nullable(),
|
|
16218
|
-
lastPhase: string2().nullable(),
|
|
16219
|
-
lastReasonCode: string2().nullable()
|
|
16220
|
-
}),
|
|
16221
|
-
operations: array(object({
|
|
16222
|
-
operationId: string2(),
|
|
16223
|
-
execution: _enum(["foreground", "background"]),
|
|
16224
|
-
state: _enum([
|
|
16225
|
-
"starting",
|
|
16226
|
-
"running",
|
|
16227
|
-
"completed",
|
|
16228
|
-
"failed",
|
|
16229
|
-
"cancelled",
|
|
16230
|
-
"not-routed",
|
|
16231
|
-
"provider-lost",
|
|
16232
|
-
"unknown"
|
|
16233
|
-
]),
|
|
16234
|
-
mutationRetrySafety: _enum(["not-needed", "safe", "unsafe", "unknown"]),
|
|
16235
|
-
reasonCode: string2()
|
|
16236
|
-
}))
|
|
16237
|
-
}),
|
|
16238
|
-
auditEventId: string2()
|
|
16239
|
-
});
|
|
16240
|
-
var additive2 = {
|
|
16241
|
-
readOnlyHint: false,
|
|
16242
|
-
destructiveHint: false,
|
|
16243
|
-
idempotentHint: true,
|
|
16244
|
-
openWorldHint: false
|
|
16245
|
-
};
|
|
16246
|
-
var auditedRead = {
|
|
16247
|
-
readOnlyHint: false,
|
|
16248
|
-
destructiveHint: false,
|
|
16249
|
-
idempotentHint: false,
|
|
16250
|
-
openWorldHint: false
|
|
16251
|
-
};
|
|
16252
|
-
var RECOVERY_ACTIONS = [
|
|
16253
|
-
{
|
|
16254
|
-
name: "computer_recovery_grant",
|
|
16255
|
-
title: "Grant delegated Computer recovery",
|
|
16256
|
-
description: "Issue one short-lived diagnostic grant for a profile explicitly targeted by the same open Request and exact Run. This grants no execution, file, environment, Secret, Git, checkpoint, or lifecycle capability.",
|
|
16257
|
-
inputSchema: {
|
|
16258
|
-
requestId: string2().describe("the targeted open Request authorizing this recovery scope, req_…"),
|
|
16259
|
-
runId: string2().describe("the exact Run whose diagnostic state may be inspected, run_…"),
|
|
16260
|
-
granteeProfileId: string2().describe("the exact targeted profile receiving diagnostic visibility"),
|
|
16261
|
-
expiresAt: string2().describe("future ISO timestamp, at most 24 hours and never after Request expiry"),
|
|
16262
|
-
idempotencyKey: string2().min(1).max(200).describe("stable key for this one logical grant")
|
|
16263
|
-
},
|
|
16264
|
-
outputSchema: grantOutput,
|
|
16265
|
-
annotations: additive2,
|
|
16266
|
-
surfaces: ["computer-cli"],
|
|
16267
|
-
toolset: "loop",
|
|
16268
|
-
run: (ex, input) => ex.call("computer_recovery.grant", input)
|
|
16454
|
+
// package.json
|
|
16455
|
+
var package_default = {
|
|
16456
|
+
name: "@lambdacurry/arbor",
|
|
16457
|
+
version: "0.24.17",
|
|
16458
|
+
description: "The Arbor CLI — a shared workspace for people and agents. The human + headless-agent write path over Arbor's guarded operation surface.",
|
|
16459
|
+
keywords: [
|
|
16460
|
+
"agents",
|
|
16461
|
+
"arbor",
|
|
16462
|
+
"cli",
|
|
16463
|
+
"collaboration",
|
|
16464
|
+
"mcp"
|
|
16465
|
+
],
|
|
16466
|
+
license: "MIT",
|
|
16467
|
+
repository: {
|
|
16468
|
+
type: "git",
|
|
16469
|
+
url: "git+https://github.com/lambda-curry/arbor.git",
|
|
16470
|
+
directory: "packages/cli"
|
|
16269
16471
|
},
|
|
16270
|
-
{
|
|
16271
|
-
|
|
16272
|
-
title: "Revoke delegated Computer recovery",
|
|
16273
|
-
description: "Revoke one previously issued delegated diagnostic grant without touching the Computer or provider. Repeating the same revoke is an idempotent no-op.",
|
|
16274
|
-
inputSchema: {
|
|
16275
|
-
grantId: string2().describe("the delegated recovery grant, crg_…")
|
|
16276
|
-
},
|
|
16277
|
-
outputSchema: grantOutput,
|
|
16278
|
-
annotations: additive2,
|
|
16279
|
-
surfaces: ["computer-cli"],
|
|
16280
|
-
toolset: "loop",
|
|
16281
|
-
run: (ex, input) => ex.call("computer_recovery.revoke", input)
|
|
16472
|
+
bin: {
|
|
16473
|
+
arbor: "./dist/arbor.js"
|
|
16282
16474
|
},
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16292
|
-
|
|
16293
|
-
|
|
16294
|
-
|
|
16475
|
+
files: [
|
|
16476
|
+
"dist",
|
|
16477
|
+
"README.md"
|
|
16478
|
+
],
|
|
16479
|
+
type: "module",
|
|
16480
|
+
publishConfig: {
|
|
16481
|
+
access: "public"
|
|
16482
|
+
},
|
|
16483
|
+
scripts: {
|
|
16484
|
+
arbor: "vpx src/bin.ts",
|
|
16485
|
+
build: "bun build ./src/bin.ts --target=node --outfile=dist/arbor.js",
|
|
16486
|
+
test: "vp test run --passWithNoTests",
|
|
16487
|
+
typecheck: "tsc -b",
|
|
16488
|
+
prepublishOnly: "bun run build"
|
|
16489
|
+
},
|
|
16490
|
+
devDependencies: {
|
|
16491
|
+
"@arbor/actions": "workspace:*",
|
|
16492
|
+
"@arbor/core": "workspace:*",
|
|
16493
|
+
"@types/node": "^26.2.0",
|
|
16494
|
+
"just-bash": "3.4.2",
|
|
16495
|
+
typescript: "^5.8.0",
|
|
16496
|
+
"vite-plus": "catalog:",
|
|
16497
|
+
zod: "^4.4.3"
|
|
16498
|
+
},
|
|
16499
|
+
engines: {
|
|
16500
|
+
node: ">=18"
|
|
16295
16501
|
}
|
|
16296
|
-
|
|
16297
|
-
var ACTIONS3 = [...ACTIONS2, ...RECOVERY_ACTIONS];
|
|
16502
|
+
};
|
|
16298
16503
|
|
|
16299
16504
|
// src/attachment-upload.ts
|
|
16300
16505
|
import { basename, resolve } from "node:path";
|
|
@@ -17130,11 +17335,11 @@ var KNOWN_MISREACHES = [
|
|
|
17130
17335
|
why: "this command is noun-verb"
|
|
17131
17336
|
}
|
|
17132
17337
|
];
|
|
17133
|
-
function familyHelp(positionals) {
|
|
17338
|
+
function familyHelp(positionals, actions = CLI_ACTIONS) {
|
|
17134
17339
|
if (positionals.length !== 1)
|
|
17135
17340
|
return;
|
|
17136
17341
|
const word = positionals[0].toLowerCase().replace(/_/g, " ");
|
|
17137
|
-
const members =
|
|
17342
|
+
const members = actions.filter((a) => commandWords(a).split(" ").includes(word)).sort((a, b) => commandWords(a).localeCompare(commandWords(b)));
|
|
17138
17343
|
if (members.length === 0)
|
|
17139
17344
|
return;
|
|
17140
17345
|
return `\`${word}\` commands — run \`arbor <command> --help\` for one command's exact flags.
|
|
@@ -17198,11 +17403,11 @@ function helpLine(action) {
|
|
|
17198
17403
|
}
|
|
17199
17404
|
var COMMAND_HELP = CLI_ACTIONS.map(helpLine).join(`
|
|
17200
17405
|
`);
|
|
17201
|
-
function commandHelp(positionals) {
|
|
17406
|
+
function commandHelp(positionals, actions = CLI_ACTIONS) {
|
|
17202
17407
|
const match = matchCommand(positionals);
|
|
17203
17408
|
if (!match)
|
|
17204
17409
|
return;
|
|
17205
|
-
const
|
|
17410
|
+
const action = actions.find((action) => action.name === match.action.name) ?? match.action;
|
|
17206
17411
|
const specs = flagsForSchema(action.inputSchema);
|
|
17207
17412
|
const explicitPositionals = positionalSpecs(action);
|
|
17208
17413
|
const primary = explicitPositionals.length === 0 ? primaryPositionalField(action.inputSchema) : undefined;
|
|
@@ -17265,8 +17470,8 @@ ${[...lines, ...waitLines].join(`
|
|
|
17265
17470
|
`)}${primaryNote}${explicitNote}${aliasNote}${notes}
|
|
17266
17471
|
`;
|
|
17267
17472
|
}
|
|
17268
|
-
function commandCatalog() {
|
|
17269
|
-
return
|
|
17473
|
+
function commandCatalog(actions = CLI_ACTIONS) {
|
|
17474
|
+
return actions.filter((action) => action.surfaces.some((surface) => surface === "cli" || surface === "computer-cli")).map((action) => ({
|
|
17270
17475
|
command: commandWords(action),
|
|
17271
17476
|
name: action.name,
|
|
17272
17477
|
description: action.description,
|
|
@@ -17335,7 +17540,8 @@ async function runObjectVerb(positionals, flags, ctx) {
|
|
|
17335
17540
|
const typed = positionals.join(" ") || "(none)";
|
|
17336
17541
|
throw new UsageError(`unknown command: ${typed} — ${suggestCommand(positionals)}`);
|
|
17337
17542
|
}
|
|
17338
|
-
const {
|
|
17543
|
+
const { words } = match;
|
|
17544
|
+
const action = { ...match.action, inputSchema: canonicalInputShape(match.action) };
|
|
17339
17545
|
applyPositionals(action, positionals.slice(words), flags);
|
|
17340
17546
|
const accepted = acceptedFlags(action.inputSchema);
|
|
17341
17547
|
const unknown = Object.keys(flags).filter((f) => !accepted.has(f) && !RESERVED_FLAGS.has(f));
|
|
@@ -17654,8 +17860,22 @@ Tokens: a human PAT or an agent key works in either ARBOR_TOKEN (env, headless)
|
|
|
17654
17860
|
|
|
17655
17861
|
${COMMAND_HELP}
|
|
17656
17862
|
`;
|
|
17657
|
-
function renderHelp(ctx) {
|
|
17658
|
-
emitDual(commandCatalog(), HELP, "help", ctx);
|
|
17863
|
+
function renderHelp(ctx, actions) {
|
|
17864
|
+
emitDual(commandCatalog(actions), HELP, "help", ctx);
|
|
17865
|
+
}
|
|
17866
|
+
async function renderRequestedHelp(ctx, positionals) {
|
|
17867
|
+
const matched = matchCommand(positionals)?.action;
|
|
17868
|
+
const family = positionals.length === 1 ? positionals[0].replace(/_/g, " ") : null;
|
|
17869
|
+
const needsDiscovery = ctx.json || Boolean(matched?.privilegedVariants?.length) || Boolean(family && ACTIONS3.some((action) => action.privilegedVariants?.length && action.name.replace(/_/g, " ").split(" ").includes(family)));
|
|
17870
|
+
const discovery = needsDiscovery ? await discoverHelpActions() : undefined;
|
|
17871
|
+
if (discovery?.note)
|
|
17872
|
+
writeStderr(`${discovery.note}
|
|
17873
|
+
`);
|
|
17874
|
+
const focused = positionals.length ? commandHelp(positionals, discovery?.actions) ?? familyHelp(positionals, discovery?.actions) : undefined;
|
|
17875
|
+
if (focused)
|
|
17876
|
+
emitDual({ help: focused }, focused, "help", ctx);
|
|
17877
|
+
else
|
|
17878
|
+
renderHelp(ctx, discovery?.actions);
|
|
17659
17879
|
}
|
|
17660
17880
|
async function renderHealth(ctx) {
|
|
17661
17881
|
const cfg = loadConfig();
|
|
@@ -17701,7 +17921,7 @@ async function main() {
|
|
|
17701
17921
|
if (cmd !== "profile") {
|
|
17702
17922
|
configureConfigTarget({
|
|
17703
17923
|
profileFlag,
|
|
17704
|
-
allowMissingProfile: cmd === "login" || cmd === "auth" || cmd === "connect"
|
|
17924
|
+
allowMissingProfile: cmd === "login" || cmd === "auth" || cmd === "connect" || cmd === "help" || cmd === undefined || truthyFlag(flags.help)
|
|
17705
17925
|
});
|
|
17706
17926
|
} else if (profileFlag !== undefined) {
|
|
17707
17927
|
throw new UsageError("--profile selects a credential for a command; profile management names its target positionally");
|
|
@@ -17718,11 +17938,7 @@ Stream authenticated bytes to a file; verify size and the recorded SHA-256 when
|
|
|
17718
17938
|
return;
|
|
17719
17939
|
}
|
|
17720
17940
|
if (truthyFlag(flags.help)) {
|
|
17721
|
-
|
|
17722
|
-
if (focused)
|
|
17723
|
-
emitDual({ help: focused }, focused, "help", ctx);
|
|
17724
|
-
else
|
|
17725
|
-
renderHelp(ctx);
|
|
17941
|
+
await renderRequestedHelp(ctx, positionals);
|
|
17726
17942
|
return;
|
|
17727
17943
|
}
|
|
17728
17944
|
if (cmd === "attachment" && positionals[1] === "download") {
|
|
@@ -17735,8 +17951,10 @@ Stream authenticated bytes to a file; verify size and the recorded SHA-256 when
|
|
|
17735
17951
|
}
|
|
17736
17952
|
switch (cmd) {
|
|
17737
17953
|
case undefined:
|
|
17954
|
+
await renderRequestedHelp(ctx, []);
|
|
17955
|
+
return;
|
|
17738
17956
|
case "help":
|
|
17739
|
-
|
|
17957
|
+
await renderRequestedHelp(ctx, positionals.slice(1));
|
|
17740
17958
|
return;
|
|
17741
17959
|
case "login": {
|
|
17742
17960
|
await login({ url: stringFlag(flags.url, "url") });
|