@clickraft/cli 0.8.3 → 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/CHANGELOG.md +1 -5
- package/dist/cli.js +121 -73
- package/dist/cli.js.map +1 -1
- package/dist/index.js +121 -73
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
## [0.8.
|
|
2
|
-
|
|
3
|
-
### Bug Fixes
|
|
4
|
-
|
|
5
|
-
* **cli:** bundle @clickraft/sdk into the CLI artifact so the published package is self-contained ([14e5c47](https://github.com/clickraft/cli/commit/14e5c47d0753156ea0ad937f9bf66ea3a9fa4d4e))
|
|
1
|
+
## [0.8.4](https://github.com/clickraft/cli/compare/v0.8.3...v0.8.4) (2026-05-31)
|
|
6
2
|
|
|
7
3
|
# Changelog
|
|
8
4
|
|
package/dist/cli.js
CHANGED
|
@@ -81,6 +81,127 @@ var TokenRowSchema = z4.object({
|
|
|
81
81
|
createdAt: z4.string()
|
|
82
82
|
}).strict();
|
|
83
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
|
+
}
|
|
84
205
|
|
|
85
206
|
// src/api/client.ts
|
|
86
207
|
import { request as undiciRequest } from "undici";
|
|
@@ -498,15 +619,6 @@ var EXIT_CODE_MAP = {
|
|
|
498
619
|
hint: "Server response did not match the expected schema. Update the CLI."
|
|
499
620
|
}
|
|
500
621
|
};
|
|
501
|
-
var CLI_ONLY_CODES = /* @__PURE__ */ new Set([
|
|
502
|
-
"NETWORK_ERROR",
|
|
503
|
-
"TIMEOUT",
|
|
504
|
-
"PARSE_ERROR",
|
|
505
|
-
"SCHEMA_MISMATCH"
|
|
506
|
-
]);
|
|
507
|
-
var KNOWN_SERVER_CODES = new Set(
|
|
508
|
-
Object.keys(EXIT_CODE_MAP).filter((k) => !CLI_ONLY_CODES.has(k))
|
|
509
|
-
);
|
|
510
622
|
function getExitCode(code) {
|
|
511
623
|
return EXIT_CODE_MAP[code]?.exitCode ?? 1;
|
|
512
624
|
}
|
|
@@ -632,18 +744,6 @@ var ServerErrorBodySchema = z5.object({
|
|
|
632
744
|
}).strict();
|
|
633
745
|
|
|
634
746
|
// src/api/client.ts
|
|
635
|
-
var ApiError = class extends Error {
|
|
636
|
-
code;
|
|
637
|
-
meta;
|
|
638
|
-
cause;
|
|
639
|
-
constructor(code, message, meta, cause) {
|
|
640
|
-
super(message);
|
|
641
|
-
this.name = "ApiError";
|
|
642
|
-
this.code = code;
|
|
643
|
-
this.meta = meta;
|
|
644
|
-
this.cause = cause;
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
747
|
var REDACT_BODY_LIMIT = 1024;
|
|
648
748
|
var REDACT_INPUT_CAP = 100 * 1024;
|
|
649
749
|
var DEFAULT_USER_AGENT = "clickraft-cli";
|
|
@@ -1757,58 +1857,6 @@ function isUrlLike(value) {
|
|
|
1757
1857
|
return value.startsWith("http://") || value.startsWith("https://");
|
|
1758
1858
|
}
|
|
1759
1859
|
|
|
1760
|
-
// src/cli/long-poll.ts
|
|
1761
|
-
async function longPoll(opts) {
|
|
1762
|
-
const now = opts.now ?? Date.now;
|
|
1763
|
-
const started = now();
|
|
1764
|
-
for (; ; ) {
|
|
1765
|
-
if (opts.signal?.aborted) {
|
|
1766
|
-
throw new ApiError("TIMEOUT", "Wait was aborted.", { retryable: true });
|
|
1767
|
-
}
|
|
1768
|
-
const elapsedBefore = now() - started;
|
|
1769
|
-
if (elapsedBefore >= opts.timeoutMs) {
|
|
1770
|
-
throw new ApiError(
|
|
1771
|
-
"TIMEOUT",
|
|
1772
|
-
`Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
|
|
1773
|
-
{ retryable: true }
|
|
1774
|
-
);
|
|
1775
|
-
}
|
|
1776
|
-
const remainingMs = opts.timeoutMs - elapsedBefore;
|
|
1777
|
-
const iterationSignal = composeIterationSignal(opts.signal, remainingMs);
|
|
1778
|
-
let result;
|
|
1779
|
-
try {
|
|
1780
|
-
result = await opts.fetcher({ signal: iterationSignal });
|
|
1781
|
-
} catch (err) {
|
|
1782
|
-
if (opts.signal?.aborted || now() - started >= opts.timeoutMs) {
|
|
1783
|
-
throw new ApiError(
|
|
1784
|
-
"TIMEOUT",
|
|
1785
|
-
`Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
|
|
1786
|
-
{ retryable: true }
|
|
1787
|
-
);
|
|
1788
|
-
}
|
|
1789
|
-
throw err;
|
|
1790
|
-
}
|
|
1791
|
-
if (opts.signal?.aborted) {
|
|
1792
|
-
throw new ApiError("TIMEOUT", "Wait was aborted.", { retryable: true });
|
|
1793
|
-
}
|
|
1794
|
-
const elapsedAfter = now() - started;
|
|
1795
|
-
if (elapsedAfter >= opts.timeoutMs) {
|
|
1796
|
-
throw new ApiError(
|
|
1797
|
-
"TIMEOUT",
|
|
1798
|
-
`Wait exceeded ${opts.timeoutMs}ms without reaching a terminal state.`,
|
|
1799
|
-
{ retryable: true }
|
|
1800
|
-
);
|
|
1801
|
-
}
|
|
1802
|
-
if (opts.isTerminal(result)) {
|
|
1803
|
-
return result;
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
function composeIterationSignal(userSignal, remainingMs) {
|
|
1808
|
-
const deadlineSignal = AbortSignal.timeout(Math.max(remainingMs, 0));
|
|
1809
|
-
return userSignal ? AbortSignal.any([userSignal, deadlineSignal]) : deadlineSignal;
|
|
1810
|
-
}
|
|
1811
|
-
|
|
1812
1860
|
// src/commands/generate/get.ts
|
|
1813
1861
|
async function generateGet(opts) {
|
|
1814
1862
|
const client = opts.client ?? await buildGenerateClient(opts);
|