@copilotkitnext/shared 1.54.0 → 1.54.1-next.1

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.cjs CHANGED
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_types = require('./types.cjs');
2
3
  const require_utils = require('./utils.cjs');
3
4
  const require_logger = require('./logger.cjs');
4
5
  const require_constants = require('./constants.cjs');
@@ -8,6 +9,8 @@ const require_standard_schema = require('./standard-schema.cjs');
8
9
 
9
10
  exports.AG_UI_CHANNEL_EVENT = require_constants.AG_UI_CHANNEL_EVENT;
10
11
  exports.DEFAULT_AGENT_ID = require_constants.DEFAULT_AGENT_ID;
12
+ exports.RUNTIME_MODE_INTELLIGENCE = require_types.RUNTIME_MODE_INTELLIGENCE;
13
+ exports.RUNTIME_MODE_SSE = require_types.RUNTIME_MODE_SSE;
11
14
  exports.TranscriptionErrorCode = require_transcription_errors.TranscriptionErrorCode;
12
15
  exports.TranscriptionErrors = require_transcription_errors.TranscriptionErrors;
13
16
  exports.finalizeRunEvents = require_finalize_events.finalizeRunEvents;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { AgentDescription, MaybePromise, NonEmptyRecord, RuntimeInfo } from "./types.cjs";
1
+ import { AgentDescription, IntelligenceRuntimeInfo, MaybePromise, NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, RuntimeInfo, RuntimeMode } from "./types.cjs";
2
2
  import { partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs } from "./utils.cjs";
3
3
  import { logger } from "./logger.cjs";
4
4
  import { AG_UI_CHANNEL_EVENT, DEFAULT_AGENT_ID } from "./constants.cjs";
5
5
  import { finalizeRunEvents } from "./finalize-events.cjs";
6
6
  import { TranscriptionErrorCode, TranscriptionErrorResponse, TranscriptionErrors } from "./transcription-errors.cjs";
7
7
  import { InferSchemaOutput, SchemaToJsonSchemaOptions, StandardJSONSchemaV1, StandardSchemaV1, schemaToJsonSchema } from "./standard-schema.cjs";
8
- export { AG_UI_CHANNEL_EVENT, type AgentDescription, DEFAULT_AGENT_ID, type InferSchemaOutput, type MaybePromise, type NonEmptyRecord, type RuntimeInfo, type SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, finalizeRunEvents, logger, partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs, schemaToJsonSchema };
8
+ export { AG_UI_CHANNEL_EVENT, type AgentDescription, DEFAULT_AGENT_ID, type InferSchemaOutput, type IntelligenceRuntimeInfo, type MaybePromise, type NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, type RuntimeInfo, type RuntimeMode, type SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, finalizeRunEvents, logger, partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs, schemaToJsonSchema };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { AgentDescription, MaybePromise, NonEmptyRecord, RuntimeInfo } from "./types.mjs";
1
+ import { AgentDescription, IntelligenceRuntimeInfo, MaybePromise, NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, RuntimeInfo, RuntimeMode } from "./types.mjs";
2
2
  import { partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs } from "./utils.mjs";
3
3
  import { logger } from "./logger.mjs";
4
4
  import { AG_UI_CHANNEL_EVENT, DEFAULT_AGENT_ID } from "./constants.mjs";
5
5
  import { finalizeRunEvents } from "./finalize-events.mjs";
6
6
  import { TranscriptionErrorCode, TranscriptionErrorResponse, TranscriptionErrors } from "./transcription-errors.mjs";
7
7
  import { InferSchemaOutput, SchemaToJsonSchemaOptions, StandardJSONSchemaV1, StandardSchemaV1, schemaToJsonSchema } from "./standard-schema.mjs";
8
- export { AG_UI_CHANNEL_EVENT, type AgentDescription, DEFAULT_AGENT_ID, type InferSchemaOutput, type MaybePromise, type NonEmptyRecord, type RuntimeInfo, type SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, finalizeRunEvents, logger, partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs, schemaToJsonSchema };
8
+ export { AG_UI_CHANNEL_EVENT, type AgentDescription, DEFAULT_AGENT_ID, type InferSchemaOutput, type IntelligenceRuntimeInfo, type MaybePromise, type NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, type RuntimeInfo, type RuntimeMode, type SchemaToJsonSchemaOptions, type StandardJSONSchemaV1, type StandardSchemaV1, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, finalizeRunEvents, logger, partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs, schemaToJsonSchema };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE } from "./types.mjs";
1
2
  import { partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs } from "./utils.mjs";
2
3
  import { logger } from "./logger.mjs";
3
4
  import { AG_UI_CHANNEL_EVENT, DEFAULT_AGENT_ID } from "./constants.mjs";
@@ -5,4 +6,4 @@ import { finalizeRunEvents } from "./finalize-events.mjs";
5
6
  import { TranscriptionErrorCode, TranscriptionErrors } from "./transcription-errors.mjs";
6
7
  import { schemaToJsonSchema } from "./standard-schema.mjs";
7
8
 
8
- export { AG_UI_CHANNEL_EVENT, DEFAULT_AGENT_ID, TranscriptionErrorCode, TranscriptionErrors, finalizeRunEvents, logger, partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs, schemaToJsonSchema };
9
+ export { AG_UI_CHANNEL_EVENT, DEFAULT_AGENT_ID, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, TranscriptionErrorCode, TranscriptionErrors, finalizeRunEvents, logger, partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs, schemaToJsonSchema };
package/dist/index.umd.js CHANGED
@@ -33,6 +33,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33
33
  //#endregion
34
34
  partial_json = __toESM(partial_json);
35
35
 
