@copilotkit/runtime 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/agent/converters/aisdk.cjs +1 -1
- package/dist/agent/converters/aisdk.mjs +1 -1
- package/dist/agent/converters/tanstack.cjs +1 -1
- package/dist/agent/converters/tanstack.mjs +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +3 -2
- package/dist/runtime/core/package-info.cjs +1 -1
- package/dist/runtime/core/package-info.mjs +1 -1
- package/dist/runtime/core/runtime.cjs +1 -19
- package/dist/runtime/core/runtime.cjs.map +1 -1
- package/dist/runtime/core/runtime.d.cts +77 -29
- package/dist/runtime/core/runtime.d.cts.map +1 -1
- package/dist/runtime/core/runtime.d.mts +77 -29
- package/dist/runtime/core/runtime.d.mts.map +1 -1
- package/dist/runtime/core/runtime.mjs +2 -19
- package/dist/runtime/core/runtime.mjs.map +1 -1
- package/dist/runtime/event-transforms/recorded-events.cjs +4 -0
- package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -1
- package/dist/runtime/event-transforms/recorded-events.d.cts +5 -1
- package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -1
- package/dist/runtime/event-transforms/recorded-events.d.mts +5 -1
- package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -1
- package/dist/runtime/event-transforms/recorded-events.mjs +4 -0
- package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -1
- package/dist/runtime/generative-ui/a2ui-v09-actions.cjs +106 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.mjs +106 -0
- package/dist/runtime/generative-ui/a2ui-v09-actions.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs +422 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs +422 -0
- package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs +84 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts +41 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts +41 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs +83 -0
- package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.cjs +620 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.cjs.map +1 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.mjs +620 -0
- package/dist/runtime/generative-ui/a2ui-v09-operations.mjs.map +1 -0
- package/dist/runtime/generative-ui/index.d.cts +1 -0
- package/dist/runtime/generative-ui/index.d.mts +1 -0
- package/dist/runtime/handlers/get-runtime-info.cjs +19 -5
- package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/runtime/handlers/get-runtime-info.mjs +20 -6
- package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/runtime/handlers/handle-run.cjs +0 -2
- package/dist/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/runtime/handlers/handle-run.mjs +0 -2
- package/dist/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/runtime/handlers/shared/agent-utils.cjs +17 -14
- package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/runtime/handlers/shared/agent-utils.mjs +18 -15
- package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/runtime/index.d.cts +2 -1
- package/dist/runtime/index.d.mts +2 -1
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2ui-v09-actions.mjs","names":[],"sources":["../../../src/runtime/generative-ui/a2ui-v09-actions.ts"],"sourcesContent":["import type { Message, RunAgentInput } from \"@ag-ui/client\";\nimport {\n GENERATIVE_UI_ACTIVITY_TYPE,\n readCopilotKitUIEnvelope,\n} from \"@copilotkit/shared\";\nimport type { CopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport { isRecord } from \"../../agent/converters/usage\";\n\n/**\n * The A2UI v0.9 user action, as the v0.9 client sent it in\n * `forwardedProps.a2uiAction.userAction`. `@ag-ui/a2ui-middleware`,\n * `@ag-ui/a2a` and the CopilotKit runtimes in other languages read this shape.\n */\ninterface A2UIV09UserAction {\n name: string;\n surfaceId: string;\n sourceComponentId: string;\n context: Record<string, unknown>;\n timestamp: string;\n}\n\nexport interface DowngradeA2UIV09ActionOptions {\n /**\n * The A2UI version the agent speaks. Used only when neither the envelope\n * summary nor `input.messages` knows the clicked surface.\n */\n agentVersion?: \"0.9\" | \"1.0\";\n}\n\n/** The 1.0 action of the user event that started the run, if one did. */\nfunction readAction(\n envelope: CopilotKitUIEnvelope | undefined,\n): A2UIV09UserAction | undefined {\n const message: unknown = envelope?.metadata.extensions.copilotkit_action;\n if (!isRecord(message) || !isRecord(message.action)) return undefined;\n const { name, surfaceId, sourceComponentId, context, timestamp } =\n message.action;\n if (typeof name !== \"string\" || typeof surfaceId !== \"string\") {\n return undefined;\n }\n return {\n name,\n surfaceId,\n sourceComponentId:\n typeof sourceComponentId === \"string\" ? sourceComponentId : \"\",\n context: isRecord(context) ? context : {},\n timestamp:\n typeof timestamp === \"string\" ? timestamp : new Date().toISOString(),\n };\n}\n\n/**\n * True when the surface was converted from A2UI v0.9. The first of these\n * that knows the surface decides:\n * 1. The summary of the surface in the envelope (`copilotkit_surfaces`).\n * 2. The last `generative-ui-surface` activity message of the surface.\n * 3. `agentVersion`.\n */\nfunction isV09Surface(\n surfaces: CopilotKitUIEnvelope[\"metadata\"][\"extensions\"][\"copilotkit_surfaces\"],\n messages: readonly Message[],\n surfaceId: string,\n agentVersion: DowngradeA2UIV09ActionOptions[\"agentVersion\"],\n) {\n // `readCopilotKitUIEnvelope` checked the summary, so the tag is \"0.9\" or\n // left out. An own-key check: the ids come from the client.\n if (Object.hasOwn(surfaces, surfaceId)) {\n return surfaces[surfaceId].a2uiSourceVersion === \"0.9\";\n }\n const surface = messages.findLast(\n (message) =>\n message.role === \"activity\" &&\n message.activityType === GENERATIVE_UI_ACTIVITY_TYPE &&\n isRecord(message.content) &&\n message.content.surfaceId === surfaceId,\n );\n if (!surface) return agentVersion === \"0.9\";\n // `a2uiSourceVersion` is set by the runtime on surfaces it converted from\n // v0.9. Read it untyped: not every surface content has it.\n const content = (surface as { content?: { a2uiSourceVersion?: unknown } })\n .content;\n return content?.a2uiSourceVersion === \"0.9\";\n}\n\n/**\n * Removes the visible user message that the 1.0 client added for the click.\n * The client adds it just before the run, so it is the last message.\n */\nfunction withoutActionUserMessage(messages: Message[]) {\n const last = messages.at(-1);\n if (last?.role !== \"user\" || typeof last.content !== \"string\") {\n return messages;\n }\n return messages.slice(0, -1);\n}\n\n/**\n * Turns a click on a surface that the runtime converted from A2UI v0.9 into\n * the v0.9 action that the agent side expects.\n *\n * The 1.0 client sends a click as a visible user message plus\n * `forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_action`. A v0.9\n * agent stack reads `forwardedProps.a2uiAction.userAction` instead. When the\n * run carries a 1.0 action for a surface of v0.9 origin, this returns a new\n * input with `forwardedProps.a2uiAction` set and the visible user message\n * removed. Otherwise it returns `input` unchanged. It never mutates `input`.\n *\n * The visible user message is removed because the v0.9 consumers already\n * turn `a2uiAction` into what the agent sees:\n * - `@ag-ui/a2ui-middleware` appends the action as a private user message,\n * `A2UI user action:` and the action JSON. The Python, Go, Ruby and .NET\n * runtimes append a synthetic `log_a2ui_event` tool call and result, and\n * prompt the model to answer them when they end the conversation. With\n * the visible message kept, the model sees the click twice, and the\n * conversation no longer ends with the action.\n * - `@ag-ui/a2a` attaches `a2uiAction` as a data part to the latest user\n * message, and A2A agents read the data part first.\n * The v0.9 client sent no user message for a click, so with it removed the\n * agent gets the same input as it did from the v0.9 client. The 1.0 client\n * still shows the message in its chat.\n *\n * Origin: the first of these that knows the clicked surface decides.\n * 1. Its summary in the envelope\n * (`forwardedProps.copilotkit.ui.metadata.extensions.copilotkit_surfaces`):\n * `a2uiSourceVersion === \"0.9\"` means v0.9 origin, left out means 1.0. The\n * 1.0 client copies the tag from the surface's activity content, so this\n * is what decides for runs from the 1.0 client.\n * 2. The last `generative-ui-surface` activity message for the surface in\n * `input.messages` (`a2uiSourceVersion === \"0.9\"`), for a caller that\n * passes activity messages.\n * 3. `options.agentVersion === \"0.9\"`.\n *\n * @param input - The run input from the 1.0 client.\n * @param options - `agentVersion`: the fallback when the surface is unknown.\n *\n * @example\n * ```ts\n * const agentInput = downgradeA2UIV09Action(input, { agentVersion: \"0.9\" });\n * // agentInput.forwardedProps.a2uiAction.userAction:\n * // { name, surfaceId, sourceComponentId, context, timestamp }\n * ```\n */\nexport function downgradeA2UIV09Action(\n input: RunAgentInput,\n options: DowngradeA2UIV09ActionOptions = {},\n): RunAgentInput {\n const forwardedProps: unknown = input.forwardedProps;\n // A run that already has a v0.9 action keeps it.\n if (!isRecord(forwardedProps) || forwardedProps.a2uiAction !== undefined) {\n return input;\n }\n const envelope = readCopilotKitUIEnvelope(forwardedProps);\n const userAction = readAction(envelope);\n if (!envelope || !userAction) return input;\n if (\n !isV09Surface(\n envelope.metadata.extensions.copilotkit_surfaces,\n input.messages,\n userAction.surfaceId,\n options.agentVersion,\n )\n ) {\n return input;\n }\n return {\n ...input,\n messages: withoutActionUserMessage(input.messages),\n forwardedProps: { ...forwardedProps, a2uiAction: { userAction } },\n };\n}\n"],"mappings":";;;;;AA8BA,SAAS,WACP,UAC+B;CAC/B,MAAM,UAAmB,UAAU,SAAS,WAAW;AACvD,KAAI,CAAC,SAAS,QAA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yB,MAAM,SAAS;EAClD,gBAAgB;GAAE,GAAG;GAAgB,YAAY,EAAE,YAAY;GAAE;EAClE"}
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
let _copilotkit_shared = require("@copilotkit/shared");
|
|
2
|
+
let _ag_ui_a2ui_middleware = require("@ag-ui/a2ui-middleware");
|
|
3
|
+
let _copilotkit_shared_generative_ui = require("@copilotkit/shared/generative-ui");
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/generative-ui/a2ui-v09-catalog.ts
|
|
6
|
+
/** Id of the A2UI v0.9 basic catalog. */
|
|
7
|
+
const A2UI_V09_BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/basic_catalog.json";
|
|
8
|
+
const CAPABILITIES_CONTEXT_DESCRIPTION = "A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.";
|
|
9
|
+
const GENERATION_GUIDELINES_CONTEXT_DESCRIPTION = "A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.";
|
|
10
|
+
const DESIGN_GUIDELINES_CONTEXT_DESCRIPTION = "A2UI design guidelines — visual design rules, component hierarchy tips, and action handler patterns.";
|
|
11
|
+
/** The components of the v0.9 basic catalog. The 1.0 standard catalog has each of them. */
|
|
12
|
+
const V09_BASIC_COMPONENTS = new Set([
|
|
13
|
+
"Text",
|
|
14
|
+
"Image",
|
|
15
|
+
"Icon",
|
|
16
|
+
"Video",
|
|
17
|
+
"AudioPlayer",
|
|
18
|
+
"Row",
|
|
19
|
+
"Column",
|
|
20
|
+
"List",
|
|
21
|
+
"Card",
|
|
22
|
+
"Tabs",
|
|
23
|
+
"Modal",
|
|
24
|
+
"Divider",
|
|
25
|
+
"Button",
|
|
26
|
+
"TextField",
|
|
27
|
+
"CheckBox",
|
|
28
|
+
"ChoicePicker",
|
|
29
|
+
"Slider",
|
|
30
|
+
"DateTimeInput"
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* The props (and events and slots) of standard components that v0.9 names
|
|
34
|
+
* differently: component → 1.0 name → v0.9 name. Every other prop has the
|
|
35
|
+
* same name in both versions.
|
|
36
|
+
*/
|
|
37
|
+
const V10_TO_V09_PROP_NAMES = { Button: { onClick: "action" } };
|
|
38
|
+
const COMMON = "common_types.json#/$defs/";
|
|
39
|
+
const ref = (name) => ({ $ref: `${COMMON}${name}` });
|
|
40
|
+
/**
|
|
41
|
+
* The v0.9 common types the schemas reference, in their v0.9 shapes, so
|
|
42
|
+
* every `common_types.json#/$defs/<Name>` ref resolves within the payload.
|
|
43
|
+
*/
|
|
44
|
+
const V09_COMMON_TYPES = {
|
|
45
|
+
ComponentId: {
|
|
46
|
+
type: "string",
|
|
47
|
+
description: "The unique identifier for a component, used for both definitions and references within the same surface."
|
|
48
|
+
},
|
|
49
|
+
ComponentCommon: {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
id: ref("ComponentId"),
|
|
53
|
+
accessibility: ref("AccessibilityAttributes")
|
|
54
|
+
},
|
|
55
|
+
required: ["id"]
|
|
56
|
+
},
|
|
57
|
+
AccessibilityAttributes: {
|
|
58
|
+
type: "object",
|
|
59
|
+
description: "Attributes to enhance accessibility when using assistive technologies like screen readers.",
|
|
60
|
+
properties: {
|
|
61
|
+
label: ref("DynamicString"),
|
|
62
|
+
description: ref("DynamicString")
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
ChildList: { oneOf: [{
|
|
66
|
+
type: "array",
|
|
67
|
+
items: ref("ComponentId"),
|
|
68
|
+
description: "A static list of child component IDs."
|
|
69
|
+
}, {
|
|
70
|
+
type: "object",
|
|
71
|
+
description: "A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.",
|
|
72
|
+
properties: {
|
|
73
|
+
componentId: ref("ComponentId"),
|
|
74
|
+
path: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "The path to the list of component property objects in the data model."
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
required: ["componentId", "path"],
|
|
80
|
+
additionalProperties: false
|
|
81
|
+
}] },
|
|
82
|
+
DataBinding: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: { path: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "A JSON Pointer path to a value in the data model."
|
|
87
|
+
} },
|
|
88
|
+
required: ["path"],
|
|
89
|
+
additionalProperties: false
|
|
90
|
+
},
|
|
91
|
+
FunctionCall: {
|
|
92
|
+
type: "object",
|
|
93
|
+
description: "Invokes a named function on the client.",
|
|
94
|
+
properties: {
|
|
95
|
+
call: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "The name of the function to call."
|
|
98
|
+
},
|
|
99
|
+
args: {
|
|
100
|
+
type: "object",
|
|
101
|
+
description: "Arguments passed to the function.",
|
|
102
|
+
additionalProperties: ref("DynamicValue")
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
required: ["call"],
|
|
106
|
+
additionalProperties: false
|
|
107
|
+
},
|
|
108
|
+
DynamicValue: {
|
|
109
|
+
description: "A value that can be a literal, a path, or a function call returning any type.",
|
|
110
|
+
anyOf: [
|
|
111
|
+
{ type: "string" },
|
|
112
|
+
{ type: "number" },
|
|
113
|
+
{ type: "boolean" },
|
|
114
|
+
{ type: "array" },
|
|
115
|
+
ref("DataBinding"),
|
|
116
|
+
ref("FunctionCall")
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
DynamicString: { anyOf: [
|
|
120
|
+
{ type: "string" },
|
|
121
|
+
ref("DataBinding"),
|
|
122
|
+
ref("FunctionCall")
|
|
123
|
+
] },
|
|
124
|
+
DynamicNumber: { anyOf: [
|
|
125
|
+
{ type: "number" },
|
|
126
|
+
ref("DataBinding"),
|
|
127
|
+
ref("FunctionCall")
|
|
128
|
+
] },
|
|
129
|
+
DynamicBoolean: { anyOf: [
|
|
130
|
+
{ type: "boolean" },
|
|
131
|
+
ref("DataBinding"),
|
|
132
|
+
ref("FunctionCall")
|
|
133
|
+
] },
|
|
134
|
+
DynamicStringList: { anyOf: [
|
|
135
|
+
{
|
|
136
|
+
type: "array",
|
|
137
|
+
items: { type: "string" }
|
|
138
|
+
},
|
|
139
|
+
ref("DataBinding"),
|
|
140
|
+
ref("FunctionCall")
|
|
141
|
+
] },
|
|
142
|
+
Action: {
|
|
143
|
+
description: "Defines an interaction handler that can either trigger a server-side event or execute a local client-side function.",
|
|
144
|
+
oneOf: [{
|
|
145
|
+
type: "object",
|
|
146
|
+
description: "Triggers a server-side event.",
|
|
147
|
+
properties: { event: {
|
|
148
|
+
type: "object",
|
|
149
|
+
properties: {
|
|
150
|
+
name: {
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "The name of the action to be dispatched to the server."
|
|
153
|
+
},
|
|
154
|
+
context: {
|
|
155
|
+
type: "object",
|
|
156
|
+
description: "A JSON object containing the key-value pairs for the action context. Values can be literals or paths.",
|
|
157
|
+
additionalProperties: ref("DynamicValue")
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
required: ["name"],
|
|
161
|
+
additionalProperties: false
|
|
162
|
+
} },
|
|
163
|
+
required: ["event"],
|
|
164
|
+
additionalProperties: false
|
|
165
|
+
}, {
|
|
166
|
+
type: "object",
|
|
167
|
+
description: "Executes a local client-side function.",
|
|
168
|
+
properties: { functionCall: ref("FunctionCall") },
|
|
169
|
+
required: ["functionCall"],
|
|
170
|
+
additionalProperties: false
|
|
171
|
+
}]
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
function isRecord(value) {
|
|
175
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
176
|
+
}
|
|
177
|
+
/** 1.0 binding and call syntax in a description, written the v0.9 way. */
|
|
178
|
+
function v09Text(text) {
|
|
179
|
+
return text.replaceAll("\"@path\"", "\"path\"").replaceAll("\"@call\"", "\"call\"");
|
|
180
|
+
}
|
|
181
|
+
/** The v0.9 dynamic type of a literal schema that is just a primitive type. */
|
|
182
|
+
const DYNAMIC_TYPES = {
|
|
183
|
+
string: "DynamicString",
|
|
184
|
+
number: "DynamicNumber",
|
|
185
|
+
boolean: "DynamicBoolean"
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* A prop value as v0.9 states it: its literal schema, a `{ path }` binding
|
|
189
|
+
* or a `{ call }` function call. A plain string, number, boolean or string
|
|
190
|
+
* list is the v0.9 `Dynamic*` type of the same meaning. A component
|
|
191
|
+
* reference stays one.
|
|
192
|
+
*
|
|
193
|
+
* Only the prop itself is made dynamic, as in the v0.9 basic catalog: the
|
|
194
|
+
* 1.0 catalog marks every nested value dynamic too, which makes the
|
|
195
|
+
* standard catalog several times larger.
|
|
196
|
+
*/
|
|
197
|
+
function dynamicValue(schema) {
|
|
198
|
+
if (!isRecord(schema)) return ref("DynamicValue");
|
|
199
|
+
const v09 = v09Schema(schema);
|
|
200
|
+
if ((0, _copilotkit_shared.childRefKind)(schema)) return v09;
|
|
201
|
+
const { description, ...literal } = v09;
|
|
202
|
+
const text = typeof description === "string" ? { description } : {};
|
|
203
|
+
const keys = Object.keys(literal);
|
|
204
|
+
if (keys.length === 1 && typeof literal.type === "string") {
|
|
205
|
+
const dynamic = DYNAMIC_TYPES[literal.type];
|
|
206
|
+
if (dynamic) return {
|
|
207
|
+
...ref(dynamic),
|
|
208
|
+
...text
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const items = literal.items;
|
|
212
|
+
if (keys.length === 2 && literal.type === "array" && isRecord(items) && Object.keys(items).length === 1 && items.type === "string") return {
|
|
213
|
+
...ref("DynamicStringList"),
|
|
214
|
+
...text
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
...text,
|
|
218
|
+
anyOf: [
|
|
219
|
+
literal,
|
|
220
|
+
ref("DataBinding"),
|
|
221
|
+
ref("FunctionCall")
|
|
222
|
+
]
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** A copy of a schema, with its descriptions written the v0.9 way. */
|
|
226
|
+
function v09Schema(value) {
|
|
227
|
+
if (Array.isArray(value)) return value.map(v09Schema);
|
|
228
|
+
if (!isRecord(value)) return value;
|
|
229
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, key === "description" && typeof child === "string" ? v09Text(child) : v09Schema(child)]));
|
|
230
|
+
}
|
|
231
|
+
const mapValues = (record, transform) => Object.fromEntries(Object.entries(record).map(([key, value]) => [key, transform(value)]));
|
|
232
|
+
/** An object schema with each of its properties made dynamic. */
|
|
233
|
+
function dynamicProperties(schema) {
|
|
234
|
+
const result = v09Schema(schema);
|
|
235
|
+
if (isRecord(schema.properties)) result.properties = mapValues(schema.properties, dynamicValue);
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Local refs (`#/...`) of a props schema, pointing to where the schema is
|
|
240
|
+
* embedded in the payload instead of to the root of the props schema.
|
|
241
|
+
*/
|
|
242
|
+
function rebaseRefs(value, base) {
|
|
243
|
+
if (Array.isArray(value)) return value.map((item) => rebaseRefs(item, base));
|
|
244
|
+
if (!isRecord(value)) return value;
|
|
245
|
+
const result = mapValues(value, (child) => rebaseRefs(child, base));
|
|
246
|
+
const target = result.$ref;
|
|
247
|
+
if (target === "#") result.$ref = base;
|
|
248
|
+
else if (typeof target === "string" && target.startsWith("#/")) result.$ref = `${base}${target.slice(1)}`;
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
/** A JSON Pointer segment: `acme/Card` is `acme~1Card`. */
|
|
252
|
+
function pointerSegment(name) {
|
|
253
|
+
return name.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* One component in the v0.9 inline catalog format: `ComponentCommon` and
|
|
257
|
+
* the props, events and slots of the 1.0 manifest under their v0.9 names.
|
|
258
|
+
*/
|
|
259
|
+
function componentSchema(name, manifest, renames) {
|
|
260
|
+
const v09Name = (key) => renames[key] ?? key;
|
|
261
|
+
const { properties, required, description, $defs, definitions } = manifest.props;
|
|
262
|
+
const fields = {};
|
|
263
|
+
for (const [key, schema] of Object.entries(isRecord(properties) ? properties : {})) fields[key] = dynamicValue(schema);
|
|
264
|
+
for (const [key, event] of Object.entries(manifest.events ?? {})) fields[key] = {
|
|
265
|
+
...ref("Action"),
|
|
266
|
+
...event.description ? { description: v09Text(event.description) } : {}
|
|
267
|
+
};
|
|
268
|
+
for (const [key, kind] of Object.entries(manifest.slots ?? {})) fields[key] = ref(kind === "single" ? "ComponentId" : "ChildList");
|
|
269
|
+
const order = [...manifest.parameterOrder ?? [], ...Object.keys(fields)];
|
|
270
|
+
const ordered = { component: { const: name } };
|
|
271
|
+
for (const key of order) if (Object.hasOwn(fields, key)) ordered[v09Name(key)] = fields[key];
|
|
272
|
+
const defs = {
|
|
273
|
+
...isRecord($defs) ? { $defs: v09Schema($defs) } : {},
|
|
274
|
+
...isRecord(definitions) ? { definitions: v09Schema(definitions) } : {}
|
|
275
|
+
};
|
|
276
|
+
const text = manifest.description ?? description;
|
|
277
|
+
const body = rebaseRefs({
|
|
278
|
+
properties: ordered,
|
|
279
|
+
required: ["component", ...Array.isArray(required) ? required.filter((key) => typeof key === "string").map(v09Name) : []],
|
|
280
|
+
...defs
|
|
281
|
+
}, `#/components/${pointerSegment(name)}/allOf/1`);
|
|
282
|
+
return {
|
|
283
|
+
...typeof text === "string" ? { description: v09Text(text) } : {},
|
|
284
|
+
allOf: [ref("ComponentCommon"), body]
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** A function in the v0.9 inline catalog `functions` format. */
|
|
288
|
+
function functionSchema(name, description, returnType, parameters) {
|
|
289
|
+
return {
|
|
290
|
+
name,
|
|
291
|
+
...description ? { description: v09Text(description) } : {},
|
|
292
|
+
returnType: returnType === "validationResult" ? "boolean" : returnType ?? "any",
|
|
293
|
+
parameters
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The functions a v0.9 `{ call }` may name: the basic ones, which v0.9 names
|
|
298
|
+
* the same, then the app functions the renderer may call.
|
|
299
|
+
*/
|
|
300
|
+
function catalogFunctions(functions) {
|
|
301
|
+
const result = Object.entries(_copilotkit_shared.A2UI_BASIC_FUNCTIONS).filter(([name]) => !Object.hasOwn(functions, name)).map(([name, info]) => functionSchema(name, info.description, info.returnType, (0, _copilotkit_shared_generative_ui.argsSchemaFromSignature)(info.parameters)));
|
|
302
|
+
for (const [name, fn] of Object.entries(functions)) {
|
|
303
|
+
if (!(0, _copilotkit_shared.functionCallers)(fn).renderer) continue;
|
|
304
|
+
result.push(functionSchema(name, fn.description, fn.returnType, dynamicProperties(fn.parameters)));
|
|
305
|
+
}
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The capabilities entry: the catalog id, then the components beyond the
|
|
310
|
+
* v0.9 basic catalog, by name. Their schemas are in the schema entry, so
|
|
311
|
+
* they are not repeated here.
|
|
312
|
+
*/
|
|
313
|
+
function capabilitiesValue(catalogId, names) {
|
|
314
|
+
const lines = ["Available A2UI catalog:"];
|
|
315
|
+
if (names === void 0) {
|
|
316
|
+
lines.push(`- ${catalogId}`);
|
|
317
|
+
return lines.join("\n");
|
|
318
|
+
}
|
|
319
|
+
const extra = names.filter((name) => !V09_BASIC_COMPONENTS.has(name));
|
|
320
|
+
const nameSet = new Set(names);
|
|
321
|
+
const isSuperset = [...V09_BASIC_COMPONENTS].every((name) => nameSet.has(name));
|
|
322
|
+
if (catalogId === A2UI_V09_BASIC_CATALOG_ID && isSuperset && !extra.length) {
|
|
323
|
+
lines.push(`- ${catalogId} (basic catalog)`);
|
|
324
|
+
return lines.join("\n");
|
|
325
|
+
}
|
|
326
|
+
lines.push(`- ${catalogId}`);
|
|
327
|
+
if (isSuperset) lines.push(" Extends the basic catalog with all standard components plus:");
|
|
328
|
+
else {
|
|
329
|
+
lines.push(" Custom catalog (does NOT include all basic components).");
|
|
330
|
+
lines.push(" Custom components:");
|
|
331
|
+
}
|
|
332
|
+
for (const name of extra) lines.push(` - ${name}`);
|
|
333
|
+
return lines.join("\n");
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Builds the A2UI v0.9 catalog context for a run, from the generative UI
|
|
337
|
+
* envelope the client sent (`forwardedProps.copilotkit.ui`).
|
|
338
|
+
*
|
|
339
|
+
* The entries are the ones the v0.9 client sent, with the same descriptions:
|
|
340
|
+
* the catalog capabilities, the component schema (the v0.9 inline catalog
|
|
341
|
+
* format that `A2UIMiddleware` reads, and replaces when it has a server
|
|
342
|
+
* schema), and the v0.9 generation and design guidelines. Without the
|
|
343
|
+
* component schemas in the envelope, only the capabilities entry is built.
|
|
344
|
+
*
|
|
345
|
+
* The components are the v0.9 basic ones of the standard catalog and the
|
|
346
|
+
* UI's own components: the other standard components (Title, Chart, ...)
|
|
347
|
+
* are left out, as a v0.9 agent never knew them and they would make the
|
|
348
|
+
* schema about three times larger. A component of the UI's own that has the
|
|
349
|
+
* name of a standard component counts as the standard one.
|
|
350
|
+
*
|
|
351
|
+
* Components keep their names. Props, events and slots keep their 1.0 names
|
|
352
|
+
* except for `V10_TO_V09_PROP_NAMES` on standard components;
|
|
353
|
+
* values take a v0.9 `{ path }` binding or `{ call }` function call, events
|
|
354
|
+
* take a v0.9 action, and slots a v0.9 `ComponentId` or `ChildList`.
|
|
355
|
+
*
|
|
356
|
+
* The catalog id is the v0.9 basic catalog id when the UI includes the 1.0
|
|
357
|
+
* standard catalog, which has every v0.9 basic component: v0.9 agents and
|
|
358
|
+
* prompts already use that id, and `A2UIMiddleware` stamps the id of the
|
|
359
|
+
* schema entry into the surfaces it creates. Otherwise it is the id of the
|
|
360
|
+
* UI, since the basic id would promise components the UI does not have.
|
|
361
|
+
*
|
|
362
|
+
* @param input - The run input.
|
|
363
|
+
* @returns The catalog id the v0.9 agent should use and the context
|
|
364
|
+
* entries, or `undefined` when the run has no generative UI envelope.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* const v09 = buildA2UIV09CatalogContext(input);
|
|
369
|
+
* if (v09) input = { ...input, context: [...input.context, ...v09.context] };
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
function buildA2UIV09CatalogContext(input) {
|
|
373
|
+
const envelope = (0, _copilotkit_shared.readCopilotKitUIEnvelope)(input.forwardedProps);
|
|
374
|
+
if (!envelope) return void 0;
|
|
375
|
+
const manifest = (0, _copilotkit_shared.envelopeToManifest)(envelope);
|
|
376
|
+
const extendsStandard = (manifest.catalogIds ?? [manifest.catalogId]).includes(_copilotkit_shared_generative_ui.STANDARD_CATALOG_ID);
|
|
377
|
+
const catalogId = extendsStandard ? A2UI_V09_BASIC_CATALOG_ID : manifest.catalogId;
|
|
378
|
+
if (!manifest.hasComponents) return {
|
|
379
|
+
catalogId,
|
|
380
|
+
context: [{
|
|
381
|
+
description: CAPABILITIES_CONTEXT_DESCRIPTION,
|
|
382
|
+
value: capabilitiesValue(catalogId, void 0)
|
|
383
|
+
}]
|
|
384
|
+
};
|
|
385
|
+
const components = {};
|
|
386
|
+
for (const [name, component] of Object.entries(manifest.components)) {
|
|
387
|
+
const isStandard = extendsStandard && Object.hasOwn(_copilotkit_shared_generative_ui.standardDeclarations, name);
|
|
388
|
+
if (isStandard && !V09_BASIC_COMPONENTS.has(name)) continue;
|
|
389
|
+
components[name] = componentSchema(name, component, isStandard && V10_TO_V09_PROP_NAMES[name] || {});
|
|
390
|
+
}
|
|
391
|
+
const schema = {
|
|
392
|
+
catalogId,
|
|
393
|
+
components,
|
|
394
|
+
functions: catalogFunctions(manifest.functions),
|
|
395
|
+
"common_types.json": { $defs: V09_COMMON_TYPES }
|
|
396
|
+
};
|
|
397
|
+
return {
|
|
398
|
+
catalogId,
|
|
399
|
+
context: [
|
|
400
|
+
{
|
|
401
|
+
description: CAPABILITIES_CONTEXT_DESCRIPTION,
|
|
402
|
+
value: capabilitiesValue(catalogId, Object.keys(components))
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
description: _ag_ui_a2ui_middleware.A2UI_SCHEMA_CONTEXT_DESCRIPTION,
|
|
406
|
+
value: JSON.stringify(schema)
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
description: GENERATION_GUIDELINES_CONTEXT_DESCRIPTION,
|
|
410
|
+
value: _copilotkit_shared.A2UI_DEFAULT_GENERATION_GUIDELINES
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
description: DESIGN_GUIDELINES_CONTEXT_DESCRIPTION,
|
|
414
|
+
value: _copilotkit_shared.A2UI_DEFAULT_DESIGN_GUIDELINES
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
//#endregion
|
|
421
|
+
exports.buildA2UIV09CatalogContext = buildA2UIV09CatalogContext;
|
|
422
|
+
//# sourceMappingURL=a2ui-v09-catalog.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2ui-v09-catalog.cjs","names":["A2UI_BASIC_FUNCTIONS","STANDARD_CATALOG_ID","standardDeclarations","A2UI_SCHEMA_CONTEXT_DESCRIPTION","A2UI_DEFAULT_GENERATION_GUIDELINES","A2UI_DEFAULT_DESIGN_GUIDELINES"],"sources":["../../../src/runtime/generative-ui/a2ui-v09-catalog.ts"],"sourcesContent":["/**\n * The A2UI v0.9 catalog context for an agent that speaks v0.9.\n *\n * The client renders A2UI 1.0 only and sends its catalog in the run envelope\n * (`forwardedProps.copilotkit.ui`). A v0.9 agent still calls `render_a2ui`\n * (injected by `A2UIMiddleware`) and must be told the components in v0.9\n * terms. The removed v0.9 client (`@copilotkit/a2ui-renderer`) sent that as\n * agent context; this module builds the same entries on the server, from the\n * 1.0 manifest.\n */\nimport type { RunAgentInput } from \"@ag-ui/client\";\nimport { A2UI_SCHEMA_CONTEXT_DESCRIPTION } from \"@ag-ui/a2ui-middleware\";\nimport {\n A2UI_BASIC_FUNCTIONS,\n A2UI_DEFAULT_DESIGN_GUIDELINES,\n A2UI_DEFAULT_GENERATION_GUIDELINES,\n childRefKind,\n envelopeToManifest,\n functionCallers,\n readCopilotKitUIEnvelope,\n} from \"@copilotkit/shared\";\nimport type {\n GenerativeUIComponentManifest,\n GenerativeUIFunctionManifest,\n} from \"@copilotkit/shared\";\nimport {\n STANDARD_CATALOG_ID,\n argsSchemaFromSignature,\n standardDeclarations,\n} from \"@copilotkit/shared/generative-ui\";\n\n/** Id of the A2UI v0.9 basic catalog. */\nconst A2UI_V09_BASIC_CATALOG_ID =\n \"https://a2ui.org/specification/v0_9/basic_catalog.json\";\n\n// The description strings of the context entries, as the v0.9 client sent\n// them (`@copilotkit/a2ui-renderer` `catalog-context.ts`). Agents and the\n// middleware find the entries by them. The schema description comes from\n// `@ag-ui/a2ui-middleware`, which looks it up and can replace the entry.\nconst CAPABILITIES_CONTEXT_DESCRIPTION =\n \"A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.\";\nconst GENERATION_GUIDELINES_CONTEXT_DESCRIPTION =\n \"A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.\";\nconst DESIGN_GUIDELINES_CONTEXT_DESCRIPTION =\n \"A2UI design guidelines — visual design rules, component hierarchy tips, and action handler patterns.\";\n\n/** The components of the v0.9 basic catalog. The 1.0 standard catalog has each of them. */\nconst V09_BASIC_COMPONENTS: ReadonlySet<string> = new Set([\n \"Text\",\n \"Image\",\n \"Icon\",\n \"Video\",\n \"AudioPlayer\",\n \"Row\",\n \"Column\",\n \"List\",\n \"Card\",\n \"Tabs\",\n \"Modal\",\n \"Divider\",\n \"Button\",\n \"TextField\",\n \"CheckBox\",\n \"ChoicePicker\",\n \"Slider\",\n \"DateTimeInput\",\n]);\n\n/**\n * The props (and events and slots) of standard components that v0.9 names\n * differently: component → 1.0 name → v0.9 name. Every other prop has the\n * same name in both versions.\n */\nconst V10_TO_V09_PROP_NAMES: Readonly<\n Record<string, Readonly<Record<string, string>>>\n> = {\n Button: { onClick: \"action\" },\n};\n\ntype JsonSchema = Record<string, unknown>;\n\nconst COMMON = \"common_types.json#/$defs/\";\nconst ref = (name: string) => ({ $ref: `${COMMON}${name}` });\n\n/**\n * The v0.9 common types the schemas reference, in their v0.9 shapes, so\n * every `common_types.json#/$defs/<Name>` ref resolves within the payload.\n */\nconst V09_COMMON_TYPES: Record<string, JsonSchema> = {\n ComponentId: {\n type: \"string\",\n description:\n \"The unique identifier for a component, used for both definitions and references within the same surface.\",\n },\n ComponentCommon: {\n type: \"object\",\n properties: {\n id: ref(\"ComponentId\"),\n accessibility: ref(\"AccessibilityAttributes\"),\n },\n required: [\"id\"],\n },\n AccessibilityAttributes: {\n type: \"object\",\n description:\n \"Attributes to enhance accessibility when using assistive technologies like screen readers.\",\n properties: {\n label: ref(\"DynamicString\"),\n description: ref(\"DynamicString\"),\n },\n },\n ChildList: {\n oneOf: [\n {\n type: \"array\",\n items: ref(\"ComponentId\"),\n description: \"A static list of child component IDs.\",\n },\n {\n type: \"object\",\n description:\n \"A template for generating a dynamic list of children from a data model list. The `componentId` is the component to use as a template.\",\n properties: {\n componentId: ref(\"ComponentId\"),\n path: {\n type: \"string\",\n description:\n \"The path to the list of component property objects in the data model.\",\n },\n },\n required: [\"componentId\", \"path\"],\n additionalProperties: false,\n },\n ],\n },\n DataBinding: {\n type: \"object\",\n properties: {\n path: {\n type: \"string\",\n description: \"A JSON Pointer path to a value in the data model.\",\n },\n },\n required: [\"path\"],\n additionalProperties: false,\n },\n FunctionCall: {\n type: \"object\",\n description: \"Invokes a named function on the client.\",\n properties: {\n call: {\n type: \"string\",\n description: \"The name of the function to call.\",\n },\n args: {\n type: \"object\",\n description: \"Arguments passed to the function.\",\n additionalProperties: ref(\"DynamicValue\"),\n },\n },\n required: [\"call\"],\n additionalProperties: false,\n },\n DynamicValue: {\n description:\n \"A value that can be a literal, a path, or a function call returning any type.\",\n anyOf: [\n { type: \"string\" },\n { type: \"number\" },\n { type: \"boolean\" },\n { type: \"array\" },\n ref(\"DataBinding\"),\n ref(\"FunctionCall\"),\n ],\n },\n DynamicString: {\n anyOf: [{ type: \"string\" }, ref(\"DataBinding\"), ref(\"FunctionCall\")],\n },\n DynamicNumber: {\n anyOf: [{ type: \"number\" }, ref(\"DataBinding\"), ref(\"FunctionCall\")],\n },\n DynamicBoolean: {\n anyOf: [{ type: \"boolean\" }, ref(\"DataBinding\"), ref(\"FunctionCall\")],\n },\n DynamicStringList: {\n anyOf: [\n { type: \"array\", items: { type: \"string\" } },\n ref(\"DataBinding\"),\n ref(\"FunctionCall\"),\n ],\n },\n Action: {\n description:\n \"Defines an interaction handler that can either trigger a server-side event or execute a local client-side function.\",\n oneOf: [\n {\n type: \"object\",\n description: \"Triggers a server-side event.\",\n properties: {\n event: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description:\n \"The name of the action to be dispatched to the server.\",\n },\n context: {\n type: \"object\",\n description:\n \"A JSON object containing the key-value pairs for the action context. Values can be literals or paths.\",\n additionalProperties: ref(\"DynamicValue\"),\n },\n },\n required: [\"name\"],\n additionalProperties: false,\n },\n },\n required: [\"event\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n description: \"Executes a local client-side function.\",\n properties: { functionCall: ref(\"FunctionCall\") },\n required: [\"functionCall\"],\n additionalProperties: false,\n },\n ],\n },\n};\n\nfunction isRecord(value: unknown): value is JsonSchema {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** 1.0 binding and call syntax in a description, written the v0.9 way. */\nfunction v09Text(text: string) {\n return text.replaceAll('\"@path\"', '\"path\"').replaceAll('\"@call\"', '\"call\"');\n}\n\n/** The v0.9 dynamic type of a literal schema that is just a primitive type. */\nconst DYNAMIC_TYPES: Readonly<Record<string, string>> = {\n string: \"DynamicString\",\n number: \"DynamicNumber\",\n boolean: \"DynamicBoolean\",\n};\n\n/**\n * A prop value as v0.9 states it: its literal schema, a `{ path }` binding\n * or a `{ call }` function call. A plain string, number, boolean or string\n * list is the v0.9 `Dynamic*` type of the same meaning. A component\n * reference stays one.\n *\n * Only the prop itself is made dynamic, as in the v0.9 basic catalog: the\n * 1.0 catalog marks every nested value dynamic too, which makes the\n * standard catalog several times larger.\n */\nfunction dynamicValue(schema: unknown): JsonSchema {\n if (!isRecord(schema)) return ref(\"DynamicValue\");\n const v09 = v09Schema(schema) as JsonSchema;\n if (childRefKind(schema)) return v09;\n const { description, ...literal } = v09;\n const text = typeof description === \"string\" ? { description } : {};\n const keys = Object.keys(literal);\n if (keys.length === 1 && typeof literal.type === \"string\") {\n const dynamic = DYNAMIC_TYPES[literal.type];\n if (dynamic) return { ...ref(dynamic), ...text };\n }\n const items = literal.items;\n if (\n keys.length === 2 &&\n literal.type === \"array\" &&\n isRecord(items) &&\n Object.keys(items).length === 1 &&\n items.type === \"string\"\n ) {\n return { ...ref(\"DynamicStringList\"), ...text };\n }\n return { ...text, anyOf: [literal, ref(\"DataBinding\"), ref(\"FunctionCall\")] };\n}\n\n/** A copy of a schema, with its descriptions written the v0.9 way. */\nfunction v09Schema(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(v09Schema);\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value).map(([key, child]) => [\n key,\n key === \"description\" && typeof child === \"string\"\n ? v09Text(child)\n : v09Schema(child),\n ]),\n );\n}\n\nconst mapValues = (\n record: JsonSchema,\n transform: (value: unknown) => unknown,\n): JsonSchema =>\n Object.fromEntries(\n Object.entries(record).map(([key, value]) => [key, transform(value)]),\n );\n\n/** An object schema with each of its properties made dynamic. */\nfunction dynamicProperties(schema: JsonSchema): JsonSchema {\n const result = v09Schema(schema) as JsonSchema;\n if (isRecord(schema.properties)) {\n result.properties = mapValues(schema.properties, dynamicValue);\n }\n return result;\n}\n\n/**\n * Local refs (`#/...`) of a props schema, pointing to where the schema is\n * embedded in the payload instead of to the root of the props schema.\n */\nfunction rebaseRefs(value: unknown, base: string): unknown {\n if (Array.isArray(value)) return value.map((item) => rebaseRefs(item, base));\n if (!isRecord(value)) return value;\n const result = mapValues(value, (child) => rebaseRefs(child, base));\n const target = result.$ref;\n if (target === \"#\") result.$ref = base;\n else if (typeof target === \"string\" && target.startsWith(\"#/\")) {\n result.$ref = `${base}${target.slice(1)}`;\n }\n return result;\n}\n\n/** A JSON Pointer segment: `acme/Card` is `acme~1Card`. */\nfunction pointerSegment(name: string) {\n return name.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\n}\n\n/**\n * One component in the v0.9 inline catalog format: `ComponentCommon` and\n * the props, events and slots of the 1.0 manifest under their v0.9 names.\n */\nfunction componentSchema(\n name: string,\n manifest: GenerativeUIComponentManifest,\n renames: Readonly<Record<string, string>>,\n): JsonSchema {\n const v09Name = (key: string) => renames[key] ?? key;\n const { properties, required, description, $defs, definitions } =\n manifest.props;\n const fields: JsonSchema = {};\n for (const [key, schema] of Object.entries(\n isRecord(properties) ? properties : {},\n )) {\n fields[key] = dynamicValue(schema);\n }\n for (const [key, event] of Object.entries(manifest.events ?? {})) {\n fields[key] = {\n ...ref(\"Action\"),\n ...(event.description ? { description: v09Text(event.description) } : {}),\n };\n }\n for (const [key, kind] of Object.entries(manifest.slots ?? {})) {\n fields[key] = ref(kind === \"single\" ? \"ComponentId\" : \"ChildList\");\n }\n const order = [...(manifest.parameterOrder ?? []), ...Object.keys(fields)];\n const ordered: JsonSchema = { component: { const: name } };\n for (const key of order) {\n if (Object.hasOwn(fields, key)) ordered[v09Name(key)] = fields[key];\n }\n // The definitions of the props schema, when its converter made some.\n const defs = {\n ...(isRecord($defs) ? { $defs: v09Schema($defs) } : {}),\n ...(isRecord(definitions) ? { definitions: v09Schema(definitions) } : {}),\n };\n const text = manifest.description ?? description;\n const body = rebaseRefs(\n {\n properties: ordered,\n required: [\n \"component\",\n ...(Array.isArray(required)\n ? required.filter((key) => typeof key === \"string\").map(v09Name)\n : []),\n ],\n ...defs,\n },\n `#/components/${pointerSegment(name)}/allOf/1`,\n ) as JsonSchema;\n return {\n ...(typeof text === \"string\" ? { description: v09Text(text) } : {}),\n allOf: [ref(\"ComponentCommon\"), body],\n };\n}\n\n/** A function in the v0.9 inline catalog `functions` format. */\nfunction functionSchema(\n name: string,\n description: string | undefined,\n returnType: string | undefined,\n parameters: JsonSchema,\n) {\n return {\n name,\n ...(description ? { description: v09Text(description) } : {}),\n // v0.9 has no `validationResult`: its checks are boolean function calls.\n returnType:\n returnType === \"validationResult\" ? \"boolean\" : (returnType ?? \"any\"),\n parameters,\n };\n}\n\n/**\n * The functions a v0.9 `{ call }` may name: the basic ones, which v0.9 names\n * the same, then the app functions the renderer may call.\n */\nfunction catalogFunctions(\n functions: Record<string, GenerativeUIFunctionManifest>,\n) {\n const result = Object.entries(A2UI_BASIC_FUNCTIONS)\n .filter(([name]) => !Object.hasOwn(functions, name))\n .map(([name, info]) =>\n functionSchema(\n name,\n info.description,\n info.returnType,\n argsSchemaFromSignature(info.parameters),\n ),\n );\n for (const [name, fn] of Object.entries(functions)) {\n if (!functionCallers(fn).renderer) continue;\n result.push(\n functionSchema(\n name,\n fn.description,\n fn.returnType,\n dynamicProperties(fn.parameters),\n ),\n );\n }\n return result;\n}\n\n/**\n * The capabilities entry: the catalog id, then the components beyond the\n * v0.9 basic catalog, by name. Their schemas are in the schema entry, so\n * they are not repeated here.\n */\nfunction capabilitiesValue(\n catalogId: string,\n names: readonly string[] | undefined,\n) {\n const lines = [\"Available A2UI catalog:\"];\n if (names === undefined) {\n lines.push(`- ${catalogId}`);\n return lines.join(\"\\n\");\n }\n const extra = names.filter((name) => !V09_BASIC_COMPONENTS.has(name));\n const nameSet = new Set(names);\n const isSuperset = [...V09_BASIC_COMPONENTS].every((name) =>\n nameSet.has(name),\n );\n if (catalogId === A2UI_V09_BASIC_CATALOG_ID && isSuperset && !extra.length) {\n lines.push(`- ${catalogId} (basic catalog)`);\n return lines.join(\"\\n\");\n }\n lines.push(`- ${catalogId}`);\n if (isSuperset) {\n lines.push(\n \" Extends the basic catalog with all standard components plus:\",\n );\n } else {\n lines.push(\" Custom catalog (does NOT include all basic components).\");\n lines.push(\" Custom components:\");\n }\n for (const name of extra) lines.push(` - ${name}`);\n return lines.join(\"\\n\");\n}\n\n/**\n * Builds the A2UI v0.9 catalog context for a run, from the generative UI\n * envelope the client sent (`forwardedProps.copilotkit.ui`).\n *\n * The entries are the ones the v0.9 client sent, with the same descriptions:\n * the catalog capabilities, the component schema (the v0.9 inline catalog\n * format that `A2UIMiddleware` reads, and replaces when it has a server\n * schema), and the v0.9 generation and design guidelines. Without the\n * component schemas in the envelope, only the capabilities entry is built.\n *\n * The components are the v0.9 basic ones of the standard catalog and the\n * UI's own components: the other standard components (Title, Chart, ...)\n * are left out, as a v0.9 agent never knew them and they would make the\n * schema about three times larger. A component of the UI's own that has the\n * name of a standard component counts as the standard one.\n *\n * Components keep their names. Props, events and slots keep their 1.0 names\n * except for `V10_TO_V09_PROP_NAMES` on standard components;\n * values take a v0.9 `{ path }` binding or `{ call }` function call, events\n * take a v0.9 action, and slots a v0.9 `ComponentId` or `ChildList`.\n *\n * The catalog id is the v0.9 basic catalog id when the UI includes the 1.0\n * standard catalog, which has every v0.9 basic component: v0.9 agents and\n * prompts already use that id, and `A2UIMiddleware` stamps the id of the\n * schema entry into the surfaces it creates. Otherwise it is the id of the\n * UI, since the basic id would promise components the UI does not have.\n *\n * @param input - The run input.\n * @returns The catalog id the v0.9 agent should use and the context\n * entries, or `undefined` when the run has no generative UI envelope.\n *\n * @example\n * ```ts\n * const v09 = buildA2UIV09CatalogContext(input);\n * if (v09) input = { ...input, context: [...input.context, ...v09.context] };\n * ```\n */\nexport function buildA2UIV09CatalogContext(input: RunAgentInput):\n | {\n catalogId: string;\n context: Array<{ description: string; value: string }>;\n }\n | undefined {\n const envelope = readCopilotKitUIEnvelope(input.forwardedProps);\n if (!envelope) return undefined;\n const manifest = envelopeToManifest(envelope);\n const extendsStandard = (\n manifest.catalogIds ?? [manifest.catalogId]\n ).includes(STANDARD_CATALOG_ID);\n const catalogId = extendsStandard\n ? A2UI_V09_BASIC_CATALOG_ID\n : manifest.catalogId;\n\n if (!manifest.hasComponents) {\n return {\n catalogId,\n context: [\n {\n description: CAPABILITIES_CONTEXT_DESCRIPTION,\n value: capabilitiesValue(catalogId, undefined),\n },\n ],\n };\n }\n\n const components: Record<string, JsonSchema> = {};\n for (const [name, component] of Object.entries(manifest.components)) {\n const isStandard =\n extendsStandard && Object.hasOwn(standardDeclarations, name);\n // Of the standard components, a v0.9 agent knows the basic ones only.\n if (isStandard && !V09_BASIC_COMPONENTS.has(name)) continue;\n const renames = (isStandard && V10_TO_V09_PROP_NAMES[name]) || {};\n components[name] = componentSchema(name, component, renames);\n }\n const schema = {\n catalogId,\n components,\n functions: catalogFunctions(manifest.functions),\n \"common_types.json\": { $defs: V09_COMMON_TYPES },\n };\n\n return {\n catalogId,\n context: [\n {\n description: CAPABILITIES_CONTEXT_DESCRIPTION,\n value: capabilitiesValue(catalogId, Object.keys(components)),\n },\n {\n description: A2UI_SCHEMA_CONTEXT_DESCRIPTION,\n value: JSON.stringify(schema),\n },\n {\n description: GENERATION_GUIDELINES_CONTEXT_DESCRIPTION,\n value: A2UI_DEFAULT_GENERATION_GUIDELINES,\n },\n {\n description: DESIGN_GUIDELINES_CONTEXT_DESCRIPTION,\n value: A2UI_DEFAULT_DESIGN_GUIDELINES,\n },\n ],\n };\n}\n"],"mappings":";;;;;;AAgCA,MAAM,4BACJ;AAMF,MAAM,mCACJ;AACF,MAAM,4CACJ;AACF,MAAM,wCACJ;;AAGF,MAAM,uBAA4C,IAAI,IAAI;CACxD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;;;AAOF,MAAM,wBAEF,EACF,QAAQ,EAAE,SAAS,UAAU,EAC9B;AAID,MAAM,SAAS;AACf,MAAM,OAAO,UAAkB,EAAE,MAAM,GAAG,SAAS,QAAQ;;;;;AAM3D,MAAM,mBAA+C;CACnD,aAAa;EACX,MAAM;EACN,aACE;EACH;CACD,iBAAiB;EACf,MAAM;EACN,YAAY;GACV,IAAI,IAAI,cAAc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