@tylertech/forge-ai 0.15.2 → 0.15.3-dev.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/custom-elements.json +4501 -1781
- package/dist/ai-artifact-card/ai-artifact-card.d.ts +75 -0
- package/dist/ai-artifact-card/ai-artifact-card.mjs +142 -0
- package/dist/ai-artifact-card/ai-artifact-card.scss.mjs +283 -0
- package/dist/ai-artifact-card/index.d.ts +1 -0
- package/dist/ai-artifact-card/index.mjs +5 -0
- package/dist/ai-artifact-card-group/ai-artifact-card-group.d.ts +57 -0
- package/dist/ai-artifact-card-group/ai-artifact-card-group.mjs +137 -0
- package/dist/ai-artifact-card-group/ai-artifact-card-group.scss.mjs +173 -0
- package/dist/ai-artifact-card-group/index.d.ts +1 -0
- package/dist/ai-artifact-card-group/index.mjs +5 -0
- package/dist/ai-assistant-response/ai-assistant-response.d.ts +2 -2
- package/dist/ai-assistant-response/ai-assistant-response.mjs +26 -2
- package/dist/ai-canvas/ai-canvas.d.ts +43 -0
- package/dist/ai-canvas/ai-canvas.mjs +95 -0
- package/dist/ai-canvas/ai-canvas.scss.mjs +4 -0
- package/dist/ai-canvas/index.d.ts +1 -0
- package/dist/ai-canvas/index.mjs +5 -0
- package/dist/ai-chatbot/ag-ui-adapter.d.ts +2 -2
- package/dist/ai-chatbot/ag-ui-adapter.mjs +1 -1
- package/dist/ai-chatbot/agent-adapter.d.ts +111 -4
- package/dist/ai-chatbot/agent-adapter.mjs +22 -0
- package/dist/ai-chatbot/agent-runner.d.ts +2 -2
- package/dist/ai-chatbot/ai-chatbot-base.d.ts +29 -2
- package/dist/ai-chatbot/ai-chatbot-base.mjs +147 -3
- package/dist/ai-chatbot/ai-chatbot-tool-call.d.ts +2 -2
- package/dist/ai-chatbot/ai-chatbot-tool-call.mjs +88 -10
- package/dist/ai-chatbot/ai-chatbot.d.ts +24 -1
- package/dist/ai-chatbot/ai-chatbot.mjs +102 -2
- package/dist/ai-chatbot/ai-chatbot.scss.mjs +1 -1
- package/dist/ai-chatbot/create-tool-renderer.d.ts +5 -5
- package/dist/ai-chatbot/index.d.ts +3 -2
- package/dist/ai-chatbot/index.mjs +3 -0
- package/dist/ai-chatbot/message-state-controller.d.ts +10 -1
- package/dist/ai-chatbot/message-state-controller.mjs +78 -20
- package/dist/ai-chatbot/tool-canvas.d.ts +60 -0
- package/dist/ai-chatbot/tool-canvas.mjs +128 -0
- package/dist/ai-chatbot/types.d.ts +325 -15
- package/dist/ai-chatbot/utils.d.ts +8 -3
- package/dist/ai-chatbot/utils.mjs +7 -1
- package/dist/ai-chatbot-launcher/ai-chatbot-launcher.d.ts +40 -2
- package/dist/ai-chatbot-launcher/ai-chatbot-launcher.mjs +224 -7
- package/dist/ai-chatbot-launcher/ai-chatbot-launcher.scss.mjs +1 -1
- package/dist/ai-embedded-chat/ai-embedded-chat.mjs +1 -0
- package/dist/ai-message-thread/ai-message-thread.d.ts +3 -2
- package/dist/ai-message-thread/ai-message-thread.mjs +36 -3
- package/dist/ai-steps/ai-steps.d.ts +67 -0
- package/dist/ai-steps/ai-steps.mjs +163 -0
- package/dist/ai-steps/ai-steps.scss.mjs +4 -0
- package/dist/ai-steps/index.d.ts +1 -0
- package/dist/ai-steps/index.mjs +5 -0
- package/dist/ai-tool-call-indicator/ai-tool-call-indicator.d.ts +2 -2
- package/dist/ai-tool-call-indicator/ai-tool-call-indicator.mjs +1 -1
- package/dist/core/canvas-controller.d.ts +81 -0
- package/dist/core/canvas-controller.mjs +221 -0
- package/dist/core/chatbot-core-controller.d.ts +4 -2
- package/dist/core/chatbot-core-controller.mjs +121 -4
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.mjs +2 -0
- package/dist/core/resize-controller.d.ts +5 -0
- package/dist/core/resize-controller.mjs +7 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +15 -0
- package/dist/tools/ai-data-table/ai-data-table-definition.mjs +1 -0
- package/dist/tools/ai-mcp-app/ai-mcp-app.d.ts +70 -0
- package/dist/tools/ai-mcp-app/ai-mcp-app.mjs +589 -0
- package/dist/tools/ai-mcp-app/ai-mcp-app.scss.mjs +4 -0
- package/dist/tools/ai-mcp-app/index.d.ts +3 -0
- package/dist/tools/ai-mcp-app/index.mjs +6 -0
- package/dist/tools/ai-mcp-app/mcp-app-bridge-controller.d.ts +60 -0
- package/dist/tools/ai-mcp-app/mcp-app-bridge-controller.mjs +147 -0
- package/dist/tools/ai-mcp-app/mcp-app-bridge-types.d.ts +124 -0
- package/dist/tools/ai-mcp-app/mcp-app-bridge.d.ts +41 -0
- package/dist/tools/ai-mcp-app/mcp-app-bridge.mjs +293 -0
- package/dist/tools/ai-mcp-app/mcp-app-context.d.ts +46 -0
- package/dist/tools/ai-mcp-app/mcp-app-context.mjs +5 -0
- package/dist/tools/ai-steps/ai-steps-definition.d.ts +2 -0
- package/dist/tools/ai-steps/ai-steps-definition.mjs +51 -0
- package/dist/tools/ai-steps/ai-steps.d.ts +28 -0
- package/dist/tools/ai-steps/ai-steps.mjs +49 -0
- package/dist/tools/ai-steps/ai-steps.scss.mjs +4 -0
- package/dist/tools/ai-steps/index.d.ts +2 -0
- package/dist/tools/ai-steps/index.mjs +6 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.mjs +5 -1
- package/dist/utils/inert-outside.d.ts +7 -0
- package/dist/utils/inert-outside.mjs +28 -0
- package/package.json +4 -1
|
@@ -19,16 +19,107 @@ export interface ForgeAiSlashCommandMenuSelectEventData {
|
|
|
19
19
|
command: SlashCommand;
|
|
20
20
|
index: number;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Function of a tool call whose parameter stays bivariant, so a `ToolDefinition<MyArgs>` can be stored in a
|
|
24
|
+
* `ToolDefinition[]` alongside untyped tools without casts.
|
|
25
|
+
*/
|
|
26
|
+
export type ToolCallMapper<TReturn, TArgs = Record<string, unknown>, TResult = unknown> = {
|
|
27
|
+
bivarianceHack(toolCall: ToolCall<TArgs, TResult>): TReturn;
|
|
28
|
+
}['bivarianceHack'];
|
|
29
|
+
/** A static value, or one derived from the tool call. */
|
|
30
|
+
export type ToolCallValue<TValue, TArgs = Record<string, unknown>, TResult = unknown> = TValue | ToolCallMapper<TValue, TArgs, TResult>;
|
|
31
|
+
/** Host-provided context passed to a tool renderer's `render` function. */
|
|
32
|
+
export interface ToolRenderContext {
|
|
33
|
+
presentation: ToolPresentation;
|
|
34
|
+
/** Controls captured when `render` runs; element renderers receive a reactive `canvas` property instead. */
|
|
35
|
+
canvas: ToolCanvas;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Bivariant like `ToolCallMapper`. `context` is optional so existing `render(toolCall)` implementations and
|
|
39
|
+
* callers keep compiling; hosts always pass it.
|
|
40
|
+
*/
|
|
41
|
+
export type ToolRenderFunction<TArgs = Record<string, unknown>, TResult = unknown> = {
|
|
42
|
+
bivarianceHack(toolCall: ToolCall<TArgs, TResult>, context?: ToolRenderContext): HTMLElement | DocumentFragment;
|
|
43
|
+
}['bivarianceHack'];
|
|
44
|
+
export interface ToolRenderer<TArgs = any, TResult = any> {
|
|
23
45
|
elementTag?: string;
|
|
24
|
-
render?:
|
|
46
|
+
render?: ToolRenderFunction<TArgs, TResult>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Where a tool renderer instance is displayed. Set by the host on the elements it creates.
|
|
50
|
+
* - `inline`: in the message thread with no canvas available
|
|
51
|
+
* - `inline-expandable`: in the message thread; a canvas is available and the renderer may request it
|
|
52
|
+
* - `canvas`: inside the canvas panel
|
|
53
|
+
*/
|
|
54
|
+
export type ToolPresentation = 'inline' | 'inline-expandable' | 'canvas';
|
|
55
|
+
/** Artifact card icon: an `<svg>` element, or SVG markup reduced to static shape elements and attributes. */
|
|
56
|
+
export type ToolCanvasIcon = SVGElement | string;
|
|
57
|
+
/** Artifact card labels for each state; shown as the tooltip and read by assistive technology. */
|
|
58
|
+
export interface ToolCanvasActionLabel {
|
|
59
|
+
/** Label while the artifact is not in the canvas, e.g. "Open report". */
|
|
60
|
+
open: string;
|
|
61
|
+
/** Label while the artifact is in the canvas, e.g. "Collapse report". */
|
|
62
|
+
collapse: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Opts a tool into the canvas panel of hosts that provide one (e.g. `forge-ai-chatbot-launcher`).
|
|
66
|
+
* Hosts without a canvas ignore this and render the tool inline as usual. Every mapper receives the
|
|
67
|
+
* `ToolCall`, so values can come from the agent's `args` or the handler's `result`.
|
|
68
|
+
*/
|
|
69
|
+
export interface ToolCanvasConfig<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
70
|
+
/**
|
|
71
|
+
* When the canvas opens. `auto`: as soon as the tool call renders (launcher only; other hosts treat it as
|
|
72
|
+
* `on-request`). `on-request` (default): only when the renderer or artifact card asks for it.
|
|
73
|
+
*/
|
|
74
|
+
open?: 'auto' | 'on-request';
|
|
75
|
+
/**
|
|
76
|
+
* What the thread shows for the tool call. `renderer`: the inline renderer. `card`: an artifact card that
|
|
77
|
+
* opens the canvas. `card-while-open`: the renderer, swapped for the card while this call is in the canvas.
|
|
78
|
+
* Defaults to `card` when `open` is `auto`, otherwise `renderer`.
|
|
79
|
+
*/
|
|
80
|
+
inline?: ToolCanvasInline;
|
|
81
|
+
/** Renderer used inside the canvas. Defaults to the tool's `renderer`. */
|
|
82
|
+
renderer?: ToolRenderer<TArgs, TResult>;
|
|
83
|
+
/** Canvas and artifact card title. Defaults to `displayName`, then `name`. */
|
|
84
|
+
title?: ToolCallValue<string, TArgs, TResult>;
|
|
85
|
+
/** Artifact card subtitle, e.g. a row count. */
|
|
86
|
+
subtitle?: ToolCallValue<string, TArgs, TResult>;
|
|
87
|
+
/** Artifact card icon. Defaults to a generic artifact glyph. */
|
|
88
|
+
icon?: ToolCallValue<ToolCanvasIcon, TArgs, TResult>;
|
|
89
|
+
/** Artifact card action labels. Defaults to "Open in canvas" / "Collapse canvas". */
|
|
90
|
+
actionLabel?: ToolCallValue<ToolCanvasActionLabel, TArgs, TResult>;
|
|
91
|
+
}
|
|
92
|
+
export type ToolCanvasInline = 'renderer' | 'card' | 'card-while-open';
|
|
93
|
+
/**
|
|
94
|
+
* Canvas controls the host injects into a tool renderer as `canvas`. A new object is assigned whenever
|
|
95
|
+
* `available` or `isOpen` changes, so declaring `canvas` as a reactive property re-renders the renderer.
|
|
96
|
+
* Hosts without a canvas inject one with `available: false` whose methods return `false`.
|
|
97
|
+
*/
|
|
98
|
+
export interface ToolCanvas {
|
|
99
|
+
/** Whether the host can show this tool call in a canvas. */
|
|
100
|
+
readonly available: boolean;
|
|
101
|
+
/** Whether this tool call is the one currently shown in the canvas. */
|
|
102
|
+
readonly isOpen: boolean;
|
|
103
|
+
/** Shows this tool call in the canvas. Returns false when unavailable or the host declined. */
|
|
104
|
+
open(options?: {
|
|
105
|
+
title?: string;
|
|
106
|
+
}): boolean;
|
|
107
|
+
/** Closes the canvas if it is showing this tool call. Returns false when it was not or the host declined. */
|
|
108
|
+
close(): boolean;
|
|
109
|
+
/** Closes the canvas when this tool call is open, otherwise opens it. */
|
|
110
|
+
toggle(): boolean;
|
|
25
111
|
}
|
|
26
112
|
/**
|
|
27
113
|
* Interface that tool renderer components should implement for type-safe tool call handling.
|
|
28
114
|
* @template TArgs - Type of the tool call arguments
|
|
115
|
+
* @template TResult - Type returned by the tool's handler
|
|
29
116
|
*/
|
|
30
|
-
export interface IToolRenderer<TArgs = Record<string, unknown
|
|
31
|
-
toolCall: ToolCall<TArgs>;
|
|
117
|
+
export interface IToolRenderer<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
118
|
+
toolCall: ToolCall<TArgs, TResult>;
|
|
119
|
+
/** Assigned by the host to tell the renderer where it is displayed. */
|
|
120
|
+
presentation?: ToolPresentation;
|
|
121
|
+
/** Assigned by the host to let the renderer open and close the canvas. */
|
|
122
|
+
canvas?: ToolCanvas;
|
|
32
123
|
}
|
|
33
124
|
/**
|
|
34
125
|
* Context provided to tool handlers when they are invoked.
|
|
@@ -73,9 +164,10 @@ export interface ToolEndContext<TArgs = Record<string, unknown>> {
|
|
|
73
164
|
export type ToolType = 'client' | 'agent';
|
|
74
165
|
/**
|
|
75
166
|
* Tool definition with optional type-safe handler.
|
|
76
|
-
* @template TArgs - Type of the tool call arguments
|
|
167
|
+
* @template TArgs - Type of the tool call arguments, typed through the handler, renderer, and canvas mappers
|
|
168
|
+
* @template TResult - Type returned by `handler`, available as `toolCall.result`
|
|
77
169
|
*/
|
|
78
|
-
export interface ToolDefinition<
|
|
170
|
+
export interface ToolDefinition<TArgs = Record<string, unknown>, TResult = string | Record<string, unknown>> {
|
|
79
171
|
name: string;
|
|
80
172
|
displayName?: string;
|
|
81
173
|
description?: string;
|
|
@@ -84,22 +176,214 @@ export interface ToolDefinition<THandlerArgs = Record<string, unknown>> {
|
|
|
84
176
|
properties?: Record<string, unknown>;
|
|
85
177
|
required?: string[];
|
|
86
178
|
};
|
|
87
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Optional renderer for displaying tool call results within the chat UI. Deliberately untyped (`any`
|
|
181
|
+
* arguments) so renderers written before `ToolDefinition` had a `TResult`, including `render` callbacks
|
|
182
|
+
* annotated with plain `ToolCall`, keep compiling on any `ToolDefinition<TArgs>`.
|
|
183
|
+
*/
|
|
88
184
|
renderer?: ToolRenderer;
|
|
89
185
|
/** If true, renderer shows immediately on tool call start (default: false). */
|
|
90
186
|
renderOnStart?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Opt-in marker declaring this tool is backed by an MCP-app UI resource. Presence
|
|
189
|
+
* signals the core controller to resolve + stamp a {@link McpAppUiResource} when the
|
|
190
|
+
* tool is called. `resourceUri` is informational; the resolved URI arrives on the
|
|
191
|
+
* `mcp-ui-resource` event.
|
|
192
|
+
*/
|
|
193
|
+
mcpApp?: {
|
|
194
|
+
resourceUri?: string;
|
|
195
|
+
};
|
|
196
|
+
/** Canvas behavior for hosts that provide a canvas panel. Requires `renderer`. */
|
|
197
|
+
canvas?: ToolCanvasConfig<TArgs, TResult>;
|
|
91
198
|
/** Called when tool call starts (before args stream). */
|
|
92
|
-
onStart
|
|
199
|
+
onStart?(context: ToolStartContext): void;
|
|
93
200
|
/** Called during streaming with partial args. */
|
|
94
|
-
onDelta
|
|
201
|
+
onDelta?(context: ToolDeltaContext<TArgs>): void;
|
|
95
202
|
/** Called when args are complete (before handler execution). */
|
|
96
|
-
onEnd
|
|
203
|
+
onEnd?(context: ToolEndContext<TArgs>): void;
|
|
97
204
|
/**
|
|
98
205
|
* Optional handler function invoked when tool is called.
|
|
99
|
-
*
|
|
206
|
+
* Strings and objects are used directly as the tool result; `void` yields a generic success message.
|
|
207
|
+
*/
|
|
208
|
+
handler?(context: HandlerContext<TArgs>): Promise<TResult | void> | TResult | void;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Content-Security-Policy domain allow-lists for an MCP-app resource, mirroring the
|
|
212
|
+
* spec's `_meta.ui.csp` shape (2026-01-26). The sandbox proxy composes these into the
|
|
213
|
+
* enforced CSP; when omitted a restrictive default block applies.
|
|
214
|
+
*
|
|
215
|
+
* Local type — intentionally NOT aliased from `@modelcontextprotocol/ext-apps` so the
|
|
216
|
+
* type layer stays bridge-agnostic.
|
|
217
|
+
*/
|
|
218
|
+
export interface McpAppResourceCsp {
|
|
219
|
+
/** Domains the widget may `connect-src` to (fetch/XHR/WebSocket). */
|
|
220
|
+
connectDomains?: string[];
|
|
221
|
+
/** Domains the widget may load passive resources from (img/media/etc.). */
|
|
222
|
+
resourceDomains?: string[];
|
|
223
|
+
/** Domains allowed in `frame-src`; absent → `frame-src 'none'`. */
|
|
224
|
+
frameDomains?: string[];
|
|
225
|
+
/** Domains allowed in `base-uri`; absent → `base-uri 'self'`. */
|
|
226
|
+
baseUriDomains?: string[];
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Iframe permission policy for an MCP-app resource, mirroring the spec's
|
|
230
|
+
* `_meta.ui.permissions` shape (2026-01-26): a key being present (with an empty object
|
|
231
|
+
* value) means the permission is requested. The sandbox maps requested keys onto the
|
|
232
|
+
* iframe `allow` attribute.
|
|
233
|
+
*
|
|
234
|
+
* Local type — not aliased from ext-apps.
|
|
235
|
+
*/
|
|
236
|
+
export interface McpAppResourcePermissions {
|
|
237
|
+
camera?: Record<string, never>;
|
|
238
|
+
microphone?: Record<string, never>;
|
|
239
|
+
geolocation?: Record<string, never>;
|
|
240
|
+
clipboardWrite?: Record<string, never>;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The resolved UI resource stamped onto a {@link ToolCall} once a `mcp-ui-resource`
|
|
244
|
+
* event arrives. Presence of this on a tool call is the single render discriminator for
|
|
245
|
+
* mounting `<forge-ai-mcp-app>`.
|
|
246
|
+
*
|
|
247
|
+
* Returned by `AgentAdapter.resolveMcpAppResource`, which fills `csp`/`permissions` from
|
|
248
|
+
* the template response's `_meta.ui` (pass `{}` when the template declares none). The
|
|
249
|
+
* widget refuses to render when either is missing.
|
|
250
|
+
*
|
|
251
|
+
* Local type — not aliased from ext-apps.
|
|
252
|
+
*/
|
|
253
|
+
export interface McpAppUiResource {
|
|
254
|
+
/** The complete standalone app HTML document, resolved server-side. */
|
|
255
|
+
html: string;
|
|
256
|
+
/** CSP domain allow-lists to enforce in the sandbox. Empty → restrictive default. */
|
|
257
|
+
csp: McpAppResourceCsp;
|
|
258
|
+
/** Iframe permission policy for the sandbox inner frame. */
|
|
259
|
+
permissions: McpAppResourcePermissions;
|
|
260
|
+
/** The concrete resolved `ui://` resource URI (never a template). */
|
|
261
|
+
resourceUri?: string;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the widget prefers the host to draw a border/background around it.
|
|
264
|
+
* `true` → visible chrome, `false` → none, omitted → renderer default.
|
|
100
265
|
*/
|
|
101
|
-
|
|
266
|
+
prefersBorder?: boolean;
|
|
102
267
|
}
|
|
268
|
+
/** Resolve state of an announced MCP-app UI resource that has not been stamped yet. */
|
|
269
|
+
export type McpAppUiResourceStatus = 'loading' | 'error';
|
|
270
|
+
/** Display modes an MCP-app widget can be presented in (spec 2026-01-26). */
|
|
271
|
+
export type McpAppDisplayMode = 'inline' | 'fullscreen' | 'pip';
|
|
272
|
+
/**
|
|
273
|
+
* The raw MCP `CallToolResult` (minus `structuredContent`) for an MCP-app tool call. The
|
|
274
|
+
* View's `ui/notifications/tool-result` is built from this plus
|
|
275
|
+
* {@link ToolCall.structuredContent} — never from the model-facing `result`.
|
|
276
|
+
*/
|
|
277
|
+
export interface McpToolResult {
|
|
278
|
+
content: unknown[];
|
|
279
|
+
isError?: boolean;
|
|
280
|
+
_meta?: Record<string, unknown>;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Size of the container holding a widget, in CSS pixels (spec `containerDimensions`): a
|
|
284
|
+
* fixed `height` or a `maxHeight` bound, and a fixed `width` or a `maxWidth` bound.
|
|
285
|
+
*/
|
|
286
|
+
export type McpAppContainerDimensions = ({
|
|
287
|
+
height: number;
|
|
288
|
+
} | {
|
|
289
|
+
maxHeight?: number;
|
|
290
|
+
}) & ({
|
|
291
|
+
width: number;
|
|
292
|
+
} | {
|
|
293
|
+
maxWidth?: number;
|
|
294
|
+
});
|
|
295
|
+
/** The tool call that instantiated a widget (spec `toolInfo`). */
|
|
296
|
+
export interface McpAppToolInfo {
|
|
297
|
+
id?: string | number;
|
|
298
|
+
tool: {
|
|
299
|
+
name: string;
|
|
300
|
+
inputSchema: {
|
|
301
|
+
type: 'object';
|
|
302
|
+
[key: string]: unknown;
|
|
303
|
+
};
|
|
304
|
+
[key: string]: unknown;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Theming sent to MCP-app widgets (spec `hostContext.styles`): spec CSS variables (e.g.
|
|
309
|
+
* `--color-background-primary`) resolved from Forge tokens. Font loading (`css.fonts`) is not sent.
|
|
310
|
+
*/
|
|
311
|
+
export interface McpAppHostStyles {
|
|
312
|
+
variables?: Record<string, string>;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Host context projected into an MCP-app widget.
|
|
316
|
+
*
|
|
317
|
+
* Local type — not aliased from ext-apps.
|
|
318
|
+
*/
|
|
319
|
+
export interface McpAppHostContext {
|
|
320
|
+
theme: 'light' | 'dark';
|
|
321
|
+
/** Spec CSS variables resolved from the widget's Forge tokens. */
|
|
322
|
+
styles?: McpAppHostStyles;
|
|
323
|
+
/** The tool call that instantiated the widget. */
|
|
324
|
+
toolInfo?: McpAppToolInfo;
|
|
325
|
+
/** Size of the container holding the widget. */
|
|
326
|
+
containerDimensions?: McpAppContainerDimensions;
|
|
327
|
+
/** The widget's current display mode. */
|
|
328
|
+
displayMode?: McpAppDisplayMode;
|
|
329
|
+
/** Display modes the host is able to present. */
|
|
330
|
+
availableDisplayModes?: McpAppDisplayMode[];
|
|
331
|
+
/** BCP 47 language tag. */
|
|
332
|
+
locale?: string;
|
|
333
|
+
/** IANA time zone. */
|
|
334
|
+
timeZone?: string;
|
|
335
|
+
userAgent?: string;
|
|
336
|
+
platform?: 'web' | 'desktop' | 'mobile';
|
|
337
|
+
deviceCapabilities?: {
|
|
338
|
+
touch?: boolean;
|
|
339
|
+
hover?: boolean;
|
|
340
|
+
};
|
|
341
|
+
safeAreaInsets?: {
|
|
342
|
+
top: number;
|
|
343
|
+
right: number;
|
|
344
|
+
bottom: number;
|
|
345
|
+
left: number;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/** Content-block types a host accepts for `ui/message` / `ui/update-model-context`. */
|
|
349
|
+
export interface McpAppContentModalities {
|
|
350
|
+
text?: Record<string, never>;
|
|
351
|
+
image?: Record<string, never>;
|
|
352
|
+
audio?: Record<string, never>;
|
|
353
|
+
resource?: Record<string, never>;
|
|
354
|
+
resourceLink?: Record<string, never>;
|
|
355
|
+
structuredContent?: Record<string, never>;
|
|
356
|
+
}
|
|
357
|
+
/** The sandbox policy the host enforces for a widget, echoed in its host capabilities. */
|
|
358
|
+
export interface McpAppSandboxCapabilities {
|
|
359
|
+
csp?: McpAppResourceCsp;
|
|
360
|
+
permissions?: McpAppResourcePermissions;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Host capability advertisement returned to the widget in `McpUiInitializeResult`.
|
|
364
|
+
* Spec-compliant widgets gate `ui/open-link` / `tools/call` / `resources/read` on these,
|
|
365
|
+
* so they must be declared, not left implicit.
|
|
366
|
+
*
|
|
367
|
+
* Local type — not aliased from ext-apps.
|
|
368
|
+
*/
|
|
369
|
+
export interface McpAppHostCapabilities {
|
|
370
|
+
openLinks?: Record<string, never>;
|
|
371
|
+
serverTools?: {
|
|
372
|
+
listChanged?: boolean;
|
|
373
|
+
};
|
|
374
|
+
serverResources?: {
|
|
375
|
+
listChanged?: boolean;
|
|
376
|
+
};
|
|
377
|
+
logging?: Record<string, never>;
|
|
378
|
+
message?: McpAppContentModalities;
|
|
379
|
+
updateModelContext?: McpAppContentModalities;
|
|
380
|
+
sandbox?: McpAppSandboxCapabilities;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Type-erased tool definition for collections that mix tools with different argument types, e.g. the
|
|
384
|
+
* `tools` passed to an adapter. Any `ToolDefinition<TArgs, TResult>` is assignable to it.
|
|
385
|
+
*/
|
|
386
|
+
export type AnyToolDefinition = ToolDefinition<object, any>;
|
|
103
387
|
export interface ChatMessage {
|
|
104
388
|
id: string;
|
|
105
389
|
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
@@ -137,18 +421,44 @@ export interface ClientMessageInput {
|
|
|
137
421
|
header?: string;
|
|
138
422
|
actions?: ClientMessageAction[];
|
|
139
423
|
}
|
|
140
|
-
export interface ToolCall<TArgs = Record<string, unknown
|
|
424
|
+
export interface ToolCall<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
141
425
|
id: string;
|
|
142
426
|
messageId: string;
|
|
143
427
|
name: string;
|
|
144
428
|
args: TArgs;
|
|
145
429
|
argsBuffer?: string;
|
|
146
|
-
|
|
147
|
-
|
|
430
|
+
/** Handler return value once the call completes; an `{ error }` object if the handler threw. */
|
|
431
|
+
result?: TResult;
|
|
432
|
+
status: ToolCallStatus;
|
|
148
433
|
type: ToolType;
|
|
149
434
|
startTimestamp?: number;
|
|
150
435
|
endTimestamp?: number;
|
|
436
|
+
/**
|
|
437
|
+
* The resolved MCP-app UI resource. When present, this tool call renders as a
|
|
438
|
+
* sandboxed `<forge-ai-mcp-app>` widget instead of the standard tool-call UI.
|
|
439
|
+
*/
|
|
440
|
+
uiResource?: McpAppUiResource;
|
|
441
|
+
/**
|
|
442
|
+
* Set while an announced MCP-app UI resource has not resolved: `loading` while it is
|
|
443
|
+
* being fetched, `error` when the fetch failed. The tool call renders as a
|
|
444
|
+
* `<forge-ai-mcp-app>` placeholder (or error) in its final position meanwhile.
|
|
445
|
+
* Cleared once `uiResource` is stamped, or when the adapter resolves no resource.
|
|
446
|
+
*/
|
|
447
|
+
uiResourceStatus?: McpAppUiResourceStatus;
|
|
448
|
+
/** Companion structured payload for the widget, stripped from LLM context. */
|
|
449
|
+
structuredContent?: unknown;
|
|
450
|
+
/** `true` when `structuredContent` was dropped by the backend (size caps). */
|
|
451
|
+
structuredContentOmitted?: boolean;
|
|
452
|
+
/** Raw MCP result for an MCP-app tool call; the source of the View's `tool-result`. */
|
|
453
|
+
mcpResult?: McpToolResult;
|
|
454
|
+
/** `true` when `mcpResult` was dropped by the backend (size caps). */
|
|
455
|
+
mcpResultOmitted?: boolean;
|
|
151
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Tool call lifecycle. `cancelled` means the call ended without a result (run aborted,
|
|
459
|
+
* stream ended/errored, or the adapter reported `cancelled: true`).
|
|
460
|
+
*/
|
|
461
|
+
export type ToolCallStatus = 'pending' | 'parsing' | 'executing' | 'complete' | 'error' | 'cancelled';
|
|
152
462
|
export type ResponseItem = {
|
|
153
463
|
type: 'text';
|
|
154
464
|
messageId: string;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { ChatMessage, ContextItem, FileAttachment, ToolCall,
|
|
1
|
+
import { ChatMessage, ContextItem, FileAttachment, ToolCall, AnyToolDefinition } from './types.js';
|
|
2
2
|
export { renderMarkdown, renderInlineMarkdown, type RenderMarkdownOptions } from '../utils/markdown.js';
|
|
3
3
|
/**
|
|
4
4
|
* Whether a tool call's renderer should currently be shown: once the call is complete,
|
|
5
5
|
* or immediately (while still parsing/executing) if the tool opted into `renderOnStart`.
|
|
6
6
|
*/
|
|
7
|
-
export declare function shouldShowToolRenderer(toolCall: ToolCall, toolDefinition?:
|
|
7
|
+
export declare function shouldShowToolRenderer(toolCall: ToolCall, toolDefinition?: AnyToolDefinition): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Whether a tool call should be treated as settled for activity indicators (thinking
|
|
10
10
|
* indicator, tool-call summary spinner): either genuinely finished, or already showing
|
|
11
11
|
* its own renderer to the user, which makes a redundant "running" spinner misleading.
|
|
12
12
|
*/
|
|
13
|
-
export declare function isToolCallSettled(toolCall: ToolCall, toolDefinition?:
|
|
13
|
+
export declare function isToolCallSettled(toolCall: ToolCall, toolDefinition?: AnyToolDefinition): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a tool call renders as a `<forge-ai-mcp-app>` widget: its UI resource is resolved,
|
|
16
|
+
* or announced and still loading (or failed to load).
|
|
17
|
+
*/
|
|
18
|
+
export declare function rendersAsMcpAppWidget(toolCall: ToolCall): boolean;
|
|
14
19
|
/**
|
|
15
20
|
* Generates a unique ID using UUID v4
|
|
16
21
|
*/
|
|
@@ -10,7 +10,10 @@ function shouldShowToolRenderer(toolCall, toolDefinition) {
|
|
|
10
10
|
return !!toolDefinition.renderOnStart && (toolCall.status === "parsing" || toolCall.status === "executing");
|
|
11
11
|
}
|
|
12
12
|
function isToolCallSettled(toolCall, toolDefinition) {
|
|
13
|
-
return toolCall.status === "complete" || toolCall.status === "error" || shouldShowToolRenderer(toolCall, toolDefinition);
|
|
13
|
+
return toolCall.status === "complete" || toolCall.status === "error" || toolCall.status === "cancelled" || shouldShowToolRenderer(toolCall, toolDefinition);
|
|
14
|
+
}
|
|
15
|
+
function rendersAsMcpAppWidget(toolCall) {
|
|
16
|
+
return !!toolCall.uiResource || !!toolCall.uiResourceStatus;
|
|
14
17
|
}
|
|
15
18
|
function generateId() {
|
|
16
19
|
return v4();
|
|
@@ -49,6 +52,8 @@ function formatToolCallForExport(toolCall) {
|
|
|
49
52
|
if (toolCall.status === "error") {
|
|
50
53
|
const errorMsg = typeof toolCall.result === "object" && toolCall.result !== null && "error" in toolCall.result ? toolCall.result.error : "Unknown error";
|
|
51
54
|
lines.push(` Error: ${errorMsg}`);
|
|
55
|
+
} else if (toolCall.status === "cancelled") {
|
|
56
|
+
lines.push(" Cancelled");
|
|
52
57
|
} else if (toolCall.result !== void 0) {
|
|
53
58
|
lines.push(` Result: ${JSON.stringify(toolCall.result)}`);
|
|
54
59
|
}
|
|
@@ -104,5 +109,6 @@ export {
|
|
|
104
109
|
isToolCallSettled,
|
|
105
110
|
renderInlineMarkdown,
|
|
106
111
|
renderMarkdown,
|
|
112
|
+
rendersAsMcpAppWidget,
|
|
107
113
|
shouldShowToolRenderer
|
|
108
114
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { TemplateResult, CSSResult } from 'lit';
|
|
1
|
+
import { PropertyValues, TemplateResult, CSSResult } from 'lit';
|
|
2
2
|
import { AiMessageThreadComponent } from '../ai-message-thread';
|
|
3
3
|
import { AiPromptComponent, ForgeAiPromptSendEventData } from '../ai-prompt';
|
|
4
4
|
import { ForgeAiSuggestionsEventData } from '../ai-suggestions';
|
|
5
|
-
import { AiChatbotBase } from '../ai-chatbot/ai-chatbot-base.js';
|
|
5
|
+
import { AiChatbotBase, FeatureToggle } from '../ai-chatbot/ai-chatbot-base.js';
|
|
6
6
|
import { ChatMessage, ThreadState } from '../ai-chatbot/types.js';
|
|
7
|
+
import { CanvasOpenEventData, OpenCanvasOptions } from '../core/canvas-controller.js';
|
|
7
8
|
import { Thread } from '../ai-threads/ai-threads';
|
|
8
9
|
import { Ref } from 'lit/directives/ref.js';
|
|
9
10
|
export type LauncherViewState = 'welcome' | 'conversation' | 'history';
|
|
@@ -32,6 +33,12 @@ export interface ForgeAiChatbotLauncherThreadLoadMoreEventData {
|
|
|
32
33
|
query: string;
|
|
33
34
|
appendResults: (results: Thread[]) => void;
|
|
34
35
|
}
|
|
36
|
+
export type { OpenCanvasOptions };
|
|
37
|
+
export type ForgeAiChatbotLauncherCanvasOpenEventData = CanvasOpenEventData;
|
|
38
|
+
export interface ForgeAiChatbotLauncherCanvasResizeEventData {
|
|
39
|
+
/** Width of the conversation column in pixels; the canvas takes the remaining width. */
|
|
40
|
+
chatWidth: number;
|
|
41
|
+
}
|
|
35
42
|
declare global {
|
|
36
43
|
interface HTMLElementTagNameMap {
|
|
37
44
|
'forge-ai-chatbot-launcher': AiChatbotLauncherComponent;
|
|
@@ -47,6 +54,9 @@ declare global {
|
|
|
47
54
|
'forge-ai-chatbot-launcher-thread-load-more': CustomEvent<ForgeAiChatbotLauncherThreadLoadMoreEventData>;
|
|
48
55
|
'forge-ai-chatbot-launcher-new-chat': CustomEvent<void>;
|
|
49
56
|
'forge-ai-chatbot-launcher-thread-retry': CustomEvent<void>;
|
|
57
|
+
'forge-ai-chatbot-launcher-canvas-open': CustomEvent<ForgeAiChatbotLauncherCanvasOpenEventData>;
|
|
58
|
+
'forge-ai-chatbot-launcher-canvas-close': CustomEvent<void>;
|
|
59
|
+
'forge-ai-chatbot-launcher-canvas-resize': CustomEvent<ForgeAiChatbotLauncherCanvasResizeEventData>;
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
export declare const AiChatbotLauncherComponentTagName: keyof HTMLElementTagNameMap;
|
|
@@ -60,10 +70,16 @@ export declare const AiChatbotLauncherComponentTagName: keyof HTMLElementTagName
|
|
|
60
70
|
* that animates into a full conversation interface when the user sends their first message.
|
|
61
71
|
* In conversation mode, a header is displayed with options for clear, export, and agent selection.
|
|
62
72
|
*
|
|
73
|
+
* In conversation mode an artifact canvas can open beside the thread via `openCanvas()`, a tool definition's
|
|
74
|
+
* `canvas` config, or a renderer's `forge-ai-canvas-open-request`. The conversation narrows to a sidebar-style
|
|
75
|
+
* column and the canvas takes the remaining width. The canvas closes whenever the conversation view is left.
|
|
76
|
+
*
|
|
63
77
|
* @slot icon - Slot for custom icon (used in both welcome view and conversation header)
|
|
64
78
|
* @slot heading - Slot for custom heading content (welcome view only)
|
|
65
79
|
* @slot description - Slot for custom description/welcome message below the title (welcome view only)
|
|
66
80
|
* @slot header-actions - Slot for custom header action buttons in conversation mode (rendered before built-in header actions)
|
|
81
|
+
* @slot canvas - Content shown in the canvas when `openCanvas()` is called without `content`
|
|
82
|
+
* @slot canvas-actions - Action buttons rendered in the canvas header before the close button
|
|
67
83
|
*
|
|
68
84
|
* @property {string} titleText - The title text to display in the welcome view and header (default: 'AI Assistant')
|
|
69
85
|
* @property {string} descriptionText - The description text displayed below the title in the welcome view.
|
|
@@ -81,6 +97,9 @@ export declare const AiChatbotLauncherComponentTagName: keyof HTMLElementTagName
|
|
|
81
97
|
* @property {boolean} threadsLoading - Whether chats are currently loading, used to show a spinner on the history button and disable it
|
|
82
98
|
* @property {string | undefined} threadsError - Message describing a failed chat history load. When set, the history popover/view shows the message with a retry button instead of the empty state, and the history button shows an error badge so the failure is visible with the popover closed. If chats are already loaded the list stays visible and the message renders as a compact single line with a retry - at the bottom of the list when a page was in flight, otherwise above it. Clear it once a load succeeds.
|
|
83
99
|
* @property {string | null} selectedThreadId - The id of the currently selected thread, highlighted in the history popover/view. Updated internally when a thread is selected or a new chat starts.
|
|
100
|
+
* @property {string} canvasTitle - Default title for the canvas header, used when the open request does not supply one
|
|
101
|
+
* @property {FeatureToggle} canvasResizable - Controls the drag handle between the conversation and the canvas. `'on'` (default) lets users resize with a pointer or the arrow keys; `'off'` hides it, so the conversation stays at `chatWidth`.
|
|
102
|
+
* @property {number} chatWidth - Width in pixels of the conversation column while the canvas is open (default: 420). Updated as the user resizes, clamped to at least 360px and to leave the canvas at least 320px when there is room. Resized widths are persisted per tab in sessionStorage and shared across tabs via localStorage; on load the session value is preferred, then the local value, then the default.
|
|
84
103
|
*
|
|
85
104
|
* @cssproperty --forge-ai-chatbot-launcher-icon-color - The fill color for the AI icon.
|
|
86
105
|
*
|
|
@@ -102,6 +121,9 @@ export declare const AiChatbotLauncherComponentTagName: keyof HTMLElementTagName
|
|
|
102
121
|
* @event {CustomEvent<ForgeAiChatbotLauncherThreadLoadMoreEventData>} forge-ai-chatbot-launcher-thread-load-more - Fired when scrolling near the bottom of the history list for pagination. Call appendResults() with the next page (empty array signals no more results)
|
|
103
122
|
* @event {CustomEvent<void>} forge-ai-chatbot-launcher-new-chat - Fired when "New chat" is clicked from the full history view. Cancelable - prevents startNewChat() from being called
|
|
104
123
|
* @event {CustomEvent<void>} forge-ai-chatbot-launcher-thread-retry - Fired when the retry button in the history error state is clicked. Re-request the chats and clear threadsError once the load succeeds
|
|
124
|
+
* @event {CustomEvent<ForgeAiChatbotLauncherCanvasOpenEventData>} forge-ai-chatbot-launcher-canvas-open - Fired before the canvas opens or replaces its content. Cancelable - prevents the canvas from opening
|
|
125
|
+
* @event {CustomEvent<ForgeAiChatbotLauncherCanvasResizeEventData>} forge-ai-chatbot-launcher-canvas-resize - Fired when a resize is committed via pointer release or keyboard step. Detail has the new `chatWidth`
|
|
126
|
+
* @event {CustomEvent<void>} forge-ai-chatbot-launcher-canvas-close - Fired when the canvas closes. Cancelable only for user or `closeCanvas()` initiated closes; closes caused by leaving the conversation view cannot be prevented
|
|
105
127
|
*/
|
|
106
128
|
export declare class AiChatbotLauncherComponent extends AiChatbotBase {
|
|
107
129
|
#private;
|
|
@@ -117,7 +139,11 @@ export declare class AiChatbotLauncherComponent extends AiChatbotBase {
|
|
|
117
139
|
threadsLoading: boolean;
|
|
118
140
|
threadsError?: string;
|
|
119
141
|
selectedThreadId: string | null;
|
|
142
|
+
canvasTitle?: string;
|
|
143
|
+
canvasResizable: FeatureToggle;
|
|
144
|
+
chatWidth: number;
|
|
120
145
|
private _viewState;
|
|
146
|
+
private _isResizing;
|
|
121
147
|
private _skipAnimation;
|
|
122
148
|
private _editingThreadId;
|
|
123
149
|
private _historyPopoverOpen;
|
|
@@ -125,6 +151,8 @@ export declare class AiChatbotLauncherComponent extends AiChatbotBase {
|
|
|
125
151
|
protected _promptRef: Ref<AiPromptComponent>;
|
|
126
152
|
constructor();
|
|
127
153
|
protected _onConnected(): void;
|
|
154
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
155
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
128
156
|
startConversation(): void;
|
|
129
157
|
/**
|
|
130
158
|
* Returns to the welcome view without touching conversation state. Unlike `startNewChat()`, this
|
|
@@ -147,6 +175,16 @@ export declare class AiChatbotLauncherComponent extends AiChatbotBase {
|
|
|
147
175
|
skipAnimation?: boolean;
|
|
148
176
|
}): Promise<void>;
|
|
149
177
|
get viewState(): LauncherViewState;
|
|
178
|
+
get canvasOpen(): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Opens the canvas beside the conversation, or swaps its content if already open. Only available in the
|
|
181
|
+
* conversation view; returns false elsewhere or when the open event is prevented.
|
|
182
|
+
*/
|
|
183
|
+
openCanvas(options?: OpenCanvasOptions): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Closes the canvas. Returns false if it was not open or the close event was prevented.
|
|
186
|
+
*/
|
|
187
|
+
closeCanvas(): boolean;
|
|
150
188
|
focus(): void;
|
|
151
189
|
render(): TemplateResult;
|
|
152
190
|
}
|