@copilotkit/shared 1.55.3 → 1.56.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.
Files changed (79) hide show
  1. package/dist/a2ui-prompts.cjs +31 -22
  2. package/dist/a2ui-prompts.cjs.map +1 -1
  3. package/dist/a2ui-prompts.d.cts +2 -2
  4. package/dist/a2ui-prompts.d.cts.map +1 -1
  5. package/dist/a2ui-prompts.d.mts +2 -2
  6. package/dist/a2ui-prompts.d.mts.map +1 -1
  7. package/dist/a2ui-prompts.mjs +31 -22
  8. package/dist/a2ui-prompts.mjs.map +1 -1
  9. package/dist/debug.cjs +38 -0
  10. package/dist/debug.cjs.map +1 -0
  11. package/dist/debug.d.cts +29 -0
  12. package/dist/debug.d.cts.map +1 -0
  13. package/dist/debug.d.mts +29 -0
  14. package/dist/debug.d.mts.map +1 -0
  15. package/dist/debug.mjs +37 -0
  16. package/dist/debug.mjs.map +1 -0
  17. package/dist/index.cjs +4 -0
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +3 -1
  20. package/dist/index.d.cts.map +1 -1
  21. package/dist/index.d.mts +3 -1
  22. package/dist/index.d.mts.map +1 -1
  23. package/dist/index.mjs +3 -1
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/index.umd.js +137 -30
  26. package/dist/index.umd.js.map +1 -1
  27. package/dist/package.cjs +1 -1
  28. package/dist/package.mjs +1 -1
  29. package/dist/standard-schema.cjs +4 -2
  30. package/dist/standard-schema.cjs.map +1 -1
  31. package/dist/standard-schema.d.cts +3 -2
  32. package/dist/standard-schema.d.cts.map +1 -1
  33. package/dist/standard-schema.d.mts +3 -2
  34. package/dist/standard-schema.d.mts.map +1 -1
  35. package/dist/standard-schema.mjs +4 -2
  36. package/dist/standard-schema.mjs.map +1 -1
  37. package/dist/utils/clipboard.cjs +28 -0
  38. package/dist/utils/clipboard.cjs.map +1 -0
  39. package/dist/utils/clipboard.d.cts +14 -0
  40. package/dist/utils/clipboard.d.cts.map +1 -0
  41. package/dist/utils/clipboard.d.mts +14 -0
  42. package/dist/utils/clipboard.d.mts.map +1 -0
  43. package/dist/utils/clipboard.mjs +27 -0
  44. package/dist/utils/clipboard.mjs.map +1 -0
  45. package/dist/utils/index.cjs +1 -0
  46. package/dist/utils/index.cjs.map +1 -1
  47. package/dist/utils/index.d.cts +1 -0
  48. package/dist/utils/index.d.cts.map +1 -1
  49. package/dist/utils/index.d.mts +1 -0
  50. package/dist/utils/index.d.mts.map +1 -1
  51. package/dist/utils/index.mjs +1 -0
  52. package/dist/utils/index.mjs.map +1 -1
  53. package/dist/utils/json-schema.cjs +36 -5
  54. package/dist/utils/json-schema.cjs.map +1 -1
  55. package/dist/utils/json-schema.d.cts +1 -1
  56. package/dist/utils/json-schema.d.cts.map +1 -1
  57. package/dist/utils/json-schema.d.mts +1 -1
  58. package/dist/utils/json-schema.d.mts.map +1 -1
  59. package/dist/utils/json-schema.mjs +36 -5
  60. package/dist/utils/json-schema.mjs.map +1 -1
  61. package/dist/utils/types.cjs.map +1 -1
  62. package/dist/utils/types.d.cts +3 -0
  63. package/dist/utils/types.d.cts.map +1 -1
  64. package/dist/utils/types.d.mts +3 -0
  65. package/dist/utils/types.d.mts.map +1 -1
  66. package/dist/utils/types.mjs.map +1 -1
  67. package/package.json +1 -1
  68. package/src/__tests__/debug.test.ts +116 -0
  69. package/src/__tests__/standard-schema.test.ts +92 -0
  70. package/src/a2ui-prompts.ts +31 -22
  71. package/src/debug.ts +55 -0
  72. package/src/index.ts +1 -0
  73. package/src/standard-schema.ts +9 -3
  74. package/src/utils/__tests__/clipboard.test.ts +87 -0
  75. package/src/utils/__tests__/json-schema.test.ts +250 -1
  76. package/src/utils/clipboard.ts +23 -0
  77. package/src/utils/index.ts +1 -0
  78. package/src/utils/json-schema.ts +84 -3
  79. package/src/utils/types.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;cAiBa,kBAAA;;;;;;;;;iBA0BG,yBAAA,CAA0B,MAAA;EACxC,MAAA;EACA,OAAA;EACA,YAAA,GAAe,OAAA;EACf,QAAA,GAAW,OAAA;AAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBa,kBAAA;;;;;;;;;iBA0BG,yBAAA,CAA0B,MAAA;EACxC,MAAA;EACA,OAAA;EACA,YAAA,GAAe,OAAA;EACf,QAAA,GAAW,OAAA;AAAA"}
