@artinet/sdk 0.5.13 → 0.5.15

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 (35) hide show
  1. package/README.md +6 -2
  2. package/dist/client/a2a-client.d.ts +10 -0
  3. package/dist/client/a2a-client.js +20 -9
  4. package/dist/server/express/server.d.ts +24 -24
  5. package/dist/services/a2a/factory/builder.d.ts +24 -24
  6. package/dist/services/a2a/helpers/message-builder.d.ts +1 -1
  7. package/dist/services/a2a/helpers/message-builder.js +4 -4
  8. package/dist/services/a2a/methods/get-task.d.ts +47 -47
  9. package/dist/services/a2a/methods/send-message.js +1 -1
  10. package/dist/services/a2a/methods/stream-message.js +1 -1
  11. package/dist/services/a2a/service.d.ts +157 -157
  12. package/dist/services/a2a/state/load.d.ts +1 -1
  13. package/dist/transport/trpc/a2a/factory/router.d.ts +1096 -1096
  14. package/dist/transport/trpc/a2a/routes/info.d.ts +37 -37
  15. package/dist/transport/trpc/a2a/routes/message/route.d.ts +227 -227
  16. package/dist/transport/trpc/a2a/routes/tasks/route.d.ts +260 -260
  17. package/dist/transport/trpc/a2a/trpc.d.ts +120 -120
  18. package/dist/types/interfaces/services/a2a/service.d.ts +1 -1
  19. package/dist/types/schemas/a2a/agent.d.ts +840 -840
  20. package/dist/types/schemas/a2a/agent.js +23 -2
  21. package/dist/types/schemas/a2a/auth.d.ts +197 -197
  22. package/dist/types/schemas/a2a/auth.js +19 -4
  23. package/dist/types/schemas/a2a/error.d.ts +24 -24
  24. package/dist/types/schemas/a2a/message.d.ts +4525 -4525
  25. package/dist/types/schemas/a2a/message.js +10 -2
  26. package/dist/types/schemas/a2a/notification.d.ts +403 -403
  27. package/dist/types/schemas/a2a/notification.js +7 -3
  28. package/dist/types/schemas/a2a/parameters.d.ts +264 -264
  29. package/dist/types/schemas/a2a/parameters.js +14 -1
  30. package/dist/types/schemas/a2a/protocol.d.ts +6042 -6042
  31. package/dist/types/schemas/a2a/rpc.d.ts +20 -20
  32. package/dist/types/schemas/a2a/rpc.js +5 -0
  33. package/dist/types/schemas/a2a/task.d.ts +2536 -2536
  34. package/dist/types/schemas/a2a/task.js +12 -11
  35. package/package.json +2 -2
