@whittlelabs/sifter 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin.js +2875 -659
- package/bin.js.map +4 -4
- package/package.json +2 -2
package/bin.js
CHANGED
|
@@ -3195,7 +3195,7 @@ var require_device_code = __commonJS({
|
|
|
3195
3195
|
hostname: (0, os_1.hostname)(),
|
|
3196
3196
|
user: (0, os_1.userInfo)().username
|
|
3197
3197
|
},
|
|
3198
|
-
|
|
3198
|
+
jobPools: token.jobPools
|
|
3199
3199
|
};
|
|
3200
3200
|
}
|
|
3201
3201
|
async function startDeviceCode(opts) {
|
|
@@ -15265,81 +15265,12 @@ ${issues}`);
|
|
|
15265
15265
|
}
|
|
15266
15266
|
});
|
|
15267
15267
|
|
|
15268
|
-
// ../../packages/jobs/dist/prompt-execution.js
|
|
15269
|
-
var require_prompt_execution = __commonJS({
|
|
15270
|
-
"../../packages/jobs/dist/prompt-execution.js"(exports2) {
|
|
15271
|
-
"use strict";
|
|
15272
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15273
|
-
exports2.DEFAULT_JOB_TYPE = void 0;
|
|
15274
|
-
exports2.buildPromptExecutionInputs = buildPromptExecutionInputs;
|
|
15275
|
-
exports2.readPromptExecutionSpec = readPromptExecutionSpec;
|
|
15276
|
-
exports2.DEFAULT_JOB_TYPE = "prompt-execution";
|
|
15277
|
-
function buildPromptExecutionInputs(options) {
|
|
15278
|
-
const spec = {
|
|
15279
|
-
rendering: options.rendering,
|
|
15280
|
-
outputLabel: options.output.label,
|
|
15281
|
-
outputSchema: options.output.schema
|
|
15282
|
-
};
|
|
15283
|
-
if (options.providerHints)
|
|
15284
|
-
spec.providerHints = options.providerHints;
|
|
15285
|
-
if (options.costCapHint)
|
|
15286
|
-
spec.costCapHint = options.costCapHint;
|
|
15287
|
-
if (options.rendering === "producer" && !options.prompt) {
|
|
15288
|
-
throw new Error("rendering='producer' requires `prompt`");
|
|
15289
|
-
}
|
|
15290
|
-
if (options.rendering === "subscriber" && !options.template) {
|
|
15291
|
-
throw new Error("rendering='subscriber' requires `template`");
|
|
15292
|
-
}
|
|
15293
|
-
const inputs = [
|
|
15294
|
-
{ label: "spec", origin: "raw", payload: { spec } }
|
|
15295
|
-
];
|
|
15296
|
-
if (options.rendering === "producer") {
|
|
15297
|
-
inputs.push({ label: "prompt", origin: "raw", payload: { text: options.prompt } });
|
|
15298
|
-
} else {
|
|
15299
|
-
inputs.push({ label: "template", origin: "raw", payload: { text: options.template } });
|
|
15300
|
-
if (options.vars) {
|
|
15301
|
-
inputs.push({ label: "vars", origin: "raw", payload: options.vars });
|
|
15302
|
-
}
|
|
15303
|
-
}
|
|
15304
|
-
if (options.artifacts) {
|
|
15305
|
-
for (const artifact of options.artifacts) {
|
|
15306
|
-
inputs.push({
|
|
15307
|
-
label: "artifacts",
|
|
15308
|
-
origin: artifact.origin,
|
|
15309
|
-
payload: { label: artifact.label, ...artifact.payload }
|
|
15310
|
-
});
|
|
15311
|
-
}
|
|
15312
|
-
}
|
|
15313
|
-
return inputs;
|
|
15314
|
-
}
|
|
15315
|
-
function readPromptExecutionSpec(inputs) {
|
|
15316
|
-
const specRow = inputs.find((i) => i.label === "spec");
|
|
15317
|
-
if (!specRow)
|
|
15318
|
-
throw new Error("prompt-execution: missing `spec` input row");
|
|
15319
|
-
const spec = specRow.payload.spec;
|
|
15320
|
-
if (!spec)
|
|
15321
|
-
throw new Error("prompt-execution: spec row payload missing `spec` field");
|
|
15322
|
-
if (spec.rendering !== "producer" && spec.rendering !== "subscriber") {
|
|
15323
|
-
throw new Error(`prompt-execution: invalid spec.rendering "${spec.rendering}"`);
|
|
15324
|
-
}
|
|
15325
|
-
if (typeof spec.outputLabel !== "string" || spec.outputLabel.length === 0) {
|
|
15326
|
-
throw new Error("prompt-execution: spec.outputLabel must be a non-empty string");
|
|
15327
|
-
}
|
|
15328
|
-
if (typeof spec.outputSchema !== "object" || spec.outputSchema === null) {
|
|
15329
|
-
throw new Error("prompt-execution: spec.outputSchema must be a JSON Schema object");
|
|
15330
|
-
}
|
|
15331
|
-
return spec;
|
|
15332
|
-
}
|
|
15333
|
-
}
|
|
15334
|
-
});
|
|
15335
|
-
|
|
15336
15268
|
// ../../packages/jobs/dist/client.js
|
|
15337
15269
|
var require_client = __commonJS({
|
|
15338
15270
|
"../../packages/jobs/dist/client.js"(exports2) {
|
|
15339
15271
|
"use strict";
|
|
15340
15272
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15341
15273
|
exports2.JobsClient = void 0;
|
|
15342
|
-
var prompt_execution_1 = require_prompt_execution();
|
|
15343
15274
|
var JobsClient = class {
|
|
15344
15275
|
baseUrl;
|
|
15345
15276
|
apiKey;
|
|
@@ -15359,12 +15290,12 @@ var require_client = __commonJS({
|
|
|
15359
15290
|
* (the manager behind it re-mints before expiry) instead of pinning the
|
|
15360
15291
|
* token it happened to hold at construction.
|
|
15361
15292
|
*/
|
|
15362
|
-
async buildHeaders() {
|
|
15293
|
+
async buildHeaders(forceRefresh = false) {
|
|
15363
15294
|
const headers = { "Content-Type": "application/json" };
|
|
15364
15295
|
if (this.apiKey) {
|
|
15365
15296
|
headers["X-API-Key"] = this.apiKey;
|
|
15366
15297
|
} else if (this.getAccessToken) {
|
|
15367
|
-
const token = await this.getAccessToken();
|
|
15298
|
+
const token = await this.getAccessToken({ forceRefresh });
|
|
15368
15299
|
if (token)
|
|
15369
15300
|
headers["Authorization"] = `Bearer ${token}`;
|
|
15370
15301
|
} else if (this.accessToken) {
|
|
@@ -15372,19 +15303,35 @@ var require_client = __commonJS({
|
|
|
15372
15303
|
}
|
|
15373
15304
|
return headers;
|
|
15374
15305
|
}
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15306
|
+
/**
|
|
15307
|
+
* Fetch with one auth retry. A 401 on a token-provider client usually means
|
|
15308
|
+
* the token was invalidated server-side (Keep restart, key rotation,
|
|
15309
|
+
* revoke-then-repair, clock skew) while the local expiry timer still thinks
|
|
15310
|
+
* it's valid. Force a re-mint and retry once before surfacing the failure.
|
|
15311
|
+
* `onResponse` (min-version contract) fires on the response we actually act
|
|
15312
|
+
* on. `body` is a string, so it is safe to resend.
|
|
15313
|
+
*/
|
|
15314
|
+
async fetchWithAuthRetry(method, url, body) {
|
|
15315
|
+
let response = await fetch(url, { method, headers: await this.buildHeaders(), body });
|
|
15316
|
+
if (response.status === 401 && this.getAccessToken) {
|
|
15317
|
+
response = await fetch(url, { method, headers: await this.buildHeaders(true), body });
|
|
15318
|
+
}
|
|
15319
|
+
this.onResponse?.(response);
|
|
15320
|
+
return response;
|
|
15321
|
+
}
|
|
15322
|
+
// ── Job Pools ──────────────────────────────────────────────
|
|
15323
|
+
async createJobPool(options) {
|
|
15324
|
+
return this.request("POST", "/api/job-pools", options);
|
|
15378
15325
|
}
|
|
15379
15326
|
/**
|
|
15380
15327
|
* Idempotent upsert by `(principal_class, principal_id, name)`. When the
|
|
15381
15328
|
* pool exists, returns the existing row without modifying membership
|
|
15382
15329
|
* constraints. The Sift provisioning hook relies on this semantics.
|
|
15383
15330
|
*/
|
|
15384
|
-
async
|
|
15385
|
-
return this.request("POST", "/api/
|
|
15331
|
+
async findOrCreateJobPool(options) {
|
|
15332
|
+
return this.request("POST", "/api/job-pools?idempotent=true", options);
|
|
15386
15333
|
}
|
|
15387
|
-
async
|
|
15334
|
+
async listJobPools(filters) {
|
|
15388
15335
|
const params = new URLSearchParams();
|
|
15389
15336
|
if (filters?.principalClass)
|
|
15390
15337
|
params.set("principalClass", filters.principalClass);
|
|
@@ -15393,47 +15340,45 @@ var require_client = __commonJS({
|
|
|
15393
15340
|
if (filters?.name)
|
|
15394
15341
|
params.set("name", filters.name);
|
|
15395
15342
|
const qs = params.toString();
|
|
15396
|
-
return this.request("GET", `/api/
|
|
15343
|
+
return this.request("GET", `/api/job-pools${qs ? `?${qs}` : ""}`);
|
|
15397
15344
|
}
|
|
15398
|
-
async
|
|
15399
|
-
return this.request("GET", `/api/
|
|
15345
|
+
async getJobPool(poolId) {
|
|
15346
|
+
return this.request("GET", `/api/job-pools/${poolId}`);
|
|
15400
15347
|
}
|
|
15401
|
-
async
|
|
15402
|
-
const pools = await this.
|
|
15348
|
+
async resolveJobPoolByName(name) {
|
|
15349
|
+
const pools = await this.listJobPools({ name });
|
|
15403
15350
|
return pools.find((p) => p.name === name);
|
|
15404
15351
|
}
|
|
15405
15352
|
/** Internal: resolve a `PoolRef` to a pool id. */
|
|
15406
15353
|
async resolvePoolRef(ref) {
|
|
15407
15354
|
if ("id" in ref)
|
|
15408
15355
|
return ref.id;
|
|
15409
|
-
const pool = await this.
|
|
15356
|
+
const pool = await this.resolveJobPoolByName(ref.name);
|
|
15410
15357
|
if (!pool)
|
|
15411
|
-
throw new Error(`
|
|
15358
|
+
throw new Error(`Job pool not found by name: "${ref.name}"`);
|
|
15412
15359
|
return pool.id;
|
|
15413
15360
|
}
|
|
15414
15361
|
// ── Members ──────────────────────────────────────────────────────
|
|
15415
15362
|
// A subscriber joins a pool by registering as a member of it. These
|
|
15416
|
-
// map to the server's `/api/
|
|
15363
|
+
// map to the server's `/api/job-pools/:poolId/members` routes.
|
|
15417
15364
|
async listMembers(poolId) {
|
|
15418
|
-
return this.request("GET", `/api/
|
|
15365
|
+
return this.request("GET", `/api/job-pools/${poolId}/members`);
|
|
15419
15366
|
}
|
|
15420
15367
|
async registerMember(poolId, options) {
|
|
15421
|
-
return this.request("POST", `/api/
|
|
15368
|
+
return this.request("POST", `/api/job-pools/${poolId}/members`, options);
|
|
15422
15369
|
}
|
|
15423
15370
|
async updateMember(poolId, memberId, options) {
|
|
15424
|
-
return this.request("PUT", `/api/
|
|
15371
|
+
return this.request("PUT", `/api/job-pools/${poolId}/members/${memberId}`, options);
|
|
15425
15372
|
}
|
|
15426
15373
|
// ── Jobs (producer) ──────────────────────────────────────────────
|
|
15427
15374
|
/**
|
|
15428
|
-
* Enqueue a job into
|
|
15429
|
-
*
|
|
15430
|
-
* `accepted_job_types`.
|
|
15375
|
+
* Enqueue a job into a job pool. The `inputs` are opaque to Jobs; a Shuttle
|
|
15376
|
+
* reads the strategy header inside them to decide how to run it (ADR 0005).
|
|
15431
15377
|
*/
|
|
15432
15378
|
async enqueueJob(options) {
|
|
15433
|
-
const
|
|
15379
|
+
const jobPoolId = await this.resolvePoolRef(options.pool);
|
|
15434
15380
|
const body = {
|
|
15435
|
-
|
|
15436
|
-
jobType: options.jobType ?? prompt_execution_1.DEFAULT_JOB_TYPE,
|
|
15381
|
+
jobPoolId,
|
|
15437
15382
|
instructions: options.instructions,
|
|
15438
15383
|
maxAttempts: options.maxAttempts,
|
|
15439
15384
|
deadlineDuration: options.deadlineDuration,
|
|
@@ -15493,82 +15438,10 @@ var require_client = __commonJS({
|
|
|
15493
15438
|
const qs = params.toString();
|
|
15494
15439
|
return this.requestPaginated("GET", `/api/my/jobs${qs ? `?${qs}` : ""}`);
|
|
15495
15440
|
}
|
|
15496
|
-
// ── Prompt-execution helpers ─────────────────────────────────────
|
|
15497
|
-
/**
|
|
15498
|
-
* Fire-and-forget prompt-execution enqueue. Returns the job id; the
|
|
15499
|
-
* caller is responsible for correlating completion (Loom's path).
|
|
15500
|
-
*/
|
|
15501
|
-
async enqueuePromptExecutionAsync(options) {
|
|
15502
|
-
const inputs = (0, prompt_execution_1.buildPromptExecutionInputs)(options);
|
|
15503
|
-
const job = await this.enqueueJob({
|
|
15504
|
-
pool: options.pool,
|
|
15505
|
-
jobType: "prompt-execution",
|
|
15506
|
-
priority: options.priority,
|
|
15507
|
-
tags: options.tags,
|
|
15508
|
-
maxAttempts: options.maxAttempts,
|
|
15509
|
-
deadlineDuration: options.deadlineDuration,
|
|
15510
|
-
clientRef: options.clientRef,
|
|
15511
|
-
clientContext: options.clientContext,
|
|
15512
|
-
inputs
|
|
15513
|
-
});
|
|
15514
|
-
return { jobId: job.id };
|
|
15515
|
-
}
|
|
15516
|
-
/**
|
|
15517
|
-
* Awaitable prompt-execution. Enqueues, then polls until the
|
|
15518
|
-
* subscriber submits a schema-valid output (or the job fails / cancels
|
|
15519
|
-
* / times out). NATS push will replace polling when available; the
|
|
15520
|
-
* public API is unchanged.
|
|
15521
|
-
*/
|
|
15522
|
-
async enqueuePromptExecution(options) {
|
|
15523
|
-
const { jobId } = await this.enqueuePromptExecutionAsync(options);
|
|
15524
|
-
const startedAt = Date.now();
|
|
15525
|
-
const deadlineMs = options.deadlineDuration ? startedAt + parseIso8601DurationMs(options.deadlineDuration) : Infinity;
|
|
15526
|
-
let pollIntervalMs = 2e3;
|
|
15527
|
-
const maxPollIntervalMs = 1e4;
|
|
15528
|
-
while (true) {
|
|
15529
|
-
if (options.signal?.aborted) {
|
|
15530
|
-
try {
|
|
15531
|
-
await this.cancelJob(jobId);
|
|
15532
|
-
} catch {
|
|
15533
|
-
}
|
|
15534
|
-
return { jobId, status: "cancelled", reason: "aborted by caller" };
|
|
15535
|
-
}
|
|
15536
|
-
if (Date.now() > deadlineMs) {
|
|
15537
|
-
return { jobId, status: "timed_out", reason: "deadline elapsed" };
|
|
15538
|
-
}
|
|
15539
|
-
const job = await this.getJob(jobId);
|
|
15540
|
-
const outputs = await this.listOutputs(jobId);
|
|
15541
|
-
if (job.status === "completed" || job.status === "succeeded") {
|
|
15542
|
-
const result = parsePromptExecutionOutputs(jobId, outputs, options.output.label);
|
|
15543
|
-
return result;
|
|
15544
|
-
}
|
|
15545
|
-
if (job.status === "failed" || job.status === "cancelled" || job.status === "abandoned") {
|
|
15546
|
-
const usage = pickUsage(outputs);
|
|
15547
|
-
const reason = readFailureReason(outputs) ?? job.status;
|
|
15548
|
-
const status = reason === "refused_over_cap" ? "refused_over_cap" : "failed";
|
|
15549
|
-
const result = {
|
|
15550
|
-
jobId,
|
|
15551
|
-
status,
|
|
15552
|
-
reason,
|
|
15553
|
-
rawOutputs: outputs.map((o) => ({ label: o.label ?? "", content: o.content }))
|
|
15554
|
-
};
|
|
15555
|
-
if (usage)
|
|
15556
|
-
result.usage = usage;
|
|
15557
|
-
return result;
|
|
15558
|
-
}
|
|
15559
|
-
await sleep(pollIntervalMs);
|
|
15560
|
-
pollIntervalMs = Math.min(pollIntervalMs * 1.5, maxPollIntervalMs);
|
|
15561
|
-
}
|
|
15562
|
-
}
|
|
15563
15441
|
// ── HTTP plumbing ────────────────────────────────────────────────
|
|
15564
15442
|
async request(method, path, body) {
|
|
15565
15443
|
const url = `${this.baseUrl}${path}`;
|
|
15566
|
-
const response = await
|
|
15567
|
-
method,
|
|
15568
|
-
headers: await this.buildHeaders(),
|
|
15569
|
-
body: body ? JSON.stringify(body) : void 0
|
|
15570
|
-
});
|
|
15571
|
-
this.onResponse?.(response);
|
|
15444
|
+
const response = await this.fetchWithAuthRetry(method, url, body ? JSON.stringify(body) : void 0);
|
|
15572
15445
|
const json = await response.json();
|
|
15573
15446
|
if (!response.ok || !json.success) {
|
|
15574
15447
|
const errorMessage = json.error?.message ?? `Request failed with status ${response.status}`;
|
|
@@ -15581,8 +15454,7 @@ var require_client = __commonJS({
|
|
|
15581
15454
|
}
|
|
15582
15455
|
async requestPaginated(method, path) {
|
|
15583
15456
|
const url = `${this.baseUrl}${path}`;
|
|
15584
|
-
const response = await
|
|
15585
|
-
this.onResponse?.(response);
|
|
15457
|
+
const response = await this.fetchWithAuthRetry(method, url);
|
|
15586
15458
|
const json = await response.json();
|
|
15587
15459
|
if (!response.ok || !json.success) {
|
|
15588
15460
|
const errorMessage = json.error?.message ?? `Request failed with status ${response.status}`;
|
|
@@ -15595,170 +15467,6 @@ var require_client = __commonJS({
|
|
|
15595
15467
|
}
|
|
15596
15468
|
};
|
|
15597
15469
|
exports2.JobsClient = JobsClient;
|
|
15598
|
-
function sleep(ms) {
|
|
15599
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15600
|
-
}
|
|
15601
|
-
function parseIso8601DurationMs(s) {
|
|
15602
|
-
const m = /^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?$/.exec(s);
|
|
15603
|
-
if (!m)
|
|
15604
|
-
return 0;
|
|
15605
|
-
const hours = m[1] ? parseInt(m[1], 10) : 0;
|
|
15606
|
-
const minutes = m[2] ? parseInt(m[2], 10) : 0;
|
|
15607
|
-
const seconds = m[3] ? parseFloat(m[3]) : 0;
|
|
15608
|
-
return (hours * 3600 + minutes * 60) * 1e3 + seconds * 1e3;
|
|
15609
|
-
}
|
|
15610
|
-
function parsePromptExecutionOutputs(jobId, outputs, outputLabel) {
|
|
15611
|
-
const usage = pickUsage(outputs);
|
|
15612
|
-
const labelled = outputs.find((o) => o.label === outputLabel);
|
|
15613
|
-
if (!labelled) {
|
|
15614
|
-
const result2 = {
|
|
15615
|
-
jobId,
|
|
15616
|
-
status: "failed",
|
|
15617
|
-
reason: `no output with label "${outputLabel}"`,
|
|
15618
|
-
rawOutputs: outputs.map((o) => ({ label: o.label ?? "", content: o.content }))
|
|
15619
|
-
};
|
|
15620
|
-
if (usage)
|
|
15621
|
-
result2.usage = usage;
|
|
15622
|
-
return result2;
|
|
15623
|
-
}
|
|
15624
|
-
const result = {
|
|
15625
|
-
jobId,
|
|
15626
|
-
status: "succeeded",
|
|
15627
|
-
output: labelled.content,
|
|
15628
|
-
rawOutputs: outputs.map((o) => ({ label: o.label ?? "", content: o.content }))
|
|
15629
|
-
};
|
|
15630
|
-
if (usage)
|
|
15631
|
-
result.usage = usage;
|
|
15632
|
-
return result;
|
|
15633
|
-
}
|
|
15634
|
-
function pickUsage(outputs) {
|
|
15635
|
-
const u = outputs.find((o) => o.label === "usage");
|
|
15636
|
-
if (!u)
|
|
15637
|
-
return void 0;
|
|
15638
|
-
return u.content;
|
|
15639
|
-
}
|
|
15640
|
-
function readFailureReason(outputs) {
|
|
15641
|
-
const f = outputs.find((o) => o.label === "failure");
|
|
15642
|
-
if (!f)
|
|
15643
|
-
return void 0;
|
|
15644
|
-
const reason = f.content.reason;
|
|
15645
|
-
return typeof reason === "string" ? reason : void 0;
|
|
15646
|
-
}
|
|
15647
|
-
}
|
|
15648
|
-
});
|
|
15649
|
-
|
|
15650
|
-
// ../../packages/jobs/dist/prompt-execution-render.js
|
|
15651
|
-
var require_prompt_execution_render = __commonJS({
|
|
15652
|
-
"../../packages/jobs/dist/prompt-execution-render.js"(exports2) {
|
|
15653
|
-
"use strict";
|
|
15654
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15655
|
-
exports2.renderPromptExecution = renderPromptExecution;
|
|
15656
|
-
exports2.renderTemplate = renderTemplate;
|
|
15657
|
-
var prompt_execution_1 = require_prompt_execution();
|
|
15658
|
-
function renderPromptExecution(inputs) {
|
|
15659
|
-
const spec = (0, prompt_execution_1.readPromptExecutionSpec)(inputs);
|
|
15660
|
-
const artifacts = [];
|
|
15661
|
-
for (const i of inputs) {
|
|
15662
|
-
if (i.label === "artifacts") {
|
|
15663
|
-
const label = i.payload.label ?? "";
|
|
15664
|
-
artifacts.push({ label, payload: i.payload });
|
|
15665
|
-
}
|
|
15666
|
-
}
|
|
15667
|
-
let prompt = "";
|
|
15668
|
-
if (spec.rendering === "producer") {
|
|
15669
|
-
const promptRow = inputs.find((i) => i.label === "prompt");
|
|
15670
|
-
if (!promptRow)
|
|
15671
|
-
throw new Error("prompt-execution: rendering='producer' but no `prompt` input row");
|
|
15672
|
-
const text = promptRow.payload.text;
|
|
15673
|
-
if (typeof text !== "string") {
|
|
15674
|
-
throw new Error("prompt-execution: prompt.payload.text must be a string");
|
|
15675
|
-
}
|
|
15676
|
-
prompt = text;
|
|
15677
|
-
} else {
|
|
15678
|
-
const templateRow = inputs.find((i) => i.label === "template");
|
|
15679
|
-
if (!templateRow)
|
|
15680
|
-
throw new Error("prompt-execution: rendering='subscriber' but no `template` input row");
|
|
15681
|
-
const text = templateRow.payload.text;
|
|
15682
|
-
if (typeof text !== "string") {
|
|
15683
|
-
throw new Error("prompt-execution: template.payload.text must be a string");
|
|
15684
|
-
}
|
|
15685
|
-
const varsRow = inputs.find((i) => i.label === "vars");
|
|
15686
|
-
const vars = varsRow?.payload ?? {};
|
|
15687
|
-
prompt = renderTemplate(text, vars);
|
|
15688
|
-
}
|
|
15689
|
-
return { spec, prompt, artifacts };
|
|
15690
|
-
}
|
|
15691
|
-
function renderTemplate(template, vars) {
|
|
15692
|
-
const eachRe = /\{\{#each\s+([a-zA-Z_$][\w$]*)\s*\}\}([\s\S]*?)\{\{\/each\}\}/g;
|
|
15693
|
-
let out = template.replace(eachRe, (_match, name, body) => {
|
|
15694
|
-
const list = vars[name];
|
|
15695
|
-
if (!Array.isArray(list))
|
|
15696
|
-
return "";
|
|
15697
|
-
return list.map((item) => body.replace(/\{\{\s*this\s*\}\}/g, String(item))).join("");
|
|
15698
|
-
});
|
|
15699
|
-
out = out.replace(/\{\{\s*([a-zA-Z_$][\w$]*)\s*\}\}/g, (_match, name) => {
|
|
15700
|
-
if (Object.prototype.hasOwnProperty.call(vars, name)) {
|
|
15701
|
-
const v = vars[name];
|
|
15702
|
-
return v === null || v === void 0 ? "" : String(v);
|
|
15703
|
-
}
|
|
15704
|
-
return "";
|
|
15705
|
-
});
|
|
15706
|
-
return out;
|
|
15707
|
-
}
|
|
15708
|
-
}
|
|
15709
|
-
});
|
|
15710
|
-
|
|
15711
|
-
// ../../packages/jobs/dist/observers.js
|
|
15712
|
-
var require_observers = __commonJS({
|
|
15713
|
-
"../../packages/jobs/dist/observers.js"(exports2) {
|
|
15714
|
-
"use strict";
|
|
15715
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15716
|
-
exports2.ObserverChain = exports2.SpendCapExceeded = void 0;
|
|
15717
|
-
var SpendCapExceeded = class extends Error {
|
|
15718
|
-
cap;
|
|
15719
|
-
used;
|
|
15720
|
-
limit;
|
|
15721
|
-
constructor(cap, used, limit) {
|
|
15722
|
-
super(`Spend cap "${cap}" exceeded: used ${used}, limit ${limit}`);
|
|
15723
|
-
this.cap = cap;
|
|
15724
|
-
this.used = used;
|
|
15725
|
-
this.limit = limit;
|
|
15726
|
-
this.name = "SpendCapExceeded";
|
|
15727
|
-
}
|
|
15728
|
-
};
|
|
15729
|
-
exports2.SpendCapExceeded = SpendCapExceeded;
|
|
15730
|
-
var VETO_EVENTS = /* @__PURE__ */ new Set([
|
|
15731
|
-
"spend.preflight"
|
|
15732
|
-
]);
|
|
15733
|
-
var ObserverChain = class {
|
|
15734
|
-
observers;
|
|
15735
|
-
constructor(observers = []) {
|
|
15736
|
-
this.observers = observers;
|
|
15737
|
-
}
|
|
15738
|
-
/**
|
|
15739
|
-
* Notify every observer in registered order. Errors on non-veto events
|
|
15740
|
-
* are caught and logged via the caller-supplied logger; veto-event
|
|
15741
|
-
* errors propagate so the dispatcher can react.
|
|
15742
|
-
*/
|
|
15743
|
-
async notify(event, onObserverError) {
|
|
15744
|
-
const isVeto = VETO_EVENTS.has(event.kind);
|
|
15745
|
-
for (const observer of this.observers) {
|
|
15746
|
-
try {
|
|
15747
|
-
await observer.notify(event);
|
|
15748
|
-
} catch (err) {
|
|
15749
|
-
if (isVeto)
|
|
15750
|
-
throw err;
|
|
15751
|
-
if (onObserverError)
|
|
15752
|
-
onObserverError(err, observer.name, event);
|
|
15753
|
-
}
|
|
15754
|
-
}
|
|
15755
|
-
}
|
|
15756
|
-
/** Number of registered observers; useful for tests. */
|
|
15757
|
-
get size() {
|
|
15758
|
-
return this.observers.length;
|
|
15759
|
-
}
|
|
15760
|
-
};
|
|
15761
|
-
exports2.ObserverChain = ObserverChain;
|
|
15762
15470
|
}
|
|
15763
15471
|
});
|
|
15764
15472
|
|
|
@@ -15766,46 +15474,8 @@ var require_observers = __commonJS({
|
|
|
15766
15474
|
var require_subscribe = __commonJS({
|
|
15767
15475
|
"../../packages/jobs/dist/subscribe.js"(exports2) {
|
|
15768
15476
|
"use strict";
|
|
15769
|
-
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
15770
|
-
if (k2 === void 0) k2 = k;
|
|
15771
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15772
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15773
|
-
desc = { enumerable: true, get: function() {
|
|
15774
|
-
return m[k];
|
|
15775
|
-
} };
|
|
15776
|
-
}
|
|
15777
|
-
Object.defineProperty(o, k2, desc);
|
|
15778
|
-
}) : (function(o, m, k, k2) {
|
|
15779
|
-
if (k2 === void 0) k2 = k;
|
|
15780
|
-
o[k2] = m[k];
|
|
15781
|
-
}));
|
|
15782
|
-
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
15783
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15784
|
-
}) : function(o, v) {
|
|
15785
|
-
o["default"] = v;
|
|
15786
|
-
});
|
|
15787
|
-
var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
|
|
15788
|
-
var ownKeys = function(o) {
|
|
15789
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
15790
|
-
var ar = [];
|
|
15791
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
15792
|
-
return ar;
|
|
15793
|
-
};
|
|
15794
|
-
return ownKeys(o);
|
|
15795
|
-
};
|
|
15796
|
-
return function(mod) {
|
|
15797
|
-
if (mod && mod.__esModule) return mod;
|
|
15798
|
-
var result = {};
|
|
15799
|
-
if (mod != null) {
|
|
15800
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
15801
|
-
}
|
|
15802
|
-
__setModuleDefault(result, mod);
|
|
15803
|
-
return result;
|
|
15804
|
-
};
|
|
15805
|
-
})();
|
|
15806
15477
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15807
15478
|
exports2.subscribe = subscribe;
|
|
15808
|
-
var observers_1 = require_observers();
|
|
15809
15479
|
var NULL_LOGGER = {
|
|
15810
15480
|
debug: () => {
|
|
15811
15481
|
},
|
|
@@ -15816,14 +15486,13 @@ var require_subscribe = __commonJS({
|
|
|
15816
15486
|
error: () => {
|
|
15817
15487
|
}
|
|
15818
15488
|
};
|
|
15819
|
-
function
|
|
15820
|
-
|
|
15489
|
+
function sleep(ms) {
|
|
15490
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15491
|
+
}
|
|
15492
|
+
function subscribe(opts) {
|
|
15493
|
+
const logger = opts.logger ?? NULL_LOGGER;
|
|
15821
15494
|
const pollIntervalMs = opts.pollIntervalMs ?? 2e3;
|
|
15822
15495
|
const maxConcurrency = opts.maxConcurrency ?? 1;
|
|
15823
|
-
const executorsByCapability = /* @__PURE__ */ new Map();
|
|
15824
|
-
for (const executor of opts.executors) {
|
|
15825
|
-
executorsByCapability.set(executor.capability.id, executor);
|
|
15826
|
-
}
|
|
15827
15496
|
let stopped = true;
|
|
15828
15497
|
let pollTimer = null;
|
|
15829
15498
|
let inflight = 0;
|
|
@@ -15841,19 +15510,10 @@ var require_subscribe = __commonJS({
|
|
|
15841
15510
|
identityId: opts.subscriber.identityId,
|
|
15842
15511
|
intelligence: opts.subscriber.intelligence,
|
|
15843
15512
|
...opts.subscriber.displayName !== void 0 ? { displayName: opts.subscriber.displayName } : {},
|
|
15844
|
-
|
|
15845
|
-
// advertised set in metadata so it persists on the member row.
|
|
15846
|
-
metadata: {
|
|
15847
|
-
...opts.subscriber.metadata,
|
|
15848
|
-
capabilities: opts.subscriber.capabilities
|
|
15849
|
-
}
|
|
15513
|
+
...opts.subscriber.metadata !== void 0 ? { metadata: opts.subscriber.metadata } : {}
|
|
15850
15514
|
});
|
|
15851
15515
|
}
|
|
15852
|
-
logger.info("subscribe loop started", {
|
|
15853
|
-
pools: resolvedPoolIds,
|
|
15854
|
-
executors: Array.from(executorsByCapability.keys()),
|
|
15855
|
-
maxConcurrency
|
|
15856
|
-
});
|
|
15516
|
+
logger.info("subscribe loop started", { pools: resolvedPoolIds, maxConcurrency });
|
|
15857
15517
|
schedulePoll(pollIntervalMs);
|
|
15858
15518
|
}
|
|
15859
15519
|
async function stop() {
|
|
@@ -15902,24 +15562,13 @@ var require_subscribe = __commonJS({
|
|
|
15902
15562
|
schedulePoll(pollIntervalMs);
|
|
15903
15563
|
}
|
|
15904
15564
|
async function runOnce(available) {
|
|
15905
|
-
const startedAt = Date.now();
|
|
15906
|
-
await opts.observerChain.notify({
|
|
15907
|
-
kind: "job.discovered",
|
|
15908
|
-
jobId: available.id,
|
|
15909
|
-
poolId: available.attentionPool.id,
|
|
15910
|
-
poolName: available.attentionPool.name,
|
|
15911
|
-
attempt: available.attempt,
|
|
15912
|
-
tags: available.tags,
|
|
15913
|
-
discoveredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
15914
|
-
}, onObserverError);
|
|
15915
15565
|
let dispatch;
|
|
15916
15566
|
try {
|
|
15917
|
-
await opts.observerChain.notify({ kind: "job.claim.requested", jobId: available.id, poolId: available.attentionPool.id }, onObserverError);
|
|
15918
15567
|
dispatch = await opts.jobsClient.acceptDispatch(available.id);
|
|
15919
15568
|
} catch (err) {
|
|
15920
15569
|
const statusCode = err.statusCode;
|
|
15921
15570
|
if (statusCode === 409) {
|
|
15922
|
-
logger.debug?.("claim conflict; another
|
|
15571
|
+
logger.debug?.("claim conflict; another member accepted", { jobId: available.id });
|
|
15923
15572
|
return;
|
|
15924
15573
|
}
|
|
15925
15574
|
logger.error("failed to accept dispatch", {
|
|
@@ -15928,15 +15577,6 @@ var require_subscribe = __commonJS({
|
|
|
15928
15577
|
});
|
|
15929
15578
|
return;
|
|
15930
15579
|
}
|
|
15931
|
-
await opts.observerChain.notify({
|
|
15932
|
-
kind: "job.claimed",
|
|
15933
|
-
jobId: available.id,
|
|
15934
|
-
attendanceId: dispatch.attendanceId,
|
|
15935
|
-
attempt: dispatch.job.attempt,
|
|
15936
|
-
deadline: dispatch.deadline,
|
|
15937
|
-
claimedAt: dispatch.claimedAt,
|
|
15938
|
-
dispatch
|
|
15939
|
-
}, onObserverError);
|
|
15940
15580
|
const controller = new AbortController();
|
|
15941
15581
|
let deadlineTimer = null;
|
|
15942
15582
|
if (dispatch.deadline) {
|
|
@@ -15947,215 +15587,2633 @@ var require_subscribe = __commonJS({
|
|
|
15947
15587
|
controller.abort();
|
|
15948
15588
|
}
|
|
15949
15589
|
}
|
|
15590
|
+
let result;
|
|
15950
15591
|
try {
|
|
15951
|
-
await
|
|
15592
|
+
result = await opts.onJob(dispatch, controller.signal);
|
|
15593
|
+
} catch (err) {
|
|
15594
|
+
result = {
|
|
15595
|
+
status: "failed",
|
|
15596
|
+
reason: `onJob threw: ${err instanceof Error ? err.message : String(err)}`
|
|
15597
|
+
};
|
|
15952
15598
|
} finally {
|
|
15953
15599
|
if (deadlineTimer !== null)
|
|
15954
15600
|
clearTimeout(deadlineTimer);
|
|
15955
15601
|
}
|
|
15602
|
+
try {
|
|
15603
|
+
for (const output of result.outputs ?? []) {
|
|
15604
|
+
await opts.jobsClient.createOutput(dispatch.job.id, {
|
|
15605
|
+
label: output.label,
|
|
15606
|
+
content: output.content
|
|
15607
|
+
});
|
|
15608
|
+
}
|
|
15609
|
+
await opts.jobsClient.submit(dispatch.job.id, {
|
|
15610
|
+
status: result.status,
|
|
15611
|
+
...result.reason !== void 0 ? { reason: result.reason } : {}
|
|
15612
|
+
});
|
|
15613
|
+
} catch (err) {
|
|
15614
|
+
logger.error("submit/close failed", {
|
|
15615
|
+
jobId: dispatch.job.id,
|
|
15616
|
+
error: err instanceof Error ? err.message : String(err)
|
|
15617
|
+
});
|
|
15618
|
+
}
|
|
15956
15619
|
}
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15620
|
+
return { start, stop };
|
|
15621
|
+
}
|
|
15622
|
+
}
|
|
15623
|
+
});
|
|
15624
|
+
|
|
15625
|
+
// ../../packages/jobs/dist/index.js
|
|
15626
|
+
var require_dist2 = __commonJS({
|
|
15627
|
+
"../../packages/jobs/dist/index.js"(exports2) {
|
|
15628
|
+
"use strict";
|
|
15629
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15630
|
+
exports2.subscribe = exports2.JobsClient = void 0;
|
|
15631
|
+
var client_1 = require_client();
|
|
15632
|
+
Object.defineProperty(exports2, "JobsClient", { enumerable: true, get: function() {
|
|
15633
|
+
return client_1.JobsClient;
|
|
15634
|
+
} });
|
|
15635
|
+
var subscribe_1 = require_subscribe();
|
|
15636
|
+
Object.defineProperty(exports2, "subscribe", { enumerable: true, get: function() {
|
|
15637
|
+
return subscribe_1.subscribe;
|
|
15638
|
+
} });
|
|
15639
|
+
}
|
|
15640
|
+
});
|
|
15641
|
+
|
|
15642
|
+
// ../../packages/loom/dist/runtime/prompt-execution.js
|
|
15643
|
+
var require_prompt_execution = __commonJS({
|
|
15644
|
+
"../../packages/loom/dist/runtime/prompt-execution.js"(exports2) {
|
|
15645
|
+
"use strict";
|
|
15646
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15647
|
+
exports2.readPromptExecutionSpec = readPromptExecutionSpec;
|
|
15648
|
+
exports2.renderPromptExecution = renderPromptExecution;
|
|
15649
|
+
exports2.pickProviderHints = pickProviderHints;
|
|
15650
|
+
exports2.renderTemplate = renderTemplate;
|
|
15651
|
+
function readPromptExecutionSpec(inputs) {
|
|
15652
|
+
const specRow = inputs.find((i) => i.label === "spec");
|
|
15653
|
+
if (!specRow)
|
|
15654
|
+
throw new Error("prompt-execution: missing `spec` input row");
|
|
15655
|
+
const spec = specRow.payload.spec;
|
|
15656
|
+
if (!spec)
|
|
15657
|
+
throw new Error("prompt-execution: spec row payload missing `spec` field");
|
|
15658
|
+
if (spec.rendering !== "producer" && spec.rendering !== "subscriber") {
|
|
15659
|
+
throw new Error(`prompt-execution: invalid spec.rendering "${spec.rendering}"`);
|
|
15660
|
+
}
|
|
15661
|
+
if (typeof spec.outputLabel !== "string" || spec.outputLabel.length === 0) {
|
|
15662
|
+
throw new Error("prompt-execution: spec.outputLabel must be a non-empty string");
|
|
15663
|
+
}
|
|
15664
|
+
if (typeof spec.outputSchema !== "object" || spec.outputSchema === null) {
|
|
15665
|
+
throw new Error("prompt-execution: spec.outputSchema must be a JSON Schema object");
|
|
15666
|
+
}
|
|
15667
|
+
return spec;
|
|
15668
|
+
}
|
|
15669
|
+
function renderPromptExecution(inputs) {
|
|
15670
|
+
const spec = readPromptExecutionSpec(inputs);
|
|
15671
|
+
const artifacts = [];
|
|
15672
|
+
for (const i of inputs) {
|
|
15673
|
+
if (i.label === "artifacts") {
|
|
15674
|
+
const label = i.payload.label ?? "";
|
|
15675
|
+
artifacts.push({ label, payload: i.payload });
|
|
15964
15676
|
}
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15981
|
-
|
|
15982
|
-
|
|
15983
|
-
|
|
15677
|
+
}
|
|
15678
|
+
let prompt = "";
|
|
15679
|
+
if (spec.rendering === "producer") {
|
|
15680
|
+
const promptRow = inputs.find((i) => i.label === "prompt");
|
|
15681
|
+
if (!promptRow)
|
|
15682
|
+
throw new Error("prompt-execution: rendering='producer' but no `prompt` input row");
|
|
15683
|
+
const text = promptRow.payload.text;
|
|
15684
|
+
if (typeof text !== "string") {
|
|
15685
|
+
throw new Error("prompt-execution: prompt.payload.text must be a string");
|
|
15686
|
+
}
|
|
15687
|
+
prompt = text;
|
|
15688
|
+
} else {
|
|
15689
|
+
const templateRow = inputs.find((i) => i.label === "template");
|
|
15690
|
+
if (!templateRow)
|
|
15691
|
+
throw new Error("prompt-execution: rendering='subscriber' but no `template` input row");
|
|
15692
|
+
const text = templateRow.payload.text;
|
|
15693
|
+
if (typeof text !== "string") {
|
|
15694
|
+
throw new Error("prompt-execution: template.payload.text must be a string");
|
|
15695
|
+
}
|
|
15696
|
+
const varsRow = inputs.find((i) => i.label === "vars");
|
|
15697
|
+
const vars = varsRow?.payload ?? {};
|
|
15698
|
+
prompt = renderTemplate(text, vars);
|
|
15699
|
+
}
|
|
15700
|
+
return { spec, prompt, artifacts };
|
|
15701
|
+
}
|
|
15702
|
+
function pickProviderHints(spec, capabilityId) {
|
|
15703
|
+
if (!spec.providerHints)
|
|
15704
|
+
return {};
|
|
15705
|
+
const key = capabilityId.replace(/-([a-z])/g, (_m, c) => c.toUpperCase());
|
|
15706
|
+
const matched = spec.providerHints[key];
|
|
15707
|
+
return matched && typeof matched === "object" ? matched : {};
|
|
15708
|
+
}
|
|
15709
|
+
function renderTemplate(template, vars) {
|
|
15710
|
+
const eachRe = /\{\{#each\s+([a-zA-Z_$][\w$]*)\s*\}\}([\s\S]*?)\{\{\/each\}\}/g;
|
|
15711
|
+
let out = template.replace(eachRe, (_match, name, body) => {
|
|
15712
|
+
const list = vars[name];
|
|
15713
|
+
if (!Array.isArray(list))
|
|
15714
|
+
return "";
|
|
15715
|
+
return list.map((item) => body.replace(/\{\{\s*this\s*\}\}/g, String(item))).join("");
|
|
15716
|
+
});
|
|
15717
|
+
out = out.replace(/\{\{\s*([a-zA-Z_$][\w$]*)\s*\}\}/g, (_match, name) => {
|
|
15718
|
+
if (Object.prototype.hasOwnProperty.call(vars, name)) {
|
|
15719
|
+
const v = vars[name];
|
|
15720
|
+
return v === null || v === void 0 ? "" : String(v);
|
|
15721
|
+
}
|
|
15722
|
+
return "";
|
|
15723
|
+
});
|
|
15724
|
+
return out;
|
|
15725
|
+
}
|
|
15726
|
+
}
|
|
15727
|
+
});
|
|
15728
|
+
|
|
15729
|
+
// ../../packages/loom/dist/runtime/strategy.js
|
|
15730
|
+
var require_strategy = __commonJS({
|
|
15731
|
+
"../../packages/loom/dist/runtime/strategy.js"(exports2) {
|
|
15732
|
+
"use strict";
|
|
15733
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15734
|
+
exports2.PROMPT_EXECUTION_STRATEGY = exports2.SHUTTLE_STRATEGY_LABEL = void 0;
|
|
15735
|
+
exports2.shuttleStrategyInput = shuttleStrategyInput;
|
|
15736
|
+
exports2.readShuttleStrategy = readShuttleStrategy;
|
|
15737
|
+
exports2.SHUTTLE_STRATEGY_LABEL = "shuttle-strategy";
|
|
15738
|
+
exports2.PROMPT_EXECUTION_STRATEGY = "prompt-execution";
|
|
15739
|
+
function shuttleStrategyInput(strategy) {
|
|
15740
|
+
return { label: exports2.SHUTTLE_STRATEGY_LABEL, origin: "raw", payload: { strategy } };
|
|
15741
|
+
}
|
|
15742
|
+
function readShuttleStrategy(inputs) {
|
|
15743
|
+
const row = inputs.find((i) => i.label === exports2.SHUTTLE_STRATEGY_LABEL);
|
|
15744
|
+
if (!row)
|
|
15745
|
+
return null;
|
|
15746
|
+
const strategy = row.payload.strategy;
|
|
15747
|
+
return typeof strategy === "string" ? strategy : null;
|
|
15748
|
+
}
|
|
15749
|
+
}
|
|
15750
|
+
});
|
|
15751
|
+
|
|
15752
|
+
// ../../packages/loom/dist/runtime/validate.js
|
|
15753
|
+
var require_validate = __commonJS({
|
|
15754
|
+
"../../packages/loom/dist/runtime/validate.js"(exports2) {
|
|
15755
|
+
"use strict";
|
|
15756
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15757
|
+
exports2.validateAgainstSchema = validateAgainstSchema;
|
|
15758
|
+
function typeOf(value) {
|
|
15759
|
+
if (value === null)
|
|
15760
|
+
return "null";
|
|
15761
|
+
if (Array.isArray(value))
|
|
15762
|
+
return "array";
|
|
15763
|
+
const t = typeof value;
|
|
15764
|
+
if (t === "number")
|
|
15765
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
15766
|
+
if (t === "boolean")
|
|
15767
|
+
return "boolean";
|
|
15768
|
+
if (t === "string")
|
|
15769
|
+
return "string";
|
|
15770
|
+
return "object";
|
|
15771
|
+
}
|
|
15772
|
+
function matchesType(value, expected) {
|
|
15773
|
+
const actual = typeOf(value);
|
|
15774
|
+
if (expected === "number")
|
|
15775
|
+
return actual === "number" || actual === "integer";
|
|
15776
|
+
if (expected === "integer")
|
|
15777
|
+
return actual === "integer";
|
|
15778
|
+
return actual === expected;
|
|
15779
|
+
}
|
|
15780
|
+
function walk(value, schema, path, errors) {
|
|
15781
|
+
if (schema === true)
|
|
15782
|
+
return;
|
|
15783
|
+
if (schema === false) {
|
|
15784
|
+
errors.push(`${path || "value"} is not allowed`);
|
|
15785
|
+
return;
|
|
15786
|
+
}
|
|
15787
|
+
if (schema.const !== void 0 && JSON.stringify(value) !== JSON.stringify(schema.const)) {
|
|
15788
|
+
errors.push(`${path || "value"} must equal ${JSON.stringify(schema.const)}`);
|
|
15789
|
+
}
|
|
15790
|
+
if (Array.isArray(schema.enum) && !schema.enum.some((e) => JSON.stringify(e) === JSON.stringify(value))) {
|
|
15791
|
+
errors.push(`${path || "value"} must be one of ${JSON.stringify(schema.enum)}`);
|
|
15792
|
+
}
|
|
15793
|
+
const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
|
|
15794
|
+
if (types.length > 0 && !types.some((t) => matchesType(value, t))) {
|
|
15795
|
+
errors.push(`${path || "value"} expected type ${types.join("|")}, got ${typeOf(value)}`);
|
|
15796
|
+
return;
|
|
15797
|
+
}
|
|
15798
|
+
if (typeOf(value) === "object") {
|
|
15799
|
+
const obj = value;
|
|
15800
|
+
if (Array.isArray(schema.required)) {
|
|
15801
|
+
for (const key of schema.required) {
|
|
15802
|
+
if (!(key in obj))
|
|
15803
|
+
errors.push(`${path ? `${path}.` : ""}${key} is required`);
|
|
15984
15804
|
}
|
|
15985
|
-
} else {
|
|
15986
|
-
artifacts = dispatch.inputs.map((i) => ({
|
|
15987
|
-
label: i.label ?? "",
|
|
15988
|
-
payload: i.payload
|
|
15989
|
-
}));
|
|
15990
15805
|
}
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
estimate: costCapHint
|
|
15997
|
-
}, onObserverError);
|
|
15998
|
-
} catch (err) {
|
|
15999
|
-
const reason = err instanceof observers_1.SpendCapExceeded ? "refused_over_cap" : `preflight rejected: ${err instanceof Error ? err.message : String(err)}`;
|
|
16000
|
-
await closeAttendanceSafely(jobId, attendanceId, "failed", reason, startedAt);
|
|
16001
|
-
return;
|
|
15806
|
+
if (schema.properties) {
|
|
15807
|
+
for (const [key, sub] of Object.entries(schema.properties)) {
|
|
15808
|
+
if (key in obj)
|
|
15809
|
+
walk(obj[key], sub, `${path ? `${path}.` : ""}${key}`, errors);
|
|
15810
|
+
}
|
|
16002
15811
|
}
|
|
16003
|
-
|
|
16004
|
-
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
15812
|
+
}
|
|
15813
|
+
if (typeOf(value) === "array" && schema.items && !Array.isArray(schema.items)) {
|
|
15814
|
+
const itemSchema = schema.items;
|
|
15815
|
+
value.forEach((item, i) => walk(item, itemSchema, `${path}[${i}]`, errors));
|
|
15816
|
+
}
|
|
15817
|
+
}
|
|
15818
|
+
function validateAgainstSchema(value, schema) {
|
|
15819
|
+
const errors = [];
|
|
15820
|
+
walk(value ?? null, schema, "", errors);
|
|
15821
|
+
return { valid: errors.length === 0, errors };
|
|
15822
|
+
}
|
|
15823
|
+
}
|
|
15824
|
+
});
|
|
15825
|
+
|
|
15826
|
+
// ../../packages/loom/dist/runtime/index.js
|
|
15827
|
+
var require_runtime = __commonJS({
|
|
15828
|
+
"../../packages/loom/dist/runtime/index.js"(exports2) {
|
|
15829
|
+
"use strict";
|
|
15830
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15831
|
+
exports2.validateAgainstSchema = exports2.readShuttleStrategy = exports2.shuttleStrategyInput = exports2.PROMPT_EXECUTION_STRATEGY = exports2.SHUTTLE_STRATEGY_LABEL = exports2.pickProviderHints = exports2.renderTemplate = exports2.renderPromptExecution = exports2.readPromptExecutionSpec = void 0;
|
|
15832
|
+
var prompt_execution_1 = require_prompt_execution();
|
|
15833
|
+
Object.defineProperty(exports2, "readPromptExecutionSpec", { enumerable: true, get: function() {
|
|
15834
|
+
return prompt_execution_1.readPromptExecutionSpec;
|
|
15835
|
+
} });
|
|
15836
|
+
Object.defineProperty(exports2, "renderPromptExecution", { enumerable: true, get: function() {
|
|
15837
|
+
return prompt_execution_1.renderPromptExecution;
|
|
15838
|
+
} });
|
|
15839
|
+
Object.defineProperty(exports2, "renderTemplate", { enumerable: true, get: function() {
|
|
15840
|
+
return prompt_execution_1.renderTemplate;
|
|
15841
|
+
} });
|
|
15842
|
+
Object.defineProperty(exports2, "pickProviderHints", { enumerable: true, get: function() {
|
|
15843
|
+
return prompt_execution_1.pickProviderHints;
|
|
15844
|
+
} });
|
|
15845
|
+
var strategy_1 = require_strategy();
|
|
15846
|
+
Object.defineProperty(exports2, "SHUTTLE_STRATEGY_LABEL", { enumerable: true, get: function() {
|
|
15847
|
+
return strategy_1.SHUTTLE_STRATEGY_LABEL;
|
|
15848
|
+
} });
|
|
15849
|
+
Object.defineProperty(exports2, "PROMPT_EXECUTION_STRATEGY", { enumerable: true, get: function() {
|
|
15850
|
+
return strategy_1.PROMPT_EXECUTION_STRATEGY;
|
|
15851
|
+
} });
|
|
15852
|
+
Object.defineProperty(exports2, "shuttleStrategyInput", { enumerable: true, get: function() {
|
|
15853
|
+
return strategy_1.shuttleStrategyInput;
|
|
15854
|
+
} });
|
|
15855
|
+
Object.defineProperty(exports2, "readShuttleStrategy", { enumerable: true, get: function() {
|
|
15856
|
+
return strategy_1.readShuttleStrategy;
|
|
15857
|
+
} });
|
|
15858
|
+
var validate_1 = require_validate();
|
|
15859
|
+
Object.defineProperty(exports2, "validateAgainstSchema", { enumerable: true, get: function() {
|
|
15860
|
+
return validate_1.validateAgainstSchema;
|
|
15861
|
+
} });
|
|
15862
|
+
}
|
|
15863
|
+
});
|
|
15864
|
+
|
|
15865
|
+
// ../../packages/loom/dist/authoring/prompt-execution.js
|
|
15866
|
+
var require_prompt_execution2 = __commonJS({
|
|
15867
|
+
"../../packages/loom/dist/authoring/prompt-execution.js"(exports2) {
|
|
15868
|
+
"use strict";
|
|
15869
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15870
|
+
exports2.buildPromptExecutionInputs = buildPromptExecutionInputs;
|
|
15871
|
+
var strategy_1 = require_strategy();
|
|
15872
|
+
function buildPromptExecutionInputs(options) {
|
|
15873
|
+
const spec = {
|
|
15874
|
+
rendering: options.rendering,
|
|
15875
|
+
outputLabel: options.output.label,
|
|
15876
|
+
outputSchema: options.output.schema
|
|
15877
|
+
};
|
|
15878
|
+
if (options.providerHints)
|
|
15879
|
+
spec.providerHints = options.providerHints;
|
|
15880
|
+
if (options.costCapHint)
|
|
15881
|
+
spec.costCapHint = options.costCapHint;
|
|
15882
|
+
if (options.rendering === "producer" && !options.prompt) {
|
|
15883
|
+
throw new Error("rendering='producer' requires `prompt`");
|
|
15884
|
+
}
|
|
15885
|
+
if (options.rendering === "subscriber" && !options.template) {
|
|
15886
|
+
throw new Error("rendering='subscriber' requires `template`");
|
|
15887
|
+
}
|
|
15888
|
+
const inputs = [
|
|
15889
|
+
(0, strategy_1.shuttleStrategyInput)(strategy_1.PROMPT_EXECUTION_STRATEGY),
|
|
15890
|
+
{ label: "spec", origin: "raw", payload: { spec } }
|
|
15891
|
+
];
|
|
15892
|
+
if (options.rendering === "producer") {
|
|
15893
|
+
inputs.push({ label: "prompt", origin: "raw", payload: { text: options.prompt } });
|
|
15894
|
+
} else {
|
|
15895
|
+
inputs.push({ label: "template", origin: "raw", payload: { text: options.template } });
|
|
15896
|
+
if (options.vars) {
|
|
15897
|
+
inputs.push({ label: "vars", origin: "raw", payload: options.vars });
|
|
15898
|
+
}
|
|
15899
|
+
}
|
|
15900
|
+
if (options.artifacts) {
|
|
15901
|
+
for (const artifact of options.artifacts) {
|
|
15902
|
+
inputs.push({
|
|
15903
|
+
label: "artifacts",
|
|
15904
|
+
origin: artifact.origin,
|
|
15905
|
+
payload: { label: artifact.label, ...artifact.payload }
|
|
15906
|
+
});
|
|
15907
|
+
}
|
|
15908
|
+
}
|
|
15909
|
+
return inputs;
|
|
15910
|
+
}
|
|
15911
|
+
}
|
|
15912
|
+
});
|
|
15913
|
+
|
|
15914
|
+
// ../../packages/loom/dist/builder/define-workflow.js
|
|
15915
|
+
var require_define_workflow = __commonJS({
|
|
15916
|
+
"../../packages/loom/dist/builder/define-workflow.js"(exports2) {
|
|
15917
|
+
"use strict";
|
|
15918
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
15919
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
15920
|
+
};
|
|
15921
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15922
|
+
exports2.defineWorkflow = defineWorkflow;
|
|
15923
|
+
var node_path_1 = __importDefault(require("node:path"));
|
|
15924
|
+
var node_url_1 = __importDefault(require("node:url"));
|
|
15925
|
+
function defineWorkflow(opts) {
|
|
15926
|
+
const sourcePath = opts.__dirname ?? captureCallerPath();
|
|
15927
|
+
const def = {
|
|
15928
|
+
name: opts.name,
|
|
15929
|
+
owner: opts.owner,
|
|
15930
|
+
nodes: opts.nodes,
|
|
15931
|
+
__sourcePath: sourcePath
|
|
15932
|
+
};
|
|
15933
|
+
if (opts.description !== void 0)
|
|
15934
|
+
def.description = opts.description;
|
|
15935
|
+
if (opts.retain !== void 0)
|
|
15936
|
+
def.retain = opts.retain;
|
|
15937
|
+
if (opts.transitions !== void 0)
|
|
15938
|
+
def.transitions = opts.transitions;
|
|
15939
|
+
return def;
|
|
15940
|
+
}
|
|
15941
|
+
function captureCallerPath() {
|
|
15942
|
+
const err = new Error();
|
|
15943
|
+
const stack = err.stack ?? "";
|
|
15944
|
+
const lines = stack.split("\n");
|
|
15945
|
+
const selfMarkers = ["/packages/loom/src/", "/packages/loom/dist/"];
|
|
15946
|
+
for (const line of lines) {
|
|
15947
|
+
const match = /\s+at\s+(?:.*?\s+)?\(?(.*?):\d+:\d+\)?$/.exec(line);
|
|
15948
|
+
if (!match)
|
|
15949
|
+
continue;
|
|
15950
|
+
let filePath = match[1];
|
|
15951
|
+
if (!filePath)
|
|
15952
|
+
continue;
|
|
15953
|
+
if (filePath.startsWith("file://")) {
|
|
15954
|
+
filePath = node_url_1.default.fileURLToPath(filePath);
|
|
15955
|
+
}
|
|
15956
|
+
if (!node_path_1.default.isAbsolute(filePath))
|
|
15957
|
+
continue;
|
|
15958
|
+
if (selfMarkers.some((m) => filePath.includes(m)))
|
|
15959
|
+
continue;
|
|
15960
|
+
if (filePath.endsWith("define-workflow.ts") || filePath.endsWith("define-workflow.js"))
|
|
15961
|
+
continue;
|
|
15962
|
+
return node_path_1.default.dirname(filePath);
|
|
15963
|
+
}
|
|
15964
|
+
return process.cwd();
|
|
15965
|
+
}
|
|
15966
|
+
}
|
|
15967
|
+
});
|
|
15968
|
+
|
|
15969
|
+
// ../../packages/loom/dist/builder/nodes.js
|
|
15970
|
+
var require_nodes = __commonJS({
|
|
15971
|
+
"../../packages/loom/dist/builder/nodes.js"(exports2) {
|
|
15972
|
+
"use strict";
|
|
15973
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15974
|
+
exports2.promptNode = promptNode;
|
|
15975
|
+
exports2.httpNode = httpNode;
|
|
15976
|
+
exports2.jobsCreateNode = jobsCreateNode;
|
|
15977
|
+
function promptNode(name, options) {
|
|
15978
|
+
return { name, entryBehavior: "loom.prompt", promptOptions: options };
|
|
15979
|
+
}
|
|
15980
|
+
function httpNode(name, options) {
|
|
15981
|
+
return { name, entryBehavior: "http.request", httpOptions: options };
|
|
15982
|
+
}
|
|
15983
|
+
function jobsCreateNode(name, options) {
|
|
15984
|
+
return { name, entryBehavior: "jobs.create", jobsCreateOptions: options };
|
|
15985
|
+
}
|
|
15986
|
+
}
|
|
15987
|
+
});
|
|
15988
|
+
|
|
15989
|
+
// ../../packages/loom/dist/builder/resolvers.js
|
|
15990
|
+
var require_resolvers = __commonJS({
|
|
15991
|
+
"../../packages/loom/dist/builder/resolvers.js"(exports2) {
|
|
15992
|
+
"use strict";
|
|
15993
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15994
|
+
exports2.principalJobPool = void 0;
|
|
15995
|
+
exports2.literalJobPool = literalJobPool;
|
|
15996
|
+
exports2.describeJobPoolRef = describeJobPoolRef;
|
|
15997
|
+
var RESOLVER_DESCRIPTORS = /* @__PURE__ */ new WeakMap();
|
|
15998
|
+
exports2.principalJobPool = makeNamedResolver("principal.job_pool_id");
|
|
15999
|
+
function literalJobPool(idOrName) {
|
|
16000
|
+
const fn = ((_ctx) => idOrName);
|
|
16001
|
+
const looksUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(idOrName);
|
|
16002
|
+
const value = looksUuid ? { id: idOrName } : { name: idOrName };
|
|
16003
|
+
RESOLVER_DESCRIPTORS.set(fn, { kind: "literal", value });
|
|
16004
|
+
return fn;
|
|
16005
|
+
}
|
|
16006
|
+
function makeNamedResolver(resolverId) {
|
|
16007
|
+
const fn = ((ctx) => {
|
|
16008
|
+
if (!ctx.principal.jobPoolId) {
|
|
16009
|
+
throw new Error(`resolver '${resolverId}' requires ctx.principal.jobPoolId; consuming service must populate it before startSession`);
|
|
16010
|
+
}
|
|
16011
|
+
return ctx.principal.jobPoolId;
|
|
16012
|
+
});
|
|
16013
|
+
RESOLVER_DESCRIPTORS.set(fn, { kind: "resolver", resolverId });
|
|
16014
|
+
return fn;
|
|
16015
|
+
}
|
|
16016
|
+
function describeJobPoolRef(ref) {
|
|
16017
|
+
if (typeof ref === "function") {
|
|
16018
|
+
return RESOLVER_DESCRIPTORS.get(ref);
|
|
16019
|
+
}
|
|
16020
|
+
if (typeof ref === "object" && ref !== null) {
|
|
16021
|
+
if ("id" in ref && typeof ref.id === "string") {
|
|
16022
|
+
return { kind: "literal", value: { id: ref.id } };
|
|
16023
|
+
}
|
|
16024
|
+
if ("name" in ref && typeof ref.name === "string") {
|
|
16025
|
+
return { kind: "literal", value: { name: ref.name } };
|
|
16026
|
+
}
|
|
16027
|
+
}
|
|
16028
|
+
return void 0;
|
|
16029
|
+
}
|
|
16030
|
+
}
|
|
16031
|
+
});
|
|
16032
|
+
|
|
16033
|
+
// ../../packages/loom/dist/builder/transitions.js
|
|
16034
|
+
var require_transitions = __commonJS({
|
|
16035
|
+
"../../packages/loom/dist/builder/transitions.js"(exports2) {
|
|
16036
|
+
"use strict";
|
|
16037
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16038
|
+
exports2.synthesiseLinearChain = synthesiseLinearChain;
|
|
16039
|
+
function synthesiseLinearChain(nodes) {
|
|
16040
|
+
const edges = [];
|
|
16041
|
+
for (let i = 0; i < nodes.length - 1; i++) {
|
|
16042
|
+
edges.push({ from: nodes[i].name, to: nodes[i + 1].name });
|
|
16043
|
+
}
|
|
16044
|
+
return edges;
|
|
16045
|
+
}
|
|
16046
|
+
}
|
|
16047
|
+
});
|
|
16048
|
+
|
|
16049
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/Options.js
|
|
16050
|
+
var require_Options = __commonJS({
|
|
16051
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/Options.js"(exports2) {
|
|
16052
|
+
"use strict";
|
|
16053
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16054
|
+
exports2.getDefaultOptions = exports2.defaultOptions = exports2.jsonDescription = exports2.ignoreOverride = void 0;
|
|
16055
|
+
exports2.ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
16056
|
+
var jsonDescription = (jsonSchema, def) => {
|
|
16057
|
+
if (def.description) {
|
|
16058
|
+
try {
|
|
16059
|
+
return {
|
|
16060
|
+
...jsonSchema,
|
|
16061
|
+
...JSON.parse(def.description)
|
|
16062
|
+
};
|
|
16063
|
+
} catch {
|
|
16064
|
+
}
|
|
16065
|
+
}
|
|
16066
|
+
return jsonSchema;
|
|
16067
|
+
};
|
|
16068
|
+
exports2.jsonDescription = jsonDescription;
|
|
16069
|
+
exports2.defaultOptions = {
|
|
16070
|
+
name: void 0,
|
|
16071
|
+
$refStrategy: "root",
|
|
16072
|
+
basePath: ["#"],
|
|
16073
|
+
effectStrategy: "input",
|
|
16074
|
+
pipeStrategy: "all",
|
|
16075
|
+
dateStrategy: "format:date-time",
|
|
16076
|
+
mapStrategy: "entries",
|
|
16077
|
+
removeAdditionalStrategy: "passthrough",
|
|
16078
|
+
allowedAdditionalProperties: true,
|
|
16079
|
+
rejectedAdditionalProperties: false,
|
|
16080
|
+
definitionPath: "definitions",
|
|
16081
|
+
target: "jsonSchema7",
|
|
16082
|
+
strictUnions: false,
|
|
16083
|
+
definitions: {},
|
|
16084
|
+
errorMessages: false,
|
|
16085
|
+
markdownDescription: false,
|
|
16086
|
+
patternStrategy: "escape",
|
|
16087
|
+
applyRegexFlags: false,
|
|
16088
|
+
emailStrategy: "format:email",
|
|
16089
|
+
base64Strategy: "contentEncoding:base64",
|
|
16090
|
+
nameStrategy: "ref",
|
|
16091
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
16092
|
+
};
|
|
16093
|
+
var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
16094
|
+
...exports2.defaultOptions,
|
|
16095
|
+
name: options
|
|
16096
|
+
} : {
|
|
16097
|
+
...exports2.defaultOptions,
|
|
16098
|
+
...options
|
|
16099
|
+
};
|
|
16100
|
+
exports2.getDefaultOptions = getDefaultOptions;
|
|
16101
|
+
}
|
|
16102
|
+
});
|
|
16103
|
+
|
|
16104
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/Refs.js
|
|
16105
|
+
var require_Refs = __commonJS({
|
|
16106
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/Refs.js"(exports2) {
|
|
16107
|
+
"use strict";
|
|
16108
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16109
|
+
exports2.getRefs = void 0;
|
|
16110
|
+
var Options_js_1 = require_Options();
|
|
16111
|
+
var getRefs = (options) => {
|
|
16112
|
+
const _options = (0, Options_js_1.getDefaultOptions)(options);
|
|
16113
|
+
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
16114
|
+
return {
|
|
16115
|
+
..._options,
|
|
16116
|
+
flags: { hasReferencedOpenAiAnyType: false },
|
|
16117
|
+
currentPath,
|
|
16118
|
+
propertyPath: void 0,
|
|
16119
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
16120
|
+
def._def,
|
|
16121
|
+
{
|
|
16122
|
+
def: def._def,
|
|
16123
|
+
path: [..._options.basePath, _options.definitionPath, name],
|
|
16124
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
16125
|
+
jsonSchema: void 0
|
|
16126
|
+
}
|
|
16127
|
+
]))
|
|
16128
|
+
};
|
|
16129
|
+
};
|
|
16130
|
+
exports2.getRefs = getRefs;
|
|
16131
|
+
}
|
|
16132
|
+
});
|
|
16133
|
+
|
|
16134
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/errorMessages.js
|
|
16135
|
+
var require_errorMessages = __commonJS({
|
|
16136
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/errorMessages.js"(exports2) {
|
|
16137
|
+
"use strict";
|
|
16138
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16139
|
+
exports2.setResponseValueAndErrors = exports2.addErrorMessage = void 0;
|
|
16140
|
+
function addErrorMessage(res, key, errorMessage, refs) {
|
|
16141
|
+
if (!refs?.errorMessages)
|
|
16142
|
+
return;
|
|
16143
|
+
if (errorMessage) {
|
|
16144
|
+
res.errorMessage = {
|
|
16145
|
+
...res.errorMessage,
|
|
16146
|
+
[key]: errorMessage
|
|
16147
|
+
};
|
|
16148
|
+
}
|
|
16149
|
+
}
|
|
16150
|
+
exports2.addErrorMessage = addErrorMessage;
|
|
16151
|
+
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
16152
|
+
res[key] = value;
|
|
16153
|
+
addErrorMessage(res, key, errorMessage, refs);
|
|
16154
|
+
}
|
|
16155
|
+
exports2.setResponseValueAndErrors = setResponseValueAndErrors;
|
|
16156
|
+
}
|
|
16157
|
+
});
|
|
16158
|
+
|
|
16159
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/getRelativePath.js
|
|
16160
|
+
var require_getRelativePath = __commonJS({
|
|
16161
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/getRelativePath.js"(exports2) {
|
|
16162
|
+
"use strict";
|
|
16163
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16164
|
+
exports2.getRelativePath = void 0;
|
|
16165
|
+
var getRelativePath = (pathA, pathB) => {
|
|
16166
|
+
let i = 0;
|
|
16167
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
16168
|
+
if (pathA[i] !== pathB[i])
|
|
16169
|
+
break;
|
|
16170
|
+
}
|
|
16171
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
16172
|
+
};
|
|
16173
|
+
exports2.getRelativePath = getRelativePath;
|
|
16174
|
+
}
|
|
16175
|
+
});
|
|
16176
|
+
|
|
16177
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/index.cjs
|
|
16178
|
+
var require_v3 = __commonJS({
|
|
16179
|
+
"../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/index.cjs"(exports2) {
|
|
16180
|
+
"use strict";
|
|
16181
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
16182
|
+
if (k2 === void 0) k2 = k;
|
|
16183
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16184
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16185
|
+
desc = { enumerable: true, get: function() {
|
|
16186
|
+
return m[k];
|
|
16187
|
+
} };
|
|
16188
|
+
}
|
|
16189
|
+
Object.defineProperty(o, k2, desc);
|
|
16190
|
+
}) : (function(o, m, k, k2) {
|
|
16191
|
+
if (k2 === void 0) k2 = k;
|
|
16192
|
+
o[k2] = m[k];
|
|
16193
|
+
}));
|
|
16194
|
+
var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
16195
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16196
|
+
}) : function(o, v) {
|
|
16197
|
+
o["default"] = v;
|
|
16198
|
+
});
|
|
16199
|
+
var __importStar = exports2 && exports2.__importStar || function(mod) {
|
|
16200
|
+
if (mod && mod.__esModule) return mod;
|
|
16201
|
+
var result = {};
|
|
16202
|
+
if (mod != null) {
|
|
16203
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
16204
|
+
}
|
|
16205
|
+
__setModuleDefault(result, mod);
|
|
16206
|
+
return result;
|
|
16207
|
+
};
|
|
16208
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
16209
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
16210
|
+
};
|
|
16211
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16212
|
+
exports2.z = void 0;
|
|
16213
|
+
var z = __importStar(require_external());
|
|
16214
|
+
exports2.z = z;
|
|
16215
|
+
__exportStar(require_external(), exports2);
|
|
16216
|
+
exports2.default = z;
|
|
16217
|
+
}
|
|
16218
|
+
});
|
|
16219
|
+
|
|
16220
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/any.js
|
|
16221
|
+
var require_any = __commonJS({
|
|
16222
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/any.js"(exports2) {
|
|
16223
|
+
"use strict";
|
|
16224
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16225
|
+
exports2.parseAnyDef = void 0;
|
|
16226
|
+
var getRelativePath_js_1 = require_getRelativePath();
|
|
16227
|
+
function parseAnyDef(refs) {
|
|
16228
|
+
if (refs.target !== "openAi") {
|
|
16229
|
+
return {};
|
|
16230
|
+
}
|
|
16231
|
+
const anyDefinitionPath = [
|
|
16232
|
+
...refs.basePath,
|
|
16233
|
+
refs.definitionPath,
|
|
16234
|
+
refs.openAiAnyTypeName
|
|
16235
|
+
];
|
|
16236
|
+
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
16237
|
+
return {
|
|
16238
|
+
$ref: refs.$refStrategy === "relative" ? (0, getRelativePath_js_1.getRelativePath)(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
16239
|
+
};
|
|
16240
|
+
}
|
|
16241
|
+
exports2.parseAnyDef = parseAnyDef;
|
|
16242
|
+
}
|
|
16243
|
+
});
|
|
16244
|
+
|
|
16245
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/array.js
|
|
16246
|
+
var require_array = __commonJS({
|
|
16247
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/array.js"(exports2) {
|
|
16248
|
+
"use strict";
|
|
16249
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16250
|
+
exports2.parseArrayDef = void 0;
|
|
16251
|
+
var v3_1 = require_v3();
|
|
16252
|
+
var errorMessages_js_1 = require_errorMessages();
|
|
16253
|
+
var parseDef_js_1 = require_parseDef();
|
|
16254
|
+
function parseArrayDef(def, refs) {
|
|
16255
|
+
const res = {
|
|
16256
|
+
type: "array"
|
|
16257
|
+
};
|
|
16258
|
+
if (def.type?._def && def.type?._def?.typeName !== v3_1.ZodFirstPartyTypeKind.ZodAny) {
|
|
16259
|
+
res.items = (0, parseDef_js_1.parseDef)(def.type._def, {
|
|
16260
|
+
...refs,
|
|
16261
|
+
currentPath: [...refs.currentPath, "items"]
|
|
16262
|
+
});
|
|
16263
|
+
}
|
|
16264
|
+
if (def.minLength) {
|
|
16265
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
16266
|
+
}
|
|
16267
|
+
if (def.maxLength) {
|
|
16268
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
16269
|
+
}
|
|
16270
|
+
if (def.exactLength) {
|
|
16271
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
16272
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
16273
|
+
}
|
|
16274
|
+
return res;
|
|
16275
|
+
}
|
|
16276
|
+
exports2.parseArrayDef = parseArrayDef;
|
|
16277
|
+
}
|
|
16278
|
+
});
|
|
16279
|
+
|
|
16280
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/bigint.js
|
|
16281
|
+
var require_bigint = __commonJS({
|
|
16282
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/bigint.js"(exports2) {
|
|
16283
|
+
"use strict";
|
|
16284
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16285
|
+
exports2.parseBigintDef = void 0;
|
|
16286
|
+
var errorMessages_js_1 = require_errorMessages();
|
|
16287
|
+
function parseBigintDef(def, refs) {
|
|
16288
|
+
const res = {
|
|
16289
|
+
type: "integer",
|
|
16290
|
+
format: "int64"
|
|
16291
|
+
};
|
|
16292
|
+
if (!def.checks)
|
|
16293
|
+
return res;
|
|
16294
|
+
for (const check of def.checks) {
|
|
16295
|
+
switch (check.kind) {
|
|
16296
|
+
case "min":
|
|
16297
|
+
if (refs.target === "jsonSchema7") {
|
|
16298
|
+
if (check.inclusive) {
|
|
16299
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs);
|
|
16300
|
+
} else {
|
|
16301
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
16302
|
+
}
|
|
16303
|
+
} else {
|
|
16304
|
+
if (!check.inclusive) {
|
|
16305
|
+
res.exclusiveMinimum = true;
|
|
16306
|
+
}
|
|
16307
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs);
|
|
16308
|
+
}
|
|
16309
|
+
break;
|
|
16310
|
+
case "max":
|
|
16311
|
+
if (refs.target === "jsonSchema7") {
|
|
16312
|
+
if (check.inclusive) {
|
|
16313
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs);
|
|
16314
|
+
} else {
|
|
16315
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
16316
|
+
}
|
|
16317
|
+
} else {
|
|
16318
|
+
if (!check.inclusive) {
|
|
16319
|
+
res.exclusiveMaximum = true;
|
|
16320
|
+
}
|
|
16321
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs);
|
|
16322
|
+
}
|
|
16323
|
+
break;
|
|
16324
|
+
case "multipleOf":
|
|
16325
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "multipleOf", check.value, check.message, refs);
|
|
16326
|
+
break;
|
|
16327
|
+
}
|
|
16328
|
+
}
|
|
16329
|
+
return res;
|
|
16330
|
+
}
|
|
16331
|
+
exports2.parseBigintDef = parseBigintDef;
|
|
16332
|
+
}
|
|
16333
|
+
});
|
|
16334
|
+
|
|
16335
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/boolean.js
|
|
16336
|
+
var require_boolean = __commonJS({
|
|
16337
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/boolean.js"(exports2) {
|
|
16338
|
+
"use strict";
|
|
16339
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16340
|
+
exports2.parseBooleanDef = void 0;
|
|
16341
|
+
function parseBooleanDef() {
|
|
16342
|
+
return {
|
|
16343
|
+
type: "boolean"
|
|
16344
|
+
};
|
|
16345
|
+
}
|
|
16346
|
+
exports2.parseBooleanDef = parseBooleanDef;
|
|
16347
|
+
}
|
|
16348
|
+
});
|
|
16349
|
+
|
|
16350
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/branded.js
|
|
16351
|
+
var require_branded = __commonJS({
|
|
16352
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/branded.js"(exports2) {
|
|
16353
|
+
"use strict";
|
|
16354
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16355
|
+
exports2.parseBrandedDef = void 0;
|
|
16356
|
+
var parseDef_js_1 = require_parseDef();
|
|
16357
|
+
function parseBrandedDef(_def, refs) {
|
|
16358
|
+
return (0, parseDef_js_1.parseDef)(_def.type._def, refs);
|
|
16359
|
+
}
|
|
16360
|
+
exports2.parseBrandedDef = parseBrandedDef;
|
|
16361
|
+
}
|
|
16362
|
+
});
|
|
16363
|
+
|
|
16364
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/catch.js
|
|
16365
|
+
var require_catch = __commonJS({
|
|
16366
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/catch.js"(exports2) {
|
|
16367
|
+
"use strict";
|
|
16368
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16369
|
+
exports2.parseCatchDef = void 0;
|
|
16370
|
+
var parseDef_js_1 = require_parseDef();
|
|
16371
|
+
var parseCatchDef = (def, refs) => {
|
|
16372
|
+
return (0, parseDef_js_1.parseDef)(def.innerType._def, refs);
|
|
16373
|
+
};
|
|
16374
|
+
exports2.parseCatchDef = parseCatchDef;
|
|
16375
|
+
}
|
|
16376
|
+
});
|
|
16377
|
+
|
|
16378
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/date.js
|
|
16379
|
+
var require_date = __commonJS({
|
|
16380
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/date.js"(exports2) {
|
|
16381
|
+
"use strict";
|
|
16382
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16383
|
+
exports2.parseDateDef = void 0;
|
|
16384
|
+
var errorMessages_js_1 = require_errorMessages();
|
|
16385
|
+
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
16386
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
16387
|
+
if (Array.isArray(strategy)) {
|
|
16388
|
+
return {
|
|
16389
|
+
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
16390
|
+
};
|
|
16391
|
+
}
|
|
16392
|
+
switch (strategy) {
|
|
16393
|
+
case "string":
|
|
16394
|
+
case "format:date-time":
|
|
16395
|
+
return {
|
|
16396
|
+
type: "string",
|
|
16397
|
+
format: "date-time"
|
|
16398
|
+
};
|
|
16399
|
+
case "format:date":
|
|
16400
|
+
return {
|
|
16401
|
+
type: "string",
|
|
16402
|
+
format: "date"
|
|
16403
|
+
};
|
|
16404
|
+
case "integer":
|
|
16405
|
+
return integerDateParser(def, refs);
|
|
16406
|
+
}
|
|
16407
|
+
}
|
|
16408
|
+
exports2.parseDateDef = parseDateDef;
|
|
16409
|
+
var integerDateParser = (def, refs) => {
|
|
16410
|
+
const res = {
|
|
16411
|
+
type: "integer",
|
|
16412
|
+
format: "unix-time"
|
|
16413
|
+
};
|
|
16414
|
+
if (refs.target === "openApi3") {
|
|
16415
|
+
return res;
|
|
16416
|
+
}
|
|
16417
|
+
for (const check of def.checks) {
|
|
16418
|
+
switch (check.kind) {
|
|
16419
|
+
case "min":
|
|
16420
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(
|
|
16421
|
+
res,
|
|
16422
|
+
"minimum",
|
|
16423
|
+
check.value,
|
|
16424
|
+
// This is in milliseconds
|
|
16425
|
+
check.message,
|
|
16426
|
+
refs
|
|
16427
|
+
);
|
|
16428
|
+
break;
|
|
16429
|
+
case "max":
|
|
16430
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(
|
|
16431
|
+
res,
|
|
16432
|
+
"maximum",
|
|
16433
|
+
check.value,
|
|
16434
|
+
// This is in milliseconds
|
|
16435
|
+
check.message,
|
|
16436
|
+
refs
|
|
16437
|
+
);
|
|
16438
|
+
break;
|
|
16439
|
+
}
|
|
16440
|
+
}
|
|
16441
|
+
return res;
|
|
16442
|
+
};
|
|
16443
|
+
}
|
|
16444
|
+
});
|
|
16445
|
+
|
|
16446
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/default.js
|
|
16447
|
+
var require_default = __commonJS({
|
|
16448
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/default.js"(exports2) {
|
|
16449
|
+
"use strict";
|
|
16450
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16451
|
+
exports2.parseDefaultDef = void 0;
|
|
16452
|
+
var parseDef_js_1 = require_parseDef();
|
|
16453
|
+
function parseDefaultDef(_def, refs) {
|
|
16454
|
+
return {
|
|
16455
|
+
...(0, parseDef_js_1.parseDef)(_def.innerType._def, refs),
|
|
16456
|
+
default: _def.defaultValue()
|
|
16457
|
+
};
|
|
16458
|
+
}
|
|
16459
|
+
exports2.parseDefaultDef = parseDefaultDef;
|
|
16460
|
+
}
|
|
16461
|
+
});
|
|
16462
|
+
|
|
16463
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/effects.js
|
|
16464
|
+
var require_effects = __commonJS({
|
|
16465
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/effects.js"(exports2) {
|
|
16466
|
+
"use strict";
|
|
16467
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16468
|
+
exports2.parseEffectsDef = void 0;
|
|
16469
|
+
var parseDef_js_1 = require_parseDef();
|
|
16470
|
+
var any_js_1 = require_any();
|
|
16471
|
+
function parseEffectsDef(_def, refs) {
|
|
16472
|
+
return refs.effectStrategy === "input" ? (0, parseDef_js_1.parseDef)(_def.schema._def, refs) : (0, any_js_1.parseAnyDef)(refs);
|
|
16473
|
+
}
|
|
16474
|
+
exports2.parseEffectsDef = parseEffectsDef;
|
|
16475
|
+
}
|
|
16476
|
+
});
|
|
16477
|
+
|
|
16478
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/enum.js
|
|
16479
|
+
var require_enum = __commonJS({
|
|
16480
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/enum.js"(exports2) {
|
|
16481
|
+
"use strict";
|
|
16482
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16483
|
+
exports2.parseEnumDef = void 0;
|
|
16484
|
+
function parseEnumDef(def) {
|
|
16485
|
+
return {
|
|
16486
|
+
type: "string",
|
|
16487
|
+
enum: Array.from(def.values)
|
|
16488
|
+
};
|
|
16489
|
+
}
|
|
16490
|
+
exports2.parseEnumDef = parseEnumDef;
|
|
16491
|
+
}
|
|
16492
|
+
});
|
|
16493
|
+
|
|
16494
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/intersection.js
|
|
16495
|
+
var require_intersection = __commonJS({
|
|
16496
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/intersection.js"(exports2) {
|
|
16497
|
+
"use strict";
|
|
16498
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16499
|
+
exports2.parseIntersectionDef = void 0;
|
|
16500
|
+
var parseDef_js_1 = require_parseDef();
|
|
16501
|
+
var isJsonSchema7AllOfType = (type) => {
|
|
16502
|
+
if ("type" in type && type.type === "string")
|
|
16503
|
+
return false;
|
|
16504
|
+
return "allOf" in type;
|
|
16505
|
+
};
|
|
16506
|
+
function parseIntersectionDef(def, refs) {
|
|
16507
|
+
const allOf = [
|
|
16508
|
+
(0, parseDef_js_1.parseDef)(def.left._def, {
|
|
16509
|
+
...refs,
|
|
16510
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
16511
|
+
}),
|
|
16512
|
+
(0, parseDef_js_1.parseDef)(def.right._def, {
|
|
16513
|
+
...refs,
|
|
16514
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
16515
|
+
})
|
|
16516
|
+
].filter((x) => !!x);
|
|
16517
|
+
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
|
|
16518
|
+
const mergedAllOf = [];
|
|
16519
|
+
allOf.forEach((schema) => {
|
|
16520
|
+
if (isJsonSchema7AllOfType(schema)) {
|
|
16521
|
+
mergedAllOf.push(...schema.allOf);
|
|
16522
|
+
if (schema.unevaluatedProperties === void 0) {
|
|
16523
|
+
unevaluatedProperties = void 0;
|
|
16524
|
+
}
|
|
16525
|
+
} else {
|
|
16526
|
+
let nestedSchema = schema;
|
|
16527
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
16528
|
+
const { additionalProperties, ...rest } = schema;
|
|
16529
|
+
nestedSchema = rest;
|
|
16530
|
+
} else {
|
|
16531
|
+
unevaluatedProperties = void 0;
|
|
16532
|
+
}
|
|
16533
|
+
mergedAllOf.push(nestedSchema);
|
|
16534
|
+
}
|
|
16535
|
+
});
|
|
16536
|
+
return mergedAllOf.length ? {
|
|
16537
|
+
allOf: mergedAllOf,
|
|
16538
|
+
...unevaluatedProperties
|
|
16539
|
+
} : void 0;
|
|
16540
|
+
}
|
|
16541
|
+
exports2.parseIntersectionDef = parseIntersectionDef;
|
|
16542
|
+
}
|
|
16543
|
+
});
|
|
16544
|
+
|
|
16545
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/literal.js
|
|
16546
|
+
var require_literal = __commonJS({
|
|
16547
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/literal.js"(exports2) {
|
|
16548
|
+
"use strict";
|
|
16549
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16550
|
+
exports2.parseLiteralDef = void 0;
|
|
16551
|
+
function parseLiteralDef(def, refs) {
|
|
16552
|
+
const parsedType = typeof def.value;
|
|
16553
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
16554
|
+
return {
|
|
16555
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
16556
|
+
};
|
|
16557
|
+
}
|
|
16558
|
+
if (refs.target === "openApi3") {
|
|
16559
|
+
return {
|
|
16560
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
16561
|
+
enum: [def.value]
|
|
16562
|
+
};
|
|
16563
|
+
}
|
|
16564
|
+
return {
|
|
16565
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
16566
|
+
const: def.value
|
|
16567
|
+
};
|
|
16568
|
+
}
|
|
16569
|
+
exports2.parseLiteralDef = parseLiteralDef;
|
|
16570
|
+
}
|
|
16571
|
+
});
|
|
16572
|
+
|
|
16573
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/string.js
|
|
16574
|
+
var require_string2 = __commonJS({
|
|
16575
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/string.js"(exports2) {
|
|
16576
|
+
"use strict";
|
|
16577
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16578
|
+
exports2.parseStringDef = exports2.zodPatterns = void 0;
|
|
16579
|
+
var errorMessages_js_1 = require_errorMessages();
|
|
16580
|
+
var emojiRegex = void 0;
|
|
16581
|
+
exports2.zodPatterns = {
|
|
16582
|
+
/**
|
|
16583
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
16584
|
+
*/
|
|
16585
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
16586
|
+
cuid2: /^[0-9a-z]+$/,
|
|
16587
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
16588
|
+
/**
|
|
16589
|
+
* `a-z` was added to replicate /i flag
|
|
16590
|
+
*/
|
|
16591
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
16592
|
+
/**
|
|
16593
|
+
* Constructed a valid Unicode RegExp
|
|
16594
|
+
*
|
|
16595
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
16596
|
+
* in all envs (e.g. React Native).
|
|
16597
|
+
*
|
|
16598
|
+
* See:
|
|
16599
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
16600
|
+
* Fix in Zod:
|
|
16601
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
16602
|
+
*/
|
|
16603
|
+
emoji: () => {
|
|
16604
|
+
if (emojiRegex === void 0) {
|
|
16605
|
+
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
16606
|
+
}
|
|
16607
|
+
return emojiRegex;
|
|
16608
|
+
},
|
|
16609
|
+
/**
|
|
16610
|
+
* Unused
|
|
16611
|
+
*/
|
|
16612
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
16613
|
+
/**
|
|
16614
|
+
* Unused
|
|
16615
|
+
*/
|
|
16616
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
16617
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
16618
|
+
/**
|
|
16619
|
+
* Unused
|
|
16620
|
+
*/
|
|
16621
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
16622
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
16623
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
16624
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
16625
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
16626
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
16627
|
+
};
|
|
16628
|
+
function parseStringDef(def, refs) {
|
|
16629
|
+
const res = {
|
|
16630
|
+
type: "string"
|
|
16631
|
+
};
|
|
16632
|
+
if (def.checks) {
|
|
16633
|
+
for (const check of def.checks) {
|
|
16634
|
+
switch (check.kind) {
|
|
16635
|
+
case "min":
|
|
16636
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
16637
|
+
break;
|
|
16638
|
+
case "max":
|
|
16639
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
16640
|
+
break;
|
|
16641
|
+
case "email":
|
|
16642
|
+
switch (refs.emailStrategy) {
|
|
16643
|
+
case "format:email":
|
|
16644
|
+
addFormat(res, "email", check.message, refs);
|
|
16645
|
+
break;
|
|
16646
|
+
case "format:idn-email":
|
|
16647
|
+
addFormat(res, "idn-email", check.message, refs);
|
|
16648
|
+
break;
|
|
16649
|
+
case "pattern:zod":
|
|
16650
|
+
addPattern(res, exports2.zodPatterns.email, check.message, refs);
|
|
16651
|
+
break;
|
|
16652
|
+
}
|
|
16653
|
+
break;
|
|
16654
|
+
case "url":
|
|
16655
|
+
addFormat(res, "uri", check.message, refs);
|
|
16656
|
+
break;
|
|
16657
|
+
case "uuid":
|
|
16658
|
+
addFormat(res, "uuid", check.message, refs);
|
|
16659
|
+
break;
|
|
16660
|
+
case "regex":
|
|
16661
|
+
addPattern(res, check.regex, check.message, refs);
|
|
16662
|
+
break;
|
|
16663
|
+
case "cuid":
|
|
16664
|
+
addPattern(res, exports2.zodPatterns.cuid, check.message, refs);
|
|
16665
|
+
break;
|
|
16666
|
+
case "cuid2":
|
|
16667
|
+
addPattern(res, exports2.zodPatterns.cuid2, check.message, refs);
|
|
16668
|
+
break;
|
|
16669
|
+
case "startsWith":
|
|
16670
|
+
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
16671
|
+
break;
|
|
16672
|
+
case "endsWith":
|
|
16673
|
+
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
16674
|
+
break;
|
|
16675
|
+
case "datetime":
|
|
16676
|
+
addFormat(res, "date-time", check.message, refs);
|
|
16677
|
+
break;
|
|
16678
|
+
case "date":
|
|
16679
|
+
addFormat(res, "date", check.message, refs);
|
|
16680
|
+
break;
|
|
16681
|
+
case "time":
|
|
16682
|
+
addFormat(res, "time", check.message, refs);
|
|
16683
|
+
break;
|
|
16684
|
+
case "duration":
|
|
16685
|
+
addFormat(res, "duration", check.message, refs);
|
|
16686
|
+
break;
|
|
16687
|
+
case "length":
|
|
16688
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
16689
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
16690
|
+
break;
|
|
16691
|
+
case "includes": {
|
|
16692
|
+
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
16693
|
+
break;
|
|
16694
|
+
}
|
|
16695
|
+
case "ip": {
|
|
16696
|
+
if (check.version !== "v6") {
|
|
16697
|
+
addFormat(res, "ipv4", check.message, refs);
|
|
16698
|
+
}
|
|
16699
|
+
if (check.version !== "v4") {
|
|
16700
|
+
addFormat(res, "ipv6", check.message, refs);
|
|
16701
|
+
}
|
|
16702
|
+
break;
|
|
16703
|
+
}
|
|
16704
|
+
case "base64url":
|
|
16705
|
+
addPattern(res, exports2.zodPatterns.base64url, check.message, refs);
|
|
16706
|
+
break;
|
|
16707
|
+
case "jwt":
|
|
16708
|
+
addPattern(res, exports2.zodPatterns.jwt, check.message, refs);
|
|
16709
|
+
break;
|
|
16710
|
+
case "cidr": {
|
|
16711
|
+
if (check.version !== "v6") {
|
|
16712
|
+
addPattern(res, exports2.zodPatterns.ipv4Cidr, check.message, refs);
|
|
16713
|
+
}
|
|
16714
|
+
if (check.version !== "v4") {
|
|
16715
|
+
addPattern(res, exports2.zodPatterns.ipv6Cidr, check.message, refs);
|
|
16716
|
+
}
|
|
16717
|
+
break;
|
|
16718
|
+
}
|
|
16719
|
+
case "emoji":
|
|
16720
|
+
addPattern(res, exports2.zodPatterns.emoji(), check.message, refs);
|
|
16721
|
+
break;
|
|
16722
|
+
case "ulid": {
|
|
16723
|
+
addPattern(res, exports2.zodPatterns.ulid, check.message, refs);
|
|
16724
|
+
break;
|
|
16725
|
+
}
|
|
16726
|
+
case "base64": {
|
|
16727
|
+
switch (refs.base64Strategy) {
|
|
16728
|
+
case "format:binary": {
|
|
16729
|
+
addFormat(res, "binary", check.message, refs);
|
|
16730
|
+
break;
|
|
16731
|
+
}
|
|
16732
|
+
case "contentEncoding:base64": {
|
|
16733
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "contentEncoding", "base64", check.message, refs);
|
|
16734
|
+
break;
|
|
16735
|
+
}
|
|
16736
|
+
case "pattern:zod": {
|
|
16737
|
+
addPattern(res, exports2.zodPatterns.base64, check.message, refs);
|
|
16738
|
+
break;
|
|
16739
|
+
}
|
|
16740
|
+
}
|
|
16741
|
+
break;
|
|
16742
|
+
}
|
|
16743
|
+
case "nanoid": {
|
|
16744
|
+
addPattern(res, exports2.zodPatterns.nanoid, check.message, refs);
|
|
16745
|
+
}
|
|
16746
|
+
case "toLowerCase":
|
|
16747
|
+
case "toUpperCase":
|
|
16748
|
+
case "trim":
|
|
16749
|
+
break;
|
|
16750
|
+
default:
|
|
16751
|
+
/* @__PURE__ */ ((_) => {
|
|
16752
|
+
})(check);
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16755
|
+
}
|
|
16756
|
+
return res;
|
|
16757
|
+
}
|
|
16758
|
+
exports2.parseStringDef = parseStringDef;
|
|
16759
|
+
function escapeLiteralCheckValue(literal, refs) {
|
|
16760
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
16761
|
+
}
|
|
16762
|
+
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
16763
|
+
function escapeNonAlphaNumeric(source) {
|
|
16764
|
+
let result = "";
|
|
16765
|
+
for (let i = 0; i < source.length; i++) {
|
|
16766
|
+
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
16767
|
+
result += "\\";
|
|
16768
|
+
}
|
|
16769
|
+
result += source[i];
|
|
16770
|
+
}
|
|
16771
|
+
return result;
|
|
16772
|
+
}
|
|
16773
|
+
function addFormat(schema, value, message, refs) {
|
|
16774
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
16775
|
+
if (!schema.anyOf) {
|
|
16776
|
+
schema.anyOf = [];
|
|
16777
|
+
}
|
|
16778
|
+
if (schema.format) {
|
|
16779
|
+
schema.anyOf.push({
|
|
16780
|
+
format: schema.format,
|
|
16781
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
16782
|
+
errorMessage: { format: schema.errorMessage.format }
|
|
16783
|
+
}
|
|
16784
|
+
});
|
|
16785
|
+
delete schema.format;
|
|
16786
|
+
if (schema.errorMessage) {
|
|
16787
|
+
delete schema.errorMessage.format;
|
|
16788
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
16789
|
+
delete schema.errorMessage;
|
|
16790
|
+
}
|
|
16791
|
+
}
|
|
16792
|
+
}
|
|
16793
|
+
schema.anyOf.push({
|
|
16794
|
+
format: value,
|
|
16795
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
16796
|
+
});
|
|
16797
|
+
} else {
|
|
16798
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(schema, "format", value, message, refs);
|
|
16799
|
+
}
|
|
16800
|
+
}
|
|
16801
|
+
function addPattern(schema, regex, message, refs) {
|
|
16802
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
16803
|
+
if (!schema.allOf) {
|
|
16804
|
+
schema.allOf = [];
|
|
16805
|
+
}
|
|
16806
|
+
if (schema.pattern) {
|
|
16807
|
+
schema.allOf.push({
|
|
16808
|
+
pattern: schema.pattern,
|
|
16809
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
16810
|
+
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
16811
|
+
}
|
|
16812
|
+
});
|
|
16813
|
+
delete schema.pattern;
|
|
16814
|
+
if (schema.errorMessage) {
|
|
16815
|
+
delete schema.errorMessage.pattern;
|
|
16816
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
16817
|
+
delete schema.errorMessage;
|
|
16818
|
+
}
|
|
16819
|
+
}
|
|
16820
|
+
}
|
|
16821
|
+
schema.allOf.push({
|
|
16822
|
+
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
16823
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
16824
|
+
});
|
|
16825
|
+
} else {
|
|
16826
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
16827
|
+
}
|
|
16828
|
+
}
|
|
16829
|
+
function stringifyRegExpWithFlags(regex, refs) {
|
|
16830
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
16831
|
+
return regex.source;
|
|
16832
|
+
}
|
|
16833
|
+
const flags = {
|
|
16834
|
+
i: regex.flags.includes("i"),
|
|
16835
|
+
m: regex.flags.includes("m"),
|
|
16836
|
+
s: regex.flags.includes("s")
|
|
16837
|
+
// `.` matches newlines
|
|
16838
|
+
};
|
|
16839
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
16840
|
+
let pattern = "";
|
|
16841
|
+
let isEscaped = false;
|
|
16842
|
+
let inCharGroup = false;
|
|
16843
|
+
let inCharRange = false;
|
|
16844
|
+
for (let i = 0; i < source.length; i++) {
|
|
16845
|
+
if (isEscaped) {
|
|
16846
|
+
pattern += source[i];
|
|
16847
|
+
isEscaped = false;
|
|
16848
|
+
continue;
|
|
16849
|
+
}
|
|
16850
|
+
if (flags.i) {
|
|
16851
|
+
if (inCharGroup) {
|
|
16852
|
+
if (source[i].match(/[a-z]/)) {
|
|
16853
|
+
if (inCharRange) {
|
|
16854
|
+
pattern += source[i];
|
|
16855
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
16856
|
+
inCharRange = false;
|
|
16857
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
16858
|
+
pattern += source[i];
|
|
16859
|
+
inCharRange = true;
|
|
16860
|
+
} else {
|
|
16861
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
16862
|
+
}
|
|
16863
|
+
continue;
|
|
16864
|
+
}
|
|
16865
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
16866
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
16867
|
+
continue;
|
|
16868
|
+
}
|
|
16869
|
+
}
|
|
16870
|
+
if (flags.m) {
|
|
16871
|
+
if (source[i] === "^") {
|
|
16872
|
+
pattern += `(^|(?<=[\r
|
|
16873
|
+
]))`;
|
|
16874
|
+
continue;
|
|
16875
|
+
} else if (source[i] === "$") {
|
|
16876
|
+
pattern += `($|(?=[\r
|
|
16877
|
+
]))`;
|
|
16878
|
+
continue;
|
|
16879
|
+
}
|
|
16880
|
+
}
|
|
16881
|
+
if (flags.s && source[i] === ".") {
|
|
16882
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
16883
|
+
` : `[${source[i]}\r
|
|
16884
|
+
]`;
|
|
16885
|
+
continue;
|
|
16886
|
+
}
|
|
16887
|
+
pattern += source[i];
|
|
16888
|
+
if (source[i] === "\\") {
|
|
16889
|
+
isEscaped = true;
|
|
16890
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
16891
|
+
inCharGroup = false;
|
|
16892
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
16893
|
+
inCharGroup = true;
|
|
16894
|
+
}
|
|
16895
|
+
}
|
|
16896
|
+
try {
|
|
16897
|
+
new RegExp(pattern);
|
|
16898
|
+
} catch {
|
|
16899
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
16900
|
+
return regex.source;
|
|
16901
|
+
}
|
|
16902
|
+
return pattern;
|
|
16903
|
+
}
|
|
16904
|
+
}
|
|
16905
|
+
});
|
|
16906
|
+
|
|
16907
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/record.js
|
|
16908
|
+
var require_record = __commonJS({
|
|
16909
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/record.js"(exports2) {
|
|
16910
|
+
"use strict";
|
|
16911
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16912
|
+
exports2.parseRecordDef = void 0;
|
|
16913
|
+
var v3_1 = require_v3();
|
|
16914
|
+
var parseDef_js_1 = require_parseDef();
|
|
16915
|
+
var string_js_1 = require_string2();
|
|
16916
|
+
var branded_js_1 = require_branded();
|
|
16917
|
+
var any_js_1 = require_any();
|
|
16918
|
+
function parseRecordDef(def, refs) {
|
|
16919
|
+
if (refs.target === "openAi") {
|
|
16920
|
+
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
16921
|
+
}
|
|
16922
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodEnum) {
|
|
16923
|
+
return {
|
|
16924
|
+
type: "object",
|
|
16925
|
+
required: def.keyType._def.values,
|
|
16926
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
16927
|
+
...acc,
|
|
16928
|
+
[key]: (0, parseDef_js_1.parseDef)(def.valueType._def, {
|
|
16929
|
+
...refs,
|
|
16930
|
+
currentPath: [...refs.currentPath, "properties", key]
|
|
16931
|
+
}) ?? (0, any_js_1.parseAnyDef)(refs)
|
|
16932
|
+
}), {}),
|
|
16933
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
16934
|
+
};
|
|
16935
|
+
}
|
|
16936
|
+
const schema = {
|
|
16937
|
+
type: "object",
|
|
16938
|
+
additionalProperties: (0, parseDef_js_1.parseDef)(def.valueType._def, {
|
|
16939
|
+
...refs,
|
|
16940
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
16941
|
+
}) ?? refs.allowedAdditionalProperties
|
|
16942
|
+
};
|
|
16943
|
+
if (refs.target === "openApi3") {
|
|
16944
|
+
return schema;
|
|
16945
|
+
}
|
|
16946
|
+
if (def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
16947
|
+
const { type, ...keyType } = (0, string_js_1.parseStringDef)(def.keyType._def, refs);
|
|
16948
|
+
return {
|
|
16949
|
+
...schema,
|
|
16950
|
+
propertyNames: keyType
|
|
16951
|
+
};
|
|
16952
|
+
} else if (def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodEnum) {
|
|
16953
|
+
return {
|
|
16954
|
+
...schema,
|
|
16955
|
+
propertyNames: {
|
|
16956
|
+
enum: def.keyType._def.values
|
|
16957
|
+
}
|
|
16958
|
+
};
|
|
16959
|
+
} else if (def.keyType?._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === v3_1.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
16960
|
+
const { type, ...keyType } = (0, branded_js_1.parseBrandedDef)(def.keyType._def, refs);
|
|
16961
|
+
return {
|
|
16962
|
+
...schema,
|
|
16963
|
+
propertyNames: keyType
|
|
16964
|
+
};
|
|
16965
|
+
}
|
|
16966
|
+
return schema;
|
|
16967
|
+
}
|
|
16968
|
+
exports2.parseRecordDef = parseRecordDef;
|
|
16969
|
+
}
|
|
16970
|
+
});
|
|
16971
|
+
|
|
16972
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/map.js
|
|
16973
|
+
var require_map2 = __commonJS({
|
|
16974
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/map.js"(exports2) {
|
|
16975
|
+
"use strict";
|
|
16976
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16977
|
+
exports2.parseMapDef = void 0;
|
|
16978
|
+
var parseDef_js_1 = require_parseDef();
|
|
16979
|
+
var record_js_1 = require_record();
|
|
16980
|
+
var any_js_1 = require_any();
|
|
16981
|
+
function parseMapDef(def, refs) {
|
|
16982
|
+
if (refs.mapStrategy === "record") {
|
|
16983
|
+
return (0, record_js_1.parseRecordDef)(def, refs);
|
|
16984
|
+
}
|
|
16985
|
+
const keys = (0, parseDef_js_1.parseDef)(def.keyType._def, {
|
|
16986
|
+
...refs,
|
|
16987
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
16988
|
+
}) || (0, any_js_1.parseAnyDef)(refs);
|
|
16989
|
+
const values = (0, parseDef_js_1.parseDef)(def.valueType._def, {
|
|
16990
|
+
...refs,
|
|
16991
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
16992
|
+
}) || (0, any_js_1.parseAnyDef)(refs);
|
|
16993
|
+
return {
|
|
16994
|
+
type: "array",
|
|
16995
|
+
maxItems: 125,
|
|
16996
|
+
items: {
|
|
16997
|
+
type: "array",
|
|
16998
|
+
items: [keys, values],
|
|
16999
|
+
minItems: 2,
|
|
17000
|
+
maxItems: 2
|
|
17001
|
+
}
|
|
17002
|
+
};
|
|
17003
|
+
}
|
|
17004
|
+
exports2.parseMapDef = parseMapDef;
|
|
17005
|
+
}
|
|
17006
|
+
});
|
|
17007
|
+
|
|
17008
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/nativeEnum.js
|
|
17009
|
+
var require_nativeEnum = __commonJS({
|
|
17010
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/nativeEnum.js"(exports2) {
|
|
17011
|
+
"use strict";
|
|
17012
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17013
|
+
exports2.parseNativeEnumDef = void 0;
|
|
17014
|
+
function parseNativeEnumDef(def) {
|
|
17015
|
+
const object = def.values;
|
|
17016
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
17017
|
+
return typeof object[object[key]] !== "number";
|
|
17018
|
+
});
|
|
17019
|
+
const actualValues = actualKeys.map((key) => object[key]);
|
|
17020
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
17021
|
+
return {
|
|
17022
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
17023
|
+
enum: actualValues
|
|
17024
|
+
};
|
|
17025
|
+
}
|
|
17026
|
+
exports2.parseNativeEnumDef = parseNativeEnumDef;
|
|
17027
|
+
}
|
|
17028
|
+
});
|
|
17029
|
+
|
|
17030
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/never.js
|
|
17031
|
+
var require_never = __commonJS({
|
|
17032
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/never.js"(exports2) {
|
|
17033
|
+
"use strict";
|
|
17034
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17035
|
+
exports2.parseNeverDef = void 0;
|
|
17036
|
+
var any_js_1 = require_any();
|
|
17037
|
+
function parseNeverDef(refs) {
|
|
17038
|
+
return refs.target === "openAi" ? void 0 : {
|
|
17039
|
+
not: (0, any_js_1.parseAnyDef)({
|
|
17040
|
+
...refs,
|
|
17041
|
+
currentPath: [...refs.currentPath, "not"]
|
|
17042
|
+
})
|
|
17043
|
+
};
|
|
17044
|
+
}
|
|
17045
|
+
exports2.parseNeverDef = parseNeverDef;
|
|
17046
|
+
}
|
|
17047
|
+
});
|
|
17048
|
+
|
|
17049
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/null.js
|
|
17050
|
+
var require_null2 = __commonJS({
|
|
17051
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/null.js"(exports2) {
|
|
17052
|
+
"use strict";
|
|
17053
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17054
|
+
exports2.parseNullDef = void 0;
|
|
17055
|
+
function parseNullDef(refs) {
|
|
17056
|
+
return refs.target === "openApi3" ? {
|
|
17057
|
+
enum: ["null"],
|
|
17058
|
+
nullable: true
|
|
17059
|
+
} : {
|
|
17060
|
+
type: "null"
|
|
17061
|
+
};
|
|
17062
|
+
}
|
|
17063
|
+
exports2.parseNullDef = parseNullDef;
|
|
17064
|
+
}
|
|
17065
|
+
});
|
|
17066
|
+
|
|
17067
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/union.js
|
|
17068
|
+
var require_union = __commonJS({
|
|
17069
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/union.js"(exports2) {
|
|
17070
|
+
"use strict";
|
|
17071
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17072
|
+
exports2.parseUnionDef = exports2.primitiveMappings = void 0;
|
|
17073
|
+
var parseDef_js_1 = require_parseDef();
|
|
17074
|
+
exports2.primitiveMappings = {
|
|
17075
|
+
ZodString: "string",
|
|
17076
|
+
ZodNumber: "number",
|
|
17077
|
+
ZodBigInt: "integer",
|
|
17078
|
+
ZodBoolean: "boolean",
|
|
17079
|
+
ZodNull: "null"
|
|
17080
|
+
};
|
|
17081
|
+
function parseUnionDef(def, refs) {
|
|
17082
|
+
if (refs.target === "openApi3")
|
|
17083
|
+
return asAnyOf(def, refs);
|
|
17084
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
17085
|
+
if (options.every((x) => x._def.typeName in exports2.primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
17086
|
+
const types = options.reduce((types2, x) => {
|
|
17087
|
+
const type = exports2.primitiveMappings[x._def.typeName];
|
|
17088
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
17089
|
+
}, []);
|
|
17090
|
+
return {
|
|
17091
|
+
type: types.length > 1 ? types : types[0]
|
|
17092
|
+
};
|
|
17093
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
17094
|
+
const types = options.reduce((acc, x) => {
|
|
17095
|
+
const type = typeof x._def.value;
|
|
17096
|
+
switch (type) {
|
|
17097
|
+
case "string":
|
|
17098
|
+
case "number":
|
|
17099
|
+
case "boolean":
|
|
17100
|
+
return [...acc, type];
|
|
17101
|
+
case "bigint":
|
|
17102
|
+
return [...acc, "integer"];
|
|
17103
|
+
case "object":
|
|
17104
|
+
if (x._def.value === null)
|
|
17105
|
+
return [...acc, "null"];
|
|
17106
|
+
case "symbol":
|
|
17107
|
+
case "undefined":
|
|
17108
|
+
case "function":
|
|
17109
|
+
default:
|
|
17110
|
+
return acc;
|
|
17111
|
+
}
|
|
17112
|
+
}, []);
|
|
17113
|
+
if (types.length === options.length) {
|
|
17114
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
17115
|
+
return {
|
|
17116
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
17117
|
+
enum: options.reduce((acc, x) => {
|
|
17118
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
17119
|
+
}, [])
|
|
17120
|
+
};
|
|
17121
|
+
}
|
|
17122
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
17123
|
+
return {
|
|
17124
|
+
type: "string",
|
|
17125
|
+
enum: options.reduce((acc, x) => [
|
|
17126
|
+
...acc,
|
|
17127
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
17128
|
+
], [])
|
|
17129
|
+
};
|
|
17130
|
+
}
|
|
17131
|
+
return asAnyOf(def, refs);
|
|
17132
|
+
}
|
|
17133
|
+
exports2.parseUnionDef = parseUnionDef;
|
|
17134
|
+
var asAnyOf = (def, refs) => {
|
|
17135
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => (0, parseDef_js_1.parseDef)(x._def, {
|
|
17136
|
+
...refs,
|
|
17137
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
17138
|
+
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
17139
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
17140
|
+
};
|
|
17141
|
+
}
|
|
17142
|
+
});
|
|
17143
|
+
|
|
17144
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/nullable.js
|
|
17145
|
+
var require_nullable = __commonJS({
|
|
17146
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/nullable.js"(exports2) {
|
|
17147
|
+
"use strict";
|
|
17148
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17149
|
+
exports2.parseNullableDef = void 0;
|
|
17150
|
+
var parseDef_js_1 = require_parseDef();
|
|
17151
|
+
var union_js_1 = require_union();
|
|
17152
|
+
function parseNullableDef(def, refs) {
|
|
17153
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
17154
|
+
if (refs.target === "openApi3") {
|
|
17155
|
+
return {
|
|
17156
|
+
type: union_js_1.primitiveMappings[def.innerType._def.typeName],
|
|
17157
|
+
nullable: true
|
|
17158
|
+
};
|
|
17159
|
+
}
|
|
17160
|
+
return {
|
|
17161
|
+
type: [
|
|
17162
|
+
union_js_1.primitiveMappings[def.innerType._def.typeName],
|
|
17163
|
+
"null"
|
|
17164
|
+
]
|
|
17165
|
+
};
|
|
17166
|
+
}
|
|
17167
|
+
if (refs.target === "openApi3") {
|
|
17168
|
+
const base2 = (0, parseDef_js_1.parseDef)(def.innerType._def, {
|
|
17169
|
+
...refs,
|
|
17170
|
+
currentPath: [...refs.currentPath]
|
|
17171
|
+
});
|
|
17172
|
+
if (base2 && "$ref" in base2)
|
|
17173
|
+
return { allOf: [base2], nullable: true };
|
|
17174
|
+
return base2 && { ...base2, nullable: true };
|
|
17175
|
+
}
|
|
17176
|
+
const base = (0, parseDef_js_1.parseDef)(def.innerType._def, {
|
|
17177
|
+
...refs,
|
|
17178
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
17179
|
+
});
|
|
17180
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
17181
|
+
}
|
|
17182
|
+
exports2.parseNullableDef = parseNullableDef;
|
|
17183
|
+
}
|
|
17184
|
+
});
|
|
17185
|
+
|
|
17186
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/number.js
|
|
17187
|
+
var require_number = __commonJS({
|
|
17188
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/number.js"(exports2) {
|
|
17189
|
+
"use strict";
|
|
17190
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17191
|
+
exports2.parseNumberDef = void 0;
|
|
17192
|
+
var errorMessages_js_1 = require_errorMessages();
|
|
17193
|
+
function parseNumberDef(def, refs) {
|
|
17194
|
+
const res = {
|
|
17195
|
+
type: "number"
|
|
17196
|
+
};
|
|
17197
|
+
if (!def.checks)
|
|
17198
|
+
return res;
|
|
17199
|
+
for (const check of def.checks) {
|
|
17200
|
+
switch (check.kind) {
|
|
17201
|
+
case "int":
|
|
17202
|
+
res.type = "integer";
|
|
17203
|
+
(0, errorMessages_js_1.addErrorMessage)(res, "type", check.message, refs);
|
|
17204
|
+
break;
|
|
17205
|
+
case "min":
|
|
17206
|
+
if (refs.target === "jsonSchema7") {
|
|
17207
|
+
if (check.inclusive) {
|
|
17208
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs);
|
|
17209
|
+
} else {
|
|
17210
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
17211
|
+
}
|
|
17212
|
+
} else {
|
|
17213
|
+
if (!check.inclusive) {
|
|
17214
|
+
res.exclusiveMinimum = true;
|
|
17215
|
+
}
|
|
17216
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "minimum", check.value, check.message, refs);
|
|
17217
|
+
}
|
|
17218
|
+
break;
|
|
17219
|
+
case "max":
|
|
17220
|
+
if (refs.target === "jsonSchema7") {
|
|
17221
|
+
if (check.inclusive) {
|
|
17222
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs);
|
|
17223
|
+
} else {
|
|
17224
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
17225
|
+
}
|
|
17226
|
+
} else {
|
|
17227
|
+
if (!check.inclusive) {
|
|
17228
|
+
res.exclusiveMaximum = true;
|
|
17229
|
+
}
|
|
17230
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "maximum", check.value, check.message, refs);
|
|
17231
|
+
}
|
|
17232
|
+
break;
|
|
17233
|
+
case "multipleOf":
|
|
17234
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(res, "multipleOf", check.value, check.message, refs);
|
|
17235
|
+
break;
|
|
17236
|
+
}
|
|
17237
|
+
}
|
|
17238
|
+
return res;
|
|
17239
|
+
}
|
|
17240
|
+
exports2.parseNumberDef = parseNumberDef;
|
|
17241
|
+
}
|
|
17242
|
+
});
|
|
17243
|
+
|
|
17244
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js
|
|
17245
|
+
var require_object = __commonJS({
|
|
17246
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js"(exports2) {
|
|
17247
|
+
"use strict";
|
|
17248
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17249
|
+
exports2.parseObjectDef = void 0;
|
|
17250
|
+
var parseDef_js_1 = require_parseDef();
|
|
17251
|
+
function parseObjectDef(def, refs) {
|
|
17252
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
17253
|
+
const result = {
|
|
17254
|
+
type: "object",
|
|
17255
|
+
properties: {}
|
|
17256
|
+
};
|
|
17257
|
+
const required = [];
|
|
17258
|
+
const shape = def.shape();
|
|
17259
|
+
for (const propName in shape) {
|
|
17260
|
+
let propDef = shape[propName];
|
|
17261
|
+
if (propDef === void 0 || propDef._def === void 0) {
|
|
17262
|
+
continue;
|
|
17263
|
+
}
|
|
17264
|
+
let propOptional = safeIsOptional(propDef);
|
|
17265
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
17266
|
+
if (propDef._def.typeName === "ZodOptional") {
|
|
17267
|
+
propDef = propDef._def.innerType;
|
|
17268
|
+
}
|
|
17269
|
+
if (!propDef.isNullable()) {
|
|
17270
|
+
propDef = propDef.nullable();
|
|
17271
|
+
}
|
|
17272
|
+
propOptional = false;
|
|
17273
|
+
}
|
|
17274
|
+
const parsedDef = (0, parseDef_js_1.parseDef)(propDef._def, {
|
|
17275
|
+
...refs,
|
|
17276
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
17277
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
17278
|
+
});
|
|
17279
|
+
if (parsedDef === void 0) {
|
|
17280
|
+
continue;
|
|
17281
|
+
}
|
|
17282
|
+
result.properties[propName] = parsedDef;
|
|
17283
|
+
if (!propOptional) {
|
|
17284
|
+
required.push(propName);
|
|
17285
|
+
}
|
|
17286
|
+
}
|
|
17287
|
+
if (required.length) {
|
|
17288
|
+
result.required = required;
|
|
17289
|
+
}
|
|
17290
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
17291
|
+
if (additionalProperties !== void 0) {
|
|
17292
|
+
result.additionalProperties = additionalProperties;
|
|
17293
|
+
}
|
|
17294
|
+
return result;
|
|
17295
|
+
}
|
|
17296
|
+
exports2.parseObjectDef = parseObjectDef;
|
|
17297
|
+
function decideAdditionalProperties(def, refs) {
|
|
17298
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
17299
|
+
return (0, parseDef_js_1.parseDef)(def.catchall._def, {
|
|
17300
|
+
...refs,
|
|
17301
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
17302
|
+
});
|
|
17303
|
+
}
|
|
17304
|
+
switch (def.unknownKeys) {
|
|
17305
|
+
case "passthrough":
|
|
17306
|
+
return refs.allowedAdditionalProperties;
|
|
17307
|
+
case "strict":
|
|
17308
|
+
return refs.rejectedAdditionalProperties;
|
|
17309
|
+
case "strip":
|
|
17310
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
17311
|
+
}
|
|
17312
|
+
}
|
|
17313
|
+
function safeIsOptional(schema) {
|
|
17314
|
+
try {
|
|
17315
|
+
return schema.isOptional();
|
|
17316
|
+
} catch {
|
|
17317
|
+
return true;
|
|
17318
|
+
}
|
|
17319
|
+
}
|
|
17320
|
+
}
|
|
17321
|
+
});
|
|
17322
|
+
|
|
17323
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js
|
|
17324
|
+
var require_optional = __commonJS({
|
|
17325
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js"(exports2) {
|
|
17326
|
+
"use strict";
|
|
17327
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17328
|
+
exports2.parseOptionalDef = void 0;
|
|
17329
|
+
var parseDef_js_1 = require_parseDef();
|
|
17330
|
+
var any_js_1 = require_any();
|
|
17331
|
+
var parseOptionalDef = (def, refs) => {
|
|
17332
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
17333
|
+
return (0, parseDef_js_1.parseDef)(def.innerType._def, refs);
|
|
17334
|
+
}
|
|
17335
|
+
const innerSchema = (0, parseDef_js_1.parseDef)(def.innerType._def, {
|
|
17336
|
+
...refs,
|
|
17337
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
17338
|
+
});
|
|
17339
|
+
return innerSchema ? {
|
|
17340
|
+
anyOf: [
|
|
17341
|
+
{
|
|
17342
|
+
not: (0, any_js_1.parseAnyDef)(refs)
|
|
17343
|
+
},
|
|
17344
|
+
innerSchema
|
|
17345
|
+
]
|
|
17346
|
+
} : (0, any_js_1.parseAnyDef)(refs);
|
|
17347
|
+
};
|
|
17348
|
+
exports2.parseOptionalDef = parseOptionalDef;
|
|
17349
|
+
}
|
|
17350
|
+
});
|
|
17351
|
+
|
|
17352
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/pipeline.js
|
|
17353
|
+
var require_pipeline = __commonJS({
|
|
17354
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/pipeline.js"(exports2) {
|
|
17355
|
+
"use strict";
|
|
17356
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17357
|
+
exports2.parsePipelineDef = void 0;
|
|
17358
|
+
var parseDef_js_1 = require_parseDef();
|
|
17359
|
+
var parsePipelineDef = (def, refs) => {
|
|
17360
|
+
if (refs.pipeStrategy === "input") {
|
|
17361
|
+
return (0, parseDef_js_1.parseDef)(def.in._def, refs);
|
|
17362
|
+
} else if (refs.pipeStrategy === "output") {
|
|
17363
|
+
return (0, parseDef_js_1.parseDef)(def.out._def, refs);
|
|
17364
|
+
}
|
|
17365
|
+
const a = (0, parseDef_js_1.parseDef)(def.in._def, {
|
|
17366
|
+
...refs,
|
|
17367
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
17368
|
+
});
|
|
17369
|
+
const b = (0, parseDef_js_1.parseDef)(def.out._def, {
|
|
17370
|
+
...refs,
|
|
17371
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
17372
|
+
});
|
|
17373
|
+
return {
|
|
17374
|
+
allOf: [a, b].filter((x) => x !== void 0)
|
|
17375
|
+
};
|
|
17376
|
+
};
|
|
17377
|
+
exports2.parsePipelineDef = parsePipelineDef;
|
|
17378
|
+
}
|
|
17379
|
+
});
|
|
17380
|
+
|
|
17381
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/promise.js
|
|
17382
|
+
var require_promise = __commonJS({
|
|
17383
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/promise.js"(exports2) {
|
|
17384
|
+
"use strict";
|
|
17385
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17386
|
+
exports2.parsePromiseDef = void 0;
|
|
17387
|
+
var parseDef_js_1 = require_parseDef();
|
|
17388
|
+
function parsePromiseDef(def, refs) {
|
|
17389
|
+
return (0, parseDef_js_1.parseDef)(def.type._def, refs);
|
|
17390
|
+
}
|
|
17391
|
+
exports2.parsePromiseDef = parsePromiseDef;
|
|
17392
|
+
}
|
|
17393
|
+
});
|
|
17394
|
+
|
|
17395
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/set.js
|
|
17396
|
+
var require_set2 = __commonJS({
|
|
17397
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/set.js"(exports2) {
|
|
17398
|
+
"use strict";
|
|
17399
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17400
|
+
exports2.parseSetDef = void 0;
|
|
17401
|
+
var errorMessages_js_1 = require_errorMessages();
|
|
17402
|
+
var parseDef_js_1 = require_parseDef();
|
|
17403
|
+
function parseSetDef(def, refs) {
|
|
17404
|
+
const items = (0, parseDef_js_1.parseDef)(def.valueType._def, {
|
|
17405
|
+
...refs,
|
|
17406
|
+
currentPath: [...refs.currentPath, "items"]
|
|
17407
|
+
});
|
|
17408
|
+
const schema = {
|
|
17409
|
+
type: "array",
|
|
17410
|
+
uniqueItems: true,
|
|
17411
|
+
items
|
|
17412
|
+
};
|
|
17413
|
+
if (def.minSize) {
|
|
17414
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
17415
|
+
}
|
|
17416
|
+
if (def.maxSize) {
|
|
17417
|
+
(0, errorMessages_js_1.setResponseValueAndErrors)(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
17418
|
+
}
|
|
17419
|
+
return schema;
|
|
17420
|
+
}
|
|
17421
|
+
exports2.parseSetDef = parseSetDef;
|
|
17422
|
+
}
|
|
17423
|
+
});
|
|
17424
|
+
|
|
17425
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/tuple.js
|
|
17426
|
+
var require_tuple = __commonJS({
|
|
17427
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/tuple.js"(exports2) {
|
|
17428
|
+
"use strict";
|
|
17429
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17430
|
+
exports2.parseTupleDef = void 0;
|
|
17431
|
+
var parseDef_js_1 = require_parseDef();
|
|
17432
|
+
function parseTupleDef(def, refs) {
|
|
17433
|
+
if (def.rest) {
|
|
17434
|
+
return {
|
|
17435
|
+
type: "array",
|
|
17436
|
+
minItems: def.items.length,
|
|
17437
|
+
items: def.items.map((x, i) => (0, parseDef_js_1.parseDef)(x._def, {
|
|
17438
|
+
...refs,
|
|
17439
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
17440
|
+
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
17441
|
+
additionalItems: (0, parseDef_js_1.parseDef)(def.rest._def, {
|
|
17442
|
+
...refs,
|
|
17443
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
17444
|
+
})
|
|
17445
|
+
};
|
|
17446
|
+
} else {
|
|
17447
|
+
return {
|
|
17448
|
+
type: "array",
|
|
17449
|
+
minItems: def.items.length,
|
|
17450
|
+
maxItems: def.items.length,
|
|
17451
|
+
items: def.items.map((x, i) => (0, parseDef_js_1.parseDef)(x._def, {
|
|
17452
|
+
...refs,
|
|
17453
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
17454
|
+
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
17455
|
+
};
|
|
17456
|
+
}
|
|
17457
|
+
}
|
|
17458
|
+
exports2.parseTupleDef = parseTupleDef;
|
|
17459
|
+
}
|
|
17460
|
+
});
|
|
17461
|
+
|
|
17462
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/undefined.js
|
|
17463
|
+
var require_undefined = __commonJS({
|
|
17464
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/undefined.js"(exports2) {
|
|
17465
|
+
"use strict";
|
|
17466
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17467
|
+
exports2.parseUndefinedDef = void 0;
|
|
17468
|
+
var any_js_1 = require_any();
|
|
17469
|
+
function parseUndefinedDef(refs) {
|
|
17470
|
+
return {
|
|
17471
|
+
not: (0, any_js_1.parseAnyDef)(refs)
|
|
17472
|
+
};
|
|
17473
|
+
}
|
|
17474
|
+
exports2.parseUndefinedDef = parseUndefinedDef;
|
|
17475
|
+
}
|
|
17476
|
+
});
|
|
17477
|
+
|
|
17478
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/unknown.js
|
|
17479
|
+
var require_unknown = __commonJS({
|
|
17480
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/unknown.js"(exports2) {
|
|
17481
|
+
"use strict";
|
|
17482
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17483
|
+
exports2.parseUnknownDef = void 0;
|
|
17484
|
+
var any_js_1 = require_any();
|
|
17485
|
+
function parseUnknownDef(refs) {
|
|
17486
|
+
return (0, any_js_1.parseAnyDef)(refs);
|
|
17487
|
+
}
|
|
17488
|
+
exports2.parseUnknownDef = parseUnknownDef;
|
|
17489
|
+
}
|
|
17490
|
+
});
|
|
17491
|
+
|
|
17492
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/readonly.js
|
|
17493
|
+
var require_readonly = __commonJS({
|
|
17494
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parsers/readonly.js"(exports2) {
|
|
17495
|
+
"use strict";
|
|
17496
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17497
|
+
exports2.parseReadonlyDef = void 0;
|
|
17498
|
+
var parseDef_js_1 = require_parseDef();
|
|
17499
|
+
var parseReadonlyDef = (def, refs) => {
|
|
17500
|
+
return (0, parseDef_js_1.parseDef)(def.innerType._def, refs);
|
|
17501
|
+
};
|
|
17502
|
+
exports2.parseReadonlyDef = parseReadonlyDef;
|
|
17503
|
+
}
|
|
17504
|
+
});
|
|
17505
|
+
|
|
17506
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/selectParser.js
|
|
17507
|
+
var require_selectParser = __commonJS({
|
|
17508
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/selectParser.js"(exports2) {
|
|
17509
|
+
"use strict";
|
|
17510
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17511
|
+
exports2.selectParser = void 0;
|
|
17512
|
+
var v3_1 = require_v3();
|
|
17513
|
+
var any_js_1 = require_any();
|
|
17514
|
+
var array_js_1 = require_array();
|
|
17515
|
+
var bigint_js_1 = require_bigint();
|
|
17516
|
+
var boolean_js_1 = require_boolean();
|
|
17517
|
+
var branded_js_1 = require_branded();
|
|
17518
|
+
var catch_js_1 = require_catch();
|
|
17519
|
+
var date_js_1 = require_date();
|
|
17520
|
+
var default_js_1 = require_default();
|
|
17521
|
+
var effects_js_1 = require_effects();
|
|
17522
|
+
var enum_js_1 = require_enum();
|
|
17523
|
+
var intersection_js_1 = require_intersection();
|
|
17524
|
+
var literal_js_1 = require_literal();
|
|
17525
|
+
var map_js_1 = require_map2();
|
|
17526
|
+
var nativeEnum_js_1 = require_nativeEnum();
|
|
17527
|
+
var never_js_1 = require_never();
|
|
17528
|
+
var null_js_1 = require_null2();
|
|
17529
|
+
var nullable_js_1 = require_nullable();
|
|
17530
|
+
var number_js_1 = require_number();
|
|
17531
|
+
var object_js_1 = require_object();
|
|
17532
|
+
var optional_js_1 = require_optional();
|
|
17533
|
+
var pipeline_js_1 = require_pipeline();
|
|
17534
|
+
var promise_js_1 = require_promise();
|
|
17535
|
+
var record_js_1 = require_record();
|
|
17536
|
+
var set_js_1 = require_set2();
|
|
17537
|
+
var string_js_1 = require_string2();
|
|
17538
|
+
var tuple_js_1 = require_tuple();
|
|
17539
|
+
var undefined_js_1 = require_undefined();
|
|
17540
|
+
var union_js_1 = require_union();
|
|
17541
|
+
var unknown_js_1 = require_unknown();
|
|
17542
|
+
var readonly_js_1 = require_readonly();
|
|
17543
|
+
var selectParser = (def, typeName, refs) => {
|
|
17544
|
+
switch (typeName) {
|
|
17545
|
+
case v3_1.ZodFirstPartyTypeKind.ZodString:
|
|
17546
|
+
return (0, string_js_1.parseStringDef)(def, refs);
|
|
17547
|
+
case v3_1.ZodFirstPartyTypeKind.ZodNumber:
|
|
17548
|
+
return (0, number_js_1.parseNumberDef)(def, refs);
|
|
17549
|
+
case v3_1.ZodFirstPartyTypeKind.ZodObject:
|
|
17550
|
+
return (0, object_js_1.parseObjectDef)(def, refs);
|
|
17551
|
+
case v3_1.ZodFirstPartyTypeKind.ZodBigInt:
|
|
17552
|
+
return (0, bigint_js_1.parseBigintDef)(def, refs);
|
|
17553
|
+
case v3_1.ZodFirstPartyTypeKind.ZodBoolean:
|
|
17554
|
+
return (0, boolean_js_1.parseBooleanDef)();
|
|
17555
|
+
case v3_1.ZodFirstPartyTypeKind.ZodDate:
|
|
17556
|
+
return (0, date_js_1.parseDateDef)(def, refs);
|
|
17557
|
+
case v3_1.ZodFirstPartyTypeKind.ZodUndefined:
|
|
17558
|
+
return (0, undefined_js_1.parseUndefinedDef)(refs);
|
|
17559
|
+
case v3_1.ZodFirstPartyTypeKind.ZodNull:
|
|
17560
|
+
return (0, null_js_1.parseNullDef)(refs);
|
|
17561
|
+
case v3_1.ZodFirstPartyTypeKind.ZodArray:
|
|
17562
|
+
return (0, array_js_1.parseArrayDef)(def, refs);
|
|
17563
|
+
case v3_1.ZodFirstPartyTypeKind.ZodUnion:
|
|
17564
|
+
case v3_1.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
17565
|
+
return (0, union_js_1.parseUnionDef)(def, refs);
|
|
17566
|
+
case v3_1.ZodFirstPartyTypeKind.ZodIntersection:
|
|
17567
|
+
return (0, intersection_js_1.parseIntersectionDef)(def, refs);
|
|
17568
|
+
case v3_1.ZodFirstPartyTypeKind.ZodTuple:
|
|
17569
|
+
return (0, tuple_js_1.parseTupleDef)(def, refs);
|
|
17570
|
+
case v3_1.ZodFirstPartyTypeKind.ZodRecord:
|
|
17571
|
+
return (0, record_js_1.parseRecordDef)(def, refs);
|
|
17572
|
+
case v3_1.ZodFirstPartyTypeKind.ZodLiteral:
|
|
17573
|
+
return (0, literal_js_1.parseLiteralDef)(def, refs);
|
|
17574
|
+
case v3_1.ZodFirstPartyTypeKind.ZodEnum:
|
|
17575
|
+
return (0, enum_js_1.parseEnumDef)(def);
|
|
17576
|
+
case v3_1.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
17577
|
+
return (0, nativeEnum_js_1.parseNativeEnumDef)(def);
|
|
17578
|
+
case v3_1.ZodFirstPartyTypeKind.ZodNullable:
|
|
17579
|
+
return (0, nullable_js_1.parseNullableDef)(def, refs);
|
|
17580
|
+
case v3_1.ZodFirstPartyTypeKind.ZodOptional:
|
|
17581
|
+
return (0, optional_js_1.parseOptionalDef)(def, refs);
|
|
17582
|
+
case v3_1.ZodFirstPartyTypeKind.ZodMap:
|
|
17583
|
+
return (0, map_js_1.parseMapDef)(def, refs);
|
|
17584
|
+
case v3_1.ZodFirstPartyTypeKind.ZodSet:
|
|
17585
|
+
return (0, set_js_1.parseSetDef)(def, refs);
|
|
17586
|
+
case v3_1.ZodFirstPartyTypeKind.ZodLazy:
|
|
17587
|
+
return () => def.getter()._def;
|
|
17588
|
+
case v3_1.ZodFirstPartyTypeKind.ZodPromise:
|
|
17589
|
+
return (0, promise_js_1.parsePromiseDef)(def, refs);
|
|
17590
|
+
case v3_1.ZodFirstPartyTypeKind.ZodNaN:
|
|
17591
|
+
case v3_1.ZodFirstPartyTypeKind.ZodNever:
|
|
17592
|
+
return (0, never_js_1.parseNeverDef)(refs);
|
|
17593
|
+
case v3_1.ZodFirstPartyTypeKind.ZodEffects:
|
|
17594
|
+
return (0, effects_js_1.parseEffectsDef)(def, refs);
|
|
17595
|
+
case v3_1.ZodFirstPartyTypeKind.ZodAny:
|
|
17596
|
+
return (0, any_js_1.parseAnyDef)(refs);
|
|
17597
|
+
case v3_1.ZodFirstPartyTypeKind.ZodUnknown:
|
|
17598
|
+
return (0, unknown_js_1.parseUnknownDef)(refs);
|
|
17599
|
+
case v3_1.ZodFirstPartyTypeKind.ZodDefault:
|
|
17600
|
+
return (0, default_js_1.parseDefaultDef)(def, refs);
|
|
17601
|
+
case v3_1.ZodFirstPartyTypeKind.ZodBranded:
|
|
17602
|
+
return (0, branded_js_1.parseBrandedDef)(def, refs);
|
|
17603
|
+
case v3_1.ZodFirstPartyTypeKind.ZodReadonly:
|
|
17604
|
+
return (0, readonly_js_1.parseReadonlyDef)(def, refs);
|
|
17605
|
+
case v3_1.ZodFirstPartyTypeKind.ZodCatch:
|
|
17606
|
+
return (0, catch_js_1.parseCatchDef)(def, refs);
|
|
17607
|
+
case v3_1.ZodFirstPartyTypeKind.ZodPipeline:
|
|
17608
|
+
return (0, pipeline_js_1.parsePipelineDef)(def, refs);
|
|
17609
|
+
case v3_1.ZodFirstPartyTypeKind.ZodFunction:
|
|
17610
|
+
case v3_1.ZodFirstPartyTypeKind.ZodVoid:
|
|
17611
|
+
case v3_1.ZodFirstPartyTypeKind.ZodSymbol:
|
|
17612
|
+
return void 0;
|
|
17613
|
+
default:
|
|
17614
|
+
return /* @__PURE__ */ ((_) => void 0)(typeName);
|
|
17615
|
+
}
|
|
17616
|
+
};
|
|
17617
|
+
exports2.selectParser = selectParser;
|
|
17618
|
+
}
|
|
17619
|
+
});
|
|
17620
|
+
|
|
17621
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parseDef.js
|
|
17622
|
+
var require_parseDef = __commonJS({
|
|
17623
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parseDef.js"(exports2) {
|
|
17624
|
+
"use strict";
|
|
17625
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17626
|
+
exports2.parseDef = void 0;
|
|
17627
|
+
var Options_js_1 = require_Options();
|
|
17628
|
+
var selectParser_js_1 = require_selectParser();
|
|
17629
|
+
var getRelativePath_js_1 = require_getRelativePath();
|
|
17630
|
+
var any_js_1 = require_any();
|
|
17631
|
+
function parseDef(def, refs, forceResolution = false) {
|
|
17632
|
+
const seenItem = refs.seen.get(def);
|
|
17633
|
+
if (refs.override) {
|
|
17634
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
17635
|
+
if (overrideResult !== Options_js_1.ignoreOverride) {
|
|
17636
|
+
return overrideResult;
|
|
17637
|
+
}
|
|
17638
|
+
}
|
|
17639
|
+
if (seenItem && !forceResolution) {
|
|
17640
|
+
const seenSchema = get$ref(seenItem, refs);
|
|
17641
|
+
if (seenSchema !== void 0) {
|
|
17642
|
+
return seenSchema;
|
|
17643
|
+
}
|
|
17644
|
+
}
|
|
17645
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
17646
|
+
refs.seen.set(def, newItem);
|
|
17647
|
+
const jsonSchemaOrGetter = (0, selectParser_js_1.selectParser)(def, def.typeName, refs);
|
|
17648
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
17649
|
+
if (jsonSchema) {
|
|
17650
|
+
addMeta(def, refs, jsonSchema);
|
|
17651
|
+
}
|
|
17652
|
+
if (refs.postProcess) {
|
|
17653
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
17654
|
+
newItem.jsonSchema = jsonSchema;
|
|
17655
|
+
return postProcessResult;
|
|
17656
|
+
}
|
|
17657
|
+
newItem.jsonSchema = jsonSchema;
|
|
17658
|
+
return jsonSchema;
|
|
17659
|
+
}
|
|
17660
|
+
exports2.parseDef = parseDef;
|
|
17661
|
+
var get$ref = (item, refs) => {
|
|
17662
|
+
switch (refs.$refStrategy) {
|
|
17663
|
+
case "root":
|
|
17664
|
+
return { $ref: item.path.join("/") };
|
|
17665
|
+
case "relative":
|
|
17666
|
+
return { $ref: (0, getRelativePath_js_1.getRelativePath)(refs.currentPath, item.path) };
|
|
17667
|
+
case "none":
|
|
17668
|
+
case "seen": {
|
|
17669
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
17670
|
+
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
17671
|
+
return (0, any_js_1.parseAnyDef)(refs);
|
|
17672
|
+
}
|
|
17673
|
+
return refs.$refStrategy === "seen" ? (0, any_js_1.parseAnyDef)(refs) : void 0;
|
|
17674
|
+
}
|
|
17675
|
+
}
|
|
17676
|
+
};
|
|
17677
|
+
var addMeta = (def, refs, jsonSchema) => {
|
|
17678
|
+
if (def.description) {
|
|
17679
|
+
jsonSchema.description = def.description;
|
|
17680
|
+
if (refs.markdownDescription) {
|
|
17681
|
+
jsonSchema.markdownDescription = def.description;
|
|
17682
|
+
}
|
|
17683
|
+
}
|
|
17684
|
+
return jsonSchema;
|
|
17685
|
+
};
|
|
17686
|
+
}
|
|
17687
|
+
});
|
|
17688
|
+
|
|
17689
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parseTypes.js
|
|
17690
|
+
var require_parseTypes = __commonJS({
|
|
17691
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/parseTypes.js"(exports2) {
|
|
17692
|
+
"use strict";
|
|
17693
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17694
|
+
}
|
|
17695
|
+
});
|
|
17696
|
+
|
|
17697
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js
|
|
17698
|
+
var require_zodToJsonSchema = __commonJS({
|
|
17699
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js"(exports2) {
|
|
17700
|
+
"use strict";
|
|
17701
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17702
|
+
exports2.zodToJsonSchema = void 0;
|
|
17703
|
+
var parseDef_js_1 = require_parseDef();
|
|
17704
|
+
var Refs_js_1 = require_Refs();
|
|
17705
|
+
var any_js_1 = require_any();
|
|
17706
|
+
var zodToJsonSchema = (schema, options) => {
|
|
17707
|
+
const refs = (0, Refs_js_1.getRefs)(options);
|
|
17708
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
|
|
17709
|
+
...acc,
|
|
17710
|
+
[name2]: (0, parseDef_js_1.parseDef)(schema2._def, {
|
|
17711
|
+
...refs,
|
|
17712
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
17713
|
+
}, true) ?? (0, any_js_1.parseAnyDef)(refs)
|
|
17714
|
+
}), {}) : void 0;
|
|
17715
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
17716
|
+
const main = (0, parseDef_js_1.parseDef)(schema._def, name === void 0 ? refs : {
|
|
17717
|
+
...refs,
|
|
17718
|
+
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
17719
|
+
}, false) ?? (0, any_js_1.parseAnyDef)(refs);
|
|
17720
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
17721
|
+
if (title !== void 0) {
|
|
17722
|
+
main.title = title;
|
|
17723
|
+
}
|
|
17724
|
+
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
17725
|
+
if (!definitions) {
|
|
17726
|
+
definitions = {};
|
|
17727
|
+
}
|
|
17728
|
+
if (!definitions[refs.openAiAnyTypeName]) {
|
|
17729
|
+
definitions[refs.openAiAnyTypeName] = {
|
|
17730
|
+
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
|
|
17731
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
17732
|
+
items: {
|
|
17733
|
+
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
17734
|
+
...refs.basePath,
|
|
17735
|
+
refs.definitionPath,
|
|
17736
|
+
refs.openAiAnyTypeName
|
|
17737
|
+
].join("/")
|
|
17738
|
+
}
|
|
17739
|
+
};
|
|
17740
|
+
}
|
|
17741
|
+
}
|
|
17742
|
+
const combined = name === void 0 ? definitions ? {
|
|
17743
|
+
...main,
|
|
17744
|
+
[refs.definitionPath]: definitions
|
|
17745
|
+
} : main : {
|
|
17746
|
+
$ref: [
|
|
17747
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
17748
|
+
refs.definitionPath,
|
|
17749
|
+
name
|
|
17750
|
+
].join("/"),
|
|
17751
|
+
[refs.definitionPath]: {
|
|
17752
|
+
...definitions,
|
|
17753
|
+
[name]: main
|
|
17754
|
+
}
|
|
17755
|
+
};
|
|
17756
|
+
if (refs.target === "jsonSchema7") {
|
|
17757
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
17758
|
+
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
17759
|
+
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
17760
|
+
}
|
|
17761
|
+
if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
|
|
17762
|
+
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
17763
|
+
}
|
|
17764
|
+
return combined;
|
|
17765
|
+
};
|
|
17766
|
+
exports2.zodToJsonSchema = zodToJsonSchema;
|
|
17767
|
+
}
|
|
17768
|
+
});
|
|
17769
|
+
|
|
17770
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/index.js
|
|
17771
|
+
var require_cjs = __commonJS({
|
|
17772
|
+
"../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@3.25.76/node_modules/zod-to-json-schema/dist/cjs/index.js"(exports2) {
|
|
17773
|
+
"use strict";
|
|
17774
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
17775
|
+
if (k2 === void 0) k2 = k;
|
|
17776
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17777
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17778
|
+
desc = { enumerable: true, get: function() {
|
|
17779
|
+
return m[k];
|
|
17780
|
+
} };
|
|
17781
|
+
}
|
|
17782
|
+
Object.defineProperty(o, k2, desc);
|
|
17783
|
+
}) : (function(o, m, k, k2) {
|
|
17784
|
+
if (k2 === void 0) k2 = k;
|
|
17785
|
+
o[k2] = m[k];
|
|
17786
|
+
}));
|
|
17787
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
17788
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
17789
|
+
};
|
|
17790
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17791
|
+
__exportStar(require_Options(), exports2);
|
|
17792
|
+
__exportStar(require_Refs(), exports2);
|
|
17793
|
+
__exportStar(require_errorMessages(), exports2);
|
|
17794
|
+
__exportStar(require_getRelativePath(), exports2);
|
|
17795
|
+
__exportStar(require_parseDef(), exports2);
|
|
17796
|
+
__exportStar(require_parseTypes(), exports2);
|
|
17797
|
+
__exportStar(require_any(), exports2);
|
|
17798
|
+
__exportStar(require_array(), exports2);
|
|
17799
|
+
__exportStar(require_bigint(), exports2);
|
|
17800
|
+
__exportStar(require_boolean(), exports2);
|
|
17801
|
+
__exportStar(require_branded(), exports2);
|
|
17802
|
+
__exportStar(require_catch(), exports2);
|
|
17803
|
+
__exportStar(require_date(), exports2);
|
|
17804
|
+
__exportStar(require_default(), exports2);
|
|
17805
|
+
__exportStar(require_effects(), exports2);
|
|
17806
|
+
__exportStar(require_enum(), exports2);
|
|
17807
|
+
__exportStar(require_intersection(), exports2);
|
|
17808
|
+
__exportStar(require_literal(), exports2);
|
|
17809
|
+
__exportStar(require_map2(), exports2);
|
|
17810
|
+
__exportStar(require_nativeEnum(), exports2);
|
|
17811
|
+
__exportStar(require_never(), exports2);
|
|
17812
|
+
__exportStar(require_null2(), exports2);
|
|
17813
|
+
__exportStar(require_nullable(), exports2);
|
|
17814
|
+
__exportStar(require_number(), exports2);
|
|
17815
|
+
__exportStar(require_object(), exports2);
|
|
17816
|
+
__exportStar(require_optional(), exports2);
|
|
17817
|
+
__exportStar(require_pipeline(), exports2);
|
|
17818
|
+
__exportStar(require_promise(), exports2);
|
|
17819
|
+
__exportStar(require_readonly(), exports2);
|
|
17820
|
+
__exportStar(require_record(), exports2);
|
|
17821
|
+
__exportStar(require_set2(), exports2);
|
|
17822
|
+
__exportStar(require_string2(), exports2);
|
|
17823
|
+
__exportStar(require_tuple(), exports2);
|
|
17824
|
+
__exportStar(require_undefined(), exports2);
|
|
17825
|
+
__exportStar(require_union(), exports2);
|
|
17826
|
+
__exportStar(require_unknown(), exports2);
|
|
17827
|
+
__exportStar(require_selectParser(), exports2);
|
|
17828
|
+
__exportStar(require_zodToJsonSchema(), exports2);
|
|
17829
|
+
var zodToJsonSchema_js_1 = require_zodToJsonSchema();
|
|
17830
|
+
exports2.default = zodToJsonSchema_js_1.zodToJsonSchema;
|
|
17831
|
+
}
|
|
17832
|
+
});
|
|
17833
|
+
|
|
17834
|
+
// ../../packages/loom/dist/errors.js
|
|
17835
|
+
var require_errors3 = __commonJS({
|
|
17836
|
+
"../../packages/loom/dist/errors.js"(exports2) {
|
|
17837
|
+
"use strict";
|
|
17838
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17839
|
+
exports2.SeedWorkflowsError = exports2.WorkflowBuilderError = void 0;
|
|
17840
|
+
var WorkflowBuilderError = class extends Error {
|
|
17841
|
+
workflowName;
|
|
17842
|
+
nodeName;
|
|
17843
|
+
constructor(workflowName, nodeName, message) {
|
|
17844
|
+
super(message);
|
|
17845
|
+
this.workflowName = workflowName;
|
|
17846
|
+
this.nodeName = nodeName;
|
|
17847
|
+
this.name = "WorkflowBuilderError";
|
|
17848
|
+
}
|
|
17849
|
+
};
|
|
17850
|
+
exports2.WorkflowBuilderError = WorkflowBuilderError;
|
|
17851
|
+
var SeedWorkflowsError = class extends Error {
|
|
17852
|
+
workflowName;
|
|
17853
|
+
cause;
|
|
17854
|
+
constructor(workflowName, message, cause) {
|
|
17855
|
+
super(message);
|
|
17856
|
+
this.workflowName = workflowName;
|
|
17857
|
+
this.cause = cause;
|
|
17858
|
+
this.name = "SeedWorkflowsError";
|
|
17859
|
+
}
|
|
17860
|
+
};
|
|
17861
|
+
exports2.SeedWorkflowsError = SeedWorkflowsError;
|
|
17862
|
+
}
|
|
17863
|
+
});
|
|
17864
|
+
|
|
17865
|
+
// ../../packages/loom/dist/seed/canonicalise.js
|
|
17866
|
+
var require_canonicalise = __commonJS({
|
|
17867
|
+
"../../packages/loom/dist/seed/canonicalise.js"(exports2) {
|
|
17868
|
+
"use strict";
|
|
17869
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
17870
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
17871
|
+
};
|
|
17872
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17873
|
+
exports2.canonicaliseWorkflow = canonicaliseWorkflow;
|
|
17874
|
+
var node_path_1 = __importDefault(require("node:path"));
|
|
17875
|
+
var node_fs_1 = require("node:fs");
|
|
17876
|
+
var zod_to_json_schema_1 = require_cjs();
|
|
17877
|
+
function toJsonSchema(schema) {
|
|
17878
|
+
const result = zod_to_json_schema_1.zodToJsonSchema(schema, { target: "jsonSchema7", $refStrategy: "none" });
|
|
17879
|
+
return result;
|
|
17880
|
+
}
|
|
17881
|
+
var errors_1 = require_errors3();
|
|
17882
|
+
var resolvers_1 = require_resolvers();
|
|
17883
|
+
var transitions_1 = require_transitions();
|
|
17884
|
+
async function canonicaliseWorkflow(workflow, opts) {
|
|
17885
|
+
const nodes = [];
|
|
17886
|
+
for (const node of workflow.nodes) {
|
|
17887
|
+
nodes.push(await canonicaliseNode(workflow, node, opts));
|
|
17888
|
+
}
|
|
17889
|
+
const transitions = (workflow.transitions ?? (0, transitions_1.synthesiseLinearChain)(workflow.nodes)).map((e) => {
|
|
17890
|
+
const out = {
|
|
17891
|
+
from: e.from,
|
|
17892
|
+
to: e.to,
|
|
17893
|
+
resolverKey: null
|
|
17894
|
+
};
|
|
17895
|
+
if (e.artifacts) {
|
|
17896
|
+
out.artifacts = e.artifacts.map((a) => {
|
|
17897
|
+
const serialised = { label: a.label };
|
|
17898
|
+
if (a.format !== void 0)
|
|
17899
|
+
serialised.format = a.format;
|
|
17900
|
+
if (a.outputSchema !== void 0) {
|
|
17901
|
+
serialised.schema = toJsonSchema(a.outputSchema);
|
|
17902
|
+
}
|
|
17903
|
+
return serialised;
|
|
17904
|
+
});
|
|
16026
17905
|
}
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16034
|
-
},
|
|
16035
|
-
|
|
17906
|
+
return out;
|
|
17907
|
+
});
|
|
17908
|
+
return {
|
|
17909
|
+
name: workflow.name,
|
|
17910
|
+
description: workflow.description ?? null,
|
|
17911
|
+
ownerOrgId: opts.ownerOrgId,
|
|
17912
|
+
retainPublishedVersions: workflow.retain?.publishedVersions ?? null,
|
|
17913
|
+
...opts.publish !== void 0 ? { publish: opts.publish } : {},
|
|
17914
|
+
nodes,
|
|
17915
|
+
transitions
|
|
17916
|
+
};
|
|
17917
|
+
}
|
|
17918
|
+
async function canonicaliseNode(workflow, node, opts) {
|
|
17919
|
+
if (node.entryBehavior === "loom.prompt") {
|
|
17920
|
+
const promptOptions = node.promptOptions;
|
|
17921
|
+
if (!promptOptions) {
|
|
17922
|
+
throw new errors_1.WorkflowBuilderError(workflow.name, node.name, "promptNode missing options");
|
|
17923
|
+
}
|
|
17924
|
+
const promptDescriptor = (0, resolvers_1.describeJobPoolRef)(promptOptions.jobPool);
|
|
17925
|
+
if (!promptDescriptor) {
|
|
17926
|
+
throw new errors_1.WorkflowBuilderError(workflow.name, node.name, "jobPool must be a substrate-shipped named resolver, literalJobPool(...), or { id } / { name }");
|
|
17927
|
+
}
|
|
17928
|
+
const templateResolved = node_path_1.default.resolve(workflow.__sourcePath, promptOptions.promptTemplate);
|
|
17929
|
+
let templateText;
|
|
16036
17930
|
try {
|
|
16037
|
-
await
|
|
16038
|
-
await opts.observerChain.notify({ kind: "output.submitted", jobId, attendanceId, label: outputLabel, content: parsedContent }, onObserverError);
|
|
16039
|
-
if (response.usage) {
|
|
16040
|
-
await opts.jobsClient.createOutput(jobId, {
|
|
16041
|
-
label: "usage",
|
|
16042
|
-
content: response.usage
|
|
16043
|
-
});
|
|
16044
|
-
await opts.observerChain.notify({ kind: "output.submitted", jobId, attendanceId, label: "usage", content: response.usage }, onObserverError);
|
|
16045
|
-
}
|
|
17931
|
+
templateText = await node_fs_1.promises.readFile(templateResolved, "utf8");
|
|
16046
17932
|
} catch (err) {
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
17933
|
+
throw new errors_1.WorkflowBuilderError(workflow.name, node.name, `failed to read prompt template at ${templateResolved}: ${err instanceof Error ? err.message : String(err)}`);
|
|
17934
|
+
}
|
|
17935
|
+
const outputLabel = promptOptions.outputLabel ?? node.name;
|
|
17936
|
+
const config2 = {
|
|
17937
|
+
jobPoolRef: promptDescriptor,
|
|
17938
|
+
promptTemplate: templateText,
|
|
17939
|
+
promptTemplatePath: promptOptions.promptTemplate,
|
|
17940
|
+
outputSchema: toJsonSchema(promptOptions.outputSchema),
|
|
17941
|
+
outputLabel,
|
|
17942
|
+
rendering: promptOptions.rendering,
|
|
17943
|
+
...promptOptions.maxAttempts !== void 0 ? { maxAttempts: promptOptions.maxAttempts } : {},
|
|
17944
|
+
...promptOptions.deadline !== void 0 ? { deadlineDuration: promptOptions.deadline } : {}
|
|
17945
|
+
};
|
|
17946
|
+
return { ...envelope(node.name, promptOptions), entryBehavior: "loom.prompt", config: config2 };
|
|
17947
|
+
}
|
|
17948
|
+
if (node.entryBehavior === "http.request") {
|
|
17949
|
+
const httpOptions = node.httpOptions;
|
|
17950
|
+
if (!httpOptions) {
|
|
17951
|
+
throw new errors_1.WorkflowBuilderError(workflow.name, node.name, "httpNode missing options");
|
|
17952
|
+
}
|
|
17953
|
+
const env = opts.env ?? {};
|
|
17954
|
+
const config2 = {
|
|
17955
|
+
endpoint: {
|
|
17956
|
+
method: httpOptions.endpoint.method,
|
|
17957
|
+
url: interpolate(httpOptions.endpoint.url, env)
|
|
17958
|
+
},
|
|
17959
|
+
...httpOptions.timeout !== void 0 ? { timeout: httpOptions.timeout } : {},
|
|
17960
|
+
...httpOptions.retryConfig !== void 0 ? { retryConfig: { ...httpOptions.retryConfig } } : {}
|
|
17961
|
+
};
|
|
17962
|
+
return { ...envelope(node.name, httpOptions), entryBehavior: "http.request", config: config2 };
|
|
16051
17963
|
}
|
|
16052
|
-
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
} catch (err) {
|
|
16056
|
-
logger.error("close attendance failed", {
|
|
16057
|
-
jobId,
|
|
16058
|
-
error: err instanceof Error ? err.message : String(err)
|
|
16059
|
-
});
|
|
16060
|
-
}
|
|
16061
|
-
await opts.observerChain.notify({
|
|
16062
|
-
kind: "attendance.closed",
|
|
16063
|
-
jobId,
|
|
16064
|
-
attendanceId,
|
|
16065
|
-
status,
|
|
16066
|
-
...reason !== void 0 ? { reason } : {},
|
|
16067
|
-
totalDurationMs: Date.now() - startedAt
|
|
16068
|
-
}, onObserverError);
|
|
16069
|
-
}
|
|
16070
|
-
function onObserverError(err, observerName, event) {
|
|
16071
|
-
logger.warn("observer threw on non-veto event", {
|
|
16072
|
-
observerName,
|
|
16073
|
-
eventKind: event.kind,
|
|
16074
|
-
error: err instanceof Error ? err.message : String(err)
|
|
16075
|
-
});
|
|
17964
|
+
const jobsCreateOptions = node.jobsCreateOptions;
|
|
17965
|
+
if (!jobsCreateOptions) {
|
|
17966
|
+
throw new errors_1.WorkflowBuilderError(workflow.name, node.name, "jobsCreateNode missing options");
|
|
16076
17967
|
}
|
|
16077
|
-
|
|
16078
|
-
|
|
16079
|
-
|
|
16080
|
-
for (const executor of byCapability.values()) {
|
|
16081
|
-
if (executor.capability.jobTypes.includes(jobType))
|
|
16082
|
-
return executor;
|
|
17968
|
+
const jobPoolDescriptor = (0, resolvers_1.describeJobPoolRef)(jobsCreateOptions.jobPool);
|
|
17969
|
+
if (!jobPoolDescriptor) {
|
|
17970
|
+
throw new errors_1.WorkflowBuilderError(workflow.name, node.name, "jobPool must be a substrate-shipped named resolver, literalJobPool(...), or { id } / { name }");
|
|
16083
17971
|
}
|
|
16084
|
-
|
|
17972
|
+
const config = {
|
|
17973
|
+
jobPoolRef: jobPoolDescriptor,
|
|
17974
|
+
inputs: { ...jobsCreateOptions.inputs },
|
|
17975
|
+
...jobsCreateOptions.maxAttempts !== void 0 ? { maxAttempts: jobsCreateOptions.maxAttempts } : {},
|
|
17976
|
+
...jobsCreateOptions.deadline !== void 0 ? { deadlineDuration: jobsCreateOptions.deadline } : {}
|
|
17977
|
+
};
|
|
17978
|
+
return { ...envelope(node.name, jobsCreateOptions), entryBehavior: "jobs.create", config };
|
|
16085
17979
|
}
|
|
16086
|
-
function
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16096
|
-
function pickCostCapHint(spec) {
|
|
16097
|
-
const hint = spec.costCapHint;
|
|
16098
|
-
if (!hint)
|
|
16099
|
-
return {};
|
|
16100
|
-
const result = {};
|
|
16101
|
-
if (typeof hint.estimatedInputTokens === "number")
|
|
16102
|
-
result.inputTokens = hint.estimatedInputTokens;
|
|
16103
|
-
if (typeof hint.estimatedOutputTokens === "number")
|
|
16104
|
-
result.outputTokens = hint.estimatedOutputTokens;
|
|
16105
|
-
return result;
|
|
17980
|
+
function envelope(name, options) {
|
|
17981
|
+
return {
|
|
17982
|
+
name,
|
|
17983
|
+
...options.description !== void 0 ? { description: options.description } : {},
|
|
17984
|
+
...options.transition !== void 0 ? {
|
|
17985
|
+
transitionResolver: options.transition.resolver,
|
|
17986
|
+
transitionContext: extractTransitionContext(options.transition)
|
|
17987
|
+
} : {},
|
|
17988
|
+
...options.qualityGates !== void 0 ? { qualityGates: serialiseQualityGates(options.qualityGates) } : {}
|
|
17989
|
+
};
|
|
16106
17990
|
}
|
|
16107
|
-
function
|
|
16108
|
-
|
|
16109
|
-
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
}
|
|
17991
|
+
function interpolate(value, env) {
|
|
17992
|
+
return value.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/g, (_match, name) => {
|
|
17993
|
+
if (Object.prototype.hasOwnProperty.call(env, name))
|
|
17994
|
+
return env[name];
|
|
17995
|
+
throw new Error(`seedWorkflows: missing env var "${name}" referenced in automation endpoint URL`);
|
|
17996
|
+
});
|
|
16114
17997
|
}
|
|
16115
|
-
function
|
|
16116
|
-
|
|
17998
|
+
function extractTransitionContext(tr) {
|
|
17999
|
+
const out = {};
|
|
18000
|
+
if (tr.to)
|
|
18001
|
+
out.to = tr.to;
|
|
18002
|
+
if (tr.rules)
|
|
18003
|
+
out.rules = tr.rules;
|
|
18004
|
+
return out;
|
|
18005
|
+
}
|
|
18006
|
+
function serialiseQualityGates(gates) {
|
|
18007
|
+
return gates.map((group) => ({
|
|
18008
|
+
group: group.group,
|
|
18009
|
+
gates: group.gates.map((g) => {
|
|
18010
|
+
if (g.strategy === "artifact_check") {
|
|
18011
|
+
return {
|
|
18012
|
+
name: g.name,
|
|
18013
|
+
strategy: "artifact_check",
|
|
18014
|
+
outputLabel: g.outputLabel,
|
|
18015
|
+
outputSchema: toJsonSchema(g.outputSchema)
|
|
18016
|
+
};
|
|
18017
|
+
}
|
|
18018
|
+
if (g.strategy === "webhook") {
|
|
18019
|
+
return {
|
|
18020
|
+
name: g.name,
|
|
18021
|
+
strategy: "webhook",
|
|
18022
|
+
url: g.url,
|
|
18023
|
+
...g.timeout !== void 0 ? { timeout: g.timeout } : {},
|
|
18024
|
+
...g.expectedStatus !== void 0 ? { expectedStatus: g.expectedStatus } : {}
|
|
18025
|
+
};
|
|
18026
|
+
}
|
|
18027
|
+
const descriptor = (0, resolvers_1.describeJobPoolRef)(g.jobPool);
|
|
18028
|
+
return {
|
|
18029
|
+
name: g.name,
|
|
18030
|
+
strategy: "job",
|
|
18031
|
+
jobPool: descriptor,
|
|
18032
|
+
...g.instructions !== void 0 ? { instructions: g.instructions } : {},
|
|
18033
|
+
passCondition: g.passCondition
|
|
18034
|
+
};
|
|
18035
|
+
})
|
|
18036
|
+
}));
|
|
16117
18037
|
}
|
|
16118
18038
|
}
|
|
16119
18039
|
});
|
|
16120
18040
|
|
|
16121
|
-
// ../../packages/
|
|
16122
|
-
var
|
|
16123
|
-
"../../packages/
|
|
18041
|
+
// ../../packages/loom/dist/seed/seed-workflows.js
|
|
18042
|
+
var require_seed_workflows = __commonJS({
|
|
18043
|
+
"../../packages/loom/dist/seed/seed-workflows.js"(exports2) {
|
|
16124
18044
|
"use strict";
|
|
16125
18045
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16126
|
-
exports2.
|
|
16127
|
-
var
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
18046
|
+
exports2.seedWorkflows = seedWorkflows;
|
|
18047
|
+
var canonicalise_1 = require_canonicalise();
|
|
18048
|
+
var errors_1 = require_errors3();
|
|
18049
|
+
var NULL_LOGGER = {
|
|
18050
|
+
info: () => {
|
|
18051
|
+
},
|
|
18052
|
+
warn: () => {
|
|
18053
|
+
},
|
|
18054
|
+
error: () => {
|
|
18055
|
+
}
|
|
18056
|
+
};
|
|
18057
|
+
async function seedWorkflows(opts) {
|
|
18058
|
+
const logger = opts.logger ?? NULL_LOGGER;
|
|
18059
|
+
const fetchFn = opts.fetchFn ?? fetch;
|
|
18060
|
+
const baseUrl = opts.loomApiUrl.replace(/\/$/, "");
|
|
18061
|
+
const headers = { "Content-Type": "application/json" };
|
|
18062
|
+
if ("accessToken" in opts.auth) {
|
|
18063
|
+
headers["Authorization"] = `Bearer ${opts.auth.accessToken}`;
|
|
18064
|
+
} else {
|
|
18065
|
+
headers["X-API-Key"] = opts.auth.apiKey;
|
|
18066
|
+
}
|
|
18067
|
+
const results = [];
|
|
18068
|
+
for (const workflow of opts.workflows) {
|
|
18069
|
+
const ownerOrgId = opts.ownerSlugToOrgId[workflow.owner.slug];
|
|
18070
|
+
if (ownerOrgId === void 0) {
|
|
18071
|
+
throw new errors_1.SeedWorkflowsError(workflow.name, `seedWorkflows: owner.slug "${workflow.owner.slug}" not present in ownerSlugToOrgId map`);
|
|
18072
|
+
}
|
|
18073
|
+
const opts2 = { ownerOrgId };
|
|
18074
|
+
if (opts.env !== void 0)
|
|
18075
|
+
opts2.env = opts.env;
|
|
18076
|
+
if (opts.publish !== void 0)
|
|
18077
|
+
opts2.publish = opts.publish;
|
|
18078
|
+
const body = await (0, canonicalise_1.canonicaliseWorkflow)(workflow, opts2);
|
|
18079
|
+
logger.info(`seeding workflow ${workflow.name}`, {
|
|
18080
|
+
ownerOrgId,
|
|
18081
|
+
nodes: body.nodes.length,
|
|
18082
|
+
transitions: body.transitions.length
|
|
18083
|
+
});
|
|
18084
|
+
const response = await fetchFn(`${baseUrl}/api/admin/seed-workflow`, {
|
|
18085
|
+
method: "POST",
|
|
18086
|
+
headers,
|
|
18087
|
+
body: JSON.stringify(body)
|
|
18088
|
+
});
|
|
18089
|
+
const json = await response.json();
|
|
18090
|
+
if (!response.ok || !json.success || !json.data) {
|
|
18091
|
+
const message = json.error?.message ?? `seedWorkflows: ${workflow.name} failed with HTTP ${response.status}`;
|
|
18092
|
+
throw new errors_1.SeedWorkflowsError(workflow.name, message);
|
|
18093
|
+
}
|
|
18094
|
+
results.push(json.data);
|
|
18095
|
+
}
|
|
18096
|
+
return { workflows: results };
|
|
18097
|
+
}
|
|
18098
|
+
}
|
|
18099
|
+
});
|
|
18100
|
+
|
|
18101
|
+
// ../../packages/loom/dist/index.js
|
|
18102
|
+
var require_dist3 = __commonJS({
|
|
18103
|
+
"../../packages/loom/dist/index.js"(exports2) {
|
|
18104
|
+
"use strict";
|
|
18105
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
18106
|
+
if (k2 === void 0) k2 = k;
|
|
18107
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18108
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18109
|
+
desc = { enumerable: true, get: function() {
|
|
18110
|
+
return m[k];
|
|
18111
|
+
} };
|
|
18112
|
+
}
|
|
18113
|
+
Object.defineProperty(o, k2, desc);
|
|
18114
|
+
}) : (function(o, m, k, k2) {
|
|
18115
|
+
if (k2 === void 0) k2 = k;
|
|
18116
|
+
o[k2] = m[k];
|
|
18117
|
+
}));
|
|
18118
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
18119
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
18120
|
+
};
|
|
18121
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18122
|
+
exports2.SeedWorkflowsError = exports2.WorkflowBuilderError = exports2.seedWorkflows = exports2.canonicaliseWorkflow = exports2.synthesiseLinearChain = exports2.describeJobPoolRef = exports2.literalJobPool = exports2.principalJobPool = exports2.jobsCreateNode = exports2.httpNode = exports2.promptNode = exports2.defineWorkflow = exports2.buildPromptExecutionInputs = void 0;
|
|
18123
|
+
__exportStar(require_runtime(), exports2);
|
|
18124
|
+
var prompt_execution_1 = require_prompt_execution2();
|
|
16132
18125
|
Object.defineProperty(exports2, "buildPromptExecutionInputs", { enumerable: true, get: function() {
|
|
16133
18126
|
return prompt_execution_1.buildPromptExecutionInputs;
|
|
16134
18127
|
} });
|
|
16135
|
-
|
|
16136
|
-
|
|
18128
|
+
var define_workflow_1 = require_define_workflow();
|
|
18129
|
+
Object.defineProperty(exports2, "defineWorkflow", { enumerable: true, get: function() {
|
|
18130
|
+
return define_workflow_1.defineWorkflow;
|
|
16137
18131
|
} });
|
|
16138
|
-
|
|
16139
|
-
|
|
18132
|
+
var nodes_1 = require_nodes();
|
|
18133
|
+
Object.defineProperty(exports2, "promptNode", { enumerable: true, get: function() {
|
|
18134
|
+
return nodes_1.promptNode;
|
|
16140
18135
|
} });
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
return prompt_execution_render_1.renderPromptExecution;
|
|
18136
|
+
Object.defineProperty(exports2, "httpNode", { enumerable: true, get: function() {
|
|
18137
|
+
return nodes_1.httpNode;
|
|
16144
18138
|
} });
|
|
16145
|
-
Object.defineProperty(exports2, "
|
|
16146
|
-
return
|
|
18139
|
+
Object.defineProperty(exports2, "jobsCreateNode", { enumerable: true, get: function() {
|
|
18140
|
+
return nodes_1.jobsCreateNode;
|
|
16147
18141
|
} });
|
|
16148
|
-
var
|
|
16149
|
-
Object.defineProperty(exports2, "
|
|
16150
|
-
return
|
|
18142
|
+
var resolvers_1 = require_resolvers();
|
|
18143
|
+
Object.defineProperty(exports2, "principalJobPool", { enumerable: true, get: function() {
|
|
18144
|
+
return resolvers_1.principalJobPool;
|
|
16151
18145
|
} });
|
|
16152
|
-
Object.defineProperty(exports2, "
|
|
16153
|
-
return
|
|
18146
|
+
Object.defineProperty(exports2, "literalJobPool", { enumerable: true, get: function() {
|
|
18147
|
+
return resolvers_1.literalJobPool;
|
|
16154
18148
|
} });
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
18149
|
+
Object.defineProperty(exports2, "describeJobPoolRef", { enumerable: true, get: function() {
|
|
18150
|
+
return resolvers_1.describeJobPoolRef;
|
|
18151
|
+
} });
|
|
18152
|
+
var transitions_1 = require_transitions();
|
|
18153
|
+
Object.defineProperty(exports2, "synthesiseLinearChain", { enumerable: true, get: function() {
|
|
18154
|
+
return transitions_1.synthesiseLinearChain;
|
|
18155
|
+
} });
|
|
18156
|
+
var canonicalise_1 = require_canonicalise();
|
|
18157
|
+
Object.defineProperty(exports2, "canonicaliseWorkflow", { enumerable: true, get: function() {
|
|
18158
|
+
return canonicalise_1.canonicaliseWorkflow;
|
|
18159
|
+
} });
|
|
18160
|
+
var seed_workflows_1 = require_seed_workflows();
|
|
18161
|
+
Object.defineProperty(exports2, "seedWorkflows", { enumerable: true, get: function() {
|
|
18162
|
+
return seed_workflows_1.seedWorkflows;
|
|
18163
|
+
} });
|
|
18164
|
+
var errors_1 = require_errors3();
|
|
18165
|
+
Object.defineProperty(exports2, "WorkflowBuilderError", { enumerable: true, get: function() {
|
|
18166
|
+
return errors_1.WorkflowBuilderError;
|
|
16158
18167
|
} });
|
|
18168
|
+
Object.defineProperty(exports2, "SeedWorkflowsError", { enumerable: true, get: function() {
|
|
18169
|
+
return errors_1.SeedWorkflowsError;
|
|
18170
|
+
} });
|
|
18171
|
+
}
|
|
18172
|
+
});
|
|
18173
|
+
|
|
18174
|
+
// ../../packages/shuttle/dist/observers/chain.js
|
|
18175
|
+
var require_chain = __commonJS({
|
|
18176
|
+
"../../packages/shuttle/dist/observers/chain.js"(exports2) {
|
|
18177
|
+
"use strict";
|
|
18178
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18179
|
+
exports2.ObserverChain = exports2.SpendCapExceeded = void 0;
|
|
18180
|
+
var SpendCapExceeded = class extends Error {
|
|
18181
|
+
cap;
|
|
18182
|
+
used;
|
|
18183
|
+
limit;
|
|
18184
|
+
constructor(cap, used, limit) {
|
|
18185
|
+
super(`Spend cap "${cap}" exceeded: used ${used}, limit ${limit}`);
|
|
18186
|
+
this.cap = cap;
|
|
18187
|
+
this.used = used;
|
|
18188
|
+
this.limit = limit;
|
|
18189
|
+
this.name = "SpendCapExceeded";
|
|
18190
|
+
}
|
|
18191
|
+
};
|
|
18192
|
+
exports2.SpendCapExceeded = SpendCapExceeded;
|
|
18193
|
+
var VETO_EVENTS = /* @__PURE__ */ new Set(["spend.preflight"]);
|
|
18194
|
+
var ObserverChain = class {
|
|
18195
|
+
observers;
|
|
18196
|
+
constructor(observers = []) {
|
|
18197
|
+
this.observers = observers;
|
|
18198
|
+
}
|
|
18199
|
+
async notify(event, onObserverError) {
|
|
18200
|
+
const isVeto = VETO_EVENTS.has(event.kind);
|
|
18201
|
+
for (const observer of this.observers) {
|
|
18202
|
+
try {
|
|
18203
|
+
await observer.notify(event);
|
|
18204
|
+
} catch (err) {
|
|
18205
|
+
if (isVeto)
|
|
18206
|
+
throw err;
|
|
18207
|
+
if (onObserverError)
|
|
18208
|
+
onObserverError(err, observer.name, event);
|
|
18209
|
+
}
|
|
18210
|
+
}
|
|
18211
|
+
}
|
|
18212
|
+
get size() {
|
|
18213
|
+
return this.observers.length;
|
|
18214
|
+
}
|
|
18215
|
+
};
|
|
18216
|
+
exports2.ObserverChain = ObserverChain;
|
|
16159
18217
|
}
|
|
16160
18218
|
});
|
|
16161
18219
|
|
|
@@ -16306,7 +18364,7 @@ var require_client2 = __commonJS({
|
|
|
16306
18364
|
}
|
|
16307
18365
|
/**
|
|
16308
18366
|
* Bind a role (by name) to a service identity. Pool-scoped bindings
|
|
16309
|
-
* pass `scopeRefs: [{kind: '
|
|
18367
|
+
* pass `scopeRefs: [{kind: 'jobPool', poolId: ...}]`. User-owned
|
|
16310
18368
|
* pools pass `userId` as the structural principal; team/org-owned
|
|
16311
18369
|
* pools pass `teamId`/`orgId`.
|
|
16312
18370
|
*
|
|
@@ -16470,10 +18528,10 @@ var require_agent_token = __commonJS({
|
|
|
16470
18528
|
this.enabled = !!(config.clientId && config.clientSecret && config.keepApiUrl);
|
|
16471
18529
|
this.onResponse = config.onResponse;
|
|
16472
18530
|
}
|
|
16473
|
-
async getToken() {
|
|
18531
|
+
async getToken(forceRefresh = false) {
|
|
16474
18532
|
if (!this.enabled)
|
|
16475
18533
|
return null;
|
|
16476
|
-
if (this.token && Date.now() < this.expiresAt - 3e4) {
|
|
18534
|
+
if (!forceRefresh && this.token && Date.now() < this.expiresAt - 3e4) {
|
|
16477
18535
|
return this.token;
|
|
16478
18536
|
}
|
|
16479
18537
|
if (this.pendingExchange) {
|
|
@@ -16512,7 +18570,7 @@ var require_agent_token = __commonJS({
|
|
|
16512
18570
|
});
|
|
16513
18571
|
|
|
16514
18572
|
// ../../packages/keep/dist/index.js
|
|
16515
|
-
var
|
|
18573
|
+
var require_dist4 = __commonJS({
|
|
16516
18574
|
"../../packages/keep/dist/index.js"(exports2) {
|
|
16517
18575
|
"use strict";
|
|
16518
18576
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -16649,6 +18707,22 @@ var require_registry = __commonJS({
|
|
|
16649
18707
|
}
|
|
16650
18708
|
});
|
|
16651
18709
|
|
|
18710
|
+
// ../../packages/shuttle/dist/executors/validate-output.js
|
|
18711
|
+
var require_validate_output = __commonJS({
|
|
18712
|
+
"../../packages/shuttle/dist/executors/validate-output.js"(exports2) {
|
|
18713
|
+
"use strict";
|
|
18714
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18715
|
+
exports2.assertOutputValid = assertOutputValid;
|
|
18716
|
+
var loom_1 = require_dist3();
|
|
18717
|
+
function assertOutputValid(spec, parsed) {
|
|
18718
|
+
const { valid, errors } = (0, loom_1.validateAgainstSchema)(parsed ?? null, spec.outputSchema);
|
|
18719
|
+
if (!valid) {
|
|
18720
|
+
throw new Error(`prompt-execution output failed schema validation: ${errors.join("; ")}`);
|
|
18721
|
+
}
|
|
18722
|
+
}
|
|
18723
|
+
}
|
|
18724
|
+
});
|
|
18725
|
+
|
|
16652
18726
|
// ../../packages/shuttle/dist/executors/claude-code.js
|
|
16653
18727
|
var require_claude_code = __commonJS({
|
|
16654
18728
|
"../../packages/shuttle/dist/executors/claude-code.js"(exports2) {
|
|
@@ -16656,18 +18730,27 @@ var require_claude_code = __commonJS({
|
|
|
16656
18730
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16657
18731
|
exports2.createClaudeCodeExecutor = createClaudeCodeExecutor;
|
|
16658
18732
|
var child_process_1 = require("child_process");
|
|
18733
|
+
var loom_1 = require_dist3();
|
|
18734
|
+
var validate_output_1 = require_validate_output();
|
|
16659
18735
|
var DEFAULT_TIMEOUT = 6e5;
|
|
16660
18736
|
var ClaudeCodeExecutor = class {
|
|
16661
18737
|
capability;
|
|
18738
|
+
strategies = [loom_1.PROMPT_EXECUTION_STRATEGY];
|
|
16662
18739
|
config;
|
|
16663
18740
|
constructor(config) {
|
|
16664
18741
|
this.config = config;
|
|
16665
|
-
this.capability = {
|
|
16666
|
-
|
|
16667
|
-
|
|
18742
|
+
this.capability = { id: config.capabilityId };
|
|
18743
|
+
}
|
|
18744
|
+
estimate(dispatch) {
|
|
18745
|
+
const spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
18746
|
+
return {
|
|
18747
|
+
inputTokens: spec.costCapHint?.estimatedInputTokens,
|
|
18748
|
+
outputTokens: spec.costCapHint?.estimatedOutputTokens
|
|
16668
18749
|
};
|
|
16669
18750
|
}
|
|
16670
|
-
dispatch
|
|
18751
|
+
execute(dispatch, signal) {
|
|
18752
|
+
const { prompt, spec } = (0, loom_1.renderPromptExecution)(dispatch.inputs);
|
|
18753
|
+
const outputLabel = spec.outputLabel;
|
|
16671
18754
|
return new Promise((resolve, reject) => {
|
|
16672
18755
|
const args = ["--print"];
|
|
16673
18756
|
if (this.config.model)
|
|
@@ -16696,7 +18779,7 @@ var require_claude_code = __commonJS({
|
|
|
16696
18779
|
fn();
|
|
16697
18780
|
};
|
|
16698
18781
|
child.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
16699
|
-
child.stdin.write(
|
|
18782
|
+
child.stdin.write(prompt);
|
|
16700
18783
|
child.stdin.end();
|
|
16701
18784
|
const timeout = this.config.timeout ?? DEFAULT_TIMEOUT;
|
|
16702
18785
|
const timer = setTimeout(() => {
|
|
@@ -16724,9 +18807,12 @@ var require_claude_code = __commonJS({
|
|
|
16724
18807
|
signal.removeEventListener("abort", onAbort);
|
|
16725
18808
|
const stdout = Buffer.concat(stdoutChunks).toString("utf-8");
|
|
16726
18809
|
if (code === 0) {
|
|
18810
|
+
const parsed = safeJsonParse(stdout);
|
|
18811
|
+
(0, validate_output_1.assertOutputValid)(spec, parsed);
|
|
16727
18812
|
settle(() => resolve({
|
|
18813
|
+
outputs: [{ label: outputLabel, content: parsed ?? { raw: stdout } }],
|
|
16728
18814
|
rawText: stdout,
|
|
16729
|
-
parsed
|
|
18815
|
+
parsed,
|
|
16730
18816
|
usage: this.config.model ? { aiProvider: "claude-code", aiModel: this.config.model } : void 0
|
|
16731
18817
|
}));
|
|
16732
18818
|
} else {
|
|
@@ -16784,24 +18870,33 @@ var require_http_api = __commonJS({
|
|
|
16784
18870
|
"use strict";
|
|
16785
18871
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16786
18872
|
exports2.createHttpApiExecutor = createHttpApiExecutor;
|
|
18873
|
+
var loom_1 = require_dist3();
|
|
18874
|
+
var validate_output_1 = require_validate_output();
|
|
16787
18875
|
var DEFAULT_MAX_TOKENS = 4096;
|
|
16788
18876
|
var DEFAULT_TIMEOUT = 12e4;
|
|
16789
18877
|
var HttpApiExecutor = class {
|
|
16790
18878
|
capability;
|
|
18879
|
+
strategies = [loom_1.PROMPT_EXECUTION_STRATEGY];
|
|
16791
18880
|
config;
|
|
16792
18881
|
constructor(config) {
|
|
16793
18882
|
this.config = config;
|
|
16794
|
-
this.capability = {
|
|
16795
|
-
|
|
16796
|
-
|
|
18883
|
+
this.capability = { id: config.capabilityId };
|
|
18884
|
+
}
|
|
18885
|
+
estimate(dispatch) {
|
|
18886
|
+
const spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
18887
|
+
return {
|
|
18888
|
+
inputTokens: spec.costCapHint?.estimatedInputTokens,
|
|
18889
|
+
outputTokens: spec.costCapHint?.estimatedOutputTokens
|
|
16797
18890
|
};
|
|
16798
18891
|
}
|
|
16799
|
-
async dispatch
|
|
18892
|
+
async execute(dispatch, signal) {
|
|
18893
|
+
const { prompt, spec } = (0, loom_1.renderPromptExecution)(dispatch.inputs);
|
|
18894
|
+
const outputLabel = spec.outputLabel;
|
|
16800
18895
|
const isAnthropic = this.config.url.includes("anthropic");
|
|
16801
18896
|
const body = {
|
|
16802
18897
|
model: this.config.model,
|
|
16803
18898
|
max_tokens: this.config.maxTokens,
|
|
16804
|
-
messages: [{ role: "user", content:
|
|
18899
|
+
messages: [{ role: "user", content: prompt }]
|
|
16805
18900
|
};
|
|
16806
18901
|
const timeoutController = new AbortController();
|
|
16807
18902
|
const timer = setTimeout(() => timeoutController.abort(), this.config.timeout);
|
|
@@ -16856,9 +18951,12 @@ var require_http_api = __commonJS({
|
|
|
16856
18951
|
};
|
|
16857
18952
|
}
|
|
16858
18953
|
}
|
|
18954
|
+
const parsed = safeJsonParse(rawText);
|
|
18955
|
+
(0, validate_output_1.assertOutputValid)(spec, parsed);
|
|
16859
18956
|
return {
|
|
18957
|
+
outputs: [{ label: outputLabel, content: parsed ?? { raw: rawText } }],
|
|
16860
18958
|
rawText,
|
|
16861
|
-
parsed
|
|
18959
|
+
parsed,
|
|
16862
18960
|
...usage ? { usage } : {}
|
|
16863
18961
|
};
|
|
16864
18962
|
} finally {
|
|
@@ -16951,8 +19049,10 @@ var require_anthropic_api = __commonJS({
|
|
|
16951
19049
|
"use strict";
|
|
16952
19050
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16953
19051
|
exports2.createAnthropicApiExecutor = createAnthropicApiExecutor;
|
|
16954
|
-
var
|
|
19052
|
+
var loom_1 = require_dist3();
|
|
19053
|
+
var keep_1 = require_dist4();
|
|
16955
19054
|
var env_ref_1 = require_env_ref();
|
|
19055
|
+
var validate_output_1 = require_validate_output();
|
|
16956
19056
|
var DEFAULT_BASE_URL = "https://api.anthropic.com/v1/messages";
|
|
16957
19057
|
var DEFAULT_MODEL = "claude-sonnet-4-6";
|
|
16958
19058
|
var DEFAULT_MAX_TOKENS = 4096;
|
|
@@ -16960,20 +19060,28 @@ var require_anthropic_api = __commonJS({
|
|
|
16960
19060
|
var ANTHROPIC_API_VERSION = "2023-06-01";
|
|
16961
19061
|
var AnthropicApiExecutor = class {
|
|
16962
19062
|
capability;
|
|
19063
|
+
strategies = [loom_1.PROMPT_EXECUTION_STRATEGY];
|
|
16963
19064
|
instance;
|
|
16964
19065
|
constructor(instance) {
|
|
16965
19066
|
this.instance = instance;
|
|
16966
|
-
this.capability = {
|
|
16967
|
-
|
|
16968
|
-
|
|
19067
|
+
this.capability = { id: instance.capabilityId };
|
|
19068
|
+
}
|
|
19069
|
+
estimate(dispatch) {
|
|
19070
|
+
const spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
19071
|
+
return {
|
|
19072
|
+
inputTokens: spec.costCapHint?.estimatedInputTokens,
|
|
19073
|
+
outputTokens: spec.costCapHint?.estimatedOutputTokens
|
|
16969
19074
|
};
|
|
16970
19075
|
}
|
|
16971
|
-
async dispatch
|
|
16972
|
-
const
|
|
19076
|
+
async execute(dispatch, signal) {
|
|
19077
|
+
const { prompt, spec } = (0, loom_1.renderPromptExecution)(dispatch.inputs);
|
|
19078
|
+
const outputLabel = spec.outputLabel;
|
|
19079
|
+
const providerHints = (0, loom_1.pickProviderHints)(spec, this.instance.capabilityId);
|
|
19080
|
+
const apiKey = await this.instance.resolveKey(providerHints);
|
|
16973
19081
|
const body = {
|
|
16974
19082
|
model: this.instance.model,
|
|
16975
19083
|
max_tokens: this.instance.maxTokens,
|
|
16976
|
-
messages: [{ role: "user", content:
|
|
19084
|
+
messages: [{ role: "user", content: prompt }]
|
|
16977
19085
|
};
|
|
16978
19086
|
const timeoutController = new AbortController();
|
|
16979
19087
|
const timer = setTimeout(() => timeoutController.abort(), this.instance.timeoutMs);
|
|
@@ -17010,9 +19118,12 @@ var require_anthropic_api = __commonJS({
|
|
|
17010
19118
|
aiProvider: "anthropic",
|
|
17011
19119
|
aiModel: this.instance.model
|
|
17012
19120
|
} : void 0;
|
|
19121
|
+
const parsed = safeJsonParse(rawText);
|
|
19122
|
+
(0, validate_output_1.assertOutputValid)(spec, parsed);
|
|
17013
19123
|
return {
|
|
19124
|
+
outputs: [{ label: outputLabel, content: parsed ?? { raw: rawText } }],
|
|
17014
19125
|
rawText,
|
|
17015
|
-
parsed
|
|
19126
|
+
parsed,
|
|
17016
19127
|
...usage ? { usage } : {}
|
|
17017
19128
|
};
|
|
17018
19129
|
} finally {
|
|
@@ -17082,8 +19193,8 @@ var require_anthropic_api = __commonJS({
|
|
|
17082
19193
|
const stmFactory = deps.buildServiceTokenManager ?? ((cfg) => new keep_1.ServiceTokenManager(cfg));
|
|
17083
19194
|
const stm = stmFactory({ keepApiUrl, clientId, clientSecret });
|
|
17084
19195
|
const keepClientFactory = deps.buildKeepClient ?? ((cfg) => new keep_1.KeepClient(cfg));
|
|
17085
|
-
return async (
|
|
17086
|
-
const hints =
|
|
19196
|
+
return async (providerHints) => {
|
|
19197
|
+
const hints = providerHints ?? {};
|
|
17087
19198
|
const customerId = typeof hints.customerId === "string" ? hints.customerId : void 0;
|
|
17088
19199
|
if (!customerId) {
|
|
17089
19200
|
throw new Error("AnthropicApiExecutor dynamic-key mode requires providerHints.customerId on every job");
|
|
@@ -17125,18 +19236,34 @@ var require_webhook = __commonJS({
|
|
|
17125
19236
|
"use strict";
|
|
17126
19237
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17127
19238
|
exports2.createWebhookExecutor = createWebhookExecutor;
|
|
19239
|
+
var loom_1 = require_dist3();
|
|
19240
|
+
var validate_output_1 = require_validate_output();
|
|
17128
19241
|
var DEFAULT_TIMEOUT = 3e4;
|
|
17129
19242
|
var WebhookExecutor = class {
|
|
17130
19243
|
capability;
|
|
19244
|
+
strategies = [loom_1.PROMPT_EXECUTION_STRATEGY];
|
|
17131
19245
|
config;
|
|
17132
19246
|
constructor(config) {
|
|
17133
19247
|
this.config = config;
|
|
17134
|
-
this.capability = {
|
|
17135
|
-
|
|
17136
|
-
|
|
19248
|
+
this.capability = { id: config.capabilityId };
|
|
19249
|
+
}
|
|
19250
|
+
estimate(dispatch) {
|
|
19251
|
+
const spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
19252
|
+
return {
|
|
19253
|
+
inputTokens: spec.costCapHint?.estimatedInputTokens,
|
|
19254
|
+
outputTokens: spec.costCapHint?.estimatedOutputTokens
|
|
17137
19255
|
};
|
|
17138
19256
|
}
|
|
17139
|
-
async dispatch
|
|
19257
|
+
async execute(dispatch, signal) {
|
|
19258
|
+
const { prompt, spec, artifacts } = (0, loom_1.renderPromptExecution)(dispatch.inputs);
|
|
19259
|
+
const outputLabel = spec.outputLabel;
|
|
19260
|
+
const request = {
|
|
19261
|
+
prompt,
|
|
19262
|
+
outputSchema: spec.outputSchema,
|
|
19263
|
+
outputLabel,
|
|
19264
|
+
providerHints: (0, loom_1.pickProviderHints)(spec, this.config.capabilityId),
|
|
19265
|
+
artifacts
|
|
19266
|
+
};
|
|
17140
19267
|
const timeoutController = new AbortController();
|
|
17141
19268
|
const timer = setTimeout(() => timeoutController.abort(), this.config.timeout);
|
|
17142
19269
|
function onAbort() {
|
|
@@ -17150,7 +19277,7 @@ var require_webhook = __commonJS({
|
|
|
17150
19277
|
...this.config.headers,
|
|
17151
19278
|
"Content-Type": "application/json"
|
|
17152
19279
|
},
|
|
17153
|
-
body: JSON.stringify(
|
|
19280
|
+
body: JSON.stringify(request),
|
|
17154
19281
|
signal: timeoutController.signal
|
|
17155
19282
|
});
|
|
17156
19283
|
if (!response.ok) {
|
|
@@ -17165,7 +19292,9 @@ var require_webhook = __commonJS({
|
|
|
17165
19292
|
if (!data || typeof data !== "object" || typeof data.rawText !== "string") {
|
|
17166
19293
|
throw new Error('Webhook response missing required "rawText" string field');
|
|
17167
19294
|
}
|
|
19295
|
+
(0, validate_output_1.assertOutputValid)(spec, data.parsed);
|
|
17168
19296
|
return {
|
|
19297
|
+
outputs: [{ label: outputLabel, content: data.parsed ?? { raw: data.rawText } }],
|
|
17169
19298
|
rawText: data.rawText,
|
|
17170
19299
|
parsed: data.parsed,
|
|
17171
19300
|
usage: data.usage
|
|
@@ -17212,18 +19341,34 @@ var require_custom_script = __commonJS({
|
|
|
17212
19341
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17213
19342
|
exports2.createCustomScriptExecutor = createCustomScriptExecutor;
|
|
17214
19343
|
var child_process_1 = require("child_process");
|
|
19344
|
+
var loom_1 = require_dist3();
|
|
19345
|
+
var validate_output_1 = require_validate_output();
|
|
17215
19346
|
var DEFAULT_TIMEOUT = 3e4;
|
|
17216
19347
|
var CustomScriptExecutor = class {
|
|
17217
19348
|
capability;
|
|
19349
|
+
strategies = [loom_1.PROMPT_EXECUTION_STRATEGY];
|
|
17218
19350
|
config;
|
|
17219
19351
|
constructor(config) {
|
|
17220
19352
|
this.config = config;
|
|
17221
|
-
this.capability = {
|
|
17222
|
-
|
|
17223
|
-
|
|
19353
|
+
this.capability = { id: config.capabilityId };
|
|
19354
|
+
}
|
|
19355
|
+
estimate(dispatch) {
|
|
19356
|
+
const spec = (0, loom_1.readPromptExecutionSpec)(dispatch.inputs);
|
|
19357
|
+
return {
|
|
19358
|
+
inputTokens: spec.costCapHint?.estimatedInputTokens,
|
|
19359
|
+
outputTokens: spec.costCapHint?.estimatedOutputTokens
|
|
17224
19360
|
};
|
|
17225
19361
|
}
|
|
17226
|
-
dispatch
|
|
19362
|
+
execute(dispatch, signal) {
|
|
19363
|
+
const { prompt, spec, artifacts } = (0, loom_1.renderPromptExecution)(dispatch.inputs);
|
|
19364
|
+
const outputLabel = spec.outputLabel;
|
|
19365
|
+
const request = {
|
|
19366
|
+
prompt,
|
|
19367
|
+
outputSchema: spec.outputSchema,
|
|
19368
|
+
outputLabel,
|
|
19369
|
+
providerHints: (0, loom_1.pickProviderHints)(spec, this.config.capabilityId),
|
|
19370
|
+
artifacts
|
|
19371
|
+
};
|
|
17227
19372
|
return new Promise((resolve, reject) => {
|
|
17228
19373
|
let child;
|
|
17229
19374
|
try {
|
|
@@ -17244,7 +19389,7 @@ var require_custom_script = __commonJS({
|
|
|
17244
19389
|
fn();
|
|
17245
19390
|
};
|
|
17246
19391
|
child.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
|
|
17247
|
-
child.stdin.write(JSON.stringify(
|
|
19392
|
+
child.stdin.write(JSON.stringify(request));
|
|
17248
19393
|
child.stdin.end();
|
|
17249
19394
|
const timer = setTimeout(() => {
|
|
17250
19395
|
child.kill("SIGTERM");
|
|
@@ -17285,8 +19430,11 @@ var require_custom_script = __commonJS({
|
|
|
17285
19430
|
settle(() => reject(new Error('Custom script output missing "rawText" string')));
|
|
17286
19431
|
return;
|
|
17287
19432
|
}
|
|
19433
|
+
const rawText = parsed.rawText;
|
|
19434
|
+
(0, validate_output_1.assertOutputValid)(spec, parsed.parsed);
|
|
17288
19435
|
settle(() => resolve({
|
|
17289
|
-
|
|
19436
|
+
outputs: [{ label: outputLabel, content: parsed.parsed ?? { raw: rawText } }],
|
|
19437
|
+
rawText,
|
|
17290
19438
|
parsed: parsed.parsed,
|
|
17291
19439
|
usage: parsed.usage
|
|
17292
19440
|
}));
|
|
@@ -17324,16 +19472,6 @@ var require_logger2 = __commonJS({
|
|
|
17324
19472
|
async notify(event) {
|
|
17325
19473
|
const logger = (0, logger_1.getLogger)();
|
|
17326
19474
|
switch (event.kind) {
|
|
17327
|
-
case "job.discovered":
|
|
17328
|
-
logger.debug("Job discovered", {
|
|
17329
|
-
jobId: event.jobId,
|
|
17330
|
-
poolId: event.poolId,
|
|
17331
|
-
attempt: event.attempt
|
|
17332
|
-
});
|
|
17333
|
-
return;
|
|
17334
|
-
case "job.claim.requested":
|
|
17335
|
-
logger.debug("Claim requested", { jobId: event.jobId, poolId: event.poolId });
|
|
17336
|
-
return;
|
|
17337
19475
|
case "job.claimed":
|
|
17338
19476
|
logger.info("Job claimed", {
|
|
17339
19477
|
jobId: event.jobId,
|
|
@@ -17526,7 +19664,7 @@ var require_audit_log = __commonJS({
|
|
|
17526
19664
|
const entry = inFlight.get(event.jobId);
|
|
17527
19665
|
if (entry) {
|
|
17528
19666
|
entry.executor = event.executor;
|
|
17529
|
-
entry.prompt = event.
|
|
19667
|
+
entry.prompt = `strategy:${event.strategy}`;
|
|
17530
19668
|
}
|
|
17531
19669
|
return;
|
|
17532
19670
|
}
|
|
@@ -17633,7 +19771,7 @@ var require_defaults2 = __commonJS({
|
|
|
17633
19771
|
cliBinary: "whittle-shuttle",
|
|
17634
19772
|
packageName: "@whittlelabs/shuttle",
|
|
17635
19773
|
version: "0.1.0",
|
|
17636
|
-
description: "Substrate agent harness for Whittle Jobs
|
|
19774
|
+
description: "Substrate agent harness for Whittle Jobs job pools."
|
|
17637
19775
|
},
|
|
17638
19776
|
paths: {
|
|
17639
19777
|
configDir: "~/.shuttle"
|
|
@@ -17673,9 +19811,9 @@ var require_spend_tracker = __commonJS({
|
|
|
17673
19811
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17674
19812
|
exports2.SpendCapExceeded = void 0;
|
|
17675
19813
|
exports2.createSpendTrackerObserver = createSpendTrackerObserver;
|
|
17676
|
-
var
|
|
19814
|
+
var chain_1 = require_chain();
|
|
17677
19815
|
Object.defineProperty(exports2, "SpendCapExceeded", { enumerable: true, get: function() {
|
|
17678
|
-
return
|
|
19816
|
+
return chain_1.SpendCapExceeded;
|
|
17679
19817
|
} });
|
|
17680
19818
|
var defaults_1 = require_defaults2();
|
|
17681
19819
|
var apply_1 = require_apply();
|
|
@@ -17795,7 +19933,7 @@ var require_spend_tracker = __commonJS({
|
|
|
17795
19933
|
remaining: String(remaining),
|
|
17796
19934
|
unit: "tokens"
|
|
17797
19935
|
});
|
|
17798
|
-
const err = new
|
|
19936
|
+
const err = new chain_1.SpendCapExceeded(`${period}.tokens`, used, cap);
|
|
17799
19937
|
err.message = message;
|
|
17800
19938
|
throw err;
|
|
17801
19939
|
}
|
|
@@ -17810,7 +19948,7 @@ var require_spend_tracker = __commonJS({
|
|
|
17810
19948
|
remaining: String(remaining),
|
|
17811
19949
|
unit: "usd"
|
|
17812
19950
|
});
|
|
17813
|
-
const err = new
|
|
19951
|
+
const err = new chain_1.SpendCapExceeded(`${period}.usd`, used, cap);
|
|
17814
19952
|
err.message = message;
|
|
17815
19953
|
throw err;
|
|
17816
19954
|
}
|
|
@@ -17824,7 +19962,9 @@ var require_shuttle = __commonJS({
|
|
|
17824
19962
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
17825
19963
|
exports2.Shuttle = void 0;
|
|
17826
19964
|
var jobs_1 = require_dist2();
|
|
17827
|
-
var
|
|
19965
|
+
var loom_1 = require_dist3();
|
|
19966
|
+
var chain_1 = require_chain();
|
|
19967
|
+
var keep_1 = require_dist4();
|
|
17828
19968
|
var apply_1 = require_apply();
|
|
17829
19969
|
var version_check_1 = require_version_check();
|
|
17830
19970
|
var logger_1 = require_logger();
|
|
@@ -17878,6 +20018,11 @@ var require_shuttle = __commonJS({
|
|
|
17878
20018
|
const registry = new registry_1.ExecutorRegistry(this.brand.executorAllowlist);
|
|
17879
20019
|
registerBuiltInExecutors(registry, this.brand.executorAllowlist);
|
|
17880
20020
|
const executors = registry.build(this.config.executors);
|
|
20021
|
+
const byStrategy = /* @__PURE__ */ new Map();
|
|
20022
|
+
for (const executor of executors) {
|
|
20023
|
+
for (const strategy of executor.strategies)
|
|
20024
|
+
byStrategy.set(strategy, executor);
|
|
20025
|
+
}
|
|
17881
20026
|
this.spendTracker = (0, spend_tracker_1.createSpendTrackerObserver)(this.brand, paths.spendStateFile);
|
|
17882
20027
|
const observers = [
|
|
17883
20028
|
(0, logger_2.createLoggerObserver)(),
|
|
@@ -17885,7 +20030,76 @@ var require_shuttle = __commonJS({
|
|
|
17885
20030
|
this.spendTracker,
|
|
17886
20031
|
...this.brand.observers ?? []
|
|
17887
20032
|
];
|
|
17888
|
-
const observerChain = new
|
|
20033
|
+
const observerChain = new chain_1.ObserverChain(observers);
|
|
20034
|
+
const onObserverError = (err, observerName, event) => {
|
|
20035
|
+
logger.warn("observer threw on non-veto event", {
|
|
20036
|
+
observerName,
|
|
20037
|
+
eventKind: event.kind,
|
|
20038
|
+
error: err instanceof Error ? err.message : String(err)
|
|
20039
|
+
});
|
|
20040
|
+
};
|
|
20041
|
+
const onJob = async (dispatch, signal) => {
|
|
20042
|
+
const jobId = dispatch.job.id;
|
|
20043
|
+
const attendanceId = dispatch.attendanceId;
|
|
20044
|
+
const startedAt = Date.now();
|
|
20045
|
+
const strategy = (0, loom_1.readShuttleStrategy)(dispatch.inputs) ?? "";
|
|
20046
|
+
const executor = byStrategy.get(strategy);
|
|
20047
|
+
if (!executor) {
|
|
20048
|
+
const reason = `no executor for shuttle strategy "${strategy}"`;
|
|
20049
|
+
await observerChain.notify({ kind: "attendance.closed", jobId, attendanceId, status: "failed", reason, totalDurationMs: Date.now() - startedAt }, onObserverError);
|
|
20050
|
+
return { status: "failed", reason };
|
|
20051
|
+
}
|
|
20052
|
+
await observerChain.notify({
|
|
20053
|
+
kind: "job.claimed",
|
|
20054
|
+
jobId,
|
|
20055
|
+
attendanceId,
|
|
20056
|
+
attempt: dispatch.job.attempt,
|
|
20057
|
+
deadline: dispatch.deadline,
|
|
20058
|
+
claimedAt: dispatch.claimedAt,
|
|
20059
|
+
dispatch
|
|
20060
|
+
}, onObserverError);
|
|
20061
|
+
let estimate = {};
|
|
20062
|
+
if (executor.estimate) {
|
|
20063
|
+
try {
|
|
20064
|
+
estimate = await executor.estimate(dispatch);
|
|
20065
|
+
} catch {
|
|
20066
|
+
}
|
|
20067
|
+
}
|
|
20068
|
+
try {
|
|
20069
|
+
await observerChain.notify({ kind: "spend.preflight", jobId, attendanceId, estimate });
|
|
20070
|
+
} catch (err) {
|
|
20071
|
+
const reason = err instanceof chain_1.SpendCapExceeded ? "refused_over_cap" : `preflight rejected: ${err instanceof Error ? err.message : String(err)}`;
|
|
20072
|
+
await observerChain.notify({ kind: "attendance.closed", jobId, attendanceId, status: "failed", reason, totalDurationMs: Date.now() - startedAt }, onObserverError);
|
|
20073
|
+
return { status: "failed", reason };
|
|
20074
|
+
}
|
|
20075
|
+
await observerChain.notify({ kind: "executor.dispatch.started", jobId, attendanceId, executor: executor.capability.id, strategy }, onObserverError);
|
|
20076
|
+
const dispatchStartedAt = Date.now();
|
|
20077
|
+
let response;
|
|
20078
|
+
try {
|
|
20079
|
+
response = await executor.execute(dispatch, signal);
|
|
20080
|
+
} catch (err) {
|
|
20081
|
+
const reason = `executor failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
20082
|
+
await observerChain.notify({ kind: "attendance.closed", jobId, attendanceId, status: "failed", reason, totalDurationMs: Date.now() - startedAt }, onObserverError);
|
|
20083
|
+
return { status: "failed", reason };
|
|
20084
|
+
}
|
|
20085
|
+
await observerChain.notify({
|
|
20086
|
+
kind: "executor.dispatch.completed",
|
|
20087
|
+
jobId,
|
|
20088
|
+
attendanceId,
|
|
20089
|
+
executor: executor.capability.id,
|
|
20090
|
+
response: { rawText: response.rawText ?? "", parsed: response.parsed, usage: response.usage },
|
|
20091
|
+
durationMs: Date.now() - dispatchStartedAt
|
|
20092
|
+
}, onObserverError);
|
|
20093
|
+
const outputs = [...response.outputs];
|
|
20094
|
+
if (response.usage) {
|
|
20095
|
+
outputs.push({ label: "usage", content: response.usage });
|
|
20096
|
+
}
|
|
20097
|
+
for (const output of outputs) {
|
|
20098
|
+
await observerChain.notify({ kind: "output.submitted", jobId, attendanceId, label: output.label, content: output.content }, onObserverError);
|
|
20099
|
+
}
|
|
20100
|
+
await observerChain.notify({ kind: "attendance.closed", jobId, attendanceId, status: "completed", totalDurationMs: Date.now() - startedAt }, onObserverError);
|
|
20101
|
+
return { status: "completed", outputs };
|
|
20102
|
+
};
|
|
17889
20103
|
const pools = this.config.pools.map((p) => p.id ? { id: p.id } : { name: p.name });
|
|
17890
20104
|
this.subscription = (0, jobs_1.subscribe)({
|
|
17891
20105
|
jobsClient,
|
|
@@ -17894,12 +20108,10 @@ var require_shuttle = __commonJS({
|
|
|
17894
20108
|
identityType: "agent",
|
|
17895
20109
|
identityId: this.config.agent.identityId,
|
|
17896
20110
|
intelligence: "digital",
|
|
17897
|
-
capabilities: [...this.brand.executorAllowlist].filter((c) => c !== "*"),
|
|
17898
20111
|
displayName: this.config.agent.displayName,
|
|
17899
20112
|
metadata: this.config.agent.metadata
|
|
17900
20113
|
},
|
|
17901
|
-
|
|
17902
|
-
observerChain,
|
|
20114
|
+
onJob,
|
|
17903
20115
|
logger: {
|
|
17904
20116
|
debug: (msg, meta) => logger.debug(msg, meta),
|
|
17905
20117
|
info: (msg, meta) => logger.info(msg, meta),
|
|
@@ -17954,8 +20166,12 @@ var require_shuttle = __commonJS({
|
|
|
17954
20166
|
onResponse
|
|
17955
20167
|
});
|
|
17956
20168
|
const token = await tokens.getToken();
|
|
17957
|
-
if (token)
|
|
17958
|
-
return {
|
|
20169
|
+
if (token) {
|
|
20170
|
+
return {
|
|
20171
|
+
kind: "tokenProvider",
|
|
20172
|
+
getToken: (opts) => tokens.getToken(opts?.forceRefresh)
|
|
20173
|
+
};
|
|
20174
|
+
}
|
|
17959
20175
|
}
|
|
17960
20176
|
if (config.auth.apiKey) {
|
|
17961
20177
|
return { kind: "apiKey", apiKey: config.auth.apiKey };
|
|
@@ -18031,7 +20247,7 @@ var require_run = __commonJS({
|
|
|
18031
20247
|
});
|
|
18032
20248
|
|
|
18033
20249
|
// ../../packages/shuttle/dist/cli/validate.js
|
|
18034
|
-
var
|
|
20250
|
+
var require_validate2 = __commonJS({
|
|
18035
20251
|
"../../packages/shuttle/dist/cli/validate.js"(exports2) {
|
|
18036
20252
|
"use strict";
|
|
18037
20253
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -18249,7 +20465,7 @@ var require_list = __commonJS({
|
|
|
18249
20465
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18250
20466
|
exports2.buildListCommand = buildListCommand;
|
|
18251
20467
|
var commander_1 = require_commander();
|
|
18252
|
-
var keep_1 =
|
|
20468
|
+
var keep_1 = require_dist4();
|
|
18253
20469
|
var apply_1 = require_apply();
|
|
18254
20470
|
var store_1 = require_store();
|
|
18255
20471
|
var pairings_1 = require_pairings();
|
|
@@ -18294,7 +20510,7 @@ var require_revoke = __commonJS({
|
|
|
18294
20510
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
18295
20511
|
exports2.buildRevokeCommand = buildRevokeCommand;
|
|
18296
20512
|
var commander_1 = require_commander();
|
|
18297
|
-
var keep_1 =
|
|
20513
|
+
var keep_1 = require_dist4();
|
|
18298
20514
|
var apply_1 = require_apply();
|
|
18299
20515
|
var store_1 = require_store();
|
|
18300
20516
|
var pairings_1 = require_pairings();
|
|
@@ -18342,7 +20558,7 @@ var require_cli = __commonJS({
|
|
|
18342
20558
|
var commander_1 = require_commander();
|
|
18343
20559
|
var init_1 = require_init();
|
|
18344
20560
|
var run_1 = require_run();
|
|
18345
|
-
var validate_1 =
|
|
20561
|
+
var validate_1 = require_validate2();
|
|
18346
20562
|
var audit_1 = require_audit();
|
|
18347
20563
|
var caps_1 = require_caps();
|
|
18348
20564
|
var list_1 = require_list();
|
|
@@ -18363,7 +20579,7 @@ var require_cli = __commonJS({
|
|
|
18363
20579
|
});
|
|
18364
20580
|
|
|
18365
20581
|
// ../../packages/shuttle/dist/index.js
|
|
18366
|
-
var
|
|
20582
|
+
var require_dist5 = __commonJS({
|
|
18367
20583
|
"../../packages/shuttle/dist/index.js"(exports2) {
|
|
18368
20584
|
"use strict";
|
|
18369
20585
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -18413,12 +20629,12 @@ var require_dist4 = __commonJS({
|
|
|
18413
20629
|
Object.defineProperty(exports2, "createCustomScriptExecutor", { enumerable: true, get: function() {
|
|
18414
20630
|
return custom_script_1.createCustomScriptExecutor;
|
|
18415
20631
|
} });
|
|
18416
|
-
var
|
|
20632
|
+
var chain_1 = require_chain();
|
|
18417
20633
|
Object.defineProperty(exports2, "ObserverChain", { enumerable: true, get: function() {
|
|
18418
|
-
return
|
|
20634
|
+
return chain_1.ObserverChain;
|
|
18419
20635
|
} });
|
|
18420
20636
|
Object.defineProperty(exports2, "SpendCapExceeded", { enumerable: true, get: function() {
|
|
18421
|
-
return
|
|
20637
|
+
return chain_1.SpendCapExceeded;
|
|
18422
20638
|
} });
|
|
18423
20639
|
var logger_1 = require_logger2();
|
|
18424
20640
|
Object.defineProperty(exports2, "createLoggerObserver", { enumerable: true, get: function() {
|
|
@@ -18482,20 +20698,20 @@ var require_dist4 = __commonJS({
|
|
|
18482
20698
|
});
|
|
18483
20699
|
|
|
18484
20700
|
// src/bin.ts
|
|
18485
|
-
var import_shuttle2 = __toESM(
|
|
20701
|
+
var import_shuttle2 = __toESM(require_dist5());
|
|
18486
20702
|
|
|
18487
20703
|
// src/brand.ts
|
|
18488
20704
|
var import_path = require("path");
|
|
18489
20705
|
var import_promises = require("fs/promises");
|
|
18490
20706
|
var import_readline = require("readline");
|
|
18491
20707
|
var import_yaml = __toESM(require_dist());
|
|
18492
|
-
var import_shuttle = __toESM(
|
|
20708
|
+
var import_shuttle = __toESM(require_dist5());
|
|
18493
20709
|
|
|
18494
20710
|
// package.json
|
|
18495
20711
|
var package_default = {
|
|
18496
20712
|
name: "@whittlelabs/sifter",
|
|
18497
|
-
version: "0.
|
|
18498
|
-
description: "Whittle Sifter: paired AI reviewer for Whittle Sift
|
|
20713
|
+
version: "0.5.0",
|
|
20714
|
+
description: "Whittle Sifter: paired AI reviewer for Whittle Sift job pools.",
|
|
18499
20715
|
bin: {
|
|
18500
20716
|
"whittle-sifter": "./dist/bin.js"
|
|
18501
20717
|
},
|
|
@@ -18587,9 +20803,9 @@ var sifterBrand = {
|
|
|
18587
20803
|
run: async (ctx) => {
|
|
18588
20804
|
const yamlPath = (0, import_path.join)(ctx.configDir, "sifter.yaml");
|
|
18589
20805
|
const pairing = new import_shuttle.PairingConfigStore((0, import_path.join)(ctx.configDir, "config.json")).read();
|
|
18590
|
-
if (pairing.
|
|
20806
|
+
if (pairing.jobPools.length === 0) {
|
|
18591
20807
|
throw new Error(
|
|
18592
|
-
"Pairing returned no
|
|
20808
|
+
"Pairing returned no job pools. The Sift backend should have provisioned one for this user during pre-pair."
|
|
18593
20809
|
);
|
|
18594
20810
|
}
|
|
18595
20811
|
let existing = {};
|
|
@@ -18612,7 +20828,7 @@ var sifterBrand = {
|
|
|
18612
20828
|
displayName: pairing.serviceIdentity.displayName,
|
|
18613
20829
|
identityId: pairing.serviceIdentity.id
|
|
18614
20830
|
},
|
|
18615
|
-
pools: pairing.
|
|
20831
|
+
pools: pairing.jobPools.map((p) => ({
|
|
18616
20832
|
id: p.id,
|
|
18617
20833
|
name: p.name,
|
|
18618
20834
|
executor
|