package/dist/index.d.mts CHANGED
@@ -4,6 +4,7 @@ import { CopilotCloudConfig } from "./types/copilot-cloud-config.mjs";
4
4
  import { PartialBy, RequiredBy } from "./types/utility.mjs";
5
5
  import { CopilotErrorEvent, CopilotErrorHandler, CopilotRequestContext } from "./types/error.mjs";
6
6
  import { AIMessage, ActivityMessage, AudioInputPart, DeveloperMessage, DocumentInputPart, ImageData, ImageInputPart, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, Message, ReasoningMessage, Role, SystemMessage, TextInputPart, ToolCall, ToolResult, UserMessage, VideoInputPart } from "./types/message.mjs";
7
+ import { copyToClipboard } from "./utils/clipboard.mjs";
7
8
  import { BaseCondition, ComparisonCondition, ComparisonRule, Condition, ExistenceCondition, ExistenceRule, LogicalCondition, LogicalRule, Rule, executeConditions } from "./utils/conditions.mjs";
8
9
  import { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole } from "./utils/console-styling.mjs";
9
10
  import { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError } from "./utils/errors.mjs";
@@ -15,6 +16,7 @@ import { isMacOS, parseJson, partialJSONParse, phoenixExponentialBackoff, safePa
15
16
  import { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID } from "./constants/index.mjs";
16
17
  import { TelemetryClient, isTelemetryDisabled } from "./telemetry/telemetry-client.mjs";
17
18
  import "./telemetry/index.mjs";
19
+ import { DebugConfig, ResolvedDebugConfig, resolveDebugConfig } from "./debug.mjs";
18
20
  import { InferSchemaOutput, SchemaToJsonSchemaOptions, StandardJSONSchemaV1, StandardSchemaV1, schemaToJsonSchema } from "./standard-schema.mjs";
19
21
  import { Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig } from "./attachments/types.mjs";
20
22
  import { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 } from "./attachments/utils.mjs";
@@ -41,5 +43,5 @@ declare function createLicenseContextValue(status: null): {
41
43
  getLimit: (feature: string) => number | null;
42
44
  };
43
45
  //#endregion
44
- export { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LicenseChecker, type LicenseContextValue, type LicenseFeatures, type LicenseMode, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, Role, Rule, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SchemaToJsonSchemaOptions, Severity, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TelemetryClient, TextInputPart, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseJson, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, safeParseToolArgs, schemaToJsonSchema, styledConsole, tryMap };
46
+ export { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, AIMessage, Action, ActivityMessage, AgentDescription, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, BaseCondition, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ComparisonCondition, ComparisonRule, Condition, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExistenceCondition, ExistenceRule, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, ImageData, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LicenseChecker, type LicenseContextValue, type LicenseFeatures, type LicenseMode, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, LogicalCondition, LogicalRule, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, NonEmptyRecord, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, Rule, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SchemaToJsonSchemaOptions, Severity, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TelemetryClient, TextInputPart, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UpgradeRequiredError, UserMessage, VideoInputPart, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseJson, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, styledConsole, tryMap };
45
47
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;cAiBa,kBAAA;;;;;;;;;iBA0BG,yBAAA,CAA0B,MAAA;EACxC,MAAA;EACA,OAAA;EACA,YAAA,GAAe,OAAA;EACf,QAAA,GAAW,OAAA;AAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBa,kBAAA;;;;;;;;;iBA0BG,yBAAA,CAA0B,MAAA;EACxC,MAAA;EACA,OAAA;EACA,YAAA,GAAe,OAAA;EACf,QAAA,GAAW,OAAA;AAAA"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { copyToClipboard } from "./utils/clipboard.mjs";
1
2
  import { executeConditions } from "./utils/conditions.mjs";
2
3
  import { ConsoleColors, ConsoleStyles, logCopilotKitPlatformMessage, logStyled, publicApiKeyRequired, styledConsole } from "./utils/console-styling.mjs";
3
4
  import { BANNER_ERROR_NAMES, COPILOT_CLOUD_ERROR_NAMES, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, ResolvedCopilotKitError, Severity, UpgradeRequiredError, ensureStructuredError, getPossibleVersionMismatch, isStructuredCopilotKitError } from "./utils/errors.mjs";
@@ -9,6 +10,7 @@ import { isMacOS, parseJson, partialJSONParse, phoenixExponentialBackoff, safePa
9
10
  import { AG_UI_CHANNEL_EVENT, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, DEFAULT_AGENT_ID } from "./constants/index.mjs";
10
11
  import { version } from "./package.mjs";
11
12
  import { TelemetryClient, isTelemetryDisabled } from "./telemetry/telemetry-client.mjs";
13
+ import { resolveDebugConfig } from "./debug.mjs";
12
14
  import { schemaToJsonSchema } from "./standard-schema.mjs";
13
15
  import { exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, readFileAsBase64 } from "./attachments/utils.mjs";
14
16
  import { logger } from "./logger.mjs";
@@ -36,5 +38,5 @@ function createLicenseContextValue(status) {
36
38
  }
37
39
 
38
40
  //#endregion
39
- export { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, BANNER_ERROR_NAMES, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, DEFAULT_AGENT_ID, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ResolvedCopilotKitError, Severity, TelemetryClient, TranscriptionErrorCode, TranscriptionErrors, UpgradeRequiredError, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseJson, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, safeParseToolArgs, schemaToJsonSchema, styledConsole, tryMap };
41
+ export { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, AG_UI_CHANNEL_EVENT, BANNER_ERROR_NAMES, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, ConfigurationError, ConsoleColors, ConsoleStyles, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, CopilotKitVersionMismatchError, DEFAULT_AGENT_ID, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, MissingPublicApiKeyError, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ResolvedCopilotKitError, Severity, TelemetryClient, TranscriptionErrorCode, TranscriptionErrors, UpgradeRequiredError, actionParametersToJsonSchema, convertJsonSchemaToZodSchema, copyToClipboard, createLicenseContextValue, dataToUUID, ensureStructuredError, exceedsMaxSize, executeConditions, finalizeRunEvents, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getPossibleVersionMismatch, getSourceUrl, getZodParameters, isMacOS, isStructuredCopilotKitError, isTelemetryDisabled, isValidUUID, jsonSchemaToActionParameters, logCopilotKitPlatformMessage, logStyled, logger, matchesAcceptFilter, parseJson, partialJSONParse, phoenixExponentialBackoff, publicApiKeyRequired, randomId, randomUUID, readBody, readFileAsBase64, resolveDebugConfig, safeParseToolArgs, schemaToJsonSchema, styledConsole, tryMap };
40
42
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["packageJson.version"],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport { finalizeRunEvents } from \"./finalize-events\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseContextValue,\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n LicenseMode,\n} from \"@copilotkit/license-verifier\";\n\n/**\n * Client-safe license context factory.\n *\n * When status is null (no token provided), all features return true\n * (unlicensed = unrestricted, with branding). This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on\n * Node's `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(status: null): {\n status: null;\n license: null;\n checkFeature: (feature: string) => boolean;\n getLimit: (feature: string) => number | null;\n} {\n return {\n status: null,\n license: null,\n checkFeature: () => true,\n getLimit: () => null,\n };\n}\n\nexport {\n A2UI_DEFAULT_GENERATION_GUIDELINES,\n A2UI_DEFAULT_DESIGN_GUIDELINES,\n} from \"./a2ui-prompts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,MAAa,qBAAqBA;;;;;;;;;AA0BlC,SAAgB,0BAA0B,QAKxC;AACA,QAAO;EACL,QAAQ;EACR,SAAS;EACT,oBAAoB;EACpB,gBAAgB;EACjB"}
1
+ {"version":3,"file":"index.mjs","names":["packageJson.version"],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./telemetry\";\nexport * from \"./debug\";\nexport * from \"./standard-schema\";\nexport * from \"./attachments\";\n\nexport { logger } from \"./logger\";\nexport { finalizeRunEvents } from \"./finalize-events\";\n\nexport {\n TranscriptionErrorCode,\n TranscriptionErrors,\n type TranscriptionErrorResponse,\n} from \"./transcription-errors\";\n\nimport * as packageJson from \"../package.json\";\nexport const COPILOTKIT_VERSION = packageJson.version;\n\n// Re-export only types from license-verifier (types are erased at compile time,\n// so they don't pull in the Node-only `crypto` dependency into client bundles).\n// Server-side packages (e.g. @copilotkit/runtime) should import runtime functions\n// like createLicenseChecker and getLicenseWarningHeader directly from\n// @copilotkit/license-verifier.\nexport type {\n LicenseContextValue,\n LicenseChecker,\n LicenseStatus,\n LicensePayload,\n LicenseFeatures,\n LicenseTier,\n LicenseOwner,\n LicenseMode,\n} from \"@copilotkit/license-verifier\";\n\n/**\n * Client-safe license context factory.\n *\n * When status is null (no token provided), all features return true\n * (unlicensed = unrestricted, with branding). This is inlined here to\n * avoid importing the full license-verifier bundle (which depends on\n * Node's `crypto`) into browser bundles.\n */\nexport function createLicenseContextValue(status: null): {\n status: null;\n license: null;\n checkFeature: (feature: string) => boolean;\n getLimit: (feature: string) => number | null;\n} {\n return {\n status: null,\n license: null,\n checkFeature: () => true,\n getLimit: () => null,\n };\n}\n\nexport {\n A2UI_DEFAULT_GENERATION_GUIDELINES,\n A2UI_DEFAULT_DESIGN_GUIDELINES,\n} from \"./a2ui-prompts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,qBAAqBA;;;;;;;;;AA0BlC,SAAgB,0BAA0B,QAKxC;AACA,QAAO;EACL,QAAQ;EACR,SAAS;EACT,oBAAoB;EACpB,gBAAgB;EACjB"}
package/dist/index.umd.js CHANGED
@@ -33,6 +33,32 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33
33
  //#endregion
34
34
  partial_json = __toESM(partial_json);
35
35
 
36
+ //#region src/utils/clipboard.ts
37
+ /**
38
+ * Safely copies text to the clipboard.
39
+ *
40
+ * Checks that the Clipboard API is available before attempting the write,
41
+ * and catches any errors (e.g. permission denied, insecure context).
42
+ *
43
+ * @param text - The text to copy to the clipboard.
44
+ * @returns `true` if the text was successfully copied, `false` otherwise.
45
+ */
46
+ async function copyToClipboard(text) {
47
+ var _navigator$clipboard;
48
+ if (!((_navigator$clipboard = navigator.clipboard) === null || _navigator$clipboard === void 0 ? void 0 : _navigator$clipboard.writeText)) {
49
+ console.error("Clipboard API is not available");
50
+ return false;
51
+ }
52
+ try {
53
+ await navigator.clipboard.writeText(text);
54
+ return true;
55
+ } catch (err) {
56
+ console.error("Failed to copy to clipboard:", err);
57
+ return false;
58
+ }
59
+ }
60
+
61
+ //#endregion
36
62
  //#region src/utils/conditions.ts
37
63
  function executeConditions({ conditions, value }) {
38
64
  if (!(conditions === null || conditions === void 0 ? void 0 : conditions.length)) return true;
@@ -684,11 +710,37 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
684
710
  };
685
711
  }
