@meetkai/mka1 0.54.4 → 0.54.6

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 (44) hide show
  1. package/bin/mcp-server.js +34 -14
  2. package/bin/mcp-server.js.map +8 -8
  3. package/dist/commonjs/lib/config.d.ts +3 -3
  4. package/dist/commonjs/lib/config.js +3 -3
  5. package/dist/commonjs/lib/config.js.map +1 -1
  6. package/dist/commonjs/lib/encodings.d.ts +10 -9
  7. package/dist/commonjs/lib/encodings.d.ts.map +1 -1
  8. package/dist/commonjs/lib/encodings.js +29 -13
  9. package/dist/commonjs/lib/encodings.js.map +1 -1
  10. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  11. package/dist/commonjs/mcp-server/server.js +1 -1
  12. package/dist/commonjs/models/components/createagentrunrequest.d.ts +5 -0
  13. package/dist/commonjs/models/components/createagentrunrequest.d.ts.map +1 -1
  14. package/dist/commonjs/models/components/createagentrunrequest.js +2 -0
  15. package/dist/commonjs/models/components/createagentrunrequest.js.map +1 -1
  16. package/dist/commonjs/models/components/responsescreaterequest.d.ts +5 -0
  17. package/dist/commonjs/models/components/responsescreaterequest.d.ts.map +1 -1
  18. package/dist/commonjs/models/components/responsescreaterequest.js +4 -0
  19. package/dist/commonjs/models/components/responsescreaterequest.js.map +1 -1
  20. package/dist/esm/lib/config.d.ts +3 -3
  21. package/dist/esm/lib/config.js +3 -3
  22. package/dist/esm/lib/config.js.map +1 -1
  23. package/dist/esm/lib/encodings.d.ts +10 -9
  24. package/dist/esm/lib/encodings.d.ts.map +1 -1
  25. package/dist/esm/lib/encodings.js +29 -13
  26. package/dist/esm/lib/encodings.js.map +1 -1
  27. package/dist/esm/mcp-server/mcp-server.js +1 -1
  28. package/dist/esm/mcp-server/server.js +1 -1
  29. package/dist/esm/models/components/createagentrunrequest.d.ts +5 -0
  30. package/dist/esm/models/components/createagentrunrequest.d.ts.map +1 -1
  31. package/dist/esm/models/components/createagentrunrequest.js +2 -0
  32. package/dist/esm/models/components/createagentrunrequest.js.map +1 -1
  33. package/dist/esm/models/components/responsescreaterequest.d.ts +5 -0
  34. package/dist/esm/models/components/responsescreaterequest.d.ts.map +1 -1
  35. package/dist/esm/models/components/responsescreaterequest.js +4 -0
  36. package/dist/esm/models/components/responsescreaterequest.js.map +1 -1
  37. package/jsr.json +1 -1
  38. package/package.json +1 -1
  39. package/src/lib/config.ts +3 -3
  40. package/src/lib/encodings.ts +58 -23
  41. package/src/mcp-server/mcp-server.ts +1 -1
  42. package/src/mcp-server/server.ts +1 -1
  43. package/src/models/components/createagentrunrequest.ts +7 -0
  44. package/src/models/components/responsescreaterequest.ts +9 -0
@@ -12,10 +12,41 @@ export class EncodingError extends Error {
12
12
  }
13
13
  }
14
14
 
