@clickraft/cli 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -5,11 +5,11 @@ import { readFileSync } from "fs";
5
5
  import { dirname as dirname2, join as join2 } from "path";
6
6
  import { fileURLToPath } from "url";
7
7
 
8
- // src/api/client.ts
9
- import { request as undiciRequest } from "undici";
8
+ // ../sdk/dist/index.js
9
+ import { z } from "zod";
10
10
  import { z as z2 } from "zod";
11
-
12
- // src/auth/redact.ts
11
+ import { z as z3 } from "zod";
12
+ import { z as z4 } from "zod";
13
13
  var TOKEN_FIELD_PATTERN = /"(access_token|refresh_token|device_code|user_code|code_verifier|client_secret)"\s*:\s*"[^"]*"/gi;
14
14
  var BARE_TOKEN_PATTERN = /\bck_(?:live|dev|test)_[A-Za-z0-9_-]+/gi;
15
15
  function redactTokenLikeFields(input) {
@@ -20,6 +20,192 @@ function redactTokenLikeValue(token) {
20
20
  if (token.length <= 12) return "[REDACTED]";
21
21
  return `${token.slice(0, 8)}...[REDACTED]`;
22
22
  }
23
+ var BalanceResponseSchema = z.object({
24
+ totalCredits: z.number(),
25
+ subscriptionCredits: z.number(),
26
+ purchasedCredits: z.number(),
27
+ promotionalCredits: z.number(),
28
+ rateLimit: z.object({
29
+ apiBurstPerMinute: z.number()
30
+ }).strict()
31
+ }).strict();
32
+ var BrandModelSummarySchema = z2.object({
33
+ id: z2.string().uuid(),
34
+ source: z2.enum(["system", "user"]),
35
+ slug: z2.string().nullable(),
36
+ name: z2.string(),
37
+ description: z2.string().nullable(),
38
+ thumbnailUrl: z2.string().nullable(),
39
+ tags: z2.array(z2.string()),
40
+ category: z2.string().nullable(),
41
+ isPremium: z2.boolean().nullable(),
42
+ isFeatured: z2.boolean().nullable(),
43
+ badgeText: z2.string().nullable(),
44
+ usageCount: z2.number().nullable(),
45
+ createdAt: z2.string()
46
+ }).strict();
47
+ var BrandModelsListResponseSchema = z2.object({
48
+ brandModels: z2.array(BrandModelSummarySchema)
49
+ }).strict();
50
+ var ProductImageSummarySchema = z3.object({
51
+ id: z3.string().uuid(),
52
+ url: z3.string(),
53
+ altText: z3.string().nullable(),
54
+ isPrimary: z3.boolean(),
55
+ sortOrder: z3.number().int()
56
+ });
57
+ var ProductSummarySchema = z3.object({
58
+ id: z3.string().uuid(),
59
+ title: z3.string(),
60
+ sourceType: z3.string(),
61
+ syncStatus: z3.enum(["synced", "pending", "stale", "error", "deleted_upstream"]).nullable(),
62
+ vendor: z3.string().nullable(),
63
+ productType: z3.string().nullable(),
64
+ tags: z3.array(z3.string()),
65
+ images: z3.array(ProductImageSummarySchema)
66
+ });
67
+ var ProductsListResponseSchema = z3.object({
68
+ items: z3.array(ProductSummarySchema),
69
+ nextCursor: z3.string().nullable()
70
+ });
71
+ var TokenRowSchema = z4.object({
72
+ id: z4.string().uuid(),
73
+ organizationId: z4.string().uuid(),
74
+ userId: z4.string().uuid(),
75
+ clientId: z4.string().nullable(),
76
+ tokenPrefix: z4.string(),
77
+ name: z4.string().nullable(),
78
+ scopes: z4.array(z4.string()),
79
+ lastUsedAt: z4.string().nullable(),
80
+ expiresAt: z4.string(),
81
+ createdAt: z4.string()
82
+ }).strict();
83
+ var TokensListResponseSchema = z4.array(TokenRowSchema);
84
+ var SERVER_ERROR_CODES = [
85
+ "AUTH_TOKEN_MISSING",
86
+ "AUTH_TOKEN_INVALID",
87
+ "AUTH_TOKEN_EXPIRED",
88
+ "AUTH_TOKEN_REVOKED",
89
+ "AUTH_TOKEN_SCOPE_INSUFFICIENT",
90
+ "AUTH_ORG_MISMATCH",
91
+ "AUTH_DEVICE_CODE_PENDING",
92
+ "AUTH_DEVICE_CODE_EXPIRED",
93
+ "AUTH_DEVICE_CODE_SLOW_DOWN",
94
+ "IDEMPOTENCY_KEY_MISSING",
95
+ "IDEMPOTENCY_KEY_CONFLICT",
96
+ "PLAN_FEATURE_LOCKED",
97
+ "PLAN_QUOTA_EXCEEDED",
98
+ "INSUFFICIENT_CREDITS",
99
+ "CREDIT_DEDUCTION_FAILED",
100
+ "RATE_LIMITED",
101
+ "INPUT_INVALID_FORMAT",
102
+ "INPUT_TOO_LONG",
103
+ "WORKFLOW_VALIDATION_FAILED",
104
+ "WORKFLOW_NODE_TYPE_UNKNOWN",
105
+ "CANVAS_REV_MISMATCH",
106
+ "CANVAS_REV_REQUIRED",
107
+ "WORKER_UNREACHABLE",
108
+ "IDEMPOTENCY_IN_PROGRESS",
109
+ "TOKEN_NAME_INVALID",
110
+ "WORKFLOW_NOT_FOUND",
111
+ "NOT_FOUND",
112
+ "NODE_TYPE_NOT_FOUND",
113
+ "FEATURE_DISABLED",
114
+ "FORBIDDEN",
115
+ "MODEL_NOT_FOUND",
116
+ "PROVIDER_UNAVAILABLE",
117
+ "STORAGE_UPLOAD_FAILED",
118
+ "STORAGE_QUOTA_EXCEEDED",
119
+ "GEN_CONTENT_REFUSAL",
120
+ "GEN_OUTPUT_SCHEMA_MISMATCH",
121
+ "GEN_EMPTY_OUTPUT",
122
+ "GEN_ITEM_COUNT_MISMATCH",
123
+ "AGENT_FINGERPRINT_REJECTED",
124
+ "INTERNAL_ERROR",
125
+ "BRAND_MODEL_NOT_FOUND",
126
+ "BRAND_MODEL_NOT_A_MODEL",
127
+ "BRAND_MODEL_NOT_ACTIVE",
128
+ "BRAND_MODEL_NO_REFERENCES",
129
+ "BRAND_MODEL_POSE_NOT_FOUND",
130
+ "BRAND_MODEL_DUPLICATE_ID",
131
+ "MODEL_DOES_NOT_SUPPORT_REFERENCES",
132
+ "REFERENCE_LIMIT_EXCEEDED",
133
+ "PRODUCT_NOT_FOUND",
134
+ "PRODUCT_DUPLICATE_REFERENCE",
135
+ "PRODUCT_IMAGE_NOT_FOUND",
136
+ "PRODUCT_IMAGE_MISMATCH",
137
+ "PRODUCT_SYNC_ERROR",
138
+ "PRODUCT_DELETED_UPSTREAM",
139
+ "PRODUCT_NO_PRIMARY_IMAGE",
140
+ "PRODUCT_SOURCE_MANAGED"
141
+ ];
142
+ var KNOWN_SERVER_CODES = new Set(SERVER_ERROR_CODES);
143
+ var ApiError = class extends Error {
144
+ code;
145
+ meta;
146
+ cause;
147
+ constructor(code, message, meta, cause) {
148
+ super(message);
149
+ this.name = "ApiError";
150
+ this.code = code;
151
+ this.meta = meta;
152
+ this.cause = cause;
153
+ }
154
+ };
155
+ async function longPoll(opts) {
156
+ const now = opts.now ?? Date.now;
157
+ const started = now();
158
+ for (; ; ) {
159
+ if (opts.signal?.aborted) {
160
+ throw new ApiError("TIMEOUT", "Wait was aborted.", { retryable: true });
161
+ }
162
+ const elapsedBefore = now() - started;
163
+ if (elapsedBefore >= opts.timeoutMs) {
164
+ throw new ApiError(
165
+ "TIMEOUT",
166
+ `Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
167
+ { retryable: true }
168
+ );
169
+ }
170
+ const remainingMs = opts.timeoutMs - elapsedBefore;
171
+ const iterationSignal = composeIterationSignal(opts.signal, remainingMs);
172
+ let result;
173
+ try {
174
+ result = await opts.fetcher({ signal: iterationSignal });
175
+ } catch (err) {
176
+ if (opts.signal?.aborted || now() - started >= opts.timeoutMs) {
177
+ throw new ApiError(
178
+ "TIMEOUT",
179
+ `Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
180
+ { retryable: true }
181
+ );
182
+ }
183
+ throw err;
184
+ }
185
+ if (opts.signal?.aborted) {
186
+ throw new ApiError("TIMEOUT", "Wait was aborted.", { retryable: true });
187
+ }
188
+ const elapsedAfter = now() - started;
189
+ if (elapsedAfter >= opts.timeoutMs) {
190
+ throw new ApiError(
191
+ "TIMEOUT",
192
+ `Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
193
+ { retryable: true }
194
+ );
195
+ }
196
+ if (opts.isTerminal(result)) {
197
+ return result;
198
+ }
199
+ }
200
+ }
201
+ function composeIterationSignal(userSignal, remainingMs) {
202
+ const deadlineSignal = AbortSignal.timeout(Math.max(remainingMs, 0));
203
+ return userSignal ? AbortSignal.any([userSignal, deadlineSignal]) : deadlineSignal;
204
+ }
205
+
206
+ // src/api/client.ts
207
+ import { request as undiciRequest } from "undici";
208
+ import { z as z6 } from "zod";
23
209
 
24
210
  // src/errors/codes.ts
25
211
  var LOGIN_HINT = "Run `clickraft login` to authenticate.";
@@ -433,15 +619,6 @@ var EXIT_CODE_MAP = {
433
619
  hint: "Server response did not match the expected schema. Update the CLI."
434
620
  }
435
621
  };
436
- var CLI_ONLY_CODES = /* @__PURE__ */ new Set([
437
- "NETWORK_ERROR",
438
- "TIMEOUT",
439
- "PARSE_ERROR",
440
- "SCHEMA_MISMATCH"
441
- ]);
442
- var KNOWN_SERVER_CODES = new Set(
443
- Object.keys(EXIT_CODE_MAP).filter((k) => !CLI_ONLY_CODES.has(k))
444
- );
445
622
  function getExitCode(code) {
446
623
  return EXIT_CODE_MAP[code]?.exitCode ?? 1;
447
624
  }
@@ -554,31 +731,19 @@ function signalToAbortError(signal) {
554
731
  }
555
732
 
556
733
  // src/api/types.ts
557
- import { z } from "zod";
558
- var ServerSuccessSchema = (payload) => z.object({ data: payload }).strict();
559
- var ServerErrorBodySchema = z.object({
560
- error: z.object({
561
- code: z.string().min(1),
562
- message: z.string(),
563
- correlationId: z.string().optional(),
564
- retryAfter: z.number().int().nonnegative().optional(),
565
- details: z.unknown().optional()
734
+ import { z as z5 } from "zod";
735
+ var ServerSuccessSchema = (payload) => z5.object({ data: payload }).strict();
736
+ var ServerErrorBodySchema = z5.object({
737
+ error: z5.object({
738
+ code: z5.string().min(1),
739
+ message: z5.string(),
740
+ correlationId: z5.string().optional(),
741
+ retryAfter: z5.number().int().nonnegative().optional(),
742
+ details: z5.unknown().optional()
566
743
  }).strict()
567
744
  }).strict();
568
745
 
569
746
  // src/api/client.ts
570
- var ApiError = class extends Error {
571
- code;
572
- meta;
573
- cause;
574
- constructor(code, message, meta, cause) {
575
- super(message);
576
- this.name = "ApiError";
577
- this.code = code;
578
- this.meta = meta;
579
- this.cause = cause;
580
- }
581
- };
582
747
  var REDACT_BODY_LIMIT = 1024;
583
748
  var REDACT_INPUT_CAP = 100 * 1024;
584
749
  var DEFAULT_USER_AGENT = "clickraft-cli";
@@ -744,7 +909,7 @@ function parseSuccessBody(args) {
744
909
  err
745
910
  );
746
911
  }
747
- const envelope = ServerSuccessSchema(args.responseSchema ?? z2.unknown()).safeParse(parsed);
912
+ const envelope = ServerSuccessSchema(args.responseSchema ?? z6.unknown()).safeParse(parsed);
748
913
  if (!envelope.success) {
749
914
  const issues = formatSchemaIssues(envelope.error);
750
915
  throw new ApiError(
@@ -985,9 +1150,6 @@ function buildPayload(args) {
985
1150
  return payload;
986
1151
  }
987
1152
 
988
- // src/commands/balance.ts
989
- import { z as z4 } from "zod";
990
-
991
1153
  // src/auth/credentials.ts
992
1154
  import {
993
1155
  access,
@@ -1030,31 +1192,31 @@ function getCredentialsPath(ctx = {}) {
1030
1192
  }
1031
1193
 
1032
1194
  // src/auth/types.ts
1033
- import { z as z3 } from "zod";
1034
- var DeviceAuthorizationRequestSchema = z3.object({
1035
- client_id: z3.string(),
1036
- scope: z3.string()
1195
+ import { z as z7 } from "zod";
1196
+ var DeviceAuthorizationRequestSchema = z7.object({
1197
+ client_id: z7.string(),
1198
+ scope: z7.string()
1037
1199
  });
1038
- var DeviceAuthorizationResponseSchema = z3.object({
1039
- device_code: z3.string(),
1040
- user_code: z3.string().min(1),
1041
- verification_uri: z3.string().url(),
1042
- verification_uri_complete: z3.string().url().optional(),
1043
- expires_in: z3.number().int().positive(),
1044
- interval: z3.number().int().positive().default(5)
1200
+ var DeviceAuthorizationResponseSchema = z7.object({
1201
+ device_code: z7.string(),
1202
+ user_code: z7.string().min(1),
1203
+ verification_uri: z7.string().url(),
1204
+ verification_uri_complete: z7.string().url().optional(),
1205
+ expires_in: z7.number().int().positive(),
1206
+ interval: z7.number().int().positive().default(5)
1045
1207
  });
1046
- var DeviceTokenPollRequestSchema = z3.object({
1047
- client_id: z3.string(),
1048
- device_code: z3.string(),
1049
- grant_type: z3.literal("urn:ietf:params:oauth:grant-type:device_code")
1208
+ var DeviceTokenPollRequestSchema = z7.object({
1209
+ client_id: z7.string(),
1210
+ device_code: z7.string(),
1211
+ grant_type: z7.literal("urn:ietf:params:oauth:grant-type:device_code")
1050
1212
  });
1051
- var TokenResponseSchema = z3.object({
1052
- access_token: z3.string(),
1053
- token_type: z3.literal("Bearer"),
1054
- expires_in: z3.number().int().positive(),
1055
- scope: z3.string()
1213
+ var TokenResponseSchema = z7.object({
1214
+ access_token: z7.string(),
1215
+ token_type: z7.literal("Bearer"),
1216
+ expires_in: z7.number().int().positive(),
1217
+ scope: z7.string()
1056
1218
  });
1057
- var DeviceTokenPollErrorCodeSchema = z3.enum([
1219
+ var DeviceTokenPollErrorCodeSchema = z7.enum([
1058
1220
  "authorization_pending",
1059
1221
  "slow_down",
1060
1222
  "access_denied",
@@ -1065,27 +1227,27 @@ var DeviceTokenPollErrorCodeSchema = z3.enum([
1065
1227
  "unsupported_grant_type",
1066
1228
  "invalid_scope"
1067
1229
  ]);
1068
- var DeviceTokenPollErrorSchema = z3.object({
1230
+ var DeviceTokenPollErrorSchema = z7.object({
1069
1231
  error: DeviceTokenPollErrorCodeSchema,
1070
- error_description: z3.string().optional()
1232
+ error_description: z7.string().optional()
1071
1233
  });
1072
- var CredentialsProfileSchema = z3.object({
1073
- apiBaseUrl: z3.string().url(),
1074
- accessToken: z3.string(),
1075
- tokenType: z3.literal("Bearer"),
1076
- tokenPrefix: z3.string(),
1077
- organizationId: z3.string().uuid(),
1078
- organizationSlug: z3.string(),
1079
- userId: z3.string().uuid(),
1080
- scopes: z3.array(z3.string()),
1081
- expiresAt: z3.string().datetime(),
1082
- issuedAt: z3.string().datetime(),
1083
- clientId: z3.string()
1234
+ var CredentialsProfileSchema = z7.object({
1235
+ apiBaseUrl: z7.string().url(),
1236
+ accessToken: z7.string(),
1237
+ tokenType: z7.literal("Bearer"),
1238
+ tokenPrefix: z7.string(),
1239
+ organizationId: z7.string().uuid(),
1240
+ organizationSlug: z7.string(),
1241
+ userId: z7.string().uuid(),
1242
+ scopes: z7.array(z7.string()),
1243
+ expiresAt: z7.string().datetime(),
1244
+ issuedAt: z7.string().datetime(),
1245
+ clientId: z7.string()
1084
1246
  }).strict();
1085
- var CredentialsFileSchema = z3.object({
1086
- version: z3.literal(1),
1087
- defaultProfile: z3.string(),
1088
- profiles: z3.record(z3.string(), CredentialsProfileSchema)
1247
+ var CredentialsFileSchema = z7.object({
1248
+ version: z7.literal(1),
1249
+ defaultProfile: z7.string(),
1250
+ profiles: z7.record(z7.string(), CredentialsProfileSchema)
1089
1251
  }).strict();
1090
1252
 
1091
1253
  // src/auth/credentials.ts
@@ -1318,15 +1480,6 @@ function trim(value) {
1318
1480
  }
1319
1481
 
1320
1482
  // src/commands/balance.ts
1321
- var BalanceResponseSchema = z4.object({
1322
- totalCredits: z4.number(),
1323
- subscriptionCredits: z4.number(),
1324
- purchasedCredits: z4.number(),
1325
- promotionalCredits: z4.number(),
1326
- rateLimit: z4.object({
1327
- apiBurstPerMinute: z4.number()
1328
- }).strict()
1329
- }).strict();
1330
1483
  async function getBalance(options) {
1331
1484
  const config = await loadConfig({
1332
1485
  flagProfile: options.profile,
@@ -1352,25 +1505,7 @@ async function getBalance(options) {
1352
1505
  }
1353
1506
 
1354
1507
  // src/commands/brand-model/list.ts
1355
- import { z as z5 } from "zod";
1356
- var BrandModelSummarySchema = z5.object({
1357
- id: z5.string().uuid(),
1358
- source: z5.enum(["system", "user"]),
1359
- slug: z5.string().nullable(),
1360
- name: z5.string(),
1361
- description: z5.string().nullable(),
1362
- thumbnailUrl: z5.string().nullable(),
1363
- tags: z5.array(z5.string()),
1364
- category: z5.string().nullable(),
1365
- isPremium: z5.boolean().nullable(),
1366
- isFeatured: z5.boolean().nullable(),
1367
- badgeText: z5.string().nullable(),
1368
- usageCount: z5.number().nullable(),
1369
- createdAt: z5.string()
1370
- }).strict();
1371
- var BrandModelsListResponseSchema = z5.object({
1372
- brandModels: z5.array(BrandModelSummarySchema)
1373
- }).strict();
1508
+ import "zod";
1374
1509
  async function listBrandModels(options) {
1375
1510
  const config = await loadConfig({
1376
1511
  flagProfile: options.profile,
@@ -1396,35 +1531,35 @@ async function listBrandModels(options) {
1396
1531
  }
1397
1532
 
1398
1533
  // src/schemas/jobs.ts
1399
- import { z as z6 } from "zod";
1400
- var ProductReferenceSchema = z6.object({
1401
- id: z6.string().uuid(),
1402
- imageId: z6.string().uuid().optional()
1534
+ import { z as z9 } from "zod";
1535
+ var ProductReferenceSchema = z9.object({
1536
+ id: z9.string().uuid(),
1537
+ imageId: z9.string().uuid().optional()
1403
1538
  }).strict();
1404
- var GenerateCreateRequestSchema = z6.object({
1405
- modelSlug: z6.string().min(1).max(100),
1406
- input: z6.object({
1407
- prompt: z6.string().max(1e4).optional(),
1408
- referenceImageUrl: z6.string().url().optional(),
1409
- referenceImages: z6.array(z6.string().url()).max(8).optional(),
1410
- aspectRatio: z6.string().regex(/^\d+:\d+$/).optional(),
1411
- resolution: z6.string().regex(/^\d+x\d+$/).optional(),
1412
- durationSeconds: z6.number().int().min(1).max(60).optional(),
1413
- providerParams: z6.record(z6.string(), z6.unknown()).optional()
1539
+ var GenerateCreateRequestSchema = z9.object({
1540
+ modelSlug: z9.string().min(1).max(100),
1541
+ input: z9.object({
1542
+ prompt: z9.string().max(1e4).optional(),
1543
+ referenceImageUrl: z9.string().url().optional(),
1544
+ referenceImages: z9.array(z9.string().url()).max(8).optional(),
1545
+ aspectRatio: z9.string().regex(/^\d+:\d+$/).optional(),
1546
+ resolution: z9.string().regex(/^\d+x\d+$/).optional(),
1547
+ durationSeconds: z9.number().int().min(1).max(60).optional(),
1548
+ providerParams: z9.record(z9.string(), z9.unknown()).optional()
1414
1549
  }).strict(),
1415
- options: z6.object({
1416
- workflowId: z6.string().uuid().optional(),
1417
- nodeId: z6.string().optional()
1550
+ options: z9.object({
1551
+ workflowId: z9.string().uuid().optional(),
1552
+ nodeId: z9.string().optional()
1418
1553
  }).strict().optional(),
1419
- products: z6.array(ProductReferenceSchema).min(1).max(10).optional()
1554
+ products: z9.array(ProductReferenceSchema).min(1).max(10).optional()
1420
1555
  }).strict();
1421
- var GenerateCreateResponseSchema = z6.object({
1422
- jobId: z6.string().uuid(),
1423
- status: z6.enum(["queued", "processing", "completed", "failed"]),
1424
- estimatedSeconds: z6.number().int().nonnegative().nullable(),
1425
- creditsCharged: z6.number().int().nonnegative()
1556
+ var GenerateCreateResponseSchema = z9.object({
1557
+ jobId: z9.string().uuid(),
1558
+ status: z9.enum(["queued", "processing", "completed", "failed"]),
1559
+ estimatedSeconds: z9.number().int().nonnegative().nullable(),
1560
+ creditsCharged: z9.number().int().nonnegative()
1426
1561
  }).strict();
1427
- var GenerationStatusSchema = z6.enum([
1562
+ var GenerationStatusSchema = z9.enum([
1428
1563
  "queued",
1429
1564
  "processing",
1430
1565
  "uploading",
@@ -1440,18 +1575,18 @@ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
1440
1575
  function isTerminalStatus(status) {
1441
1576
  return TERMINAL_STATUSES.has(status);
1442
1577
  }
1443
- var GenerationResultSchema = z6.object({
1444
- jobId: z6.string().uuid(),
1578
+ var GenerationResultSchema = z9.object({
1579
+ jobId: z9.string().uuid(),
1445
1580
  status: GenerationStatusSchema,
1446
- modelSlug: z6.string(),
1447
- resultUrl: z6.string().url().nullable(),
1448
- thumbnailUrl: z6.string().url().nullable(),
1449
- errorCode: z6.string().nullable(),
1450
- errorMessage: z6.string().nullable(),
1451
- creditsCharged: z6.number().int().nonnegative(),
1452
- creditsRefunded: z6.boolean(),
1453
- startedAt: z6.string().nullable(),
1454
- completedAt: z6.string().nullable()
1581
+ modelSlug: z9.string(),
1582
+ resultUrl: z9.string().url().nullable(),
1583
+ thumbnailUrl: z9.string().url().nullable(),
1584
+ errorCode: z9.string().nullable(),
1585
+ errorMessage: z9.string().nullable(),
1586
+ creditsCharged: z9.number().int().nonnegative(),
1587
+ creditsRefunded: z9.boolean(),
1588
+ startedAt: z9.string().nullable(),
1589
+ completedAt: z9.string().nullable()
1455
1590
  }).strict();
1456
1591
 
1457
1592
  // src/commands/upload.ts
@@ -1461,19 +1596,19 @@ import { basename } from "path";
1461
1596
  import { request as undiciRequest2 } from "undici";
1462
1597
 
1463
1598
  // src/schemas/assets.ts
1464
- import { z as z7 } from "zod";
1599
+ import { z as z10 } from "zod";
1465
1600
  var MAX_UPLOAD_SIZE_BYTES = 15 * 1024 * 1024;
1466
- var UploadRequestSchema = z7.object({
1467
- filename: z7.string().min(1).max(255),
1468
- contentType: z7.string().regex(/^[\w-]+\/[\w+.-]+$/),
1469
- sizeBytes: z7.number().int().positive().max(MAX_UPLOAD_SIZE_BYTES),
1470
- contentHash: z7.string().regex(/^sha256:[0-9a-f]{64}$/)
1601
+ var UploadRequestSchema = z10.object({
1602
+ filename: z10.string().min(1).max(255),
1603
+ contentType: z10.string().regex(/^[\w-]+\/[\w+.-]+$/),
1604
+ sizeBytes: z10.number().int().positive().max(MAX_UPLOAD_SIZE_BYTES),
1605
+ contentHash: z10.string().regex(/^sha256:[0-9a-f]{64}$/)
1471
1606
  }).strict();
1472
- var UploadResponseSchema = z7.object({
1473
- assetId: z7.string().uuid(),
1474
- uploadUrl: z7.string().url(),
1475
- publicUrl: z7.string().url(),
1476
- deduplicated: z7.boolean()
1607
+ var UploadResponseSchema = z10.object({
1608
+ assetId: z10.string().uuid(),
1609
+ uploadUrl: z10.string().url(),
1610
+ publicUrl: z10.string().url(),
1611
+ deduplicated: z10.boolean()
1477
1612
  }).strict();
1478
1613
 
1479
1614
  // src/commands/upload.ts
@@ -1722,58 +1857,6 @@ function isUrlLike(value) {
1722
1857
  return value.startsWith("http://") || value.startsWith("https://");
1723
1858
  }
1724
1859
 
1725
- // src/cli/long-poll.ts
1726
- async function longPoll(opts) {
1727
- const now = opts.now ?? Date.now;
1728
- const started = now();
1729
- for (; ; ) {
1730
- if (opts.signal?.aborted) {
1731
- throw new ApiError("TIMEOUT", "Wait was aborted.", { retryable: true });
1732
- }
1733
- const elapsedBefore = now() - started;
1734
- if (elapsedBefore >= opts.timeoutMs) {
1735
- throw new ApiError(
1736
- "TIMEOUT",
1737
- `Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
1738
- { retryable: true }
1739
- );
1740
- }
1741
- const remainingMs = opts.timeoutMs - elapsedBefore;
1742
- const iterationSignal = composeIterationSignal(opts.signal, remainingMs);
1743
- let result;
1744
- try {
1745
- result = await opts.fetcher({ signal: iterationSignal });
1746
- } catch (err) {
1747
- if (opts.signal?.aborted || now() - started >= opts.timeoutMs) {
1748
- throw new ApiError(
1749
- "TIMEOUT",
1750
- `Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
1751
- { retryable: true }
1752
- );
1753
- }
1754
- throw err;
1755
- }
1756
- if (opts.signal?.aborted) {
1757
- throw new ApiError("TIMEOUT", "Wait was aborted.", { retryable: true });
1758
- }
1759
- const elapsedAfter = now() - started;
1760
- if (elapsedAfter >= opts.timeoutMs) {
1761
- throw new ApiError(
1762
- "TIMEOUT",
1763
- `Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
1764
- { retryable: true }
1765
- );
1766
- }
1767
- if (opts.isTerminal(result)) {
1768
- return result;
1769
- }
1770
- }
1771
- }
1772
- function composeIterationSignal(userSignal, remainingMs) {
1773
- const deadlineSignal = AbortSignal.timeout(Math.max(remainingMs, 0));
1774
- return userSignal ? AbortSignal.any([userSignal, deadlineSignal]) : deadlineSignal;
1775
- }
1776
-
1777
1860
  // src/commands/generate/get.ts
1778
1861
  async function generateGet(opts) {
1779
1862
  const client = opts.client ?? await buildGenerateClient(opts);
@@ -2569,48 +2652,48 @@ function formatRevokeFailure(err, token) {
2569
2652
  }
2570
2653
 
2571
2654
  // src/schemas/models.ts
2572
- import { z as z8 } from "zod";
2573
- var ModelSummarySchema = z8.object({
2574
- id: z8.string().uuid(),
2575
- slug: z8.string(),
2576
- displayName: z8.string(),
2577
- description: z8.string().nullable(),
2578
- shortDescription: z8.string().nullable(),
2579
- providerSlug: z8.string(),
2580
- providerName: z8.string(),
2581
- modelType: z8.string(),
2582
- category: z8.string(),
2583
- costTier: z8.string(),
2584
- creditCost: z8.number(),
2585
- pricingStrategy: z8.string(),
2586
- estimatedSeconds: z8.object({
2587
- typical: z8.number(),
2588
- range: z8.array(z8.number())
2655
+ import { z as z11 } from "zod";
2656
+ var ModelSummarySchema = z11.object({
2657
+ id: z11.string().uuid(),
2658
+ slug: z11.string(),
2659
+ displayName: z11.string(),
2660
+ description: z11.string().nullable(),
2661
+ shortDescription: z11.string().nullable(),
2662
+ providerSlug: z11.string(),
2663
+ providerName: z11.string(),
2664
+ modelType: z11.string(),
2665
+ category: z11.string(),
2666
+ costTier: z11.string(),
2667
+ creditCost: z11.number(),
2668
+ pricingStrategy: z11.string(),
2669
+ estimatedSeconds: z11.object({
2670
+ typical: z11.number(),
2671
+ range: z11.array(z11.number())
2589
2672
  }).passthrough().nullable(),
2590
- status: z8.string(),
2591
- modalities: z8.object({
2592
- input: z8.array(z8.string()),
2593
- output: z8.array(z8.string())
2673
+ status: z11.string(),
2674
+ modalities: z11.object({
2675
+ input: z11.array(z11.string()),
2676
+ output: z11.array(z11.string())
2594
2677
  }).passthrough().nullable(),
2595
- bestFor: z8.array(z8.string()),
2596
- badges: z8.array(
2597
- z8.object({
2598
- type: z8.string(),
2599
- label: z8.string(),
2600
- color: z8.string(),
2601
- expires_at: z8.string().nullable().optional()
2678
+ bestFor: z11.array(z11.string()),
2679
+ badges: z11.array(
2680
+ z11.object({
2681
+ type: z11.string(),
2682
+ label: z11.string(),
2683
+ color: z11.string(),
2684
+ expires_at: z11.string().nullable().optional()
2602
2685
  }).strict()
2603
2686
  ),
2604
- isFeatured: z8.boolean(),
2605
- isDefault: z8.boolean(),
2606
- docsUrl: z8.string().nullable(),
2607
- llmContext: z8.string().nullable(),
2608
- constraints: z8.record(z8.string(), z8.unknown()).nullable(),
2609
- modelFamily: z8.string().nullable(),
2610
- isFamilyPrimary: z8.boolean().nullable()
2687
+ isFeatured: z11.boolean(),
2688
+ isDefault: z11.boolean(),
2689
+ docsUrl: z11.string().nullable(),
2690
+ llmContext: z11.string().nullable(),
2691
+ constraints: z11.record(z11.string(), z11.unknown()).nullable(),
2692
+ modelFamily: z11.string().nullable(),
2693
+ isFamilyPrimary: z11.boolean().nullable()
2611
2694
  }).strict();
2612
- var ModelsListResponseSchema = z8.object({
2613
- models: z8.array(ModelSummarySchema)
2695
+ var ModelsListResponseSchema = z11.object({
2696
+ models: z11.array(ModelSummarySchema)
2614
2697
  }).strict();
2615
2698
 
2616
2699
  // src/commands/models/internal.ts
@@ -2647,23 +2730,23 @@ async function listModels(opts) {
2647
2730
  }
2648
2731
 
2649
2732
  // src/schemas/node-types.ts
2650
- import { z as z9 } from "zod";
2651
- var NodeTypeSummarySchema = z9.object({
2652
- type: z9.string(),
2653
- portCount: z9.number()
2733
+ import { z as z12 } from "zod";
2734
+ var NodeTypeSummarySchema = z12.object({
2735
+ type: z12.string(),
2736
+ portCount: z12.number()
2654
2737
  }).strict();
2655
- var NodeTypePortSchema = z9.object({
2656
- handleId: z9.string(),
2657
- direction: z9.enum(["input", "output"]),
2658
- dataType: z9.string()
2738
+ var NodeTypePortSchema = z12.object({
2739
+ handleId: z12.string(),
2740
+ direction: z12.enum(["input", "output"]),
2741
+ dataType: z12.string()
2659
2742
  }).strict();
2660
- var NodeTypeDetailSchema = z9.object({
2661
- type: z9.string(),
2662
- ports: z9.array(NodeTypePortSchema),
2663
- agentWritableFields: z9.array(z9.string())
2743
+ var NodeTypeDetailSchema = z12.object({
2744
+ type: z12.string(),
2745
+ ports: z12.array(NodeTypePortSchema),
2746
+ agentWritableFields: z12.array(z12.string())
2664
2747
  }).strict();
2665
- var NodeTypesListResponseSchema = z9.object({
2666
- nodeTypes: z9.array(NodeTypeSummarySchema)
2748
+ var NodeTypesListResponseSchema = z12.object({
2749
+ nodeTypes: z12.array(NodeTypeSummarySchema)
2667
2750
  }).strict();
2668
2751
 
2669
2752
  // src/commands/nodes/internal.ts
@@ -2705,28 +2788,7 @@ async function listNodes(opts) {
2705
2788
  }
2706
2789
 
2707
2790
  // src/commands/product/list.ts
2708
- import { z as z10 } from "zod";
2709
- var ProductImageSummarySchema = z10.object({
2710
- id: z10.string().uuid(),
2711
- url: z10.string(),
2712
- altText: z10.string().nullable(),
2713
- isPrimary: z10.boolean(),
2714
- sortOrder: z10.number().int()
2715
- });
2716
- var ProductSummarySchema = z10.object({
2717
- id: z10.string().uuid(),
2718
- title: z10.string(),
2719
- sourceType: z10.string(),
2720
- syncStatus: z10.enum(["synced", "pending", "stale", "error", "deleted_upstream"]).nullable(),
2721
- vendor: z10.string().nullable(),
2722
- productType: z10.string().nullable(),
2723
- tags: z10.array(z10.string()),
2724
- images: z10.array(ProductImageSummarySchema)
2725
- });
2726
- var ProductsListResponseSchema = z10.object({
2727
- items: z10.array(ProductSummarySchema),
2728
- nextCursor: z10.string().nullable()
2729
- });
2791
+ import "zod";
2730
2792
  var DEFAULT_LIMIT = 50;
2731
2793
  async function listProducts(options) {
2732
2794
  const config = await loadConfig({
@@ -2856,33 +2918,33 @@ async function buildTemplateClient(opts) {
2856
2918
  }
2857
2919
 
2858
2920
  // src/schemas/templates.ts
2859
- import { z as z11 } from "zod";
2860
- var DeclaredParamSchema = z11.object({
2861
- name: z11.string(),
2862
- type: z11.string(),
2863
- required: z11.boolean(),
2864
- defaultValue: z11.string().nullable().optional(),
2865
- enumValues: z11.array(z11.string()).nullable().optional(),
2866
- description: z11.string().nullable().optional()
2921
+ import { z as z14 } from "zod";
2922
+ var DeclaredParamSchema = z14.object({
2923
+ name: z14.string(),
2924
+ type: z14.string(),
2925
+ required: z14.boolean(),
2926
+ defaultValue: z14.string().nullable().optional(),
2927
+ enumValues: z14.array(z14.string()).nullable().optional(),
2928
+ description: z14.string().nullable().optional()
2867
2929
  }).strict();
2868
- var TemplateSummarySchema = z11.object({
2869
- id: z11.string().uuid(),
2870
- source: z11.enum(["own", "system"]),
2871
- name: z11.string(),
2872
- description: z11.string().nullable(),
2873
- category: z11.string().nullable(),
2874
- thumbnailUrl: z11.string().nullable(),
2875
- tags: z11.array(z11.string()),
2876
- createdAt: z11.string()
2930
+ var TemplateSummarySchema = z14.object({
2931
+ id: z14.string().uuid(),
2932
+ source: z14.enum(["own", "system"]),
2933
+ name: z14.string(),
2934
+ description: z14.string().nullable(),
2935
+ category: z14.string().nullable(),
2936
+ thumbnailUrl: z14.string().nullable(),
2937
+ tags: z14.array(z14.string()),
2938
+ createdAt: z14.string()
2877
2939
  }).strict();
2878
2940
  var TemplateDetailSchema = TemplateSummarySchema.extend({
2879
- declaredParams: z11.array(DeclaredParamSchema),
2880
- timesUsed: z11.number()
2941
+ declaredParams: z14.array(DeclaredParamSchema),
2942
+ timesUsed: z14.number()
2881
2943
  }).strict();
2882
- var TemplatesListResponseSchema = z11.object({
2883
- templates: z11.array(TemplateSummarySchema),
2884
- cursor: z11.string().nullable(),
2885
- hasMore: z11.boolean()
2944
+ var TemplatesListResponseSchema = z14.object({
2945
+ templates: z14.array(TemplateSummarySchema),
2946
+ cursor: z14.string().nullable(),
2947
+ hasMore: z14.boolean()
2886
2948
  }).strict();
2887
2949
 
2888
2950
  // src/commands/template/list.ts
@@ -2932,20 +2994,7 @@ async function getTemplate(opts) {
2932
2994
  }
2933
2995
 
2934
2996
  // src/commands/tokens/list.ts
2935
- import { z as z12 } from "zod";
2936
- var TokenRowSchema = z12.object({
2937
- id: z12.string().uuid(),
2938
- organizationId: z12.string().uuid(),
2939
- userId: z12.string().uuid(),
2940
- clientId: z12.string().nullable(),
2941
- tokenPrefix: z12.string(),
2942
- name: z12.string().nullable(),
2943
- scopes: z12.array(z12.string()),
2944
- lastUsedAt: z12.string().nullable(),
2945
- expiresAt: z12.string(),
2946
- createdAt: z12.string()
2947
- }).strict();
2948
- var TokensListResponseSchema = z12.array(TokenRowSchema);
2997
+ import "zod";
2949
2998
  async function listTokens(options) {
2950
2999
  const config = await loadConfig({
2951
3000
  flagProfile: options.profile,
@@ -2971,51 +3020,51 @@ async function listTokens(options) {
2971
3020
  }
2972
3021
 
2973
3022
  // src/schemas/workflows.ts
2974
- import { z as z13 } from "zod";
2975
- var WorkflowDeclaredParamSchema = z13.object({
2976
- name: z13.string(),
2977
- type: z13.string(),
2978
- required: z13.boolean().optional(),
2979
- defaultValue: z13.unknown().optional(),
2980
- description: z13.unknown().optional()
3023
+ import { z as z16 } from "zod";
3024
+ var WorkflowDeclaredParamSchema = z16.object({
3025
+ name: z16.string(),
3026
+ type: z16.string(),
3027
+ required: z16.boolean().optional(),
3028
+ defaultValue: z16.unknown().optional(),
3029
+ description: z16.unknown().optional()
2981
3030
  }).passthrough();
2982
- var WorkflowSummarySchema = z13.object({
2983
- id: z13.string().uuid(),
2984
- name: z13.string(),
2985
- tags: z13.array(z13.string()),
2986
- declared_params: z13.array(WorkflowDeclaredParamSchema).nullable().default([]),
2987
- canvas_rev: z13.number().int().nonnegative(),
2988
- updated_at: z13.string()
3031
+ var WorkflowSummarySchema = z16.object({
3032
+ id: z16.string().uuid(),
3033
+ name: z16.string(),
3034
+ tags: z16.array(z16.string()),
3035
+ declared_params: z16.array(WorkflowDeclaredParamSchema).nullable().default([]),
3036
+ canvas_rev: z16.number().int().nonnegative(),
3037
+ updated_at: z16.string()
2989
3038
  }).strict();
2990
- var WorkflowsListResponseSchema = z13.object({
2991
- items: z13.array(WorkflowSummarySchema),
2992
- nextCursor: z13.string().nullable()
3039
+ var WorkflowsListResponseSchema = z16.object({
3040
+ items: z16.array(WorkflowSummarySchema),
3041
+ nextCursor: z16.string().nullable()
2993
3042
  }).strict();
2994
- var WorkflowDetailSchema = z13.object({
2995
- id: z13.string().uuid(),
2996
- name: z13.string(),
2997
- description: z13.string().nullable(),
2998
- tags: z13.array(z13.string()),
2999
- declared_params: z13.array(WorkflowDeclaredParamSchema).nullable().default([]),
3000
- canvas_rev: z13.number().int().nonnegative(),
3001
- nodes: z13.array(z13.unknown()),
3002
- edges: z13.array(z13.unknown()),
3003
- created_at: z13.string(),
3004
- updated_at: z13.string()
3043
+ var WorkflowDetailSchema = z16.object({
3044
+ id: z16.string().uuid(),
3045
+ name: z16.string(),
3046
+ description: z16.string().nullable(),
3047
+ tags: z16.array(z16.string()),
3048
+ declared_params: z16.array(WorkflowDeclaredParamSchema).nullable().default([]),
3049
+ canvas_rev: z16.number().int().nonnegative(),
3050
+ nodes: z16.array(z16.unknown()),
3051
+ edges: z16.array(z16.unknown()),
3052
+ created_at: z16.string(),
3053
+ updated_at: z16.string()
3005
3054
  }).strict();
3006
- var WorkflowCreateResponseSchema = z13.object({
3007
- id: z13.string().uuid(),
3008
- name: z13.string(),
3009
- description: z13.string().nullable(),
3010
- tags: z13.array(z13.string()),
3011
- declared_params: z13.array(WorkflowDeclaredParamSchema).nullable().default([]),
3012
- canvas_rev: z13.number().int().nonnegative(),
3013
- created_at: z13.string(),
3014
- updated_at: z13.string()
3055
+ var WorkflowCreateResponseSchema = z16.object({
3056
+ id: z16.string().uuid(),
3057
+ name: z16.string(),
3058
+ description: z16.string().nullable(),
3059
+ tags: z16.array(z16.string()),
3060
+ declared_params: z16.array(WorkflowDeclaredParamSchema).nullable().default([]),
3061
+ canvas_rev: z16.number().int().nonnegative(),
3062
+ created_at: z16.string(),
3063
+ updated_at: z16.string()
3015
3064
  }).strict();
3016
- var WorkflowMutateResponseSchema = z13.object({
3017
- canvas_rev: z13.number().int().nonnegative(),
3018
- applied: z13.number().int().nonnegative(),
3065
+ var WorkflowMutateResponseSchema = z16.object({
3066
+ canvas_rev: z16.number().int().nonnegative(),
3067
+ applied: z16.number().int().nonnegative(),
3019
3068
  workflow: WorkflowDetailSchema
3020
3069
  }).strict();
3021
3070