@artooi/ag-ui-web-component 0.36.0 → 0.37.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 +66 -1
- package/README.md +9 -5
- package/dist/ag-ui-web-component.bundle.js +3 -3
- package/dist/ag-ui-web-component.bundle.js.map +3 -3
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/index.js +89 -31
- package/dist/index.js.map +2 -2
- package/dist/ui/ui_strings.d.ts +4 -0
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/ag_ui_chat.ts +118 -33
- package/src/ui/ui_strings.ts +6 -0
- package/src/version.ts +1 -1
package/dist/ui/ui_strings.d.ts
CHANGED
|
@@ -89,6 +89,10 @@ export interface UiStrings {
|
|
|
89
89
|
pageMoved: string;
|
|
90
90
|
/** Notice when Send ran while a file was still uploading. Token: `{n}`. */
|
|
91
91
|
attachmentsStillUploading: string;
|
|
92
|
+
/** Notice shown when a message was typed at an element with no `endpoint`. */
|
|
93
|
+
notConnected: string;
|
|
94
|
+
/** Composer hint when a run continuation was picked with an empty composer. */
|
|
95
|
+
continueNeedsTurn: string;
|
|
92
96
|
/** `aria-label` of the message textarea. */
|
|
93
97
|
message: string;
|
|
94
98
|
/** Placeholder of the message textarea. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui_strings.d.ts","sourceRoot":"","sources":["../../src/ui/ui_strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IAExB,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,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AE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,gBAAgB,EAAE,MAAM,CAAC;IAGzB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IAGnB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAGlB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,EAAE,SAmIhC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CASvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artooi/ag-ui-web-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Framework-free <ag-ui-chat> Web Component over the AG-UI protocol. Drop-in chat sidebar with a pluggable client-side tool registry, DOM driver primitives, animations, and destructive-action confirmation modal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/src/core/ag_ui_chat.ts
CHANGED
|
@@ -829,7 +829,17 @@ export class AgUiChat extends HTMLElement {
|
|
|
829
829
|
readonly #checkpoints: CheckpointMenu;
|
|
830
830
|
/** Built lazily from `data-runs-url`; `null` when the host didn't opt in. */
|
|
831
831
|
#runIndex: RunIndex | null = null;
|
|
832
|
-
|
|
832
|
+
/**
|
|
833
|
+
* The one-line hint above the composer, cleared by the next keystroke.
|
|
834
|
+
*
|
|
835
|
+
* Two things write it -- a skill whose template is short of a field, and a
|
|
836
|
+
* run continuation picked with nothing typed -- and both say the same kind of
|
|
837
|
+
* thing: what the composer still needs before this can go. Its `part` stays
|
|
838
|
+
* `skill-hint`, which the skills feature named and the README documents;
|
|
839
|
+
* renaming a part is breaking, and a second hint element in the same slot
|
|
840
|
+
* would be worse than one whose name is a release older than its job.
|
|
841
|
+
*/
|
|
842
|
+
readonly #composerHint: HTMLDivElement;
|
|
833
843
|
/** File-picker button + hidden input + tray slot; the tray mounts on connect. */
|
|
834
844
|
readonly #attachButton: HTMLButtonElement;
|
|
835
845
|
readonly #fileInput: HTMLInputElement;
|
|
@@ -1052,7 +1062,7 @@ export class AgUiChat extends HTMLElement {
|
|
|
1052
1062
|
this.#input = document.createElement("textarea");
|
|
1053
1063
|
this.#send = document.createElement("button");
|
|
1054
1064
|
this.#title = document.createElement("span");
|
|
1055
|
-
this.#
|
|
1065
|
+
this.#composerHint = document.createElement("div");
|
|
1056
1066
|
this.#attachButton = document.createElement("button");
|
|
1057
1067
|
this.#fileInput = document.createElement("input");
|
|
1058
1068
|
this.#attachSlot = document.createElement("div");
|
|
@@ -1144,10 +1154,29 @@ export class AgUiChat extends HTMLElement {
|
|
|
1144
1154
|
async #continueRun(runId: string, verb: CheckpointVerb): Promise<void> {
|
|
1145
1155
|
const index = this.#runs();
|
|
1146
1156
|
if (index === null) {
|
|
1157
|
+
// Unreachable from the built-in control: the header button is only
|
|
1158
|
+
// rendered when `#runs()` is configured, so a row to pick cannot exist
|
|
1159
|
+
// without one. A host calling `openCheckpoints()` regardless gets the
|
|
1160
|
+
// documented empty panel, which has no rows either. Typed, not silent.
|
|
1147
1161
|
return;
|
|
1148
1162
|
}
|
|
1149
1163
|
const content = this.#input.value.trim();
|
|
1150
1164
|
if (content === "") {
|
|
1165
|
+
// A continuation sends *only* the next turn -- the snapshot supplies
|
|
1166
|
+
// everything before it -- so with an empty composer there is nothing to
|
|
1167
|
+
// send. Returning here was the same failure the endpoint guard above had:
|
|
1168
|
+
// the row's button closes the panel before this runs, so the widget
|
|
1169
|
+
// visibly reacted and then did nothing, which reads as a resume that was
|
|
1170
|
+
// attempted and lost rather than one that never started.
|
|
1171
|
+
//
|
|
1172
|
+
// Said at the composer rather than in the transcript, because that is
|
|
1173
|
+
// where the fix goes and because the hint clears itself on the first
|
|
1174
|
+
// keystroke -- a transcript notice for a recoverable slip would outlive
|
|
1175
|
+
// the slip. Focus follows for the same reason `#applySkill` moves it when
|
|
1176
|
+
// a template is short of a field.
|
|
1177
|
+
this.#composerHint.textContent = this.#strings.continueNeedsTurn;
|
|
1178
|
+
this.#composerHint.hidden = false;
|
|
1179
|
+
this.#input.focus();
|
|
1151
1180
|
return;
|
|
1152
1181
|
}
|
|
1153
1182
|
this.#input.value = "";
|
|
@@ -1805,21 +1834,45 @@ export class AgUiChat extends HTMLElement {
|
|
|
1805
1834
|
return value !== null && value !== "false";
|
|
1806
1835
|
}
|
|
1807
1836
|
|
|
1808
|
-
/**
|
|
1809
|
-
|
|
1810
|
-
|
|
1837
|
+
/**
|
|
1838
|
+
* Parse a JSON-valued attribute, saying so when it will not parse.
|
|
1839
|
+
*
|
|
1840
|
+
* `null` for an absent attribute, and `null` again for one that is not JSON --
|
|
1841
|
+
* but not quietly the second time. Quoting JSON inside an HTML attribute is
|
|
1842
|
+
* fiddly, and the result of getting it wrong is indistinguishable from the
|
|
1843
|
+
* feature being switched off: no chips appear, or the strings stay English,
|
|
1844
|
+
* with nothing anywhere saying why. That is the same failure `data-paste-attach`
|
|
1845
|
+
* already reports for a value it cannot read.
|
|
1846
|
+
*
|
|
1847
|
+
* Console only. A page author's typo is not the reader's business, nothing the
|
|
1848
|
+
* reader did was refused, and the degraded widget is still perfectly usable.
|
|
1849
|
+
*/
|
|
1850
|
+
#readJsonAttribute(name: string): unknown {
|
|
1851
|
+
const raw = this.getAttribute(name);
|
|
1811
1852
|
if (raw === null) {
|
|
1812
|
-
return
|
|
1853
|
+
return null;
|
|
1813
1854
|
}
|
|
1814
1855
|
try {
|
|
1815
|
-
|
|
1816
|
-
if (typeof parsed === "object" && parsed !== null) {
|
|
1817
|
-
return parsed as Partial<UiStrings>;
|
|
1818
|
-
}
|
|
1856
|
+
return JSON.parse(raw);
|
|
1819
1857
|
} catch {
|
|
1820
|
-
|
|
1858
|
+
console.warn(
|
|
1859
|
+
`<ag-ui-chat>: ${name} is not valid JSON, so it was ignored entirely and ` +
|
|
1860
|
+
"the built-in default is being used. Check the quoting -- JSON inside " +
|
|
1861
|
+
"an HTML attribute needs single quotes around the attribute value, or " +
|
|
1862
|
+
"its own double quotes escaped.",
|
|
1863
|
+
);
|
|
1864
|
+
return null;
|
|
1821
1865
|
}
|
|
1822
|
-
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/** Parse the inline `data-strings` JSON overrides (empty when absent/malformed). */
|
|
1869
|
+
#readStringOverrides(): Partial<UiStrings> {
|
|
1870
|
+
const parsed = this.#readJsonAttribute("data-strings");
|
|
1871
|
+
// A JSON number or string parses fine and overrides nothing. Not warned
|
|
1872
|
+
// about separately: it is the same "this attribute did not take effect"
|
|
1873
|
+
// as a parse failure, and the warning above already covers the spelling
|
|
1874
|
+
// that produces it by accident.
|
|
1875
|
+
return typeof parsed === "object" && parsed !== null ? (parsed as Partial<UiStrings>) : {};
|
|
1823
1876
|
}
|
|
1824
1877
|
|
|
1825
1878
|
/**
|
|
@@ -2278,15 +2331,9 @@ export class AgUiChat extends HTMLElement {
|
|
|
2278
2331
|
|
|
2279
2332
|
/** Parse the inline `data-skills` JSON catalog (empty when absent/malformed). */
|
|
2280
2333
|
#readEmbeddedSkills(): readonly Skill[] {
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
}
|
|
2285
|
-
try {
|
|
2286
|
-
return parseSkills(JSON.parse(raw));
|
|
2287
|
-
} catch {
|
|
2288
|
-
return [];
|
|
2289
|
-
}
|
|
2334
|
+
// `parseSkills` drops anything that is not a well-formed skill, `null`
|
|
2335
|
+
// included, so the absent and unparseable cases need no branch here.
|
|
2336
|
+
return parseSkills(this.#readJsonAttribute("data-skills"));
|
|
2290
2337
|
}
|
|
2291
2338
|
|
|
2292
2339
|
/** Fetch the backend skills catalog from `data-skills-url`, if set. */
|
|
@@ -2329,7 +2376,7 @@ export class AgUiChat extends HTMLElement {
|
|
|
2329
2376
|
*/
|
|
2330
2377
|
#applySkill(skill: Skill): void {
|
|
2331
2378
|
if (skill.prompt === undefined) {
|
|
2332
|
-
this.#
|
|
2379
|
+
this.#composerHint.hidden = true;
|
|
2333
2380
|
void this.sendMessage(`/${skill.name}`);
|
|
2334
2381
|
return;
|
|
2335
2382
|
}
|
|
@@ -2341,17 +2388,17 @@ export class AgUiChat extends HTMLElement {
|
|
|
2341
2388
|
// keystroke replaces it. Blocking with a hint alone left whatever the
|
|
2342
2389
|
// user had typed to open the palette — a lone "/" — sitting there, which
|
|
2343
2390
|
// says nothing about what the skill wanted or how to give it.
|
|
2344
|
-
this.#
|
|
2391
|
+
this.#composerHint.textContent = this.#strings.skillNeeds
|
|
2345
2392
|
.replace("{title}", skill.title)
|
|
2346
2393
|
.replace("{fields}", missing.join(", "));
|
|
2347
|
-
this.#
|
|
2394
|
+
this.#composerHint.hidden = false;
|
|
2348
2395
|
this.#input.value = text;
|
|
2349
2396
|
this.#autoGrow();
|
|
2350
2397
|
this.#input.focus();
|
|
2351
2398
|
this.#selectFirstPlaceholder(text);
|
|
2352
2399
|
return;
|
|
2353
2400
|
}
|
|
2354
|
-
this.#
|
|
2401
|
+
this.#composerHint.hidden = true;
|
|
2355
2402
|
this.#input.value = text;
|
|
2356
2403
|
this.#autoGrow();
|
|
2357
2404
|
if (skill.sendImmediately === false) {
|
|
@@ -4318,9 +4365,9 @@ export class AgUiChat extends HTMLElement {
|
|
|
4318
4365
|
void this.#submit();
|
|
4319
4366
|
});
|
|
4320
4367
|
|
|
4321
|
-
this.#
|
|
4322
|
-
this.#
|
|
4323
|
-
this.#
|
|
4368
|
+
this.#composerHint.className = "skill-hint";
|
|
4369
|
+
this.#composerHint.setAttribute("part", "skill-hint");
|
|
4370
|
+
this.#composerHint.hidden = true;
|
|
4324
4371
|
|
|
4325
4372
|
// File-upload affordance: a paperclip button (hidden until
|
|
4326
4373
|
// `data-attachments-url` is wired) opening a hidden multi-file input.
|
|
@@ -4352,8 +4399,9 @@ export class AgUiChat extends HTMLElement {
|
|
|
4352
4399
|
tools.append(this.#attachButton, this.#voiceSlot, this.#send);
|
|
4353
4400
|
composer.append(this.#input, tools);
|
|
4354
4401
|
inputRow.append(composer, this.#fileInput);
|
|
4355
|
-
//
|
|
4356
|
-
// the
|
|
4402
|
+
// Composer surfaces sit just above the input: the skills palette (opens on
|
|
4403
|
+
// `/`), the chips, the hint saying what the composer still needs, and the
|
|
4404
|
+
// pending-attachments tray.
|
|
4357
4405
|
this.#messagesWrap.className = "messages-wrap";
|
|
4358
4406
|
// Sibling of the list inside a shared box, not a child of it: the
|
|
4359
4407
|
// affordance offering to scroll must not scroll away with the content.
|
|
@@ -4364,7 +4412,7 @@ export class AgUiChat extends HTMLElement {
|
|
|
4364
4412
|
this.#messagesWrap,
|
|
4365
4413
|
this.#skillsMenu.palette,
|
|
4366
4414
|
this.#skillsMenu.chips,
|
|
4367
|
-
this.#
|
|
4415
|
+
this.#composerHint,
|
|
4368
4416
|
this.#queuedRow,
|
|
4369
4417
|
this.#attachSlot,
|
|
4370
4418
|
inputRow,
|
|
@@ -4689,10 +4737,16 @@ export class AgUiChat extends HTMLElement {
|
|
|
4689
4737
|
this.#emptyWrap.hidden = this.#messages.childElementCount > 1;
|
|
4690
4738
|
}
|
|
4691
4739
|
|
|
4692
|
-
/**
|
|
4740
|
+
/**
|
|
4741
|
+
* Forward input changes to the skills palette and clear any stale hint.
|
|
4742
|
+
*
|
|
4743
|
+
* Typing is the answer to every hint that surface carries -- a skill short of
|
|
4744
|
+
* a field, a continuation short of its next turn -- so the keystroke that
|
|
4745
|
+
* starts answering it is the right moment to take it down.
|
|
4746
|
+
*/
|
|
4693
4747
|
#onInput(): void {
|
|
4694
4748
|
this.#skillsMenu.onInput(this.#input.value);
|
|
4695
|
-
this.#
|
|
4749
|
+
this.#composerHint.hidden = true;
|
|
4696
4750
|
this.#autoGrow();
|
|
4697
4751
|
// Typing puts the composer back in the user's hands: the next ArrowUp
|
|
4698
4752
|
// starts from the newest turn again rather than continuing a walk through
|
|
@@ -4992,8 +5046,39 @@ export class AgUiChat extends HTMLElement {
|
|
|
4992
5046
|
);
|
|
4993
5047
|
}
|
|
4994
5048
|
|
|
5049
|
+
/**
|
|
5050
|
+
* Hand the message to the client, or say why it is going nowhere.
|
|
5051
|
+
*
|
|
5052
|
+
* With no `endpoint` there is nothing to send to, and this used to return
|
|
5053
|
+
* here in silence. That is the worst shape the failure can take, because the
|
|
5054
|
+
* two halves of a send that *did* work have already happened by now: the
|
|
5055
|
+
* user's bubble is on screen and {@link SUBMIT_EVENT} has been dispatched. So
|
|
5056
|
+
* the message looks sent, the composer is empty, the Send button never turns
|
|
5057
|
+
* into Stop, and no request is ever made -- an unanswered question rather
|
|
5058
|
+
* than a broken widget. Nothing reached the console either, so the developer
|
|
5059
|
+
* had no thread to pull and the user had no reason to think anything was
|
|
5060
|
+
* wrong with the page.
|
|
5061
|
+
*
|
|
5062
|
+
* Both audiences are told, because they need different things. The console
|
|
5063
|
+
* carries the developer's version -- the attribute is missing, here is what
|
|
5064
|
+
* to set -- since a missing attribute is a page's mistake and not the
|
|
5065
|
+
* reader's. The transcript carries the reader's, because they are looking at
|
|
5066
|
+
* their own message waiting for a reply that cannot come, and the honest
|
|
5067
|
+
* alternative to one muted line is an indefinite wait.
|
|
5068
|
+
*
|
|
5069
|
+
* Said on every attempt rather than once. Each send is a separate thing the
|
|
5070
|
+
* user asked for and did not get, and a once-only report is silence for every
|
|
5071
|
+
* attempt after the first -- which is the defect again, just later.
|
|
5072
|
+
*/
|
|
4995
5073
|
async #client_send(content: string, attachments: readonly AttachmentRef[]): Promise<void> {
|
|
4996
5074
|
if (this.endpoint === "") {
|
|
5075
|
+
console.error(
|
|
5076
|
+
"<ag-ui-chat>: no endpoint is set, so this message was not sent and no " +
|
|
5077
|
+
"request was made. Point the element at your AG-UI mount with the " +
|
|
5078
|
+
'endpoint attribute (endpoint="/agent/"), or assign chat.endpoint ' +
|
|
5079
|
+
"before sending.",
|
|
5080
|
+
);
|
|
5081
|
+
this.#appendNotice("⚠", this.#strings.notConnected, "not-connected");
|
|
4997
5082
|
return;
|
|
4998
5083
|
}
|
|
4999
5084
|
await this.#ensureClient().send(content, attachments);
|
package/src/ui/ui_strings.ts
CHANGED
|
@@ -92,6 +92,10 @@ export interface UiStrings {
|
|
|
92
92
|
pageMoved: string;
|
|
93
93
|
/** Notice when Send ran while a file was still uploading. Token: `{n}`. */
|
|
94
94
|
attachmentsStillUploading: string;
|
|
95
|
+
/** Notice shown when a message was typed at an element with no `endpoint`. */
|
|
96
|
+
notConnected: string;
|
|
97
|
+
/** Composer hint when a run continuation was picked with an empty composer. */
|
|
98
|
+
continueNeedsTurn: string;
|
|
95
99
|
|
|
96
100
|
// ── Composer ────────────────────────────────────────────────────────────────
|
|
97
101
|
/** `aria-label` of the message textarea. */
|
|
@@ -347,6 +351,8 @@ export const DEFAULT_UI_STRINGS: UiStrings = {
|
|
|
347
351
|
"The page changed since you last looked at it. Call read_page to see the current page, then retry.",
|
|
348
352
|
attachmentsStillUploading:
|
|
349
353
|
"{n} file still uploading — it was not sent with this message and is still attached.",
|
|
354
|
+
notConnected: "This chat isn’t connected to an agent, so the message wasn’t sent.",
|
|
355
|
+
continueNeedsTurn: "Type the next turn in the composer first, then pick a run to continue.",
|
|
350
356
|
skillNeeds: "“{title}” needs {fields} — fill it in below, then send.",
|
|
351
357
|
|
|
352
358
|
message: "Message",
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION: string = "0.
|
|
1
|
+
export const VERSION: string = "0.37.0";
|