@llmnative/agentico 0.14.0 → 0.15.1

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/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { zodToJsonSchema as e } from "zod-to-json-schema";
2
- import { ActionButton as t, Badge as n, Card as r, ChatMarkdown as i, ChatQuestions as a, ChatReasoning as o, Chatbot as s, Code as c, Dropdown as l, DropdownItem as u, Form as d, Icon as f, Input as p, LoadingButton as m, Modal as h, PromptUtils as g, Tree as _, getAIModelCatalog as v, interpolate as y, parseAIModelRef as b, proxyFetch as x, useAIProviderRegistry as S, useFormController as C, useI18n as w, useProxy as T } from "@llmnative/react";
3
- import { createContext as E, useCallback as D, useContext as O, useEffect as k, useLayoutEffect as A, useMemo as j, useRef as M, useState as N } from "react";
4
- import { Fragment as P, jsx as F, jsxs as I } from "react/jsx-runtime";
2
+ import { ActionButton as t, Badge as n, Card as r, ChatMarkdown as i, ChatQuestions as a, ChatReasoning as o, Chatbot as s, Code as c, Dropdown as l, DropdownItem as u, Form as d, Icon as f, Input as p, LoadingButton as m, Modal as h, ModalYesNo as g, PromptUtils as _, Tree as v, getAIModelCatalog as y, interpolate as b, parseAIModelRef as x, proxyFetch as S, useAIProviderRegistry as C, useFormController as w, useI18n as T, useProxy as E } from "@llmnative/react";
3
+ import { createContext as D, useCallback as O, useContext as ee, useEffect as k, useLayoutEffect as te, useMemo as A, useRef as j, useState as M } from "react";
4
+ import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
5
5
  //#region src/domain/messageParts.ts
