@clickraft/cli 0.8.7 → 0.8.9

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
@@ -10,10 +10,15 @@ import { z } from "zod";
10
10
  import { z as z2 } from "zod";
11
11
  import { z as z3 } from "zod";
12
12
  import { z as z4 } from "zod";
13
- import { request as undiciRequest } from "undici";
13
+ import { z as z5 } from "zod";
14
14
  import { z as z6 } from "zod";
15
+ import { z as z7 } from "zod";
16
+ import { z as z8 } from "zod";
17
+ import { z as z9 } from "zod";
18
+ import { request as undiciRequest } from "undici";
19
+ import { z as z11 } from "zod";
15
20
  import { createHash, randomUUID } from "crypto";
16
- import { z as z5 } from "zod";
21
+ import { z as z10 } from "zod";
17
22
  import { createHash as createHash2 } from "crypto";
18
23
  import { request as undiciRequest2 } from "undici";
19
24
  var TOKEN_FIELD_PATTERN = /"(access_token|refresh_token|device_code|user_code|code_verifier|client_secret)"\s*:\s*"[^"]*"/gi;
@@ -87,6 +92,165 @@ var TokenRowSchema = z4.object({
87
92
  createdAt: z4.string()
88
93
  }).strict();
89
94
  var TokensListResponseSchema = z4.array(TokenRowSchema);