686
712
  }
687
- function convertJsonSchemaToZodSchema(jsonSchema, required) {
713
+ function convertJsonSchemaToZodSchema(jsonSchema, required, definitions, visitedRefs) {
714
+ var _ref, _jsonSchema$anyOf, _jsonSchema$type;
715
+ if (jsonSchema.$ref && definitions) {
716
+ const refPath = jsonSchema.$ref.replace(/^#\/\$defs\/|^#\/definitions\//, "");
717
+ const refs = visitedRefs !== null && visitedRefs !== void 0 ? visitedRefs : /* @__PURE__ */ new Set();
718
+ if (refs.has(refPath)) {
719
+ console.warn(`[CopilotKit] Circular $ref detected for "${refPath}" — falling back to z.any()`);
720
+ let schema = zod.z.any();
721
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
722
+ return required ? schema : schema.optional();
723
+ }
724
+ const resolved = definitions[refPath];
725
+ if (resolved) {
726
+ const nextRefs = new Set(refs);
727
+ nextRefs.add(refPath);
728
+ return convertJsonSchemaToZodSchema(resolved, required, definitions, nextRefs);
729
+ }
730
+ }
731
+ const defs = (_ref = definitions !== null && definitions !== void 0 ? definitions : jsonSchema.$defs) !== null && _ref !== void 0 ? _ref : jsonSchema.definitions;
732
+ const unionVariants = (_jsonSchema$anyOf = jsonSchema.anyOf) !== null && _jsonSchema$anyOf !== void 0 ? _jsonSchema$anyOf : jsonSchema.oneOf;
733
+ if (Array.isArray(unionVariants) && unionVariants.length > 0) {
734
+ if (unionVariants.length === 1) return convertJsonSchemaToZodSchema(unionVariants[0], required, defs, visitedRefs);
735
+ const schemas = unionVariants.map((v) => convertJsonSchemaToZodSchema(v, true, defs, visitedRefs));
736
+ let schema = zod.z.union(schemas);
737
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
738
+ return required ? schema : schema.optional();
739
+ }
688
740
  if (jsonSchema.type === "object") {
689
741
  const spec = {};
690
742
  if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) return !required ? zod.z.object(spec).optional() : zod.z.object(spec);
691
- for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
743
+ for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false, defs, visitedRefs);
692
744
  let schema = zod.z.object(spec).describe(jsonSchema.description);
693
745
  return required ? schema : schema.optional();
694
746
  } else if (jsonSchema.type === "string") {
@@ -698,18 +750,24 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
698
750
  }
699
751
  let schema = zod.z.string().describe(jsonSchema.description);
700
752
  return required ? schema : schema.optional();
701
- } else if (jsonSchema.type === "number") {
753
+ } else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
702
754
  let schema = zod.z.number().describe(jsonSchema.description);
