@copilotkit/shared 2.0.0-rc.42 → 2.0.0-rc.44
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/a2ui-envelope.cjs +1 -1
- package/dist/a2ui-envelope.cjs.map +1 -1
- package/dist/a2ui-envelope.d.cts.map +1 -1
- package/dist/a2ui-envelope.d.mts.map +1 -1
- package/dist/a2ui-envelope.mjs +1 -1
- package/dist/a2ui-envelope.mjs.map +1 -1
- package/dist/generative-ui/types.cjs.map +1 -1
- package/dist/generative-ui/types.d.cts +13 -0
- package/dist/generative-ui/types.d.cts.map +1 -1
- package/dist/generative-ui/types.d.mts +13 -0
- package/dist/generative-ui/types.d.mts.map +1 -1
- package/dist/generative-ui/types.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/types.cjs.map +1 -1
- package/dist/utils/types.d.cts +5 -12
- package/dist/utils/types.d.cts.map +1 -1
- package/dist/utils/types.d.mts +5 -12
- package/dist/utils/types.d.mts.map +1 -1
- package/dist/utils/types.mjs.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/a2ui-envelope.test.ts +20 -0
- package/src/a2ui-envelope.ts +2 -1
- package/src/generative-ui/types.ts +13 -0
- package/src/utils/types.ts +4 -11
package/dist/a2ui-envelope.cjs
CHANGED
|
@@ -65,7 +65,7 @@ function isRejectionList(value) {
|
|
|
65
65
|
return Array.isArray(value) && value.length <= require_types.GENERATIVE_UI_MAX_SUMMARY_REJECTIONS && value.every((entry) => typeof entry === "string" && entry.length <= require_types.GENERATIVE_UI_MAX_REJECTION_LENGTH);
|
|
66
66
|
}
|
|
67
67
|
function isSurfaceEntry(value) {
|
|
68
|
-
return require_is_record.isRecord(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || require_is_record.isRecord(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed");
|
|
68
|
+
return require_is_record.isRecord(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || require_is_record.isRecord(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed") && (value.a2uiSourceVersion === void 0 || value.a2uiSourceVersion === "0.9");
|
|
69
69
|
}
|
|
70
70
|
/** Checks the `copilotkit_` keys only. Other extensions can be there too. */
|
|
71
71
|
function isExtensions(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2ui-envelope.cjs","names":["isRecord","GENERATIVE_UI_MAX_TARGET_COMPONENTS","GENERATIVE_UI_MAX_SUMMARY_REJECTIONS","GENERATIVE_UI_MAX_REJECTION_LENGTH"],"sources":["../src/a2ui-envelope.ts"],"sourcesContent":["/**\n * The generative UI envelope that the client sends on every run as\n * `forwardedProps.copilotkit.ui`. It has the A2UI v1.0 renderer capabilities\n * shape, so a backend that speaks A2UI v1.0 can read the catalog as it is.\n * CopilotKit data goes in `metadata.extensions`, under `copilotkit_` keys.\n * The runtime reads it to pick the transport and to build the guide.\n */\nimport {\n GENERATIVE_UI_MAX_REJECTION_LENGTH,\n GENERATIVE_UI_MAX_SUMMARY_REJECTIONS,\n GENERATIVE_UI_MAX_TARGET_COMPONENTS,\n} from \"./generative-ui/types\";\nimport type {\n A2UIActionMessage,\n GenerativeUIComponentManifest,\n GenerativeUIFunctionManifest,\n GenerativeUIManifest,\n GenerativeUISurfaceSummary,\n GenerativeUITarget,\n} from \"./generative-ui/types\";\nimport { isRecord } from \"./generative-ui/is-record\";\n\n/** Top-level `forwardedProps` key that holds the CopilotKit run properties. */\nexport const COPILOTKIT_FORWARDED_PROPS_KEY = \"copilotkit\";\n\n/** Version of the envelope shape (not of the UI protocol that it carries). */\nexport const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;\n\n/** What the client renders and calls, and how the model must write UI. */\nexport interface CopilotKitUIEnvelope {\n /** The A2UI v1.0 renderer capabilities. */\n \"1.0\": {\n /**\n * The catalog that the client renders comes first, then the catalogs of\n * its `extends`. An operation can name any of them.\n */\n supportedCatalogIds: string[];\n inlineCatalogs?: Array<{\n catalogId: string;\n protocolVersion: \"1.0\";\n /** Not there when the client is set up with `includeCatalog: false`. */\n components?: Record<string, GenerativeUIComponentManifest>;\n /** The app functions that are mounted now. */\n functions: Record<string, GenerativeUIFunctionManifest>;\n /** The markdown guideline. Only the markdown transport sends it. */\n instructions?: string;\n }>;\n };\n metadata: {\n extensions: {\n /** Envelope shape version. */\n copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT;\n /** \"tool\": the model calls the render tool. \"markdown\": the model writes ```a2ui fences. */\n copilotkit_transport: \"tool\" | \"markdown\";\n copilotkit_targets: GenerativeUIManifest[\"targets\"];\n copilotkit_surfaces: GenerativeUIManifest[\"surfaces\"];\n /** True when the client also sent the guide as context entries on this run. */\n copilotkit_contextSent: boolean;\n /**\n * The A2UI action that started this run, when a user event did: the\n * structured form of the user message that the event added.\n */\n copilotkit_action?: A2UIActionMessage;\n };\n };\n}\n\ntype InlineCatalog = NonNullable<\n CopilotKitUIEnvelope[\"1.0\"][\"inlineCatalogs\"]\n>[number];\ntype Extensions = CopilotKitUIEnvelope[\"metadata\"][\"extensions\"];\n\nfunction isOptionalString(value: unknown) {\n return value === undefined || typeof value === \"string\";\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value !== \"\";\n}\n\nfunction isRecordOf<T>(\n value: unknown,\n isEntry: (entry: unknown) => entry is T,\n): value is Record<string, T> {\n return isRecord(value) && Object.values(value).every(isEntry);\n}\n\n/** A function, or an event of a component: a description and a parameter schema. */\nfunction isSchemaEntry(value: unknown): value is GenerativeUIFunctionManifest {\n return (\n isRecord(value) &&\n isRecord(value.parameters) &&\n isOptionalString(value.description)\n );\n}\n\nfunction isSlotKind(value: unknown): value is \"single\" | \"multiple\" {\n return value === \"single\" || value === \"multiple\";\n}\n\n/**\n * `validateOperation` reads `properties` and `required` of a props schema,\n * so those two must have the right shape when they are there.\n */\nfunction isPropsSchema(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (value.properties === undefined || isRecord(value.properties)) &&\n (value.required === undefined ||\n (Array.isArray(value.required) &&\n value.required.every((name) => typeof name === \"string\")))\n );\n}\n\nfunction isComponentManifest(\n value: unknown,\n): value is GenerativeUIComponentManifest {\n if (\n !isRecord(value) ||\n !isPropsSchema(value.props) ||\n !isOptionalString(value.description) ||\n (value.events !== undefined && !isRecordOf(value.events, isSchemaEntry)) ||\n (value.slots !== undefined && !isRecordOf(value.slots, isSlotKind))\n )\n return false;\n const order = value.parameterOrder;\n if (order === undefined) return true;\n const keys = new Set([\n ...Object.keys(value.props.properties ?? {}),\n ...Object.keys(value.slots ?? {}),\n ...Object.keys(value.events ?? {}),\n ]);\n return (\n Array.isArray(order) &&\n new Set(order).size === order.length &&\n order.every((key) => typeof key === \"string\" && keys.has(key))\n );\n}\n\nfunction isInlineCatalog(value: unknown): value is InlineCatalog {\n return (\n isRecord(value) &&\n isNonEmptyString(value.catalogId) &&\n value.protocolVersion === \"1.0\" &&\n (value.components === undefined ||\n isRecordOf(value.components, isComponentManifest)) &&\n isRecordOf(value.functions, isSchemaEntry) &&\n isOptionalString(value.instructions)\n );\n}\n\nfunction isCapabilities(value: unknown): value is CopilotKitUIEnvelope[\"1.0\"] {\n return (\n isRecord(value) &&\n Array.isArray(value.supportedCatalogIds) &&\n value.supportedCatalogIds.length > 0 &&\n value.supportedCatalogIds.every(isNonEmptyString) &&\n (value.inlineCatalogs === undefined ||\n (Array.isArray(value.inlineCatalogs) &&\n value.inlineCatalogs.every(isInlineCatalog)))\n );\n}\n\n/** A short list of component names. */\nfunction isComponentNameList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_TARGET_COMPONENTS &&\n value.every(isNonEmptyString)\n );\n}\n\nfunction isTarget(value: unknown): value is GenerativeUITarget {\n return (\n isRecord(value) &&\n isNonEmptyString(value.id) &&\n (value.kind === \"chat\" || value.kind === \"inline\") &&\n isOptionalString(value.description) &&\n (value.components === undefined || isComponentNameList(value.components))\n );\n}\n\n/** A short list of short strings. The summary limits keep the guide small. */\nfunction isRejectionList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS &&\n value.every(\n (entry) =>\n typeof entry === \"string\" &&\n entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH,\n )\n );\n}\n\nfunction isSurfaceEntry(value: unknown): value is GenerativeUISurfaceSummary {\n return (\n isRecord(value) &&\n isNonEmptyString(value.target) &&\n (value.dataModel === undefined || isRecord(value.dataModel)) &&\n (value.rejected === undefined || isRejectionList(value.rejected)) &&\n (value.status === undefined ||\n value.status === \"deleted\" ||\n value.status === \"failed\")\n );\n}\n\n/** Checks the `copilotkit_` keys only. Other extensions can be there too. */\nfunction isExtensions(value: unknown): value is Extensions {\n return (\n isRecord(value) &&\n value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT &&\n (value.copilotkit_transport === \"tool\" ||\n value.copilotkit_transport === \"markdown\") &&\n Array.isArray(value.copilotkit_targets) &&\n value.copilotkit_targets.every(isTarget) &&\n isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) &&\n typeof value.copilotkit_contextSent === \"boolean\"\n );\n}\n\nfunction isEnvelope(value: unknown): value is CopilotKitUIEnvelope {\n return (\n isRecord(value) &&\n isCapabilities(value[\"1.0\"]) &&\n isRecord(value.metadata) &&\n isExtensions(value.metadata.extensions)\n );\n}\n\n/**\n * Reads the generative UI envelope from the `forwardedProps` of a run.\n *\n * The envelope comes from the client, so it is not trusted: every field is\n * checked. Returns `undefined` when the envelope is not there, or when it is\n * malformed (for example a wrong `copilotkit_format` or\n * `copilotkit_transport`, or no catalog id).\n *\n * @param forwardedProps - The `forwardedProps` of the run input.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * if (envelope?.metadata.extensions.copilotkit_transport === \"markdown\") {\n * // The model writes ```a2ui fences. Add no render tool.\n * }\n * ```\n */\nexport function readCopilotKitUIEnvelope(forwardedProps: unknown) {\n if (!isRecord(forwardedProps)) return undefined;\n const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];\n if (!isRecord(namespace)) return undefined;\n const envelope = namespace.ui;\n return isEnvelope(envelope) ? envelope : undefined;\n}\n\n/**\n * Turns an envelope into the manifest that the runtime and the prompts use.\n *\n * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists\n * all of them. The components, functions, and instructions come from the\n * inline catalog of the first id.\n * With no such inline catalog, there are no components and no functions.\n *\n * The result also has:\n * - `transport` and `contextSent`, from the extensions.\n * - `instructions`, when the inline catalog has them.\n * - `hasComponents`: false when the client left the component schemas out.\n * The runtime cannot check operations without them.\n * - `action`: the A2UI action message of the user event that started the\n * run, when one did.\n *\n * @param envelope - An envelope from `readCopilotKitUIEnvelope`.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * const manifest = envelope && envelopeToManifest(envelope);\n * if (manifest?.transport === \"tool\" && manifest.hasComponents) {\n * // Add the render tool and validate operations against manifest.components.\n * }\n * ```\n */\nexport function envelopeToManifest(envelope: CopilotKitUIEnvelope) {\n const { supportedCatalogIds, inlineCatalogs } = envelope[\"1.0\"];\n // `readCopilotKitUIEnvelope` only accepts a non-empty `supportedCatalogIds`.\n const catalogId = supportedCatalogIds[0]!;\n const catalog = inlineCatalogs?.find(\n (entry) => entry.catalogId === catalogId,\n );\n const extensions = envelope.metadata.extensions;\n const manifest: GenerativeUIManifest = {\n catalogId,\n catalogIds: supportedCatalogIds,\n components: catalog?.components ?? {},\n functions: catalog?.functions ?? {},\n targets: extensions.copilotkit_targets,\n surfaces: extensions.copilotkit_surfaces,\n };\n return {\n ...manifest,\n transport: extensions.copilotkit_transport,\n contextSent: extensions.copilotkit_contextSent,\n instructions: catalog?.instructions,\n hasComponents: catalog?.components !== undefined,\n ...(extensions.copilotkit_action === undefined\n ? {}\n : { action: extensions.copilotkit_action }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAa,iCAAiC;;AAG9C,MAAa,gCAAgC;AA8C7C,SAAS,iBAAiB,OAAgB;AACxC,QAAO,UAAU,UAAa,OAAO,UAAU;;AAGjD,SAAS,iBAAiB,OAAiC;AACzD,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,WACP,OACA,SAC4B;AAC5B,QAAOA,2BAAS,MAAM,IAAI,OAAO,OAAO,MAAM,CAAC,MAAM,QAAQ;;;AAI/D,SAAS,cAAc,OAAuD;AAC5E,QACEA,2BAAS,MAAM,IACfA,2BAAS,MAAM,WAAW,IAC1B,iBAAiB,MAAM,YAAY;;AAIvC,SAAS,WAAW,OAAgD;AAClE,QAAO,UAAU,YAAY,UAAU;;;;;;AAOzC,SAAS,cAAc,OAAkD;AACvE,QACEA,2BAAS,MAAM,KACd,MAAM,eAAe,UAAaA,2BAAS,MAAM,WAAW,MAC5D,MAAM,aAAa,UACjB,MAAM,QAAQ,MAAM,SAAS,IAC5B,MAAM,SAAS,OAAO,SAAS,OAAO,SAAS,SAAS;;AAIhE,SAAS,oBACP,OACwC;AACxC,KACE,CAACA,2BAAS,MAAM,IAChB,CAAC,cAAc,MAAM,MAAM,IAC3B,CAAC,iBAAiB,MAAM,YAAY,IACnC,MAAM,WAAW,UAAa,CAAC,WAAW,MAAM,QAAQ,cAAc,IACtE,MAAM,UAAU,UAAa,CAAC,WAAW,MAAM,OAAO,WAAW,CAElE,QAAO;CACT,MAAM,QAAQ,MAAM;AACpB,KAAI,UAAU,OAAW,QAAO;CAChC,MAAM,OAAO,IAAI,IAAI;EACnB,GAAG,OAAO,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EAAE,QAAQ,WAAW,mBAAmB;EAC7C"}
|
|
1
|
+
{"version":3,"file":"a2ui-envelope.cjs","names":["isRecord","GENERATIVE_UI_MAX_TARGET_COMPONENTS","GENERATIVE_UI_MAX_SUMMARY_REJECTIONS","GENERATIVE_UI_MAX_REJECTION_LENGTH"],"sources":["../src/a2ui-envelope.ts"],"sourcesContent":["/**\n * The generative UI envelope that the client sends on every run as\n * `forwardedProps.copilotkit.ui`. It has the A2UI v1.0 renderer capabilities\n * shape, so a backend that speaks A2UI v1.0 can read the catalog as it is.\n * CopilotKit data goes in `metadata.extensions`, under `copilotkit_` keys.\n * The runtime reads it to pick the transport and to build the guide.\n */\nimport {\n GENERATIVE_UI_MAX_REJECTION_LENGTH,\n GENERATIVE_UI_MAX_SUMMARY_REJECTIONS,\n GENERATIVE_UI_MAX_TARGET_COMPONENTS,\n} from \"./generative-ui/types\";\nimport type {\n A2UIActionMessage,\n GenerativeUIComponentManifest,\n GenerativeUIFunctionManifest,\n GenerativeUIManifest,\n GenerativeUISurfaceSummary,\n GenerativeUITarget,\n} from \"./generative-ui/types\";\nimport { isRecord } from \"./generative-ui/is-record\";\n\n/** Top-level `forwardedProps` key that holds the CopilotKit run properties. */\nexport const COPILOTKIT_FORWARDED_PROPS_KEY = \"copilotkit\";\n\n/** Version of the envelope shape (not of the UI protocol that it carries). */\nexport const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;\n\n/** What the client renders and calls, and how the model must write UI. */\nexport interface CopilotKitUIEnvelope {\n /** The A2UI v1.0 renderer capabilities. */\n \"1.0\": {\n /**\n * The catalog that the client renders comes first, then the catalogs of\n * its `extends`. An operation can name any of them.\n */\n supportedCatalogIds: string[];\n inlineCatalogs?: Array<{\n catalogId: string;\n protocolVersion: \"1.0\";\n /** Not there when the client is set up with `includeCatalog: false`. */\n components?: Record<string, GenerativeUIComponentManifest>;\n /** The app functions that are mounted now. */\n functions: Record<string, GenerativeUIFunctionManifest>;\n /** The markdown guideline. Only the markdown transport sends it. */\n instructions?: string;\n }>;\n };\n metadata: {\n extensions: {\n /** Envelope shape version. */\n copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT;\n /** \"tool\": the model calls the render tool. \"markdown\": the model writes ```a2ui fences. */\n copilotkit_transport: \"tool\" | \"markdown\";\n copilotkit_targets: GenerativeUIManifest[\"targets\"];\n copilotkit_surfaces: GenerativeUIManifest[\"surfaces\"];\n /** True when the client also sent the guide as context entries on this run. */\n copilotkit_contextSent: boolean;\n /**\n * The A2UI action that started this run, when a user event did: the\n * structured form of the user message that the event added.\n */\n copilotkit_action?: A2UIActionMessage;\n };\n };\n}\n\ntype InlineCatalog = NonNullable<\n CopilotKitUIEnvelope[\"1.0\"][\"inlineCatalogs\"]\n>[number];\ntype Extensions = CopilotKitUIEnvelope[\"metadata\"][\"extensions\"];\n\nfunction isOptionalString(value: unknown) {\n return value === undefined || typeof value === \"string\";\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value !== \"\";\n}\n\nfunction isRecordOf<T>(\n value: unknown,\n isEntry: (entry: unknown) => entry is T,\n): value is Record<string, T> {\n return isRecord(value) && Object.values(value).every(isEntry);\n}\n\n/** A function, or an event of a component: a description and a parameter schema. */\nfunction isSchemaEntry(value: unknown): value is GenerativeUIFunctionManifest {\n return (\n isRecord(value) &&\n isRecord(value.parameters) &&\n isOptionalString(value.description)\n );\n}\n\nfunction isSlotKind(value: unknown): value is \"single\" | \"multiple\" {\n return value === \"single\" || value === \"multiple\";\n}\n\n/**\n * `validateOperation` reads `properties` and `required` of a props schema,\n * so those two must have the right shape when they are there.\n */\nfunction isPropsSchema(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (value.properties === undefined || isRecord(value.properties)) &&\n (value.required === undefined ||\n (Array.isArray(value.required) &&\n value.required.every((name) => typeof name === \"string\")))\n );\n}\n\nfunction isComponentManifest(\n value: unknown,\n): value is GenerativeUIComponentManifest {\n if (\n !isRecord(value) ||\n !isPropsSchema(value.props) ||\n !isOptionalString(value.description) ||\n (value.events !== undefined && !isRecordOf(value.events, isSchemaEntry)) ||\n (value.slots !== undefined && !isRecordOf(value.slots, isSlotKind))\n )\n return false;\n const order = value.parameterOrder;\n if (order === undefined) return true;\n const keys = new Set([\n ...Object.keys(value.props.properties ?? {}),\n ...Object.keys(value.slots ?? {}),\n ...Object.keys(value.events ?? {}),\n ]);\n return (\n Array.isArray(order) &&\n new Set(order).size === order.length &&\n order.every((key) => typeof key === \"string\" && keys.has(key))\n );\n}\n\nfunction isInlineCatalog(value: unknown): value is InlineCatalog {\n return (\n isRecord(value) &&\n isNonEmptyString(value.catalogId) &&\n value.protocolVersion === \"1.0\" &&\n (value.components === undefined ||\n isRecordOf(value.components, isComponentManifest)) &&\n isRecordOf(value.functions, isSchemaEntry) &&\n isOptionalString(value.instructions)\n );\n}\n\nfunction isCapabilities(value: unknown): value is CopilotKitUIEnvelope[\"1.0\"] {\n return (\n isRecord(value) &&\n Array.isArray(value.supportedCatalogIds) &&\n value.supportedCatalogIds.length > 0 &&\n value.supportedCatalogIds.every(isNonEmptyString) &&\n (value.inlineCatalogs === undefined ||\n (Array.isArray(value.inlineCatalogs) &&\n value.inlineCatalogs.every(isInlineCatalog)))\n );\n}\n\n/** A short list of component names. */\nfunction isComponentNameList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_TARGET_COMPONENTS &&\n value.every(isNonEmptyString)\n );\n}\n\nfunction isTarget(value: unknown): value is GenerativeUITarget {\n return (\n isRecord(value) &&\n isNonEmptyString(value.id) &&\n (value.kind === \"chat\" || value.kind === \"inline\") &&\n isOptionalString(value.description) &&\n (value.components === undefined || isComponentNameList(value.components))\n );\n}\n\n/** A short list of short strings. The summary limits keep the guide small. */\nfunction isRejectionList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS &&\n value.every(\n (entry) =>\n typeof entry === \"string\" &&\n entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH,\n )\n );\n}\n\nfunction isSurfaceEntry(value: unknown): value is GenerativeUISurfaceSummary {\n return (\n isRecord(value) &&\n isNonEmptyString(value.target) &&\n (value.dataModel === undefined || isRecord(value.dataModel)) &&\n (value.rejected === undefined || isRejectionList(value.rejected)) &&\n (value.status === undefined ||\n value.status === \"deleted\" ||\n value.status === \"failed\") &&\n (value.a2uiSourceVersion === undefined || value.a2uiSourceVersion === \"0.9\")\n );\n}\n\n/** Checks the `copilotkit_` keys only. Other extensions can be there too. */\nfunction isExtensions(value: unknown): value is Extensions {\n return (\n isRecord(value) &&\n value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT &&\n (value.copilotkit_transport === \"tool\" ||\n value.copilotkit_transport === \"markdown\") &&\n Array.isArray(value.copilotkit_targets) &&\n value.copilotkit_targets.every(isTarget) &&\n isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) &&\n typeof value.copilotkit_contextSent === \"boolean\"\n );\n}\n\nfunction isEnvelope(value: unknown): value is CopilotKitUIEnvelope {\n return (\n isRecord(value) &&\n isCapabilities(value[\"1.0\"]) &&\n isRecord(value.metadata) &&\n isExtensions(value.metadata.extensions)\n );\n}\n\n/**\n * Reads the generative UI envelope from the `forwardedProps` of a run.\n *\n * The envelope comes from the client, so it is not trusted: every field is\n * checked. Returns `undefined` when the envelope is not there, or when it is\n * malformed (for example a wrong `copilotkit_format` or\n * `copilotkit_transport`, or no catalog id).\n *\n * @param forwardedProps - The `forwardedProps` of the run input.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * if (envelope?.metadata.extensions.copilotkit_transport === \"markdown\") {\n * // The model writes ```a2ui fences. Add no render tool.\n * }\n * ```\n */\nexport function readCopilotKitUIEnvelope(forwardedProps: unknown) {\n if (!isRecord(forwardedProps)) return undefined;\n const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];\n if (!isRecord(namespace)) return undefined;\n const envelope = namespace.ui;\n return isEnvelope(envelope) ? envelope : undefined;\n}\n\n/**\n * Turns an envelope into the manifest that the runtime and the prompts use.\n *\n * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists\n * all of them. The components, functions, and instructions come from the\n * inline catalog of the first id.\n * With no such inline catalog, there are no components and no functions.\n *\n * The result also has:\n * - `transport` and `contextSent`, from the extensions.\n * - `instructions`, when the inline catalog has them.\n * - `hasComponents`: false when the client left the component schemas out.\n * The runtime cannot check operations without them.\n * - `action`: the A2UI action message of the user event that started the\n * run, when one did.\n *\n * @param envelope - An envelope from `readCopilotKitUIEnvelope`.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * const manifest = envelope && envelopeToManifest(envelope);\n * if (manifest?.transport === \"tool\" && manifest.hasComponents) {\n * // Add the render tool and validate operations against manifest.components.\n * }\n * ```\n */\nexport function envelopeToManifest(envelope: CopilotKitUIEnvelope) {\n const { supportedCatalogIds, inlineCatalogs } = envelope[\"1.0\"];\n // `readCopilotKitUIEnvelope` only accepts a non-empty `supportedCatalogIds`.\n const catalogId = supportedCatalogIds[0]!;\n const catalog = inlineCatalogs?.find(\n (entry) => entry.catalogId === catalogId,\n );\n const extensions = envelope.metadata.extensions;\n const manifest: GenerativeUIManifest = {\n catalogId,\n catalogIds: supportedCatalogIds,\n components: catalog?.components ?? {},\n functions: catalog?.functions ?? {},\n targets: extensions.copilotkit_targets,\n surfaces: extensions.copilotkit_surfaces,\n };\n return {\n ...manifest,\n transport: extensions.copilotkit_transport,\n contextSent: extensions.copilotkit_contextSent,\n instructions: catalog?.instructions,\n hasComponents: catalog?.components !== undefined,\n ...(extensions.copilotkit_action === undefined\n ? {}\n : { action: extensions.copilotkit_action }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAa,iCAAiC;;AAG9C,MAAa,gCAAgC;AA8C7C,SAAS,iBAAiB,OAAgB;AACxC,QAAO,UAAU,UAAa,OAAO,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Aa,MAAA,SAAe,6BAAA,GAEjB;MAAX,SAAA,EAAW,MAAA,SAAe,4BAAA,GAQA;MAN1B,YAAA;IAAA;EAAA;EAGJ,QAAA;IACE,UAAA;MAlBF,8BAoBI,iBAAA,SAA0B,6BAAA,EAd5B;MAgBE,oBAAA;MACA,kBAAA,EAAoB,oBAAA;MACpB,mBAAA,EAAqB,oBAAA,cAdrB;MAgBA,sBAAA;MAhB4B;;;;MAqB5B,iBAAA,GAAoB,iBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"a2ui-envelope.d.cts","names":[],"sources":["../src/a2ui-envelope.ts"],"mappings":";;;;cAuBa,8BAAA;AAAb;AAAA,cAGa,6BAAA;;UAGI,oBAAA;EAN0B;EAQzC,KAAA;IALwC;;;;IAUtC,mBAAA;IACA,cAAA,GAAiB,KAAA;MACf,SAAA;MACA,eAAA,SAEa;MAAb,UAAA,GAAa,MAAA,SAAe,6BAAA,GAEjB;MAAX,SAAA,EAAW,MAAA,SAAe,4BAAA,GAQA;MAN1B,YAAA;IAAA;EAAA;EAGJ,QAAA;IACE,UAAA;MAlBF,8BAoBI,iBAAA,SAA0B,6BAAA,EAd5B;MAgBE,oBAAA;MACA,kBAAA,EAAoB,oBAAA;MACpB,mBAAA,EAAqB,oBAAA,cAdrB;MAgBA,sBAAA;MAhB4B;;;;MAqB5B,iBAAA,GAAoB,iBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;AA2L1B;;;;;AAmCA;;iBAnCgB,wBAAA,CAAyB,cAAA,YAAuB,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmChD,kBAAA,CAAmB,QAAA,EAAU,oBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2ui-envelope.d.mts","names":[],"sources":["../src/a2ui-envelope.ts"],"mappings":";;;;cAuBa,8BAAA;AAAb;AAAA,cAGa,6BAAA;;UAGI,oBAAA;EAN0B;EAQzC,KAAA;IALwC;;;;IAUtC,mBAAA;IACA,cAAA,GAAiB,KAAA;MACf,SAAA;MACA,eAAA,SAEa;MAAb,UAAA,GAAa,MAAA,SAAe,6BAAA,GAEjB;MAAX,SAAA,EAAW,MAAA,SAAe,4BAAA,GAQA;MAN1B,YAAA;IAAA;EAAA;EAGJ,QAAA;IACE,UAAA;MAlBF,8BAoBI,iBAAA,SAA0B,6BAAA,EAd5B;MAgBE,oBAAA;MACA,kBAAA,EAAoB,oBAAA;MACpB,mBAAA,EAAqB,oBAAA,cAdrB;MAgBA,sBAAA;MAhB4B;;;;MAqB5B,iBAAA,GAAoB,iBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"a2ui-envelope.d.mts","names":[],"sources":["../src/a2ui-envelope.ts"],"mappings":";;;;cAuBa,8BAAA;AAAb;AAAA,cAGa,6BAAA;;UAGI,oBAAA;EAN0B;EAQzC,KAAA;IALwC;;;;IAUtC,mBAAA;IACA,cAAA,GAAiB,KAAA;MACf,SAAA;MACA,eAAA,SAEa;MAAb,UAAA,GAAa,MAAA,SAAe,6BAAA,GAEjB;MAAX,SAAA,EAAW,MAAA,SAAe,4BAAA,GAQA;MAN1B,YAAA;IAAA;EAAA;EAGJ,QAAA;IACE,UAAA;MAlBF,8BAoBI,iBAAA,SAA0B,6BAAA,EAd5B;MAgBE,oBAAA;MACA,kBAAA,EAAoB,oBAAA;MACpB,mBAAA,EAAqB,oBAAA,cAdrB;MAgBA,sBAAA;MAhB4B;;;;MAqB5B,iBAAA,GAAoB,iBAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;AA2L1B;;;;;AAmCA;;iBAnCgB,wBAAA,CAAyB,cAAA,YAAuB,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmChD,kBAAA,CAAmB,QAAA,EAAU,oBAAA"}
|
package/dist/a2ui-envelope.mjs
CHANGED
|
@@ -65,7 +65,7 @@ function isRejectionList(value) {
|
|
|
65
65
|
return Array.isArray(value) && value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS && value.every((entry) => typeof entry === "string" && entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH);
|
|
66
66
|
}
|
|
67
67
|
function isSurfaceEntry(value) {
|
|
68
|
-
return isRecord(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || isRecord(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed");
|
|
68
|
+
return isRecord(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || isRecord(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed") && (value.a2uiSourceVersion === void 0 || value.a2uiSourceVersion === "0.9");
|
|
69
69
|
}
|
|
70
70
|
/** Checks the `copilotkit_` keys only. Other extensions can be there too. */
|
|
71
71
|
function isExtensions(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2ui-envelope.mjs","names":[],"sources":["../src/a2ui-envelope.ts"],"sourcesContent":["/**\n * The generative UI envelope that the client sends on every run as\n * `forwardedProps.copilotkit.ui`. It has the A2UI v1.0 renderer capabilities\n * shape, so a backend that speaks A2UI v1.0 can read the catalog as it is.\n * CopilotKit data goes in `metadata.extensions`, under `copilotkit_` keys.\n * The runtime reads it to pick the transport and to build the guide.\n */\nimport {\n GENERATIVE_UI_MAX_REJECTION_LENGTH,\n GENERATIVE_UI_MAX_SUMMARY_REJECTIONS,\n GENERATIVE_UI_MAX_TARGET_COMPONENTS,\n} from \"./generative-ui/types\";\nimport type {\n A2UIActionMessage,\n GenerativeUIComponentManifest,\n GenerativeUIFunctionManifest,\n GenerativeUIManifest,\n GenerativeUISurfaceSummary,\n GenerativeUITarget,\n} from \"./generative-ui/types\";\nimport { isRecord } from \"./generative-ui/is-record\";\n\n/** Top-level `forwardedProps` key that holds the CopilotKit run properties. */\nexport const COPILOTKIT_FORWARDED_PROPS_KEY = \"copilotkit\";\n\n/** Version of the envelope shape (not of the UI protocol that it carries). */\nexport const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;\n\n/** What the client renders and calls, and how the model must write UI. */\nexport interface CopilotKitUIEnvelope {\n /** The A2UI v1.0 renderer capabilities. */\n \"1.0\": {\n /**\n * The catalog that the client renders comes first, then the catalogs of\n * its `extends`. An operation can name any of them.\n */\n supportedCatalogIds: string[];\n inlineCatalogs?: Array<{\n catalogId: string;\n protocolVersion: \"1.0\";\n /** Not there when the client is set up with `includeCatalog: false`. */\n components?: Record<string, GenerativeUIComponentManifest>;\n /** The app functions that are mounted now. */\n functions: Record<string, GenerativeUIFunctionManifest>;\n /** The markdown guideline. Only the markdown transport sends it. */\n instructions?: string;\n }>;\n };\n metadata: {\n extensions: {\n /** Envelope shape version. */\n copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT;\n /** \"tool\": the model calls the render tool. \"markdown\": the model writes ```a2ui fences. */\n copilotkit_transport: \"tool\" | \"markdown\";\n copilotkit_targets: GenerativeUIManifest[\"targets\"];\n copilotkit_surfaces: GenerativeUIManifest[\"surfaces\"];\n /** True when the client also sent the guide as context entries on this run. */\n copilotkit_contextSent: boolean;\n /**\n * The A2UI action that started this run, when a user event did: the\n * structured form of the user message that the event added.\n */\n copilotkit_action?: A2UIActionMessage;\n };\n };\n}\n\ntype InlineCatalog = NonNullable<\n CopilotKitUIEnvelope[\"1.0\"][\"inlineCatalogs\"]\n>[number];\ntype Extensions = CopilotKitUIEnvelope[\"metadata\"][\"extensions\"];\n\nfunction isOptionalString(value: unknown) {\n return value === undefined || typeof value === \"string\";\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value !== \"\";\n}\n\nfunction isRecordOf<T>(\n value: unknown,\n isEntry: (entry: unknown) => entry is T,\n): value is Record<string, T> {\n return isRecord(value) && Object.values(value).every(isEntry);\n}\n\n/** A function, or an event of a component: a description and a parameter schema. */\nfunction isSchemaEntry(value: unknown): value is GenerativeUIFunctionManifest {\n return (\n isRecord(value) &&\n isRecord(value.parameters) &&\n isOptionalString(value.description)\n );\n}\n\nfunction isSlotKind(value: unknown): value is \"single\" | \"multiple\" {\n return value === \"single\" || value === \"multiple\";\n}\n\n/**\n * `validateOperation` reads `properties` and `required` of a props schema,\n * so those two must have the right shape when they are there.\n */\nfunction isPropsSchema(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (value.properties === undefined || isRecord(value.properties)) &&\n (value.required === undefined ||\n (Array.isArray(value.required) &&\n value.required.every((name) => typeof name === \"string\")))\n );\n}\n\nfunction isComponentManifest(\n value: unknown,\n): value is GenerativeUIComponentManifest {\n if (\n !isRecord(value) ||\n !isPropsSchema(value.props) ||\n !isOptionalString(value.description) ||\n (value.events !== undefined && !isRecordOf(value.events, isSchemaEntry)) ||\n (value.slots !== undefined && !isRecordOf(value.slots, isSlotKind))\n )\n return false;\n const order = value.parameterOrder;\n if (order === undefined) return true;\n const keys = new Set([\n ...Object.keys(value.props.properties ?? {}),\n ...Object.keys(value.slots ?? {}),\n ...Object.keys(value.events ?? {}),\n ]);\n return (\n Array.isArray(order) &&\n new Set(order).size === order.length &&\n order.every((key) => typeof key === \"string\" && keys.has(key))\n );\n}\n\nfunction isInlineCatalog(value: unknown): value is InlineCatalog {\n return (\n isRecord(value) &&\n isNonEmptyString(value.catalogId) &&\n value.protocolVersion === \"1.0\" &&\n (value.components === undefined ||\n isRecordOf(value.components, isComponentManifest)) &&\n isRecordOf(value.functions, isSchemaEntry) &&\n isOptionalString(value.instructions)\n );\n}\n\nfunction isCapabilities(value: unknown): value is CopilotKitUIEnvelope[\"1.0\"] {\n return (\n isRecord(value) &&\n Array.isArray(value.supportedCatalogIds) &&\n value.supportedCatalogIds.length > 0 &&\n value.supportedCatalogIds.every(isNonEmptyString) &&\n (value.inlineCatalogs === undefined ||\n (Array.isArray(value.inlineCatalogs) &&\n value.inlineCatalogs.every(isInlineCatalog)))\n );\n}\n\n/** A short list of component names. */\nfunction isComponentNameList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_TARGET_COMPONENTS &&\n value.every(isNonEmptyString)\n );\n}\n\nfunction isTarget(value: unknown): value is GenerativeUITarget {\n return (\n isRecord(value) &&\n isNonEmptyString(value.id) &&\n (value.kind === \"chat\" || value.kind === \"inline\") &&\n isOptionalString(value.description) &&\n (value.components === undefined || isComponentNameList(value.components))\n );\n}\n\n/** A short list of short strings. The summary limits keep the guide small. */\nfunction isRejectionList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS &&\n value.every(\n (entry) =>\n typeof entry === \"string\" &&\n entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH,\n )\n );\n}\n\nfunction isSurfaceEntry(value: unknown): value is GenerativeUISurfaceSummary {\n return (\n isRecord(value) &&\n isNonEmptyString(value.target) &&\n (value.dataModel === undefined || isRecord(value.dataModel)) &&\n (value.rejected === undefined || isRejectionList(value.rejected)) &&\n (value.status === undefined ||\n value.status === \"deleted\" ||\n value.status === \"failed\")\n );\n}\n\n/** Checks the `copilotkit_` keys only. Other extensions can be there too. */\nfunction isExtensions(value: unknown): value is Extensions {\n return (\n isRecord(value) &&\n value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT &&\n (value.copilotkit_transport === \"tool\" ||\n value.copilotkit_transport === \"markdown\") &&\n Array.isArray(value.copilotkit_targets) &&\n value.copilotkit_targets.every(isTarget) &&\n isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) &&\n typeof value.copilotkit_contextSent === \"boolean\"\n );\n}\n\nfunction isEnvelope(value: unknown): value is CopilotKitUIEnvelope {\n return (\n isRecord(value) &&\n isCapabilities(value[\"1.0\"]) &&\n isRecord(value.metadata) &&\n isExtensions(value.metadata.extensions)\n );\n}\n\n/**\n * Reads the generative UI envelope from the `forwardedProps` of a run.\n *\n * The envelope comes from the client, so it is not trusted: every field is\n * checked. Returns `undefined` when the envelope is not there, or when it is\n * malformed (for example a wrong `copilotkit_format` or\n * `copilotkit_transport`, or no catalog id).\n *\n * @param forwardedProps - The `forwardedProps` of the run input.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * if (envelope?.metadata.extensions.copilotkit_transport === \"markdown\") {\n * // The model writes ```a2ui fences. Add no render tool.\n * }\n * ```\n */\nexport function readCopilotKitUIEnvelope(forwardedProps: unknown) {\n if (!isRecord(forwardedProps)) return undefined;\n const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];\n if (!isRecord(namespace)) return undefined;\n const envelope = namespace.ui;\n return isEnvelope(envelope) ? envelope : undefined;\n}\n\n/**\n * Turns an envelope into the manifest that the runtime and the prompts use.\n *\n * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists\n * all of them. The components, functions, and instructions come from the\n * inline catalog of the first id.\n * With no such inline catalog, there are no components and no functions.\n *\n * The result also has:\n * - `transport` and `contextSent`, from the extensions.\n * - `instructions`, when the inline catalog has them.\n * - `hasComponents`: false when the client left the component schemas out.\n * The runtime cannot check operations without them.\n * - `action`: the A2UI action message of the user event that started the\n * run, when one did.\n *\n * @param envelope - An envelope from `readCopilotKitUIEnvelope`.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * const manifest = envelope && envelopeToManifest(envelope);\n * if (manifest?.transport === \"tool\" && manifest.hasComponents) {\n * // Add the render tool and validate operations against manifest.components.\n * }\n * ```\n */\nexport function envelopeToManifest(envelope: CopilotKitUIEnvelope) {\n const { supportedCatalogIds, inlineCatalogs } = envelope[\"1.0\"];\n // `readCopilotKitUIEnvelope` only accepts a non-empty `supportedCatalogIds`.\n const catalogId = supportedCatalogIds[0]!;\n const catalog = inlineCatalogs?.find(\n (entry) => entry.catalogId === catalogId,\n );\n const extensions = envelope.metadata.extensions;\n const manifest: GenerativeUIManifest = {\n catalogId,\n catalogIds: supportedCatalogIds,\n components: catalog?.components ?? {},\n functions: catalog?.functions ?? {},\n targets: extensions.copilotkit_targets,\n surfaces: extensions.copilotkit_surfaces,\n };\n return {\n ...manifest,\n transport: extensions.copilotkit_transport,\n contextSent: extensions.copilotkit_contextSent,\n instructions: catalog?.instructions,\n hasComponents: catalog?.components !== undefined,\n ...(extensions.copilotkit_action === undefined\n ? {}\n : { action: extensions.copilotkit_action }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAa,iCAAiC;;AAG9C,MAAa,gCAAgC;AA8C7C,SAAS,iBAAiB,OAAgB;AACxC,QAAO,UAAU,UAAa,OAAO,UAAU;;AAGjD,SAAS,iBAAiB,OAAiC;AACzD,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,WACP,OACA,SAC4B;AAC5B,QAAO,SAAS,MAAM,IAAI,OAAO,OAAO,MAAM,CAAC,MAAM,QAAQ;;;AAI/D,SAAS,cAAc,OAAuD;AAC5E,QACE,SAAS,MAAM,IACf,SAAS,MAAM,WAAW,IAC1B,iBAAiB,MAAM,YAAY;;AAIvC,SAAS,WAAW,OAAgD;AAClE,QAAO,UAAU,YAAY,UAAU;;;;;;AAOzC,SAAS,cAAc,OAAkD;AACvE,QACE,SAAS,MAAM,KACd,MAAM,eAAe,UAAa,SAAS,MAAM,WAAW,MAC5D,MAAM,aAAa,UACjB,MAAM,QAAQ,MAAM,SAAS,IAC5B,MAAM,SAAS,OAAO,SAAS,OAAO,SAAS,SAAS;;AAIhE,SAAS,oBACP,OACwC;AACxC,KACE,CAAC,SAAS,MAAM,IAChB,CAAC,cAAc,MAAM,MAAM,IAC3B,CAAC,iBAAiB,MAAM,YAAY,IACnC,MAAM,WAAW,UAAa,CAAC,WAAW,MAAM,QAAQ,cAAc,IACtE,MAAM,UAAU,UAAa,CAAC,WAAW,MAAM,OAAO,WAAW,CAElE,QAAO;CACT,MAAM,QAAQ,MAAM;AACpB,KAAI,UAAU,OAAW,QAAO;CAChC,MAAM,OAA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AE,GACF,EAAE,QAAQ,WAAW,mBAAmB;EAC7C"}
|
|
1
|
+
{"version":3,"file":"a2ui-envelope.mjs","names":[],"sources":["../src/a2ui-envelope.ts"],"sourcesContent":["/**\n * The generative UI envelope that the client sends on every run as\n * `forwardedProps.copilotkit.ui`. It has the A2UI v1.0 renderer capabilities\n * shape, so a backend that speaks A2UI v1.0 can read the catalog as it is.\n * CopilotKit data goes in `metadata.extensions`, under `copilotkit_` keys.\n * The runtime reads it to pick the transport and to build the guide.\n */\nimport {\n GENERATIVE_UI_MAX_REJECTION_LENGTH,\n GENERATIVE_UI_MAX_SUMMARY_REJECTIONS,\n GENERATIVE_UI_MAX_TARGET_COMPONENTS,\n} from \"./generative-ui/types\";\nimport type {\n A2UIActionMessage,\n GenerativeUIComponentManifest,\n GenerativeUIFunctionManifest,\n GenerativeUIManifest,\n GenerativeUISurfaceSummary,\n GenerativeUITarget,\n} from \"./generative-ui/types\";\nimport { isRecord } from \"./generative-ui/is-record\";\n\n/** Top-level `forwardedProps` key that holds the CopilotKit run properties. */\nexport const COPILOTKIT_FORWARDED_PROPS_KEY = \"copilotkit\";\n\n/** Version of the envelope shape (not of the UI protocol that it carries). */\nexport const COPILOTKIT_UI_ENVELOPE_FORMAT = 3;\n\n/** What the client renders and calls, and how the model must write UI. */\nexport interface CopilotKitUIEnvelope {\n /** The A2UI v1.0 renderer capabilities. */\n \"1.0\": {\n /**\n * The catalog that the client renders comes first, then the catalogs of\n * its `extends`. An operation can name any of them.\n */\n supportedCatalogIds: string[];\n inlineCatalogs?: Array<{\n catalogId: string;\n protocolVersion: \"1.0\";\n /** Not there when the client is set up with `includeCatalog: false`. */\n components?: Record<string, GenerativeUIComponentManifest>;\n /** The app functions that are mounted now. */\n functions: Record<string, GenerativeUIFunctionManifest>;\n /** The markdown guideline. Only the markdown transport sends it. */\n instructions?: string;\n }>;\n };\n metadata: {\n extensions: {\n /** Envelope shape version. */\n copilotkit_format: typeof COPILOTKIT_UI_ENVELOPE_FORMAT;\n /** \"tool\": the model calls the render tool. \"markdown\": the model writes ```a2ui fences. */\n copilotkit_transport: \"tool\" | \"markdown\";\n copilotkit_targets: GenerativeUIManifest[\"targets\"];\n copilotkit_surfaces: GenerativeUIManifest[\"surfaces\"];\n /** True when the client also sent the guide as context entries on this run. */\n copilotkit_contextSent: boolean;\n /**\n * The A2UI action that started this run, when a user event did: the\n * structured form of the user message that the event added.\n */\n copilotkit_action?: A2UIActionMessage;\n };\n };\n}\n\ntype InlineCatalog = NonNullable<\n CopilotKitUIEnvelope[\"1.0\"][\"inlineCatalogs\"]\n>[number];\ntype Extensions = CopilotKitUIEnvelope[\"metadata\"][\"extensions\"];\n\nfunction isOptionalString(value: unknown) {\n return value === undefined || typeof value === \"string\";\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value !== \"\";\n}\n\nfunction isRecordOf<T>(\n value: unknown,\n isEntry: (entry: unknown) => entry is T,\n): value is Record<string, T> {\n return isRecord(value) && Object.values(value).every(isEntry);\n}\n\n/** A function, or an event of a component: a description and a parameter schema. */\nfunction isSchemaEntry(value: unknown): value is GenerativeUIFunctionManifest {\n return (\n isRecord(value) &&\n isRecord(value.parameters) &&\n isOptionalString(value.description)\n );\n}\n\nfunction isSlotKind(value: unknown): value is \"single\" | \"multiple\" {\n return value === \"single\" || value === \"multiple\";\n}\n\n/**\n * `validateOperation` reads `properties` and `required` of a props schema,\n * so those two must have the right shape when they are there.\n */\nfunction isPropsSchema(value: unknown): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (value.properties === undefined || isRecord(value.properties)) &&\n (value.required === undefined ||\n (Array.isArray(value.required) &&\n value.required.every((name) => typeof name === \"string\")))\n );\n}\n\nfunction isComponentManifest(\n value: unknown,\n): value is GenerativeUIComponentManifest {\n if (\n !isRecord(value) ||\n !isPropsSchema(value.props) ||\n !isOptionalString(value.description) ||\n (value.events !== undefined && !isRecordOf(value.events, isSchemaEntry)) ||\n (value.slots !== undefined && !isRecordOf(value.slots, isSlotKind))\n )\n return false;\n const order = value.parameterOrder;\n if (order === undefined) return true;\n const keys = new Set([\n ...Object.keys(value.props.properties ?? {}),\n ...Object.keys(value.slots ?? {}),\n ...Object.keys(value.events ?? {}),\n ]);\n return (\n Array.isArray(order) &&\n new Set(order).size === order.length &&\n order.every((key) => typeof key === \"string\" && keys.has(key))\n );\n}\n\nfunction isInlineCatalog(value: unknown): value is InlineCatalog {\n return (\n isRecord(value) &&\n isNonEmptyString(value.catalogId) &&\n value.protocolVersion === \"1.0\" &&\n (value.components === undefined ||\n isRecordOf(value.components, isComponentManifest)) &&\n isRecordOf(value.functions, isSchemaEntry) &&\n isOptionalString(value.instructions)\n );\n}\n\nfunction isCapabilities(value: unknown): value is CopilotKitUIEnvelope[\"1.0\"] {\n return (\n isRecord(value) &&\n Array.isArray(value.supportedCatalogIds) &&\n value.supportedCatalogIds.length > 0 &&\n value.supportedCatalogIds.every(isNonEmptyString) &&\n (value.inlineCatalogs === undefined ||\n (Array.isArray(value.inlineCatalogs) &&\n value.inlineCatalogs.every(isInlineCatalog)))\n );\n}\n\n/** A short list of component names. */\nfunction isComponentNameList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_TARGET_COMPONENTS &&\n value.every(isNonEmptyString)\n );\n}\n\nfunction isTarget(value: unknown): value is GenerativeUITarget {\n return (\n isRecord(value) &&\n isNonEmptyString(value.id) &&\n (value.kind === \"chat\" || value.kind === \"inline\") &&\n isOptionalString(value.description) &&\n (value.components === undefined || isComponentNameList(value.components))\n );\n}\n\n/** A short list of short strings. The summary limits keep the guide small. */\nfunction isRejectionList(value: unknown): value is string[] {\n return (\n Array.isArray(value) &&\n value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS &&\n value.every(\n (entry) =>\n typeof entry === \"string\" &&\n entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH,\n )\n );\n}\n\nfunction isSurfaceEntry(value: unknown): value is GenerativeUISurfaceSummary {\n return (\n isRecord(value) &&\n isNonEmptyString(value.target) &&\n (value.dataModel === undefined || isRecord(value.dataModel)) &&\n (value.rejected === undefined || isRejectionList(value.rejected)) &&\n (value.status === undefined ||\n value.status === \"deleted\" ||\n value.status === \"failed\") &&\n (value.a2uiSourceVersion === undefined || value.a2uiSourceVersion === \"0.9\")\n );\n}\n\n/** Checks the `copilotkit_` keys only. Other extensions can be there too. */\nfunction isExtensions(value: unknown): value is Extensions {\n return (\n isRecord(value) &&\n value.copilotkit_format === COPILOTKIT_UI_ENVELOPE_FORMAT &&\n (value.copilotkit_transport === \"tool\" ||\n value.copilotkit_transport === \"markdown\") &&\n Array.isArray(value.copilotkit_targets) &&\n value.copilotkit_targets.every(isTarget) &&\n isRecordOf(value.copilotkit_surfaces, isSurfaceEntry) &&\n typeof value.copilotkit_contextSent === \"boolean\"\n );\n}\n\nfunction isEnvelope(value: unknown): value is CopilotKitUIEnvelope {\n return (\n isRecord(value) &&\n isCapabilities(value[\"1.0\"]) &&\n isRecord(value.metadata) &&\n isExtensions(value.metadata.extensions)\n );\n}\n\n/**\n * Reads the generative UI envelope from the `forwardedProps` of a run.\n *\n * The envelope comes from the client, so it is not trusted: every field is\n * checked. Returns `undefined` when the envelope is not there, or when it is\n * malformed (for example a wrong `copilotkit_format` or\n * `copilotkit_transport`, or no catalog id).\n *\n * @param forwardedProps - The `forwardedProps` of the run input.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * if (envelope?.metadata.extensions.copilotkit_transport === \"markdown\") {\n * // The model writes ```a2ui fences. Add no render tool.\n * }\n * ```\n */\nexport function readCopilotKitUIEnvelope(forwardedProps: unknown) {\n if (!isRecord(forwardedProps)) return undefined;\n const namespace = forwardedProps[COPILOTKIT_FORWARDED_PROPS_KEY];\n if (!isRecord(namespace)) return undefined;\n const envelope = namespace.ui;\n return isEnvelope(envelope) ? envelope : undefined;\n}\n\n/**\n * Turns an envelope into the manifest that the runtime and the prompts use.\n *\n * The catalog is the first of `supportedCatalogIds`, and `catalogIds` lists\n * all of them. The components, functions, and instructions come from the\n * inline catalog of the first id.\n * With no such inline catalog, there are no components and no functions.\n *\n * The result also has:\n * - `transport` and `contextSent`, from the extensions.\n * - `instructions`, when the inline catalog has them.\n * - `hasComponents`: false when the client left the component schemas out.\n * The runtime cannot check operations without them.\n * - `action`: the A2UI action message of the user event that started the\n * run, when one did.\n *\n * @param envelope - An envelope from `readCopilotKitUIEnvelope`.\n *\n * @example\n * ```ts\n * const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n * const manifest = envelope && envelopeToManifest(envelope);\n * if (manifest?.transport === \"tool\" && manifest.hasComponents) {\n * // Add the render tool and validate operations against manifest.components.\n * }\n * ```\n */\nexport function envelopeToManifest(envelope: CopilotKitUIEnvelope) {\n const { supportedCatalogIds, inlineCatalogs } = envelope[\"1.0\"];\n // `readCopilotKitUIEnvelope` only accepts a non-empty `supportedCatalogIds`.\n const catalogId = supportedCatalogIds[0]!;\n const catalog = inlineCatalogs?.find(\n (entry) => entry.catalogId === catalogId,\n );\n const extensions = envelope.metadata.extensions;\n const manifest: GenerativeUIManifest = {\n catalogId,\n catalogIds: supportedCatalogIds,\n components: catalog?.components ?? {},\n functions: catalog?.functions ?? {},\n targets: extensions.copilotkit_targets,\n surfaces: extensions.copilotkit_surfaces,\n };\n return {\n ...manifest,\n transport: extensions.copilotkit_transport,\n contextSent: extensions.copilotkit_contextSent,\n instructions: catalog?.instructions,\n hasComponents: catalog?.components !== undefined,\n ...(extensions.copilotkit_action === undefined\n ? {}\n : { action: extensions.copilotkit_action }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAa,iCAAiC;;AAG9C,MAAa,gCAAgC;AA8C7C,SAAS,iBAAiB,OAAgB;AACxC,QAAO,UAAU,UAAa,OAAO,UAAU;;AAGjD,SAAS,iBAAiB,OAAiC;AACzD,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,WACP,OACA,SAC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,QACE,SAAS,MAAM,IACf,eAAe,MAAM,OAAO,IAC5B,SAAS,MAAM,SAAS,IACxB,aAAa,MAAM,SAAS,WAAW;;;;;;;;;;;;;;;;;;;;AAsB3C,SAAgB,yBAAyB,gBAAyB;AAChE,KAAI,CAAC,SAAS,eAAe,CAAE,QAAO;CACtC,MAAM,YAAY,eAAe;AACjC,KAAI,CAAC,SAAS,UAAU,CAAE,QAAO;CACjC,MAAM,WAAW,UAAU;AAC3B,QAAO,WAAW,SAAS,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B3C,SAAgB,mBAAmB,UAAgC;CACjE,MAAM,EAAE,qBAAqB,mBAAmB,SAAS;CAEzD,MAAM,YAAY,oBAAoB;CACtC,MAAM,UAAU,gBAAgB,MAC7B,UAAU,MAAM,cAAc,UAChC;CACD,MAAM,aAAa,SAAS,SAAS;AASrC,QAAO;EAPL;EACA,YAAY;EACZ,YAAY,SAAS,cAAc,EAAE;EACrC,WAAW,SAAS,aAAa,EAAE;EACnC,SAAS,WAAW;EACpB,UAAU,WAAW;EAIrB,WAAW,WAAW;EACtB,aAAa,WAAW;EACxB,cAAc,SAAS;EACvB,eAAe,SAAS,eAAe;EACvC,GAAI,WAAW,sBAAsB,SACjC,EAAE,GACF,EAAE,QAAQ,WAAW,mBAAmB;EAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: typeof A2UI_VERSION;\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: typeof A2UI_VERSION;\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: typeof A2UI_VERSION;\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | {\n version: typeof A2UI_VERSION;\n deleteSurface: { surfaceId: string };\n }\n | {\n version: typeof A2UI_VERSION;\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AAiKF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: typeof A2UI_VERSION;\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: typeof A2UI_VERSION;\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: typeof A2UI_VERSION;\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | {\n version: typeof A2UI_VERSION;\n deleteSurface: { surfaceId: string };\n }\n | {\n version: typeof A2UI_VERSION;\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n /**\n * `\"0.9\"` when the runtime converted the surface from A2UI v0.9 operations,\n * so a user event on it goes back to the agent as a v0.9 action. Left out\n * for a surface that the agent wrote in 1.0.\n */\n a2uiSourceVersion?: \"0.9\";\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n /**\n * `\"0.9\"` when the runtime converted the surface from A2UI v0.9 (copied\n * from {@link GenerativeUISurfaceContent.a2uiSourceVersion}), so the\n * runtime sends a user event on it to the agent as a v0.9 action. Left out\n * for a surface that the agent wrote in 1.0.\n */\n a2uiSourceVersion?: \"0.9\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AAuKF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AAsElD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
@@ -132,6 +132,12 @@ interface GenerativeUISurfaceContent {
|
|
|
132
132
|
operations: A2UIOperation[];
|
|
133
133
|
status: GenerativeUISurfaceStatus;
|
|
134
134
|
rejected: GenerativeUIRejectedOperation[];
|
|
135
|
+
/**
|
|
136
|
+
* `"0.9"` when the runtime converted the surface from A2UI v0.9 operations,
|
|
137
|
+
* so a user event on it goes back to the agent as a v0.9 action. Left out
|
|
138
|
+
* for a surface that the agent wrote in 1.0.
|
|
139
|
+
*/
|
|
140
|
+
a2uiSourceVersion?: "0.9";
|
|
135
141
|
}
|
|
136
142
|
/** Content of a `generative-ui-function-call` activity message. */
|
|
137
143
|
interface GenerativeUIFunctionCallContent {
|
|
@@ -225,6 +231,13 @@ interface GenerativeUISurfaceSummary {
|
|
|
225
231
|
* rejected, so it does not exist; a corrected createSurface can use the id.
|
|
226
232
|
*/
|
|
227
233
|
status?: "deleted" | "failed";
|
|
234
|
+
/**
|
|
235
|
+
* `"0.9"` when the runtime converted the surface from A2UI v0.9 (copied
|
|
236
|
+
* from {@link GenerativeUISurfaceContent.a2uiSourceVersion}), so the
|
|
237
|
+
* runtime sends a user event on it to the agent as a v0.9 action. Left out
|
|
238
|
+
* for a surface that the agent wrote in 1.0.
|
|
239
|
+
*/
|
|
240
|
+
a2uiSourceVersion?: "0.9";
|
|
228
241
|
}
|
|
229
242
|
/** A user interaction bound to `{ event }`, sent to the agent. */
|
|
230
243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EACA,WAAA;EAnCc;;;;;EAyCd,UAAA;AAAA;;cAIW,mCAAA;;cAGA,oCAAA;;cAEA,kCAAA;;UAGI,0BAAA;EACf,MAAA;EAnD4C;EAqD5C,SAAA,GAAY,MAAA;EAnDA;;;;;;EA0DZ,QAAA;EA1DA;;;;;EAgEA,MAAA;EA1De;;;;;;EAiEf,iBAAA;AAAA;;UAIe,qBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;EACA,OAAA,EAAS,MAAA;EAjET;EAmEA,WAAA;EAnE2B;EAqE3B,SAAA;AAAA;;;;;;;UASe,iBAAA;EACf,OAAA,SAAgB,YAAA;EAChB,MAAA;IACE,IAAA;IACA,SAAA;IACA,iBAAA,UArEF;IAuEE,SAAA;IACA,WAAA;IACA,OAAA,EAAS,MAAA;EAAA;AAAA;AA7Db;;;;;AAGA;;;;;AAHA,iBA2EgB,mBAAA,CACd,KAAA,EAAO,qBAAA,GACN,iBAAA"}
|
|
@@ -132,6 +132,12 @@ interface GenerativeUISurfaceContent {
|
|
|
132
132
|
operations: A2UIOperation[];
|
|
133
133
|
status: GenerativeUISurfaceStatus;
|
|
134
134
|
rejected: GenerativeUIRejectedOperation[];
|
|
135
|
+
/**
|
|
136
|
+
* `"0.9"` when the runtime converted the surface from A2UI v0.9 operations,
|
|
137
|
+
* so a user event on it goes back to the agent as a v0.9 action. Left out
|
|
138
|
+
* for a surface that the agent wrote in 1.0.
|
|
139
|
+
*/
|
|
140
|
+
a2uiSourceVersion?: "0.9";
|
|
135
141
|
}
|
|
136
142
|
/** Content of a `generative-ui-function-call` activity message. */
|
|
137
143
|
interface GenerativeUIFunctionCallContent {
|
|
@@ -225,6 +231,13 @@ interface GenerativeUISurfaceSummary {
|
|
|
225
231
|
* rejected, so it does not exist; a corrected createSurface can use the id.
|
|
226
232
|
*/
|
|
227
233
|
status?: "deleted" | "failed";
|
|
234
|
+
/**
|
|
235
|
+
* `"0.9"` when the runtime converted the surface from A2UI v0.9 (copied
|
|
236
|
+
* from {@link GenerativeUISurfaceContent.a2uiSourceVersion}), so the
|
|
237
|
+
* runtime sends a user event on it to the agent as a v0.9 action. Left out
|
|
238
|
+
* for a surface that the agent wrote in 1.0.
|
|
239
|
+
*/
|
|
240
|
+
a2uiSourceVersion?: "0.9";
|
|
228
241
|
}
|
|
229
242
|
/** A user interaction bound to `{ event }`, sent to the agent. */
|
|
230
243
|
interface GenerativeUIUserEvent {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/generative-ui/types.ts"],"mappings":";;;;cACa,YAAA;;cAEA,2BAAA;;cAEA,yCAAA;;cAGA,yBAAA;AALb;AAAA,cAOa,yBAAA;;cAEA,qBAAA;;AAPb;;;;;AAGA;;cAaa,kCAAA;;cAEA,6CAAA;AAbb;AAAA,iBAiBgB,4BAAA,CAA6B,SAAA;;;;AAf7C;;;;;AASA;;;iBAqBgB,iCAAA,CAAkC,cAAA;AAAA,KAWtC,sBAAA,GAAyB,MAAA;AAAA,KAEzB,iBAAA;EACV,EAAA;EACA,SAAA;EAAA,CACC,IAAA;AAAA;;;;;AAhBH;;cAyBa,4BAAA,EAA8B,WAAA;;;AAd3C;;KAwBY,gBAAA;EACV,OAAA;EACA,IAAA,GAAO,MAAA;EACP,SAAA;AAAA;AAAA,KAGU,aAAA;EAEN,OAAA,SAAgB,YAAA;EAChB,aAAA;IACE,SAAA,UA7BL;IA+BK,SAAA,WA/BO;IAiCP,UAAA,GAAa,iBAAA,IApBnB;IAsBM,SAAA,GAAY,MAAA;IACZ,aAAA;IACA,QAAA;MAAa,UAAA,GAAa,MAAA;IAAA;EAAA;AAAA;EAI5B,OAAA,SAAgB,YAAA;EAChB,gBAAA;IAAoB,SAAA;IAAmB,UAAA,EAAY,iBAAA;EAAA;AAAA;EAGnD,OAAA,SAAgB,YAAA;EApBG;;;;EAyBnB,eAAA;IAAmB,SAAA;IAAmB,IAAA;IAAe,KAAA;EAAA;AAAA;EAGrD,OAAA,SAAg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;EA1Ce;;;;EA+Cf,UAAA;EACA,UAAA,EAAY,MAAA,SAAe,6BAAA;EAC3B,SAAA,EAAW,MAAA,SAAe,4BAAA;EA/CI;;AAOhC;;;EA8CE,OAAA,EAAS,kBAAA;EA5CL;EA8CJ,QAAA,EAAU,MAAA,SAAe,0BAAA;AAAA;;UAIV,kBAAA;EACf,EAAA;EACA,IAAA;EACA,WAAA;EAnCc;;;;;EAyCd,UAAA;AAAA;;cAIW,mCAAA;;cAGA,oCAAA;;cAEA,kCAAA;;UAGI,0BAAA;EACf,MAAA;EAnD4C;EAqD5C,SAAA,GAAY,MAAA;EAnDA;;;;;;EA0DZ,QAAA;EA1DA;;;;;EAgEA,MAAA;EA1De;;;;;;EAiEf,iBAAA;AAAA;;UAIe,qBAAA;EACf,IAAA;EACA,SAAA;EACA,WAAA;EACA,OAAA,EAAS,MAAA;EAjET;EAmEA,WAAA;EAnE2B;EAqE3B,SAAA;AAAA;;;;;;;UASe,iBAAA;EACf,OAAA,SAAgB,YAAA;EAChB,MAAA;IACE,IAAA;IACA,SAAA;IACA,iBAAA,UArEF;IAuEE,SAAA;IACA,WAAA;IACA,OAAA,EAAS,MAAA;EAAA;AAAA;AA7Db;;;;;AAGA;;;;;AAHA,iBA2EgB,mBAAA,CACd,KAAA,EAAO,qBAAA,GACN,iBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: typeof A2UI_VERSION;\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: typeof A2UI_VERSION;\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: typeof A2UI_VERSION;\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | {\n version: typeof A2UI_VERSION;\n deleteSurface: { surfaceId: string };\n }\n | {\n version: typeof A2UI_VERSION;\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AAiKF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AA+DlD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/generative-ui/types.ts"],"sourcesContent":["/** A2UI protocol version used on the wire. */\nexport const A2UI_VERSION = \"1.0\";\n/** Activity type of a generated surface message. */\nexport const GENERATIVE_UI_ACTIVITY_TYPE = \"generative-ui-surface\";\n/** Activity type of a function call that the agent asks the client to run. */\nexport const GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE =\n \"generative-ui-function-call\";\n/** Tool the model calls to render or update surfaces. */\nexport const GENERATIVE_UI_RENDER_TOOL = \"render_ui\";\n/** Target id of the chat transcript. */\nexport const GENERATIVE_UI_CHAT_TARGET = \"chat\";\n/** Component id every surface renders from. */\nexport const GENERATIVE_UI_ROOT_ID = \"root\";\n/**\n * Whether the agent may call renderer functions with `callRendererFunction`.\n * Off for now: the result goes back as a developer message, and not every\n * backend keeps that message where the model reads it in order. While off,\n * the prompts do not mention the operation, the validator rejects it, and\n * the dispatcher refuses the agent, whatever a declaration's\n * `allowedCallers` says. The code and its tests stay for when it is on.\n */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS = false;\n/** The reason an agent function call is rejected while they are off. */\nexport const GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON =\n \"callRendererFunction is not supported in this version: the agent cannot call renderer functions until their results can be sent back to it reliably\";\n\n/** Activity message id of a surface. One message per surface. */\nexport function generativeUISurfaceMessageId(surfaceId: string) {\n return `genui:${surfaceId}`;\n}\n\n/**\n * Activity message id of an agent-called function. One message per\n * `functionCallId`.\n *\n * @param functionCallId - The `functionCallId` of the `callRendererFunction` operation.\n *\n * @example\n * ```ts\n * generativeUIFunctionCallMessageId(\"f1\"); // \"genui-fn:f1\"\n * ```\n */\nexport function generativeUIFunctionCallMessageId(functionCallId: string) {\n return `genui-fn:${functionCallId}`;\n}\n\nimport type {\n A2UIFunctionPermissions,\n A2UIFunctionReturnType,\n} from \"./basic-functions\";\n\n// Named `GenerativeUIJSONSchema` because the package root already exports a\n// `JSONSchema` (utils/json-schema.ts); the bare name would collide.\nexport type GenerativeUIJSONSchema = Record<string, unknown>;\n\nexport type A2UIComponentNode = {\n id: string;\n component: string;\n [prop: string]: unknown;\n};\n\n/**\n * The keys of the A2UI 1.0 component envelope next to `id` and\n * `component`: `catalogId`, `accessibility` and `metadata`. They are not\n * props of the component. The renderer reads `accessibility` and ignores\n * the other two.\n */\nexport const A2UI_COMPONENT_ENVELOPE_KEYS: ReadonlySet<string> = new Set([\n \"catalogId\",\n \"accessibility\",\n \"metadata\",\n]);\n\n/**\n * A call of a named function: `{ \"@call\": \"addToCart\", \"args\": { ... } }`.\n * Without `catalogId`, the function comes from the catalog of the run.\n */\nexport type A2UIFunctionCall = {\n \"@call\": string;\n args?: Record<string, unknown>;\n catalogId?: string;\n};\n\nexport type A2UIOperation =\n | {\n version: typeof A2UI_VERSION;\n createSurface: {\n surfaceId: string;\n /** Left out by the model. The run's catalog id is filled in. */\n catalogId?: string;\n /** Components to add at once, checked like `updateComponents`. */\n components?: A2UIComponentNode[];\n /** The initial root data model. */\n dataModel?: Record<string, unknown>;\n sendDataModel?: boolean;\n metadata?: { extensions?: Record<string, unknown> };\n };\n }\n | {\n version: typeof A2UI_VERSION;\n updateComponents: { surfaceId: string; components: A2UIComponentNode[] };\n }\n | {\n version: typeof A2UI_VERSION;\n /**\n * Sets `value` at `path`. A `null` value deletes the key at `path`.\n * With no `path`, or `\"/\"`, it sets the whole data model.\n */\n updateDataModel: { surfaceId: string; path?: string; value: unknown };\n }\n | {\n version: typeof A2UI_VERSION;\n deleteSurface: { surfaceId: string };\n }\n | {\n version: typeof A2UI_VERSION;\n /** Runs an app function in the browser, with no user interaction. */\n callRendererFunction: {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n };\n };\n\n/** Value of an event prop: run a host function, or report the event to the agent. */\nexport type GenerativeUIActionBinding =\n | {\n event: {\n name: string;\n /**\n * First line of the user message that the event becomes: text, a\n * data binding, or a function value such as formatString.\n */\n userMessage?: string | { \"@path\": string } | A2UIFunctionCall;\n context?: Record<string, unknown>;\n };\n }\n | { functionCall: A2UIFunctionCall };\n\nexport type GenerativeUISurfaceStatus = \"streaming\" | \"ready\" | \"error\";\n\nexport interface GenerativeUIRejectedOperation {\n /** Position of the operation in the render_ui call, or in the content list. */\n index: number;\n reason: string;\n}\n\n/** Content of a `generative-ui-surface` activity message. */\nexport interface GenerativeUISurfaceContent {\n surfaceId: string;\n target: string;\n catalogId: string;\n /** Committed (validated) operations, cumulative. */\n operations: A2UIOperation[];\n status: GenerativeUISurfaceStatus;\n rejected: GenerativeUIRejectedOperation[];\n /**\n * `\"0.9\"` when the runtime converted the surface from A2UI v0.9 operations,\n * so a user event on it goes back to the agent as a v0.9 action. Left out\n * for a surface that the agent wrote in 1.0.\n */\n a2uiSourceVersion?: \"0.9\";\n}\n\n/** Content of a `generative-ui-function-call` activity message. */\nexport interface GenerativeUIFunctionCallContent {\n functionCallId: string;\n callFunction: A2UIFunctionCall;\n}\n\n/**\n * Value of a \"multiple\" slot that repeats one component for each item of the\n * list at `path`. Paths inside the repeated component are relative to the item.\n */\nexport type GenerativeUITemplateChildren = {\n componentId: string;\n path: string;\n};\n\nexport interface GenerativeUIComponentManifest {\n /** CopilotKit positional order across model-visible props, slots and events.\n * Exporters encode this as JSON Schema property order; it is not an A2UI keyword. */\n parameterOrder?: readonly string[];\n description?: string;\n props: GenerativeUIJSONSchema;\n events?: Record<\n string,\n { description?: string; parameters: GenerativeUIJSONSchema }\n >;\n /**\n * Props that hold child components. A \"single\" slot takes one component id.\n * A \"multiple\" slot takes a `string[]` of component ids, or a\n * {@link GenerativeUITemplateChildren} template.\n */\n slots?: Record<string, \"single\" | \"multiple\">;\n}\n\nexport interface GenerativeUIFunctionManifest extends A2UIFunctionPermissions {\n description?: string;\n parameters: GenerativeUIJSONSchema;\n /** What the function gives back, as A2UI 1.0 names it. */\n returnType?: A2UIFunctionReturnType;\n}\n\n/** Serializable description of what the browser can render and call. */\nexport interface GenerativeUIManifest {\n /** The catalog of the run. A surface with no `catalogId` gets this one. */\n catalogId: string;\n /**\n * Every catalog that a `catalogId` can name: `catalogId` first, then the\n * catalogs of `extends`. Left out, only `catalogId`.\n */\n catalogIds?: string[];\n components: Record<string, GenerativeUIComponentManifest>;\n functions: Record<string, GenerativeUIFunctionManifest>;\n /**\n * Places where the model can render surfaces. Only mounted targets are\n * listed. `description` tells the model where the target is on the page\n * and what to put in it.\n */\n targets: GenerativeUITarget[];\n /** Surfaces the client already holds for the current thread. */\n surfaces: Record<string, GenerativeUISurfaceSummary>;\n}\n\n/** A place where the model can render surfaces. */\nexport interface GenerativeUITarget {\n id: string;\n kind: \"chat\" | \"inline\";\n description?: string;\n /**\n * The only components that the surfaces of this target can use, at most\n * {@link GENERATIVE_UI_MAX_TARGET_COMPONENTS} names. Left out, the target\n * takes every component of the catalog.\n */\n components?: string[];\n}\n\n/** Most component names that one target can list. */\nexport const GENERATIVE_UI_MAX_TARGET_COMPONENTS = 100;\n\n/** Most rejections that a surface summary lists. */\nexport const GENERATIVE_UI_MAX_SUMMARY_REJECTIONS = 20;\n/** Most characters of one rejection in a surface summary. */\nexport const GENERATIVE_UI_MAX_REJECTION_LENGTH = 500;\n\n/** One surface that the client holds, as the model sees it. */\nexport interface GenerativeUISurfaceSummary {\n target: string;\n /** The values that the user set, by path. Left out when there are none. */\n dataModel?: Record<string, unknown>;\n /**\n * Operations that the client dropped, as `\"operation <index>: <reason>\"`.\n * At most {@link GENERATIVE_UI_MAX_SUMMARY_REJECTIONS} entries of at most\n * {@link GENERATIVE_UI_MAX_REJECTION_LENGTH} characters. Left out when\n * there are none.\n */\n rejected?: string[];\n /**\n * Left out while the surface exists. `\"deleted\"`: a deleteSurface removed\n * it, and its id cannot be used again. `\"failed\"`: its createSurface was\n * rejected, so it does not exist; a corrected createSurface can use the id.\n */\n status?: \"deleted\" | \"failed\";\n /**\n * `\"0.9\"` when the runtime converted the surface from A2UI v0.9 (copied\n * from {@link GenerativeUISurfaceContent.a2uiSourceVersion}), so the\n * runtime sends a user event on it to the agent as a v0.9 action. Left out\n * for a surface that the agent wrote in 1.0.\n */\n a2uiSourceVersion?: \"0.9\";\n}\n\n/** A user interaction bound to `{ event }`, sent to the agent. */\nexport interface GenerativeUIUserEvent {\n name: string;\n surfaceId: string;\n componentId: string;\n context: Record<string, unknown>;\n /** The resolved `event.userMessage`: the first line of the user message. */\n userMessage?: string;\n /** When the user acted, as an ISO 8601 string. Filled in when left out. */\n timestamp?: string;\n}\n\n/**\n * The A2UI 1.0 action message of a user event: what a renderer sends to the\n * agent when the user triggers an `{ event }` action. The run that the\n * event starts carries it in the envelope (`copilotkit_action`), next to\n * the visible user message.\n */\nexport interface A2UIActionMessage {\n version: typeof A2UI_VERSION;\n action: {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n /** ISO 8601. */\n timestamp: string;\n userMessage?: string;\n context: Record<string, unknown>;\n };\n}\n\n/**\n * The action message of a user event, with the A2UI field names. Takes the\n * time of the call when the event has no timestamp.\n *\n * @example\n * ```ts\n * toA2UIActionMessage({ name: \"buy\", surfaceId: \"s1\", componentId: \"b\", context: { sku: \"a\" } });\n * // { version: \"1.0\", action: { name: \"buy\", surfaceId: \"s1\", sourceComponentId: \"b\", timestamp: \"2026-…\", context: { sku: \"a\" } } }\n * ```\n */\nexport function toA2UIActionMessage(\n event: GenerativeUIUserEvent,\n): A2UIActionMessage {\n return {\n version: A2UI_VERSION,\n action: {\n name: event.name,\n surfaceId: event.surfaceId,\n sourceComponentId: event.componentId,\n timestamp: event.timestamp ?? new Date().toISOString(),\n ...(event.userMessage === undefined\n ? {}\n : { userMessage: event.userMessage }),\n context: event.context,\n },\n };\n}\n"],"mappings":";;AACA,MAAa,eAAe;;AAE5B,MAAa,8BAA8B;;AAE3C,MAAa,4CACX;;AAEF,MAAa,4BAA4B;;AAEzC,MAAa,4BAA4B;;AAEzC,MAAa,wBAAwB;;;;;;;;;AASrC,MAAa,qCAAqC;;AAElD,MAAa,gDACX;;AAGF,SAAgB,6BAA6B,WAAmB;AAC9D,QAAO,SAAS;;;;;;;;;;;;;AAclB,SAAgB,kCAAkC,gBAAwB;AACxE,QAAO,YAAY;;;;;;;;AAwBrB,MAAa,+BAAoD,IAAI,IAAI;CACvE;CACA;CACA;CACD,CAAC;;AAuKF,MAAa,sCAAsC;;AAGnD,MAAa,uCAAuC;;AAEpD,MAAa,qCAAqC;;;;;;;;;;;AAsElD,SAAgB,oBACd,OACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ;GACN,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,mBAAmB,MAAM;GACzB,WAAW,MAAM,8BAAa,IAAI,MAAM,EAAC,aAAa;GACtD,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;GACtC,SAAS,MAAM;GAChB;EACF"}
|
package/dist/index.d.cts
CHANGED
|
@@ -21,7 +21,7 @@ import { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONS
|
|
|
21
21
|
import { InspectorMetadataV1, parseInspectorMetadataV1 } from "./utils/inspector-metadata.cjs";
|
|
22
22
|
import { InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorLearningTrajectoryEvidence, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl } from "./utils/inspector-learning.cjs";
|
|
23
23
|
import { InspectorVisibilityOptions, shouldEnableInspector, ɵINSPECTOR_LOOPBACK_HOSTS } from "./utils/inspector-visibility.cjs";
|
|
24
|
-
import {
|
|
24
|
+
import { AgentDescription, GenerativeUIRuntimeInfo, IntelligenceRuntimeInfo, MaybePromise, NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SingleRouteRuntimeInfo, ThreadEndpointRuntimeInfo } from "./utils/types.cjs";
|
|
25
25
|
import { randomId, randomUUID } from "./utils/random-id.cjs";
|
|
26
26
|
import { processEnv } from "./utils/process-env.cjs";
|
|
27
27
|
import { readBody } from "./utils/requests.cjs";
|
|
@@ -78,5 +78,5 @@ interface LicenseContextValue {
|
|
|
78
78
|
*/
|
|
79
79
|
declare function createLicenseContextValue(status: RuntimeLicenseStatus | null | undefined, runtimeEntitlements?: RuntimeEntitlementResponse): LicenseContextValue;
|
|
80
80
|
//#endregion
|
|
81
|
-
export { A2UIActionMessage, A2UIAllowedCallers, A2UIBasicFunctionInfo, A2UIComponentNode, A2UIFunctionCall, A2UIFunctionPermissions, A2UIFunctionReturnType, A2UIOperation,
|
|
81
|
+
export { A2UIActionMessage, A2UIAllowedCallers, A2UIBasicFunctionInfo, A2UIComponentNode, A2UIFunctionCall, A2UIFunctionPermissions, A2UIFunctionReturnType, A2UIOperation, A2UIValidationResult, A2UIValidationSeverity, A2UI_BASIC_FUNCTIONS, A2UI_CHILD_LIST_MARK, A2UI_CHILD_LIST_REF, A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_COMPONENT_ID_MARK, A2UI_COMPONENT_ID_REF, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, A2UI_INDEX_FUNCTION, A2UI_VERSION, AG_UI_CHANNEL_EVENT, AIMessage, ALL_GENERATIVE_UI_GUIDE_FEATURES, Action, ActivityMessage, AgentDescription, AllowedComponents, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, COPILOTKIT_FORWARDED_PROPS_KEY, COPILOTKIT_FUNCTIONS, COPILOTKIT_UI_ENVELOPE_FORMAT, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, ChildRef, ChildRefKind, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ConfigurationError, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitErrorExtensions, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, type CopilotKitUIEnvelope, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, type DebugEventEnvelope, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExtractedRenderUIArgs, type FinalizeRunOptions, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, GENERATE_SANDBOXED_UI_DESCRIPTION, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_AGENT_FUNCTION_CALLS, GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_CONTEXT_DESCRIPTION, GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_MARKDOWN_GUIDELINES, GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION, GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION, GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW, GENERATIVE_UI_MAX_REJECTION_LENGTH, GENERATIVE_UI_MAX_SUMMARY_REJECTIONS, GENERATIVE_UI_MAX_TARGET_COMPONENTS, GENERATIVE_UI_RENDER_TOOL, GENERATIVE_UI_ROOT_ID, GENERATIVE_UI_WHEN_TO_SHOW, GUIDE_COMPONENTS, GenerativeUIActionBinding, GenerativeUIComponentManifest, GenerativeUIFunctionCallContent, GenerativeUIFunctionManifest, type GenerativeUIGuideFeatures, GenerativeUIJSONSchema, GenerativeUIManifest, GenerativeUIPromptFeature, GenerativeUIPromptFeatures, GenerativeUIPromptItem, GenerativeUIPromptSection, GenerativeUIPromptSpec, GenerativeUIRejectedOperation, GenerativeUIRuntimeInfo, GenerativeUISchemaSettings, GenerativeUISurfaceContent, GenerativeUISurfaceStatus, GenerativeUISurfaceSummary, GenerativeUITarget, GenerativeUITemplateChildren, GenerativeUIUserEvent, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorLearningTrajectoryEvidence, InspectorMetadataV1, InspectorVisibilityOptions, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LambdaSendOptions, type LicenseChecker, LicenseContextValue, type LicenseFeatures, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, MODEL_HOST_CLASSES, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, ModelHostClass, NonEmptyRecord, OperationKind, OperationValidation, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RenderUIArgsStream, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, RowKeyStore, type RunEventFinalizer, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SamplingMeta, Severity, SingleRouteRuntimeInfo, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, THREAD_ALREADY_RUNNING_ERROR_CODE, TelemetryEmitter, TelemetrySurface, TelemetryTransport, TextInputPart, ThreadEndpointRuntimeInfo, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UNSAMPLED_RATE, UpgradeRequiredError, UserMessage, ValidateOperationOptions, VideoInputPart, actionParametersToJsonSchema, applyChildRefMarks, applyDescriptionOverrides, buildCompactGenerativeUISchema, buildGenerativeUIMarkdownGuidelines, buildGenerativeUIPrompt, callerProblem, childIdsAtRefs, childRefKind, classifyModelHost, cloneValue, collectChildRefs, commitRowKeyStore, computeSamplingMeta, copyToClipboard, createAttachmentContent, createLicenseContextValue, createRowKeyStore, createRunEventFinalizer, defaultGenerativeUIPromptSpec, ensureStructuredError, envelopeToManifest, exceedsMaxSize, extractRenderUIArgs, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, functionCallers, generateVideoThumbnail, generativeUIFunctionCallMessageId, generativeUIGuideFeatures, generativeUIPromptFeatures, generativeUISurfaceMessageId, getDocumentIcon, getModalityFromMimeType, getOperationKind, getOperationSurfaceId, getSourceUrl, hasBoundChildRef, isA2UIBasicFunction, isA2UIValueFunction, isActionBinding, isCallBinding, isIndexCall, isMacOS, isPathBinding, isStructuredCopilotKitError, isTelemetryDisabled, isValidationResult, jsonSchemaToActionParameters, lambdaClient, logger, mapAtChildRef, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, processEnv, pruneRowKeyStore, randomId, randomUUID, readBody, readCopilotKitUIEnvelope, readFileAsBase64, renderGenerativeUIComponentList, renderGenerativeUISchema, resolveDebugConfig, resolveRowRenderKeys, resolveRowRenderKeysById, safeParseToolArgs, schemaCoverage, schemaToJsonSchema, selectPromptItems, shouldEnableInspector, stripIntelligenceRoutingFields, toA2UIActionMessage, tryMap, validateOperation, ɵINSPECTOR_LOOPBACK_HOSTS, ɵanySchema };
|
|
82
82
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -21,7 +21,7 @@ import { JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONS
|
|
|
21
21
|
import { InspectorMetadataV1, parseInspectorMetadataV1 } from "./utils/inspector-metadata.mjs";
|
|
22
22
|
import { InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorLearningTrajectoryEvidence, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl } from "./utils/inspector-learning.mjs";
|
|
23
23
|
import { InspectorVisibilityOptions, shouldEnableInspector, ɵINSPECTOR_LOOPBACK_HOSTS } from "./utils/inspector-visibility.mjs";
|
|
24
|
-
import {
|
|
24
|
+
import { AgentDescription, GenerativeUIRuntimeInfo, IntelligenceRuntimeInfo, MaybePromise, NonEmptyRecord, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SingleRouteRuntimeInfo, ThreadEndpointRuntimeInfo } from "./utils/types.mjs";
|
|
25
25
|
import { randomId, randomUUID } from "./utils/random-id.mjs";
|
|
26
26
|
import { processEnv } from "./utils/process-env.mjs";
|
|
27
27
|
import { readBody } from "./utils/requests.mjs";
|
|
@@ -78,5 +78,5 @@ interface LicenseContextValue {
|
|
|
78
78
|
*/
|
|
79
79
|
declare function createLicenseContextValue(status: RuntimeLicenseStatus | null | undefined, runtimeEntitlements?: RuntimeEntitlementResponse): LicenseContextValue;
|
|
80
80
|
//#endregion
|
|
81
|
-
export { A2UIActionMessage, A2UIAllowedCallers, A2UIBasicFunctionInfo, A2UIComponentNode, A2UIFunctionCall, A2UIFunctionPermissions, A2UIFunctionReturnType, A2UIOperation,
|
|
81
|
+
export { A2UIActionMessage, A2UIAllowedCallers, A2UIBasicFunctionInfo, A2UIComponentNode, A2UIFunctionCall, A2UIFunctionPermissions, A2UIFunctionReturnType, A2UIOperation, A2UIValidationResult, A2UIValidationSeverity, A2UI_BASIC_FUNCTIONS, A2UI_CHILD_LIST_MARK, A2UI_CHILD_LIST_REF, A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_COMPONENT_ID_MARK, A2UI_COMPONENT_ID_REF, A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, A2UI_INDEX_FUNCTION, A2UI_VERSION, AG_UI_CHANNEL_EVENT, AIMessage, ALL_GENERATIVE_UI_GUIDE_FEATURES, Action, ActivityMessage, AgentDescription, AllowedComponents, AssistantMessage, Attachment, AttachmentModality, AttachmentUploadError, AttachmentUploadErrorReason, AttachmentUploadResult, AttachmentsConfig, AudioInputPart, BANNER_ERROR_NAMES, COPILOTKIT_FORWARDED_PROPS_KEY, COPILOTKIT_FUNCTIONS, COPILOTKIT_UI_ENVELOPE_FORMAT, COPILOTKIT_VERSION, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_ERROR_NAMES, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, COPILOT_CLOUD_VERSION, ChildRef, ChildRefKind, CoAgentStateRenderHandler, CoAgentStateRenderHandlerArguments, ConfigurationError, CopilotCloudConfig, CopilotErrorEvent, CopilotErrorHandler, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitErrorExtensions, CopilotKitLowLevelError, CopilotKitMisuseError, CopilotKitRemoteEndpointDiscoveryError, type CopilotKitUIEnvelope, CopilotRequestContext, DEFAULT_AGENT_ID, DebugConfig, type DebugEventEnvelope, DeveloperMessage, DocumentInputPart, ERROR_CONFIG, ERROR_NAMES, ErrorVisibility, ExtractedRenderUIArgs, type FinalizeRunOptions, FunctionCallHandler, FunctionCallHandlerArguments, FunctionDefinition, GENERATE_SANDBOXED_UI_DESCRIPTION, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_AGENT_FUNCTION_CALLS, GENERATIVE_UI_AGENT_FUNCTION_CALLS_OFF_REASON, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_CONTEXT_DESCRIPTION, GENERATIVE_UI_DEFAULT_ALLOWED_CALLERS, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_MARKDOWN_GUIDELINES, GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION, GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION, GENERATIVE_UI_MARKDOWN_WHEN_TO_SHOW, GENERATIVE_UI_MAX_REJECTION_LENGTH, GENERATIVE_UI_MAX_SUMMARY_REJECTIONS, GENERATIVE_UI_MAX_TARGET_COMPONENTS, GENERATIVE_UI_RENDER_TOOL, GENERATIVE_UI_ROOT_ID, GENERATIVE_UI_WHEN_TO_SHOW, GUIDE_COMPONENTS, GenerativeUIActionBinding, GenerativeUIComponentManifest, GenerativeUIFunctionCallContent, GenerativeUIFunctionManifest, type GenerativeUIGuideFeatures, GenerativeUIJSONSchema, GenerativeUIManifest, GenerativeUIPromptFeature, GenerativeUIPromptFeatures, GenerativeUIPromptItem, GenerativeUIPromptSection, GenerativeUIPromptSpec, GenerativeUIRejectedOperation, GenerativeUIRuntimeInfo, GenerativeUISchemaSettings, GenerativeUISurfaceContent, GenerativeUISurfaceStatus, GenerativeUISurfaceSummary, GenerativeUITarget, GenerativeUITemplateChildren, GenerativeUIUserEvent, ImageInputPart, InferSchemaOutput, InputContent, InputContentDataSource, InputContentSource, InputContentUrlSource, InspectorLearningEvidence, InspectorLearningInsight, InspectorLearningPage, InspectorLearningRequestV1, InspectorLearningSkill, InspectorLearningSnapshotV1, InspectorLearningTrajectoryEvidence, InspectorMetadataV1, InspectorVisibilityOptions, IntelligenceRuntimeInfo, JSONSchema, JSONSchemaArray, JSONSchemaBoolean, JSONSchemaNumber, JSONSchemaObject, JSONSchemaString, JSONValue, type LambdaSendOptions, type LicenseChecker, LicenseContextValue, type LicenseFeatures, type LicenseOwner, type LicensePayload, type LicenseStatus, type LicenseTier, MODEL_HOST_CLASSES, MappedParameterTypes, MaybePromise, Message, MissingPublicApiKeyError, ModelHostClass, NonEmptyRecord, OperationKind, OperationValidation, Parameter, PartialBy, RUNTIME_MODE_INTELLIGENCE, RUNTIME_MODE_SSE, ReasoningMessage, RenderUIArgsStream, RequiredBy, ResolvedCopilotKitError, ResolvedDebugConfig, Role, RowKeyStore, type RunEventFinalizer, RuntimeEntitlementResponse, RuntimeInfo, RuntimeLicenseStatus, RuntimeMode, SamplingMeta, Severity, SingleRouteRuntimeInfo, StandardJSONSchemaV1, StandardSchemaV1, SystemMessage, TELEMETRY_EMITTER_V1, TELEMETRY_EMITTER_V2, TELEMETRY_SURFACE_V1, TELEMETRY_SURFACE_V2, THREAD_ALREADY_RUNNING_ERROR_CODE, TelemetryEmitter, TelemetrySurface, TelemetryTransport, TextInputPart, ThreadEndpointRuntimeInfo, ToolCall, ToolDefinition, ToolResult, TranscriptionErrorCode, type TranscriptionErrorResponse, TranscriptionErrors, UNSAMPLED_RATE, UpgradeRequiredError, UserMessage, ValidateOperationOptions, VideoInputPart, actionParametersToJsonSchema, applyChildRefMarks, applyDescriptionOverrides, buildCompactGenerativeUISchema, buildGenerativeUIMarkdownGuidelines, buildGenerativeUIPrompt, callerProblem, childIdsAtRefs, childRefKind, classifyModelHost, cloneValue, collectChildRefs, commitRowKeyStore, computeSamplingMeta, copyToClipboard, createAttachmentContent, createLicenseContextValue, createRowKeyStore, createRunEventFinalizer, defaultGenerativeUIPromptSpec, ensureStructuredError, envelopeToManifest, exceedsMaxSize, extractRenderUIArgs, finalizeRunEvents, firstNonBlankTelemetryId, formatFileSize, functionCallers, generateVideoThumbnail, generativeUIFunctionCallMessageId, generativeUIGuideFeatures, generativeUIPromptFeatures, generativeUISurfaceMessageId, getDocumentIcon, getModalityFromMimeType, getOperationKind, getOperationSurfaceId, getSourceUrl, hasBoundChildRef, isA2UIBasicFunction, isA2UIValueFunction, isActionBinding, isCallBinding, isIndexCall, isMacOS, isPathBinding, isStructuredCopilotKitError, isTelemetryDisabled, isValidationResult, jsonSchemaToActionParameters, lambdaClient, logger, mapAtChildRef, matchesAcceptFilter, parseAndWarnTelemetryId, parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1, parseInspectorLearningUrl, parseInspectorMetadataV1, parseJson, parseTelemetryIdFromLicense, partialJSONParse, phoenixExponentialBackoff, processEnv, pruneRowKeyStore, randomId, randomUUID, readBody, readCopilotKitUIEnvelope, readFileAsBase64, renderGenerativeUIComponentList, renderGenerativeUISchema, resolveDebugConfig, resolveRowRenderKeys, resolveRowRenderKeysById, safeParseToolArgs, schemaCoverage, schemaToJsonSchema, selectPromptItems, shouldEnableInspector, stripIntelligenceRoutingFields, toA2UIActionMessage, tryMap, validateOperation, ɵINSPECTOR_LOOPBACK_HOSTS, ɵanySchema };
|
|
82
82
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.umd.js
CHANGED
|
@@ -2166,7 +2166,7 @@ ${getSeeMoreMarkdown(troubleshootingLink)}`;
|
|
|
2166
2166
|
|
|
2167
2167
|
//#endregion
|
|
2168
2168
|
//#region package.json
|
|
2169
|
-
var version = "2.0.0-rc.
|
|
2169
|
+
var version = "2.0.0-rc.44";
|
|
2170
2170
|
|
|
2171
2171
|
//#endregion
|
|
2172
2172
|
//#region src/generative-ui/basic-functions.ts
|
|
@@ -3071,7 +3071,7 @@ Use the SAME surfaceId as the main surface. Match action names to button action
|
|
|
3071
3071
|
return Array.isArray(value) && value.length <= GENERATIVE_UI_MAX_SUMMARY_REJECTIONS && value.every((entry) => typeof entry === "string" && entry.length <= GENERATIVE_UI_MAX_REJECTION_LENGTH);
|
|
3072
3072
|
}
|
|
3073
3073
|
function isSurfaceEntry(value) {
|
|
3074
|
-
return isRecord$2(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || isRecord$2(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed");
|
|
3074
|
+
return isRecord$2(value) && isNonEmptyString(value.target) && (value.dataModel === void 0 || isRecord$2(value.dataModel)) && (value.rejected === void 0 || isRejectionList(value.rejected)) && (value.status === void 0 || value.status === "deleted" || value.status === "failed") && (value.a2uiSourceVersion === void 0 || value.a2uiSourceVersion === "0.9");
|
|
3075
3075
|
}
|
|
3076
3076
|
/** Checks the `copilotkit_` keys only. Other extensions can be there too. */
|
|
3077
3077
|
function isExtensions(value) {
|