15
+ export type CharEncoding = "percent" | "percentExceptReserved" | "none";
16
+
17
+ const reservedEscapes = /%(2[346bcf]|3[abdf]|40|5[bd])/gi;
18
+
19
+ function encodeKeyChars(
20
+ v: string,
21
+ charEncoding: CharEncoding | undefined,
22
+ ): string {
23
+ return encodeChars(
24
+ v,
25
+ charEncoding === "percentExceptReserved" ? "percent" : charEncoding,
26
+ );
27
+ }
28
+
29
+ function encodeChars(
30
+ v: string,
31
+ charEncoding: CharEncoding | undefined,
32
+ ): string {
33
+ switch (charEncoding) {
34
+ case "percent":
35
+ return encodeURIComponent(v);
36
+ case "percentExceptReserved":
37
+ return encodeURIComponent(v).replace(
38
+ reservedEscapes,
39
+ (m) => decodeURIComponent(m),
40
+ );
41
+ default:
42
+ return v;
43
+ }
44
+ }
45
+
15
46
  export function encodeMatrix(
16
47
  key: string,
17
48
  value: unknown,
18
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
49
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
19
50
  ): string | undefined {
20
51
  let out = "";
21
52
  const pairs: [string, unknown][] = options?.explode
@@ -27,7 +58,7 @@ export function encodeMatrix(
27
58
  }
28
59
 
29
60
  const encodeString = (v: string) => {
30
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
61
+ return encodeChars(v, options?.charEncoding);
31
62
  };
32
63
  const encodeValue = (v: unknown) => encodeString(serializeValue(v));
33
64
 
@@ -52,7 +83,7 @@ export function encodeMatrix(
52
83
  return;
53
84
  }
54
85
 
55
- const keyPrefix = encodeString(pk);
86
+ const keyPrefix = encodeKeyChars(pk, options?.charEncoding);
56
87
  tmp = `${keyPrefix}=${encValue}`;
57
88
  // trim trailing '=' if value was empty
58
89
  if (tmp === `${keyPrefix}=`) {
@@ -73,7 +104,7 @@ export function encodeMatrix(
73
104
  export function encodeLabel(
74
105
  key: string,
75
106
  value: unknown,
76
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
107
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
77
108
  ): string | undefined {
78
109
  let out = "";
79
110
  const pairs: [string, unknown][] = options?.explode
@@ -85,7 +116,7 @@ export function encodeLabel(
85
116
  }
86
117
 
87
118
  const encodeString = (v: string) => {
88
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
119
+ return encodeChars(v, options?.charEncoding);
89
120
  };
90
121
  const encodeValue = (v: unknown) => encodeString(serializeValue(v));
91
122
 
@@ -103,7 +134,7 @@ export function encodeLabel(
103
134
  encValue = mapped?.join("").slice(1);
104
135
  } else {
105
136
  const k = options?.explode && isPlainObject(value)
106
- ? `${encodeString(pk)}=`
137
+ ? `${encodeKeyChars(pk, options?.charEncoding)}=`
107
138
  : "";
108
139
  encValue = `${k}${encodeValue(pv)}`;
109
140
  }
@@ -117,14 +148,14 @@ export function encodeLabel(
117
148
  type FormEncoder = (
118
149
  key: string,
119
150
  value: unknown,
120
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
151
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
121
152
  ) => string | undefined;
122
153
 
123
154
  function formEncoder(sep: string): FormEncoder {
124
155
  return (
125
156
  key: string,
126
157
  value: unknown,
127
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
158
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
128
159
  ) => {
129
160
  let out = "";
130
161
  const pairs: [string, unknown][] = options?.explode
@@ -136,7 +167,7 @@ function formEncoder(sep: string): FormEncoder {
136
167
  }
137
168
 
138
169
  const encodeString = (v: string) => {
139
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
170
+ return encodeChars(v, options?.charEncoding);
140
171
  };
141
172
 
142
173
  const encodeValue = (v: unknown) => encodeString(serializeValue(v));
@@ -163,7 +194,7 @@ function formEncoder(sep: string): FormEncoder {
163
194
  return;
164
195
  }
165
196
 
166
- tmp = `${encodeString(pk)}=${encValue}`;
197
+ tmp = `${encodeKeyChars(pk, options?.charEncoding)}=${encValue}`;
167
198
 
168
199
  // If we end up with the nothing then skip forward
169
200
  if (!tmp || tmp === "=") {
@@ -184,7 +215,7 @@ export const encodePipeDelimited = formEncoder("|");
184
215
  export function encodeBodyForm(
185
216
  key: string,
186
217
  value: unknown,
187
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
218
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
188
219
  ): string {
189
220
  let out = "";
190
221
  const pairs: [string, unknown][] = options?.explode
@@ -192,7 +223,7 @@ export function encodeBodyForm(
192
223
  : [[key, value]];
193
224
 
194
225
  const encodeString = (v: string) => {
195
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
226
+ return encodeChars(v, options?.charEncoding);
196
227
  };
197
228
 
198
229
  const encodeValue = (v: unknown) => encodeString(serializeValue(v));
@@ -211,7 +242,7 @@ export function encodeBodyForm(
211
242
  encValue = `${encodeValue(pv)}`;
212
243
  }
213
244
 
214
- tmp = `${encodeString(pk)}=${encValue}`;
245
+ tmp = `${encodeKeyChars(pk, options?.charEncoding)}=${encValue}`;
215
246
 
216
247
  // If we end up with the nothing then skip forward
217
248
  if (!tmp || tmp === "=") {
@@ -227,7 +258,7 @@ export function encodeBodyForm(
227
258
  export function encodeDeepObject(
228
259
  key: string,
229
260
  value: unknown,
230
- options?: { charEncoding?: "percent" | "none" },
261
+ options?: { charEncoding?: CharEncoding },
231
262
  ): string | undefined {
232
263
  if (value == null) {
233
264
  return;
@@ -245,7 +276,7 @@ export function encodeDeepObject(
245
276
  export function encodeDeepObjectObject(
246
277
  key: string,
247
278
  value: unknown,
248
- options?: { charEncoding?: "percent" | "none" },
279
+ options?: { charEncoding?: CharEncoding },
249
280
  ): string | undefined {
250
281
  if (value == null) {
251
282
  return;
@@ -254,7 +285,7 @@ export function encodeDeepObjectObject(
254
285
  let out = "";
255
286
 
256
287
  const encodeString = (v: string) => {
257
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
288
+ return encodeChars(v, options?.charEncoding);
258
289
  };
259
290
 
260
291
  if (!isPlainObject(value)) {
@@ -278,7 +309,9 @@ export function encodeDeepObjectObject(
278
309
 
279
310
  const pairs: unknown[] = Array.isArray(cv) ? cv : [cv];
280
311
  const encoded = mapDefined(pairs, (v) => {
281
- return `${encodeString(pk)}=${encodeString(serializeValue(v))}`;
312
+ return `${encodeKeyChars(pk, options?.charEncoding)}=${
313
+ encodeString(serializeValue(v))
314
+ }`;
282
315
  })?.join("&");
283
316
 
284
317
  out += encoded == null ? "" : `&${encoded}`;
@@ -290,25 +323,27 @@ export function encodeDeepObjectObject(
290
323
  export function encodeJSON(
291
324
  key: string,
292
325
  value: unknown,
293
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
326
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
294
327
  ): string | undefined {
295
328
  if (typeof value === "undefined") {
296
329
  return;
297
330
  }
298
331
 
299
332
  const encodeString = (v: string) => {
300
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
333
+ return encodeChars(v, options?.charEncoding);
301
334
  };
302
335
 
303
336
  const encVal = encodeString(JSON.stringify(value, jsonReplacer));
304
337
 
305
- return options?.explode ? encVal : `${encodeString(key)}=${encVal}`;
338
+ return options?.explode
339
+ ? encVal
340
+ : `${encodeKeyChars(key, options?.charEncoding)}=${encVal}`;
306
341
  }
307
342
 
308
343
  export const encodeSimple = (
309
344
  key: string,
310
345
  value: unknown,
311
- options?: { explode?: boolean; charEncoding?: "percent" | "none" },
346
+ options?: { explode?: boolean; charEncoding?: CharEncoding },
312
347
  ): string | undefined => {
313
348
  let out = "";
314
349
  const pairs: [string, unknown][] = options?.explode
@@ -320,7 +355,7 @@ export const encodeSimple = (
320
355
  }
321
356
 
322
357
  const encodeString = (v: string) => {
323
- return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
358
+ return encodeChars(v, options?.charEncoding);
324
359
  };
325
360
  const encodeValue = (v: unknown) => encodeString(serializeValue(v));
326
361
 
@@ -426,7 +461,7 @@ export function queryJoin(...args: (string | undefined)[]): string {
426
461
 
427
462
  type QueryEncoderOptions = {
428
463
  explode?: boolean;
429
- charEncoding?: "percent" | "none";
464
+ charEncoding?: CharEncoding;
430
465
  allowEmptyValue?: string[];
431
466
  };
432
467
 
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.54.4",
22
+ currentVersion: "0.54.6",
23
23
  },
24
24
  });
25
25
 
@@ -384,7 +384,7 @@ export function createMCPServer(deps: {
384
384
  }) {
385
385
  const server = new McpServer({
386
386
  name: "SDK",
387
- version: "0.54.4",
387
+ version: "0.54.6",
388
388
  });
389
389
 
390
390
  const client = new SDKCore({
@@ -37,6 +37,10 @@ export type CreateAgentRunRequest = {
37
37
  * Context management strategies to apply during agent-run response generation. Supports compaction, which summarizes older conversation history when the context exceeds a token threshold.
38
38
  */
39
39
  contextManagement?: Array<AgentCompactionContextManagement> | undefined;
40
+ /**
41
+ * When true, the gateway generates per-token delta events for this run, so the events endpoint streams incremental output instead of only item and lifecycle boundaries. The run still executes in the background and this endpoint still returns the queued run record.
42
+ */
43
+ stream?: boolean | undefined;
40
44
  metadata?: { [k: string]: string } | undefined;
41
45
  };
42
46
 
@@ -149,6 +153,7 @@ export const CreateAgentRunRequest$inboundSchema: z.ZodType<
149
153
  previous_response_id: z.string().optional(),
150
154
  context_management: z.array(AgentCompactionContextManagement$inboundSchema)
151
155
  .optional(),
156
+ stream: z.boolean().default(false),
152
157
  metadata: z.record(z.string()).optional(),
153
158
  }).transform((v) => {
154
159
  return remap$(v, {
@@ -164,6 +169,7 @@ export type CreateAgentRunRequest$Outbound = {
164
169
  context_management?:
165
170
  | Array<AgentCompactionContextManagement$Outbound>
166
171
  | undefined;
172
+ stream: boolean;
167
173
  metadata?: { [k: string]: string } | undefined;
168
174
  };
169
175
 
@@ -181,6 +187,7 @@ export const CreateAgentRunRequest$outboundSchema: z.ZodType<
181
187
  previousResponseId: z.string().optional(),
182
188
  contextManagement: z.array(AgentCompactionContextManagement$outboundSchema)
183
189
  .optional(),
190
+ stream: z.boolean().default(false),
184
191
  metadata: z.record(z.string()).optional(),
185
192
  }).transform((v) => {
186
193
  return remap$(v, {
@@ -295,6 +295,10 @@ export type ResponsesCreateRequest = {
295
295
  * Additional options for configuring streaming behavior when stream is enabled.
296
296
  */
297
297
  streamOptions?: ResponsesCreateRequestStreamOptions | null | undefined;
298
+ /**
299
+ * Gateway extension. When true, provider calls are streamed even when `stream` is false, so per-token delta events are published to the response's event channel and visible via GET /responses/{id}?stream=true. Does not change the shape of this endpoint's HTTP response. Only valid when background=true; foreground requests are rejected. Defaults to false.
300
+ */
301
+ streamEvents?: boolean | undefined;
298
302
  /**
299
303
  * Whether to store the generated response for later retrieval. When true, the response is saved and can be retrieved via GET /responses/{id}. When false, the response is not persisted after generation. Defaults to true.
300
304
  */
@@ -812,6 +816,7 @@ export const ResponsesCreateRequest$inboundSchema: z.ZodType<
812
816
  stream_options: z.nullable(
813
817
  z.lazy(() => ResponsesCreateRequestStreamOptions$inboundSchema),
814
818
  ).optional(),
819
+ stream_events: z.boolean().optional(),
815
820
  store: z.boolean().default(true),
816
821
  background: z.boolean().default(false),
817
822
  webhook_url: z.string().optional(),
@@ -869,6 +874,7 @@ export const ResponsesCreateRequest$inboundSchema: z.ZodType<
869
874
  return remap$(v, {
870
875
  "previous_response_id": "previousResponseId",
871
876
  "stream_options": "streamOptions",
877
+ "stream_events": "streamEvents",
872
878
  "webhook_url": "webhookUrl",
873
879
  "webhook_secret": "webhookSecret",
874
880
  "tool_choice": "toolChoice",
@@ -910,6 +916,7 @@ export type ResponsesCreateRequest$Outbound = {
910
916
  | ResponsesCreateRequestStreamOptions$Outbound
911
917
  | null
912
918
  | undefined;
919
+ stream_events?: boolean | undefined;
913
920
  store: boolean;
914
921
  background: boolean;
915
922
  webhook_url?: string | undefined;
@@ -983,6 +990,7 @@ export const ResponsesCreateRequest$outboundSchema: z.ZodType<
983
990
  streamOptions: z.nullable(
984
991
  z.lazy(() => ResponsesCreateRequestStreamOptions$outboundSchema),
985
992
  ).optional(),
993
+ streamEvents: z.boolean().optional(),
986
994
  store: z.boolean().default(true),
987
995
  background: z.boolean().default(false),
988
996
  webhookUrl: z.string().optional(),
@@ -1040,6 +1048,7 @@ export const ResponsesCreateRequest$outboundSchema: z.ZodType<
1040
1048
  return remap$(v, {
1041
1049
  previousResponseId: "previous_response_id",
1042
1050
  streamOptions: "stream_options",
1051
+ streamEvents: "stream_events",
1043
1052
  webhookUrl: "webhook_url",
1044
1053
  webhookSecret: "webhook_secret",
1045
1054
  toolChoice: "tool_choice",