@darqlabs/curator-sdk-react 0.6.1 → 0.8.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/README.md +18 -0
- package/dist/cjs/CuratorAdapter.d.ts +37 -2
- package/dist/cjs/CuratorAdapter.d.ts.map +1 -1
- package/dist/cjs/CuratorAdapter.js +119 -20
- package/dist/cjs/CuratorAdapter.js.map +1 -1
- package/dist/cjs/CuratorChat.d.ts +8 -0
- package/dist/cjs/CuratorChat.d.ts.map +1 -1
- package/dist/cjs/CuratorChat.js +28 -8
- package/dist/cjs/CuratorChat.js.map +1 -1
- package/dist/cjs/historyMessages.d.ts +20 -1
- package/dist/cjs/historyMessages.d.ts.map +1 -1
- package/dist/cjs/historyMessages.js +25 -3
- package/dist/cjs/historyMessages.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mcpApps/McpAppContext.d.ts +39 -0
- package/dist/cjs/mcpApps/McpAppContext.d.ts.map +1 -0
- package/dist/cjs/mcpApps/McpAppContext.js +19 -0
- package/dist/cjs/mcpApps/McpAppContext.js.map +1 -0
- package/dist/cjs/mcpApps/McpAppToolPart.d.ts +27 -0
- package/dist/cjs/mcpApps/McpAppToolPart.d.ts.map +1 -0
- package/dist/cjs/mcpApps/McpAppToolPart.js +275 -0
- package/dist/cjs/mcpApps/McpAppToolPart.js.map +1 -0
- package/dist/cjs/mcpApps/hostBridge.d.ts +127 -0
- package/dist/cjs/mcpApps/hostBridge.d.ts.map +1 -0
- package/dist/cjs/mcpApps/hostBridge.js +306 -0
- package/dist/cjs/mcpApps/hostBridge.js.map +1 -0
- package/dist/esm/CuratorAdapter.d.ts +37 -2
- package/dist/esm/CuratorAdapter.d.ts.map +1 -1
- package/dist/esm/CuratorAdapter.js +119 -20
- package/dist/esm/CuratorAdapter.js.map +1 -1
- package/dist/esm/CuratorChat.d.ts +8 -0
- package/dist/esm/CuratorChat.d.ts.map +1 -1
- package/dist/esm/CuratorChat.js +28 -8
- package/dist/esm/CuratorChat.js.map +1 -1
- package/dist/esm/historyMessages.d.ts +20 -1
- package/dist/esm/historyMessages.d.ts.map +1 -1
- package/dist/esm/historyMessages.js +25 -3
- package/dist/esm/historyMessages.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mcpApps/McpAppContext.d.ts +39 -0
- package/dist/esm/mcpApps/McpAppContext.d.ts.map +1 -0
- package/dist/esm/mcpApps/McpAppContext.js +15 -0
- package/dist/esm/mcpApps/McpAppContext.js.map +1 -0
- package/dist/esm/mcpApps/McpAppToolPart.d.ts +27 -0
- package/dist/esm/mcpApps/McpAppToolPart.d.ts.map +1 -0
- package/dist/esm/mcpApps/McpAppToolPart.js +271 -0
- package/dist/esm/mcpApps/McpAppToolPart.js.map +1 -0
- package/dist/esm/mcpApps/hostBridge.d.ts +127 -0
- package/dist/esm/mcpApps/hostBridge.d.ts.map +1 -0
- package/dist/esm/mcpApps/hostBridge.js +300 -0
- package/dist/esm/mcpApps/hostBridge.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Host side of the MCP Apps (SEP-1865) bridge: JSON-RPC 2.0 over a message
|
|
4
|
+
* transport, from the widget to one rendered view.
|
|
5
|
+
*
|
|
6
|
+
* Pure. Knows nothing about React, iframes or the network: the caller hands
|
|
7
|
+
* it a `post` function to reach the view and feeds it every message the view
|
|
8
|
+
* sends. Everything the view may ask for is a `handlers` callback, so the
|
|
9
|
+
* whole protocol can be exercised in a unit test with a fake view.
|
|
10
|
+
*
|
|
11
|
+
* What the view may do, and what this bridge does with it:
|
|
12
|
+
*
|
|
13
|
+
* ui/initialize → handshake; answers with host info,
|
|
14
|
+
* capabilities and context
|
|
15
|
+
* ui/notifications/initialized → view is ready; deliver the tool input,
|
|
16
|
+
* then the tool result once known
|
|
17
|
+
* tools/call → handlers.callTool (the Curator data plane)
|
|
18
|
+
* ui/message → handlers.sendMessage (app-reported text)
|
|
19
|
+
* ui/update-model-context → handlers.updateModelContext (surfaced only)
|
|
20
|
+
* ui/open-link → handlers.openLink (http(s) only)
|
|
21
|
+
* ui/request-display-mode → always `inline` in v1
|
|
22
|
+
* ui/notifications/size-changed → handlers.onSizeChange
|
|
23
|
+
* notifications/message → handlers.onLog
|
|
24
|
+
* ping → {}
|
|
25
|
+
* anything else → JSON-RPC "method not found"
|
|
26
|
+
*
|
|
27
|
+
* Method names are the ones ext-apps 2.0 emits (`ui/…`). The deprecated
|
|
28
|
+
* `notifications/…` spellings assistant-ui also accepts are NOT supported:
|
|
29
|
+
* fewer names to reason about, and our reference view uses the current SDK.
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.McpAppHostBridge = exports.MCP_APPS_PROTOCOL_VERSION = void 0;
|
|
33
|
+
exports.extractMessageText = extractMessageText;
|
|
34
|
+
exports.isOpenableUrl = isOpenableUrl;
|
|
35
|
+
exports.MCP_APPS_PROTOCOL_VERSION = "2026-01-26";
|
|
36
|
+
const ERR = { invalidRequest: -32600, methodNotFound: -32601, invalidParams: -32602, internal: -32603 };
|
|
37
|
+
const DEFAULT_MAX_MESSAGE_CHARS = 2048;
|
|
38
|
+
// Control characters except tab / newline / carriage return.
|
|
39
|
+
// eslint-disable-next-line no-control-regex
|
|
40
|
+
const CONTROL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g;
|
|
41
|
+
function isRecord(v) {
|
|
42
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The text of a spec-shaped `ui/message`: `{ role, content: [{type:"text", text}] }`.
|
|
46
|
+
* Also accepts a bare `{ text }` for lenient views. Control characters are
|
|
47
|
+
* stripped and the length capped; the result is plain text, never markup.
|
|
48
|
+
*/
|
|
49
|
+
function extractMessageText(params, maxChars = DEFAULT_MAX_MESSAGE_CHARS) {
|
|
50
|
+
if (!isRecord(params))
|
|
51
|
+
return null;
|
|
52
|
+
let text = null;
|
|
53
|
+
if (Array.isArray(params.content)) {
|
|
54
|
+
text = params.content
|
|
55
|
+
.filter((c) => isRecord(c) && c.type === "text" && typeof c.text === "string")
|
|
56
|
+
.map((c) => c.text)
|
|
57
|
+
.join("\n");
|
|
58
|
+
}
|
|
59
|
+
else if (typeof params.text === "string") {
|
|
60
|
+
text = params.text;
|
|
61
|
+
}
|
|
62
|
+
if (text === null)
|
|
63
|
+
return null;
|
|
64
|
+
const clean = text.replace(CONTROL_CHARS, "").slice(0, maxChars).trim();
|
|
65
|
+
return clean.length > 0 ? clean : null;
|
|
66
|
+
}
|
|
67
|
+
/** Only web links leave the sandbox. */
|
|
68
|
+
function isOpenableUrl(url) {
|
|
69
|
+
if (typeof url !== "string")
|
|
70
|
+
return false;
|
|
71
|
+
try {
|
|
72
|
+
const u = new URL(url);
|
|
73
|
+
return u.protocol === "https:" || u.protocol === "http:";
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class McpAppHostBridge {
|
|
80
|
+
post;
|
|
81
|
+
handlers;
|
|
82
|
+
hostInfo;
|
|
83
|
+
hostContext;
|
|
84
|
+
maxMessageChars;
|
|
85
|
+
initialized = false;
|
|
86
|
+
closed = false;
|
|
87
|
+
nextId = 1;
|
|
88
|
+
pending = new Map();
|
|
89
|
+
/** Tool input, delivered on `initialized` (or immediately when already ready). */
|
|
90
|
+
toolInput;
|
|
91
|
+
toolInputSent = false;
|
|
92
|
+
/** Tool result, delivered after input once known. */
|
|
93
|
+
toolResult;
|
|
94
|
+
toolResultSent = false;
|
|
95
|
+
constructor(opts) {
|
|
96
|
+
this.post = opts.post;
|
|
97
|
+
this.handlers = opts.handlers;
|
|
98
|
+
this.hostInfo = opts.hostInfo ?? { name: "Curator", version: "1" };
|
|
99
|
+
this.hostContext = {
|
|
100
|
+
platform: "web",
|
|
101
|
+
displayMode: "inline",
|
|
102
|
+
availableDisplayModes: ["inline"],
|
|
103
|
+
...opts.hostContext,
|
|
104
|
+
};
|
|
105
|
+
this.maxMessageChars = opts.maxMessageChars ?? DEFAULT_MAX_MESSAGE_CHARS;
|
|
106
|
+
}
|
|
107
|
+
get isInitialized() {
|
|
108
|
+
return this.initialized;
|
|
109
|
+
}
|
|
110
|
+
// ── host → view ─────────────────────────────────────────────────────────
|
|
111
|
+
setToolInput(args) {
|
|
112
|
+
this.toolInput = args;
|
|
113
|
+
this.flush();
|
|
114
|
+
}
|
|
115
|
+
setToolResult(result) {
|
|
116
|
+
this.toolResult = result;
|
|
117
|
+
this.flush();
|
|
118
|
+
}
|
|
119
|
+
notifyToolCancelled(reason) {
|
|
120
|
+
this.notify("ui/notifications/tool-cancelled", { reason });
|
|
121
|
+
}
|
|
122
|
+
updateHostContext(patch) {
|
|
123
|
+
this.hostContext = { ...this.hostContext, ...patch };
|
|
124
|
+
if (this.initialized)
|
|
125
|
+
this.notify("ui/notifications/host-context-changed", patch);
|
|
126
|
+
}
|
|
127
|
+
/** Ask the view to tear down; resolves when it answers or after `timeoutMs`. */
|
|
128
|
+
async teardown(timeoutMs = 500) {
|
|
129
|
+
if (this.closed)
|
|
130
|
+
return;
|
|
131
|
+
if (this.initialized) {
|
|
132
|
+
await Promise.race([
|
|
133
|
+
this.request("ui/resource-teardown", {}).catch(() => undefined),
|
|
134
|
+
new Promise((r) => setTimeout(r, timeoutMs)),
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
this.close();
|
|
138
|
+
}
|
|
139
|
+
close() {
|
|
140
|
+
this.closed = true;
|
|
141
|
+
for (const p of this.pending.values())
|
|
142
|
+
p.reject(new Error("bridge closed"));
|
|
143
|
+
this.pending.clear();
|
|
144
|
+
}
|
|
145
|
+
// ── view → host ─────────────────────────────────────────────────────────
|
|
146
|
+
/** Feed one message received from the view. Non-JSON-RPC traffic is ignored. */
|
|
147
|
+
onMessage(data) {
|
|
148
|
+
if (this.closed || !isRecord(data) || data.jsonrpc !== "2.0")
|
|
149
|
+
return;
|
|
150
|
+
if ("method" in data && typeof data.method === "string") {
|
|
151
|
+
if ("id" in data && (typeof data.id === "string" || typeof data.id === "number")) {
|
|
152
|
+
void this.handleRequest(data);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.handleNotification(data);
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if ("id" in data && (typeof data.id === "string" || typeof data.id === "number")) {
|
|
160
|
+
const pending = this.pending.get(data.id);
|
|
161
|
+
if (!pending)
|
|
162
|
+
return;
|
|
163
|
+
this.pending.delete(data.id);
|
|
164
|
+
const res = data;
|
|
165
|
+
if (res.error)
|
|
166
|
+
pending.reject(new Error(res.error.message));
|
|
167
|
+
else
|
|
168
|
+
pending.resolve(res.result);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async handleRequest(req) {
|
|
172
|
+
const params = isRecord(req.params) ? req.params : {};
|
|
173
|
+
try {
|
|
174
|
+
switch (req.method) {
|
|
175
|
+
case "ui/initialize": {
|
|
176
|
+
const requested = typeof params.protocolVersion === "string" ? params.protocolVersion : exports.MCP_APPS_PROTOCOL_VERSION;
|
|
177
|
+
this.respond(req.id, {
|
|
178
|
+
protocolVersion: requested,
|
|
179
|
+
hostInfo: this.hostInfo,
|
|
180
|
+
hostCapabilities: {
|
|
181
|
+
openLinks: {},
|
|
182
|
+
serverTools: {},
|
|
183
|
+
message: { text: {} },
|
|
184
|
+
updateModelContext: { text: {}, structuredContent: {} },
|
|
185
|
+
logging: {},
|
|
186
|
+
},
|
|
187
|
+
hostContext: this.hostContext,
|
|
188
|
+
});
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
case "ping":
|
|
192
|
+
this.respond(req.id, {});
|
|
193
|
+
return;
|
|
194
|
+
case "tools/call": {
|
|
195
|
+
if (typeof params.name !== "string" || !params.name) {
|
|
196
|
+
this.error(req.id, ERR.invalidParams, "`name` is required");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const args = isRecord(params.arguments) ? params.arguments : {};
|
|
200
|
+
const meta = isRecord(params._meta) ? params._meta : undefined;
|
|
201
|
+
const result = await this.handlers.callTool({
|
|
202
|
+
name: params.name,
|
|
203
|
+
arguments: args,
|
|
204
|
+
...(meta ? { _meta: meta } : {}),
|
|
205
|
+
});
|
|
206
|
+
this.respond(req.id, result);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
case "ui/message": {
|
|
210
|
+
const text = extractMessageText(params, this.maxMessageChars);
|
|
211
|
+
if (!text) {
|
|
212
|
+
this.error(req.id, ERR.invalidParams, "ui/message needs text content");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const accepted = await this.handlers.sendMessage(text);
|
|
216
|
+
this.respond(req.id, accepted ? {} : { isError: true });
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
case "ui/update-model-context": {
|
|
220
|
+
this.handlers.updateModelContext?.({
|
|
221
|
+
content: params.content,
|
|
222
|
+
structuredContent: params.structuredContent,
|
|
223
|
+
});
|
|
224
|
+
this.respond(req.id, {});
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
case "ui/open-link": {
|
|
228
|
+
const ok = isOpenableUrl(params.url) && (this.handlers.openLink?.(params.url) ?? false);
|
|
229
|
+
this.respond(req.id, ok ? {} : { isError: true });
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
case "ui/request-display-mode":
|
|
233
|
+
// Inline only in v1; the host has final authority per spec.
|
|
234
|
+
this.respond(req.id, { mode: "inline" });
|
|
235
|
+
return;
|
|
236
|
+
default:
|
|
237
|
+
this.error(req.id, ERR.methodNotFound, `${req.method} is not supported by this host`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
242
|
+
this.handlers.onError?.(err instanceof Error ? err : new Error(message));
|
|
243
|
+
// A refused/failed tool call is still a well-formed JSON-RPC error; the
|
|
244
|
+
// view decides how to show it.
|
|
245
|
+
this.error(req.id, ERR.internal, message);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
handleNotification(n) {
|
|
249
|
+
const params = isRecord(n.params) ? n.params : {};
|
|
250
|
+
switch (n.method) {
|
|
251
|
+
case "ui/notifications/initialized":
|
|
252
|
+
this.initialized = true;
|
|
253
|
+
this.handlers.onInitialized?.();
|
|
254
|
+
this.flush();
|
|
255
|
+
return;
|
|
256
|
+
case "ui/notifications/size-changed":
|
|
257
|
+
this.handlers.onSizeChange?.({
|
|
258
|
+
...(typeof params.width === "number" ? { width: params.width } : {}),
|
|
259
|
+
...(typeof params.height === "number" ? { height: params.height } : {}),
|
|
260
|
+
});
|
|
261
|
+
return;
|
|
262
|
+
case "notifications/message":
|
|
263
|
+
this.handlers.onLog?.(params);
|
|
264
|
+
return;
|
|
265
|
+
default:
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// ── plumbing ────────────────────────────────────────────────────────────
|
|
270
|
+
flush() {
|
|
271
|
+
if (!this.initialized || this.closed)
|
|
272
|
+
return;
|
|
273
|
+
if (this.toolInput !== undefined && !this.toolInputSent) {
|
|
274
|
+
this.notify("ui/notifications/tool-input", { arguments: this.toolInput });
|
|
275
|
+
this.toolInputSent = true;
|
|
276
|
+
}
|
|
277
|
+
if (this.toolResult !== undefined && !this.toolResultSent) {
|
|
278
|
+
this.notify("ui/notifications/tool-result", this.toolResult);
|
|
279
|
+
this.toolResultSent = true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
notify(method, params) {
|
|
283
|
+
if (this.closed)
|
|
284
|
+
return;
|
|
285
|
+
this.post({ jsonrpc: "2.0", method, params });
|
|
286
|
+
}
|
|
287
|
+
request(method, params) {
|
|
288
|
+
const id = this.nextId++;
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
this.pending.set(id, { resolve, reject });
|
|
291
|
+
this.post({ jsonrpc: "2.0", id, method, params });
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
respond(id, result) {
|
|
295
|
+
if (this.closed)
|
|
296
|
+
return;
|
|
297
|
+
this.post({ jsonrpc: "2.0", id, result });
|
|
298
|
+
}
|
|
299
|
+
error(id, code, message) {
|
|
300
|
+
if (this.closed)
|
|
301
|
+
return;
|
|
302
|
+
this.post({ jsonrpc: "2.0", id, error: { code, message } });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.McpAppHostBridge = McpAppHostBridge;
|
|
306
|
+
//# sourceMappingURL=hostBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostBridge.js","sourceRoot":"","sources":["../../../src/mcpApps/hostBridge.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAgFH,gDAiBC;AAGD,sCAQC;AA1GY,QAAA,yBAAyB,GAAG,YAAY,CAAA;AA+DrD,MAAM,GAAG,GAAG,EAAE,cAAc,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAW,CAAA;AAChH,MAAM,yBAAyB,GAAG,IAAI,CAAA;AACtC,6DAA6D;AAC7D,4CAA4C;AAC5C,MAAM,aAAa,GAAG,iDAAiD,CAAA;AAEvE,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,MAAe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
-
import type { AssistantMessage, Chat, CuratorError, StreamState, StreamPlanProgress } from "@darqlabs/curator-sdk";
|
|
22
|
+
import type { AssistantMessage, Chat, CuratorError, McpCallToolResult, StreamState, StreamPlanProgress } from "@darqlabs/curator-sdk";
|
|
23
|
+
/**
|
|
24
|
+
* A tool-call part as assistant-ui renders it. `mcp.app.serverId` carries the
|
|
25
|
+
* Curator APP SESSION, not a server id: it is the opaque routing key the view
|
|
26
|
+
* renderer threads through every data-plane call, and a session is exactly
|
|
27
|
+
* "which server, which tool call, for whom".
|
|
28
|
+
*/
|
|
29
|
+
/** JSON as assistant-ui types a tool call's arguments. Stream arguments ARE JSON (they were parsed from it). */
|
|
30
|
+
export type JsonValue = string | number | boolean | null | readonly JsonValue[] | JsonObject;
|
|
31
|
+
export type JsonObject = {
|
|
32
|
+
readonly [k: string]: JsonValue;
|
|
33
|
+
};
|
|
34
|
+
export interface McpAppToolCallPart {
|
|
35
|
+
type: "tool-call";
|
|
36
|
+
toolCallId: string;
|
|
37
|
+
toolName: string;
|
|
38
|
+
args: JsonObject;
|
|
39
|
+
argsText: string;
|
|
40
|
+
result?: McpCallToolResult;
|
|
41
|
+
isError?: boolean;
|
|
42
|
+
mcp: {
|
|
43
|
+
app: {
|
|
44
|
+
resourceUri: string;
|
|
45
|
+
serverId: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
23
49
|
export interface CuratorAdapterCallbacks {
|
|
24
50
|
/** Fired once per successfully-returned assistant message. */
|
|
25
51
|
onMessage?: (message: AssistantMessage) => void;
|
|
@@ -40,11 +66,20 @@ export interface CuratorAdapterCallbacks {
|
|
|
40
66
|
/** Fired on any send-time error surfaced through the stream. */
|
|
41
67
|
onError?: (error: CuratorError | Error) => void;
|
|
42
68
|
}
|
|
69
|
+
export interface CuratorAdapterOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Declare to the server that this client renders MCP App views. Default
|
|
72
|
+
* true — the widget does. When false (the host passed
|
|
73
|
+
* `mcpApps={{ enabled: false }}`), the server mints no app session, sends
|
|
74
|
+
* plain tool-call frames, and does not tell the agent a view is showing.
|
|
75
|
+
*/
|
|
76
|
+
rendersMcpApps?: boolean;
|
|
77
|
+
}
|
|
43
78
|
export declare function createCuratorAdapter(chat: Chat, callbacks?: CuratorAdapterCallbacks,
|
|
44
79
|
/**
|
|
45
80
|
* Supplies the storage references for this turn's attachments. Absent when
|
|
46
81
|
* the widget was mounted without attachment support, in which case the send
|
|
47
82
|
* behaves exactly as before.
|
|
48
83
|
*/
|
|
49
|
-
attachments?: Pick<CuratorAttachmentAdapter, "takeReferences"
|
|
84
|
+
attachments?: Pick<CuratorAttachmentAdapter, "takeReferences">, options?: CuratorAdapterOptions): ChatModelAdapter;
|
|
50
85
|
//# sourceMappingURL=CuratorAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CuratorAdapter.d.ts","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAA;AAC/E,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,kBAAkB,EACnB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"CuratorAdapter.d.ts","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAA;AAC/E,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,EACJ,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EACnB,MAAM,u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EAAE,gBAAgB,CAAC,EAC9D,OAAO,GAAE,qBAA0B,GAClC,gBAAgB,CA8PlB"}
|
|
@@ -17,19 +17,29 @@
|
|
|
17
17
|
* mounted CuratorChat / launcher panel) so multi-turn context stays
|
|
18
18
|
* intact across runs.
|
|
19
19
|
*/
|
|
20
|
+
import { APP_SESSION_METADATA_KEY } from "./mcpApps/McpAppContext.js";
|
|
20
21
|
export function createCuratorAdapter(chat, callbacks = {},
|
|
21
22
|
/**
|
|
22
23
|
* Supplies the storage references for this turn's attachments. Absent when
|
|
23
24
|
* the widget was mounted without attachment support, in which case the send
|
|
24
25
|
* behaves exactly as before.
|
|
25
26
|
*/
|
|
26
|
-
attachments) {
|
|
27
|
+
attachments, options = {}) {
|
|
28
|
+
// Declared on every send, never inferred server-side: this is how the
|
|
29
|
+
// server tells the browser widget apart from a customer's own caller on the
|
|
30
|
+
// same API key.
|
|
31
|
+
const clientCapabilities = { mcpApps: options.rendersMcpApps !== false };
|
|
27
32
|
return {
|
|
28
33
|
async *run({ messages, abortSignal }) {
|
|
29
34
|
const userText = extractLatestUserText(messages);
|
|
30
35
|
const files = attachments
|
|
31
36
|
? attachments.takeReferences(latestUserAttachmentIds(messages))
|
|
32
37
|
: [];
|
|
38
|
+
// MCP Apps: a turn a rendered VIEW sent (`ui/message`). The session it was
|
|
39
|
+
// rendered under rides on the message metadata and goes to the server as
|
|
40
|
+
// `app_session`, which validates it and stores the row with a `source`
|
|
41
|
+
// marker — the record says a view sent it, never that a person typed it.
|
|
42
|
+
const appSession = latestUserAppSession(messages);
|
|
33
43
|
// A file with no caption is a complete message — the SDK accepts content
|
|
34
44
|
// OR files, and a bill of lading dropped in with nothing typed is the
|
|
35
45
|
// single most common way this widget is used. Returning early on empty
|
|
@@ -46,16 +56,41 @@ attachments) {
|
|
|
46
56
|
// then `done` (whose message is the terminal reply ALONE) replaced the
|
|
47
57
|
// whole thing — so the user watched a paragraph appear and then get
|
|
48
58
|
// overwritten by different text. Segments keep every token the user saw.
|
|
49
|
-
|
|
59
|
+
// Ordered list of settled parts — text segments and MCP App tool-call
|
|
60
|
+
// parts interleaved in arrival order — plus the in-flight text.
|
|
61
|
+
const settled = [];
|
|
62
|
+
/** Live tool-call parts by id, so completed/failed can update in place. */
|
|
63
|
+
const appParts = new Map();
|
|
50
64
|
let acc = "";
|
|
51
|
-
/**
|
|
65
|
+
/** Settled parts plus the in-flight text, as assistant-ui parts. */
|
|
52
66
|
const partsWith = (trailing) => {
|
|
53
|
-
const
|
|
67
|
+
const out = [...settled];
|
|
68
|
+
if (trailing.length > 0)
|
|
69
|
+
out.push({ type: "text", text: trailing });
|
|
54
70
|
// assistant-ui expects at least one part; an empty run yields empty text.
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
return out.length > 0 ? out : [{ type: "text", text: "" }];
|
|
72
|
+
};
|
|
73
|
+
/** Settle the in-flight text as its own segment, if there is any. */
|
|
74
|
+
const settleText = () => {
|
|
75
|
+
if (acc.trim().length > 0)
|
|
76
|
+
settled.push({ type: "text", text: acc });
|
|
77
|
+
acc = "";
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* A view whose call never got a terminal event would spin forever. Give
|
|
81
|
+
* every unresolved app part a valid error result so the frame receives a
|
|
82
|
+
* terminal tool-result.
|
|
83
|
+
*/
|
|
84
|
+
const interruptUnresolvedApps = (text) => {
|
|
85
|
+
for (const [id, p] of appParts) {
|
|
86
|
+
if (p.result !== undefined)
|
|
87
|
+
continue;
|
|
88
|
+
const updated = { ...p, isError: true, result: { isError: true, content: [{ type: "text", text }] } };
|
|
89
|
+
appParts.set(id, updated);
|
|
90
|
+
const idx = settled.indexOf(p);
|
|
91
|
+
if (idx >= 0)
|
|
92
|
+
settled[idx] = updated;
|
|
93
|
+
}
|
|
59
94
|
};
|
|
60
95
|
try {
|
|
61
96
|
// The options object is now always passed, including when there are no
|
|
@@ -70,9 +105,12 @@ attachments) {
|
|
|
70
105
|
// the local stream and left the agent running to completion — burning
|
|
71
106
|
// tokens for a reply nobody would ever see. Checking an abort is not
|
|
72
107
|
// the same as acting on it.
|
|
73
|
-
const stream =
|
|
74
|
-
?
|
|
75
|
-
|
|
108
|
+
const stream = chat.stream(userText, {
|
|
109
|
+
...(files.length ? { files } : {}),
|
|
110
|
+
...(appSession ? { appSession } : {}),
|
|
111
|
+
clientCapabilities,
|
|
112
|
+
signal: abortSignal,
|
|
113
|
+
});
|
|
76
114
|
for await (const event of stream) {
|
|
77
115
|
if (abortSignal.aborted)
|
|
78
116
|
return;
|
|
@@ -89,14 +127,58 @@ attachments) {
|
|
|
89
127
|
// Turn boundary: anything streamed before this belongs to the turn
|
|
90
128
|
// that decided to call a tool. Settle it so the next turn's tokens
|
|
91
129
|
// start a new part instead of extending someone else's sentence.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
130
|
+
// (Whitespace-only narration is dropped by settleText.)
|
|
131
|
+
const hadText = acc.trim().length > 0;
|
|
132
|
+
settleText();
|
|
133
|
+
// MCP Apps: a call that renders a view becomes a tool-call part.
|
|
134
|
+
// Only when the server minted a session for it — a plain tool call
|
|
135
|
+
// stays what it always was, a boundary and nothing rendered.
|
|
136
|
+
if (event.app) {
|
|
137
|
+
const partForApp = {
|
|
138
|
+
type: "tool-call",
|
|
139
|
+
toolCallId: event.toolCallId,
|
|
140
|
+
toolName: event.toolName,
|
|
141
|
+
args: (event.arguments ?? {}),
|
|
142
|
+
argsText: JSON.stringify(event.arguments ?? {}),
|
|
143
|
+
mcp: { app: { resourceUri: event.app.resourceUri, serverId: event.app.session } },
|
|
144
|
+
};
|
|
145
|
+
appParts.set(event.toolCallId, partForApp);
|
|
146
|
+
settled.push(partForApp);
|
|
95
147
|
yield { content: partsWith(acc) };
|
|
96
148
|
}
|
|
97
|
-
else {
|
|
98
|
-
|
|
99
|
-
|
|
149
|
+
else if (hadText) {
|
|
150
|
+
yield { content: partsWith(acc) };
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (event.type === "tool_call.completed" || event.type === "tool_call.failed") {
|
|
155
|
+
// Only MCP App parts exist to update; every other tool call was a
|
|
156
|
+
// boundary. Idempotent: a duplicate terminal event for the same id
|
|
157
|
+
// is a no-op once the result is set.
|
|
158
|
+
const existing = appParts.get(event.toolCallId);
|
|
159
|
+
if (existing && existing.result === undefined) {
|
|
160
|
+
const idx = settled.indexOf(existing);
|
|
161
|
+
const updated = event.type === "tool_call.completed"
|
|
162
|
+
? { ...existing, result: event.result ?? { content: [] }, isError: event.result?.isError === true }
|
|
163
|
+
: {
|
|
164
|
+
...existing,
|
|
165
|
+
isError: true,
|
|
166
|
+
result: event.result ?? {
|
|
167
|
+
isError: true,
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
type: "text",
|
|
171
|
+
text: event.reason === "policy_denied"
|
|
172
|
+
? "This action was not allowed."
|
|
173
|
+
: "The tool could not complete.",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
appParts.set(event.toolCallId, updated);
|
|
179
|
+
if (idx >= 0)
|
|
180
|
+
settled[idx] = updated;
|
|
181
|
+
yield { content: partsWith(acc) };
|
|
100
182
|
}
|
|
101
183
|
continue;
|
|
102
184
|
}
|
|
@@ -114,6 +196,7 @@ attachments) {
|
|
|
114
196
|
// `done` carries the TERMINAL reply only, so it replaces the
|
|
115
197
|
// in-flight segment — never the settled ones.
|
|
116
198
|
const finalText = event.message?.content ?? acc;
|
|
199
|
+
interruptUnresolvedApps("The turn ended before this view received a result.");
|
|
117
200
|
yield {
|
|
118
201
|
content: partsWith(finalText),
|
|
119
202
|
status: { type: "complete", reason: "stop" },
|
|
@@ -123,8 +206,9 @@ attachments) {
|
|
|
123
206
|
return;
|
|
124
207
|
}
|
|
125
208
|
if (event.type === "error") {
|
|
209
|
+
interruptUnresolvedApps("The agent failed before this view received a result.");
|
|
126
210
|
yield {
|
|
127
|
-
content: [{ type: "text", text: event.message }],
|
|
211
|
+
content: [...settled.filter((p) => p.type === "tool-call"), { type: "text", text: event.message }],
|
|
128
212
|
status: { type: "incomplete", reason: "error" },
|
|
129
213
|
};
|
|
130
214
|
callbacks.onError?.(new Error(event.message));
|
|
@@ -167,10 +251,11 @@ attachments) {
|
|
|
167
251
|
//
|
|
168
252
|
// Anything already streamed is kept — partial text the user watched
|
|
169
253
|
// arrive is real — and the status marks the turn incomplete.
|
|
170
|
-
const
|
|
254
|
+
const hadAnything = settled.some((p) => p.type === "text") || acc.length > 0;
|
|
171
255
|
const truncatedNotice = "The connection to the agent ended unexpectedly. Please try again.";
|
|
256
|
+
interruptUnresolvedApps("The stream was interrupted before this view received a result.");
|
|
172
257
|
yield {
|
|
173
|
-
content: partsWith(
|
|
258
|
+
content: partsWith(hadAnything ? acc : truncatedNotice),
|
|
174
259
|
status: { type: "incomplete", reason: "error" },
|
|
175
260
|
};
|
|
176
261
|
callbacks.onError?.(new Error("Stream ended without a terminal event"));
|
|
@@ -203,6 +288,20 @@ function latestUserAttachmentIds(messages) {
|
|
|
203
288
|
}
|
|
204
289
|
return [];
|
|
205
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* The app session on the latest user turn, when a rendered view sent it.
|
|
293
|
+
* Stamped by `McpAppToolPart` on `metadata.custom`; absent for typed turns.
|
|
294
|
+
*/
|
|
295
|
+
function latestUserAppSession(messages) {
|
|
296
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
297
|
+
const m = messages[i];
|
|
298
|
+
if (m.role !== "user")
|
|
299
|
+
continue;
|
|
300
|
+
const v = m.metadata?.custom?.[APP_SESSION_METADATA_KEY];
|
|
301
|
+
return typeof v === "string" && v ? v : undefined;
|
|
302
|
+
}
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
206
305
|
/**
|
|
207
306
|
* Pull the latest user-turn text out of assistant-ui's structured
|
|
208
307
|
* message array. Text parts are concatenated with newlines; other
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CuratorAdapter.js","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"CuratorAdapter.js","sourceRoot":"","sources":["../../src/CuratorAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAYH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAyDrE,MAAM,UAAU,oBAAoB,CAClC,IAAU,EACV,YAAqC,EAAE;AACvC;;;;GAIG;AACH,WAA8D,EAC9D,UAAiC,EAAE;IAEnC,sEAAsE;IACtE,4EAA4E;IAC5E,gBAAgB;IAChB,MAAM,kBAAkB,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,KAAK,KAAK,EAAE,CAAA;IACxE,OAAO;QACL,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE;YAClC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAChD,MAAM,KAAK,GAAG,WAAW;gBACvB,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;gBAC/D,CAAC,CAAC,EAAE,CAAA;YACN,2EAA2E;YAC3E,yEAAyE;YACzE,uEAAuE;YACvE,yEAAyE;YACzE,MAAM,UAAU,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;YACjD,yEAAyE;YACzE,sEAAsE;YACtE,uEAAuE;YACvE,kCAAkC;YAClC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAM;YAE3C,yEAAyE;YACzE,qEAAqE;YACrE,0EAA0E;YAC1E,mDAAmD;YACnD,EAAE;YACF,qEAAqE;YACrE,wEAAwE;YACxE,uEAAuE;YACvE,oEAAoE;YACpE,yEAAyE;YACzE,sEAAsE;YACtE,gEAAgE;YAChE,MAAM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