@kenkaiiii/gg-ai 5.87.1 → 5.87.2
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.cjs +23 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1806,7 +1806,7 @@ function parseToolArguments(argsJson) {
|
|
|
1806
1806
|
|
|
1807
1807
|
// src/utils/provider-fetch.ts
|
|
1808
1808
|
var import_undici = require("undici");
|
|
1809
|
-
var PROVIDER_TRANSPORT_TIMEOUT_MS =
|
|
1809
|
+
var PROVIDER_TRANSPORT_TIMEOUT_MS = 45 * 6e4;
|
|
1810
1810
|
function nodeUsesEnvProxy({
|
|
1811
1811
|
env = process.env,
|
|
1812
1812
|
execArgv = process.execArgv,
|
|
@@ -1834,6 +1834,25 @@ function createProviderFetch(timeoutMs, { useEnvProxy = nodeUsesEnvProxy() } = {
|
|
|
1834
1834
|
};
|
|
1835
1835
|
return Object.assign(providerFetch2, { Response: globalThis.Response });
|
|
1836
1836
|
}
|
|
1837
|
+
function withBodyActivity(fetchImpl, onActivity) {
|
|
1838
|
+
return async (input, init2) => {
|
|
1839
|
+
const response = await fetchImpl(input, init2);
|
|
1840
|
+
if (!response.body || !response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
1841
|
+
return response;
|
|
1842
|
+
}
|
|
1843
|
+
const tap = new TransformStream({
|
|
1844
|
+
transform(chunk, controller) {
|
|
1845
|
+
onActivity();
|
|
1846
|
+
controller.enqueue(chunk);
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
return new Response(response.body.pipeThrough(tap), {
|
|
1850
|
+
status: response.status,
|
|
1851
|
+
statusText: response.statusText,
|
|
1852
|
+
headers: response.headers
|
|
1853
|
+
});
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1837
1856
|
var providerFetch = createProviderFetch(
|
|
1838
1857
|
PROVIDER_TRANSPORT_TIMEOUT_MS
|
|
1839
1858
|
);
|
|
@@ -2134,8 +2153,10 @@ async function* runStream(options) {
|
|
|
2134
2153
|
const keepalive = { type: "keepalive" };
|
|
2135
2154
|
let receivedAnyEvent = false;
|
|
2136
2155
|
try {
|
|
2156
|
+
const onActivity = options.onTransportActivity;
|
|
2157
|
+
const streamClient = onActivity ? client.withOptions({ fetch: withBodyActivity(options.fetch ?? providerFetch, onActivity) }) : client;
|
|
2137
2158
|
const stream2 = await send(
|
|
2138
|
-
(p, o) =>
|
|
2159
|
+
(p, o) => streamClient.messages.create(p, o)
|
|
2139
2160
|
);
|
|
2140
2161
|
for await (const event of stream2) {
|
|
2141
2162
|
receivedAnyEvent = true;
|