6
- var L = "text", R = "reasoning";
7
- function z(e, t, n) {
6
+ var ne = "text", I = "reasoning";
7
+ function L(e, t, n) {
8
8
  let r = e.findIndex((e) => e.type === t.type && e.id === t.id);
9
9
  if (r >= 0) return e.map((e, n) => n === r ? t : e);
10
10
  let i = t.type === "reasoning" || !n ? e : e.map((e) => e.type === "reasoning" && e.streaming ? n(e) : e), a = i.findIndex((e) => e.type === "text" && e.id === "text");
@@ -14,15 +14,15 @@ function z(e, t, n) {
14
14
  ...i.slice(a)
15
15
  ] : [...i, t];
16
16
  }
17
- function ee(e) {
17
+ function R(e) {
18
18
  return e.filter((e) => e.type === "text").map((e) => e.text).filter(Boolean).join("\n\n");
19
19
  }
20
- function B(e, t) {
20
+ function z(e, t) {
21
21
  return t.map((t, n) => `${t.header ?? e[n]?.header ?? e[n]?.question ?? t.id ?? `${n + 1}`}: ${t.values.join(", ")}`).join("\n");
22
22
  }
23
23
  //#endregion
24
24
  //#region src/domain/defineSubagent.ts
25
- function te(e) {
25
+ function B(e) {
26
26
  return e;
27
27
  }
28
28
  //#endregion
@@ -48,25 +48,25 @@ function q(e) {
48
48
  }
49
49
  //#endregion
50
50
  //#region src/domain/mcpTool.ts
51
- function ne(t) {
51
+ function re(t) {
52
52
  let { $schema: n, ...r } = e(t, {
53
53
  target: "jsonSchema7",
54
54
  $refStrategy: "none"
55
55
  });
56
56
  return r;
57
57
  }
58
- function re(e, t, n, r) {
58
+ function ie(e, t, n, r) {
59
59
  return {
60
60
  name: e,
61
61
  description: t,
62
- inputSchema: ne(n),
63
- ...r ? { outputSchema: ne(r) } : {}
62
+ inputSchema: re(n),
63
+ ...r ? { outputSchema: re(r) } : {}
64
64
  };
65
65
  }
66
66
  //#endregion
67
67
  //#region src/domain/subagentUsageCard.ts
68
- function J(e) {
69
- let t = ne(e.inputSchema), n = t.properties ?? {}, r = new Set(t.required ?? []);
68
+ function ae(e) {
69
+ let t = re(e.inputSchema), n = t.properties ?? {}, r = new Set(t.required ?? []);
70
70
  return Object.entries(n).map(([t, n]) => {
71
71
  let i = typeof n.description == "string" ? n.description : "";
72
72
  return {
@@ -80,7 +80,7 @@ function J(e) {
80
80
  }
81
81
  //#endregion
82
82
  //#region src/domain/prompts.ts
83
- var ie = {
83
+ var J = {
84
84
  orchestratorIntro: "You are Agentico, the orchestrator of this application's tools. Your job is to understand what the user wants to achieve and, once every required parameter is collected, start the right tool among those listed below — do not carry it out yourself \"in words\", invoke it as a tool.",
85
85
  responseRules: [
86
86
  "BEFORE asking for any parameter, check the \"Page context\" below (if present): if a parameter required by the command is already there or can be deduced from it with reasonable certainty, USE it directly — do not ask the user again. Only ask for parameters that cannot be derived from the context.",
@@ -110,7 +110,7 @@ var ie = {
110
110
  ].join(" "),
111
111
  multipleCandidates: "Several subagents are candidates on this page — ask the user which one they mean if their message does not make it clear, before going on.",
112
112
  chatTitle: "Write a title for this chat, as a list of chats shows it: 3 to 6 words saying what it is about, in the language the person writes in. Answer with the title only: no quotes, no final period.\n\n{chat}"
113
- }, ae = {
113
+ }, Y = {
114
114
  orchestratorIntro: "Sei Agentico, l'orchestratore dei tool di questa applicazione. Il tuo compito è capire cosa vuole ottenere l'utente e, una volta raccolti tutti i parametri necessari, avviare il tool giusto tra quelli elencati sotto — non eseguirlo tu stesso \"a parole\", invocalo come strumento.",
115
115
  responseRules: [
116
116
  "PRIMA di chiedere qualunque parametro, controlla il \"Contesto pagina\" (se presente) qui sotto: se un parametro richiesto dal comando è già lì o si può dedurre da lì con ragionevole certezza (es. l'utente sta guardando lo storico di un tool specifico, o un'esecuzione passata con parametri simili), USALO direttamente — non chiederlo di nuovo all'utente. Chiedi solo i parametri che NON emergono in nessun modo dal contesto.",
@@ -140,26 +140,26 @@ var ie = {
140
140
  ].join(" "),
141
141
  multipleCandidates: "Più subagent sono candidati su questa pagina — chiedi all'utente quale intende se non è chiaro dal suo messaggio, prima di procedere.",
142
142
  chatTitle: "Scrivi un titolo per questa chat, come lo mostra un elenco di chat: da 3 a 6 parole che dicono di cosa parla, nella lingua in cui scrive la persona. Rispondi solo con il titolo: niente virgolette, niente punto finale.\n\n{chat}"
143
- }, Y = ie;
144
- function oe(e) {
145
- Y = {
146
- ...Y,
143
+ }, oe = J;
144
+ function se(e) {
145
+ oe = {
146
+ ...oe,
147
147
  ...e
148
148
  };
149
149
  }
150
150
  function X() {
151
- return Y;
151
+ return oe;
152
152
  }
153
- function Z() {
154
- Y = ie;
153
+ function ce() {
154
+ oe = J;
155
155
  }
156
156
  //#endregion
157
157
  //#region src/domain/cli/renderManifestCli.ts
158
- function se(e, t) {
158
+ function le(e, t) {
159
159
  return `${e} ${t.map((e) => e.required ? `--${e.key} <${e.type}>` : `[--${e.key} <${e.type}>]`).join(" ")}`.trim();
160
160
  }
161
- function ce(e, t) {
162
- let n = J(t), r = se(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
161
+ function ue(e, t) {
162
+ let n = ae(t), r = le(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
163
163
  return [
164
164
  `COMMAND: ${e} ${t.name}`,
165
165
  ` ${t.summary}`,
@@ -171,46 +171,46 @@ function ce(e, t) {
171
171
  ...i,
172
172
  "",
173
173
  " OUTPUT",
174
- le(t.describeOutput(), 4),
174
+ de(t.describeOutput(), 4),
175
175
  (t.example, ""),
176
176
  t.example ? " EXAMPLE" : "",
177
177
  t.example ? ` ${t.example}` : ""
178
178
  ].filter((e) => e !== "").join("\n");
179
179
  }
180
- function le(e, t) {
180
+ function de(e, t) {
181
181
  let n = " ".repeat(t);
182
182
  return e.split("\n").map((e) => e && n + e).join("\n");
183
183
  }
184
- function ue(e) {
184
+ function fe(e) {
185
185
  return [
186
186
  "NAME",
187
187
  ` ${e.id} — ${e.label}`,
188
188
  "",
189
189
  "DESCRIPTION",
190
- le(e.description, 2),
190
+ de(e.description, 2),
191
191
  "",
192
- ...e.commands.map((t) => ce(e.id, t))
192
+ ...e.commands.map((t) => ue(e.id, t))
193
193
  ].join("\n");
194
194
  }
195
- function de(e) {
195
+ function pe(e) {
196
196
  return e.length === 0 ? X().noToolsAvailable : e.map((e) => `${e.id} [${e.commands.map((e) => e.name).join("|")}] — ${e.label}: ${e.commands.map((e) => e.summary).join(" / ")}`).join("\n");
197
197
  }
198
198
  //#endregion
199
199
  //#region src/domain/microPrompts.ts
200
- var fe = {
200
+ var me = {
201
201
  id: "closing-summary",
202
202
  get text() {
203
203
  return X().closingSummary;
204
204
  }
205
- }, pe = { [fe.id]: fe };
206
- function me(e, t) {
205
+ }, he = { [me.id]: me };
206
+ function ge(e, t) {
207
207
  if (!t || t.length === 0) return e;
208
- let n = t.map((e) => pe[e]?.text).filter((e) => !!e);
208
+ let n = t.map((e) => he[e]?.text).filter((e) => !!e);
209
209
  return n.length === 0 ? e : `${e}\n\n${n.join("\n")}`;
210
210
  }
211
211
  //#endregion
212
212
  //#region src/domain/extractErrorMessage.ts
213
- function he(e) {
213
+ function Z(e) {
214
214
  if (e instanceof Error) return e.message;
215
215
  if (typeof e == "object" && e) {
216
216
  let t = e;
@@ -229,13 +229,13 @@ function he(e) {
229
229
  }
230
230
  //#endregion
231
231
  //#region src/domain/extractJsonBlock.ts
232
- function ge(e) {
232
+ function _e(e) {
233
233
  let t = e.match(/```(?:json)?\s*\n?([\s\S]*?)```/i);
234
234
  if (t) return t[1].trim();
235
235
  let n = e.replace(/^```json\s*/i, "").replace(/^```\s*/i, "").replace(/```\s*$/, "").trim();
236
- return _e(n) ?? n;
236
+ return ve(n) ?? n;
237
237
  }
238
- function _e(e) {
238
+ function ve(e) {
239
239
  let t = e.search(/[{[]/);
240
240
  if (t === -1) return null;
241
241
  let n = e[t], r = n === "{" ? "}" : "]", i = 0, a = !1, o = !1;
@@ -256,8 +256,8 @@ function _e(e) {
256
256
  }
257
257
  //#endregion
258
258
  //#region src/domain/jsonExportDestination.ts
259
- var ve = "json-export", ye = {
260
- id: ve,
259
+ var ye = "json-export", be = {
260
+ id: ye,
261
261
  label: "Export as JSON",
262
262
  async apply(e) {
263
263
  let t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), n = URL.createObjectURL(t);
@@ -268,19 +268,19 @@ var ve = "json-export", ye = {
268
268
  URL.revokeObjectURL(n);
269
269
  }
270
270
  }
271
- }, be = {};
272
- function xe(e) {
273
- be = e;
271
+ }, xe = {};
272
+ function Se(e) {
273
+ xe = e;
274
274
  }
275
- function Se() {
275
+ function Ce() {
276
276
  return {
277
- [ye.id]: ye,
278
- ...be
277
+ [be.id]: be,
278
+ ...xe
279
279
  };
280
280
  }
281
281
  //#endregion
282
282
  //#region src/i18n/en.ts
283
- var Ce = {
283
+ var we = {
284
284
  modelLabel: "Model",
285
285
  modelsLoading: "Loading…",
286
286
  noModelsAvailable: "No models available",
@@ -342,8 +342,14 @@ var Ce = {
342
342
  resizePanel: "Resize the agent panel",
343
343
  resizePanelHint: "Drag to resize, double-click to reset",
344
344
  pendingQuestions: "Questions of the agent",
345
+ retryFromHere: "Retry from here",
346
+ editMessage: "Edit",
347
+ editingMessage: "Editing a message: sent, the chat goes back to it.",
348
+ cancelEdit: "Cancel",
349
+ rewindTitle: "Go back to this message?",
350
+ rewindText: "What came after it leaves the chat and the memory of the agent. What its steps did stays done:",
345
351
  stop: "Stop"
346
- }, we = {
352
+ }, Te = {
347
353
  modelLabel: "Modello",
348
354
  modelsLoading: "Caricamento…",
349
355
  noModelsAvailable: "Nessun modello disponibile",
@@ -405,8 +411,14 @@ var Ce = {
405
411
  resizePanel: "Ridimensiona il pannello dell'agente",
406
412
  resizePanelHint: "Trascina per ridimensionare, doppio clic per ripristinare",
407
413
  pendingQuestions: "Domande dell'agente",
414
+ retryFromHere: "Riprova da qui",
415
+ editMessage: "Modifica",
416
+ editingMessage: "Modifichi un messaggio: inviato, la chat torna a quel punto.",
417
+ cancelEdit: "Annulla",
418
+ rewindTitle: "Tornare a questo messaggio?",
419
+ rewindText: "Ciò che è venuto dopo lascia la chat e la memoria dell'agente. Ciò che hanno fatto i suoi passi resta fatto:",
408
420
  stop: "Ferma"
409
- }, Te = {
421
+ }, Ee = {
410
422
  modelLabel: "Modell",
411
423
  modelsLoading: "Wird geladen…",
412
424
  noModelsAvailable: "Keine Modelle verfügbar",
@@ -468,40 +480,46 @@ var Ce = {
468
480
  resizePanel: "Agent-Bereich in der Größe ändern",
469
481
  resizePanelHint: "Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen",
470
482
  pendingQuestions: "Fragen des Agenten",
483
+ retryFromHere: "Ab hier wiederholen",
484
+ editMessage: "Bearbeiten",
485
+ editingMessage: "Du bearbeitest eine Nachricht: gesendet, geht der Chat dorthin zurück.",
486
+ cancelEdit: "Abbrechen",
487
+ rewindTitle: "Zu dieser Nachricht zurückgehen?",
488
+ rewindText: "Was danach kam, verlässt den Chat und das Gedächtnis des Agenten. Was seine Schritte getan haben, bleibt getan:",
471
489
  stop: "Stoppen"
472
- }, Ee = "llmnative.agentico.entityChat", De;
473
- function Oe(e) {
474
- Ee = e.storageKey, De = e.backend;
490
+ }, De = "llmnative.agentico.entityChat", Oe;
491
+ function ke(e) {
492
+ De = e.storageKey, Oe = e.backend;
475
493
  }
476
- var ke = () => !!De, Ae = ({ synced: e, ...t }) => t;
477
- function je(e) {
478
- if (!De) return;
494
+ var Ae = () => !!Oe, je = ({ synced: e, ...t }) => t;
495
+ function Me(e) {
496
+ if (!Oe) return;
479
497
  let t = Q(e.scopeId, e.subagentId, e.entityId);
480
- Promise.resolve(De.save(Ae(e))).then(() => {
481
- let e = Pe(), n = e.find((e) => Q(e.scopeId, e.subagentId, e.entityId) === t);
482
- n && !n.synced && Le(e.map((e) => e === n ? {
498
+ Promise.resolve(Oe.save(je(e))).then(() => {
499
+ let e = Fe(), n = e.find((e) => Q(e.scopeId, e.subagentId, e.entityId) === t);
500
+ n && !n.synced && Re(e.map((e) => e === n ? {
483
501
  ...e,
484
502
  synced: !0
485
503
  } : e));
486
504
  }, () => void 0);
487
505
  }
488
- async function Me(e) {
489
- if (!De) return;
490
- let t = (await De.load(e)).map(Ne).filter((t) => t !== null && t.scopeId === e), n = (e) => e.changedAt ?? e.savedAt, r = Pe(), i = r.filter((t) => t.scopeId !== e), a = r.filter((t) => t.scopeId === e), o = t.map((e) => {
506
+ async function Ne(e) {
507
+ if (!Oe) return;
508
+ let t = (await Oe.load(e)).map(Pe).filter((t) => t !== null && t.scopeId === e), n = (e) => e.changedAt ?? e.savedAt, r = Fe(), i = r.filter((t) => t.scopeId !== e), a = r.filter((t) => t.scopeId === e), o = t.map((e) => {
491
509
  let t = a.find((t) => Q(t.scopeId, t.subagentId, t.entityId) === Q(e.scopeId, e.subagentId, e.entityId));
492
- return t && n(t) > n(e) ? (je(t), t) : {
510
+ return t && n(t) > n(e) ? (Me(t), t) : {
493
511
  ...e,
494
512
  synced: !0
495
513
  };
496
514
  }), s = a.filter((e) => !e.synced && !t.some((t) => Q(t.scopeId, t.subagentId, t.entityId) === Q(e.scopeId, e.subagentId, e.entityId)));
497
- Le([
515
+ Re([
498
516
  ...i,
499
517
  ...o,
500
518
  ...s
501
519
  ]);
502
- for (let e of s) je(e);
520
+ for (let e of s) Me(e);
503
521
  }
504
- function Ne(e) {
522
+ function Pe(e) {
505
523
  if (!e || typeof e != "object") return null;
506
524
  let t = e;
507
525
  if (typeof t.entityId != "string") return null;
@@ -513,57 +531,57 @@ function Ne(e) {
513
531
  scopeId: n
514
532
  };
515
533
  }
516
- function Pe() {
534
+ function Fe() {
517
535
  try {
518
- let e = localStorage.getItem(Ee);
536
+ let e = localStorage.getItem(De);
519
537
  if (!e) return [];
520
538
  let t = JSON.parse(e);
521
- return Array.isArray(t) ? t.map(Ne).filter((e) => e !== null) : [];
539
+ return Array.isArray(t) ? t.map(Pe).filter((e) => e !== null) : [];
522
540
  } catch {
523
541
  return [];
524
542
  }
525
543
  }
526
- var Fe = /* @__PURE__ */ new Set();
527
- function Ie(e) {
528
- return Fe.add(e), () => {
529
- Fe.delete(e);
544
+ var Ie = /* @__PURE__ */ new Set();
545
+ function Le(e) {
546
+ return Ie.add(e), () => {
547
+ Ie.delete(e);
530
548
  };
531
549
  }
532
- function Le(e) {
550
+ function Re(e) {
533
551
  try {
534
- localStorage.setItem(Ee, JSON.stringify(e));
552
+ localStorage.setItem(De, JSON.stringify(e));
535
553
  } catch {}
536
- for (let e of [...Fe]) e();
554
+ for (let e of [...Ie]) e();
537
555
  }
538
556
  var Q = (e, t, n) => `${e}:${t}:${n}`;
539
- function Re(e, t, n) {
557
+ function ze(e, t, n) {
540
558
  let r = Q(e, t, n);
541
- return Pe().find((e) => Q(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
559
+ return Fe().find((e) => Q(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
542
560
  }
543
- function ze(e) {
544
- let t = Q(e.scopeId, e.subagentId, e.entityId), n = Pe(), r = n.find((e) => Q(e.scopeId, e.subagentId, e.entityId) === t), i = Date.now(), a = n.filter((e) => e !== r), o = {
561
+ function Be(e) {
562
+ let t = Q(e.scopeId, e.subagentId, e.entityId), n = Fe(), r = n.find((e) => Q(e.scopeId, e.subagentId, e.entityId) === t), i = Date.now(), a = n.filter((e) => e !== r), o = {
545
563
  ...e,
546
564
  savedAt: i,
547
565
  changedAt: i,
548
- startedAt: r ? qe(r) : i,
566
+ startedAt: r ? Je(r) : i,
549
567
  ...r?.name ? {
550
568
  name: r.name,
551
569
  namedBy: r.namedBy
552
570
  } : {},
553
571
  ...r?.synced ? { synced: !0 } : {}
554
572
  };
555
- a.push(o), Le(a), je(o);
573
+ a.push(o), Re(a), Me(o);
556
574
  }
557
- var Be = new Set([
558
- Ce,
575
+ var Ve = new Set([
559
576
  we,
560
- Te
561
- ].map((e) => e.retryMessage.trim().toLowerCase())), Ve = (e) => e.kind === "user" && !!e.detail?.trim() && !e.retry && !Be.has(e.detail.trim().toLowerCase()), He = (e) => {
562
- let t = (e.activity.find(Ve)?.detail ?? "").trim().split("\n")[0].trim();
577
+ Te,
578
+ Ee
579
+ ].map((e) => e.retryMessage.trim().toLowerCase())), He = (e) => e.kind === "user" && !!e.detail?.trim() && !e.retry && !Ve.has(e.detail.trim().toLowerCase()), Ue = (e) => {
580
+ let t = (e.activity.find(He)?.detail ?? "").trim().split("\n")[0].trim();
563
581
  return t.length > 80 ? `${t.slice(0, 80).trimEnd()}…` : t;
564
- }, Ue = (e) => e.name || He(e) || e.title || e.entityId, We = (e) => e.activity.some(Ve), Ge = (e) => e.kind === "user" && !Ve(e) && !!e.detail?.trim();
565
- function Ke(e, t, n, r, i = "person") {
566
- let a = Q(e, t, n), o = Pe(), s = o.find((e) => Q(e.scopeId, e.subagentId, e.entityId) === a);
582
+ }, We = (e) => e.name || Ue(e) || e.title || e.entityId, Ge = (e) => e.activity.some(He), Ke = (e) => e.kind === "user" && !He(e) && !!e.detail?.trim();
583
+ function qe(e, t, n, r, i = "person") {
584
+ let a = Q(e, t, n), o = Fe(), s = o.find((e) => Q(e.scopeId, e.subagentId, e.entityId) === a);
567
585
  if (!s || i === "model" && s.namedBy === "person") return !1;
568
586
  let c = r.trim().replace(/\s+/g, " ").slice(0, 120), { name: l, namedBy: u, ...d } = s, f = c ? {
569
587
  ...d,
@@ -574,41 +592,41 @@ function Ke(e, t, n, r, i = "person") {
574
592
  ...d,
575
593
  changedAt: Date.now()
576
594
  };
577
- return Le(o.map((e) => e === s ? f : e)), je(f), !0;
595
+ return Re(o.map((e) => e === s ? f : e)), Me(f), !0;
578
596
  }
579
- var qe = (e) => e.startedAt ?? e.savedAt;
580
- function Je(e, t, n) {
597
+ var Je = (e) => e.startedAt ?? e.savedAt;
598
+ function Ye(e, t, n) {
581
599
  let r = Q(e, t, n);
582
- Le(Pe().filter((e) => Q(e.scopeId, e.subagentId, e.entityId) !== r)), De && Promise.resolve(De.remove(e, t, n)).catch(() => void 0);
600
+ Re(Fe().filter((e) => Q(e.scopeId, e.subagentId, e.entityId) !== r)), Oe && Promise.resolve(Oe.remove(e, t, n)).catch(() => void 0);
583
601
  }
584
- function Ye(e) {
585
- return Pe().filter((t) => t.scopeId === e).sort((e, t) => qe(t) - qe(e));
602
+ function Xe(e) {
603
+ return Fe().filter((t) => t.scopeId === e).sort((e, t) => Je(t) - Je(e));
586
604
  }
587
- var Xe = (e, t) => `entitychat-${e}-${t}`, Ze = {
588
- en: { agentico: Ce },
589
- it: { agentico: we },
590
- de: { agentico: Te }
605
+ var Ze = (e, t) => `entitychat-${e}-${t}`, Qe = {
606
+ en: { agentico: we },
607
+ it: { agentico: Te },
608
+ de: { agentico: Ee }
591
609
  };
592
610
  function $() {
593
- let { dict: e } = w(), t = e.agentico;
611
+ let { dict: e } = T(), t = e.agentico;
594
612
  return t ? {
595
- ...Ce,
613
+ ...we,
596
614
  ...t
597
- } : Ce;
615
+ } : we;
598
616
  }
599
617
  //#endregion
600
618
  //#region src/presentation/AgenticoContext.tsx
601
- var Qe = "agentico-orchestrator", $e = E(null);
602
- function et({ children: e, scope: t = null }) {
603
- let [n, r] = N(null), i = M(null);
619
+ var $e = "agentico-orchestrator", et = D(null);
620
+ function tt({ children: e, scope: t = null }) {
621
+ let [n, r] = M(null), i = j(null);
604
622
  k(() => {
605
623
  i.current = n;
606
624
  }, [n]);
607
- let [a, o] = N(!1), s = t?.id;
625
+ let [a, o] = M(!1), s = t?.id;
608
626
  k(() => {
609
- s && Me(s).catch(() => void 0);
627
+ s && Ne(s).catch(() => void 0);
610
628
  }, [s]);
611
- let c = D((e) => {
629
+ let c = O((e) => {
612
630
  let t = i.current;
613
631
  t && t.id !== e.id && t.onDismiss();
614
632
  let n = t && t.id === e.id && t.savedToDisk && e.savedToDisk === void 0 ? {
@@ -616,10 +634,10 @@ function et({ children: e, scope: t = null }) {
616
634
  savedToDisk: !0
617
635
  } : e;
618
636
  r(n);
619
- }, []), l = D((e) => {
637
+ }, []), l = O((e) => {
620
638
  r((t) => t && t.id === e ? null : t);
621
- }, []), u = D(() => o((e) => !e), []), d = D(() => o(!0), []), [f, p] = N(null), [m, h] = N(void 0), [g, _] = N(void 0), [v, y] = N(void 0), [b, x] = N(null), [S, C] = N(null), [w, T] = N(void 0), [E, O] = N([]), A = D((e, t, n = null) => {
622
- O((r) => {
639
+ }, []), u = O(() => o((e) => !e), []), d = O(() => o(!0), []), [f, p] = M(null), [m, h] = M(void 0), [g, _] = M(void 0), [v, y] = M(void 0), [b, x] = M(null), [S, C] = M(null), [w, T] = M(void 0), [E, D] = M([]), ee = O((e, t, n = null) => {
640
+ D((r) => {
623
641
  let i = r.filter((t) => t.id !== e);
624
642
  return t ? [...i, {
625
643
  id: e,
@@ -627,29 +645,29 @@ function et({ children: e, scope: t = null }) {
627
645
  card: n
628
646
  }] : i;
629
647
  });
630
- }, []), P = E.length > 0 ? E[E.length - 1] : null, [I, L] = N([]), R = D((e, t) => {
631
- L((n) => {
648
+ }, []), te = E.length > 0 ? E[E.length - 1] : null, [N, F] = M([]), ne = O((e, t) => {
649
+ F((n) => {
632
650
  let r = n.filter((t) => t.id !== e);
633
651
  return t ? [...r, {
634
652
  id: e,
635
653
  ...t
636
654
  }] : r;
637
655
  });
638
- }, []), z = j(() => I.map((e) => ({
656
+ }, []), I = A(() => N.map((e) => ({
639
657
  subagentId: e.subagentId,
640
658
  componentKey: e.componentKey,
641
659
  onResult: e.onResult,
642
660
  pinnedEntityId: e.pinnedEntityId
643
- })), [I]), ee = j(() => {
661
+ })), [N]), L = A(() => {
644
662
  let e = /* @__PURE__ */ new Map();
645
- for (let t of I) e.set(t.subagentId, {
663
+ for (let t of N) e.set(t.subagentId, {
646
664
  subagentId: t.subagentId,
647
665
  componentKey: t.componentKey,
648
666
  onResult: t.onResult,
649
667
  contextInfo: t.contextInfo
650
668
  });
651
669
  return [...e.values()];
652
- }, [I]), B = j(() => ee.map((e) => {
670
+ }, [N]), R = A(() => L.map((e) => {
653
671
  let t = W(e.subagentId)?.componentContexts?.[e.componentKey];
654
672
  if (!t) return null;
655
673
  let n = e.contextInfo ? `${t.agenticoHint}\n${e.contextInfo}` : t.agenticoHint;
@@ -658,26 +676,26 @@ function et({ children: e, scope: t = null }) {
658
676
  agenticoHint: n,
659
677
  userMessage: t.userMessage
660
678
  };
661
- }).filter((e) => e !== null), [ee]), te = j(() => B.map((e) => e.userMessage), [B]), V = j(() => {
662
- if (B.length === 0) return null;
663
- if (B.length === 1) return B[0].agenticoHint;
664
- let e = B.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
679
+ }).filter((e) => e !== null), [L]), z = A(() => R.map((e) => e.userMessage), [R]), B = A(() => {
680
+ if (R.length === 0) return null;
681
+ if (R.length === 1) return R[0].agenticoHint;
682
+ let e = R.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
665
683
  return `${X().multipleCandidates}\n\n${e}`;
666
- }, [B]) ?? P?.text ?? null, H = B.length > 0 ? null : P?.card ?? null, U = j(() => [...new Set(z.map((e) => e.subagentId))], [z]), G = U.length === 1 ? U[0] : U.length === 0 ? P?.card?.subagentId ?? null : null, K = D((e, t) => {
684
+ }, [R]) ?? te?.text ?? null, V = R.length > 0 ? null : te?.card ?? null, H = A(() => [...new Set(I.map((e) => e.subagentId))], [I]), U = H.length === 1 ? H[0] : H.length === 0 ? te?.card?.subagentId ?? null : null, G = O((e, t) => {
667
685
  d();
668
686
  let n = i.current;
669
687
  if (n?.id === "agentico-orchestrator") return;
670
- let r = G && n?.id.startsWith(`subagent-${G}-`) ? n : void 0;
688
+ let r = U && n?.id.startsWith(`subagent-${U}-`) ? n : void 0;
671
689
  C(r ? {
672
690
  taskId: r.id,
673
691
  activity: [...r.precedingActivity ?? [], ...r.agent.activity]
674
692
  } : null), p(e), h(t?.extraDestinations), _(t?.attachments), y(t?.model), T(t?.scopedSubagentId), x(crypto.randomUUID());
675
- }, [d, G]), q = D((e, t, n, a, o, s) => {
693
+ }, [d, U]), K = O((e, t, n, a, o, s) => {
676
694
  if (!n || !a) return;
677
695
  let c = i.current;
678
696
  if (!c || c.id !== n) return;
679
697
  let l = c.agent.snapshot();
680
- l && (ze({
698
+ l && (Be({
681
699
  scopeId: a,
682
700
  subagentId: e,
683
701
  entityId: t,
@@ -689,33 +707,33 @@ function et({ children: e, scope: t = null }) {
689
707
  ...e,
690
708
  savedToDisk: !0
691
709
  } : e));
692
- }, []), [ne, re] = N(null), [J, ie] = N(null), ae = D((e, t, n) => {
710
+ }, []), [q, re] = M(null), [ie, ae] = M(null), J = O((e, t, n) => {
693
711
  d(), re({
694
712
  subagentId: e,
695
713
  entityId: t,
696
714
  snapshot: n
697
- }), ie(crypto.randomUUID());
698
- }, [d]), [Y, oe] = N(null), [Z, se] = N(null), ce = D((e, t) => {
699
- d(), l(Qe), oe({
715
+ }), ae(crypto.randomUUID());
716
+ }, [d]), [Y, oe] = M(null), [se, ce] = M(null), le = O((e, t) => {
717
+ d(), l($e), oe({
700
718
  subagentId: e,
701
719
  extraDestinations: t
702
- }), se(crypto.randomUUID());
703
- }, [d, l]), [le, ue] = N(null), [de, fe] = N(null), pe = D((e, t, n) => {
704
- oe(null), ue({
720
+ }), ce(crypto.randomUUID());
721
+ }, [d, l]), [ue, de] = M(null), [fe, pe] = M(null), me = O((e, t, n) => {
722
+ oe(null), de({
705
723
  subagentId: e,
706
724
  params: t,
707
725
  extraDestinations: n
708
- }), fe(crypto.randomUUID());
709
- }, []), [me, he] = N(null), [ge, _e] = N(null), ve = D((e, t, n) => {
710
- d(), he({
726
+ }), pe(crypto.randomUUID());
727
+ }, []), [he, ge] = M(null), [Z, _e] = M(null), ve = O((e, t, n) => {
728
+ d(), ge({
711
729
  subagentId: e,
712
730
  params: t,
713
731
  ...n
714
732
  }), _e(crypto.randomUUID());
715
- }, [d]), ye = D(() => {
733
+ }, [d]), ye = O(() => {
716
734
  let e = i.current;
717
735
  e && e.onDismiss();
718
- }, []), be = j(() => ({
736
+ }, []), be = A(() => ({
719
737
  scope: t,
720
738
  task: n,
721
739
  isOpen: a,
@@ -723,35 +741,35 @@ function et({ children: e, scope: t = null }) {
723
741
  closeTask: l,
724
742
  toggleOpen: u,
725
743
  pendingGoal: f,
726
- startOrchestrator: K,
727
- pageContext: V,
728
- pageContextCard: H,
729
- setPageContext: A,
730
- scopedSubagentId: G,
744
+ startOrchestrator: G,
745
+ pageContext: B,
746
+ pageContextCard: V,
747
+ setPageContext: ee,
748
+ scopedSubagentId: U,
731
749
  pendingScopedSubagentId: w,
732
- componentAnchors: z,
733
- anchoredUserMessages: te,
734
- registerComponentAnchor: R,
750
+ componentAnchors: I,
751
+ anchoredUserMessages: z,
752
+ registerComponentAnchor: ne,
735
753
  openPanel: d,
736
754
  pendingExtraDestinations: m,
737
755
  pendingAttachments: g,
738
756
  pendingModel: v,
739
757
  orchestratorRunId: b,
740
758
  pendingCarryOver: S,
741
- commitEntityChat: q,
742
- resumeEntityChat: ae,
743
- pendingResume: ne,
744
- resumeRunId: J,
759
+ commitEntityChat: K,
760
+ resumeEntityChat: J,
761
+ pendingResume: q,
762
+ resumeRunId: ie,
745
763
  dismissForeignTask: ye,
746
764
  pendingManualEntry: Y,
747
- manualEntryRunId: Z,
748
- startManualEntry: ce,
749
- pendingResumeWithAI: le,
750
- resumeWithAIRunId: de,
751
- resumeWithAI: pe,
765
+ manualEntryRunId: se,
766
+ startManualEntry: le,
767
+ pendingResumeWithAI: ue,
768
+ resumeWithAIRunId: fe,
769
+ resumeWithAI: me,
752
770
  startSubagent: ve,
753
- pendingStart: me,
754
- startRunId: ge
771
+ pendingStart: he,
772
+ startRunId: Z
755
773
  }), [
756
774
  t,
757
775
  n,
@@ -760,49 +778,49 @@ function et({ children: e, scope: t = null }) {
760
778
  l,
761
779
  u,
762
780
  f,
763
- K,
764
- V,
765
- H,
766
- A,
767
781
  G,
782
+ B,
783
+ V,
784
+ ee,
785
+ U,
768
786
  w,
787
+ I,
769
788
  z,
770
- te,
771
- R,
789
+ ne,
772
790
  d,
773
791
  m,
774
792
  g,
775
793
  v,
776
794
  b,
777
795
  S,
778
- q,
779
- ae,
780
- ne,
796
+ K,
781
797
  J,
798
+ q,
799
+ ie,
782
800
  ye,
783
801
  Y,
784
- Z,
785
- ce,
802
+ se,
786
803
  le,
787
- de,
788
- pe,
789
- ve,
804
+ ue,
805
+ fe,
790
806
  me,
791
- ge
807
+ ve,
808
+ he,
809
+ Z
792
810
  ]);
793
- return /* @__PURE__ */ F($e.Provider, {
811
+ return /* @__PURE__ */ P(et.Provider, {
794
812
  value: be,
795
813
  children: e
796
814
  });
797
815
  }
798
- function tt() {
799
- let e = O($e);
816
+ function nt() {
817
+ let e = ee(et);
800
818
  if (!e) throw Error("useAgentico must be used inside AgenticoProvider");
801
819
  return e;
802
820
  }
803
821
  //#endregion
804
822
  //#region src/presentation/AgentActivityLog.tsx
805
- function nt(e) {
823
+ function rt(e) {
806
824
  let t = e.search(/[{[]/);
807
825
  if (t === -1) return [{
808
826
  type: "text",
@@ -848,51 +866,51 @@ function nt(e) {
848
866
  language: "json"
849
867
  });
850
868
  let u = e.slice(s + 1);
851
- return u.trim() && l.push(...nt(u)), l;
869
+ return u.trim() && l.push(...rt(u)), l;
852
870
  }
853
- function rt(e) {
871
+ function it(e) {
854
872
  let t = [], n = /```(\w+)?\n?([\s\S]*?)```/g, r = 0, i;
855
- for (; i = n.exec(e);) i.index > r && t.push(...nt(e.slice(r, i.index))), t.push({
873
+ for (; i = n.exec(e);) i.index > r && t.push(...rt(e.slice(r, i.index))), t.push({
856
874
  type: "code",
857
875
  content: i[2].replace(/\n$/, ""),
858
876
  language: i[1]
859
877
  }), r = n.lastIndex;
860
- return r < e.length && t.push(...nt(e.slice(r))), t;
878
+ return r < e.length && t.push(...rt(e.slice(r))), t;
861
879
  }
862
- function it({ content: e, language: t }) {
863
- let [n, r] = N(!1);
864
- return /* @__PURE__ */ I("div", {
880
+ function at({ content: e, language: t }) {
881
+ let [n, r] = M(!1);
882
+ return /* @__PURE__ */ F("div", {
865
883
  className: `relative cursor-pointer rounded-md ${n ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
866
884
  onClick: () => r((e) => !e),
867
885
  title: n ? "Clic per comprimere" : "Clic per espandere",
868
- children: [/* @__PURE__ */ F(c, {
886
+ children: [/* @__PURE__ */ P(c, {
869
887
  language: t,
870
888
  showCopy: n,
871
889
  background: "transparent",
872
890
  className: "!text-[11px]",
873
891
  children: e
874
- }), !n && /* @__PURE__ */ F("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
892
+ }), !n && /* @__PURE__ */ P("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
875
893
  });
876
894
  }
877
- function at({ text: e, tone: t }) {
878
- let n = rt(e);
879
- return /* @__PURE__ */ F(P, { children: n.map((e, n) => e.type === "code" ? /* @__PURE__ */ F(it, {
895
+ function ot({ text: e, tone: t }) {
896
+ let n = it(e);
897
+ return /* @__PURE__ */ P(N, { children: n.map((e, n) => e.type === "code" ? /* @__PURE__ */ P(at, {
880
898
  content: e.content,
881
899
  language: e.language
882
- }, n) : e.content.trim() && /* @__PURE__ */ F(i, {
900
+ }, n) : e.content.trim() && /* @__PURE__ */ P(i, {
883
901
  content: e.content.trim(),
884
902
  tone: t,
885
903
  className: "break-words text-xs leading-relaxed"
886
904
  }, n)) });
887
905
  }
888
- function ot() {
889
- let [e] = N(() => Date.now()), [t, n] = N(e);
906
+ function st() {
907
+ let [e] = M(() => Date.now()), [t, n] = M(e);
890
908
  k(() => {
891
909
  let e = setInterval(() => n(Date.now()), 1e3);
892
910
  return () => clearInterval(e);
893
911
  }, []);
894
912
  let r = Math.floor((t - e) / 1e3);
895
- return r < 10 ? null : /* @__PURE__ */ I("span", {
913
+ return r < 10 ? null : /* @__PURE__ */ F("span", {
896
914
  className: "tabular-nums",
897
915
  children: [
898
916
  " · ",
@@ -902,76 +920,95 @@ function ot() {
902
920
  ]
903
921
  });
904
922
  }
905
- function st({ status: e }) {
906
- return e === "running" ? /* @__PURE__ */ F("span", { className: "inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" }) : e === "done" ? /* @__PURE__ */ F(f, {
923
+ function ct({ status: e }) {
924
+ return e === "running" ? /* @__PURE__ */ P("span", { className: "inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" }) : e === "done" ? /* @__PURE__ */ P(f, {
907
925
  name: "check",
908
926
  size: 12,
909
927
  className: "shrink-0 text-green-600"
910
- }) : e === "stopped" ? /* @__PURE__ */ F(f, {
928
+ }) : e === "stopped" ? /* @__PURE__ */ P(f, {
911
929
  name: "circle-slash",
912
930
  size: 12,
913
931
  className: "shrink-0 text-muted-foreground"
914
- }) : /* @__PURE__ */ F(f, {
932
+ }) : /* @__PURE__ */ P(f, {
915
933
  name: "x",
916
934
  size: 12,
917
935
  className: "shrink-0 text-destructive"
918
936
  });
919
937
  }
920
- function ct(e, t) {
938
+ function lt(e, t) {
921
939
  return e.status === "running" ? t.thinking : e.status === "error" ? t.modelRequestError : e.status === "stopped" ? t.stopped : e.detail ? t.responseReceived : e.toolNames && e.toolNames.length > 0 ? e.toolNames.join(" · ") : t.toolRequest;
922
940
  }
923
- var lt = 96;
924
- function ut({ entry: e, pinned: t = !0 }) {
925
- let n = M(null), [r, i] = N(!1), [a, o] = N(!1);
926
- A(() => {
927
- let e = n.current;
928
- e && o(e.scrollHeight > 97);
941
+ var ut = 96;
942
+ function dt({ entry: e, pinned: n = !0, actions: r }) {
943
+ let i = $(), a = j(null), [o, s] = M(!1), [c, l] = M(!1);
944
+ te(() => {
945
+ let e = a.current;
946
+ e && l(e.scrollHeight > 97);
929
947
  }, [e.detail, e.attachmentNames]);
930
- let s = a && !r;
948
+ let u = c && !o;
931
949
  return /* @__PURE__ */ F("div", {
932
- className: `${t ? "sticky top-0 z-20 border-b border-border/40" : ""} flex justify-end bg-background py-1.5`,
933
- children: /* @__PURE__ */ I("div", {
950
+ className: `${n ? "sticky top-0 z-20 border-b border-border/40" : ""} group flex items-start justify-end gap-1 bg-background py-1.5`,
951
+ children: [r?.available(e) && /* @__PURE__ */ F("span", {
952
+ className: "flex shrink-0 items-center opacity-50 transition-opacity focus-within:opacity-100 group-hover:opacity-100",
953
+ children: [/* @__PURE__ */ P(t, {
954
+ icon: "rotate-ccw",
955
+ ariaLabel: i.retryFromHere,
956
+ title: i.retryFromHere,
957
+ variant: "link",
958
+ className: "p-1 text-muted-foreground hover:text-foreground",
959
+ disabled: r.disabled,
960
+ onClick: () => r.onRetry(e)
961
+ }), /* @__PURE__ */ P(t, {
962
+ icon: "pencil",
963
+ ariaLabel: i.editMessage,
964
+ title: i.editMessage,
965
+ variant: "link",
966
+ className: "p-1 text-muted-foreground hover:text-foreground",
967
+ disabled: r.disabled,
968
+ onClick: () => r.onEdit(e)
969
+ })]
970
+ }), /* @__PURE__ */ F("div", {
934
971
  className: "max-w-[85%] rounded-lg bg-primary/10 text-xs text-foreground",
935
- children: [/* @__PURE__ */ I("div", {
936
- ref: n,
937
- className: `space-y-1 px-2.5 pt-1.5 ${s ? "overflow-hidden" : ""}`,
938
- style: s ? { maxHeight: lt } : void 0,
939
- children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ F("div", {
972
+ children: [/* @__PURE__ */ F("div", {
973
+ ref: a,
974
+ className: `space-y-1 px-2.5 pt-1.5 ${u ? "overflow-hidden" : ""}`,
975
+ style: u ? { maxHeight: ut } : void 0,
976
+ children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ P("div", {
940
977
  className: "flex flex-wrap gap-1",
941
- children: e.attachmentNames.map((e, t) => /* @__PURE__ */ I("span", {
978
+ children: e.attachmentNames.map((e, t) => /* @__PURE__ */ F("span", {
942
979
  className: "inline-flex items-center gap-1 rounded-md bg-primary/15 px-1.5 py-0.5 text-[11px] text-foreground",
943
- children: [/* @__PURE__ */ F(f, {
980
+ children: [/* @__PURE__ */ P(f, {
944
981
  name: "paperclip",
945
982
  size: 10,
946
983
  className: "shrink-0"
947
- }), /* @__PURE__ */ F("span", {
984
+ }), /* @__PURE__ */ P("span", {
948
985
  className: "max-w-[160px] truncate",
949
986
  children: e
950
987
  })]
951
988
  }, t))
952
- }), /* @__PURE__ */ F(at, { text: e.detail ?? "" })]
953
- }), a && /* @__PURE__ */ I("button", {
989
+ }), /* @__PURE__ */ P(ot, { text: e.detail ?? "" })]
990
+ }), c && /* @__PURE__ */ F("button", {
954
991
  type: "button",
955
- onClick: () => i((e) => !e),
992
+ onClick: () => s((e) => !e),
956
993
  className: "relative flex w-full items-center justify-center rounded-b-lg py-1 text-muted-foreground hover:bg-primary/15",
957
- title: r ? "Comprimi" : "Espandi",
958
- children: [s && /* @__PURE__ */ F("div", { className: "pointer-events-none absolute inset-x-0 -top-4 h-4 bg-gradient-to-t from-primary/10 to-transparent" }), /* @__PURE__ */ F(f, {
959
- name: r ? "chevron-up" : "chevron-down",
994
+ title: o ? "Comprimi" : "Espandi",
995
+ children: [u && /* @__PURE__ */ P("div", { className: "pointer-events-none absolute inset-x-0 -top-4 h-4 bg-gradient-to-t from-primary/10 to-transparent" }), /* @__PURE__ */ P(f, {
996
+ name: o ? "chevron-up" : "chevron-down",
960
997
  size: 12
961
998
  })]
962
999
  })]
963
- })
1000
+ })]
964
1001
  });
965
1002
  }
966
- var dt = {
1003
+ var ft = {
967
1004
  running: "loader-circle",
968
1005
  done: "check",
969
1006
  error: "x",
970
1007
  stopped: "circle-slash"
971
1008
  };
972
- function ft({ steps: e }) {
973
- let t = $(), n = e.filter((e) => e.status === "running").at(-1), r = e.some((e) => e.status === "error"), i = n?.label ?? (e.length === 1 ? t.oneStep : y(t.steps, { count: e.length }));
974
- return /* @__PURE__ */ F(_, {
1009
+ function pt({ steps: e }) {
1010
+ let t = $(), n = e.filter((e) => e.status === "running").at(-1), r = e.some((e) => e.status === "error"), i = n?.label ?? (e.length === 1 ? t.oneStep : b(t.steps, { count: e.length }));
1011
+ return /* @__PURE__ */ P(v, {
975
1012
  ariaLabel: t.stepsLabel,
976
1013
  selectedId: null,
977
1014
  itemClassName: "py-0.5 text-xs text-muted-foreground",
@@ -981,40 +1018,40 @@ function ft({ steps: e }) {
981
1018
  icon: n ? "loader-circle" : r ? "circle-alert" : "list-checks",
982
1019
  children: e.map((e) => ({
983
1020
  id: e.id,
984
- label: /* @__PURE__ */ F("span", {
1021
+ label: /* @__PURE__ */ P("span", {
985
1022
  className: e.status === "error" ? "text-destructive" : void 0,
986
1023
  children: e.label
987
1024
  }),
988
- icon: dt[e.status]
1025
+ icon: ft[e.status]
989
1026
  }))
990
1027
  }]
991
1028
  });
992
1029
  }
993
- function pt({ entry: e, part: a, questions: o }) {
994
- let s = $(), [c, l] = N(!1), u = !!(o?.onCardAction && o.canAnswer(e.id) && !a.outcome), d = a.outcome?.status === "done" ? "text-success" : a.outcome?.status === "error" ? "text-destructive" : "text-muted-foreground";
995
- return /* @__PURE__ */ I(r, {
1030
+ function mt({ entry: e, part: a, questions: o }) {
1031
+ let s = $(), [c, l] = M(!1), u = !!(o?.onCardAction && o.canAnswer(e.id) && !a.outcome), d = a.outcome?.status === "done" ? "text-success" : a.outcome?.status === "error" ? "text-destructive" : "text-muted-foreground";
1032
+ return /* @__PURE__ */ F(r, {
996
1033
  headerClassName: "flex items-center justify-between gap-2 px-3 py-2",
997
1034
  bodyClassName: "px-3 py-2",
998
- header: /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F("span", {
1035
+ header: /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P("span", {
999
1036
  className: "min-w-0 text-xs font-semibold text-foreground",
1000
1037
  children: a.title
1001
- }), a.badge && /* @__PURE__ */ F(n, {
1038
+ }), a.badge && /* @__PURE__ */ P(n, {
1002
1039
  variant: a.badge.variant ?? "info",
1003
1040
  children: a.badge.label
1004
1041
  })] }),
1005
- footer: /* @__PURE__ */ I("div", {
1042
+ footer: /* @__PURE__ */ F("div", {
1006
1043
  className: "space-y-1.5 px-3 py-2",
1007
- children: [/* @__PURE__ */ I("div", {
1044
+ children: [/* @__PURE__ */ F("div", {
1008
1045
  className: "flex items-center gap-1",
1009
1046
  children: [
1010
- a.details && /* @__PURE__ */ F(t, {
1047
+ a.details && /* @__PURE__ */ P(t, {
1011
1048
  icon: "eye",
1012
1049
  ariaLabel: s.cardView,
1013
1050
  title: s.cardView,
1014
1051
  variant: "outline-secondary",
1015
1052
  onClick: () => l(!0)
1016
1053
  }),
1017
- (a.actions ?? []).filter((e) => e.variant !== "primary" && e.icon).map((t) => /* @__PURE__ */ F(m, {
1054
+ (a.actions ?? []).filter((e) => e.variant !== "primary" && e.icon).map((t) => /* @__PURE__ */ P(m, {
1018
1055
  icon: t.icon,
1019
1056
  ariaLabel: t.label,
1020
1057
  title: t.label,
@@ -1022,9 +1059,9 @@ function pt({ entry: e, part: a, questions: o }) {
1022
1059
  disabled: !u,
1023
1060
  onClick: () => o.onCardAction(e.id, a.id, t.id)
1024
1061
  }, t.id)),
1025
- /* @__PURE__ */ F("span", {
1062
+ /* @__PURE__ */ P("span", {
1026
1063
  className: "ms-auto flex items-center gap-1",
1027
- children: (a.actions ?? []).filter((e) => e.variant === "primary" || !e.icon).map((t) => /* @__PURE__ */ F(m, {
1064
+ children: (a.actions ?? []).filter((e) => e.variant === "primary" || !e.icon).map((t) => /* @__PURE__ */ P(m, {
1028
1065
  ...t.icon ? { icon: t.icon } : {},
1029
1066
  label: t.label,
1030
1067
  variant: t.variant ?? "outline-primary",
@@ -1033,9 +1070,9 @@ function pt({ entry: e, part: a, questions: o }) {
1033
1070
  }, t.id))
1034
1071
  })
1035
1072
  ]
1036
- }), a.outcome && /* @__PURE__ */ I("p", {
1073
+ }), a.outcome && /* @__PURE__ */ F("p", {
1037
1074
  className: `text-xs ${d}`,
1038
- children: [a.outcome.text, a.outcome.link && /* @__PURE__ */ I(P, { children: [" ", /* @__PURE__ */ F("a", {
1075
+ children: [a.outcome.text, a.outcome.link && /* @__PURE__ */ F(N, { children: [" ", /* @__PURE__ */ P("a", {
1039
1076
  className: "underline",
1040
1077
  href: a.outcome.link.url,
1041
1078
  target: "_blank",
@@ -1044,27 +1081,27 @@ function pt({ entry: e, part: a, questions: o }) {
1044
1081
  })] })]
1045
1082
  })]
1046
1083
  }),
1047
- children: [a.body ? /* @__PURE__ */ F(i, {
1084
+ children: [a.body ? /* @__PURE__ */ P(i, {
1048
1085
  content: a.body,
1049
1086
  className: "break-words text-xs leading-relaxed text-foreground"
1050
- }) : null, c && a.details && /* @__PURE__ */ F(h, {
1087
+ }) : null, c && a.details && /* @__PURE__ */ P(h, {
1051
1088
  title: a.title,
1052
1089
  position: "right",
1053
1090
  size: "lg",
1054
1091
  onClose: () => l(!1),
1055
- footer: /* @__PURE__ */ F(t, {
1092
+ footer: /* @__PURE__ */ P(t, {
1056
1093
  label: s.cardClose,
1057
1094
  variant: "outline-secondary",
1058
1095
  onClick: () => l(!1)
1059
1096
  }),
1060
- children: /* @__PURE__ */ F(i, {
1097
+ children: /* @__PURE__ */ P(i, {
1061
1098
  content: a.details,
1062
1099
  className: "break-words text-sm leading-relaxed text-foreground"
1063
1100
  })
1064
1101
  })]
1065
1102
  });
1066
1103
  }
1067
- function mt(e, t) {
1104
+ function ht(e, t) {
1068
1105
  let n = e.at(-1);
1069
1106
  if (!n || n.kind !== "thinking" || !n.parts || n.status === "stopped" || n.status === "error") return null;
1070
1107
  let r = [...n.parts].reverse().find((e) => e.type === "questions");
@@ -1073,9 +1110,9 @@ function mt(e, t) {
1073
1110
  part: r
1074
1111
  };
1075
1112
  }
1076
- function ht({ entry: e, part: t, questions: n, autoFocus: r, className: i }) {
1113
+ function gt({ entry: e, part: t, questions: n, autoFocus: r, className: i }) {
1077
1114
  let o = !!n?.canAnswer(e.id);
1078
- return /* @__PURE__ */ F(a, {
1115
+ return /* @__PURE__ */ P(a, {
1079
1116
  questions: t.questions,
1080
1117
  ...t.answers ? { answers: t.answers } : {},
1081
1118
  disabled: !t.answers && !o,
@@ -1084,7 +1121,7 @@ function ht({ entry: e, part: t, questions: n, autoFocus: r, className: i }) {
1084
1121
  className: i ?? "text-xs"
1085
1122
  });
1086
1123
  }
1087
- function gt({ entry: e, questions: t, hiddenPartId: n }) {
1124
+ function _t({ entry: e, questions: t, hiddenPartId: n }) {
1088
1125
  let r = (e.parts ?? []).filter((e) => e.type !== "questions" || e.id !== n), a = [];
1089
1126
  for (let e of r) {
1090
1127
  let t = a.at(-1);
@@ -1096,25 +1133,25 @@ function gt({ entry: e, questions: t, hiddenPartId: n }) {
1096
1133
  part: e
1097
1134
  });
1098
1135
  }
1099
- return /* @__PURE__ */ F("div", {
1136
+ return /* @__PURE__ */ P("div", {
1100
1137
  className: "space-y-2",
1101
1138
  children: a.map((n) => {
1102
- if ("steps" in n) return /* @__PURE__ */ F(ft, { steps: n.steps }, n.key);
1139
+ if ("steps" in n) return /* @__PURE__ */ P(pt, { steps: n.steps }, n.key);
1103
1140
  let { part: r } = n;
1104
- return r.type === "text" ? r.text.trim() ? /* @__PURE__ */ F(i, {
1141
+ return r.type === "text" ? r.text.trim() ? /* @__PURE__ */ P(i, {
1105
1142
  content: r.text,
1106
1143
  streaming: r.streaming,
1107
1144
  className: "break-words text-xs leading-relaxed text-foreground"
1108
- }, n.key) : null : r.type === "reasoning" ? /* @__PURE__ */ F(o, {
1145
+ }, n.key) : null : r.type === "reasoning" ? /* @__PURE__ */ P(o, {
1109
1146
  content: r.text,
1110
1147
  streaming: r.streaming,
1111
1148
  duration: r.duration,
1112
1149
  className: "my-0"
1113
- }, n.key) : r.type === "card" ? /* @__PURE__ */ F(pt, {
1150
+ }, n.key) : r.type === "card" ? /* @__PURE__ */ P(mt, {
1114
1151
  entry: e,
1115
1152
  part: r,
1116
1153
  questions: t
1117
- }, n.key) : /* @__PURE__ */ F(ht, {
1154
+ }, n.key) : /* @__PURE__ */ P(gt, {
1118
1155
  entry: e,
1119
1156
  part: r,
1120
1157
  questions: t
@@ -1122,52 +1159,52 @@ function gt({ entry: e, questions: t, hiddenPartId: n }) {
1122
1159
  })
1123
1160
  });
1124
1161
  }
1125
- function _t({ entry: e, questions: t, hiddenPartId: n }) {
1162
+ function vt({ entry: e, questions: t, hiddenPartId: n }) {
1126
1163
  let r = $();
1127
1164
  if (e.kind === "thinking" && e.parts) {
1128
1165
  let i = e.status === "error" || e.status === "stopped" || e.status === "running";
1129
- return /* @__PURE__ */ I("li", {
1166
+ return /* @__PURE__ */ F("li", {
1130
1167
  className: "text-xs text-muted-foreground",
1131
- children: [e.parts.length > 0 && /* @__PURE__ */ F(gt, {
1168
+ children: [e.parts.length > 0 && /* @__PURE__ */ P(_t, {
1132
1169
  entry: e,
1133
1170
  questions: t,
1134
1171
  hiddenPartId: n
1135
- }), i && /* @__PURE__ */ I("div", {
1172
+ }), i && /* @__PURE__ */ F("div", {
1136
1173
  className: `flex items-start gap-1.5 ${e.parts.length > 0 ? "mt-1" : ""}`,
1137
- children: [/* @__PURE__ */ F("span", {
1174
+ children: [/* @__PURE__ */ P("span", {
1138
1175
  className: "pt-px",
1139
- children: /* @__PURE__ */ F(st, { status: e.status })
1140
- }), /* @__PURE__ */ I("span", {
1176
+ children: /* @__PURE__ */ P(ct, { status: e.status })
1177
+ }), /* @__PURE__ */ F("span", {
1141
1178
  className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
1142
- children: [ct(e, r), e.status === "running" && /* @__PURE__ */ F(ot, {})]
1179
+ children: [lt(e, r), e.status === "running" && /* @__PURE__ */ P(st, {})]
1143
1180
  })]
1144
1181
  })]
1145
1182
  });
1146
1183
  }
1147
- let a = e.kind === "thinking" && e.detail ? rt(e.detail) : [], o = a.filter((e) => e.type === "code"), s = a.filter((e) => e.type === "text" && e.content.trim()), c = e.kind === "thinking" ? ct(e, r) : e.label;
1148
- return /* @__PURE__ */ I("li", {
1184
+ let a = e.kind === "thinking" && e.detail ? it(e.detail) : [], o = a.filter((e) => e.type === "code"), s = a.filter((e) => e.type === "text" && e.content.trim()), c = e.kind === "thinking" ? lt(e, r) : e.label;
1185
+ return /* @__PURE__ */ F("li", {
1149
1186
  className: "text-xs text-muted-foreground",
1150
1187
  children: [
1151
- /* @__PURE__ */ I("div", {
1188
+ /* @__PURE__ */ F("div", {
1152
1189
  className: "flex items-start gap-1.5",
1153
- children: [/* @__PURE__ */ F("span", {
1190
+ children: [/* @__PURE__ */ P("span", {
1154
1191
  className: "pt-px",
1155
- children: /* @__PURE__ */ F(st, { status: e.status })
1156
- }), /* @__PURE__ */ F("span", {
1192
+ children: /* @__PURE__ */ P(ct, { status: e.status })
1193
+ }), /* @__PURE__ */ P("span", {
1157
1194
  className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
1158
1195
  children: c
1159
1196
  })]
1160
1197
  }),
1161
- o.length > 0 && /* @__PURE__ */ F("div", {
1198
+ o.length > 0 && /* @__PURE__ */ P("div", {
1162
1199
  className: "mt-1 ml-[18px] space-y-1",
1163
- children: o.map((e, t) => /* @__PURE__ */ F(it, {
1200
+ children: o.map((e, t) => /* @__PURE__ */ P(at, {
1164
1201
  content: e.content,
1165
1202
  language: e.language
1166
1203
  }, t))
1167
1204
  }),
1168
- s.length > 0 && /* @__PURE__ */ F("div", {
1205
+ s.length > 0 && /* @__PURE__ */ P("div", {
1169
1206
  className: "mt-1 ml-[18px] space-y-2",
1170
- children: s.map((e, t) => /* @__PURE__ */ F(i, {
1207
+ children: s.map((e, t) => /* @__PURE__ */ P(i, {
1171
1208
  content: e.content.trim(),
1172
1209
  tone: "muted",
1173
1210
  className: "break-words text-xs leading-relaxed"
@@ -1176,21 +1213,22 @@ function _t({ entry: e, questions: t, hiddenPartId: n }) {
1176
1213
  ]
1177
1214
  });
1178
1215
  }
1179
- function vt({ activity: e, questions: t, docked: n, pinUserMessages: r = !0 }) {
1216
+ function yt({ activity: e, questions: t, docked: n, pinUserMessages: r = !0, messageActions: i }) {
1180
1217
  if (e.length === 0) return null;
1181
- let i = [];
1182
- for (let t of e) t.kind === "user" || i.length === 0 ? i.push(t.kind === "user" ? {
1218
+ let a = [];
1219
+ for (let t of e) t.kind === "user" || a.length === 0 ? a.push(t.kind === "user" ? {
1183
1220
  user: t,
1184
1221
  entries: []
1185
- } : { entries: [t] }) : i[i.length - 1].entries.push(t);
1186
- return /* @__PURE__ */ F("ul", {
1222
+ } : { entries: [t] }) : a[a.length - 1].entries.push(t);
1223
+ return /* @__PURE__ */ P("ul", {
1187
1224
  className: "space-y-0.5",
1188
- children: i.map((e) => /* @__PURE__ */ I("li", { children: [e.user && /* @__PURE__ */ F(ut, {
1225
+ children: a.map((e) => /* @__PURE__ */ F("li", { children: [e.user && /* @__PURE__ */ P(dt, {
1189
1226
  entry: e.user,
1190
- pinned: r
1191
- }), e.entries.length > 0 && /* @__PURE__ */ F("ul", {
1227
+ pinned: r,
1228
+ actions: i
1229
+ }), e.entries.length > 0 && /* @__PURE__ */ P("ul", {
1192
1230
  className: "space-y-0.5",
1193
- children: e.entries.map((e) => /* @__PURE__ */ F(_t, {
1231
+ children: e.entries.map((e) => /* @__PURE__ */ P(vt, {
1194
1232
  entry: e,
1195
1233
  questions: t,
1196
1234
  hiddenPartId: n?.entry.id === e.id ? n.part.id : void 0
@@ -1200,56 +1238,56 @@ function vt({ activity: e, questions: t, docked: n, pinUserMessages: r = !0 }) {
1200
1238
  }
1201
1239
  //#endregion
1202
1240
  //#region src/presentation/panelWidth.ts
1203
- var yt = 420, bt = 320, xt = "60vw", St = "agentico:panel-width";
1204
- function Ct(e, t) {
1241
+ var bt = 420, xt = 320, St = "60vw", Ct = "agentico:panel-width";
1242
+ function wt(e, t) {
1205
1243
  if (typeof e == "number") return e;
1206
1244
  let n = Number.parseFloat(e);
1207
1245
  return Number.isFinite(n) ? Math.round(n / 100 * t) : Infinity;
1208
1246
  }
1209
- function wt(e, t, n) {
1247
+ function Tt(e, t, n) {
1210
1248
  return Math.round(Math.min(Math.max(e, t), Math.max(t, n)));
1211
1249
  }
1212
- function Tt() {
1250
+ function Et() {
1213
1251
  try {
1214
- let e = window.localStorage.getItem(St), t = e === null ? NaN : Number(e);
1252
+ let e = window.localStorage.getItem(Ct), t = e === null ? NaN : Number(e);
1215
1253
  return Number.isFinite(t) && t > 0 ? t : null;
1216
1254
  } catch {
1217
1255
  return null;
1218
1256
  }
1219
1257
  }
1220
- function Et(e) {
1258
+ function Dt(e) {
1221
1259
  try {
1222
- e === null ? window.localStorage.removeItem(St) : window.localStorage.setItem(St, String(e));
1260
+ e === null ? window.localStorage.removeItem(Ct) : window.localStorage.setItem(Ct, String(e));
1223
1261
  } catch {}
1224
1262
  }
1225
- function Dt() {
1263
+ function Ot() {
1226
1264
  return typeof window > "u" ? Infinity : window.innerWidth;
1227
1265
  }
1228
- function Ot({ defaultWidth: e = 420, minWidth: t = 320, maxWidth: n = xt, onWidthChange: r }) {
1229
- let [i, a] = N(Dt), [o, s] = N(() => Tt() ?? e);
1266
+ function kt({ defaultWidth: e = 420, minWidth: t = 320, maxWidth: n = St, onWidthChange: r }) {
1267
+ let [i, a] = M(Ot), [o, s] = M(() => Et() ?? e);
1230
1268
  k(() => {
1231
1269
  if (typeof window > "u") return;
1232
1270
  let e = () => a(window.innerWidth);
1233
1271
  return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
1234
1272
  }, []);
1235
- let c = t, l = Math.max(c, Ct(n, i)), u = wt(o, c, l);
1273
+ let c = t, l = Math.max(c, wt(n, i)), u = Tt(o, c, l);
1236
1274
  return k(() => {
1237
1275
  r?.(u);
1238
1276
  }, [u]), {
1239
1277
  width: u,
1240
1278
  min: c,
1241
1279
  max: l,
1242
- set: D((e) => s(wt(e, c, l)), [c, l]),
1243
- commit: D((e) => Et(wt(e, c, l)), [c, l]),
1244
- reset: D(() => {
1245
- s(e), Et(null);
1280
+ set: O((e) => s(Tt(e, c, l)), [c, l]),
1281
+ commit: O((e) => Dt(Tt(e, c, l)), [c, l]),
1282
+ reset: O(() => {
1283
+ s(e), Dt(null);
1246
1284
  }, [e])
1247
1285
  };
1248
1286
  }
1249
1287
  //#endregion
1250
1288
  //#region src/presentation/AgenticoResizeHandle.tsx
1251
- function kt({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a }) {
1252
- let o = $(), s = M(null), [c, l] = N(!1), u = (e) => Math.round(Math.min(Math.max(e, t), Math.max(t, n))), d = (e) => {
1289
+ function At({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a }) {
1290
+ let o = $(), s = j(null), [c, l] = M(!1), u = (e) => Math.round(Math.min(Math.max(e, t), Math.max(t, n))), d = (e) => {
1253
1291
  let t = s.current;
1254
1292
  if (t && t.pointerId === e.pointerId) {
1255
1293
  s.current = null, l(!1), document.body.style.removeProperty("cursor"), document.body.style.removeProperty("user-select");
@@ -1259,7 +1297,7 @@ function kt({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a })
1259
1297
  i(t.last);
1260
1298
  }
1261
1299
  };
1262
- return /* @__PURE__ */ F("div", {
1300
+ return /* @__PURE__ */ P("div", {
1263
1301
  role: "separator",
1264
1302
  "aria-orientation": "vertical",
1265
1303
  "aria-label": o.resizePanel,
@@ -1298,7 +1336,7 @@ function kt({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a })
1298
1336
  let c = u(s);
1299
1337
  r(c), i(c);
1300
1338
  },
1301
- children: /* @__PURE__ */ F("span", {
1339
+ children: /* @__PURE__ */ P("span", {
1302
1340
  "aria-hidden": !0,
1303
1341
  className: `h-full w-0.5 transition-colors ${c ? "bg-primary" : "bg-transparent group-hover:bg-primary/50 group-focus-visible:bg-primary"}`
1304
1342
  })
@@ -1306,9 +1344,9 @@ function kt({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a })
1306
1344
  }
1307
1345
  //#endregion
1308
1346
  //#region src/presentation/AgenticoToggle.tsx
1309
- function At({ className: e = "" }) {
1310
- let { isOpen: n, toggleOpen: r, task: i } = tt(), a = $(), o = i?.agent.running ?? !1;
1311
- return /* @__PURE__ */ F(t, {
1347
+ function jt({ className: e = "" }) {
1348
+ let { isOpen: n, toggleOpen: r, task: i } = nt(), a = $(), o = i?.agent.running ?? !1;
1349
+ return /* @__PURE__ */ P(t, {
1312
1350
  icon: "bot",
1313
1351
  ariaLabel: n ? a.closePanel : a.openPanel,
1314
1352
  title: n ? a.closePanel : a.openPanel,
@@ -1319,32 +1357,32 @@ function At({ className: e = "" }) {
1319
1357
  }
1320
1358
  //#endregion
1321
1359
  //#region src/presentation/useAIModelCatalog.ts
1322
- var jt = "llmnative-cms.selectedAIModel";
1323
- function Mt() {
1360
+ var Mt = "llmnative-cms.selectedAIModel";
1361
+ function Nt() {
1324
1362
  try {
1325
- return localStorage.getItem(jt) ?? "";
1363
+ return localStorage.getItem(Mt) ?? "";
1326
1364
  } catch {
1327
1365
  return "";
1328
1366
  }
1329
1367
  }
1330
- function Nt(e) {
1368
+ function Pt(e) {
1331
1369
  try {
1332
- e ? localStorage.setItem(jt, e) : localStorage.removeItem(jt);
1370
+ e ? localStorage.setItem(Mt, e) : localStorage.removeItem(Mt);
1333
1371
  } catch {}
1334
1372
  }
1335
- function Pt() {
1336
- let e = S()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = N({}), [i, a] = N(!1), [o, s] = N(Mt);
1373
+ function Ft() {
1374
+ let e = C()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = M({}), [i, a] = M(!1), [o, s] = M(Nt);
1337
1375
  return k(() => {
1338
1376
  if (!t) {
1339
1377
  r({});
1340
1378
  return;
1341
1379
  }
1342
1380
  let n = !1;
1343
- return a(!0), v(e).then((e) => {
1381
+ return a(!0), y(e).then((e) => {
1344
1382
  if (n) return;
1345
1383
  r(e.modelsByProvider);
1346
1384
  let t = Object.values(e.modelsByProvider).flat();
1347
- s((e) => t.some((t) => t.id === e) ? e : (Nt(""), ""));
1385
+ s((e) => t.some((t) => t.id === e) ? e : (Pt(""), ""));
1348
1386
  }).catch((e) => {
1349
1387
  console.error("useAIModelCatalog: getAIModelCatalog failed", e), n || r({});
1350
1388
  }).finally(() => {
@@ -1358,17 +1396,17 @@ function Pt() {
1358
1396
  modelsLoading: i,
1359
1397
  selectedModel: o,
1360
1398
  setSelectedModel: (e) => {
1361
- Nt(e), s(e);
1399
+ Pt(e), s(e);
1362
1400
  }
1363
1401
  };
1364
1402
  }
1365
1403
  //#endregion
1366
1404
  //#region src/domain/approval.ts
1367
- var Ft = "approval";
1368
- function It(e, t) {
1405
+ var It = "approval";
1406
+ function Lt(e, t) {
1369
1407
  return typeof e.needsApproval == "function" ? e.needsApproval(t) : e.needsApproval === !0;
1370
1408
  }
1371
- function Lt(e, t, n) {
1409
+ function Rt(e, t, n) {
1372
1410
  let r = e[0]?.values ?? [], i = r.filter((e) => e !== t && e !== n).join(" ").trim();
1373
1411
  return {
1374
1412
  approved: r.includes(t) && !r.includes(n),
@@ -1377,11 +1415,11 @@ function Lt(e, t, n) {
1377
1415
  }
1378
1416
  //#endregion
1379
1417
  //#region src/presentation/useAgent.ts
1380
- var Rt = 20, zt = 26e4;
1381
- function Bt(e) {
1382
- return e.filter((e) => !g.isTextAttachment(e.mimeType) || e.base64.length <= zt);
1383
- }
1418
+ var zt = 20, Bt = 26e4;
1384
1419
  function Vt(e) {
1420
+ return e.filter((e) => !_.isTextAttachment(e.mimeType) || e.base64.length <= Bt);
1421
+ }
1422
+ function Ht(e) {
1385
1423
  return e.map((e) => e.status !== "running" && !e.parts?.some((e) => e.type === "tool" && e.status === "running" || (e.type === "text" || e.type === "reasoning") && e.streaming) ? e : {
1386
1424
  ...e,
1387
1425
  status: e.status === "running" ? "stopped" : e.status,
@@ -1394,37 +1432,37 @@ function Vt(e) {
1394
1432
  } : e) } : {}
1395
1433
  });
1396
1434
  }
1397
- function Ht(e, t = {}) {
1398
- let { defaultEnabled: n = !1 } = t, [r, i] = N(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: c, setSelectedModel: l } = Pt(), [u, d] = N(!1), [f, p] = N(null), [m, h] = N(!1), [_, v] = N([]), y = M([]), x = (e) => {
1435
+ function Ut(e, t = {}) {
1436
+ let { defaultEnabled: n = !1 } = t, [r, i] = M(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: c, setSelectedModel: l } = Ft(), [u, d] = M(!1), [f, p] = M(null), [m, h] = M(!1), [g, v] = M([]), y = j([]), b = (e) => {
1399
1437
  v((t) => {
1400
1438
  let n = typeof e == "function" ? e(t) : e;
1401
1439
  return y.current = n, n;
1402
1440
  });
1403
- }, C = M(/* @__PURE__ */ new Map()), w = $(), T = M(w);
1441
+ }, S = j(/* @__PURE__ */ new Map()), w = $(), T = j(w);
1404
1442
  T.current = w;
1405
- let E = M(null), D = M(!1), O = M(null), k = () => {
1406
- O.current?.abort();
1407
- }, A = S()?.registry ?? {}, [P, F] = N(void 0), I = M(void 0), R = (e, t) => {
1443
+ let E = j(null), D = j(!1), O = j(null), ee = j(null), k = j(null), te = () => {
1444
+ k.current?.abort();
1445
+ }, N = C()?.registry ?? {}, [P, F] = M(void 0), I = j(void 0), B = (e, t) => {
1408
1446
  if (!t) return !1;
1409
1447
  if (!e) return !0;
1410
- let n = b(t);
1448
+ let n = x(t);
1411
1449
  return !!n && e.includes(n.provider);
1412
- }, te = j(() => P ? Object.fromEntries(Object.entries(o).map(([e, t]) => [e, t.filter((e) => P.includes(e.provider))]).filter(([, e]) => e.length)) : o, [P, o]), V = R(P, c) ? c : Object.values(te).flat()[0]?.id ?? "", H = r && V ? b(V) : null, U = H ? A[H.provider] : null, W = e.executor, G = !!W?.alongside, K = !!W && !G, q = M([]), re = (e) => !!e && q.current.some((t) => t.value === e), J = M(!1), [ie, ae] = N([]), [Y, oe] = N(""), Z = M(""), se = (e) => {
1413
- Z.current = e, oe(e);
1414
- }, ce = (e) => {
1415
- let t = W?.models?.(e) ?? [];
1416
- q.current = t, ae(t);
1417
- let n = W?.catalogProviders?.(e);
1450
+ }, V = A(() => P ? Object.fromEntries(Object.entries(o).map(([e, t]) => [e, t.filter((e) => P.includes(e.provider))]).filter(([, e]) => e.length)) : o, [P, o]), H = B(P, c) ? c : Object.values(V).flat()[0]?.id ?? "", U = r && H ? x(H) : null, W = U ? N[U.provider] : null, G = e.executor, K = !!G?.alongside, q = !!G && !K, ie = !G || !!G.canRewind, ae = j([]), J = (e) => !!e && ae.current.some((t) => t.value === e), Y = j(!1), [oe, se] = M([]), [ce, le] = M(""), ue = j(""), de = (e) => {
1451
+ ue.current = e, le(e);
1452
+ }, fe = (e) => {
1453
+ let t = G?.models?.(e) ?? [];
1454
+ ae.current = t, se(t);
1455
+ let n = G?.catalogProviders?.(e);
1418
1456
  I.current = n, F(n);
1419
- let r = G && !R(n, c) ? t[0]?.value : void 0;
1420
- se(W?.defaultModel?.(e) ?? r ?? "");
1421
- }, le = async (e, t, n, r) => {
1457
+ let r = K && !B(n, c) ? t[0]?.value : void 0;
1458
+ de(G?.defaultModel?.(e) ?? r ?? "");
1459
+ }, pe = async (e, t, n, r) => {
1422
1460
  let i = E.current;
1423
- if (!i || !W) return p(T.current.noActiveSession), null;
1461
+ if (!i || !G) return p(T.current.noActiveSession), null;
1424
1462
  let a = new AbortController();
1425
- O.current = a;
1463
+ k.current = a;
1426
1464
  let o = crypto.randomUUID();
1427
- x((e) => [...e, {
1465
+ b((e) => [...e, {
1428
1466
  id: o,
1429
1467
  kind: "thinking",
1430
1468
  label: T.current.thinking,
@@ -1435,16 +1473,16 @@ function Ht(e, t = {}) {
1435
1473
  ...e,
1436
1474
  streaming: !1,
1437
1475
  duration: e.duration ?? c(e.id)
1438
- }), u = (e, t) => x((n) => n.map((n) => {
1476
+ }), u = (e, t) => b((n) => n.map((n) => {
1439
1477
  if (n.id !== o) return n;
1440
- let r = e(n.parts ?? []), i = ee(r);
1478
+ let r = e(n.parts ?? []), i = R(r);
1441
1479
  return {
1442
1480
  ...n,
1443
1481
  parts: r,
1444
1482
  ...t ? { status: t } : {},
1445
1483
  ...i ? { detail: i } : {}
1446
1484
  };
1447
- })), d = (e) => u((t) => z(t, e, l)), f = !1, m = (e, t) => {
1485
+ })), d = (e) => u((t) => L(t, e, l)), f = !1, m = (e, t) => {
1448
1486
  t?.id && t.id !== "text" && (f = !0), d({
1449
1487
  type: "text",
1450
1488
  id: t?.id ?? "text",
@@ -1468,17 +1506,17 @@ function Ht(e, t = {}) {
1468
1506
  }), _ = (e) => d({
1469
1507
  ...e,
1470
1508
  type: "card"
1471
- }), v = /* @__PURE__ */ new Set(), y = 0, b = () => {
1509
+ }), v = /* @__PURE__ */ new Set(), x = 0, C = () => {
1472
1510
  for (let e of v) {
1473
- let t = C.current.get(e);
1474
- C.current.delete(e), t?.reject(new DOMException("The turn was stopped.", "AbortError"));
1511
+ let t = S.current.get(e);
1512
+ S.current.delete(e), t?.reject(new DOMException("The turn was stopped.", "AbortError"));
1475
1513
  }
1476
1514
  v.clear();
1477
1515
  };
1478
- a.signal.addEventListener("abort", b);
1479
- let S = (e, t) => {
1480
- y += 1;
1481
- let n = t?.id ?? `questions-${y}`;
1516
+ a.signal.addEventListener("abort", C);
1517
+ let w = (e, t) => {
1518
+ x += 1;
1519
+ let n = t?.id ?? `questions-${x}`;
1482
1520
  d({
1483
1521
  type: "questions",
1484
1522
  id: n,
@@ -1486,15 +1524,15 @@ function Ht(e, t = {}) {
1486
1524
  });
1487
1525
  let r = `${o}:${n}`;
1488
1526
  return a.signal.aborted ? Promise.reject(new DOMException("The turn was stopped.", "AbortError")) : (v.add(r), new Promise((e, t) => {
1489
- C.current.set(r, {
1527
+ S.current.set(r, {
1490
1528
  resolve: e,
1491
1529
  reject: t
1492
1530
  });
1493
1531
  }));
1494
- }, w = (e, t) => {
1495
- u((n) => (t && !f ? z(n, {
1532
+ }, D = (e, t) => {
1533
+ u((n) => (t && !f ? L(n, {
1496
1534
  type: "text",
1497
- id: L,
1535
+ id: ne,
1498
1536
  text: t,
1499
1537
  streaming: !1
1500
1538
  }, l) : n).map((t) => t.type === "reasoning" && t.streaming ? l(t) : t.type === "text" && t.streaming ? {
@@ -1503,18 +1541,21 @@ function Ht(e, t = {}) {
1503
1541
  } : t.type === "tool" && t.status === "running" && e !== "done" ? {
1504
1542
  ...t,
1505
1543
  status: "stopped"
1506
- } : t), e), a.signal.removeEventListener("abort", b);
1507
- for (let e of v) C.current.delete(e);
1544
+ } : t), e), a.signal.removeEventListener("abort", C);
1545
+ for (let e of v) S.current.delete(e);
1508
1546
  v.clear();
1509
- }, D = e || r?.historyText || "";
1547
+ }, te = e || r?.historyText || "";
1510
1548
  try {
1511
- let o = await W.turn({
1549
+ let s = O.current;
1550
+ O.current = null;
1551
+ let c = y.current, l = c.findIndex((e) => e.id === ee.current), u = s ? { activity: s.fresh ? s.activity : (l >= 0 ? c.slice(0, l) : c).filter((e) => e.id !== o) } : void 0, d = await G.turn({
1512
1552
  params: i.params,
1513
1553
  context: i.context,
1514
1554
  text: e,
1515
1555
  first: t,
1516
1556
  signal: a.signal,
1517
- ...n || Z.current ? { model: n || Z.current } : {},
1557
+ ...u ? { rewound: u } : {},
1558
+ ...n || ue.current ? { model: n || ue.current } : {},
1518
1559
  ...r ? { answers: {
1519
1560
  id: r.id,
1520
1561
  answers: r.answers
@@ -1522,29 +1563,29 @@ function Ht(e, t = {}) {
1522
1563
  onText: m,
1523
1564
  onReasoning: h,
1524
1565
  onStep: g,
1525
- onQuestions: S,
1566
+ onQuestions: w,
1526
1567
  onCard: _
1527
1568
  });
1528
- return w("done", o.text), i.history = [
1569
+ return D("done", d.text), i.history = [
1529
1570
  ...i.history,
1530
- ...D ? [{
1571
+ ...te ? [{
1531
1572
  role: "user",
1532
- content: D
1573
+ content: te
1533
1574
  }] : [],
1534
1575
  {
1535
1576
  role: "assistant",
1536
- content: o.text
1577
+ content: d.text
1537
1578
  }
1538
- ], o.result ?? null;
1579
+ ], d.result ?? null;
1539
1580
  } catch (e) {
1540
- return i.history = [...i.history, ...D ? [{
1581
+ return i.history = [...i.history, ...te ? [{
1541
1582
  role: "user",
1542
- content: D
1543
- }] : []], a.signal.aborted ? (w("stopped"), null) : (w("error"), p(he(e)), null);
1583
+ content: te
1584
+ }] : []], a.signal.aborted ? (D("stopped"), null) : (D("error"), p(Z(e)), null);
1544
1585
  } finally {
1545
- O.current = null;
1586
+ k.current = null;
1546
1587
  }
1547
- }, ue = async (t, n, r) => {
1588
+ }, me = async (t, n, r) => {
1548
1589
  let i = y.current.find((e) => e.id === t)?.parts?.find((e) => e.type === "card" && e.id === n), a = E.current;
1549
1590
  if (!i || !a || !e.onCardAction) return;
1550
1591
  let o;
@@ -1553,59 +1594,59 @@ function Ht(e, t = {}) {
1553
1594
  } catch (e) {
1554
1595
  o = {
1555
1596
  status: "error",
1556
- text: he(e)
1597
+ text: Z(e)
1557
1598
  };
1558
1599
  }
1559
- o && x((e) => e.map((e) => e.id === t ? {
1600
+ o && b((e) => e.map((e) => e.id === t ? {
1560
1601
  ...e,
1561
1602
  parts: e.parts?.map((e) => e.type === "card" && e.id === n ? {
1562
1603
  ...e,
1563
1604
  outcome: o
1564
1605
  } : e)
1565
1606
  } : e));
1566
- }, de = async (e, t, n) => {
1607
+ }, he = async (e, t, n) => {
1567
1608
  let r = y.current.find((t) => t.id === e)?.parts?.find((e) => e.type === "questions" && e.id === t);
1568
1609
  if (!r || r.type !== "questions") throw p(T.current.noActiveSession), Error(T.current.noActiveSession);
1569
- let i = () => x((r) => r.map((r) => r.id === e ? {
1610
+ let i = () => b((r) => r.map((r) => r.id === e ? {
1570
1611
  ...r,
1571
1612
  parts: r.parts?.map((e) => e.type === "questions" && e.id === t ? {
1572
1613
  ...e,
1573
1614
  answers: n
1574
1615
  } : e)
1575
- } : r)), a = `${e}:${t}`, o = C.current.get(a);
1576
- if (o) return C.current.delete(a), i(), o.resolve(n), null;
1616
+ } : r)), a = `${e}:${t}`, o = S.current.get(a);
1617
+ if (o) return S.current.delete(a), i(), o.resolve(n), null;
1577
1618
  if (D.current) throw p(T.current.requestInProgress), Error(T.current.requestInProgress);
1578
- if (!K || !E.current) throw p(T.current.noActiveSession), Error(T.current.noActiveSession);
1619
+ if (!q || !E.current) throw p(T.current.noActiveSession), Error(T.current.noActiveSession);
1579
1620
  D.current = !0, d(!0), p(null), i();
1580
1621
  try {
1581
- return await le("", !1, void 0, {
1622
+ return await pe("", !1, void 0, {
1582
1623
  id: t,
1583
1624
  answers: n,
1584
- historyText: B(r.questions, n)
1625
+ historyText: z(r.questions, n)
1585
1626
  });
1586
1627
  } finally {
1587
1628
  D.current = !1, d(!1);
1588
1629
  }
1589
- }, fe = async (t, n, r) => {
1590
- let i = I.current, a = Object.values(o).flat().find((e) => !i || i.includes(e.provider))?.id, s = r && R(i, r) ? r : R(i, V) ? void 0 : a, c = s ? b(s) : H, l = c && E.current ? W?.catalogReasoning?.(E.current.params, c.provider) : void 0, u = l ? { reasoning: l } : {}, d = E.current;
1630
+ }, _e = async (t, n, r) => {
1631
+ let i = I.current, a = Object.values(o).flat().find((e) => !i || i.includes(e.provider))?.id, s = r && B(i, r) ? r : B(i, H) ? void 0 : a, c = s ? x(s) : U, l = c && E.current ? G?.catalogReasoning?.(E.current.params, c.provider) : void 0, u = l ? { reasoning: l } : {}, d = E.current;
1591
1632
  if (!d) return p(T.current.noActiveSession), null;
1592
- let f = s ? b(s) : H, m = f ? A[f.provider] : null;
1633
+ let f = s ? x(s) : U, m = f ? N[f.provider] : null;
1593
1634
  if (!m || !f) return p(T.current.noProviderAvailable), null;
1594
1635
  n?.length && (d.attachmentsRef.current = [...d.attachmentsRef.current ?? [], ...n]);
1595
- let h = (n ?? []).filter((e) => g.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= zt ? `\n\n[File allegato: ${e.name}]\n${g.decodeBase64Text(e.base64)}` : `\n\n[File allegato: ${e.name} — troppo grande per essere incollato qui. Usa uno dei tool di lettura file disponibili (es. list_csv_columns/extract_csv_column) per leggerne il contenuto prima di chiedere altro all'utente.]`).join(""), _ = Bt(n ?? []), v = d.tools.map((e) => ({
1636
+ let h = (n ?? []).filter((e) => _.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= Bt ? `\n\n[File allegato: ${e.name}]\n${_.decodeBase64Text(e.base64)}` : `\n\n[File allegato: ${e.name} — troppo grande per essere incollato qui. Usa uno dei tool di lettura file disponibili (es. list_csv_columns/extract_csv_column) per leggerne il contenuto prima di chiedere altro all'utente.]`).join(""), g = Vt(n ?? []), v = d.tools.map((e) => ({
1596
1637
  name: e.name,
1597
1638
  description: e.description,
1598
- inputSchema: ne(e.inputSchema)
1639
+ inputSchema: re(e.inputSchema)
1599
1640
  })), y = (e, t, n, r) => {
1600
1641
  let i = T.current, a = `approval-${e}`, o = t.describeApproval?.(n) ?? t.describeInvocation?.(n) ?? t.name;
1601
- x((e) => [...e, {
1642
+ b((e) => [...e, {
1602
1643
  id: a,
1603
1644
  kind: "thinking",
1604
1645
  label: i.approvalHeader,
1605
1646
  status: "running",
1606
1647
  parts: [{
1607
1648
  type: "questions",
1608
- id: Ft,
1649
+ id: It,
1609
1650
  questions: [{
1610
1651
  header: i.approvalHeader,
1611
1652
  question: i.approveQuestion.replace("{action}", o),
@@ -1614,25 +1655,25 @@ function Ht(e, t = {}) {
1614
1655
  }]
1615
1656
  }]
1616
1657
  }]);
1617
- let s = `${a}:${Ft}`;
1658
+ let s = `${a}:${It}`;
1618
1659
  return new Promise((e, t) => {
1619
1660
  let n = () => {
1620
- C.current.delete(s), D(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
1661
+ S.current.delete(s), D(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
1621
1662
  };
1622
1663
  if (r.aborted) {
1623
1664
  n();
1624
1665
  return;
1625
1666
  }
1626
- r.addEventListener("abort", n, { once: !0 }), C.current.set(s, {
1667
+ r.addEventListener("abort", n, { once: !0 }), S.current.set(s, {
1627
1668
  resolve: (t) => {
1628
- r.removeEventListener("abort", n), D(a, "done"), e(Lt(t, i.approve, i.reject));
1669
+ r.removeEventListener("abort", n), D(a, "done"), e(Rt(t, i.approve, i.reject));
1629
1670
  },
1630
1671
  reject: t
1631
1672
  });
1632
1673
  });
1633
- }, S = new Map(d.tools.map((e) => [e.name, e])), w = new AbortController();
1634
- O.current = w;
1635
- let D = (e, t, n, r) => x((i) => i.map((i) => i.id === e ? {
1674
+ }, C = new Map(d.tools.map((e) => [e.name, e])), w = new AbortController();
1675
+ k.current = w;
1676
+ let D = (e, t, n, r) => b((i) => i.map((i) => i.id === e ? {
1636
1677
  ...i,
1637
1678
  status: t,
1638
1679
  ...n === void 0 ? {} : { detail: n },
@@ -1640,9 +1681,9 @@ function Ht(e, t = {}) {
1640
1681
  } : i));
1641
1682
  try {
1642
1683
  let n = d.history, r = t;
1643
- for (let t = 0; t < Rt; t++) {
1684
+ for (let t = 0; t < zt; t++) {
1644
1685
  let i = crypto.randomUUID();
1645
- x((e) => [...e, {
1686
+ b((e) => [...e, {
1646
1687
  id: i,
1647
1688
  kind: "thinking",
1648
1689
  label: T.current.thinking,
@@ -1657,20 +1698,20 @@ function Ht(e, t = {}) {
1657
1698
  history: n,
1658
1699
  tools: v.length ? v : void 0,
1659
1700
  signal: w.signal,
1660
- attachments: t === 0 ? _ : void 0,
1701
+ attachments: t === 0 ? g : void 0,
1661
1702
  logId: d.logId
1662
1703
  });
1663
1704
  } catch (t) {
1664
1705
  return d.history = [...n, ...r ? [{
1665
1706
  role: "user",
1666
1707
  content: r + h
1667
- }] : []], w.signal.aborted ? (D(i, "stopped"), e.fallback(d.params, d.context)) : (D(i, "error"), p(he(t)), null);
1708
+ }] : []], w.signal.aborted ? (D(i, "stopped"), e.fallback(d.params, d.context)) : (D(i, "error"), p(Z(t)), null);
1668
1709
  }
1669
1710
  if (d.history = [...n, ...r ? [{
1670
1711
  role: "user",
1671
1712
  content: r + h
1672
1713
  }] : []], !a) return w.signal.aborted ? (D(i, "stopped"), e.fallback(d.params, d.context)) : (D(i, "error"), p(T.current.noProviderResponse), null);
1673
- if (a.type === "text") return D(i, "done", a.text), e.conversational && a.text.trim() && x((e) => e.map((e) => e.id === i ? {
1714
+ if (a.type === "text") return D(i, "done", a.text), e.conversational && a.text.trim() && b((e) => e.map((e) => e.id === i ? {
1674
1715
  ...e,
1675
1716
  parts: [{
1676
1717
  type: "text",
@@ -1693,23 +1734,23 @@ function Ht(e, t = {}) {
1693
1734
  params: d.params
1694
1735
  }), p(T.current.invalidResponse), e.fallback(d.params, d.context));
1695
1736
  let o = a.toolCalls.map((e) => {
1696
- let t = S.get(e.name);
1737
+ let t = C.get(e.name);
1697
1738
  return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1698
1739
  });
1699
1740
  D(i, "done", a.text || void 0, a.text ? void 0 : o);
1700
1741
  let s = /* @__PURE__ */ new Map();
1701
1742
  for (let t of a.toolCalls) {
1702
- let n = S.get(t.name);
1703
- if (n && It(n, t.input)) try {
1743
+ let n = C.get(t.name);
1744
+ if (n && Lt(n, t.input)) try {
1704
1745
  s.set(t.id, await y(t.id, n, t.input, w.signal));
1705
1746
  } catch {
1706
1747
  return e.fallback(d.params, d.context);
1707
1748
  }
1708
1749
  }
1709
1750
  let c = await Promise.all(a.toolCalls.map(async (e) => {
1710
- let t = S.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = s.get(e.id);
1751
+ let t = C.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = s.get(e.id);
1711
1752
  if (r && !r.approved) {
1712
- x((t) => [...t, {
1753
+ b((t) => [...t, {
1713
1754
  id: e.id,
1714
1755
  kind: "tool",
1715
1756
  label: n,
@@ -1723,7 +1764,7 @@ function Ht(e, t = {}) {
1723
1764
  isError: !0
1724
1765
  };
1725
1766
  }
1726
- if (x((t) => [...t, {
1767
+ if (b((t) => [...t, {
1727
1768
  id: e.id,
1728
1769
  kind: "tool",
1729
1770
  label: n,
@@ -1738,7 +1779,7 @@ function Ht(e, t = {}) {
1738
1779
  let n = await t.execute(e.input);
1739
1780
  D(e.id, "done");
1740
1781
  let r = t.card?.(e.input, n);
1741
- return r && x((t) => [...t, {
1782
+ return r && b((t) => [...t, {
1742
1783
  id: `card-${e.id}`,
1743
1784
  kind: "thinking",
1744
1785
  label: "",
@@ -1756,7 +1797,7 @@ function Ht(e, t = {}) {
1756
1797
  return D(e.id, "error"), {
1757
1798
  toolCallId: e.id,
1758
1799
  name: e.name,
1759
- output: he(t),
1800
+ output: Z(t),
1760
1801
  isError: !0
1761
1802
  };
1762
1803
  }
@@ -1779,7 +1820,7 @@ function Ht(e, t = {}) {
1779
1820
  ], r = "";
1780
1821
  }
1781
1822
  let i = crypto.randomUUID();
1782
- x((e) => [...e, {
1823
+ b((e) => [...e, {
1783
1824
  id: i,
1784
1825
  kind: "thinking",
1785
1826
  label: T.current.thinking,
@@ -1789,7 +1830,7 @@ function Ht(e, t = {}) {
1789
1830
  try {
1790
1831
  a = await m.complete({
1791
1832
  ...u,
1792
- prompt: me(X().stopCallingTools, e.microPromptIds),
1833
+ prompt: ge(X().stopCallingTools, e.microPromptIds),
1793
1834
  model: f.model,
1794
1835
  history: n,
1795
1836
  signal: w.signal,
@@ -1808,11 +1849,11 @@ function Ht(e, t = {}) {
1808
1849
  } else D(i, w.signal.aborted ? "stopped" : "error"), d.history = n;
1809
1850
  return w.signal.aborted || p(T.current.tooManyToolTurns), e.fallback(d.params, d.context);
1810
1851
  } finally {
1811
- O.current = null;
1852
+ k.current = null;
1812
1853
  }
1813
- }, pe = async (t, n) => {
1854
+ }, ve = async (t, n) => {
1814
1855
  if (D.current) return p(T.current.requestInProgress), null;
1815
- D.current = !0, p(null), x(n?.openingMessage ? [{
1856
+ D.current = !0, p(null), b(n?.openingMessage ? [{
1816
1857
  id: crypto.randomUUID(),
1817
1858
  kind: "user",
1818
1859
  label: "Tu",
@@ -1829,17 +1870,17 @@ function Ht(e, t = {}) {
1829
1870
  history: [],
1830
1871
  logId: crypto.randomUUID(),
1831
1872
  attachmentsRef: a
1832
- }, K) return h(!0), ce(t), await le(n?.openingMessage ?? "", !0);
1833
- if (G) {
1834
- ce(t), J.current = !1;
1835
- let e = n?.model || Z.current;
1836
- if (re(e)) return h(!0), J.current = !0, await le(n?.openingMessage ?? "", !0, e);
1873
+ }, q) return h(!0), fe(t), await pe(n?.openingMessage ?? "", !0);
1874
+ if (K) {
1875
+ fe(t), Y.current = !1;
1876
+ let e = n?.model || ue.current;
1877
+ if (J(e)) return h(!0), Y.current = !0, await pe(n?.openingMessage ?? "", !0, e);
1837
1878
  }
1838
- let s = n?.model || void 0, c = s ? !!A[b(s)?.provider ?? ""] : !!U;
1879
+ let s = n?.model || void 0, c = s ? !!N[x(s)?.provider ?? ""] : !!W;
1839
1880
  if (!r || !c) {
1840
1881
  h(!1);
1841
1882
  let n = e.fallback(t, i);
1842
- return x((t) => [...t, {
1883
+ return b((t) => [...t, {
1843
1884
  id: crypto.randomUUID(),
1844
1885
  kind: "tool",
1845
1886
  status: "done",
@@ -1847,19 +1888,19 @@ function Ht(e, t = {}) {
1847
1888
  }]), n;
1848
1889
  }
1849
1890
  h(!0);
1850
- let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => g.fileToAttachment(e))) : void 0, u = me(e.buildPrompt(t, i), e.microPromptIds);
1851
- return await fe(u, l, s);
1891
+ let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => _.fileToAttachment(e))) : void 0, u = ge(e.buildPrompt(t, i), e.microPromptIds);
1892
+ return await _e(u, l, s);
1852
1893
  } catch (e) {
1853
- return p(he(e)), null;
1894
+ return p(Z(e)), null;
1854
1895
  } finally {
1855
1896
  D.current = !1, d(!1);
1856
1897
  }
1857
- }, ge = async (t, n) => {
1898
+ }, ye = async (t, n) => {
1858
1899
  if (D.current) {
1859
1900
  p(T.current.requestInProgress);
1860
1901
  return;
1861
1902
  }
1862
- D.current = !0, p(null), x(Vt(n.activity)), d(!0);
1903
+ D.current = !0, p(null), b(Ht(n.activity)), d(!0);
1863
1904
  try {
1864
1905
  let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
1865
1906
  E.current = {
@@ -1869,103 +1910,136 @@ function Ht(e, t = {}) {
1869
1910
  history: n.history,
1870
1911
  logId: crypto.randomUUID(),
1871
1912
  attachmentsRef: a
1872
- }, (K || G) && ce(t), J.current = !1, h(K || G || r && !!U);
1913
+ }, (q || K) && fe(t), Y.current = !1, h(q || K || r && !!W);
1873
1914
  } catch (e) {
1874
- p(he(e));
1915
+ p(Z(e));
1875
1916
  } finally {
1876
1917
  D.current = !1, d(!1);
1877
1918
  }
1878
- }, _e = async (t, n) => {
1919
+ }, be = async (t, n) => {
1879
1920
  if (D.current) return p(T.current.requestInProgress), null;
1880
1921
  if (p(null), !t.trim()) return p("Messaggio vuoto."), null;
1881
1922
  let r = E.current;
1882
1923
  if (!r) return p(T.current.noActiveSession), null;
1883
- D.current = !0, d(!0), x((e) => [...e, {
1884
- id: crypto.randomUUID(),
1924
+ D.current = !0, d(!0);
1925
+ let i = crypto.randomUUID();
1926
+ ee.current = i, b((e) => [...e, {
1927
+ id: i,
1885
1928
  kind: "user",
1886
1929
  label: "Tu",
1887
1930
  status: "done",
1888
1931
  detail: t,
1889
1932
  ...n?.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {},
1890
- ...n?.retry ? { retry: !0 } : {}
1933
+ ...n?.retry ? { retry: !0 } : {},
1934
+ historyAt: r.history.length
1891
1935
  }]);
1892
1936
  try {
1893
- if (K) return await le(t, !1, n?.model || void 0);
1894
- let i = n?.model || (G ? Z.current : "");
1895
- if (G && re(i)) {
1896
- let e = !J.current;
1897
- return J.current = !0, await le(t, e, i);
1937
+ if (q) return await pe(t, !1, n?.model || void 0);
1938
+ let i = n?.model || (K ? ue.current : "");
1939
+ if (K && J(i)) {
1940
+ let e = !Y.current;
1941
+ return Y.current = !0, await pe(t, e, i);
1898
1942
  }
1899
- let a = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => g.fileToAttachment(e))) : void 0, o = me(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
1900
- return await fe(o, a, n?.model || void 0);
1943
+ O.current &&= {
1944
+ ...O.current,
1945
+ fresh: !1
1946
+ };
1947
+ let a = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => _.fileToAttachment(e))) : void 0, o = ge(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
1948
+ return await _e(o, a, n?.model || void 0);
1901
1949
  } catch (e) {
1902
- return p(he(e)), null;
1950
+ return p(Z(e)), null;
1903
1951
  } finally {
1904
1952
  D.current = !1, d(!1);
1905
1953
  }
1906
- }, ve = () => {
1954
+ }, xe = (e) => {
1955
+ let t = E.current, n = g.findIndex((t) => t.id === e), r = g[n], i = r?.detail?.trim();
1956
+ if (!ie || !t || !r || r.kind !== "user" || !i) return;
1957
+ if (r.historyAt !== void 0) return r.historyAt;
1958
+ let a = g.slice(0, n).filter((e) => e.kind === "user" && e.detail?.trim() === i).length, o = 0;
1959
+ for (let e = 0; e < t.history.length; e += 1) {
1960
+ let n = t.history[e];
1961
+ if (n.role === "user" && n.content.includes(i)) {
1962
+ if (o === a) return e;
1963
+ o += 1;
1964
+ }
1965
+ }
1966
+ }, Se = (e) => xe(e) !== void 0, Ce = async (e, t) => {
1967
+ if (D.current) return p(T.current.requestInProgress), null;
1968
+ let n = E.current, r = g.findIndex((t) => t.id === e), i = g[r], a = xe(e);
1969
+ if (!n || !i || a === void 0) return null;
1970
+ let o = (t ?? i.detail ?? "").trim();
1971
+ if (!o) return null;
1972
+ let s = g.slice(0, r);
1973
+ return n.history = n.history.slice(0, a), O.current = {
1974
+ activity: s,
1975
+ fresh: !0
1976
+ }, b(s), be(o);
1977
+ }, we = () => {
1907
1978
  let t = E.current;
1908
1979
  if (!t) return null;
1909
1980
  p(null);
1910
1981
  let n = e.fallback(t.params, t.context);
1911
- return x((t) => [...t, {
1982
+ return b((t) => [...t, {
1912
1983
  id: crypto.randomUUID(),
1913
1984
  kind: "tool",
1914
1985
  status: "done",
1915
1986
  label: e.describeFallback?.(n) ?? T.current.continueWithoutAiFallback
1916
1987
  }]), n;
1917
- }, ye = () => E.current ? {
1988
+ }, Te = () => E.current ? {
1918
1989
  history: E.current.history,
1919
- activity: _
1990
+ activity: g
1920
1991
  } : null;
1921
1992
  return {
1922
1993
  enabled: r,
1923
1994
  setEnabled: i,
1924
1995
  hasProviders: a,
1925
- selectedModel: K || G && Y ? Y : V,
1926
- setSelectedModel: K ? se : G ? (e) => {
1927
- re(e) ? se(e) : (se(""), l(e));
1996
+ selectedModel: q || K && ce ? ce : H,
1997
+ setSelectedModel: q ? de : K ? (e) => {
1998
+ J(e) ? de(e) : (de(""), l(e));
1928
1999
  } : l,
1929
- modelsByProvider: te,
2000
+ modelsByProvider: V,
1930
2001
  modelsLoading: s,
1931
2002
  running: u,
1932
2003
  error: f,
1933
2004
  canContinue: m,
1934
- remote: K,
1935
- remoteModels: ie,
1936
- alongside: G,
1937
- ...W?.catalogGroup ? { catalogGroup: W.catalogGroup } : {},
1938
- activity: _,
1939
- run: pe,
1940
- resume: ge,
1941
- sendMessage: _e,
1942
- stop: k,
1943
- runFallback: ve,
1944
- snapshot: ye,
1945
- answerQuestions: de,
1946
- cardAction: ue,
2005
+ remote: q,
2006
+ remoteModels: oe,
2007
+ alongside: K,
2008
+ ...G?.catalogGroup ? { catalogGroup: G.catalogGroup } : {},
2009
+ activity: g,
2010
+ run: ve,
2011
+ resume: ye,
2012
+ sendMessage: be,
2013
+ stop: te,
2014
+ runFallback: we,
2015
+ snapshot: Te,
2016
+ answerQuestions: he,
2017
+ cardAction: me,
2018
+ rewind: Ce,
2019
+ canRewind: ie,
2020
+ rewindable: Se,
1947
2021
  offersFallback: e.offersFallback !== !1
1948
2022
  };
1949
2023
  }
1950
2024
  //#endregion
1951
2025
  //#region src/domain/orchestrator/prompt.ts
1952
- function Ut() {
2026
+ function Wt() {
1953
2027
  let e = X();
1954
2028
  return [e.responseRulesHeading, ...e.responseRules.map((e) => `- ${e}`)].join("\n");
1955
2029
  }
1956
- function Wt(e, t, n) {
2030
+ function Gt(e, t, n) {
1957
2031
  let r = X(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
1958
2032
  return `${r.orchestratorIntro}
1959
2033
 
1960
2034
  ${r.toolsHeading}
1961
2035
  ${t}
1962
2036
  ${i}
1963
- ${Ut()}
2037
+ ${Wt()}
1964
2038
 
1965
2039
  ${r.userRequestHeading}
1966
2040
  ${e}`;
1967
2041
  }
1968
- function Gt(e, t) {
2042
+ function Kt(e, t) {
1969
2043
  return t ? {
1970
2044
  kind: "handoff",
1971
2045
  ...t
@@ -1976,27 +2050,27 @@ function Gt(e, t) {
1976
2050
  }
1977
2051
  //#endregion
1978
2052
  //#region src/domain/orchestrator/agenticoOrchestratorAgent.ts
1979
- function Kt(e) {
2053
+ function qt(e) {
1980
2054
  return U().filter((t) => !t.onlyWhenAnchored || e === t.id);
1981
2055
  }
1982
- function qt(e) {
2056
+ function Jt(e) {
1983
2057
  return {
1984
2058
  buildContext(e) {
1985
2059
  return {
1986
- cliCatalog: de(Kt(e.scopedSubagentId)),
2060
+ cliCatalog: pe(qt(e.scopedSubagentId)),
1987
2061
  handoff: { current: null },
1988
2062
  collected: {}
1989
2063
  };
1990
2064
  },
1991
2065
  buildPrompt({ userGoal: e, pageContext: t }, { cliCatalog: n }) {
1992
- return Wt(e, n, t);
2066
+ return Gt(e, n, t);
1993
2067
  },
1994
2068
  buildFollowUpPrompt(e, t, { cliCatalog: n }) {
1995
- return `${e}\n\n${Ut()}\n\n${X().toolsHeading}\n${n}`;
2069
+ return `${e}\n\n${Wt()}\n\n${X().toolsHeading}\n${n}`;
1996
2070
  },
1997
2071
  parseResponse(e, t, n) {
1998
2072
  let r = n.handoff.current;
1999
- return n.handoff.current = null, Gt(e, r);
2073
+ return n.handoff.current = null, Kt(e, r);
2000
2074
  },
2001
2075
  fallback() {
2002
2076
  return {
@@ -2011,13 +2085,13 @@ function qt(e) {
2011
2085
  let i = q({
2012
2086
  attachmentsRef: r,
2013
2087
  collected: n.collected,
2014
- proxyFetch: x
2015
- }), a = t.scopedSubagentId ? W(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = Kt(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
2088
+ proxyFetch: S
2089
+ }), a = t.scopedSubagentId ? W(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = qt(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
2016
2090
  name: `${t.id}_${r.name}`,
2017
2091
  description: `${t.label}: ${r.summary}`,
2018
2092
  inputSchema: r.inputSchema,
2019
- describeInvocation: () => y(e.preparing, { label: t.label }),
2020
- describeIntent: y(e.collecting, { label: t.label }),
2093
+ describeInvocation: () => b(e.preparing, { label: t.label }),
2094
+ describeIntent: b(e.collecting, { label: t.label }),
2021
2095
  async execute(e) {
2022
2096
  let i = t.withCollected ? t.withCollected({ ...e }, n.collected) : e;
2023
2097
  return n.handoff.current = {
@@ -2026,7 +2100,7 @@ function qt(e) {
2026
2100
  params: i
2027
2101
  }, {
2028
2102
  status: "queued",
2029
- note: y(X().handoffQueued, { label: t.label })
2103
+ note: b(X().handoffQueued, { label: t.label })
2030
2104
  };
2031
2105
  }
2032
2106
  })));
@@ -2036,22 +2110,22 @@ function qt(e) {
2036
2110
  }
2037
2111
  //#endregion
2038
2112
  //#region src/presentation/deriveHistoryTitle.ts
2039
- function Jt(e, t) {
2113
+ function Yt(e, t) {
2040
2114
  return e.deriveHistoryTitle?.(t) ?? e.label;
2041
2115
  }
2042
2116
  //#endregion
2043
2117
  //#region src/presentation/ResultDestinationPicker.tsx
2044
- function Yt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
2045
- let s = $(), c = tt(), l = c.scope, u = T(), [d, f] = N(null), [p, m] = N(new Set(i ?? [])), [h, g] = N(null), _ = Se(), v = /* @__PURE__ */ new Map();
2118
+ function Xt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
2119
+ let s = $(), c = nt(), l = c.scope, u = E(), [d, f] = M(null), [p, m] = M(new Set(i ?? [])), [h, g] = M(null), _ = Ce(), v = /* @__PURE__ */ new Map();
2046
2120
  e.destinationIds.forEach((e) => {
2047
2121
  let t = _[e];
2048
2122
  t && v.set(e, t);
2049
- }), (o ?? []).forEach((e) => v.set(e.id, e)), v.set(ye.id, ye);
2050
- let b = Array.from(v.values()), x = async (i) => {
2123
+ }), (o ?? []).forEach((e) => v.set(e.id, e)), v.set(be.id, be);
2124
+ let y = Array.from(v.values()), x = async (i) => {
2051
2125
  f(i), g(null);
2052
2126
  try {
2053
2127
  let o = v.get(i);
2054
- if (!o) throw Error(y(s.unknownDestination, { id: i }));
2128
+ if (!o) throw Error(b(s.unknownDestination, { id: i }));
2055
2129
  if (i !== "json-export" && !l) throw Error(s.destinationNoScope);
2056
2130
  let d = await o.apply(t, {
2057
2131
  scopeId: l?.id ?? "",
@@ -2059,23 +2133,23 @@ function Yt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
2059
2133
  storageProvider: l?.storageProvider ?? null,
2060
2134
  proxyFetch: u
2061
2135
  }, n);
2062
- m((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, Jt(e, n));
2136
+ m((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, Yt(e, n));
2063
2137
  } catch (e) {
2064
2138
  g(e instanceof Error ? e.message : String(e));
2065
2139
  } finally {
2066
2140
  f(null);
2067
2141
  }
2068
2142
  };
2069
- return /* @__PURE__ */ I("div", {
2143
+ return /* @__PURE__ */ F("div", {
2070
2144
  className: "space-y-2",
2071
2145
  children: [
2072
- /* @__PURE__ */ F("p", {
2146
+ /* @__PURE__ */ P("p", {
2073
2147
  className: "text-xs font-medium text-muted-foreground",
2074
2148
  children: s.destinationPickerTitle
2075
2149
  }),
2076
- /* @__PURE__ */ F("div", {
2150
+ /* @__PURE__ */ P("div", {
2077
2151
  className: "flex flex-wrap gap-2",
2078
- children: b.map((e) => /* @__PURE__ */ F("button", {
2152
+ children: y.map((e) => /* @__PURE__ */ P("button", {
2079
2153
  type: "button",
2080
2154
  disabled: d !== null,
2081
2155
  onClick: () => void x(e.id),
@@ -2083,7 +2157,7 @@ function Yt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
2083
2157
  children: d === e.id ? s.destinationApplying : `${p.has(e.id) ? "✓ " : ""}${e.id === "json-export" ? s.exportJson : e.label}`
2084
2158
  }, e.id))
2085
2159
  }),
2086
- h && /* @__PURE__ */ F("p", {
2160
+ h && /* @__PURE__ */ P("p", {
2087
2161
  className: "text-xs text-destructive",
2088
2162
  children: h
2089
2163
  })
@@ -2092,33 +2166,33 @@ function Yt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
2092
2166
  }
2093
2167
  //#endregion
2094
2168
  //#region src/presentation/reports/subagentReportRegistry.tsx
2095
- var Xt = {};
2096
- function Zt(e) {
2097
- Object.assign(Xt, e);
2098
- }
2169
+ var Zt = {};
2099
2170
  function Qt(e) {
2100
- return Xt[e];
2171
+ Object.assign(Zt, e);
2172
+ }
2173
+ function $t(e) {
2174
+ return Zt[e];
2101
2175
  }
2102
2176
  //#endregion
2103
2177
  //#region src/presentation/reports/GenericResultPreview.tsx
2104
- function $t({ result: e }) {
2105
- let [t, n] = N(!1);
2106
- return /* @__PURE__ */ I("div", {
2178
+ function en({ result: e }) {
2179
+ let [t, n] = M(!1);
2180
+ return /* @__PURE__ */ F("div", {
2107
2181
  className: `relative cursor-pointer rounded-md border border-border/60 ${t ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
2108
2182
  onClick: () => n((e) => !e),
2109
2183
  title: t ? "Clic per comprimere" : "Clic per espandere",
2110
- children: [/* @__PURE__ */ F(c, {
2184
+ children: [/* @__PURE__ */ P(c, {
2111
2185
  language: "json",
2112
2186
  showCopy: t,
2113
2187
  background: "transparent",
2114
2188
  className: "!text-[11px]",
2115
2189
  children: JSON.stringify(e, null, 2)
2116
- }), !t && /* @__PURE__ */ F("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
2190
+ }), !t && /* @__PURE__ */ P("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
2117
2191
  });
2118
2192
  }
2119
2193
  //#endregion
2120
2194
  //#region src/presentation/liveAnchorDestination.ts
2121
- function en(e, t, n) {
2195
+ function tn(e, t, n) {
2122
2196
  return e.length === 0 ? null : {
2123
2197
  id: "live-component",
2124
2198
  label: "Applica al componente aperto",
@@ -2129,38 +2203,38 @@ function en(e, t, n) {
2129
2203
  }
2130
2204
  //#endregion
2131
2205
  //#region src/presentation/subagentControls.ts
2132
- var tn = {};
2133
- function nn(e) {
2134
- Object.assign(tn, e);
2135
- }
2206
+ var nn = {};
2136
2207
  function rn(e) {
2137
- return tn[e];
2208
+ Object.assign(nn, e);
2209
+ }
2210
+ function an(e) {
2211
+ return nn[e];
2138
2212
  }
2139
2213
  //#endregion
2140
2214
  //#region src/presentation/chatTitles.ts
2141
- function an(e, t = 6e3) {
2142
- let n = e.filter((e) => (e.kind === "user" || e.kind === "thinking") && e.detail?.trim() && !Ge(e)).map((e) => `${e.kind === "user" ? "Person" : "Agent"}: ${e.detail.trim()}`).join("\n\n");
2215
+ function on(e, t = 6e3) {
2216
+ let n = e.filter((e) => (e.kind === "user" || e.kind === "thinking") && e.detail?.trim() && !Ke(e)).map((e) => `${e.kind === "user" ? "Person" : "Agent"}: ${e.detail.trim()}`).join("\n\n");
2143
2217
  return n.length > t ? `${n.slice(0, t * .7)}\n\n[…]\n\n${n.slice(-t * .3)}` : n;
2144
2218
  }
2145
- function on(e) {
2219
+ function sn(e) {
2146
2220
  return (e.trim().split("\n").map((e) => e.trim()).find(Boolean) ?? "").replace(/^(title|titolo)\s*:\s*/i, "").replace(/^#+\s*/, "").replace(/^["'«“]+|["'»”]+$/g, "").replace(/[.。]+$/, "").trim().slice(0, 80);
2147
2221
  }
2148
- function sn(e, t) {
2222
+ function cn(e, t) {
2149
2223
  try {
2150
2224
  return e.definition.executor?.catalogProviders?.(e.toParams(t));
2151
2225
  } catch {
2152
2226
  return;
2153
2227
  }
2154
2228
  }
2155
- function cn(e, t, n, r, i) {
2156
- let a = sn(e, t), o = (e) => {
2157
- let t = e ? b(e) : null;
2229
+ function ln(e, t, n, r, i) {
2230
+ let a = cn(e, t), o = (e) => {
2231
+ let t = e ? x(e) : null;
2158
2232
  return !(!t || !i[t.provider] || a && !a.includes(t.provider));
2159
2233
  };
2160
2234
  return o(n) ? n : Object.values(r).flat().map((e) => e.id).find(o);
2161
2235
  }
2162
- function ln(e) {
2163
- let t = S()?.registry ?? {}, { modelsByProvider: n, selectedModel: r } = Pt(), i = M({
2236
+ function un(e) {
2237
+ let t = C()?.registry ?? {}, { modelsByProvider: n, selectedModel: r } = Ft(), i = j({
2164
2238
  registry: t,
2165
2239
  modelsByProvider: n,
2166
2240
  selectedModel: r
@@ -2170,20 +2244,20 @@ function ln(e) {
2170
2244
  modelsByProvider: n,
2171
2245
  selectedModel: r
2172
2246
  };
2173
- let a = M(/* @__PURE__ */ new Set()), o = D(async (t, n, r) => {
2247
+ let a = j(/* @__PURE__ */ new Set()), o = O(async (t, n, r) => {
2174
2248
  if (!e) return !1;
2175
- let o = Re(e, t, n), s = W(t), c = `${e}:${t}:${n}`;
2176
- if (!o || !s?.autoTitle || o.name || !We(o) || a.current.has(c)) return !1;
2177
- let { registry: l, modelsByProvider: u, selectedModel: d } = i.current, f = cn(s, o.params, r ?? d, u, l), p = f ? b(f) : null;
2249
+ let o = ze(e, t, n), s = W(t), c = `${e}:${t}:${n}`;
2250
+ if (!o || !s?.autoTitle || o.name || !Ge(o) || a.current.has(c)) return !1;
2251
+ let { registry: l, modelsByProvider: u, selectedModel: d } = i.current, f = ln(s, o.params, r ?? d, u, l), p = f ? x(f) : null;
2178
2252
  if (!p) return !1;
2179
2253
  a.current.add(c);
2180
2254
  try {
2181
2255
  let r = await l[p.provider].complete({
2182
- prompt: X().chatTitle.replace("{chat}", an(o.activity)),
2256
+ prompt: X().chatTitle.replace("{chat}", on(o.activity)),
2183
2257
  model: p.model,
2184
2258
  history: []
2185
- }), i = r && r.type === "text" ? on(r.text) : "";
2186
- return i ? Ke(e, t, n, i, "model") : !1;
2259
+ }), i = r && r.type === "text" ? sn(r.text) : "";
2260
+ return i ? qe(e, t, n, i, "model") : !1;
2187
2261
  } catch {
2188
2262
  return !1;
2189
2263
  } finally {
@@ -2191,12 +2265,12 @@ function ln(e) {
2191
2265
  }
2192
2266
  }, [e]), s = Object.keys(n).length > 0;
2193
2267
  return k(() => {
2194
- e && s && !un.has(e) && (un.add(e), (async () => {
2195
- for (let t of Ye(e)) {
2268
+ e && s && !dn.has(e) && (dn.add(e), (async () => {
2269
+ for (let t of Xe(e)) {
2196
2270
  let n = W(t.subagentId);
2197
2271
  if (n?.autoTitle) {
2198
- if (n.definition.conversational && !We(t)) {
2199
- Je(e, t.subagentId, t.entityId);
2272
+ if (n.definition.conversational && !Ge(t)) {
2273
+ Ye(e, t.subagentId, t.entityId);
2200
2274
  continue;
2201
2275
  }
2202
2276
  t.name || await o(t.subagentId, t.entityId);
@@ -2209,23 +2283,23 @@ function ln(e) {
2209
2283
  o
2210
2284
  ]), o;
2211
2285
  }
2212
- var un = /* @__PURE__ */ new Set(), dn = () => ({});
2213
- function fn({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
2214
- let c = Ht(e.definition, { defaultEnabled: !0 }), l = tt(), u = l.scope, d = T(), f = M(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = N(null), h = (t) => {
2286
+ var dn = /* @__PURE__ */ new Set(), fn = () => ({});
2287
+ function pn({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
2288
+ let c = Ut(e.definition, { defaultEnabled: !0 }), l = nt(), u = l.scope, d = E(), f = j(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = M(null), h = (t) => {
2215
2289
  e.definition.conversational || m(t);
2216
- }, [g, _] = N([]), [v, y] = N(null), b = Qt(e.id), x = b?.kind === "selection" ? b : null, [S, C] = N(null), w = M(!1), E = M(0), D = M(null);
2217
- p && p !== D.current && (D.current = p, E.current = (r?.length ?? 0) + c.activity.length);
2218
- let O = M(!1), A = c.remote || !c.hasProviders || c.selectedModel !== "";
2290
+ }, [g, _] = M([]), [v, y] = M(null), b = $t(e.id), x = b?.kind === "selection" ? b : null, [S, C] = M(null), w = j(!1), T = j(0), D = j(null);
2291
+ p && p !== D.current && (D.current = p, T.current = (r?.length ?? 0) + c.activity.length);
2292
+ let O = j(!1), ee = c.remote || !c.hasProviders || c.selectedModel !== "";
2219
2293
  k(() => {
2220
- !w.current && A && (w.current = !0, a ? (W.current = !0, c.resume(e.toParams(t), a)) : (o && c.setSelectedModel(o), c.run(e.toParams(t), {
2294
+ !w.current && ee && (w.current = !0, a ? (U.current = !0, c.resume(e.toParams(t), a)) : (o && c.setSelectedModel(o), c.run(e.toParams(t), {
2221
2295
  model: o,
2222
2296
  openingMessage: s
2223
2297
  }).then((e) => {
2224
2298
  e && h(e);
2225
2299
  })));
2226
- }, [A]), k(() => {
2300
+ }, [ee]), k(() => {
2227
2301
  if (!p || !u) return;
2228
- let n = e.autoApplyDestinationIds ?? [], r = l.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = Se();
2302
+ let n = e.autoApplyDestinationIds ?? [], r = l.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = Ce();
2229
2303
  n.forEach((n) => {
2230
2304
  let a = i[n];
2231
2305
  a && (y(null), a.apply(p, {
@@ -2237,7 +2311,7 @@ function fn({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
2237
2311
  ...t,
2238
2312
  pinnedEntityId: r
2239
2313
  }).then((n) => {
2240
- n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, Jt(e, t));
2314
+ n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, Yt(e, t));
2241
2315
  }).catch((e) => y(e instanceof Error ? e.message : String(e))));
2242
2316
  });
2243
2317
  }, [
@@ -2247,85 +2321,85 @@ function fn({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
2247
2321
  ]), k(() => {
2248
2322
  p && x && C(x.defaultSelection(p));
2249
2323
  }, [p, x]);
2250
- let L = (e, t) => {
2324
+ let te = (e, t) => {
2251
2325
  C((n) => n && {
2252
2326
  ...n,
2253
2327
  [e]: t
2254
2328
  });
2255
- }, R = (e) => h(e), z = j(() => p && x && S ? x.applySelection(p, S) : p, [
2329
+ }, ne = (e) => h(e), I = A(() => p && x && S ? x.applySelection(p, S) : p, [
2256
2330
  p,
2257
2331
  x,
2258
2332
  S
2259
- ]), ee = j(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), B = j(() => en(ee, t, f), [
2260
- ee,
2333
+ ]), L = A(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), R = A(() => tn(L, t, f), [
2334
+ L,
2261
2335
  t,
2262
2336
  f
2263
- ]), te = j(() => B ? [B, ...n ?? []] : n, [B, n]), V = e.chatEntityId?.(t), H = ln(u?.id), U = M(!1), W = M(!1);
2337
+ ]), z = A(() => R ? [R, ...n ?? []] : n, [R, n]), B = e.chatEntityId?.(t), V = un(u?.id), H = j(!1), U = j(!1);
2264
2338
  k(() => {
2265
- let n = !U.current && c.running, i = U.current && !c.running;
2266
- if (U.current = c.running, !n && !i || !V || !u) return;
2267
- if (W.current) {
2268
- i && (W.current = !1);
2339
+ let n = !H.current && c.running, i = H.current && !c.running;
2340
+ if (H.current = c.running, !n && !i || !B || !u) return;
2341
+ if (U.current) {
2342
+ i && (U.current = !1);
2269
2343
  return;
2270
2344
  }
2271
2345
  let a = c.snapshot();
2272
2346
  if (!a) return;
2273
2347
  let o = [...r ?? [], ...a.activity];
2274
- e.autoTitle && e.definition.conversational && !We({ activity: o }) || (ze({
2348
+ e.autoTitle && e.definition.conversational && !Ge({ activity: o }) || (Be({
2275
2349
  scopeId: u.id,
2276
2350
  subagentId: e.id,
2277
- entityId: V,
2351
+ entityId: B,
2278
2352
  params: t,
2279
- title: Jt(e, t),
2353
+ title: Yt(e, t),
2280
2354
  history: a.history,
2281
2355
  activity: o
2282
- }), i && e.autoTitle && H(e.id, V, c.selectedModel));
2356
+ }), i && e.autoTitle && V(e.id, B, c.selectedModel));
2283
2357
  }, [c.running]);
2284
- let G = () => {
2358
+ let W = () => {
2285
2359
  O.current = !0, c.running && c.stop(), l.closeTask(f);
2286
- }, K = M(rn(e.id) ?? dn).current, q = K({
2360
+ }, G = j(an(e.id) ?? fn).current, K = G({
2287
2361
  params: t,
2288
2362
  taskId: f,
2289
2363
  running: c.running,
2290
- close: G
2291
- }), ne = (e) => {
2364
+ close: W
2365
+ }), q = (e) => {
2292
2366
  _((t) => t.includes(e) ? t : [...t, e]);
2293
2367
  };
2294
2368
  return k(() => {
2295
2369
  O.current || l.openTask({
2296
2370
  id: f,
2297
- title: Jt(e, t),
2371
+ title: Yt(e, t),
2298
2372
  icon: e.icon,
2299
2373
  agent: c,
2300
2374
  onApplied: (e) => h(e),
2301
2375
  precedingActivity: r,
2302
- panelExtraAnchorIndex: E.current,
2303
- onDismiss: G,
2304
- ...V ? { savedToDisk: !0 } : {},
2305
- panelActions: q.content,
2306
- composerActions: q.actions,
2307
- composerCommands: q.commands,
2308
- panelExtra: p ? /* @__PURE__ */ I(P, { children: [
2309
- x && S ? /* @__PURE__ */ F(x.Report, {
2376
+ panelExtraAnchorIndex: T.current,
2377
+ onDismiss: W,
2378
+ ...B ? { savedToDisk: !0 } : {},
2379
+ panelActions: K.content,
2380
+ composerActions: K.actions,
2381
+ composerCommands: K.commands,
2382
+ panelExtra: p ? /* @__PURE__ */ F(N, { children: [
2383
+ x && S ? /* @__PURE__ */ P(x.Report, {
2310
2384
  result: p,
2311
2385
  selection: S,
2312
- onChange: L
2313
- }) : b?.kind === "editable" ? /* @__PURE__ */ F(b.Report, {
2386
+ onChange: te
2387
+ }) : b?.kind === "editable" ? /* @__PURE__ */ P(b.Report, {
2314
2388
  result: p,
2315
- onResultChange: R
2316
- }) : /* @__PURE__ */ F($t, { result: z }),
2317
- v && /* @__PURE__ */ I("p", {
2389
+ onResultChange: ne
2390
+ }) : /* @__PURE__ */ P(en, { result: I }),
2391
+ v && /* @__PURE__ */ F("p", {
2318
2392
  className: "text-xs text-destructive",
2319
2393
  children: ["Salvataggio automatico non riuscito: ", v]
2320
2394
  }),
2321
- /* @__PURE__ */ F(Yt, {
2395
+ /* @__PURE__ */ P(Xt, {
2322
2396
  manifest: e,
2323
- result: z,
2397
+ result: I,
2324
2398
  meta: t,
2325
2399
  taskId: f,
2326
2400
  initiallyApplied: g,
2327
- onApplied: ne,
2328
- extraDestinations: te
2401
+ onApplied: q,
2402
+ extraDestinations: z
2329
2403
  })
2330
2404
  ] }) : void 0
2331
2405
  });
@@ -2344,29 +2418,29 @@ function fn({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
2344
2418
  e,
2345
2419
  t,
2346
2420
  p,
2347
- z,
2421
+ I,
2348
2422
  S,
2349
2423
  g,
2350
2424
  n,
2351
2425
  r,
2352
2426
  v,
2353
- q.content,
2354
- q.actions,
2355
- q.commands
2427
+ K.content,
2428
+ K.actions,
2429
+ K.commands
2356
2430
  ]), k(() => () => {
2357
2431
  l.closeTask(f);
2358
2432
  }, [l.closeTask, f]), null;
2359
2433
  }
2360
2434
  //#endregion
2361
2435
  //#region src/presentation/OrchestratorRunner.tsx
2362
- function pn({ userGoal: e }) {
2363
- let t = $(), n = Ht(j(() => qt({
2436
+ function mn({ userGoal: e }) {
2437
+ let t = $(), n = Ut(A(() => Jt({
2364
2438
  unavailable: t.orchestratorUnavailable,
2365
2439
  continueWithoutAi: t.orchestratorContinueWithoutAi,
2366
2440
  preparing: t.orchestratorPreparing,
2367
2441
  collecting: t.orchestratorCollecting
2368
- }), []), { defaultEnabled: !0 }), r = tt(), [i, a] = N(null), o = M(!1), s = !n.hasProviders || n.selectedModel !== "", c = M(r.pendingExtraDestinations), l = M(r.pendingAttachments), u = M(r.pendingModel), d = M(r.pendingScopedSubagentId ?? r.scopedSubagentId ?? void 0), f = M(r.pendingCarryOver), p = M(!1), m = (e) => {
2369
- e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask(Qe));
2442
+ }), []), { defaultEnabled: !0 }), r = nt(), [i, a] = M(null), o = j(!1), s = !n.hasProviders || n.selectedModel !== "", c = j(r.pendingExtraDestinations), l = j(r.pendingAttachments), u = j(r.pendingModel), d = j(r.pendingScopedSubagentId ?? r.scopedSubagentId ?? void 0), f = j(r.pendingCarryOver), p = j(!1), m = (e) => {
2443
+ e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask($e));
2370
2444
  };
2371
2445
  k(() => {
2372
2446
  !o.current && s && (o.current = !0, u.current && n.setSelectedModel(u.current), n.run({
@@ -2382,7 +2456,7 @@ function pn({ userGoal: e }) {
2382
2456
  }));
2383
2457
  }, [s]), k(() => {
2384
2458
  p.current || r.openTask({
2385
- id: Qe,
2459
+ id: $e,
2386
2460
  title: "Agentico",
2387
2461
  icon: "bot",
2388
2462
  agent: n,
@@ -2390,7 +2464,7 @@ function pn({ userGoal: e }) {
2390
2464
  scopedSubagentId: d.current,
2391
2465
  precedingActivity: f.current?.activity,
2392
2466
  onDismiss: () => {
2393
- p.current = !0, n.running && n.stop(), r.closeTask(Qe);
2467
+ p.current = !0, n.running && n.stop(), r.closeTask($e);
2394
2468
  }
2395
2469
  });
2396
2470
  }, [
@@ -2403,12 +2477,12 @@ function pn({ userGoal: e }) {
2403
2477
  n.hasProviders,
2404
2478
  r.openTask
2405
2479
  ]), k(() => () => {
2406
- r.closeTask(Qe);
2480
+ r.closeTask($e);
2407
2481
  }, [r.closeTask]);
2408
- let h = j(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
2482
+ let h = A(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
2409
2483
  if (!i) return null;
2410
2484
  let g = W(i.subagentId);
2411
- return g ? /* @__PURE__ */ F(fn, {
2485
+ return g ? /* @__PURE__ */ P(pn, {
2412
2486
  manifest: g,
2413
2487
  params: i.params,
2414
2488
  extraDestinations: c.current,
@@ -2419,8 +2493,8 @@ function pn({ userGoal: e }) {
2419
2493
  }
2420
2494
  //#endregion
2421
2495
  //#region src/presentation/ManualEntryRunner.tsx
2422
- function mn({ manifest: e, extraDestinations: n }) {
2423
- let r = Ht(e.definition, { defaultEnabled: !1 }), i = $(), a = tt(), o = M(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = N(null), [l, u] = N([]), d = Qt(e.id), f = d?.kind === "selection" ? d : null, [p, m] = N(null), [h, g] = N(null), _ = M(!1), v = (t) => {
2496
+ function hn({ manifest: e, extraDestinations: n }) {
2497
+ let r = Ut(e.definition, { defaultEnabled: !1 }), i = $(), a = nt(), o = j(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = M(null), [l, u] = M([]), d = $t(e.id), f = d?.kind === "selection" ? d : null, [p, m] = M(null), [h, g] = M(null), _ = j(!1), v = (t) => {
2424
2498
  if (!e.manualEntry) return;
2425
2499
  let n;
2426
2500
  try {
@@ -2441,17 +2515,17 @@ function mn({ manifest: e, extraDestinations: n }) {
2441
2515
  ...n,
2442
2516
  [e]: t
2443
2517
  });
2444
- }, b = (e) => c(e), x = j(() => s && f && p ? f.applySelection(s, p) : s, [
2518
+ }, b = (e) => c(e), x = A(() => s && f && p ? f.applySelection(s, p) : s, [
2445
2519
  s,
2446
2520
  f,
2447
2521
  p
2448
2522
  ]), S = (e) => {
2449
2523
  u((t) => t.includes(e) ? t : [...t, e]);
2450
- }, C = j(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), w = j(() => h ? en(C, h, o) : null, [
2524
+ }, C = A(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), w = A(() => h ? tn(C, h, o) : null, [
2451
2525
  C,
2452
2526
  h,
2453
2527
  o
2454
- ]), T = j(() => w ? [w, ...n ?? []] : n, [w, n]);
2528
+ ]), T = A(() => w ? [w, ...n ?? []] : n, [w, n]);
2455
2529
  return k(() => {
2456
2530
  _.current || a.openTask({
2457
2531
  id: o,
@@ -2466,18 +2540,18 @@ function mn({ manifest: e, extraDestinations: n }) {
2466
2540
  onDismiss: () => {
2467
2541
  _.current = !0, r.running && r.stop(), a.closeTask(o);
2468
2542
  },
2469
- panelExtra: s ? /* @__PURE__ */ I("div", {
2543
+ panelExtra: s ? /* @__PURE__ */ F("div", {
2470
2544
  className: "space-y-2",
2471
2545
  children: [
2472
- f && p ? /* @__PURE__ */ F(f.Report, {
2546
+ f && p ? /* @__PURE__ */ P(f.Report, {
2473
2547
  result: s,
2474
2548
  selection: p,
2475
2549
  onChange: y
2476
- }) : d?.kind === "editable" ? /* @__PURE__ */ F(d.Report, {
2550
+ }) : d?.kind === "editable" ? /* @__PURE__ */ P(d.Report, {
2477
2551
  result: s,
2478
2552
  onResultChange: b
2479
- }) : /* @__PURE__ */ F($t, { result: x }),
2480
- /* @__PURE__ */ F(Yt, {
2553
+ }) : /* @__PURE__ */ P(en, { result: x }),
2554
+ /* @__PURE__ */ P(Xt, {
2481
2555
  manifest: e,
2482
2556
  result: x,
2483
2557
  meta: h ?? {},
@@ -2486,7 +2560,7 @@ function mn({ manifest: e, extraDestinations: n }) {
2486
2560
  onApplied: S,
2487
2561
  extraDestinations: T
2488
2562
  }),
2489
- r.hasProviders && /* @__PURE__ */ F(t, {
2563
+ r.hasProviders && /* @__PURE__ */ P(t, {
2490
2564
  label: i.resumeWithAi,
2491
2565
  variant: "outline-secondary",
2492
2566
  className: "text-xs",
@@ -2514,7 +2588,7 @@ function mn({ manifest: e, extraDestinations: n }) {
2514
2588
  }
2515
2589
  //#endregion
2516
2590
  //#region src/presentation/Agentico.tsx
2517
- function hn(e, t) {
2591
+ function gn(e, t) {
2518
2592
  return Object.values(e).flat().map((e) => {
2519
2593
  let n = t?.(e.provider, e.providerLabel ?? e.provider);
2520
2594
  return {
@@ -2526,53 +2600,82 @@ function hn(e, t) {
2526
2600
  };
2527
2601
  });
2528
2602
  }
2529
- function gn({ task: e }) {
2530
- let t = $(), [n, r] = N(""), { agent: i, onApplied: a, manualEntry: o } = e, c = i.running, l = (e) => {
2531
- if (r(""), o) {
2532
- o.onSubmit(e.text);
2603
+ function _n({ task: e, editing: n, onCancelEdit: r, onSendEdit: i }) {
2604
+ let a = $(), [o, c] = M(""), { agent: l, onApplied: u, manualEntry: d } = e, p = l.running;
2605
+ k(() => {
2606
+ n && c(n.detail ?? "");
2607
+ }, [n]);
2608
+ let m = (e) => {
2609
+ if (c(""), n && i) {
2610
+ i(n, e.text);
2611
+ return;
2612
+ }
2613
+ if (d) {
2614
+ d.onSubmit(e.text);
2533
2615
  return;
2534
2616
  }
2535
- i.sendMessage(e.text, {
2617
+ l.sendMessage(e.text, {
2536
2618
  attachments: e.files,
2537
2619
  model: e.model
2538
2620
  }).then((e) => {
2539
- e && a(e);
2621
+ e && u(e);
2540
2622
  });
2541
- }, u = !!o || i.remote && i.remoteModels.length === 0, d = i.alongside && i.remoteModels.some((e) => e.value === i.selectedModel), f = !u && !i.remote && !d && i.hasProviders && !i.selectedModel, p = u ? [] : i.remote ? i.remoteModels : i.alongside ? [...i.remoteModels, ...hn(i.modelsByProvider, i.catalogGroup)] : hn(i.modelsByProvider);
2542
- return /* @__PURE__ */ F(s, {
2543
- value: n,
2544
- onChange: r,
2545
- placeholder: o?.prompt ?? t.messagePlaceholder,
2546
- running: c,
2547
- onStop: i.stop,
2548
- disabled: !n.trim() || f,
2549
- onSubmit: l,
2550
- attachments: !o && !i.remote && !d,
2551
- models: p,
2552
- selectedModel: u ? "" : i.selectedModel,
2623
+ }, h = !!d || l.remote && l.remoteModels.length === 0, g = l.alongside && l.remoteModels.some((e) => e.value === l.selectedModel), _ = !h && !l.remote && !g && l.hasProviders && !l.selectedModel, v = h ? [] : l.remote ? l.remoteModels : l.alongside ? [...l.remoteModels, ...gn(l.modelsByProvider, l.catalogGroup)] : gn(l.modelsByProvider);
2624
+ return /* @__PURE__ */ F(N, { children: [n && /* @__PURE__ */ F("div", {
2625
+ className: "mb-2 flex items-center gap-2 text-xs text-muted-foreground",
2626
+ children: [
2627
+ /* @__PURE__ */ P(f, {
2628
+ name: "pencil",
2629
+ size: 12,
2630
+ className: "shrink-0"
2631
+ }),
2632
+ /* @__PURE__ */ P("span", {
2633
+ className: "flex-1",
2634
+ children: a.editingMessage
2635
+ }),
2636
+ /* @__PURE__ */ P(t, {
2637
+ label: a.cancelEdit,
2638
+ variant: "link",
2639
+ className: "p-0 text-xs",
2640
+ onClick: () => {
2641
+ c(""), r?.();
2642
+ }
2643
+ })
2644
+ ]
2645
+ }), /* @__PURE__ */ P(s, {
2646
+ value: o,
2647
+ onChange: c,
2648
+ placeholder: d?.prompt ?? a.messagePlaceholder,
2649
+ running: p,
2650
+ onStop: l.stop,
2651
+ disabled: !o.trim() || _,
2652
+ onSubmit: m,
2653
+ attachments: !d && !l.remote && !g,
2654
+ models: v,
2655
+ selectedModel: h ? "" : l.selectedModel,
2553
2656
  actions: e.composerActions,
2554
2657
  commands: e.composerCommands,
2555
- onModelChange: i.setSelectedModel,
2556
- modelPlaceholder: t.selectModelPlaceholder,
2658
+ onModelChange: l.setSelectedModel,
2659
+ modelPlaceholder: a.selectModelPlaceholder,
2557
2660
  minHeight: 44,
2558
2661
  maxHeight: 220
2559
- });
2662
+ })] });
2560
2663
  }
2561
- function _n() {
2562
- let { startOrchestrator: e } = tt(), t = $(), [n, r] = N(""), { hasProviders: i, modelsByProvider: a, selectedModel: o, setSelectedModel: c } = Pt(), l = (t) => {
2664
+ function vn() {
2665
+ let { startOrchestrator: e } = nt(), t = $(), [n, r] = M(""), { hasProviders: i, modelsByProvider: a, selectedModel: o, setSelectedModel: c } = Ft(), l = (t) => {
2563
2666
  t.text.trim() && (e(t.text.trim(), {
2564
2667
  attachments: t.files.length > 0 ? t.files : void 0,
2565
2668
  model: t.model || void 0
2566
2669
  }), r(""));
2567
2670
  }, u = i && !o;
2568
- return /* @__PURE__ */ F(s, {
2671
+ return /* @__PURE__ */ P(s, {
2569
2672
  value: n,
2570
2673
  onChange: r,
2571
2674
  placeholder: t.orchestratorStarterPlaceholder,
2572
2675
  disabled: !n.trim() || u,
2573
2676
  onSubmit: l,
2574
2677
  attachments: !0,
2575
- models: hn(a),
2678
+ models: gn(a),
2576
2679
  selectedModel: o,
2577
2680
  onModelChange: c,
2578
2681
  modelPlaceholder: t.selectModelPlaceholder,
@@ -2580,30 +2683,30 @@ function _n() {
2580
2683
  maxHeight: 220
2581
2684
  });
2582
2685
  }
2583
- function vn({ chat: e, onClose: t }) {
2584
- let n = $(), r = C();
2585
- return /* @__PURE__ */ F(h, {
2686
+ function yn({ chat: e, onClose: t }) {
2687
+ let n = $(), r = w();
2688
+ return /* @__PURE__ */ P(h, {
2586
2689
  title: n.renameChat,
2587
2690
  size: "sm",
2588
2691
  onClose: t,
2589
- onSave: () => (Ke(e.scopeId, e.subagentId, e.entityId, String(r.record?.title ?? Ue(e)), "person"), t(), Promise.resolve(!0)),
2590
- children: /* @__PURE__ */ I(d, {
2692
+ onSave: () => (qe(e.scopeId, e.subagentId, e.entityId, String(r.record?.title ?? We(e)), "person"), t(), Promise.resolve(!0)),
2693
+ children: /* @__PURE__ */ F(d, {
2591
2694
  appearance: "empty",
2592
2695
  controller: r,
2593
- defaultValues: { title: Ue(e) },
2696
+ defaultValues: { title: We(e) },
2594
2697
  footer: !1,
2595
- children: [/* @__PURE__ */ F(p, {
2698
+ children: [/* @__PURE__ */ P(p, {
2596
2699
  name: "title",
2597
2700
  label: n.chatTitleLabel,
2598
2701
  placeholder: e.title
2599
- }), /* @__PURE__ */ F("p", {
2702
+ }), /* @__PURE__ */ P("p", {
2600
2703
  className: "text-xs text-muted-foreground",
2601
2704
  children: n.chatTitleHint
2602
2705
  })]
2603
2706
  })
2604
2707
  });
2605
2708
  }
2606
- function yn(e, t, n = Date.now()) {
2709
+ function bn(e, t, n = Date.now()) {
2607
2710
  let r = Math.round((e - n) / 1e3), i = new Intl.RelativeTimeFormat(t, {
2608
2711
  numeric: "auto",
2609
2712
  style: "short"
@@ -2615,55 +2718,55 @@ function yn(e, t, n = Date.now()) {
2615
2718
  ]) if (Math.abs(r) >= t) return i.format(Math.round(r / t), e);
2616
2719
  return i.format(0, "minute");
2617
2720
  }
2618
- function bn({ card: e }) {
2721
+ function xn({ card: e }) {
2619
2722
  let t = $();
2620
- return e.humanSummaryOnly ? /* @__PURE__ */ I("div", {
2723
+ return e.humanSummaryOnly ? /* @__PURE__ */ F("div", {
2621
2724
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2622
- children: [/* @__PURE__ */ I("p", {
2725
+ children: [/* @__PURE__ */ F("p", {
2623
2726
  className: "text-xs font-medium text-foreground",
2624
2727
  children: [
2625
2728
  "\"",
2626
2729
  e.label,
2627
2730
  "\""
2628
2731
  ]
2629
- }), /* @__PURE__ */ F("p", {
2732
+ }), /* @__PURE__ */ P("p", {
2630
2733
  className: "text-xs text-muted-foreground",
2631
2734
  children: e.humanSummary
2632
2735
  })]
2633
- }) : /* @__PURE__ */ I("div", {
2736
+ }) : /* @__PURE__ */ F("div", {
2634
2737
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2635
2738
  children: [
2636
- /* @__PURE__ */ F("p", {
2739
+ /* @__PURE__ */ P("p", {
2637
2740
  className: "text-xs font-medium text-foreground",
2638
- children: y(t.newInstance, { label: e.label })
2741
+ children: b(t.newInstance, { label: e.label })
2639
2742
  }),
2640
- /* @__PURE__ */ F("p", {
2743
+ /* @__PURE__ */ P("p", {
2641
2744
  className: "text-xs text-muted-foreground",
2642
2745
  children: e.humanSummary
2643
2746
  }),
2644
- e.fields.length > 0 && /* @__PURE__ */ F("ul", {
2747
+ e.fields.length > 0 && /* @__PURE__ */ P("ul", {
2645
2748
  className: "space-y-1",
2646
- children: e.fields.map((e) => /* @__PURE__ */ I("li", {
2749
+ children: e.fields.map((e) => /* @__PURE__ */ F("li", {
2647
2750
  className: "flex items-start gap-1.5 text-xs",
2648
- children: [/* @__PURE__ */ F(n, {
2751
+ children: [/* @__PURE__ */ P(n, {
2649
2752
  variant: e.required ? "primary" : "secondary",
2650
2753
  className: "mt-px shrink-0",
2651
2754
  children: e.required ? "richiesto" : "opzionale"
2652
- }), /* @__PURE__ */ I("span", {
2755
+ }), /* @__PURE__ */ F("span", {
2653
2756
  className: "min-w-0",
2654
- children: [/* @__PURE__ */ F("span", {
2757
+ children: [/* @__PURE__ */ P("span", {
2655
2758
  className: "font-mono text-foreground",
2656
2759
  children: e.key
2657
- }), e.humanDescription ? /* @__PURE__ */ I("span", {
2760
+ }), e.humanDescription ? /* @__PURE__ */ F("span", {
2658
2761
  className: "text-muted-foreground",
2659
2762
  children: [" — ", e.humanDescription]
2660
2763
  }) : null]
2661
2764
  })]
2662
2765
  }, e.key))
2663
2766
  }),
2664
- e.example && /* @__PURE__ */ I("p", {
2767
+ e.example && /* @__PURE__ */ F("p", {
2665
2768
  className: "text-xs text-muted-foreground",
2666
- children: ["Esempio: ", /* @__PURE__ */ F("span", {
2769
+ children: ["Esempio: ", /* @__PURE__ */ P("span", {
2667
2770
  className: "font-mono",
2668
2771
  children: e.example
2669
2772
  })]
@@ -2671,23 +2774,23 @@ function bn({ card: e }) {
2671
2774
  ]
2672
2775
  });
2673
2776
  }
2674
- function xn({ messages: e }) {
2675
- return /* @__PURE__ */ F("div", {
2777
+ function Sn({ messages: e }) {
2778
+ return /* @__PURE__ */ P("div", {
2676
2779
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2677
- children: e.map((e, t) => /* @__PURE__ */ F("p", {
2780
+ children: e.map((e, t) => /* @__PURE__ */ P("p", {
2678
2781
  className: "text-xs text-muted-foreground",
2679
2782
  children: e
2680
2783
  }, t))
2681
2784
  });
2682
2785
  }
2683
- function Sn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2684
- let c = $(), { locale: d } = w(), [p, m] = N(""), [h, g] = N(0);
2685
- k(() => Ie(() => g((e) => e + 1)), []);
2686
- let _ = j(() => r ? Ye(e) : [], [
2786
+ function Cn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2787
+ let c = $(), { locale: d } = T(), [p, m] = M(""), [h, g] = M(0);
2788
+ k(() => Le(() => g((e) => e + 1)), []);
2789
+ let _ = A(() => r ? Xe(e) : [], [
2687
2790
  e,
2688
2791
  r,
2689
2792
  h
2690
- ]), [v, y] = N(null), b = async (t) => {
2793
+ ]), [v, y] = M(null), b = async (t) => {
2691
2794
  let r = W(t.subagentId), i = await r?.confirmArchive?.(t.entityId, t.params);
2692
2795
  if (!i || window.confirm(i)) {
2693
2796
  try {
@@ -2695,16 +2798,16 @@ function Sn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
2695
2798
  } catch {
2696
2799
  return;
2697
2800
  }
2698
- Je(e, t.subagentId, t.entityId), n === Xe(t.subagentId, t.entityId) && s(), g((e) => e + 1);
2801
+ Ye(e, t.subagentId, t.entityId), n === Ze(t.subagentId, t.entityId) && s(), g((e) => e + 1);
2699
2802
  }
2700
- }, x = j(() => {
2803
+ }, x = A(() => {
2701
2804
  let e = p.trim().toLowerCase();
2702
2805
  return e ? _.filter((t) => {
2703
2806
  let n = W(t.subagentId)?.label ?? t.subagentId;
2704
- return Ue(t).toLowerCase().includes(e) || n.toLowerCase().includes(e);
2807
+ return We(t).toLowerCase().includes(e) || n.toLowerCase().includes(e);
2705
2808
  }) : _;
2706
2809
  }, [_, p]);
2707
- return /* @__PURE__ */ I(P, { children: [/* @__PURE__ */ F(l, {
2810
+ return /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P(l, {
2708
2811
  trigger: {
2709
2812
  icon: "history",
2710
2813
  title: c.chatHistory
@@ -2715,22 +2818,22 @@ function Sn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
2715
2818
  position: "end",
2716
2819
  strategy: "absolute",
2717
2820
  menuClassName: "w-[380px] max-h-[70vh] overflow-y-auto",
2718
- header: /* @__PURE__ */ I("div", {
2821
+ header: /* @__PURE__ */ F("div", {
2719
2822
  className: "flex items-center gap-2 px-1 pb-1.5",
2720
2823
  children: [
2721
- /* @__PURE__ */ F(f, {
2824
+ /* @__PURE__ */ P(f, {
2722
2825
  name: "search",
2723
2826
  size: 14,
2724
2827
  className: "shrink-0 text-muted-foreground"
2725
2828
  }),
2726
- /* @__PURE__ */ F("input", {
2829
+ /* @__PURE__ */ P("input", {
2727
2830
  autoFocus: !0,
2728
2831
  value: p,
2729
2832
  onChange: (e) => m(e.target.value),
2730
2833
  placeholder: c.searchChats,
2731
2834
  className: "min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
2732
2835
  }),
2733
- /* @__PURE__ */ F(t, {
2836
+ /* @__PURE__ */ P(t, {
2734
2837
  icon: "square-pen",
2735
2838
  ariaLabel: c.newChat,
2736
2839
  title: c.newChat,
@@ -2740,12 +2843,12 @@ function Sn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
2740
2843
  })
2741
2844
  ]
2742
2845
  }),
2743
- children: x.length === 0 ? /* @__PURE__ */ F("p", {
2846
+ children: x.length === 0 ? /* @__PURE__ */ P("p", {
2744
2847
  className: "px-2 py-3 text-center text-xs text-muted-foreground",
2745
2848
  children: _.length === 0 ? c.noSavedChats : c.noResults
2746
2849
  }) : x.map((e) => {
2747
- let t = W(e.subagentId), r = n === Xe(e.subagentId, e.entityId);
2748
- return /* @__PURE__ */ F(u, {
2850
+ let t = W(e.subagentId), r = n === Ze(e.subagentId, e.entityId);
2851
+ return /* @__PURE__ */ P(u, {
2749
2852
  icon: r ? "check" : t?.icon ?? "bot",
2750
2853
  className: r ? "bg-accent font-semibold text-primary" : void 0,
2751
2854
  actions: [{
@@ -2760,180 +2863,203 @@ function Sn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
2760
2863
  onClick: () => void b(e)
2761
2864
  }],
2762
2865
  onClick: () => a(e.subagentId, e.entityId, e),
2763
- children: /* @__PURE__ */ I("span", {
2866
+ children: /* @__PURE__ */ F("span", {
2764
2867
  className: "flex min-w-0 flex-1 items-center justify-between gap-2",
2765
- children: [/* @__PURE__ */ F("span", {
2868
+ children: [/* @__PURE__ */ P("span", {
2766
2869
  className: "min-w-0 truncate",
2767
- title: `${t?.label ?? e.subagentId} · ${Ue(e)}`,
2768
- children: Ue(e)
2769
- }), /* @__PURE__ */ F("span", {
2870
+ title: `${t?.label ?? e.subagentId} · ${We(e)}`,
2871
+ children: We(e)
2872
+ }), /* @__PURE__ */ P("span", {
2770
2873
  className: "shrink-0 text-xs text-muted-foreground",
2771
- title: `${c.chatStarted.replace("{at}", new Date(qe(e)).toLocaleString(d))} · ${c.chatLastMessage.replace("{at}", new Date(e.savedAt).toLocaleString(d))}`,
2772
- children: yn(qe(e), d)
2874
+ title: `${c.chatStarted.replace("{at}", new Date(Je(e)).toLocaleString(d))} · ${c.chatLastMessage.replace("{at}", new Date(e.savedAt).toLocaleString(d))}`,
2875
+ children: bn(Je(e), d)
2773
2876
  })]
2774
2877
  })
2775
2878
  }, `${e.subagentId}:${e.entityId}`);
2776
2879
  })
2777
- }), v && /* @__PURE__ */ F(vn, {
2880
+ }), v && /* @__PURE__ */ P(yn, {
2778
2881
  chat: v,
2779
2882
  onClose: () => y(null)
2780
2883
  })] });
2781
2884
  }
2782
- function Cn({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
2783
- let { task: a, isOpen: o, pendingGoal: s, orchestratorRunId: c, pageContext: l, pageContextCard: u, anchoredUserMessages: d, pendingResume: f, resumeRunId: p, dismissForeignTask: m, resumeEntityChat: h, pendingManualEntry: g, manualEntryRunId: _, startManualEntry: v, pendingExtraDestinations: y, pendingResumeWithAI: b, resumeWithAIRunId: x, pendingStart: S, startRunId: C, scope: w } = tt(), T = $(), E = M(null), [D, O] = N(!1);
2784
- ln(w?.id);
2785
- let A = Ot({
2885
+ function wn({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
2886
+ let { task: a, isOpen: o, pendingGoal: s, orchestratorRunId: c, pageContext: l, pageContextCard: u, anchoredUserMessages: d, pendingResume: f, resumeRunId: p, dismissForeignTask: m, resumeEntityChat: h, pendingManualEntry: _, manualEntryRunId: v, startManualEntry: y, pendingExtraDestinations: b, pendingResumeWithAI: x, resumeWithAIRunId: S, pendingStart: C, startRunId: w, scope: T } = nt(), E = $(), D = j(null), [O, ee] = M(!1), [te, A] = M(null), [ne, I] = M(null);
2887
+ k(() => {
2888
+ A(null), I(null);
2889
+ }, [a?.id]), un(T?.id);
2890
+ let L = kt({
2786
2891
  defaultWidth: e,
2787
2892
  minWidth: n,
2788
2893
  maxWidth: r,
2789
2894
  onWidthChange: i
2790
- }), j = () => {
2791
- (!a || a.agent.running || a.savedToDisk || window.confirm(T.unsavedConversationConfirm)) && (m(), O(!1));
2792
- }, L = a ? [...a.precedingActivity ?? [], ...a.agent.activity] : [], R = L.length, z = Math.max(0, Math.min(a?.panelExtraAnchorIndex ?? R, R)), ee = L.slice(0, z), B = L.slice(z), te = !!(a && !a.agent.running && a.agent.error), V = new Set(a?.agent.activity.map((e) => e.id) ?? []), H = a ? {
2793
- canAnswer: (e) => V.has(e),
2895
+ }), R = () => {
2896
+ (!a || a.agent.running || a.savedToDisk || window.confirm(E.unsavedConversationConfirm)) && (m(), ee(!1));
2897
+ }, z = a ? [...a.precedingActivity ?? [], ...a.agent.activity] : [], B = z.length, V = Math.max(0, Math.min(a?.panelExtraAnchorIndex ?? B, B)), H = z.slice(0, V), U = z.slice(V), G = !!(a && !a.agent.running && a.agent.error), K = (e, t) => {
2898
+ a && (A(null), a.agent.rewind(e.id, t).then((e) => {
2899
+ e && a.onApplied(e);
2900
+ }));
2901
+ }, q = (e) => {
2902
+ let t = a?.agent.activity ?? [], n = t.slice(t.findIndex((t) => t.id === e.id) + 1).flatMap((e) => [...e.kind === "tool" && e.status === "done" ? [e.label] : [], ...(e.parts ?? []).flatMap((e) => e.type === "tool" && e.status === "done" ? [e.label] : [])]);
2903
+ return [...new Set(n.filter(Boolean))];
2904
+ }, re = (e, t) => {
2905
+ let n = q(e);
2906
+ n.length ? I({
2907
+ entry: e,
2908
+ steps: n,
2909
+ ...t === void 0 ? {} : { text: t }
2910
+ }) : K(e, t);
2911
+ }, ie = a ? {
2912
+ available: (e) => a.agent.activity.some((t) => t.id === e.id) && a.agent.rewindable(e.id),
2913
+ disabled: a.agent.running,
2914
+ onRetry: (e) => re(e),
2915
+ onEdit: (e) => A(e)
2916
+ } : void 0, ae = new Set(a?.agent.activity.map((e) => e.id) ?? []), J = a ? {
2917
+ canAnswer: (e) => ae.has(e),
2794
2918
  onAnswer: (e, t, n) => a.agent.answerQuestions(e, t, n).then((e) => {
2795
2919
  e && a.onApplied(e);
2796
2920
  }),
2797
2921
  onCardAction: (e, t, n) => a.agent.cardAction(e, t, n)
2798
- } : void 0, U = H ? mt(L, H.canAnswer) : null, G = a?.id === "agentico-orchestrator" && a.scopedSubagentId ? W(a.scopedSubagentId) : void 0, K = G?.manualEntry ? G : null, q = M(!0);
2922
+ } : void 0, Y = J ? ht(z, J.canAnswer) : null, oe = a?.id === "agentico-orchestrator" && a.scopedSubagentId ? W(a.scopedSubagentId) : void 0, se = oe?.manualEntry ? oe : null, X = j(!0);
2799
2923
  k(() => {
2800
- let e = E.current;
2924
+ let e = D.current;
2801
2925
  if (!e) return;
2802
2926
  let t = () => {
2803
- q.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
2927
+ X.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
2804
2928
  };
2805
2929
  return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
2806
2930
  }, [a?.id]), k(() => {
2807
- let e = E.current;
2808
- e && (q.current = !0, e.scrollTop = e.scrollHeight);
2931
+ let e = D.current;
2932
+ e && (X.current = !0, e.scrollTop = e.scrollHeight);
2809
2933
  }, [a?.id]);
2810
- let ne = L.at(-1)?.detail?.length ?? 0;
2934
+ let ce = z.at(-1)?.detail?.length ?? 0;
2811
2935
  k(() => {
2812
- let e = E.current;
2813
- e && q.current && (e.scrollTop = e.scrollHeight);
2936
+ let e = D.current;
2937
+ e && X.current && (e.scrollTop = e.scrollHeight);
2814
2938
  }, [
2815
- R,
2816
- te,
2817
- ne
2939
+ B,
2940
+ G,
2941
+ ce
2818
2942
  ]);
2819
- let re = M(null);
2943
+ let le = j(null);
2820
2944
  k(() => {
2821
- let e = E.current, t = re.current;
2945
+ let e = D.current, t = le.current;
2822
2946
  if (!e || !t || typeof ResizeObserver > "u") return;
2823
2947
  let n = new ResizeObserver(() => {
2824
- q.current && (e.scrollTop = e.scrollHeight);
2948
+ X.current && (e.scrollTop = e.scrollHeight);
2825
2949
  });
2826
2950
  return n.observe(t), () => n.disconnect();
2827
2951
  }, [a?.id, o]);
2828
- let J = s ? /* @__PURE__ */ F(pn, { userGoal: s }, c) : null, ie = f ? W(f.subagentId) : void 0, ae = f && ie ? /* @__PURE__ */ F(fn, {
2829
- manifest: ie,
2952
+ let ue = s ? /* @__PURE__ */ P(mn, { userGoal: s }, c) : null, de = f ? W(f.subagentId) : void 0, fe = f && de ? /* @__PURE__ */ P(pn, {
2953
+ manifest: de,
2830
2954
  params: f.snapshot.params,
2831
- taskId: Xe(f.subagentId, f.entityId),
2955
+ taskId: Ze(f.subagentId, f.entityId),
2832
2956
  resumeSeed: {
2833
2957
  history: f.snapshot.history,
2834
2958
  activity: f.snapshot.activity
2835
2959
  }
2836
- }, p) : null, Y = g ? W(g.subagentId) : void 0, oe = g && Y ? /* @__PURE__ */ F(mn, {
2837
- manifest: Y,
2838
- extraDestinations: g.extraDestinations
2839
- }, _) : null, X = b ? W(b.subagentId) : void 0, Z = b && X ? /* @__PURE__ */ F(fn, {
2840
- manifest: X,
2841
- params: b.params,
2842
- extraDestinations: b.extraDestinations
2843
- }, x) : null, se = S ? W(S.subagentId) : void 0, ce = S && se ? /* @__PURE__ */ F(fn, {
2844
- manifest: se,
2845
- params: S.params,
2846
- taskId: S.taskId,
2847
- openingMessage: S.openingMessage
2848
- }, C) : null;
2849
- return o ? /* @__PURE__ */ I(P, { children: [
2850
- J,
2851
- ae,
2852
- oe,
2853
- Z,
2854
- ce,
2855
- /* @__PURE__ */ I("div", {
2856
- style: { width: A.width },
2960
+ }, p) : null, pe = _ ? W(_.subagentId) : void 0, me = _ && pe ? /* @__PURE__ */ P(hn, {
2961
+ manifest: pe,
2962
+ extraDestinations: _.extraDestinations
2963
+ }, v) : null, he = x ? W(x.subagentId) : void 0, ge = x && he ? /* @__PURE__ */ P(pn, {
2964
+ manifest: he,
2965
+ params: x.params,
2966
+ extraDestinations: x.extraDestinations
2967
+ }, S) : null, Z = C ? W(C.subagentId) : void 0, _e = C && Z ? /* @__PURE__ */ P(pn, {
2968
+ manifest: Z,
2969
+ params: C.params,
2970
+ taskId: C.taskId,
2971
+ openingMessage: C.openingMessage
2972
+ }, w) : null;
2973
+ return o ? /* @__PURE__ */ F(N, { children: [
2974
+ ue,
2975
+ fe,
2976
+ me,
2977
+ ge,
2978
+ _e,
2979
+ /* @__PURE__ */ F("div", {
2980
+ style: { width: L.width },
2857
2981
  className: "relative flex h-full shrink-0 flex-col border-l border-border bg-background",
2858
2982
  children: [
2859
- /* @__PURE__ */ F(kt, {
2860
- width: A.width,
2861
- min: A.min,
2862
- max: A.max,
2863
- onResize: A.set,
2864
- onCommit: A.commit,
2865
- onReset: A.reset
2983
+ /* @__PURE__ */ P(At, {
2984
+ width: L.width,
2985
+ min: L.min,
2986
+ max: L.max,
2987
+ onResize: L.set,
2988
+ onCommit: L.commit,
2989
+ onReset: L.reset
2866
2990
  }),
2867
- /* @__PURE__ */ I("div", {
2991
+ /* @__PURE__ */ F("div", {
2868
2992
  className: "flex min-h-[60px] items-center gap-1 border-b border-border/60 px-4 py-3",
2869
2993
  children: [
2870
- /* @__PURE__ */ F("span", {
2994
+ /* @__PURE__ */ P("span", {
2871
2995
  className: "min-w-0 flex-1 truncate text-lg font-semibold leading-tight",
2872
2996
  children: a ? a.title : "Agentico"
2873
2997
  }),
2874
- w && /* @__PURE__ */ F(Sn, {
2875
- scopeId: w.id,
2998
+ T && /* @__PURE__ */ P(Cn, {
2999
+ scopeId: T.id,
2876
3000
  currentTaskId: a?.id ?? null,
2877
- open: D,
2878
- onOpenChange: O,
2879
- onNewChat: j,
3001
+ open: O,
3002
+ onOpenChange: ee,
3003
+ onNewChat: R,
2880
3004
  onSelect: (e, t, n) => h(e, t, n),
2881
3005
  onArchivedCurrent: m
2882
3006
  }),
2883
- /* @__PURE__ */ F(At, {})
3007
+ /* @__PURE__ */ P(jt, {})
2884
3008
  ]
2885
3009
  }),
2886
- /* @__PURE__ */ F("div", {
2887
- ref: E,
2888
- className: `flex-1 overflow-y-auto px-3 pb-2 ${U ? "min-h-24" : "min-h-0"}`,
2889
- children: /* @__PURE__ */ F("div", {
2890
- ref: re,
3010
+ /* @__PURE__ */ P("div", {
3011
+ ref: D,
3012
+ className: `flex-1 overflow-y-auto px-3 pb-2 ${Y ? "min-h-24" : "min-h-0"}`,
3013
+ children: /* @__PURE__ */ P("div", {
3014
+ ref: le,
2891
3015
  className: "pt-2",
2892
- children: a ? /* @__PURE__ */ I(P, { children: [
2893
- a.manualEntry && L.length === 0 && /* @__PURE__ */ F("p", {
3016
+ children: a ? /* @__PURE__ */ F(N, { children: [
3017
+ a.manualEntry && z.length === 0 && /* @__PURE__ */ P("p", {
2894
3018
  className: "text-xs text-muted-foreground",
2895
3019
  children: a.manualEntry.prompt
2896
3020
  }),
2897
- /* @__PURE__ */ F(vt, {
2898
- activity: ee,
2899
- questions: H,
2900
- docked: U,
2901
- pinUserMessages: !U
3021
+ /* @__PURE__ */ P(yt, {
3022
+ activity: H,
3023
+ questions: J,
3024
+ docked: Y,
3025
+ pinUserMessages: !Y,
3026
+ messageActions: ie
2902
3027
  }),
2903
- a.panelExtra && /* @__PURE__ */ F("div", {
3028
+ a.panelExtra && /* @__PURE__ */ P("div", {
2904
3029
  className: "mt-3",
2905
3030
  children: a.panelExtra
2906
3031
  }),
2907
- B.length > 0 && /* @__PURE__ */ F(vt, {
2908
- activity: B,
2909
- questions: H,
2910
- docked: U,
2911
- pinUserMessages: !U
3032
+ U.length > 0 && /* @__PURE__ */ P(yt, {
3033
+ activity: U,
3034
+ questions: J,
3035
+ docked: Y,
3036
+ pinUserMessages: !Y,
3037
+ messageActions: ie
2912
3038
  }),
2913
- !a.agent.running && a.agent.error && /* @__PURE__ */ I("div", {
3039
+ !a.agent.running && a.agent.error && /* @__PURE__ */ F("div", {
2914
3040
  className: "mt-2 flex items-center gap-2",
2915
3041
  children: [
2916
- /* @__PURE__ */ F("p", {
3042
+ /* @__PURE__ */ P("p", {
2917
3043
  className: "flex-1 text-xs text-destructive",
2918
3044
  children: a.agent.error
2919
3045
  }),
2920
- /* @__PURE__ */ F(t, {
2921
- label: T.retry,
3046
+ /* @__PURE__ */ P(t, {
3047
+ label: E.retry,
2922
3048
  variant: "secondary",
2923
3049
  className: "shrink-0",
2924
3050
  onClick: () => {
2925
- a.agent.sendMessage(T.retryMessage, { retry: !0 }).then((e) => {
3051
+ a.agent.sendMessage(E.retryMessage, { retry: !0 }).then((e) => {
2926
3052
  e && a.onApplied(e);
2927
3053
  });
2928
3054
  }
2929
3055
  }),
2930
- !a.agent.remote && a.agent.offersFallback !== !1 && /* @__PURE__ */ F(t, {
2931
- label: T.continueWithoutAi,
3056
+ !a.agent.remote && a.agent.offersFallback !== !1 && /* @__PURE__ */ P(t, {
3057
+ label: E.continueWithoutAi,
2932
3058
  variant: "secondary",
2933
3059
  className: "shrink-0",
2934
3060
  onClick: () => {
2935
- if (K) {
2936
- v(K.id, y);
3061
+ if (se) {
3062
+ y(se.id, b);
2937
3063
  return;
2938
3064
  }
2939
3065
  let e = a.agent.runFallback();
@@ -2942,66 +3068,83 @@ function Cn({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2942
3068
  })
2943
3069
  ]
2944
3070
  })
2945
- ] }) : d.length > 0 ? /* @__PURE__ */ F(xn, { messages: d }) : u ? /* @__PURE__ */ F(bn, { card: u }) : /* @__PURE__ */ F("p", {
3071
+ ] }) : d.length > 0 ? /* @__PURE__ */ P(Sn, { messages: d }) : u ? /* @__PURE__ */ P(xn, { card: u }) : /* @__PURE__ */ P("p", {
2946
3072
  className: "text-xs text-muted-foreground",
2947
- children: l ?? T.orchestratorStarterHint
3073
+ children: l ?? E.orchestratorStarterHint
2948
3074
  })
2949
3075
  })
2950
3076
  }),
2951
- a && U ? /* @__PURE__ */ I("section", {
2952
- "aria-label": T.pendingQuestions,
3077
+ a && Y ? /* @__PURE__ */ F("section", {
3078
+ "aria-label": E.pendingQuestions,
2953
3079
  className: "flex min-h-0 shrink flex-col border-t border-border/60",
2954
3080
  children: [
2955
- a.panelActions && /* @__PURE__ */ F("div", {
3081
+ a.panelActions && /* @__PURE__ */ P("div", {
2956
3082
  className: "shrink-0 px-4 pt-3",
2957
3083
  children: a.panelActions
2958
3084
  }),
2959
- /* @__PURE__ */ F("div", {
3085
+ /* @__PURE__ */ P("div", {
2960
3086
  className: "min-h-0 overflow-y-auto px-4 py-3",
2961
- children: /* @__PURE__ */ F(ht, {
2962
- entry: U.entry,
2963
- part: U.part,
2964
- questions: H,
3087
+ children: /* @__PURE__ */ P(gt, {
3088
+ entry: Y.entry,
3089
+ part: Y.part,
3090
+ questions: J,
2965
3091
  autoFocus: !0
2966
- }, `${U.entry.id}:${U.part.id}`)
3092
+ }, `${Y.entry.id}:${Y.part.id}`)
2967
3093
  }),
2968
- a.agent.running && /* @__PURE__ */ F("div", {
3094
+ a.agent.running && /* @__PURE__ */ P("div", {
2969
3095
  className: "flex shrink-0 justify-end px-4 pb-3",
2970
- children: /* @__PURE__ */ F(t, {
3096
+ children: /* @__PURE__ */ P(t, {
2971
3097
  icon: "square",
2972
- label: T.stop,
3098
+ label: E.stop,
2973
3099
  variant: "secondary",
2974
3100
  onClick: a.agent.stop
2975
3101
  })
2976
3102
  })
2977
3103
  ]
2978
- }) : /* @__PURE__ */ I("div", {
3104
+ }) : /* @__PURE__ */ F("div", {
2979
3105
  className: "border-t border-border/60 px-4 py-3",
2980
- children: [a?.panelActions && /* @__PURE__ */ F("div", {
3106
+ children: [a?.panelActions && /* @__PURE__ */ P("div", {
2981
3107
  className: "mb-2",
2982
3108
  children: a.panelActions
2983
- }), a ? /* @__PURE__ */ F(gn, { task: a }, a.id) : /* @__PURE__ */ F(_n, {})]
3109
+ }), a ? /* @__PURE__ */ P(_n, {
3110
+ task: a,
3111
+ editing: te,
3112
+ onCancelEdit: () => A(null),
3113
+ onSendEdit: (e, t) => re(e, t)
3114
+ }, a.id) : /* @__PURE__ */ P(vn, {})]
3115
+ }),
3116
+ ne && /* @__PURE__ */ F(g, {
3117
+ title: E.rewindTitle,
3118
+ onClose: () => I(null),
3119
+ onYes: async () => (K(ne.entry, ne.text), !0),
3120
+ children: [/* @__PURE__ */ P("p", {
3121
+ className: "text-sm",
3122
+ children: E.rewindText
3123
+ }), /* @__PURE__ */ P("ul", {
3124
+ className: "mt-2 list-disc space-y-0.5 ps-5 text-sm text-muted-foreground",
3125
+ children: ne.steps.slice(0, 8).map((e) => /* @__PURE__ */ P("li", { children: e }, e))
3126
+ })]
2984
3127
  })
2985
3128
  ]
2986
3129
  })
2987
- ] }) : /* @__PURE__ */ I(P, { children: [
2988
- J,
2989
- ae,
2990
- oe,
2991
- Z,
2992
- ce
3130
+ ] }) : /* @__PURE__ */ F(N, { children: [
3131
+ ue,
3132
+ fe,
3133
+ me,
3134
+ ge,
3135
+ _e
2993
3136
  ] });
2994
3137
  }
2995
3138
  //#endregion
2996
3139
  //#region src/presentation/useAgenticoPageContext.ts
2997
- function wn(e, t) {
2998
- let { setPageContext: n } = tt(), r = M(crypto.randomUUID()).current;
3140
+ function Tn(e, t) {
3141
+ let { setPageContext: n } = nt(), r = j(crypto.randomUUID()).current;
2999
3142
  k(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
3000
3143
  }
3001
3144
  //#endregion
3002
3145
  //#region src/presentation/useSubagentComponentContext.ts
3003
- function Tn(e, t, n, r, i = !0, a) {
3004
- let { registerComponentAnchor: o } = tt(), s = M(crypto.randomUUID()).current, c = M(n);
3146
+ function En(e, t, n, r, i = !0, a) {
3147
+ let { registerComponentAnchor: o } = nt(), s = j(crypto.randomUUID()).current, c = j(n);
3005
3148
  c.current = n, k(() => {
3006
3149
  if (i) return o(s, {
3007
3150
  subagentId: e,
@@ -3019,6 +3162,6 @@ function Tn(e, t, n, r, i = !0, a) {
3019
3162
  ]);
3020
3163
  }
3021
3164
  //#endregion
3022
- export { xt as AGENTICO_MAX_WIDTH, bt as AGENTICO_MIN_WIDTH, yt as AGENTICO_WIDTH, St as AGENTICO_WIDTH_STORAGE_KEY, Cn as Agentico, et as AgenticoProvider, At as AgenticoToggle, R as DEFAULT_REASONING_PART_ID, L as DEFAULT_TEXT_PART_ID, ve as JSON_EXPORT_DESTINATION_ID, pe as MICRO_PROMPT_REGISTRY, Qe as ORCHESTRATOR_TASK_ID, fe as SUMMARY_MICRO_PROMPT, Te as agenticoDe, Ce as agenticoEn, we as agenticoIt, ie as agenticoPromptsEn, ae as agenticoPromptsIt, Ze as agenticoTranslations, me as applyMicroPrompts, We as chatHasPersonMessage, qe as chatStartedAt, Ue as chatTitle, oe as configureAgenticoPrompts, Oe as configureEntityChatStore, q as createCrossAgentTools, te as defineSubagent, Xe as entityChatTaskId, he as extractErrorMessage, ge as extractJsonBlock, W as findSubagentManifest, B as formatQuestionAnswers, X as getAgenticoPrompts, Se as getDestinationRegistry, Re as getEntityChat, rn as getSubagentControls, U as getSubagentRegistry, Qt as getSubagentReport, ke as hasEntityChatBackend, ye as jsonExportDestination, Ye as listEntityChats, ee as messagePartsText, Ie as onEntityChatsChange, K as registerCrossAgentTools, xe as registerDestinations, nn as registerSubagentControls, Zt as registerSubagentReports, H as registerSubagents, Je as removeEntityChat, Ke as renameEntityChat, de as renderRegistryCli, ue as renderSubagentCli, Z as resetAgenticoPrompts, ze as saveEntityChat, Me as syncEntityChats, ne as toJsonSchema, re as toMcpTool, z as upsertMessagePart, Ht as useAgent, tt as useAgentico, $ as useAgenticoI18n, wn as useAgenticoPageContext, Tn as useSubagentComponentContext };
3165
+ export { St as AGENTICO_MAX_WIDTH, xt as AGENTICO_MIN_WIDTH, bt as AGENTICO_WIDTH, Ct as AGENTICO_WIDTH_STORAGE_KEY, wn as Agentico, tt as AgenticoProvider, jt as AgenticoToggle, I as DEFAULT_REASONING_PART_ID, ne as DEFAULT_TEXT_PART_ID, ye as JSON_EXPORT_DESTINATION_ID, he as MICRO_PROMPT_REGISTRY, $e as ORCHESTRATOR_TASK_ID, me as SUMMARY_MICRO_PROMPT, Ee as agenticoDe, we as agenticoEn, Te as agenticoIt, J as agenticoPromptsEn, Y as agenticoPromptsIt, Qe as agenticoTranslations, ge as applyMicroPrompts, Ge as chatHasPersonMessage, Je as chatStartedAt, We as chatTitle, se as configureAgenticoPrompts, ke as configureEntityChatStore, q as createCrossAgentTools, B as defineSubagent, Ze as entityChatTaskId, Z as extractErrorMessage, _e as extractJsonBlock, W as findSubagentManifest, z as formatQuestionAnswers, X as getAgenticoPrompts, Ce as getDestinationRegistry, ze as getEntityChat, an as getSubagentControls, U as getSubagentRegistry, $t as getSubagentReport, Ae as hasEntityChatBackend, be as jsonExportDestination, Xe as listEntityChats, R as messagePartsText, Le as onEntityChatsChange, K as registerCrossAgentTools, Se as registerDestinations, rn as registerSubagentControls, Qt as registerSubagentReports, H as registerSubagents, Ye as removeEntityChat, qe as renameEntityChat, pe as renderRegistryCli, fe as renderSubagentCli, ce as resetAgenticoPrompts, Be as saveEntityChat, Ne as syncEntityChats, re as toJsonSchema, ie as toMcpTool, L as upsertMessagePart, Ut as useAgent, nt as useAgentico, $ as useAgenticoI18n, Tn as useAgenticoPageContext, En as useSubagentComponentContext };
3023
3166
 
3024
3167
  //# sourceMappingURL=index.mjs.map