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