@jini-ai/agentic 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/core/a2ui/index.d.ts +1 -0
  3. package/dist/core/a2ui/index.js +1 -0
  4. package/dist/core/a2ui/surface-properties.d.ts +34 -0
  5. package/dist/core/a2ui/surface-properties.js +49 -0
  6. package/dist/core/annotated-actions-script.d.ts +13 -0
  7. package/dist/core/annotated-actions-script.js +137 -0
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +1 -0
  10. package/package.json +2 -2
  11. package/dist/a2ui/agent-to-renderer.d.ts +0 -613
  12. package/dist/a2ui/agent-to-renderer.js +0 -191
  13. package/dist/a2ui/catalog.d.ts +0 -73
  14. package/dist/a2ui/catalog.js +0 -304
  15. package/dist/a2ui/common-types.d.ts +0 -401
  16. package/dist/a2ui/common-types.js +0 -130
  17. package/dist/a2ui/index.d.ts +0 -16
  18. package/dist/a2ui/index.js +0 -16
  19. package/dist/a2ui/interpreter.d.ts +0 -71
  20. package/dist/a2ui/interpreter.js +0 -337
  21. package/dist/a2ui/json-pointer.d.ts +0 -48
  22. package/dist/a2ui/json-pointer.js +0 -174
  23. package/dist/a2ui/renderer-to-agent.d.ts +0 -342
  24. package/dist/a2ui/renderer-to-agent.js +0 -111
  25. package/dist/a2ui/resolve.d.ts +0 -28
  26. package/dist/a2ui/resolve.js +0 -144
  27. package/dist/a2ui/tree.d.ts +0 -66
  28. package/dist/a2ui/tree.js +0 -74
  29. package/dist/ag-ui.d.ts +0 -82
  30. package/dist/ag-ui.js +0 -85
  31. package/dist/agui/encoder.d.ts +0 -50
  32. package/dist/agui/encoder.js +0 -97
  33. package/dist/agui/events.d.ts +0 -59
  34. package/dist/agui/events.js +0 -15
  35. package/dist/capability.d.ts +0 -81
  36. package/dist/capability.js +0 -79
  37. package/dist/dom/dom-page-driver.d.ts +0 -36
  38. package/dist/dom/dom-page-driver.js +0 -601
  39. package/dist/dom/index.d.ts +0 -17
  40. package/dist/dom/index.js +0 -17
  41. package/dist/dom/model-context.d.ts +0 -69
  42. package/dist/dom/model-context.js +0 -44
  43. package/dist/element-handles.d.ts +0 -120
  44. package/dist/element-handles.js +0 -39
  45. package/dist/gen-ui/encoder.d.ts +0 -50
  46. package/dist/gen-ui/encoder.js +0 -97
  47. package/dist/gen-ui/events.d.ts +0 -59
  48. package/dist/gen-ui/events.js +0 -15
  49. package/dist/gen-ui/index.d.ts +0 -18
  50. package/dist/gen-ui/index.js +0 -17
  51. package/dist/guards.d.ts +0 -96
  52. package/dist/guards.js +0 -186
  53. package/dist/handle.d.ts +0 -41
  54. package/dist/handle.js +0 -41
  55. package/dist/mcp-ui-apps.d.ts +0 -223
  56. package/dist/mcp-ui-apps.js +0 -252
  57. package/dist/mcp-ui.d.ts +0 -133
  58. package/dist/mcp-ui.js +0 -134
  59. package/dist/page-capabilities.d.ts +0 -14
  60. package/dist/page-capabilities.js +0 -129
  61. package/dist/page-driver.d.ts +0 -120
  62. package/dist/page-driver.js +0 -2
  63. package/dist/page-executor.d.ts +0 -94
  64. package/dist/page-executor.js +0 -320
  65. package/dist/webmcp.d.ts +0 -202
  66. package/dist/webmcp.js +0 -173