703
755
  return required ? schema : schema.optional();
704
756
  } else if (jsonSchema.type === "boolean") {
705
757
  let schema = zod.z.boolean().describe(jsonSchema.description);
706
758
  return required ? schema : schema.optional();
707
759
  } else if (jsonSchema.type === "array") {
708
- let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
760
+ let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true, defs, visitedRefs);
709
761
  let schema = zod.z.array(itemSchema).describe(jsonSchema.description);
710
762
  return required ? schema : schema.optional();
763
+ } else if (jsonSchema.type === "null") {
764
+ let schema = zod.z.null().describe(jsonSchema.description);
765
+ return required ? schema : schema.optional();
711
766
  }
712
- throw new Error("Invalid JSON schema");
767
+ console.warn(`[CopilotKit] Unsupported JSON schema type "${(_jsonSchema$type = jsonSchema.type) !== null && _jsonSchema$type !== void 0 ? _jsonSchema$type : "unknown"}" — falling back to z.any()`);
768
+ let schema = zod.z.any();
769
+ if (jsonSchema.description) schema = schema.describe(jsonSchema.description);
770
+ return required ? schema : schema.optional();
713
771
  }
714
772
  function getZodParameters(parameters) {
715
773
  if (!parameters) return zod.z.object({});
@@ -911,7 +969,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
911
969
 
912
970
  //#endregion
913
971
  //#region package.json
914
- var version = "1.55.3";
972
+ var version = "1.56.1";
915
973
 
916
974
  //#endregion
917
975
  //#region src/telemetry/scarf-client.ts
@@ -1016,6 +1074,42 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1016
1074
  }