36
+ //#region src/types.ts
37
+ const RUNTIME_MODE_SSE = "sse";
38
+ const RUNTIME_MODE_INTELLIGENCE = "intelligence";
39
+
40
+ //#endregion
36
41
  //#region src/utils.ts
37
42
  function randomUUID() {
38
43
  return (0, uuid.v4)();
@@ -298,6 +303,8 @@ partial_json = __toESM(partial_json);
298
303
  //#endregion
299
304
  exports.AG_UI_CHANNEL_EVENT = AG_UI_CHANNEL_EVENT;
300
305
  exports.DEFAULT_AGENT_ID = DEFAULT_AGENT_ID;
306
+ exports.RUNTIME_MODE_INTELLIGENCE = RUNTIME_MODE_INTELLIGENCE;
307
+ exports.RUNTIME_MODE_SSE = RUNTIME_MODE_SSE;
301
308
  exports.TranscriptionErrorCode = TranscriptionErrorCode;
302
309
  exports.TranscriptionErrors = TranscriptionErrors;
303
310
  exports.finalizeRunEvents = finalizeRunEvents;
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","names":["PartialJSON","EventType"],"sources":["../src/utils.ts","../src/logger.ts","../src/constants.ts","../src/finalize-events.ts","../src/transcription-errors.ts","../src/standard-schema.ts"],"sourcesContent":["import { v4 as uuidv4 } from \"uuid\";\nimport * as PartialJSON from \"partial-json\";\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function partialJSONParse(json: string): unknown {\n try {\n const parsed = PartialJSON.parse(json);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n !Array.isArray(parsed)\n ) {\n return parsed as Record<string, unknown>;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch (error) {\n return {};\n }\n}\n\n/**\n * Safely parses a JSON string into a plain object for tool arguments.\n * Handles two failure modes:\n * 1. Malformed JSON (SyntaxError from JSON.parse)\n * 2. Valid JSON that isn't a plain object (e.g. \"\", [], null, 42, true)\n * Falls back to an empty object for safety in both cases.\n */\nexport function safeParseToolArgs(raw: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n !Array.isArray(parsed)\n ) {\n return parsed as Record<string, unknown>;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch {\n console.warn(\n \"[CopilotKit] Failed to parse tool arguments, falling back to empty object\",\n );\n return {};\n }\n}\n\n/**\n * Returns an exponential backoff function suitable for Phoenix.js\n * `reconnectAfterMs` and `rejoinAfterMs` options.\n *\n * @param baseMs - Initial delay for the first retry attempt.\n * @param maxMs - Upper bound — delays are capped at this value.\n *\n * Phoenix calls the returned function with a 1-based `tries` count.\n * The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.\n */\nexport function phoenixExponentialBackoff(\n baseMs: number,\n maxMs: number,\n): (tries: number) => number {\n return (tries: number) => Math.min(baseMs * 2 ** (tries - 1), maxMs);\n}\n","export const logger = console;\n","export const DEFAULT_AGENT_ID = \"default\";\n\n/** Phoenix channel event name used for all AG-UI events. */\nexport const AG_UI_CHANNEL_EVENT = \"ag-ui\";\n","import { BaseEvent, EventType, RunErrorEvent } from \"@ag-ui/client\";\nimport { randomUUID } from \"./utils\";\n\ninterface FinalizeRunOptions {\n stopRequested?: boolean;\n interruptionMessage?: string;\n}\n\nconst defaultStopMessage = \"Run stopped by user\";\nconst defaultAbruptEndMessage = \"Run ended without emitting a terminal event\";\n\nexport function finalizeRunEvents(\n events: BaseEvent[],\n options: FinalizeRunOptions = {},\n): BaseEvent[] {\n const { stopRequested = false, interruptionMessage } = options;\n\n const resolvedStopMessage = interruptionMessage ?? defaultStopMessage;\n const resolvedAbruptMessage =\n interruptionMessage && interruptionMessage !== defaultStopMessage\n ? interruptionMessage\n : defaultAbruptEndMessage;\n\n const appended: BaseEvent[] = [];\n\n const openMessageIds = new Set<string>();\n const openToolCalls = new Map<\n string,\n {\n hasEnd: boolean;\n hasResult: boolean;\n }\n >();\n\n for (const event of events) {\n switch (event.type) {\n case EventType.TEXT_MESSAGE_START: {\n const messageId = (event as { messageId?: string }).messageId;\n if (typeof messageId === \"string\") {\n openMessageIds.add(messageId);\n }\n break;\n }\n case EventType.TEXT_MESSAGE_END: {\n const messageId = (event as { messageId?: string }).messageId;\n if (typeof messageId === \"string\") {\n openMessageIds.delete(messageId);\n }\n break;\n }\n case EventType.TOOL_CALL_START: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n if (typeof toolCallId === \"string\") {\n openToolCalls.set(toolCallId, {\n hasEnd: false,\n hasResult: false,\n });\n }\n break;\n }\n case EventType.TOOL_CALL_END: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n const info = toolCallId ? openToolCalls.get(toolCallId) : undefined;\n if (info) {\n info.hasEnd = true;\n }\n break;\n }\n case EventType.TOOL_CALL_RESULT: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n const info = toolCallId ? openToolCalls.get(toolCallId) : undefined;\n if (info) {\n info.hasResult = true;\n }\n break;\n }\n default:\n break;\n }\n }\n\n const hasRunFinished = events.some(\n (event) => event.type === EventType.RUN_FINISHED,\n );\n const hasRunError = events.some(\n (event) => event.type === EventType.RUN_ERROR,\n );\n const hasTerminalEvent = hasRunFinished || hasRunError;\n const terminalEventMissing = !hasTerminalEvent;\n\n for (const messageId of openMessageIds) {\n const endEvent = {\n type: EventType.TEXT_MESSAGE_END,\n messageId,\n } as BaseEvent;\n events.push(endEvent);\n appended.push(endEvent);\n }\n\n for (const [toolCallId, info] of openToolCalls) {\n if (!info.hasEnd) {\n const endEvent = {\n type: EventType.TOOL_CALL_END,\n toolCallId,\n } as BaseEvent;\n events.push(endEvent);\n appended.push(endEvent);\n }\n\n if (terminalEventMissing && !info.hasResult) {\n const resultEvent = {\n type: EventType.TOOL_CALL_RESULT,\n toolCallId,\n messageId: `${toolCallId ?? randomUUID()}-result`,\n role: \"tool\",\n content: JSON.stringify(\n stopRequested\n ? {\n status: \"stopped\",\n reason: \"stop_requested\",\n message: resolvedStopMessage,\n }\n : {\n status: \"error\",\n reason: \"missing_terminal_event\",\n message: resolvedAbruptMessage,\n },\n ),\n } as BaseEvent;\n events.push(resultEvent);\n appended.push(resultEvent);\n }\n }\n\n if (terminalEventMissing) {\n if (stopRequested) {\n const finishedEvent = {\n type: EventType.RUN_FINISHED,\n } as BaseEvent;\n events.push(finishedEvent);\n appended.push(finishedEvent);\n } else {\n const errorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: resolvedAbruptMessage,\n code: \"INCOMPLETE_STREAM\",\n };\n events.push(errorEvent);\n appended.push(errorEvent);\n }\n }\n\n return appended;\n}\n","/**\n * Error codes for transcription HTTP responses.\n * Uses snake_case to align with existing CopilotKitCoreErrorCode pattern.\n * These codes are returned by the runtime and parsed by the client.\n */\nexport enum TranscriptionErrorCode {\n /** Transcription service not configured in runtime */\n SERVICE_NOT_CONFIGURED = \"service_not_configured\",\n /** Audio format not supported */\n INVALID_AUDIO_FORMAT = \"invalid_audio_format\",\n /** Audio file is too long */\n AUDIO_TOO_LONG = \"audio_too_long\",\n /** Audio file is empty or too short */\n AUDIO_TOO_SHORT = \"audio_too_short\",\n /** Rate limited by transcription provider */\n RATE_LIMITED = \"rate_limited\",\n /** Authentication failed with transcription provider */\n AUTH_FAILED = \"auth_failed\",\n /** Transcription provider returned an error */\n PROVIDER_ERROR = \"provider_error\",\n /** Network error during transcription */\n NETWORK_ERROR = \"network_error\",\n /** Invalid request format */\n INVALID_REQUEST = \"invalid_request\",\n}\n\n/**\n * Error response format returned by the transcription endpoint.\n */\nexport interface TranscriptionErrorResponse {\n error: TranscriptionErrorCode;\n message: string;\n retryable?: boolean;\n}\n\n/**\n * Helper functions to create transcription error responses.\n * Used by the runtime to return consistent error responses.\n */\nexport const TranscriptionErrors = {\n serviceNotConfigured: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.SERVICE_NOT_CONFIGURED,\n message: \"Transcription service is not configured\",\n retryable: false,\n }),\n\n invalidAudioFormat: (\n format: string,\n supported: string[],\n ): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.INVALID_AUDIO_FORMAT,\n message: `Unsupported audio format: ${format}. Supported: ${supported.join(\", \")}`,\n retryable: false,\n }),\n\n invalidRequest: (details: string): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.INVALID_REQUEST,\n message: details,\n retryable: false,\n }),\n\n rateLimited: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.RATE_LIMITED,\n message: \"Rate limited. Please try again later.\",\n retryable: true,\n }),\n\n authFailed: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.AUTH_FAILED,\n message: \"Authentication failed with transcription provider\",\n retryable: false,\n }),\n\n providerError: (message: string): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.PROVIDER_ERROR,\n message,\n retryable: true,\n }),\n\n networkError: (\n message: string = \"Network error during transcription\",\n ): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.NETWORK_ERROR,\n message,\n retryable: true,\n }),\n\n audioTooLong: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.AUDIO_TOO_LONG,\n message: \"Audio file is too long\",\n retryable: false,\n }),\n\n audioTooShort: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.AUDIO_TOO_SHORT,\n message: \"Audio is too short to transcribe\",\n retryable: false,\n }),\n};\n","import type {\n StandardSchemaV1,\n StandardJSONSchemaV1,\n} from \"@standard-schema/spec\";\n\nexport type { StandardSchemaV1, StandardJSONSchemaV1 };\n\n/**\n * Extract the Output type from a StandardSchemaV1 schema.\n * Replaces `z.infer<S>` for generic schema inference.\n */\nexport type InferSchemaOutput<S> =\n S extends StandardSchemaV1<any, infer O> ? O : never;\n\nexport interface SchemaToJsonSchemaOptions {\n /**\n * Injected `zodToJsonSchema` function so that `shared` does not depend on\n * `zod-to-json-schema`. Required when the schema is a Zod v3 schema that\n * does not implement Standard JSON Schema V1.\n */\n zodToJsonSchema?: (\n schema: unknown,\n options?: { $refStrategy?: string },\n ) => Record<string, unknown>;\n}\n\n/**\n * Check whether a schema implements the Standard JSON Schema V1 protocol.\n */\nfunction hasStandardJsonSchema(\n schema: StandardSchemaV1,\n): schema is StandardSchemaV1 & StandardJSONSchemaV1 {\n const props = schema[\"~standard\"];\n return (\n props != null &&\n typeof props === \"object\" &&\n \"jsonSchema\" in props &&\n props.jsonSchema != null &&\n typeof props.jsonSchema === \"object\" &&\n \"input\" in props.jsonSchema &&\n typeof props.jsonSchema.input === \"function\"\n );\n}\n\n/**\n * Convert any StandardSchemaV1-compatible schema to a JSON Schema object.\n *\n * Strategy:\n * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),\n * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.\n * 2. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the\n * injected `zodToJsonSchema()` function.\n * 3. Otherwise throw a descriptive error.\n */\nexport function schemaToJsonSchema(\n schema: StandardSchemaV1,\n options?: SchemaToJsonSchemaOptions,\n): Record<string, unknown> {\n // 1. Standard JSON Schema V1\n if (hasStandardJsonSchema(schema)) {\n return schema[\"~standard\"].jsonSchema.input({ target: \"draft-07\" });\n }\n\n // 2. Zod v3 fallback\n const vendor = schema[\"~standard\"].vendor;\n if (vendor === \"zod\" && options?.zodToJsonSchema) {\n return options.zodToJsonSchema(schema, { $refStrategy: \"none\" });\n }\n\n throw new Error(\n `Cannot convert schema to JSON Schema. The schema (vendor: \"${vendor}\") does not implement Standard JSON Schema V1 ` +\n `and no zodToJsonSchema fallback is available. ` +\n `Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) ` +\n `or pass a zodToJsonSchema function in options.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGA,SAAgB,aAAa;AAC3B,uBAAe;;CAGjB,SAAgB,iBAAiB,MAAuB;AACtD,MAAI;GACF,MAAM,SAASA,aAAY,MAAM,KAAK;AACtC,OACE,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,MAAM,QAAQ,OAAO,CAEtB,QAAO;AAET,WAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,UAAO,EAAE;WACF,OAAO;AACd,UAAO,EAAE;;;;;;;;;;CAWb,SAAgB,kBAAkB,KAAsC;AACtE,MAAI;GACF,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,OACE,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,MAAM,QAAQ,OAAO,CAEtB,QAAO;AAET,WAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,UAAO,EAAE;oBACH;AACN,WAAQ,KACN,4EACD;AACD,UAAO,EAAE;;;;;;;;;;;;;CAcb,SAAgB,0BACd,QACA,OAC2B;AAC3B,UAAQ,UAAkB,KAAK,IAAI,SAAS,MAAM,QAAQ,IAAI,MAAM;;;;;CCrEtE,MAAa,SAAS;;;;CCAtB,MAAa,mBAAmB;;CAGhC,MAAa,sBAAsB;;;;CCKnC,MAAM,qBAAqB;CAC3B,MAAM,0BAA0B;CAEhC,SAAgB,kBACd,QACA,UAA8B,EAAE,EACnB;EACb,MAAM,EAAE,gBAAgB,OAAO,wBAAwB;EAEvD,MAAM,sBAAsB,uFAAuB;EACnD,MAAM,wBACJ,uBAAuB,wBAAwB,qBAC3C,sBACA;EAEN,MAAM,WAAwB,EAAE;EAEhC,MAAM,iCAAiB,IAAI,KAAa;EACxC,MAAM,gCAAgB,IAAI,KAMvB;AAEH,OAAK,MAAM,SAAS,OAClB,SAAQ,MAAM,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ACF;;;;;;;CCrED,SAAS,sBACP,QACmD;EACnD,MAAM,QAAQ,OAAO;AACrB,SACE,SAAS,QACT,OAAO,UAAU,YACjB,gBAAgB,SAChB,MAAM,cAAc,QACpB,OAAO,MAAM,eAAe,YAC5B,WAAW,MAAM,cACjB,OAAO,MAAM,WAAW,UAAU;;;;;;;;;;;;CActC,SAAgB,mBACd,QACA,SACyB;AAEzB,MAAI,sBAAsB,OAAO,CAC/B,QAAO,OAAO,aAAa,WAAW,MAAM,EAAE,QAAQ,YAAY,CAAC;EAIrE,MAAM,SAAS,OAAO,aAAa;AACnC,MAAI,WAAW,4DAAS,QAAS,iBAC/B,QAAO,QAAQ,gBAAgB,QAAQ,EAAE,cAAc,QAAQ,CAAC;AAGlE,QAAM,IAAI,MACR,8DAA8D,OAAO,yOAItE"}
1
+ {"version":3,"file":"index.umd.js","names":["PartialJSON","EventType"],"sources":["../src/types.ts","../src/utils.ts","../src/logger.ts","../src/constants.ts","../src/finalize-events.ts","../src/transcription-errors.ts","../src/standard-schema.ts"],"sourcesContent":["export type MaybePromise<T> = T | PromiseLike<T>;\n\n/**\n * More specific utility for records with at least one key\n */\nexport type NonEmptyRecord<T> =\n T extends Record<string, unknown>\n ? keyof T extends never\n ? never\n : T\n : never;\n\n/**\n * Type representing an agent's basic information\n */\nexport interface AgentDescription {\n name: string;\n className: string;\n description: string;\n}\n\nexport type RuntimeMode = \"sse\" | \"intelligence\";\n\nexport const RUNTIME_MODE_SSE = \"sse\" as const;\nexport const RUNTIME_MODE_INTELLIGENCE = \"intelligence\" as const;\n\nexport interface IntelligenceRuntimeInfo {\n wsUrl: string;\n}\n\nexport interface RuntimeInfo {\n version: string;\n agents: Record<string, AgentDescription>;\n audioFileTranscriptionEnabled: boolean;\n mode: RuntimeMode;\n intelligence?: IntelligenceRuntimeInfo;\n a2uiEnabled?: boolean;\n}\n","import { v4 as uuidv4 } from \"uuid\";\nimport * as PartialJSON from \"partial-json\";\n\nexport function randomUUID() {\n return uuidv4();\n}\n\nexport function partialJSONParse(json: string): unknown {\n try {\n const parsed = PartialJSON.parse(json);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n !Array.isArray(parsed)\n ) {\n return parsed as Record<string, unknown>;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch (error) {\n return {};\n }\n}\n\n/**\n * Safely parses a JSON string into a plain object for tool arguments.\n * Handles two failure modes:\n * 1. Malformed JSON (SyntaxError from JSON.parse)\n * 2. Valid JSON that isn't a plain object (e.g. \"\", [], null, 42, true)\n * Falls back to an empty object for safety in both cases.\n */\nexport function safeParseToolArgs(raw: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n !Array.isArray(parsed)\n ) {\n return parsed as Record<string, unknown>;\n }\n console.warn(\n `[CopilotKit] Tool arguments parsed to non-object (${typeof parsed}), falling back to empty object`,\n );\n return {};\n } catch {\n console.warn(\n \"[CopilotKit] Failed to parse tool arguments, falling back to empty object\",\n );\n return {};\n }\n}\n\n/**\n * Returns an exponential backoff function suitable for Phoenix.js\n * `reconnectAfterMs` and `rejoinAfterMs` options.\n *\n * @param baseMs - Initial delay for the first retry attempt.\n * @param maxMs - Upper bound — delays are capped at this value.\n *\n * Phoenix calls the returned function with a 1-based `tries` count.\n * The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.\n */\nexport function phoenixExponentialBackoff(\n baseMs: number,\n maxMs: number,\n): (tries: number) => number {\n return (tries: number) => Math.min(baseMs * 2 ** (tries - 1), maxMs);\n}\n","export const logger = console;\n","export const DEFAULT_AGENT_ID = \"default\";\n\n/** Phoenix channel event name used for all AG-UI events. */\nexport const AG_UI_CHANNEL_EVENT = \"ag-ui\";\n","import { BaseEvent, EventType, RunErrorEvent } from \"@ag-ui/client\";\nimport { randomUUID } from \"./utils\";\n\ninterface FinalizeRunOptions {\n stopRequested?: boolean;\n interruptionMessage?: string;\n}\n\nconst defaultStopMessage = \"Run stopped by user\";\nconst defaultAbruptEndMessage = \"Run ended without emitting a terminal event\";\n\nexport function finalizeRunEvents(\n events: BaseEvent[],\n options: FinalizeRunOptions = {},\n): BaseEvent[] {\n const { stopRequested = false, interruptionMessage } = options;\n\n const resolvedStopMessage = interruptionMessage ?? defaultStopMessage;\n const resolvedAbruptMessage =\n interruptionMessage && interruptionMessage !== defaultStopMessage\n ? interruptionMessage\n : defaultAbruptEndMessage;\n\n const appended: BaseEvent[] = [];\n\n const openMessageIds = new Set<string>();\n const openToolCalls = new Map<\n string,\n {\n hasEnd: boolean;\n hasResult: boolean;\n }\n >();\n\n for (const event of events) {\n switch (event.type) {\n case EventType.TEXT_MESSAGE_START: {\n const messageId = (event as { messageId?: string }).messageId;\n if (typeof messageId === \"string\") {\n openMessageIds.add(messageId);\n }\n break;\n }\n case EventType.TEXT_MESSAGE_END: {\n const messageId = (event as { messageId?: string }).messageId;\n if (typeof messageId === \"string\") {\n openMessageIds.delete(messageId);\n }\n break;\n }\n case EventType.TOOL_CALL_START: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n if (typeof toolCallId === \"string\") {\n openToolCalls.set(toolCallId, {\n hasEnd: false,\n hasResult: false,\n });\n }\n break;\n }\n case EventType.TOOL_CALL_END: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n const info = toolCallId ? openToolCalls.get(toolCallId) : undefined;\n if (info) {\n info.hasEnd = true;\n }\n break;\n }\n case EventType.TOOL_CALL_RESULT: {\n const toolCallId = (event as { toolCallId?: string }).toolCallId;\n const info = toolCallId ? openToolCalls.get(toolCallId) : undefined;\n if (info) {\n info.hasResult = true;\n }\n break;\n }\n default:\n break;\n }\n }\n\n const hasRunFinished = events.some(\n (event) => event.type === EventType.RUN_FINISHED,\n );\n const hasRunError = events.some(\n (event) => event.type === EventType.RUN_ERROR,\n );\n const hasTerminalEvent = hasRunFinished || hasRunError;\n const terminalEventMissing = !hasTerminalEvent;\n\n for (const messageId of openMessageIds) {\n const endEvent = {\n type: EventType.TEXT_MESSAGE_END,\n messageId,\n } as BaseEvent;\n events.push(endEvent);\n appended.push(endEvent);\n }\n\n for (const [toolCallId, info] of openToolCalls) {\n if (!info.hasEnd) {\n const endEvent = {\n type: EventType.TOOL_CALL_END,\n toolCallId,\n } as BaseEvent;\n events.push(endEvent);\n appended.push(endEvent);\n }\n\n if (terminalEventMissing && !info.hasResult) {\n const resultEvent = {\n type: EventType.TOOL_CALL_RESULT,\n toolCallId,\n messageId: `${toolCallId ?? randomUUID()}-result`,\n role: \"tool\",\n content: JSON.stringify(\n stopRequested\n ? {\n status: \"stopped\",\n reason: \"stop_requested\",\n message: resolvedStopMessage,\n }\n : {\n status: \"error\",\n reason: \"missing_terminal_event\",\n message: resolvedAbruptMessage,\n },\n ),\n } as BaseEvent;\n events.push(resultEvent);\n appended.push(resultEvent);\n }\n }\n\n if (terminalEventMissing) {\n if (stopRequested) {\n const finishedEvent = {\n type: EventType.RUN_FINISHED,\n } as BaseEvent;\n events.push(finishedEvent);\n appended.push(finishedEvent);\n } else {\n const errorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: resolvedAbruptMessage,\n code: \"INCOMPLETE_STREAM\",\n };\n events.push(errorEvent);\n appended.push(errorEvent);\n }\n }\n\n return appended;\n}\n","/**\n * Error codes for transcription HTTP responses.\n * Uses snake_case to align with existing CopilotKitCoreErrorCode pattern.\n * These codes are returned by the runtime and parsed by the client.\n */\nexport enum TranscriptionErrorCode {\n /** Transcription service not configured in runtime */\n SERVICE_NOT_CONFIGURED = \"service_not_configured\",\n /** Audio format not supported */\n INVALID_AUDIO_FORMAT = \"invalid_audio_format\",\n /** Audio file is too long */\n AUDIO_TOO_LONG = \"audio_too_long\",\n /** Audio file is empty or too short */\n AUDIO_TOO_SHORT = \"audio_too_short\",\n /** Rate limited by transcription provider */\n RATE_LIMITED = \"rate_limited\",\n /** Authentication failed with transcription provider */\n AUTH_FAILED = \"auth_failed\",\n /** Transcription provider returned an error */\n PROVIDER_ERROR = \"provider_error\",\n /** Network error during transcription */\n NETWORK_ERROR = \"network_error\",\n /** Invalid request format */\n INVALID_REQUEST = \"invalid_request\",\n}\n\n/**\n * Error response format returned by the transcription endpoint.\n */\nexport interface TranscriptionErrorResponse {\n error: TranscriptionErrorCode;\n message: string;\n retryable?: boolean;\n}\n\n/**\n * Helper functions to create transcription error responses.\n * Used by the runtime to return consistent error responses.\n */\nexport const TranscriptionErrors = {\n serviceNotConfigured: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.SERVICE_NOT_CONFIGURED,\n message: \"Transcription service is not configured\",\n retryable: false,\n }),\n\n invalidAudioFormat: (\n format: string,\n supported: string[],\n ): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.INVALID_AUDIO_FORMAT,\n message: `Unsupported audio format: ${format}. Supported: ${supported.join(\", \")}`,\n retryable: false,\n }),\n\n invalidRequest: (details: string): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.INVALID_REQUEST,\n message: details,\n retryable: false,\n }),\n\n rateLimited: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.RATE_LIMITED,\n message: \"Rate limited. Please try again later.\",\n retryable: true,\n }),\n\n authFailed: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.AUTH_FAILED,\n message: \"Authentication failed with transcription provider\",\n retryable: false,\n }),\n\n providerError: (message: string): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.PROVIDER_ERROR,\n message,\n retryable: true,\n }),\n\n networkError: (\n message: string = \"Network error during transcription\",\n ): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.NETWORK_ERROR,\n message,\n retryable: true,\n }),\n\n audioTooLong: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.AUDIO_TOO_LONG,\n message: \"Audio file is too long\",\n retryable: false,\n }),\n\n audioTooShort: (): TranscriptionErrorResponse => ({\n error: TranscriptionErrorCode.AUDIO_TOO_SHORT,\n message: \"Audio is too short to transcribe\",\n retryable: false,\n }),\n};\n","import type {\n StandardSchemaV1,\n StandardJSONSchemaV1,\n} from \"@standard-schema/spec\";\n\nexport type { StandardSchemaV1, StandardJSONSchemaV1 };\n\n/**\n * Extract the Output type from a StandardSchemaV1 schema.\n * Replaces `z.infer<S>` for generic schema inference.\n */\nexport type InferSchemaOutput<S> =\n S extends StandardSchemaV1<any, infer O> ? O : never;\n\nexport interface SchemaToJsonSchemaOptions {\n /**\n * Injected `zodToJsonSchema` function so that `shared` does not depend on\n * `zod-to-json-schema`. Required when the schema is a Zod v3 schema that\n * does not implement Standard JSON Schema V1.\n */\n zodToJsonSchema?: (\n schema: unknown,\n options?: { $refStrategy?: string },\n ) => Record<string, unknown>;\n}\n\n/**\n * Check whether a schema implements the Standard JSON Schema V1 protocol.\n */\nfunction hasStandardJsonSchema(\n schema: StandardSchemaV1,\n): schema is StandardSchemaV1 & StandardJSONSchemaV1 {\n const props = schema[\"~standard\"];\n return (\n props != null &&\n typeof props === \"object\" &&\n \"jsonSchema\" in props &&\n props.jsonSchema != null &&\n typeof props.jsonSchema === \"object\" &&\n \"input\" in props.jsonSchema &&\n typeof props.jsonSchema.input === \"function\"\n );\n}\n\n/**\n * Convert any StandardSchemaV1-compatible schema to a JSON Schema object.\n *\n * Strategy:\n * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),\n * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.\n * 2. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the\n * injected `zodToJsonSchema()` function.\n * 3. Otherwise throw a descriptive error.\n */\nexport function schemaToJsonSchema(\n schema: StandardSchemaV1,\n options?: SchemaToJsonSchemaOptions,\n): Record<string, unknown> {\n // 1. Standard JSON Schema V1\n if (hasStandardJsonSchema(schema)) {\n return schema[\"~standard\"].jsonSchema.input({ target: \"draft-07\" });\n }\n\n // 2. Zod v3 fallback\n const vendor = schema[\"~standard\"].vendor;\n if (vendor === \"zod\" && options?.zodToJsonSchema) {\n return options.zodToJsonSchema(schema, { $refStrategy: \"none\" });\n }\n\n throw new Error(\n `Cannot convert schema to JSON Schema. The schema (vendor: \"${vendor}\") does not implement Standard JSON Schema V1 ` +\n `and no zodToJsonSchema fallback is available. ` +\n `Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) ` +\n `or pass a zodToJsonSchema function in options.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBA,MAAa,mBAAmB;CAChC,MAAa,4BAA4B;;;;CCrBzC,SAAgB,aAAa;AAC3B,uBAAe;;CAGjB,SAAgB,iBAAiB,MAAuB;AACtD,MAAI;GACF,MAAM,SAASA,aAAY,MAAM,KAAK;AACtC,OACE,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,MAAM,QAAQ,OAAO,CAEtB,QAAO;AAET,WAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,UAAO,EAAE;WACF,OAAO;AACd,UAAO,EAAE;;;;;;;;;;CAWb,SAAgB,kBAAkB,KAAsC;AACtE,MAAI;GACF,MAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,OACE,OAAO,WAAW,YAClB,WAAW,QACX,CAAC,MAAM,QAAQ,OAAO,CAEtB,QAAO;AAET,WAAQ,KACN,qDAAqD,OAAO,OAAO,iCACpE;AACD,UAAO,EAAE;oBACH;AACN,WAAQ,KACN,4EACD;AACD,UAAO,EAAE;;;;;;;;;;;;;CAcb,SAAgB,0BACd,QACA,OAC2B;AAC3B,UAAQ,UAAkB,KAAK,IAAI,SAAS,MAAM,QAAQ,IAAI,MAAM;;;;;CCrEtE,MAAa,SAAS;;;;CCAtB,MAAa,mBAAmB;;CAGhC,MAAa,sBAAsB;;;;CCKnC,MAAM,qBAAqB;CAC3B,MAAM,0BAA0B;CAEhC,SAAgB,kBACd,QACA,UAA8B,EAAE,EACnB;EACb,MAAM,EAAE,gBAAgB,OAAO,wBAAwB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9B;GACA,WAAW;GACZ;EAED,eACE,UAAkB,0CACc;GAChC,OAAO,uBAAuB;GAC9B;GACA,WAAW;GACZ;EAED,qBAAiD;GAC/C,OAAO,uBAAuB;GAC9B,SAAS;GACT,WAAW;GACZ;EAED,sBAAkD;GAChD,OAAO,uBAAuB;GAC9B,SAAS;GACT,WAAW;GACZ;EACF;;;;;;;CCrED,SAAS,sBACP,QACmD;EACnD,MAAM,QAAQ,OAAO;AACrB,SACE,SAAS,QACT,OAAO,UAAU,YACjB,gBAAgB,SAChB,MAAM,cAAc,QACpB,OAAO,MAAM,eAAe,YAC5B,WAAW,MAAM,cACjB,OAAO,MAAM,WAAW,UAAU;;;;;;;;;;;;CActC,SAAgB,mBACd,QACA,SACyB;AAEzB,MAAI,sBAAsB,OAAO,CAC/B,QAAO,OAAO,aAAa,WAAW,MAAM,EAAE,QAAQ,YAAY,CAAC;EAIrE,MAAM,SAAS,OAAO,aAAa;AACnC,MAAI,WAAW,4DAAS,QAAS,iBAC/B,QAAO,QAAQ,gBAAgB,QAAQ,EAAE,cAAc,QAAQ,CAAC;AAGlE,QAAM,IAAI,MACR,8DAA8D,OAAO,yOAItE"}
package/dist/types.cjs ADDED
@@ -0,0 +1,9 @@
1
+
2
+ //#region src/types.ts
3
+ const RUNTIME_MODE_SSE = "sse";
4
+ const RUNTIME_MODE_INTELLIGENCE = "intelligence";
5
+
6
+ //#endregion
7
+ exports.RUNTIME_MODE_INTELLIGENCE = RUNTIME_MODE_INTELLIGENCE;
8
+ exports.RUNTIME_MODE_SSE = RUNTIME_MODE_SSE;
9
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type MaybePromise<T> = T | PromiseLike<T>;\n\n/**\n * More specific utility for records with at least one key\n */\nexport type NonEmptyRecord<T> =\n T extends Record<string, unknown>\n ? keyof T extends never\n ? never\n : T\n : never;\n\n/**\n * Type representing an agent's basic information\n */\nexport interface AgentDescription {\n name: string;\n className: string;\n description: string;\n}\n\nexport type RuntimeMode = \"sse\" | \"intelligence\";\n\nexport const RUNTIME_MODE_SSE = \"sse\" as const;\nexport const RUNTIME_MODE_INTELLIGENCE = \"intelligence\" as const;\n\nexport interface IntelligenceRuntimeInfo {\n wsUrl: string;\n}\n\nexport interface RuntimeInfo {\n version: string;\n agents: Record<string, AgentDescription>;\n audioFileTranscriptionEnabled: boolean;\n mode: RuntimeMode;\n intelligence?: IntelligenceRuntimeInfo;\n a2uiEnabled?: boolean;\n}\n"],"mappings":";;AAuBA,MAAa,mBAAmB;AAChC,MAAa,4BAA4B"}
package/dist/types.d.cts CHANGED
@@ -12,12 +12,20 @@ interface AgentDescription {
12
12
  className: string;
13
13
  description: string;
14
14
  }
