@artooi/ag-ui-web-component 0.11.0 → 0.12.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 +35 -1
- package/README.md +55 -0
- package/dist/ag-ui-web-component.bundle.js +130 -54
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/run_index.d.ts +50 -0
- package/dist/core/run_index.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +351 -27
- package/dist/index.js.map +3 -3
- package/dist/ui/checkpoint_menu.d.ts +32 -0
- package/dist/ui/checkpoint_menu.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/ui_strings.d.ts +10 -0
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/ag_ui_chat.ts +91 -1
- package/src/core/run_index.ts +91 -0
- package/src/index.ts +2 -0
- package/src/ui/checkpoint_menu.ts +153 -0
- package/src/ui/styles.ts +76 -0
- package/src/ui/ui_strings.ts +15 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ag_ui_chat.d.ts","sourceRoot":"","sources":["../../src/core/ag_ui_chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAsB,IAAI,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAEL,YAAY,EAOb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,kCAAkC,CAAC;AAGvF,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;A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,eAAe,EAErC;IAED,iBAAiB,IAAI,IAAI;IAqCzB;;;;;;;OAOG;IACH,oBAAoB,IAAI,IAAI;IA2L5B;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI;IAsEzC,gFAAgF;IAChF,IAAI,SAAS,IAAI,OAAO,CAEvB;IAID,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAE3B;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAiBtC,qEAAqE;IACrE,eAAe,IAAI,IAAI;IAIvB;;;;;OAKG;IACH,WAAW,IAAI,IAAI;IA+BnB;;;OAGG;IACH,OAAO,IAAI,IAAI;IAsKf;;;;;;;;;;OAUG;IACH,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc;CAmsBlE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** One row of the server run index (django-ag-ui's `RunsView` wire shape). */
|
|
2
|
+
export interface RunRow {
|
|
3
|
+
readonly run_id: string;
|
|
4
|
+
readonly thread_id: string | null;
|
|
5
|
+
readonly parent_run_id: string | null;
|
|
6
|
+
readonly started_at: string | null;
|
|
7
|
+
/** Whether the run has a snapshot to seed from — see {@link RunIndex}. */
|
|
8
|
+
readonly continuable: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Live header source, read per request so rotated tokens / CSRF reach the server. */
|
|
11
|
+
type HeadersProvider = () => Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Reads the server's run index and derives the resume / fork URLs beside it.
|
|
14
|
+
*
|
|
15
|
+
* Backed by django-ag-ui's owner-scoped `RunsView` — the URL passed to
|
|
16
|
+
* `<ag-ui-chat>` as `data-runs-url`:
|
|
17
|
+
*
|
|
18
|
+
* - `GET <url>` → the user's runs, newest first.
|
|
19
|
+
*
|
|
20
|
+
* **Only `continuable` rows can be resumed.** The server reports whether a run
|
|
21
|
+
* has a saved snapshot to seed from; a run that never reached a provider-valid
|
|
22
|
+
* boundary has none, so resuming it would start from nothing. Callers should
|
|
23
|
+
* offer the action only for those rows and treat the rest as informational — a
|
|
24
|
+
* crashed run worth showing, not worth continuing. {@link continuable} filters
|
|
25
|
+
* for exactly that.
|
|
26
|
+
*
|
|
27
|
+
* **Resume and fork are siblings of the index**, not separate configuration.
|
|
28
|
+
* django-ag-ui mounts all three under one prefix whenever a step store is
|
|
29
|
+
* configured (`runs/`, `resume/<id>/`, `fork/<id>/`), so one URL locates them
|
|
30
|
+
* all and there is no way to configure a half-working set.
|
|
31
|
+
*/
|
|
32
|
+
export declare class RunIndex {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(url: string, headers?: HeadersProvider);
|
|
35
|
+
/**
|
|
36
|
+
* The user's runs, or `[]` when the endpoint is unreachable or answers with
|
|
37
|
+
* an error. A history affordance that cannot load is empty, never broken:
|
|
38
|
+
* the caller renders its empty state rather than surfacing a transport fault
|
|
39
|
+
* the user can do nothing about.
|
|
40
|
+
*/
|
|
41
|
+
list(): Promise<readonly RunRow[]>;
|
|
42
|
+
/** The rows a client may actually continue. */
|
|
43
|
+
continuable(): Promise<readonly RunRow[]>;
|
|
44
|
+
/** The endpoint that continues `runId` as a new run. */
|
|
45
|
+
resumeUrl(runId: string): string;
|
|
46
|
+
/** The endpoint that branches `runId` into a new run, leaving the source untouched. */
|
|
47
|
+
forkUrl(runId: string): string;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=run_index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_index.d.ts","sourceRoot":"","sources":["../../src/core/run_index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED,sFAAsF;AACtF,KAAK,eAAe,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,QAAQ;;gBAIP,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAA4B;IAK9D;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAgBxC,+CAA+C;IACzC,WAAW,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAI/C,wDAAwD;IACxD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIhC,uFAAuF;IACvF,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAe/B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { type ClientConversationStore, type NavigationCheckpoint, SessionStorage
|
|
|
6
6
|
export { type AgentFactory, createHttpAgent, type HttpAgentOptions, } from "./core/create_http_agent.js";
|
|
7
7
|
export { defineAgUiChat } from "./core/define_ag_ui_chat.js";
|
|
8
8
|
export { RemoteConversationStore } from "./core/remote_conversation_store.js";
|
|
9
|
+
export { RunIndex, type RunRow } from "./core/run_index.js";
|
|
9
10
|
export { type TranscribeHandler, type TranscribeOptions, transcribeAudio, } from "./core/transcribe_audio.js";
|
|
10
11
|
export { type UploadHandler, type UploadOptions, uploadAttachment, } from "./core/upload_attachment.js";
|
|
11
12
|
export { type FlashOptions, focusWithFlash, type HighlightClickOptions, highlightThenClick, type PressOptions, prefersReducedMotion, pressThenClick, type SelectOptions, scrollIntoCenterView, selectOption, type TextLikeElement, type ToggleOptions, type TypeOptions, toggleControl, typeInto, } from "./dom/animations.js";
|
|
@@ -21,6 +22,7 @@ export { parseToolCatalog, type ToolCatalogEntry } from "./tools/parse_tool_cata
|
|
|
21
22
|
export { createRouteTools, type Route, type RouteMap, type RouteWithParams, } from "./tools/route_map.js";
|
|
22
23
|
export { createStateHookTools, type StateHook } from "./tools/state_hook.js";
|
|
23
24
|
export { type ApprovalOptions, type ApprovalRenderer, type ApprovalRequest, requestApproval, } from "./ui/approval_card.js";
|
|
25
|
+
export { CheckpointMenu, type CheckpointVerb } from "./ui/checkpoint_menu.js";
|
|
24
26
|
export { type ConfirmationOptions, type ConfirmationRequest, requestConfirmation, } from "./ui/confirmation_card.js";
|
|
25
27
|
export { prettifyToolName } from "./ui/prettify_tool_name.js";
|
|
26
28
|
export { type QuestionOptions, type QuestionRenderer, type QuestionRequest, requestQuestion, } from "./ui/question_card.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,mBAAmB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Ac,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -451,6 +451,11 @@ var DEFAULT_UI_STRINGS = {
|
|
|
451
451
|
collapse: "Collapse",
|
|
452
452
|
expand: "Expand",
|
|
453
453
|
toggleTheme: "Toggle theme",
|
|
454
|
+
checkpoints: "Continue a run",
|
|
455
|
+
noCheckpoints: "Nothing to continue yet.",
|
|
456
|
+
resumeRun: "Resume",
|
|
457
|
+
forkRun: "Fork",
|
|
458
|
+
forkedRun: "branched",
|
|
454
459
|
conversation: "Conversation",
|
|
455
460
|
thinking: "Assistant is thinking\u2026",
|
|
456
461
|
thoughts: "Thoughts",
|
|
@@ -841,6 +846,138 @@ function accepts(accept, file) {
|
|
|
841
846
|
});
|
|
842
847
|
}
|
|
843
848
|
|
|
849
|
+
// src/ui/relative_time.ts
|
|
850
|
+
function relativeTime(timestamp, now = Date.now(), strings = DEFAULT_UI_STRINGS) {
|
|
851
|
+
if (!Number.isFinite(timestamp)) {
|
|
852
|
+
return strings.justNow;
|
|
853
|
+
}
|
|
854
|
+
const seconds = Math.round((now - timestamp) / 1e3);
|
|
855
|
+
if (seconds < 60) {
|
|
856
|
+
return strings.justNow;
|
|
857
|
+
}
|
|
858
|
+
const minutes = Math.round(seconds / 60);
|
|
859
|
+
if (minutes < 60) {
|
|
860
|
+
return strings.minutesAgo.replace("{n}", String(minutes));
|
|
861
|
+
}
|
|
862
|
+
const hours = Math.round(minutes / 60);
|
|
863
|
+
if (hours < 24) {
|
|
864
|
+
return strings.hoursAgo.replace("{n}", String(hours));
|
|
865
|
+
}
|
|
866
|
+
const days = Math.round(hours / 24);
|
|
867
|
+
if (days < 7) {
|
|
868
|
+
return strings.daysAgo.replace("{n}", String(days));
|
|
869
|
+
}
|
|
870
|
+
return strings.weeksAgo.replace("{n}", String(Math.round(days / 7)));
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// src/ui/checkpoint_menu.ts
|
|
874
|
+
var CheckpointMenu = class {
|
|
875
|
+
/** The panel root. Append to the chat shell; hidden until opened. */
|
|
876
|
+
element;
|
|
877
|
+
#onPick;
|
|
878
|
+
#list;
|
|
879
|
+
#heading;
|
|
880
|
+
#strings;
|
|
881
|
+
#runs = [];
|
|
882
|
+
constructor(onPick, strings = DEFAULT_UI_STRINGS) {
|
|
883
|
+
this.#onPick = onPick;
|
|
884
|
+
this.#strings = strings;
|
|
885
|
+
this.element = document.createElement("div");
|
|
886
|
+
this.element.className = "checkpoints";
|
|
887
|
+
this.element.setAttribute("part", "checkpoints");
|
|
888
|
+
this.element.setAttribute("role", "dialog");
|
|
889
|
+
this.element.setAttribute("aria-label", strings.checkpoints);
|
|
890
|
+
this.element.hidden = true;
|
|
891
|
+
const header = document.createElement("div");
|
|
892
|
+
header.className = "checkpoints-header";
|
|
893
|
+
header.setAttribute("part", "checkpoints-header");
|
|
894
|
+
this.#heading = document.createElement("span");
|
|
895
|
+
this.#heading.className = "checkpoints-title";
|
|
896
|
+
this.#heading.textContent = strings.checkpoints;
|
|
897
|
+
header.append(this.#heading);
|
|
898
|
+
this.#list = document.createElement("div");
|
|
899
|
+
this.#list.className = "checkpoints-list";
|
|
900
|
+
this.#list.setAttribute("part", "checkpoints-list");
|
|
901
|
+
this.element.append(header, this.#list);
|
|
902
|
+
this.element.addEventListener("keydown", (event) => {
|
|
903
|
+
if (event.key === "Escape") {
|
|
904
|
+
event.stopPropagation();
|
|
905
|
+
this.close();
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
/** Replace the rows. The host passes only `continuable` runs. */
|
|
910
|
+
setRuns(runs) {
|
|
911
|
+
this.#runs = runs;
|
|
912
|
+
this.#render();
|
|
913
|
+
}
|
|
914
|
+
/** Re-localize a panel built before the host's strings resolved. */
|
|
915
|
+
setStrings(strings) {
|
|
916
|
+
this.#strings = strings;
|
|
917
|
+
this.element.setAttribute("aria-label", strings.checkpoints);
|
|
918
|
+
this.#heading.textContent = strings.checkpoints;
|
|
919
|
+
this.#render();
|
|
920
|
+
}
|
|
921
|
+
open() {
|
|
922
|
+
this.element.hidden = false;
|
|
923
|
+
}
|
|
924
|
+
close() {
|
|
925
|
+
this.element.hidden = true;
|
|
926
|
+
}
|
|
927
|
+
get open_() {
|
|
928
|
+
return !this.element.hidden;
|
|
929
|
+
}
|
|
930
|
+
#render() {
|
|
931
|
+
this.#list.replaceChildren();
|
|
932
|
+
if (this.#runs.length === 0) {
|
|
933
|
+
const empty = document.createElement("div");
|
|
934
|
+
empty.className = "checkpoints-empty";
|
|
935
|
+
empty.setAttribute("part", "checkpoints-empty");
|
|
936
|
+
empty.textContent = this.#strings.noCheckpoints;
|
|
937
|
+
this.#list.append(empty);
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
for (const run of this.#runs) {
|
|
941
|
+
this.#list.append(this.#row(run));
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
#row(run) {
|
|
945
|
+
const row = document.createElement("div");
|
|
946
|
+
row.className = "checkpoint-row";
|
|
947
|
+
row.setAttribute("part", "checkpoint-row");
|
|
948
|
+
const label = document.createElement("span");
|
|
949
|
+
label.className = "checkpoint-label";
|
|
950
|
+
label.textContent = run.started_at === null ? run.run_id : relativeTime(Date.parse(run.started_at), Date.now(), this.#strings);
|
|
951
|
+
label.title = run.run_id;
|
|
952
|
+
row.append(label);
|
|
953
|
+
if (run.parent_run_id !== null) {
|
|
954
|
+
const branch = document.createElement("span");
|
|
955
|
+
branch.className = "checkpoint-branch";
|
|
956
|
+
branch.setAttribute("part", "checkpoint-branch");
|
|
957
|
+
branch.textContent = this.#strings.forkedRun;
|
|
958
|
+
branch.title = run.parent_run_id;
|
|
959
|
+
row.append(branch);
|
|
960
|
+
}
|
|
961
|
+
row.append(
|
|
962
|
+
this.#action(run.run_id, "resume", this.#strings.resumeRun),
|
|
963
|
+
this.#action(run.run_id, "fork", this.#strings.forkRun)
|
|
964
|
+
);
|
|
965
|
+
return row;
|
|
966
|
+
}
|
|
967
|
+
#action(runId, verb, label) {
|
|
968
|
+
const button = document.createElement("button");
|
|
969
|
+
button.type = "button";
|
|
970
|
+
button.className = `checkpoint-action checkpoint-${verb}`;
|
|
971
|
+
button.setAttribute("part", `checkpoint-action checkpoint-${verb}`);
|
|
972
|
+
button.textContent = label;
|
|
973
|
+
button.addEventListener("click", () => {
|
|
974
|
+
this.close();
|
|
975
|
+
this.#onPick(runId, verb);
|
|
976
|
+
});
|
|
977
|
+
return button;
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
|
|
844
981
|
// src/ui/confirmation_card.ts
|
|
845
982
|
function actionButton2(modifier, label) {
|
|
846
983
|
const button = document.createElement("button");
|
|
@@ -4952,6 +5089,82 @@ var STYLES = `
|
|
|
4952
5089
|
display: none;
|
|
4953
5090
|
}
|
|
4954
5091
|
|
|
5092
|
+
.checkpoints {
|
|
5093
|
+
position: absolute;
|
|
5094
|
+
inset-block-start: 3rem;
|
|
5095
|
+
inset-inline: 0.75rem;
|
|
5096
|
+
z-index: 6;
|
|
5097
|
+
display: flex;
|
|
5098
|
+
flex-direction: column;
|
|
5099
|
+
gap: 0.25rem;
|
|
5100
|
+
padding: 0.5rem;
|
|
5101
|
+
border: 1px solid var(--agui-border, #d7d7dc);
|
|
5102
|
+
border-radius: 0.5rem;
|
|
5103
|
+
background: var(--agui-surface, #fff);
|
|
5104
|
+
box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
|
|
5105
|
+
max-height: 60%;
|
|
5106
|
+
overflow-y: auto;
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5109
|
+
.checkpoints[hidden] {
|
|
5110
|
+
display: none;
|
|
5111
|
+
}
|
|
5112
|
+
|
|
5113
|
+
.checkpoints-title {
|
|
5114
|
+
font-size: 0.75rem;
|
|
5115
|
+
font-weight: 600;
|
|
5116
|
+
opacity: 0.7;
|
|
5117
|
+
}
|
|
5118
|
+
|
|
5119
|
+
.checkpoints-empty {
|
|
5120
|
+
padding: 0.5rem 0.25rem;
|
|
5121
|
+
font-size: 0.8125rem;
|
|
5122
|
+
opacity: 0.7;
|
|
5123
|
+
}
|
|
5124
|
+
|
|
5125
|
+
.checkpoint-row {
|
|
5126
|
+
display: flex;
|
|
5127
|
+
align-items: center;
|
|
5128
|
+
gap: 0.5rem;
|
|
5129
|
+
padding: 0.25rem;
|
|
5130
|
+
border-radius: 0.375rem;
|
|
5131
|
+
}
|
|
5132
|
+
|
|
5133
|
+
.checkpoint-row:hover {
|
|
5134
|
+
background: var(--agui-hover, #f3f3f5);
|
|
5135
|
+
}
|
|
5136
|
+
|
|
5137
|
+
.checkpoint-label {
|
|
5138
|
+
flex: 1;
|
|
5139
|
+
font-size: 0.8125rem;
|
|
5140
|
+
white-space: nowrap;
|
|
5141
|
+
overflow: hidden;
|
|
5142
|
+
text-overflow: ellipsis;
|
|
5143
|
+
}
|
|
5144
|
+
|
|
5145
|
+
.checkpoint-branch {
|
|
5146
|
+
font-size: 0.6875rem;
|
|
5147
|
+
padding: 0 0.375rem;
|
|
5148
|
+
border-radius: 999px;
|
|
5149
|
+
background: var(--agui-hover, #f3f3f5);
|
|
5150
|
+
opacity: 0.8;
|
|
5151
|
+
}
|
|
5152
|
+
|
|
5153
|
+
.checkpoint-action {
|
|
5154
|
+
font: inherit;
|
|
5155
|
+
font-size: 0.75rem;
|
|
5156
|
+
cursor: pointer;
|
|
5157
|
+
padding: 0.125rem 0.5rem;
|
|
5158
|
+
border: 1px solid var(--agui-border, #d7d7dc);
|
|
5159
|
+
border-radius: 0.375rem;
|
|
5160
|
+
background: transparent;
|
|
5161
|
+
color: inherit;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
.checkpoint-action:hover {
|
|
5165
|
+
background: var(--agui-hover, #f3f3f5);
|
|
5166
|
+
}
|
|
5167
|
+
|
|
4955
5168
|
.drawer-backdrop {
|
|
4956
5169
|
position: absolute;
|
|
4957
5170
|
inset: 0;
|
|
@@ -5182,30 +5395,6 @@ var ThoughtsBlock = class {
|
|
|
5182
5395
|
}
|
|
5183
5396
|
};
|
|
5184
5397
|
|
|
5185
|
-
// src/ui/relative_time.ts
|
|
5186
|
-
function relativeTime(timestamp, now = Date.now(), strings = DEFAULT_UI_STRINGS) {
|
|
5187
|
-
if (!Number.isFinite(timestamp)) {
|
|
5188
|
-
return strings.justNow;
|
|
5189
|
-
}
|
|
5190
|
-
const seconds = Math.round((now - timestamp) / 1e3);
|
|
5191
|
-
if (seconds < 60) {
|
|
5192
|
-
return strings.justNow;
|
|
5193
|
-
}
|
|
5194
|
-
const minutes = Math.round(seconds / 60);
|
|
5195
|
-
if (minutes < 60) {
|
|
5196
|
-
return strings.minutesAgo.replace("{n}", String(minutes));
|
|
5197
|
-
}
|
|
5198
|
-
const hours = Math.round(minutes / 60);
|
|
5199
|
-
if (hours < 24) {
|
|
5200
|
-
return strings.hoursAgo.replace("{n}", String(hours));
|
|
5201
|
-
}
|
|
5202
|
-
const days = Math.round(hours / 24);
|
|
5203
|
-
if (days < 7) {
|
|
5204
|
-
return strings.daysAgo.replace("{n}", String(days));
|
|
5205
|
-
}
|
|
5206
|
-
return strings.weeksAgo.replace("{n}", String(Math.round(days / 7)));
|
|
5207
|
-
}
|
|
5208
|
-
|
|
5209
5398
|
// src/ui/thread_drawer.ts
|
|
5210
5399
|
var ThreadDrawer = class {
|
|
5211
5400
|
/** The drawer root (backdrop + panel). Append to the chat shell; hidden until opened. */
|
|
@@ -6256,6 +6445,60 @@ var RemoteConversationStore = class {
|
|
|
6256
6445
|
}
|
|
6257
6446
|
};
|
|
6258
6447
|
|
|
6448
|
+
// src/core/run_index.ts
|
|
6449
|
+
var RunIndex = class {
|
|
6450
|
+
#url;
|
|
6451
|
+
#headers;
|
|
6452
|
+
constructor(url, headers = () => ({})) {
|
|
6453
|
+
this.#url = url.endsWith("/") ? url : `${url}/`;
|
|
6454
|
+
this.#headers = headers;
|
|
6455
|
+
}
|
|
6456
|
+
/**
|
|
6457
|
+
* The user's runs, or `[]` when the endpoint is unreachable or answers with
|
|
6458
|
+
* an error. A history affordance that cannot load is empty, never broken:
|
|
6459
|
+
* the caller renders its empty state rather than surfacing a transport fault
|
|
6460
|
+
* the user can do nothing about.
|
|
6461
|
+
*/
|
|
6462
|
+
async list() {
|
|
6463
|
+
try {
|
|
6464
|
+
const response = await fetch(this.#url, {
|
|
6465
|
+
method: "GET",
|
|
6466
|
+
headers: { Accept: "application/json", ...this.#headers() }
|
|
6467
|
+
});
|
|
6468
|
+
if (!response.ok) {
|
|
6469
|
+
return [];
|
|
6470
|
+
}
|
|
6471
|
+
const body = await response.json();
|
|
6472
|
+
return body.runs ?? [];
|
|
6473
|
+
} catch {
|
|
6474
|
+
return [];
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
/** The rows a client may actually continue. */
|
|
6478
|
+
async continuable() {
|
|
6479
|
+
return (await this.list()).filter((run) => run.continuable);
|
|
6480
|
+
}
|
|
6481
|
+
/** The endpoint that continues `runId` as a new run. */
|
|
6482
|
+
resumeUrl(runId) {
|
|
6483
|
+
return this.#sibling("resume", runId);
|
|
6484
|
+
}
|
|
6485
|
+
/** The endpoint that branches `runId` into a new run, leaving the source untouched. */
|
|
6486
|
+
forkUrl(runId) {
|
|
6487
|
+
return this.#sibling("fork", runId);
|
|
6488
|
+
}
|
|
6489
|
+
/**
|
|
6490
|
+
* `<mount>/<verb>/<runId>/`, derived from the index URL's own prefix.
|
|
6491
|
+
*
|
|
6492
|
+
* Built by string surgery on the trailing `runs/` rather than with `new URL`,
|
|
6493
|
+
* because the configured value may be root-relative (`/agent/runs/`) — the
|
|
6494
|
+
* common case in a Django template — and `new URL` needs an absolute base.
|
|
6495
|
+
*/
|
|
6496
|
+
#sibling(verb, runId) {
|
|
6497
|
+
const prefix = this.#url.slice(0, -"runs/".length);
|
|
6498
|
+
return `${prefix}${verb}/${encodeURIComponent(runId)}/`;
|
|
6499
|
+
}
|
|
6500
|
+
};
|
|
6501
|
+
|
|
6259
6502
|
// src/core/transcribe_audio.ts
|
|
6260
6503
|
async function transcribeAudio(audio, options) {
|
|
6261
6504
|
const form = new FormData();
|
|
@@ -6528,6 +6771,10 @@ var AgUiChat = class extends HTMLElement {
|
|
|
6528
6771
|
#title;
|
|
6529
6772
|
#skillsMenu;
|
|
6530
6773
|
#drawer;
|
|
6774
|
+
/** Checkpoint panel; rows load only when `data-runs-url` is set. */
|
|
6775
|
+
#checkpoints;
|
|
6776
|
+
/** Built lazily from `data-runs-url`; `null` when the host didn't opt in. */
|
|
6777
|
+
#runIndex = null;
|
|
6531
6778
|
#skillHint;
|
|
6532
6779
|
/** File-picker button + hidden input + tray slot; the tray mounts on connect. */
|
|
6533
6780
|
#attachButton;
|
|
@@ -6618,6 +6865,70 @@ var AgUiChat = class extends HTMLElement {
|
|
|
6618
6865
|
this.#deleteThread(threadId);
|
|
6619
6866
|
}
|
|
6620
6867
|
});
|
|
6868
|
+
this.#checkpoints = new CheckpointMenu((runId, verb) => {
|
|
6869
|
+
void this.#continueRun(runId, verb);
|
|
6870
|
+
});
|
|
6871
|
+
}
|
|
6872
|
+
/** The run index, built once from `data-runs-url`; `null` when unset. */
|
|
6873
|
+
#runs() {
|
|
6874
|
+
const url = this.getAttribute("data-runs-url");
|
|
6875
|
+
if (url === null || url === "") {
|
|
6876
|
+
return null;
|
|
6877
|
+
}
|
|
6878
|
+
if (this.#runIndex === null) {
|
|
6879
|
+
this.#runIndex = new RunIndex(url, () => this.headers);
|
|
6880
|
+
}
|
|
6881
|
+
return this.#runIndex;
|
|
6882
|
+
}
|
|
6883
|
+
/**
|
|
6884
|
+
* Continue `runId` as a **new** run, seeded server-side from its snapshot.
|
|
6885
|
+
*
|
|
6886
|
+
* Uses a short-lived agent pointed at the resume / fork endpoint and seeded
|
|
6887
|
+
* with **no** history, so the request carries only the turn typed here — the
|
|
6888
|
+
* contract those endpoints assume, since the server supplies the prior turns
|
|
6889
|
+
* from the snapshot and re-sending them would duplicate. Building a separate
|
|
6890
|
+
* agent makes that structural: the main agent keeps its own history, and
|
|
6891
|
+
* "only the new turn" can't be got wrong by forgetting to clear it. The
|
|
6892
|
+
* fresh `run_id` the endpoints also require comes free — a new agent mints
|
|
6893
|
+
* one per run.
|
|
6894
|
+
*
|
|
6895
|
+
* Handlers are the element's own, so the continuation streams into the same
|
|
6896
|
+
* transcript the user is looking at.
|
|
6897
|
+
*/
|
|
6898
|
+
async #continueRun(runId, verb) {
|
|
6899
|
+
const index = this.#runs();
|
|
6900
|
+
if (index === null) {
|
|
6901
|
+
return;
|
|
6902
|
+
}
|
|
6903
|
+
const content = this.#input.value.trim();
|
|
6904
|
+
if (content === "") {
|
|
6905
|
+
return;
|
|
6906
|
+
}
|
|
6907
|
+
this.#input.value = "";
|
|
6908
|
+
const endpoint = verb === "resume" ? index.resumeUrl(runId) : index.forkUrl(runId);
|
|
6909
|
+
const agent = this.agentFactory({
|
|
6910
|
+
endpoint,
|
|
6911
|
+
headers: this.headers,
|
|
6912
|
+
getHeaders: () => this.headers,
|
|
6913
|
+
threadId: this.#threadId,
|
|
6914
|
+
// The seed the endpoints assume: nothing. The snapshot is the history.
|
|
6915
|
+
initialMessages: []
|
|
6916
|
+
});
|
|
6917
|
+
const client = new AgUiClient({
|
|
6918
|
+
agent,
|
|
6919
|
+
handlers: this.#handlers(),
|
|
6920
|
+
getTools: () => this.getTools(),
|
|
6921
|
+
getContext: () => this.getContext(),
|
|
6922
|
+
executeTool: (call) => this.#executeTool(call),
|
|
6923
|
+
resolveInterrupts: (interrupts) => this.#resolveInterrupts(interrupts),
|
|
6924
|
+
connectionLostMessage: this.#strings.connectionLost
|
|
6925
|
+
});
|
|
6926
|
+
await client.send(content);
|
|
6927
|
+
}
|
|
6928
|
+
/** Load the checkpoint panel with the runs that can actually be continued. */
|
|
6929
|
+
async #refreshCheckpoints() {
|
|
6930
|
+
const index = this.#runs();
|
|
6931
|
+
this.#checkpoints.setRuns(index === null ? [] : await index.continuable());
|
|
6621
6932
|
}
|
|
6622
6933
|
/** Attributes whose late changes must reflect in already-rendered chrome. */
|
|
6623
6934
|
static get observedAttributes() {
|
|
@@ -6797,6 +7108,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
6797
7108
|
}
|
|
6798
7109
|
this.#render();
|
|
6799
7110
|
this.#drawer.setStrings(this.#strings);
|
|
7111
|
+
this.#checkpoints.setStrings(this.#strings);
|
|
6800
7112
|
if (this.#readScopedItem(COLLAPSED_KEY) === "1") {
|
|
6801
7113
|
this.setAttribute("collapsed", "");
|
|
6802
7114
|
}
|
|
@@ -7338,11 +7650,20 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
7338
7650
|
void this.#refreshDrawer();
|
|
7339
7651
|
this.#drawer.open();
|
|
7340
7652
|
});
|
|
7653
|
+
const checkpoints = this.#headerButton("checkpoints", this.#strings.checkpoints, "\u2B6F");
|
|
7654
|
+
checkpoints.addEventListener("click", () => {
|
|
7655
|
+
void this.#refreshCheckpoints();
|
|
7656
|
+
this.#checkpoints.open();
|
|
7657
|
+
});
|
|
7341
7658
|
const newChat = this.#headerButton("new", this.#strings.newChat, "\u271A");
|
|
7342
7659
|
newChat.addEventListener("click", () => this.newChat());
|
|
7343
7660
|
const collapse = this.#headerButton("collapse", this.#strings.collapse, "\u2014");
|
|
7344
7661
|
collapse.addEventListener("click", () => this.toggleCollapsed());
|
|
7345
|
-
|
|
7662
|
+
if (this.#runs() !== null) {
|
|
7663
|
+
controls.append(history, checkpoints, newChat);
|
|
7664
|
+
} else {
|
|
7665
|
+
controls.append(history, newChat);
|
|
7666
|
+
}
|
|
7346
7667
|
if (this.getAttribute("data-theme-toggle") !== null) {
|
|
7347
7668
|
this.#themeToggle.type = "button";
|
|
7348
7669
|
this.#themeToggle.className = "header-btn header-btn--theme";
|
|
@@ -7419,7 +7740,8 @@ Use the read_attachment tool with an id to read a file's contents.`
|
|
|
7419
7740
|
this.#attachSlot,
|
|
7420
7741
|
inputRow,
|
|
7421
7742
|
footer,
|
|
7422
|
-
this.#drawer.element
|
|
7743
|
+
this.#drawer.element,
|
|
7744
|
+
this.#checkpoints.element
|
|
7423
7745
|
);
|
|
7424
7746
|
this.#rail.className = "rail";
|
|
7425
7747
|
this.#rail.type = "button";
|
|
@@ -7870,10 +8192,11 @@ function setControlValue(el, value) {
|
|
|
7870
8192
|
}
|
|
7871
8193
|
|
|
7872
8194
|
// src/version.ts
|
|
7873
|
-
var VERSION = "0.
|
|
8195
|
+
var VERSION = "0.12.0";
|
|
7874
8196
|
export {
|
|
7875
8197
|
AgUiChat,
|
|
7876
8198
|
AgUiClient,
|
|
8199
|
+
CheckpointMenu,
|
|
7877
8200
|
ClientToolRegistry,
|
|
7878
8201
|
ConnectionLostError,
|
|
7879
8202
|
DEFAULT_UI_STRINGS,
|
|
@@ -7882,6 +8205,7 @@ export {
|
|
|
7882
8205
|
MESSAGE_ROLE,
|
|
7883
8206
|
PAGE_ACTIONS,
|
|
7884
8207
|
RemoteConversationStore,
|
|
8208
|
+
RunIndex,
|
|
7885
8209
|
SUBMIT_EVENT,
|
|
7886
8210
|
SessionStorageStore,
|
|
7887
8211
|
TOGGLE_EVENT,
|