@artooi/ag-ui-web-component 0.42.0 → 0.44.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 +161 -1
- package/README.md +88 -22
- package/dist/ag-ui-web-component.bundle.js +74 -74
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +12 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts +36 -8
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +27 -2
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/core/events/feedback_detail.d.ts +21 -0
- package/dist/core/events/feedback_detail.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +317 -139
- package/dist/index.js.map +4 -4
- package/dist/tools/tool_dispatch.d.ts +11 -1
- package/dist/tools/tool_dispatch.d.ts.map +1 -1
- package/dist/ui/composer/voice_input.d.ts +2 -2
- package/dist/ui/composer/voice_input.d.ts.map +1 -1
- package/dist/ui/history/conversation_history.d.ts +40 -24
- package/dist/ui/history/conversation_history.d.ts.map +1 -1
- package/dist/ui/transcript/answer_actions.d.ts +12 -3
- package/dist/ui/transcript/answer_actions.d.ts.map +1 -1
- package/dist/ui/ui_strings.d.ts +5 -0
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +12 -4
- package/src/core/ag_ui_chat.ts +127 -35
- package/src/core/agui_client.ts +43 -3
- package/src/core/events/feedback_detail.ts +21 -0
- package/src/core/run_handlers.ts +2 -2
- package/src/index.ts +1 -0
- package/src/tools/tool_dispatch.ts +40 -4
- package/src/ui/composer/voice_input.ts +57 -23
- package/src/ui/history/conversation_history.ts +117 -35
- package/src/ui/transcript/answer_actions.ts +31 -3
- package/src/ui/ui_strings.ts +6 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -987,6 +987,7 @@ var DEFAULT_UI_STRINGS = {
|
|
|
987
987
|
notConnected: "This chat isn\u2019t connected to an agent, so the message wasn\u2019t sent.",
|
|
988
988
|
continueNeedsTurn: "Type the next turn in the composer first, then pick a run to continue.",
|
|
989
989
|
continueWhileRunning: "Wait for the current answer or stop it, then pick a run to continue.",
|
|
990
|
+
continueWhileLoading: "Wait for the conversation to finish loading, then pick a run to continue.",
|
|
990
991
|
skillNeeds: "\u201C{title}\u201D needs {fields} \u2014 fill it in below, then send.",
|
|
991
992
|
message: "Message",
|
|
992
993
|
inputPlaceholder: "Ask anything\u2026",
|
|
@@ -1736,13 +1737,17 @@ var ToolDispatch = class {
|
|
|
1736
1737
|
* check that it has not. A Stop while the host's predicate is pending ends
|
|
1737
1738
|
* the call there, and one while the card is open declines it. A handover
|
|
1738
1739
|
* during any of the three leaves the call with no transcript to draw in and
|
|
1739
|
-
* no store to write to, so it does neither.
|
|
1740
|
+
* no store to write to, so it does neither. Any other reset of the
|
|
1741
|
+
* conversation -- New chat, a drawer switch, `reload()` -- leaves the call
|
|
1742
|
+
* its store and its result but not the transcript, so it still settles and
|
|
1743
|
+
* returns, and does not show the run waiting in a conversation it is not in.
|
|
1740
1744
|
*/
|
|
1741
1745
|
async execute(call) {
|
|
1742
1746
|
if (skillNameFrom(call) !== null) {
|
|
1743
1747
|
return null;
|
|
1744
1748
|
}
|
|
1745
1749
|
const tenure = this.#host.tenure();
|
|
1750
|
+
const conversation = this.#host.conversation();
|
|
1746
1751
|
const threadId = this.#host.threadId();
|
|
1747
1752
|
const card = this.#host.transcript.cardFor(call);
|
|
1748
1753
|
this.#host.transcript.forgetCard(call.id);
|
|
@@ -1796,7 +1801,9 @@ var ToolDispatch = class {
|
|
|
1796
1801
|
if (!accepted) {
|
|
1797
1802
|
const message = this.#host.strings().declinedAction;
|
|
1798
1803
|
card.settle(TOOL_CALL_STATUS.DECLINED, message);
|
|
1799
|
-
this.#host.
|
|
1804
|
+
if (this.#host.conversation() === conversation) {
|
|
1805
|
+
this.#host.transcript.showPending();
|
|
1806
|
+
}
|
|
1800
1807
|
return { content: message, outcome: TOOL_OUTCOME.DENIED };
|
|
1801
1808
|
}
|
|
1802
1809
|
if (signal.aborted) {
|
|
@@ -1821,7 +1828,9 @@ var ToolDispatch = class {
|
|
|
1821
1828
|
}
|
|
1822
1829
|
const content = JSON.stringify(result ?? null);
|
|
1823
1830
|
card.settle(TOOL_CALL_STATUS.DONE, content);
|
|
1824
|
-
this.#host.
|
|
1831
|
+
if (this.#host.conversation() === conversation) {
|
|
1832
|
+
this.#host.transcript.showPending();
|
|
1833
|
+
}
|
|
1825
1834
|
return { content };
|
|
1826
1835
|
} catch (error) {
|
|
1827
1836
|
if (this.#host.tenure() !== tenure) {
|
|
@@ -1832,7 +1841,9 @@ var ToolDispatch = class {
|
|
|
1832
1841
|
}
|
|
1833
1842
|
const message = error instanceof Error ? error.message : String(error);
|
|
1834
1843
|
card.settle(TOOL_CALL_STATUS.ERROR, message);
|
|
1835
|
-
this.#host.
|
|
1844
|
+
if (this.#host.conversation() === conversation) {
|
|
1845
|
+
this.#host.transcript.showPending();
|
|
1846
|
+
}
|
|
1836
1847
|
return { content: `Error: ${message}`, error: message, outcome: TOOL_OUTCOME.FAILED };
|
|
1837
1848
|
}
|
|
1838
1849
|
}
|
|
@@ -3073,6 +3084,8 @@ var VoiceInput = class {
|
|
|
3073
3084
|
#capTimer = null;
|
|
3074
3085
|
#hitCap = false;
|
|
3075
3086
|
#disposed = false;
|
|
3087
|
+
/** Identifies the newest start; an older one that settles is stale. */
|
|
3088
|
+
#startToken = {};
|
|
3076
3089
|
constructor(options) {
|
|
3077
3090
|
this.#transcribe = options.transcribe;
|
|
3078
3091
|
this.#onText = options.onText;
|
|
@@ -3102,31 +3115,42 @@ var VoiceInput = class {
|
|
|
3102
3115
|
await this.#start();
|
|
3103
3116
|
}
|
|
3104
3117
|
async #start() {
|
|
3118
|
+
const token = {};
|
|
3119
|
+
this.#startToken = token;
|
|
3105
3120
|
let stream;
|
|
3106
3121
|
try {
|
|
3107
3122
|
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
3108
3123
|
} catch {
|
|
3109
|
-
|
|
3110
|
-
return;
|
|
3124
|
+
stream = null;
|
|
3111
3125
|
}
|
|
3112
|
-
if (this.#disposed) {
|
|
3113
|
-
for (const track of stream
|
|
3126
|
+
if (token !== this.#startToken || this.#disposed) {
|
|
3127
|
+
for (const track of stream?.getTracks() ?? []) {
|
|
3114
3128
|
track.stop();
|
|
3115
3129
|
}
|
|
3116
3130
|
return;
|
|
3117
3131
|
}
|
|
3132
|
+
if (stream === null) {
|
|
3133
|
+
this.#fail(this.#strings.transcriptionFailed);
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3118
3136
|
this.#stream = stream;
|
|
3119
3137
|
this.#chunks = [];
|
|
3120
3138
|
this.#hitCap = false;
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3139
|
+
let recorder;
|
|
3140
|
+
try {
|
|
3141
|
+
recorder = new MediaRecorder(stream);
|
|
3142
|
+
recorder.addEventListener("dataavailable", (event) => {
|
|
3143
|
+
this.#chunks.push(event.data);
|
|
3144
|
+
});
|
|
3145
|
+
recorder.addEventListener("stop", () => {
|
|
3146
|
+
void this.#finish(recorder.mimeType);
|
|
3147
|
+
});
|
|
3148
|
+
this.#recorder = recorder;
|
|
3149
|
+
recorder.start();
|
|
3150
|
+
} catch {
|
|
3151
|
+
this.#fail(this.#strings.transcriptionFailed);
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3130
3154
|
this.#capTimer = setTimeout(() => {
|
|
3131
3155
|
this.#hitCap = true;
|
|
3132
3156
|
this.#stop();
|
|
@@ -3152,8 +3176,8 @@ var VoiceInput = class {
|
|
|
3152
3176
|
* a detached element.
|
|
3153
3177
|
*
|
|
3154
3178
|
* Disposal is final: nothing un-disposes an instance, and the host's next
|
|
3155
|
-
* wiring builds a new one. So the disposed flag alone tells a
|
|
3156
|
-
*
|
|
3179
|
+
* wiring builds a new one. So the disposed flag alone tells a continuation
|
|
3180
|
+
* that outlived the control from a live one, and a clip already posted when this runs is
|
|
3157
3181
|
* dropped whenever its answer arrives.
|
|
3158
3182
|
*/
|
|
3159
3183
|
dispose() {
|
|
@@ -4166,8 +4190,6 @@ function toolStatusFromOutcome(outcome) {
|
|
|
4166
4190
|
}
|
|
4167
4191
|
|
|
4168
4192
|
// src/ui/history/conversation_history.ts
|
|
4169
|
-
var UNHELD = Object.freeze({ release: () => {
|
|
4170
|
-
} });
|
|
4171
4193
|
var ConversationHistory = class {
|
|
4172
4194
|
#host;
|
|
4173
4195
|
/** The active thread's id. Empty until the element connects. */
|
|
@@ -4204,6 +4226,17 @@ var ConversationHistory = class {
|
|
|
4204
4226
|
* reaches it. `null` when none is running.
|
|
4205
4227
|
*/
|
|
4206
4228
|
#continuation = null;
|
|
4229
|
+
/**
|
|
4230
|
+
* Settles what a host's send waits on while the restore now current, one
|
|
4231
|
+
* with no run to resume, loads and replays; `null` when no such restore is
|
|
4232
|
+
* under way. Called when that restore ends, and as soon as it is stopped by
|
|
4233
|
+
* anything that moves the generation, so a send waiting on a conversation
|
|
4234
|
+
* that is no longer on screen hears so at once rather than when an
|
|
4235
|
+
* abandoned load answers.
|
|
4236
|
+
*
|
|
4237
|
+
* Also what tells a pick refused for a load from one refused for a run.
|
|
4238
|
+
*/
|
|
4239
|
+
#loading = null;
|
|
4207
4240
|
constructor(host) {
|
|
4208
4241
|
this.#host = host;
|
|
4209
4242
|
}
|
|
@@ -4245,6 +4278,13 @@ var ConversationHistory = class {
|
|
|
4245
4278
|
this.#restored = [];
|
|
4246
4279
|
this.#cleared += 1;
|
|
4247
4280
|
this.#generation += 1;
|
|
4281
|
+
this.#endWait();
|
|
4282
|
+
}
|
|
4283
|
+
/** Settle what waits on the restore now loading, if anything does, and forget it. */
|
|
4284
|
+
#endWait() {
|
|
4285
|
+
const end = this.#loading;
|
|
4286
|
+
this.#loading = null;
|
|
4287
|
+
end?.();
|
|
4248
4288
|
}
|
|
4249
4289
|
/** Delete the active thread if nothing was ever sent in it. */
|
|
4250
4290
|
reapUnsent() {
|
|
@@ -4349,7 +4389,10 @@ var ConversationHistory = class {
|
|
|
4349
4389
|
return;
|
|
4350
4390
|
}
|
|
4351
4391
|
if (this.#host.running() || this.#continuation !== null) {
|
|
4352
|
-
this.#
|
|
4392
|
+
const strings = this.#host.strings();
|
|
4393
|
+
this.#refuse(
|
|
4394
|
+
this.#loading === null ? strings.continueWhileRunning : strings.continueWhileLoading
|
|
4395
|
+
);
|
|
4353
4396
|
return;
|
|
4354
4397
|
}
|
|
4355
4398
|
const content = this.#host.input.value.trim();
|
|
@@ -4435,16 +4478,30 @@ var ConversationHistory = class {
|
|
|
4435
4478
|
* exclusion is held by "resumes with the landed page's result, and its card says
|
|
4436
4479
|
* so" in `ag_ui_chat_reload_mid_run.test.ts`.
|
|
4437
4480
|
*
|
|
4438
|
-
* **
|
|
4439
|
-
*
|
|
4440
|
-
* remote store that is a real request, and a send, a Retry or a pick
|
|
4441
|
-
* was refused by nothing: each built the conversation's client before
|
|
4442
|
-
* conversation had loaded, so a send went out carrying none of it
|
|
4443
|
-
* first save replaced the stored one, and the
|
|
4444
|
-
*
|
|
4445
|
-
*
|
|
4446
|
-
*
|
|
4447
|
-
*
|
|
4481
|
+
* **Every restore holds the composer from before the load.** Until the
|
|
4482
|
+
* store answers, the conversation's client can only be seeded from nothing.
|
|
4483
|
+
* With a remote store that is a real request, and a send, a Retry or a pick
|
|
4484
|
+
* in it was refused by nothing: each built the conversation's client before
|
|
4485
|
+
* the conversation had loaded, so a send went out carrying none of it, its
|
|
4486
|
+
* first save replaced the stored one, and the replay then drew the stored
|
|
4487
|
+
* conversation under the new turn. The client stayed cached without it, so
|
|
4488
|
+
* every later turn went out without it too. So the composer is held as a
|
|
4489
|
+
* send holds it: what was typed parks and goes out after the replay, and a
|
|
4490
|
+
* Retry and a pick are refused -- a Retry has nothing on screen to retry, and
|
|
4491
|
+
* after the load it would re-ask the previous visit's last question.
|
|
4492
|
+
*
|
|
4493
|
+
* **A host's send waits for a restore with no run to resume.** It is
|
|
4494
|
+
* usually a prompt fired as the element mounts, which no host could time
|
|
4495
|
+
* against a load nothing announces, and refusing it would lose the turn.
|
|
4496
|
+
* So it waits for this restore to end, taking the hold over as it does,
|
|
4497
|
+
* and then sends with the conversation drawn above it; what the built-in
|
|
4498
|
+
* Send parked goes out after its run. Stopped while it waits, it is dropped,
|
|
4499
|
+
* as a send stopped by its own submit listener is.
|
|
4500
|
+
*
|
|
4501
|
+
* **A restore that resumes refuses a host's send instead.** The resume is a
|
|
4502
|
+
* run, and the restore ends by starting it, so a send that waited would only
|
|
4503
|
+
* reach that run and be refused there. The resume gives way to nothing: what
|
|
4504
|
+
* was typed parks behind the resumed run and goes out after its answer.
|
|
4448
4505
|
*
|
|
4449
4506
|
* The other way round, the resume standing down for the send, was rejected.
|
|
4450
4507
|
* The send that got in first had already gone out without the conversation,
|
|
@@ -4457,8 +4514,8 @@ var ConversationHistory = class {
|
|
|
4457
4514
|
* page can each come while the store answers, and from host code the restore
|
|
4458
4515
|
* runs itself: the activity and tool renderers each replayed message draws
|
|
4459
4516
|
* through, and `navigationResult`. From then on it draws nothing more and
|
|
4460
|
-
* resumes nothing. The hold cannot say so, because a
|
|
4461
|
-
*
|
|
4517
|
+
* resumes nothing. The hold cannot say so, because a host's send that
|
|
4518
|
+
* waited may hold it by then. So the restore asks its generation, which clearing
|
|
4462
4519
|
* the conversation moves on as a newer restore does, and asks it after the
|
|
4463
4520
|
* load, after each replayed message -- as a Retry asks after each one -- and
|
|
4464
4521
|
* once more before the resume. Stopped by anything but the element leaving
|
|
@@ -4466,10 +4523,6 @@ var ConversationHistory = class {
|
|
|
4466
4523
|
* for the run it would have resumed -- unless what replaced it is a restore
|
|
4467
4524
|
* of the same conversation, still current, which answers for that run
|
|
4468
4525
|
* instead; see `#forgetStopped`.
|
|
4469
|
-
*
|
|
4470
|
-
* What a restore with no run to resume still does not do is refuse a send
|
|
4471
|
-
* made while it loads. That send goes out without the stored conversation,
|
|
4472
|
-
* and its save replaces it.
|
|
4473
4526
|
*/
|
|
4474
4527
|
async rehydrate() {
|
|
4475
4528
|
this.#generation += 1;
|
|
@@ -4478,7 +4531,11 @@ var ConversationHistory = class {
|
|
|
4478
4531
|
const store = this.#host.conversationStore();
|
|
4479
4532
|
this.#claim = { generation, store, threadId };
|
|
4480
4533
|
const checkpoint = store.loadCheckpoint(threadId);
|
|
4481
|
-
const
|
|
4534
|
+
const restored = checkpoint === null ? new Promise((resolve) => {
|
|
4535
|
+
this.#loading = resolve;
|
|
4536
|
+
}) : null;
|
|
4537
|
+
const waiting = this.#loading;
|
|
4538
|
+
const hold = this.#host.holdRun(restored);
|
|
4482
4539
|
try {
|
|
4483
4540
|
this.#host.element.setAttribute("data-restoring", "");
|
|
4484
4541
|
let messages;
|
|
@@ -4495,7 +4552,7 @@ var ConversationHistory = class {
|
|
|
4495
4552
|
}
|
|
4496
4553
|
if (messages !== null) {
|
|
4497
4554
|
const unfinished = this.#host.strings().callNotFinished;
|
|
4498
|
-
const
|
|
4555
|
+
const restored2 = answerUnansweredCalls(
|
|
4499
4556
|
messages,
|
|
4500
4557
|
// The shape the store holds for a call the client answered the same
|
|
4501
4558
|
// way: its tool message, with the outcome in its metadata.
|
|
@@ -4508,8 +4565,8 @@ var ConversationHistory = class {
|
|
|
4508
4565
|
}),
|
|
4509
4566
|
new Set(checkpoint === null ? [] : [checkpoint.toolCallId])
|
|
4510
4567
|
);
|
|
4511
|
-
this.#restored =
|
|
4512
|
-
for (const message of
|
|
4568
|
+
this.#restored = restored2;
|
|
4569
|
+
for (const message of restored2) {
|
|
4513
4570
|
this.replay(message);
|
|
4514
4571
|
if (!this.#restoring(generation)) {
|
|
4515
4572
|
this.#forgetStopped(store, threadId, checkpoint);
|
|
@@ -4524,6 +4581,9 @@ var ConversationHistory = class {
|
|
|
4524
4581
|
this.#noticeIfRunUnfinished(messages);
|
|
4525
4582
|
} finally {
|
|
4526
4583
|
hold.release();
|
|
4584
|
+
if (this.#loading === waiting) {
|
|
4585
|
+
this.#endWait();
|
|
4586
|
+
}
|
|
4527
4587
|
}
|
|
4528
4588
|
}
|
|
4529
4589
|
/**
|
|
@@ -4670,7 +4730,11 @@ var ConversationHistory = class {
|
|
|
4670
4730
|
if (text4 !== "") {
|
|
4671
4731
|
const restoredBubble = this.#host.appendMessage(MESSAGE_ROLE.ASSISTANT, text4);
|
|
4672
4732
|
restoredBubble.classList.add("message--restored");
|
|
4673
|
-
|
|
4733
|
+
const id = message.id;
|
|
4734
|
+
this.#host.actions.attach(
|
|
4735
|
+
restoredBubble,
|
|
4736
|
+
typeof id === "string" && id !== "" ? { messageId: id } : { rateable: false }
|
|
4737
|
+
);
|
|
4674
4738
|
}
|
|
4675
4739
|
for (const call of restoredToolCalls(message.toolCalls)) {
|
|
4676
4740
|
const restored = {
|
|
@@ -10956,11 +11020,16 @@ var AnswerActions = class {
|
|
|
10956
11020
|
* something survives to go in it: an empty row still takes its margin, still
|
|
10957
11021
|
* answers to the `message-actions` part, and still reads to a screen reader
|
|
10958
11022
|
* as a group of actions with none in it.
|
|
11023
|
+
*
|
|
11024
|
+
* `message` names the answer, which is what a rating is filed under; a bubble
|
|
11025
|
+
* that is not an answer says so instead, and has no id to give.
|
|
10959
11026
|
*/
|
|
10960
|
-
attach(bubble,
|
|
11027
|
+
attach(bubble, message) {
|
|
10961
11028
|
const enabled = this.#enabled();
|
|
10962
11029
|
const copyable = enabled.has(MESSAGE_ACTIONS.COPY);
|
|
10963
|
-
const
|
|
11030
|
+
const answer = "messageId" in message ? message : null;
|
|
11031
|
+
const rateable = answer !== null && enabled.has(MESSAGE_ACTIONS.FEEDBACK);
|
|
11032
|
+
const threadId = this.#host.threadId();
|
|
10964
11033
|
if (copyable || rateable) {
|
|
10965
11034
|
attachMessageActions(bubble, {
|
|
10966
11035
|
strings: this.#host.strings(),
|
|
@@ -10977,7 +11046,16 @@ var AnswerActions = class {
|
|
|
10977
11046
|
onFeedback: (rating) => {
|
|
10978
11047
|
this.#host.element.dispatchEvent(
|
|
10979
11048
|
new CustomEvent(FEEDBACK_EVENT, {
|
|
10980
|
-
detail: {
|
|
11049
|
+
detail: {
|
|
11050
|
+
content: copyPayload(bubble).text,
|
|
11051
|
+
rating,
|
|
11052
|
+
messageId: answer.messageId,
|
|
11053
|
+
threadId,
|
|
11054
|
+
// Omitted rather than undefined: a restored message has
|
|
11055
|
+
// no run, and a key holding nothing reads as one that
|
|
11056
|
+
// was looked up and came back empty.
|
|
11057
|
+
...answer.runId === void 0 ? {} : { runId: answer.runId }
|
|
11058
|
+
},
|
|
10981
11059
|
bubbles: true,
|
|
10982
11060
|
composed: true
|
|
10983
11061
|
})
|
|
@@ -13002,13 +13080,13 @@ function createDOMPurify() {
|
|
|
13002
13080
|
}
|
|
13003
13081
|
var purify_default = createDOMPurify();
|
|
13004
13082
|
|
|
13005
|
-
// node_modules/.pnpm/marked@18.0
|
|
13083
|
+
// node_modules/.pnpm/marked@18.1.0/node_modules/marked/lib/marked.esm.js
|
|
13006
13084
|
function I() {
|
|
13007
13085
|
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
13008
13086
|
}
|
|
13009
|
-
var
|
|
13087
|
+
var P = I();
|
|
13010
13088
|
function W(l3) {
|
|
13011
|
-
|
|
13089
|
+
P = l3;
|
|
13012
13090
|
}
|
|
13013
13091
|
var A = { exec: () => null };
|
|
13014
13092
|
function C(l3) {
|
|
@@ -13039,9 +13117,9 @@ var ze = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(
|
|
|
13039
13117
|
var G = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
13040
13118
|
var Ae = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
13041
13119
|
var J = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
13042
|
-
var
|
|
13043
|
-
var
|
|
13044
|
-
var Ee = h(
|
|
13120
|
+
var he = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
13121
|
+
var de = h(he).replace(/bull/g, J).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
13122
|
+
var Ee = h(he).replace(/bull/g, J).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
13045
13123
|
var V = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
13046
13124
|
var Me = /^[^\n]+/;
|
|
13047
13125
|
var Y = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
@@ -13050,36 +13128,36 @@ var Ce = h(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, J).getRegex();
|
|
|
13050
13128
|
var N = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
13051
13129
|
var ee = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
13052
13130
|
var Be = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", ee).replace("tag", N).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
13053
|
-
var
|
|
13054
|
-
var De =
|
|
13055
|
-
var qe =
|
|
13131
|
+
var ke = (l3) => h(V).replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", N).getRegex();
|
|
13132
|
+
var De = ke(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
13133
|
+
var qe = ke(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
13056
13134
|
var ve = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", qe).getRegex();
|
|
13057
|
-
var te = { blockquote: ve, code: Le, def: Ie, fences: ze, heading: Ae, hr: G, html: Be, lheading:
|
|
13058
|
-
var
|
|
13059
|
-
var Ze = { ...te, lheading: Ee, table:
|
|
13135
|
+
var te = { blockquote: ve, code: Le, def: Ie, fences: ze, heading: Ae, hr: G, html: Be, lheading: de, list: Ce, newline: $e, paragraph: De, table: A, text: Me };
|
|
13136
|
+
var ue = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", N).getRegex();
|
|
13137
|
+
var Ze = { ...te, lheading: Ee, table: ue, paragraph: h(V).replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ue).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", N).getRegex() };
|
|
13060
13138
|
var He = { ...te, html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", ee).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: A, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: h(V).replace("hr", G).replace("heading", ` *#{1,6} *[^
|
|
13061
|
-
]`).replace("lheading",
|
|
13139
|
+
]`).replace("lheading", de).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
13062
13140
|
var Ge = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
13063
13141
|
var Ne = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
13064
|
-
var
|
|
13142
|
+
var ge = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
|
|
13065
13143
|
var Qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
13066
13144
|
var $ = /[\p{P}\p{S}]/u;
|
|
13067
13145
|
var B = /[\s\p{P}\p{S}]/u;
|
|
13068
13146
|
var Q = /[^\s\p{P}\p{S}]/u;
|
|
13069
13147
|
var je = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, B).getRegex();
|
|
13070
13148
|
var Fe = /[\p{Pi}\p{Ps}"']/u;
|
|
13071
|
-
var
|
|
13149
|
+
var fe = /(?!~)[\p{P}\p{S}]/u;
|
|
13072
13150
|
var Ue = /(?!~)[\s\p{P}\p{S}]/u;
|
|
13073
13151
|
var Ke = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
13074
13152
|
var We = h(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", _e ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
13075
|
-
var
|
|
13076
|
-
var Xe = h(
|
|
13077
|
-
var Je = h(
|
|
13153
|
+
var me = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
13154
|
+
var Xe = h(me, "u").replace(/punct/g, $).getRegex();
|
|
13155
|
+
var Je = h(me, "u").replace(/punct/g, fe).getRegex();
|
|
13078
13156
|
var Ve = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
13079
13157
|
var Ye = h(Ve, "u").replace(/openQuote/g, Fe).replace(/punct/g, $).getRegex();
|
|
13080
|
-
var
|
|
13081
|
-
var et = h(
|
|
13082
|
-
var tt = h(
|
|
13158
|
+
var xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
13159
|
+
var et = h(xe, "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
|
|
13160
|
+
var tt = h(xe, "gu").replace(/notPunctSpace/g, Ke).replace(/punctSpace/g, Ue).replace(/punct/g, fe).getRegex();
|
|
13083
13161
|
var nt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
13084
13162
|
var rt = h(nt, "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
|
|
13085
13163
|
var st = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
|
|
@@ -13092,32 +13170,32 @@ var pt = h(/\\(punct)/, "gu").replace(/punct/g, $).getRegex();
|
|
|
13092
13170
|
var ct = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
13093
13171
|
var ht = h(ee).replace("(?:-->|$)", "-->").getRegex();
|
|
13094
13172
|
var dt = h("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ht).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
13095
|
-
var
|
|
13096
|
-
var U = h(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",
|
|
13097
|
-
var kt = h(/^!?\[(label)\]\(\
|
|
13173
|
+
var be = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
|
|
13174
|
+
var U = h(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", be).getRegex();
|
|
13175
|
+
var kt = h(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label", U).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
13098
13176
|
var gt = h(/^!?\[(label)\]\[(ref)\]/).replace("label", U).replace("ref", Y).getRegex();
|
|
13099
13177
|
var ft = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Y).getRegex();
|
|
13100
|
-
var
|
|
13101
|
-
var mt = h(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",
|
|
13102
|
-
var xt = h("reflink|nolink(?!\\()", "g").replace("reflink", h(/^!?\[(label)\]\[(ref)\]/).replace("label", mt).replace("ref",
|
|
13103
|
-
var
|
|
13178
|
+
var pe = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
|
|
13179
|
+
var mt = h(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", be).getRegex();
|
|
13180
|
+
var xt = h("reflink|nolink(?!\\()", "g").replace("reflink", h(/^!?\[(label)\]\[(ref)\]/).replace("label", mt).replace("ref", pe).getRegex()).replace("nolink", h(/^!?\[(ref)\](?:\[\])?/).replace("ref", pe).getRegex()).getRegex();
|
|
13181
|
+
var ce = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
13104
13182
|
var bt = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
|
|
13105
13183
|
var Rt = h(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, bt).getRegex();
|
|
13106
|
-
var ne = { _backpedal: A, anyPunctuation: pt, autolink: ct, blockSkip: We, br:
|
|
13184
|
+
var ne = { _backpedal: A, anyPunctuation: pt, autolink: ct, blockSkip: We, br: ge, code: Ne, del: A, delLDelim: A, delRDelim: A, emStrongLDelim: Xe, emStrongRDelimAst: et, emStrongRDelimUnd: st, escape: Ge, link: kt, nolink: ft, punctuation: je, reflink: gt, reflinkSearch: xt, tag: dt, text: Qe, url: A };
|
|
13107
13185
|
var Tt = { ...ne, emStrongLDelim: Ye, emStrongRDelimAst: rt, emStrongRDelimUnd: ot, link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", U).getRegex(), reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", U).getRegex() };
|
|
13108
|
-
var X = { ...ne, emStrongRDelimAst: tt, emStrongLDelim: Je, delLDelim: at, delRDelim: ut, url: h(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Rt).replace("protocol",
|
|
13109
|
-
var Ot = { ...X, br: h(
|
|
13186
|
+
var X = { ...ne, emStrongRDelimAst: tt, emStrongLDelim: Je, delLDelim: at, delRDelim: ut, url: h(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Rt).replace("protocol", ce).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: h(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", ce).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex() };
|
|
13187
|
+
var Ot = { ...X, br: h(ge).replace("{2,}", "*").getRegex(), text: h(X.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
13110
13188
|
var j = { normal: te, gfm: Ze, pedantic: He };
|
|
13111
13189
|
var D = { normal: ne, gfm: X, breaks: Ot, pedantic: Tt };
|
|
13112
13190
|
var wt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
13113
|
-
var
|
|
13191
|
+
var Re = (l3) => wt[l3];
|
|
13114
13192
|
function O(l3, e) {
|
|
13115
13193
|
if (e) {
|
|
13116
|
-
if (x.escapeTest.test(l3)) return l3.replace(x.escapeReplace,
|
|
13117
|
-
} else if (x.escapeTestNoEncode.test(l3)) return l3.replace(x.escapeReplaceNoEncode,
|
|
13194
|
+
if (x.escapeTest.test(l3)) return l3.replace(x.escapeReplace, Re);
|
|
13195
|
+
} else if (x.escapeTestNoEncode.test(l3)) return l3.replace(x.escapeReplaceNoEncode, Re);
|
|
13118
13196
|
return l3;
|
|
13119
13197
|
}
|
|
13120
|
-
function
|
|
13198
|
+
function Te(l3) {
|
|
13121
13199
|
return l3.replace(x.numericCharacterReference, (e, t, n) => {
|
|
13122
13200
|
let s = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
|
|
13123
13201
|
return s === 0 || s > 1114111 || s >= 55296 && s <= 57343 ? "\uFFFD" : String.fromCodePoint(s);
|
|
@@ -13164,15 +13242,15 @@ function ie(l3) {
|
|
|
13164
13242
|
function q(l3) {
|
|
13165
13243
|
return l3.trim().toLowerCase().toUpperCase().toLowerCase();
|
|
13166
13244
|
}
|
|
13167
|
-
function
|
|
13168
|
-
if (l3.indexOf(e[1]) === -1) return -1;
|
|
13245
|
+
function oe(l3, e) {
|
|
13246
|
+
if (l3.indexOf(e[0]) === -1 && l3.indexOf(e[1]) === -1) return -1;
|
|
13169
13247
|
let t = 0;
|
|
13170
13248
|
for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
|
|
13171
13249
|
else if (l3[n] === e[0]) t++;
|
|
13172
13250
|
else if (l3[n] === e[1] && (t--, t < 0)) return n;
|
|
13173
13251
|
return t > 0 ? -2 : -1;
|
|
13174
13252
|
}
|
|
13175
|
-
function
|
|
13253
|
+
function ae(l3, e = 0) {
|
|
13176
13254
|
let t = e, n = "";
|
|
13177
13255
|
for (let s of l3) if (s === " ") {
|
|
13178
13256
|
let r = 4 - t % 4;
|
|
@@ -13195,7 +13273,7 @@ function Oe(l3, e, t, n, s) {
|
|
|
13195
13273
|
}
|
|
13196
13274
|
return { type: u ? "image" : "link", raw: t, href: r, title: o, text: i, tokens: c };
|
|
13197
13275
|
}
|
|
13198
|
-
function
|
|
13276
|
+
function Pt(l3, e, t) {
|
|
13199
13277
|
let n = l3.match(t.other.indentCodeCompensation);
|
|
13200
13278
|
if (n === null) return e;
|
|
13201
13279
|
let s = n[1];
|
|
@@ -13231,12 +13309,12 @@ function we(l3, e, t, n) {
|
|
|
13231
13309
|
}
|
|
13232
13310
|
return false;
|
|
13233
13311
|
}
|
|
13234
|
-
var
|
|
13312
|
+
var y = class {
|
|
13235
13313
|
options;
|
|
13236
13314
|
rules;
|
|
13237
13315
|
lexer;
|
|
13238
13316
|
constructor(e) {
|
|
13239
|
-
this.options = e ||
|
|
13317
|
+
this.options = e || P;
|
|
13240
13318
|
}
|
|
13241
13319
|
space(e) {
|
|
13242
13320
|
let t = this.rules.block.newline.exec(e);
|
|
@@ -13252,7 +13330,7 @@ var P = class {
|
|
|
13252
13330
|
fences(e) {
|
|
13253
13331
|
let t = this.rules.block.fences.exec(e);
|
|
13254
13332
|
if (t) {
|
|
13255
|
-
let n = t[0], s =
|
|
13333
|
+
let n = t[0], s = Pt(n, t[3] || "", this.rules);
|
|
13256
13334
|
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
13257
13335
|
}
|
|
13258
13336
|
}
|
|
@@ -13329,19 +13407,19 @@ ${Z.join(`
|
|
|
13329
13407
|
if (!(t = o.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
13330
13408
|
p = t[0], e = e.substring(p.length);
|
|
13331
13409
|
let d = t[2].split(`
|
|
13332
|
-
`, 1)[0], m = t[1].length, b = this.options.pedantic ?
|
|
13410
|
+
`, 1)[0], m = t[1].length, b = this.options.pedantic ? ae(d, m) : d.replace(this.rules.other.leadingSpaceTab, (M) => ae(M, m)), g = e.split(`
|
|
13333
13411
|
`, 1)[0], w = !b.trim(), f = 0;
|
|
13334
13412
|
if (this.options.pedantic ? (f = 2, c = b.trimStart()) : w ? f = m + 1 : (f = b.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = b.slice(f), f += m), w && this.rules.other.blankLine.test(g) && (p += g + `
|
|
13335
13413
|
`, e = e.substring(g.length + 1), a = true), !a) {
|
|
13336
|
-
let M = this.rules.other.nextBulletRegex(f), v = this.rules.other.hrRegex(f), Z = this.rules.other.fencesBeginRegex(f),
|
|
13414
|
+
let M = this.rules.other.nextBulletRegex(f), v = this.rules.other.hrRegex(f), Z = this.rules.other.fencesBeginRegex(f), le = this.rules.other.headingBeginRegex(f), Pe = this.rules.other.htmlBeginRegex(f), ye = this.rules.other.blockquoteBeginRegex(f);
|
|
13337
13415
|
for (; e; ) {
|
|
13338
13416
|
let K = e.split(`
|
|
13339
13417
|
`, 1)[0], H;
|
|
13340
|
-
if (g = K, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), H = g) : H = g.replace(this.rules.other.leadingSpaceTab, (Se) => Se.replace(this.rules.other.tabCharGlobal, " ")), Z.test(g) ||
|
|
13418
|
+
if (g = K, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), H = g) : H = g.replace(this.rules.other.leadingSpaceTab, (Se) => Se.replace(this.rules.other.tabCharGlobal, " ")), Z.test(g) || le.test(g) || Pe.test(g) || ye.test(g) || M.test(g) || v.test(g)) break;
|
|
13341
13419
|
if (H.search(this.rules.other.nonSpaceChar) >= f || !g.trim()) c += `
|
|
13342
13420
|
` + H.slice(f);
|
|
13343
13421
|
else {
|
|
13344
|
-
if (w || b.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Z.test(b) ||
|
|
13422
|
+
if (w || b.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Z.test(b) || le.test(b) || v.test(b)) break;
|
|
13345
13423
|
c += `
|
|
13346
13424
|
` + g;
|
|
13347
13425
|
}
|
|
@@ -13391,6 +13469,7 @@ ${Z.join(`
|
|
|
13391
13469
|
def(e) {
|
|
13392
13470
|
let t = this.rules.block.def.exec(e);
|
|
13393
13471
|
if (t) {
|
|
13472
|
+
if (!this.rules.other.startAngleBracket.test(t[2]) && oe(t[2], "()") !== -1) return;
|
|
13394
13473
|
let n = q(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
13395
13474
|
return { type: "def", tag: n, raw: L(t[0], `
|
|
13396
13475
|
`), href: s, title: r };
|
|
@@ -13438,6 +13517,7 @@ ${Z.join(`
|
|
|
13438
13517
|
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
13439
13518
|
}
|
|
13440
13519
|
link(e) {
|
|
13520
|
+
if (this.lexer.state.linkParenPossible === false) return;
|
|
13441
13521
|
let t = this.rules.inline.link.exec(e);
|
|
13442
13522
|
if (t) {
|
|
13443
13523
|
let n = t[0].charAt(0) === "!" ? 2 : 1;
|
|
@@ -13448,7 +13528,7 @@ ${Z.join(`
|
|
|
13448
13528
|
let i = L(s.slice(0, -1), "\\");
|
|
13449
13529
|
if ((s.length - i.length) % 2 === 0) return;
|
|
13450
13530
|
} else {
|
|
13451
|
-
let i =
|
|
13531
|
+
let i = oe(t[2], "()");
|
|
13452
13532
|
if (i === -2) return;
|
|
13453
13533
|
if (i > -1) {
|
|
13454
13534
|
let a = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
@@ -13560,7 +13640,7 @@ ${Z.join(`
|
|
|
13560
13640
|
let t = this.rules.inline.text.exec(e);
|
|
13561
13641
|
if (t) {
|
|
13562
13642
|
let n = this.lexer.state.inRawBlock;
|
|
13563
|
-
return { type: "text", raw: t[0], text: n ? t[0] :
|
|
13643
|
+
return { type: "text", raw: t[0], text: n ? t[0] : Te(t[0]), escaped: n };
|
|
13564
13644
|
}
|
|
13565
13645
|
}
|
|
13566
13646
|
};
|
|
@@ -13571,7 +13651,7 @@ var R = class l {
|
|
|
13571
13651
|
inlineQueue;
|
|
13572
13652
|
tokenizer;
|
|
13573
13653
|
constructor(e) {
|
|
13574
|
-
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e ||
|
|
13654
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || P, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, linkParenPossible: true, top: true };
|
|
13575
13655
|
let t = { other: x, block: j.normal, inline: D.normal };
|
|
13576
13656
|
this.options.pedantic ? (t.block = j.pedantic, t.inline = D.pedantic) : this.options.gfm && (t.block = j.gfm, this.options.breaks ? t.inline = D.breaks : t.inline = D.gfm), this.tokenizer.rules = t;
|
|
13577
13657
|
}
|
|
@@ -13707,6 +13787,15 @@ var R = class l {
|
|
|
13707
13787
|
}
|
|
13708
13788
|
inlineTokens(e, t = []) {
|
|
13709
13789
|
this.tokenizer.lexer = this;
|
|
13790
|
+
let n = this.state.linkParenPossible;
|
|
13791
|
+
this.state.linkParenPossible = n && e.includes(")");
|
|
13792
|
+
try {
|
|
13793
|
+
return this.#e(e, t);
|
|
13794
|
+
} finally {
|
|
13795
|
+
this.state.linkParenPossible = n;
|
|
13796
|
+
}
|
|
13797
|
+
}
|
|
13798
|
+
#e(e, t) {
|
|
13710
13799
|
let n = e;
|
|
13711
13800
|
if (this.tokens.links && e.includes("[")) {
|
|
13712
13801
|
let i = this.tokenizer.rules.inline.reflinkSearch, u = (a) => {
|
|
@@ -13806,7 +13895,7 @@ var S = class {
|
|
|
13806
13895
|
options;
|
|
13807
13896
|
parser;
|
|
13808
13897
|
constructor(e) {
|
|
13809
|
-
this.options = e ||
|
|
13898
|
+
this.options = e || P;
|
|
13810
13899
|
}
|
|
13811
13900
|
space(e) {
|
|
13812
13901
|
return "";
|
|
@@ -13957,7 +14046,7 @@ var T = class l2 {
|
|
|
13957
14046
|
renderer;
|
|
13958
14047
|
textRenderer;
|
|
13959
14048
|
constructor(e) {
|
|
13960
|
-
this.options = e ||
|
|
14049
|
+
this.options = e || P, this.options.renderer = this.options.renderer || new S(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new z();
|
|
13961
14050
|
}
|
|
13962
14051
|
static parse(e, t) {
|
|
13963
14052
|
return new l2(t).parse(e);
|
|
@@ -14108,7 +14197,7 @@ var _ = class {
|
|
|
14108
14197
|
options;
|
|
14109
14198
|
block;
|
|
14110
14199
|
constructor(e) {
|
|
14111
|
-
this.options = e ||
|
|
14200
|
+
this.options = e || P;
|
|
14112
14201
|
}
|
|
14113
14202
|
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
14114
14203
|
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
@@ -14140,7 +14229,7 @@ var F = class {
|
|
|
14140
14229
|
Renderer = S;
|
|
14141
14230
|
TextRenderer = z;
|
|
14142
14231
|
Lexer = R;
|
|
14143
|
-
Tokenizer =
|
|
14232
|
+
Tokenizer = y;
|
|
14144
14233
|
Hooks = _;
|
|
14145
14234
|
constructor(...e) {
|
|
14146
14235
|
this.use(...e);
|
|
@@ -14202,7 +14291,7 @@ var F = class {
|
|
|
14202
14291
|
s.renderer = r;
|
|
14203
14292
|
}
|
|
14204
14293
|
if (n.tokenizer) {
|
|
14205
|
-
let r = this.defaults.tokenizer || new
|
|
14294
|
+
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
14206
14295
|
for (let o in n.tokenizer) {
|
|
14207
14296
|
if (!(o in r)) throw new Error(`tokenizer '${o}' does not exist`);
|
|
14208
14297
|
if (["options", "rules", "lexer"].includes(o)) continue;
|
|
@@ -14300,11 +14389,11 @@ k.options = k.setOptions = function(l3) {
|
|
|
14300
14389
|
return E.setOptions(l3), k.defaults = E.defaults, W(k.defaults), k;
|
|
14301
14390
|
};
|
|
14302
14391
|
k.getDefaults = I;
|
|
14303
|
-
k.defaults =
|
|
14304
|
-
function
|
|
14392
|
+
k.defaults = P;
|
|
14393
|
+
function yt(...l3) {
|
|
14305
14394
|
return E.use(...l3), k.defaults = E.defaults, W(k.defaults), k;
|
|
14306
14395
|
}
|
|
14307
|
-
k.use =
|
|
14396
|
+
k.use = yt;
|
|
14308
14397
|
k.walkTokens = function(l3, e) {
|
|
14309
14398
|
return E.walkTokens(l3, e);
|
|
14310
14399
|
};
|
|
@@ -14315,7 +14404,7 @@ k.Renderer = S;
|
|
|
14315
14404
|
k.TextRenderer = z;
|
|
14316
14405
|
k.Lexer = R;
|
|
14317
14406
|
k.lexer = R.lex;
|
|
14318
|
-
k.Tokenizer =
|
|
14407
|
+
k.Tokenizer = y;
|
|
14319
14408
|
k.Hooks = _;
|
|
14320
14409
|
k.parse = k;
|
|
14321
14410
|
var gn = k.options;
|
|
@@ -15590,10 +15679,14 @@ var AgUiClient = class {
|
|
|
15590
15679
|
const closed = this.#closedMessageIds;
|
|
15591
15680
|
const cancelled = () => this.#cancelled;
|
|
15592
15681
|
const pendingDeltas = /* @__PURE__ */ new Set();
|
|
15682
|
+
let runId;
|
|
15593
15683
|
return {
|
|
15594
15684
|
onRunInitialized() {
|
|
15595
15685
|
h2.onRunStart();
|
|
15596
15686
|
},
|
|
15687
|
+
onRunStartedEvent({ event }) {
|
|
15688
|
+
runId = event.runId;
|
|
15689
|
+
},
|
|
15597
15690
|
onTextMessageStartEvent({ event }) {
|
|
15598
15691
|
if (closed.has(event.messageId)) {
|
|
15599
15692
|
console.warn(
|
|
@@ -15606,7 +15699,10 @@ var AgUiClient = class {
|
|
|
15606
15699
|
},
|
|
15607
15700
|
onTextMessageEndEvent({ event, textMessageBuffer }) {
|
|
15608
15701
|
closed.add(event.messageId);
|
|
15609
|
-
h2.onTextEnd(textMessageBuffer
|
|
15702
|
+
h2.onTextEnd(textMessageBuffer, {
|
|
15703
|
+
messageId: event.messageId,
|
|
15704
|
+
...runId === void 0 ? {} : { runId }
|
|
15705
|
+
});
|
|
15610
15706
|
},
|
|
15611
15707
|
onToolCallEndEvent({ event, toolCallName, toolCallArgs }) {
|
|
15612
15708
|
const call = {
|
|
@@ -16263,7 +16359,7 @@ var RunHandlers = class {
|
|
|
16263
16359
|
this.#host.stream.queue(buffer);
|
|
16264
16360
|
this.#host.stream.countDelta();
|
|
16265
16361
|
},
|
|
16266
|
-
onTextEnd: (buffer) => {
|
|
16362
|
+
onTextEnd: (buffer, message) => {
|
|
16267
16363
|
if (buffer === "") {
|
|
16268
16364
|
this.#host.stream.end();
|
|
16269
16365
|
return;
|
|
@@ -16273,7 +16369,7 @@ var RunHandlers = class {
|
|
|
16273
16369
|
this.#host.transcript.revealWords(bubble);
|
|
16274
16370
|
}
|
|
16275
16371
|
attachCopyButtons(bubble, this.#host.strings());
|
|
16276
|
-
this.#host.actions.attach(bubble);
|
|
16372
|
+
this.#host.actions.attach(bubble, message);
|
|
16277
16373
|
this.#host.stream.end();
|
|
16278
16374
|
this.#host.noteUnread();
|
|
16279
16375
|
},
|
|
@@ -16939,7 +17035,9 @@ var AgUiChat = class extends HTMLElement {
|
|
|
16939
17035
|
strings: () => this.#strings,
|
|
16940
17036
|
retry: () => {
|
|
16941
17037
|
void this.retryLastTurn();
|
|
16942
|
-
}
|
|
17038
|
+
},
|
|
17039
|
+
// Late-bound: the history is built in the constructor, after this field.
|
|
17040
|
+
threadId: () => this.#history.threadId
|
|
16943
17041
|
});
|
|
16944
17042
|
#root;
|
|
16945
17043
|
/** The screen-reader-only status region the run and its tool calls report into. */
|
|
@@ -17124,6 +17222,26 @@ var AgUiChat = class extends HTMLElement {
|
|
|
17124
17222
|
* conversation the handover purged.
|
|
17125
17223
|
*/
|
|
17126
17224
|
#tenure = {};
|
|
17225
|
+
/**
|
|
17226
|
+
* The conversation on screen: replaced every time the transcript is cleared
|
|
17227
|
+
* for another one -- New chat, a drawer switch, deleting the active thread,
|
|
17228
|
+
* `reload()`, re-insertion and a handover all pass through
|
|
17229
|
+
* {@link #resetConversation} -- and captured by each frontend tool call as it
|
|
17230
|
+
* is dispatched, so the call can tell whether the conversation it was drawn
|
|
17231
|
+
* in is still the one showing.
|
|
17232
|
+
*
|
|
17233
|
+
* A call outlives the reset that stops its run. A handler cannot be aborted,
|
|
17234
|
+
* and a card open at the time is declined, so the call resumes once the new
|
|
17235
|
+
* conversation is showing; drawing the run's pending indicator then put it
|
|
17236
|
+
* in a conversation with no run to take it down.
|
|
17237
|
+
*
|
|
17238
|
+
* Not {@link #tenure}, which only a handover replaces. A reset is not a
|
|
17239
|
+
* change of principal: the call still belongs to someone this element
|
|
17240
|
+
* serves, so it still settles its card, clears its checkpoint and returns
|
|
17241
|
+
* its result, and only the drawing is skipped. The tenure checks end the
|
|
17242
|
+
* call before any of that.
|
|
17243
|
+
*/
|
|
17244
|
+
#conversation = {};
|
|
17127
17245
|
/**
|
|
17128
17246
|
* The remote store `data-threads-url` wrapped around the conversation store,
|
|
17129
17247
|
* and the store inside it, so connecting again can wrap that store rather
|
|
@@ -17154,9 +17272,9 @@ var AgUiChat = class extends HTMLElement {
|
|
|
17154
17272
|
* requests, and the listener's turn drawn between the user's turn and its
|
|
17155
17273
|
* answer. It is the gap a picked checkpoint closes by counting from the pick,
|
|
17156
17274
|
* closed the same way for a send. A retry asks for its run the same way, so
|
|
17157
|
-
* it takes the same hold, and so does
|
|
17158
|
-
*
|
|
17159
|
-
*
|
|
17275
|
+
* it takes the same hold, and so does every restore, from before it asks the
|
|
17276
|
+
* store for the conversation, through the history host's `holdRun`: until
|
|
17277
|
+
* the store answers, the client can only be built from nothing.
|
|
17160
17278
|
*
|
|
17161
17279
|
* Let go of once the run starts, because `running` holds from then until the
|
|
17162
17280
|
* run settles, and a send held past that would refuse a host's follow-up from
|
|
@@ -17166,9 +17284,18 @@ var AgUiChat = class extends HTMLElement {
|
|
|
17166
17284
|
* An object rather than a flag, so a send or a retry ending releases only
|
|
17167
17285
|
* what it took. By the time either ends, the turn queued behind it has
|
|
17168
17286
|
* usually taken the field for itself, and a Stop lets go of it for the next
|
|
17169
|
-
* send to take; the earlier one ending must release neither.
|
|
17287
|
+
* send to take; the earlier one ending must release neither. It is also how
|
|
17288
|
+
* {@link sendMessage} tells the one hold it waits on from all the others it
|
|
17289
|
+
* refuses behind: see {@link #restoreHold}.
|
|
17170
17290
|
*/
|
|
17171
17291
|
#sending = null;
|
|
17292
|
+
/**
|
|
17293
|
+
* The hold the latest restore with no run to resume took, and what settles
|
|
17294
|
+
* once that restore has ended or been stopped; `null` when the latest
|
|
17295
|
+
* restore will resume a run. Only meaningful while `#sending` is that hold:
|
|
17296
|
+
* then a host's {@link sendMessage} waits for it rather than refusing.
|
|
17297
|
+
*/
|
|
17298
|
+
#restoreHold = null;
|
|
17172
17299
|
/** The decision a run is suspended on, which a Stop abandons. */
|
|
17173
17300
|
#decision = new PendingDecision();
|
|
17174
17301
|
/**
|
|
@@ -17261,7 +17388,9 @@ var AgUiChat = class extends HTMLElement {
|
|
|
17261
17388
|
threadId: () => this.#history.threadId,
|
|
17262
17389
|
// Read live and compared, the way each client compares the one it was
|
|
17263
17390
|
// built with: see #tenure.
|
|
17264
|
-
tenure: () => this.#tenure
|
|
17391
|
+
tenure: () => this.#tenure,
|
|
17392
|
+
// The same, for the conversation on screen: see #conversation.
|
|
17393
|
+
conversation: () => this.#conversation
|
|
17265
17394
|
});
|
|
17266
17395
|
this.#runHandlers = new RunHandlers({
|
|
17267
17396
|
element: this,
|
|
@@ -17409,25 +17538,29 @@ var AgUiChat = class extends HTMLElement {
|
|
|
17409
17538
|
// A held send or retry is as much in flight to a pick as a run is: it has
|
|
17410
17539
|
// asked this element's client for a run that has not started, and a
|
|
17411
17540
|
// continuation started beside it was a second run in one conversation.
|
|
17412
|
-
// So is a restore
|
|
17413
|
-
//
|
|
17541
|
+
// So is a restore, which holds through the same field from before the
|
|
17542
|
+
// store answers.
|
|
17414
17543
|
running: () => this.#running || this.#sending !== null,
|
|
17415
|
-
// The hold a send takes, taken for
|
|
17416
|
-
//
|
|
17417
|
-
//
|
|
17418
|
-
//
|
|
17419
|
-
//
|
|
17420
|
-
//
|
|
17421
|
-
//
|
|
17422
|
-
//
|
|
17423
|
-
//
|
|
17424
|
-
//
|
|
17544
|
+
// The hold a send takes, taken for every restore, so what refuses a send
|
|
17545
|
+
// held short of its run holds one made while the store is still
|
|
17546
|
+
// answering: Send parks the turn, a Retry and a pick refuse, and
|
|
17547
|
+
// `sendMessage` refuses behind a restore that will resume a run and waits
|
|
17548
|
+
// for one that will not -- `restored` is what it waits on, given only for
|
|
17549
|
+
// that kind. The same field rather than a flag beside it, because what
|
|
17550
|
+
// lets go of a send's hold is right for this one too. The resumed run
|
|
17551
|
+
// starting lets go, in `#setRunning`, so there is no gap after the resume
|
|
17552
|
+
// is asked for, and a Stop does, in `#cancelRun`. A flag the restore
|
|
17553
|
+
// cleared itself would still be set when the resumed run settles and
|
|
17554
|
+
// sends the parked turn, so that send would be refused after the turn had
|
|
17555
|
+
// left the queue, and lost.
|
|
17425
17556
|
//
|
|
17426
|
-
// Whether the restore was stopped is not read off this hold, because
|
|
17427
|
-
//
|
|
17428
|
-
|
|
17557
|
+
// Whether the restore was stopped is not read off this hold, because a
|
|
17558
|
+
// host's send that waited takes it over; the restore asks its own
|
|
17559
|
+
// generation.
|
|
17560
|
+
holdRun: (restored) => {
|
|
17429
17561
|
const hold = {};
|
|
17430
17562
|
this.#sending = hold;
|
|
17563
|
+
this.#restoreHold = restored === null ? null : { hold, restored };
|
|
17431
17564
|
return {
|
|
17432
17565
|
release: () => {
|
|
17433
17566
|
if (this.#sending === hold) {
|
|
@@ -18247,6 +18380,7 @@ var AgUiChat = class extends HTMLElement {
|
|
|
18247
18380
|
#resetConversation() {
|
|
18248
18381
|
this.#client = null;
|
|
18249
18382
|
this.#runHandlers.detach();
|
|
18383
|
+
this.#conversation = {};
|
|
18250
18384
|
this.#clearTranscript();
|
|
18251
18385
|
this.#history.forgetRestored();
|
|
18252
18386
|
}
|
|
@@ -18275,9 +18409,12 @@ var AgUiChat = class extends HTMLElement {
|
|
|
18275
18409
|
* History is truncated to the most recent user message inclusive and the run
|
|
18276
18410
|
* repeats, so the agent answers what it was asked rather than being told its
|
|
18277
18411
|
* last answer was wrong. Returns `false` when there is nothing to retry, or
|
|
18278
|
-
* while anything that
|
|
18412
|
+
* while anything that holds a send is in flight: a run, a send or another
|
|
18279
18413
|
* retry whose run has not started yet, a checkpoint continuation, or a
|
|
18280
|
-
*
|
|
18414
|
+
* restore of the stored conversation that is still loading. It does not wait
|
|
18415
|
+
* for a restore as a send does: nothing is on screen to retry yet, and after
|
|
18416
|
+
* the load it would re-ask the previous visit's last question. Also `false`
|
|
18417
|
+
* when host code it
|
|
18281
18418
|
* runs before its run starts -- the store's save, or an activity or tool
|
|
18282
18419
|
* renderer the replay draws through -- has stopped it by starting a new chat
|
|
18283
18420
|
* or changing `user-key`. A tool or context provider that stops it does so
|
|
@@ -18798,18 +18935,57 @@ var AgUiChat = class extends HTMLElement {
|
|
|
18798
18935
|
* `attachments` are durable {@link AttachmentRef}s — what {@link attachFile}
|
|
18799
18936
|
* resolves to and what {@link ATTACHMENT_EVENT} reports.
|
|
18800
18937
|
*
|
|
18801
|
-
*
|
|
18802
|
-
*
|
|
18803
|
-
*
|
|
18804
|
-
*
|
|
18805
|
-
*
|
|
18938
|
+
* Resolves `true` once the turn has been handed to the client for its run,
|
|
18939
|
+
* which is when the interaction settles, frontend-tool rounds included; a
|
|
18940
|
+
* run a tool or context provider then stops still counts, as it does for
|
|
18941
|
+
* {@link retryLastTurn}. Resolves `false` when nothing was sent.
|
|
18942
|
+
*
|
|
18943
|
+
* Nothing is sent for an empty message, nor while a run or a picked
|
|
18944
|
+
* checkpoint's continuation is in flight, since a second concurrent run
|
|
18945
|
+
* would orphan the first. A send is in flight from the moment it is taken
|
|
18946
|
+
* rather than from its run's start, so nothing is sent from a
|
|
18947
|
+
* {@link SUBMIT_EVENT} listener or for a second call in the same task
|
|
18948
|
+
* either. Nor with no `endpoint`, which says so in the transcript. Nor
|
|
18949
|
+
* behind a reload's restore that will resume a run a navigating tool
|
|
18950
|
+
* interrupted, since that restore ends by starting the run.
|
|
18951
|
+
*
|
|
18952
|
+
* **While the element restores a stored conversation with no run to resume
|
|
18953
|
+
* -- on connect, {@link reload}, a thread picked from the drawer, a change
|
|
18954
|
+
* from one `user-key` to another -- it waits, then sends.** The turn has to follow the
|
|
18955
|
+
* conversation it is part of: sent at once, it went out without it, the
|
|
18956
|
+
* conversation was then drawn under it, and its save replaced the stored
|
|
18957
|
+
* one. So the bubble, the {@link SUBMIT_EVENT} and the request all come after
|
|
18958
|
+
* the replay, by the length of the store's load. A New chat, a thread
|
|
18959
|
+
* switch, a change from one `user-key` to another, a reload or the element
|
|
18960
|
+
* leaving the page while it waits drops it, resolving `false`: the
|
|
18961
|
+
* conversation it was addressed to is no longer on screen. Leaving the page
|
|
18962
|
+
* resolves it only once the load answers or the element is back, since
|
|
18963
|
+
* that is when the restore learns it was stopped. A first `user-key` on an
|
|
18964
|
+
* anonymous conversation adopts it rather than replacing it, and stops
|
|
18965
|
+
* nothing. A second call while one waits is
|
|
18966
|
+
* refused, as a second call in the same task is.
|
|
18967
|
+
*
|
|
18806
18968
|
* Unlike the built-in Send it does not queue: it returns, and the caller
|
|
18807
18969
|
* keeps what it tried to send. Nor does it consult the tray -- what you pass
|
|
18808
18970
|
* is what is sent.
|
|
18809
18971
|
*/
|
|
18810
18972
|
async sendMessage(content, attachments = []) {
|
|
18811
|
-
if (
|
|
18812
|
-
return;
|
|
18973
|
+
if (content === "" && attachments.length === 0) {
|
|
18974
|
+
return false;
|
|
18975
|
+
}
|
|
18976
|
+
const restore = this.#restoreHold;
|
|
18977
|
+
if (restore !== null && this.#sending === restore.hold) {
|
|
18978
|
+
const waiting = {};
|
|
18979
|
+
this.#sending = waiting;
|
|
18980
|
+
await restore.restored;
|
|
18981
|
+
if (this.#sending !== waiting) {
|
|
18982
|
+
return false;
|
|
18983
|
+
}
|
|
18984
|
+
this.#sending = null;
|
|
18985
|
+
return this.sendMessage(content, attachments);
|
|
18986
|
+
}
|
|
18987
|
+
if (this.#running || this.#sending !== null || this.#history.continuation !== null) {
|
|
18988
|
+
return false;
|
|
18813
18989
|
}
|
|
18814
18990
|
const send = {};
|
|
18815
18991
|
this.#sending = send;
|
|
@@ -18819,9 +18995,11 @@ var AgUiChat = class extends HTMLElement {
|
|
|
18819
18995
|
}
|
|
18820
18996
|
this.#announceTurn(content, attachments);
|
|
18821
18997
|
if (this.#sending !== send) {
|
|
18822
|
-
return;
|
|
18998
|
+
return false;
|
|
18823
18999
|
}
|
|
19000
|
+
const connected = this.endpoint !== "";
|
|
18824
19001
|
await this.#client_send(content, attachments);
|
|
19002
|
+
return connected;
|
|
18825
19003
|
} finally {
|
|
18826
19004
|
if (this.#sending === send) {
|
|
18827
19005
|
this.#sending = null;
|
|
@@ -19137,7 +19315,7 @@ function setControlValue(el2, value) {
|
|
|
19137
19315
|
}
|
|
19138
19316
|
|
|
19139
19317
|
// src/version.ts
|
|
19140
|
-
var VERSION = "0.
|
|
19318
|
+
var VERSION = "0.44.0";
|
|
19141
19319
|
export {
|
|
19142
19320
|
ATTACHMENT_EVENT,
|
|
19143
19321
|
AgUiChat,
|