@copilotkit/runtime 1.4.8-no-pino-redact.1 → 1.4.8

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +9 -7
  2. package/dist/{chunk-OSWF5QDO.mjs → chunk-GGNRDS7N.mjs} +2 -2
  3. package/dist/{chunk-APVJZO3R.mjs → chunk-LSLFIYKP.mjs} +2 -2
  4. package/dist/{chunk-36AYTJIE.mjs → chunk-R6AUAQK6.mjs} +29 -27
  5. package/dist/chunk-R6AUAQK6.mjs.map +1 -0
  6. package/dist/{chunk-M74ZTUCC.mjs → chunk-TA5I5LYF.mjs} +2 -2
  7. package/dist/{chunk-OKQVDDJ2.mjs → chunk-W7GP2EOT.mjs} +50 -2
  8. package/dist/chunk-W7GP2EOT.mjs.map +1 -0
  9. package/dist/{copilot-runtime-12e7ac40.d.ts → copilot-runtime-48d7c2fc.d.ts} +1 -1
  10. package/dist/{groq-adapter-24abe931.d.ts → groq-adapter-ac43305a.d.ts} +1 -1
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +83 -31
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +9 -5
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/{langserve-f021ab9c.d.ts → langserve-b74e8606.d.ts} +2 -2
  17. package/dist/lib/index.d.ts +3 -3
  18. package/dist/lib/index.js +16 -14
  19. package/dist/lib/index.js.map +1 -1
  20. package/dist/lib/index.mjs +5 -5
  21. package/dist/lib/integrations/index.d.ts +3 -3
  22. package/dist/lib/integrations/index.js +9 -2
  23. package/dist/lib/integrations/index.js.map +1 -1
  24. package/dist/lib/integrations/index.mjs +5 -5
  25. package/dist/lib/integrations/nest/index.d.ts +2 -2
  26. package/dist/lib/integrations/nest/index.js +9 -2
  27. package/dist/lib/integrations/nest/index.js.map +1 -1
  28. package/dist/lib/integrations/nest/index.mjs +3 -3
  29. package/dist/lib/integrations/node-express/index.d.ts +2 -2
  30. package/dist/lib/integrations/node-express/index.js +9 -2
  31. package/dist/lib/integrations/node-express/index.js.map +1 -1
  32. package/dist/lib/integrations/node-express/index.mjs +3 -3
  33. package/dist/lib/integrations/node-http/index.d.ts +2 -2
  34. package/dist/lib/integrations/node-http/index.js +9 -2
  35. package/dist/lib/integrations/node-http/index.js.map +1 -1
  36. package/dist/lib/integrations/node-http/index.mjs +2 -2
  37. package/dist/service-adapters/index.d.ts +35 -4
  38. package/dist/service-adapters/index.js +50 -0
  39. package/dist/service-adapters/index.js.map +1 -1
  40. package/dist/service-adapters/index.mjs +5 -1
  41. package/package.json +2 -2
  42. package/src/lib/logger.ts +4 -0
  43. package/src/lib/runtime/copilot-runtime.ts +1 -7
  44. package/src/lib/runtime/remote-action-constructors.ts +61 -57
  45. package/src/service-adapters/events.ts +2 -2
  46. package/src/service-adapters/experimental/empty/empty-adapter.ts +33 -0
  47. package/src/service-adapters/index.ts +7 -1
  48. package/dist/chunk-36AYTJIE.mjs.map +0 -1
  49. package/dist/chunk-OKQVDDJ2.mjs.map +0 -1
  50. /package/dist/{chunk-OSWF5QDO.mjs.map → chunk-GGNRDS7N.mjs.map} +0 -0
  51. /package/dist/{chunk-APVJZO3R.mjs.map → chunk-LSLFIYKP.mjs.map} +0 -0
  52. /package/dist/{chunk-M74ZTUCC.mjs.map → chunk-TA5I5LYF.mjs.map} +0 -0
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.4.8-no-pino-redact.1",
12
+ "version": "1.4.8",
13
13
  "sideEffects": false,
14
14
  "main": "./dist/index.js",
15
15
  "module": "./dist/index.mjs",
@@ -58,7 +58,7 @@
58
58
  "rxjs": "^7.8.1",
59
59
  "type-graphql": "2.0.0-rc.1",
60
60
  "zod": "^3.23.3",
61
- "@copilotkit/shared": "1.4.8-no-pino-redact.1"
61
+ "@copilotkit/shared": "1.4.8"
62
62
  },
