tesseract-agent 0.6.0 → 0.6.1
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-bundle/cli.js +865 -664
- package/package.json +1 -1
package/dist-bundle/cli.js
CHANGED
|
@@ -4799,12 +4799,12 @@ function prefixIssues(path5, issues) {
|
|
|
4799
4799
|
function unwrapMessage(message) {
|
|
4800
4800
|
return typeof message === "string" ? message : message?.message;
|
|
4801
4801
|
}
|
|
4802
|
-
function finalizeIssue(iss,
|
|
4803
|
-
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(
|
|
4802
|
+
function finalizeIssue(iss, ctx2, config2) {
|
|
4803
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx2?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
4804
4804
|
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
|
4805
4805
|
rest.path ?? (rest.path = []);
|
|
4806
4806
|
rest.message = message;
|
|
4807
|
-
if (
|
|
4807
|
+
if (ctx2?.reportInput) {
|
|
4808
4808
|
rest.input = _input;
|
|
4809
4809
|
}
|
|
4810
4810
|
return rest;
|
|
@@ -5147,13 +5147,13 @@ var init_parse = __esm({
|
|
|
5147
5147
|
init_errors();
|
|
5148
5148
|
init_util();
|
|
5149
5149
|
_parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
5150
|
-
const
|
|
5151
|
-
const result2 = schema._zod.run({ value, issues: [] },
|
|
5150
|
+
const ctx2 = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
5151
|
+
const result2 = schema._zod.run({ value, issues: [] }, ctx2);
|
|
5152
5152
|
if (result2 instanceof Promise) {
|
|
5153
5153
|
throw new $ZodAsyncError();
|
|
5154
5154
|
}
|
|
5155
5155
|
if (result2.issues.length) {
|
|
5156
|
-
const e = new (_params?.Err ?? _Err)(result2.issues.map((iss) => finalizeIssue(iss,
|
|
5156
|
+
const e = new (_params?.Err ?? _Err)(result2.issues.map((iss) => finalizeIssue(iss, ctx2, config())));
|
|
5157
5157
|
captureStackTrace(e, _params?.callee);
|
|
5158
5158
|
throw e;
|
|
5159
5159
|
}
|
|
@@ -5161,12 +5161,12 @@ var init_parse = __esm({
|
|
|
5161
5161
|
};
|
|
5162
5162
|
parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
5163
5163
|
_parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
5164
|
-
const
|
|
5165
|
-
let result2 = schema._zod.run({ value, issues: [] },
|
|
5164
|
+
const ctx2 = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
5165
|
+
let result2 = schema._zod.run({ value, issues: [] }, ctx2);
|
|
5166
5166
|
if (result2 instanceof Promise)
|
|
5167
5167
|
result2 = await result2;
|
|
5168
5168
|
if (result2.issues.length) {
|
|
5169
|
-
const e = new (params?.Err ?? _Err)(result2.issues.map((iss) => finalizeIssue(iss,
|
|
5169
|
+
const e = new (params?.Err ?? _Err)(result2.issues.map((iss) => finalizeIssue(iss, ctx2, config())));
|
|
5170
5170
|
captureStackTrace(e, params?.callee);
|
|
5171
5171
|
throw e;
|
|
5172
5172
|
}
|
|
@@ -5174,31 +5174,31 @@ var init_parse = __esm({
|
|
|
5174
5174
|
};
|
|
5175
5175
|
parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
5176
5176
|
_safeParse = (_Err) => (schema, value, _ctx) => {
|
|
5177
|
-
const
|
|
5178
|
-
const result2 = schema._zod.run({ value, issues: [] },
|
|
5177
|
+
const ctx2 = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
5178
|
+
const result2 = schema._zod.run({ value, issues: [] }, ctx2);
|
|
5179
5179
|
if (result2 instanceof Promise) {
|
|
5180
5180
|
throw new $ZodAsyncError();
|
|
5181
5181
|
}
|
|
5182
5182
|
return result2.issues.length ? {
|
|
5183
5183
|
success: false,
|
|
5184
|
-
error: new (_Err ?? $ZodError)(result2.issues.map((iss) => finalizeIssue(iss,
|
|
5184
|
+
error: new (_Err ?? $ZodError)(result2.issues.map((iss) => finalizeIssue(iss, ctx2, config())))
|
|
5185
5185
|
} : { success: true, data: result2.value };
|
|
5186
5186
|
};
|
|
5187
5187
|
safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
5188
5188
|
_safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
5189
|
-
const
|
|
5190
|
-
let result2 = schema._zod.run({ value, issues: [] },
|
|
5189
|
+
const ctx2 = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
5190
|
+
let result2 = schema._zod.run({ value, issues: [] }, ctx2);
|
|
5191
5191
|
if (result2 instanceof Promise)
|
|
5192
5192
|
result2 = await result2;
|
|
5193
5193
|
return result2.issues.length ? {
|
|
5194
5194
|
success: false,
|
|
5195
|
-
error: new _Err(result2.issues.map((iss) => finalizeIssue(iss,
|
|
5195
|
+
error: new _Err(result2.issues.map((iss) => finalizeIssue(iss, ctx2, config())))
|
|
5196
5196
|
} : { success: true, data: result2.value };
|
|
5197
5197
|
};
|
|
5198
5198
|
safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
5199
5199
|
_encode = (_Err) => (schema, value, _ctx) => {
|
|
5200
|
-
const
|
|
5201
|
-
return _parse(_Err)(schema, value,
|
|
5200
|
+
const ctx2 = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5201
|
+
return _parse(_Err)(schema, value, ctx2);
|
|
5202
5202
|
};
|
|
5203
5203
|
encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
5204
5204
|
_decode = (_Err) => (schema, value, _ctx) => {
|
|
@@ -5206,8 +5206,8 @@ var init_parse = __esm({
|
|
|
5206
5206
|
};
|
|
5207
5207
|
decode = /* @__PURE__ */ _decode($ZodRealError);
|
|
5208
5208
|
_encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
5209
|
-
const
|
|
5210
|
-
return _parseAsync(_Err)(schema, value,
|
|
5209
|
+
const ctx2 = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5210
|
+
return _parseAsync(_Err)(schema, value, ctx2);
|
|
5211
5211
|
};
|
|
5212
5212
|
encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
5213
5213
|
_decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
@@ -5215,8 +5215,8 @@ var init_parse = __esm({
|
|
|
5215
5215
|
};
|
|
5216
5216
|
decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
5217
5217
|
_safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
5218
|
-
const
|
|
5219
|
-
return _safeParse(_Err)(schema, value,
|
|
5218
|
+
const ctx2 = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5219
|
+
return _safeParse(_Err)(schema, value, ctx2);
|
|
5220
5220
|
};
|
|
5221
5221
|
safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
5222
5222
|
_safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
@@ -5224,8 +5224,8 @@ var init_parse = __esm({
|
|
|
5224
5224
|
};
|
|
5225
5225
|
safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
5226
5226
|
_safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
5227
|
-
const
|
|
5228
|
-
return _safeParseAsync(_Err)(schema, value,
|
|
5227
|
+
const ctx2 = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5228
|
+
return _safeParseAsync(_Err)(schema, value, ctx2);
|
|
5229
5229
|
};
|
|
5230
5230
|
safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
5231
5231
|
_safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
@@ -6100,7 +6100,7 @@ function normalizeDef(def) {
|
|
|
6100
6100
|
optionalKeys: new Set(okeys)
|
|
6101
6101
|
};
|
|
6102
6102
|
}
|
|
6103
|
-
function handleCatchall(proms, input, payload,
|
|
6103
|
+
function handleCatchall(proms, input, payload, ctx2, def, inst) {
|
|
6104
6104
|
const unrecognized = [];
|
|
6105
6105
|
const keySet = def.keySet;
|
|
6106
6106
|
const _catchall = def.catchall._zod;
|
|
@@ -6116,7 +6116,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
6116
6116
|
unrecognized.push(key2);
|
|
6117
6117
|
continue;
|
|
6118
6118
|
}
|
|
6119
|
-
const r = _catchall.run({ value: input[key2], issues: [] },
|
|
6119
|
+
const r = _catchall.run({ value: input[key2], issues: [] }, ctx2);
|
|
6120
6120
|
if (r instanceof Promise) {
|
|
6121
6121
|
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key2, input, isOptionalIn, isOptionalOut)));
|
|
6122
6122
|
} else {
|
|
@@ -6137,7 +6137,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
6137
6137
|
return payload;
|
|
6138
6138
|
});
|
|
6139
6139
|
}
|
|
6140
|
-
function handleUnionResults(results, final, inst,
|
|
6140
|
+
function handleUnionResults(results, final, inst, ctx2) {
|
|
6141
6141
|
for (const result2 of results) {
|
|
6142
6142
|
if (result2.issues.length === 0) {
|
|
6143
6143
|
final.value = result2.value;
|
|
@@ -6153,11 +6153,11 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
6153
6153
|
code: "invalid_union",
|
|
6154
6154
|
input: final.value,
|
|
6155
6155
|
inst,
|
|
6156
|
-
errors: results.map((result2) => result2.issues.map((iss) => finalizeIssue(iss,
|
|
6156
|
+
errors: results.map((result2) => result2.issues.map((iss) => finalizeIssue(iss, ctx2, config())))
|
|
6157
6157
|
});
|
|
6158
6158
|
return final;
|
|
6159
6159
|
}
|
|
6160
|
-
function handleExclusiveUnionResults(results, final, inst,
|
|
6160
|
+
function handleExclusiveUnionResults(results, final, inst, ctx2) {
|
|
6161
6161
|
const successes = results.filter((r) => r.issues.length === 0);
|
|
6162
6162
|
if (successes.length === 1) {
|
|
6163
6163
|
final.value = successes[0].value;
|
|
@@ -6168,7 +6168,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
6168
6168
|
code: "invalid_union",
|
|
6169
6169
|
input: final.value,
|
|
6170
6170
|
inst,
|
|
6171
|
-
errors: results.map((result2) => result2.issues.map((iss) => finalizeIssue(iss,
|
|
6171
|
+
errors: results.map((result2) => result2.issues.map((iss) => finalizeIssue(iss, ctx2, config())))
|
|
6172
6172
|
});
|
|
6173
6173
|
} else {
|
|
6174
6174
|
final.issues.push({
|
|
@@ -6299,7 +6299,7 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
|
|
|
6299
6299
|
}
|
|
6300
6300
|
return final;
|
|
6301
6301
|
}
|
|
6302
|
-
function handleMapResult(keyResult, valueResult, final, key2, input, inst,
|
|
6302
|
+
function handleMapResult(keyResult, valueResult, final, key2, input, inst, ctx2) {
|
|
6303
6303
|
if (keyResult.issues.length) {
|
|
6304
6304
|
if (propertyKeyTypes.has(typeof key2)) {
|
|
6305
6305
|
final.issues.push(...prefixIssues(key2, keyResult.issues));
|
|
@@ -6309,7 +6309,7 @@ function handleMapResult(keyResult, valueResult, final, key2, input, inst, ctx)
|
|
|
6309
6309
|
origin: "map",
|
|
6310
6310
|
input,
|
|
6311
6311
|
inst,
|
|
6312
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss,
|
|
6312
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config()))
|
|
6313
6313
|
});
|
|
6314
6314
|
}
|
|
6315
6315
|
}
|
|
@@ -6323,7 +6323,7 @@ function handleMapResult(keyResult, valueResult, final, key2, input, inst, ctx)
|
|
|
6323
6323
|
input,
|
|
6324
6324
|
inst,
|
|
6325
6325
|
key: key2,
|
|
6326
|
-
issues: valueResult.issues.map((iss) => finalizeIssue(iss,
|
|
6326
|
+
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx2, config()))
|
|
6327
6327
|
});
|
|
6328
6328
|
}
|
|
6329
6329
|
}
|
|
@@ -6358,39 +6358,39 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
6358
6358
|
}
|
|
6359
6359
|
return payload;
|
|
6360
6360
|
}
|
|
6361
|
-
function handlePipeResult(left, next,
|
|
6361
|
+
function handlePipeResult(left, next, ctx2) {
|
|
6362
6362
|
if (left.issues.length) {
|
|
6363
6363
|
left.aborted = true;
|
|
6364
6364
|
return left;
|
|
6365
6365
|
}
|
|
6366
|
-
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback },
|
|
6366
|
+
return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx2);
|
|
6367
6367
|
}
|
|
6368
|
-
function handleCodecAResult(result2, def,
|
|
6368
|
+
function handleCodecAResult(result2, def, ctx2) {
|
|
6369
6369
|
if (result2.issues.length) {
|
|
6370
6370
|
result2.aborted = true;
|
|
6371
6371
|
return result2;
|
|
6372
6372
|
}
|
|
6373
|
-
const direction =
|
|
6373
|
+
const direction = ctx2.direction || "forward";
|
|
6374
6374
|
if (direction === "forward") {
|
|
6375
6375
|
const transformed = def.transform(result2.value, result2);
|
|
6376
6376
|
if (transformed instanceof Promise) {
|
|
6377
|
-
return transformed.then((value) => handleCodecTxResult(result2, value, def.out,
|
|
6377
|
+
return transformed.then((value) => handleCodecTxResult(result2, value, def.out, ctx2));
|
|
6378
6378
|
}
|
|
6379
|
-
return handleCodecTxResult(result2, transformed, def.out,
|
|
6379
|
+
return handleCodecTxResult(result2, transformed, def.out, ctx2);
|
|
6380
6380
|
} else {
|
|
6381
6381
|
const transformed = def.reverseTransform(result2.value, result2);
|
|
6382
6382
|
if (transformed instanceof Promise) {
|
|
6383
|
-
return transformed.then((value) => handleCodecTxResult(result2, value, def.in,
|
|
6383
|
+
return transformed.then((value) => handleCodecTxResult(result2, value, def.in, ctx2));
|
|
6384
6384
|
}
|
|
6385
|
-
return handleCodecTxResult(result2, transformed, def.in,
|
|
6385
|
+
return handleCodecTxResult(result2, transformed, def.in, ctx2);
|
|
6386
6386
|
}
|
|
6387
6387
|
}
|
|
6388
|
-
function handleCodecTxResult(left, value, nextSchema,
|
|
6388
|
+
function handleCodecTxResult(left, value, nextSchema, ctx2) {
|
|
6389
6389
|
if (left.issues.length) {
|
|
6390
6390
|
left.aborted = true;
|
|
6391
6391
|
return left;
|
|
6392
6392
|
}
|
|
6393
|
-
return nextSchema._zod.run({ value, issues: left.issues },
|
|
6393
|
+
return nextSchema._zod.run({ value, issues: left.issues }, ctx2);
|
|
6394
6394
|
}
|
|
6395
6395
|
function handleReadonlyResult(payload) {
|
|
6396
6396
|
payload.value = Object.freeze(payload.value);
|
|
@@ -6445,7 +6445,7 @@ var init_schemas = __esm({
|
|
|
6445
6445
|
inst._zod.run = inst._zod.parse;
|
|
6446
6446
|
});
|
|
6447
6447
|
} else {
|
|
6448
|
-
const runChecks = (payload, checks2,
|
|
6448
|
+
const runChecks = (payload, checks2, ctx2) => {
|
|
6449
6449
|
let isAborted = aborted(payload);
|
|
6450
6450
|
let asyncResult;
|
|
6451
6451
|
for (const ch of checks2) {
|
|
@@ -6460,7 +6460,7 @@ var init_schemas = __esm({
|
|
|
6460
6460
|
}
|
|
6461
6461
|
const currLen = payload.issues.length;
|
|
6462
6462
|
const _ = ch._zod.check(payload);
|
|
6463
|
-
if (_ instanceof Promise &&
|
|
6463
|
+
if (_ instanceof Promise && ctx2?.async === false) {
|
|
6464
6464
|
throw new $ZodAsyncError();
|
|
6465
6465
|
}
|
|
6466
6466
|
if (asyncResult || _ instanceof Promise) {
|
|
@@ -6487,39 +6487,39 @@ var init_schemas = __esm({
|
|
|
6487
6487
|
}
|
|
6488
6488
|
return payload;
|
|
6489
6489
|
};
|
|
6490
|
-
const handleCanaryResult = (canary, payload,
|
|
6490
|
+
const handleCanaryResult = (canary, payload, ctx2) => {
|
|
6491
6491
|
if (aborted(canary)) {
|
|
6492
6492
|
canary.aborted = true;
|
|
6493
6493
|
return canary;
|
|
6494
6494
|
}
|
|
6495
|
-
const checkResult = runChecks(payload, checks,
|
|
6495
|
+
const checkResult = runChecks(payload, checks, ctx2);
|
|
6496
6496
|
if (checkResult instanceof Promise) {
|
|
6497
|
-
if (
|
|
6497
|
+
if (ctx2.async === false)
|
|
6498
6498
|
throw new $ZodAsyncError();
|
|
6499
|
-
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2,
|
|
6499
|
+
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx2));
|
|
6500
6500
|
}
|
|
6501
|
-
return inst._zod.parse(checkResult,
|
|
6501
|
+
return inst._zod.parse(checkResult, ctx2);
|
|
6502
6502
|
};
|
|
6503
|
-
inst._zod.run = (payload,
|
|
6504
|
-
if (
|
|
6505
|
-
return inst._zod.parse(payload,
|
|
6503
|
+
inst._zod.run = (payload, ctx2) => {
|
|
6504
|
+
if (ctx2.skipChecks) {
|
|
6505
|
+
return inst._zod.parse(payload, ctx2);
|
|
6506
6506
|
}
|
|
6507
|
-
if (
|
|
6508
|
-
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...
|
|
6507
|
+
if (ctx2.direction === "backward") {
|
|
6508
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx2, skipChecks: true });
|
|
6509
6509
|
if (canary instanceof Promise) {
|
|
6510
6510
|
return canary.then((canary2) => {
|
|
6511
|
-
return handleCanaryResult(canary2, payload,
|
|
6511
|
+
return handleCanaryResult(canary2, payload, ctx2);
|
|
6512
6512
|
});
|
|
6513
6513
|
}
|
|
6514
|
-
return handleCanaryResult(canary, payload,
|
|
6514
|
+
return handleCanaryResult(canary, payload, ctx2);
|
|
6515
6515
|
}
|
|
6516
|
-
const result2 = inst._zod.parse(payload,
|
|
6516
|
+
const result2 = inst._zod.parse(payload, ctx2);
|
|
6517
6517
|
if (result2 instanceof Promise) {
|
|
6518
|
-
if (
|
|
6518
|
+
if (ctx2.async === false)
|
|
6519
6519
|
throw new $ZodAsyncError();
|
|
6520
|
-
return result2.then((result3) => runChecks(result3, checks,
|
|
6520
|
+
return result2.then((result3) => runChecks(result3, checks, ctx2));
|
|
6521
6521
|
}
|
|
6522
|
-
return runChecks(result2, checks,
|
|
6522
|
+
return runChecks(result2, checks, ctx2);
|
|
6523
6523
|
};
|
|
6524
6524
|
}
|
|
6525
6525
|
defineLazy(inst, "~standard", () => ({
|
|
@@ -7002,7 +7002,7 @@ var init_schemas = __esm({
|
|
|
7002
7002
|
});
|
|
7003
7003
|
$ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
7004
7004
|
$ZodType.init(inst, def);
|
|
7005
|
-
inst._zod.parse = (payload,
|
|
7005
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7006
7006
|
const input = payload.value;
|
|
7007
7007
|
if (!Array.isArray(input)) {
|
|
7008
7008
|
payload.issues.push({
|
|
@@ -7020,7 +7020,7 @@ var init_schemas = __esm({
|
|
|
7020
7020
|
const result2 = def.element._zod.run({
|
|
7021
7021
|
value: item,
|
|
7022
7022
|
issues: []
|
|
7023
|
-
},
|
|
7023
|
+
}, ctx2);
|
|
7024
7024
|
if (result2 instanceof Promise) {
|
|
7025
7025
|
proms.push(result2.then((result3) => handleArrayResult(result3, payload, i)));
|
|
7026
7026
|
} else {
|
|
@@ -7065,7 +7065,7 @@ var init_schemas = __esm({
|
|
|
7065
7065
|
const isObject2 = isObject;
|
|
7066
7066
|
const catchall = def.catchall;
|
|
7067
7067
|
let value;
|
|
7068
|
-
inst._zod.parse = (payload,
|
|
7068
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7069
7069
|
value ?? (value = _normalized.value);
|
|
7070
7070
|
const input = payload.value;
|
|
7071
7071
|
if (!isObject2(input)) {
|
|
@@ -7084,7 +7084,7 @@ var init_schemas = __esm({
|
|
|
7084
7084
|
const el2 = shape[key2];
|
|
7085
7085
|
const isOptionalIn = el2._zod.optin === "optional";
|
|
7086
7086
|
const isOptionalOut = el2._zod.optout === "optional";
|
|
7087
|
-
const r = el2._zod.run({ value: input[key2], issues: [] },
|
|
7087
|
+
const r = el2._zod.run({ value: input[key2], issues: [] }, ctx2);
|
|
7088
7088
|
if (r instanceof Promise) {
|
|
7089
7089
|
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key2, input, isOptionalIn, isOptionalOut)));
|
|
7090
7090
|
} else {
|
|
@@ -7094,7 +7094,7 @@ var init_schemas = __esm({
|
|
|
7094
7094
|
if (!catchall) {
|
|
7095
7095
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
7096
7096
|
}
|
|
7097
|
-
return handleCatchall(proms, input, payload,
|
|
7097
|
+
return handleCatchall(proms, input, payload, ctx2, _normalized.value, inst);
|
|
7098
7098
|
};
|
|
7099
7099
|
});
|
|
7100
7100
|
$ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
@@ -7192,7 +7192,7 @@ var init_schemas = __esm({
|
|
|
7192
7192
|
doc.write(`payload.value = newResult;`);
|
|
7193
7193
|
doc.write(`return payload;`);
|
|
7194
7194
|
const fn = doc.compile();
|
|
7195
|
-
return (payload,
|
|
7195
|
+
return (payload, ctx2) => fn(shape, payload, ctx2);
|
|
7196
7196
|
};
|
|
7197
7197
|
let fastpass;
|
|
7198
7198
|
const isObject2 = isObject;
|
|
@@ -7201,7 +7201,7 @@ var init_schemas = __esm({
|
|
|
7201
7201
|
const fastEnabled = jit && allowsEval2.value;
|
|
7202
7202
|
const catchall = def.catchall;
|
|
7203
7203
|
let value;
|
|
7204
|
-
inst._zod.parse = (payload,
|
|
7204
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7205
7205
|
value ?? (value = _normalized.value);
|
|
7206
7206
|
const input = payload.value;
|
|
7207
7207
|
if (!isObject2(input)) {
|
|
@@ -7213,15 +7213,15 @@ var init_schemas = __esm({
|
|
|
7213
7213
|
});
|
|
7214
7214
|
return payload;
|
|
7215
7215
|
}
|
|
7216
|
-
if (jit && fastEnabled &&
|
|
7216
|
+
if (jit && fastEnabled && ctx2?.async === false && ctx2.jitless !== true) {
|
|
7217
7217
|
if (!fastpass)
|
|
7218
7218
|
fastpass = generateFastpass(def.shape);
|
|
7219
|
-
payload = fastpass(payload,
|
|
7219
|
+
payload = fastpass(payload, ctx2);
|
|
7220
7220
|
if (!catchall)
|
|
7221
7221
|
return payload;
|
|
7222
|
-
return handleCatchall([], input, payload,
|
|
7222
|
+
return handleCatchall([], input, payload, ctx2, value, inst);
|
|
7223
7223
|
}
|
|
7224
|
-
return superParse(payload,
|
|
7224
|
+
return superParse(payload, ctx2);
|
|
7225
7225
|
};
|
|
7226
7226
|
});
|
|
7227
7227
|
$ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
@@ -7242,9 +7242,9 @@ var init_schemas = __esm({
|
|
|
7242
7242
|
return void 0;
|
|
7243
7243
|
});
|
|
7244
7244
|
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
7245
|
-
inst._zod.parse = (payload,
|
|
7245
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7246
7246
|
if (first) {
|
|
7247
|
-
return first(payload,
|
|
7247
|
+
return first(payload, ctx2);
|
|
7248
7248
|
}
|
|
7249
7249
|
let async = false;
|
|
7250
7250
|
const results = [];
|
|
@@ -7252,7 +7252,7 @@ var init_schemas = __esm({
|
|
|
7252
7252
|
const result2 = option._zod.run({
|
|
7253
7253
|
value: payload.value,
|
|
7254
7254
|
issues: []
|
|
7255
|
-
},
|
|
7255
|
+
}, ctx2);
|
|
7256
7256
|
if (result2 instanceof Promise) {
|
|
7257
7257
|
results.push(result2);
|
|
7258
7258
|
async = true;
|
|
@@ -7263,9 +7263,9 @@ var init_schemas = __esm({
|
|
|
7263
7263
|
}
|
|
7264
7264
|
}
|
|
7265
7265
|
if (!async)
|
|
7266
|
-
return handleUnionResults(results, payload, inst,
|
|
7266
|
+
return handleUnionResults(results, payload, inst, ctx2);
|
|
7267
7267
|
return Promise.all(results).then((results2) => {
|
|
7268
|
-
return handleUnionResults(results2, payload, inst,
|
|
7268
|
+
return handleUnionResults(results2, payload, inst, ctx2);
|
|
7269
7269
|
});
|
|
7270
7270
|
};
|
|
7271
7271
|
});
|
|
@@ -7273,9 +7273,9 @@ var init_schemas = __esm({
|
|
|
7273
7273
|
$ZodUnion.init(inst, def);
|
|
7274
7274
|
def.inclusive = false;
|
|
7275
7275
|
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
7276
|
-
inst._zod.parse = (payload,
|
|
7276
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7277
7277
|
if (first) {
|
|
7278
|
-
return first(payload,
|
|
7278
|
+
return first(payload, ctx2);
|
|
7279
7279
|
}
|
|
7280
7280
|
let async = false;
|
|
7281
7281
|
const results = [];
|
|
@@ -7283,7 +7283,7 @@ var init_schemas = __esm({
|
|
|
7283
7283
|
const result2 = option._zod.run({
|
|
7284
7284
|
value: payload.value,
|
|
7285
7285
|
issues: []
|
|
7286
|
-
},
|
|
7286
|
+
}, ctx2);
|
|
7287
7287
|
if (result2 instanceof Promise) {
|
|
7288
7288
|
results.push(result2);
|
|
7289
7289
|
async = true;
|
|
@@ -7292,9 +7292,9 @@ var init_schemas = __esm({
|
|
|
7292
7292
|
}
|
|
7293
7293
|
}
|
|
7294
7294
|
if (!async)
|
|
7295
|
-
return handleExclusiveUnionResults(results, payload, inst,
|
|
7295
|
+
return handleExclusiveUnionResults(results, payload, inst, ctx2);
|
|
7296
7296
|
return Promise.all(results).then((results2) => {
|
|
7297
|
-
return handleExclusiveUnionResults(results2, payload, inst,
|
|
7297
|
+
return handleExclusiveUnionResults(results2, payload, inst, ctx2);
|
|
7298
7298
|
});
|
|
7299
7299
|
};
|
|
7300
7300
|
});
|
|
@@ -7334,7 +7334,7 @@ var init_schemas = __esm({
|
|
|
7334
7334
|
}
|
|
7335
7335
|
return map2;
|
|
7336
7336
|
});
|
|
7337
|
-
inst._zod.parse = (payload,
|
|
7337
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7338
7338
|
const input = payload.value;
|
|
7339
7339
|
if (!isObject(input)) {
|
|
7340
7340
|
payload.issues.push({
|
|
@@ -7347,10 +7347,10 @@ var init_schemas = __esm({
|
|
|
7347
7347
|
}
|
|
7348
7348
|
const opt = disc.value.get(input?.[def.discriminator]);
|
|
7349
7349
|
if (opt) {
|
|
7350
|
-
return opt._zod.run(payload,
|
|
7350
|
+
return opt._zod.run(payload, ctx2);
|
|
7351
7351
|
}
|
|
7352
|
-
if (def.unionFallback ||
|
|
7353
|
-
return _super(payload,
|
|
7352
|
+
if (def.unionFallback || ctx2.direction === "backward") {
|
|
7353
|
+
return _super(payload, ctx2);
|
|
7354
7354
|
}
|
|
7355
7355
|
payload.issues.push({
|
|
7356
7356
|
code: "invalid_union",
|
|
@@ -7367,10 +7367,10 @@ var init_schemas = __esm({
|
|
|
7367
7367
|
});
|
|
7368
7368
|
$ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
7369
7369
|
$ZodType.init(inst, def);
|
|
7370
|
-
inst._zod.parse = (payload,
|
|
7370
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7371
7371
|
const input = payload.value;
|
|
7372
|
-
const left = def.left._zod.run({ value: input, issues: [] },
|
|
7373
|
-
const right = def.right._zod.run({ value: input, issues: [] },
|
|
7372
|
+
const left = def.left._zod.run({ value: input, issues: [] }, ctx2);
|
|
7373
|
+
const right = def.right._zod.run({ value: input, issues: [] }, ctx2);
|
|
7374
7374
|
const async = left instanceof Promise || right instanceof Promise;
|
|
7375
7375
|
if (async) {
|
|
7376
7376
|
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
@@ -7383,7 +7383,7 @@ var init_schemas = __esm({
|
|
|
7383
7383
|
$ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
7384
7384
|
$ZodType.init(inst, def);
|
|
7385
7385
|
const items = def.items;
|
|
7386
|
-
inst._zod.parse = (payload,
|
|
7386
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7387
7387
|
const input = payload.value;
|
|
7388
7388
|
if (!Array.isArray(input)) {
|
|
7389
7389
|
payload.issues.push({
|
|
@@ -7423,7 +7423,7 @@ var init_schemas = __esm({
|
|
|
7423
7423
|
}
|
|
7424
7424
|
const itemResults = new Array(items.length);
|
|
7425
7425
|
for (let i = 0; i < items.length; i++) {
|
|
7426
|
-
const r = items[i]._zod.run({ value: input[i], issues: [] },
|
|
7426
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx2);
|
|
7427
7427
|
if (r instanceof Promise) {
|
|
7428
7428
|
proms.push(r.then((rr) => {
|
|
7429
7429
|
itemResults[i] = rr;
|
|
@@ -7437,7 +7437,7 @@ var init_schemas = __esm({
|
|
|
7437
7437
|
const rest = input.slice(items.length);
|
|
7438
7438
|
for (const el2 of rest) {
|
|
7439
7439
|
i++;
|
|
7440
|
-
const result2 = def.rest._zod.run({ value: el2, issues: [] },
|
|
7440
|
+
const result2 = def.rest._zod.run({ value: el2, issues: [] }, ctx2);
|
|
7441
7441
|
if (result2 instanceof Promise) {
|
|
7442
7442
|
proms.push(result2.then((r) => handleTupleResult(r, payload, i)));
|
|
7443
7443
|
} else {
|
|
@@ -7453,7 +7453,7 @@ var init_schemas = __esm({
|
|
|
7453
7453
|
});
|
|
7454
7454
|
$ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
7455
7455
|
$ZodType.init(inst, def);
|
|
7456
|
-
inst._zod.parse = (payload,
|
|
7456
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7457
7457
|
const input = payload.value;
|
|
7458
7458
|
if (!isPlainObject(input)) {
|
|
7459
7459
|
payload.issues.push({
|
|
@@ -7472,7 +7472,7 @@ var init_schemas = __esm({
|
|
|
7472
7472
|
for (const key2 of values) {
|
|
7473
7473
|
if (typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol") {
|
|
7474
7474
|
recordKeys.add(typeof key2 === "number" ? key2.toString() : key2);
|
|
7475
|
-
const keyResult = def.keyType._zod.run({ value: key2, issues: [] },
|
|
7475
|
+
const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx2);
|
|
7476
7476
|
if (keyResult instanceof Promise) {
|
|
7477
7477
|
throw new Error("Async schemas not supported in object keys currently");
|
|
7478
7478
|
}
|
|
@@ -7480,7 +7480,7 @@ var init_schemas = __esm({
|
|
|
7480
7480
|
payload.issues.push({
|
|
7481
7481
|
code: "invalid_key",
|
|
7482
7482
|
origin: "record",
|
|
7483
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss,
|
|
7483
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config())),
|
|
7484
7484
|
input: key2,
|
|
7485
7485
|
path: [key2],
|
|
7486
7486
|
inst
|
|
@@ -7488,7 +7488,7 @@ var init_schemas = __esm({
|
|
|
7488
7488
|
continue;
|
|
7489
7489
|
}
|
|
7490
7490
|
const outKey = keyResult.value;
|
|
7491
|
-
const result2 = def.valueType._zod.run({ value: input[key2], issues: [] },
|
|
7491
|
+
const result2 = def.valueType._zod.run({ value: input[key2], issues: [] }, ctx2);
|
|
7492
7492
|
if (result2 instanceof Promise) {
|
|
7493
7493
|
proms.push(result2.then((result3) => {
|
|
7494
7494
|
if (result3.issues.length) {
|
|
@@ -7526,13 +7526,13 @@ var init_schemas = __esm({
|
|
|
7526
7526
|
continue;
|
|
7527
7527
|
if (!Object.prototype.propertyIsEnumerable.call(input, key2))
|
|
7528
7528
|
continue;
|
|
7529
|
-
let keyResult = def.keyType._zod.run({ value: key2, issues: [] },
|
|
7529
|
+
let keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx2);
|
|
7530
7530
|
if (keyResult instanceof Promise) {
|
|
7531
7531
|
throw new Error("Async schemas not supported in object keys currently");
|
|
7532
7532
|
}
|
|
7533
7533
|
const checkNumericKey = typeof key2 === "string" && number.test(key2) && keyResult.issues.length;
|
|
7534
7534
|
if (checkNumericKey) {
|
|
7535
|
-
const retryResult = def.keyType._zod.run({ value: Number(key2), issues: [] },
|
|
7535
|
+
const retryResult = def.keyType._zod.run({ value: Number(key2), issues: [] }, ctx2);
|
|
7536
7536
|
if (retryResult instanceof Promise) {
|
|
7537
7537
|
throw new Error("Async schemas not supported in object keys currently");
|
|
7538
7538
|
}
|
|
@@ -7547,7 +7547,7 @@ var init_schemas = __esm({
|
|
|
7547
7547
|
payload.issues.push({
|
|
7548
7548
|
code: "invalid_key",
|
|
7549
7549
|
origin: "record",
|
|
7550
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss,
|
|
7550
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config())),
|
|
7551
7551
|
input: key2,
|
|
7552
7552
|
path: [key2],
|
|
7553
7553
|
inst
|
|
@@ -7555,7 +7555,7 @@ var init_schemas = __esm({
|
|
|
7555
7555
|
}
|
|
7556
7556
|
continue;
|
|
7557
7557
|
}
|
|
7558
|
-
const result2 = def.valueType._zod.run({ value: input[key2], issues: [] },
|
|
7558
|
+
const result2 = def.valueType._zod.run({ value: input[key2], issues: [] }, ctx2);
|
|
7559
7559
|
if (result2 instanceof Promise) {
|
|
7560
7560
|
proms.push(result2.then((result3) => {
|
|
7561
7561
|
if (result3.issues.length) {
|
|
@@ -7579,7 +7579,7 @@ var init_schemas = __esm({
|
|
|
7579
7579
|
});
|
|
7580
7580
|
$ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
7581
7581
|
$ZodType.init(inst, def);
|
|
7582
|
-
inst._zod.parse = (payload,
|
|
7582
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7583
7583
|
const input = payload.value;
|
|
7584
7584
|
if (!(input instanceof Map)) {
|
|
7585
7585
|
payload.issues.push({
|
|
@@ -7593,14 +7593,14 @@ var init_schemas = __esm({
|
|
|
7593
7593
|
const proms = [];
|
|
7594
7594
|
payload.value = /* @__PURE__ */ new Map();
|
|
7595
7595
|
for (const [key2, value] of input) {
|
|
7596
|
-
const keyResult = def.keyType._zod.run({ value: key2, issues: [] },
|
|
7597
|
-
const valueResult = def.valueType._zod.run({ value, issues: [] },
|
|
7596
|
+
const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx2);
|
|
7597
|
+
const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx2);
|
|
7598
7598
|
if (keyResult instanceof Promise || valueResult instanceof Promise) {
|
|
7599
7599
|
proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
|
|
7600
|
-
handleMapResult(keyResult2, valueResult2, payload, key2, input, inst,
|
|
7600
|
+
handleMapResult(keyResult2, valueResult2, payload, key2, input, inst, ctx2);
|
|
7601
7601
|
}));
|
|
7602
7602
|
} else {
|
|
7603
|
-
handleMapResult(keyResult, valueResult, payload, key2, input, inst,
|
|
7603
|
+
handleMapResult(keyResult, valueResult, payload, key2, input, inst, ctx2);
|
|
7604
7604
|
}
|
|
7605
7605
|
}
|
|
7606
7606
|
if (proms.length)
|
|
@@ -7610,7 +7610,7 @@ var init_schemas = __esm({
|
|
|
7610
7610
|
});
|
|
7611
7611
|
$ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
7612
7612
|
$ZodType.init(inst, def);
|
|
7613
|
-
inst._zod.parse = (payload,
|
|
7613
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7614
7614
|
const input = payload.value;
|
|
7615
7615
|
if (!(input instanceof Set)) {
|
|
7616
7616
|
payload.issues.push({
|
|
@@ -7624,7 +7624,7 @@ var init_schemas = __esm({
|
|
|
7624
7624
|
const proms = [];
|
|
7625
7625
|
payload.value = /* @__PURE__ */ new Set();
|
|
7626
7626
|
for (const item of input) {
|
|
7627
|
-
const result2 = def.valueType._zod.run({ value: item, issues: [] },
|
|
7627
|
+
const result2 = def.valueType._zod.run({ value: item, issues: [] }, ctx2);
|
|
7628
7628
|
if (result2 instanceof Promise) {
|
|
7629
7629
|
proms.push(result2.then((result3) => handleSetResult(result3, payload)));
|
|
7630
7630
|
} else
|
|
@@ -7695,12 +7695,12 @@ var init_schemas = __esm({
|
|
|
7695
7695
|
$ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
7696
7696
|
$ZodType.init(inst, def);
|
|
7697
7697
|
inst._zod.optin = "optional";
|
|
7698
|
-
inst._zod.parse = (payload,
|
|
7699
|
-
if (
|
|
7698
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7699
|
+
if (ctx2.direction === "backward") {
|
|
7700
7700
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
7701
7701
|
}
|
|
7702
7702
|
const _out = def.transform(payload.value, payload);
|
|
7703
|
-
if (
|
|
7703
|
+
if (ctx2.async) {
|
|
7704
7704
|
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
7705
7705
|
return output.then((output2) => {
|
|
7706
7706
|
payload.value = output2;
|
|
@@ -7727,10 +7727,10 @@ var init_schemas = __esm({
|
|
|
7727
7727
|
const pattern = def.innerType._zod.pattern;
|
|
7728
7728
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
7729
7729
|
});
|
|
7730
|
-
inst._zod.parse = (payload,
|
|
7730
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7731
7731
|
if (def.innerType._zod.optin === "optional") {
|
|
7732
7732
|
const input = payload.value;
|
|
7733
|
-
const result2 = def.innerType._zod.run(payload,
|
|
7733
|
+
const result2 = def.innerType._zod.run(payload, ctx2);
|
|
7734
7734
|
if (result2 instanceof Promise)
|
|
7735
7735
|
return result2.then((r) => handleOptionalResult(r, input));
|
|
7736
7736
|
return handleOptionalResult(result2, input);
|
|
@@ -7738,15 +7738,15 @@ var init_schemas = __esm({
|
|
|
7738
7738
|
if (payload.value === void 0) {
|
|
7739
7739
|
return payload;
|
|
7740
7740
|
}
|
|
7741
|
-
return def.innerType._zod.run(payload,
|
|
7741
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7742
7742
|
};
|
|
7743
7743
|
});
|
|
7744
7744
|
$ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
7745
7745
|
$ZodOptional.init(inst, def);
|
|
7746
7746
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7747
7747
|
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
7748
|
-
inst._zod.parse = (payload,
|
|
7749
|
-
return def.innerType._zod.run(payload,
|
|
7748
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7749
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7750
7750
|
};
|
|
7751
7751
|
});
|
|
7752
7752
|
$ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
@@ -7760,25 +7760,25 @@ var init_schemas = __esm({
|
|
|
7760
7760
|
defineLazy(inst._zod, "values", () => {
|
|
7761
7761
|
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
7762
7762
|
});
|
|
7763
|
-
inst._zod.parse = (payload,
|
|
7763
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7764
7764
|
if (payload.value === null)
|
|
7765
7765
|
return payload;
|
|
7766
|
-
return def.innerType._zod.run(payload,
|
|
7766
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7767
7767
|
};
|
|
7768
7768
|
});
|
|
7769
7769
|
$ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
7770
7770
|
$ZodType.init(inst, def);
|
|
7771
7771
|
inst._zod.optin = "optional";
|
|
7772
7772
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7773
|
-
inst._zod.parse = (payload,
|
|
7774
|
-
if (
|
|
7775
|
-
return def.innerType._zod.run(payload,
|
|
7773
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7774
|
+
if (ctx2.direction === "backward") {
|
|
7775
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7776
7776
|
}
|
|
7777
7777
|
if (payload.value === void 0) {
|
|
7778
7778
|
payload.value = def.defaultValue;
|
|
7779
7779
|
return payload;
|
|
7780
7780
|
}
|
|
7781
|
-
const result2 = def.innerType._zod.run(payload,
|
|
7781
|
+
const result2 = def.innerType._zod.run(payload, ctx2);
|
|
7782
7782
|
if (result2 instanceof Promise) {
|
|
7783
7783
|
return result2.then((result3) => handleDefaultResult(result3, def));
|
|
7784
7784
|
}
|
|
@@ -7789,14 +7789,14 @@ var init_schemas = __esm({
|
|
|
7789
7789
|
$ZodType.init(inst, def);
|
|
7790
7790
|
inst._zod.optin = "optional";
|
|
7791
7791
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7792
|
-
inst._zod.parse = (payload,
|
|
7793
|
-
if (
|
|
7794
|
-
return def.innerType._zod.run(payload,
|
|
7792
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7793
|
+
if (ctx2.direction === "backward") {
|
|
7794
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7795
7795
|
}
|
|
7796
7796
|
if (payload.value === void 0) {
|
|
7797
7797
|
payload.value = def.defaultValue;
|
|
7798
7798
|
}
|
|
7799
|
-
return def.innerType._zod.run(payload,
|
|
7799
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7800
7800
|
};
|
|
7801
7801
|
});
|
|
7802
7802
|
$ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
@@ -7805,8 +7805,8 @@ var init_schemas = __esm({
|
|
|
7805
7805
|
const v = def.innerType._zod.values;
|
|
7806
7806
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
7807
7807
|
});
|
|
7808
|
-
inst._zod.parse = (payload,
|
|
7809
|
-
const result2 = def.innerType._zod.run(payload,
|
|
7808
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7809
|
+
const result2 = def.innerType._zod.run(payload, ctx2);
|
|
7810
7810
|
if (result2 instanceof Promise) {
|
|
7811
7811
|
return result2.then((result3) => handleNonOptionalResult(result3, inst));
|
|
7812
7812
|
}
|
|
@@ -7815,11 +7815,11 @@ var init_schemas = __esm({
|
|
|
7815
7815
|
});
|
|
7816
7816
|
$ZodSuccess = /* @__PURE__ */ $constructor("$ZodSuccess", (inst, def) => {
|
|
7817
7817
|
$ZodType.init(inst, def);
|
|
7818
|
-
inst._zod.parse = (payload,
|
|
7819
|
-
if (
|
|
7818
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7819
|
+
if (ctx2.direction === "backward") {
|
|
7820
7820
|
throw new $ZodEncodeError("ZodSuccess");
|
|
7821
7821
|
}
|
|
7822
|
-
const result2 = def.innerType._zod.run(payload,
|
|
7822
|
+
const result2 = def.innerType._zod.run(payload, ctx2);
|
|
7823
7823
|
if (result2 instanceof Promise) {
|
|
7824
7824
|
return result2.then((result3) => {
|
|
7825
7825
|
payload.value = result3.issues.length === 0;
|
|
@@ -7835,11 +7835,11 @@ var init_schemas = __esm({
|
|
|
7835
7835
|
inst._zod.optin = "optional";
|
|
7836
7836
|
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
7837
7837
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7838
|
-
inst._zod.parse = (payload,
|
|
7839
|
-
if (
|
|
7840
|
-
return def.innerType._zod.run(payload,
|
|
7838
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7839
|
+
if (ctx2.direction === "backward") {
|
|
7840
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7841
7841
|
}
|
|
7842
|
-
const result2 = def.innerType._zod.run(payload,
|
|
7842
|
+
const result2 = def.innerType._zod.run(payload, ctx2);
|
|
7843
7843
|
if (result2 instanceof Promise) {
|
|
7844
7844
|
return result2.then((result3) => {
|
|
7845
7845
|
payload.value = result3.value;
|
|
@@ -7847,7 +7847,7 @@ var init_schemas = __esm({
|
|
|
7847
7847
|
payload.value = def.catchValue({
|
|
7848
7848
|
...payload,
|
|
7849
7849
|
error: {
|
|
7850
|
-
issues: result3.issues.map((iss) => finalizeIssue(iss,
|
|
7850
|
+
issues: result3.issues.map((iss) => finalizeIssue(iss, ctx2, config()))
|
|
7851
7851
|
},
|
|
7852
7852
|
input: payload.value
|
|
7853
7853
|
});
|
|
@@ -7862,7 +7862,7 @@ var init_schemas = __esm({
|
|
|
7862
7862
|
payload.value = def.catchValue({
|
|
7863
7863
|
...payload,
|
|
7864
7864
|
error: {
|
|
7865
|
-
issues: result2.issues.map((iss) => finalizeIssue(iss,
|
|
7865
|
+
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config()))
|
|
7866
7866
|
},
|
|
7867
7867
|
input: payload.value
|
|
7868
7868
|
});
|
|
@@ -7893,19 +7893,19 @@ var init_schemas = __esm({
|
|
|
7893
7893
|
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
7894
7894
|
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
7895
7895
|
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
7896
|
-
inst._zod.parse = (payload,
|
|
7897
|
-
if (
|
|
7898
|
-
const right = def.out._zod.run(payload,
|
|
7896
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7897
|
+
if (ctx2.direction === "backward") {
|
|
7898
|
+
const right = def.out._zod.run(payload, ctx2);
|
|
7899
7899
|
if (right instanceof Promise) {
|
|
7900
|
-
return right.then((right2) => handlePipeResult(right2, def.in,
|
|
7900
|
+
return right.then((right2) => handlePipeResult(right2, def.in, ctx2));
|
|
7901
7901
|
}
|
|
7902
|
-
return handlePipeResult(right, def.in,
|
|
7902
|
+
return handlePipeResult(right, def.in, ctx2);
|
|
7903
7903
|
}
|
|
7904
|
-
const left = def.in._zod.run(payload,
|
|
7904
|
+
const left = def.in._zod.run(payload, ctx2);
|
|
7905
7905
|
if (left instanceof Promise) {
|
|
7906
|
-
return left.then((left2) => handlePipeResult(left2, def.out,
|
|
7906
|
+
return left.then((left2) => handlePipeResult(left2, def.out, ctx2));
|
|
7907
7907
|
}
|
|
7908
|
-
return handlePipeResult(left, def.out,
|
|
7908
|
+
return handlePipeResult(left, def.out, ctx2);
|
|
7909
7909
|
};
|
|
7910
7910
|
});
|
|
7911
7911
|
$ZodCodec = /* @__PURE__ */ $constructor("$ZodCodec", (inst, def) => {
|
|
@@ -7914,20 +7914,20 @@ var init_schemas = __esm({
|
|
|
7914
7914
|
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
7915
7915
|
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
7916
7916
|
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
7917
|
-
inst._zod.parse = (payload,
|
|
7918
|
-
const direction =
|
|
7917
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7918
|
+
const direction = ctx2.direction || "forward";
|
|
7919
7919
|
if (direction === "forward") {
|
|
7920
|
-
const left = def.in._zod.run(payload,
|
|
7920
|
+
const left = def.in._zod.run(payload, ctx2);
|
|
7921
7921
|
if (left instanceof Promise) {
|
|
7922
|
-
return left.then((left2) => handleCodecAResult(left2, def,
|
|
7922
|
+
return left.then((left2) => handleCodecAResult(left2, def, ctx2));
|
|
7923
7923
|
}
|
|
7924
|
-
return handleCodecAResult(left, def,
|
|
7924
|
+
return handleCodecAResult(left, def, ctx2);
|
|
7925
7925
|
} else {
|
|
7926
|
-
const right = def.out._zod.run(payload,
|
|
7926
|
+
const right = def.out._zod.run(payload, ctx2);
|
|
7927
7927
|
if (right instanceof Promise) {
|
|
7928
|
-
return right.then((right2) => handleCodecAResult(right2, def,
|
|
7928
|
+
return right.then((right2) => handleCodecAResult(right2, def, ctx2));
|
|
7929
7929
|
}
|
|
7930
|
-
return handleCodecAResult(right, def,
|
|
7930
|
+
return handleCodecAResult(right, def, ctx2);
|
|
7931
7931
|
}
|
|
7932
7932
|
};
|
|
7933
7933
|
});
|
|
@@ -7940,11 +7940,11 @@ var init_schemas = __esm({
|
|
|
7940
7940
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
7941
7941
|
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
7942
7942
|
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
7943
|
-
inst._zod.parse = (payload,
|
|
7944
|
-
if (
|
|
7945
|
-
return def.innerType._zod.run(payload,
|
|
7943
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
7944
|
+
if (ctx2.direction === "backward") {
|
|
7945
|
+
return def.innerType._zod.run(payload, ctx2);
|
|
7946
7946
|
}
|
|
7947
|
-
const result2 = def.innerType._zod.run(payload,
|
|
7947
|
+
const result2 = def.innerType._zod.run(payload, ctx2);
|
|
7948
7948
|
if (result2 instanceof Promise) {
|
|
7949
7949
|
return result2.then(handleReadonlyResult);
|
|
7950
7950
|
}
|
|
@@ -8075,8 +8075,8 @@ var init_schemas = __esm({
|
|
|
8075
8075
|
});
|
|
8076
8076
|
$ZodPromise = /* @__PURE__ */ $constructor("$ZodPromise", (inst, def) => {
|
|
8077
8077
|
$ZodType.init(inst, def);
|
|
8078
|
-
inst._zod.parse = (payload,
|
|
8079
|
-
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] },
|
|
8078
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
8079
|
+
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx2));
|
|
8080
8080
|
};
|
|
8081
8081
|
});
|
|
8082
8082
|
$ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
|
|
@@ -8091,9 +8091,9 @@ var init_schemas = __esm({
|
|
|
8091
8091
|
defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
|
|
8092
8092
|
defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
|
|
8093
8093
|
defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
|
|
8094
|
-
inst._zod.parse = (payload,
|
|
8094
|
+
inst._zod.parse = (payload, ctx2) => {
|
|
8095
8095
|
const inner = inst._zod.innerType;
|
|
8096
|
-
return inner._zod.run(payload,
|
|
8096
|
+
return inner._zod.run(payload, ctx2);
|
|
8097
8097
|
};
|
|
8098
8098
|
});
|
|
8099
8099
|
$ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -15560,10 +15560,10 @@ function initializeContext(params) {
|
|
|
15560
15560
|
external: params?.external ?? void 0
|
|
15561
15561
|
};
|
|
15562
15562
|
}
|
|
15563
|
-
function process2(schema,
|
|
15563
|
+
function process2(schema, ctx2, _params = { path: [], schemaPath: [] }) {
|
|
15564
15564
|
var _a3;
|
|
15565
15565
|
const def = schema._zod.def;
|
|
15566
|
-
const seen =
|
|
15566
|
+
const seen = ctx2.seen.get(schema);
|
|
15567
15567
|
if (seen) {
|
|
15568
15568
|
seen.count++;
|
|
15569
15569
|
const isCycle = _params.schemaPath.includes(schema);
|
|
@@ -15573,7 +15573,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
15573
15573
|
return seen.schema;
|
|
15574
15574
|
}
|
|
15575
15575
|
const result2 = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
15576
|
-
|
|
15576
|
+
ctx2.seen.set(schema, result2);
|
|
15577
15577
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
15578
15578
|
if (overrideSchema) {
|
|
15579
15579
|
result2.schema = overrideSchema;
|
|
@@ -15584,43 +15584,43 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
15584
15584
|
path: _params.path
|
|
15585
15585
|
};
|
|
15586
15586
|
if (schema._zod.processJSONSchema) {
|
|
15587
|
-
schema._zod.processJSONSchema(
|
|
15587
|
+
schema._zod.processJSONSchema(ctx2, result2.schema, params);
|
|
15588
15588
|
} else {
|
|
15589
15589
|
const _json = result2.schema;
|
|
15590
|
-
const processor =
|
|
15590
|
+
const processor = ctx2.processors[def.type];
|
|
15591
15591
|
if (!processor) {
|
|
15592
15592
|
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
15593
15593
|
}
|
|
15594
|
-
processor(schema,
|
|
15594
|
+
processor(schema, ctx2, _json, params);
|
|
15595
15595
|
}
|
|
15596
15596
|
const parent = schema._zod.parent;
|
|
15597
15597
|
if (parent) {
|
|
15598
15598
|
if (!result2.ref)
|
|
15599
15599
|
result2.ref = parent;
|
|
15600
|
-
process2(parent,
|
|
15601
|
-
|
|
15600
|
+
process2(parent, ctx2, params);
|
|
15601
|
+
ctx2.seen.get(parent).isParent = true;
|
|
15602
15602
|
}
|
|
15603
15603
|
}
|
|
15604
|
-
const meta4 =
|
|
15604
|
+
const meta4 = ctx2.metadataRegistry.get(schema);
|
|
15605
15605
|
if (meta4)
|
|
15606
15606
|
Object.assign(result2.schema, meta4);
|
|
15607
|
-
if (
|
|
15607
|
+
if (ctx2.io === "input" && isTransforming(schema)) {
|
|
15608
15608
|
delete result2.schema.examples;
|
|
15609
15609
|
delete result2.schema.default;
|
|
15610
15610
|
}
|
|
15611
|
-
if (
|
|
15611
|
+
if (ctx2.io === "input" && "_prefault" in result2.schema)
|
|
15612
15612
|
(_a3 = result2.schema).default ?? (_a3.default = result2.schema._prefault);
|
|
15613
15613
|
delete result2.schema._prefault;
|
|
15614
|
-
const _result =
|
|
15614
|
+
const _result = ctx2.seen.get(schema);
|
|
15615
15615
|
return _result.schema;
|
|
15616
15616
|
}
|
|
15617
|
-
function extractDefs(
|
|
15618
|
-
const root =
|
|
15617
|
+
function extractDefs(ctx2, schema) {
|
|
15618
|
+
const root = ctx2.seen.get(schema);
|
|
15619
15619
|
if (!root)
|
|
15620
15620
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
15621
15621
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
15622
|
-
for (const entry of
|
|
15623
|
-
const id =
|
|
15622
|
+
for (const entry of ctx2.seen.entries()) {
|
|
15623
|
+
const id = ctx2.metadataRegistry.get(entry[0])?.id;
|
|
15624
15624
|
if (id) {
|
|
15625
15625
|
const existing = idToSchema.get(id);
|
|
15626
15626
|
if (existing && existing !== entry[0]) {
|
|
@@ -15630,14 +15630,14 @@ function extractDefs(ctx, schema) {
|
|
|
15630
15630
|
}
|
|
15631
15631
|
}
|
|
15632
15632
|
const makeURI = (entry) => {
|
|
15633
|
-
const defsSegment =
|
|
15634
|
-
if (
|
|
15635
|
-
const externalId =
|
|
15636
|
-
const uriGenerator =
|
|
15633
|
+
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
15634
|
+
if (ctx2.external) {
|
|
15635
|
+
const externalId = ctx2.external.registry.get(entry[0])?.id;
|
|
15636
|
+
const uriGenerator = ctx2.external.uri ?? ((id2) => id2);
|
|
15637
15637
|
if (externalId) {
|
|
15638
15638
|
return { ref: uriGenerator(externalId) };
|
|
15639
15639
|
}
|
|
15640
|
-
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${
|
|
15640
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx2.counter++}`;
|
|
15641
15641
|
entry[1].defId = id;
|
|
15642
15642
|
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
15643
15643
|
}
|
|
@@ -15646,7 +15646,7 @@ function extractDefs(ctx, schema) {
|
|
|
15646
15646
|
}
|
|
15647
15647
|
const uriPrefix = `#`;
|
|
15648
15648
|
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
15649
|
-
const defId = entry[1].schema.id ?? `__schema${
|
|
15649
|
+
const defId = entry[1].schema.id ?? `__schema${ctx2.counter++}`;
|
|
15650
15650
|
return { defId, ref: defUriPrefix + defId };
|
|
15651
15651
|
};
|
|
15652
15652
|
const extractToDef = (entry) => {
|
|
@@ -15664,8 +15664,8 @@ function extractDefs(ctx, schema) {
|
|
|
15664
15664
|
}
|
|
15665
15665
|
schema2.$ref = ref;
|
|
15666
15666
|
};
|
|
15667
|
-
if (
|
|
15668
|
-
for (const entry of
|
|
15667
|
+
if (ctx2.cycles === "throw") {
|
|
15668
|
+
for (const entry of ctx2.seen.entries()) {
|
|
15669
15669
|
const seen = entry[1];
|
|
15670
15670
|
if (seen.cycle) {
|
|
15671
15671
|
throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
@@ -15674,20 +15674,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15674
15674
|
}
|
|
15675
15675
|
}
|
|
15676
15676
|
}
|
|
15677
|
-
for (const entry of
|
|
15677
|
+
for (const entry of ctx2.seen.entries()) {
|
|
15678
15678
|
const seen = entry[1];
|
|
15679
15679
|
if (schema === entry[0]) {
|
|
15680
15680
|
extractToDef(entry);
|
|
15681
15681
|
continue;
|
|
15682
15682
|
}
|
|
15683
|
-
if (
|
|
15684
|
-
const ext =
|
|
15683
|
+
if (ctx2.external) {
|
|
15684
|
+
const ext = ctx2.external.registry.get(entry[0])?.id;
|
|
15685
15685
|
if (schema !== entry[0] && ext) {
|
|
15686
15686
|
extractToDef(entry);
|
|
15687
15687
|
continue;
|
|
15688
15688
|
}
|
|
15689
15689
|
}
|
|
15690
|
-
const id =
|
|
15690
|
+
const id = ctx2.metadataRegistry.get(entry[0])?.id;
|
|
15691
15691
|
if (id) {
|
|
15692
15692
|
extractToDef(entry);
|
|
15693
15693
|
continue;
|
|
@@ -15697,19 +15697,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15697
15697
|
continue;
|
|
15698
15698
|
}
|
|
15699
15699
|
if (seen.count > 1) {
|
|
15700
|
-
if (
|
|
15700
|
+
if (ctx2.reused === "ref") {
|
|
15701
15701
|
extractToDef(entry);
|
|
15702
15702
|
continue;
|
|
15703
15703
|
}
|
|
15704
15704
|
}
|
|
15705
15705
|
}
|
|
15706
15706
|
}
|
|
15707
|
-
function finalize(
|
|
15708
|
-
const root =
|
|
15707
|
+
function finalize(ctx2, schema) {
|
|
15708
|
+
const root = ctx2.seen.get(schema);
|
|
15709
15709
|
if (!root)
|
|
15710
15710
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
15711
15711
|
const flattenRef = (zodSchema) => {
|
|
15712
|
-
const seen =
|
|
15712
|
+
const seen = ctx2.seen.get(zodSchema);
|
|
15713
15713
|
if (seen.ref === null)
|
|
15714
15714
|
return;
|
|
15715
15715
|
const schema2 = seen.def ?? seen.schema;
|
|
@@ -15718,9 +15718,9 @@ function finalize(ctx, schema) {
|
|
|
15718
15718
|
seen.ref = null;
|
|
15719
15719
|
if (ref) {
|
|
15720
15720
|
flattenRef(ref);
|
|
15721
|
-
const refSeen =
|
|
15721
|
+
const refSeen = ctx2.seen.get(ref);
|
|
15722
15722
|
const refSchema = refSeen.schema;
|
|
15723
|
-
if (refSchema.$ref && (
|
|
15723
|
+
if (refSchema.$ref && (ctx2.target === "draft-07" || ctx2.target === "draft-04" || ctx2.target === "openapi-3.0")) {
|
|
15724
15724
|
schema2.allOf = schema2.allOf ?? [];
|
|
15725
15725
|
schema2.allOf.push(refSchema);
|
|
15726
15726
|
} else {
|
|
@@ -15750,7 +15750,7 @@ function finalize(ctx, schema) {
|
|
|
15750
15750
|
const parent = zodSchema._zod.parent;
|
|
15751
15751
|
if (parent && parent !== ref) {
|
|
15752
15752
|
flattenRef(parent);
|
|
15753
|
-
const parentSeen =
|
|
15753
|
+
const parentSeen = ctx2.seen.get(parent);
|
|
15754
15754
|
if (parentSeen?.schema.$ref) {
|
|
15755
15755
|
schema2.$ref = parentSeen.schema.$ref;
|
|
15756
15756
|
if (parentSeen.def) {
|
|
@@ -15764,37 +15764,37 @@ function finalize(ctx, schema) {
|
|
|
15764
15764
|
}
|
|
15765
15765
|
}
|
|
15766
15766
|
}
|
|
15767
|
-
|
|
15767
|
+
ctx2.override({
|
|
15768
15768
|
zodSchema,
|
|
15769
15769
|
jsonSchema: schema2,
|
|
15770
15770
|
path: seen.path ?? []
|
|
15771
15771
|
});
|
|
15772
15772
|
};
|
|
15773
|
-
for (const entry of [...
|
|
15773
|
+
for (const entry of [...ctx2.seen.entries()].reverse()) {
|
|
15774
15774
|
flattenRef(entry[0]);
|
|
15775
15775
|
}
|
|
15776
15776
|
const result2 = {};
|
|
15777
|
-
if (
|
|
15777
|
+
if (ctx2.target === "draft-2020-12") {
|
|
15778
15778
|
result2.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
15779
|
-
} else if (
|
|
15779
|
+
} else if (ctx2.target === "draft-07") {
|
|
15780
15780
|
result2.$schema = "http://json-schema.org/draft-07/schema#";
|
|
15781
|
-
} else if (
|
|
15781
|
+
} else if (ctx2.target === "draft-04") {
|
|
15782
15782
|
result2.$schema = "http://json-schema.org/draft-04/schema#";
|
|
15783
|
-
} else if (
|
|
15783
|
+
} else if (ctx2.target === "openapi-3.0") {
|
|
15784
15784
|
} else {
|
|
15785
15785
|
}
|
|
15786
|
-
if (
|
|
15787
|
-
const id =
|
|
15786
|
+
if (ctx2.external?.uri) {
|
|
15787
|
+
const id = ctx2.external.registry.get(schema)?.id;
|
|
15788
15788
|
if (!id)
|
|
15789
15789
|
throw new Error("Schema is missing an `id` property");
|
|
15790
|
-
result2.$id =
|
|
15790
|
+
result2.$id = ctx2.external.uri(id);
|
|
15791
15791
|
}
|
|
15792
15792
|
Object.assign(result2, root.def ?? root.schema);
|
|
15793
|
-
const rootMetaId =
|
|
15793
|
+
const rootMetaId = ctx2.metadataRegistry.get(schema)?.id;
|
|
15794
15794
|
if (rootMetaId !== void 0 && result2.id === rootMetaId)
|
|
15795
15795
|
delete result2.id;
|
|
15796
|
-
const defs =
|
|
15797
|
-
for (const entry of
|
|
15796
|
+
const defs = ctx2.external?.defs ?? {};
|
|
15797
|
+
for (const entry of ctx2.seen.entries()) {
|
|
15798
15798
|
const seen = entry[1];
|
|
15799
15799
|
if (seen.def && seen.defId) {
|
|
15800
15800
|
if (seen.def.id === seen.defId)
|
|
@@ -15802,10 +15802,10 @@ function finalize(ctx, schema) {
|
|
|
15802
15802
|
defs[seen.defId] = seen.def;
|
|
15803
15803
|
}
|
|
15804
15804
|
}
|
|
15805
|
-
if (
|
|
15805
|
+
if (ctx2.external) {
|
|
15806
15806
|
} else {
|
|
15807
15807
|
if (Object.keys(defs).length > 0) {
|
|
15808
|
-
if (
|
|
15808
|
+
if (ctx2.target === "draft-2020-12") {
|
|
15809
15809
|
result2.$defs = defs;
|
|
15810
15810
|
} else {
|
|
15811
15811
|
result2.definitions = defs;
|
|
@@ -15818,8 +15818,8 @@ function finalize(ctx, schema) {
|
|
|
15818
15818
|
value: {
|
|
15819
15819
|
...schema["~standard"],
|
|
15820
15820
|
jsonSchema: {
|
|
15821
|
-
input: createStandardJSONSchemaMethod(schema, "input",
|
|
15822
|
-
output: createStandardJSONSchemaMethod(schema, "output",
|
|
15821
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx2.processors),
|
|
15822
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx2.processors)
|
|
15823
15823
|
}
|
|
15824
15824
|
},
|
|
15825
15825
|
enumerable: false,
|
|
@@ -15831,53 +15831,53 @@ function finalize(ctx, schema) {
|
|
|
15831
15831
|
}
|
|
15832
15832
|
}
|
|
15833
15833
|
function isTransforming(_schema, _ctx) {
|
|
15834
|
-
const
|
|
15835
|
-
if (
|
|
15834
|
+
const ctx2 = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
15835
|
+
if (ctx2.seen.has(_schema))
|
|
15836
15836
|
return false;
|
|
15837
|
-
|
|
15837
|
+
ctx2.seen.add(_schema);
|
|
15838
15838
|
const def = _schema._zod.def;
|
|
15839
15839
|
if (def.type === "transform")
|
|
15840
15840
|
return true;
|
|
15841
15841
|
if (def.type === "array")
|
|
15842
|
-
return isTransforming(def.element,
|
|
15842
|
+
return isTransforming(def.element, ctx2);
|
|
15843
15843
|
if (def.type === "set")
|
|
15844
|
-
return isTransforming(def.valueType,
|
|
15844
|
+
return isTransforming(def.valueType, ctx2);
|
|
15845
15845
|
if (def.type === "lazy")
|
|
15846
|
-
return isTransforming(def.getter(),
|
|
15846
|
+
return isTransforming(def.getter(), ctx2);
|
|
15847
15847
|
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
|
|
15848
|
-
return isTransforming(def.innerType,
|
|
15848
|
+
return isTransforming(def.innerType, ctx2);
|
|
15849
15849
|
}
|
|
15850
15850
|
if (def.type === "intersection") {
|
|
15851
|
-
return isTransforming(def.left,
|
|
15851
|
+
return isTransforming(def.left, ctx2) || isTransforming(def.right, ctx2);
|
|
15852
15852
|
}
|
|
15853
15853
|
if (def.type === "record" || def.type === "map") {
|
|
15854
|
-
return isTransforming(def.keyType,
|
|
15854
|
+
return isTransforming(def.keyType, ctx2) || isTransforming(def.valueType, ctx2);
|
|
15855
15855
|
}
|
|
15856
15856
|
if (def.type === "pipe") {
|
|
15857
15857
|
if (_schema._zod.traits.has("$ZodCodec"))
|
|
15858
15858
|
return true;
|
|
15859
|
-
return isTransforming(def.in,
|
|
15859
|
+
return isTransforming(def.in, ctx2) || isTransforming(def.out, ctx2);
|
|
15860
15860
|
}
|
|
15861
15861
|
if (def.type === "object") {
|
|
15862
15862
|
for (const key2 in def.shape) {
|
|
15863
|
-
if (isTransforming(def.shape[key2],
|
|
15863
|
+
if (isTransforming(def.shape[key2], ctx2))
|
|
15864
15864
|
return true;
|
|
15865
15865
|
}
|
|
15866
15866
|
return false;
|
|
15867
15867
|
}
|
|
15868
15868
|
if (def.type === "union") {
|
|
15869
15869
|
for (const option of def.options) {
|
|
15870
|
-
if (isTransforming(option,
|
|
15870
|
+
if (isTransforming(option, ctx2))
|
|
15871
15871
|
return true;
|
|
15872
15872
|
}
|
|
15873
15873
|
return false;
|
|
15874
15874
|
}
|
|
15875
15875
|
if (def.type === "tuple") {
|
|
15876
15876
|
for (const item of def.items) {
|
|
15877
|
-
if (isTransforming(item,
|
|
15877
|
+
if (isTransforming(item, ctx2))
|
|
15878
15878
|
return true;
|
|
15879
15879
|
}
|
|
15880
|
-
if (def.rest && isTransforming(def.rest,
|
|
15880
|
+
if (def.rest && isTransforming(def.rest, ctx2))
|
|
15881
15881
|
return true;
|
|
15882
15882
|
return false;
|
|
15883
15883
|
}
|
|
@@ -15888,17 +15888,17 @@ var init_to_json_schema = __esm({
|
|
|
15888
15888
|
"../../node_modules/zod/v4/core/to-json-schema.js"() {
|
|
15889
15889
|
init_registries();
|
|
15890
15890
|
createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
15891
|
-
const
|
|
15892
|
-
process2(schema,
|
|
15893
|
-
extractDefs(
|
|
15894
|
-
return finalize(
|
|
15891
|
+
const ctx2 = initializeContext({ ...params, processors });
|
|
15892
|
+
process2(schema, ctx2);
|
|
15893
|
+
extractDefs(ctx2, schema);
|
|
15894
|
+
return finalize(ctx2, schema);
|
|
15895
15895
|
};
|
|
15896
15896
|
createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
15897
15897
|
const { libraryOptions, target } = params ?? {};
|
|
15898
|
-
const
|
|
15899
|
-
process2(schema,
|
|
15900
|
-
extractDefs(
|
|
15901
|
-
return finalize(
|
|
15898
|
+
const ctx2 = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
15899
|
+
process2(schema, ctx2);
|
|
15900
|
+
extractDefs(ctx2, schema);
|
|
15901
|
+
return finalize(ctx2, schema);
|
|
15902
15902
|
};
|
|
15903
15903
|
}
|
|
15904
15904
|
});
|
|
@@ -15907,11 +15907,11 @@ var init_to_json_schema = __esm({
|
|
|
15907
15907
|
function toJSONSchema(input, params) {
|
|
15908
15908
|
if ("_idmap" in input) {
|
|
15909
15909
|
const registry2 = input;
|
|
15910
|
-
const
|
|
15910
|
+
const ctx3 = initializeContext({ ...params, processors: allProcessors });
|
|
15911
15911
|
const defs = {};
|
|
15912
15912
|
for (const entry of registry2._idmap.entries()) {
|
|
15913
15913
|
const [_, schema] = entry;
|
|
15914
|
-
process2(schema,
|
|
15914
|
+
process2(schema, ctx3);
|
|
15915
15915
|
}
|
|
15916
15916
|
const schemas = {};
|
|
15917
15917
|
const external = {
|
|
@@ -15919,24 +15919,24 @@ function toJSONSchema(input, params) {
|
|
|
15919
15919
|
uri: params?.uri,
|
|
15920
15920
|
defs
|
|
15921
15921
|
};
|
|
15922
|
-
|
|
15922
|
+
ctx3.external = external;
|
|
15923
15923
|
for (const entry of registry2._idmap.entries()) {
|
|
15924
15924
|
const [key2, schema] = entry;
|
|
15925
|
-
extractDefs(
|
|
15926
|
-
schemas[key2] = finalize(
|
|
15925
|
+
extractDefs(ctx3, schema);
|
|
15926
|
+
schemas[key2] = finalize(ctx3, schema);
|
|
15927
15927
|
}
|
|
15928
15928
|
if (Object.keys(defs).length > 0) {
|
|
15929
|
-
const defsSegment =
|
|
15929
|
+
const defsSegment = ctx3.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
15930
15930
|
schemas.__shared = {
|
|
15931
15931
|
[defsSegment]: defs
|
|
15932
15932
|
};
|
|
15933
15933
|
}
|
|
15934
15934
|
return { schemas };
|
|
15935
15935
|
}
|
|
15936
|
-
const
|
|
15937
|
-
process2(input,
|
|
15938
|
-
extractDefs(
|
|
15939
|
-
return finalize(
|
|
15936
|
+
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
15937
|
+
process2(input, ctx2);
|
|
15938
|
+
extractDefs(ctx2, input);
|
|
15939
|
+
return finalize(ctx2, input);
|
|
15940
15940
|
}
|
|
15941
15941
|
var formatMap, stringProcessor, numberProcessor, booleanProcessor, bigintProcessor, symbolProcessor, nullProcessor, undefinedProcessor, voidProcessor, neverProcessor, anyProcessor, unknownProcessor, dateProcessor, enumProcessor, literalProcessor, nanProcessor, templateLiteralProcessor, fileProcessor, successProcessor, customProcessor, functionProcessor, transformProcessor, mapProcessor, setProcessor, arrayProcessor, objectProcessor, unionProcessor, intersectionProcessor, tupleProcessor, recordProcessor, nullableProcessor, nonoptionalProcessor, defaultProcessor, prefaultProcessor, catchProcessor, pipeProcessor, readonlyProcessor, promiseProcessor, optionalProcessor, lazyProcessor, allProcessors;
|
|
15942
15942
|
var init_json_schema_processors = __esm({
|
|
@@ -15951,7 +15951,7 @@ var init_json_schema_processors = __esm({
|
|
|
15951
15951
|
regex: ""
|
|
15952
15952
|
// do not set
|
|
15953
15953
|
};
|
|
15954
|
-
stringProcessor = (schema,
|
|
15954
|
+
stringProcessor = (schema, ctx2, _json, _params) => {
|
|
15955
15955
|
const json3 = _json;
|
|
15956
15956
|
json3.type = "string";
|
|
15957
15957
|
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
@@ -15976,14 +15976,14 @@ var init_json_schema_processors = __esm({
|
|
|
15976
15976
|
else if (regexes.length > 1) {
|
|
15977
15977
|
json3.allOf = [
|
|
15978
15978
|
...regexes.map((regex) => ({
|
|
15979
|
-
...
|
|
15979
|
+
...ctx2.target === "draft-07" || ctx2.target === "draft-04" || ctx2.target === "openapi-3.0" ? { type: "string" } : {},
|
|
15980
15980
|
pattern: regex.source
|
|
15981
15981
|
}))
|
|
15982
15982
|
];
|
|
15983
15983
|
}
|
|
15984
15984
|
}
|
|
15985
15985
|
};
|
|
15986
|
-
numberProcessor = (schema,
|
|
15986
|
+
numberProcessor = (schema, ctx2, _json, _params) => {
|
|
15987
15987
|
const json3 = _json;
|
|
15988
15988
|
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
15989
15989
|
if (typeof format === "string" && format.includes("int"))
|
|
@@ -15992,7 +15992,7 @@ var init_json_schema_processors = __esm({
|
|
|
15992
15992
|
json3.type = "number";
|
|
15993
15993
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
15994
15994
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
15995
|
-
const legacy =
|
|
15995
|
+
const legacy = ctx2.target === "draft-04" || ctx2.target === "openapi-3.0";
|
|
15996
15996
|
if (exMin) {
|
|
15997
15997
|
if (legacy) {
|
|
15998
15998
|
json3.minimum = exclusiveMinimum;
|
|
@@ -16019,18 +16019,18 @@ var init_json_schema_processors = __esm({
|
|
|
16019
16019
|
booleanProcessor = (_schema, _ctx, json3, _params) => {
|
|
16020
16020
|
json3.type = "boolean";
|
|
16021
16021
|
};
|
|
16022
|
-
bigintProcessor = (_schema,
|
|
16023
|
-
if (
|
|
16022
|
+
bigintProcessor = (_schema, ctx2, _json, _params) => {
|
|
16023
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16024
16024
|
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
16025
16025
|
}
|
|
16026
16026
|
};
|
|
16027
|
-
symbolProcessor = (_schema,
|
|
16028
|
-
if (
|
|
16027
|
+
symbolProcessor = (_schema, ctx2, _json, _params) => {
|
|
16028
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16029
16029
|
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
16030
16030
|
}
|
|
16031
16031
|
};
|
|
16032
|
-
nullProcessor = (_schema,
|
|
16033
|
-
if (
|
|
16032
|
+
nullProcessor = (_schema, ctx2, json3, _params) => {
|
|
16033
|
+
if (ctx2.target === "openapi-3.0") {
|
|
16034
16034
|
json3.type = "string";
|
|
16035
16035
|
json3.nullable = true;
|
|
16036
16036
|
json3.enum = [null];
|
|
@@ -16038,13 +16038,13 @@ var init_json_schema_processors = __esm({
|
|
|
16038
16038
|
json3.type = "null";
|
|
16039
16039
|
}
|
|
16040
16040
|
};
|
|
16041
|
-
undefinedProcessor = (_schema,
|
|
16042
|
-
if (
|
|
16041
|
+
undefinedProcessor = (_schema, ctx2, _json, _params) => {
|
|
16042
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16043
16043
|
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
16044
16044
|
}
|
|
16045
16045
|
};
|
|
16046
|
-
voidProcessor = (_schema,
|
|
16047
|
-
if (
|
|
16046
|
+
voidProcessor = (_schema, ctx2, _json, _params) => {
|
|
16047
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16048
16048
|
throw new Error("Void cannot be represented in JSON Schema");
|
|
16049
16049
|
}
|
|
16050
16050
|
};
|
|
@@ -16055,8 +16055,8 @@ var init_json_schema_processors = __esm({
|
|
|
16055
16055
|
};
|
|
16056
16056
|
unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
16057
16057
|
};
|
|
16058
|
-
dateProcessor = (_schema,
|
|
16059
|
-
if (
|
|
16058
|
+
dateProcessor = (_schema, ctx2, _json, _params) => {
|
|
16059
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16060
16060
|
throw new Error("Date cannot be represented in JSON Schema");
|
|
16061
16061
|
}
|
|
16062
16062
|
};
|
|
@@ -16069,17 +16069,17 @@ var init_json_schema_processors = __esm({
|
|
|
16069
16069
|
json3.type = "string";
|
|
16070
16070
|
json3.enum = values;
|
|
16071
16071
|
};
|
|
16072
|
-
literalProcessor = (schema,
|
|
16072
|
+
literalProcessor = (schema, ctx2, json3, _params) => {
|
|
16073
16073
|
const def = schema._zod.def;
|
|
16074
16074
|
const vals = [];
|
|
16075
16075
|
for (const val of def.values) {
|
|
16076
16076
|
if (val === void 0) {
|
|
16077
|
-
if (
|
|
16077
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16078
16078
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
16079
16079
|
} else {
|
|
16080
16080
|
}
|
|
16081
16081
|
} else if (typeof val === "bigint") {
|
|
16082
|
-
if (
|
|
16082
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16083
16083
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
16084
16084
|
} else {
|
|
16085
16085
|
vals.push(Number(val));
|
|
@@ -16092,7 +16092,7 @@ var init_json_schema_processors = __esm({
|
|
|
16092
16092
|
} else if (vals.length === 1) {
|
|
16093
16093
|
const val = vals[0];
|
|
16094
16094
|
json3.type = val === null ? "null" : typeof val;
|
|
16095
|
-
if (
|
|
16095
|
+
if (ctx2.target === "draft-04" || ctx2.target === "openapi-3.0") {
|
|
16096
16096
|
json3.enum = [val];
|
|
16097
16097
|
} else {
|
|
16098
16098
|
json3.const = val;
|
|
@@ -16109,8 +16109,8 @@ var init_json_schema_processors = __esm({
|
|
|
16109
16109
|
json3.enum = vals;
|
|
16110
16110
|
}
|
|
16111
16111
|
};
|
|
16112
|
-
nanProcessor = (_schema,
|
|
16113
|
-
if (
|
|
16112
|
+
nanProcessor = (_schema, ctx2, _json, _params) => {
|
|
16113
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16114
16114
|
throw new Error("NaN cannot be represented in JSON Schema");
|
|
16115
16115
|
}
|
|
16116
16116
|
};
|
|
@@ -16149,32 +16149,32 @@ var init_json_schema_processors = __esm({
|
|
|
16149
16149
|
successProcessor = (_schema, _ctx, json3, _params) => {
|
|
16150
16150
|
json3.type = "boolean";
|
|
16151
16151
|
};
|
|
16152
|
-
customProcessor = (_schema,
|
|
16153
|
-
if (
|
|
16152
|
+
customProcessor = (_schema, ctx2, _json, _params) => {
|
|
16153
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16154
16154
|
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
16155
16155
|
}
|
|
16156
16156
|
};
|
|
16157
|
-
functionProcessor = (_schema,
|
|
16158
|
-
if (
|
|
16157
|
+
functionProcessor = (_schema, ctx2, _json, _params) => {
|
|
16158
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16159
16159
|
throw new Error("Function types cannot be represented in JSON Schema");
|
|
16160
16160
|
}
|
|
16161
16161
|
};
|
|
16162
|
-
transformProcessor = (_schema,
|
|
16163
|
-
if (
|
|
16162
|
+
transformProcessor = (_schema, ctx2, _json, _params) => {
|
|
16163
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16164
16164
|
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
16165
16165
|
}
|
|
16166
16166
|
};
|
|
16167
|
-
mapProcessor = (_schema,
|
|
16168
|
-
if (
|
|
16167
|
+
mapProcessor = (_schema, ctx2, _json, _params) => {
|
|
16168
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16169
16169
|
throw new Error("Map cannot be represented in JSON Schema");
|
|
16170
16170
|
}
|
|
16171
16171
|
};
|
|
16172
|
-
setProcessor = (_schema,
|
|
16173
|
-
if (
|
|
16172
|
+
setProcessor = (_schema, ctx2, _json, _params) => {
|
|
16173
|
+
if (ctx2.unrepresentable === "throw") {
|
|
16174
16174
|
throw new Error("Set cannot be represented in JSON Schema");
|
|
16175
16175
|
}
|
|
16176
16176
|
};
|
|
16177
|
-
arrayProcessor = (schema,
|
|
16177
|
+
arrayProcessor = (schema, ctx2, _json, params) => {
|
|
16178
16178
|
const json3 = _json;
|
|
16179
16179
|
const def = schema._zod.def;
|
|
16180
16180
|
const { minimum, maximum } = schema._zod.bag;
|
|
@@ -16183,19 +16183,19 @@ var init_json_schema_processors = __esm({
|
|
|
16183
16183
|
if (typeof maximum === "number")
|
|
16184
16184
|
json3.maxItems = maximum;
|
|
16185
16185
|
json3.type = "array";
|
|
16186
|
-
json3.items = process2(def.element,
|
|
16186
|
+
json3.items = process2(def.element, ctx2, {
|
|
16187
16187
|
...params,
|
|
16188
16188
|
path: [...params.path, "items"]
|
|
16189
16189
|
});
|
|
16190
16190
|
};
|
|
16191
|
-
objectProcessor = (schema,
|
|
16191
|
+
objectProcessor = (schema, ctx2, _json, params) => {
|
|
16192
16192
|
const json3 = _json;
|
|
16193
16193
|
const def = schema._zod.def;
|
|
16194
16194
|
json3.type = "object";
|
|
16195
16195
|
json3.properties = {};
|
|
16196
16196
|
const shape = def.shape;
|
|
16197
16197
|
for (const key2 in shape) {
|
|
16198
|
-
json3.properties[key2] = process2(shape[key2],
|
|
16198
|
+
json3.properties[key2] = process2(shape[key2], ctx2, {
|
|
16199
16199
|
...params,
|
|
16200
16200
|
path: [...params.path, "properties", key2]
|
|
16201
16201
|
});
|
|
@@ -16203,7 +16203,7 @@ var init_json_schema_processors = __esm({
|
|
|
16203
16203
|
const allKeys = new Set(Object.keys(shape));
|
|
16204
16204
|
const requiredKeys = new Set([...allKeys].filter((key2) => {
|
|
16205
16205
|
const v = def.shape[key2]._zod;
|
|
16206
|
-
if (
|
|
16206
|
+
if (ctx2.io === "input") {
|
|
16207
16207
|
return v.optin === void 0;
|
|
16208
16208
|
} else {
|
|
16209
16209
|
return v.optout === void 0;
|
|
@@ -16215,19 +16215,19 @@ var init_json_schema_processors = __esm({
|
|
|
16215
16215
|
if (def.catchall?._zod.def.type === "never") {
|
|
16216
16216
|
json3.additionalProperties = false;
|
|
16217
16217
|
} else if (!def.catchall) {
|
|
16218
|
-
if (
|
|
16218
|
+
if (ctx2.io === "output")
|
|
16219
16219
|
json3.additionalProperties = false;
|
|
16220
16220
|
} else if (def.catchall) {
|
|
16221
|
-
json3.additionalProperties = process2(def.catchall,
|
|
16221
|
+
json3.additionalProperties = process2(def.catchall, ctx2, {
|
|
16222
16222
|
...params,
|
|
16223
16223
|
path: [...params.path, "additionalProperties"]
|
|
16224
16224
|
});
|
|
16225
16225
|
}
|
|
16226
16226
|
};
|
|
16227
|
-
unionProcessor = (schema,
|
|
16227
|
+
unionProcessor = (schema, ctx2, json3, params) => {
|
|
16228
16228
|
const def = schema._zod.def;
|
|
16229
16229
|
const isExclusive = def.inclusive === false;
|
|
16230
|
-
const options = def.options.map((x, i) => process2(x,
|
|
16230
|
+
const options = def.options.map((x, i) => process2(x, ctx2, {
|
|
16231
16231
|
...params,
|
|
16232
16232
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
16233
16233
|
}));
|
|
@@ -16237,13 +16237,13 @@ var init_json_schema_processors = __esm({
|
|
|
16237
16237
|
json3.anyOf = options;
|
|
16238
16238
|
}
|
|
16239
16239
|
};
|
|
16240
|
-
intersectionProcessor = (schema,
|
|
16240
|
+
intersectionProcessor = (schema, ctx2, json3, params) => {
|
|
16241
16241
|
const def = schema._zod.def;
|
|
16242
|
-
const a = process2(def.left,
|
|
16242
|
+
const a = process2(def.left, ctx2, {
|
|
16243
16243
|
...params,
|
|
16244
16244
|
path: [...params.path, "allOf", 0]
|
|
16245
16245
|
});
|
|
16246
|
-
const b = process2(def.right,
|
|
16246
|
+
const b = process2(def.right, ctx2, {
|
|
16247
16247
|
...params,
|
|
16248
16248
|
path: [...params.path, "allOf", 1]
|
|
16249
16249
|
});
|
|
@@ -16254,26 +16254,26 @@ var init_json_schema_processors = __esm({
|
|
|
16254
16254
|
];
|
|
16255
16255
|
json3.allOf = allOf;
|
|
16256
16256
|
};
|
|
16257
|
-
tupleProcessor = (schema,
|
|
16257
|
+
tupleProcessor = (schema, ctx2, _json, params) => {
|
|
16258
16258
|
const json3 = _json;
|
|
16259
16259
|
const def = schema._zod.def;
|
|
16260
16260
|
json3.type = "array";
|
|
16261
|
-
const prefixPath =
|
|
16262
|
-
const restPath =
|
|
16263
|
-
const prefixItems = def.items.map((x, i) => process2(x,
|
|
16261
|
+
const prefixPath = ctx2.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
16262
|
+
const restPath = ctx2.target === "draft-2020-12" ? "items" : ctx2.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
16263
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx2, {
|
|
16264
16264
|
...params,
|
|
16265
16265
|
path: [...params.path, prefixPath, i]
|
|
16266
16266
|
}));
|
|
16267
|
-
const rest = def.rest ? process2(def.rest,
|
|
16267
|
+
const rest = def.rest ? process2(def.rest, ctx2, {
|
|
16268
16268
|
...params,
|
|
16269
|
-
path: [...params.path, restPath, ...
|
|
16269
|
+
path: [...params.path, restPath, ...ctx2.target === "openapi-3.0" ? [def.items.length] : []]
|
|
16270
16270
|
}) : null;
|
|
16271
|
-
if (
|
|
16271
|
+
if (ctx2.target === "draft-2020-12") {
|
|
16272
16272
|
json3.prefixItems = prefixItems;
|
|
16273
16273
|
if (rest) {
|
|
16274
16274
|
json3.items = rest;
|
|
16275
16275
|
}
|
|
16276
|
-
} else if (
|
|
16276
|
+
} else if (ctx2.target === "openapi-3.0") {
|
|
16277
16277
|
json3.items = {
|
|
16278
16278
|
anyOf: prefixItems
|
|
16279
16279
|
};
|
|
@@ -16296,7 +16296,7 @@ var init_json_schema_processors = __esm({
|
|
|
16296
16296
|
if (typeof maximum === "number")
|
|
16297
16297
|
json3.maxItems = maximum;
|
|
16298
16298
|
};
|
|
16299
|
-
recordProcessor = (schema,
|
|
16299
|
+
recordProcessor = (schema, ctx2, _json, params) => {
|
|
16300
16300
|
const json3 = _json;
|
|
16301
16301
|
const def = schema._zod.def;
|
|
16302
16302
|
json3.type = "object";
|
|
@@ -16304,7 +16304,7 @@ var init_json_schema_processors = __esm({
|
|
|
16304
16304
|
const keyBag = keyType._zod.bag;
|
|
16305
16305
|
const patterns = keyBag?.patterns;
|
|
16306
16306
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
16307
|
-
const valueSchema = process2(def.valueType,
|
|
16307
|
+
const valueSchema = process2(def.valueType, ctx2, {
|
|
16308
16308
|
...params,
|
|
16309
16309
|
path: [...params.path, "patternProperties", "*"]
|
|
16310
16310
|
});
|
|
@@ -16313,13 +16313,13 @@ var init_json_schema_processors = __esm({
|
|
|
16313
16313
|
json3.patternProperties[pattern.source] = valueSchema;
|
|
16314
16314
|
}
|
|
16315
16315
|
} else {
|
|
16316
|
-
if (
|
|
16317
|
-
json3.propertyNames = process2(def.keyType,
|
|
16316
|
+
if (ctx2.target === "draft-07" || ctx2.target === "draft-2020-12") {
|
|
16317
|
+
json3.propertyNames = process2(def.keyType, ctx2, {
|
|
16318
16318
|
...params,
|
|
16319
16319
|
path: [...params.path, "propertyNames"]
|
|
16320
16320
|
});
|
|
16321
16321
|
}
|
|
16322
|
-
json3.additionalProperties = process2(def.valueType,
|
|
16322
|
+
json3.additionalProperties = process2(def.valueType, ctx2, {
|
|
16323
16323
|
...params,
|
|
16324
16324
|
path: [...params.path, "additionalProperties"]
|
|
16325
16325
|
});
|
|
@@ -16332,42 +16332,42 @@ var init_json_schema_processors = __esm({
|
|
|
16332
16332
|
}
|
|
16333
16333
|
}
|
|
16334
16334
|
};
|
|
16335
|
-
nullableProcessor = (schema,
|
|
16335
|
+
nullableProcessor = (schema, ctx2, json3, params) => {
|
|
16336
16336
|
const def = schema._zod.def;
|
|
16337
|
-
const inner = process2(def.innerType,
|
|
16338
|
-
const seen =
|
|
16339
|
-
if (
|
|
16337
|
+
const inner = process2(def.innerType, ctx2, params);
|
|
16338
|
+
const seen = ctx2.seen.get(schema);
|
|
16339
|
+
if (ctx2.target === "openapi-3.0") {
|
|
16340
16340
|
seen.ref = def.innerType;
|
|
16341
16341
|
json3.nullable = true;
|
|
16342
16342
|
} else {
|
|
16343
16343
|
json3.anyOf = [inner, { type: "null" }];
|
|
16344
16344
|
}
|
|
16345
16345
|
};
|
|
16346
|
-
nonoptionalProcessor = (schema,
|
|
16346
|
+
nonoptionalProcessor = (schema, ctx2, _json, params) => {
|
|
16347
16347
|
const def = schema._zod.def;
|
|
16348
|
-
process2(def.innerType,
|
|
16349
|
-
const seen =
|
|
16348
|
+
process2(def.innerType, ctx2, params);
|
|
16349
|
+
const seen = ctx2.seen.get(schema);
|
|
16350
16350
|
seen.ref = def.innerType;
|
|
16351
16351
|
};
|
|
16352
|
-
defaultProcessor = (schema,
|
|
16352
|
+
defaultProcessor = (schema, ctx2, json3, params) => {
|
|
16353
16353
|
const def = schema._zod.def;
|
|
16354
|
-
process2(def.innerType,
|
|
16355
|
-
const seen =
|
|
16354
|
+
process2(def.innerType, ctx2, params);
|
|
16355
|
+
const seen = ctx2.seen.get(schema);
|
|
16356
16356
|
seen.ref = def.innerType;
|
|
16357
16357
|
json3.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
16358
16358
|
};
|
|
16359
|
-
prefaultProcessor = (schema,
|
|
16359
|
+
prefaultProcessor = (schema, ctx2, json3, params) => {
|
|
16360
16360
|
const def = schema._zod.def;
|
|
16361
|
-
process2(def.innerType,
|
|
16362
|
-
const seen =
|
|
16361
|
+
process2(def.innerType, ctx2, params);
|
|
16362
|
+
const seen = ctx2.seen.get(schema);
|
|
16363
16363
|
seen.ref = def.innerType;
|
|
16364
|
-
if (
|
|
16364
|
+
if (ctx2.io === "input")
|
|
16365
16365
|
json3._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
16366
16366
|
};
|
|
16367
|
-
catchProcessor = (schema,
|
|
16367
|
+
catchProcessor = (schema, ctx2, json3, params) => {
|
|
16368
16368
|
const def = schema._zod.def;
|
|
16369
|
-
process2(def.innerType,
|
|
16370
|
-
const seen =
|
|
16369
|
+
process2(def.innerType, ctx2, params);
|
|
16370
|
+
const seen = ctx2.seen.get(schema);
|
|
16371
16371
|
seen.ref = def.innerType;
|
|
16372
16372
|
let catchValue;
|
|
16373
16373
|
try {
|
|
@@ -16377,37 +16377,37 @@ var init_json_schema_processors = __esm({
|
|
|
16377
16377
|
}
|
|
16378
16378
|
json3.default = catchValue;
|
|
16379
16379
|
};
|
|
16380
|
-
pipeProcessor = (schema,
|
|
16380
|
+
pipeProcessor = (schema, ctx2, _json, params) => {
|
|
16381
16381
|
const def = schema._zod.def;
|
|
16382
16382
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
16383
|
-
const innerType =
|
|
16384
|
-
process2(innerType,
|
|
16385
|
-
const seen =
|
|
16383
|
+
const innerType = ctx2.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
16384
|
+
process2(innerType, ctx2, params);
|
|
16385
|
+
const seen = ctx2.seen.get(schema);
|
|
16386
16386
|
seen.ref = innerType;
|
|
16387
16387
|
};
|
|
16388
|
-
readonlyProcessor = (schema,
|
|
16388
|
+
readonlyProcessor = (schema, ctx2, json3, params) => {
|
|
16389
16389
|
const def = schema._zod.def;
|
|
16390
|
-
process2(def.innerType,
|
|
16391
|
-
const seen =
|
|
16390
|
+
process2(def.innerType, ctx2, params);
|
|
16391
|
+
const seen = ctx2.seen.get(schema);
|
|
16392
16392
|
seen.ref = def.innerType;
|
|
16393
16393
|
json3.readOnly = true;
|
|
16394
16394
|
};
|
|
16395
|
-
promiseProcessor = (schema,
|
|
16395
|
+
promiseProcessor = (schema, ctx2, _json, params) => {
|
|
16396
16396
|
const def = schema._zod.def;
|
|
16397
|
-
process2(def.innerType,
|
|
16398
|
-
const seen =
|
|
16397
|
+
process2(def.innerType, ctx2, params);
|
|
16398
|
+
const seen = ctx2.seen.get(schema);
|
|
16399
16399
|
seen.ref = def.innerType;
|
|
16400
16400
|
};
|
|
16401
|
-
optionalProcessor = (schema,
|
|
16401
|
+
optionalProcessor = (schema, ctx2, _json, params) => {
|
|
16402
16402
|
const def = schema._zod.def;
|
|
16403
|
-
process2(def.innerType,
|
|
16404
|
-
const seen =
|
|
16403
|
+
process2(def.innerType, ctx2, params);
|
|
16404
|
+
const seen = ctx2.seen.get(schema);
|
|
16405
16405
|
seen.ref = def.innerType;
|
|
16406
16406
|
};
|
|
16407
|
-
lazyProcessor = (schema,
|
|
16407
|
+
lazyProcessor = (schema, ctx2, _json, params) => {
|
|
16408
16408
|
const innerType = schema._zod.innerType;
|
|
16409
|
-
process2(innerType,
|
|
16410
|
-
const seen =
|
|
16409
|
+
process2(innerType, ctx2, params);
|
|
16410
|
+
const seen = ctx2.seen.get(schema);
|
|
16411
16411
|
seen.ref = innerType;
|
|
16412
16412
|
};
|
|
16413
16413
|
allProcessors = {
|
|
@@ -17823,7 +17823,7 @@ var init_schemas2 = __esm({
|
|
|
17823
17823
|
_ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
17824
17824
|
$ZodString.init(inst, def);
|
|
17825
17825
|
ZodType.init(inst, def);
|
|
17826
|
-
inst._zod.processJSONSchema = (
|
|
17826
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => stringProcessor(inst, ctx2, json3, params);
|
|
17827
17827
|
const bag = inst._zod.bag;
|
|
17828
17828
|
inst.format = bag.format ?? null;
|
|
17829
17829
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -17998,7 +17998,7 @@ var init_schemas2 = __esm({
|
|
|
17998
17998
|
ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
17999
17999
|
$ZodNumber.init(inst, def);
|
|
18000
18000
|
ZodType.init(inst, def);
|
|
18001
|
-
inst._zod.processJSONSchema = (
|
|
18001
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => numberProcessor(inst, ctx2, json3, params);
|
|
18002
18002
|
_installLazyMethods(inst, "ZodNumber", {
|
|
18003
18003
|
gt(value, params) {
|
|
18004
18004
|
return this.check(_gt(value, params));
|
|
@@ -18060,12 +18060,12 @@ var init_schemas2 = __esm({
|
|
|
18060
18060
|
ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
18061
18061
|
$ZodBoolean.init(inst, def);
|
|
18062
18062
|
ZodType.init(inst, def);
|
|
18063
|
-
inst._zod.processJSONSchema = (
|
|
18063
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => booleanProcessor(inst, ctx2, json3, params);
|
|
18064
18064
|
});
|
|
18065
18065
|
ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
|
|
18066
18066
|
$ZodBigInt.init(inst, def);
|
|
18067
18067
|
ZodType.init(inst, def);
|
|
18068
|
-
inst._zod.processJSONSchema = (
|
|
18068
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => bigintProcessor(inst, ctx2, json3, params);
|
|
18069
18069
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
18070
18070
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
18071
18071
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
@@ -18091,42 +18091,42 @@ var init_schemas2 = __esm({
|
|
|
18091
18091
|
ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
18092
18092
|
$ZodSymbol.init(inst, def);
|
|
18093
18093
|
ZodType.init(inst, def);
|
|
18094
|
-
inst._zod.processJSONSchema = (
|
|
18094
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => symbolProcessor(inst, ctx2, json3, params);
|
|
18095
18095
|
});
|
|
18096
18096
|
ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
18097
18097
|
$ZodUndefined.init(inst, def);
|
|
18098
18098
|
ZodType.init(inst, def);
|
|
18099
|
-
inst._zod.processJSONSchema = (
|
|
18099
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => undefinedProcessor(inst, ctx2, json3, params);
|
|
18100
18100
|
});
|
|
18101
18101
|
ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
18102
18102
|
$ZodNull.init(inst, def);
|
|
18103
18103
|
ZodType.init(inst, def);
|
|
18104
|
-
inst._zod.processJSONSchema = (
|
|
18104
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => nullProcessor(inst, ctx2, json3, params);
|
|
18105
18105
|
});
|
|
18106
18106
|
ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
18107
18107
|
$ZodAny.init(inst, def);
|
|
18108
18108
|
ZodType.init(inst, def);
|
|
18109
|
-
inst._zod.processJSONSchema = (
|
|
18109
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => anyProcessor(inst, ctx2, json3, params);
|
|
18110
18110
|
});
|
|
18111
18111
|
ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
18112
18112
|
$ZodUnknown.init(inst, def);
|
|
18113
18113
|
ZodType.init(inst, def);
|
|
18114
|
-
inst._zod.processJSONSchema = (
|
|
18114
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => unknownProcessor(inst, ctx2, json3, params);
|
|
18115
18115
|
});
|
|
18116
18116
|
ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
18117
18117
|
$ZodNever.init(inst, def);
|
|
18118
18118
|
ZodType.init(inst, def);
|
|
18119
|
-
inst._zod.processJSONSchema = (
|
|
18119
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => neverProcessor(inst, ctx2, json3, params);
|
|
18120
18120
|
});
|
|
18121
18121
|
ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
18122
18122
|
$ZodVoid.init(inst, def);
|
|
18123
18123
|
ZodType.init(inst, def);
|
|
18124
|
-
inst._zod.processJSONSchema = (
|
|
18124
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => voidProcessor(inst, ctx2, json3, params);
|
|
18125
18125
|
});
|
|
18126
18126
|
ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
|
|
18127
18127
|
$ZodDate.init(inst, def);
|
|
18128
18128
|
ZodType.init(inst, def);
|
|
18129
|
-
inst._zod.processJSONSchema = (
|
|
18129
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => dateProcessor(inst, ctx2, json3, params);
|
|
18130
18130
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
18131
18131
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
18132
18132
|
const c = inst._zod.bag;
|
|
@@ -18136,7 +18136,7 @@ var init_schemas2 = __esm({
|
|
|
18136
18136
|
ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
18137
18137
|
$ZodArray.init(inst, def);
|
|
18138
18138
|
ZodType.init(inst, def);
|
|
18139
|
-
inst._zod.processJSONSchema = (
|
|
18139
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => arrayProcessor(inst, ctx2, json3, params);
|
|
18140
18140
|
inst.element = def.element;
|
|
18141
18141
|
_installLazyMethods(inst, "ZodArray", {
|
|
18142
18142
|
min(n, params) {
|
|
@@ -18159,7 +18159,7 @@ var init_schemas2 = __esm({
|
|
|
18159
18159
|
ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
18160
18160
|
$ZodObjectJIT.init(inst, def);
|
|
18161
18161
|
ZodType.init(inst, def);
|
|
18162
|
-
inst._zod.processJSONSchema = (
|
|
18162
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => objectProcessor(inst, ctx2, json3, params);
|
|
18163
18163
|
util_exports.defineLazy(inst, "shape", () => {
|
|
18164
18164
|
return def.shape;
|
|
18165
18165
|
});
|
|
@@ -18208,13 +18208,13 @@ var init_schemas2 = __esm({
|
|
|
18208
18208
|
ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
18209
18209
|
$ZodUnion.init(inst, def);
|
|
18210
18210
|
ZodType.init(inst, def);
|
|
18211
|
-
inst._zod.processJSONSchema = (
|
|
18211
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => unionProcessor(inst, ctx2, json3, params);
|
|
18212
18212
|
inst.options = def.options;
|
|
18213
18213
|
});
|
|
18214
18214
|
ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
18215
18215
|
ZodUnion.init(inst, def);
|
|
18216
18216
|
$ZodXor.init(inst, def);
|
|
18217
|
-
inst._zod.processJSONSchema = (
|
|
18217
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => unionProcessor(inst, ctx2, json3, params);
|
|
18218
18218
|
inst.options = def.options;
|
|
18219
18219
|
});
|
|
18220
18220
|
ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
@@ -18224,12 +18224,12 @@ var init_schemas2 = __esm({
|
|
|
18224
18224
|
ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
18225
18225
|
$ZodIntersection.init(inst, def);
|
|
18226
18226
|
ZodType.init(inst, def);
|
|
18227
|
-
inst._zod.processJSONSchema = (
|
|
18227
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => intersectionProcessor(inst, ctx2, json3, params);
|
|
18228
18228
|
});
|
|
18229
18229
|
ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
18230
18230
|
$ZodTuple.init(inst, def);
|
|
18231
18231
|
ZodType.init(inst, def);
|
|
18232
|
-
inst._zod.processJSONSchema = (
|
|
18232
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => tupleProcessor(inst, ctx2, json3, params);
|
|
18233
18233
|
inst.rest = (rest) => inst.clone({
|
|
18234
18234
|
...inst._zod.def,
|
|
18235
18235
|
rest
|
|
@@ -18238,14 +18238,14 @@ var init_schemas2 = __esm({
|
|
|
18238
18238
|
ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
18239
18239
|
$ZodRecord.init(inst, def);
|
|
18240
18240
|
ZodType.init(inst, def);
|
|
18241
|
-
inst._zod.processJSONSchema = (
|
|
18241
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => recordProcessor(inst, ctx2, json3, params);
|
|
18242
18242
|
inst.keyType = def.keyType;
|
|
18243
18243
|
inst.valueType = def.valueType;
|
|
18244
18244
|
});
|
|
18245
18245
|
ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
18246
18246
|
$ZodMap.init(inst, def);
|
|
18247
18247
|
ZodType.init(inst, def);
|
|
18248
|
-
inst._zod.processJSONSchema = (
|
|
18248
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => mapProcessor(inst, ctx2, json3, params);
|
|
18249
18249
|
inst.keyType = def.keyType;
|
|
18250
18250
|
inst.valueType = def.valueType;
|
|
18251
18251
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -18256,7 +18256,7 @@ var init_schemas2 = __esm({
|
|
|
18256
18256
|
ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
18257
18257
|
$ZodSet.init(inst, def);
|
|
18258
18258
|
ZodType.init(inst, def);
|
|
18259
|
-
inst._zod.processJSONSchema = (
|
|
18259
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => setProcessor(inst, ctx2, json3, params);
|
|
18260
18260
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
18261
18261
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
18262
18262
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -18265,7 +18265,7 @@ var init_schemas2 = __esm({
|
|
|
18265
18265
|
ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
18266
18266
|
$ZodEnum.init(inst, def);
|
|
18267
18267
|
ZodType.init(inst, def);
|
|
18268
|
-
inst._zod.processJSONSchema = (
|
|
18268
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => enumProcessor(inst, ctx2, json3, params);
|
|
18269
18269
|
inst.enum = def.entries;
|
|
18270
18270
|
inst.options = Object.values(def.entries);
|
|
18271
18271
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -18303,7 +18303,7 @@ var init_schemas2 = __esm({
|
|
|
18303
18303
|
ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
18304
18304
|
$ZodLiteral.init(inst, def);
|
|
18305
18305
|
ZodType.init(inst, def);
|
|
18306
|
-
inst._zod.processJSONSchema = (
|
|
18306
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => literalProcessor(inst, ctx2, json3, params);
|
|
18307
18307
|
inst.values = new Set(def.values);
|
|
18308
18308
|
Object.defineProperty(inst, "value", {
|
|
18309
18309
|
get() {
|
|
@@ -18317,7 +18317,7 @@ var init_schemas2 = __esm({
|
|
|
18317
18317
|
ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
18318
18318
|
$ZodFile.init(inst, def);
|
|
18319
18319
|
ZodType.init(inst, def);
|
|
18320
|
-
inst._zod.processJSONSchema = (
|
|
18320
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => fileProcessor(inst, ctx2, json3, params);
|
|
18321
18321
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
18322
18322
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
18323
18323
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -18325,7 +18325,7 @@ var init_schemas2 = __esm({
|
|
|
18325
18325
|
ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
18326
18326
|
$ZodTransform.init(inst, def);
|
|
18327
18327
|
ZodType.init(inst, def);
|
|
18328
|
-
inst._zod.processJSONSchema = (
|
|
18328
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => transformProcessor(inst, ctx2, json3, params);
|
|
18329
18329
|
inst._zod.parse = (payload, _ctx) => {
|
|
18330
18330
|
if (_ctx.direction === "backward") {
|
|
18331
18331
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -18359,62 +18359,62 @@ var init_schemas2 = __esm({
|
|
|
18359
18359
|
ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
18360
18360
|
$ZodOptional.init(inst, def);
|
|
18361
18361
|
ZodType.init(inst, def);
|
|
18362
|
-
inst._zod.processJSONSchema = (
|
|
18362
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => optionalProcessor(inst, ctx2, json3, params);
|
|
18363
18363
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18364
18364
|
});
|
|
18365
18365
|
ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
18366
18366
|
$ZodExactOptional.init(inst, def);
|
|
18367
18367
|
ZodType.init(inst, def);
|
|
18368
|
-
inst._zod.processJSONSchema = (
|
|
18368
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => optionalProcessor(inst, ctx2, json3, params);
|
|
18369
18369
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18370
18370
|
});
|
|
18371
18371
|
ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
18372
18372
|
$ZodNullable.init(inst, def);
|
|
18373
18373
|
ZodType.init(inst, def);
|
|
18374
|
-
inst._zod.processJSONSchema = (
|
|
18374
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => nullableProcessor(inst, ctx2, json3, params);
|
|
18375
18375
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18376
18376
|
});
|
|
18377
18377
|
ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
18378
18378
|
$ZodDefault.init(inst, def);
|
|
18379
18379
|
ZodType.init(inst, def);
|
|
18380
|
-
inst._zod.processJSONSchema = (
|
|
18380
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => defaultProcessor(inst, ctx2, json3, params);
|
|
18381
18381
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18382
18382
|
inst.removeDefault = inst.unwrap;
|
|
18383
18383
|
});
|
|
18384
18384
|
ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
18385
18385
|
$ZodPrefault.init(inst, def);
|
|
18386
18386
|
ZodType.init(inst, def);
|
|
18387
|
-
inst._zod.processJSONSchema = (
|
|
18387
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => prefaultProcessor(inst, ctx2, json3, params);
|
|
18388
18388
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18389
18389
|
});
|
|
18390
18390
|
ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
18391
18391
|
$ZodNonOptional.init(inst, def);
|
|
18392
18392
|
ZodType.init(inst, def);
|
|
18393
|
-
inst._zod.processJSONSchema = (
|
|
18393
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => nonoptionalProcessor(inst, ctx2, json3, params);
|
|
18394
18394
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18395
18395
|
});
|
|
18396
18396
|
ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
18397
18397
|
$ZodSuccess.init(inst, def);
|
|
18398
18398
|
ZodType.init(inst, def);
|
|
18399
|
-
inst._zod.processJSONSchema = (
|
|
18399
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => successProcessor(inst, ctx2, json3, params);
|
|
18400
18400
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18401
18401
|
});
|
|
18402
18402
|
ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
18403
18403
|
$ZodCatch.init(inst, def);
|
|
18404
18404
|
ZodType.init(inst, def);
|
|
18405
|
-
inst._zod.processJSONSchema = (
|
|
18405
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => catchProcessor(inst, ctx2, json3, params);
|
|
18406
18406
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18407
18407
|
inst.removeCatch = inst.unwrap;
|
|
18408
18408
|
});
|
|
18409
18409
|
ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
18410
18410
|
$ZodNaN.init(inst, def);
|
|
18411
18411
|
ZodType.init(inst, def);
|
|
18412
|
-
inst._zod.processJSONSchema = (
|
|
18412
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => nanProcessor(inst, ctx2, json3, params);
|
|
18413
18413
|
});
|
|
18414
18414
|
ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
18415
18415
|
$ZodPipe.init(inst, def);
|
|
18416
18416
|
ZodType.init(inst, def);
|
|
18417
|
-
inst._zod.processJSONSchema = (
|
|
18417
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => pipeProcessor(inst, ctx2, json3, params);
|
|
18418
18418
|
inst.in = def.in;
|
|
18419
18419
|
inst.out = def.out;
|
|
18420
18420
|
});
|
|
@@ -18429,35 +18429,35 @@ var init_schemas2 = __esm({
|
|
|
18429
18429
|
ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
18430
18430
|
$ZodReadonly.init(inst, def);
|
|
18431
18431
|
ZodType.init(inst, def);
|
|
18432
|
-
inst._zod.processJSONSchema = (
|
|
18432
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => readonlyProcessor(inst, ctx2, json3, params);
|
|
18433
18433
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18434
18434
|
});
|
|
18435
18435
|
ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
18436
18436
|
$ZodTemplateLiteral.init(inst, def);
|
|
18437
18437
|
ZodType.init(inst, def);
|
|
18438
|
-
inst._zod.processJSONSchema = (
|
|
18438
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => templateLiteralProcessor(inst, ctx2, json3, params);
|
|
18439
18439
|
});
|
|
18440
18440
|
ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
18441
18441
|
$ZodLazy.init(inst, def);
|
|
18442
18442
|
ZodType.init(inst, def);
|
|
18443
|
-
inst._zod.processJSONSchema = (
|
|
18443
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => lazyProcessor(inst, ctx2, json3, params);
|
|
18444
18444
|
inst.unwrap = () => inst._zod.def.getter();
|
|
18445
18445
|
});
|
|
18446
18446
|
ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
18447
18447
|
$ZodPromise.init(inst, def);
|
|
18448
18448
|
ZodType.init(inst, def);
|
|
18449
|
-
inst._zod.processJSONSchema = (
|
|
18449
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => promiseProcessor(inst, ctx2, json3, params);
|
|
18450
18450
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
18451
18451
|
});
|
|
18452
18452
|
ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
18453
18453
|
$ZodFunction.init(inst, def);
|
|
18454
18454
|
ZodType.init(inst, def);
|
|
18455
|
-
inst._zod.processJSONSchema = (
|
|
18455
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => functionProcessor(inst, ctx2, json3, params);
|
|
18456
18456
|
});
|
|
18457
18457
|
ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
18458
18458
|
$ZodCustom.init(inst, def);
|
|
18459
18459
|
ZodType.init(inst, def);
|
|
18460
|
-
inst._zod.processJSONSchema = (
|
|
18460
|
+
inst._zod.processJSONSchema = (ctx2, json3, params) => customProcessor(inst, ctx2, json3, params);
|
|
18461
18461
|
});
|
|
18462
18462
|
describe2 = describe;
|
|
18463
18463
|
meta2 = meta;
|
|
@@ -18514,25 +18514,25 @@ function detectVersion(schema, defaultTarget) {
|
|
|
18514
18514
|
}
|
|
18515
18515
|
return defaultTarget ?? "draft-2020-12";
|
|
18516
18516
|
}
|
|
18517
|
-
function resolveRef(ref,
|
|
18517
|
+
function resolveRef(ref, ctx2) {
|
|
18518
18518
|
if (!ref.startsWith("#")) {
|
|
18519
18519
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18520
18520
|
}
|
|
18521
18521
|
const path5 = ref.slice(1).split("/").filter(Boolean);
|
|
18522
18522
|
if (path5.length === 0) {
|
|
18523
|
-
return
|
|
18523
|
+
return ctx2.rootSchema;
|
|
18524
18524
|
}
|
|
18525
|
-
const defsKey =
|
|
18525
|
+
const defsKey = ctx2.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18526
18526
|
if (path5[0] === defsKey) {
|
|
18527
18527
|
const key2 = path5[1];
|
|
18528
|
-
if (!key2 || !
|
|
18528
|
+
if (!key2 || !ctx2.defs[key2]) {
|
|
18529
18529
|
throw new Error(`Reference not found: ${ref}`);
|
|
18530
18530
|
}
|
|
18531
|
-
return
|
|
18531
|
+
return ctx2.defs[key2];
|
|
18532
18532
|
}
|
|
18533
18533
|
throw new Error(`Reference not found: ${ref}`);
|
|
18534
18534
|
}
|
|
18535
|
-
function convertBaseSchema(schema,
|
|
18535
|
+
function convertBaseSchema(schema, ctx2) {
|
|
18536
18536
|
if (schema.not !== void 0) {
|
|
18537
18537
|
if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
|
|
18538
18538
|
return z.never();
|
|
@@ -18553,27 +18553,27 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18553
18553
|
}
|
|
18554
18554
|
if (schema.$ref) {
|
|
18555
18555
|
const refPath = schema.$ref;
|
|
18556
|
-
if (
|
|
18557
|
-
return
|
|
18556
|
+
if (ctx2.refs.has(refPath)) {
|
|
18557
|
+
return ctx2.refs.get(refPath);
|
|
18558
18558
|
}
|
|
18559
|
-
if (
|
|
18559
|
+
if (ctx2.processing.has(refPath)) {
|
|
18560
18560
|
return z.lazy(() => {
|
|
18561
|
-
if (!
|
|
18561
|
+
if (!ctx2.refs.has(refPath)) {
|
|
18562
18562
|
throw new Error(`Circular reference not resolved: ${refPath}`);
|
|
18563
18563
|
}
|
|
18564
|
-
return
|
|
18564
|
+
return ctx2.refs.get(refPath);
|
|
18565
18565
|
});
|
|
18566
18566
|
}
|
|
18567
|
-
|
|
18568
|
-
const resolved = resolveRef(refPath,
|
|
18569
|
-
const zodSchema2 = convertSchema(resolved,
|
|
18570
|
-
|
|
18571
|
-
|
|
18567
|
+
ctx2.processing.add(refPath);
|
|
18568
|
+
const resolved = resolveRef(refPath, ctx2);
|
|
18569
|
+
const zodSchema2 = convertSchema(resolved, ctx2);
|
|
18570
|
+
ctx2.refs.set(refPath, zodSchema2);
|
|
18571
|
+
ctx2.processing.delete(refPath);
|
|
18572
18572
|
return zodSchema2;
|
|
18573
18573
|
}
|
|
18574
18574
|
if (schema.enum !== void 0) {
|
|
18575
18575
|
const enumValues = schema.enum;
|
|
18576
|
-
if (
|
|
18576
|
+
if (ctx2.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
|
|
18577
18577
|
return z.null();
|
|
18578
18578
|
}
|
|
18579
18579
|
if (enumValues.length === 0) {
|
|
@@ -18598,7 +18598,7 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18598
18598
|
if (Array.isArray(type)) {
|
|
18599
18599
|
const typeSchemas = type.map((t) => {
|
|
18600
18600
|
const typeSchema = { ...schema, type: t };
|
|
18601
|
-
return convertBaseSchema(typeSchema,
|
|
18601
|
+
return convertBaseSchema(typeSchema, ctx2);
|
|
18602
18602
|
});
|
|
18603
18603
|
if (typeSchemas.length === 0) {
|
|
18604
18604
|
return z.never();
|
|
@@ -18715,12 +18715,12 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18715
18715
|
const properties = schema.properties || {};
|
|
18716
18716
|
const requiredSet = new Set(schema.required || []);
|
|
18717
18717
|
for (const [key2, propSchema] of Object.entries(properties)) {
|
|
18718
|
-
const propZodSchema = convertSchema(propSchema,
|
|
18718
|
+
const propZodSchema = convertSchema(propSchema, ctx2);
|
|
18719
18719
|
shape[key2] = requiredSet.has(key2) ? propZodSchema : propZodSchema.optional();
|
|
18720
18720
|
}
|
|
18721
18721
|
if (schema.propertyNames) {
|
|
18722
|
-
const keySchema = convertSchema(schema.propertyNames,
|
|
18723
|
-
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties,
|
|
18722
|
+
const keySchema = convertSchema(schema.propertyNames, ctx2);
|
|
18723
|
+
const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx2) : z.any();
|
|
18724
18724
|
if (Object.keys(shape).length === 0) {
|
|
18725
18725
|
zodSchema = z.record(keySchema, valueSchema);
|
|
18726
18726
|
break;
|
|
@@ -18735,7 +18735,7 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18735
18735
|
const patternKeys = Object.keys(patternProps);
|
|
18736
18736
|
const looseRecords = [];
|
|
18737
18737
|
for (const pattern of patternKeys) {
|
|
18738
|
-
const patternValue = convertSchema(patternProps[pattern],
|
|
18738
|
+
const patternValue = convertSchema(patternProps[pattern], ctx2);
|
|
18739
18739
|
const keySchema = z.string().regex(new RegExp(pattern));
|
|
18740
18740
|
looseRecords.push(z.looseRecord(keySchema, patternValue));
|
|
18741
18741
|
}
|
|
@@ -18761,7 +18761,7 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18761
18761
|
if (schema.additionalProperties === false) {
|
|
18762
18762
|
zodSchema = objectSchema.strict();
|
|
18763
18763
|
} else if (typeof schema.additionalProperties === "object") {
|
|
18764
|
-
zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties,
|
|
18764
|
+
zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx2));
|
|
18765
18765
|
} else {
|
|
18766
18766
|
zodSchema = objectSchema.passthrough();
|
|
18767
18767
|
}
|
|
@@ -18771,8 +18771,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18771
18771
|
const prefixItems = schema.prefixItems;
|
|
18772
18772
|
const items = schema.items;
|
|
18773
18773
|
if (prefixItems && Array.isArray(prefixItems)) {
|
|
18774
|
-
const tupleItems = prefixItems.map((item) => convertSchema(item,
|
|
18775
|
-
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items,
|
|
18774
|
+
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx2));
|
|
18775
|
+
const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx2) : void 0;
|
|
18776
18776
|
if (rest) {
|
|
18777
18777
|
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
18778
18778
|
} else {
|
|
@@ -18785,8 +18785,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18785
18785
|
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
18786
18786
|
}
|
|
18787
18787
|
} else if (Array.isArray(items)) {
|
|
18788
|
-
const tupleItems = items.map((item) => convertSchema(item,
|
|
18789
|
-
const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems,
|
|
18788
|
+
const tupleItems = items.map((item) => convertSchema(item, ctx2));
|
|
18789
|
+
const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx2) : void 0;
|
|
18790
18790
|
if (rest) {
|
|
18791
18791
|
zodSchema = z.tuple(tupleItems).rest(rest);
|
|
18792
18792
|
} else {
|
|
@@ -18799,7 +18799,7 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18799
18799
|
zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
|
|
18800
18800
|
}
|
|
18801
18801
|
} else if (items !== void 0) {
|
|
18802
|
-
const element = convertSchema(items,
|
|
18802
|
+
const element = convertSchema(items, ctx2);
|
|
18803
18803
|
let arraySchema = z.array(element);
|
|
18804
18804
|
if (typeof schema.minItems === "number") {
|
|
18805
18805
|
arraySchema = arraySchema.min(schema.minItems);
|
|
@@ -18818,19 +18818,19 @@ function convertBaseSchema(schema, ctx) {
|
|
|
18818
18818
|
}
|
|
18819
18819
|
return zodSchema;
|
|
18820
18820
|
}
|
|
18821
|
-
function convertSchema(schema,
|
|
18821
|
+
function convertSchema(schema, ctx2) {
|
|
18822
18822
|
if (typeof schema === "boolean") {
|
|
18823
18823
|
return schema ? z.any() : z.never();
|
|
18824
18824
|
}
|
|
18825
|
-
let baseSchema = convertBaseSchema(schema,
|
|
18825
|
+
let baseSchema = convertBaseSchema(schema, ctx2);
|
|
18826
18826
|
const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
|
|
18827
18827
|
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
18828
|
-
const options = schema.anyOf.map((s) => convertSchema(s,
|
|
18828
|
+
const options = schema.anyOf.map((s) => convertSchema(s, ctx2));
|
|
18829
18829
|
const anyOfUnion = z.union(options);
|
|
18830
18830
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
18831
18831
|
}
|
|
18832
18832
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
18833
|
-
const options = schema.oneOf.map((s) => convertSchema(s,
|
|
18833
|
+
const options = schema.oneOf.map((s) => convertSchema(s, ctx2));
|
|
18834
18834
|
const oneOfUnion = z.xor(options);
|
|
18835
18835
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
18836
18836
|
}
|
|
@@ -18838,15 +18838,15 @@ function convertSchema(schema, ctx) {
|
|
|
18838
18838
|
if (schema.allOf.length === 0) {
|
|
18839
18839
|
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
18840
18840
|
} else {
|
|
18841
|
-
let result2 = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0],
|
|
18841
|
+
let result2 = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx2);
|
|
18842
18842
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
18843
18843
|
for (let i = startIdx; i < schema.allOf.length; i++) {
|
|
18844
|
-
result2 = z.intersection(result2, convertSchema(schema.allOf[i],
|
|
18844
|
+
result2 = z.intersection(result2, convertSchema(schema.allOf[i], ctx2));
|
|
18845
18845
|
}
|
|
18846
18846
|
baseSchema = result2;
|
|
18847
18847
|
}
|
|
18848
18848
|
}
|
|
18849
|
-
if (schema.nullable === true &&
|
|
18849
|
+
if (schema.nullable === true && ctx2.version === "openapi-3.0") {
|
|
18850
18850
|
baseSchema = z.nullable(baseSchema);
|
|
18851
18851
|
}
|
|
18852
18852
|
if (schema.readOnly === true) {
|
|
@@ -18874,7 +18874,7 @@ function convertSchema(schema, ctx) {
|
|
|
18874
18874
|
}
|
|
18875
18875
|
}
|
|
18876
18876
|
if (Object.keys(extraMeta).length > 0) {
|
|
18877
|
-
|
|
18877
|
+
ctx2.registry.add(baseSchema, extraMeta);
|
|
18878
18878
|
}
|
|
18879
18879
|
if (schema.description) {
|
|
18880
18880
|
baseSchema = baseSchema.describe(schema.description);
|
|
@@ -18893,7 +18893,7 @@ function fromJSONSchema(schema, params) {
|
|
|
18893
18893
|
}
|
|
18894
18894
|
const version2 = detectVersion(normalized, params?.defaultTarget);
|
|
18895
18895
|
const defs = normalized.$defs || normalized.definitions || {};
|
|
18896
|
-
const
|
|
18896
|
+
const ctx2 = {
|
|
18897
18897
|
version: version2,
|
|
18898
18898
|
defs,
|
|
18899
18899
|
refs: /* @__PURE__ */ new Map(),
|
|
@@ -18901,7 +18901,7 @@ function fromJSONSchema(schema, params) {
|
|
|
18901
18901
|
rootSchema: normalized,
|
|
18902
18902
|
registry: params?.registry ?? globalRegistry
|
|
18903
18903
|
};
|
|
18904
|
-
return convertSchema(normalized,
|
|
18904
|
+
return convertSchema(normalized, ctx2);
|
|
18905
18905
|
}
|
|
18906
18906
|
var z, RECOGNIZED_KEYS;
|
|
18907
18907
|
var init_from_json_schema = __esm({
|
|
@@ -21840,16 +21840,16 @@ var init_interaction = __esm({
|
|
|
21840
21840
|
});
|
|
21841
21841
|
|
|
21842
21842
|
// ../../packages/os-control/dist/registry.js
|
|
21843
|
-
function withConsent(
|
|
21844
|
-
if (!
|
|
21845
|
-
return
|
|
21846
|
-
const inner =
|
|
21843
|
+
function withConsent(tool9, consent) {
|
|
21844
|
+
if (!tool9.destructive)
|
|
21845
|
+
return tool9;
|
|
21846
|
+
const inner = tool9.handler;
|
|
21847
21847
|
return {
|
|
21848
|
-
...
|
|
21848
|
+
...tool9,
|
|
21849
21849
|
handler: async (args) => {
|
|
21850
|
-
const verdict = await consent({ name:
|
|
21850
|
+
const verdict = await consent({ name: tool9.name, destructive: tool9.destructive }, args);
|
|
21851
21851
|
if (verdict !== true) {
|
|
21852
|
-
return text3(typeof verdict === "string" ? verdict : `Refused: "${
|
|
21852
|
+
return text3(typeof verdict === "string" ? verdict : `Refused: "${tool9.name}" is a state-changing action and is not permitted by the current policy.`, true);
|
|
21853
21853
|
}
|
|
21854
21854
|
return inner(args);
|
|
21855
21855
|
}
|
|
@@ -21911,14 +21911,144 @@ var init_os_control_tools = __esm({
|
|
|
21911
21911
|
}
|
|
21912
21912
|
});
|
|
21913
21913
|
|
|
21914
|
-
// ../../packages/agent-core/dist/
|
|
21914
|
+
// ../../packages/agent-core/dist/screen-control-tools.js
|
|
21915
21915
|
import { tool as tool6 } from "@anthropic-ai/claude-agent-sdk";
|
|
21916
|
+
function specParametersJsonSchema(spec) {
|
|
21917
|
+
const properties = {};
|
|
21918
|
+
const required2 = [];
|
|
21919
|
+
for (const [key2, pp] of Object.entries(spec.params)) {
|
|
21920
|
+
properties[key2] = { type: pp.type, description: pp.description, ...pp.enum ? { enum: [...pp.enum] } : {} };
|
|
21921
|
+
if (pp.required)
|
|
21922
|
+
required2.push(key2);
|
|
21923
|
+
}
|
|
21924
|
+
return required2.length ? { type: "object", properties, required: required2 } : { type: "object", properties };
|
|
21925
|
+
}
|
|
21926
|
+
function zodShapeFromParams(params) {
|
|
21927
|
+
const shape = {};
|
|
21928
|
+
for (const [key2, pp] of Object.entries(params)) {
|
|
21929
|
+
let zt = pp.enum ? external_exports.enum([...pp.enum]) : pp.type === "number" ? external_exports.number() : pp.type === "boolean" ? external_exports.boolean() : external_exports.string();
|
|
21930
|
+
zt = zt.describe(pp.description);
|
|
21931
|
+
shape[key2] = pp.required ? zt : zt.optional();
|
|
21932
|
+
}
|
|
21933
|
+
return shape;
|
|
21934
|
+
}
|
|
21935
|
+
function buildScreenControlSdkTools(p) {
|
|
21936
|
+
return SCREEN_CONTROL_SPECS.map((spec) => tool6(spec.name, spec.description, zodShapeFromParams(spec.params), async (args) => {
|
|
21937
|
+
const text4 = await p.exec(spec.name, args ?? {});
|
|
21938
|
+
return { content: [{ type: "text", text: text4 || "Done." }] };
|
|
21939
|
+
}));
|
|
21940
|
+
}
|
|
21941
|
+
var ANNOTATE_STYLES, SCREEN_CONTROL_SPECS;
|
|
21942
|
+
var init_screen_control_tools = __esm({
|
|
21943
|
+
"../../packages/agent-core/dist/screen-control-tools.js"() {
|
|
21944
|
+
"use strict";
|
|
21945
|
+
init_zod();
|
|
21946
|
+
ANNOTATE_STYLES = ["auto", "circle", "box", "bracket", "underline", "zigzag", "strike", "highlight", "arrow", "check", "cross", "star", "scribble", "cloud", "caret"];
|
|
21947
|
+
SCREEN_CONTROL_SPECS = [
|
|
21948
|
+
{
|
|
21949
|
+
name: "look_at_screen",
|
|
21950
|
+
description: "Look at the developer's current screen. This gives you the screen IMAGE plus a detailed description from a strong vision model: the focused app/window and its contents, the main page/content, any dialog/menu/notification, any selection or active field, where the MOUSE pointer is, and what it's hovering over. Call it whenever you need to know what's on screen \u2014 'what's on my screen / what do you see / read this / where's my cursor', or to check the result of an action.",
|
|
21951
|
+
params: {}
|
|
21952
|
+
},
|
|
21953
|
+
{
|
|
21954
|
+
name: "figure_out_next",
|
|
21955
|
+
description: "Your GET-UNSTUCK button. Call this whenever you're confused, an action didn't do what you expected, or you've hit something you don't know how to handle (a dialog, a 'See options' / size-or-color picker, a login wall, a page that won't load, an unexpected screen). A stronger model looks at the screen and EVERYTHING you've been doing, then hands you back the goal plus the exact next steps to get past it. Then carry those steps out (with perform_step). Use this BEFORE flailing with random clicks or stopping to ask the developer.",
|
|
21956
|
+
params: {}
|
|
21957
|
+
},
|
|
21958
|
+
{
|
|
21959
|
+
name: "verify",
|
|
21960
|
+
description: "Check whether something is ACTUALLY true on the screen right now \u2014 your CHECKPOINT after an action or plan step. Describe what you expect (e.g. 'a new browser tab is open', 'Google Chrome is the active app', 'the Amazon search results for jeans are showing', 'the item was added to the cart'). A strong vision model looks and answers YES or NO with what it really sees. ALWAYS use this to confirm a step worked before moving on \u2014 never assume or claim a result you haven't verified.",
|
|
21961
|
+
params: { expectation: { type: "string", required: true, description: "What you expect to be true on the screen, in plain words." } }
|
|
21962
|
+
},
|
|
21963
|
+
{
|
|
21964
|
+
name: "perform_step",
|
|
21965
|
+
description: "Do ONE step described in plain words; a stronger model works out the exact sequence of clicks/typing and RUNS it in order for you (so nothing races), then tells you what the screen shows afterward. Use this for ANY step that needs more than one action \u2014 e.g. 'search Amazon for jeans', 'open a new tab and go to gmail.com', 'add the first result to the cart', 'log in with this email and password'. PREFER this over firing click/press_key yourself.",
|
|
21966
|
+
params: { instruction: { type: "string", required: true, description: "The single step to perform, in plain words." } }
|
|
21967
|
+
},
|
|
21968
|
+
{
|
|
21969
|
+
name: "type_into",
|
|
21970
|
+
description: "Type text INTO a field in one reliable action \u2014 it clicks the field to focus it, then types, then optionally presses Enter. Use this for any 'type X in the search box / address bar / field' instead of doing click then typing yourself (which races and the text goes nowhere).",
|
|
21971
|
+
params: {
|
|
21972
|
+
field: { type: "string", required: true, description: 'The field to type into, described (e.g. "the Amazon search box", "the address bar").' },
|
|
21973
|
+
text: { type: "string", required: true, description: "The text to type." },
|
|
21974
|
+
submit: { type: "boolean", description: "Press Enter after typing, to search/go. Default false." }
|
|
21975
|
+
}
|
|
21976
|
+
},
|
|
21977
|
+
{
|
|
21978
|
+
name: "click",
|
|
21979
|
+
description: "Click a UI element by DESCRIBING it in plain words \u2014 do NOT pass coordinates. The system finds its exact location (the macOS accessibility tree first, then a vision model) and clicks it precisely. Be specific and include any visible label/text.",
|
|
21980
|
+
params: {
|
|
21981
|
+
target: { type: "string", required: true, description: 'What to click, described precisely \u2014 e.g. "the Google Chrome icon in the Dock", "the blue Sign in button", "the address bar", "the Submit button at the bottom of the form".' },
|
|
21982
|
+
button: { type: "string", enum: ["left", "right"], description: "Mouse button (default left)." },
|
|
21983
|
+
double: { type: "boolean", description: "Double-click when true." }
|
|
21984
|
+
}
|
|
21985
|
+
},
|
|
21986
|
+
{
|
|
21987
|
+
name: "launch_app",
|
|
21988
|
+
description: 'Open / launch / switch to an application by name (e.g. "Google Chrome", "Safari", "Terminal", "System Settings"). This is the RELIABLE way to open an app \u2014 use it instead of hunting for a Dock icon to click.',
|
|
21989
|
+
params: { name: { type: "string", required: true, description: 'The application name, e.g. "Google Chrome".' } }
|
|
21990
|
+
},
|
|
21991
|
+
{
|
|
21992
|
+
name: "annotate",
|
|
21993
|
+
description: "POINT something out on the developer's screen with a hand-drawn red marker doodle (animated as if drawn live). Use it for 'where is X', 'show me X', 'point at X', 'underline X', 'cross out X', 'check off X', 'highlight X'. It only highlights \u2014 it does NOT click. Pick the style that fits what they asked; omit it for an auto choice based on the item's shape.",
|
|
21994
|
+
params: {
|
|
21995
|
+
target: { type: "string", required: true, description: "What to mark, described precisely." },
|
|
21996
|
+
style: { type: "string", enum: ANNOTATE_STYLES, description: "Which kind of doodle: circle/box/bracket to enclose; underline/zigzag/highlight to emphasise text; arrow to point; check/cross/star to mark; strike to cross through. Default auto." },
|
|
21997
|
+
label: { type: "string", description: 'Optional short text to write next to it, e.g. "Here!".' }
|
|
21998
|
+
}
|
|
21999
|
+
},
|
|
22000
|
+
{
|
|
22001
|
+
name: "remove_annotations",
|
|
22002
|
+
description: "Clear ALL the marker doodles you've drawn on the screen. Call this when you move on to a different topic or the developer asks you to remove them. Annotations otherwise stay on screen.",
|
|
22003
|
+
params: {}
|
|
22004
|
+
},
|
|
22005
|
+
{
|
|
22006
|
+
name: "press_key",
|
|
22007
|
+
description: 'Press a key or combo, e.g. "enter", "esc", "cmd+a", "cmd+c", "tab".',
|
|
22008
|
+
params: { keys: { type: "string", required: true, description: 'Key or combo like "enter" or "cmd+c".' } }
|
|
22009
|
+
},
|
|
22010
|
+
{
|
|
22011
|
+
name: "scroll_screen",
|
|
22012
|
+
description: "Scroll the screen (at the centre). Positive dy scrolls down, negative up.",
|
|
22013
|
+
params: {
|
|
22014
|
+
dy: { type: "number", required: true, description: "Vertical amount; positive scrolls down." },
|
|
22015
|
+
dx: { type: "number", description: "Horizontal amount; positive scrolls right." }
|
|
22016
|
+
}
|
|
22017
|
+
},
|
|
22018
|
+
{
|
|
22019
|
+
name: "draw_shape",
|
|
22020
|
+
description: "DRAW a basic shape on the screen with the mouse (the drawing app's brush/pen/shape tool must already be selected): a line, arrow, rectangle, ellipse, or underline. For rectangle/ellipse/underline give the target to draw on/around; for line/arrow give a start (target) and an end (to). Drawn at a natural human pace.",
|
|
22021
|
+
params: {
|
|
22022
|
+
shape: { type: "string", required: true, enum: ["line", "arrow", "rectangle", "ellipse", "underline"], description: "The shape to draw." },
|
|
22023
|
+
target: { type: "string", required: true, description: "What to draw on/around (rectangle/ellipse/underline), or the START point (line/arrow), in plain words." },
|
|
22024
|
+
to: { type: "string", description: "The END point for a line/arrow, in plain words." }
|
|
22025
|
+
}
|
|
22026
|
+
},
|
|
22027
|
+
{
|
|
22028
|
+
name: "draw_sketch",
|
|
22029
|
+
description: "Freehand-DRAW a simple line sketch of something with the mouse \u2014 e.g. 'a stick figure', 'a house', 'a smiley face', 'a star'. The brush/pen must already be selected in the drawing app. It will be a simple, child-like line drawing made at a natural pace. Optionally say WHERE to draw it.",
|
|
22030
|
+
params: {
|
|
22031
|
+
subject: { type: "string", required: true, description: 'What to draw, e.g. "a stick figure".' },
|
|
22032
|
+
where: { type: "string", description: 'Where to draw it, described (e.g. "the centre of the canvas"). Omit for the centre of the screen.' }
|
|
22033
|
+
}
|
|
22034
|
+
},
|
|
22035
|
+
{
|
|
22036
|
+
name: "release_control",
|
|
22037
|
+
description: "Stop controlling the computer when you've finished the on-screen task. Removes the coral cursor and the 'working with your computer' bar. Call this as soon as you're done acting on the screen.",
|
|
22038
|
+
params: {}
|
|
22039
|
+
}
|
|
22040
|
+
];
|
|
22041
|
+
}
|
|
22042
|
+
});
|
|
22043
|
+
|
|
22044
|
+
// ../../packages/agent-core/dist/report-tools.js
|
|
22045
|
+
import { tool as tool7 } from "@anthropic-ai/claude-agent-sdk";
|
|
21916
22046
|
function slug(s) {
|
|
21917
22047
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "mission";
|
|
21918
22048
|
}
|
|
21919
22049
|
function buildReportTools(deps) {
|
|
21920
22050
|
return [
|
|
21921
|
-
|
|
22051
|
+
tool7("emit_report", `Deliver the structured findings of a mission playbook run as a Report card in the chat (this is the deliverable \u2014 do NOT just write findings as prose). Call it ONCE near the end with all findings grouped into the playbook's sections. To UPDATE after fixing/verifying a finding (Fix / Re-run), call again with the SAME id and finding ids, changing each finding's status \u2014 it re-renders in place. For "legal" bucket reports, never claim the site is compliant/certified; describe risks and route the verdict to a human.`, {
|
|
21922
22052
|
id: external_exports.string().optional().describe("Stable report id to UPDATE an existing report; omit on the first call to create one."),
|
|
21923
22053
|
playbookId: external_exports.string().describe("The playbook id this report belongs to."),
|
|
21924
22054
|
title: external_exports.string().describe("Report title (usually the playbook name)."),
|
|
@@ -21971,10 +22101,10 @@ var init_report_tools = __esm({
|
|
|
21971
22101
|
});
|
|
21972
22102
|
|
|
21973
22103
|
// ../../packages/agent-core/dist/interactive-ui-tools.js
|
|
21974
|
-
import { tool as
|
|
22104
|
+
import { tool as tool8 } from "@anthropic-ai/claude-agent-sdk";
|
|
21975
22105
|
function buildInteractiveUiTools(deps) {
|
|
21976
22106
|
return [
|
|
21977
|
-
|
|
22107
|
+
tool8("ask_form", "Show the user a FORM in the chat and wait for them to fill it in. Use this to collect structured input mid-task (settings, scope, details) instead of asking in prose. Returns the submitted values (or that the user cancelled). Prefer this over free-text questions when the answer is structured.", {
|
|
21978
22108
|
title: external_exports.string().describe("Form heading (plain language)."),
|
|
21979
22109
|
description: external_exports.string().optional().describe("Short explanation shown above the fields."),
|
|
21980
22110
|
submitLabel: external_exports.string().optional().describe('Submit button label (default "Submit").'),
|
|
@@ -21988,7 +22118,7 @@ function buildInteractiveUiTools(deps) {
|
|
|
21988
22118
|
return { content: [{ type: "text", text: `The user submitted the form:
|
|
21989
22119
|
${JSON.stringify(res.values ?? {}, null, 2)}` }] };
|
|
21990
22120
|
}),
|
|
21991
|
-
|
|
22121
|
+
tool8("present_choices", "Show the user a CHOICE picker in the chat and wait for them to choose. Use this to let the user make a decision or pick from options (single or multi-select). Returns the selected value(s) (or cancellation).", {
|
|
21992
22122
|
title: external_exports.string().describe("The question / heading."),
|
|
21993
22123
|
description: external_exports.string().optional(),
|
|
21994
22124
|
options: external_exports.array(choiceOption).min(1),
|
|
@@ -22001,7 +22131,7 @@ ${JSON.stringify(res.values ?? {}, null, 2)}` }] };
|
|
|
22001
22131
|
return { content: [{ type: "text", text: "The user cancelled the choice (nothing selected)." }] };
|
|
22002
22132
|
return { content: [{ type: "text", text: `The user selected: ${JSON.stringify(res.selected ?? [])}` }] };
|
|
22003
22133
|
}),
|
|
22004
|
-
|
|
22134
|
+
tool8("update_progress", `Update the live Mission card so the user sees ongoing status. Call this whenever you move between stages (and once at the start). Pass the FULL ordered stage list each time with each stage's current status, plus a short "what I'm doing now" note. This is a one-way feedback channel \u2014 it returns immediately, does not wait for the user.`, {
|
|
22005
22135
|
stages: external_exports.array(external_exports.object({
|
|
22006
22136
|
label: external_exports.string(),
|
|
22007
22137
|
status: external_exports.enum(["pending", "active", "done"])
|
|
@@ -22678,21 +22808,25 @@ var init_session_store = __esm({
|
|
|
22678
22808
|
* Returns the new session id, or null on failure. NOTE: forked sessions start
|
|
22679
22809
|
* WITHOUT file-history/undo snapshots (SDK behavior). */
|
|
22680
22810
|
async forkSession(sessionId, opts) {
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22811
|
+
const dirs = opts?.projectDir ? [opts.projectDir, void 0] : [void 0];
|
|
22812
|
+
for (const dir2 of dirs) {
|
|
22813
|
+
for (let attempt = 0; ; attempt++) {
|
|
22814
|
+
try {
|
|
22815
|
+
const upToMessageId = opts?.upToMessageId ?? await this.lastResumableMessageId(sessionId, dir2);
|
|
22816
|
+
const result2 = await forkSession(sessionId, {
|
|
22817
|
+
...dir2 ? { dir: dir2 } : {},
|
|
22818
|
+
...upToMessageId ? { upToMessageId } : {},
|
|
22819
|
+
...opts?.title ? { title: opts.title } : {}
|
|
22820
|
+
});
|
|
22821
|
+
return result2.sessionId;
|
|
22822
|
+
} catch {
|
|
22823
|
+
if (attempt >= FORK_RETRY_ATTEMPTS)
|
|
22824
|
+
break;
|
|
22825
|
+
await delay(FORK_RETRY_DELAY_MS);
|
|
22826
|
+
}
|
|
22694
22827
|
}
|
|
22695
22828
|
}
|
|
22829
|
+
return null;
|
|
22696
22830
|
}
|
|
22697
22831
|
/** The uuid of the last transcript message after which NO tool_use is left without
|
|
22698
22832
|
* its tool_result — the safe point to fork at. Reads the same on-disk `.jsonl` the
|
|
@@ -22937,11 +23071,11 @@ import { writeFile as writeFile4, mkdir as mkdir4, readFile as readFile6 } from
|
|
|
22937
23071
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22938
23072
|
import { tmpdir, homedir as homedir4 } from "node:os";
|
|
22939
23073
|
import { join as join9, dirname as dirname5 } from "node:path";
|
|
22940
|
-
import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
23074
|
+
import { existsSync as existsSync2, readFileSync as readFileSync3, readdirSync } from "node:fs";
|
|
22941
23075
|
import { fileURLToPath } from "node:url";
|
|
22942
23076
|
import { createRequire } from "node:module";
|
|
22943
23077
|
import { createServer } from "node:net";
|
|
22944
|
-
import { spawn as spawn2, execSync } from "node:child_process";
|
|
23078
|
+
import { spawn as spawn2, execSync, execFileSync } from "node:child_process";
|
|
22945
23079
|
function findClaudeCliJs() {
|
|
22946
23080
|
const require2 = createRequire(import.meta.url);
|
|
22947
23081
|
const sdkMain = require2.resolve("@anthropic-ai/claude-agent-sdk");
|
|
@@ -22951,6 +23085,56 @@ function findClaudeCliJs() {
|
|
|
22951
23085
|
}
|
|
22952
23086
|
return cliJs;
|
|
22953
23087
|
}
|
|
23088
|
+
function newestVersionManagerNode() {
|
|
23089
|
+
const home = homedir4();
|
|
23090
|
+
for (const p of [
|
|
23091
|
+
join9(home, ".volta", "bin", "node"),
|
|
23092
|
+
join9(home, "Library", "pnpm", "node"),
|
|
23093
|
+
join9(home, ".local", "bin", "node")
|
|
23094
|
+
])
|
|
23095
|
+
if (existsSync2(p))
|
|
23096
|
+
return p;
|
|
23097
|
+
const roots = [
|
|
23098
|
+
{ dir: join9(home, ".nvm", "versions", "node"), bin: (v) => join9(v, "bin", "node") },
|
|
23099
|
+
{ dir: join9(home, ".local", "share", "fnm", "node-versions"), bin: (v) => join9(v, "installation", "bin", "node") },
|
|
23100
|
+
{ dir: join9(home, "Library", "Application Support", "fnm", "node-versions"), bin: (v) => join9(v, "installation", "bin", "node") },
|
|
23101
|
+
{ dir: join9(home, "n", "versions", "node"), bin: (v) => join9(v, "bin", "node") }
|
|
23102
|
+
];
|
|
23103
|
+
let best = null;
|
|
23104
|
+
for (const { dir: dir2, bin } of roots) {
|
|
23105
|
+
let names;
|
|
23106
|
+
try {
|
|
23107
|
+
names = readdirSync(dir2);
|
|
23108
|
+
} catch {
|
|
23109
|
+
continue;
|
|
23110
|
+
}
|
|
23111
|
+
for (const name of names) {
|
|
23112
|
+
const path5 = bin(join9(dir2, name));
|
|
23113
|
+
if (!existsSync2(path5))
|
|
23114
|
+
continue;
|
|
23115
|
+
const parts = name.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
23116
|
+
const ver = [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
|
|
23117
|
+
const gt = !best || ver[0] > best.ver[0] || ver[0] === best.ver[0] && (ver[1] > best.ver[1] || ver[1] === best.ver[1] && ver[2] > best.ver[2]);
|
|
23118
|
+
if (gt)
|
|
23119
|
+
best = { ver, path: path5 };
|
|
23120
|
+
}
|
|
23121
|
+
}
|
|
23122
|
+
return best?.path ?? null;
|
|
23123
|
+
}
|
|
23124
|
+
function loginShellNode() {
|
|
23125
|
+
if (process.platform === "win32")
|
|
23126
|
+
return null;
|
|
23127
|
+
const shell = process.env.SHELL || "/bin/zsh";
|
|
23128
|
+
if (!existsSync2(shell))
|
|
23129
|
+
return null;
|
|
23130
|
+
try {
|
|
23131
|
+
const out = execFileSync(shell, ["-lic", `printf '<<NODE:%s>>' "$(command -v node 2>/dev/null)"`], { encoding: "utf8", timeout: 4e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
23132
|
+
const path5 = out.match(/<<NODE:(.*?)>>/)?.[1]?.trim();
|
|
23133
|
+
return path5 && existsSync2(path5) ? path5 : null;
|
|
23134
|
+
} catch {
|
|
23135
|
+
return null;
|
|
23136
|
+
}
|
|
23137
|
+
}
|
|
22954
23138
|
function resolveNodeExecutable() {
|
|
22955
23139
|
if (cachedNodeExe !== void 0)
|
|
22956
23140
|
return cachedNodeExe;
|
|
@@ -22961,13 +23145,25 @@ function resolveNodeExecutable() {
|
|
|
22961
23145
|
return cachedNodeExe = p;
|
|
22962
23146
|
}
|
|
22963
23147
|
try {
|
|
22964
|
-
const found = execSync(process.platform === "win32" ? "where node" : "command -v node", { encoding: "utf8" }).split(/\r?\n/)[0].trim();
|
|
23148
|
+
const found = execSync(process.platform === "win32" ? "where node" : "command -v node", { encoding: "utf8", timeout: 3e3 }).split(/\r?\n/)[0].trim();
|
|
22965
23149
|
if (found && existsSync2(found))
|
|
22966
23150
|
return cachedNodeExe = found;
|
|
22967
23151
|
} catch {
|
|
22968
23152
|
}
|
|
23153
|
+
const vm = newestVersionManagerNode();
|
|
23154
|
+
if (vm)
|
|
23155
|
+
return cachedNodeExe = vm;
|
|
23156
|
+
const shellNode = loginShellNode();
|
|
23157
|
+
if (shellNode)
|
|
23158
|
+
return cachedNodeExe = shellNode;
|
|
22969
23159
|
return cachedNodeExe = null;
|
|
22970
23160
|
}
|
|
23161
|
+
function warnNoRealNodeOnce() {
|
|
23162
|
+
if (warnedNoNode)
|
|
23163
|
+
return;
|
|
23164
|
+
warnedNoNode = true;
|
|
23165
|
+
log("[agent] no real `node` binary found \u2014 running the Claude CLI via the Electron binary (ELECTRON_RUN_AS_NODE).", "A stray window/Dock tile may briefly appear when a session starts.", "Install Node.js or set CCB_NODE_PATH to a node binary to eliminate it.");
|
|
23166
|
+
}
|
|
22971
23167
|
function extractHumanReadable(message) {
|
|
22972
23168
|
const parts = [];
|
|
22973
23169
|
for (const key2 of HUMAN_READABLE_FIELDS) {
|
|
@@ -23148,7 +23344,7 @@ MOBILE (${fw}):
|
|
|
23148
23344
|
return "";
|
|
23149
23345
|
}
|
|
23150
23346
|
}
|
|
23151
|
-
var cachedNodeExe, HUMAN_READABLE_FIELDS, TOOL_RESULT_CAP, MAX_RESULT_IMAGES, MAX_IMAGE_BASE64, PERMISSION_MODES, EDIT_PREVIEW_CAP, AsyncMessagePump, IDLE_REAP_MS, MODERATE_IDLE_MS, STEER_COALESCE_MS, STOP_HARD_KILL_AFTER_MS, AgentManager;
|
|
23347
|
+
var cachedNodeExe, warnedNoNode, HUMAN_READABLE_FIELDS, TOOL_RESULT_CAP, MAX_RESULT_IMAGES, MAX_IMAGE_BASE64, PERMISSION_MODES, EDIT_PREVIEW_CAP, AsyncMessagePump, IDLE_REAP_MS, MODERATE_IDLE_MS, STEER_COALESCE_MS, STOP_HARD_KILL_AFTER_MS, AgentManager;
|
|
23152
23348
|
var init_agent_manager = __esm({
|
|
23153
23349
|
"../../packages/agent-core/dist/agent-manager.js"() {
|
|
23154
23350
|
"use strict";
|
|
@@ -23158,6 +23354,7 @@ var init_agent_manager = __esm({
|
|
|
23158
23354
|
init_imagegen_tools();
|
|
23159
23355
|
init_canvas_tools();
|
|
23160
23356
|
init_os_control_tools();
|
|
23357
|
+
init_screen_control_tools();
|
|
23161
23358
|
init_report_tools();
|
|
23162
23359
|
init_interactive_ui_tools();
|
|
23163
23360
|
init_session_artifacts();
|
|
@@ -23169,6 +23366,7 @@ var init_agent_manager = __esm({
|
|
|
23169
23366
|
init_session_usage();
|
|
23170
23367
|
init_kill_tree();
|
|
23171
23368
|
init_log();
|
|
23369
|
+
warnedNoNode = false;
|
|
23172
23370
|
HUMAN_READABLE_FIELDS = ["message", "text", "content", "summary", "description", "output", "stdout", "error", "reason", "name"];
|
|
23173
23371
|
TOOL_RESULT_CAP = 16e3;
|
|
23174
23372
|
MAX_RESULT_IMAGES = 4;
|
|
@@ -23288,6 +23486,7 @@ var init_agent_manager = __esm({
|
|
|
23288
23486
|
* 'tesseract-os-control' tools. Default-OFF: the daemon only sets this when the
|
|
23289
23487
|
* user enabled computer control. */
|
|
23290
23488
|
osControlProvider = null;
|
|
23489
|
+
screenControlProvider = null;
|
|
23291
23490
|
/** M6 — scheduling. Built lazily by setCronConfig when cron is enabled. */
|
|
23292
23491
|
cronStore = null;
|
|
23293
23492
|
cronScheduler = null;
|
|
@@ -23326,6 +23525,13 @@ var init_agent_manager = __esm({
|
|
|
23326
23525
|
setComputerControl(provider) {
|
|
23327
23526
|
this.osControlProvider = provider;
|
|
23328
23527
|
}
|
|
23528
|
+
/** Inject the CURATED screen-control bridge (the voice co-pilot's toolset: look_at_screen /
|
|
23529
|
+
* perform_step / click / annotate / …). When set, conversations get the in-process
|
|
23530
|
+
* 'tesseract-screen' MCP, routed through the daemon's ai-control manager (consent + coral cursor).
|
|
23531
|
+
* Read per call, so toggling stops new conversations getting the tools without a restart. */
|
|
23532
|
+
setScreenControl(provider) {
|
|
23533
|
+
this.screenControlProvider = provider;
|
|
23534
|
+
}
|
|
23329
23535
|
/** M6 — enable/disable model-facing scheduling. When enabled, builds a CronStore
|
|
23330
23536
|
* (durable at `file`/`storeDir` if given, else session-only), starts the scheduler
|
|
23331
23537
|
* whose fires dispatch a turn, and exposes the Cron / Sleep / PushNotification tools
|
|
@@ -24172,6 +24378,9 @@ CRITICAL RULES:
|
|
|
24172
24378
|
if (this.osControlProvider) {
|
|
24173
24379
|
mcp["tesseract-os-control"] = createSdkMcpServer({ name: "tesseract-os-control", version: "0.1.0", tools: buildOsControlSdkTools(this.osControlProvider) });
|
|
24174
24380
|
}
|
|
24381
|
+
if (this.screenControlProvider) {
|
|
24382
|
+
mcp["tesseract-screen"] = createSdkMcpServer({ name: "tesseract-screen", version: "0.1.0", tools: buildScreenControlSdkTools(this.screenControlProvider) });
|
|
24383
|
+
}
|
|
24175
24384
|
{
|
|
24176
24385
|
const projectDir = this.projectDir;
|
|
24177
24386
|
const canvasTools = buildCanvasTools({
|
|
@@ -24351,6 +24560,8 @@ CRITICAL RULES:
|
|
|
24351
24560
|
spawnClaudeCodeProcess: (options) => {
|
|
24352
24561
|
const cliJs = findClaudeCliJs();
|
|
24353
24562
|
const nodeExe2 = resolveNodeExecutable();
|
|
24563
|
+
if (!nodeExe2 && process.versions.electron)
|
|
24564
|
+
warnNoRealNodeOnce();
|
|
24354
24565
|
const exe = nodeExe2 ?? process.execPath;
|
|
24355
24566
|
const runAsNode = exe === process.execPath && !!process.versions.electron;
|
|
24356
24567
|
const compileCache = process.env.NODE_COMPILE_CACHE || join9(process.env.CCB_TESSERACT_DIR ?? join9(homedir4(), ".tesseract"), "node-compile-cache");
|
|
@@ -25201,6 +25412,7 @@ __export(dist_exports, {
|
|
|
25201
25412
|
DTCG_TYPES: () => DTCG_TYPES,
|
|
25202
25413
|
DesignTokensSchema: () => DesignTokensSchema,
|
|
25203
25414
|
DtcgTokensSchema: () => DtcgTokensSchema,
|
|
25415
|
+
SCREEN_CONTROL_SPECS: () => SCREEN_CONTROL_SPECS,
|
|
25204
25416
|
SessionStore: () => SessionStore,
|
|
25205
25417
|
TOKENS_CSS_FILE: () => TOKENS_CSS_FILE,
|
|
25206
25418
|
TOKENS_FILE: () => TOKENS_FILE,
|
|
@@ -25210,6 +25422,7 @@ __export(dist_exports, {
|
|
|
25210
25422
|
buildClaudeNarrationLlm: () => buildClaudeNarrationLlm,
|
|
25211
25423
|
buildImagegenTools: () => buildImagegenTools,
|
|
25212
25424
|
buildOsControlSdkTools: () => buildOsControlSdkTools,
|
|
25425
|
+
buildScreenControlSdkTools: () => buildScreenControlSdkTools,
|
|
25213
25426
|
bumpVersion: () => bumpVersion,
|
|
25214
25427
|
contrastRatio: () => contrastRatio,
|
|
25215
25428
|
diffTokens: () => diffTokens,
|
|
@@ -25224,6 +25437,7 @@ __export(dist_exports, {
|
|
|
25224
25437
|
normalizeTokens: () => normalizeTokens,
|
|
25225
25438
|
parseColorToRgb: () => parseColorToRgb,
|
|
25226
25439
|
readSessionArtifacts: () => readSessionArtifacts,
|
|
25440
|
+
resolveNodeExecutable: () => resolveNodeExecutable,
|
|
25227
25441
|
resolveOauthToken: () => resolveOauthToken,
|
|
25228
25442
|
resolveSessionFile: () => resolveSessionFile,
|
|
25229
25443
|
sanitizeProjectDir: () => sanitizeProjectDir,
|
|
@@ -25232,6 +25446,7 @@ __export(dist_exports, {
|
|
|
25232
25446
|
sessionSidecarDir: () => sessionSidecarDir,
|
|
25233
25447
|
setTokenPath: () => setTokenPath,
|
|
25234
25448
|
setTokenSegments: () => setTokenSegments,
|
|
25449
|
+
specParametersJsonSchema: () => specParametersJsonSchema,
|
|
25235
25450
|
stringifyValue: () => stringifyValue,
|
|
25236
25451
|
tokenCssVarName: () => tokenCssVarName,
|
|
25237
25452
|
tokensToCss: () => tokensToCss,
|
|
@@ -25252,6 +25467,7 @@ var init_dist5 = __esm({
|
|
|
25252
25467
|
init_session_artifacts();
|
|
25253
25468
|
init_imagegen_tools();
|
|
25254
25469
|
init_os_control_tools();
|
|
25470
|
+
init_screen_control_tools();
|
|
25255
25471
|
init_design_tokens2();
|
|
25256
25472
|
}
|
|
25257
25473
|
});
|
|
@@ -45646,6 +45862,7 @@ async function createClaudeCodeBackend(send2, onBrowserRequest, loadPluginRuntim
|
|
|
45646
45862
|
setNarrationLlm: (cfg2) => manager2.setNarrationLlm(cfg2),
|
|
45647
45863
|
setImageGen: (runner2) => manager2.setImageGen(runner2),
|
|
45648
45864
|
setComputerControl: (provider) => manager2.setComputerControl(provider),
|
|
45865
|
+
setScreenControl: (provider) => manager2.setScreenControl(provider),
|
|
45649
45866
|
setRunMode: (sessionId, opts) => manager2.setRunMode(sessionId, opts),
|
|
45650
45867
|
setSessionKeepAlive: (sessionId, keep, holder) => manager2.setSessionKeepAlive(sessionId, keep, holder),
|
|
45651
45868
|
warmSession: (params) => manager2.warmSession(params),
|
|
@@ -45716,11 +45933,11 @@ var CliAgentBackend = class {
|
|
|
45716
45933
|
return;
|
|
45717
45934
|
}
|
|
45718
45935
|
const sessionId = params.sessionId ?? randomUUID3();
|
|
45719
|
-
const
|
|
45936
|
+
const ctx2 = { sessionId, clientRequestId: params.clientRequestId, messageId: randomUUID3() };
|
|
45720
45937
|
if (!params.sessionId)
|
|
45721
45938
|
emitMsg({ type: "session:created", sessionId, clientRequestId: params.clientRequestId });
|
|
45722
45939
|
emitMsg({ type: "agent:status", sessionId, clientRequestId: params.clientRequestId, status: "running" });
|
|
45723
|
-
const args = this.adapter.buildArgs(params,
|
|
45940
|
+
const args = this.adapter.buildArgs(params, ctx2);
|
|
45724
45941
|
const child = spawn3(spawnCfg.command, args, {
|
|
45725
45942
|
cwd: params.projectDir,
|
|
45726
45943
|
// engineEnv carries the resolved runner env + enabled-skill secrets (the desktop
|
|
@@ -45733,7 +45950,7 @@ var CliAgentBackend = class {
|
|
|
45733
45950
|
// CLI's PID — these engines spawn their own tool subprocesses too.
|
|
45734
45951
|
detached: process.platform !== "win32"
|
|
45735
45952
|
});
|
|
45736
|
-
const turn = { child, sessionId, clientRequestId: params.clientRequestId, messageId:
|
|
45953
|
+
const turn = { child, sessionId, clientRequestId: params.clientRequestId, messageId: ctx2.messageId, acc: "", buf: "", errored: false, interrupted: false };
|
|
45737
45954
|
this.live.set(sessionId, turn);
|
|
45738
45955
|
const emit = (m) => {
|
|
45739
45956
|
if (m.type === "chat:stream" && m.kind !== "thinking")
|
|
@@ -45752,7 +45969,7 @@ var CliAgentBackend = class {
|
|
|
45752
45969
|
} catch {
|
|
45753
45970
|
}
|
|
45754
45971
|
try {
|
|
45755
|
-
this.adapter.translate(parsed, trimmed, emit,
|
|
45972
|
+
this.adapter.translate(parsed, trimmed, emit, ctx2);
|
|
45756
45973
|
} catch (err) {
|
|
45757
45974
|
emit({ type: "agent:tool_use", sessionId, clientRequestId: turn.clientRequestId, toolName: "parse", summary: `(unparsed event) ${String(err)}` });
|
|
45758
45975
|
}
|
|
@@ -45874,7 +46091,7 @@ var codexAdapter = {
|
|
|
45874
46091
|
const model = params.model;
|
|
45875
46092
|
return ["exec", "--json", "--dangerously-bypass-approvals-and-sandbox", ...model ? ["-m", model] : [], params.message];
|
|
45876
46093
|
},
|
|
45877
|
-
translate(event, _raw, emit,
|
|
46094
|
+
translate(event, _raw, emit, ctx2) {
|
|
45878
46095
|
const o = asObj(event);
|
|
45879
46096
|
if (!o)
|
|
45880
46097
|
return;
|
|
@@ -45882,9 +46099,9 @@ var codexAdapter = {
|
|
|
45882
46099
|
const type = String(o.type ?? inner.type ?? "").toLowerCase();
|
|
45883
46100
|
const itemType = String(asObj(o.item)?.type ?? asObj(o.item)?.item_type ?? inner.type ?? "").toLowerCase();
|
|
45884
46101
|
const kindHint = `${type} ${itemType}`;
|
|
45885
|
-
const stream = (delta, kind) => emit({ type: "chat:stream", sessionId:
|
|
46102
|
+
const stream = (delta, kind) => emit({ type: "chat:stream", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, delta, messageId: ctx2.messageId, kind });
|
|
45886
46103
|
if (kindHint.includes("error")) {
|
|
45887
|
-
emit({ type: "chat:error", sessionId:
|
|
46104
|
+
emit({ type: "chat:error", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, error: bestEffortText(inner) || bestEffortText(o) || "Codex error." });
|
|
45888
46105
|
return;
|
|
45889
46106
|
}
|
|
45890
46107
|
if (kindHint.includes("thread") || kindHint.includes("turn"))
|
|
@@ -45900,7 +46117,7 @@ var codexAdapter = {
|
|
|
45900
46117
|
}
|
|
45901
46118
|
if (kindHint.includes("command") || kindHint.includes("exec") || kindHint.includes("tool") || kindHint.includes("patch") || kindHint.includes("file_change")) {
|
|
45902
46119
|
const cmd = inner.command ?? inner.name ?? inner.tool ?? "command";
|
|
45903
|
-
emit({ type: "agent:tool_use", sessionId:
|
|
46120
|
+
emit({ type: "agent:tool_use", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, toolName: String(cmd), summary: bestEffortText(inner) || String(cmd) });
|
|
45904
46121
|
return;
|
|
45905
46122
|
}
|
|
45906
46123
|
if (kindHint.includes("assistant") || kindHint.includes("agent_message") || kindHint.includes("message") || kindHint.includes("output_text")) {
|
|
@@ -45926,17 +46143,17 @@ var opencodeAdapter = {
|
|
|
45926
46143
|
buildArgs(params) {
|
|
45927
46144
|
return ["run", "--format", "json", params.message];
|
|
45928
46145
|
},
|
|
45929
|
-
translate(event, _raw, emit,
|
|
46146
|
+
translate(event, _raw, emit, ctx2) {
|
|
45930
46147
|
const o = asObj2(event);
|
|
45931
46148
|
if (!o)
|
|
45932
46149
|
return;
|
|
45933
46150
|
const inner = asObj2(o.part) ?? asObj2(o.data) ?? o;
|
|
45934
46151
|
const type = String(o.type ?? inner.type ?? "").toLowerCase();
|
|
45935
|
-
const stream = (delta, kind) => emit({ type: "chat:stream", sessionId:
|
|
46152
|
+
const stream = (delta, kind) => emit({ type: "chat:stream", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, delta, messageId: ctx2.messageId, kind });
|
|
45936
46153
|
if (type.includes("step"))
|
|
45937
46154
|
return;
|
|
45938
46155
|
if (type.includes("error")) {
|
|
45939
|
-
emit({ type: "chat:error", sessionId:
|
|
46156
|
+
emit({ type: "chat:error", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, error: bestEffortText(inner) || "OpenCode error." });
|
|
45940
46157
|
return;
|
|
45941
46158
|
}
|
|
45942
46159
|
if (type.includes("reason") || type.includes("think")) {
|
|
@@ -45947,7 +46164,7 @@ var opencodeAdapter = {
|
|
|
45947
46164
|
}
|
|
45948
46165
|
if (type.includes("tool") || type.includes("command")) {
|
|
45949
46166
|
const name = inner.tool ?? inner.name ?? asObj2(inner.state)?.title ?? "tool";
|
|
45950
|
-
emit({ type: "agent:tool_use", sessionId:
|
|
46167
|
+
emit({ type: "agent:tool_use", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, toolName: String(name), summary: bestEffortText(inner) || String(name) });
|
|
45951
46168
|
return;
|
|
45952
46169
|
}
|
|
45953
46170
|
if (type.includes("finish") || type.includes("done") || type.includes("complete"))
|
|
@@ -45972,16 +46189,16 @@ var geminiAdapter = {
|
|
|
45972
46189
|
const model = params.model;
|
|
45973
46190
|
return ["--yolo", "--skip-trust", "--output-format", "json", ...model ? ["-m", model] : [], "-p", params.message];
|
|
45974
46191
|
},
|
|
45975
|
-
translate(event, raw, emit,
|
|
46192
|
+
translate(event, raw, emit, ctx2) {
|
|
45976
46193
|
const o = asObj3(event);
|
|
45977
46194
|
const text4 = o ? typeof o.response === "string" ? o.response : bestEffortText(o) : typeof event === "string" ? event : raw;
|
|
45978
46195
|
if (text4)
|
|
45979
|
-
emit({ type: "chat:stream", sessionId:
|
|
46196
|
+
emit({ type: "chat:stream", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, delta: text4, messageId: ctx2.messageId, kind: "text" });
|
|
45980
46197
|
const tools = o?.tools;
|
|
45981
46198
|
if (Array.isArray(tools)) {
|
|
45982
46199
|
for (const t of tools) {
|
|
45983
46200
|
const name = asObj3(t)?.name ?? "tool";
|
|
45984
|
-
emit({ type: "agent:tool_use", sessionId:
|
|
46201
|
+
emit({ type: "agent:tool_use", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, toolName: String(name), summary: bestEffortText(t) || String(name) });
|
|
45985
46202
|
}
|
|
45986
46203
|
}
|
|
45987
46204
|
}
|
|
@@ -45995,11 +46212,11 @@ var openclawAdapter = {
|
|
|
45995
46212
|
id: "openclaw",
|
|
45996
46213
|
capabilities: { permissionGating: false, browserControl: false, liveRunMode: false, resume: false },
|
|
45997
46214
|
streaming: false,
|
|
45998
|
-
buildArgs(params,
|
|
46215
|
+
buildArgs(params, ctx2) {
|
|
45999
46216
|
const model = params.model;
|
|
46000
|
-
return ["agent", "--local", "--json", "--session-id",
|
|
46217
|
+
return ["agent", "--local", "--json", "--session-id", ctx2.sessionId, ...model ? ["--model", model] : [], "-m", params.message];
|
|
46001
46218
|
},
|
|
46002
|
-
translate(event, raw, emit,
|
|
46219
|
+
translate(event, raw, emit, ctx2) {
|
|
46003
46220
|
const o = asObj4(event);
|
|
46004
46221
|
const result2 = asObj4(o?.result) ?? o;
|
|
46005
46222
|
let text4 = "";
|
|
@@ -46018,15 +46235,15 @@ var openclawAdapter = {
|
|
|
46018
46235
|
if (!text4)
|
|
46019
46236
|
text4 = o ? bestEffortText(result2 ?? o) : typeof event === "string" ? event : raw;
|
|
46020
46237
|
if (text4)
|
|
46021
|
-
emit({ type: "chat:stream", sessionId:
|
|
46238
|
+
emit({ type: "chat:stream", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, delta: text4, messageId: ctx2.messageId, kind: "text" });
|
|
46022
46239
|
const status2 = typeof o?.status === "string" ? o.status : void 0;
|
|
46023
46240
|
if (!text4 && status2 && status2 !== "ok" && status2 !== "accepted") {
|
|
46024
46241
|
const summary = typeof o?.summary === "string" && o.summary ? o.summary : `OpenClaw run ${status2}.`;
|
|
46025
|
-
emit({ type: "chat:error", sessionId:
|
|
46242
|
+
emit({ type: "chat:error", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, error: summary });
|
|
46026
46243
|
}
|
|
46027
46244
|
const ds = asObj4(o?.deliveryStatus);
|
|
46028
46245
|
if (ds && ds.requested === true && ds.succeeded === false) {
|
|
46029
|
-
emit({ type: "chat:error", sessionId:
|
|
46246
|
+
emit({ type: "chat:error", sessionId: ctx2.sessionId, clientRequestId: ctx2.clientRequestId, error: `OpenClaw delivery ${String(ds.status ?? "failed")}.` });
|
|
46030
46247
|
}
|
|
46031
46248
|
}
|
|
46032
46249
|
};
|
|
@@ -46065,12 +46282,28 @@ async function createBackend(engineId, send2, onBrowserRequest, resolver, loadPl
|
|
|
46065
46282
|
|
|
46066
46283
|
// ../../packages/host-core/dist/session-recorder.js
|
|
46067
46284
|
import { join as join10 } from "node:path";
|
|
46068
|
-
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, appendFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
46285
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, appendFileSync, readdirSync as readdirSync2, rmSync, statSync } from "node:fs";
|
|
46069
46286
|
init_dist5();
|
|
46070
46287
|
var dir = null;
|
|
46071
46288
|
var seq = 0;
|
|
46072
46289
|
var now = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
46290
|
+
var ctx = [];
|
|
46291
|
+
var CTX_MAX = 60;
|
|
46292
|
+
function pushCtx(role, text4) {
|
|
46293
|
+
const t = (text4 ?? "").trim();
|
|
46294
|
+
if (!t)
|
|
46295
|
+
return;
|
|
46296
|
+
ctx.push({ role, text: t.length > 300 ? `${t.slice(0, 300)}\u2026` : t });
|
|
46297
|
+
if (ctx.length > CTX_MAX)
|
|
46298
|
+
ctx.splice(0, ctx.length - CTX_MAX);
|
|
46299
|
+
}
|
|
46073
46300
|
function recordEvent(type, data = {}) {
|
|
46301
|
+
if (type === "transcript")
|
|
46302
|
+
pushCtx(data.speaker === "user" ? "User" : "Assistant", String(data.text ?? ""));
|
|
46303
|
+
else if (type === "tool_call")
|
|
46304
|
+
pushCtx("Action", `called ${String(data.name)}(${JSON.stringify(data.args ?? {}).slice(0, 140)})`);
|
|
46305
|
+
else if (type === "tool_result")
|
|
46306
|
+
pushCtx("Result", `${String(data.name)}${data.isError ? " ERROR" : ""}: ${String(data.text ?? "")}`);
|
|
46074
46307
|
if (!dir)
|
|
46075
46308
|
return;
|
|
46076
46309
|
try {
|
|
@@ -46084,7 +46317,7 @@ function recordEvent(type, data = {}) {
|
|
|
46084
46317
|
init_dist5();
|
|
46085
46318
|
|
|
46086
46319
|
// ../../packages/host-core/dist/plugin-tools.js
|
|
46087
|
-
import { existsSync as existsSync7, readdirSync as
|
|
46320
|
+
import { existsSync as existsSync7, readdirSync as readdirSync3 } from "node:fs";
|
|
46088
46321
|
import { join as join17 } from "node:path";
|
|
46089
46322
|
import { homedir as homedir9 } from "node:os";
|
|
46090
46323
|
|
|
@@ -46256,8 +46489,8 @@ function createOpenClawAdapter(pluginId, config2, secretResolver, registry2) {
|
|
|
46256
46489
|
pluginId,
|
|
46257
46490
|
config: config2,
|
|
46258
46491
|
secret: (envKey2) => secretResolver(pluginId, envKey2),
|
|
46259
|
-
registerTool: (
|
|
46260
|
-
const got = typeof
|
|
46492
|
+
registerTool: (tool9) => {
|
|
46493
|
+
const got = typeof tool9 === "function" ? tool9({}) : tool9;
|
|
46261
46494
|
const arr = Array.isArray(got) ? got : got ? [got] : [];
|
|
46262
46495
|
for (const t of arr) {
|
|
46263
46496
|
const c = convertTool(t);
|
|
@@ -46326,10 +46559,10 @@ var HostPluginApi = class {
|
|
|
46326
46559
|
secret(envKey2) {
|
|
46327
46560
|
return this.secretResolver(this.pluginId, envKey2);
|
|
46328
46561
|
}
|
|
46329
|
-
registerTool(
|
|
46562
|
+
registerTool(tool9) {
|
|
46330
46563
|
const prefix = this.pluginId.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
46331
|
-
const name =
|
|
46332
|
-
this.registry.tools.push({ ...
|
|
46564
|
+
const name = tool9.name.startsWith(`${prefix}_`) ? tool9.name : `${prefix}_${tool9.name}`;
|
|
46565
|
+
this.registry.tools.push({ ...tool9, name });
|
|
46333
46566
|
}
|
|
46334
46567
|
registerHook(reg) {
|
|
46335
46568
|
this.registry.hooks.push(reg);
|
|
@@ -46927,7 +47160,7 @@ function setActiveConfig(id) {
|
|
|
46927
47160
|
|
|
46928
47161
|
// ../../packages/host-core/dist/daemon-engine-spawn.js
|
|
46929
47162
|
init_dist2();
|
|
46930
|
-
import { execFileSync } from "node:child_process";
|
|
47163
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
46931
47164
|
import { homedir as homedir8 } from "node:os";
|
|
46932
47165
|
import { join as join15 } from "node:path";
|
|
46933
47166
|
function envKey(id) {
|
|
@@ -46956,9 +47189,9 @@ function augmentedPath() {
|
|
|
46956
47189
|
return parts.join(sep8);
|
|
46957
47190
|
}
|
|
46958
47191
|
function which(bin, path5) {
|
|
46959
|
-
const
|
|
47192
|
+
const tool9 = process.platform === "win32" ? "where" : "which";
|
|
46960
47193
|
try {
|
|
46961
|
-
const out =
|
|
47194
|
+
const out = execFileSync2(tool9, [bin], { env: { ...process.env, PATH: path5 }, timeout: 4e3, encoding: "utf-8" });
|
|
46962
47195
|
return out.split(/\r?\n/).map((l) => l.trim()).find(Boolean) || void 0;
|
|
46963
47196
|
} catch {
|
|
46964
47197
|
return void 0;
|
|
@@ -47076,7 +47309,7 @@ async function loadPluginRuntime(opts) {
|
|
|
47076
47309
|
const engines2 = registry2.modelProviders.map((p) => ({
|
|
47077
47310
|
id: p.id,
|
|
47078
47311
|
label: p.label,
|
|
47079
|
-
create: async (
|
|
47312
|
+
create: async (ctx2) => await p.create(ctx2)
|
|
47080
47313
|
}));
|
|
47081
47314
|
registerPluginEngines(engines2);
|
|
47082
47315
|
pluginTtsProviders = registry2.speechProviders.filter((p) => p.kind === "tts").map((p) => ({ id: p.id, label: p.label, create: p.create }));
|
|
@@ -47107,7 +47340,7 @@ function daemonSkillsPluginConfig() {
|
|
|
47107
47340
|
return null;
|
|
47108
47341
|
const enabled = join17(root, "skills");
|
|
47109
47342
|
try {
|
|
47110
|
-
const hasSkill =
|
|
47343
|
+
const hasSkill = readdirSync3(enabled).some((slug2) => existsSync7(join17(enabled, slug2, "SKILL.md")));
|
|
47111
47344
|
return hasSkill ? { type: "local", path: root } : null;
|
|
47112
47345
|
} catch {
|
|
47113
47346
|
return null;
|
|
@@ -47399,8 +47632,7 @@ async function closeEnginePage(browserId) {
|
|
|
47399
47632
|
import { spawn as spawn5 } from "node:child_process";
|
|
47400
47633
|
import { promises as fsp2 } from "node:fs";
|
|
47401
47634
|
import { join as join21, basename as basename2 } from "node:path";
|
|
47402
|
-
import {
|
|
47403
|
-
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
47635
|
+
import { networkInterfaces, homedir as homedir10 } from "node:os";
|
|
47404
47636
|
|
|
47405
47637
|
// ../../packages/host-core/dist/activity/activity-tracker.js
|
|
47406
47638
|
import { promises as fsp, writeFileSync as writeFileSync9, mkdirSync as mkdirSync8, existsSync as existsSync8 } from "node:fs";
|
|
@@ -47997,11 +48229,11 @@ async function nutOrThrow() {
|
|
|
47997
48229
|
}
|
|
47998
48230
|
var NUT_BTN = { left: "left", middle: "middle", right: "right" };
|
|
47999
48231
|
var MOD_ALIAS = {
|
|
48000
|
-
cmd: "
|
|
48001
|
-
command: "
|
|
48002
|
-
meta: "
|
|
48003
|
-
super: "
|
|
48004
|
-
win: "
|
|
48232
|
+
cmd: "meta",
|
|
48233
|
+
command: "meta",
|
|
48234
|
+
meta: "meta",
|
|
48235
|
+
super: "meta",
|
|
48236
|
+
win: "meta",
|
|
48005
48237
|
ctrl: "control",
|
|
48006
48238
|
control: "control",
|
|
48007
48239
|
alt: "alt",
|
|
@@ -48046,11 +48278,6 @@ function loadMacAx2() {
|
|
|
48046
48278
|
})();
|
|
48047
48279
|
return macAxPromise2;
|
|
48048
48280
|
}
|
|
48049
|
-
function pngSize(buf) {
|
|
48050
|
-
if (buf.length < 24 || buf.readUInt32BE(12) !== 1229472850)
|
|
48051
|
-
return null;
|
|
48052
|
-
return { w: buf.readUInt32BE(16), h: buf.readUInt32BE(20) };
|
|
48053
|
-
}
|
|
48054
48281
|
function orderedDisplays() {
|
|
48055
48282
|
const el2 = electronModule();
|
|
48056
48283
|
if (!el2)
|
|
@@ -48062,60 +48289,11 @@ function orderedDisplays() {
|
|
|
48062
48289
|
return null;
|
|
48063
48290
|
}
|
|
48064
48291
|
}
|
|
48065
|
-
|
|
48066
|
-
const ds = orderedDisplays();
|
|
48067
|
-
if (!ds || !ds.length)
|
|
48068
|
-
return 1;
|
|
48069
|
-
if (displayIndex !== void 0)
|
|
48070
|
-
return ds[displayIndex]?.scaleFactor ?? ds[0].scaleFactor;
|
|
48071
|
-
return (ds.find((d) => d.primary) ?? ds[0]).scaleFactor;
|
|
48072
|
-
}
|
|
48292
|
+
var injectedGrabber = null;
|
|
48073
48293
|
async function captureScreenshot(opts) {
|
|
48074
|
-
if (!
|
|
48075
|
-
throw new Error("Screen capture is
|
|
48076
|
-
|
|
48077
|
-
const args = ["-x", "-t", "png"];
|
|
48078
|
-
let region = opts?.region;
|
|
48079
|
-
if (!region && opts?.display !== void 0) {
|
|
48080
|
-
const d = orderedDisplays()?.[opts.display];
|
|
48081
|
-
if (d)
|
|
48082
|
-
region = { ...d.bounds };
|
|
48083
|
-
}
|
|
48084
|
-
if (region)
|
|
48085
|
-
args.push("-R", `${region.x},${region.y},${region.width},${region.height}`);
|
|
48086
|
-
else if (opts?.display !== void 0)
|
|
48087
|
-
args.push("-D", String(opts.display + 1));
|
|
48088
|
-
args.push(file2);
|
|
48089
|
-
const r = await capture("screencapture", args, { timeoutMs: 15e3 });
|
|
48090
|
-
if (r.code !== 0) {
|
|
48091
|
-
log3(`screenshot FAILED (${r.stderr.trim() || `exit ${r.code}`}) \u2014 Screen Recording permission may be required`);
|
|
48092
|
-
throw new Error(`screencapture failed (Screen Recording permission may be required): ${r.stderr.trim() || `exit ${r.code}`}`);
|
|
48093
|
-
}
|
|
48094
|
-
try {
|
|
48095
|
-
let buf = await fsp2.readFile(file2);
|
|
48096
|
-
const sz = pngSize(buf);
|
|
48097
|
-
let pointW = sz?.w ?? 0, pointH = sz?.h ?? 0;
|
|
48098
|
-
if (region) {
|
|
48099
|
-
pointW = Math.round(region.width);
|
|
48100
|
-
pointH = Math.round(region.height);
|
|
48101
|
-
} else if (sz) {
|
|
48102
|
-
const sf = targetScaleFactor(opts?.display);
|
|
48103
|
-
pointW = Math.round(sz.w / sf);
|
|
48104
|
-
pointH = Math.round(sz.h / sf);
|
|
48105
|
-
}
|
|
48106
|
-
const downscaled = !opts?.fullRes && !!(sz && pointW > 0 && pointH > 0 && (pointW !== sz.w || pointH !== sz.h));
|
|
48107
|
-
if (downscaled) {
|
|
48108
|
-
await capture("sips", ["-z", String(pointH), String(pointW), file2], { timeoutMs: 1e4 });
|
|
48109
|
-
buf = await fsp2.readFile(file2);
|
|
48110
|
-
}
|
|
48111
|
-
const outW = opts?.fullRes && sz ? sz.w : pointW, outH = opts?.fullRes && sz ? sz.h : pointH;
|
|
48112
|
-
const tgt = region ? `region ${region.x},${region.y} ${region.width}\xD7${region.height}` : opts?.display !== void 0 ? `display ${opts.display}` : "main display";
|
|
48113
|
-
log3(`screenshot ${tgt} \u2192 ${outW}\xD7${outH}px${opts?.fullRes ? " (full native res)" : downscaled && sz ? ` (downscaled from ${sz.w}\xD7${sz.h}px native)` : ""}`);
|
|
48114
|
-
return { dataBase64: buf.toString("base64"), mimeType: "image/png", width: outW || void 0, height: outH || void 0 };
|
|
48115
|
-
} finally {
|
|
48116
|
-
void fsp2.unlink(file2).catch(() => {
|
|
48117
|
-
});
|
|
48118
|
-
}
|
|
48294
|
+
if (!injectedGrabber)
|
|
48295
|
+
throw new Error("Screen capture unavailable: the Electron screen grabber is not registered (GUI daemon not running).");
|
|
48296
|
+
return injectedGrabber(opts);
|
|
48119
48297
|
}
|
|
48120
48298
|
async function listAppsMac() {
|
|
48121
48299
|
const script = `tell application "System Events"
|
|
@@ -48188,6 +48366,7 @@ function createDaemonOsControlRunner() {
|
|
|
48188
48366
|
if (o.at)
|
|
48189
48367
|
n.moveMouse(Math.round(o.at.x), Math.round(o.at.y));
|
|
48190
48368
|
n.mouseClick(NUT_BTN[o.button ?? "left"], o.double === true);
|
|
48369
|
+
log3(`${o.button ?? "left"}${o.double ? "-double" : ""}-click${o.at ? ` @ ${Math.round(o.at.x)},${Math.round(o.at.y)}` : ""}`);
|
|
48191
48370
|
},
|
|
48192
48371
|
async mouseDrag(from, to, o) {
|
|
48193
48372
|
const n = await nutOrThrow();
|
|
@@ -48200,6 +48379,37 @@ function createDaemonOsControlRunner() {
|
|
|
48200
48379
|
n.moveMouse(Math.round(fx + (tx - fx) * i / steps), Math.round(fy + (ty - fy) * i / steps));
|
|
48201
48380
|
n.mouseToggle("up", btn);
|
|
48202
48381
|
},
|
|
48382
|
+
async mouseDragPath(points, opts) {
|
|
48383
|
+
if (!points || points.length < 2)
|
|
48384
|
+
return;
|
|
48385
|
+
const n = await nutOrThrow();
|
|
48386
|
+
const btn = NUT_BTN[opts?.button ?? "left"];
|
|
48387
|
+
const stepPx = opts?.stepPx ?? 5, stepMs = opts?.stepMs ?? 12;
|
|
48388
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
48389
|
+
const move = (x, y) => {
|
|
48390
|
+
const rx = Math.round(x), ry = Math.round(y);
|
|
48391
|
+
n.moveMouse(rx, ry);
|
|
48392
|
+
opts?.onStep?.({ x: rx, y: ry });
|
|
48393
|
+
};
|
|
48394
|
+
move(points[0].x, points[0].y);
|
|
48395
|
+
await sleep(120);
|
|
48396
|
+
n.mouseToggle("down", btn);
|
|
48397
|
+
try {
|
|
48398
|
+
for (let i = 1; i < points.length; i++) {
|
|
48399
|
+
const a = points[i - 1], b = points[i];
|
|
48400
|
+
const dist = Math.hypot(b.x - a.x, b.y - a.y);
|
|
48401
|
+
const segs = Math.max(1, Math.round(dist / stepPx));
|
|
48402
|
+
for (let s = 1; s <= segs; s++) {
|
|
48403
|
+
if (opts?.signal?.aborted)
|
|
48404
|
+
return;
|
|
48405
|
+
move(a.x + (b.x - a.x) * s / segs, a.y + (b.y - a.y) * s / segs);
|
|
48406
|
+
await sleep(stepMs);
|
|
48407
|
+
}
|
|
48408
|
+
}
|
|
48409
|
+
} finally {
|
|
48410
|
+
n.mouseToggle("up", btn);
|
|
48411
|
+
}
|
|
48412
|
+
},
|
|
48203
48413
|
async scroll(o) {
|
|
48204
48414
|
const n = await nutOrThrow();
|
|
48205
48415
|
if (o.at)
|
|
@@ -48214,6 +48424,7 @@ function createDaemonOsControlRunner() {
|
|
|
48214
48424
|
async typeText(t) {
|
|
48215
48425
|
const n = await nutOrThrow();
|
|
48216
48426
|
n.typeString(t);
|
|
48427
|
+
log3(`type "${t.length > 50 ? `${t.slice(0, 50)}\u2026` : t}"`);
|
|
48217
48428
|
},
|
|
48218
48429
|
async pressKeys(combo) {
|
|
48219
48430
|
const n = await nutOrThrow();
|
|
@@ -48221,6 +48432,7 @@ function createDaemonOsControlRunner() {
|
|
|
48221
48432
|
if (!key2)
|
|
48222
48433
|
throw new Error(`Empty key combo: "${combo}"`);
|
|
48223
48434
|
n.keyTap(key2, modifiers);
|
|
48435
|
+
log3(`key ${combo}`);
|
|
48224
48436
|
},
|
|
48225
48437
|
// Screen
|
|
48226
48438
|
async displays() {
|
|
@@ -48471,6 +48683,7 @@ function createDaemonOsControlRunner() {
|
|
|
48471
48683
|
// ../../packages/host-core/dist/gui/ai-control.js
|
|
48472
48684
|
init_dist5();
|
|
48473
48685
|
var runner = createDaemonOsControlRunner();
|
|
48686
|
+
var controlAbort = new AbortController();
|
|
48474
48687
|
var IDLE_RELEASE_MS = 15 * 6e4;
|
|
48475
48688
|
var STOP = new Set("the a an in on at of to for and or is it this that with my your please click open press tap select choose go button icon taskbar dock toolbar screen top bottom left right corner side middle center centre near above below first second third".split(" "));
|
|
48476
48689
|
|
|
@@ -48735,7 +48948,7 @@ async function createElevenLabsAgent(args) {
|
|
|
48735
48948
|
}
|
|
48736
48949
|
|
|
48737
48950
|
// ../../packages/voice-core/dist/orchestrator.js
|
|
48738
|
-
import { randomUUID as
|
|
48951
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
48739
48952
|
|
|
48740
48953
|
// ../../packages/voice-core/dist/summarizer.js
|
|
48741
48954
|
var TURN_SYSTEM = [
|
|
@@ -49091,7 +49304,7 @@ Additional context: ${context}` : task;
|
|
|
49091
49304
|
this.emitFocusedState();
|
|
49092
49305
|
const sessionId = track.sessionId || void 0;
|
|
49093
49306
|
this.deps.emit({ type: "voice:dispatched", text: message, sessionId });
|
|
49094
|
-
const clientRequestId =
|
|
49307
|
+
const clientRequestId = randomUUID7();
|
|
49095
49308
|
track.pendingClientRequestId = clientRequestId;
|
|
49096
49309
|
try {
|
|
49097
49310
|
const sid = await this.deps.agent.dispatch({ message, clientRequestId, sessionId });
|
|
@@ -49124,7 +49337,7 @@ Additional context: ${context}` : task;
|
|
|
49124
49337
|
this.emitFocusedState();
|
|
49125
49338
|
const sessionId = track.sessionId || void 0;
|
|
49126
49339
|
this.deps.emit({ type: "voice:dispatched", text: message, sessionId });
|
|
49127
|
-
const clientRequestId =
|
|
49340
|
+
const clientRequestId = randomUUID7();
|
|
49128
49341
|
track.pendingClientRequestId = clientRequestId;
|
|
49129
49342
|
try {
|
|
49130
49343
|
const sid = await this.deps.agent.dispatch({ message, clientRequestId, sessionId });
|
|
@@ -49147,7 +49360,7 @@ Additional context: ${context}` : task;
|
|
|
49147
49360
|
this.voice?.respondToTool(inv.callId, "Got it \u2014 passing that along.");
|
|
49148
49361
|
this.focusTrack(track);
|
|
49149
49362
|
this.deps.emit({ type: "voice:dispatched", text: addendum, sessionId: track.sessionId });
|
|
49150
|
-
const clientRequestId =
|
|
49363
|
+
const clientRequestId = randomUUID7();
|
|
49151
49364
|
track.pendingClientRequestId = clientRequestId;
|
|
49152
49365
|
try {
|
|
49153
49366
|
await this.deps.agent.dispatch({ message: addendum, sessionId: track.sessionId, clientRequestId });
|
|
@@ -49185,7 +49398,7 @@ Additional context: ${context}` : task;
|
|
|
49185
49398
|
this.voice?.respondToTool(inv.callId, "Got it \u2014 passing that along.");
|
|
49186
49399
|
this.focusTrack(track);
|
|
49187
49400
|
this.deps.emit({ type: "voice:dispatched", text: answer, sessionId: track.sessionId });
|
|
49188
|
-
const clientRequestId =
|
|
49401
|
+
const clientRequestId = randomUUID7();
|
|
49189
49402
|
track.pendingClientRequestId = clientRequestId;
|
|
49190
49403
|
void this.deps.agent.dispatch({ message: answer, sessionId: track.sessionId, clientRequestId }).catch((err) => this.say(`I couldn't send that: ${errMsg(err)}.`, { urgent: true }));
|
|
49191
49404
|
track.state = "working";
|
|
@@ -49612,104 +49825,57 @@ var ClientProxyProvider = class {
|
|
|
49612
49825
|
|
|
49613
49826
|
// ../../packages/host-core/dist/voice-control.js
|
|
49614
49827
|
init_dist5();
|
|
49828
|
+
init_dist5();
|
|
49615
49829
|
var OPENAI_REALTIME_MODEL = "gpt-realtime";
|
|
49616
49830
|
var GEMINI_LIVE_MODEL = "gemini-3.1-flash-live-preview";
|
|
49831
|
+
var DEFAULT_GEMINI_VOICE = "Aoede";
|
|
49617
49832
|
var GATEWAY_OPERATOR_PROMPT = `
|
|
49618
49833
|
|
|
49619
|
-
|
|
49620
|
-
|
|
49834
|
+
YOU ARE THE VOICE LAYER. You talk with the developer, understand what they want, and hand the actual DOING to a powerful agent (Claude Code) that fully controls this Mac \u2014 it takes high-res screenshots, uses the mouse/keyboard, the accessibility tree, processes, files, and every other tool. You do NOT operate the screen yourself.
|
|
49835
|
+
|
|
49836
|
+
You also see a LOW-RESOLUTION ~1 fps view of the screen, so you can follow along, describe what's happening, and confirm results in your own words \u2014 but it's just for awareness; never try to act on it.
|
|
49837
|
+
|
|
49838
|
+
So whenever the developer asks for ANYTHING on the computer ("open Chrome", "search Amazon for X", "fill in this form", "click that", "what's on my screen", "read this") \u2014 hand it to the agent with dispatch_to_claude_code. You are the ears and voice; the agent is the hands and eyes. Never say you can't do something on screen \u2014 hand it to the agent and report back.
|
|
49839
|
+
|
|
49840
|
+
WORK IN SMALL STEPS \u2014 this is important. Break the developer's request into the SMALLEST sensible actions and dispatch them ONE AT A TIME. For "open Chrome and find Levi's jeans on Amazon" you'd dispatch, in order: "open Google Chrome" \u2192 "navigate to amazon.com" \u2192 "search for Levi's jeans" \u2192 "find the search results and outline the first one". Send ONE step, WAIT for the agent to actually finish it and REPLY, tell the developer briefly what the agent reported, THEN send the next step. Do NOT cram the whole goal into one dispatch \u2014 small steps are easier to follow, verify, and correct, and the developer can redirect you between them. All your steps go to the SAME agent session automatically, so it REMEMBERS everything done so far \u2014 you never need to repeat earlier context, just give the next action.
|
|
49841
|
+
|
|
49842
|
+
BE HONEST \u2014 NEVER PRETEND TO SEE OR KNOW. Your screen view is LOW-RES and blurry; the AGENT is the one actually looking and doing. So NEVER state specific things like "Amazon is open", "the results are showing", "you're signed in", "it worked" UNLESS the agent told you that in its reply. Do NOT narrate what you imagine or expect happened \u2014 only relay what the agent ACTUALLY reported, in your own short words. After you dispatch a step, WAIT for the agent's reply before saying it's done \u2014 don't announce success the instant you send the task. If you're unsure whether something worked, dispatch a quick check ("check whether amazon.com is loaded") rather than guessing. The developer instantly catches you when you describe something that isn't there \u2014 so only ever say what you actually know from the agent.`;
|
|
49843
|
+
var REQUEST_CONSENT_TOOL = {
|
|
49844
|
+
name: "request_control_consent",
|
|
49845
|
+
description: `Ask the developer for permission to interact with their computer. Call this FIRST \u2014 before any annotate / click / type / scroll \u2014 whenever you're about to act on the screen and don't already have permission this call. It pops a permission box on their screen; you must ALSO say out loud, word for word: "I need your permission in order to interact with your computer." and ask them to click Allow. Once they click Allow, call the action tool (annotate/click/\u2026). look_at_screen does NOT need this.`,
|
|
49846
|
+
parameters: { type: "object", properties: {} }
|
|
49847
|
+
};
|
|
49621
49848
|
var SCREEN_CONTROL_TOOLS = [
|
|
49622
|
-
|
|
49623
|
-
|
|
49624
|
-
description: `Ask the developer for permission to interact with their computer. Call this FIRST \u2014 before any annotate / click / type / scroll \u2014 whenever you're about to act on the screen and don't already have permission this call. It pops a permission box on their screen; you must ALSO say out loud, word for word: "I need your permission in order to interact with your computer." and ask them to click Allow. Once they click Allow, call the action tool (annotate/click/\u2026). look_at_screen does NOT need this.`,
|
|
49625
|
-
parameters: { type: "object", properties: {} }
|
|
49626
|
-
},
|
|
49627
|
-
{
|
|
49628
|
-
name: "look_at_screen",
|
|
49629
|
-
description: "Take a fresh look at the developer's current screen. The screen is NOT streamed to you continuously, so call this whenever you need to SEE what's on screen \u2014 before locating something to click, to verify the result of an action, or when they ask what's on their screen. After you call it, the current screen image is given to you.",
|
|
49630
|
-
parameters: { type: "object", properties: {} }
|
|
49631
|
-
},
|
|
49632
|
-
{
|
|
49633
|
-
name: "click",
|
|
49634
|
-
description: "Click a UI element by DESCRIBING it in plain words \u2014 do NOT pass coordinates. The system finds its exact location (the macOS accessibility tree first, then a vision model) and clicks it precisely. Be specific and include any visible label/text.",
|
|
49635
|
-
parameters: {
|
|
49636
|
-
type: "object",
|
|
49637
|
-
properties: {
|
|
49638
|
-
target: { type: "string", description: 'What to click, described precisely \u2014 e.g. "the Google Chrome icon in the Dock", "the blue Sign in button", "the address bar", "the Submit button at the bottom of the form".' },
|
|
49639
|
-
button: { type: "string", enum: ["left", "right"], description: "Mouse button (default left)." },
|
|
49640
|
-
double: { type: "boolean", description: "Double-click when true." }
|
|
49641
|
-
},
|
|
49642
|
-
required: ["target"]
|
|
49643
|
-
}
|
|
49644
|
-
},
|
|
49645
|
-
{
|
|
49646
|
-
name: "move_to",
|
|
49647
|
-
description: 'Move the cursor OVER a UI element without clicking \u2014 to hover, or to show/verify where something is (use this when the developer says "move the mouse over X" or "point at X"). Describe the target in plain words.',
|
|
49648
|
-
parameters: { type: "object", properties: { target: { type: "string", description: "What to move the cursor over, described precisely." } }, required: ["target"] }
|
|
49649
|
-
},
|
|
49650
|
-
{
|
|
49651
|
-
name: "launch_app",
|
|
49652
|
-
description: 'Open / launch / switch to an application by name (e.g. "Google Chrome", "Safari", "Terminal", "System Settings"). This is the RELIABLE way to open an app \u2014 use it instead of hunting for a Dock icon to click.',
|
|
49653
|
-
parameters: { type: "object", properties: { name: { type: "string", description: 'The application name, e.g. "Google Chrome".' } }, required: ["name"] }
|
|
49654
|
-
},
|
|
49655
|
-
{
|
|
49656
|
-
name: "list_apps",
|
|
49657
|
-
description: "List the apps currently running \u2014 to check whether something opened or is ready before the next step.",
|
|
49658
|
-
parameters: { type: "object", properties: {} }
|
|
49659
|
-
},
|
|
49660
|
-
{
|
|
49661
|
-
name: "annotate",
|
|
49662
|
-
description: "POINT something out on the developer's screen with a hand-drawn red marker doodle (animated as if drawn live). Use it for 'where is X', 'show me X', 'point at X', 'underline X', 'cross out X', 'check off X', 'highlight X'. It only highlights \u2014 it does NOT click. Pick the style that fits what they asked; omit it for an auto choice based on the item's shape.",
|
|
49663
|
-
parameters: {
|
|
49664
|
-
type: "object",
|
|
49665
|
-
properties: {
|
|
49666
|
-
target: { type: "string", description: "What to mark, described precisely." },
|
|
49667
|
-
style: { type: "string", enum: ["auto", "circle", "box", "bracket", "underline", "zigzag", "strike", "highlight", "arrow", "check", "cross", "star", "scribble", "cloud", "caret"], description: "Which kind of doodle: circle/box/bracket to enclose; underline/zigzag/highlight to emphasise text; arrow to point; check/cross/star to mark; strike to cross through. Default auto." },
|
|
49668
|
-
label: { type: "string", description: 'Optional short text to write next to it, e.g. "Here!".' }
|
|
49669
|
-
},
|
|
49670
|
-
required: ["target"]
|
|
49671
|
-
}
|
|
49672
|
-
},
|
|
49673
|
-
{
|
|
49674
|
-
name: "remove_annotations",
|
|
49675
|
-
description: "Clear ALL the marker doodles you've drawn on the screen. Call this when you move on to a different topic or the developer asks you to remove them. Annotations otherwise stay on screen.",
|
|
49676
|
-
parameters: { type: "object", properties: {} }
|
|
49677
|
-
},
|
|
49678
|
-
{
|
|
49679
|
-
name: "type_text",
|
|
49680
|
-
description: "Type text at the current cursor/focus. Click the target field first if it is not focused.",
|
|
49681
|
-
parameters: { type: "object", properties: { text: { type: "string", description: "The text to type." } }, required: ["text"] }
|
|
49682
|
-
},
|
|
49683
|
-
{
|
|
49684
|
-
name: "press_key",
|
|
49685
|
-
description: 'Press a key or combo, e.g. "enter", "esc", "cmd+a", "cmd+c", "tab".',
|
|
49686
|
-
parameters: { type: "object", properties: { keys: { type: "string", description: 'Key or combo like "enter" or "cmd+c".' } }, required: ["keys"] }
|
|
49687
|
-
},
|
|
49688
|
-
{
|
|
49689
|
-
name: "scroll_screen",
|
|
49690
|
-
description: "Scroll the screen (at the centre). Positive dy scrolls down, negative up.",
|
|
49691
|
-
parameters: {
|
|
49692
|
-
type: "object",
|
|
49693
|
-
properties: {
|
|
49694
|
-
dy: { type: "number", description: "Vertical amount; positive scrolls down." },
|
|
49695
|
-
dx: { type: "number", description: "Horizontal amount; positive scrolls right." }
|
|
49696
|
-
},
|
|
49697
|
-
required: ["dy"]
|
|
49698
|
-
}
|
|
49699
|
-
},
|
|
49700
|
-
{
|
|
49701
|
-
name: "release_control",
|
|
49702
|
-
description: "Stop controlling the computer when you've finished the on-screen task. Removes the coral cursor and the 'working with your computer' bar. Call this as soon as you're done acting on the screen.",
|
|
49703
|
-
parameters: { type: "object", properties: {} }
|
|
49704
|
-
}
|
|
49849
|
+
REQUEST_CONSENT_TOOL,
|
|
49850
|
+
...SCREEN_CONTROL_SPECS.map((s) => ({ name: s.name, description: s.description, parameters: specParametersJsonSchema(s) }))
|
|
49705
49851
|
];
|
|
49852
|
+
var SCREEN_TOOL_NAMES = /* @__PURE__ */ new Set(["request_control_consent", ...SCREEN_CONTROL_SPECS.map((s) => s.name)]);
|
|
49706
49853
|
var SCREEN_CONTROL_PROMPT = `
|
|
49707
49854
|
|
|
49708
|
-
You can SEE and directly CONTROL the developer's screen \u2014 THIS IS YOUR PRIMARY JOB. When they ask you to interact with what's on screen (open/switch apps, click a button/icon/link, type into a field, navigate a website or menu, fill a form, scroll, or anything you can point at and do), DO IT YOURSELF
|
|
49855
|
+
You can SEE and directly CONTROL the developer's screen \u2014 THIS IS YOUR PRIMARY JOB. When they ask you to interact with what's on screen (open/switch apps, click a button/icon/link, type into a field, navigate a website or menu, fill a form, scroll, or anything you can point at and do), DO IT YOURSELF: use perform_step for any multi-action step, type_into to type into a field, and look_at_screen / verify / click / press_key / scroll_screen / launch_app as needed.
|
|
49856
|
+
|
|
49857
|
+
BE DECISIVE \u2014 JUST DO IT, DON'T ASK: when the developer tells you to do something ("read it", "what does it say", "click that", "find X", "open Y"), DO IT immediately and report the RESULT. NEVER ask permission for HOW you do it \u2014 taking a screenshot, looking closer, zooming in, choosing high- vs low-resolution, picking which tool to use are YOUR internal mechanics and NONE of the developer's concern. Just call look_at_screen / click / annotate / etc. silently and get on with it. Do NOT say things like "should I pull up a high-resolution version?", "would you like me to look closer?", or "which one do you mean?" for the obvious case. Do NOT narrate each step or ask for confirmation between steps \u2014 you are NOT tiptoeing through a minefield; that constant checking is annoying. Make the reasonable choice and act. Only ask a question when the request is GENUINELY ambiguous and you truly cannot proceed (e.g. there really are two equally-likely buttons) \u2014 otherwise pick the most likely interpretation and do it. (Narrating what you're doing out loud is REQUIRED \u2014 see KEEP TALKING below \u2014 but ASKING for confirmation or permission between steps is not. Describe; don't check in.)
|
|
49858
|
+
|
|
49859
|
+
OWN THE TASK \u2014 RECOVER FROM ERRORS YOURSELF: you have a toolbox (look_at_screen, figure_out_next, verify, perform_step, type_into, click, press_key, scroll_screen, launch_app, annotate). YOU decide which to use and in what order \u2014 there's almost always more than one way. For a complex task, break it into steps and do them ONE AT A TIME with perform_step (it plans + runs + self-corrects each step). After each step, use verify to CHECK it actually worked (e.g. verify "a new tab is open", verify "the search results are showing") before moving to the next. If verify says NO, fix that step before continuing. The moment you're unsure what to do or you hit an obstacle, call figure_out_next instead of guessing. When something fails or doesn't do what you expected, do NOT stop and ask the developer what to do \u2014 figure it out and try again a different way: if a keyboard shortcut does nothing, click the element instead; if a click misses, look_at_screen and re-aim; if an app isn't where you expect, launch_app it; if a page didn't load, retry or navigate another way. After each action, VERIFY by looking at the screen \u2014 don't assume it worked; check, and if it didn't, fix it. Keep working the problem until the goal is ACTUALLY achieved, then report the outcome. Treat the developer's request as a goal to complete autonomously, not a script to read back. Only come back to them if you're genuinely stuck after really trying alternatives, or you need something only they can give (a password, a choice between real options). Don't ask permission or check in every few seconds \u2014 just get it done.
|
|
49860
|
+
|
|
49861
|
+
KEEP TALKING \u2014 NARRATE IN PLAIN WORDS, NEVER GO SILENT WHILE WORKING: your tools run in the background while you keep speaking, so EVERY time you start a tool you MUST first say, out loud, what you're doing \u2014 and say it as the ACTIVITY in everyday words (WHAT you're working on), NEVER the tool's name or any technical jargon. Say "Okay, opening Photoshop now\u2026", "Let me find the brush tool\u2026", "Drawing the star now\u2026", "One sec, searching Amazon for jeans\u2026", "Just taking a look at your screen\u2026" \u2014 NOT "calling launch_app", "running perform_step", "invoking look_at_screen", "executing click". The developer should hear a person describing their work, not a robot reading function names. When a result comes back, say what happened in plain words \u2014 "Done, the results are up" or "Hmm, that didn't work \u2014 let me try another way". If something fails or you switch approach, SAY SO out loud. The developer should NEVER sit in silence wondering what you're doing \u2014 keep them in the loop before, during, and after every single action. A few seconds of silence with no narration is a failure.
|
|
49862
|
+
|
|
49863
|
+
HAND THE TURN BACK WHEN YOU'RE IDLE: the moment you've finished what they asked and have nothing else queued to do, tell them OUT LOUD that you're done and waiting for them \u2014 e.g. "All set \u2014 what would you like next?", "Done. Ready when you are.", "Okay, I'm waiting for your input." NEVER finish a task and then just go quiet; always close the loop with a short hand-back so they clearly know it's their turn to speak. Going idle without saying so leaves them wondering whether you're still working or stuck.
|
|
49864
|
+
|
|
49865
|
+
TELL THE TRUTH \u2014 VERIFY BEFORE YOU CLAIM: NEVER say something worked, opened, loaded, searched, or that "here are the results" / "you're on X now" unless you JUST confirmed it with verify or look_at_screen. A tool returning "done" only means the click/keystroke was SENT \u2014 NOT that it had the effect you wanted. After any action that should change the screen, call verify (or look_at_screen) and report ONLY what is actually there. Claiming a result you haven't checked is the WORST thing you can do \u2014 it makes you useless and impossible to trust (the developer instantly catches you). If the check says it didn't work, say so plainly and try a different way.
|
|
49866
|
+
|
|
49867
|
+
PREFER COMPOSITE STEPS \u2014 NEVER RACE MICRO-ACTIONS: do NOT try to do a multi-action step by firing several quick single calls \u2014 they run out of order. Instead:
|
|
49868
|
+
- To put text in a field \u2192 use type_into (it clicks the field, types, and optionally presses Enter, IN THE RIGHT ORDER).
|
|
49869
|
+
- For ANY step that needs more than one action ("search Amazon for jeans", "open a new tab and go to gmail.com", "add the first result to the cart") \u2192 use perform_step. A stronger model figures out the exact click/type sequence and RUNS it in order, then tells you the resulting screen. This is far more reliable than you sequencing the actions.
|
|
49870
|
+
- Use the single-action tools (click, press_key, scroll_screen) only for a genuinely SINGLE action.
|
|
49871
|
+
|
|
49872
|
+
WHEN YOU'RE STUCK OR CONFUSED: if you don't know how to proceed, an action didn't do what you expected, or you hit an obstacle (a dialog, a "See options" / size picker, a login wall, an unexpected screen) \u2014 do NOT flail with random clicks and do NOT just ask the developer. Call figure_out_next: a stronger model looks at the screen + everything you've been doing and hands you back the goal and a short list of the exact next steps to get past it. Then carry those steps out (with perform_step). This is your get-unstuck button \u2014 use it the moment you're unsure.
|
|
49873
|
+
|
|
49874
|
+
SEEING THE SCREEN: you do NOT have a continuous video feed. Instead you get a FRESH screen image right after every action you take (click, type_into, perform_step, scroll, etc.) and whenever you call look_at_screen. Between actions, you're working from that last image \u2014 if you haven't acted or looked recently, look_at_screen before you assume anything. For anything you must be SURE about \u2014 reading text, identifying a specific element, confirming a result actually happened \u2014 call look_at_screen (the current image + a detailed written description from a strong vision model: focused app/window + contents, any dialog/menu/notification, any selection, where the mouse is and what it's hovering over) or verify. Whenever the developer asks "what's on my screen / what do you see / read this / where's my cursor", or you need to confirm the state or result of an action, call look_at_screen and relay what it reports \u2014 never describe the screen from memory.
|
|
49709
49875
|
|
|
49710
|
-
|
|
49876
|
+
NEVER CLAIM A RESULT YOU HAVEN'T SEEN: do NOT say a step "is done", "is ready", "is typed", "was added", etc. until the tool RESULT or a verify/look_at_screen has actually confirmed it. While a tool is running and you're filling the silence, say only what you are DOING ("typing that in now\u2026", "opening it\u2026") \u2014 NEVER the OUTCOME. Sending a click or some keys is NOT proof it worked. If you're not sure, verify or look_at_screen and report ONLY what you truly see \u2014 saying something happened when it didn't is the worst thing you can do.
|
|
49711
49877
|
|
|
49712
|
-
FINDING / LOCATING: when they ask WHERE something is, to FIND it, point it out, or for its location \u2014
|
|
49878
|
+
FINDING / LOCATING: when they ask WHERE something is, to FIND it, point it out, or for its location \u2014 ALWAYS use annotate (or click): it takes a HIGH-RESOLUTION screenshot and asks the reasoning model for the exact spot. If the model can't find it, say so and offer to open it (launch_app) \u2014 don't pretend you can see it.
|
|
49713
49879
|
|
|
49714
49880
|
POINTING THINGS OUT: when they ask "where is X", "show me X", "point at X", "underline X", "cross out X", "check off X", or "highlight X", use annotate \u2014 it draws a hand-drawn red marker doodle around/at the item (circle, box, bracket, underline, zigzag, highlight, arrow, check, cross, star, strike, \u2026), animated as if drawn live, with an optional label like "Here!". Choose the style that matches their words (or omit it to auto-pick from the item's shape). annotate only highlights; it does NOT click \u2014 but it does draw on their screen, so it needs the same permission as control (ask the first time).
|
|
49715
49881
|
|
|
@@ -49717,11 +49883,13 @@ CLEARING ANNOTATIONS (important): your marker doodles PERSIST on the screen \u20
|
|
|
49717
49883
|
|
|
49718
49884
|
PERMISSION (read carefully): before you point at, annotate, click, type, or otherwise act on the screen for the FIRST time, you MUST call the request_control_consent tool. Calling it pops a permission box on the developer's screen \u2014 and at the same time you must SAY, word for word: "I need your permission in order to interact with your computer." Then tell them to click Allow on the box. The moment they click Allow, go ahead and call the action tool (annotate / click / \u2026) \u2014 it now works. NEVER just talk about needing permission without calling request_control_consent: if you don't call it, NOTHING appears on their screen and they'll be confused. (look_at_screen never needs permission.) A coral cursor + a top bar appear while you're interacting.
|
|
49719
49885
|
|
|
49720
|
-
To click or point: DESCRIBE the target in plain words (e.g. "the Google Chrome icon in the Dock", "the blue Sign in button") \u2014 never coordinates; the system locates it from the screen image. To
|
|
49886
|
+
To click or point: DESCRIBE the target in plain words (e.g. "the Google Chrome icon in the Dock", "the blue Sign in button") \u2014 never coordinates; the system locates it from the screen image. To point something out for the developer ("where is X", "show me X"), use annotate.
|
|
49721
49887
|
|
|
49722
|
-
OPENING APPS: to open or switch to an app, use launch_app with its name (e.g. launch_app "Google Chrome") \u2014 that is far more reliable than locating and clicking a Dock icon. Use
|
|
49888
|
+
OPENING APPS: to open or switch to an app, use launch_app with its name (e.g. launch_app "Google Chrome") \u2014 that is far more reliable than locating and clicking a Dock icon. Use verify or look_at_screen to check it opened and is ready before the next step.
|
|
49723
49889
|
|
|
49724
|
-
CLICKS
|
|
49890
|
+
CLICKS: the system locates your described target with a two-pass high-res zoom (accurate), moves the coral cursor there, and clicks. It does NOT know whether the click had the effect you wanted \u2014 so after any click, look_at_screen and report ONLY what actually changed. If it couldn't find the target, change approach (launch_app, scroll it into view, re-describe it, or use the accessibility tools below) \u2014 don't repeat the same click.
|
|
49891
|
+
|
|
49892
|
+
MORE TOOLS \u2014 you also have the full computer toolset (os_* tools): read/write/search files (os_fs_*), clipboard (os_clipboard_read/write), run a shell command (os_run), open a file or URL (os_open), manage windows and apps (os_windows, os_window_action, os_app_activate, os_app_quit, os_ps, os_proc_kill), inspect the network (os_net_*, os_http_probe), post a notification (os_notify), and read the macOS ACCESSIBILITY TREE (os_ax_tree gives the exact on-screen elements with their positions + actions; os_ax_action presses/focuses one precisely). When a vision-grounded click keeps missing a NATIVE control (a menu item, button, or Dock icon), use os_ax_tree to find it and os_ax_action to press it \u2014 that's pixel-exact. Anything that changes the machine (write/run/kill/quit/move/delete) asks the developer's permission the first time, exactly like clicking.
|
|
49725
49893
|
|
|
49726
49894
|
BE CAREFUL AND DELIBERATE \u2014 never act hastily:
|
|
49727
49895
|
1. look_at_screen so you can SEE the current state, and identify the target precisely.
|
|
@@ -49730,6 +49898,8 @@ BE CAREFUL AND DELIBERATE \u2014 never act hastily:
|
|
|
49730
49898
|
4. If it did NOT work, do NOT give up or blindly repeat \u2014 look again, re-describe the target more precisely, pick a different element, scroll it into view, or try another route. Persist with a better approach.
|
|
49731
49899
|
|
|
49732
49900
|
KEEP CONTROL for the rest of the conversation once granted \u2014 do NOT release between actions or tasks. Call release_control ONLY when the developer EXPLICITLY tells you to stop / let go. (Ending the call releases automatically.) If you genuinely cannot see or find the target, say so and ask. For real coding or multi-step automation, still delegate to Claude Code with the task tools.`;
|
|
49901
|
+
var SLOW_TOOL_FIRST = `(System note \u2014 do NOT read this note aloud or mention it. The action you're running is taking a little while. Say ONE short, natural, reassuring spoken sentence to the developer in your own words \u2014 like "this is taking a bit longer, just hold on" or "bear with me a second, still working on it". Do NOT claim it finished or describe any result \u2014 you're still waiting for it.)`;
|
|
49902
|
+
var SLOW_TOOL_MORE = `(System note \u2014 do NOT read this note aloud or mention it. That same action is STILL running. Say ONE short, natural reassurance that you're still on it \u2014 like "still working on it, almost there" \u2014 in your own words. Do NOT claim it finished or describe a result yet.)`;
|
|
49733
49903
|
async function mintOpenAi(apiKey, model, voice) {
|
|
49734
49904
|
const res = await fetch("https://api.openai.com/v1/realtime/sessions", {
|
|
49735
49905
|
method: "POST",
|
|
@@ -49782,6 +49952,10 @@ var VoiceControl = class {
|
|
|
49782
49952
|
/** Agent events tee'd in before the orchestrator subscribes (the connect window)
|
|
49783
49953
|
* are buffered and flushed on subscribe so no narration/session-bind is lost. */
|
|
49784
49954
|
pending = [];
|
|
49955
|
+
/** SERIALIZE screen-control tools. Gemini Live can emit several functionCalls in ONE turn
|
|
49956
|
+
* (parallel function calling); running them concurrently let `type` fire before `click` landed.
|
|
49957
|
+
* Chaining each onto the previous makes them run strictly in arrival order, one at a time. */
|
|
49958
|
+
screenQueue = Promise.resolve();
|
|
49785
49959
|
constructor(deps) {
|
|
49786
49960
|
this.deps = deps;
|
|
49787
49961
|
}
|
|
@@ -49794,7 +49968,9 @@ var VoiceControl = class {
|
|
|
49794
49968
|
if (this.deps.screenControl && this.deps.execScreenControl && SCREEN_TOOL_NAMES.has(msg.name)) {
|
|
49795
49969
|
log(`voice: tool-call (screen) ${msg.name} ${JSON.stringify(msg.args)}`);
|
|
49796
49970
|
recordEvent("tool_call", { kind: "screen", name: msg.name, args: msg.args });
|
|
49797
|
-
|
|
49971
|
+
const { callId, name, args } = msg;
|
|
49972
|
+
this.screenQueue = this.screenQueue.then(() => this.runScreenControl(callId, name, args)).catch(() => {
|
|
49973
|
+
});
|
|
49798
49974
|
} else {
|
|
49799
49975
|
log(`voice: tool-call (guide) ${msg.name}`);
|
|
49800
49976
|
recordEvent("tool_call", { kind: "guide", name: msg.name, args: msg.args });
|
|
@@ -49836,11 +50012,28 @@ var VoiceControl = class {
|
|
|
49836
50012
|
async runScreenControl(callId, name, args) {
|
|
49837
50013
|
let text4;
|
|
49838
50014
|
let isError = false;
|
|
50015
|
+
let finished = false, nudges = 0;
|
|
50016
|
+
let slowTimer = null;
|
|
50017
|
+
const scheduleNudge = (ms) => {
|
|
50018
|
+
slowTimer = setTimeout(() => {
|
|
50019
|
+
if (finished)
|
|
50020
|
+
return;
|
|
50021
|
+
nudges++;
|
|
50022
|
+
this.deps.send({ type: "voice:cd:inject", text: nudges === 1 ? SLOW_TOOL_FIRST : SLOW_TOOL_MORE });
|
|
50023
|
+
if (nudges < 4)
|
|
50024
|
+
scheduleNudge(3e4);
|
|
50025
|
+
}, ms);
|
|
50026
|
+
};
|
|
50027
|
+
scheduleNudge(2e4);
|
|
49839
50028
|
try {
|
|
49840
50029
|
text4 = await this.deps.execScreenControl(name, args);
|
|
49841
50030
|
} catch (e) {
|
|
49842
50031
|
text4 = e instanceof Error ? e.message : "screen action failed";
|
|
49843
50032
|
isError = true;
|
|
50033
|
+
} finally {
|
|
50034
|
+
finished = true;
|
|
50035
|
+
if (slowTimer)
|
|
50036
|
+
clearTimeout(slowTimer);
|
|
49844
50037
|
}
|
|
49845
50038
|
log(`voice: screen-control ${name} \u2192 ${isError ? "ERROR " : ""}${text4}`);
|
|
49846
50039
|
recordEvent("tool_result", { name, text: text4, isError });
|
|
@@ -49936,15 +50129,23 @@ var VoiceControl = class {
|
|
|
49936
50129
|
llm = cfg2?.complete ?? null;
|
|
49937
50130
|
} catch {
|
|
49938
50131
|
}
|
|
50132
|
+
const priorText = typeof msg.history === "string" ? msg.history.trim() : "";
|
|
50133
|
+
const priorTextPrompt = priorText ? `
|
|
50134
|
+
|
|
50135
|
+
CONTEXT \u2014 the developer was just chatting with you in TEXT (typed) and has now switched to VOICE. Here is that conversation so far; you have its FULL context, so continue naturally and never ask them to repeat anything:
|
|
50136
|
+
|
|
50137
|
+
${priorText}` : "";
|
|
49939
50138
|
const realtime = {
|
|
49940
50139
|
provider: msg.provider,
|
|
49941
50140
|
apiKey: "",
|
|
49942
50141
|
// unused: the proxy doesn't open a provider socket (the client does)
|
|
49943
|
-
voice: msg.voice,
|
|
50142
|
+
voice: msg.voice || (msg.provider === "gemini" ? DEFAULT_GEMINI_VOICE : void 0),
|
|
50143
|
+
// fixed female default
|
|
49944
50144
|
language: msg.language,
|
|
49945
50145
|
turnSensitivity: msg.turnSensitivity,
|
|
49946
|
-
instructions: buildGuidePrompt({ projectName: projectDir ? basename3(projectDir) : void 0, sessions: msg.sessions }) + (this.deps.screenControl ? SCREEN_CONTROL_PROMPT : "") + (this.deps.dispatchAppendPrompt ? GATEWAY_OPERATOR_PROMPT : ""),
|
|
49947
|
-
greeting: DEFAULT_GREETING
|
|
50146
|
+
instructions: buildGuidePrompt({ projectName: projectDir ? basename3(projectDir) : void 0, sessions: msg.sessions }) + (this.deps.screenControl ? SCREEN_CONTROL_PROMPT : "") + (this.deps.dispatchAppendPrompt ? GATEWAY_OPERATOR_PROMPT : "") + priorTextPrompt,
|
|
50147
|
+
greeting: priorText ? "" : DEFAULT_GREETING
|
|
50148
|
+
// already mid-conversation → don't re-greet
|
|
49948
50149
|
};
|
|
49949
50150
|
const orchestrator = new VoiceGuideOrchestrator({
|
|
49950
50151
|
agent,
|
|
@@ -49973,7 +50174,7 @@ var VoiceControl = class {
|
|
|
49973
50174
|
};
|
|
49974
50175
|
const proxy = new ClientProxyProvider(realtime, callbacks, { auth, send: (m) => this.deps.send(m), clientRequestId: msg.clientRequestId });
|
|
49975
50176
|
this.proxy = proxy;
|
|
49976
|
-
const tools = this.deps.screenControl ? [...GUIDE_TOOLS, ...SCREEN_CONTROL_TOOLS] : GUIDE_TOOLS;
|
|
50177
|
+
const tools = this.deps.screenControl ? [...GUIDE_TOOLS.filter((t) => t.name === "end_call"), ...SCREEN_CONTROL_TOOLS] : GUIDE_TOOLS;
|
|
49977
50178
|
proxy.setTools(tools);
|
|
49978
50179
|
log(`voice: tools declared (${tools.length}): ${tools.map((t) => t.name).join(", ")}`);
|
|
49979
50180
|
orchestrator.attachProvider(proxy);
|
|
@@ -50018,7 +50219,7 @@ var VoiceControl = class {
|
|
|
50018
50219
|
};
|
|
50019
50220
|
|
|
50020
50221
|
// ../../packages/host-core/dist/image-gen-runner.js
|
|
50021
|
-
import { randomUUID as
|
|
50222
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
50022
50223
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync10, readFileSync as readFileSync8 } from "node:fs";
|
|
50023
50224
|
import { homedir as homedir11 } from "node:os";
|
|
50024
50225
|
import { join as join22 } from "node:path";
|
|
@@ -50281,7 +50482,7 @@ function createDaemonImageGenRunner() {
|
|
|
50281
50482
|
const images = await runImageGeneration(provider, { prompt: req.prompt, providerId: id, count: req.count, inputImageB64, inputMime });
|
|
50282
50483
|
if (!images.length)
|
|
50283
50484
|
return { ok: false, error: "The provider returned no image." };
|
|
50284
|
-
const dir2 = req.outDir ?? join22(generatedImagesDir(),
|
|
50485
|
+
const dir2 = req.outDir ?? join22(generatedImagesDir(), randomUUID8());
|
|
50285
50486
|
mkdirSync9(dir2, { recursive: true });
|
|
50286
50487
|
const files = images.map((img, i) => {
|
|
50287
50488
|
const ext = img.mime.split("/")[1]?.split("+")[0] || "png";
|
|
@@ -50433,8 +50634,8 @@ var VOICE_GATEWAY = process.env.CCB_VOICE_GATEWAY === "1";
|
|
|
50433
50634
|
|
|
50434
50635
|
// ../../packages/host-core/dist/fs-remote.js
|
|
50435
50636
|
import { readdir as readdir3, readFile as readFile8, writeFile as writeFile5, mkdir as mkdir5, cp, rm, rename as renameAsync, stat as stat2 } from "node:fs/promises";
|
|
50436
|
-
import { openSync as openSync2, readSync, writeSync, closeSync as closeSync2, statSync as statSync4, existsSync as existsSync10, mkdtempSync, rmSync as rmSync2, readFileSync as readFileSync9, readdirSync as
|
|
50437
|
-
import { tmpdir as
|
|
50637
|
+
import { openSync as openSync2, readSync, writeSync, closeSync as closeSync2, statSync as statSync4, existsSync as existsSync10, mkdtempSync, rmSync as rmSync2, readFileSync as readFileSync9, readdirSync as readdirSync4, watch, realpathSync as realpathSync2, constants as fsConstants } from "node:fs";
|
|
50638
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
50438
50639
|
import { basename as basename4, dirname as dirname8, join as join25, relative as relative4, resolve as resolve5, sep as sep4, isAbsolute as isAbsolute4 } from "node:path";
|
|
50439
50640
|
import { execFile as execFile3 } from "node:child_process";
|
|
50440
50641
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -50814,9 +51015,9 @@ async function renderThumbnailImpl(real, maxPx) {
|
|
|
50814
51015
|
return { error: "Thumbnails are only available on macOS hosts." };
|
|
50815
51016
|
let dir2 = null;
|
|
50816
51017
|
try {
|
|
50817
|
-
dir2 = mkdtempSync(join25(
|
|
51018
|
+
dir2 = mkdtempSync(join25(tmpdir2(), "fp-thumb-"));
|
|
50818
51019
|
await execFileAsync("qlmanage", ["-t", "-s", String(maxPx), "-o", dir2, real], { timeout: 1e4, killSignal: "SIGKILL" }).catch(() => void 0);
|
|
50819
|
-
const produced =
|
|
51020
|
+
const produced = readdirSync4(dir2).find((f) => f.toLowerCase().endsWith(".png"));
|
|
50820
51021
|
if (!produced)
|
|
50821
51022
|
return { error: "No thumbnail available." };
|
|
50822
51023
|
return { png: readFileSync9(join25(dir2, produced)).toString("base64") };
|
|
@@ -50864,7 +51065,7 @@ function pruneTrash(root) {
|
|
|
50864
51065
|
return;
|
|
50865
51066
|
const cutoff = Date.now() - TRASH_RETENTION_MS;
|
|
50866
51067
|
try {
|
|
50867
|
-
for (const e of
|
|
51068
|
+
for (const e of readdirSync4(trashDir, { withFileTypes: true })) {
|
|
50868
51069
|
if (!e.isDirectory())
|
|
50869
51070
|
continue;
|
|
50870
51071
|
try {
|
|
@@ -51159,7 +51360,7 @@ async function runRemoteFsOp(root, op, args, quotaKey) {
|
|
|
51159
51360
|
return [];
|
|
51160
51361
|
try {
|
|
51161
51362
|
const out = [];
|
|
51162
|
-
for (const e of
|
|
51363
|
+
for (const e of readdirSync4(trashDir, { withFileTypes: true })) {
|
|
51163
51364
|
if (!e.isDirectory())
|
|
51164
51365
|
continue;
|
|
51165
51366
|
try {
|
|
@@ -52343,7 +52544,7 @@ var PeerLinkManager = class {
|
|
|
52343
52544
|
* {@link openLink}) and the unsolicited responder (a peer-initiated rendezvous —
|
|
52344
52545
|
* we just dial/listen and cache the link for the transfer engine to find).
|
|
52345
52546
|
*/
|
|
52346
|
-
onServerMessage(msg,
|
|
52547
|
+
onServerMessage(msg, ctx2) {
|
|
52347
52548
|
if (!("rid" in msg))
|
|
52348
52549
|
return;
|
|
52349
52550
|
const pending = this.pendingOpens.get(msg.rid);
|
|
@@ -52355,7 +52556,7 @@ var PeerLinkManager = class {
|
|
|
52355
52556
|
return;
|
|
52356
52557
|
}
|
|
52357
52558
|
if (msg.type === "p2p:go") {
|
|
52358
|
-
this.handleGo(msg).catch((e) =>
|
|
52559
|
+
this.handleGo(msg).catch((e) => ctx2.sendP2p({ type: "p2p:failed", rid: msg.rid, reason: e.message }));
|
|
52359
52560
|
}
|
|
52360
52561
|
}
|
|
52361
52562
|
/**
|
|
@@ -52364,11 +52565,11 @@ var PeerLinkManager = class {
|
|
|
52364
52565
|
* dialer/listener once on failure) via {@link onServerMessage}. Rejects if no
|
|
52365
52566
|
* rung connects within the rendezvous window — NO relay fallback.
|
|
52366
52567
|
*/
|
|
52367
|
-
async openLink(peerHostId,
|
|
52568
|
+
async openLink(peerHostId, ctx2) {
|
|
52368
52569
|
const existing = this.liveLinks.get(peerHostId);
|
|
52369
52570
|
if (existing)
|
|
52370
52571
|
return existing;
|
|
52371
|
-
this.attach(
|
|
52572
|
+
this.attach(ctx2);
|
|
52372
52573
|
await this.ensureListener();
|
|
52373
52574
|
const myFingerprint = (await this.identity()).fingerprint256;
|
|
52374
52575
|
const rid = randomBytes3(8).toString("hex");
|
|
@@ -52393,23 +52594,23 @@ var PeerLinkManager = class {
|
|
|
52393
52594
|
// tears the rendezvous down — no role-flip) AND reject fast. NO relay fallback.
|
|
52394
52595
|
onGo: (go) => {
|
|
52395
52596
|
this.handleGo(go).then((l) => finish(void 0, l)).catch((e) => {
|
|
52396
|
-
|
|
52597
|
+
ctx2.sendP2p({ type: "p2p:failed", rid, reason: e.message });
|
|
52397
52598
|
finish(e);
|
|
52398
52599
|
});
|
|
52399
52600
|
},
|
|
52400
52601
|
onFailed: (reason) => finish(new Error(`peer-link: rendezvous failed (${reason})`))
|
|
52401
52602
|
});
|
|
52402
|
-
|
|
52603
|
+
ctx2.sendP2p({ type: "p2p:connect", rid, toHost: peerHostId, candidates: myCandidates, tlsFingerprint256: myFingerprint });
|
|
52403
52604
|
});
|
|
52404
52605
|
}
|
|
52405
52606
|
/** Install the single standing `p2p`-channel subscription (idempotent). A host
|
|
52406
52607
|
* that can be DRIVEN must attach at startup so it answers unsolicited rendezvous
|
|
52407
52608
|
* even when it never calls openLink itself. */
|
|
52408
|
-
attach(
|
|
52609
|
+
attach(ctx2) {
|
|
52409
52610
|
if (this.attached)
|
|
52410
52611
|
return;
|
|
52411
52612
|
this.attached = true;
|
|
52412
|
-
|
|
52613
|
+
ctx2.onP2p((msg) => this.onServerMessage(msg, ctx2));
|
|
52413
52614
|
}
|
|
52414
52615
|
/** Tear down all links + the listener (process shutdown / account change). */
|
|
52415
52616
|
close() {
|
|
@@ -52467,8 +52668,8 @@ function peerLinkManager() {
|
|
|
52467
52668
|
}
|
|
52468
52669
|
return manager;
|
|
52469
52670
|
}
|
|
52470
|
-
async function openPeerLink(peerHostId,
|
|
52471
|
-
return peerLinkManager().openLink(peerHostId,
|
|
52671
|
+
async function openPeerLink(peerHostId, ctx2) {
|
|
52672
|
+
return peerLinkManager().openLink(peerHostId, ctx2);
|
|
52472
52673
|
}
|
|
52473
52674
|
|
|
52474
52675
|
// ../../packages/host-core/dist/active-link/engine.js
|
|
@@ -58006,11 +58207,11 @@ async function dispatch(msg, tools) {
|
|
|
58006
58207
|
return result(id, { tools: tools.map((t) => ({ name: t.name, description: t.description, inputSchema: jsonSchema(t.schema) })) });
|
|
58007
58208
|
case "tools/call": {
|
|
58008
58209
|
const name = params?.name;
|
|
58009
|
-
const
|
|
58010
|
-
if (!
|
|
58210
|
+
const tool9 = tools.find((t) => t.name === name);
|
|
58211
|
+
if (!tool9)
|
|
58011
58212
|
return rpcError(id, -32602, `Unknown tool: ${name}`);
|
|
58012
58213
|
try {
|
|
58013
|
-
const out = await
|
|
58214
|
+
const out = await tool9.handler(params?.arguments ?? {});
|
|
58014
58215
|
return result(id, out);
|
|
58015
58216
|
} catch (e) {
|
|
58016
58217
|
return result(id, { content: [{ type: "text", text: e instanceof Error ? e.message : String(e) }], isError: true });
|
|
@@ -58025,7 +58226,7 @@ function startOsControlMcpEndpoint(opts) {
|
|
|
58025
58226
|
});
|
|
58026
58227
|
const allowDestructive = opts.allowDestructive ?? true;
|
|
58027
58228
|
const tools = buildOsControlTools(opts.provider, {
|
|
58028
|
-
consent: (
|
|
58229
|
+
consent: (tool9) => allowDestructive || !tool9.destructive ? true : `Refused: "${tool9.name}" changes machine state and the endpoint is in read-only mode.`
|
|
58029
58230
|
});
|
|
58030
58231
|
const handle2 = async (req, res) => {
|
|
58031
58232
|
if (!originAllowed2(req.headers.origin)) {
|
|
@@ -58632,7 +58833,7 @@ function getServiceController(instanceId) {
|
|
|
58632
58833
|
|
|
58633
58834
|
// src/auth.ts
|
|
58634
58835
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
58635
|
-
import { randomUUID as
|
|
58836
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
58636
58837
|
import { existsSync as existsSync22, rmSync as rmSync3 } from "node:fs";
|
|
58637
58838
|
import { join as join41 } from "node:path";
|
|
58638
58839
|
|
|
@@ -58774,7 +58975,7 @@ async function login(opts) {
|
|
|
58774
58975
|
process.exit(1);
|
|
58775
58976
|
}
|
|
58776
58977
|
}
|
|
58777
|
-
const deviceId2 = readCredentials()?.deviceId ?? process.env.CCB_DEVICE_ID ??
|
|
58978
|
+
const deviceId2 = readCredentials()?.deviceId ?? process.env.CCB_DEVICE_ID ?? randomUUID9().slice(0, 8);
|
|
58778
58979
|
const label = opts.name ?? defaultLabel();
|
|
58779
58980
|
if (opts.token) {
|
|
58780
58981
|
const dt = await fetchJson(`${api}/auth/device-token`, {
|