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