@adonis-agora/agent 0.70.1 → 0.71.0
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 +9 -0
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +3 -0
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/src/a2ui/adapter.d.ts +34 -0
- package/dist/src/a2ui/adapter.d.ts.map +1 -0
- package/dist/src/a2ui/adapter.js +223 -0
- package/dist/src/a2ui/adapter.js.map +1 -0
- package/dist/src/a2ui/core.d.ts +181 -0
- package/dist/src/a2ui/core.d.ts.map +1 -0
- package/dist/src/a2ui/core.js +513 -0
- package/dist/src/a2ui/core.js.map +1 -0
- package/dist/src/a2ui/index.d.ts +10 -0
- package/dist/src/a2ui/index.d.ts.map +1 -0
- package/dist/src/a2ui/index.js +10 -0
- package/dist/src/a2ui/index.js.map +1 -0
- package/dist/src/ag-ui/adapter.d.ts +9 -0
- package/dist/src/ag-ui/adapter.d.ts.map +1 -1
- package/dist/src/ag-ui/adapter.js +29 -2
- package/dist/src/ag-ui/adapter.js.map +1 -1
- package/dist/src/ag-ui/core/encoder.d.ts +7 -0
- package/dist/src/ag-ui/core/encoder.d.ts.map +1 -1
- package/dist/src/ag-ui/core/encoder.js +12 -1
- package/dist/src/ag-ui/core/encoder.js.map +1 -1
- package/dist/src/ag-ui/core/input.d.ts +7 -0
- package/dist/src/ag-ui/core/input.d.ts.map +1 -1
- package/dist/src/ag-ui/core/input.js +7 -0
- package/dist/src/ag-ui/core/input.js.map +1 -1
- package/dist/src/ag-ui/core/types.d.ts +8 -0
- package/dist/src/ag-ui/core/types.d.ts.map +1 -1
- package/dist/src/ag-ui/core/types.js.map +1 -1
- package/dist/src/genui/actions.d.ts +70 -0
- package/dist/src/genui/actions.d.ts.map +1 -0
- package/dist/src/genui/actions.js +116 -0
- package/dist/src/genui/actions.js.map +1 -0
- package/dist/src/genui/builtins.d.ts +1 -1
- package/dist/src/genui/builtins.d.ts.map +1 -1
- package/dist/src/genui/builtins.js +1 -0
- package/dist/src/genui/builtins.js.map +1 -1
- package/dist/src/genui/catalog.d.ts +9 -0
- package/dist/src/genui/catalog.d.ts.map +1 -1
- package/dist/src/genui/catalog.js +2 -0
- package/dist/src/genui/catalog.js.map +1 -1
- package/dist/src/genui/index.d.ts +9 -0
- package/dist/src/genui/index.d.ts.map +1 -1
- package/dist/src/genui/index.js +6 -2
- package/dist/src/genui/index.js.map +1 -1
- package/dist/src/genui/progressive.d.ts.map +1 -1
- package/dist/src/genui/progressive.js +4 -1
- package/dist/src/genui/progressive.js.map +1 -1
- package/dist/src/genui/public.d.ts +2 -0
- package/dist/src/genui/public.d.ts.map +1 -1
- package/dist/src/genui/public.js +2 -0
- package/dist/src/genui/public.js.map +1 -1
- package/dist/src/genui/sandbox.d.ts +169 -0
- package/dist/src/genui/sandbox.d.ts.map +1 -0
- package/dist/src/genui/sandbox.js +307 -0
- package/dist/src/genui/sandbox.js.map +1 -0
- package/dist/src/genui/tools.d.ts.map +1 -1
- package/dist/src/genui/tools.js +36 -0
- package/dist/src/genui/tools.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/react/core/genui/generative-ui.d.ts +19 -2
- package/dist/src/react/core/genui/generative-ui.d.ts.map +1 -1
- package/dist/src/react/core/genui/generative-ui.js +14 -3
- package/dist/src/react/core/genui/generative-ui.js.map +1 -1
- package/dist/src/react/core/genui/index.d.ts +3 -1
- package/dist/src/react/core/genui/index.d.ts.map +1 -1
- package/dist/src/react/core/genui/index.js +2 -1
- package/dist/src/react/core/genui/index.js.map +1 -1
- package/dist/src/react/core/genui/sandbox.d.ts +91 -0
- package/dist/src/react/core/genui/sandbox.d.ts.map +1 -0
- package/dist/src/react/core/genui/sandbox.js +242 -0
- package/dist/src/react/core/genui/sandbox.js.map +1 -0
- package/dist/src/react/core/genui/types.d.ts +6 -0
- package/dist/src/react/core/genui/types.d.ts.map +1 -1
- package/dist/src/react/core/use-agent-chat.d.ts +3 -0
- package/dist/src/react/core/use-agent-chat.d.ts.map +1 -1
- package/dist/src/react/core/use-agent-chat.js +8 -0
- package/dist/src/react/core/use-agent-chat.js.map +1 -1
- package/dist/src/spi/protocol-adapter.d.ts +3 -0
- package/dist/src/spi/protocol-adapter.d.ts.map +1 -1
- package/package.json +30 -22
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { decodeInterruptId } from '../ag-ui/core/interrupt-id.js';
|
|
2
|
+
import { agUiEvents } from '../ag-ui/stream.js';
|
|
3
|
+
import { uiActionText } from '../genui/actions.js';
|
|
4
|
+
import { validateUiCapabilities } from '../genui/capabilities.js';
|
|
5
|
+
import { A2UI_APPROVE_ACTION, A2UI_REJECT_ACTION, A2uiProjector, readA2uiAction, } from './core.js';
|
|
6
|
+
const VIA = 'a2ui';
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Serve the agent as an A2UI (https://a2ui.org, v0.9) agent: `POST <path>/a2ui` answers with the
|
|
12
|
+
* run as a JSON Lines stream of A2UI server-to-client messages — `createSurface`,
|
|
13
|
+
* `updateComponents`, `updateDataModel`, `deleteSurface` — that any A2UI renderer draws.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { a2uiAdapter } from '@adonis-agora/agent/a2ui'
|
|
17
|
+
*
|
|
18
|
+
* export default defineConfig({ adapters: [a2uiAdapter()] })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The body is `{ threadId?, message?, action?, uiCapabilities?, agent? }`:
|
|
22
|
+
* - `message` — the user's text;
|
|
23
|
+
* - `action` — an A2UI client message (`{ version: 'v0.9', action: { name, surfaceId,
|
|
24
|
+
* sourceComponentId, timestamp, context } }`, or v0.8's `{ userAction }`): it becomes the turn
|
|
25
|
+
* (`uiActionText`). `agora.approve` / `agora.reject` with `context.interruptId` decide the
|
|
26
|
+
* approval a previous stream ended on, and stream the rest of that run;
|
|
27
|
+
* - `threadId` — continue that thread (its owner is checked), or start one under that id.
|
|
28
|
+
*
|
|
29
|
+
* Response headers name the library's ids: `X-Agent-Thread-Id`, `X-Agent-Run-Id`. Authenticated and
|
|
30
|
+
* owner-scoped exactly as `chat` is.
|
|
31
|
+
*/
|
|
32
|
+
export function a2uiAdapter(options = {}) {
|
|
33
|
+
const path = (options.path ?? 'a2ui').replace(/^\/+|\/+$/g, '');
|
|
34
|
+
const { path: _path, quietMs, maxActionBytes, ...projection } = options;
|
|
35
|
+
return {
|
|
36
|
+
name: 'a2ui',
|
|
37
|
+
mount(host) {
|
|
38
|
+
const { service } = host;
|
|
39
|
+
host.post(path, async (ctx) => {
|
|
40
|
+
const body = ctx.request.body();
|
|
41
|
+
const agentName = typeof body.agent === 'string' && body.agent.length > 0 ? body.agent : undefined;
|
|
42
|
+
const actor = await host.resolveActor(ctx, agentName ?? host.defaultAgentName);
|
|
43
|
+
if (actor === null)
|
|
44
|
+
return;
|
|
45
|
+
let action;
|
|
46
|
+
if (body.action !== undefined) {
|
|
47
|
+
const read = isRecord(body.action)
|
|
48
|
+
? readA2uiAction(body.action, {
|
|
49
|
+
...(maxActionBytes !== undefined ? { maxBytes: maxActionBytes } : {}),
|
|
50
|
+
})
|
|
51
|
+
: 'action must be an A2UI action message';
|
|
52
|
+
if (typeof read === 'string') {
|
|
53
|
+
return ctx.response.badRequest({ message: read, code: 'invalid_action' });
|
|
54
|
+
}
|
|
55
|
+
action = read;
|
|
56
|
+
}
|
|
57
|
+
// Deciding the approval a stream ended on: settle it, then stream the rest of the run.
|
|
58
|
+
if (action?.name === A2UI_APPROVE_ACTION || action?.name === A2UI_REJECT_ACTION) {
|
|
59
|
+
const interruptId = action.context.interruptId;
|
|
60
|
+
const address = typeof interruptId === 'string' ? decodeInterruptId(interruptId) : undefined;
|
|
61
|
+
if (address === undefined || address === null || address.kind === 'elicitation') {
|
|
62
|
+
return ctx.response.badRequest({
|
|
63
|
+
message: 'an approval action carries the interruptId it decides',
|
|
64
|
+
code: 'invalid_action',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// An independent proposal: decided through the proposal service (its own run is not
|
|
68
|
+
// waiting), answered with the configured reply.
|
|
69
|
+
if (address.kind === 'proposal') {
|
|
70
|
+
if (address.proposalId === undefined || address.threadId === undefined) {
|
|
71
|
+
return ctx.response.badRequest({
|
|
72
|
+
message: 'the interruptId names no proposal',
|
|
73
|
+
code: 'invalid_action',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const decision = action.name === A2UI_APPROVE_ACTION ? 'approved' : 'rejected';
|
|
77
|
+
let reply;
|
|
78
|
+
try {
|
|
79
|
+
const result = await service.decideActionProposal(actor, address.threadId, address.proposalId, decision, {}, VIA);
|
|
80
|
+
reply = service.actionProposalReply(result, decision);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (host.refuseSend(ctx, error))
|
|
84
|
+
return;
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
writeHead(ctx, { 'X-Agent-Thread-Id': address.threadId });
|
|
88
|
+
const projector = new A2uiProjector(projection);
|
|
89
|
+
const messageId = `proposal-${address.proposalId}`;
|
|
90
|
+
for (const event of [
|
|
91
|
+
{ type: 'TEXT_MESSAGE_START', messageId, role: 'assistant' },
|
|
92
|
+
{ type: 'TEXT_MESSAGE_CONTENT', messageId, delta: reply },
|
|
93
|
+
]) {
|
|
94
|
+
for (const message of projector.project(event)) {
|
|
95
|
+
ctx.response.response.write(`${JSON.stringify(message)}\n`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
ctx.response.response.end();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!(await host.mayDecide(ctx, actor, address.parked, address.toolCallId)))
|
|
102
|
+
return;
|
|
103
|
+
try {
|
|
104
|
+
if (action.name === A2UI_APPROVE_ACTION) {
|
|
105
|
+
await service.approve(address.parked, address.toolCallId, {
|
|
106
|
+
executedByRef: actor.id,
|
|
107
|
+
via: VIA,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
await service.reject(address.parked, address.toolCallId, undefined, {
|
|
112
|
+
executedByRef: actor.id,
|
|
113
|
+
via: VIA,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
host.conflictOnMismatch(ctx, error);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
await stream(ctx, host, address.stream, {
|
|
122
|
+
skip: address.position,
|
|
123
|
+
answered: [address.toolCallId],
|
|
124
|
+
projection,
|
|
125
|
+
quietMs,
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const message = typeof body.message === 'string' ? body.message : '';
|
|
130
|
+
const text = action !== undefined ? uiActionText(action) : message;
|
|
131
|
+
if (text.trim().length === 0) {
|
|
132
|
+
return ctx.response.badRequest({
|
|
133
|
+
message: 'send a message or an action',
|
|
134
|
+
code: 'no_user_message',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const threadId = typeof body.threadId === 'string' && body.threadId.length > 0 ? body.threadId : undefined;
|
|
138
|
+
const owner = threadId !== undefined ? await service.threadOwner(threadId) : null;
|
|
139
|
+
if (owner !== null && !(await host.assertOwner(ctx, actor, owner, 'thread')))
|
|
140
|
+
return;
|
|
141
|
+
let started;
|
|
142
|
+
try {
|
|
143
|
+
started = await service.chat({
|
|
144
|
+
actor,
|
|
145
|
+
message: text,
|
|
146
|
+
...(threadId === undefined
|
|
147
|
+
? {}
|
|
148
|
+
: owner !== null
|
|
149
|
+
? { threadId }
|
|
150
|
+
: { newThreadId: threadId }),
|
|
151
|
+
...(agentName !== undefined ? { agentName } : {}),
|
|
152
|
+
...(Object.hasOwn(body, 'uiCapabilities')
|
|
153
|
+
? { uiCapabilities: validateUiCapabilities(body.uiCapabilities) }
|
|
154
|
+
: {}),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (host.refuseSend(ctx, error))
|
|
159
|
+
return;
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
await stream(ctx, host, started.runId, {
|
|
163
|
+
threadId: started.threadId,
|
|
164
|
+
projection,
|
|
165
|
+
quietMs,
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Write one run as A2UI JSON Lines, until it ends or stops to ask. */
|
|
172
|
+
async function stream(ctx, host, runId, options) {
|
|
173
|
+
const raw = ctx.response.response;
|
|
174
|
+
writeHead(ctx, {
|
|
175
|
+
'X-Agent-Run-Id': runId,
|
|
176
|
+
...(options.threadId !== undefined ? { 'X-Agent-Thread-Id': options.threadId } : {}),
|
|
177
|
+
});
|
|
178
|
+
const projector = new A2uiProjector({
|
|
179
|
+
...options.projection,
|
|
180
|
+
...(options.projection.catalog === undefined && host.genuiCatalog !== undefined
|
|
181
|
+
? { catalog: host.genuiCatalog }
|
|
182
|
+
: {}),
|
|
183
|
+
});
|
|
184
|
+
const write = (messages) => {
|
|
185
|
+
for (const message of messages)
|
|
186
|
+
raw.write(`${JSON.stringify(message)}\n`);
|
|
187
|
+
};
|
|
188
|
+
try {
|
|
189
|
+
for await (const event of agUiEvents(host.service.subscribe(runId), {
|
|
190
|
+
threadId: options.threadId ?? runId,
|
|
191
|
+
runId,
|
|
192
|
+
streamRunId: runId,
|
|
193
|
+
...(options.threadId !== undefined ? { streamThreadId: options.threadId } : {}),
|
|
194
|
+
...(options.skip !== undefined ? { skip: options.skip } : {}),
|
|
195
|
+
...(options.answered !== undefined ? { answered: options.answered } : {}),
|
|
196
|
+
...(options.quietMs !== undefined ? { quietMs: options.quietMs } : {}),
|
|
197
|
+
})) {
|
|
198
|
+
write(projector.project(event));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
write(projector.project({ type: 'RUN_ERROR', message: 'The run could not be followed.' }));
|
|
203
|
+
}
|
|
204
|
+
raw.end();
|
|
205
|
+
}
|
|
206
|
+
/** Open the JSON Lines response, carrying over the headers already set on the context (cookies). */
|
|
207
|
+
function writeHead(ctx, extra) {
|
|
208
|
+
const raw = ctx.response.response;
|
|
209
|
+
const headers = {
|
|
210
|
+
'Content-Type': 'application/jsonl; charset=utf-8',
|
|
211
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
212
|
+
Connection: 'keep-alive',
|
|
213
|
+
'X-Accel-Buffering': 'no',
|
|
214
|
+
...extra,
|
|
215
|
+
};
|
|
216
|
+
const pending = ctx.response.getHeaders();
|
|
217
|
+
for (const [name, value] of Object.entries(pending)) {
|
|
218
|
+
if (value !== undefined && !(name in headers))
|
|
219
|
+
raw.setHeader(name, value);
|
|
220
|
+
}
|
|
221
|
+
raw.writeHead(200, headers);
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../src/a2ui/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EAGb,cAAc,GACf,MAAM,WAAW,CAAC;AAWnB,MAAM,GAAG,GAAG,MAAM,CAAC;AAEnB,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AA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UAAU,EAAE,YAAY;QACxB,mBAAmB,EAAE,IAAI;QACzB,GAAG,KAAK;KACT,CAAC;IACF,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC;YAAE,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAA0B,CAAC,CAAC;IACjG,CAAC;IACD,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI (https://a2ui.org) — Google's declarative agent-to-UI protocol — for this agent's generative
|
|
3
|
+
* UI, framework-free. Targets A2UI **v0.9** (the current production family: v0.9.1 is a patch of
|
|
4
|
+
* it; v1.0 is a release candidate).
|
|
5
|
+
*
|
|
6
|
+
* - Outbound: a `ui` frame (one component, or a composed `genui:tree`) becomes a surface — a flat
|
|
7
|
+
* list of A2UI components keyed by id — that any A2UI renderer (Lit, Angular, Flutter, React)
|
|
8
|
+
* draws. Library builtins map onto A2UI's basic catalog; an app maps its own components with a
|
|
9
|
+
* function, or sends them through as custom components of its own A2UI catalog.
|
|
10
|
+
* - Streamed: a preview frame the model is still writing becomes the same surface, partially —
|
|
11
|
+
* A2UI renderers draw what has arrived and leave a child that is not there yet as a placeholder.
|
|
12
|
+
* - Inbound: an A2UI `action` (v0.9) or `userAction` (v0.8) becomes a {@link UiAction}: the next
|
|
13
|
+
* user turn.
|
|
14
|
+
*/
|
|
15
|
+
import type { AgUiEvent, AgUiInterrupt } from '../ag-ui/core/types.js';
|
|
16
|
+
import { type UiAction } from '../genui/actions.js';
|
|
17
|
+
import type { Catalog } from '../genui/catalog.js';
|
|
18
|
+
/** The A2UI protocol version every message is stamped with. */
|
|
19
|
+
export declare const A2UI_VERSION = "v0.9";
|
|
20
|
+
/** The catalog id of A2UI v0.9's basic catalog (what `@a2ui/react`'s `basicCatalog.id` is). */
|
|
21
|
+
export declare const A2UI_BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json";
|
|
22
|
+
/** The components of A2UI v0.9's basic catalog. */
|
|
23
|
+
export declare const A2UI_BASIC_COMPONENTS: readonly ['Text', 'Image', 'Icon', 'Video', 'AudioPlayer', 'Row', 'Column', 'List', 'Card', 'Tabs', 'Modal', 'Divider', 'Button', 'CheckBox', 'TextField', 'DateTimeInput', 'ChoicePicker', 'Slider'];
|
|
24
|
+
/** The AG-UI activity type A2UI surfaces travel under (AG-UI's A2UI middleware, CopilotKit). */
|
|
25
|
+
export declare const A2UI_ACTIVITY_TYPE = "a2ui-surface";
|
|
26
|
+
/** The key of the A2UI messages in an `a2ui-surface` activity's content. */
|
|
27
|
+
export declare const A2UI_OPERATIONS_KEY = "a2ui_operations";
|
|
28
|
+
/** Action names the transports answer themselves: deciding a parked approval. */
|
|
29
|
+
export declare const A2UI_APPROVE_ACTION = "agora.approve";
|
|
30
|
+
export declare const A2UI_REJECT_ACTION = "agora.reject";
|
|
31
|
+
/** One A2UI component: its id, its catalog type, and its properties flat beside them. */
|
|
32
|
+
export interface A2uiComponent {
|
|
33
|
+
id: string;
|
|
34
|
+
component: string;
|
|
35
|
+
[property: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** One server-to-client A2UI message. */
|
|
38
|
+
export type A2uiServerMessage = {
|
|
39
|
+
version: typeof A2UI_VERSION;
|
|
40
|
+
} & ({
|
|
41
|
+
createSurface: {
|
|
42
|
+
surfaceId: string;
|
|
43
|
+
catalogId: string;
|
|
44
|
+
theme?: Record<string, unknown>;
|
|
45
|
+
sendDataModel?: boolean;
|
|
46
|
+
};
|
|
47
|
+
} | {
|
|
48
|
+
updateComponents: {
|
|
49
|
+
surfaceId: string;
|
|
50
|
+
components: A2uiComponent[];
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
updateDataModel: {
|
|
54
|
+
surfaceId: string;
|
|
55
|
+
path?: string;
|
|
56
|
+
value?: unknown;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
deleteSurface: {
|
|
60
|
+
surfaceId: string;
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
/** What a mapper is handed for one node. */
|
|
64
|
+
export interface A2uiMapContext {
|
|
65
|
+
/** The id the node's root component MUST take (its parent references it). */
|
|
66
|
+
id: string;
|
|
67
|
+
/** The ids of the node's children, already converted (a layout lists them). */
|
|
68
|
+
children: readonly string[];
|
|
69
|
+
/** A fresh id derived from the node's (`<id>~<suffix>`), for the extra components a mapping needs. */
|
|
70
|
+
derive(suffix: string): string;
|
|
71
|
+
/** The node is still being written (a preview): props may be missing — default them. */
|
|
72
|
+
incomplete: boolean;
|
|
73
|
+
/** The component's plain-text fallback (`fallbackText`), for a mapping that only has text. */
|
|
74
|
+
text(): string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Maps one of this agent's components to A2UI components. Must return a component whose `id` is
|
|
78
|
+
* `ctx.id`; any others it adds take ids from `ctx.derive`.
|
|
79
|
+
*/
|
|
80
|
+
export type A2uiMapper = (props: Record<string, unknown>, ctx: A2uiMapContext) => A2uiComponent[];
|
|
81
|
+
export interface A2uiOptions {
|
|
82
|
+
/**
|
|
83
|
+
* The A2UI catalog surfaces are created with. Default the basic catalog. An app that registers
|
|
84
|
+
* its own components on the client names its catalog here (and lists them in `custom`).
|
|
85
|
+
*/
|
|
86
|
+
catalogId?: string;
|
|
87
|
+
/** Per component: a mapping to A2UI (overrides a builtin's), or `'custom'` to send it as is. */
|
|
88
|
+
components?: Record<string, A2uiMapper | 'custom'>;
|
|
89
|
+
/**
|
|
90
|
+
* A component with no mapping: `'text'` (default) draws its `fallbackText` as an A2UI `Text`;
|
|
91
|
+
* `'custom'` sends it as a custom component of the same name, props flat (the client's catalog
|
|
92
|
+
* must have it).
|
|
93
|
+
*/
|
|
94
|
+
unmapped?: 'text' | 'custom';
|
|
95
|
+
/** The agent's catalog: what unmapped components' text comes from. */
|
|
96
|
+
catalog?: Catalog;
|
|
97
|
+
/** `createSurface.theme` (basic catalog: `primaryColor`, `agentDisplayName`, `iconUrl`). */
|
|
98
|
+
theme?: Record<string, unknown>;
|
|
99
|
+
}
|
|
100
|
+
/** The library builtins, mapped onto A2UI's basic catalog. */
|
|
101
|
+
export declare const A2UI_BUILTIN_MAPPERS: Readonly<Record<string, A2uiMapper>>;
|
|
102
|
+
/**
|
|
103
|
+
* A `ui` frame as A2UI components, flat, the root's id `root`. A composed tree (`genui:tree`) maps
|
|
104
|
+
* node by node — node ids are their positions (`root`, `root.0`, `root.0.2`), stable from the first
|
|
105
|
+
* preview to the final frame, so a streamed surface only ever grows. A node still held back
|
|
106
|
+
* (`held`) is left out: its parent references an id that arrives later, which A2UI draws as a
|
|
107
|
+
* placeholder.
|
|
108
|
+
*/
|
|
109
|
+
export declare function toA2uiComponents(frame: {
|
|
110
|
+
component: string;
|
|
111
|
+
props: unknown;
|
|
112
|
+
}, options?: A2uiOptions): A2uiComponent[];
|
|
113
|
+
/** The messages that draw (or redraw) a surface: `createSurface` the first time, then its components. */
|
|
114
|
+
export declare function a2uiSurfaceMessages(surfaceId: string, components: A2uiComponent[], options: A2uiOptions & {
|
|
115
|
+
create: boolean;
|
|
116
|
+
sendDataModel?: boolean;
|
|
117
|
+
}): A2uiServerMessage[];
|
|
118
|
+
/** A surface id A2UI clients accept, from a `ui` frame id (`<toolCallId>:ui:0`). */
|
|
119
|
+
export declare function a2uiSurfaceId(frameId: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* A2UI's AG-UI binding (the AG-UI A2UI middleware, CopilotKit's renderer): one `ACTIVITY_SNAPSHOT`
|
|
122
|
+
* of type `a2ui-surface` per `ui` frame, carrying the whole surface (`createSurface` +
|
|
123
|
+
* `updateComponents`) with `replace: true` — so each preview of a streaming tree repaints the same
|
|
124
|
+
* activity in place, keyed by the frame id.
|
|
125
|
+
*/
|
|
126
|
+
export declare function a2uiActivityEvent(frame: {
|
|
127
|
+
id: string;
|
|
128
|
+
component: string;
|
|
129
|
+
props: unknown;
|
|
130
|
+
partial?: boolean;
|
|
131
|
+
}, options?: A2uiOptions): AgUiEvent | null;
|
|
132
|
+
/**
|
|
133
|
+
* An A2UI catalog definition (v0.9 inline catalog shape) for an agent catalog's components sent
|
|
134
|
+
* as custom components: `{ catalogId, components: { Name: JSON Schema } }` — what a client
|
|
135
|
+
* registers, or hands an A2UI-aware runtime (`a2uiClientCapabilities.inlineCatalogs`).
|
|
136
|
+
*/
|
|
137
|
+
export declare function a2uiCatalog(catalog: Catalog, options: {
|
|
138
|
+
catalogId: string;
|
|
139
|
+
only?: readonly string[];
|
|
140
|
+
}): {
|
|
141
|
+
catalogId: string;
|
|
142
|
+
components: Record<string, Record<string, unknown>>;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* A client-to-server A2UI message, or an AG-UI `forwardedProps.a2uiAction`, as a {@link UiAction}:
|
|
146
|
+
* v0.9 `{ version, action: { name, surfaceId, sourceComponentId, timestamp, context } }`, v0.8
|
|
147
|
+
* `{ userAction: { … } }`, or the bare action object. A string when it is not one.
|
|
148
|
+
*/
|
|
149
|
+
export declare function readA2uiAction(raw: unknown, options?: {
|
|
150
|
+
maxBytes?: number;
|
|
151
|
+
}): UiAction | string;
|
|
152
|
+
/** The surface an approval interrupt is shown on: its message, and Approve / Reject buttons. */
|
|
153
|
+
export declare function a2uiApprovalComponents(interrupt: AgUiInterrupt): A2uiComponent[];
|
|
154
|
+
export interface A2uiStreamOptions extends A2uiOptions {
|
|
155
|
+
/**
|
|
156
|
+
* Assistant text: `'surface'` (default) streams it into a surface of its own — one `Text` bound
|
|
157
|
+
* to `/text` in the data model, updated as tokens arrive; `'omit'` leaves text out (UI only).
|
|
158
|
+
*/
|
|
159
|
+
text?: 'surface' | 'omit';
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* One AG-UI run as an A2UI message stream — the projection the A2UI transport serves. Stateful
|
|
163
|
+
* (which surfaces exist), pure otherwise: feed it the run's AG-UI events in order.
|
|
164
|
+
*
|
|
165
|
+
* - `CUSTOM agora.ui` → a surface per `ui` frame id, created once and updated in place (previews
|
|
166
|
+
* included); a withdrawn preview deletes it;
|
|
167
|
+
* - text messages → a text surface each (see {@link A2uiStreamOptions.text});
|
|
168
|
+
* - an approval interrupt → a surface with Approve / Reject buttons ({@link A2UI_APPROVE_ACTION});
|
|
169
|
+
* any other interrupt → a text surface saying to answer it in the app;
|
|
170
|
+
* - `RUN_ERROR` → a text surface with the message.
|
|
171
|
+
*/
|
|
172
|
+
export declare class A2uiProjector {
|
|
173
|
+
private readonly options;
|
|
174
|
+
private readonly surfaces;
|
|
175
|
+
private readonly texts;
|
|
176
|
+
constructor(options?: A2uiStreamOptions);
|
|
177
|
+
project(event: AgUiEvent): A2uiServerMessage[];
|
|
178
|
+
private surface;
|
|
179
|
+
private ui;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/a2ui/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,+DAA+D;AAC/D,eAAO,MAAM,YAAY,SAAS,CAAC;AAEnC,+FAA+F;AAC/F,eAAO,MAAM,qBAAqB,oEACiC,CAAC;AAEpE,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,YAChC,MAAM,EACN,OAAO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