@@ -1,342 +0,0 @@
1
- /**
2
- * @module renderer-to-agent
3
- *
4
- * A2UI v1.0 renderer→agent envelope — mirrors `specification/v1_0/json/renderer_to_agent.json`
5
- * (fetched from https://github.com/a2ui-project/a2ui, `main` branch, this session). Three message
6
- * kinds, each envelope carrying `version` plus **exactly one** of `action` | `functionResponse` |
7
- * `error` (`minProperties: 2, maxProperties: 2` in the real schema — enforced below via `.refine`,
8
- * since zod's object schema has no direct min/max-properties primitive).
9
- */
10
- import { z } from 'zod';
11
- /** `renderer_to_agent.json#/properties/action` — "Reports a user-initiated action from a component." */
12
- export declare const ActionMessagePayloadSchema: z.ZodObject<{
13
- name: z.ZodString;
14
- surfaceId: z.ZodString;
15
- sourceComponentId: z.ZodString;
16
- /** ISO 8601 timestamp — validated as a non-empty string, not parsed as a `Date`: the real schema only declares `format: "date-time"` (an annotation, not a structural constraint zod enforces by default). */
17
- timestamp: z.ZodString;
18
- context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
19
- wantResponse: z.ZodOptional<z.ZodBoolean>;
20
- actionId: z.ZodOptional<z.ZodString>;
21
- }, "strip", z.ZodTypeAny, {
22
- name: string;
23
- surfaceId: string;
24
- context: Record<string, unknown>;
25
- sourceComponentId: string;
26
- timestamp: string;
27
- wantResponse?: boolean | undefined;
28
- actionId?: string | undefined;
29
- }, {
30
- name: string;
31
- surfaceId: string;
32
- context: Record<string, unknown>;
33
- sourceComponentId: string;
34
- timestamp: string;
35
- wantResponse?: boolean | undefined;
36
- actionId?: string | undefined;
37
- }>;
38
- export type ActionMessagePayload = z.infer<typeof ActionMessagePayloadSchema>;
39
- /**
40
- * `renderer_to_agent.json#/properties/functionResponse`.
41
- *
42
- * `value` is required (`"required": ["functionCallId", "call", "value"]`), and — as with
43
- * `updateDataModel.value`, see that schema's own note — `z.unknown()` alone does not enforce a
44
- * required key in Zod 3, so a response with no `value` at all validated clean. Presence is
45
- * asserted on the object instead. JSON has no `undefined`: a function returning nothing must say
46
- * `null`, which is why `interpreter.ts` encodes a void return that way rather than omitting it.
47
- */
48
- export declare const FunctionResponsePayloadSchema: z.ZodEffects<z.ZodObject<{
49
- functionCallId: z.ZodString;
50
- call: z.ZodString;
51
- value: z.ZodUnknown;
52
- }, "strip", z.ZodTypeAny, {
53
- call: string;
54
- functionCallId: string;
55
- value?: unknown;
56
- }, {
57
- call: string;
58
- functionCallId: string;
59
- value?: unknown;
60
- }>, {
61
- call: string;
62
- functionCallId: string;
63
- value?: unknown;
64
- }, {
65
- call: string;
66
- functionCallId: string;
67
- value?: unknown;
68
- }>;
69
- export type FunctionResponsePayload = z.infer<typeof FunctionResponsePayloadSchema>;
70
- /**
71
- * `renderer_to_agent.json#/properties/error` — two mutually-exclusive shapes: a `VALIDATION_FAILED`
72
- * error (always carries `surfaceId` + a JSON-Pointer `path`), or a generic error (any other `code`,
73
- * carrying exactly one of `surfaceId` XOR `functionCallId`).
74
- */
75
- export declare const ValidationFailedErrorSchema: z.ZodObject<{
76
- code: z.ZodLiteral<"VALIDATION_FAILED">;
77
- surfaceId: z.ZodString;
78
- path: z.ZodString;
79
- message: z.ZodString;
80
- }, "strict", z.ZodTypeAny, {
81
- surfaceId: string;
82
- code: "VALIDATION_FAILED";
83
- message: string;
84
- path: string;
85
- }, {
86
- surfaceId: string;
87
- code: "VALIDATION_FAILED";
88
- message: string;
89
- path: string;
90
- }>;
91
- export type ValidationFailedError = z.infer<typeof ValidationFailedErrorSchema>;
92
- export declare const GenericErrorSchema: z.ZodEffects<z.ZodObject<{
93
- code: z.ZodEffects<z.ZodString, string, string>;
94
- message: z.ZodString;
95
- surfaceId: z.ZodOptional<z.ZodString>;
96
- functionCallId: z.ZodOptional<z.ZodString>;
97
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
98
- code: z.ZodEffects<z.ZodString, string, string>;
99
- message: z.ZodString;
100
- surfaceId: z.ZodOptional<z.ZodString>;
101
- functionCallId: z.ZodOptional<z.ZodString>;
102
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
103
- code: z.ZodEffects<z.ZodString, string, string>;
104
- message: z.ZodString;
105
- surfaceId: z.ZodOptional<z.ZodString>;
106
- functionCallId: z.ZodOptional<z.ZodString>;
107
- }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
108
- code: z.ZodEffects<z.ZodString, string, string>;
109
- message: z.ZodString;
110
- surfaceId: z.ZodOptional<z.ZodString>;
111
- functionCallId: z.ZodOptional<z.ZodString>;
112
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
113
- code: z.ZodEffects<z.ZodString, string, string>;
114
- message: z.ZodString;
115
- surfaceId: z.ZodOptional<z.ZodString>;
116
- functionCallId: z.ZodOptional<z.ZodString>;
117
- }, z.ZodTypeAny, "passthrough">>;
118
- export type GenericError = z.infer<typeof GenericErrorSchema>;
119
- export declare const ErrorPayloadSchema: z.ZodUnion<[z.ZodObject<{
120
- code: z.ZodLiteral<"VALIDATION_FAILED">;
121
- surfaceId: z.ZodString;
122
- path: z.ZodString;
123
- message: z.ZodString;
124
- }, "strict", z.ZodTypeAny, {
125
- surfaceId: string;
126
- code: "VALIDATION_FAILED";
127
- message: string;
128
- path: string;
129
- }, {
130
- surfaceId: string;
131
- code: "VALIDATION_FAILED";
132
- message: string;
133
- path: string;
134
- }>, z.ZodEffects<z.ZodObject<{
135
- code: z.ZodEffects<z.ZodString, string, string>;
136
- message: z.ZodString;
137
- surfaceId: z.ZodOptional<z.ZodString>;
138
- functionCallId: z.ZodOptional<z.ZodString>;
139
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
140
- code: z.ZodEffects<z.ZodString, string, string>;
141
- message: z.ZodString;
142
- surfaceId: z.ZodOptional<z.ZodString>;
143
- functionCallId: z.ZodOptional<z.ZodString>;
144
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
145
- code: z.ZodEffects<z.ZodString, string, string>;
146
- message: z.ZodString;
147
- surfaceId: z.ZodOptional<z.ZodString>;
148
- functionCallId: z.ZodOptional<z.ZodString>;
149
- }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
150
- code: z.ZodEffects<z.ZodString, string, string>;
151
- message: z.ZodString;
152
- surfaceId: z.ZodOptional<z.ZodString>;
153
- functionCallId: z.ZodOptional<z.ZodString>;
154
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
155
- code: z.ZodEffects<z.ZodString, string, string>;
156
- message: z.ZodString;
157
- surfaceId: z.ZodOptional<z.ZodString>;
158
- functionCallId: z.ZodOptional<z.ZodString>;
159
- }, z.ZodTypeAny, "passthrough">>]>;
160
- export type ErrorPayload = z.infer<typeof ErrorPayloadSchema>;
161
- export declare const ActionMessageSchema: z.ZodObject<{
162
- version: z.ZodLiteral<"v1.0">;
163
- action: z.ZodObject<{
164
- name: z.ZodString;
165
- surfaceId: z.ZodString;
166
- sourceComponentId: z.ZodString;
167
- /** ISO 8601 timestamp — validated as a non-empty string, not parsed as a `Date`: the real schema only declares `format: "date-time"` (an annotation, not a structural constraint zod enforces by default). */
168
- timestamp: z.ZodString;
169
- context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
170
- wantResponse: z.ZodOptional<z.ZodBoolean>;
171
- actionId: z.ZodOptional<z.ZodString>;
172
- }, "strip", z.ZodTypeAny, {
173
- name: string;
174
- surfaceId: string;
175
- context: Record<string, unknown>;
176
- sourceComponentId: string;
177
- timestamp: string;
178
- wantResponse?: boolean | undefined;
179
- actionId?: string | undefined;
180
- }, {
181
- name: string;
182
- surfaceId: string;
183
- context: Record<string, unknown>;
184
- sourceComponentId: string;
185
- timestamp: string;
186
- wantResponse?: boolean | undefined;
187
- actionId?: string | undefined;
188
- }>;
189
- }, "strict", z.ZodTypeAny, {
190
- version: "v1.0";
191
- action: {
192
- name: string;
193
- surfaceId: string;
194
- context: Record<string, unknown>;
195
- sourceComponentId: string;
196
- timestamp: string;
197
- wantResponse?: boolean | undefined;
198
- actionId?: string | undefined;
199
- };
200
- }, {
201
- version: "v1.0";
202
- action: {
203
- name: string;
204
- surfaceId: string;
205
- context: Record<string, unknown>;
206
- sourceComponentId: string;
207
- timestamp: string;
208
- wantResponse?: boolean | undefined;
209
- actionId?: string | undefined;
210
- };
211
- }>;
212
- export type ActionMessage = z.infer<typeof ActionMessageSchema>;
213
- export declare const FunctionResponseMessageSchema: z.ZodObject<{
214
- version: z.ZodLiteral<"v1.0">;
215
- functionResponse: z.ZodEffects<z.ZodObject<{
216
- functionCallId: z.ZodString;
217
- call: z.ZodString;
218
- value: z.ZodUnknown;
219
- }, "strip", z.ZodTypeAny, {
220
- call: string;
221
- functionCallId: string;
222
- value?: unknown;
223
- }, {
224
- call: string;
225
- functionCallId: string;
226
- value?: unknown;
227
- }>, {
228
- call: string;
229
- functionCallId: string;
230
- value?: unknown;
231
- }, {
232
- call: string;
233
- functionCallId: string;
234
- value?: unknown;
235
- }>;
236
- }, "strict", z.ZodTypeAny, {
237
- version: "v1.0";
238
- functionResponse: {
239
- call: string;
240
- functionCallId: string;
241
- value?: unknown;
242
- };
243
- }, {
244
- version: "v1.0";
245
- functionResponse: {
246
- call: string;
247
- functionCallId: string;
248
- value?: unknown;
249
- };
250
- }>;
251
- export type FunctionResponseMessage = z.infer<typeof FunctionResponseMessageSchema>;
252
- export declare const ErrorMessageSchema: z.ZodObject<{
253
- version: z.ZodLiteral<"v1.0">;
254
- error: z.ZodUnion<[z.ZodObject<{
255
- code: z.ZodLiteral<"VALIDATION_FAILED">;
256
- surfaceId: z.ZodString;
257
- path: z.ZodString;
258
- message: z.ZodString;
259
- }, "strict", z.ZodTypeAny, {
260
- surfaceId: string;
261
- code: "VALIDATION_FAILED";
262
- message: string;
263
- path: string;
264
- }, {
265
- surfaceId: string;
266
- code: "VALIDATION_FAILED";
267
- message: string;
268
- path: string;
269
- }>, z.ZodEffects<z.ZodObject<{
270
- code: z.ZodEffects<z.ZodString, string, string>;
271
- message: z.ZodString;
272
- surfaceId: z.ZodOptional<z.ZodString>;
273
- functionCallId: z.ZodOptional<z.ZodString>;
274
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
275
- code: z.ZodEffects<z.ZodString, string, string>;
276
- message: z.ZodString;
277
- surfaceId: z.ZodOptional<z.ZodString>;
278
- functionCallId: z.ZodOptional<z.ZodString>;
279
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
280
- code: z.ZodEffects<z.ZodString, string, string>;
281
- message: z.ZodString;
282
- surfaceId: z.ZodOptional<z.ZodString>;
283
- functionCallId: z.ZodOptional<z.ZodString>;
284
- }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
285
- code: z.ZodEffects<z.ZodString, string, string>;
286
- message: z.ZodString;
287
- surfaceId: z.ZodOptional<z.ZodString>;
288
- functionCallId: z.ZodOptional<z.ZodString>;
289
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
290
- code: z.ZodEffects<z.ZodString, string, string>;
291
- message: z.ZodString;
292
- surfaceId: z.ZodOptional<z.ZodString>;
293
- functionCallId: z.ZodOptional<z.ZodString>;
294
- }, z.ZodTypeAny, "passthrough">>]>;
295
- }, "strict", z.ZodTypeAny, {
296
- error: {
297
- surfaceId: string;
298
- code: "VALIDATION_FAILED";
299
- message: string;
300
- path: string;
301
- } | z.objectOutputType<{
302
- code: z.ZodEffects<z.ZodString, string, string>;
303
- message: z.ZodString;
304
- surfaceId: z.ZodOptional<z.ZodString>;
305
- functionCallId: z.ZodOptional<z.ZodString>;
306
- }, z.ZodTypeAny, "passthrough">;
307
- version: "v1.0";
308
- }, {
309
- error: {
310
- surfaceId: string;
311
- code: "VALIDATION_FAILED";
312
- message: string;
313
- path: string;
314
- } | z.objectInputType<{
315
- code: z.ZodEffects<z.ZodString, string, string>;
316
- message: z.ZodString;
317
- surfaceId: z.ZodOptional<z.ZodString>;
318
- functionCallId: z.ZodOptional<z.ZodString>;
319
- }, z.ZodTypeAny, "passthrough">;
320
- version: "v1.0";
321
- }>;
322
- export type ErrorMessage = z.infer<typeof ErrorMessageSchema>;
323
- export type RendererToAgentMessage = ActionMessage | FunctionResponseMessage | ErrorMessage;
324
- export declare function buildActionMessage(payload: ActionMessagePayload): ActionMessage;
325
- export declare function buildFunctionResponseMessage(payload: FunctionResponsePayload): FunctionResponseMessage;
326
- export declare function buildValidationFailedMessage(surfaceId: string, path: string, message: string): ErrorMessage;
327
- export declare function buildGenericErrorMessage(code: string, message: string, target: {
328
- surfaceId: string;
329
- } | {
330
- functionCallId: string;
331
- }): ErrorMessage;
332
- export interface RendererParseFailure {
333
- readonly ok: false;
334
- readonly reason: string;
335
- }
336
- export interface RendererParseSuccess {
337
- readonly ok: true;
338
- readonly message: RendererToAgentMessage;
339
- }
340
- /** Same "inspect the shape, validate the one matching branch" dispatcher as `parseAgentToRendererMessage` — see that function's doc for why this beats a plain `z.union`. Used by tests and by anything on the agent side of this fixture that needs to validate what the browser sent. */
341
- export declare function parseRendererToAgentMessage(raw: unknown): RendererParseSuccess | RendererParseFailure;
342
- //# sourceMappingURL=renderer-to-agent.d.ts.map
@@ -1,111 +0,0 @@
1
- /**
2
- * @module renderer-to-agent
3
- *
4
- * A2UI v1.0 renderer→agent envelope — mirrors `specification/v1_0/json/renderer_to_agent.json`
5
- * (fetched from https://github.com/a2ui-project/a2ui, `main` branch, this session). Three message
6
- * kinds, each envelope carrying `version` plus **exactly one** of `action` | `functionResponse` |
7
- * `error` (`minProperties: 2, maxProperties: 2` in the real schema — enforced below via `.refine`,
8
- * since zod's object schema has no direct min/max-properties primitive).
9
- */
10
- import { z } from 'zod';
11
- import { CallIdSchema } from './common-types.js';
12
- const PROTOCOL_VERSION = 'v1.0';
13
- /** `renderer_to_agent.json#/properties/action` — "Reports a user-initiated action from a component." */
14
- export const ActionMessagePayloadSchema = z.object({
15
- name: z.string(),
16
- surfaceId: z.string(),
17
- sourceComponentId: z.string(),
18
- /** ISO 8601 timestamp — validated as a non-empty string, not parsed as a `Date`: the real schema only declares `format: "date-time"` (an annotation, not a structural constraint zod enforces by default). */
19
- timestamp: z.string(),
20
- context: z.record(z.string(), z.unknown()),
21
- wantResponse: z.boolean().optional(),
22
- actionId: z.string().optional(),
23
- });
24
- /**
25
- * `renderer_to_agent.json#/properties/functionResponse`.
26
- *
27
- * `value` is required (`"required": ["functionCallId", "call", "value"]`), and — as with
28
- * `updateDataModel.value`, see that schema's own note — `z.unknown()` alone does not enforce a
29
- * required key in Zod 3, so a response with no `value` at all validated clean. Presence is
30
- * asserted on the object instead. JSON has no `undefined`: a function returning nothing must say
31
- * `null`, which is why `interpreter.ts` encodes a void return that way rather than omitting it.
32
- */
33
- export const FunctionResponsePayloadSchema = z
34
- .object({
35
- functionCallId: CallIdSchema,
36
- call: z.string(),
37
- value: z.unknown(),
38
- })
39
- .refine((payload) => 'value' in payload, {
40
- message: 'functionResponse requires an explicit "value" (use null for a function that returns nothing)',
41
- path: ['value'],
42
- });
43
- /**
44
- * `renderer_to_agent.json#/properties/error` — two mutually-exclusive shapes: a `VALIDATION_FAILED`
45
- * error (always carries `surfaceId` + a JSON-Pointer `path`), or a generic error (any other `code`,
46
- * carrying exactly one of `surfaceId` XOR `functionCallId`).
47
- */
48
- export const ValidationFailedErrorSchema = z
49
- .object({
50
- code: z.literal('VALIDATION_FAILED'),
51
- surfaceId: z.string(),
52
- path: z.string(),
53
- message: z.string(),
54
- })
55
- .strict();
56
- export const GenericErrorSchema = z
57
- .object({
58
- code: z.string().refine((c) => c !== 'VALIDATION_FAILED', 'code must not be VALIDATION_FAILED here'),
59
- message: z.string(),
60
- surfaceId: z.string().optional(),
61
- functionCallId: CallIdSchema.optional(),
62
- })
63
- .passthrough()
64
- .refine((v) => ('surfaceId' in v) !== ('functionCallId' in v), 'exactly one of surfaceId/functionCallId is required');
65
- export const ErrorPayloadSchema = z.union([ValidationFailedErrorSchema, GenericErrorSchema]);
66
- export const ActionMessageSchema = z
67
- .object({ version: z.literal(PROTOCOL_VERSION), action: ActionMessagePayloadSchema })
68
- .strict();
69
- export const FunctionResponseMessageSchema = z
70
- .object({ version: z.literal(PROTOCOL_VERSION), functionResponse: FunctionResponsePayloadSchema })
71
- .strict();
72
- export const ErrorMessageSchema = z
73
- .object({ version: z.literal(PROTOCOL_VERSION), error: ErrorPayloadSchema })
74
- .strict();
75
- export function buildActionMessage(payload) {
76
- return { version: PROTOCOL_VERSION, action: payload };
77
- }
78
- export function buildFunctionResponseMessage(payload) {
79
- return { version: PROTOCOL_VERSION, functionResponse: payload };
80
- }
81
- export function buildValidationFailedMessage(surfaceId, path, message) {
82
- return { version: PROTOCOL_VERSION, error: { code: 'VALIDATION_FAILED', surfaceId, path, message } };
83
- }
84
- export function buildGenericErrorMessage(code, message, target) {
85
- return { version: PROTOCOL_VERSION, error: { code, message, ...target } };
86
- }
87
- const MESSAGE_KEYS = ['action', 'functionResponse', 'error'];
88
- /** Same "inspect the shape, validate the one matching branch" dispatcher as `parseAgentToRendererMessage` — see that function's doc for why this beats a plain `z.union`. Used by tests and by anything on the agent side of this fixture that needs to validate what the browser sent. */
89
- export function parseRendererToAgentMessage(raw) {
90
- if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
91
- return { ok: false, reason: 'envelope must be a JSON object' };
92
- }
93
- const obj = raw;
94
- if (obj.version !== PROTOCOL_VERSION) {
95
- return { ok: false, reason: `envelope declares version ${JSON.stringify(obj.version)}, expected "${PROTOCOL_VERSION}"` };
96
- }
97
- const presentKeys = MESSAGE_KEYS.filter((key) => key in obj);
98
- if (presentKeys.length !== 1) {
99
- return { ok: false, reason: `expected exactly one of ${MESSAGE_KEYS.join(', ')}, found ${presentKeys.length}` };
100
- }
101
- const key = presentKeys[0];
102
- const schema = key === 'action' ? ActionMessageSchema : key === 'functionResponse' ? FunctionResponseMessageSchema : ErrorMessageSchema;
103
- const result = schema.safeParse(obj);
104
- if (!result.success) {
105
- // Same zod guarantee as `parseAgentToRendererMessage` relies on: `success: false` implies a
106
- // non-empty `issues` array — see that function's comment for why this is asserted, not branched.
107
- return { ok: false, reason: result.error.issues[0].message };
108
- }
109
- return { ok: true, message: result.data };
110
- }
111
- //# sourceMappingURL=renderer-to-agent.js.map
@@ -1,28 +0,0 @@
1
- import type { Catalog } from './catalog.js';
2
- export type ResolveSide = 'renderer' | 'agent';
3
- /** Set while resolving one item of a `ChildList` template (`common_types.json`'s "Collection Scope"): relative (no leading `/`) `DataBinding` paths resolve under `${basePath}/${index}/...` instead of the data-model root. */
4
- export interface ItemScope {
5
- readonly basePath: string;
6
- readonly index: number;
7
- }
8
- export interface ResolveContext {
9
- readonly dataModel: unknown;
10
- readonly catalog: Catalog;
11
- /** Which side is *evaluating* this binding — the renderer resolving a component's own props (`'renderer'`), or something acting on the agent's behalf. A2UI's spec doesn't explicitly name a case where the agent-side evaluates a `Dynamic*` binding (that's a renderer-only concept — the agent only ever sends `callFunction` for direct RPC), but `callableFromOf` is checked against this side regardless, so a future agent-side evaluator (e.g. resolving `action.event.context` bindings before dispatch — which today happens on the renderer, see `interpreter.ts`'s `buildAction`) is covered by the same boundary without a second resolver. */
12
- readonly side: ResolveSide;
13
- readonly itemScope?: ItemScope;
14
- }
15
- export type ResolveFailureReason = 'PATH_NOT_FOUND' | 'FUNCTION_NOT_REGISTERED' | 'FUNCTION_NOT_CALLABLE_FROM_SIDE' | 'FUNCTION_NOT_IMPLEMENTED' | 'FUNCTION_THREW' | 'INDEX_OUTSIDE_LIST_CONTEXT' | 'RELATIVE_PATH_OUTSIDE_LIST_CONTEXT';
16
- export interface ResolveFailure {
17
- readonly ok: false;
18
- readonly reason: ResolveFailureReason;
19
- readonly detail: string;
20
- }
21
- export interface ResolveOk {
22
- readonly ok: true;
23
- readonly value: unknown;
24
- }
25
- export type ResolveResult = ResolveOk | ResolveFailure;
26
- /** Resolves any `Dynamic*` value (`DynamicString`/`DynamicNumber`/`DynamicBoolean`/`DynamicStringList`/`DynamicValue` all share this one shape: literal | `DataBinding` | `FunctionCall`). */
27
- export declare function resolveDynamicValue(value: unknown, ctx: ResolveContext): ResolveResult;
28
- //# sourceMappingURL=resolve.d.ts.map
@@ -1,144 +0,0 @@
1
- /**
2
- * @module resolve
3
- *
4
- * Resolves A2UI's `Dynamic*` binding types (literal | `DataBinding` | `FunctionCall`) against a
5
- * surface's data model. This is the piece the task brief called out as GenUI/AG-UI having no
6
- * equivalent of: AG-UI's `state_update` event is "some path changed, some value" with no binding
7
- * *resolution* step — A2UI's `Dynamic*` types are unresolved references a renderer must actively
8
- * walk the data model to answer.
9
- *
10
- * **Never throws.** Every failure mode (a path that doesn't resolve, a function that isn't
11
- * registered, a function that crosses a `callableFrom` boundary it isn't allowed to cross, a
12
- * registered function whose implementation throws on the arguments it was handed, `@index`
13
- * used outside a list-template context) returns a tagged `ResolveFailure` instead — this is the
14
- * direct answer to this task's adversarial question "a binding whose path doesn't resolve — does
15
- * it crash or degrade sanely?": it degrades sanely, always, by construction (no code path in this
16
- * module can throw on bad *input data*; only a genuine programming error, e.g. calling this module
17
- * incorrectly, would).
18
- */
19
- import { getAtPointer, joinPointer, parsePointerTokens } from './json-pointer.js';
20
- import { callableFromOf, isFunctionRegistered } from './catalog.js';
21
- /**
22
- * `path` must actually be a *string*, not merely present — the same check `isFunctionCall` already
23
- * makes on `call`, and its absence here was a live crash rather than a nicety. `FunctionCall.args`
24
- * accepts a plain object (`common-types.ts`'s `ArgValueSchema` record branch), so an agent could
25
- * send `{path: 7}` as an arg, pass wire validation, get classified as a binding here, and blow up
26
- * on `path.startsWith` inside `resolveBindingPath` — a throw straight out through
27
- * `applyAgentMessage`, which this module's own doc says cannot happen.
28
- */
29
- function isDataBinding(value) {
30
- return typeof value === 'object'
31
- && value !== null
32
- && !Array.isArray(value)
33
- && 'path' in value
34
- && typeof value.path === 'string'
35
- && Object.keys(value).length === 1;
36
- }
37
- function isFunctionCall(value) {
38
- return typeof value === 'object' && value !== null && !Array.isArray(value) && 'call' in value && typeof value.call === 'string';
39
- }
40
- function resolveBindingPath(path, ctx) {
41
- // A relative path is still RFC 6901 syntax, so its `~0`/`~1` escapes must be decoded into real
42
- // token text before `joinPointer` re-escapes them. Splitting the raw string on `/` instead would
43
- // hand `joinPointer` already-escaped text and double-escape it, making a relative `a~1b` resolve
44
- // the literal key `a~1b` while the equivalent absolute pointer correctly resolves `a/b`.
45
- const absolute = path.startsWith('/')
46
- ? path
47
- : ctx.itemScope
48
- ? joinPointer(ctx.itemScope.basePath, String(ctx.itemScope.index), ...parsePointerTokens(`/${path}`))
49
- : null;
50
- if (absolute === null) {
51
- return { ok: false, reason: 'RELATIVE_PATH_OUTSIDE_LIST_CONTEXT', detail: `relative path "${path}" used outside a list-template item context` };
52
- }
53
- const result = getAtPointer(ctx.dataModel, absolute);
54
- if (!result.found) {
55
- return { ok: false, reason: 'PATH_NOT_FOUND', detail: `no value at "${absolute}" in the current data model` };
56
- }
57
- return { ok: true, value: result.value };
58
- }
59
- function resolveFunctionCall(call, ctx) {
60
- if (call.call === '@index') {
61
- if (!ctx.itemScope) {
62
- return { ok: false, reason: 'INDEX_OUTSIDE_LIST_CONTEXT', detail: '@index used outside a list-template item context' };
63
- }
64
- const offsetArg = call.args?.offset;
65
- const offsetResult = offsetArg === undefined ? { ok: true, value: 0 } : resolveDynamicValue(offsetArg, ctx);
66
- if (!offsetResult.ok)
67
- return offsetResult;
68
- const offset = typeof offsetResult.value === 'number' ? offsetResult.value : 0;
69
- return { ok: true, value: ctx.itemScope.index + offset };
70
- }
71
- if (!isFunctionRegistered(ctx.catalog, call.call)) {
72
- return { ok: false, reason: 'FUNCTION_NOT_REGISTERED', detail: `function "${call.call}" is not registered in catalog "${ctx.catalog.catalogId}"` };
73
- }
74
- const callableFrom = callableFromOf(ctx.catalog, call.call);
75
- const allowed = callableFrom === 'rendererOrAgent' || (callableFrom === 'rendererOnly' && ctx.side === 'renderer') || (callableFrom === 'agentOnly' && ctx.side === 'agent');
76
- if (!allowed) {
77
- return {
78
- ok: false,
79
- reason: 'FUNCTION_NOT_CALLABLE_FROM_SIDE',
80
- detail: `function "${call.call}" has callableFrom="${callableFrom}", not callable from the "${ctx.side}" side`,
81
- };
82
- }
83
- const spec = ctx.catalog.functions.get(call.call);
84
- if (!spec?.impl) {
85
- return { ok: false, reason: 'FUNCTION_NOT_IMPLEMENTED', detail: `function "${call.call}" is registered but this renderer has no implementation for it` };
86
- }
87
- const resolvedArgs = {};
88
- for (const [key, argValue] of Object.entries(call.args ?? {})) {
89
- const argResult = resolveArgValue(argValue, ctx);
90
- if (!argResult.ok)
91
- return argResult;
92
- resolvedArgs[key] = argResult.value;
93
- }
94
- // `impl` is host-supplied code handed agent-supplied arguments, and this module validates
95
- // neither against the other (the catalog's per-function arg schemas are not implemented — see
96
- // `catalog.ts`'s module doc). An entirely ordinary implementation therefore throws the moment an
97
- // agent sends the wrong shape (`args.name.toUpperCase()` on a number), and that throw used to
98
- // travel out through `applyAgentMessage` into the host's render, where nothing catches it. It is
99
- // a resolution failure like any other: reported, not propagated.
100
- try {
101
- return { ok: true, value: spec.impl(resolvedArgs) };
102
- }
103
- catch (error) {
104
- const detail = error instanceof Error ? error.message : String(error);
105
- return { ok: false, reason: 'FUNCTION_THREW', detail: `function "${call.call}" threw while evaluating: ${detail}` };
106
- }
107
- }
108
- /**
109
- * Resolves one `FunctionCall` arg value, recursing into arrays element-by-element. Real
110
- * basic-catalog functions commonly type an arg as an *array* of `Dynamic*` values (e.g. `and`/`or`'s
111
- * `values: DynamicBoolean[]`, confirmed against `specification/v1_0/catalogs/basic/catalog.json`'s
112
- * own function definitions and the spec repo's `button_checks.json` conformance fixture, both
113
- * fetched this session) — `common_types.json`'s generic `DynamicValue` schema's own `array` branch
114
- * has no `items` sub-schema (it does not itself promise recursive binding resolution), so this
115
- * per-element recursion is a deliberate generalization by this port, not a literal requirement of
116
- * that one generic type — done because without it, an array-of-`DynamicBoolean` arg's own nested
117
- * `DataBinding`/`FunctionCall` entries would pass through unresolved (as raw, non-boolean objects)
118
- * to a function's `impl`, silently producing wrong results instead of a clean failure or a correct
119
- * answer. `resolveDynamicValue` itself is left alone (a literal-array `DynamicValue` at the top
120
- * level — e.g. a `DynamicStringList`'s literal-array branch — still passes through as-is, matching
121
- * the generic type's own contract); only this arg-resolution path recurses.
122
- */
123
- function resolveArgValue(argValue, ctx) {
124
- if (Array.isArray(argValue)) {
125
- const resolvedItems = [];
126
- for (const item of argValue) {
127
- const itemResult = resolveArgValue(item, ctx);
128
- if (!itemResult.ok)
129
- return itemResult;
130
- resolvedItems.push(itemResult.value);
131
- }
132
- return { ok: true, value: resolvedItems };
133
- }
134
- return resolveDynamicValue(argValue, ctx);
135
- }
136
- /** Resolves any `Dynamic*` value (`DynamicString`/`DynamicNumber`/`DynamicBoolean`/`DynamicStringList`/`DynamicValue` all share this one shape: literal | `DataBinding` | `FunctionCall`). */
137
- export function resolveDynamicValue(value, ctx) {
138
- if (isDataBinding(value))
139
- return resolveBindingPath(value.path, ctx);
140
- if (isFunctionCall(value))
141
- return resolveFunctionCall(value, ctx);
142
- return { ok: true, value };
143
- }
144
- //# sourceMappingURL=resolve.js.map