63
63
  "keywords": [
64
64
  "copilotkit",
package/src/lib/logger.ts CHANGED
@@ -12,6 +12,10 @@ export function createLogger(options?: { level?: LogLevel; component?: string })
12
12
  const logger = createPinoLogger(
13
13
  {
14
14
  level: process.env.LOG_LEVEL || level || "error",
15
+ redact: {
16
+ paths: ["pid", "hostname"],
17
+ remove: true,
18
+ },
15
19
  },
16
20
  stream,
17
21
  );
@@ -249,13 +249,7 @@ export class CopilotRuntime<const T extends Parameter[] | [] = []> {
249
249
  } catch (error) {
250
250
  console.error("Error getting response:", error);
251
251
  eventSource.sendErrorMessageToChat();
252
- return {
253
- threadId: threadId || randomId(),
254
- runId: runId || randomId(),
255
- eventSource,
256
- serverSideActions: [],
257
- actionInputsWithoutAgents: [],
258
- };
252
+ throw error;
259
253
  }
260
254
  }
261
255
 
@@ -109,6 +109,8 @@ export function constructRemoteActions({
109
109
  messages: Message[];
110
110
  agentStates?: AgentStateInput[];
111
111
  }): Action<any>[] {
112
+ const totalAgents = Array.isArray(json["agents"]) ? json["agents"].length : 0;
113
+
112
114
  const actions = json["actions"].map((action) => ({
113
115
  name: action.name,
114
116
  description: action.description,
@@ -120,7 +122,7 @@ export function constructRemoteActions({
120
122
  telemetry.capture("oss.runtime.remote_action_executed", {
121
123
  agentExecution: false,
122
124
  type: "self-hosted",
123
- agentsAmount: json["agents"].length,
125
+ agentsAmount: totalAgents,
124
126
  });
125
127
 
126
128
  try {
@@ -157,66 +159,68 @@ export function constructRemoteActions({
157
159
  },
158
160
  }));
159
161
 
160
- const agents = json["agents"].map((agent) => ({
161
- name: agent.name,
162
- description: agent.description,
163
- parameters: [],
164
- handler: async (_args: any) => {},
162
+ const agents = totalAgents
163
+ ? json["agents"].map((agent) => ({
164
+ name: agent.name,
165
+ description: agent.description,
166
+ parameters: [],
167
+ handler: async (_args: any) => {},
165
168
 
166
- langGraphAgentHandler: async ({
167
- name,
168
- actionInputsWithoutAgents,
169
- threadId,
170
- nodeName,
171
- }: LangGraphAgentHandlerParams): Promise<Observable<RuntimeEvent>> => {
172
- logger.debug({ actionName: agent.name }, "Executing remote agent");
173
-
174
- const headers = createHeaders(onBeforeRequest, graphqlContext);
175
- telemetry.capture("oss.runtime.remote_action_executed", {
176
- agentExecution: true,
177
- type: "self-hosted",
178
- agentsAmount: json["agents"].length,
179
- });
180
-
181
- let state = {};
182
- if (agentStates) {
183
- const jsonState = agentStates.find((state) => state.agentName === name)?.state;
184
- if (jsonState) {
185
- state = JSON.parse(jsonState);
186
- }
187
- }
188
-
189
- const response = await fetch(`${url}/agents/execute`, {
190
- method: "POST",
191
- headers,
192
- body: JSON.stringify({
169
+ langGraphAgentHandler: async ({
193
170
  name,
171
+ actionInputsWithoutAgents,
194
172
  threadId,
195
173
  nodeName,
196
- messages,
197
- state,
198
- properties: graphqlContext.properties,
199
- actions: actionInputsWithoutAgents.map((action) => ({
200
- name: action.name,
201
- description: action.description,
202
- parameters: JSON.parse(action.jsonSchema),
203
- })),
204
- }),
205
- });
206
-
207
- if (!response.ok) {
208
- logger.error(
209
- { url, status: response.status, body: await response.text() },
210
- "Failed to execute remote agent",
211
- );
212
- throw new Error("Failed to execute remote agent");
213
- }
214
-
215
- const eventSource = new RemoteLangGraphEventSource();
216
- streamResponse(response.body!, eventSource.eventStream$);
217
- return eventSource.processLangGraphEvents();
218
- },
219
- }));
174
+ }: LangGraphAgentHandlerParams): Promise<Observable<RuntimeEvent>> => {
175
+ logger.debug({ actionName: agent.name }, "Executing remote agent");
176
+
177
+ const headers = createHeaders(onBeforeRequest, graphqlContext);
178
+ telemetry.capture("oss.runtime.remote_action_executed", {
179
+ agentExecution: true,
180
+ type: "self-hosted",
181
+ agentsAmount: json["agents"].length,
182
+ });
183
+
184
+ let state = {};
185
+ if (agentStates) {
186
+ const jsonState = agentStates.find((state) => state.agentName === name)?.state;
187
+ if (jsonState) {
188
+ state = JSON.parse(jsonState);
189
+ }
190
+ }
191
+
192
+ const response = await fetch(`${url}/agents/execute`, {
193
+ method: "POST",
194
+ headers,
195
+ body: JSON.stringify({
196
+ name,
197
+ threadId,
198
+ nodeName,
199
+ messages,
200
+ state,
201
+ properties: graphqlContext.properties,
202
+ actions: actionInputsWithoutAgents.map((action) => ({
203
+ name: action.name,
204
+ description: action.description,
205
+ parameters: JSON.parse(action.jsonSchema),
206
+ })),
207
+ }),
208
+ });
209
+
210
+ if (!response.ok) {
211
+ logger.error(
212
+ { url, status: response.status, body: await response.text() },
213
+ "Failed to execute remote agent",
214
+ );
215
+ throw new Error("Failed to execute remote agent");
216
+ }
217
+
218
+ const eventSource = new RemoteLangGraphEventSource();
219
+ streamResponse(response.body!, eventSource.eventStream$);
220
+ return eventSource.processLangGraphEvents();
221
+ },
222
+ }))
223
+ : [];
220
224
 
221
225
  return [...actions, ...agents];
222
226
  }
@@ -158,8 +158,8 @@ export class RuntimeEventSource {
158
158
  this.callback = callback;
159
159
  }
160
160
 
161
- sendErrorMessageToChat() {
162
- const errorMessage = "❌ An error occurred. Please try again.";
161
+ sendErrorMessageToChat(message = "An error occurred. Please try again.") {
162
+ const errorMessage = `❌ ${message}`;
163
163
  if (!this.callback) {
164
164
  this.stream(async (eventStream$) => {
165
165
  eventStream$.sendTextMessage(randomId(), errorMessage);
@@ -0,0 +1,33 @@
1
+ /**
2
+ * CopilotKit Empty Adapter
3
+ *
4
+ * This adapter is meant to preserve adherence to runtime requirements, while doing nothing
5
+ * Ideal if you don't want to connect an LLM the to the runtime, and only use your LangGraph agent.
6
+ * Be aware that Copilot Suggestions will not work if you use this adapter
7
+ *
8
+ * ## Example
9
+ *
10
+ * ```ts
11
+ * import { CopilotRuntime, ExperimentalEmptyAdapter } from "@copilotkit/runtime";
12
+ *
13
+ * const copilotKit = new CopilotRuntime();
14
+ *
15
+ * return new ExperimentalEmptyAdapter();
16
+ * ```
17
+ */
18
+ import {
19
+ CopilotServiceAdapter,
20
+ CopilotRuntimeChatCompletionRequest,
21
+ CopilotRuntimeChatCompletionResponse,
22
+ } from "../../service-adapter";
23
+ import { randomId } from "@copilotkit/shared";
24
+
25
+ export class ExperimentalEmptyAdapter implements CopilotServiceAdapter {
26
+ async process(
27
+ request: CopilotRuntimeChatCompletionRequest,
28
+ ): Promise<CopilotRuntimeChatCompletionResponse> {
29
+ return {
30
+ threadId: request.threadId || randomId(),
31
+ };
32
+ }
33
+ }
@@ -1,4 +1,8 @@
1
- export type { CopilotServiceAdapter } from "./service-adapter";
1
+ export type {
2
+ CopilotRuntimeChatCompletionRequest,
3
+ CopilotRuntimeChatCompletionResponse,
4
+ CopilotServiceAdapter,
5
+ } from "./service-adapter";
2
6
  export type { RemoteChainParameters } from "./langchain/langserve";
3
7
  export { RemoteChain } from "./langchain/langserve";
4
8
  export * from "./openai/openai-adapter";
@@ -8,3 +12,5 @@ export * from "./openai/openai-assistant-adapter";
8
12
  export * from "./unify/unify-adapter";
9
13
  export * from "./groq/groq-adapter";
10
14
  export * from "./anthropic/anthropic-adapter";
15
+ export * from "./experimental/ollama/ollama-adapter";
16
+ export * from "./experimental/empty/empty-adapter";