@dudko.dev/agent-web-react 0.0.39 → 0.0.41
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/README.md +14 -7
- package/dist/{chunk-RJM7JCWI.js → chunk-V4JGQQRB.js} +5 -1
- package/dist/chunk-V4JGQQRB.js.map +1 -0
- package/dist/{elicitation-DdzjMut9.d.cts → elicitation-Dp6Fi6ZA.d.cts} +17 -0
- package/dist/{elicitation-DdzjMut9.d.ts → elicitation-Dp6Fi6ZA.d.ts} +17 -0
- package/dist/index.cjs +511 -264
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -10
- package/dist/index.d.ts +133 -10
- package/dist/index.js +507 -264
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/pipeline.cjs.map +1 -1
- package/dist/pipeline.js +1 -1
- package/dist/styles.css +93 -3
- package/package.json +3 -3
- package/dist/chunk-RJM7JCWI.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ArrowUpIcon,
|
|
12
12
|
BoltIcon,
|
|
13
13
|
BookIcon,
|
|
14
|
+
BookmarkIcon,
|
|
14
15
|
BotIcon,
|
|
15
16
|
BrainIcon,
|
|
16
17
|
CheckIcon,
|
|
@@ -56,8 +57,9 @@ import {
|
|
|
56
57
|
formatTokens,
|
|
57
58
|
imagesInOutput,
|
|
58
59
|
previewValue,
|
|
60
|
+
remoteAnswerOf,
|
|
59
61
|
webSearchOf
|
|
60
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-V4JGQQRB.js";
|
|
61
63
|
import {
|
|
62
64
|
MCP_APP_POLICY_TOKEN_MAX_CHARS,
|
|
63
65
|
MCP_APP_SANDBOX_PROXY_READY,
|
|
@@ -326,8 +328,15 @@ var resetRun = (state) => ({
|
|
|
326
328
|
seq: state.seq,
|
|
327
329
|
learned: state.learned,
|
|
328
330
|
// An MCP App's request is the user's, not the run's: it waits across runs.
|
|
329
|
-
approvals: state.approvals.filter((a) => a.app && a.status === "pending")
|
|
331
|
+
approvals: state.approvals.filter((a) => a.app && a.status === "pending"),
|
|
332
|
+
// So is what this tab sent to another tab's run, until that tab answers (a replay that opens
|
|
333
|
+
// with the run's start is not an answer).
|
|
334
|
+
queued: sentToOtherTab(state.queued)
|
|
330
335
|
});
|
|
336
|
+
var sentToOtherTab = (queued) => queued.filter((q) => q.sentTo === "another-tab");
|
|
337
|
+
var sentEntryOf = (queued, text) => queued.findIndex(
|
|
338
|
+
(q) => q.sentTo === "another-tab" && (q.text === text || text.endsWith("\u2026") && q.text.length > text.length && q.text.startsWith(text.slice(0, -1)))
|
|
339
|
+
);
|
|
331
340
|
var patchStep = (steps, id, fn) => steps.map((s) => s.id === id ? fn(s) : s);
|
|
332
341
|
var withoutSkillBody = (a) => {
|
|
333
342
|
if (!a.skill || a.skill.body === void 0) return a;
|
|
@@ -807,6 +816,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
807
816
|
const base = resetRun(ctx.remote ? state : withoutSubmitted(state));
|
|
808
817
|
const userId = `msg-${base.seq}`;
|
|
809
818
|
const assistantId = `msg-${base.seq + 1}`;
|
|
819
|
+
const began = ctx.at !== void 0 ? { startedAt: ctx.at } : {};
|
|
810
820
|
return {
|
|
811
821
|
...base,
|
|
812
822
|
// Another tab's run keeps the view of it; a run of this tab's ends it (and any wait).
|
|
@@ -824,6 +834,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
824
834
|
content: event.goal,
|
|
825
835
|
pending: false,
|
|
826
836
|
...ctx.remote ? { remote: true } : {},
|
|
837
|
+
...began,
|
|
827
838
|
...ctx.attachments?.length ? { attachments: ctx.attachments } : {}
|
|
828
839
|
},
|
|
829
840
|
{
|
|
@@ -831,7 +842,8 @@ var applyEvent = (state, event, ctx) => {
|
|
|
831
842
|
role: "assistant",
|
|
832
843
|
content: "",
|
|
833
844
|
pending: true,
|
|
834
|
-
...ctx.remote ? { remote: true } : {}
|
|
845
|
+
...ctx.remote ? { remote: true } : {},
|
|
846
|
+
...began
|
|
835
847
|
}
|
|
836
848
|
],
|
|
837
849
|
seq: base.seq + 2
|
|
@@ -1076,14 +1088,17 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1076
1088
|
return fileDeleted(state, event.path);
|
|
1077
1089
|
case "mcp.app":
|
|
1078
1090
|
return ctx.remote ? state : addApp(state, event);
|
|
1079
|
-
case "message.queued":
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
]
|
|
1091
|
+
case "message.queued": {
|
|
1092
|
+
if (state.queued.some((q) => q.id === event.id)) return state;
|
|
1093
|
+
const entry = {
|
|
1094
|
+
id: event.id,
|
|
1095
|
+
text: event.text,
|
|
1096
|
+
...event.origin ? { origin: event.origin } : {}
|
|
1086
1097
|
};
|
|
1098
|
+
const mine = ctx.remote && event.origin === "another-tab" ? sentEntryOf(state.queued, event.text) : -1;
|
|
1099
|
+
if (mine < 0) return { ...state, queued: [...state.queued, entry] };
|
|
1100
|
+
return { ...state, queued: state.queued.map((q, i) => i === mine ? entry : q) };
|
|
1101
|
+
}
|
|
1087
1102
|
case "message.delivered": {
|
|
1088
1103
|
const anchor = event.at === "round" ? runningStepId(state.steps) : event.at === "step" ? state.steps[state.steps.length - 1]?.id : void 0;
|
|
1089
1104
|
return {
|
|
@@ -1411,9 +1426,21 @@ var agentStateReducer = (state, action) => {
|
|
|
1411
1426
|
case "undelivered":
|
|
1412
1427
|
return {
|
|
1413
1428
|
...state,
|
|
1414
|
-
queued: action.keepQueued ? state.queued :
|
|
1429
|
+
queued: action.keepQueued ? state.queued : sentToOtherTab(state.queued),
|
|
1415
1430
|
undelivered: action.texts
|
|
1416
1431
|
};
|
|
1432
|
+
case "remote-send":
|
|
1433
|
+
return state.queued.some((q) => q.id === action.id) ? state : {
|
|
1434
|
+
...state,
|
|
1435
|
+
queued: [
|
|
1436
|
+
...state.queued,
|
|
1437
|
+
{ id: action.id, text: action.text, sentTo: "another-tab" }
|
|
1438
|
+
]
|
|
1439
|
+
};
|
|
1440
|
+
case "remote-answer": {
|
|
1441
|
+
const queued = state.queued.filter((q) => q.id !== action.id);
|
|
1442
|
+
return action.answer === "refused" ? { ...state, queued, undelivered: [...state.undelivered, action.text] } : { ...state, queued };
|
|
1443
|
+
}
|
|
1417
1444
|
case "load": {
|
|
1418
1445
|
const maxSeq = action.messages.reduce((n, m) => {
|
|
1419
1446
|
const k = Number(/^msg-(\d+)$/.exec(m.id)?.[1] ?? -1);
|
|
@@ -1667,18 +1694,16 @@ var useAgent = (config, options = {}) => {
|
|
|
1667
1694
|
);
|
|
1668
1695
|
runRef.current = run;
|
|
1669
1696
|
const send = useCallback((text) => controlRef.current?.send(text) ?? false, []);
|
|
1697
|
+
const remoteSendsRef = useRef(0);
|
|
1670
1698
|
const sendRemote = useCallback((text) => {
|
|
1671
1699
|
const watch = watchRef.current;
|
|
1672
1700
|
const clean = typeof text === "string" ? text.trim() : "";
|
|
1673
1701
|
if (!watch?.state.running || !clean) return false;
|
|
1702
|
+
const id = `to-other-tab-${remoteSendsRef.current += 1}`;
|
|
1703
|
+
dispatch({ type: "remote-send", id, text: clean });
|
|
1674
1704
|
void watch.send(clean).then((ok) => {
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
type: "undelivered",
|
|
1678
|
-
texts: [...stateRef.current.undelivered, clean],
|
|
1679
|
-
keepQueued: true
|
|
1680
|
-
});
|
|
1681
|
-
}
|
|
1705
|
+
const answer = remoteAnswerOf(ok, watchRef.current === watch);
|
|
1706
|
+
dispatch({ type: "remote-answer", id, text: clean, answer });
|
|
1682
1707
|
});
|
|
1683
1708
|
return true;
|
|
1684
1709
|
}, []);
|
|
@@ -2031,6 +2056,22 @@ var renumber = (own, after) => {
|
|
|
2031
2056
|
);
|
|
2032
2057
|
return own.map((m) => ({ ...m, id: `msg-${next += 1}` }));
|
|
2033
2058
|
};
|
|
2059
|
+
var turnAt = (m) => typeof m.startedAt === "number" && Number.isFinite(m.startedAt) ? m.startedAt : void 0;
|
|
2060
|
+
var placeByTurn = (stored, own) => {
|
|
2061
|
+
let i = stored.length;
|
|
2062
|
+
while (i > 0 && turnAt(stored[i - 1]) !== void 0) i -= 1;
|
|
2063
|
+
const out = stored.slice(0, i);
|
|
2064
|
+
for (const m of own) {
|
|
2065
|
+
const at = turnAt(m);
|
|
2066
|
+
while (i < stored.length && (at === void 0 || turnAt(stored[i]) <= at)) {
|
|
2067
|
+
out.push(stored[i]);
|
|
2068
|
+
i += 1;
|
|
2069
|
+
}
|
|
2070
|
+
out.push(m);
|
|
2071
|
+
}
|
|
2072
|
+
return [...out, ...stored.slice(i)];
|
|
2073
|
+
};
|
|
2074
|
+
var ownUnsaved = (messages, base) => messages.some((m) => !m.remote && !base?.known.has(m));
|
|
2034
2075
|
var unchangedSince = (messages, base) => base !== void 0 && messages.length === base.known.size && messages.every((m) => base.known.has(m));
|
|
2035
2076
|
var mergeChatRecord = (view, stored, base, texts) => {
|
|
2036
2077
|
const local = view.messages.filter((m) => !m.remote);
|
|
@@ -2038,7 +2079,7 @@ var mergeChatRecord = (view, stored, base, texts) => {
|
|
|
2038
2079
|
return { record: { ...view, messages: local }, merged: false };
|
|
2039
2080
|
}
|
|
2040
2081
|
const own = local.filter((m) => !base?.known.has(m));
|
|
2041
|
-
const messages =
|
|
2082
|
+
const messages = placeByTurn(stored.messages, renumber(own, stored.messages));
|
|
2042
2083
|
return {
|
|
2043
2084
|
record: {
|
|
2044
2085
|
...view,
|
|
@@ -2151,9 +2192,10 @@ var useChatHistory = (agent, options = {}) => {
|
|
|
2151
2192
|
void select(sessionId);
|
|
2152
2193
|
return;
|
|
2153
2194
|
}
|
|
2154
|
-
if (
|
|
2195
|
+
if (messages.length === 0) return;
|
|
2155
2196
|
const base = baseRef.current?.id === sessionId ? baseRef.current : void 0;
|
|
2156
2197
|
if (unchangedSince(messages, base)) return;
|
|
2198
|
+
if (remote && !ownUnsaved(messages, base)) return;
|
|
2157
2199
|
const now = Date.now();
|
|
2158
2200
|
const createdAt = createdRef.current.get(sessionId) ?? now;
|
|
2159
2201
|
createdRef.current.set(sessionId, createdAt);
|
|
@@ -2602,189 +2644,6 @@ var useAudioRecorder = (options = {}) => {
|
|
|
2602
2644
|
|
|
2603
2645
|
// src/hooks/use-read-aloud.ts
|
|
2604
2646
|
import { useCallback as useCallback6, useEffect as useEffect6, useRef as useRef5, useState as useState6 } from "react";
|
|
2605
|
-
var useReadAloud = (speak, lang) => {
|
|
2606
|
-
const [current, setCurrent] = useState6();
|
|
2607
|
-
const [state, setState] = useState6();
|
|
2608
|
-
const [failed, setFailed] = useState6();
|
|
2609
|
-
const playback = useRef5(void 0);
|
|
2610
|
-
const langRef = useRef5(lang);
|
|
2611
|
-
langRef.current = lang;
|
|
2612
|
-
const stop = useCallback6(() => {
|
|
2613
|
-
const now = playback.current;
|
|
2614
|
-
playback.current = void 0;
|
|
2615
|
-
now?.handle.stop();
|
|
2616
|
-
setCurrent(void 0);
|
|
2617
|
-
setState(void 0);
|
|
2618
|
-
}, []);
|
|
2619
|
-
const start = useCallback6(
|
|
2620
|
-
(id, text) => {
|
|
2621
|
-
if (!speak) return;
|
|
2622
|
-
stop();
|
|
2623
|
-
setFailed(void 0);
|
|
2624
|
-
setCurrent(id);
|
|
2625
|
-
setState("loading");
|
|
2626
|
-
const mine = { id, handle: void 0 };
|
|
2627
|
-
playback.current = mine;
|
|
2628
|
-
let handle;
|
|
2629
|
-
try {
|
|
2630
|
-
handle = speak(text, {
|
|
2631
|
-
lang: langRef.current,
|
|
2632
|
-
onState: (s) => {
|
|
2633
|
-
if (playback.current === mine) setState(s);
|
|
2634
|
-
}
|
|
2635
|
-
});
|
|
2636
|
-
} catch (err) {
|
|
2637
|
-
playback.current = void 0;
|
|
2638
|
-
setCurrent(void 0);
|
|
2639
|
-
setState(void 0);
|
|
2640
|
-
const own = err instanceof Error && err.name !== "SpeechOutputError";
|
|
2641
|
-
setFailed({ id, ...own && err.message ? { message: err.message } : {} });
|
|
2642
|
-
return;
|
|
2643
|
-
}
|
|
2644
|
-
mine.handle = handle;
|
|
2645
|
-
handle.done.then(
|
|
2646
|
-
() => {
|
|
2647
|
-
if (playback.current !== mine) return;
|
|
2648
|
-
playback.current = void 0;
|
|
2649
|
-
setCurrent(void 0);
|
|
2650
|
-
setState(void 0);
|
|
2651
|
-
},
|
|
2652
|
-
(err) => {
|
|
2653
|
-
if (playback.current !== mine) return;
|
|
2654
|
-
playback.current = void 0;
|
|
2655
|
-
setCurrent(void 0);
|
|
2656
|
-
setState(void 0);
|
|
2657
|
-
const own = err instanceof Error && err.name !== "SpeechOutputError";
|
|
2658
|
-
setFailed({ id, ...own && err.message ? { message: err.message } : {} });
|
|
2659
|
-
}
|
|
2660
|
-
);
|
|
2661
|
-
},
|
|
2662
|
-
[speak, stop]
|
|
2663
|
-
);
|
|
2664
|
-
useEffect6(() => stop, [speak, stop]);
|
|
2665
|
-
return {
|
|
2666
|
-
current,
|
|
2667
|
-
state,
|
|
2668
|
-
failed,
|
|
2669
|
-
start,
|
|
2670
|
-
pause: () => playback.current?.handle.pause(),
|
|
2671
|
-
resume: () => playback.current?.handle.resume(),
|
|
2672
|
-
stop
|
|
2673
|
-
};
|
|
2674
|
-
};
|
|
2675
|
-
|
|
2676
|
-
// src/hooks/use-speech-voices.ts
|
|
2677
|
-
import { useEffect as useEffect7, useState as useState7 } from "react";
|
|
2678
|
-
var useSpeechVoices = () => {
|
|
2679
|
-
const synth = typeof globalThis !== "undefined" ? globalThis.speechSynthesis : void 0;
|
|
2680
|
-
const read = () => {
|
|
2681
|
-
try {
|
|
2682
|
-
return (synth?.getVoices() ?? []).map((v) => ({
|
|
2683
|
-
voiceURI: v.voiceURI,
|
|
2684
|
-
name: v.name,
|
|
2685
|
-
lang: v.lang,
|
|
2686
|
-
localService: v.localService,
|
|
2687
|
-
default: v.default
|
|
2688
|
-
}));
|
|
2689
|
-
} catch {
|
|
2690
|
-
return [];
|
|
2691
|
-
}
|
|
2692
|
-
};
|
|
2693
|
-
const [voices, setVoices] = useState7(read);
|
|
2694
|
-
useEffect7(() => {
|
|
2695
|
-
if (!synth) return;
|
|
2696
|
-
const update = () => setVoices(read());
|
|
2697
|
-
update();
|
|
2698
|
-
synth.addEventListener?.("voiceschanged", update);
|
|
2699
|
-
return () => synth.removeEventListener?.("voiceschanged", update);
|
|
2700
|
-
}, [synth]);
|
|
2701
|
-
return voices;
|
|
2702
|
-
};
|
|
2703
|
-
|
|
2704
|
-
// src/voice/recognizer.ts
|
|
2705
|
-
var createRecordingRecognizer = (options) => () => {
|
|
2706
|
-
let recording;
|
|
2707
|
-
let starting;
|
|
2708
|
-
let stopAsked = false;
|
|
2709
|
-
let aborted = false;
|
|
2710
|
-
let ended = false;
|
|
2711
|
-
const controller = new AbortController();
|
|
2712
|
-
const rec = {
|
|
2713
|
-
lang: "",
|
|
2714
|
-
continuous: true,
|
|
2715
|
-
interimResults: false,
|
|
2716
|
-
onresult: null,
|
|
2717
|
-
onerror: null,
|
|
2718
|
-
onend: null,
|
|
2719
|
-
start() {
|
|
2720
|
-
if (starting) return;
|
|
2721
|
-
starting = (async () => {
|
|
2722
|
-
try {
|
|
2723
|
-
recording = await startRecording({
|
|
2724
|
-
...options,
|
|
2725
|
-
maxMs: options.maxMs,
|
|
2726
|
-
onLimit: () => rec.stop()
|
|
2727
|
-
});
|
|
2728
|
-
} catch (err) {
|
|
2729
|
-
if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
|
|
2730
|
-
return finish();
|
|
2731
|
-
}
|
|
2732
|
-
if (aborted) {
|
|
2733
|
-
recording.cancel();
|
|
2734
|
-
return finish();
|
|
2735
|
-
}
|
|
2736
|
-
if (stopAsked) void transcribeNow();
|
|
2737
|
-
})();
|
|
2738
|
-
},
|
|
2739
|
-
stop() {
|
|
2740
|
-
if (stopAsked || ended) return;
|
|
2741
|
-
stopAsked = true;
|
|
2742
|
-
if (recording) void transcribeNow();
|
|
2743
|
-
},
|
|
2744
|
-
abort() {
|
|
2745
|
-
if (ended) return;
|
|
2746
|
-
aborted = true;
|
|
2747
|
-
controller.abort();
|
|
2748
|
-
recording?.cancel();
|
|
2749
|
-
if (!starting || recording) finish();
|
|
2750
|
-
}
|
|
2751
|
-
};
|
|
2752
|
-
const finish = () => {
|
|
2753
|
-
if (ended) return;
|
|
2754
|
-
ended = true;
|
|
2755
|
-
rec.onend?.();
|
|
2756
|
-
};
|
|
2757
|
-
let transcribing = false;
|
|
2758
|
-
const transcribeNow = async () => {
|
|
2759
|
-
if (transcribing || !recording) return;
|
|
2760
|
-
transcribing = true;
|
|
2761
|
-
let audio;
|
|
2762
|
-
try {
|
|
2763
|
-
audio = await recording.stop();
|
|
2764
|
-
} catch (err) {
|
|
2765
|
-
if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
|
|
2766
|
-
return finish();
|
|
2767
|
-
}
|
|
2768
|
-
if (aborted) return finish();
|
|
2769
|
-
if (audio.blob.size === 0) return finish();
|
|
2770
|
-
try {
|
|
2771
|
-
const text = (await options.transcribe(audio, { lang: rec.lang, signal: controller.signal })).replace(/\s+/g, " ").trim();
|
|
2772
|
-
if (!aborted && text)
|
|
2773
|
-
rec.onresult?.({
|
|
2774
|
-
resultIndex: 0,
|
|
2775
|
-
results: [{ isFinal: true, 0: { transcript: text } }]
|
|
2776
|
-
});
|
|
2777
|
-
} catch (err) {
|
|
2778
|
-
if (!aborted)
|
|
2779
|
-
rec.onerror?.({
|
|
2780
|
-
error: "transcription",
|
|
2781
|
-
message: err instanceof Error ? err.message : String(err)
|
|
2782
|
-
});
|
|
2783
|
-
}
|
|
2784
|
-
finish();
|
|
2785
|
-
};
|
|
2786
|
-
return rec;
|
|
2787
|
-
};
|
|
2788
2647
|
|
|
2789
2648
|
// src/voice/speak.ts
|
|
2790
2649
|
var SpeechOutputError = class extends Error {
|
|
@@ -2851,10 +2710,98 @@ var splitForSpeech = (text, max = 220) => {
|
|
|
2851
2710
|
if (rest) pieces.push(rest);
|
|
2852
2711
|
return pieces;
|
|
2853
2712
|
};
|
|
2713
|
+
var SCRIPT_RANGES = [
|
|
2714
|
+
["latin", /\p{Script=Latin}/u],
|
|
2715
|
+
["cyrillic", /\p{Script=Cyrillic}/u],
|
|
2716
|
+
["greek", /\p{Script=Greek}/u],
|
|
2717
|
+
["arabic", /\p{Script=Arabic}/u],
|
|
2718
|
+
["hebrew", /\p{Script=Hebrew}/u],
|
|
2719
|
+
["kana", /[\p{Script=Hiragana}\p{Script=Katakana}]/u],
|
|
2720
|
+
["han", /\p{Script=Han}/u],
|
|
2721
|
+
["hangul", /\p{Script=Hangul}/u],
|
|
2722
|
+
["devanagari", /\p{Script=Devanagari}/u],
|
|
2723
|
+
["thai", /\p{Script=Thai}/u],
|
|
2724
|
+
["georgian", /\p{Script=Georgian}/u],
|
|
2725
|
+
["armenian", /\p{Script=Armenian}/u]
|
|
2726
|
+
];
|
|
2727
|
+
var LANGUAGE_SCRIPT = {
|
|
2728
|
+
ru: "cyrillic",
|
|
2729
|
+
uk: "cyrillic",
|
|
2730
|
+
be: "cyrillic",
|
|
2731
|
+
bg: "cyrillic",
|
|
2732
|
+
sr: "cyrillic",
|
|
2733
|
+
mk: "cyrillic",
|
|
2734
|
+
kk: "cyrillic",
|
|
2735
|
+
ky: "cyrillic",
|
|
2736
|
+
tg: "cyrillic",
|
|
2737
|
+
mn: "cyrillic",
|
|
2738
|
+
el: "greek",
|
|
2739
|
+
ar: "arabic",
|
|
2740
|
+
fa: "arabic",
|
|
2741
|
+
ur: "arabic",
|
|
2742
|
+
he: "hebrew",
|
|
2743
|
+
yi: "hebrew",
|
|
2744
|
+
zh: "han",
|
|
2745
|
+
ja: "kana",
|
|
2746
|
+
ko: "hangul",
|
|
2747
|
+
hi: "devanagari",
|
|
2748
|
+
mr: "devanagari",
|
|
2749
|
+
ne: "devanagari",
|
|
2750
|
+
th: "thai",
|
|
2751
|
+
ka: "georgian",
|
|
2752
|
+
hy: "armenian"
|
|
2753
|
+
};
|
|
2754
|
+
var SCRIPT_DEFAULT = {
|
|
2755
|
+
latin: "en",
|
|
2756
|
+
cyrillic: "ru",
|
|
2757
|
+
greek: "el",
|
|
2758
|
+
arabic: "ar",
|
|
2759
|
+
hebrew: "he",
|
|
2760
|
+
han: "zh",
|
|
2761
|
+
kana: "ja",
|
|
2762
|
+
hangul: "ko",
|
|
2763
|
+
devanagari: "hi",
|
|
2764
|
+
thai: "th",
|
|
2765
|
+
georgian: "ka",
|
|
2766
|
+
armenian: "hy"
|
|
2767
|
+
};
|
|
2768
|
+
var scriptOfLanguage = (lang) => {
|
|
2769
|
+
const parts = lang.toLowerCase().replace(/_/g, "-").split("-");
|
|
2770
|
+
if (parts.includes("latn")) return "latin";
|
|
2771
|
+
if (parts.includes("cyrl")) return "cyrillic";
|
|
2772
|
+
return LANGUAGE_SCRIPT[parts[0]] ?? "latin";
|
|
2773
|
+
};
|
|
2774
|
+
var scriptOfText = (text) => {
|
|
2775
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2776
|
+
for (const ch of text) {
|
|
2777
|
+
if (!/\p{L}/u.test(ch)) continue;
|
|
2778
|
+
const found = SCRIPT_RANGES.find(([, re]) => re.test(ch));
|
|
2779
|
+
if (!found) continue;
|
|
2780
|
+
counts.set(found[0], (counts.get(found[0]) ?? 0) + 1);
|
|
2781
|
+
}
|
|
2782
|
+
if (counts.has("kana")) {
|
|
2783
|
+
counts.set("kana", (counts.get("kana") ?? 0) + (counts.get("han") ?? 0));
|
|
2784
|
+
counts.delete("han");
|
|
2785
|
+
}
|
|
2786
|
+
let best;
|
|
2787
|
+
let most = 0;
|
|
2788
|
+
for (const [script, n] of counts)
|
|
2789
|
+
if (n > most) {
|
|
2790
|
+
best = script;
|
|
2791
|
+
most = n;
|
|
2792
|
+
}
|
|
2793
|
+
return best;
|
|
2794
|
+
};
|
|
2795
|
+
var languageOfText = (text, preferred = []) => {
|
|
2796
|
+
const mine = preferred.filter((l) => Boolean(l));
|
|
2797
|
+
const script = scriptOfText(text);
|
|
2798
|
+
if (!script) return mine[0];
|
|
2799
|
+
return mine.find((l) => scriptOfLanguage(l) === script) ?? SCRIPT_DEFAULT[script];
|
|
2800
|
+
};
|
|
2854
2801
|
var voiceFor = (voices, lang, preferred) => {
|
|
2855
2802
|
if (preferred) {
|
|
2856
2803
|
const chosen = voices.find((v) => v.voiceURI === preferred);
|
|
2857
|
-
if (chosen) return chosen;
|
|
2804
|
+
if (chosen && (!lang || scriptOfLanguage(chosen.lang) === scriptOfLanguage(lang))) return chosen;
|
|
2858
2805
|
}
|
|
2859
2806
|
if (!lang) return void 0;
|
|
2860
2807
|
const norm = (l) => l.toLowerCase().replace(/_/g, "-");
|
|
@@ -3068,6 +3015,193 @@ var createAudioSpeaker = (options) => (text, { lang, onState }) => {
|
|
|
3068
3015
|
};
|
|
3069
3016
|
};
|
|
3070
3017
|
|
|
3018
|
+
// src/hooks/use-read-aloud.ts
|
|
3019
|
+
var browserLanguages = () => typeof navigator !== "undefined" && Array.isArray(navigator.languages) ? navigator.languages : [];
|
|
3020
|
+
var useReadAloud = (speak, lang) => {
|
|
3021
|
+
const [current, setCurrent] = useState6();
|
|
3022
|
+
const [state, setState] = useState6();
|
|
3023
|
+
const [failed, setFailed] = useState6();
|
|
3024
|
+
const playback = useRef5(void 0);
|
|
3025
|
+
const langRef = useRef5(lang);
|
|
3026
|
+
langRef.current = lang;
|
|
3027
|
+
const stop = useCallback6(() => {
|
|
3028
|
+
const now = playback.current;
|
|
3029
|
+
playback.current = void 0;
|
|
3030
|
+
now?.handle.stop();
|
|
3031
|
+
setCurrent(void 0);
|
|
3032
|
+
setState(void 0);
|
|
3033
|
+
}, []);
|
|
3034
|
+
const start = useCallback6(
|
|
3035
|
+
(id, text) => {
|
|
3036
|
+
if (!speak) return;
|
|
3037
|
+
stop();
|
|
3038
|
+
setFailed(void 0);
|
|
3039
|
+
setCurrent(id);
|
|
3040
|
+
setState("loading");
|
|
3041
|
+
const mine = { id, handle: void 0 };
|
|
3042
|
+
playback.current = mine;
|
|
3043
|
+
let handle;
|
|
3044
|
+
try {
|
|
3045
|
+
handle = speak(text, {
|
|
3046
|
+
// The TEXT's language: a Russian answer in an English interface is read in Russian.
|
|
3047
|
+
lang: languageOfText(text, [langRef.current, ...browserLanguages()]),
|
|
3048
|
+
onState: (s) => {
|
|
3049
|
+
if (playback.current === mine) setState(s);
|
|
3050
|
+
}
|
|
3051
|
+
});
|
|
3052
|
+
} catch (err) {
|
|
3053
|
+
playback.current = void 0;
|
|
3054
|
+
setCurrent(void 0);
|
|
3055
|
+
setState(void 0);
|
|
3056
|
+
const own = err instanceof Error && err.name !== "SpeechOutputError";
|
|
3057
|
+
setFailed({ id, ...own && err.message ? { message: err.message } : {} });
|
|
3058
|
+
return;
|
|
3059
|
+
}
|
|
3060
|
+
mine.handle = handle;
|
|
3061
|
+
handle.done.then(
|
|
3062
|
+
() => {
|
|
3063
|
+
if (playback.current !== mine) return;
|
|
3064
|
+
playback.current = void 0;
|
|
3065
|
+
setCurrent(void 0);
|
|
3066
|
+
setState(void 0);
|
|
3067
|
+
},
|
|
3068
|
+
(err) => {
|
|
3069
|
+
if (playback.current !== mine) return;
|
|
3070
|
+
playback.current = void 0;
|
|
3071
|
+
setCurrent(void 0);
|
|
3072
|
+
setState(void 0);
|
|
3073
|
+
const own = err instanceof Error && err.name !== "SpeechOutputError";
|
|
3074
|
+
setFailed({ id, ...own && err.message ? { message: err.message } : {} });
|
|
3075
|
+
}
|
|
3076
|
+
);
|
|
3077
|
+
},
|
|
3078
|
+
[speak, stop]
|
|
3079
|
+
);
|
|
3080
|
+
useEffect6(() => stop, [speak, stop]);
|
|
3081
|
+
return {
|
|
3082
|
+
current,
|
|
3083
|
+
state,
|
|
3084
|
+
failed,
|
|
3085
|
+
start,
|
|
3086
|
+
pause: () => playback.current?.handle.pause(),
|
|
3087
|
+
resume: () => playback.current?.handle.resume(),
|
|
3088
|
+
stop
|
|
3089
|
+
};
|
|
3090
|
+
};
|
|
3091
|
+
|
|
3092
|
+
// src/hooks/use-speech-voices.ts
|
|
3093
|
+
import { useEffect as useEffect7, useState as useState7 } from "react";
|
|
3094
|
+
var useSpeechVoices = () => {
|
|
3095
|
+
const synth = typeof globalThis !== "undefined" ? globalThis.speechSynthesis : void 0;
|
|
3096
|
+
const read = () => {
|
|
3097
|
+
try {
|
|
3098
|
+
return (synth?.getVoices() ?? []).map((v) => ({
|
|
3099
|
+
voiceURI: v.voiceURI,
|
|
3100
|
+
name: v.name,
|
|
3101
|
+
lang: v.lang,
|
|
3102
|
+
localService: v.localService,
|
|
3103
|
+
default: v.default
|
|
3104
|
+
}));
|
|
3105
|
+
} catch {
|
|
3106
|
+
return [];
|
|
3107
|
+
}
|
|
3108
|
+
};
|
|
3109
|
+
const [voices, setVoices] = useState7(read);
|
|
3110
|
+
useEffect7(() => {
|
|
3111
|
+
if (!synth) return;
|
|
3112
|
+
const update = () => setVoices(read());
|
|
3113
|
+
update();
|
|
3114
|
+
synth.addEventListener?.("voiceschanged", update);
|
|
3115
|
+
return () => synth.removeEventListener?.("voiceschanged", update);
|
|
3116
|
+
}, [synth]);
|
|
3117
|
+
return voices;
|
|
3118
|
+
};
|
|
3119
|
+
|
|
3120
|
+
// src/voice/recognizer.ts
|
|
3121
|
+
var createRecordingRecognizer = (options) => () => {
|
|
3122
|
+
let recording;
|
|
3123
|
+
let starting;
|
|
3124
|
+
let stopAsked = false;
|
|
3125
|
+
let aborted = false;
|
|
3126
|
+
let ended = false;
|
|
3127
|
+
const controller = new AbortController();
|
|
3128
|
+
const rec = {
|
|
3129
|
+
lang: "",
|
|
3130
|
+
continuous: true,
|
|
3131
|
+
interimResults: false,
|
|
3132
|
+
onresult: null,
|
|
3133
|
+
onerror: null,
|
|
3134
|
+
onend: null,
|
|
3135
|
+
start() {
|
|
3136
|
+
if (starting) return;
|
|
3137
|
+
starting = (async () => {
|
|
3138
|
+
try {
|
|
3139
|
+
recording = await startRecording({
|
|
3140
|
+
...options,
|
|
3141
|
+
maxMs: options.maxMs,
|
|
3142
|
+
onLimit: () => rec.stop()
|
|
3143
|
+
});
|
|
3144
|
+
} catch (err) {
|
|
3145
|
+
if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
|
|
3146
|
+
return finish();
|
|
3147
|
+
}
|
|
3148
|
+
if (aborted) {
|
|
3149
|
+
recording.cancel();
|
|
3150
|
+
return finish();
|
|
3151
|
+
}
|
|
3152
|
+
if (stopAsked) void transcribeNow();
|
|
3153
|
+
})();
|
|
3154
|
+
},
|
|
3155
|
+
stop() {
|
|
3156
|
+
if (stopAsked || ended) return;
|
|
3157
|
+
stopAsked = true;
|
|
3158
|
+
if (recording) void transcribeNow();
|
|
3159
|
+
},
|
|
3160
|
+
abort() {
|
|
3161
|
+
if (ended) return;
|
|
3162
|
+
aborted = true;
|
|
3163
|
+
controller.abort();
|
|
3164
|
+
recording?.cancel();
|
|
3165
|
+
if (!starting || recording) finish();
|
|
3166
|
+
}
|
|
3167
|
+
};
|
|
3168
|
+
const finish = () => {
|
|
3169
|
+
if (ended) return;
|
|
3170
|
+
ended = true;
|
|
3171
|
+
rec.onend?.();
|
|
3172
|
+
};
|
|
3173
|
+
let transcribing = false;
|
|
3174
|
+
const transcribeNow = async () => {
|
|
3175
|
+
if (transcribing || !recording) return;
|
|
3176
|
+
transcribing = true;
|
|
3177
|
+
let audio;
|
|
3178
|
+
try {
|
|
3179
|
+
audio = await recording.stop();
|
|
3180
|
+
} catch (err) {
|
|
3181
|
+
if (!aborted) rec.onerror?.({ error: micProblemOf(err) });
|
|
3182
|
+
return finish();
|
|
3183
|
+
}
|
|
3184
|
+
if (aborted) return finish();
|
|
3185
|
+
if (audio.blob.size === 0) return finish();
|
|
3186
|
+
try {
|
|
3187
|
+
const text = (await options.transcribe(audio, { lang: rec.lang, signal: controller.signal })).replace(/\s+/g, " ").trim();
|
|
3188
|
+
if (!aborted && text)
|
|
3189
|
+
rec.onresult?.({
|
|
3190
|
+
resultIndex: 0,
|
|
3191
|
+
results: [{ isFinal: true, 0: { transcript: text } }]
|
|
3192
|
+
});
|
|
3193
|
+
} catch (err) {
|
|
3194
|
+
if (!aborted)
|
|
3195
|
+
rec.onerror?.({
|
|
3196
|
+
error: "transcription",
|
|
3197
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
finish();
|
|
3201
|
+
};
|
|
3202
|
+
return rec;
|
|
3203
|
+
};
|
|
3204
|
+
|
|
3071
3205
|
// src/hooks/use-credentials.ts
|
|
3072
3206
|
import { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo3, useState as useState8 } from "react";
|
|
3073
3207
|
import * as core5 from "@dudko.dev/agent-web";
|
|
@@ -3485,6 +3619,11 @@ var defaultLabels = {
|
|
|
3485
3619
|
notebookForget: "Forget",
|
|
3486
3620
|
notebookRevision: (n) => `revision ${n}`,
|
|
3487
3621
|
notebookFrom: "from",
|
|
3622
|
+
memorySaved: "Remembered",
|
|
3623
|
+
memoryUpdated: "Memory updated",
|
|
3624
|
+
memoryForgotten: "Forgotten",
|
|
3625
|
+
memoryUndo: "Undo",
|
|
3626
|
+
memoryUndone: "Undone",
|
|
3488
3627
|
placeholder: "Ask the agent to do something\u2026 ( / for commands, Ctrl+V to paste an image )",
|
|
3489
3628
|
listening: "Listening\u2026",
|
|
3490
3629
|
message: "Message",
|
|
@@ -3584,6 +3723,7 @@ var defaultLabels = {
|
|
|
3584
3723
|
noAttachmentsWhileBusy: "Files can\u2019t be added while the agent is working \u2014 send them with your next message.",
|
|
3585
3724
|
queuedWaiting: "waiting for the agent\u2019s next step",
|
|
3586
3725
|
queuedForSession: (heldBy) => heldBy === "this-tab" ? "waiting for the other run to finish" : "waiting for the other tab to finish",
|
|
3726
|
+
queuedForOtherTab: "waiting for the other tab to pick it up",
|
|
3587
3727
|
noteAt: {
|
|
3588
3728
|
round: "you said, between tool calls",
|
|
3589
3729
|
step: "you said, after this step",
|
|
@@ -6255,6 +6395,47 @@ ${draftText}` : draftText);
|
|
|
6255
6395
|
if (full) noRoom[full].push(name);
|
|
6256
6396
|
else setPending((cur) => [...cur, a]);
|
|
6257
6397
|
};
|
|
6398
|
+
const sendAs = async (name, f, kind, mediaType, transform, id) => {
|
|
6399
|
+
const blob = transform === "downscale" ? await downscaleImage(f, {
|
|
6400
|
+
maxDimension: imageMax,
|
|
6401
|
+
maxPixels: attachCfg.imageMaxPixels
|
|
6402
|
+
}) : f;
|
|
6403
|
+
const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
|
|
6404
|
+
if (sentOver) return overLimitText(name, sentOver);
|
|
6405
|
+
add(name, {
|
|
6406
|
+
id,
|
|
6407
|
+
name,
|
|
6408
|
+
kind,
|
|
6409
|
+
mediaType: blob.type || mediaType,
|
|
6410
|
+
dataUrl: await readDataUrl2(blob),
|
|
6411
|
+
bytes: blob.size,
|
|
6412
|
+
...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
|
|
6413
|
+
});
|
|
6414
|
+
return void 0;
|
|
6415
|
+
};
|
|
6416
|
+
const addImage = async (name, blob, id) => {
|
|
6417
|
+
const mediaType = blob.type || "image/jpeg";
|
|
6418
|
+
if (attachmentKindOf(mediaType, name) !== "image") return L.binaryText(name);
|
|
6419
|
+
const transform = attachmentTransformOf({
|
|
6420
|
+
kind: "image",
|
|
6421
|
+
mediaType,
|
|
6422
|
+
imageMaxDimension: imageMax,
|
|
6423
|
+
converts: false
|
|
6424
|
+
});
|
|
6425
|
+
const size = transform === "downscale" ? await imageSizeOf(blob) : void 0;
|
|
6426
|
+
const over = attachmentOverLimit(
|
|
6427
|
+
{ bytes: blob.size, pixels: size && size.width * size.height },
|
|
6428
|
+
"original",
|
|
6429
|
+
transform,
|
|
6430
|
+
bounds
|
|
6431
|
+
);
|
|
6432
|
+
if (over) return overLimitText(name, over);
|
|
6433
|
+
if (messageOverLimit(pendingRef.current, { kind: "image", bytes: 0 }, bounds) === "images") {
|
|
6434
|
+
noRoom.images.push(name);
|
|
6435
|
+
return void 0;
|
|
6436
|
+
}
|
|
6437
|
+
return sendAs(name, blob, "image", mediaType, transform, id);
|
|
6438
|
+
};
|
|
6258
6439
|
for (const f of list) {
|
|
6259
6440
|
const mediaType = f.type || "application/octet-stream";
|
|
6260
6441
|
const name = f.name || `pasted-${Date.now()}.${mediaType.split("/")[1] ?? "bin"}`;
|
|
@@ -6293,9 +6474,9 @@ ${draftText}` : draftText);
|
|
|
6293
6474
|
const converted = await convertFile(f);
|
|
6294
6475
|
if (converted) {
|
|
6295
6476
|
const bytes = new Blob([converted.text]).size;
|
|
6296
|
-
const
|
|
6297
|
-
if (
|
|
6298
|
-
problem = overLimitText(name,
|
|
6477
|
+
const sentOver = attachmentOverLimit({ bytes }, "sent", transform, bounds);
|
|
6478
|
+
if (sentOver) {
|
|
6479
|
+
problem = overLimitText(name, sentOver);
|
|
6299
6480
|
continue;
|
|
6300
6481
|
}
|
|
6301
6482
|
add(name, {
|
|
@@ -6305,8 +6486,18 @@ ${draftText}` : draftText);
|
|
|
6305
6486
|
mediaType: "text/markdown",
|
|
6306
6487
|
text: converted.text,
|
|
6307
6488
|
bytes,
|
|
6308
|
-
note: L.convertedFrom(name)
|
|
6489
|
+
note: converted.note ?? L.convertedFrom(name)
|
|
6309
6490
|
});
|
|
6491
|
+
const images = converted.images ?? [];
|
|
6492
|
+
if (images.length > 0) {
|
|
6493
|
+
const imageRefusal = attachmentRefusal("image", caps);
|
|
6494
|
+
if (imageRefusal) problem = imageRefusal;
|
|
6495
|
+
else
|
|
6496
|
+
for (const image of images) {
|
|
6497
|
+
const said3 = await addImage(image.name, image.blob, `att-${attachSeq += 1}`);
|
|
6498
|
+
if (said3) problem = said3;
|
|
6499
|
+
}
|
|
6500
|
+
}
|
|
6310
6501
|
continue;
|
|
6311
6502
|
}
|
|
6312
6503
|
}
|
|
@@ -6314,24 +6505,8 @@ ${draftText}` : draftText);
|
|
|
6314
6505
|
problem = refusal;
|
|
6315
6506
|
continue;
|
|
6316
6507
|
}
|
|
6317
|
-
const
|
|
6318
|
-
|
|
6319
|
-
maxPixels: attachCfg.imageMaxPixels
|
|
6320
|
-
}) : f;
|
|
6321
|
-
const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
|
|
6322
|
-
if (sentOver) {
|
|
6323
|
-
problem = overLimitText(name, sentOver);
|
|
6324
|
-
continue;
|
|
6325
|
-
}
|
|
6326
|
-
add(name, {
|
|
6327
|
-
id,
|
|
6328
|
-
name,
|
|
6329
|
-
kind,
|
|
6330
|
-
mediaType: blob.type || mediaType,
|
|
6331
|
-
dataUrl: await readDataUrl2(blob),
|
|
6332
|
-
bytes: blob.size,
|
|
6333
|
-
...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
|
|
6334
|
-
});
|
|
6508
|
+
const said2 = await sendAs(name, f, kind, mediaType, transform, id);
|
|
6509
|
+
if (said2) problem = said2;
|
|
6335
6510
|
} catch (err) {
|
|
6336
6511
|
problem = `${name}: ${err instanceof Error ? err.message : String(err)}`;
|
|
6337
6512
|
}
|
|
@@ -6583,7 +6758,7 @@ ${draftText}` : draftText);
|
|
|
6583
6758
|
/* @__PURE__ */ jsx5(ClockIcon, { size: 13, className: "awr-queued__icon" }),
|
|
6584
6759
|
/* @__PURE__ */ jsx5("span", { className: "awr-queued__text", title: q.text, children: q.text }),
|
|
6585
6760
|
q.origin === "another-tab" && /* @__PURE__ */ jsx5("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
|
|
6586
|
-
/* @__PURE__ */ jsx5("span", { className: "awr-queued__state", children: q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
|
|
6761
|
+
/* @__PURE__ */ jsx5("span", { className: "awr-queued__state", children: q.sentTo ? L.queuedForOtherTab : q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
|
|
6587
6762
|
] }, q.id)),
|
|
6588
6763
|
agent.undelivered.length > 0 && /* @__PURE__ */ jsxs3("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
|
|
6589
6764
|
/* @__PURE__ */ jsx5(AlertIcon, { size: 13, className: "awr-queued__icon" }),
|
|
@@ -8839,6 +9014,12 @@ var AttachmentView = ({
|
|
|
8839
9014
|
" ",
|
|
8840
9015
|
a.name
|
|
8841
9016
|
] });
|
|
9017
|
+
var toolCardsOf = (m, render) => (m.steps ?? []).flatMap(
|
|
9018
|
+
(step, s) => step.toolCalls.flatMap((call, c) => {
|
|
9019
|
+
const node = render(call, m);
|
|
9020
|
+
return node === null || node === void 0 || node === false ? [] : [{ key: `${s}:${c}`, node }];
|
|
9021
|
+
})
|
|
9022
|
+
);
|
|
8842
9023
|
var toolCallCount = (m) => (m.steps ?? []).reduce((n, s) => n + s.toolCalls.length, 0);
|
|
8843
9024
|
var activitySummary = (m, showToolCalls, showLearned, showTiers, showFileChips, L, showApps = false) => {
|
|
8844
9025
|
const steps = m.steps ?? [];
|
|
@@ -8884,6 +9065,8 @@ var MessageList = ({
|
|
|
8884
9065
|
renderMessage,
|
|
8885
9066
|
renderAttachment,
|
|
8886
9067
|
renderToolCall,
|
|
9068
|
+
renderToolCard,
|
|
9069
|
+
showToolCards = true,
|
|
8887
9070
|
renderApp,
|
|
8888
9071
|
showApps = true,
|
|
8889
9072
|
imageViewer = true,
|
|
@@ -8901,6 +9084,7 @@ var MessageList = ({
|
|
|
8901
9084
|
const steps = m.steps ?? [];
|
|
8902
9085
|
const hasActivity = showActivity && (steps.length > 0 || (m.subagents?.length ?? 0) > 0 || m.pending && !!liveExtra);
|
|
8903
9086
|
const usage = showUsage ? usageLine(m.usage, m.durationMs) : "";
|
|
9087
|
+
const cards = showToolCards && renderToolCard && m.role === "assistant" ? toolCardsOf(m, renderToolCard) : [];
|
|
8904
9088
|
const node = /* @__PURE__ */ jsx16(
|
|
8905
9089
|
"div",
|
|
8906
9090
|
{
|
|
@@ -8967,12 +9151,22 @@ var MessageList = ({
|
|
|
8967
9151
|
/* @__PURE__ */ jsx16("p", { className: "awr-thought__text", children: m.reasoning.trim() })
|
|
8968
9152
|
] })
|
|
8969
9153
|
] }),
|
|
9154
|
+
cards.length > 0 && /* @__PURE__ */ jsx16("div", { className: "awr-msg__cards", children: cards.map((card) => /* @__PURE__ */ jsx16("div", { className: "awr-msg__card", children: card.node }, card.key)) }),
|
|
8970
9155
|
showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ jsx16("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ jsx16("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
|
|
8971
9156
|
showMedia && m.transcripts?.length ? /* @__PURE__ */ jsx16("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ jsx16(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
|
|
8972
9157
|
(m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ jsxs14("div", { className: "awr-msg__bubble", children: [
|
|
8973
9158
|
m.content ? renderContent ? renderContent(m) : m.content : m.stopped && !m.pending ? /* @__PURE__ */ jsx16("span", { className: "awr-msg__stopped", children: L.answerStopped }) : null,
|
|
8974
9159
|
m.pending && !m.content && /* @__PURE__ */ jsx16(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
|
|
8975
9160
|
] }),
|
|
9161
|
+
readAloud && m.role === "assistant" && m.content && !m.pending && !m.error && /* @__PURE__ */ jsx16(
|
|
9162
|
+
ReadAloudControl,
|
|
9163
|
+
{
|
|
9164
|
+
id: m.id,
|
|
9165
|
+
text: () => readAloud.textOf ? readAloud.textOf(m) : speakableText(m.content, { code: L.readAloudCode }),
|
|
9166
|
+
reader,
|
|
9167
|
+
labels: L
|
|
9168
|
+
}
|
|
9169
|
+
),
|
|
8976
9170
|
showMedia && m.media?.length ? /* @__PURE__ */ jsx16("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
|
|
8977
9171
|
const built = /* @__PURE__ */ jsx16(GeneratedMedia, { media: item, files, labels }, i);
|
|
8978
9172
|
return renderMedia ? /* @__PURE__ */ jsx16("span", { className: "awr-msg__mediaitem", children: renderMedia(item, m, built) }, i) : built;
|
|
@@ -8998,15 +9192,6 @@ var MessageList = ({
|
|
|
8998
9192
|
children: m.attachments.map((a, i) => /* @__PURE__ */ jsx16("span", { className: "awr-msg__attachment", children: renderAttachment ? renderAttachment(a, m) : /* @__PURE__ */ jsx16(AttachmentView, { attachment: a, files, labels }) }, i))
|
|
8999
9193
|
}
|
|
9000
9194
|
) : null,
|
|
9001
|
-
readAloud && m.role === "assistant" && m.content && !m.pending && !m.error && /* @__PURE__ */ jsx16(
|
|
9002
|
-
ReadAloudControl,
|
|
9003
|
-
{
|
|
9004
|
-
id: m.id,
|
|
9005
|
-
text: () => readAloud.textOf ? readAloud.textOf(m) : speakableText(m.content, { code: L.readAloudCode }),
|
|
9006
|
-
reader,
|
|
9007
|
-
labels: L
|
|
9008
|
-
}
|
|
9009
|
-
),
|
|
9010
9195
|
m.role === "assistant" && usage && !m.pending && /* @__PURE__ */ jsx16("div", { className: "awr-msg__usage", title: L.usageTitle, children: usage })
|
|
9011
9196
|
] })
|
|
9012
9197
|
},
|
|
@@ -9631,6 +9816,8 @@ var AgentChatInner = ({
|
|
|
9631
9816
|
renderAttachment,
|
|
9632
9817
|
readAloud,
|
|
9633
9818
|
renderToolCall,
|
|
9819
|
+
renderToolCard,
|
|
9820
|
+
showToolCards = true,
|
|
9634
9821
|
renderSubagent,
|
|
9635
9822
|
renderMedia,
|
|
9636
9823
|
renderFile,
|
|
@@ -9942,6 +10129,8 @@ var AgentChatInner = ({
|
|
|
9942
10129
|
renderAttachment,
|
|
9943
10130
|
readAloud,
|
|
9944
10131
|
renderToolCall,
|
|
10132
|
+
renderToolCard,
|
|
10133
|
+
showToolCards,
|
|
9945
10134
|
showApps: appsOn,
|
|
9946
10135
|
renderApp: appsOn ? drawApp : void 0,
|
|
9947
10136
|
imageViewer,
|
|
@@ -10115,9 +10304,59 @@ var LearnedSkills = ({
|
|
|
10115
10304
|
] });
|
|
10116
10305
|
};
|
|
10117
10306
|
|
|
10118
|
-
// src/components/
|
|
10307
|
+
// src/components/MemoryCard.tsx
|
|
10119
10308
|
import { useState as useState21 } from "react";
|
|
10120
10309
|
import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
10310
|
+
var MemoryCard = ({
|
|
10311
|
+
kind,
|
|
10312
|
+
text,
|
|
10313
|
+
onUndo,
|
|
10314
|
+
undone = false,
|
|
10315
|
+
problem,
|
|
10316
|
+
labels,
|
|
10317
|
+
className
|
|
10318
|
+
}) => {
|
|
10319
|
+
const L = useLabels(labels);
|
|
10320
|
+
const [busy, setBusy] = useState21(false);
|
|
10321
|
+
const label = kind === "saved" ? L.memorySaved : kind === "updated" ? L.memoryUpdated : L.memoryForgotten;
|
|
10322
|
+
const undo = () => {
|
|
10323
|
+
if (!onUndo || busy) return;
|
|
10324
|
+
setBusy(true);
|
|
10325
|
+
void Promise.resolve().then(onUndo).catch(() => {
|
|
10326
|
+
}).finally(() => setBusy(false));
|
|
10327
|
+
};
|
|
10328
|
+
return /* @__PURE__ */ jsxs21(
|
|
10329
|
+
"div",
|
|
10330
|
+
{
|
|
10331
|
+
className: ["awr-memory", `awr-memory--${kind}`, undone ? "is-undone" : "", className].filter(Boolean).join(" "),
|
|
10332
|
+
"data-memory": kind,
|
|
10333
|
+
children: [
|
|
10334
|
+
/* @__PURE__ */ jsx22(BookmarkIcon, { size: 14, className: "awr-memory__icon" }),
|
|
10335
|
+
/* @__PURE__ */ jsxs21("div", { className: "awr-memory__body", children: [
|
|
10336
|
+
/* @__PURE__ */ jsx22("span", { className: "awr-memory__label", children: label }),
|
|
10337
|
+
/* @__PURE__ */ jsx22("span", { className: "awr-memory__text", children: text }),
|
|
10338
|
+
problem && /* @__PURE__ */ jsx22("span", { className: "awr-memory__problem", role: "alert", children: problem })
|
|
10339
|
+
] }),
|
|
10340
|
+
undone ? /* @__PURE__ */ jsx22("span", { className: "awr-memory__undone", children: L.memoryUndone }) : onUndo ? /* @__PURE__ */ jsx22(
|
|
10341
|
+
"button",
|
|
10342
|
+
{
|
|
10343
|
+
type: "button",
|
|
10344
|
+
className: "awr-memory__undo",
|
|
10345
|
+
disabled: busy,
|
|
10346
|
+
"aria-busy": busy,
|
|
10347
|
+
"aria-label": `${L.memoryUndo}: ${text}`,
|
|
10348
|
+
onClick: undo,
|
|
10349
|
+
children: L.memoryUndo
|
|
10350
|
+
}
|
|
10351
|
+
) : null
|
|
10352
|
+
]
|
|
10353
|
+
}
|
|
10354
|
+
);
|
|
10355
|
+
};
|
|
10356
|
+
|
|
10357
|
+
// src/components/Composer.tsx
|
|
10358
|
+
import { useState as useState22 } from "react";
|
|
10359
|
+
import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
10121
10360
|
var Composer = ({
|
|
10122
10361
|
onSubmit,
|
|
10123
10362
|
busy = false,
|
|
@@ -10126,7 +10365,7 @@ var Composer = ({
|
|
|
10126
10365
|
placeholder = "Ask the agent to do something\u2026",
|
|
10127
10366
|
className
|
|
10128
10367
|
}) => {
|
|
10129
|
-
const [text, setText] =
|
|
10368
|
+
const [text, setText] = useState22("");
|
|
10130
10369
|
const submit = () => {
|
|
10131
10370
|
const value = text.trim();
|
|
10132
10371
|
if (!value || busy || disabled) return;
|
|
@@ -10139,7 +10378,7 @@ var Composer = ({
|
|
|
10139
10378
|
submit();
|
|
10140
10379
|
}
|
|
10141
10380
|
};
|
|
10142
|
-
return /* @__PURE__ */
|
|
10381
|
+
return /* @__PURE__ */ jsxs22(
|
|
10143
10382
|
"form",
|
|
10144
10383
|
{
|
|
10145
10384
|
className: ["awr-composer", className].filter(Boolean).join(" "),
|
|
@@ -10148,7 +10387,7 @@ var Composer = ({
|
|
|
10148
10387
|
submit();
|
|
10149
10388
|
},
|
|
10150
10389
|
children: [
|
|
10151
|
-
/* @__PURE__ */
|
|
10390
|
+
/* @__PURE__ */ jsx23(
|
|
10152
10391
|
"textarea",
|
|
10153
10392
|
{
|
|
10154
10393
|
className: "awr-composer__input",
|
|
@@ -10160,23 +10399,23 @@ var Composer = ({
|
|
|
10160
10399
|
rows: 1
|
|
10161
10400
|
}
|
|
10162
10401
|
),
|
|
10163
|
-
busy ? /* @__PURE__ */
|
|
10402
|
+
busy ? /* @__PURE__ */ jsx23(
|
|
10164
10403
|
"button",
|
|
10165
10404
|
{
|
|
10166
10405
|
type: "button",
|
|
10167
10406
|
className: "awr-composer__btn awr-composer__btn--stop",
|
|
10168
10407
|
onClick: onStop,
|
|
10169
10408
|
"aria-label": "Stop",
|
|
10170
|
-
children: /* @__PURE__ */
|
|
10409
|
+
children: /* @__PURE__ */ jsx23(StopIcon, { size: 18 })
|
|
10171
10410
|
}
|
|
10172
|
-
) : /* @__PURE__ */
|
|
10411
|
+
) : /* @__PURE__ */ jsx23(
|
|
10173
10412
|
"button",
|
|
10174
10413
|
{
|
|
10175
10414
|
type: "submit",
|
|
10176
10415
|
className: "awr-composer__btn",
|
|
10177
10416
|
disabled: disabled || !text.trim(),
|
|
10178
10417
|
"aria-label": "Send",
|
|
10179
|
-
children: disabled ? /* @__PURE__ */
|
|
10418
|
+
children: disabled ? /* @__PURE__ */ jsx23(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ jsx23(SendIcon, { size: 18 })
|
|
10180
10419
|
}
|
|
10181
10420
|
)
|
|
10182
10421
|
]
|
|
@@ -10185,17 +10424,17 @@ var Composer = ({
|
|
|
10185
10424
|
};
|
|
10186
10425
|
|
|
10187
10426
|
// src/components/PlanView.tsx
|
|
10188
|
-
import { jsx as
|
|
10427
|
+
import { jsx as jsx24, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
10189
10428
|
var PlanView = ({ plan, showThought = true, className }) => {
|
|
10190
10429
|
if (!plan.steps.length && !plan.thought) return null;
|
|
10191
|
-
return /* @__PURE__ */
|
|
10192
|
-
showThought && plan.thought.trim() && /* @__PURE__ */
|
|
10193
|
-
plan.steps.length > 0 && /* @__PURE__ */
|
|
10430
|
+
return /* @__PURE__ */ jsxs23("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
|
|
10431
|
+
showThought && plan.thought.trim() && /* @__PURE__ */ jsx24("p", { className: "awr-plan__thought", children: plan.thought }),
|
|
10432
|
+
plan.steps.length > 0 && /* @__PURE__ */ jsx24("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ jsx24("li", { className: "awr-plan__step", children: step.description }, step.id)) })
|
|
10194
10433
|
] });
|
|
10195
10434
|
};
|
|
10196
10435
|
|
|
10197
10436
|
// src/components/ApprovalModeSwitch.tsx
|
|
10198
|
-
import { jsx as
|
|
10437
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
10199
10438
|
var DEFAULT_LABELS = {
|
|
10200
10439
|
autopilot: "Autopilot",
|
|
10201
10440
|
"ask-writes": "Ask before changes",
|
|
@@ -10215,13 +10454,13 @@ var ApprovalModeSwitch = ({
|
|
|
10215
10454
|
labels,
|
|
10216
10455
|
disabled,
|
|
10217
10456
|
className
|
|
10218
|
-
}) => /* @__PURE__ */
|
|
10457
|
+
}) => /* @__PURE__ */ jsx25(
|
|
10219
10458
|
"div",
|
|
10220
10459
|
{
|
|
10221
10460
|
className: ["awr-modeswitch", className].filter(Boolean).join(" "),
|
|
10222
10461
|
role: "radiogroup",
|
|
10223
10462
|
"aria-label": "Tool consent",
|
|
10224
|
-
children: modes.map((m) => /* @__PURE__ */
|
|
10463
|
+
children: modes.map((m) => /* @__PURE__ */ jsx25(
|
|
10225
10464
|
"button",
|
|
10226
10465
|
{
|
|
10227
10466
|
type: "button",
|
|
@@ -10239,8 +10478,8 @@ var ApprovalModeSwitch = ({
|
|
|
10239
10478
|
);
|
|
10240
10479
|
|
|
10241
10480
|
// src/components/ApiKeyForm.tsx
|
|
10242
|
-
import { useEffect as useEffect21, useState as
|
|
10243
|
-
import { jsx as
|
|
10481
|
+
import { useEffect as useEffect21, useState as useState23 } from "react";
|
|
10482
|
+
import { jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
10244
10483
|
var ApiKeyForm = ({
|
|
10245
10484
|
credentials,
|
|
10246
10485
|
credentialRef,
|
|
@@ -10249,9 +10488,9 @@ var ApiKeyForm = ({
|
|
|
10249
10488
|
onChange,
|
|
10250
10489
|
className
|
|
10251
10490
|
}) => {
|
|
10252
|
-
const [value, setValue] =
|
|
10253
|
-
const [present, setPresent] =
|
|
10254
|
-
const [busy, setBusy] =
|
|
10491
|
+
const [value, setValue] = useState23("");
|
|
10492
|
+
const [present, setPresent] = useState23(false);
|
|
10493
|
+
const [busy, setBusy] = useState23(false);
|
|
10255
10494
|
useEffect21(() => {
|
|
10256
10495
|
let active = true;
|
|
10257
10496
|
credentials.hasKey(credentialRef).then((has) => {
|
|
@@ -10284,16 +10523,16 @@ var ApiKeyForm = ({
|
|
|
10284
10523
|
setBusy(false);
|
|
10285
10524
|
}
|
|
10286
10525
|
};
|
|
10287
|
-
return /* @__PURE__ */
|
|
10288
|
-
/* @__PURE__ */
|
|
10526
|
+
return /* @__PURE__ */ jsxs24("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
|
|
10527
|
+
/* @__PURE__ */ jsxs24("label", { className: "awr-keyform__label", children: [
|
|
10289
10528
|
label,
|
|
10290
|
-
present && /* @__PURE__ */
|
|
10291
|
-
/* @__PURE__ */
|
|
10529
|
+
present && /* @__PURE__ */ jsxs24("span", { className: "awr-keyform__saved", children: [
|
|
10530
|
+
/* @__PURE__ */ jsx26(CheckIcon, { size: 12 }),
|
|
10292
10531
|
" stored, encrypted"
|
|
10293
10532
|
] })
|
|
10294
10533
|
] }),
|
|
10295
|
-
/* @__PURE__ */
|
|
10296
|
-
/* @__PURE__ */
|
|
10534
|
+
/* @__PURE__ */ jsxs24("div", { className: "awr-keyform__row", children: [
|
|
10535
|
+
/* @__PURE__ */ jsx26(
|
|
10297
10536
|
"input",
|
|
10298
10537
|
{
|
|
10299
10538
|
className: "awr-keyform__input",
|
|
@@ -10311,7 +10550,7 @@ var ApiKeyForm = ({
|
|
|
10311
10550
|
disabled: busy
|
|
10312
10551
|
}
|
|
10313
10552
|
),
|
|
10314
|
-
/* @__PURE__ */
|
|
10553
|
+
/* @__PURE__ */ jsx26(
|
|
10315
10554
|
"button",
|
|
10316
10555
|
{
|
|
10317
10556
|
type: "button",
|
|
@@ -10321,7 +10560,7 @@ var ApiKeyForm = ({
|
|
|
10321
10560
|
children: "Save"
|
|
10322
10561
|
}
|
|
10323
10562
|
),
|
|
10324
|
-
present && /* @__PURE__ */
|
|
10563
|
+
present && /* @__PURE__ */ jsx26(
|
|
10325
10564
|
"button",
|
|
10326
10565
|
{
|
|
10327
10566
|
type: "button",
|
|
@@ -10430,6 +10669,7 @@ export {
|
|
|
10430
10669
|
McpAppLine,
|
|
10431
10670
|
McpAppRpcError,
|
|
10432
10671
|
McpAppSandboxLink,
|
|
10672
|
+
MemoryCard,
|
|
10433
10673
|
MemoryCredentialStore,
|
|
10434
10674
|
MemorySkillStore,
|
|
10435
10675
|
MemoryStore,
|
|
@@ -10518,6 +10758,7 @@ export {
|
|
|
10518
10758
|
imageSizeOf,
|
|
10519
10759
|
isMcpAppSandboxMessage,
|
|
10520
10760
|
isWebGPUAvailable2 as isWebGPUAvailable,
|
|
10761
|
+
languageOfText,
|
|
10521
10762
|
lessonsOf,
|
|
10522
10763
|
linkedFilesOf,
|
|
10523
10764
|
loadSkillFromUrl,
|
|
@@ -10554,6 +10795,8 @@ export {
|
|
|
10554
10795
|
sandboxedCsp,
|
|
10555
10796
|
saveAppFile,
|
|
10556
10797
|
saveChat,
|
|
10798
|
+
scriptOfLanguage,
|
|
10799
|
+
scriptOfText,
|
|
10557
10800
|
serveSubagentWorker,
|
|
10558
10801
|
settleAudioDuration,
|
|
10559
10802
|
speakableText,
|