@great-arrow/cli 0.1.54 → 0.1.55
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/index.js +63 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9402,7 +9402,7 @@ function isNodeError(value) {
|
|
|
9402
9402
|
|
|
9403
9403
|
// src/lib/version.ts
|
|
9404
9404
|
var CLI_PACKAGE_NAME = "@great-arrow/cli";
|
|
9405
|
-
var CLI_VERSION = "0.1.
|
|
9405
|
+
var CLI_VERSION = "0.1.55";
|
|
9406
9406
|
var GAD_INSTALL_VERSION = "2026.08.08";
|
|
9407
9407
|
var GAD_INSTALL_MIN_VERSION = "2026.06.22";
|
|
9408
9408
|
var GAD_INSTALL_HEADER = "X-GAD-Install-Version";
|
|
@@ -11180,6 +11180,68 @@ var GadClient = class {
|
|
|
11180
11180
|
}
|
|
11181
11181
|
return payload;
|
|
11182
11182
|
}
|
|
11183
|
+
/**
|
|
11184
|
+
* Own one chat response through body consumption, with the normal workspace
|
|
11185
|
+
* attribution. A received turn is never replayed. The consumer handles either
|
|
11186
|
+
* the versioned local handoff or the actual frontier stream inside this scope.
|
|
11187
|
+
*/
|
|
11188
|
+
async withChatResponse(body, consume, options = {}) {
|
|
11189
|
+
const deadlineMs = options.deadlineMs ?? 3e5;
|
|
11190
|
+
if (!Number.isInteger(deadlineMs) || deadlineMs < 1 || deadlineMs > 3e5) {
|
|
11191
|
+
throw new CliError(
|
|
11192
|
+
"Chat deadline must be between 1 and 300000 milliseconds.",
|
|
11193
|
+
3 /* VALIDATION_ERROR */
|
|
11194
|
+
);
|
|
11195
|
+
}
|
|
11196
|
+
const controller = new AbortController();
|
|
11197
|
+
const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
11198
|
+
const timer = setTimeout(
|
|
11199
|
+
() => controller.abort(new Error("Chat response deadline exceeded.")),
|
|
11200
|
+
deadlineMs
|
|
11201
|
+
);
|
|
11202
|
+
let rejectAbort;
|
|
11203
|
+
let response;
|
|
11204
|
+
const aborted = new Promise((_, reject) => {
|
|
11205
|
+
rejectAbort = () => reject(signal.reason ?? new Error("Chat stopped."));
|
|
11206
|
+
if (signal.aborted) rejectAbort();
|
|
11207
|
+
else signal.addEventListener("abort", rejectAbort, { once: true });
|
|
11208
|
+
});
|
|
11209
|
+
try {
|
|
11210
|
+
return await Promise.race([
|
|
11211
|
+
(async () => {
|
|
11212
|
+
signal.throwIfAborted();
|
|
11213
|
+
response = await fetch(`${this.apiUrl}/api/chat`, {
|
|
11214
|
+
method: "POST",
|
|
11215
|
+
headers: {
|
|
11216
|
+
...this.buildHeaders(),
|
|
11217
|
+
Accept: "text/event-stream, application/json"
|
|
11218
|
+
},
|
|
11219
|
+
body: JSON.stringify(body),
|
|
11220
|
+
redirect: "error",
|
|
11221
|
+
cache: "no-store",
|
|
11222
|
+
signal
|
|
11223
|
+
});
|
|
11224
|
+
signal.throwIfAborted();
|
|
11225
|
+
if (!response.ok) await this.handleResponse(response);
|
|
11226
|
+
return consume(response, signal);
|
|
11227
|
+
})(),
|
|
11228
|
+
aborted
|
|
11229
|
+
]);
|
|
11230
|
+
} finally {
|
|
11231
|
+
clearTimeout(timer);
|
|
11232
|
+
if (rejectAbort) signal.removeEventListener("abort", rejectAbort);
|
|
11233
|
+
controller.abort();
|
|
11234
|
+
const body2 = response?.body;
|
|
11235
|
+
if (body2 && !body2.locked)
|
|
11236
|
+
void (async () => {
|
|
11237
|
+
try {
|
|
11238
|
+
await body2.cancel();
|
|
11239
|
+
} catch (error) {
|
|
11240
|
+
debugSwallow("chat.response.cancel", error);
|
|
11241
|
+
}
|
|
11242
|
+
})();
|
|
11243
|
+
}
|
|
11244
|
+
}
|
|
11183
11245
|
/**
|
|
11184
11246
|
* Make a GET request to a REST API endpoint.
|
|
11185
11247
|
*
|