@kenkaiiii/gg-boss 4.6.0 → 4.6.1
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.
|
@@ -63365,21 +63365,21 @@ var StreamResult = class {
|
|
|
63365
63365
|
resolveResponse;
|
|
63366
63366
|
rejectResponse;
|
|
63367
63367
|
resolveWait = null;
|
|
63368
|
-
constructor(generator) {
|
|
63368
|
+
constructor(generator, signal) {
|
|
63369
63369
|
this.response = new Promise((resolve2, reject) => {
|
|
63370
63370
|
this.resolveResponse = resolve2;
|
|
63371
63371
|
this.rejectResponse = reject;
|
|
63372
63372
|
});
|
|
63373
|
-
this.pump(generator);
|
|
63373
|
+
this.pump(generator, signal);
|
|
63374
63374
|
}
|
|
63375
|
-
async pump(generator) {
|
|
63375
|
+
async pump(generator, signal) {
|
|
63376
63376
|
try {
|
|
63377
|
-
let next = await
|
|
63377
|
+
let next = await this._nextWithAbort(generator, signal);
|
|
63378
63378
|
while (!next.done) {
|
|
63379
63379
|
this.buffer.push(next.value);
|
|
63380
63380
|
this.resolveWait?.();
|
|
63381
63381
|
this.resolveWait = null;
|
|
63382
|
-
next = await
|
|
63382
|
+
next = await this._nextWithAbort(generator, signal);
|
|
63383
63383
|
}
|
|
63384
63384
|
this.done = true;
|
|
63385
63385
|
this.resolveResponse(next.value);
|
|
@@ -63394,6 +63394,28 @@ var StreamResult = class {
|
|
|
63394
63394
|
this.resolveWait = null;
|
|
63395
63395
|
}
|
|
63396
63396
|
}
|
|
63397
|
+
async _nextWithAbort(generator, signal) {
|
|
63398
|
+
if (!signal) {
|
|
63399
|
+
return generator.next();
|
|
63400
|
+
}
|
|
63401
|
+
if (signal.aborted) {
|
|
63402
|
+
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
63403
|
+
}
|
|
63404
|
+
let onAbort;
|
|
63405
|
+
const abortPromise = new Promise((_, reject) => {
|
|
63406
|
+
onAbort = () => {
|
|
63407
|
+
generator.return?.(void 0).catch(() => {
|
|
63408
|
+
});
|
|
63409
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
63410
|
+
};
|
|
63411
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
63412
|
+
});
|
|
63413
|
+
try {
|
|
63414
|
+
return await Promise.race([generator.next(), abortPromise]);
|
|
63415
|
+
} finally {
|
|
63416
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
63417
|
+
}
|
|
63418
|
+
}
|
|
63397
63419
|
async *[Symbol.asyncIterator]() {
|
|
63398
63420
|
let index = 0;
|
|
63399
63421
|
while (true) {
|
|
@@ -64001,10 +64023,10 @@ function createClient(options) {
|
|
|
64001
64023
|
...isOAuth ? { apiKey: null, authToken: options.apiKey } : { apiKey: options.apiKey },
|
|
64002
64024
|
...options.baseUrl ? { baseURL: options.baseUrl } : {},
|
|
64003
64025
|
...options.fetch ? { fetch: options.fetch } : {},
|
|
64004
|
-
//
|
|
64005
|
-
//
|
|
64006
|
-
//
|
|
64007
|
-
maxRetries:
|
|
64026
|
+
// Disable SDK retries — the agent loop has its own stall/overload retry
|
|
64027
|
+
// logic that surfaces errors properly. SDK retries on 429s can cause
|
|
64028
|
+
// multi-minute hangs when the provider stops responding mid-retry.
|
|
64029
|
+
maxRetries: 0,
|
|
64008
64030
|
...isOAuth ? {
|
|
64009
64031
|
defaultHeaders: {
|
|
64010
64032
|
// Anthropic's OAuth edge validates the claude-cli version. Callers
|
|
@@ -64017,7 +64039,7 @@ function createClient(options) {
|
|
|
64017
64039
|
});
|
|
64018
64040
|
}
|
|
64019
64041
|
function streamAnthropic(options) {
|
|
64020
|
-
return new StreamResult(runStream(options));
|
|
64042
|
+
return new StreamResult(runStream(options), options.signal);
|
|
64021
64043
|
}
|
|
64022
64044
|
async function* runStream(options) {
|
|
64023
64045
|
const client = createClient(options);
|
|
@@ -64112,7 +64134,6 @@ async function* runStream(options) {
|
|
|
64112
64134
|
throw toError(err);
|
|
64113
64135
|
}
|
|
64114
64136
|
}
|
|
64115
|
-
const stream2 = client.messages.stream(params, requestOptions);
|
|
64116
64137
|
const contentParts = [];
|
|
64117
64138
|
const blocks = /* @__PURE__ */ new Map();
|
|
64118
64139
|
let inputTokens = 0;
|
|
@@ -64121,8 +64142,14 @@ async function* runStream(options) {
|
|
|
64121
64142
|
let cacheWrite;
|
|
64122
64143
|
let stopReason = null;
|
|
64123
64144
|
const keepalive = { type: "keepalive" };
|
|
64145
|
+
let receivedAnyEvent = false;
|
|
64124
64146
|
try {
|
|
64147
|
+
const stream2 = await client.messages.create(
|
|
64148
|
+
params,
|
|
64149
|
+
requestOptions
|
|
64150
|
+
);
|
|
64125
64151
|
for await (const event of stream2) {
|
|
64152
|
+
receivedAnyEvent = true;
|
|
64126
64153
|
switch (event.type) {
|
|
64127
64154
|
case "message_start": {
|
|
64128
64155
|
const usage = event.message.usage;
|
|
@@ -64159,7 +64186,7 @@ async function* runStream(options) {
|
|
|
64159
64186
|
accum.toolId = block2.id;
|
|
64160
64187
|
accum.toolName = block2.name;
|
|
64161
64188
|
accum.input = block2.input;
|
|
64162
|
-
} else if (block2.type
|
|
64189
|
+
} else if (block2.type !== "text" && block2.type !== "thinking") {
|
|
64163
64190
|
accum.raw = block2;
|
|
64164
64191
|
}
|
|
64165
64192
|
blocks.set(idx, accum);
|
|
@@ -64256,8 +64283,7 @@ async function* runStream(options) {
|
|
|
64256
64283
|
contentParts.push({ type: "raw", data: accum.raw });
|
|
64257
64284
|
yield keepalive;
|
|
64258
64285
|
} else {
|
|
64259
|
-
const
|
|
64260
|
-
const rawBlock = msg?.content[event.index];
|
|
64286
|
+
const rawBlock = accum.raw;
|
|
64261
64287
|
if (rawBlock) {
|
|
64262
64288
|
const blockType = rawBlock.type;
|
|
64263
64289
|
if (blockType === "web_search_tool_result") {
|
|
@@ -64303,6 +64329,11 @@ async function* runStream(options) {
|
|
|
64303
64329
|
} catch (err) {
|
|
64304
64330
|
throw toError(err);
|
|
64305
64331
|
}
|
|
64332
|
+
if (!receivedAnyEvent) {
|
|
64333
|
+
throw new ProviderError("anthropic", "Stream ended without producing any events.", {
|
|
64334
|
+
statusCode: 504
|
|
64335
|
+
});
|
|
64336
|
+
}
|
|
64306
64337
|
const normalizedStop = normalizeAnthropicStopReason(stopReason);
|
|
64307
64338
|
const response = {
|
|
64308
64339
|
message: {
|
|
@@ -64578,7 +64609,7 @@ function createClient2(options) {
|
|
|
64578
64609
|
});
|
|
64579
64610
|
}
|
|
64580
64611
|
function streamOpenAI(options) {
|
|
64581
|
-
return new StreamResult(runStream2(options));
|
|
64612
|
+
return new StreamResult(runStream2(options), options.signal);
|
|
64582
64613
|
}
|
|
64583
64614
|
async function* runStream2(options) {
|
|
64584
64615
|
const providerName = options.provider ?? "openai";
|
|
@@ -64670,51 +64701,62 @@ async function* runStream2(options) {
|
|
|
64670
64701
|
let outputTokens = 0;
|
|
64671
64702
|
let cacheRead = 0;
|
|
64672
64703
|
let finishReason = null;
|
|
64673
|
-
|
|
64674
|
-
|
|
64675
|
-
|
|
64676
|
-
|
|
64677
|
-
|
|
64678
|
-
|
|
64679
|
-
|
|
64680
|
-
|
|
64681
|
-
|
|
64682
|
-
|
|
64683
|
-
|
|
64684
|
-
|
|
64685
|
-
|
|
64686
|
-
|
|
64687
|
-
|
|
64688
|
-
|
|
64689
|
-
|
|
64690
|
-
|
|
64691
|
-
|
|
64692
|
-
|
|
64693
|
-
|
|
64694
|
-
|
|
64695
|
-
|
|
64696
|
-
|
|
64697
|
-
|
|
64698
|
-
|
|
64699
|
-
|
|
64700
|
-
|
|
64701
|
-
|
|
64702
|
-
|
|
64703
|
-
|
|
64704
|
-
|
|
64705
|
-
|
|
64706
|
-
|
|
64707
|
-
|
|
64708
|
-
accum.
|
|
64709
|
-
|
|
64710
|
-
|
|
64711
|
-
|
|
64712
|
-
|
|
64713
|
-
|
|
64714
|
-
|
|
64704
|
+
let receivedAnyChunk = false;
|
|
64705
|
+
try {
|
|
64706
|
+
for await (const chunk of stream2) {
|
|
64707
|
+
receivedAnyChunk = true;
|
|
64708
|
+
const choice = chunk.choices?.[0];
|
|
64709
|
+
if (chunk.usage) {
|
|
64710
|
+
({ inputTokens, outputTokens, cacheRead } = extractOpenAIUsage(chunk.usage));
|
|
64711
|
+
}
|
|
64712
|
+
if (!choice) continue;
|
|
64713
|
+
if (choice.finish_reason) {
|
|
64714
|
+
finishReason = choice.finish_reason;
|
|
64715
|
+
}
|
|
64716
|
+
const delta = choice.delta;
|
|
64717
|
+
const reasoningContent = delta.reasoning_content;
|
|
64718
|
+
if (typeof reasoningContent === "string" && reasoningContent) {
|
|
64719
|
+
thinkingAccum += reasoningContent;
|
|
64720
|
+
if (options.thinking) {
|
|
64721
|
+
yield { type: "thinking_delta", text: reasoningContent };
|
|
64722
|
+
}
|
|
64723
|
+
}
|
|
64724
|
+
if (delta.content) {
|
|
64725
|
+
textAccum += delta.content;
|
|
64726
|
+
yield { type: "text_delta", text: delta.content };
|
|
64727
|
+
}
|
|
64728
|
+
if (delta.tool_calls) {
|
|
64729
|
+
for (const tc of delta.tool_calls) {
|
|
64730
|
+
let accum = toolCallAccum.get(tc.index);
|
|
64731
|
+
if (!accum) {
|
|
64732
|
+
accum = {
|
|
64733
|
+
id: tc.id ?? "",
|
|
64734
|
+
name: tc.function?.name ?? "",
|
|
64735
|
+
argsJson: ""
|
|
64736
|
+
};
|
|
64737
|
+
toolCallAccum.set(tc.index, accum);
|
|
64738
|
+
}
|
|
64739
|
+
if (tc.id) accum.id = tc.id;
|
|
64740
|
+
if (tc.function?.name) accum.name = tc.function.name;
|
|
64741
|
+
if (tc.function?.arguments) {
|
|
64742
|
+
accum.argsJson += tc.function.arguments;
|
|
64743
|
+
yield {
|
|
64744
|
+
type: "toolcall_delta",
|
|
64745
|
+
id: accum.id,
|
|
64746
|
+
name: accum.name,
|
|
64747
|
+
argsJson: tc.function.arguments
|
|
64748
|
+
};
|
|
64749
|
+
}
|
|
64715
64750
|
}
|
|
64716
64751
|
}
|
|
64717
64752
|
}
|
|
64753
|
+
} catch (err) {
|
|
64754
|
+
throw toError2(err, providerName);
|
|
64755
|
+
}
|
|
64756
|
+
if (!receivedAnyChunk) {
|
|
64757
|
+
throw new ProviderError(providerName, "Stream ended without producing any chunks.", {
|
|
64758
|
+
statusCode: 504
|
|
64759
|
+
});
|
|
64718
64760
|
}
|
|
64719
64761
|
if (thinkingAccum) {
|
|
64720
64762
|
contentParts.push({ type: "thinking", text: thinkingAccum });
|
|
@@ -64948,7 +64990,7 @@ function isVisibleOutputItem(itemType) {
|
|
|
64948
64990
|
return itemType === "message";
|
|
64949
64991
|
}
|
|
64950
64992
|
function streamOpenAICodex(options) {
|
|
64951
|
-
return new StreamResult(runStream3(options));
|
|
64993
|
+
return new StreamResult(runStream3(options), options.signal);
|
|
64952
64994
|
}
|
|
64953
64995
|
async function* runStream3(options) {
|
|
64954
64996
|
const baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
@@ -65278,10 +65320,16 @@ async function* parseSSE(body) {
|
|
|
65278
65320
|
}
|
|
65279
65321
|
}
|
|
65280
65322
|
function remapCodexId(id2, idMap) {
|
|
65281
|
-
if (id2.startsWith("fc_") || id2.startsWith("fc-")) return id2;
|
|
65282
65323
|
const existing = idMap.get(id2);
|
|
65283
65324
|
if (existing) return existing;
|
|
65284
|
-
const
|
|
65325
|
+
const withPrefix = id2.startsWith("fc_") || id2.startsWith("fc-") ? id2 : `fc_${id2.replace(/^toolu_/, "")}`;
|
|
65326
|
+
const sanitized = withPrefix.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
65327
|
+
let mapped = sanitized;
|
|
65328
|
+
let suffix = 2;
|
|
65329
|
+
const used = new Set(idMap.values());
|
|
65330
|
+
while (used.has(mapped)) {
|
|
65331
|
+
mapped = `${sanitized}_${suffix++}`;
|
|
65332
|
+
}
|
|
65285
65333
|
idMap.set(id2, mapped);
|
|
65286
65334
|
return mapped;
|
|
65287
65335
|
}
|
|
@@ -65802,7 +65850,7 @@ async function fetchCodeAssistWithRetry(plan, options) {
|
|
|
65802
65850
|
throw lastError ?? new ProviderError("gemini", "Gemini Code Assist request failed.");
|
|
65803
65851
|
}
|
|
65804
65852
|
function streamGemini(options) {
|
|
65805
|
-
return new StreamResult(runStream4(options));
|
|
65853
|
+
return new StreamResult(runStream4(options), options.signal);
|
|
65806
65854
|
}
|
|
65807
65855
|
async function* runStream4(options) {
|
|
65808
65856
|
const useStreaming = options.streaming !== false;
|
|
@@ -114431,4 +114479,4 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
114431
114479
|
* LICENSE file in the root directory of this source tree.
|
|
114432
114480
|
*)
|
|
114433
114481
|
*/
|
|
114434
|
-
//# sourceMappingURL=chunk-
|
|
114482
|
+
//# sourceMappingURL=chunk-NFL55QLO.js.map
|