1017
1075
  };
1018
1076
 
1077
+ //#endregion
1078
+ //#region src/debug.ts
1079
+ /** The all-off config used when debug is falsy. */
1080
+ const DEBUG_OFF = {
1081
+ enabled: false,
1082
+ events: false,
1083
+ lifecycle: false,
1084
+ verbose: false
1085
+ };
1086
+ /**
1087
+ * Normalizes a DebugConfig value into a ResolvedDebugConfig.
1088
+ *
1089
+ * - `false` / `undefined` → all off
1090
+ * - `true` → events + lifecycle on, verbose off (no PII in logs)
1091
+ * - object → merges with defaults (events: true, lifecycle: true, verbose: false)
1092
+ */
1093
+ function resolveDebugConfig(debug) {
1094
+ var _debug$events, _debug$lifecycle, _debug$verbose;
1095
+ if (!debug) return DEBUG_OFF;
1096
+ if (debug === true) return {
1097
+ enabled: true,
1098
+ events: true,
1099
+ lifecycle: true,
1100
+ verbose: false
1101
+ };
1102
+ const events = (_debug$events = debug.events) !== null && _debug$events !== void 0 ? _debug$events : true;
1103
+ const lifecycle = (_debug$lifecycle = debug.lifecycle) !== null && _debug$lifecycle !== void 0 ? _debug$lifecycle : true;
1104
+ const enabled = events || lifecycle;
1105
+ return {
1106
+ enabled,
1107
+ events,
1108
+ lifecycle,
1109
+ verbose: enabled && ((_debug$verbose = debug.verbose) !== null && _debug$verbose !== void 0 ? _debug$verbose : false)
1110
+ };
1111
+ }
1112
+
1019
1113
  //#endregion