95
+ var DeclaredParamSchema = z5.object({
96
+ name: z5.string(),
97
+ type: z5.string(),
98
+ required: z5.boolean(),
99
+ defaultValue: z5.string().nullable().optional(),
100
+ enumValues: z5.array(z5.string()).nullable().optional(),
101
+ description: z5.string().nullable().optional()
102
+ }).strict();
103
+ var TemplateSummarySchema = z5.object({
104
+ id: z5.string().uuid(),
105
+ source: z5.enum(["own", "system"]),
106
+ name: z5.string(),
107
+ description: z5.string().nullable(),
108
+ category: z5.string().nullable(),
109
+ thumbnailUrl: z5.string().nullable(),
110
+ tags: z5.array(z5.string()),
111
+ createdAt: z5.string()
112
+ }).strict();
113
+ var TemplateDetailSchema = TemplateSummarySchema.extend({
114
+ declaredParams: z5.array(DeclaredParamSchema),
115
+ timesUsed: z5.number()
116
+ }).strict();
117
+ var TemplatesListResponseSchema = z5.object({
118
+ templates: z5.array(TemplateSummarySchema),
119
+ cursor: z5.string().nullable(),
120
+ hasMore: z5.boolean()
121
+ }).strict();
122
+ var ProductReferenceSchema = z6.object({
123
+ id: z6.string().uuid(),
124
+ imageId: z6.string().uuid().optional()
125
+ }).strict();
126
+ var GenerateCreateRequestSchema = z6.object({
127
+ modelSlug: z6.string().min(1).max(100),
128
+ input: z6.object({
129
+ prompt: z6.string().max(1e4).optional(),
130
+ referenceImageUrl: z6.string().url().optional(),
131
+ referenceImages: z6.array(z6.string().url()).max(8).optional(),
132
+ aspectRatio: z6.string().regex(/^\d+:\d+$/).optional(),
133
+ resolution: z6.string().regex(/^\d+x\d+$/).optional(),
134
+ durationSeconds: z6.number().int().min(1).max(60).optional(),
135
+ providerParams: z6.record(z6.string(), z6.unknown()).optional()
136
+ }).strict(),
137
+ options: z6.object({
138
+ workflowId: z6.string().uuid().optional(),
139
+ nodeId: z6.string().optional()
140
+ }).strict().optional(),
141
+ products: z6.array(ProductReferenceSchema).min(1).max(10).optional()
142
+ }).strict();
143
+ var GenerateCreateResponseSchema = z6.object({
144
+ jobId: z6.string().uuid(),
145
+ status: z6.enum(["queued", "processing", "completed", "failed"]),
146
+ estimatedSeconds: z6.number().int().nonnegative().nullable(),
147
+ creditsCharged: z6.number().int().nonnegative()
148
+ }).strict();
149
+ var GenerationStatusSchema = z6.enum([
150
+ "queued",
151
+ "processing",
152
+ "uploading",
153
+ "completed",
154
+ "failed",
155
+ "cancelled"
156
+ ]);
157
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
158
+ "completed",
159
+ "failed",
160
+ "cancelled"
161
+ ]);
162
+ function isTerminalStatus(status) {
163
+ return TERMINAL_STATUSES.has(status);
164
+ }
165
+ var GenerationResultSchema = z6.object({
166
+ jobId: z6.string().uuid(),
167
+ status: GenerationStatusSchema,
168
+ modelSlug: z6.string(),
169
+ resultUrl: z6.string().url().nullable(),
170
+ thumbnailUrl: z6.string().url().nullable(),
171
+ errorCode: z6.string().nullable(),
172
+ errorMessage: z6.string().nullable(),
173
+ creditsCharged: z6.number().int().nonnegative(),
174
+ creditsRefunded: z6.boolean(),
175
+ startedAt: z6.string().nullable(),
176
+ completedAt: z6.string().nullable()
177
+ }).strict();
178
+ var MAX_UPLOAD_SIZE_BYTES = 15 * 1024 * 1024;
179
+ var UploadRequestSchema = z7.object({
180
+ filename: z7.string().min(1).max(255),
181
+ contentType: z7.string().regex(/^[\w-]+\/[\w+.-]+$/),
182
+ sizeBytes: z7.number().int().positive().max(MAX_UPLOAD_SIZE_BYTES),
183
+ contentHash: z7.string().regex(/^sha256:[0-9a-f]{64}$/)
184
+ }).strict();
185
+ var UploadResponseSchema = z7.object({
186
+ assetId: z7.string().uuid(),
187
+ uploadUrl: z7.string().url(),
188
+ publicUrl: z7.string().url(),
189
+ deduplicated: z7.boolean()
190
+ }).strict();
191
+ var NodeTypeSummarySchema = z8.object({
192
+ type: z8.string(),
193
+ portCount: z8.number()
194
+ }).strict();
195
+ var NodeTypePortSchema = z8.object({
196
+ handleId: z8.string(),
197
+ direction: z8.enum(["input", "output"]),
198
+ dataType: z8.string()
199
+ }).strict();
200
+ var NodeTypeDetailSchema = z8.object({
201
+ type: z8.string(),
202
+ ports: z8.array(NodeTypePortSchema),
203
+ agentWritableFields: z8.array(z8.string())
204
+ }).strict();
205
+ var NodeTypesListResponseSchema = z8.object({
206
+ nodeTypes: z8.array(NodeTypeSummarySchema)
207
+ }).strict();
208
+ var WorkflowDeclaredParamSchema = z9.object({
209
+ name: z9.string(),
210
+ type: z9.string(),
211
+ required: z9.boolean().optional(),
212
+ defaultValue: z9.unknown().optional(),
213
+ description: z9.unknown().optional()
214
+ }).passthrough();
215
+ var WorkflowSummarySchema = z9.object({
216
+ id: z9.string().uuid(),
217
+ name: z9.string(),
218
+ tags: z9.array(z9.string()),
219
+ declared_params: z9.array(WorkflowDeclaredParamSchema).nullable().default([]),
220
+ canvas_rev: z9.number().int().nonnegative(),
221
+ updated_at: z9.string()
222
+ }).strict();
223
+ var WorkflowsListResponseSchema = z9.object({
224
+ items: z9.array(WorkflowSummarySchema),
225
+ nextCursor: z9.string().nullable()
226
+ }).strict();
227
+ var WorkflowDetailSchema = z9.object({
228
+ id: z9.string().uuid(),
229
+ name: z9.string(),
230
+ description: z9.string().nullable(),
231
+ tags: z9.array(z9.string()),
232
+ declared_params: z9.array(WorkflowDeclaredParamSchema).nullable().default([]),
233
+ canvas_rev: z9.number().int().nonnegative(),
234
+ nodes: z9.array(z9.unknown()),
235
+ edges: z9.array(z9.unknown()),
236
+ created_at: z9.string(),
237
+ updated_at: z9.string()
238
+ }).strict();
239
+ var WorkflowCreateResponseSchema = z9.object({
240
+ id: z9.string().uuid(),
241
+ name: z9.string(),
242
+ description: z9.string().nullable(),
243
+ tags: z9.array(z9.string()),
244
+ declared_params: z9.array(WorkflowDeclaredParamSchema).nullable().default([]),
245
+ canvas_rev: z9.number().int().nonnegative(),
246
+ created_at: z9.string(),
247
+ updated_at: z9.string()
248
+ }).strict();
249
+ var WorkflowMutateResponseSchema = z9.object({
250
+ canvas_rev: z9.number().int().nonnegative(),
251
+ applied: z9.number().int().nonnegative(),
252
+ workflow: WorkflowDetailSchema
253
+ }).strict();
90
254
  var SERVER_ERROR_CODES = [
91
255
  "AUTH_TOKEN_MISSING",
92
256
  "AUTH_TOKEN_INVALID",
@@ -304,14 +468,14 @@ function signalToAbortError(signal) {
304
468
  err.name = "AbortError";
305
469
  return err;
306
470
  }
307
- var ServerSuccessSchema = (payload) => z5.object({ data: payload }).strict();
308
- var ServerErrorBodySchema = z5.object({
309
- error: z5.object({
310
- code: z5.string().min(1),
311
- message: z5.string(),
312
- correlationId: z5.string().optional(),
313
- retryAfter: z5.number().int().nonnegative().optional(),
314
- details: z5.unknown().optional()
471
+ var ServerSuccessSchema = (payload) => z10.object({ data: payload }).strict();
472
+ var ServerErrorBodySchema = z10.object({
473
+ error: z10.object({
474
+ code: z10.string().min(1),
475
+ message: z10.string(),
476
+ correlationId: z10.string().optional(),
477
+ retryAfter: z10.number().int().nonnegative().optional(),
478
+ details: z10.unknown().optional()
315
479
  }).strict()
316
480
  }).strict();
317
481
  var REDACT_BODY_LIMIT = 1024;
@@ -485,7 +649,7 @@ function parseSuccessBody(args) {
485
649
  err
486
650
  );
487
651
  }
488
- const envelope = ServerSuccessSchema(args.responseSchema ?? z6.unknown()).safeParse(parsed);
652
+ const envelope = ServerSuccessSchema(args.responseSchema ?? z11.unknown()).safeParse(parsed);
489
653
  if (!envelope.success) {
490
654
  const issues = formatSchemaIssues(envelope.error);
491
655
  throw new ApiError(
@@ -813,6 +977,44 @@ function matchesPrefix(content, prefix) {
813
977
  }
814
978
  return true;
815
979
  }
980
+ function waitForGeneration(params) {
981
+ return longPoll({
982
+ // Forward the iteration signal so the in-flight server hold is aborted as
983
+ // soon as the overall deadline expires — otherwise `--timeout 1` would still
984
+ // block for the full server long-poll round.
985
+ fetcher: (args) => params.client.request({
986
+ method: "GET",
987
+ path: `/jobs/${encodeURIComponent(params.jobId)}`,
988
+ query: { wait: params.serverWaitSeconds },
989
+ responseSchema: params.resultSchema,
990
+ signal: args?.signal
991
+ }),
992
+ isTerminal: params.isTerminal,
993
+ timeoutMs: params.timeoutMs,
994
+ signal: params.signal
995
+ });
996
+ }
997
+ async function createGeneration(params) {
998
+ const created = await params.client.request({
999
+ method: "POST",
1000
+ path: "/jobs",
1001
+ body: params.body,
1002
+ responseSchema: params.createSchema,
1003
+ signal: params.signal
1004
+ });
1005
+ if (!params.wait) {
1006
+ return params.projectCreated(created, params.modelSlug);
1007
+ }
1008
+ return waitForGeneration({
1009
+ client: params.client,
1010
+ jobId: created.jobId,
1011
+ timeoutMs: params.timeoutMs,
1012
+ serverWaitSeconds: params.serverWaitSeconds,
1013
+ signal: params.signal,
1014
+ resultSchema: params.resultSchema,
1015
+ isTerminal: params.isTerminal
1016
+ });
1017
+ }
816
1018
 
817
1019
  // src/errors/codes.ts
818
1020
  var LOGIN_HINT = "Run `clickraft login` to authenticate.";
@@ -1373,31 +1575,31 @@ function getCredentialsPath(ctx = {}) {
1373
1575
  }
1374
1576
 
1375
1577
  // src/auth/types.ts
1376
- import { z as z7 } from "zod";
1377
- var DeviceAuthorizationRequestSchema = z7.object({
1378
- client_id: z7.string(),
1379
- scope: z7.string()
1578
+ import { z as z12 } from "zod";
1579
+ var DeviceAuthorizationRequestSchema = z12.object({
1580
+ client_id: z12.string(),
1581
+ scope: z12.string()
1380
1582
  });
1381
- var DeviceAuthorizationResponseSchema = z7.object({
1382
- device_code: z7.string(),
1383
- user_code: z7.string().min(1),
1384
- verification_uri: z7.string().url(),
1385
- verification_uri_complete: z7.string().url().optional(),
1386
- expires_in: z7.number().int().positive(),
1387
- interval: z7.number().int().positive().default(5)
1583
+ var DeviceAuthorizationResponseSchema = z12.object({
1584
+ device_code: z12.string(),
1585
+ user_code: z12.string().min(1),
1586
+ verification_uri: z12.string().url(),
1587
+ verification_uri_complete: z12.string().url().optional(),
1588
+ expires_in: z12.number().int().positive(),
1589
+ interval: z12.number().int().positive().default(5)
1388
1590
  });
1389
- var DeviceTokenPollRequestSchema = z7.object({
1390
- client_id: z7.string(),
1391
- device_code: z7.string(),
1392
- grant_type: z7.literal("urn:ietf:params:oauth:grant-type:device_code")
1591
+ var DeviceTokenPollRequestSchema = z12.object({
1592
+ client_id: z12.string(),
1593
+ device_code: z12.string(),
1594
+ grant_type: z12.literal("urn:ietf:params:oauth:grant-type:device_code")
1393
1595
  });
1394
- var TokenResponseSchema = z7.object({
1395
- access_token: z7.string(),
1396
- token_type: z7.literal("Bearer"),
1397
- expires_in: z7.number().int().positive(),
1398
- scope: z7.string()
1596
+ var TokenResponseSchema = z12.object({
1597
+ access_token: z12.string(),
1598
+ token_type: z12.literal("Bearer"),
1599
+ expires_in: z12.number().int().positive(),
1600
+ scope: z12.string()
1399
1601
  });
1400
- var DeviceTokenPollErrorCodeSchema = z7.enum([
1602
+ var DeviceTokenPollErrorCodeSchema = z12.enum([
1401
1603
  "authorization_pending",
1402
1604
  "slow_down",
1403
1605
  "access_denied",
@@ -1408,27 +1610,27 @@ var DeviceTokenPollErrorCodeSchema = z7.enum([
1408
1610
  "unsupported_grant_type",
1409
1611
  "invalid_scope"
1410
1612
  ]);
1411
- var DeviceTokenPollErrorSchema = z7.object({
1613
+ var DeviceTokenPollErrorSchema = z12.object({
1412
1614
  error: DeviceTokenPollErrorCodeSchema,
1413
- error_description: z7.string().optional()
1615
+ error_description: z12.string().optional()
1414
1616
  });
1415
- var CredentialsProfileSchema = z7.object({
1416
- apiBaseUrl: z7.string().url(),
1417
- accessToken: z7.string(),
1418
- tokenType: z7.literal("Bearer"),
1419
- tokenPrefix: z7.string(),
1420
- organizationId: z7.string().uuid(),
1421
- organizationSlug: z7.string(),
1422
- userId: z7.string().uuid(),
1423
- scopes: z7.array(z7.string()),
1424
- expiresAt: z7.string().datetime(),
1425
- issuedAt: z7.string().datetime(),
1426
- clientId: z7.string()
1617
+ var CredentialsProfileSchema = z12.object({
1618
+ apiBaseUrl: z12.string().url(),
1619
+ accessToken: z12.string(),
1620
+ tokenType: z12.literal("Bearer"),
1621
+ tokenPrefix: z12.string(),
1622
+ organizationId: z12.string().uuid(),
1623
+ organizationSlug: z12.string(),
1624
+ userId: z12.string().uuid(),
1625
+ scopes: z12.array(z12.string()),
1626
+ expiresAt: z12.string().datetime(),
1627
+ issuedAt: z12.string().datetime(),
1628
+ clientId: z12.string()
1427
1629
  }).strict();
1428
- var CredentialsFileSchema = z7.object({
1429
- version: z7.literal(1),
1430
- defaultProfile: z7.string(),
1431
- profiles: z7.record(z7.string(), CredentialsProfileSchema)
1630
+ var CredentialsFileSchema = z12.object({
1631
+ version: z12.literal(1),
1632
+ defaultProfile: z12.string(),
1633
+ profiles: z12.record(z12.string(), CredentialsProfileSchema)
1432
1634
  }).strict();
1433
1635
 
1434
1636
  // src/auth/credentials.ts
@@ -1711,87 +1913,10 @@ async function listBrandModels(options) {
1711
1913
  return data.brandModels;
1712
1914
  }
1713
1915
 
1714
- // src/schemas/jobs.ts
1715
- import { z as z9 } from "zod";
1716
- var ProductReferenceSchema = z9.object({
1717
- id: z9.string().uuid(),
1718
- imageId: z9.string().uuid().optional()
1719
- }).strict();
1720
- var GenerateCreateRequestSchema = z9.object({
1721
- modelSlug: z9.string().min(1).max(100),
1722
- input: z9.object({
1723
- prompt: z9.string().max(1e4).optional(),
1724
- referenceImageUrl: z9.string().url().optional(),
1725
- referenceImages: z9.array(z9.string().url()).max(8).optional(),
1726
- aspectRatio: z9.string().regex(/^\d+:\d+$/).optional(),
1727
- resolution: z9.string().regex(/^\d+x\d+$/).optional(),
1728
- durationSeconds: z9.number().int().min(1).max(60).optional(),
1729
- providerParams: z9.record(z9.string(), z9.unknown()).optional()
1730
- }).strict(),
1731
- options: z9.object({
1732
- workflowId: z9.string().uuid().optional(),
1733
- nodeId: z9.string().optional()
1734
- }).strict().optional(),
1735
- products: z9.array(ProductReferenceSchema).min(1).max(10).optional()
1736
- }).strict();
1737
- var GenerateCreateResponseSchema = z9.object({
1738
- jobId: z9.string().uuid(),
1739
- status: z9.enum(["queued", "processing", "completed", "failed"]),
1740
- estimatedSeconds: z9.number().int().nonnegative().nullable(),
1741
- creditsCharged: z9.number().int().nonnegative()
1742
- }).strict();
1743
- var GenerationStatusSchema = z9.enum([
1744
- "queued",
1745
- "processing",
1746
- "uploading",
1747
- "completed",
1748
- "failed",
1749
- "cancelled"
1750
- ]);
1751
- var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
1752
- "completed",
1753
- "failed",
1754
- "cancelled"
1755
- ]);
1756
- function isTerminalStatus(status) {
1757
- return TERMINAL_STATUSES.has(status);
1758
- }
1759
- var GenerationResultSchema = z9.object({
1760
- jobId: z9.string().uuid(),
1761
- status: GenerationStatusSchema,
1762
- modelSlug: z9.string(),
1763
- resultUrl: z9.string().url().nullable(),
1764
- thumbnailUrl: z9.string().url().nullable(),
1765
- errorCode: z9.string().nullable(),
1766
- errorMessage: z9.string().nullable(),
1767
- creditsCharged: z9.number().int().nonnegative(),
1768
- creditsRefunded: z9.boolean(),
1769
- startedAt: z9.string().nullable(),
1770
- completedAt: z9.string().nullable()
1771
- }).strict();
1772
-
1773
1916
  // src/commands/upload.ts
1774
1917
  import { readFile as readFile2, stat as stat2 } from "fs/promises";
1775
1918
  import { basename } from "path";
1776
1919
  import "undici";
1777
-
1778
- // src/schemas/assets.ts
1779
- import { z as z10 } from "zod";
1780
- var MAX_UPLOAD_SIZE_BYTES = 15 * 1024 * 1024;
1781
- var UploadRequestSchema = z10.object({
1782
- filename: z10.string().min(1).max(255),
1783
- contentType: z10.string().regex(/^[\w-]+\/[\w+.-]+$/),
1784
- sizeBytes: z10.number().int().positive().max(MAX_UPLOAD_SIZE_BYTES),
1785
- contentHash: z10.string().regex(/^sha256:[0-9a-f]{64}$/)
1786
- }).strict();
1787
- var UploadResponseSchema = z10.object({
1788
- assetId: z10.string().uuid(),
1789
- uploadUrl: z10.string().url(),
1790
- publicUrl: z10.string().url(),
1791
- deduplicated: z10.boolean()
1792
- }).strict();
1793
-
1794
- // src/commands/upload.ts
1795
1920
  var DEFAULT_UPLOAD_SCOPE = "user-uploads";
1796
1921
  async function uploadFile(opts) {
1797
1922
  const scope = opts.scope ?? DEFAULT_UPLOAD_SCOPE;
@@ -1902,37 +2027,19 @@ function isUrlLike(value) {
1902
2027
  return value.startsWith("http://") || value.startsWith("https://");
1903
2028
  }
1904
2029
 
1905
- // src/commands/generate/get.ts
1906
- async function generateGet(opts) {
1907
- const client = opts.client ?? await buildGenerateClient(opts);
1908
- return client.request({
1909
- method: "GET",
1910
- path: `/jobs/${encodeURIComponent(opts.jobId)}`,
1911
- query: opts.waitSeconds && opts.waitSeconds > 0 ? { wait: opts.waitSeconds } : void 0,
1912
- responseSchema: GenerationResultSchema,
1913
- signal: opts.signal
1914
- });
1915
- }
1916
-
1917
2030
  // src/commands/generate/wait.ts
1918
2031
  var DEFAULT_WAIT_TIMEOUT_SECONDS = 120;
1919
2032
  var SERVER_LONG_POLL_SECONDS = 30;
1920
2033
  async function generateWait(opts) {
1921
2034
  const client = opts.client ?? await buildGenerateClient(opts);
1922
- const timeoutSeconds = opts.timeoutSeconds ?? DEFAULT_WAIT_TIMEOUT_SECONDS;
1923
- return longPoll({
1924
- // Forward the iteration signal so the in-flight server hold is aborted
1925
- // as soon as the overall deadline expires — otherwise `--timeout 1` would
1926
- // still block for the full 30s server long-poll round.
1927
- fetcher: (args) => generateGet({
1928
- jobId: opts.jobId,
1929
- waitSeconds: SERVER_LONG_POLL_SECONDS,
1930
- client,
1931
- signal: args?.signal
1932
- }),
1933
- isTerminal: (r) => isTerminalStatus(r.status),
1934
- timeoutMs: timeoutSeconds * 1e3,
1935
- signal: opts.signal
2035
+ return waitForGeneration({
2036
+ client,
2037
+ jobId: opts.jobId,
2038
+ timeoutMs: (opts.timeoutSeconds ?? DEFAULT_WAIT_TIMEOUT_SECONDS) * 1e3,
2039
+ serverWaitSeconds: SERVER_LONG_POLL_SECONDS,
2040
+ signal: opts.signal,
2041
+ resultSchema: GenerationResultSchema,
2042
+ isTerminal: (r) => isTerminalStatus(r.status)
1936
2043
  });
1937
2044
  }
1938
2045
 
@@ -1950,22 +2057,18 @@ async function generateCreate(opts) {
1950
2057
  signal: opts.signal
1951
2058
  });
1952
2059
  const body = buildRequestBody({ ...opts, referenceImages });
1953
- const created = await client.request({
1954
- method: "POST",
1955
- path: "/jobs",
1956
- body,
1957
- responseSchema: GenerateCreateResponseSchema,
1958
- signal: opts.signal
1959
- });
1960
- const wait = opts.wait ?? true;
1961
- if (!wait) {
1962
- return projectCreateToResult(created, opts.modelSlug);
1963
- }
1964
- return generateWait({
1965
- jobId: created.jobId,
1966
- timeoutSeconds: opts.timeoutSeconds ?? DEFAULT_WAIT_TIMEOUT_SECONDS,
2060
+ return createGeneration({
1967
2061
  client,
1968
- signal: opts.signal
2062
+ body,
2063
+ modelSlug: opts.modelSlug,
2064
+ wait: opts.wait ?? true,
2065
+ timeoutMs: (opts.timeoutSeconds ?? DEFAULT_WAIT_TIMEOUT_SECONDS) * 1e3,
2066
+ serverWaitSeconds: SERVER_LONG_POLL_SECONDS,
2067
+ signal: opts.signal,
2068
+ createSchema: GenerateCreateResponseSchema,
2069
+ resultSchema: GenerationResultSchema,
2070
+ isTerminal: (r) => isTerminalStatus(r.status),
2071
+ projectCreated: projectCreateToResult
1969
2072
  });
1970
2073
  }
1971
2074
  async function resolveReferenceImages(args) {
@@ -2048,6 +2151,18 @@ function projectCreateToResult(response, modelSlug) {
2048
2151
  };
2049
2152
  }
2050
2153
 
2154
+ // src/commands/generate/get.ts
2155
+ async function generateGet(opts) {
2156
+ const client = opts.client ?? await buildGenerateClient(opts);
2157
+ return client.request({
2158
+ method: "GET",
2159
+ path: `/jobs/${encodeURIComponent(opts.jobId)}`,
2160
+ query: opts.waitSeconds && opts.waitSeconds > 0 ? { wait: opts.waitSeconds } : void 0,
2161
+ responseSchema: GenerationResultSchema,
2162
+ signal: opts.signal
2163
+ });
2164
+ }
2165
+
2051
2166
  // src/cli/args.ts
2052
2167
  var ArgError = class extends Error {
2053
2168
  constructor(message) {
@@ -2697,48 +2812,48 @@ function formatRevokeFailure(err, token) {
2697
2812
  }
2698
2813
 
2699
2814
  // src/schemas/models.ts
2700
- import { z as z11 } from "zod";
2701
- var ModelSummarySchema = z11.object({
2702
- id: z11.string().uuid(),
2703
- slug: z11.string(),
2704
- displayName: z11.string(),
2705
- description: z11.string().nullable(),
2706
- shortDescription: z11.string().nullable(),
2707
- providerSlug: z11.string(),
2708
- providerName: z11.string(),
2709
- modelType: z11.string(),
2710
- category: z11.string(),
2711
- costTier: z11.string(),
2712
- creditCost: z11.number(),
2713
- pricingStrategy: z11.string(),
2714
- estimatedSeconds: z11.object({
2715
- typical: z11.number(),
2716
- range: z11.array(z11.number())
2815
+ import { z as z14 } from "zod";
2816
+ var ModelSummarySchema = z14.object({
2817
+ id: z14.string().uuid(),
2818
+ slug: z14.string(),
2819
+ displayName: z14.string(),
2820
+ description: z14.string().nullable(),
2821
+ shortDescription: z14.string().nullable(),
2822
+ providerSlug: z14.string(),
2823
+ providerName: z14.string(),
2824
+ modelType: z14.string(),
2825
+ category: z14.string(),
2826
+ costTier: z14.string(),
2827
+ creditCost: z14.number(),
2828
+ pricingStrategy: z14.string(),
2829
+ estimatedSeconds: z14.object({
2830
+ typical: z14.number(),
2831
+ range: z14.array(z14.number())
2717
2832
  }).passthrough().nullable(),
2718
- status: z11.string(),
2719
- modalities: z11.object({
2720
- input: z11.array(z11.string()),
2721
- output: z11.array(z11.string())
2833
+ status: z14.string(),
2834
+ modalities: z14.object({
2835
+ input: z14.array(z14.string()),
2836
+ output: z14.array(z14.string())
2722
2837
  }).passthrough().nullable(),
2723
- bestFor: z11.array(z11.string()),
2724
- badges: z11.array(
2725
- z11.object({
2726
- type: z11.string(),
2727
- label: z11.string(),
2728
- color: z11.string(),
2729
- expires_at: z11.string().nullable().optional()
2838
+ bestFor: z14.array(z14.string()),
2839
+ badges: z14.array(
2840
+ z14.object({
2841
+ type: z14.string(),
2842
+ label: z14.string(),
2843
+ color: z14.string(),
2844
+ expires_at: z14.string().nullable().optional()
2730
2845
  }).strict()
2731
2846
  ),
2732
- isFeatured: z11.boolean(),
2733
- isDefault: z11.boolean(),
2734
- docsUrl: z11.string().nullable(),
2735
- llmContext: z11.string().nullable(),
2736
- constraints: z11.record(z11.string(), z11.unknown()).nullable(),
2737
- modelFamily: z11.string().nullable(),
2738
- isFamilyPrimary: z11.boolean().nullable()
2847
+ isFeatured: z14.boolean(),
2848
+ isDefault: z14.boolean(),
2849
+ docsUrl: z14.string().nullable(),
2850
+ llmContext: z14.string().nullable(),
2851
+ constraints: z14.record(z14.string(), z14.unknown()).nullable(),
2852
+ modelFamily: z14.string().nullable(),
2853
+ isFamilyPrimary: z14.boolean().nullable()
2739
2854
  }).strict();
2740
- var ModelsListResponseSchema = z11.object({
2741
- models: z11.array(ModelSummarySchema)
2855
+ var ModelsListResponseSchema = z14.object({
2856
+ models: z14.array(ModelSummarySchema)
2742
2857
  }).strict();
2743
2858
 
2744
2859
  // src/commands/models/internal.ts
@@ -2774,26 +2889,6 @@ async function listModels(opts) {
2774
2889
  return data;
2775
2890
  }
2776
2891
 
2777
- // src/schemas/node-types.ts
2778
- import { z as z12 } from "zod";
2779
- var NodeTypeSummarySchema = z12.object({
2780
- type: z12.string(),
2781
- portCount: z12.number()
2782
- }).strict();
2783
- var NodeTypePortSchema = z12.object({
2784
- handleId: z12.string(),
2785
- direction: z12.enum(["input", "output"]),
2786
- dataType: z12.string()
2787
- }).strict();
2788
- var NodeTypeDetailSchema = z12.object({
2789
- type: z12.string(),
2790
- ports: z12.array(NodeTypePortSchema),
2791
- agentWritableFields: z12.array(z12.string())
2792
- }).strict();
2793
- var NodeTypesListResponseSchema = z12.object({
2794
- nodeTypes: z12.array(NodeTypeSummarySchema)
2795
- }).strict();
2796
-
2797
2892
  // src/commands/nodes/internal.ts
2798
2893
  async function buildNodesClient(opts) {
2799
2894
  const cfg = await loadConfig({
@@ -2962,36 +3057,6 @@ async function buildTemplateClient(opts) {
2962
3057
  });
2963
3058
  }
2964
3059
 
2965
- // src/schemas/templates.ts
2966
- import { z as z14 } from "zod";
2967
- var DeclaredParamSchema = z14.object({
2968
- name: z14.string(),
2969
- type: z14.string(),
2970
- required: z14.boolean(),
2971
- defaultValue: z14.string().nullable().optional(),
2972
- enumValues: z14.array(z14.string()).nullable().optional(),
2973
- description: z14.string().nullable().optional()
2974
- }).strict();
2975
- var TemplateSummarySchema = z14.object({
2976
- id: z14.string().uuid(),
2977
- source: z14.enum(["own", "system"]),
2978
- name: z14.string(),
2979
- description: z14.string().nullable(),
2980
- category: z14.string().nullable(),
2981
- thumbnailUrl: z14.string().nullable(),
2982
- tags: z14.array(z14.string()),
2983
- createdAt: z14.string()
2984
- }).strict();
2985
- var TemplateDetailSchema = TemplateSummarySchema.extend({
2986
- declaredParams: z14.array(DeclaredParamSchema),
2987
- timesUsed: z14.number()
2988
- }).strict();
2989
- var TemplatesListResponseSchema = z14.object({
2990
- templates: z14.array(TemplateSummarySchema),
2991
- cursor: z14.string().nullable(),
2992
- hasMore: z14.boolean()
2993
- }).strict();
2994
-
2995
3060
  // src/commands/template/list.ts
2996
3061
  async function listTemplates(opts) {
2997
3062
  const client = opts.client ?? await buildTemplateClient(opts);
@@ -3064,55 +3129,6 @@ async function listTokens(options) {
3064
3129
  return data;
3065
3130
  }
3066
3131
 
3067
- // src/schemas/workflows.ts
3068
- import { z as z16 } from "zod";
3069
- var WorkflowDeclaredParamSchema = z16.object({
3070
- name: z16.string(),
3071
- type: z16.string(),
3072
- required: z16.boolean().optional(),
3073
- defaultValue: z16.unknown().optional(),
3074
- description: z16.unknown().optional()
3075
- }).passthrough();
3076
- var WorkflowSummarySchema = z16.object({
3077
- id: z16.string().uuid(),
3078
- name: z16.string(),
3079
- tags: z16.array(z16.string()),
3080
- declared_params: z16.array(WorkflowDeclaredParamSchema).nullable().default([]),
3081
- canvas_rev: z16.number().int().nonnegative(),
3082
- updated_at: z16.string()
3083
- }).strict();
3084
- var WorkflowsListResponseSchema = z16.object({
3085
- items: z16.array(WorkflowSummarySchema),
3086
- nextCursor: z16.string().nullable()
3087
- }).strict();
3088
- var WorkflowDetailSchema = z16.object({
3089
- id: z16.string().uuid(),
3090
- name: z16.string(),
3091
- description: z16.string().nullable(),
3092
- tags: z16.array(z16.string()),
3093
- declared_params: z16.array(WorkflowDeclaredParamSchema).nullable().default([]),
3094
- canvas_rev: z16.number().int().nonnegative(),
3095
- nodes: z16.array(z16.unknown()),
3096
- edges: z16.array(z16.unknown()),
3097
- created_at: z16.string(),
3098
- updated_at: z16.string()
3099
- }).strict();
3100
- var WorkflowCreateResponseSchema = z16.object({
3101
- id: z16.string().uuid(),
3102
- name: z16.string(),
3103
- description: z16.string().nullable(),
3104
- tags: z16.array(z16.string()),
3105
- declared_params: z16.array(WorkflowDeclaredParamSchema).nullable().default([]),
3106
- canvas_rev: z16.number().int().nonnegative(),
3107
- created_at: z16.string(),
3108
- updated_at: z16.string()
3109
- }).strict();
3110
- var WorkflowMutateResponseSchema = z16.object({
3111
- canvas_rev: z16.number().int().nonnegative(),
3112
- applied: z16.number().int().nonnegative(),
3113
- workflow: WorkflowDetailSchema
3114
- }).strict();
3115
-
3116
3132
  // src/commands/workflow/internal.ts
3117
3133
  async function buildWorkflowClient(opts) {
3118
3134
  const cfg = await loadConfig({