package/README.md CHANGED
@@ -66,8 +66,12 @@ It has [serveral template projects](https://github.com/the-artinet-project/creat
66
66
  - AgentBuilder now prefers the contextId & taskId from the calling context.
67
67
  - In a future release the following packages will be set as peer dependancies to reduce the size of the build: `@modelcontextprotocol/sdk`, `@trpc/server`, `cors`, `express`
68
68
  - The `history` object from `TaskAndHistory` is deprecated and no longer being updated. Use `Task.history` instead.
69
- - The A2AClient now checks `/.well-known/agent-card.json` as a opposed to `/.well-known/agent.json` in-line with the A2A spec.
70
- - The examples folder will be removed in favor of [`create-agent`](https://github.com/the-artinet-project/create-agent)
69
+ - The `A2AClient` now checks `/.well-known/agent-card.json` as a opposed to `/.well-known/agent.json` in-line with the A2A spec.
70
+ - The `A2AClient` now uses uses the `AgentCard`.url if an `AgentCard` has been successfully retrieved, else it will default to the `baseUrl`.
71
+ - The examples folder will be removed in favor of [`create-agent`](https://github.com/the-artinet-project/create-agent).
72
+ - In `Task` the `contextId` field is now required (inline with the A2A spec).
73
+ - In `AgentSkill` the `tag` field is now required (inline with the A2A spec).
74
+ - Optional fields in Agent2Agent schema fields are now nullable for better interoperability.
71
75
 
72
76
  ## Installation
73
77
 
@@ -13,10 +13,20 @@ export declare class A2AClient implements Client {
13
13
  private cachedAgentCard;
14
14
  private customHeaders;
15
15
  private fallbackPath;
16
+ private agentUrl;
16
17
  /**
17
18
  * Creates a new A2AClient instance.
18
19
  * @param baseUrl The base URL for the A2A server.
19
20
  * @param headers Optional custom headers to include in all requests.
21
+ * @param fallbackPath Optional fallback path to use if the agent card is not found at the base URL.
22
+ * @example
23
+ * const client = new A2AClient("http://localhost:4000/a2a");
24
+ * const card = await client.agentCard();
25
+ * console.log(card);
26
+ * @example
27
+ * const client = new A2AClient("http://localhost:4000/a2a", {}, "/agent-card");
28
+ * const card = await client.agentCard();
29
+ * console.log(card);
20
30
  */
21
31
  constructor(baseUrl: URL | string, headers?: Record<string, string>, fallbackPath?: string);
22
32
  /**
@@ -15,15 +15,26 @@ export class A2AClient {
15
15
  cachedAgentCard = null;
16
16
  customHeaders = {};
17
17
  fallbackPath;
18
+ agentUrl;
18
19
  /**
19
20
  * Creates a new A2AClient instance.
20
21
  * @param baseUrl The base URL for the A2A server.
21
22
  * @param headers Optional custom headers to include in all requests.
23
+ * @param fallbackPath Optional fallback path to use if the agent card is not found at the base URL.
24
+ * @example
25
+ * const client = new A2AClient("http://localhost:4000/a2a");
26
+ * const card = await client.agentCard();
27
+ * console.log(card);
28
+ * @example
29
+ * const client = new A2AClient("http://localhost:4000/a2a", {}, "/agent-card");
30
+ * const card = await client.agentCard();
31
+ * console.log(card);
22
32
  */
23
33
  constructor(baseUrl, headers = {}, fallbackPath) {
24
34
  this.baseUrl = typeof baseUrl === "string" ? new URL(baseUrl) : baseUrl;
25
35
  this.customHeaders = headers;
26
36
  this.fallbackPath = fallbackPath ?? "/agent-card";
37
+ this.agentUrl = this.baseUrl;
27
38
  }
28
39
  /**
29
40
  * Retrieves the AgentCard from the A2A server.
@@ -46,7 +57,6 @@ export class A2AClient {
46
57
  throw new Error("No agent card found");
47
58
  }
48
59
  this.cachedAgentCard = card;
49
- return this.cachedAgentCard;
50
60
  }
51
61
  catch (error) {
52
62
  const fallbackUrl = new URL(this.fallbackPath, this.baseUrl);
@@ -57,13 +67,14 @@ export class A2AClient {
57
67
  throw new Error("No fallback agent card found");
58
68
  }
59
69
  this.cachedAgentCard = fallbackCard;
60
- return this.cachedAgentCard;
61
70
  }
62
71
  }
63
72
  catch (error) {
64
73
  logError("A2AClient:agentCard", "Failed to fetch or parse agent card:", error);
65
74
  throw INTERNAL_ERROR(`Could not retrieve agent card: ${error instanceof Error ? error.message : String(error)}`);
66
75
  }
76
+ this.agentUrl = new URL(this.cachedAgentCard.url, this.baseUrl);
77
+ return this.cachedAgentCard;
67
78
  }
68
79
  /**
69
80
  * Refreshes the cached AgentCard by fetching it again from the server.
@@ -79,7 +90,7 @@ export class A2AClient {
79
90
  * @returns A promise resolving to Message/Task response from the agent server or null.
80
91
  */
81
92
  async sendMessage(params) {
82
- return await executeJsonRpcRequest(this.baseUrl, "message/send", createMessageSendParams(params), this.customHeaders);
93
+ return await executeJsonRpcRequest(this.agentUrl, "message/send", createMessageSendParams(params), this.customHeaders);
83
94
  }
84
95
  /**
85
96
  * @deprecated Use sendMessage instead.
@@ -96,7 +107,7 @@ export class A2AClient {
96
107
  * @returns An AsyncIterable that yields TaskStatusUpdateEvent/TaskArtifactUpdateEvent/Task/Message payloads.
97
108
  */
98
109
  sendStreamingMessage(params) {
99
- return executeStreamEvents(this.baseUrl, "message/stream", createMessageSendParams(params), this.customHeaders);
110
+ return executeStreamEvents(this.agentUrl, "message/stream", createMessageSendParams(params), this.customHeaders);
100
111
  }
101
112
  /**
102
113
  * @deprecated Use sendStreamingMessage instead.
@@ -113,7 +124,7 @@ export class A2AClient {
113
124
  * @returns A promise resolving to the Task object or null.
114
125
  */
115
126
  async getTask(params) {
116
- return await executeJsonRpcRequest(this.baseUrl, "tasks/get", params, this.customHeaders);
127
+ return await executeJsonRpcRequest(this.agentUrl, "tasks/get", params, this.customHeaders);
117
128
  }
118
129
  /**
119
130
  * Cancels a currently running task.
@@ -121,7 +132,7 @@ export class A2AClient {
121
132
  * @returns A promise resolving to the updated Task object (usually canceled state) or null.
122
133
  */
123
134
  async cancelTask(params) {
124
- return await executeJsonRpcRequest(this.baseUrl, "tasks/cancel", params, this.customHeaders);
135
+ return await executeJsonRpcRequest(this.agentUrl, "tasks/cancel", params, this.customHeaders);
125
136
  }
126
137
  /**
127
138
  * Sets or updates the push notification config for a task.
@@ -129,7 +140,7 @@ export class A2AClient {
129
140
  * @returns A promise resolving to the confirmed TaskPushNotificationConfig or null.
130
141
  */
131
142
  async setTaskPushNotification(params) {
132
- return await executeJsonRpcRequest(this.baseUrl, "tasks/pushNotificationConfig/set", params, this.customHeaders);
143
+ return await executeJsonRpcRequest(this.agentUrl, "tasks/pushNotificationConfig/set", params, this.customHeaders);
133
144
  }
134
145
  /**
135
146
  * Retrieves the currently configured push notification config for a task.
@@ -137,7 +148,7 @@ export class A2AClient {
137
148
  * @returns A promise resolving to the TaskPushNotificationConfig or null.
138
149
  */
139
150
  async getTaskPushNotification(params) {
140
- return await executeJsonRpcRequest(this.baseUrl, "tasks/pushNotificationConfig/get", params, this.customHeaders);
151
+ return await executeJsonRpcRequest(this.agentUrl, "tasks/pushNotificationConfig/get", params, this.customHeaders);
141
152
  }
142
153
  /**
143
154
  * Resubscribes to an existing task's update stream.
@@ -145,7 +156,7 @@ export class A2AClient {
145
156
  * @returns An AsyncIterable that yields TaskStatusUpdateEvent or TaskArtifactUpdateEvent payloads.
146
157
  */
147
158
  resubscribeTask(params) {
148
- return executeStreamEvents(this.baseUrl, "tasks/resubscribe", params, this.customHeaders);
159
+ return executeStreamEvents(this.agentUrl, "tasks/resubscribe", params, this.customHeaders);
149
160
  }
150
161
  /**
151
162
  * Checks if the server supports a specific capability based on the agent card.
@@ -23,48 +23,48 @@ export declare function createAgentServer(params: ServerParams & {
23
23
  parts: ({
24
24
  file: {
25
25
  bytes: string;
26
- name?: string | undefined;
27
- mimeType?: string | undefined;
28
- uri?: undefined;
26
+ name?: string | null | undefined;
27
+ mimeType?: string | null | undefined;
28
+ uri?: null | undefined;
29
29
  } | {
30
30
  uri: string;
31
- name?: string | undefined;
32
- bytes?: undefined;
33
- mimeType?: string | undefined;
31
+ name?: string | null | undefined;
32
+ bytes?: null | undefined;
33
+ mimeType?: string | null | undefined;
34
34
  };
35
35
  kind: "file";
36
- metadata?: Record<string, unknown> | undefined;
36
+ metadata?: Record<string, unknown> | null | undefined;
37
37
  } | {
38
38
  text: string;
39
39
  kind: "text";
40
- metadata?: Record<string, unknown> | undefined;
40
+ metadata?: Record<string, unknown> | null | undefined;
41
41
  } | {
42
42
  data: Record<string, unknown>;
43
43
  kind: "data";
44
- metadata?: Record<string, unknown> | undefined;
44
+ metadata?: Record<string, unknown> | null | undefined;
45
45
  })[];
46
46
  messageId: string;
47
- metadata?: Record<string, unknown> | undefined;
48
- extensions?: string[] | undefined;
49
- referenceTaskIds?: string[] | undefined;
50
- taskId?: string | undefined;
51
- contextId?: string | undefined;
47
+ metadata?: Record<string, unknown> | null | undefined;
48
+ extensions?: string[] | null | undefined;
49
+ referenceTaskIds?: string[] | null | undefined;
50
+ taskId?: string | null | undefined;
51
+ contextId?: string | null | undefined;
52
52
  };
53
- metadata?: Record<string, unknown> | undefined;
53
+ metadata?: Record<string, unknown> | null | undefined;
54
54
  configuration?: {
55
- historyLength?: number | undefined;
55
+ historyLength?: number | null | undefined;
56
56
  pushNotificationConfig?: {
57
57
  url: string;
58
- id?: string | undefined;
59
- token?: string | undefined;
58
+ id?: string | null | undefined;
59
+ token?: string | null | undefined;
60
60
  authentication?: {
61
61
  schemes: string[];
62
- credentials?: string | undefined;
63
- } | undefined;
64
- } | undefined;
65
- acceptedOutputModes?: string[] | undefined;
66
- blocking?: boolean | undefined;
67
- } | undefined;
62
+ credentials?: string | null | undefined;
63
+ } | null | undefined;
64
+ } | null | undefined;
65
+ acceptedOutputModes?: string[] | null | undefined;
66
+ blocking?: boolean | null | undefined;
67
+ } | null | undefined;
68
68
  }, import("../../types/index.js").TaskAndHistory, import("../../types/index.js").UpdateEvent>;
69
69
  };
70
70
  export type ExpressAgentServer = ReturnType<typeof createAgentServer>;
@@ -282,48 +282,48 @@ export declare const AgentBuilder: () => EngineBuilder<{
282
282
  parts: ({
283
283
  file: {
284
284
  bytes: string;
285
- name?: string | undefined;
286
- mimeType?: string | undefined;
287
- uri?: undefined;
285
+ name?: string | null | undefined;
286
+ mimeType?: string | null | undefined;
287
+ uri?: null | undefined;
288
288
  } | {
289
289
  uri: string;
290
- name?: string | undefined;
291
- bytes?: undefined;
292
- mimeType?: string | undefined;
290
+ name?: string | null | undefined;
291
+ bytes?: null | undefined;
292
+ mimeType?: string | null | undefined;
293
293
  };
294
294
  kind: "file";
295
- metadata?: Record<string, unknown> | undefined;
295
+ metadata?: Record<string, unknown> | null | undefined;
296
296
  } | {
297
297
  text: string;
298
298
  kind: "text";
299
- metadata?: Record<string, unknown> | undefined;
299
+ metadata?: Record<string, unknown> | null | undefined;
300
300
  } | {
301
301
  data: Record<string, unknown>;
302
302
  kind: "data";
303
- metadata?: Record<string, unknown> | undefined;
303
+ metadata?: Record<string, unknown> | null | undefined;
304
304
  })[];
305
305
  messageId: string;
306
- metadata?: Record<string, unknown> | undefined;
307
- extensions?: string[] | undefined;
308
- referenceTaskIds?: string[] | undefined;
309
- taskId?: string | undefined;
310
- contextId?: string | undefined;
306
+ metadata?: Record<string, unknown> | null | undefined;
307
+ extensions?: string[] | null | undefined;
308
+ referenceTaskIds?: string[] | null | undefined;
309
+ taskId?: string | null | undefined;
310
+ contextId?: string | null | undefined;
311
311
  };
312
- metadata?: Record<string, unknown> | undefined;
312
+ metadata?: Record<string, unknown> | null | undefined;
313
313
  configuration?: {
314
- historyLength?: number | undefined;
314
+ historyLength?: number | null | undefined;
315
315
  pushNotificationConfig?: {
316
316
  url: string;
317
- id?: string | undefined;
318
- token?: string | undefined;
317
+ id?: string | null | undefined;
318
+ token?: string | null | undefined;
319
319
  authentication?: {
320
320
  schemes: string[];
321
- credentials?: string | undefined;
322
- } | undefined;
323
- } | undefined;
324
- acceptedOutputModes?: string[] | undefined;
325
- blocking?: boolean | undefined;
326
- } | undefined;
321
+ credentials?: string | null | undefined;
322
+ } | null | undefined;
323
+ } | null | undefined;
324
+ acceptedOutputModes?: string[] | null | undefined;
325
+ blocking?: boolean | null | undefined;
326
+ } | null | undefined;
327
327
  }, []>;
328
328
  /**
329
329
  * Creates an agent execution engine from a list of workflow steps.
@@ -6,7 +6,7 @@ export declare class MessageBuilder {
6
6
  }
7
7
  export declare class MessageSendConfigurationBuilder {
8
8
  configuration: MessageSendConfiguration;
9
- constructor(configuration?: Partial<MessageSendConfiguration>);
9
+ constructor(configuration?: Partial<MessageSendConfiguration> | null);
10
10
  valueOf(): MessageSendConfiguration;
11
11
  }
12
12
  export declare const createMessageSendParams: (messageSendParams: Partial<MessageSendParams> | string) => MessageSendParams;
@@ -35,15 +35,15 @@ export class MessageSendConfigurationBuilder {
35
35
  };
36
36
  constructor(configuration = {}) {
37
37
  this.configuration.acceptedOutputModes =
38
- configuration.acceptedOutputModes ??
38
+ configuration?.acceptedOutputModes ??
39
39
  this.configuration.acceptedOutputModes;
40
40
  this.configuration.historyLength =
41
- configuration.historyLength ?? this.configuration.historyLength;
41
+ configuration?.historyLength ?? this.configuration.historyLength;
42
42
  this.configuration.pushNotificationConfig =
43
- configuration.pushNotificationConfig ??
43
+ configuration?.pushNotificationConfig ??
44
44
  this.configuration.pushNotificationConfig;
45
45
  this.configuration.blocking =
46
- configuration.blocking ?? this.configuration.blocking;
46
+ configuration?.blocking ?? this.configuration.blocking;
47
47
  }
48
48
  valueOf() {
49
49
  return this.configuration;
@@ -13,100 +13,100 @@ export declare function getTask(input: TaskQueryParams, params: Omit<MethodParam
13
13
  parts: ({
14
14
  file: {
15
15
  bytes: string;
16
- name?: string | undefined;
17
- mimeType?: string | undefined;
18
- uri?: undefined;
16
+ name?: string | null | undefined;
17
+ mimeType?: string | null | undefined;
18
+ uri?: null | undefined;
19
19
  } | {
20
20
  uri: string;
21
- name?: string | undefined;
22
- bytes?: undefined;
23
- mimeType?: string | undefined;
21
+ name?: string | null | undefined;
22
+ bytes?: null | undefined;
23
+ mimeType?: string | null | undefined;
24
24
  };
25
25
  kind: "file";
26
- metadata?: Record<string, unknown> | undefined;
26
+ metadata?: Record<string, unknown> | null | undefined;
27
27
  } | {
28
28
  text: string;
29
29
  kind: "text";
30
- metadata?: Record<string, unknown> | undefined;
30
+ metadata?: Record<string, unknown> | null | undefined;
31
31
  } | {
32
32
  data: Record<string, unknown>;
33
33
  kind: "data";
34
- metadata?: Record<string, unknown> | undefined;
34
+ metadata?: Record<string, unknown> | null | undefined;
35
35
  })[];
36
36
  messageId: string;
37
- metadata?: Record<string, unknown> | undefined;
38
- extensions?: string[] | undefined;
39
- referenceTaskIds?: string[] | undefined;
40
- taskId?: string | undefined;
41
- contextId?: string | undefined;
42
- } | undefined;
43
- timestamp?: string | undefined;
37
+ metadata?: Record<string, unknown> | null | undefined;
38
+ extensions?: string[] | null | undefined;
39
+ referenceTaskIds?: string[] | null | undefined;
40
+ taskId?: string | null | undefined;
41
+ contextId?: string | null | undefined;
42
+ } | null | undefined;
43
+ timestamp?: string | null | undefined;
44
44
  };
45
45
  kind: "task";
46
- metadata?: Record<string, unknown> | undefined;
46
+ contextId: string;
47
+ metadata?: Record<string, unknown> | null | undefined;
47
48
  history?: {
48
49
  role: "user" | "agent";
49
50
  kind: "message";
50
51
  parts: ({
51
52
  file: {
52
53
  bytes: string;
53
- name?: string | undefined;
54
- mimeType?: string | undefined;
55
- uri?: undefined;
54
+ name?: string | null | undefined;
55
+ mimeType?: string | null | undefined;
56
+ uri?: null | undefined;
56
57
  } | {
57
58
  uri: string;
58
- name?: string | undefined;
59
- bytes?: undefined;
60
- mimeType?: string | undefined;
59
+ name?: string | null | undefined;
60
+ bytes?: null | undefined;
61
+ mimeType?: string | null | undefined;
61
62
  };
62
63
  kind: "file";
63
- metadata?: Record<string, unknown> | undefined;
64
+ metadata?: Record<string, unknown> | null | undefined;
64
65
  } | {
65
66
  text: string;
66
67
  kind: "text";
67
- metadata?: Record<string, unknown> | undefined;
68
+ metadata?: Record<string, unknown> | null | undefined;
68
69
  } | {
69
70
  data: Record<string, unknown>;
70
71
  kind: "data";
71
- metadata?: Record<string, unknown> | undefined;
72
+ metadata?: Record<string, unknown> | null | undefined;
72
73
  })[];
73
74
  messageId: string;
74
- metadata?: Record<string, unknown> | undefined;
75
- extensions?: string[] | undefined;
76
- referenceTaskIds?: string[] | undefined;
77
- taskId?: string | undefined;
78
- contextId?: string | undefined;
79
- }[] | undefined;
80
- contextId?: string | undefined;
75
+ metadata?: Record<string, unknown> | null | undefined;
76
+ extensions?: string[] | null | undefined;
77
+ referenceTaskIds?: string[] | null | undefined;
78
+ taskId?: string | null | undefined;
79
+ contextId?: string | null | undefined;
80
+ }[] | null | undefined;
81
81
  artifacts?: {
82
82
  artifactId: string;
83
83
  parts: ({
84
84
  file: {
85
85
  bytes: string;
86
- name?: string | undefined;
87
- mimeType?: string | undefined;
88
- uri?: undefined;
86
+ name?: string | null | undefined;
87
+ mimeType?: string | null | undefined;
88
+ uri?: null | undefined;
89
89
  } | {
90
90
  uri: string;
91
- name?: string | undefined;
92
- bytes?: undefined;
93
- mimeType?: string | undefined;
91
+ name?: string | null | undefined;
92
+ bytes?: null | undefined;
93
+ mimeType?: string | null | undefined;
94
94
  };
95
95
  kind: "file";
96
- metadata?: Record<string, unknown> | undefined;
96
+ metadata?: Record<string, unknown> | null | undefined;
97
97
  } | {
98
98
  text: string;
99
99
  kind: "text";
100
- metadata?: Record<string, unknown> | undefined;
100
+ metadata?: Record<string, unknown> | null | undefined;
101
101
  } | {
102
102
  data: Record<string, unknown>;
103
103
  kind: "data";
104
- metadata?: Record<string, unknown> | undefined;
104
+ metadata?: Record<string, unknown> | null | undefined;
105
105
  })[];
106
- name?: string | undefined;
107
- metadata?: Record<string, unknown> | undefined;
108
- description?: string | undefined;
109
- extension?: string[] | undefined;
110
- }[] | undefined;
106
+ name?: string | null | undefined;
107
+ metadata?: Record<string, unknown> | null | undefined;
108
+ description?: string | null | undefined;
109
+ extension?: string[] | null | undefined;
110
+ }[] | null | undefined;
111
111
  }>;
112
112
  export type GetTaskMethod = typeof getTask;
@@ -6,7 +6,7 @@ import { createContext } from "../factory/context.js";
6
6
  export async function sendMessage(input, params) {
7
7
  const { service, engine, contextManager, signal } = params;
8
8
  const contextId = input.message.contextId;
9
- const context = createContext(input, service, contextManager, signal, contextId, service.eventOverrides);
9
+ const context = createContext(input, service, contextManager, signal, contextId ?? undefined, service.eventOverrides);
10
10
  context.events.on("complete", () => {
11
11
  contextManager.deleteContext(context.events.contextId);
12
12
  });
@@ -7,7 +7,7 @@ import { createContext } from "../factory/context.js";
7
7
  export async function* streamMessage(input, params) {
8
8
  const { service, engine, contextManager, signal } = params;
9
9
  let contextId = input.message.contextId;
10
- const context = createContext(input, service, contextManager, signal, contextId, service.eventOverrides);
10
+ const context = createContext(input, service, contextManager, signal, contextId ?? undefined, service.eventOverrides);
11
11
  const stream = new StreamManager(context);
12
12
  contextId = stream.getContextId();
13
13
  context.events.on("complete", () => {