@jini-ai/agentic 0.3.7 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -0
- package/README.md +33 -6
- package/dist/core/a2ui/agent-to-renderer.d.ts +3 -1
- package/dist/core/a2ui/agent-to-renderer.js +1 -1
- package/dist/core/a2ui/catalog.d.ts +14 -5
- package/dist/core/a2ui/catalog.js +5 -5
- package/dist/core/a2ui/common-types.d.ts +11 -3
- package/dist/core/a2ui/common-types.js +5 -3
- package/dist/core/a2ui/index.d.ts +1 -1
- package/dist/core/a2ui/index.js +1 -1
- package/dist/core/a2ui/interpreter.d.ts +45 -10
- package/dist/core/a2ui/interpreter.js +38 -43
- package/dist/core/a2ui/json-pointer.d.ts +16 -4
- package/dist/core/a2ui/json-pointer.js +7 -7
- package/dist/core/a2ui/renderer-to-agent.d.ts +22 -8
- package/dist/core/a2ui/renderer-to-agent.js +5 -5
- package/dist/core/a2ui/resolve.d.ts +7 -2
- package/dist/core/a2ui/resolve.js +10 -9
- package/dist/core/a2ui/tree.d.ts +8 -2
- package/dist/core/a2ui/tree.js +2 -2
- package/dist/core/ag-ui.d.ts +17 -9
- package/dist/core/ag-ui.js +4 -4
- package/dist/core/annotated-actions-script.d.ts +13 -0
- package/dist/core/annotated-actions-script.js +137 -0
- package/dist/core/capability.d.ts +12 -3
- package/dist/core/capability.js +3 -3
- package/dist/core/dom/dom-page-driver.d.ts +8 -4
- package/dist/core/dom/dom-page-driver.js +19 -20
- package/dist/core/dom/index.d.ts +3 -3
- package/dist/core/dom/index.js +1 -1
- package/dist/core/dom/model-context.d.ts +18 -8
- package/dist/core/dom/model-context.js +12 -15
- package/dist/core/dom/native-model-context.d.ts +6 -0
- package/dist/core/dom/native-model-context.js +19 -0
- package/dist/core/element-handles.d.ts +6 -2
- package/dist/core/element-handles.js +3 -3
- package/dist/core/gen-ui/encoder.d.ts +21 -11
- package/dist/core/gen-ui/encoder.js +8 -7
- package/dist/core/gen-ui/events.d.ts +6 -5
- package/dist/core/gen-ui/events.js +6 -5
- package/dist/core/gen-ui/index.d.ts +1 -1
- package/dist/core/gen-ui/index.js +1 -1
- package/dist/core/guards.d.ts +17 -5
- package/dist/core/guards.js +6 -6
- package/dist/core/handle.d.ts +12 -5
- package/dist/core/handle.js +9 -8
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +3 -1
- package/dist/core/list-handles.d.ts +4 -1
- package/dist/core/list-handles.js +1 -1
- package/dist/core/mcp-ui-apps.d.ts +39 -9
- package/dist/core/mcp-ui-apps.js +10 -8
- package/dist/core/messages.d.ts +6 -0
- package/dist/core/messages.js +6 -0
- package/dist/core/page-capabilities.d.ts +0 -11
- package/dist/core/page-capabilities.js +13 -1
- package/dist/core/page-driver.d.ts +32 -11
- package/dist/core/page-executor.d.ts +8 -2
- package/dist/core/page-executor.js +31 -31
- package/dist/core/webmcp.d.ts +27 -8
- package/dist/core/webmcp.js +14 -14
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/skills/install/archive.d.ts +8 -0
- package/dist/skills/install/archive.js +47 -0
- package/dist/skills/install/fetch-adapter.d.ts +6 -0
- package/dist/skills/install/fetch-adapter.js +6 -0
- package/dist/skills/install/github.d.ts +21 -0
- package/dist/skills/install/github.js +92 -0
- package/dist/skills/install/index.d.ts +11 -0
- package/dist/skills/install/index.js +11 -0
- package/dist/skills/install/install-service.d.ts +44 -0
- package/dist/skills/install/install-service.js +121 -0
- package/dist/skills/install/layout.d.ts +13 -0
- package/dist/skills/install/layout.js +22 -0
- package/dist/skills/install/live-registration.d.ts +61 -0
- package/dist/skills/install/live-registration.js +64 -0
- package/dist/skills/install/node-filesystem.d.ts +4 -0
- package/dist/skills/install/node-filesystem.js +41 -0
- package/dist/skills/install/ports.d.ts +101 -0
- package/dist/skills/install/ports.js +2 -0
- package/dist/skills/install/state.d.ts +13 -0
- package/dist/skills/install/state.js +23 -0
- package/dist/skills/install/validation.d.ts +45 -0
- package/dist/skills/install/validation.js +104 -0
- package/package.json +20 -5
- package/dist/a2ui/agent-to-renderer.d.ts +0 -613
- package/dist/a2ui/agent-to-renderer.js +0 -191
- package/dist/a2ui/catalog.d.ts +0 -73
- package/dist/a2ui/catalog.js +0 -304
- package/dist/a2ui/common-types.d.ts +0 -401
- package/dist/a2ui/common-types.js +0 -130
- package/dist/a2ui/index.d.ts +0 -16
- package/dist/a2ui/index.js +0 -16
- package/dist/a2ui/interpreter.d.ts +0 -71
- package/dist/a2ui/interpreter.js +0 -337
- package/dist/a2ui/json-pointer.d.ts +0 -48
- package/dist/a2ui/json-pointer.js +0 -174
- package/dist/a2ui/renderer-to-agent.d.ts +0 -342
- package/dist/a2ui/renderer-to-agent.js +0 -111
- package/dist/a2ui/resolve.d.ts +0 -28
- package/dist/a2ui/resolve.js +0 -144
- package/dist/a2ui/tree.d.ts +0 -66
- package/dist/a2ui/tree.js +0 -74
- package/dist/ag-ui.d.ts +0 -82
- package/dist/ag-ui.js +0 -85
- package/dist/agui/encoder.d.ts +0 -50
- package/dist/agui/encoder.js +0 -97
- package/dist/agui/events.d.ts +0 -59
- package/dist/agui/events.js +0 -15
- package/dist/capability.d.ts +0 -81
- package/dist/capability.js +0 -79
- package/dist/dom/dom-page-driver.d.ts +0 -36
- package/dist/dom/dom-page-driver.js +0 -601
- package/dist/dom/index.d.ts +0 -17
- package/dist/dom/index.js +0 -17
- package/dist/dom/model-context.d.ts +0 -69
- package/dist/dom/model-context.js +0 -44
- package/dist/element-handles.d.ts +0 -120
- package/dist/element-handles.js +0 -39
- package/dist/gen-ui/encoder.d.ts +0 -50
- package/dist/gen-ui/encoder.js +0 -97
- package/dist/gen-ui/events.d.ts +0 -59
- package/dist/gen-ui/events.js +0 -15
- package/dist/gen-ui/index.d.ts +0 -18
- package/dist/gen-ui/index.js +0 -17
- package/dist/guards.d.ts +0 -96
- package/dist/guards.js +0 -186
- package/dist/handle.d.ts +0 -41
- package/dist/handle.js +0 -41
- package/dist/mcp-ui-apps.d.ts +0 -223
- package/dist/mcp-ui-apps.js +0 -252
- package/dist/mcp-ui.d.ts +0 -133
- package/dist/mcp-ui.js +0 -134
- package/dist/page-capabilities.d.ts +0 -14
- package/dist/page-capabilities.js +0 -129
- package/dist/page-driver.d.ts +0 -120
- package/dist/page-driver.js +0 -2
- package/dist/page-executor.d.ts +0 -94
- package/dist/page-executor.js +0 -320
- package/dist/webmcp.d.ts +0 -202
- package/dist/webmcp.js +0 -173
|
@@ -46,12 +46,7 @@ import { buildActionMessage, buildFunctionResponseMessage, buildGenericErrorMess
|
|
|
46
46
|
import { setAtPointer } from './json-pointer.js';
|
|
47
47
|
import { isComponentAllowed } from './catalog.js';
|
|
48
48
|
import { resolveDynamicValue } from './resolve.js';
|
|
49
|
-
import {
|
|
50
|
-
let actionIdCounter = 0;
|
|
51
|
-
function nextActionId() {
|
|
52
|
-
actionIdCounter += 1;
|
|
53
|
-
return `a2ui-action-${actionIdCounter}-${Date.now().toString(36)}`;
|
|
54
|
-
}
|
|
49
|
+
import {} from './common-types.js';
|
|
55
50
|
/**
|
|
56
51
|
* Best-effort `surfaceId` extraction from a raw envelope's message-type-keyed body, without
|
|
57
52
|
* assuming the envelope is well-formed. Used only to attribute a parse failure to a surface when
|
|
@@ -77,7 +72,7 @@ function bestEffortSurfaceId(raw, key) {
|
|
|
77
72
|
* Exported and pure — it only reads `parsed`/`raw`, so the surfaceId-attribution rule can be
|
|
78
73
|
* tested directly, without a live interpreter instance.
|
|
79
74
|
*/
|
|
80
|
-
export function buildParseFailureResult(parsed, raw) {
|
|
75
|
+
export function buildParseFailureResult({ parsed, raw }, _optional = {}) {
|
|
81
76
|
if (parsed.code === 'MISSING_VERSION'
|
|
82
77
|
|| parsed.code === 'UNSUPPORTED_VERSION'
|
|
83
78
|
|| parsed.code === 'NO_MESSAGE_KEY'
|
|
@@ -103,7 +98,7 @@ export function buildParseFailureResult(parsed, raw) {
|
|
|
103
98
|
// (`bestEffortSurfaceId` requires that) — so this specific combination (object-shaped raw,
|
|
104
99
|
// yet no `path`) cannot occur. Asserted, not defensively branched, per this package's
|
|
105
100
|
// testing discipline (see the zod-issues-array comments elsewhere in this file).
|
|
106
|
-
return { rendererMessages: [buildValidationFailedMessage(surfaceId, parsed.path, parsed.message)] };
|
|
101
|
+
return { rendererMessages: [buildValidationFailedMessage({ surfaceId, path: parsed.path, message: parsed.message })] };
|
|
107
102
|
}
|
|
108
103
|
return { rendererMessages: [], unattributedViolation: parsed.message };
|
|
109
104
|
}
|
|
@@ -116,23 +111,23 @@ export function buildParseFailureResult(parsed, raw) {
|
|
|
116
111
|
* data model, and a resolution failure becomes a typed refusal rather than a thrown error" can be
|
|
117
112
|
* tested without a live interpreter instance.
|
|
118
113
|
*/
|
|
119
|
-
export function runLocalFunctionAction(dataModel, catalog, action) {
|
|
120
|
-
const result = resolveDynamicValue(action.functionCall, { dataModel, catalog, side: 'renderer' });
|
|
114
|
+
export function runLocalFunctionAction({ dataModel, catalog, action }, _optional = {}) {
|
|
115
|
+
const result = resolveDynamicValue({ value: action.functionCall, ctx: { dataModel, catalog, side: 'renderer' } });
|
|
121
116
|
return result.ok ? { ok: true, kind: 'local', result: result.value } : { ok: false, reason: result.detail };
|
|
122
117
|
}
|
|
123
|
-
export function createA2uiInterpreter(catalog) {
|
|
118
|
+
export function createA2uiInterpreter({ catalog, clock, ids }, _optional = {}) {
|
|
124
119
|
const surfaces = new Map();
|
|
125
120
|
const listeners = new Set();
|
|
126
121
|
function notify() {
|
|
127
122
|
for (const listener of listeners)
|
|
128
|
-
listener();
|
|
123
|
+
listener({});
|
|
129
124
|
}
|
|
130
125
|
function applyComponentsList(surface, wireComponents) {
|
|
131
126
|
const errors = [];
|
|
132
127
|
wireComponents.forEach((wireComponent, index) => {
|
|
133
128
|
const { id, component: type, ...rest } = wireComponent;
|
|
134
|
-
if (!isComponentAllowed(catalog, type)) {
|
|
135
|
-
errors.push(buildValidationFailedMessage(surface.surfaceId, `/components/${index}/component`, `Component type "${type}" is not in catalog "${catalog.catalogId}" — refused, not rendered.`));
|
|
129
|
+
if (!isComponentAllowed({ catalog, componentType: type })) {
|
|
130
|
+
errors.push(buildValidationFailedMessage({ surfaceId: surface.surfaceId, path: `/components/${index}/component`, message: `Component type "${type}" is not in catalog "${catalog.catalogId}" — refused, not rendered.` }));
|
|
136
131
|
return;
|
|
137
132
|
}
|
|
138
133
|
const spec = catalog.components.get(type);
|
|
@@ -145,7 +140,7 @@ export function createA2uiInterpreter(catalog) {
|
|
|
145
140
|
// instead, so it has to be spliced back in here or the only place a human sees this (this
|
|
146
141
|
// string, not the sibling `path` pointer on the built message) never says which prop.
|
|
147
142
|
const field = issue.path.length > 0 ? issue.path.join('.') : '(root)';
|
|
148
|
-
errors.push(buildValidationFailedMessage(surface.surfaceId, `/components/${index}/${issue.path.join('/')}`, `Component "${id}" (${type}) failed catalog validation: ${field}: ${issue.message}`));
|
|
143
|
+
errors.push(buildValidationFailedMessage({ surfaceId: surface.surfaceId, path: `/components/${index}/${issue.path.join('/')}`, message: `Component "${id}" (${type}) failed catalog validation: ${field}: ${issue.message}` }));
|
|
149
144
|
return;
|
|
150
145
|
}
|
|
151
146
|
surface.components.set(id, { id, component: type, props: parsed.data });
|
|
@@ -155,10 +150,10 @@ export function createA2uiInterpreter(catalog) {
|
|
|
155
150
|
function handleCreateSurface(message) {
|
|
156
151
|
const { surfaceId, catalogId, components, dataModel } = message.createSurface;
|
|
157
152
|
if (catalogId !== catalog.catalogId) {
|
|
158
|
-
return [buildValidationFailedMessage(surfaceId, '/createSurface/catalogId', `Unknown catalogId "${catalogId}" — this renderer only has "${catalog.catalogId}" loaded.`)];
|
|
153
|
+
return [buildValidationFailedMessage({ surfaceId, path: '/createSurface/catalogId', message: `Unknown catalogId "${catalogId}" — this renderer only has "${catalog.catalogId}" loaded.` })];
|
|
159
154
|
}
|
|
160
155
|
if (surfaces.has(surfaceId)) {
|
|
161
|
-
return [buildValidationFailedMessage(surfaceId, '/createSurface/surfaceId', `Surface "${surfaceId}" already exists — delete it before recreating (per spec).`)];
|
|
156
|
+
return [buildValidationFailedMessage({ surfaceId, path: '/createSurface/surfaceId', message: `Surface "${surfaceId}" already exists — delete it before recreating (per spec).` })];
|
|
162
157
|
}
|
|
163
158
|
const surface = {
|
|
164
159
|
surfaceId,
|
|
@@ -175,7 +170,7 @@ export function createA2uiInterpreter(catalog) {
|
|
|
175
170
|
const { surfaceId, components } = message.updateComponents;
|
|
176
171
|
const surface = surfaces.get(surfaceId);
|
|
177
172
|
if (!surface) {
|
|
178
|
-
return [buildValidationFailedMessage(surfaceId, '/updateComponents/surfaceId', `Unknown surfaceId "${surfaceId}" — createSurface must be sent first.`)];
|
|
173
|
+
return [buildValidationFailedMessage({ surfaceId, path: '/updateComponents/surfaceId', message: `Unknown surfaceId "${surfaceId}" — createSurface must be sent first.` })];
|
|
179
174
|
}
|
|
180
175
|
return applyComponentsList(surface, components);
|
|
181
176
|
}
|
|
@@ -183,15 +178,15 @@ export function createA2uiInterpreter(catalog) {
|
|
|
183
178
|
const { surfaceId, path, value } = message.updateDataModel;
|
|
184
179
|
const surface = surfaces.get(surfaceId);
|
|
185
180
|
if (!surface) {
|
|
186
|
-
return [buildValidationFailedMessage(surfaceId, '/updateDataModel/surfaceId', `Unknown surfaceId "${surfaceId}" — createSurface must be sent first.`)];
|
|
181
|
+
return [buildValidationFailedMessage({ surfaceId, path: '/updateDataModel/surfaceId', message: `Unknown surfaceId "${surfaceId}" — createSurface must be sent first.` })];
|
|
187
182
|
}
|
|
188
|
-
surface.dataModel = setAtPointer(surface.dataModel, path ?? '/', value);
|
|
183
|
+
surface.dataModel = setAtPointer({ doc: surface.dataModel, pointer: path ?? '/', value });
|
|
189
184
|
return [];
|
|
190
185
|
}
|
|
191
186
|
function handleDeleteSurface(message) {
|
|
192
187
|
const { surfaceId } = message.deleteSurface;
|
|
193
188
|
if (!surfaces.has(surfaceId)) {
|
|
194
|
-
return [buildValidationFailedMessage(surfaceId, '/deleteSurface/surfaceId', `Unknown surfaceId "${surfaceId}" — nothing to delete.`)];
|
|
189
|
+
return [buildValidationFailedMessage({ surfaceId, path: '/deleteSurface/surfaceId', message: `Unknown surfaceId "${surfaceId}" — nothing to delete.` })];
|
|
195
190
|
}
|
|
196
191
|
// Dropping the whole SurfaceState also drops its pendingActions map — any actionResponse that
|
|
197
192
|
// arrives afterward for an actionId that lived here simply won't be found (handled gracefully
|
|
@@ -202,10 +197,10 @@ export function createA2uiInterpreter(catalog) {
|
|
|
202
197
|
}
|
|
203
198
|
function handleCallFunction(message) {
|
|
204
199
|
const { functionCallId, callFunction, wantResponse } = message;
|
|
205
|
-
const result = resolveDynamicValue(callFunction, { dataModel: undefined, catalog, side: 'agent' });
|
|
200
|
+
const result = resolveDynamicValue({ value: callFunction, ctx: { dataModel: undefined, catalog, side: 'agent' } });
|
|
206
201
|
if (!result.ok) {
|
|
207
202
|
const code = result.reason === 'FUNCTION_NOT_CALLABLE_FROM_SIDE' || result.reason === 'FUNCTION_NOT_REGISTERED' ? 'INVALID_FUNCTION_CALL' : result.reason;
|
|
208
|
-
return [buildGenericErrorMessage(code, result.detail, { functionCallId })];
|
|
203
|
+
return [buildGenericErrorMessage({ code, message: result.detail, target: { functionCallId } })];
|
|
209
204
|
}
|
|
210
205
|
if (!wantResponse)
|
|
211
206
|
return [];
|
|
@@ -213,7 +208,7 @@ export function createA2uiInterpreter(catalog) {
|
|
|
213
208
|
// `undefined`: a `returnType: 'void'` function (the catalog has three) resolves to
|
|
214
209
|
// `undefined`, and passing that straight through built a message whose `value` vanished on
|
|
215
210
|
// serialization — one this package's own `parseRendererToAgentMessage` correctly refuses.
|
|
216
|
-
return [buildFunctionResponseMessage({ functionCallId, call: callFunction.call, value: result.value ?? null })];
|
|
211
|
+
return [buildFunctionResponseMessage({ payload: { functionCallId, call: callFunction.call, value: result.value ?? null } })];
|
|
217
212
|
}
|
|
218
213
|
function handleActionResponse(message) {
|
|
219
214
|
const { actionId, actionResponse } = message;
|
|
@@ -223,7 +218,7 @@ export function createA2uiInterpreter(catalog) {
|
|
|
223
218
|
continue;
|
|
224
219
|
surface.pendingActions.delete(actionId);
|
|
225
220
|
if ('value' in actionResponse && pending.responsePath) {
|
|
226
|
-
surface.dataModel = setAtPointer(surface.dataModel, pending.responsePath, actionResponse.value);
|
|
221
|
+
surface.dataModel = setAtPointer({ doc: surface.dataModel, pointer: pending.responsePath, value: actionResponse.value });
|
|
227
222
|
}
|
|
228
223
|
return [];
|
|
229
224
|
}
|
|
@@ -246,32 +241,32 @@ export function createA2uiInterpreter(catalog) {
|
|
|
246
241
|
return handleCallFunction(message);
|
|
247
242
|
return handleActionResponse(message);
|
|
248
243
|
}
|
|
249
|
-
function applyAgentMessage(raw) {
|
|
250
|
-
const parsed = parseAgentToRendererMessage(raw);
|
|
244
|
+
function applyAgentMessage({ raw }, _optional = {}) {
|
|
245
|
+
const parsed = parseAgentToRendererMessage({ raw });
|
|
251
246
|
if (!parsed.ok)
|
|
252
|
-
return buildParseFailureResult(parsed, raw);
|
|
247
|
+
return buildParseFailureResult({ parsed, raw });
|
|
253
248
|
const rendererMessages = dispatchAgentMessage(parsed.message);
|
|
254
249
|
notify();
|
|
255
250
|
return { rendererMessages };
|
|
256
251
|
}
|
|
257
|
-
function getSurface(surfaceId) {
|
|
252
|
+
function getSurface({ surfaceId }, _optional = {}) {
|
|
258
253
|
const surface = surfaces.get(surfaceId);
|
|
259
254
|
if (!surface)
|
|
260
255
|
return undefined;
|
|
261
256
|
return { surfaceId: surface.surfaceId, catalogId: surface.catalogId, components: surface.components, dataModel: surface.dataModel };
|
|
262
257
|
}
|
|
263
|
-
function getRoot(surfaceId) {
|
|
258
|
+
function getRoot({ surfaceId }, _optional = {}) {
|
|
264
259
|
return surfaces.get(surfaceId)?.components.get('root');
|
|
265
260
|
}
|
|
266
|
-
function resolve(surfaceId, value, itemBasePath, itemIndex) {
|
|
261
|
+
function resolve({ surfaceId, value }, { itemBasePath, itemIndex } = {}) {
|
|
267
262
|
const surface = surfaces.get(surfaceId);
|
|
268
263
|
const itemScope = itemBasePath !== undefined && itemIndex !== undefined ? { basePath: itemBasePath, index: itemIndex } : undefined;
|
|
269
|
-
return resolveDynamicValue(value, { dataModel: surface?.dataModel, catalog, side: 'renderer'
|
|
264
|
+
return resolveDynamicValue({ value, ctx: { dataModel: surface?.dataModel, catalog, side: 'renderer' } }, { itemScope });
|
|
270
265
|
}
|
|
271
266
|
function resolveActionContext(context, surfaceId) {
|
|
272
267
|
const resolved = {};
|
|
273
268
|
for (const [key, value] of Object.entries(context ?? {})) {
|
|
274
|
-
const result = resolve(surfaceId, value);
|
|
269
|
+
const result = resolve({ surfaceId, value });
|
|
275
270
|
resolved[key] = result.ok ? result.value : null;
|
|
276
271
|
}
|
|
277
272
|
return resolved;
|
|
@@ -292,7 +287,7 @@ export function createA2uiInterpreter(catalog) {
|
|
|
292
287
|
/** Builds the `action` wire envelope for an agent-event action, registering a pending response if `wantResponse` was set. */
|
|
293
288
|
function buildAgentEventAction(surface, surfaceId, componentId, event, now) {
|
|
294
289
|
const { name, context, wantResponse, responsePath } = event;
|
|
295
|
-
const actionId = wantResponse ?
|
|
290
|
+
const actionId = wantResponse ? ids.next({}) : undefined;
|
|
296
291
|
if (actionId) {
|
|
297
292
|
surface.pendingActions.set(actionId, { name, sourceComponentId: componentId, responsePath });
|
|
298
293
|
}
|
|
@@ -300,20 +295,20 @@ export function createA2uiInterpreter(catalog) {
|
|
|
300
295
|
name,
|
|
301
296
|
surfaceId,
|
|
302
297
|
sourceComponentId: componentId,
|
|
303
|
-
timestamp: new Date(now()).toISOString(),
|
|
298
|
+
timestamp: new Date(now({})).toISOString(),
|
|
304
299
|
context: resolveActionContext(context, surfaceId),
|
|
305
300
|
...(wantResponse !== undefined ? { wantResponse } : {}),
|
|
306
301
|
...(actionId !== undefined ? { actionId } : {}),
|
|
307
302
|
};
|
|
308
|
-
return { ok: true, kind: 'agent', message: buildActionMessage(payload) };
|
|
303
|
+
return { ok: true, kind: 'agent', message: buildActionMessage({ payload }) };
|
|
309
304
|
}
|
|
310
|
-
function buildAction(surfaceId, componentId, now =
|
|
305
|
+
function buildAction({ surfaceId, componentId }, { now } = {}) {
|
|
311
306
|
const target = resolveActionTarget(surfaceId, componentId);
|
|
312
307
|
if (!target.ok)
|
|
313
308
|
return target;
|
|
314
309
|
const { surface, action } = target;
|
|
315
|
-
if (
|
|
316
|
-
return runLocalFunctionAction(surface.dataModel, catalog, action);
|
|
310
|
+
if ('functionCall' in action) {
|
|
311
|
+
return runLocalFunctionAction({ dataModel: surface.dataModel, catalog, action });
|
|
317
312
|
}
|
|
318
313
|
// `ActionSchema` (validated when this component's props were ingested — see
|
|
319
314
|
// `applyComponentsList`) is a closed 2-branch union: `{event}` | `{functionCall}`. Having
|
|
@@ -322,18 +317,18 @@ export function createA2uiInterpreter(catalog) {
|
|
|
322
317
|
// malformed third shape could never have made it into `component.props.action` in the first
|
|
323
318
|
// place. (Not defensively branched-and-left-untested, per this package's own testing
|
|
324
319
|
// discipline — see the zod-issues-array comments above for the same principle.)
|
|
325
|
-
return buildAgentEventAction(surface, surfaceId, componentId, action.event, now);
|
|
320
|
+
return buildAgentEventAction(surface, surfaceId, componentId, action.event, now ?? (() => clock.nowMs()));
|
|
326
321
|
}
|
|
327
322
|
return {
|
|
328
323
|
applyAgentMessage,
|
|
329
324
|
getSurface,
|
|
330
|
-
listSurfaceIds: () => [...surfaces.keys()],
|
|
325
|
+
listSurfaceIds: (_required) => [...surfaces.keys()],
|
|
331
326
|
getRoot,
|
|
332
327
|
buildAction,
|
|
333
328
|
resolve,
|
|
334
|
-
subscribe: (listener) => {
|
|
329
|
+
subscribe: ({ listener }) => {
|
|
335
330
|
listeners.add(listener);
|
|
336
|
-
return () => listeners.delete(listener);
|
|
331
|
+
return (_required) => { listeners.delete(listener); };
|
|
337
332
|
},
|
|
338
333
|
};
|
|
339
334
|
}
|
|
@@ -22,10 +22,18 @@ export interface PointerGetResult {
|
|
|
22
22
|
readonly value: unknown;
|
|
23
23
|
}
|
|
24
24
|
/** Splits a non-root pointer into its unescaped reference tokens. `pointer` must start with `/`. */
|
|
25
|
-
export declare function parsePointerTokens(pointer
|
|
26
|
-
|
|
25
|
+
export declare function parsePointerTokens({ pointer }: {
|
|
26
|
+
pointer: string;
|
|
27
|
+
}, _optional?: Record<string, never>): string[];
|
|
28
|
+
export declare function joinPointer({ base, tokens }: {
|
|
29
|
+
base: string;
|
|
30
|
+
tokens: string[];
|
|
31
|
+
}, _optional?: Record<string, never>): string;
|
|
27
32
|
/** Reads the value at `pointer` in `doc`. Never throws on a non-resolving path — `found: false` degrades sanely, matching this port's "a bad binding must not crash the renderer" adversarial requirement (see `resolve.ts`). */
|
|
28
|
-
export declare function getAtPointer(doc
|
|
33
|
+
export declare function getAtPointer({ doc, pointer }: {
|
|
34
|
+
doc: unknown;
|
|
35
|
+
pointer: string;
|
|
36
|
+
}, _optional?: Record<string, never>): PointerGetResult;
|
|
29
37
|
/**
|
|
30
38
|
* Writes `value` at `pointer` in `doc`, returning a **new** document (the original is never
|
|
31
39
|
* mutated — every intermediate object on the path is shallow-copied). Missing intermediate
|
|
@@ -44,5 +52,9 @@ export declare function getAtPointer(doc: unknown, pointer: string): PointerGetR
|
|
|
44
52
|
* for the same class of bug — this is the specific root cause it would otherwise have had to
|
|
45
53
|
* catch).
|
|
46
54
|
*/
|
|
47
|
-
export declare function setAtPointer(doc
|
|
55
|
+
export declare function setAtPointer({ doc, pointer, value }: {
|
|
56
|
+
doc: unknown;
|
|
57
|
+
pointer: string;
|
|
58
|
+
value: unknown;
|
|
59
|
+
}, _optional?: Record<string, never>): unknown;
|
|
48
60
|
//# sourceMappingURL=json-pointer.d.ts.map
|
|
@@ -55,7 +55,7 @@ function escapeToken(token) {
|
|
|
55
55
|
return token.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
56
56
|
}
|
|
57
57
|
/** Splits a non-root pointer into its unescaped reference tokens. `pointer` must start with `/`. */
|
|
58
|
-
export function parsePointerTokens(pointer) {
|
|
58
|
+
export function parsePointerTokens({ pointer }, _optional = {}) {
|
|
59
59
|
if (pointer === '')
|
|
60
60
|
return [];
|
|
61
61
|
if (!pointer.startsWith('/')) {
|
|
@@ -63,17 +63,17 @@ export function parsePointerTokens(pointer) {
|
|
|
63
63
|
}
|
|
64
64
|
return pointer.slice(1).split('/').map(unescapeToken);
|
|
65
65
|
}
|
|
66
|
-
export function joinPointer(base,
|
|
67
|
-
const baseTokens = base === '' || base === '/' ? [] : parsePointerTokens(base);
|
|
66
|
+
export function joinPointer({ base, tokens }, _optional = {}) {
|
|
67
|
+
const baseTokens = base === '' || base === '/' ? [] : parsePointerTokens({ pointer: base });
|
|
68
68
|
return '/' + [...baseTokens, ...tokens].map(escapeToken).join('/');
|
|
69
69
|
}
|
|
70
70
|
/** Reads the value at `pointer` in `doc`. Never throws on a non-resolving path — `found: false` degrades sanely, matching this port's "a bad binding must not crash the renderer" adversarial requirement (see `resolve.ts`). */
|
|
71
|
-
export function getAtPointer(doc, pointer) {
|
|
71
|
+
export function getAtPointer({ doc, pointer }, _optional = {}) {
|
|
72
72
|
if (isRootPointer(pointer))
|
|
73
73
|
return { found: true, value: doc };
|
|
74
74
|
let tokens;
|
|
75
75
|
try {
|
|
76
|
-
tokens = parsePointerTokens(pointer);
|
|
76
|
+
tokens = parsePointerTokens({ pointer });
|
|
77
77
|
}
|
|
78
78
|
catch {
|
|
79
79
|
return { found: false, value: undefined };
|
|
@@ -118,12 +118,12 @@ export function getAtPointer(doc, pointer) {
|
|
|
118
118
|
* for the same class of bug — this is the specific root cause it would otherwise have had to
|
|
119
119
|
* catch).
|
|
120
120
|
*/
|
|
121
|
-
export function setAtPointer(doc, pointer, value) {
|
|
121
|
+
export function setAtPointer({ doc, pointer, value }, _optional = {}) {
|
|
122
122
|
if (isRootPointer(pointer))
|
|
123
123
|
return value;
|
|
124
124
|
let tokens;
|
|
125
125
|
try {
|
|
126
|
-
tokens = parsePointerTokens(pointer);
|
|
126
|
+
tokens = parsePointerTokens({ pointer });
|
|
127
127
|
}
|
|
128
128
|
catch {
|
|
129
129
|
return doc;
|
|
@@ -321,14 +321,26 @@ export declare const ErrorMessageSchema: z.ZodObject<{
|
|
|
321
321
|
}>;
|
|
322
322
|
export type ErrorMessage = z.infer<typeof ErrorMessageSchema>;
|
|
323
323
|
export type RendererToAgentMessage = ActionMessage | FunctionResponseMessage | ErrorMessage;
|
|
324
|
-
export declare function buildActionMessage(payload
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
export declare function
|
|
324
|
+
export declare function buildActionMessage({ payload }: {
|
|
325
|
+
payload: ActionMessagePayload;
|
|
326
|
+
}, _optional?: Record<string, never>): ActionMessage;
|
|
327
|
+
export declare function buildFunctionResponseMessage({ payload }: {
|
|
328
|
+
payload: FunctionResponsePayload;
|
|
329
|
+
}, _optional?: Record<string, never>): FunctionResponseMessage;
|
|
330
|
+
export declare function buildValidationFailedMessage({ surfaceId, path, message }: {
|
|
328
331
|
surfaceId: string;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}): ErrorMessage;
|
|
332
|
+
path: string;
|
|
333
|
+
message: string;
|
|
334
|
+
}, _optional?: Record<string, never>): ErrorMessage;
|
|
335
|
+
export declare function buildGenericErrorMessage({ code, message, target }: {
|
|
336
|
+
code: string;
|
|
337
|
+
message: string;
|
|
338
|
+
target: {
|
|
339
|
+
surfaceId: string;
|
|
340
|
+
} | {
|
|
341
|
+
functionCallId: string;
|
|
342
|
+
};
|
|
343
|
+
}, _optional?: Record<string, never>): ErrorMessage;
|
|
332
344
|
export interface RendererParseFailure {
|
|
333
345
|
readonly ok: false;
|
|
334
346
|
readonly reason: string;
|
|
@@ -338,5 +350,7 @@ export interface RendererParseSuccess {
|
|
|
338
350
|
readonly message: RendererToAgentMessage;
|
|
339
351
|
}
|
|
340
352
|
/** 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
|
|
353
|
+
export declare function parseRendererToAgentMessage({ raw }: {
|
|
354
|
+
raw: unknown;
|
|
355
|
+
}, _optional?: Record<string, never>): RendererParseSuccess | RendererParseFailure;
|
|
342
356
|
//# sourceMappingURL=renderer-to-agent.d.ts.map
|
|
@@ -72,21 +72,21 @@ export const FunctionResponseMessageSchema = z
|
|
|
72
72
|
export const ErrorMessageSchema = z
|
|
73
73
|
.object({ version: z.literal(PROTOCOL_VERSION), error: ErrorPayloadSchema })
|
|
74
74
|
.strict();
|
|
75
|
-
export function buildActionMessage(payload) {
|
|
75
|
+
export function buildActionMessage({ payload }, _optional = {}) {
|
|
76
76
|
return { version: PROTOCOL_VERSION, action: payload };
|
|
77
77
|
}
|
|
78
|
-
export function buildFunctionResponseMessage(payload) {
|
|
78
|
+
export function buildFunctionResponseMessage({ payload }, _optional = {}) {
|
|
79
79
|
return { version: PROTOCOL_VERSION, functionResponse: payload };
|
|
80
80
|
}
|
|
81
|
-
export function buildValidationFailedMessage(surfaceId, path, message) {
|
|
81
|
+
export function buildValidationFailedMessage({ surfaceId, path, message }, _optional = {}) {
|
|
82
82
|
return { version: PROTOCOL_VERSION, error: { code: 'VALIDATION_FAILED', surfaceId, path, message } };
|
|
83
83
|
}
|
|
84
|
-
export function buildGenericErrorMessage(code, message, target) {
|
|
84
|
+
export function buildGenericErrorMessage({ code, message, target }, _optional = {}) {
|
|
85
85
|
return { version: PROTOCOL_VERSION, error: { code, message, ...target } };
|
|
86
86
|
}
|
|
87
87
|
const MESSAGE_KEYS = ['action', 'functionResponse', 'error'];
|
|
88
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) {
|
|
89
|
+
export function parseRendererToAgentMessage({ raw }, _optional = {}) {
|
|
90
90
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
91
91
|
return { ok: false, reason: 'envelope must be a JSON object' };
|
|
92
92
|
}
|
|
@@ -10,7 +10,7 @@ export interface ResolveContext {
|
|
|
10
10
|
readonly catalog: Catalog;
|
|
11
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
12
|
readonly side: ResolveSide;
|
|
13
|
-
readonly itemScope?: ItemScope;
|
|
13
|
+
readonly itemScope?: ItemScope | undefined;
|
|
14
14
|
}
|
|
15
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
16
|
export interface ResolveFailure {
|
|
@@ -24,5 +24,10 @@ export interface ResolveOk {
|
|
|
24
24
|
}
|
|
25
25
|
export type ResolveResult = ResolveOk | ResolveFailure;
|
|
26
26
|
/** Resolves any `Dynamic*` value (`DynamicString`/`DynamicNumber`/`DynamicBoolean`/`DynamicStringList`/`DynamicValue` all share this one shape: literal | `DataBinding` | `FunctionCall`). */
|
|
27
|
-
export declare function resolveDynamicValue(value
|
|
27
|
+
export declare function resolveDynamicValue({ value, ctx }: {
|
|
28
|
+
value: unknown;
|
|
29
|
+
ctx: Omit<ResolveContext, 'itemScope'>;
|
|
30
|
+
}, { itemScope }?: {
|
|
31
|
+
itemScope?: ItemScope | undefined;
|
|
32
|
+
}): ResolveResult;
|
|
28
33
|
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -45,12 +45,12 @@ function resolveBindingPath(path, ctx) {
|
|
|
45
45
|
const absolute = path.startsWith('/')
|
|
46
46
|
? path
|
|
47
47
|
: ctx.itemScope
|
|
48
|
-
? joinPointer(ctx.itemScope.basePath, String(ctx.itemScope.index), ...parsePointerTokens(`/${path}`))
|
|
48
|
+
? joinPointer({ base: ctx.itemScope.basePath, tokens: [String(ctx.itemScope.index), ...parsePointerTokens({ pointer: `/${path}` })] })
|
|
49
49
|
: null;
|
|
50
50
|
if (absolute === null) {
|
|
51
51
|
return { ok: false, reason: 'RELATIVE_PATH_OUTSIDE_LIST_CONTEXT', detail: `relative path "${path}" used outside a list-template item context` };
|
|
52
52
|
}
|
|
53
|
-
const result = getAtPointer(ctx.dataModel, absolute);
|
|
53
|
+
const result = getAtPointer({ doc: ctx.dataModel, pointer: absolute });
|
|
54
54
|
if (!result.found) {
|
|
55
55
|
return { ok: false, reason: 'PATH_NOT_FOUND', detail: `no value at "${absolute}" in the current data model` };
|
|
56
56
|
}
|
|
@@ -62,16 +62,16 @@ function resolveFunctionCall(call, ctx) {
|
|
|
62
62
|
return { ok: false, reason: 'INDEX_OUTSIDE_LIST_CONTEXT', detail: '@index used outside a list-template item context' };
|
|
63
63
|
}
|
|
64
64
|
const offsetArg = call.args?.offset;
|
|
65
|
-
const offsetResult = offsetArg === undefined ? { ok: true, value: 0 } : resolveDynamicValue(offsetArg, ctx);
|
|
65
|
+
const offsetResult = offsetArg === undefined ? { ok: true, value: 0 } : resolveDynamicValue({ value: offsetArg, ctx: ctx }, { itemScope: ctx.itemScope });
|
|
66
66
|
if (!offsetResult.ok)
|
|
67
67
|
return offsetResult;
|
|
68
68
|
const offset = typeof offsetResult.value === 'number' ? offsetResult.value : 0;
|
|
69
69
|
return { ok: true, value: ctx.itemScope.index + offset };
|
|
70
70
|
}
|
|
71
|
-
if (!isFunctionRegistered(ctx.catalog, call.call)) {
|
|
71
|
+
if (!isFunctionRegistered({ catalog: ctx.catalog, functionName: call.call })) {
|
|
72
72
|
return { ok: false, reason: 'FUNCTION_NOT_REGISTERED', detail: `function "${call.call}" is not registered in catalog "${ctx.catalog.catalogId}"` };
|
|
73
73
|
}
|
|
74
|
-
const callableFrom = callableFromOf(ctx.catalog, call.call);
|
|
74
|
+
const callableFrom = callableFromOf({ catalog: ctx.catalog, functionName: call.call });
|
|
75
75
|
const allowed = callableFrom === 'rendererOrAgent' || (callableFrom === 'rendererOnly' && ctx.side === 'renderer') || (callableFrom === 'agentOnly' && ctx.side === 'agent');
|
|
76
76
|
if (!allowed) {
|
|
77
77
|
return {
|
|
@@ -131,14 +131,15 @@ function resolveArgValue(argValue, ctx) {
|
|
|
131
131
|
}
|
|
132
132
|
return { ok: true, value: resolvedItems };
|
|
133
133
|
}
|
|
134
|
-
return resolveDynamicValue(argValue, ctx);
|
|
134
|
+
return resolveDynamicValue({ value: argValue, ctx: ctx }, { itemScope: ctx.itemScope });
|
|
135
135
|
}
|
|
136
136
|
/** Resolves any `Dynamic*` value (`DynamicString`/`DynamicNumber`/`DynamicBoolean`/`DynamicStringList`/`DynamicValue` all share this one shape: literal | `DataBinding` | `FunctionCall`). */
|
|
137
|
-
export function resolveDynamicValue(value, ctx) {
|
|
137
|
+
export function resolveDynamicValue({ value, ctx }, { itemScope } = {}) {
|
|
138
|
+
const context = { ...ctx, ...(itemScope === undefined ? {} : { itemScope }) };
|
|
138
139
|
if (isDataBinding(value))
|
|
139
|
-
return resolveBindingPath(value.path,
|
|
140
|
+
return resolveBindingPath(value.path, context);
|
|
140
141
|
if (isFunctionCall(value))
|
|
141
|
-
return resolveFunctionCall(value,
|
|
142
|
+
return resolveFunctionCall(value, context);
|
|
142
143
|
return { ok: true, value };
|
|
143
144
|
}
|
|
144
145
|
//# sourceMappingURL=resolve.js.map
|
package/dist/core/a2ui/tree.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Scope: only the *static array* form of `ChildList` (`common_types.json#/$defs/ChildList`'s
|
|
11
11
|
* first `oneOf` branch) is walked here. The *template* form (`{componentId, path}`, generating N
|
|
12
12
|
* children from a data-model list) is accepted by the wire schema (`ChildListSchema`) but not
|
|
13
|
-
* expanded by this port — see `../
|
|
13
|
+
* expanded by this port — see `../archived provenance ledger` for why (a distinct, substantially larger
|
|
14
14
|
* rendering feature: item-scoped relative-path resolution, `@index`, per-item React keys for one
|
|
15
15
|
* shared component definition rendered N times). A `getChildIds` callback that always returns
|
|
16
16
|
* `[]` for a template-shaped `children` value is a safe, honest way to consume this module without
|
|
@@ -62,5 +62,11 @@ export declare const MAX_RENDER_NODES = 50000;
|
|
|
62
62
|
* which is both what makes the iterative form equivalent (an ancestor set IS the path from the
|
|
63
63
|
* root) and what removes the old walk's quadratic set-copying cost.
|
|
64
64
|
*/
|
|
65
|
-
export declare function flattenRenderTree<C extends ComponentLike>(components
|
|
65
|
+
export declare function flattenRenderTree<C extends ComponentLike>({ components, rootId, getChildIds }: {
|
|
66
|
+
components: ReadonlyMap<string, C>;
|
|
67
|
+
rootId: string;
|
|
68
|
+
getChildIds: (required: {
|
|
69
|
+
component: C;
|
|
70
|
+
}) => readonly string[];
|
|
71
|
+
}, _optional?: Record<string, never>): RenderNode[];
|
|
66
72
|
//# sourceMappingURL=tree.d.ts.map
|
package/dist/core/a2ui/tree.js
CHANGED
|
@@ -35,7 +35,7 @@ export const MAX_RENDER_NODES = 50_000;
|
|
|
35
35
|
* which is both what makes the iterative form equivalent (an ancestor set IS the path from the
|
|
36
36
|
* root) and what removes the old walk's quadratic set-copying cost.
|
|
37
37
|
*/
|
|
38
|
-
export function flattenRenderTree(components, rootId, getChildIds) {
|
|
38
|
+
export function flattenRenderTree({ components, rootId, getChildIds }, _optional = {}) {
|
|
39
39
|
const output = [];
|
|
40
40
|
/** Ids on the path from the root to the node being visited — the recursive walk's `ancestors`. */
|
|
41
41
|
const ancestors = new Set();
|
|
@@ -64,7 +64,7 @@ export function flattenRenderTree(components, rootId, getChildIds) {
|
|
|
64
64
|
ancestors.add(id);
|
|
65
65
|
stack.push({ leave: id });
|
|
66
66
|
// Pushed in reverse so the first child is popped first, preserving pre-order.
|
|
67
|
-
const childIds = getChildIds(component);
|
|
67
|
+
const childIds = getChildIds({ component });
|
|
68
68
|
for (let index = childIds.length - 1; index >= 0; index -= 1) {
|
|
69
69
|
stack.push({ id: childIds[index], depth: depth + 1 });
|
|
70
70
|
}
|
package/dist/core/ag-ui.d.ts
CHANGED
|
@@ -52,14 +52,18 @@ export interface AgUiToolResultMessage {
|
|
|
52
52
|
* @param capability - The capability to expose.
|
|
53
53
|
* @returns The tool entry for `RunAgentInput.tools`.
|
|
54
54
|
*/
|
|
55
|
-
export declare function toAgUiTool(capability
|
|
55
|
+
export declare function toAgUiTool({ capability }: {
|
|
56
|
+
capability: CapabilityDef;
|
|
57
|
+
}, _optional?: Record<string, never>): AgUiTool;
|
|
56
58
|
/**
|
|
57
59
|
* Projects a whole manifest.
|
|
58
60
|
*
|
|
59
61
|
* @param capabilities - Capabilities to expose, already filtered by whatever policy applies.
|
|
60
62
|
* @returns One tool per capability, in manifest order.
|
|
61
63
|
*/
|
|
62
|
-
export declare function toAgUiTools(capabilities
|
|
64
|
+
export declare function toAgUiTools({ capabilities }: {
|
|
65
|
+
capabilities: readonly CapabilityDef[];
|
|
66
|
+
}, _optional?: Record<string, never>): readonly AgUiTool[];
|
|
63
67
|
/**
|
|
64
68
|
* Builds the result message for a completed frontend tool call.
|
|
65
69
|
*
|
|
@@ -72,11 +76,15 @@ export declare function toAgUiTools(capabilities: readonly CapabilityDef[]): rea
|
|
|
72
76
|
* @param outcome - What happened.
|
|
73
77
|
* @returns The `role: "tool"` message to send back.
|
|
74
78
|
*/
|
|
75
|
-
export declare function createAgUiToolResult(messageId
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
79
|
+
export declare function createAgUiToolResult({ messageId, toolCallId, outcome }: {
|
|
80
|
+
messageId: string;
|
|
81
|
+
toolCallId: string;
|
|
82
|
+
outcome: {
|
|
83
|
+
ok: true;
|
|
84
|
+
output: unknown;
|
|
85
|
+
} | {
|
|
86
|
+
ok: false;
|
|
87
|
+
error: string;
|
|
88
|
+
};
|
|
89
|
+
}, _optional?: Record<string, never>): AgUiToolResultMessage;
|
|
82
90
|
//# sourceMappingURL=ag-ui.d.ts.map
|
package/dist/core/ag-ui.js
CHANGED
|
@@ -19,7 +19,7 @@ export const AG_UI_TOOL_CALL_EVENTS = {
|
|
|
19
19
|
* @param capability - The capability to expose.
|
|
20
20
|
* @returns The tool entry for `RunAgentInput.tools`.
|
|
21
21
|
*/
|
|
22
|
-
export function toAgUiTool(capability) {
|
|
22
|
+
export function toAgUiTool({ capability }, _optional = {}) {
|
|
23
23
|
return {
|
|
24
24
|
name: capability.id,
|
|
25
25
|
description: capability.description,
|
|
@@ -32,8 +32,8 @@ export function toAgUiTool(capability) {
|
|
|
32
32
|
* @param capabilities - Capabilities to expose, already filtered by whatever policy applies.
|
|
33
33
|
* @returns One tool per capability, in manifest order.
|
|
34
34
|
*/
|
|
35
|
-
export function toAgUiTools(capabilities) {
|
|
36
|
-
return capabilities.map(toAgUiTool);
|
|
35
|
+
export function toAgUiTools({ capabilities }, _optional = {}) {
|
|
36
|
+
return capabilities.map(capability => toAgUiTool({ capability }));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* JSON, or a description of why there is none — always a string, which `JSON.stringify` alone is
|
|
@@ -76,7 +76,7 @@ function encodeToolContent(output) {
|
|
|
76
76
|
* @param outcome - What happened.
|
|
77
77
|
* @returns The `role: "tool"` message to send back.
|
|
78
78
|
*/
|
|
79
|
-
export function createAgUiToolResult(messageId, toolCallId, outcome) {
|
|
79
|
+
export function createAgUiToolResult({ messageId, toolCallId, outcome }, _optional = {}) {
|
|
80
80
|
const content = outcome.ok
|
|
81
81
|
? typeof outcome.output === 'string' ? outcome.output : encodeToolContent(outcome.output)
|
|
82
82
|
: JSON.stringify({ error: outcome.error });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-free script asset for data-toolname/data-tooldescription actions.
|
|
3
|
+
* Native tool* forms remain the browser's responsibility. No polyfill, transport,
|
|
4
|
+
* field-value reader, arbitrary selector input or cross-origin exposure is added.
|
|
5
|
+
* The host owns consent copy and its browser preference key. This string asset
|
|
6
|
+
* can be inlined into static exports without importing a DOM runtime on Node.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAnnotatedActionsScript({ preferenceKey, confirmationMessage, confirmationMessages }: {
|
|
9
|
+
preferenceKey?: string;
|
|
10
|
+
confirmationMessage?: string;
|
|
11
|
+
confirmationMessages?: Readonly<Record<string, string>>;
|
|
12
|
+
}, _optional?: Record<string, never>): string;
|
|
13
|
+
//# sourceMappingURL=annotated-actions-script.d.ts.map
|