@copilotkit/aimock 1.35.0 → 1.36.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +22 -0
- package/dist/agui-types.d.cts.map +1 -1
- package/dist/agui-types.d.ts.map +1 -1
- package/dist/cli.cjs +2 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/config-loader.d.cts.map +1 -1
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/fal-audio.cjs +1 -0
- package/dist/fal-audio.cjs.map +1 -1
- package/dist/fal-audio.js +1 -0
- package/dist/fal-audio.js.map +1 -1
- package/dist/fal.cjs +4 -1
- package/dist/fal.cjs.map +1 -1
- package/dist/fal.d.cts.map +1 -1
- package/dist/fal.d.ts.map +1 -1
- package/dist/fal.js +4 -1
- package/dist/fal.js.map +1 -1
- package/dist/provider-auth.cjs +170 -0
- package/dist/provider-auth.cjs.map +1 -0
- package/dist/provider-auth.js +168 -0
- package/dist/provider-auth.js.map +1 -0
- package/dist/recorder.cjs +29 -12
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.d.cts.map +1 -1
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +29 -12
- package/dist/recorder.js.map +1 -1
- package/dist/types.d.cts +13 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vector-types.d.cts.map +1 -1
- package/dist/vector-types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/recorder.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.d.cts","names":[],"sources":["../src/recorder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"recorder.d.cts","names":[],"sources":["../src/recorder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAkIiB,qBAAA;;;QAGT;;UAGS,YAAA;;;;;;;;;;;;;;;;;;mCAkBkB,oCAAoC;;;;;;;;;;;;;;;;;;;;;;KAuB3D,YAAA;;;;;;;;;;;;;;;iBA6MU,cAAA,MACf,MAAA,CAAK,sBACL,MAAA,CAAK,yBACD,oCACI,+CAEH;WAEC;UACD;2BACiB,0BAA0B;+BAG3C,eACT,QAAQ"}
|
package/dist/recorder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recorder.d.ts","names":[],"sources":["../src/recorder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"recorder.d.ts","names":[],"sources":["../src/recorder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAkIiB,qBAAA;;;QAGT;;UAGS,YAAA;;;;;;;;;;;;;;;;;;mCAkBkB,oCAAoC;;;;;;;;;;;;;;;;;;;;;;KAuB3D,YAAA;;;;;;;;;;;;;;;iBA6MU,cAAA,MACf,MAAA,CAAK,sBACL,MAAA,CAAK,yBACD,oCACI,+CAEH;WAEC;UACD;2BACiB,0BAA0B;+BAG3C,eACT,QAAQ"}
|
package/dist/recorder.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getLastMessageByRole, getTextContent } from "./router.js";
|
|
|
5
5
|
import { writeErrorResponse } from "./sse-writer.js";
|
|
6
6
|
import { capturedRedactedData, collapseStreamingResponse } from "./stream-collapse.js";
|
|
7
7
|
import { resolveUpstreamUrl } from "./url.js";
|
|
8
|
+
import { applyProviderAuth } from "./provider-auth.js";
|
|
8
9
|
import * as http$1 from "node:http";
|
|
9
10
|
import * as crypto$1 from "node:crypto";
|
|
10
11
|
import * as https from "node:https";
|
|
@@ -201,7 +202,9 @@ function persistFixture(opts) {
|
|
|
201
202
|
async function proxyAndRecord(req, res, request, providerKey, pathname, fixtures, defaults, rawBody, options) {
|
|
202
203
|
const record = defaults.record;
|
|
203
204
|
if (!record) return "not_configured";
|
|
204
|
-
const
|
|
205
|
+
const providers = record.providers;
|
|
206
|
+
const lookupKey = providerKey === "gemini-interactions" ? "gemini" : providerKey;
|
|
207
|
+
const upstreamUrl = providers[lookupKey];
|
|
205
208
|
if (!upstreamUrl) {
|
|
206
209
|
defaults.logger.warn(`No upstream URL configured for provider "${providerKey}" — cannot proxy`);
|
|
207
210
|
return "not_configured";
|
|
@@ -220,6 +223,7 @@ async function proxyAndRecord(req, res, request, providerKey, pathname, fixtures
|
|
|
220
223
|
}
|
|
221
224
|
defaults.logger.warn(`NO FIXTURE MATCH — proxying to ${upstreamUrl}${pathname}`);
|
|
222
225
|
const forwardHeaders = buildForwardHeaders(req);
|
|
226
|
+
applyProviderAuth(forwardHeaders, target, providerKey, record.providerKeys?.[lookupKey]);
|
|
223
227
|
const requestBody = rawBody ?? JSON.stringify(request);
|
|
224
228
|
let upstreamStatus;
|
|
225
229
|
let upstreamHeaders;
|
|
@@ -231,6 +235,7 @@ async function proxyAndRecord(req, res, request, providerKey, pathname, fixtures
|
|
|
231
235
|
let hardCeilingExceeded = false;
|
|
232
236
|
let streamedToClient = false;
|
|
233
237
|
let clientDisconnected = false;
|
|
238
|
+
let sawDone = false;
|
|
234
239
|
let frameTimestamps = [];
|
|
235
240
|
let streamStartTime = 0;
|
|
236
241
|
const maxProxyBufferBytes = clampMaxBufferBytes(record.maxProxyBufferBytes);
|
|
@@ -246,6 +251,7 @@ async function proxyAndRecord(req, res, request, providerKey, pathname, fixtures
|
|
|
246
251
|
rawBuffer = result.rawBuffer;
|
|
247
252
|
streamedToClient = result.streamedToClient;
|
|
248
253
|
clientDisconnected = result.clientDisconnected;
|
|
254
|
+
sawDone = result.sawDone;
|
|
249
255
|
frameTimestamps = result.frameTimestamps;
|
|
250
256
|
streamStartTime = result.streamStartTime;
|
|
251
257
|
bufferTruncated = result.bufferTruncated;
|
|
@@ -400,8 +406,11 @@ async function proxyAndRecord(req, res, request, providerKey, pathname, fixtures
|
|
|
400
406
|
} else fixtureResponse = buildFixtureResponse(parsedResponse, upstreamStatus, defaults.logger);
|
|
401
407
|
}
|
|
402
408
|
if (clientDisconnected) {
|
|
403
|
-
|
|
404
|
-
|
|
409
|
+
if (!sawDone) {
|
|
410
|
+
defaults.logger.warn("Client disconnected mid-stream — skipping fixture save to avoid truncated data");
|
|
411
|
+
return "relayed";
|
|
412
|
+
}
|
|
413
|
+
defaults.logger.warn("Client closed connection before upstream end — upstream response completed, recording full fixture");
|
|
405
414
|
}
|
|
406
415
|
let recordedTimings;
|
|
407
416
|
if (frameTimestamps.length > 1) {
|
|
@@ -548,6 +557,7 @@ function makeUpstreamRequest(target, headers, body, clientRes, method = "POST",
|
|
|
548
557
|
let binaryFrameBuffer = Buffer.alloc(0);
|
|
549
558
|
let streamedToClient = false;
|
|
550
559
|
let clientDisconnected = false;
|
|
560
|
+
let sawDone = false;
|
|
551
561
|
if (isProgressiveStream && clientRes && !clientRes.headersSent) {
|
|
552
562
|
const relayHeaders = {
|
|
553
563
|
"Cache-Control": "no-cache, no-transform",
|
|
@@ -563,13 +573,15 @@ function makeUpstreamRequest(target, headers, body, clientRes, method = "POST",
|
|
|
563
573
|
clientRes.on("close", () => {
|
|
564
574
|
if (!clientRes.writableFinished) {
|
|
565
575
|
clientDisconnected = true;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
576
|
+
if (!sawDone) {
|
|
577
|
+
req.destroy();
|
|
578
|
+
res.removeListener("data", onUpstreamData);
|
|
579
|
+
chunks.length = 0;
|
|
580
|
+
bufferedBytes = 0;
|
|
581
|
+
frameTimestamps.length = 0;
|
|
582
|
+
frameBuffer = "";
|
|
583
|
+
binaryFrameBuffer = Buffer.alloc(0);
|
|
584
|
+
}
|
|
573
585
|
}
|
|
574
586
|
});
|
|
575
587
|
}
|
|
@@ -621,7 +633,11 @@ function makeUpstreamRequest(target, headers, body, clientRes, method = "POST",
|
|
|
621
633
|
tripTruncation("frame");
|
|
622
634
|
break;
|
|
623
635
|
}
|
|
624
|
-
|
|
636
|
+
const frame = parts[fi].trim();
|
|
637
|
+
if (frame.length > 0) {
|
|
638
|
+
frameTimestamps.push(Date.now());
|
|
639
|
+
if (frame === "data: [DONE]") sawDone = true;
|
|
640
|
+
}
|
|
625
641
|
}
|
|
626
642
|
if (!bufferTruncated) frameBuffer = parts[parts.length - 1];
|
|
627
643
|
}
|
|
@@ -673,7 +689,8 @@ function makeUpstreamRequest(target, headers, body, clientRes, method = "POST",
|
|
|
673
689
|
bufferTruncated,
|
|
674
690
|
truncationCap,
|
|
675
691
|
totalBytes,
|
|
676
|
-
hardCeilingExceeded
|
|
692
|
+
hardCeilingExceeded,
|
|
693
|
+
sawDone
|
|
677
694
|
});
|
|
678
695
|
});
|
|
679
696
|
});
|