@happyvertical/smrt-chat 0.51.39 → 0.53.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/AGENTS.md +19 -2
- package/README.md +13 -0
- package/dist/assistant-turn-events.d.ts +152 -0
- package/dist/assistant-turn-events.d.ts.map +1 -0
- package/dist/assistant-turn-events.js +2 -0
- package/dist/assistant-turn.d.ts +236 -0
- package/dist/assistant-turn.d.ts.map +1 -0
- package/dist/chunks/{ChatService-D48KBDZy.js → ChatService-jJi2JJJi.js} +2 -2
- package/dist/chunks/ChatService-jJi2JJJi.js.map +1 -0
- package/dist/chunks/assistant-turn-events-BbZUf-Ju.js +77 -0
- package/dist/chunks/assistant-turn-events-BbZUf-Ju.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +776 -104
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-runtime.js +1 -1
- package/dist/manifest.json +6 -2
- package/dist/models/AgentSession.d.ts +11 -1
- package/dist/models/AgentSession.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +7 -13
- package/dist/svelte/components/assistant/AssistantChoiceCards.svelte +309 -0
- package/dist/svelte/components/assistant/AssistantChoiceCards.svelte.d.ts +19 -0
- package/dist/svelte/components/assistant/AssistantChoiceCards.svelte.d.ts.map +1 -0
- package/dist/svelte/components/assistant/AssistantComposer.svelte +116 -14
- package/dist/svelte/components/assistant/AssistantComposer.svelte.d.ts +28 -0
- package/dist/svelte/components/assistant/AssistantComposer.svelte.d.ts.map +1 -1
- package/dist/svelte/components/assistant/AssistantDock.svelte +196 -1
- package/dist/svelte/components/assistant/AssistantDock.svelte.d.ts +38 -1
- package/dist/svelte/components/assistant/AssistantDock.svelte.d.ts.map +1 -1
- package/dist/svelte/components/assistant/AssistantThreadList.svelte +13 -1
- package/dist/svelte/components/assistant/__tests__/AssistantDock.test.js +16 -16
- package/dist/svelte/components/assistant/__tests__/assistant-composer-dictation.test.js +197 -0
- package/dist/svelte/components/assistant/__tests__/assistant-dock-choices-pending.test.js +224 -0
- package/dist/svelte/components/assistant/__tests__/assistant-dock-choices-preview.test.js +312 -0
- package/dist/svelte/components/assistant/__tests__/assistant-dock-choices.test.js +338 -0
- package/dist/svelte/components/assistant/__tests__/assistant-dock-client-tools.test.js +442 -0
- package/dist/svelte/components/assistant/__tests__/assistant-dock-run.test.js +303 -0
- package/dist/svelte/components/assistant/__tests__/assistant-dock-settle.test.js +146 -0
- package/dist/svelte/components/assistant/assistant-choices.svelte.d.ts +251 -0
- package/dist/svelte/components/assistant/assistant-choices.svelte.d.ts.map +1 -0
- package/dist/svelte/components/assistant/assistant-choices.svelte.js +520 -0
- package/dist/svelte/components/assistant/assistant-transport.d.ts +54 -1
- package/dist/svelte/components/assistant/assistant-transport.d.ts.map +1 -1
- package/dist/svelte/components/assistant/assistant-transport.js +64 -0
- package/dist/svelte/components/assistant/client-tools.d.ts +85 -0
- package/dist/svelte/components/assistant/client-tools.d.ts.map +1 -0
- package/dist/svelte/components/assistant/client-tools.js +61 -0
- package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts +159 -0
- package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.d.ts.map +1 -1
- package/dist/svelte/components/assistant/create-assistant-dock-controller.svelte.js +0 -0
- package/dist/svelte/i18n.d.ts +15 -0
- package/dist/svelte/i18n.d.ts.map +1 -1
- package/dist/svelte/i18n.js +17 -1
- package/dist/svelte/index.d.ts +6 -2
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +8 -1
- package/dist/tool-allow-list.d.ts +8 -0
- package/dist/tool-allow-list.d.ts.map +1 -0
- package/dist/tool-loop.d.ts +191 -3
- package/dist/tool-loop.d.ts.map +1 -1
- package/package.json +19 -15
- package/dist/chunks/ChatService-D48KBDZy.js.map +0 -1
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
* rather than silently faked. See the "smrt-generated-REST-backed
|
|
29
29
|
* transport" section below for the full read wire contract.
|
|
30
30
|
*/
|
|
31
|
+
/**
|
|
32
|
+
* AssistantDock uses its own light thread/message shapes rather than the
|
|
33
|
+
* room-based `ChatThreadData`/`ChatMessageData` (`../types.js`): those UI
|
|
34
|
+
* types require room-scoped fields (e.g. `ChatThreadData.rootMessage`,
|
|
35
|
+
* `ChatMessageData.senderName`/`reactions`) that don't apply to a
|
|
36
|
+
* tenant-scoped, route-agnostic assistant thread. Field names below
|
|
37
|
+
* intentionally line up with `ChatThreadData`/`ChatMessageData` so a future
|
|
38
|
+
* adapter between the two is a narrow mapping, not a rewrite.
|
|
39
|
+
*/
|
|
40
|
+
import { readAssistantTurnStream, } from '../../../assistant-turn-events.js';
|
|
31
41
|
export function createInMemoryAssistantTransport(options = {}) {
|
|
32
42
|
const now = options.now ?? (() => Date.now());
|
|
33
43
|
let counter = 0;
|
|
@@ -302,5 +312,59 @@ export function createSmrtAssistantTransport(options) {
|
|
|
302
312
|
async uploadAttachment(file) {
|
|
303
313
|
return requireWrite('uploadAttachment')(file);
|
|
304
314
|
},
|
|
315
|
+
...(options.writeEndpoint?.resumeTurn
|
|
316
|
+
? { resumeTurn: options.writeEndpoint.resumeTurn }
|
|
317
|
+
: {}),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Read a streamed assistant turn response (#2908) into an
|
|
322
|
+
* {@link AssistantSendMessageResult}, forwarding each event (with persisted
|
|
323
|
+
* messages mapped by `mapMessage`) to `onEvent`. For a host transport whose
|
|
324
|
+
* send route answers `text/event-stream` (the server side is
|
|
325
|
+
* `runAssistantTurn` + `createAssistantTurnResponse`). Rejects on an in-band
|
|
326
|
+
* `error` or a cut stream.
|
|
327
|
+
*/
|
|
328
|
+
export async function readAssistantTurnResult(response, options) {
|
|
329
|
+
const mapped = [];
|
|
330
|
+
const outcome = await readAssistantTurnStream(response, (event) => {
|
|
331
|
+
if (!options.onEvent)
|
|
332
|
+
return;
|
|
333
|
+
if (event.type === 'message') {
|
|
334
|
+
options.onEvent({
|
|
335
|
+
type: 'message',
|
|
336
|
+
message: options.mapMessage(event.message),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else if (event.type === 'done') {
|
|
340
|
+
options.onEvent({
|
|
341
|
+
type: 'done',
|
|
342
|
+
stoppedReason: event.stoppedReason,
|
|
343
|
+
...(event.message
|
|
344
|
+
? { message: options.mapMessage(event.message) }
|
|
345
|
+
: {}),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
options.onEvent(event);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
for (const wire of outcome.messages)
|
|
353
|
+
mapped.push(options.mapMessage(wire));
|
|
354
|
+
const assistantMessage = [...mapped]
|
|
355
|
+
.reverse()
|
|
356
|
+
.find((m) => m.role === 'assistant');
|
|
357
|
+
return {
|
|
358
|
+
inProgress: false,
|
|
359
|
+
messages: mapped,
|
|
360
|
+
...(assistantMessage ? { assistantMessage } : {}),
|
|
361
|
+
...(outcome.clientToolCalls
|
|
362
|
+
? {
|
|
363
|
+
clientToolCalls: {
|
|
364
|
+
continuationId: outcome.clientToolCalls.continuationId,
|
|
365
|
+
calls: outcome.clientToolCalls.calls,
|
|
366
|
+
},
|
|
367
|
+
}
|
|
368
|
+
: {}),
|
|
305
369
|
};
|
|
306
370
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser tools for the AssistantDock (#2908).
|
|
3
|
+
*
|
|
4
|
+
* The dock offers the model the page's own WebMCP tools — the same set an
|
|
5
|
+
* outside agent sees — and runs the model's calls to them in the browser,
|
|
6
|
+
* through the same registry, as the signed-in user. The page registry is
|
|
7
|
+
* `@happyvertical/smrt-web/webmcp-page-tools`'s `WebMcpPageToolRegistry`,
|
|
8
|
+
* which satisfies {@link AssistantClientToolSource} structurally (this
|
|
9
|
+
* package keeps no runtime dependency on smrt-web).
|
|
10
|
+
*
|
|
11
|
+
* Whether a call runs at once or waits for the user is decided HERE, in the
|
|
12
|
+
* browser, from the registry's own description of the tool — never from what
|
|
13
|
+
* the server echoes back:
|
|
14
|
+
*
|
|
15
|
+
* - `read` runs;
|
|
16
|
+
* - `destructive` always waits for the user's own confirmation;
|
|
17
|
+
* - `write` runs only when the registry marks the tool `proposal: true` —
|
|
18
|
+
* smrt-web sets that solely from a module-private brand that compiled view
|
|
19
|
+
* intents and the fixed `smrt_ui_*` tools carry, because those tools only
|
|
20
|
+
* stage a value or dispatch a registry command as `source: 'agent'` (the
|
|
21
|
+
* control/surface registry keeps the change a proposal the user applies);
|
|
22
|
+
* - any other `write` waits for the user's confirmation — including one whose
|
|
23
|
+
* `owner` label says `ui` or `intent`: that label is a diagnostic any
|
|
24
|
+
* bespoke registration can set, so it never grants auto-run.
|
|
25
|
+
*
|
|
26
|
+
* A host may narrow this with `clientToolPolicy`, but can never make a
|
|
27
|
+
* destructive call run without confirmation.
|
|
28
|
+
*/
|
|
29
|
+
import type { AssistantClientToolDeclaration, AssistantToolEffect } from '../../../assistant-turn-events.js';
|
|
30
|
+
/** One live browser tool, as the page registry describes it. */
|
|
31
|
+
export interface AssistantClientTool {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
inputSchema: Record<string, unknown>;
|
|
35
|
+
effect: AssistantToolEffect;
|
|
36
|
+
/**
|
|
37
|
+
* The registration path (`generated`, `ui`, `intent`, `bespoke`), when
|
|
38
|
+
* known. Diagnostic only — it never decides whether a write runs.
|
|
39
|
+
*/
|
|
40
|
+
owner?: string;
|
|
41
|
+
/**
|
|
42
|
+
* True only for a registry-branded proposal-only tool (a compiled view
|
|
43
|
+
* intent or a fixed `smrt_ui_*` tool). Absent or false means a write acts.
|
|
44
|
+
*/
|
|
45
|
+
proposal?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Where the dock finds and runs browser tools. */
|
|
48
|
+
export interface AssistantClientToolSource {
|
|
49
|
+
list(): AssistantClientTool[];
|
|
50
|
+
execute(name: string, args: Record<string, unknown>, options?: {
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<string>;
|
|
53
|
+
subscribe?(listener: (event: unknown) => void): () => void;
|
|
54
|
+
}
|
|
55
|
+
/** Run now, or wait for the user's confirmation. */
|
|
56
|
+
export type AssistantClientToolPolicy = 'run' | 'confirm';
|
|
57
|
+
/** The default policy described in the module doc. */
|
|
58
|
+
export declare function defaultClientToolPolicy(tool: Pick<AssistantClientTool, 'effect' | 'owner' | 'proposal'>): AssistantClientToolPolicy;
|
|
59
|
+
/**
|
|
60
|
+
* Apply a host policy without ever weakening the floor: a destructive tool is
|
|
61
|
+
* always `confirm`, whatever the host says.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveClientToolPolicy(tool: AssistantClientTool, hostPolicy?: (tool: AssistantClientTool) => AssistantClientToolPolicy): AssistantClientToolPolicy;
|
|
64
|
+
/** The declarations sent to the server with a turn (bounded). */
|
|
65
|
+
export declare function declareClientTools(tools: readonly AssistantClientTool[], limit?: number): AssistantClientToolDeclaration[];
|
|
66
|
+
/** A browser tool call waiting for (or past) the user's decision. */
|
|
67
|
+
export interface AssistantToolRequest {
|
|
68
|
+
/** The model's call id. */
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
/** What the tool says it does (its registry description). */
|
|
72
|
+
description: string;
|
|
73
|
+
args: Record<string, unknown>;
|
|
74
|
+
effect: AssistantToolEffect;
|
|
75
|
+
status: 'waiting' | 'running' | 'done' | 'declined' | 'failed';
|
|
76
|
+
error?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The name of the dock's own proposal tool. It lets the model PROPOSE an
|
|
80
|
+
* action on a mounted data surface: the dock previews it and shows the usual
|
|
81
|
+
* Confirm/Reject, so nothing changes until the user confirms. Add it to the
|
|
82
|
+
* server's browser-tool allow-list to offer it.
|
|
83
|
+
*/
|
|
84
|
+
export declare const ASSISTANT_PROPOSE_ACTION_TOOL = "assistant_propose_action";
|
|
85
|
+
//# sourceMappingURL=client-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-tools.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/client-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EACV,8BAA8B,EAC9B,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAE3C,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,EAAE,mBAAmB,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,IAAI,IAAI,mBAAmB,EAAE,CAAC;IAC9B,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC5D;AAED,oDAAoD;AACpD,MAAM,MAAM,yBAAyB,GAAG,KAAK,GAAG,SAAS,CAAC;AAE1D,sDAAsD;AACtD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAC,GAC/D,yBAAyB,CAI3B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,mBAAmB,EACzB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,yBAAyB,GACpE,yBAAyB,CAG3B;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EACrC,KAAK,SAAK,GACT,8BAA8B,EAAE,CAOlC;AAED,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser tools for the AssistantDock (#2908).
|
|
3
|
+
*
|
|
4
|
+
* The dock offers the model the page's own WebMCP tools — the same set an
|
|
5
|
+
* outside agent sees — and runs the model's calls to them in the browser,
|
|
6
|
+
* through the same registry, as the signed-in user. The page registry is
|
|
7
|
+
* `@happyvertical/smrt-web/webmcp-page-tools`'s `WebMcpPageToolRegistry`,
|
|
8
|
+
* which satisfies {@link AssistantClientToolSource} structurally (this
|
|
9
|
+
* package keeps no runtime dependency on smrt-web).
|
|
10
|
+
*
|
|
11
|
+
* Whether a call runs at once or waits for the user is decided HERE, in the
|
|
12
|
+
* browser, from the registry's own description of the tool — never from what
|
|
13
|
+
* the server echoes back:
|
|
14
|
+
*
|
|
15
|
+
* - `read` runs;
|
|
16
|
+
* - `destructive` always waits for the user's own confirmation;
|
|
17
|
+
* - `write` runs only when the registry marks the tool `proposal: true` —
|
|
18
|
+
* smrt-web sets that solely from a module-private brand that compiled view
|
|
19
|
+
* intents and the fixed `smrt_ui_*` tools carry, because those tools only
|
|
20
|
+
* stage a value or dispatch a registry command as `source: 'agent'` (the
|
|
21
|
+
* control/surface registry keeps the change a proposal the user applies);
|
|
22
|
+
* - any other `write` waits for the user's confirmation — including one whose
|
|
23
|
+
* `owner` label says `ui` or `intent`: that label is a diagnostic any
|
|
24
|
+
* bespoke registration can set, so it never grants auto-run.
|
|
25
|
+
*
|
|
26
|
+
* A host may narrow this with `clientToolPolicy`, but can never make a
|
|
27
|
+
* destructive call run without confirmation.
|
|
28
|
+
*/
|
|
29
|
+
/** The default policy described in the module doc. */
|
|
30
|
+
export function defaultClientToolPolicy(tool) {
|
|
31
|
+
if (tool.effect === 'read')
|
|
32
|
+
return 'run';
|
|
33
|
+
if (tool.effect === 'destructive')
|
|
34
|
+
return 'confirm';
|
|
35
|
+
return tool.proposal === true ? 'run' : 'confirm';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Apply a host policy without ever weakening the floor: a destructive tool is
|
|
39
|
+
* always `confirm`, whatever the host says.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveClientToolPolicy(tool, hostPolicy) {
|
|
42
|
+
if (tool.effect === 'destructive')
|
|
43
|
+
return 'confirm';
|
|
44
|
+
return hostPolicy ? hostPolicy(tool) : defaultClientToolPolicy(tool);
|
|
45
|
+
}
|
|
46
|
+
/** The declarations sent to the server with a turn (bounded). */
|
|
47
|
+
export function declareClientTools(tools, limit = 64) {
|
|
48
|
+
return tools.slice(0, limit).map((tool) => ({
|
|
49
|
+
name: tool.name,
|
|
50
|
+
description: tool.description,
|
|
51
|
+
inputSchema: tool.inputSchema,
|
|
52
|
+
effect: tool.effect,
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The name of the dock's own proposal tool. It lets the model PROPOSE an
|
|
57
|
+
* action on a mounted data surface: the dock previews it and shows the usual
|
|
58
|
+
* Confirm/Reject, so nothing changes until the user confirms. Add it to the
|
|
59
|
+
* server's browser-tool allow-list to offer it.
|
|
60
|
+
*/
|
|
61
|
+
export const ASSISTANT_PROPOSE_ACTION_TOOL = 'assistant_propose_action';
|
|
@@ -37,7 +37,10 @@
|
|
|
37
37
|
* `createInMemoryAssistantTransport.sendMessage`).
|
|
38
38
|
*/
|
|
39
39
|
import { type DataSurfaceActionRequest, type DataSurfaceActionResult, type DataSurfaceIdentity, type DataSurfaceRegistry } from '@happyvertical/smrt-ui/data-surface';
|
|
40
|
+
import type { AssistantStatus, AssistantTurnStep } from '../../../assistant-turn-events.js';
|
|
41
|
+
import { type AssistantChoiceSet, type AssistantChoiceSourceRegistry } from './assistant-choices.svelte.js';
|
|
40
42
|
import type { AssistantAttachmentRef, AssistantMessage, AssistantThreadSummary, AssistantTransport, ModelOption } from './assistant-transport.js';
|
|
43
|
+
import { type AssistantClientTool, type AssistantClientToolPolicy, type AssistantClientToolSource, type AssistantToolRequest } from './client-tools.js';
|
|
41
44
|
export type AssistantPendingSendStatus = 'sending' | 'processing' | 'stale' | 'failed';
|
|
42
45
|
export interface AssistantPendingSend {
|
|
43
46
|
clientRequestId: string;
|
|
@@ -125,6 +128,67 @@ export type AssistantActionOutcome = {
|
|
|
125
128
|
result?: DataSurfaceActionResult;
|
|
126
129
|
error?: string;
|
|
127
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* One supervised assistant run (#assistant-watch): the work behind one user
|
|
133
|
+
* message, from the send until the turn ends, across every browser round
|
|
134
|
+
* trip. A host shows it as a status ("watch it work"); the dock keeps it.
|
|
135
|
+
*
|
|
136
|
+
* - `running`: the turn is working;
|
|
137
|
+
* - `paused`: the person paused it; the next step waits (`continueRun`);
|
|
138
|
+
* - `waiting`: the person is needed — see `waitingFor`;
|
|
139
|
+
* - `done`, `failed`, `cancelled`: it ended (`stoppedReason` says why).
|
|
140
|
+
*/
|
|
141
|
+
export type AssistantRunState = 'running' | 'paused' | 'waiting' | 'done' | 'failed' | 'cancelled';
|
|
142
|
+
/**
|
|
143
|
+
* What a `waiting` run needs from the person:
|
|
144
|
+
* - `confirm`: a browser tool call waits for Allow/Decline in the chat;
|
|
145
|
+
* - `choice`: a host asked the person to pick (see `holdForUser`);
|
|
146
|
+
* - `review`: a proposal is ready — a previewed action, a staged form value,
|
|
147
|
+
* or a host hold of kind `review`;
|
|
148
|
+
* - `continue`: the run stopped at its step or budget limit; the person can
|
|
149
|
+
* ask it to continue.
|
|
150
|
+
*/
|
|
151
|
+
export interface AssistantRunWaiting {
|
|
152
|
+
kind: 'confirm' | 'choice' | 'review' | 'continue';
|
|
153
|
+
/** How many things wait (at least 1). */
|
|
154
|
+
count: number;
|
|
155
|
+
/** A host hold's own label, when the newest wait is a hold. */
|
|
156
|
+
label?: string;
|
|
157
|
+
}
|
|
158
|
+
/** Why a run ended. */
|
|
159
|
+
export type AssistantRunStopReason = 'max_steps' | 'budget' | 'paused_too_long' | 'user' | 'error';
|
|
160
|
+
export interface AssistantRun {
|
|
161
|
+
/** The send's `clientRequestId`. */
|
|
162
|
+
id: string;
|
|
163
|
+
/** What the person asked, trimmed to one line (at most 80 characters). */
|
|
164
|
+
goal: string;
|
|
165
|
+
state: AssistantRunState;
|
|
166
|
+
/** The current step in plain language ("Opening Events"), if any. */
|
|
167
|
+
step: string | null;
|
|
168
|
+
/** Tool steps taken so far (server and browser). */
|
|
169
|
+
stepCount: number;
|
|
170
|
+
/** Browser tools that ran, in order (names; at most 50). A host decides
|
|
171
|
+
* from these whether the run has acted on the page yet. */
|
|
172
|
+
pageTools: string[];
|
|
173
|
+
waitingFor: AssistantRunWaiting | null;
|
|
174
|
+
stoppedReason: AssistantRunStopReason | null;
|
|
175
|
+
/** The failure message for `failed`. */
|
|
176
|
+
error: string | null;
|
|
177
|
+
startedAt: number;
|
|
178
|
+
endedAt: number | null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* A decision a host is waiting on the person for, while the run is shown
|
|
182
|
+
* (`holdForUser`). The generic seam for "the assistant presents choices, the
|
|
183
|
+
* person picks": while any hold is registered, the run is `waiting`.
|
|
184
|
+
*/
|
|
185
|
+
export interface AssistantUserHold {
|
|
186
|
+
/** Unique per hold; registering the same id again replaces it. */
|
|
187
|
+
id: string;
|
|
188
|
+
kind: 'choice' | 'review' | 'confirm';
|
|
189
|
+
/** Plain-language line for the status ("Pick a picture"). */
|
|
190
|
+
label?: string;
|
|
191
|
+
}
|
|
128
192
|
export interface AssistantDockControllerOptions {
|
|
129
193
|
transport: AssistantTransport;
|
|
130
194
|
registry: DataSurfaceRegistry;
|
|
@@ -175,6 +239,49 @@ export interface AssistantDockControllerOptions {
|
|
|
175
239
|
/** Initial composer draft text (#2991). Seeds the composer; it is never
|
|
176
240
|
* sent until the user sends it. */
|
|
177
241
|
initialDraft?: string;
|
|
242
|
+
/** The page's browser tools (#2908), offered to the model each turn and
|
|
243
|
+
* run here when it calls them — typically
|
|
244
|
+
* `@happyvertical/smrt-web/webmcp-page-tools`'s page registry. See
|
|
245
|
+
* `./client-tools.ts` for when a call runs and when it waits for the
|
|
246
|
+
* user. */
|
|
247
|
+
pageTools?: AssistantClientToolSource;
|
|
248
|
+
/** Narrows when a browser tool call waits for the user. A destructive
|
|
249
|
+
* tool always waits, whatever this returns. */
|
|
250
|
+
clientToolPolicy?: (tool: AssistantClientTool) => AssistantClientToolPolicy;
|
|
251
|
+
/** Called whenever `status` changes (#2908). */
|
|
252
|
+
onStatus?: (status: AssistantStatus) => void;
|
|
253
|
+
/**
|
|
254
|
+
* Waits for the page to settle after the browser tools of one step ran,
|
|
255
|
+
* before the turn resumes and the model is shown the page's tools again
|
|
256
|
+
* (e.g. SvelteKit: resolve once `navigating` is null). The dock also waits
|
|
257
|
+
* for navigations tracked on `registry` (`registerLinkSurface`) and for the
|
|
258
|
+
* registry and `pageTools` to go quiet, so the next step sees the new
|
|
259
|
+
* page's tools rather than the old page's or none. Bounded by
|
|
260
|
+
* `settleTimeoutMs`; a throw is ignored.
|
|
261
|
+
*/
|
|
262
|
+
settle?: () => Promise<void> | void;
|
|
263
|
+
/** Longest wait for the page to settle after a step. Default 5000ms. */
|
|
264
|
+
settleTimeoutMs?: number;
|
|
265
|
+
/**
|
|
266
|
+
* Narrows which page tools the dock declares and runs (e.g. a person's
|
|
267
|
+
* setting that turns off moving around the site). A tool it rejects is
|
|
268
|
+
* never offered to the model; a call to one is refused as `not_available`.
|
|
269
|
+
* The dock's own `assistant_propose_action` is not affected.
|
|
270
|
+
*/
|
|
271
|
+
clientToolFilter?: (tool: AssistantClientTool) => boolean;
|
|
272
|
+
/**
|
|
273
|
+
* How long a run may stay paused before it is stopped (reason
|
|
274
|
+
* `paused_too_long`). Match the server's continuation TTL. Default 15 min.
|
|
275
|
+
*/
|
|
276
|
+
maxPauseMs?: number;
|
|
277
|
+
/** Called whenever `run` changes (#assistant-watch). */
|
|
278
|
+
onRun?: (run: AssistantRun | null) => void;
|
|
279
|
+
/**
|
|
280
|
+
* Features on the page that can offer the person a few options to pick
|
|
281
|
+
* from (see `./assistant-choices.svelte.ts`). Each is offered to the model
|
|
282
|
+
* as `assistant_offer_<id>`; the person's click applies the option.
|
|
283
|
+
*/
|
|
284
|
+
choiceSources?: AssistantChoiceSourceRegistry;
|
|
178
285
|
}
|
|
179
286
|
export interface AssistantDockController {
|
|
180
287
|
readonly threads: AssistantThreadSummary[];
|
|
@@ -200,6 +307,58 @@ export interface AssistantDockController {
|
|
|
200
307
|
* user to edit. Never sends. Survives registry/transport swaps: it is the
|
|
201
308
|
* user's unsent text, not conversation state. */
|
|
202
309
|
setDraft(text: string): void;
|
|
310
|
+
/** What the assistant is doing, as one generic status (#2908): `working`
|
|
311
|
+
* with a plain-language label while a turn, a browser tool, or an action
|
|
312
|
+
* runs; `done` (with the number of changes applied) or `error` after;
|
|
313
|
+
* `idle` otherwise. `cancellable` is true while `cancel()` can stop it. */
|
|
314
|
+
readonly status: AssistantStatus;
|
|
315
|
+
/** The current turn's progress steps (#2908), newest last. */
|
|
316
|
+
readonly steps: AssistantTurnStep[];
|
|
317
|
+
/** Live preview of the reply being generated (#2908). Cleared once the
|
|
318
|
+
* persisted reply arrives. */
|
|
319
|
+
readonly streamingText: string;
|
|
320
|
+
/** Browser tool calls that wait for the user's decision (#2908). */
|
|
321
|
+
readonly toolRequests: AssistantToolRequest[];
|
|
322
|
+
/** Options the assistant offered, newest last (see `choiceSources`). */
|
|
323
|
+
readonly choices: AssistantChoiceSet[];
|
|
324
|
+
/** The person picked an option: apply it through its source. */
|
|
325
|
+
chooseOption(setId: string, optionId: string): Promise<void>;
|
|
326
|
+
/** Show a card of a previewable offer in place on the page (nothing applied). */
|
|
327
|
+
previewOption(setId: string, optionId: string): Promise<void>;
|
|
328
|
+
/** Apply the previewed option (the commit button); resolves the offer. */
|
|
329
|
+
commitOption(setId: string): Promise<void>;
|
|
330
|
+
/** Restore the original and close the offer (Cancel, Escape). */
|
|
331
|
+
cancelChoices(setId: string): void;
|
|
332
|
+
/** The person wants none of the offered options. */
|
|
333
|
+
dismissChoices(setId: string): void;
|
|
334
|
+
/** Lets a waiting browser tool call run. */
|
|
335
|
+
approveToolRequest(id: string): void;
|
|
336
|
+
/** Refuses a waiting browser tool call; the model is told it was declined. */
|
|
337
|
+
declineToolRequest(id: string): void;
|
|
338
|
+
/** Stops the turn in flight (#2908): aborts the stream and declines every
|
|
339
|
+
* waiting browser tool call. A no-op when nothing is running. */
|
|
340
|
+
cancel(): void;
|
|
341
|
+
/** The current or last supervised run (#assistant-watch), or `null`. */
|
|
342
|
+
readonly run: AssistantRun | null;
|
|
343
|
+
/** Pause the run: the next step waits until `continueRun`, bounded by
|
|
344
|
+
* `maxPauseMs`. A no-op unless a turn is running. */
|
|
345
|
+
pauseRun(): void;
|
|
346
|
+
/** Continue a paused run. */
|
|
347
|
+
continueRun(): void;
|
|
348
|
+
/**
|
|
349
|
+
* The person has seen what the run left for them (a staged value to
|
|
350
|
+
* review, a limit to continue from): those stop counting as `waiting`.
|
|
351
|
+
* Previewed actions, tool requests and holds still count until decided.
|
|
352
|
+
*/
|
|
353
|
+
acknowledgeRun(): void;
|
|
354
|
+
/** Forget a finished run (the host hid its status). No-op while running. */
|
|
355
|
+
dismissRun(): void;
|
|
356
|
+
/**
|
|
357
|
+
* Register a decision the host waits on the person for. While any hold is
|
|
358
|
+
* registered the run is `waiting` (kind from the hold). Returns the release
|
|
359
|
+
* function; call it once the person decided.
|
|
360
|
+
*/
|
|
361
|
+
holdForUser(hold: AssistantUserHold): () => void;
|
|
203
362
|
/** Records (or clears, with `null`) a background failure for `error` to
|
|
204
363
|
* report. Distinct from a failed `AssistantPendingSend`/`AssistantActionState`,
|
|
205
364
|
* which already carry their own `error` field — this is for failures with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-assistant-dock-controller.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/create-assistant-dock-controller.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"create-assistant-dock-controller.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/components/assistant/create-assistant-dock-controller.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAGzB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EAGV,eAAe,EACf,iBAAiB,EAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAEnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,sBAAsB,E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AC;CACjB;AA0BD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CAg4DzB"}
|
|
Binary file
|
package/dist/svelte/i18n.d.ts
CHANGED
|
@@ -34,6 +34,21 @@ export declare const M: {
|
|
|
34
34
|
readonly 'chat.assistant_thread_list.new_conversation': "chat.assistant_thread_list.new_conversation";
|
|
35
35
|
readonly 'chat.assistant_thread_list.untitled': "chat.assistant_thread_list.untitled";
|
|
36
36
|
readonly 'chat.assistant_dock.no_surfaces': "chat.assistant_dock.no_surfaces";
|
|
37
|
+
readonly 'chat.assistant_dock.stop': "chat.assistant_dock.stop";
|
|
38
|
+
readonly 'chat.assistant_dock.tool_request_title': "chat.assistant_dock.tool_request_title";
|
|
39
|
+
readonly 'chat.assistant_dock.choices_pick': "chat.assistant_dock.choices_pick";
|
|
40
|
+
readonly 'chat.assistant_dock.choices_none': "chat.assistant_dock.choices_none";
|
|
41
|
+
readonly 'chat.assistant_dock.choices_applying': "chat.assistant_dock.choices_applying";
|
|
42
|
+
readonly 'chat.assistant_dock.choices_applied': "chat.assistant_dock.choices_applied";
|
|
43
|
+
readonly 'chat.assistant_dock.choices_failed': "chat.assistant_dock.choices_failed";
|
|
44
|
+
readonly 'chat.assistant_dock.choices_making': "chat.assistant_dock.choices_making";
|
|
45
|
+
readonly 'chat.assistant_dock.choices_unavailable': "chat.assistant_dock.choices_unavailable";
|
|
46
|
+
readonly 'chat.assistant_dock.tool_request_allow': "chat.assistant_dock.tool_request_allow";
|
|
47
|
+
readonly 'chat.assistant_dock.tool_request_decline': "chat.assistant_dock.tool_request_decline";
|
|
48
|
+
readonly 'chat.assistant_dock.tool_request_destructive': "chat.assistant_dock.tool_request_destructive";
|
|
49
|
+
readonly 'chat.assistant_dock.tool_request_details': "chat.assistant_dock.tool_request_details";
|
|
50
|
+
readonly 'chat.assistant_dock.steps_label': "chat.assistant_dock.steps_label";
|
|
51
|
+
readonly 'chat.assistant_dock.reply_in_progress': "chat.assistant_dock.reply_in_progress";
|
|
37
52
|
readonly 'chat.assistant_dock.taking_longer': "chat.assistant_dock.taking_longer";
|
|
38
53
|
readonly 'chat.assistant_dock.retry': "chat.assistant_dock.retry";
|
|
39
54
|
readonly 'chat.assistant_dock.error': "chat.assistant_dock.error";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/svelte/i18n.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2HZ,CAAC"}
|
package/dist/svelte/i18n.js
CHANGED
|
@@ -53,7 +53,23 @@ export const M = defineMessages({
|
|
|
53
53
|
'chat.assistant_thread_list.new_conversation': '+ New conversation',
|
|
54
54
|
'chat.assistant_thread_list.untitled': 'Untitled',
|
|
55
55
|
// AssistantDock (#2904)
|
|
56
|
-
'chat.assistant_dock.no_surfaces': '
|
|
56
|
+
'chat.assistant_dock.no_surfaces': 'Nothing on this page can be changed from the chat. You can still ask questions.',
|
|
57
|
+
// Streamed turns and browser tools (#2908)
|
|
58
|
+
'chat.assistant_dock.stop': 'Stop',
|
|
59
|
+
'chat.assistant_dock.tool_request_title': 'The assistant wants to do this:',
|
|
60
|
+
'chat.assistant_dock.choices_pick': 'Pick one to use it.',
|
|
61
|
+
'chat.assistant_dock.choices_none': 'None of these',
|
|
62
|
+
'chat.assistant_dock.choices_applying': 'Using your pick…',
|
|
63
|
+
'chat.assistant_dock.choices_applied': 'Used: {label}',
|
|
64
|
+
'chat.assistant_dock.choices_failed': 'That did not work: {message}. Pick again.',
|
|
65
|
+
'chat.assistant_dock.choices_making': 'Making…',
|
|
66
|
+
'chat.assistant_dock.choices_unavailable': 'That could not be made: {message}',
|
|
67
|
+
'chat.assistant_dock.tool_request_allow': 'Allow',
|
|
68
|
+
'chat.assistant_dock.tool_request_decline': "Don't allow",
|
|
69
|
+
'chat.assistant_dock.tool_request_destructive': "This can't be undone.",
|
|
70
|
+
'chat.assistant_dock.tool_request_details': 'Details',
|
|
71
|
+
'chat.assistant_dock.steps_label': 'What the assistant did',
|
|
72
|
+
'chat.assistant_dock.reply_in_progress': 'Reply in progress',
|
|
57
73
|
'chat.assistant_dock.taking_longer': 'The assistant is taking longer than expected.',
|
|
58
74
|
'chat.assistant_dock.retry': 'Retry "{content}"',
|
|
59
75
|
'chat.assistant_dock.error': 'Something went wrong: {message}',
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -18,15 +18,19 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export { MessageBubble, TypingIndicator } from '@happyvertical/smrt-ui/chat';
|
|
21
|
+
export { type AssistantClientToolCall, type AssistantClientToolDeclaration, type AssistantClientToolResult, type AssistantStatus, type AssistantStatusState, type AssistantTurnEvent, type AssistantTurnStep, AssistantTurnStreamError, matchesToolAllowList, readAssistantTurnStream, } from '../assistant-turn-events.js';
|
|
21
22
|
export { default as AgentChat } from './components/agent/AgentChat.svelte';
|
|
22
23
|
export { default as AgentSelector } from './components/agent/AgentSelector.svelte';
|
|
23
24
|
export { default as AgentSessionPanel } from './components/agent/AgentSessionPanel.svelte';
|
|
24
25
|
export { default as ToolCallDisplay } from './components/agent/ToolCallDisplay.svelte';
|
|
26
|
+
export { default as AssistantChoiceCards } from './components/assistant/AssistantChoiceCards.svelte';
|
|
25
27
|
export { default as AssistantComposer } from './components/assistant/AssistantComposer.svelte';
|
|
26
28
|
export { default as AssistantDock } from './components/assistant/AssistantDock.svelte';
|
|
27
29
|
export { default as AssistantThreadList } from './components/assistant/AssistantThreadList.svelte';
|
|
28
|
-
export { type
|
|
29
|
-
export {
|
|
30
|
+
export { ASSISTANT_CHOICE_MAX_OPTIONS, ASSISTANT_CHOICE_TOOL_PREFIX, type AssistantChoiceOffer, type AssistantChoiceOption, type AssistantChoicePending, type AssistantChoicePendingUpdate, type AssistantChoiceSet, type AssistantChoiceSource, type AssistantChoiceSourceRegistry, AssistantChoices, choiceToolName, createAssistantChoiceSourceRegistry, normalizeChoiceOptions, safeChoiceImageUrl, } from './components/assistant/assistant-choices.svelte.js';
|
|
31
|
+
export { type AssistantAttachmentRef, type AssistantMessage, type AssistantResumeTurnInput, type AssistantSendMessageInput, type AssistantSendMessageResult, type AssistantThreadSummary, type AssistantTransport, type AssistantTransportEvent, type AssistantTurnStreamInput, createInMemoryAssistantTransport, createSmrtAssistantTransport, type InMemoryAssistantTransportOptions, readAssistantTurnResult, type SmrtAssistantTransportOptions, } from './components/assistant/assistant-transport.js';
|
|
32
|
+
export { ASSISTANT_PROPOSE_ACTION_TOOL, type AssistantClientTool, type AssistantClientToolPolicy, type AssistantClientToolSource, type AssistantToolRequest, declareClientTools, defaultClientToolPolicy, resolveClientToolPolicy, } from './components/assistant/client-tools.js';
|
|
33
|
+
export { ASSISTANT_ACTION_UNKNOWN_OUTCOME_REASONS, type AssistantActionClient, type AssistantActionOutcome, type AssistantActionState, type AssistantDockController, type AssistantDockControllerOptions, type AssistantPendingSend, type AssistantPendingSendStatus, type AssistantRun, type AssistantRunState, type AssistantRunStopReason, type AssistantRunWaiting, type AssistantUserHold, createAssistantDockController, } from './components/assistant/create-assistant-dock-controller.svelte.js';
|
|
30
34
|
export { default as RoomCreateDialog } from './components/dialogs/RoomCreateDialog.svelte';
|
|
31
35
|
export { default as SearchMessages } from './components/dialogs/SearchMessages.svelte';
|
|
32
36
|
export { default as ChatLayout } from './components/layout/ChatLayout.svelte';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/svelte/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA8CH,OAAO,EAAE,aAAa,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,14 +61,21 @@ import MiniChat from './components/tabs/MiniChat.svelte';
|
|
|
61
61
|
// `@happyvertical/smrt-ui/chat` primitives (consolidated in #1589);
|
|
62
62
|
// ReactionPicker keeps a thin chat-local adapter for the package's i18n + palette.
|
|
63
63
|
export { MessageBubble, TypingIndicator } from '@happyvertical/smrt-ui/chat';
|
|
64
|
+
// The assistant-turn wire contract (#2908), for hosts writing a transport.
|
|
65
|
+
// From the assistant-turn entry: the svelte build only resolves files the
|
|
66
|
+
// library build emits as entries (tool-allow-list.ts is bundled into it).
|
|
67
|
+
export { AssistantTurnStreamError, matchesToolAllowList, readAssistantTurnStream, } from '../assistant-turn-events.js';
|
|
64
68
|
export { default as AgentChat } from './components/agent/AgentChat.svelte';
|
|
65
69
|
export { default as AgentSelector } from './components/agent/AgentSelector.svelte';
|
|
66
70
|
export { default as AgentSessionPanel } from './components/agent/AgentSessionPanel.svelte';
|
|
67
71
|
export { default as ToolCallDisplay } from './components/agent/ToolCallDisplay.svelte';
|
|
72
|
+
export { default as AssistantChoiceCards } from './components/assistant/AssistantChoiceCards.svelte';
|
|
68
73
|
export { default as AssistantComposer } from './components/assistant/AssistantComposer.svelte';
|
|
69
74
|
export { default as AssistantDock } from './components/assistant/AssistantDock.svelte';
|
|
70
75
|
export { default as AssistantThreadList } from './components/assistant/AssistantThreadList.svelte';
|
|
71
|
-
export {
|
|
76
|
+
export { ASSISTANT_CHOICE_MAX_OPTIONS, ASSISTANT_CHOICE_TOOL_PREFIX, AssistantChoices, choiceToolName, createAssistantChoiceSourceRegistry, normalizeChoiceOptions, safeChoiceImageUrl, } from './components/assistant/assistant-choices.svelte.js';
|
|
77
|
+
export { createInMemoryAssistantTransport, createSmrtAssistantTransport, readAssistantTurnResult, } from './components/assistant/assistant-transport.js';
|
|
78
|
+
export { ASSISTANT_PROPOSE_ACTION_TOOL, declareClientTools, defaultClientToolPolicy, resolveClientToolPolicy, } from './components/assistant/client-tools.js';
|
|
72
79
|
export { ASSISTANT_ACTION_UNKNOWN_OUTCOME_REASONS, createAssistantDockController, } from './components/assistant/create-assistant-dock-controller.svelte.js';
|
|
73
80
|
export { default as RoomCreateDialog } from './components/dialogs/RoomCreateDialog.svelte';
|
|
74
81
|
export { default as SearchMessages } from './components/dialogs/SearchMessages.svelte';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool allow-list matching, shared by the server loop (which narrows the
|
|
3
|
+
* browser tools a page declares) and browser hosts (which narrow what they
|
|
4
|
+
* declare in the first place). No server dependencies: safe in the browser.
|
|
5
|
+
*/
|
|
6
|
+
/** Whether `name` matches an allow-list entry (exact, or `prefix*`). */
|
|
7
|
+
export declare function matchesToolAllowList(name: string, allowList: readonly string[]): boolean;
|
|
8
|
+
//# sourceMappingURL=tool-allow-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-allow-list.d.ts","sourceRoot":"","sources":["../src/tool-allow-list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wEAAwE;AACxE,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAMT"}
|