@copilotkitnext/runtime 0.0.22-alpha.7 → 0.0.22-alpha.9
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/{chunk-LATEWAAG.mjs → chunk-S556ZC5H.mjs} +12 -106
- package/dist/chunk-S556ZC5H.mjs.map +1 -0
- package/dist/express.js +45 -162
- package/dist/express.js.map +1 -1
- package/dist/express.mjs +17 -38
- package/dist/express.mjs.map +1 -1
- package/dist/index.js +53 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
- package/dist/chunk-LATEWAAG.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,108 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
VERSION: () => VERSION,
|
|
27
|
-
createCopilotEndpoint: () => createCopilotEndpoint,
|
|
28
|
-
createCopilotEndpointSingleRoute: () => createCopilotEndpointSingleRoute,
|
|
29
|
-
finalizeRunEvents: () => import_shared5.finalizeRunEvents
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(index_exports);
|
|
3
|
+
var rxjs = require('rxjs');
|
|
4
|
+
var client = require('@ag-ui/client');
|
|
5
|
+
var shared = require('@copilotkitnext/shared');
|
|
6
|
+
var hono = require('hono');
|
|
7
|
+
var cors = require('hono/cors');
|
|
8
|
+
var encoder = require('@ag-ui/encoder');
|
|
32
9
|
|
|
33
10
|
// package.json
|
|
34
11
|
var package_default = {
|
|
35
|
-
|
|
36
|
-
version: "0.0.22-alpha.7",
|
|
37
|
-
description: "Server-side runtime package for CopilotKit2",
|
|
38
|
-
main: "dist/index.js",
|
|
39
|
-
types: "dist/index.d.ts",
|
|
40
|
-
exports: {
|
|
41
|
-
".": {
|
|
42
|
-
types: "./dist/index.d.ts",
|
|
43
|
-
import: "./dist/index.mjs",
|
|
44
|
-
require: "./dist/index.js"
|
|
45
|
-
},
|
|
46
|
-
"./express": {
|
|
47
|
-
types: "./dist/express.d.ts",
|
|
48
|
-
import: "./dist/express.mjs",
|
|
49
|
-
require: "./dist/express.js"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
publishConfig: {
|
|
53
|
-
access: "public"
|
|
54
|
-
},
|
|
55
|
-
scripts: {
|
|
56
|
-
build: "tsup",
|
|
57
|
-
prepublishOnly: "pnpm run build",
|
|
58
|
-
dev: "tsup --watch",
|
|
59
|
-
lint: "eslint . --max-warnings 0",
|
|
60
|
-
"check-types": "tsc --noEmit",
|
|
61
|
-
clean: "rm -rf dist",
|
|
62
|
-
test: "vitest run",
|
|
63
|
-
"test:watch": "vitest",
|
|
64
|
-
"test:coverage": "vitest run --coverage"
|
|
65
|
-
},
|
|
66
|
-
devDependencies: {
|
|
67
|
-
"@copilotkitnext/eslint-config": "workspace:*",
|
|
68
|
-
"@copilotkitnext/typescript-config": "workspace:*",
|
|
69
|
-
"@types/cors": "^2.8.17",
|
|
70
|
-
"@types/express": "^4.17.21",
|
|
71
|
-
"@types/node": "^22.15.3",
|
|
72
|
-
eslint: "^9.30.0",
|
|
73
|
-
openai: "^5.9.0",
|
|
74
|
-
supertest: "^7.1.1",
|
|
75
|
-
tsup: "^8.5.0",
|
|
76
|
-
typescript: "5.8.2",
|
|
77
|
-
vitest: "^3.0.5"
|
|
78
|
-
},
|
|
79
|
-
dependencies: {
|
|
80
|
-
"@ag-ui/client": "0.0.41-alpha.0",
|
|
81
|
-
"@ag-ui/core": "0.0.41-alpha.0",
|
|
82
|
-
"@ag-ui/encoder": "0.0.41-alpha.0",
|
|
83
|
-
"@copilotkitnext/shared": "workspace:*",
|
|
84
|
-
cors: "^2.8.5",
|
|
85
|
-
rxjs: "7.8.1"
|
|
86
|
-
},
|
|
87
|
-
peerDependencies: {
|
|
88
|
-
express: "^4.21.2",
|
|
89
|
-
hono: "^4.6.13",
|
|
90
|
-
openai: "^5.9.0"
|
|
91
|
-
},
|
|
92
|
-
peerDependenciesMeta: {},
|
|
93
|
-
engines: {
|
|
94
|
-
node: ">=18"
|
|
95
|
-
}
|
|
96
|
-
};
|
|
12
|
+
version: "0.0.22-alpha.9"};
|
|
97
13
|
|
|
98
14
|
// src/runner/agent-runner.ts
|
|
99
15
|
var AgentRunner = class {
|
|
100
16
|
};
|
|
101
|
-
|
|
102
|
-
// src/runner/in-memory.ts
|
|
103
|
-
var import_rxjs = require("rxjs");
|
|
104
|
-
var import_client = require("@ag-ui/client");
|
|
105
|
-
var import_shared = require("@copilotkitnext/shared");
|
|
106
17
|
var InMemoryEventStore = class {
|
|
107
18
|
constructor(threadId) {
|
|
108
19
|
this.threadId = threadId;
|
|
@@ -149,7 +60,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
149
60
|
if ("messageId" in event && typeof event.messageId === "string") {
|
|
150
61
|
historicMessageIds.add(event.messageId);
|
|
151
62
|
}
|
|
152
|
-
if (event.type ===
|
|
63
|
+
if (event.type === client.EventType.RUN_STARTED) {
|
|
153
64
|
const runStarted = event;
|
|
154
65
|
const messages = runStarted.input?.messages ?? [];
|
|
155
66
|
for (const message of messages) {
|
|
@@ -158,10 +69,10 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
158
69
|
}
|
|
159
70
|
}
|
|
160
71
|
}
|
|
161
|
-
const nextSubject = new
|
|
72
|
+
const nextSubject = new rxjs.ReplaySubject(Infinity);
|
|
162
73
|
const prevSubject = store.subject;
|
|
163
74
|
store.subject = nextSubject;
|
|
164
|
-
const runSubject = new
|
|
75
|
+
const runSubject = new rxjs.ReplaySubject(Infinity);
|
|
165
76
|
store.runSubject = runSubject;
|
|
166
77
|
const runAgent = async () => {
|
|
167
78
|
const lastRun = store.historicRuns[store.historicRuns.length - 1];
|
|
@@ -170,7 +81,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
170
81
|
await request.agent.runAgent(request.input, {
|
|
171
82
|
onEvent: ({ event }) => {
|
|
172
83
|
let processedEvent = event;
|
|
173
|
-
if (event.type ===
|
|
84
|
+
if (event.type === client.EventType.RUN_STARTED) {
|
|
174
85
|
const runStartedEvent = event;
|
|
175
86
|
if (!runStartedEvent.input) {
|
|
176
87
|
const sanitizedMessages = request.input.messages ? request.input.messages.filter(
|
|
@@ -205,7 +116,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
205
116
|
}
|
|
206
117
|
}
|
|
207
118
|
});
|
|
208
|
-
const appendedEvents =
|
|
119
|
+
const appendedEvents = shared.finalizeRunEvents(currentRunEvents, {
|
|
209
120
|
stopRequested: store.stopRequested
|
|
210
121
|
});
|
|
211
122
|
for (const event of appendedEvents) {
|
|
@@ -213,7 +124,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
213
124
|
nextSubject.next(event);
|
|
214
125
|
}
|
|
215
126
|
if (store.currentRunId) {
|
|
216
|
-
const compactedEvents =
|
|
127
|
+
const compactedEvents = client.compactEvents(currentRunEvents);
|
|
217
128
|
store.historicRuns.push({
|
|
218
129
|
threadId: request.threadId,
|
|
219
130
|
runId: store.currentRunId,
|
|
@@ -231,7 +142,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
231
142
|
runSubject.complete();
|
|
232
143
|
nextSubject.complete();
|
|
233
144
|
} catch {
|
|
234
|
-
const appendedEvents =
|
|
145
|
+
const appendedEvents = shared.finalizeRunEvents(currentRunEvents, {
|
|
235
146
|
stopRequested: store.stopRequested
|
|
236
147
|
});
|
|
237
148
|
for (const event of appendedEvents) {
|
|
@@ -239,7 +150,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
239
150
|
nextSubject.next(event);
|
|
240
151
|
}
|
|
241
152
|
if (store.currentRunId && currentRunEvents.length > 0) {
|
|
242
|
-
const compactedEvents =
|
|
153
|
+
const compactedEvents = client.compactEvents(currentRunEvents);
|
|
243
154
|
store.historicRuns.push({
|
|
244
155
|
threadId: request.threadId,
|
|
245
156
|
runId: store.currentRunId,
|
|
@@ -271,7 +182,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
271
182
|
}
|
|
272
183
|
connect(request) {
|
|
273
184
|
const store = GLOBAL_STORE.get(request.threadId);
|
|
274
|
-
const connectionSubject = new
|
|
185
|
+
const connectionSubject = new rxjs.ReplaySubject(Infinity);
|
|
275
186
|
if (!store) {
|
|
276
187
|
connectionSubject.complete();
|
|
277
188
|
return connectionSubject.asObservable();
|
|
@@ -280,7 +191,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
|
|
|
280
191
|
for (const run of store.historicRuns) {
|
|
281
192
|
allHistoricEvents.push(...run.events);
|
|
282
193
|
}
|
|
283
|
-
const compactedEvents =
|
|
194
|
+
const compactedEvents = client.compactEvents(allHistoricEvents);
|
|
284
195
|
const emittedMessageIds = /* @__PURE__ */ new Set();
|
|
285
196
|
for (const event of compactedEvents) {
|
|
286
197
|
connectionSubject.next(event);
|
|
@@ -358,14 +269,6 @@ var CopilotRuntime = class {
|
|
|
358
269
|
this.runner = runner ?? new InMemoryAgentRunner();
|
|
359
270
|
}
|
|
360
271
|
};
|
|
361
|
-
|
|
362
|
-
// src/endpoints/hono.ts
|
|
363
|
-
var import_hono = require("hono");
|
|
364
|
-
var import_cors = require("hono/cors");
|
|
365
|
-
|
|
366
|
-
// src/handlers/handle-run.ts
|
|
367
|
-
var import_client2 = require("@ag-ui/client");
|
|
368
|
-
var import_encoder = require("@ag-ui/encoder");
|
|
369
272
|
async function handleRunAgent({
|
|
370
273
|
runtime,
|
|
371
274
|
request,
|
|
@@ -405,13 +308,13 @@ async function handleRunAgent({
|
|
|
405
308
|
}
|
|
406
309
|
const stream = new TransformStream();
|
|
407
310
|
const writer = stream.writable.getWriter();
|
|
408
|
-
const encoder = new
|
|
311
|
+
const encoder$1 = new encoder.EventEncoder();
|
|
409
312
|
let streamClosed = false;
|
|
410
313
|
(async () => {
|
|
411
314
|
let input;
|
|
412
315
|
try {
|
|
413
316
|
const requestBody = await request.json();
|
|
414
|
-
input =
|
|
317
|
+
input = client.RunAgentInputSchema.parse(requestBody);
|
|
415
318
|
} catch {
|
|
416
319
|
return new Response(
|
|
417
320
|
JSON.stringify({
|
|
@@ -431,7 +334,7 @@ async function handleRunAgent({
|
|
|
431
334
|
next: async (event) => {
|
|
432
335
|
if (!request.signal.aborted && !streamClosed) {
|
|
433
336
|
try {
|
|
434
|
-
await writer.write(encoder.encode(event));
|
|
337
|
+
await writer.write(encoder$1.encode(event));
|
|
435
338
|
} catch (error) {
|
|
436
339
|
if (error instanceof Error && error.name === "AbortError") {
|
|
437
340
|
streamClosed = true;
|
|
@@ -647,12 +550,6 @@ async function handleTranscribe({
|
|
|
647
550
|
);
|
|
648
551
|
}
|
|
649
552
|
}
|
|
650
|
-
|
|
651
|
-
// src/endpoints/hono.ts
|
|
652
|
-
var import_shared3 = require("@copilotkitnext/shared");
|
|
653
|
-
|
|
654
|
-
// src/middleware.ts
|
|
655
|
-
var import_shared2 = require("@copilotkitnext/shared");
|
|
656
553
|
async function callBeforeRequestMiddleware({
|
|
657
554
|
runtime,
|
|
658
555
|
request,
|
|
@@ -663,7 +560,7 @@ async function callBeforeRequestMiddleware({
|
|
|
663
560
|
if (typeof mw === "function") {
|
|
664
561
|
return mw({ runtime, request, path });
|
|
665
562
|
}
|
|
666
|
-
|
|
563
|
+
shared.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value \u2013 skipped");
|
|
667
564
|
return;
|
|
668
565
|
}
|
|
669
566
|
async function callAfterRequestMiddleware({
|
|
@@ -676,12 +573,8 @@ async function callAfterRequestMiddleware({
|
|
|
676
573
|
if (typeof mw === "function") {
|
|
677
574
|
return mw({ runtime, response, path });
|
|
678
575
|
}
|
|
679
|
-
|
|
576
|
+
shared.logger.warn({ mw }, "Unsupported afterRequestMiddleware value \u2013 skipped");
|
|
680
577
|
}
|
|
681
|
-
|
|
682
|
-
// src/handlers/handle-connect.ts
|
|
683
|
-
var import_client3 = require("@ag-ui/client");
|
|
684
|
-
var import_encoder2 = require("@ag-ui/encoder");
|
|
685
578
|
async function handleConnectAgent({
|
|
686
579
|
runtime,
|
|
687
580
|
request,
|
|
@@ -703,13 +596,13 @@ async function handleConnectAgent({
|
|
|
703
596
|
}
|
|
704
597
|
const stream = new TransformStream();
|
|
705
598
|
const writer = stream.writable.getWriter();
|
|
706
|
-
const encoder = new
|
|
599
|
+
const encoder$1 = new encoder.EventEncoder();
|
|
707
600
|
let streamClosed = false;
|
|
708
601
|
(async () => {
|
|
709
602
|
let input;
|
|
710
603
|
try {
|
|
711
604
|
const requestBody = await request.json();
|
|
712
|
-
input =
|
|
605
|
+
input = client.RunAgentInputSchema.parse(requestBody);
|
|
713
606
|
} catch {
|
|
714
607
|
return new Response(
|
|
715
608
|
JSON.stringify({
|
|
@@ -724,7 +617,7 @@ async function handleConnectAgent({
|
|
|
724
617
|
next: async (event) => {
|
|
725
618
|
if (!request.signal.aborted && !streamClosed) {
|
|
726
619
|
try {
|
|
727
|
-
await writer.write(encoder.encode(event));
|
|
620
|
+
await writer.write(encoder$1.encode(event));
|
|
728
621
|
} catch (error) {
|
|
729
622
|
if (error instanceof Error && error.name === "AbortError") {
|
|
730
623
|
streamClosed = true;
|
|
@@ -802,9 +695,6 @@ async function handleConnectAgent({
|
|
|
802
695
|
);
|
|
803
696
|
}
|
|
804
697
|
}
|
|
805
|
-
|
|
806
|
-
// src/handlers/handle-stop.ts
|
|
807
|
-
var import_client4 = require("@ag-ui/client");
|
|
808
698
|
async function handleStopAgent({
|
|
809
699
|
runtime,
|
|
810
700
|
request,
|
|
@@ -842,7 +732,7 @@ async function handleStopAgent({
|
|
|
842
732
|
JSON.stringify({
|
|
843
733
|
stopped: true,
|
|
844
734
|
interrupt: {
|
|
845
|
-
type:
|
|
735
|
+
type: client.EventType.RUN_ERROR,
|
|
846
736
|
message: "Run stopped by user",
|
|
847
737
|
code: "STOPPED"
|
|
848
738
|
}
|
|
@@ -869,10 +759,10 @@ async function handleStopAgent({
|
|
|
869
759
|
|
|
870
760
|
// src/endpoints/hono.ts
|
|
871
761
|
function createCopilotEndpoint({ runtime, basePath }) {
|
|
872
|
-
const app = new
|
|
762
|
+
const app = new hono.Hono();
|
|
873
763
|
return app.basePath(basePath).use(
|
|
874
764
|
"*",
|
|
875
|
-
|
|
765
|
+
cors.cors({
|
|
876
766
|
origin: "*",
|
|
877
767
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
|
|
878
768
|
allowHeaders: ["*"]
|
|
@@ -890,7 +780,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
890
780
|
c.set("modifiedRequest", maybeModifiedRequest);
|
|
891
781
|
}
|
|
892
782
|
} catch (error) {
|
|
893
|
-
|
|
783
|
+
shared.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
|
|
894
784
|
if (error instanceof Response) {
|
|
895
785
|
return error;
|
|
896
786
|
}
|
|
@@ -906,7 +796,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
906
796
|
response,
|
|
907
797
|
path
|
|
908
798
|
}).catch((error) => {
|
|
909
|
-
|
|
799
|
+
shared.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
|
|
910
800
|
});
|
|
911
801
|
}).post("/agent/:agentId/run", async (c) => {
|
|
912
802
|
const agentId = c.req.param("agentId");
|
|
@@ -918,7 +808,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
918
808
|
agentId
|
|
919
809
|
});
|
|
920
810
|
} catch (error) {
|
|
921
|
-
|
|
811
|
+
shared.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
922
812
|
throw error;
|
|
923
813
|
}
|
|
924
814
|
}).post("/agent/:agentId/connect", async (c) => {
|
|
@@ -931,7 +821,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
931
821
|
agentId
|
|
932
822
|
});
|
|
933
823
|
} catch (error) {
|
|
934
|
-
|
|
824
|
+
shared.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
935
825
|
throw error;
|
|
936
826
|
}
|
|
937
827
|
}).post("/agent/:agentId/stop/:threadId", async (c) => {
|
|
@@ -946,7 +836,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
946
836
|
threadId
|
|
947
837
|
});
|
|
948
838
|
} catch (error) {
|
|
949
|
-
|
|
839
|
+
shared.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
950
840
|
throw error;
|
|
951
841
|
}
|
|
952
842
|
}).get("/info", async (c) => {
|
|
@@ -957,7 +847,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
957
847
|
request
|
|
958
848
|
});
|
|
959
849
|
} catch (error) {
|
|
960
|
-
|
|
850
|
+
shared.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
961
851
|
throw error;
|
|
962
852
|
}
|
|
963
853
|
}).post("/transcribe", async (c) => {
|
|
@@ -968,7 +858,7 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
968
858
|
request
|
|
969
859
|
});
|
|
970
860
|
} catch (error) {
|
|
971
|
-
|
|
861
|
+
shared.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
972
862
|
throw error;
|
|
973
863
|
}
|
|
974
864
|
}).notFound((c) => {
|
|
@@ -976,11 +866,6 @@ function createCopilotEndpoint({ runtime, basePath }) {
|
|
|
976
866
|
});
|
|
977
867
|
}
|
|
978
868
|
|
|
979
|
-
// src/endpoints/hono-single.ts
|
|
980
|
-
var import_hono2 = require("hono");
|
|
981
|
-
var import_cors2 = require("hono/cors");
|
|
982
|
-
var import_shared4 = require("@copilotkitnext/shared");
|
|
983
|
-
|
|
984
869
|
// src/endpoints/single-route-helpers.ts
|
|
985
870
|
var METHOD_NAMES = [
|
|
986
871
|
"agent/run",
|
|
@@ -1067,11 +952,11 @@ function serializeJsonBody(body) {
|
|
|
1067
952
|
|
|
1068
953
|
// src/endpoints/hono-single.ts
|
|
1069
954
|
function createCopilotEndpointSingleRoute({ runtime, basePath }) {
|
|
1070
|
-
const app = new
|
|
955
|
+
const app = new hono.Hono();
|
|
1071
956
|
const routePath = normalizePath(basePath);
|
|
1072
957
|
return app.basePath(routePath).use(
|
|
1073
958
|
"*",
|
|
1074
|
-
|
|
959
|
+
cors.cors({
|
|
1075
960
|
origin: "*",
|
|
1076
961
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
|
|
1077
962
|
allowHeaders: ["*"]
|
|
@@ -1089,7 +974,7 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
|
|
|
1089
974
|
c.set("modifiedRequest", maybeModifiedRequest);
|
|
1090
975
|
}
|
|
1091
976
|
} catch (error) {
|
|
1092
|
-
|
|
977
|
+
shared.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
|
|
1093
978
|
if (error instanceof Response) {
|
|
1094
979
|
return error;
|
|
1095
980
|
}
|
|
@@ -1105,7 +990,7 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
|
|
|
1105
990
|
response,
|
|
1106
991
|
path
|
|
1107
992
|
}).catch((error) => {
|
|
1108
|
-
|
|
993
|
+
shared.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
|
|
1109
994
|
});
|
|
1110
995
|
}).post("/", async (c) => {
|
|
1111
996
|
const request = c.get("modifiedRequest") || c.req.raw;
|
|
@@ -1114,10 +999,10 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
|
|
|
1114
999
|
methodCall = await parseMethodCall(request);
|
|
1115
1000
|
} catch (error) {
|
|
1116
1001
|
if (error instanceof Response) {
|
|
1117
|
-
|
|
1002
|
+
shared.logger.warn({ url: request.url }, "Invalid single-route payload");
|
|
1118
1003
|
return error;
|
|
1119
1004
|
}
|
|
1120
|
-
|
|
1005
|
+
shared.logger.warn({ err: error, url: request.url }, "Invalid single-route payload");
|
|
1121
1006
|
return c.json(
|
|
1122
1007
|
{
|
|
1123
1008
|
error: "invalid_request",
|
|
@@ -1158,7 +1043,7 @@ function createCopilotEndpointSingleRoute({ runtime, basePath }) {
|
|
|
1158
1043
|
if (error instanceof Response) {
|
|
1159
1044
|
return error;
|
|
1160
1045
|
}
|
|
1161
|
-
|
|
1046
|
+
shared.logger.error({ err: error, url: request.url, method: methodCall.method }, "Error running single-route handler");
|
|
1162
1047
|
throw error;
|
|
1163
1048
|
}
|
|
1164
1049
|
}).notFound((c) => {
|
|
@@ -1178,16 +1063,15 @@ function normalizePath(path) {
|
|
|
1178
1063
|
return path;
|
|
1179
1064
|
}
|
|
1180
1065
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
0 && (module.exports = {
|
|
1185
|
-
AgentRunner,
|
|
1186
|
-
CopilotRuntime,
|
|
1187
|
-
InMemoryAgentRunner,
|
|
1188
|
-
VERSION,
|
|
1189
|
-
createCopilotEndpoint,
|
|
1190
|
-
createCopilotEndpointSingleRoute,
|
|
1191
|
-
finalizeRunEvents
|
|
1066
|
+
Object.defineProperty(exports, "finalizeRunEvents", {
|
|
1067
|
+
enumerable: true,
|
|
1068
|
+
get: function () { return shared.finalizeRunEvents; }
|
|
1192
1069
|
});
|
|
1070
|
+
exports.AgentRunner = AgentRunner;
|
|
1071
|
+
exports.CopilotRuntime = CopilotRuntime;
|
|
1072
|
+
exports.InMemoryAgentRunner = InMemoryAgentRunner;
|
|
1073
|
+
exports.VERSION = VERSION;
|
|
1074
|
+
exports.createCopilotEndpoint = createCopilotEndpoint;
|
|
1075
|
+
exports.createCopilotEndpointSingleRoute = createCopilotEndpointSingleRoute;
|
|
1076
|
+
//# sourceMappingURL=index.js.map
|
|
1193
1077
|
//# sourceMappingURL=index.js.map
|