@copilotkitnext/runtime 0.0.17-alpha.0 → 0.0.18

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.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { MaybePromise, NonEmptyRecord } from '@copilotkitnext/shared';
2
+ export { finalizeRunEvents } from '@copilotkitnext/shared';
2
3
  import { AbstractAgent, RunAgentInput, BaseEvent } from '@ag-ui/client';
3
4
  import { Observable } from 'rxjs';
4
5
  import * as hono_hono_base from 'hono/hono-base';
@@ -18,8 +19,6 @@ import * as hono_utils_http_status from 'hono/utils/http-status';
18
19
  * • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.
19
20
  */
20
21
 
21
- /** A string beginning with http:// or https:// that points to a webhook endpoint. */
22
- type MiddlewareURL = `${"http" | "https"}://${string}`;
23
22
  interface BeforeRequestMiddlewareParameters {
24
23
  runtime: CopilotRuntime;
25
24
  request: Request;
@@ -35,8 +34,8 @@ type AfterRequestMiddlewareFn = (params: AfterRequestMiddlewareParameters) => Ma
35
34
  /**
36
35
  * A middleware value can be either a callback function or a webhook URL.
37
36
  */
38
- type BeforeRequestMiddleware = BeforeRequestMiddlewareFn | MiddlewareURL;
39
- type AfterRequestMiddleware = AfterRequestMiddlewareFn | MiddlewareURL;
37
+ type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;
38
+ type AfterRequestMiddleware = AfterRequestMiddlewareFn;
40
39
 
41
40
  interface TranscribeFileOptions {
42
41
  audioFile: File;
@@ -107,7 +106,7 @@ type CopilotEndpointContext = {
107
106
  modifiedRequest?: Request;
108
107
  };
109
108
  };
110
- declare function createCopilotEndpoint({ runtime, basePath, }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
109
+ declare function createCopilotEndpoint({ runtime, basePath }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
111
110
  [x: `${string}/*`]: {};
112
111
  } & {
113
112
  [x: `${string}/agent/:agentId/run`]: {
@@ -135,6 +134,21 @@ declare function createCopilotEndpoint({ runtime, basePath, }: CopilotEndpointPa
135
134
  status: hono_utils_http_status.StatusCode;
136
135
  };
137
136
  };
137
+ } & {
138
+ [x: `${string}/agent/:agentId/stop/:threadId`]: {
139
+ $post: {
140
+ input: {
141
+ param: {
142
+ agentId: string;
143
+ } & {
144
+ threadId: string;
145
+ };
146
+ };
147
+ output: {};
148
+ outputFormat: string;
149
+ status: hono_utils_http_status.StatusCode;
150
+ };
151
+ };
138
152
  } & {
139
153
  [x: `${string}/info`]: {
140
154
  $get: {
@@ -159,7 +173,7 @@ declare class InMemoryAgentRunner extends AgentRunner {
159
173
  run(request: AgentRunnerRunRequest): Observable<BaseEvent>;
160
174
  connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;
161
175
  isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;
162
- stop(_request: AgentRunnerStopRequest): Promise<boolean | undefined>;
176
+ stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
163
177
  }
164
178
 
165
179
  export { AgentRunner, type AgentRunnerConnectRequest, type AgentRunnerIsRunningRequest, type AgentRunnerRunRequest, type AgentRunnerStopRequest, CopilotRuntime, type CopilotRuntimeOptions, InMemoryAgentRunner, VERSION, createCopilotEndpoint };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { MaybePromise, NonEmptyRecord } from '@copilotkitnext/shared';
2
+ export { finalizeRunEvents } from '@copilotkitnext/shared';
2
3
  import { AbstractAgent, RunAgentInput, BaseEvent } from '@ag-ui/client';
3
4
  import { Observable } from 'rxjs';
4
5
  import * as hono_hono_base from 'hono/hono-base';
@@ -18,8 +19,6 @@ import * as hono_utils_http_status from 'hono/utils/http-status';
18
19
  * • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.
19
20
  */
20
21
 
21
- /** A string beginning with http:// or https:// that points to a webhook endpoint. */
22
- type MiddlewareURL = `${"http" | "https"}://${string}`;
23
22
  interface BeforeRequestMiddlewareParameters {
24
23
  runtime: CopilotRuntime;
25
24
  request: Request;
@@ -35,8 +34,8 @@ type AfterRequestMiddlewareFn = (params: AfterRequestMiddlewareParameters) => Ma
35
34
  /**
36
35
  * A middleware value can be either a callback function or a webhook URL.
37
36
  */
38
- type BeforeRequestMiddleware = BeforeRequestMiddlewareFn | MiddlewareURL;
39
- type AfterRequestMiddleware = AfterRequestMiddlewareFn | MiddlewareURL;
37
+ type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;
38
+ type AfterRequestMiddleware = AfterRequestMiddlewareFn;
40
39
 
41
40
  interface TranscribeFileOptions {
42
41
  audioFile: File;
@@ -107,7 +106,7 @@ type CopilotEndpointContext = {
107
106
  modifiedRequest?: Request;
108
107
  };
109
108
  };
110
- declare function createCopilotEndpoint({ runtime, basePath, }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
109
+ declare function createCopilotEndpoint({ runtime, basePath }: CopilotEndpointParams): hono_hono_base.HonoBase<CopilotEndpointContext, {
111
110
  [x: `${string}/*`]: {};
112
111
  } & {
113
112
  [x: `${string}/agent/:agentId/run`]: {
@@ -135,6 +134,21 @@ declare function createCopilotEndpoint({ runtime, basePath, }: CopilotEndpointPa
135
134
  status: hono_utils_http_status.StatusCode;
136
135
  };
137
136
  };
137
+ } & {
138
+ [x: `${string}/agent/:agentId/stop/:threadId`]: {
139
+ $post: {
140
+ input: {
141
+ param: {
142
+ agentId: string;
143
+ } & {
144
+ threadId: string;
145
+ };
146
+ };
147
+ output: {};
148
+ outputFormat: string;
149
+ status: hono_utils_http_status.StatusCode;
150
+ };
151
+ };
138
152
  } & {
139
153
  [x: `${string}/info`]: {
140
154
  $get: {
@@ -159,7 +173,7 @@ declare class InMemoryAgentRunner extends AgentRunner {
159
173
  run(request: AgentRunnerRunRequest): Observable<BaseEvent>;
160
174
  connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;
161
175
  isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;
162
- stop(_request: AgentRunnerStopRequest): Promise<boolean | undefined>;
176
+ stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
163
177
  }
164
178
 
165
179
  export { AgentRunner, type AgentRunnerConnectRequest, type AgentRunnerIsRunningRequest, type AgentRunnerRunRequest, type AgentRunnerStopRequest, CopilotRuntime, type CopilotRuntimeOptions, InMemoryAgentRunner, VERSION, createCopilotEndpoint };
package/dist/index.js CHANGED
@@ -24,14 +24,15 @@ __export(index_exports, {
24
24
  CopilotRuntime: () => CopilotRuntime,
25
25
  InMemoryAgentRunner: () => InMemoryAgentRunner,
26
26
  VERSION: () => VERSION,
27
- createCopilotEndpoint: () => createCopilotEndpoint
27
+ createCopilotEndpoint: () => createCopilotEndpoint,
28
+ finalizeRunEvents: () => import_shared4.finalizeRunEvents
28
29
  });
29
30
  module.exports = __toCommonJS(index_exports);
30
31
 
31
32
  // package.json
32
33
  var package_default = {
33
34
  name: "@copilotkitnext/runtime",
34
- version: "0.0.17-alpha.0",
35
+ version: "0.0.18",
35
36
  description: "Server-side runtime package for CopilotKit2",
36
37
  main: "dist/index.js",
37
38
  types: "dist/index.d.ts",
@@ -90,6 +91,7 @@ var AgentRunner = class {
90
91
  // src/runner/in-memory.ts
91
92
  var import_rxjs = require("rxjs");
92
93
  var import_client = require("@ag-ui/client");
94
+ var import_shared = require("@copilotkitnext/shared");
93
95
  var InMemoryEventStore = class {
94
96
  constructor(threadId) {
95
97
  this.threadId = threadId;
@@ -98,12 +100,18 @@ var InMemoryEventStore = class {
98
100
  subject = null;
99
101
  /** True while a run is actively producing events. */
100
102
  isRunning = false;
101
- /** Lets stop() cancel the current producer. */
102
- abortController = new AbortController();
103
103
  /** Current run ID */
104
104
  currentRunId = null;
105
105
  /** Historic completed runs */
106
106
  historicRuns = [];
107
+ /** Currently running agent instance (if any). */
108
+ agent = null;
109
+ /** Subject returned from run() while the run is active. */
110
+ runSubject = null;
111
+ /** True once stop() has been requested but the run has not yet finalized. */
112
+ stopRequested = false;
113
+ /** Reference to the events emitted in the current run. */
114
+ currentEvents = null;
107
115
  };
108
116
  var GLOBAL_STORE = /* @__PURE__ */ new Map();
109
117
  var InMemoryAgentRunner = class extends AgentRunner {
@@ -119,8 +127,11 @@ var InMemoryAgentRunner = class extends AgentRunner {
119
127
  }
120
128
  store.isRunning = true;
121
129
  store.currentRunId = request.input.runId;
130
+ store.agent = request.agent;
131
+ store.stopRequested = false;
122
132
  const seenMessageIds = /* @__PURE__ */ new Set();
123
133
  const currentRunEvents = [];
134
+ store.currentEvents = currentRunEvents;
124
135
  const historicMessageIds = /* @__PURE__ */ new Set();
125
136
  for (const run of store.historicRuns) {
126
137
  for (const event of run.events) {
@@ -139,8 +150,8 @@ var InMemoryAgentRunner = class extends AgentRunner {
139
150
  const nextSubject = new import_rxjs.ReplaySubject(Infinity);
140
151
  const prevSubject = store.subject;
141
152
  store.subject = nextSubject;
142
- store.abortController = new AbortController();
143
153
  const runSubject = new import_rxjs.ReplaySubject(Infinity);
154
+ store.runSubject = runSubject;
144
155
  const runAgent = async () => {
145
156
  const lastRun = store.historicRuns[store.historicRuns.length - 1];
146
157
  const parentRunId = lastRun?.runId ?? null;
@@ -183,6 +194,13 @@ var InMemoryAgentRunner = class extends AgentRunner {
183
194
  }
184
195
  }
185
196
  });
197
+ const appendedEvents = (0, import_shared.finalizeRunEvents)(currentRunEvents, {
198
+ stopRequested: store.stopRequested
199
+ });
200
+ for (const event of appendedEvents) {
201
+ runSubject.next(event);
202
+ nextSubject.next(event);
203
+ }
186
204
  if (store.currentRunId) {
187
205
  const compactedEvents = (0, import_client.compactEvents)(currentRunEvents);
188
206
  store.historicRuns.push({
@@ -193,11 +211,22 @@ var InMemoryAgentRunner = class extends AgentRunner {
193
211
  createdAt: Date.now()
194
212
  });
195
213
  }
196
- store.isRunning = false;
214
+ store.currentEvents = null;
197
215
  store.currentRunId = null;
216
+ store.agent = null;
217
+ store.runSubject = null;
218
+ store.stopRequested = false;
219
+ store.isRunning = false;
198
220
  runSubject.complete();
199
221
  nextSubject.complete();
200
222
  } catch {
223
+ const appendedEvents = (0, import_shared.finalizeRunEvents)(currentRunEvents, {
224
+ stopRequested: store.stopRequested
225
+ });
226
+ for (const event of appendedEvents) {
227
+ runSubject.next(event);
228
+ nextSubject.next(event);
229
+ }
201
230
  if (store.currentRunId && currentRunEvents.length > 0) {
202
231
  const compactedEvents = (0, import_client.compactEvents)(currentRunEvents);
203
232
  store.historicRuns.push({
@@ -208,8 +237,12 @@ var InMemoryAgentRunner = class extends AgentRunner {
208
237
  createdAt: Date.now()
209
238
  });
210
239
  }
211
- store.isRunning = false;
240
+ store.currentEvents = null;
212
241
  store.currentRunId = null;
242
+ store.agent = null;
243
+ store.runSubject = null;
244
+ store.stopRequested = false;
245
+ store.isRunning = false;
213
246
  runSubject.complete();
214
247
  nextSubject.complete();
215
248
  }
@@ -244,7 +277,7 @@ var InMemoryAgentRunner = class extends AgentRunner {
244
277
  emittedMessageIds.add(event.messageId);
245
278
  }
246
279
  }
247
- if (store.subject && store.isRunning) {
280
+ if (store.subject && (store.isRunning || store.stopRequested)) {
248
281
  store.subject.subscribe({
249
282
  next: (event) => {
250
283
  if ("messageId" in event && typeof event.messageId === "string" && emittedMessageIds.has(event.messageId)) {
@@ -264,9 +297,31 @@ var InMemoryAgentRunner = class extends AgentRunner {
264
297
  const store = GLOBAL_STORE.get(request.threadId);
265
298
  return Promise.resolve(store?.isRunning ?? false);
266
299
  }
267
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
268
- stop(_request) {
269
- throw new Error("Method not implemented.");
300
+ stop(request) {
301
+ const store = GLOBAL_STORE.get(request.threadId);
302
+ if (!store || !store.isRunning) {
303
+ return Promise.resolve(false);
304
+ }
305
+ if (store.stopRequested) {
306
+ return Promise.resolve(false);
307
+ }
308
+ store.stopRequested = true;
309
+ store.isRunning = false;
310
+ const agent = store.agent;
311
+ if (!agent) {
312
+ store.stopRequested = false;
313
+ store.isRunning = false;
314
+ return Promise.resolve(false);
315
+ }
316
+ try {
317
+ agent.abortRun();
318
+ return Promise.resolve(true);
319
+ } catch (error) {
320
+ console.error("Failed to abort agent run", error);
321
+ store.stopRequested = false;
322
+ store.isRunning = true;
323
+ return Promise.resolve(false);
324
+ }
270
325
  }
271
326
  };
272
327
 
@@ -583,13 +638,10 @@ async function handleTranscribe({
583
638
  }
584
639
 
585
640
  // src/endpoint.ts
586
- var import_shared2 = require("@copilotkitnext/shared");
641
+ var import_shared3 = require("@copilotkitnext/shared");
587
642
 
588
643
  // src/middleware.ts
589
- var import_shared = require("@copilotkitnext/shared");
590
- function isMiddlewareURL(value) {
591
- return typeof value === "string" && /^https?:\/\//.test(value);
592
- }
644
+ var import_shared2 = require("@copilotkitnext/shared");
593
645
  async function callBeforeRequestMiddleware({
594
646
  runtime,
595
647
  request,
@@ -600,78 +652,7 @@ async function callBeforeRequestMiddleware({
600
652
  if (typeof mw === "function") {
601
653
  return mw({ runtime, request, path });
602
654
  }
603
- if (isMiddlewareURL(mw)) {
604
- const clone = request.clone();
605
- const url = new URL(request.url);
606
- const headersObj = {};
607
- clone.headers.forEach((v, k) => {
608
- headersObj[k] = v;
609
- });
610
- let bodyJson = void 0;
611
- try {
612
- bodyJson = await clone.json();
613
- } catch {
614
- }
615
- const payload = {
616
- method: request.method,
617
- path: url.pathname,
618
- query: url.search.startsWith("?") ? url.search.slice(1) : url.search,
619
- headers: headersObj,
620
- body: bodyJson
621
- };
622
- const ac = new AbortController();
623
- const to = setTimeout(() => ac.abort(), 2e3);
624
- let res;
625
- try {
626
- res = await fetch(mw, {
627
- method: "POST",
628
- headers: {
629
- "content-type": "application/json",
630
- "X-CopilotKit-Webhook-Stage": "before_request" /* BeforeRequest */
631
- },
632
- body: JSON.stringify(payload),
633
- signal: ac.signal
634
- });
635
- } catch {
636
- clearTimeout(to);
637
- throw new Response(void 0, { status: 502 });
638
- }
639
- clearTimeout(to);
640
- if (res.status >= 500) {
641
- throw new Response(void 0, { status: 502 });
642
- }
643
- if (res.status >= 400) {
644
- const errBody = await res.text();
645
- throw new Response(errBody || null, {
646
- status: res.status,
647
- headers: {
648
- "content-type": res.headers.get("content-type") || "application/json"
649
- }
650
- });
651
- }
652
- if (res.status === 204) return;
653
- let json;
654
- try {
655
- json = await res.json();
656
- } catch {
657
- return;
658
- }
659
- if (json && typeof json === "object") {
660
- const { headers, body } = json;
661
- const init = {
662
- method: request.method
663
- };
664
- if (headers) {
665
- init.headers = headers;
666
- }
667
- if (body !== void 0 && request.method !== "GET" && request.method !== "HEAD") {
668
- init.body = JSON.stringify(body);
669
- }
670
- return new Request(request.url, init);
671
- }
672
- return;
673
- }
674
- import_shared.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value \u2013 skipped");
655
+ import_shared2.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value \u2013 skipped");
675
656
  return;
676
657
  }
677
658
  async function callAfterRequestMiddleware({
@@ -684,46 +665,7 @@ async function callAfterRequestMiddleware({
684
665
  if (typeof mw === "function") {
685
666
  return mw({ runtime, response, path });
686
667
  }
687
- if (isMiddlewareURL(mw)) {
688
- const clone = response.clone();
689
- const headersObj = {};
690
- clone.headers.forEach((v, k) => {
691
- headersObj[k] = v;
692
- });
693
- let body = "";
694
- try {
695
- body = await clone.text();
696
- } catch {
697
- }
698
- const payload = {
699
- status: clone.status,
700
- headers: headersObj,
701
- body
702
- };
703
- const ac = new AbortController();
704
- const to = setTimeout(() => ac.abort(), 2e3);
705
- let res;
706
- try {
707
- res = await fetch(mw, {
708
- method: "POST",
709
- headers: {
710
- "content-type": "application/json",
711
- "X-CopilotKit-Webhook-Stage": "after_request" /* AfterRequest */
712
- },
713
- body: JSON.stringify(payload),
714
- signal: ac.signal
715
- });
716
- } finally {
717
- clearTimeout(to);
718
- }
719
- if (!res.ok) {
720
- throw new Error(
721
- `after_request webhook ${mw} responded with ${res.status}`
722
- );
723
- }
724
- return;
725
- }
726
- import_shared.logger.warn({ mw }, "Unsupported afterRequestMiddleware value \u2013 skipped");
668
+ import_shared2.logger.warn({ mw }, "Unsupported afterRequestMiddleware value \u2013 skipped");
727
669
  }
728
670
 
729
671
  // src/handlers/handle-connect.ts
@@ -850,11 +792,72 @@ async function handleConnectAgent({
850
792
  }
851
793
  }
852
794
 
853
- // src/endpoint.ts
854
- function createCopilotEndpoint({
795
+ // src/handlers/handle-stop.ts
796
+ var import_client4 = require("@ag-ui/client");
797
+ async function handleStopAgent({
855
798
  runtime,
856
- basePath
799
+ request,
800
+ agentId,
801
+ threadId
857
802
  }) {
803
+ try {
804
+ const agents = await runtime.agents;
805
+ if (!agents[agentId]) {
806
+ return new Response(
807
+ JSON.stringify({
808
+ error: "Agent not found",
809
+ message: `Agent '${agentId}' does not exist`
810
+ }),
811
+ {
812
+ status: 404,
813
+ headers: { "Content-Type": "application/json" }
814
+ }
815
+ );
816
+ }
817
+ const stopped = await runtime.runner.stop({ threadId });
818
+ if (!stopped) {
819
+ return new Response(
820
+ JSON.stringify({
821
+ stopped: false,
822
+ message: `No active run for thread '${threadId}'.`
823
+ }),
824
+ {
825
+ status: 200,
826
+ headers: { "Content-Type": "application/json" }
827
+ }
828
+ );
829
+ }
830
+ return new Response(
831
+ JSON.stringify({
832
+ stopped: true,
833
+ interrupt: {
834
+ type: import_client4.EventType.RUN_ERROR,
835
+ message: "Run stopped by user",
836
+ code: "STOPPED"
837
+ }
838
+ }),
839
+ {
840
+ status: 200,
841
+ headers: { "Content-Type": "application/json" }
842
+ }
843
+ );
844
+ } catch (error) {
845
+ console.error("Error stopping agent run:", error);
846
+ return new Response(
847
+ JSON.stringify({
848
+ error: "Failed to stop agent",
849
+ message: error instanceof Error ? error.message : "Unknown error"
850
+ }),
851
+ {
852
+ status: 500,
853
+ headers: { "Content-Type": "application/json" }
854
+ }
855
+ );
856
+ }
857
+ }
858
+
859
+ // src/endpoint.ts
860
+ function createCopilotEndpoint({ runtime, basePath }) {
858
861
  const app = new import_hono.Hono();
859
862
  return app.basePath(basePath).use(
860
863
  "*",
@@ -876,10 +879,7 @@ function createCopilotEndpoint({
876
879
  c.set("modifiedRequest", maybeModifiedRequest);
877
880
  }
878
881
  } catch (error) {
879
- import_shared2.logger.error(
880
- { err: error, url: request.url, path },
881
- "Error running before request middleware"
882
- );
882
+ import_shared3.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
883
883
  if (error instanceof Response) {
884
884
  return error;
885
885
  }
@@ -895,10 +895,7 @@ function createCopilotEndpoint({
895
895
  response,
896
896
  path
897
897
  }).catch((error) => {
898
- import_shared2.logger.error(
899
- { err: error, url: c.req.url, path },
900
- "Error running after request middleware"
901
- );
898
+ import_shared3.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
902
899
  });
903
900
  }).post("/agent/:agentId/run", async (c) => {
904
901
  const agentId = c.req.param("agentId");
@@ -910,10 +907,7 @@ function createCopilotEndpoint({
910
907
  agentId
911
908
  });
912
909
  } catch (error) {
913
- import_shared2.logger.error(
914
- { err: error, url: request.url, path: c.req.path },
915
- "Error running request handler"
916
- );
910
+ import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
917
911
  throw error;
918
912
  }
919
913
  }).post("/agent/:agentId/connect", async (c) => {
@@ -926,10 +920,22 @@ function createCopilotEndpoint({
926
920
  agentId
927
921
  });
928
922
  } catch (error) {
929
- import_shared2.logger.error(
930
- { err: error, url: request.url, path: c.req.path },
931
- "Error running request handler"
932
- );
923
+ import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
924
+ throw error;
925
+ }
926
+ }).post("/agent/:agentId/stop/:threadId", async (c) => {
927
+ const agentId = c.req.param("agentId");
928
+ const threadId = c.req.param("threadId");
929
+ const request = c.get("modifiedRequest") || c.req.raw;
930
+ try {
931
+ return await handleStopAgent({
932
+ runtime,
933
+ request,
934
+ agentId,
935
+ threadId
936
+ });
937
+ } catch (error) {
938
+ import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
933
939
  throw error;
934
940
  }
935
941
  }).get("/info", async (c) => {
@@ -940,10 +946,7 @@ function createCopilotEndpoint({
940
946
  request
941
947
  });
942
948
  } catch (error) {
943
- import_shared2.logger.error(
944
- { err: error, url: request.url, path: c.req.path },
945
- "Error running request handler"
946
- );
949
+ import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
947
950
  throw error;
948
951
  }
949
952
  }).post("/transcribe", async (c) => {
@@ -954,22 +957,23 @@ function createCopilotEndpoint({
954
957
  request
955
958
  });
956
959
  } catch (error) {
957
- import_shared2.logger.error(
958
- { err: error, url: request.url, path: c.req.path },
959
- "Error running request handler"
960
- );
960
+ import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
961
961
  throw error;
962
962
  }
963
963
  }).notFound((c) => {
964
964
  return c.json({ error: "Not found" }, 404);
965
965
  });
966
966
  }
967
+
968
+ // src/runner/index.ts
969
+ var import_shared4 = require("@copilotkitnext/shared");
967
970
  // Annotate the CommonJS export names for ESM import in node:
968
971
  0 && (module.exports = {
969
972
  AgentRunner,
970
973
  CopilotRuntime,
971
974
  InMemoryAgentRunner,
972
975
  VERSION,
973
- createCopilotEndpoint
976
+ createCopilotEndpoint,
977
+ finalizeRunEvents
974
978
  });
975
979
  //# sourceMappingURL=index.js.map