1020
1114
  //#region src/standard-schema.ts
1021
1115
  /**
@@ -1031,12 +1125,14 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
1031
1125
  * Strategy:
1032
1126
  * 1. If the schema implements Standard JSON Schema V1 (`~standard.jsonSchema`),
1033
1127
  * call `schema['~standard'].jsonSchema.input({ target: 'draft-07' })`.
1034
- * 2. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the
1128
+ * 2. If the schema exposes a `toJSONSchema()` method (Zod v4), call it directly.
1129
+ * 3. If the schema is a Zod v3 schema (`~standard.vendor === 'zod'`), use the
1035
1130
  * injected `zodToJsonSchema()` function.
1036
- * 3. Otherwise throw a descriptive error.
1131
+ * 4. Otherwise throw a descriptive error.
1037
1132
  */
1038
1133
  function schemaToJsonSchema(schema, options) {
1039
1134
  if (hasStandardJsonSchema(schema)) return schema["~standard"].jsonSchema.input({ target: "draft-07" });
1135
+ if (typeof schema.toJSONSchema === "function") return schema.toJSONSchema();
1040
1136
  const vendor = schema["~standard"].vendor;
1041
1137
  if (vendor === "zod" && (options === null || options === void 0 ? void 0 : options.zodToJsonSchema)) return options.zodToJsonSchema(schema, { $refStrategy: "none" });
1042
1138
  throw new Error(`Cannot convert schema to JSON Schema. The schema (vendor: "${vendor}") does not implement Standard JSON Schema V1 and no zodToJsonSchema fallback is available. Use a library that supports Standard JSON Schema (e.g., Zod 3.24+, Valibot v1+, ArkType v2+) or pass a zodToJsonSchema function in options.`);
@@ -1405,29 +1501,38 @@ CRITICAL: Do NOT use "/name" (absolute) inside templates — use "name" (relativ
1405
1501
  The container's path ("/items") uses a leading slash (absolute), but all
1406
1502
  components INSIDE the template use paths WITHOUT leading slash.
1407
1503
 
1408
- DATA MODEL:
1409
- The "data" key in the tool args is a plain JSON object that initializes the surface
1410
- data model. Components bound to paths (e.g. "value": { "path": "/form/name" })
1411
- read from and write to this data model. Examples:
1412
- For forms: "data": { "form": { "name": "Alice", "email": "" } }
1413
- For lists: "data": { "items": [{"name": "Product A"}, {"name": "Product B"}] }
1414
- For mixed: "data": { "form": { "query": "" }, "results": [...] }
1504
+ COMPONENT VALUES — DEFAULT RULE:
1505
+ Use inline literal values for ALL component properties. Pass strings, numbers,
1506
+ arrays, and objects directly on the component. Do NOT use { "path": "..." }
1507
+ objects unless the property's schema explicitly allows it (see exception below).
1508
+ CRITICAL: USING { "path": "..." } ON A PROPERTY THAT DOES NOT DECLARE PATH
1509
+ SUPPORT IN ITS SCHEMA WILL CAUSE A RUNTIME CRASH AND BREAK THE ENTIRE UI.
1510
+ ALWAYS CHECK THE COMPONENT SCHEMA FIRST IF THE PROPERTY ONLY ACCEPTS A
1511
+ PLAIN TYPE, YOU MUST USE A LITERAL VALUE.
1512
+ VERY IMPORTANT: THE APPLICATION WILL BREAK IF YOU DO NOT FOLLOW THIS RULE!
1415
1513
 
1416
- FORMS AND TWO-WAY DATA BINDING:
1417
- To create editable forms, bind input components to data model paths using { "path": "..." }.
1418
- The client automatically writes user input back to the data model at the bound path.
1419
- CRITICAL: Using a literal value (e.g. "value": "") makes the field READ-ONLY.
1420
- You MUST use { "path": "..." } to make inputs editable.
1514
+ For example, a chart's "data" must always be an inline array:
1515
+ "data": [{"label": "Jan", "value": 100}, {"label": "Feb", "value": 200}]
1516
+ A metric's "value" must always be an inline string:
1517
+ "value": "$1,200"
1421
1518
 
1422
- Input components use "value" as the binding property:
1423
- "value": { "path": "/form/fieldName" }
1519
+ PATH BINDING EXCEPTION SCHEMA-DRIVEN:
1520
+ A few properties accept { "path": "/some/path" } as an alternative to a literal
1521
+ value. You can identify these in the Available Components schema: the property
1522
+ will list BOTH a literal type AND an object-with-path option. If a property only
1523
+ shows a single type (string, number, array, etc.), it does NOT support path
1524
+ binding — use a literal value only.
1424
1525
 
1425
- To retrieve form values when a button is clicked, include "context" with path references
1426
- in the button's action. Paths are resolved to their current values at click time:
1427
- "action": { "event": { "name": "submit", "context": { "userName": { "path": "/form/name" } } } }
1526
+ Path binding is typically used for editable form inputs so the client can write
1527
+ user input back to the data model. When building forms:
1528
+ - Bind input "value" to a data model path: "value": { "path": "/form/name" }
1529
+ - Pre-fill via the "data" tool argument: "data": { "form": { "name": "Alice" } }
1530
+ - Capture values on submit via button action context:
1531
+ "action": { "event": { "name": "submit", "context": { "name": { "path": "/form/name" } } } }
1428
1532
 
1429
- To pre-fill form values, pass initial data via the "data" tool argument:
1430
- "data": { "form": { "name": "Markus" } }`;
1533
+ REPEATING CONTENT uses a structural children format (not the same as value binding):
1534
+ children: { componentId: "card-id", path: "/items" }
1535
+ Components inside templates use RELATIVE paths (no leading slash): { "path": "name" }.`;
1431
1536
  /**
1432
1537
  * Design guidelines — visual design rules, component hierarchy tips,
1433
1538
  * and action handler patterns.
@@ -1451,9 +1556,9 @@ Design principles:
1451
1556
  "action": { "event": { "name": "myAction", "context": { "key": "value" } } }
1452
1557
  The "event" key holds an OBJECT with "name" (required) and "context" (optional).
1453
1558
  Do NOT use a flat format like {"event": "name"} — "event" must be an object.
1454
- - For forms: every input MUST use path binding on the "value" property
1455
- (e.g. "value": { "path": "/form/name" }) to be editable. The submit button's
1456
- action context MUST reference the same paths to capture the user's input.
1559
+ - For forms: check the component schema if an input's "value" property
1560
+ supports path binding, use it for editable fields. The submit button's
1561
+ action context should reference the same paths to capture user input.
1457
1562
 
1458
1563
  Use the SAME surfaceId as the main surface. Match action names to button action event names.`;
1459
1564
 
@@ -1514,6 +1619,7 @@ exports.TranscriptionErrors = TranscriptionErrors;
1514
1619
  exports.UpgradeRequiredError = UpgradeRequiredError;
1515
1620
  exports.actionParametersToJsonSchema = actionParametersToJsonSchema;
1516
1621
  exports.convertJsonSchemaToZodSchema = convertJsonSchemaToZodSchema;
1622
+ exports.copyToClipboard = copyToClipboard;
1517
1623
  exports.createLicenseContextValue = createLicenseContextValue;
1518
1624
  exports.dataToUUID = dataToUUID;
1519
1625
  exports.ensureStructuredError = ensureStructuredError;
@@ -1544,6 +1650,7 @@ exports.randomId = randomId;
1544
1650
  exports.randomUUID = randomUUID;
1545
1651
  exports.readBody = readBody;
1546
1652
  exports.readFileAsBase64 = readFileAsBase64;
1653
+ exports.resolveDebugConfig = resolveDebugConfig;
1547
1654
  exports.safeParseToolArgs = safeParseToolArgs;
1548
1655
  exports.schemaToJsonSchema = schemaToJsonSchema;
1549
1656
  exports.styledConsole = styledConsole;