15
+ type RuntimeMode = "sse" | "intelligence";
16
+ declare const RUNTIME_MODE_SSE: "sse";
17
+ declare const RUNTIME_MODE_INTELLIGENCE: "intelligence";
18
+ interface IntelligenceRuntimeInfo {
19
+ wsUrl: string;
20
+ }
15
21
  interface RuntimeInfo {
16
22
  version: string;
17
23
  agents: Record<string, AgentDescription>;
18
24
  audioFileTranscriptionEnabled: boolean;
25
+ mode: RuntimeMode;
26
+ intelligence?: IntelligenceRuntimeInfo;
19
27
  a2uiEnabled?: boolean;
20
28
  }
21
29
  //#endregion
22
- export { AgentDescription, MaybePromise, NonEmptyRecord, RuntimeInfo };
30
+ export { AgentDescription, IntelligenceRuntimeInfo, MaybePromise, NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, RuntimeInfo, RuntimeMode };
23
31
  //# sourceMappingURL=types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;AAA9C;;;AAAA,KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;AAAA;AAAA,UAGe,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,WAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;AAA9C;;;AAAA,KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;AAAA;AAAA,KAGU,WAAA;AAAA,cAEC,gBAAA;AAAA,cACA,yBAAA;AAAA,UAEI,uBAAA;EACf,KAAA;AAAA;AAAA,UAGe,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,IAAA,EAAM,WAAA;EACN,YAAA,GAAe,uBAAA;EACf,WAAA;AAAA"}
