@artooi/ag-ui-web-component 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +515 -1
- package/README.md +232 -56
- package/dist/ag-ui-web-component.bundle.js +370 -139
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +17 -14
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/activity_registry.d.ts +46 -0
- package/dist/core/activity_registry.d.ts.map +1 -0
- package/dist/core/ag_ui_chat.d.ts +23 -10
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +28 -0
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/client_seed.d.ts +27 -0
- package/dist/core/client_seed.d.ts.map +1 -0
- package/dist/core/read_max_tool_rounds.d.ts +9 -0
- package/dist/core/read_max_tool_rounds.d.ts.map +1 -0
- package/dist/core/run_handlers.d.ts +80 -0
- package/dist/core/run_handlers.d.ts.map +1 -0
- package/dist/core/storage_scope.d.ts +110 -0
- package/dist/core/storage_scope.d.ts.map +1 -0
- package/dist/core/tool_outcome.d.ts +2 -3
- package/dist/core/tool_outcome.d.ts.map +1 -1
- package/dist/core/utils.d.ts +46 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/index.js +16268 -14747
- package/dist/index.js.map +4 -4
- package/dist/skills/skill_catalog.d.ts +67 -0
- package/dist/skills/skill_catalog.d.ts.map +1 -0
- package/dist/skills/skill_name_from.d.ts +12 -0
- package/dist/skills/skill_name_from.d.ts.map +1 -0
- package/dist/tools/tool_catalog.d.ts +79 -0
- package/dist/tools/tool_catalog.d.ts.map +1 -0
- package/dist/tools/tool_dispatch.d.ts +104 -0
- package/dist/tools/tool_dispatch.d.ts.map +1 -0
- package/dist/ui/composer/attachment_tray.d.ts.map +1 -1
- package/dist/ui/composer/auto_grow.d.ts +10 -0
- package/dist/ui/composer/auto_grow.d.ts.map +1 -0
- package/dist/ui/composer/composer_attachments.d.ts +57 -0
- package/dist/ui/composer/composer_attachments.d.ts.map +1 -0
- package/dist/ui/composer/composer_voice.d.ts +48 -0
- package/dist/ui/composer/composer_voice.d.ts.map +1 -0
- package/dist/ui/composer/voice_input.d.ts.map +1 -1
- package/dist/ui/excerpts/transcript_quote_offer.d.ts +57 -0
- package/dist/ui/excerpts/transcript_quote_offer.d.ts.map +1 -0
- package/dist/ui/fill_ui_string.d.ts +32 -0
- package/dist/ui/fill_ui_string.d.ts.map +1 -0
- package/dist/ui/history/conversation_history.d.ts +203 -0
- package/dist/ui/history/conversation_history.d.ts.map +1 -0
- package/dist/ui/history/relative_time.d.ts.map +1 -1
- package/dist/ui/history/thread_drawer.d.ts +0 -14
- package/dist/ui/history/thread_drawer.d.ts.map +1 -1
- package/dist/ui/interrupts/confirmation_card.d.ts.map +1 -1
- package/dist/ui/interrupts/pending_decision.d.ts +23 -0
- package/dist/ui/interrupts/pending_decision.d.ts.map +1 -0
- package/dist/ui/placement/is_collapsible_placement.d.ts +18 -0
- package/dist/ui/placement/is_collapsible_placement.d.ts.map +1 -0
- package/dist/ui/placement/is_draggable_placement.d.ts +9 -0
- package/dist/ui/placement/is_draggable_placement.d.ts.map +1 -0
- package/dist/ui/placement/launcher_drag.d.ts +6 -0
- package/dist/ui/placement/launcher_drag.d.ts.map +1 -1
- package/dist/ui/placement/panel_placement.d.ts +119 -0
- package/dist/ui/placement/panel_placement.d.ts.map +1 -0
- package/dist/ui/progress/run_announcer.d.ts +41 -0
- package/dist/ui/progress/run_announcer.d.ts.map +1 -0
- package/dist/ui/progress/subagent_progress.d.ts +58 -0
- package/dist/ui/progress/subagent_progress.d.ts.map +1 -0
- package/dist/ui/progress/tool_call_card.d.ts.map +1 -1
- package/dist/ui/shell/adopt_styles.d.ts +23 -0
- package/dist/ui/shell/adopt_styles.d.ts.map +1 -0
- package/dist/ui/shell/glyph_slot.d.ts +7 -0
- package/dist/ui/shell/glyph_slot.d.ts.map +1 -0
- package/dist/ui/shell/header_button.d.ts +10 -0
- package/dist/ui/shell/header_button.d.ts.map +1 -0
- package/dist/ui/shell/icon_element.d.ts +12 -0
- package/dist/ui/shell/icon_element.d.ts.map +1 -0
- package/dist/ui/shell/is_unread_badge_enabled.d.ts +10 -0
- package/dist/ui/shell/is_unread_badge_enabled.d.ts.map +1 -0
- package/dist/ui/shell/read_launcher_icon_url.d.ts +8 -0
- package/dist/ui/shell/read_launcher_icon_url.d.ts.map +1 -0
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/transcript/answer_actions.d.ts +39 -0
- package/dist/ui/transcript/answer_actions.d.ts.map +1 -0
- package/dist/ui/transcript/answer_stream.d.ts +56 -0
- package/dist/ui/transcript/answer_stream.d.ts.map +1 -0
- package/dist/ui/transcript/render_or_warn.d.ts +16 -0
- package/dist/ui/transcript/render_or_warn.d.ts.map +1 -0
- package/dist/ui/transcript/starter_chips.d.ts +21 -0
- package/dist/ui/transcript/starter_chips.d.ts.map +1 -0
- package/dist/ui/transcript/transcript.d.ts +171 -0
- package/dist/ui/transcript/transcript.d.ts.map +1 -0
- package/dist/ui/ui_strings.d.ts +29 -1
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +17 -15
- package/src/core/activity_registry.ts +133 -0
- package/src/core/ag_ui_chat.ts +945 -4419
- package/src/core/agui_client.ts +172 -16
- package/src/core/client_seed.ts +27 -0
- package/src/core/read_max_tool_rounds.ts +13 -0
- package/src/core/remote_conversation_store.ts +1 -1
- package/src/core/run_handlers.ts +501 -0
- package/src/core/storage_scope.ts +279 -0
- package/src/core/tool_outcome.ts +5 -3
- package/src/core/utils.ts +109 -0
- package/src/skills/skill_catalog.ts +166 -0
- package/src/skills/skill_name_from.ts +19 -0
- package/src/tools/tool_catalog.ts +354 -0
- package/src/tools/tool_dispatch.ts +521 -0
- package/src/ui/composer/attachment_tray.ts +6 -5
- package/src/ui/composer/auto_grow.ts +12 -0
- package/src/ui/composer/composer_attachments.ts +324 -0
- package/src/ui/composer/composer_voice.ts +93 -0
- package/src/ui/composer/voice_input.ts +4 -4
- package/src/ui/excerpts/transcript_quote_offer.ts +198 -0
- package/src/ui/fill_ui_string.ts +41 -0
- package/src/ui/history/conversation_history.ts +699 -0
- package/src/ui/history/relative_time.ts +5 -4
- package/src/ui/history/thread_drawer.ts +3 -50
- package/src/ui/interrupts/confirmation_card.ts +4 -2
- package/src/ui/interrupts/pending_decision.ts +34 -0
- package/src/ui/placement/is_collapsible_placement.ts +19 -0
- package/src/ui/placement/is_draggable_placement.ts +23 -0
- package/src/ui/placement/launcher_drag.ts +104 -89
- package/src/ui/placement/panel_placement.ts +1130 -0
- package/src/ui/progress/run_announcer.ts +67 -0
- package/src/ui/progress/subagent_progress.ts +201 -0
- package/src/ui/progress/tool_call_card.ts +2 -0
- package/src/ui/shell/adopt_styles.ts +28 -0
- package/src/ui/shell/glyph_slot.ts +12 -0
- package/src/ui/shell/header_button.ts +21 -0
- package/src/ui/shell/icon_element.ts +33 -0
- package/src/ui/shell/is_unread_badge_enabled.ts +11 -0
- package/src/ui/shell/read_launcher_icon_url.ts +9 -0
- package/src/ui/styles.ts +301 -70
- package/src/ui/transcript/answer_actions.ts +139 -0
- package/src/ui/transcript/answer_stream.ts +123 -0
- package/src/ui/transcript/render_or_warn.ts +22 -0
- package/src/ui/transcript/starter_chips.ts +42 -0
- package/src/ui/transcript/transcript.ts +429 -0
- package/src/ui/ui_strings.ts +38 -1
- package/src/version.ts +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { SkillsMenu } from "../ui/composer/skills_menu.js";
|
|
2
|
+
import type { UiStrings } from "../ui/ui_strings.js";
|
|
3
|
+
import type { Skill } from "./skill.js";
|
|
4
|
+
/** What the skill catalog needs from the element that owns it. */
|
|
5
|
+
export interface SkillCatalogHost {
|
|
6
|
+
/** The custom element, whose `data-skills-url` names the backend catalog. */
|
|
7
|
+
readonly element: HTMLElement;
|
|
8
|
+
/** The chips row and the slash palette the merged catalog is shown in. */
|
|
9
|
+
readonly menu: SkillsMenu;
|
|
10
|
+
/** The composer a picked skill's prompt is written into. */
|
|
11
|
+
readonly input: HTMLTextAreaElement;
|
|
12
|
+
/** The hint above the composer, saying what a skill still needs. */
|
|
13
|
+
readonly hint: HTMLElement;
|
|
14
|
+
/** The resolved string table. */
|
|
15
|
+
readonly strings: () => UiStrings;
|
|
16
|
+
/** The host's `skillContext`, read at the moment of the pick. */
|
|
17
|
+
readonly context: () => Record<string, unknown>;
|
|
18
|
+
/** Read an opt-in flag attribute. */
|
|
19
|
+
readonly flag: (name: string) => boolean;
|
|
20
|
+
/** Parse a JSON-valued attribute, warning when it will not parse. */
|
|
21
|
+
readonly readJsonAttribute: (name: string) => unknown;
|
|
22
|
+
/** The fetch options every request the element makes carries. */
|
|
23
|
+
readonly fetchInit: (url: string) => RequestInit | undefined;
|
|
24
|
+
/** The element's public `sendMessage`. */
|
|
25
|
+
readonly send: (content: string) => void;
|
|
26
|
+
/** Send whatever the composer holds, as the Send button does. */
|
|
27
|
+
readonly submit: () => void;
|
|
28
|
+
/** Resize the composer to what it now holds. */
|
|
29
|
+
readonly autoGrow: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The element's skills: the three catalogs a skill can come from, merged into
|
|
33
|
+
* the chips and the slash palette, and what picking one does to the composer.
|
|
34
|
+
*
|
|
35
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
36
|
+
* instance.
|
|
37
|
+
*/
|
|
38
|
+
export declare class SkillCatalog {
|
|
39
|
+
#private;
|
|
40
|
+
constructor(host: SkillCatalogHost);
|
|
41
|
+
/** The replacement behind `AgUiChat.setSkills`, whose doc is the contract. */
|
|
42
|
+
setClientSkills(skills: readonly Skill[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Wire the skill surfaces: opt-in flags and the embedded catalog. The backend
|
|
45
|
+
* catalog is fetched from the element's startup, a microtask later, so it
|
|
46
|
+
* carries the host's transport configuration.
|
|
47
|
+
*/
|
|
48
|
+
init(): void;
|
|
49
|
+
/** Fetch the backend skills catalog from `data-skills-url`, if set. */
|
|
50
|
+
fetch(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Act on a picked skill.
|
|
53
|
+
*
|
|
54
|
+
* A skill with no `prompt` is server-resolved: picking it sends the bare
|
|
55
|
+
* `/name` token for the agent to expand, so the wording never reaches the
|
|
56
|
+
* browser. Prefer that shape — a skill often states a project's internal
|
|
57
|
+
* workflow most plainly, and a catalog endpoint is a plain GET.
|
|
58
|
+
*
|
|
59
|
+
* A skill carrying a `prompt` has the client fill its `{placeholder}`s from
|
|
60
|
+
* the page instead, which is right for placeholders only the page can supply.
|
|
61
|
+
*
|
|
62
|
+
* Either way a pick sends; `sendImmediately: false` opts into pre-filling the
|
|
63
|
+
* composer instead.
|
|
64
|
+
*/
|
|
65
|
+
apply(skill: Skill): void;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=skill_catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill_catalog.d.ts","sourceRoot":"","sources":["../../src/skills/skill_catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,SAAS,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,qEAAqE;IACrE,QAAQ,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtD,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IAC7D,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,qBAAa,YAAY;;IAOvB,YAAY,IAAI,EAAE,gBAAgB,EAEjC;IAED,8EAA8E;IAC9E,eAAe,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI,CAG9C;IAED;;;;OAIG;IACH,IAAI,IAAI,IAAI,CAKX;IAED,uEAAuE;IACjE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAY3B;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAkCxB;CA+BF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgUiToolCall } from "../core/agui_client.js";
|
|
2
|
+
/**
|
|
3
|
+
* The skill name a `load_capability` call activated, or `null` when the call is
|
|
4
|
+
* something else.
|
|
5
|
+
*
|
|
6
|
+
* Every deferred capability loads through this one tool, so the id is a skill
|
|
7
|
+
* name only when the project wired agent skills; another project's capability
|
|
8
|
+
* id surfaces here too. Acceptable for a muted notice, and better than a
|
|
9
|
+
* parallel signal — the id is exactly what the model selected.
|
|
10
|
+
*/
|
|
11
|
+
export declare function skillNameFrom(call: AgUiToolCall): string | null;
|
|
12
|
+
//# sourceMappingURL=skill_name_from.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill_name_from.d.ts","sourceRoot":"","sources":["../../src/skills/skill_name_from.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAM/D"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Tool } from "@ag-ui/core";
|
|
2
|
+
import type { PendingDecision } from "../ui/interrupts/pending_decision.js";
|
|
3
|
+
import { type QuestionRenderer } from "../ui/interrupts/question_card.js";
|
|
4
|
+
import type { UiStrings } from "../ui/ui_strings.js";
|
|
5
|
+
import { type ChatSurface } from "./chat_surface_tools.js";
|
|
6
|
+
import { type ClientTool } from "./client_tool_registry.js";
|
|
7
|
+
import type { PageMap } from "./page_map.js";
|
|
8
|
+
import { type PageState } from "./page_state.js";
|
|
9
|
+
import { type RouteMap } from "./route_map.js";
|
|
10
|
+
/** What the tool catalog needs from the element that owns it. */
|
|
11
|
+
export interface ToolCatalogHost {
|
|
12
|
+
/** The custom element: its tool attributes, and the surface the chat tools drive. */
|
|
13
|
+
readonly element: HTMLElement & ChatSurface;
|
|
14
|
+
/** The element's `routeMap`, read per call. */
|
|
15
|
+
readonly routeMap: () => RouteMap;
|
|
16
|
+
/** The element's `navigate`, read per call. */
|
|
17
|
+
readonly navigate: () => ((path: string) => void) | null;
|
|
18
|
+
/** The element's `getPageMap`, read per call. */
|
|
19
|
+
readonly getPageMap: () => (() => PageMap) | null;
|
|
20
|
+
/** The element's `resolvePageTarget`, called per target. */
|
|
21
|
+
readonly resolvePageTarget: (target: string) => HTMLElement | null;
|
|
22
|
+
/** The element's `getTools`, which a host may have replaced. */
|
|
23
|
+
readonly getTools: () => Tool[];
|
|
24
|
+
/** The element's `askUser` flag. */
|
|
25
|
+
readonly askUser: () => boolean;
|
|
26
|
+
/** The element's `askUserRenderer`. */
|
|
27
|
+
readonly askUserRenderer: () => QuestionRenderer | null;
|
|
28
|
+
/** The decision a run is suspended on, which a Stop abandons. */
|
|
29
|
+
readonly decision: PendingDecision;
|
|
30
|
+
/** The current answer group, opening one if none is open. */
|
|
31
|
+
readonly ensureGroup: () => HTMLDivElement;
|
|
32
|
+
/** The resolved string table. */
|
|
33
|
+
readonly strings: () => UiStrings;
|
|
34
|
+
/** Remove the pending indicator if shown. */
|
|
35
|
+
readonly hidePending: () => void;
|
|
36
|
+
/** Update the empty state after the transcript changed. */
|
|
37
|
+
readonly updateEmptyState: () => void;
|
|
38
|
+
/** Keep the transcript at its foot, if the reader is there. */
|
|
39
|
+
readonly follow: () => void;
|
|
40
|
+
/** The fetch options every request the element makes carries. */
|
|
41
|
+
readonly fetchInit: (url: string) => RequestInit | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The frontend tools the agent is offered: the host's registered tools, the
|
|
45
|
+
* built-in ones the element's configuration switches on, what the current round
|
|
46
|
+
* advertised, and the server's catalog of labels for the tools it runs itself.
|
|
47
|
+
*
|
|
48
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
49
|
+
* instance.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ToolCatalog {
|
|
52
|
+
#private;
|
|
53
|
+
constructor(host: ToolCatalogHost);
|
|
54
|
+
/** The registration behind `AgUiChat.registerTool`, whose doc is the contract. */
|
|
55
|
+
register(tool: ClientTool): void;
|
|
56
|
+
/** The binding behind `AgUiChat.registerPageState`, whose doc is the contract. */
|
|
57
|
+
registerPageState(binding: PageState): void;
|
|
58
|
+
/** Whether a tool of this name is registered, built-ins aside. */
|
|
59
|
+
has(name: string): boolean;
|
|
60
|
+
/** The catalog behind the default `AgUiChat.getTools`, whose doc is the contract. */
|
|
61
|
+
defaultTools(): Tool[];
|
|
62
|
+
/**
|
|
63
|
+
* The catalog for the round about to start, remembering what it offered.
|
|
64
|
+
*
|
|
65
|
+
* Every path to a frontend tool goes through here first — the client asks
|
|
66
|
+
* for `RunAgentInput.tools` at the top of each round — so this is the one
|
|
67
|
+
* place that can know what the agent was actually told about.
|
|
68
|
+
*/
|
|
69
|
+
advertise(): Tool[];
|
|
70
|
+
/** Whether the current round offered a tool of this name. */
|
|
71
|
+
wasAdvertised(name: string): boolean;
|
|
72
|
+
/** Resolve a tool by name: built-in tools first, then the registry. */
|
|
73
|
+
resolve(name: string): ClientTool | null;
|
|
74
|
+
/** The server catalog's label for a tool, if it sent one. */
|
|
75
|
+
summary(name: string): string | undefined;
|
|
76
|
+
/** Fetch the server tool-label catalog from `data-tools-url`, if set. */
|
|
77
|
+
fetchCatalog(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=tool_catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool_catalog.d.ts","sourceRoot":"","sources":["../../src/tools/tool_catalog.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Context, Interrupt } from "@ag-ui/core";
|
|
2
|
+
import type { AgUiToolCall, InterruptResponse, ToolExecution } from "../core/agui_client.js";
|
|
3
|
+
import type { ClientConversationStore } from "../core/conversation_store.js";
|
|
4
|
+
import { type ApprovalRenderer } from "../ui/interrupts/approval_card.js";
|
|
5
|
+
import type { PendingDecision } from "../ui/interrupts/pending_decision.js";
|
|
6
|
+
import type { Transcript } from "../ui/transcript/transcript.js";
|
|
7
|
+
import type { UiStrings } from "../ui/ui_strings.js";
|
|
8
|
+
import type { PageMap } from "./page_map.js";
|
|
9
|
+
import type { ToolCatalog } from "./tool_catalog.js";
|
|
10
|
+
/** What tool dispatch needs from the element that owns it. */
|
|
11
|
+
export interface ToolDispatchHost {
|
|
12
|
+
/** The custom element, which a host's predicate and renderer are called on. */
|
|
13
|
+
readonly element: HTMLElement;
|
|
14
|
+
/** The transcript the cards and prompts are drawn in. */
|
|
15
|
+
readonly transcript: Transcript;
|
|
16
|
+
/** The tools this round advertised, and their implementations. */
|
|
17
|
+
readonly tools: ToolCatalog;
|
|
18
|
+
/** The decision a run is suspended on, which a Stop abandons. */
|
|
19
|
+
readonly decision: PendingDecision;
|
|
20
|
+
/** The resolved string table. */
|
|
21
|
+
readonly strings: () => UiStrings;
|
|
22
|
+
/** Say one short thing to a screen reader. */
|
|
23
|
+
readonly announce: (message: string) => void;
|
|
24
|
+
/** The element's `autoConfirm`. */
|
|
25
|
+
readonly autoConfirm: () => boolean;
|
|
26
|
+
/** The element's `confirmPredicate`. */
|
|
27
|
+
readonly confirmPredicate: () => ((toolName: string, args: Record<string, unknown>) => boolean | Promise<boolean>) | null;
|
|
28
|
+
/** The element's `getPageMap`. */
|
|
29
|
+
readonly getPageMap: () => (() => PageMap) | null;
|
|
30
|
+
/** The element's `navigate`. */
|
|
31
|
+
readonly navigate: () => ((path: string) => void) | null;
|
|
32
|
+
/** The element's `approveWithEdits`. */
|
|
33
|
+
readonly approveWithEdits: () => boolean;
|
|
34
|
+
/** The element's `approvalRenderer`. */
|
|
35
|
+
readonly approvalRenderer: () => ApprovalRenderer | null;
|
|
36
|
+
/** The element's `getContext`, which a host may have replaced. */
|
|
37
|
+
readonly getContext: () => Context[];
|
|
38
|
+
/** The element's `conversationStore`, read per use. */
|
|
39
|
+
readonly conversationStore: () => ClientConversationStore;
|
|
40
|
+
/** The active thread's id. */
|
|
41
|
+
readonly threadId: () => string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Running the frontend tool calls a round produced, and answering the server's
|
|
45
|
+
* interrupts: the page each round's context described, the confirmation rules,
|
|
46
|
+
* and the tools the user waived confirmation for.
|
|
47
|
+
*
|
|
48
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
49
|
+
* instance.
|
|
50
|
+
*/
|
|
51
|
+
export declare class ToolDispatch {
|
|
52
|
+
#private;
|
|
53
|
+
constructor(host: ToolDispatchHost);
|
|
54
|
+
/**
|
|
55
|
+
* Forget every tool the user waived confirmation for.
|
|
56
|
+
*
|
|
57
|
+
* A waiver is one person's click, and it is only ever that person's to give.
|
|
58
|
+
* `user-key` exists because a logout is a navigation inside one tab rather
|
|
59
|
+
* than a remount, so the element outlives the principal who clicked Always
|
|
60
|
+
* allow -- and without this the next one's destructive calls would run on the
|
|
61
|
+
* previous one's say-so, with no card to show that anyone was asked.
|
|
62
|
+
*/
|
|
63
|
+
forgetWaivers(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Build a round's context, recording which page it describes.
|
|
66
|
+
*
|
|
67
|
+
* The AG-UI client re-invokes this at the top of **every** tool round, not
|
|
68
|
+
* once per `send()`, so the page map the agent sees is already refreshed
|
|
69
|
+
* between rounds and the href captured here is the page it was shown for
|
|
70
|
+
* *this* round. {@link execute} compares against it to catch a page that
|
|
71
|
+
* moved under a round still in flight.
|
|
72
|
+
*/
|
|
73
|
+
buildContext(): Context[];
|
|
74
|
+
/**
|
|
75
|
+
* Execute one frontend tool call the round produced, against its own card:
|
|
76
|
+
* refused when the page moved under the round, asked about when a rule gates
|
|
77
|
+
* it, and settled with what the handler returned or threw.
|
|
78
|
+
*/
|
|
79
|
+
execute(call: AgUiToolCall): Promise<ToolExecution | null>;
|
|
80
|
+
/**
|
|
81
|
+
* Render an approval card per server-side-tool interrupt and collect the
|
|
82
|
+
* user's decisions (approve → run it, deny → decline it).
|
|
83
|
+
*
|
|
84
|
+
* **One card per gated call, in that call's own tool card, all at once.** A run
|
|
85
|
+
* can defer several calls, and the wire answers each independently — so the UI
|
|
86
|
+
* has to let a person answer each independently, which means saying which is
|
|
87
|
+
* which. The prompt cannot: it comes from the tool's `x-confirm` and is
|
|
88
|
+
* identical for every call of that tool. The tool card can, by position, and it
|
|
89
|
+
* is already showing the arguments. Asking them serially was the other half of
|
|
90
|
+
* the problem: the second question only appeared once the first was answered,
|
|
91
|
+
* so a person could neither compare them nor tell that more were coming.
|
|
92
|
+
*
|
|
93
|
+
* Each gated card is marked `deferred` for the wait. That is not cosmetic — at
|
|
94
|
+
* `pending` it read "running…" while the stream was over and the server idle.
|
|
95
|
+
*
|
|
96
|
+
* The run is suspended on these cards. A Stop while any is open aborts the
|
|
97
|
+
* shared pending decision, resolving every still-open card as
|
|
98
|
+
* denied. An approved tool runs on the follow-up resume run and streams its
|
|
99
|
+
* result into the same card (returned to `pending`, since it now really is
|
|
100
|
+
* running); a denied one settles here, as no result will ever arrive.
|
|
101
|
+
*/
|
|
102
|
+
resolveInterrupts(interrupts: readonly Interrupt[]): Promise<Record<string, InterruptResponse>>;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=tool_dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool_dispatch.d.ts","sourceRoot":"","sources":["../../src/tools/tool_dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,mCAAmC,CAAC;AAK3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,SAAS,CAAC;IAClC,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,mCAAmC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,OAAO,CAAC;IACpC,wCAAwC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MACvB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GACjF,IAAI,CAAC;IACT,kCAAkC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC;IAClD,gCAAgC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACzD,wCAAwC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,OAAO,CAAC;IACzC,wCAAwC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,gBAAgB,GAAG,IAAI,CAAC;IACzD,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,EAAE,CAAC;IACrC,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;IAC1D,8BAA8B;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;;IAiBvB,YAAY,IAAI,EAAE,gBAAgB,EAEjC;IAED;;;;;;;;OAQG;IACH,aAAa,IAAI,IAAI,CAEpB;IAED;;;;;;;;OAQG;IACH,YAAY,IAAI,OAAO,EAAE,CAGxB;IAED;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAuJ/D;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,iBAAiB,CACrB,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CA+F5C;CAiGF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment_tray.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/attachment_tray.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment_tray.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/attachment_tray.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAIrE,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKtE,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;CAC9B;AAcD;;;;;;;;;GASG;AACH,qBAAa,cAAc;;IACzB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IAMjC,YAAY,MAAM,EAAE,oBAAoB,EAOvC;IAED,gFAAgF;IAChF,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAsBpB;IAED,8DAA8D;IAC9D,SAAS,IAAI,SAAS,aAAa,EAAE,CAQpC;IAED,gFAAgF;IAChF,UAAU,IAAI,OAAO,CAEpB;IAED,+EAA+E;IAC/E,YAAY,IAAI,MAAM,CAErB;IAED,uCAAuC;IACvC,OAAO,IAAI,OAAO,CAEjB;IAED,2EAA2E;IAC3E,UAAU,IAAI,IAAI,CAGjB;IAED,2EAA2E;IAC3E,KAAK,IAAI,IAAI,CAMZ;IAED;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAId;CAqIF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Size the field to its content: one row when empty, growing with what is
|
|
3
|
+
* typed until the CSS ceiling takes over and it scrolls.
|
|
4
|
+
*
|
|
5
|
+
* Resetting to `auto` first is what makes it shrink again — `scrollHeight`
|
|
6
|
+
* never reports less than the current height, so measuring without the reset
|
|
7
|
+
* would ratchet the composer taller and never back down.
|
|
8
|
+
*/
|
|
9
|
+
export declare function autoGrow(input: HTMLTextAreaElement): void;
|
|
10
|
+
//# sourceMappingURL=auto_grow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto_grow.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/auto_grow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAGzD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type UploadHandler } from "../../core/upload_attachment.js";
|
|
2
|
+
import type { UiStrings } from "../ui_strings.js";
|
|
3
|
+
import { AttachmentTray } from "./attachment_tray.js";
|
|
4
|
+
/** What the composer's attachments need from the element that owns them. */
|
|
5
|
+
export interface ComposerAttachmentsHost {
|
|
6
|
+
/** The custom element: its upload attributes, and where the event is dispatched. */
|
|
7
|
+
readonly element: HTMLElement;
|
|
8
|
+
/** The chat shell, which a file can be dropped or pasted anywhere on. */
|
|
9
|
+
readonly chat: HTMLElement;
|
|
10
|
+
/** Where the tray mounts, above the composer. */
|
|
11
|
+
readonly slot: HTMLElement;
|
|
12
|
+
/** The hidden multi-file input the paperclip opens. */
|
|
13
|
+
readonly fileInput: HTMLInputElement;
|
|
14
|
+
/** The paperclip, revealed once uploads are possible. */
|
|
15
|
+
readonly button: HTMLButtonElement;
|
|
16
|
+
/** The resolved string table. */
|
|
17
|
+
readonly strings: () => UiStrings;
|
|
18
|
+
/** The host's `uploadHandler`, read when the tray is wired. */
|
|
19
|
+
readonly uploadHandler: () => UploadHandler | null;
|
|
20
|
+
/** The headers a request to `url` carries. */
|
|
21
|
+
readonly headersFor: (url: string) => Record<string, string>;
|
|
22
|
+
/** The cookie policy every request carries, when one is configured. */
|
|
23
|
+
readonly credentialsOption: () => {
|
|
24
|
+
credentials?: RequestCredentials;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Files handed to the composer: the tray they upload through, and the four
|
|
29
|
+
* ways into it -- the picker, a drop, a paste, and a host's `attachFile`.
|
|
30
|
+
*
|
|
31
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
32
|
+
* instance.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ComposerAttachments {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(host: ComposerAttachmentsHost);
|
|
37
|
+
/** The tray, once uploads are wired; `null` while the chat is text-only. */
|
|
38
|
+
get tray(): AttachmentTray | null;
|
|
39
|
+
/**
|
|
40
|
+
* Enable the composer's file-upload tray when uploads are possible — either a
|
|
41
|
+
* custom `uploadHandler` is set or `data-attachments-url` provides the
|
|
42
|
+
* built-in multipart endpoint: reveal the 📎 button, wire the hidden file
|
|
43
|
+
* input + drag-and-drop, and mount the tray. With neither, the affordance
|
|
44
|
+
* stays hidden and the chat degrades to text-only.
|
|
45
|
+
*
|
|
46
|
+
* Called on every connect, so it starts by taking down the tray the last
|
|
47
|
+
* connection mounted: that one was disposed when the element left, and the
|
|
48
|
+
* attributes that decide whether there is a tray at all may have changed
|
|
49
|
+
* since. The shell outlives a connection, so its listeners go under `signal`.
|
|
50
|
+
*/
|
|
51
|
+
wire(signal: AbortSignal): void;
|
|
52
|
+
/** The queueing behind `AgUiChat.attachFile`, whose doc is the contract. */
|
|
53
|
+
attach(file: File): boolean;
|
|
54
|
+
/** Queue every file from the picker into the tray, then reset the input. */
|
|
55
|
+
onFilesPicked(): void;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=composer_attachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer_attachments.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/composer_attachments.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,iCAAiC,CAAC;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,4EAA4E;AAC5E,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,SAAS,CAAC;IAClC,+DAA+D;IAC/D,QAAQ,CAAC,aAAa,EAAE,MAAM,aAAa,GAAG,IAAI,CAAC;IACnD,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7D,uEAAuE;IACvE,QAAQ,CAAC,iBAAiB,EAAE,MAAM;QAAE,WAAW,CAAC,EAAE,kBAAkB,CAAA;KAAE,CAAC;CACxE;AAED;;;;;;GAMG;AACH,qBAAa,mBAAmB;;IAK9B,YAAY,IAAI,EAAE,uBAAuB,EAExC;IAED,4EAA4E;IAC5E,IAAI,IAAI,IAAI,cAAc,GAAG,IAAI,CAEhC;IAED;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CA4B9B;IAED,4EAA4E;IAC5E,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAM1B;IAED,4EAA4E;IAC5E,aAAa,IAAI,IAAI,CAUpB;CA2KF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type TranscribeHandler } from "../../core/transcribe_audio.js";
|
|
2
|
+
import type { UiStrings } from "../ui_strings.js";
|
|
3
|
+
/** What the composer's mic needs from the element that owns it. */
|
|
4
|
+
export interface ComposerVoiceHost {
|
|
5
|
+
/** The custom element, whose `data-transcribe-url` names the built-in endpoint. */
|
|
6
|
+
readonly element: HTMLElement;
|
|
7
|
+
/** Where the mic button mounts, in the composer's tool row. */
|
|
8
|
+
readonly slot: HTMLElement;
|
|
9
|
+
/** The composer a transcript is written into. */
|
|
10
|
+
readonly input: HTMLTextAreaElement;
|
|
11
|
+
/** The resolved string table. */
|
|
12
|
+
readonly strings: () => UiStrings;
|
|
13
|
+
/** The host's `transcribeHandler`, read when the mic is wired. */
|
|
14
|
+
readonly transcribeHandler: () => TranscribeHandler | null;
|
|
15
|
+
/** The headers a request to `url` carries. */
|
|
16
|
+
readonly headersFor: (url: string) => Record<string, string>;
|
|
17
|
+
/** The cookie policy every request carries, when one is configured. */
|
|
18
|
+
readonly credentialsOption: () => {
|
|
19
|
+
credentials?: RequestCredentials;
|
|
20
|
+
};
|
|
21
|
+
/** React to the composer's value changing, as typing does. */
|
|
22
|
+
readonly onInput: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The composer's mic: mounted when transcription is possible, and what a
|
|
26
|
+
* transcript does to the composer.
|
|
27
|
+
*
|
|
28
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
29
|
+
* instance.
|
|
30
|
+
*/
|
|
31
|
+
export declare class ComposerVoice {
|
|
32
|
+
#private;
|
|
33
|
+
constructor(host: ComposerVoiceHost);
|
|
34
|
+
/**
|
|
35
|
+
* Reveal the composer's 🎤 mic button when transcription is possible — either
|
|
36
|
+
* a custom `transcribeHandler` is set or `data-transcribe-url` provides the
|
|
37
|
+
* built-in POST endpoint. The control records via `MediaRecorder` and drops
|
|
38
|
+
* the transcript into the composer; with neither configured the mic stays
|
|
39
|
+
* hidden and the chat is text-only.
|
|
40
|
+
*
|
|
41
|
+
* Called on every connect, so it starts by taking down the mic the last
|
|
42
|
+
* connection mounted, which was released when the element left.
|
|
43
|
+
*/
|
|
44
|
+
wire(): void;
|
|
45
|
+
/** Release the mic, so the browser's recording indicator clears. */
|
|
46
|
+
dispose(): void;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=composer_voice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer_voice.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/composer_voice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,gCAAgC,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,SAAS,CAAC;IAClC,kEAAkE;IAClE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,iBAAiB,GAAG,IAAI,CAAC;IAC3D,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7D,uEAAuE;IACvE,QAAQ,CAAC,iBAAiB,EAAE,MAAM;QAAE,WAAW,CAAC,EAAE,kBAAkB,CAAA;KAAE,CAAC;IACvE,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,qBAAa,aAAa;;IAKxB,YAAY,IAAI,EAAE,iBAAiB,EAElC;IAED;;;;;;;;;OASG;IACH,IAAI,IAAI,IAAI,CAcX;IAED,oEAAoE;IACpE,OAAO,IAAI,IAAI,CAEd;CAuBF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voice_input.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/voice_input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"voice_input.d.ts","sourceRoot":"","sources":["../../../src/ui/composer/voice_input.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAoBtE,mDAAmD;AACnD,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,yCAAyC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;CAC9B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,UAAU;;IACrB,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IAapC,YAAY,OAAO,EAAE,iBAAiB,EAmBrC;IAED,uEAAuE;IACjE,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAS5B;IA6CD;;;;;OAKG;IACH,OAAO,IAAI,IAAI,CAQd;CAiEF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { UiStrings } from "../ui_strings.js";
|
|
2
|
+
/** What the quote offer needs from the element that owns it. */
|
|
3
|
+
export interface TranscriptQuoteHost {
|
|
4
|
+
/** The custom element: its opt-out attribute, and what a page offer excludes. */
|
|
5
|
+
readonly element: HTMLElement;
|
|
6
|
+
/** The shadow root a transcript selection is read through. */
|
|
7
|
+
readonly root: ShadowRoot;
|
|
8
|
+
/** The transcript, whose selections are offered. */
|
|
9
|
+
readonly messages: HTMLElement;
|
|
10
|
+
/** The transcript's positioning box, which the offer floats inside. */
|
|
11
|
+
readonly messagesWrap: HTMLElement;
|
|
12
|
+
/** The composer a quotation is written into. */
|
|
13
|
+
readonly input: HTMLTextAreaElement;
|
|
14
|
+
/** The resolved string table. */
|
|
15
|
+
readonly strings: () => UiStrings;
|
|
16
|
+
/** Resize the composer to what it now holds. */
|
|
17
|
+
readonly autoGrow: () => void;
|
|
18
|
+
/** The element's public `quote`, so a host that replaced it is the one called. */
|
|
19
|
+
readonly quote: (text: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Quoting a selection into the composer: the offer floated beside a selection
|
|
23
|
+
* in the transcript, the same offer over the host page, and the quotation
|
|
24
|
+
* itself.
|
|
25
|
+
*
|
|
26
|
+
* Owned one-to-one by an `<ag-ui-chat>`, and holding no state outside the
|
|
27
|
+
* instance.
|
|
28
|
+
*/
|
|
29
|
+
export declare class TranscriptQuoteOffer {
|
|
30
|
+
#private;
|
|
31
|
+
/**
|
|
32
|
+
* Offer to quote the current selection, floated beside it.
|
|
33
|
+
*
|
|
34
|
+
* Shares the transcript's positioning box with the jump button for the same
|
|
35
|
+
* reason: it is positioned against the transcript, and must not scroll away
|
|
36
|
+
* with the words it is pointing at.
|
|
37
|
+
*/
|
|
38
|
+
readonly button: HTMLButtonElement;
|
|
39
|
+
constructor(host: TranscriptQuoteHost);
|
|
40
|
+
/** The quotation behind `AgUiChat.quote`, whose doc is the contract. */
|
|
41
|
+
insert(text: string): void;
|
|
42
|
+
/** The offer behind `AgUiChat.offerQuoteInPage`, whose doc is the contract. */
|
|
43
|
+
offerInPage(within: HTMLElement): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Take the host-page offer down. It listens on the host's document, not on
|
|
46
|
+
* anything of ours, so nothing else would ever take it down.
|
|
47
|
+
*/
|
|
48
|
+
detachPageOffer(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Build the offer and listen for settled selections in the transcript.
|
|
51
|
+
*
|
|
52
|
+
* The button and the transcript outlive a connection, so the listeners go
|
|
53
|
+
* under `signal`, which the element aborts when it leaves the document.
|
|
54
|
+
*/
|
|
55
|
+
mount(signal: AbortSignal): void;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=transcript_quote_offer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript_quote_offer.d.ts","sourceRoot":"","sources":["../../../src/ui/excerpts/transcript_quote_offer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAOlD,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;IACnC,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,SAAS,CAAC;IAClC,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAoB;;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAoC;IAQtE,YAAY,IAAI,EAAE,mBAAmB,EAEpC;IAED,wEAAwE;IACxE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgBzB;IAED,+EAA+E;IAC/E,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,IAAI,CAe3C;IAED;;;OAGG;IACH,eAAe,IAAI,IAAI,CAGtB;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAoC/B;CAsDF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fill the `{token}` placeholders of a string-table template.
|
|
3
|
+
*
|
|
4
|
+
* Every string-table template goes through here rather than through
|
|
5
|
+
* `template.replace("{token}", value)`, which was wrong in two ways at once:
|
|
6
|
+
*
|
|
7
|
+
* - **A string replacement interprets dollar patterns in the value.** `$&`
|
|
8
|
+
* inserts the matched token, and `` $` `` and `$'` the text either side of it,
|
|
9
|
+
* so a queued message reading `costs $& more` was labelled
|
|
10
|
+
* `Do not send "costs {text} more"`. Several of these values are text a user
|
|
11
|
+
* or a server wrote -- a queued message, a tool name, a skill title, an
|
|
12
|
+
* agent name -- so the value has to land verbatim. A replacer function's
|
|
13
|
+
* return value is never interpreted, which is the whole fix.
|
|
14
|
+
* - **A string pattern replaces only the first occurrence**, so a translation
|
|
15
|
+
* that uses a token twice was left half filled.
|
|
16
|
+
*
|
|
17
|
+
* One pass over the template, so a value that itself contains a `{token}` is
|
|
18
|
+
* inserted as written rather than filled in turn: a skill titled
|
|
19
|
+
* `Fill {fields}` stays that, where chained replacements filled it twice.
|
|
20
|
+
*
|
|
21
|
+
* A token with no entry in `values` is left as written. Every call site passes
|
|
22
|
+
* the tokens its key documents, so that is a translation carrying a token the
|
|
23
|
+
* call site does not know, and printing it is more honest than dropping it.
|
|
24
|
+
* `skills/fill_template.ts` is the prompt-side counterpart, and its contract is
|
|
25
|
+
* different on purpose: a prompt reports what it could not fill so a send can
|
|
26
|
+
* be refused.
|
|
27
|
+
*
|
|
28
|
+
* @param template - A string-table value, e.g. `strings.removeQueued`.
|
|
29
|
+
* @param values - The value for each token the template's key documents.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fillUiString(template: string, values: Readonly<Record<string, string | number>>): string;
|
|
32
|
+
//# sourceMappingURL=fill_ui_string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill_ui_string.d.ts","sourceRoot":"","sources":["../../src/ui/fill_ui_string.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,GAChD,MAAM,CAIR"}
|