package/dist/types.d.mts CHANGED
@@ -12,12 +12,20 @@ interface AgentDescription {
12
12
  className: string;
13
13
  description: string;
14
14
  }
15
+ type RuntimeMode = "sse" | "intelligence";
16
+ declare const RUNTIME_MODE_SSE: "sse";
17
+ declare const RUNTIME_MODE_INTELLIGENCE: "intelligence";
18
+ interface IntelligenceRuntimeInfo {
19
+ wsUrl: string;
20
+ }
15
21
  interface RuntimeInfo {
16
22
  version: string;
17
23
  agents: Record<string, AgentDescription>;
18
24
  audioFileTranscriptionEnabled: boolean;
25
+ mode: RuntimeMode;
26
+ intelligence?: IntelligenceRuntimeInfo;
19
27
  a2uiEnabled?: boolean;
20
28
  }
21
29
  //#endregion
22
- export { AgentDescription, MaybePromise, NonEmptyRecord, RuntimeInfo };
30
+ export { AgentDescription, IntelligenceRuntimeInfo, MaybePromise, NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, RuntimeInfo, RuntimeMode };
23
31
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;AAA9C;;;AAAA,KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;AAAA;AAAA,UAGe,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,WAAA;AAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,YAAA,MAAkB,CAAA,GAAI,WAAA,CAAY,CAAA;AAA9C;;;AAAA,KAKY,cAAA,MACV,CAAA,SAAU,MAAA,0BACA,CAAA,yBAEJ,CAAA;;;;UAMS,gBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;AAAA;AAAA,KAGU,WAAA;AAAA,cAEC,gBAAA;AAAA,cACA,yBAAA;AAAA,UAEI,uBAAA;EACf,KAAA;AAAA;AAAA,UAGe,WAAA;EACf,OAAA;EACA,MAAA,EAAQ,MAAA,SAAe,gBAAA;EACvB,6BAAA;EACA,IAAA,EAAM,WAAA;EACN,YAAA,GAAe,uBAAA;EACf,WAAA;AAAA"}
package/dist/types.mjs ADDED
@@ -0,0 +1,7 @@
1
+ //#region src/types.ts
2
+ const RUNTIME_MODE_SSE = "sse";
3
+ const RUNTIME_MODE_INTELLIGENCE = "intelligence";
4
+
5
+ //#endregion
6
+ export { RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE };
7
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type MaybePromise<T> = T | PromiseLike<T>;\n\n/**\n * More specific utility for records with at least one key\n */\nexport type NonEmptyRecord<T> =\n T extends Record<string, unknown>\n ? keyof T extends never\n ? never\n : T\n : never;\n\n/**\n * Type representing an agent's basic information\n */\nexport interface AgentDescription {\n name: string;\n className: string;\n description: string;\n}\n\nexport type RuntimeMode = \"sse\" | \"intelligence\";\n\nexport const RUNTIME_MODE_SSE = \"sse\" as const;\nexport const RUNTIME_MODE_INTELLIGENCE = \"intelligence\" as const;\n\nexport interface IntelligenceRuntimeInfo {\n wsUrl: string;\n}\n\nexport interface RuntimeInfo {\n version: string;\n agents: Record<string, AgentDescription>;\n audioFileTranscriptionEnabled: boolean;\n mode: RuntimeMode;\n intelligence?: IntelligenceRuntimeInfo;\n a2uiEnabled?: boolean;\n}\n"],"mappings":";AAuBA,MAAa,mBAAmB;AAChC,MAAa,4BAA4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkitnext/shared",
3
- "version": "1.54.0",
3
+ "version": "1.54.1-next.1",
4
4
  "deprecated": "This package is deprecated. Use @copilotkit/shared instead. V2 features are being integrated into the main @copilotkit exports and will be available under the /v2 subpath.",
5
5
  "description": "Shared utilities and types for CopilotKit2",
6
6
  "main": "./dist/index.cjs",
@@ -29,8 +29,8 @@
29
29
  "vitest": "^4.0.18",
30
30
  "zod": "^3.25.75",
31
31
  "zod-to-json-schema": "^3.24.6",
32
- "@copilotkitnext/eslint-config": "1.54.0",
33
- "@copilotkitnext/typescript-config": "1.54.0"
32
+ "@copilotkitnext/eslint-config": "1.54.1-next.1",
33
+ "@copilotkitnext/typescript-config": "1.54.1-next.1"
34
34
  },
35
35
  "dependencies": {
36
36
  "@ag-ui/client": "0.0.47",