@llmnative/agentico 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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, ChatMarkdown as r, ChatQuestions as i, ChatReasoning as a, Chatbot as o, Code as s, Dropdown as c, DropdownItem as l, Icon as u, PromptUtils as d, Tree as f, getAIModelCatalog as p, interpolate as m, parseAIModelRef as h, proxyFetch as g, useAIProviderRegistry as _, useI18n as v, useProxy as y } from "@llmnative/react";
3
- import { createContext as b, useCallback as x, useContext as S, useEffect as C, useLayoutEffect as w, useMemo as T, useRef as E, useState as D } from "react";
4
- import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
2
+ import { ActionButton as t, Badge as n, ChatMarkdown as r, ChatQuestions as i, ChatReasoning as a, Chatbot as o, Code as s, Dropdown as c, DropdownItem as l, Form as u, Icon as d, Input as f, Modal as p, PromptUtils as m, Tree as h, getAIModelCatalog as g, interpolate as _, parseAIModelRef as v, proxyFetch as y, useAIProviderRegistry as b, useFormController as x, useI18n as S, useProxy as C } from "@llmnative/react";
3
+ import { createContext as w, useCallback as T, useContext as E, useEffect as D, useLayoutEffect as O, useMemo as k, useRef as A, useState as j } from "react";
4
+ import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
5
5
  //#region src/domain/messageParts.ts
6
- var j = "text", M = "reasoning";
7
- function N(e, t, n) {
6
+ var F = "text", ee = "reasoning";
7
+ function I(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 N(e, t, n) {
14
14
  ...i.slice(a)
15
15
  ] : [...i, t];
16
16
  }
17
- function P(e) {
17
+ function L(e) {
18
18
  return e.filter((e) => e.type === "text").map((e) => e.text).filter(Boolean).join("\n\n");
19
19
  }
20
- function F(e, t) {
20
+ function R(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 ee(e) {
25
+ function z(e) {
26
26
  return e;
27
27
  }
28
28
  //#endregion
29
29
  //#region src/domain/subagentRegistry.ts
30
- var I = [];
31
- function L(e) {
32
- I = e;
30
+ var B = [];
31
+ function te(e) {
32
+ B = e;
33
33
  }
34
- function R() {
35
- return I.length === 0 && typeof console < "u" && console.warn("[agentico] getSubagentRegistry() letto a registro vuoto — registerSubagents() non è ancora stato chiamato?"), I;
34
+ function V() {
35
+ return B.length === 0 && typeof console < "u" && console.warn("[agentico] getSubagentRegistry() letto a registro vuoto — registerSubagents() non è ancora stato chiamato?"), B;
36
36
  }
37
- function z(e) {
38
- return I.find((t) => t.id === e);
37
+ function H(e) {
38
+ return B.find((t) => t.id === e);
39
39
  }
40
40
  //#endregion
41
41
  //#region src/domain/crossAgentTools.ts
42
- var B = [];
43
- function V(...e) {
44
- B = e;
42
+ var U = [];
43
+ function W(...e) {
44
+ U = e;
45
45
  }
46
- function H(e) {
47
- return B.flatMap((t) => t(e));
46
+ function G(e) {
47
+ return U.flatMap((t) => t(e));
48
48
  }
49
49
  //#endregion
50
50
  //#region src/domain/mcpTool.ts
51
- function U(t) {
51
+ function K(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 W(e, t, n, r) {
58
+ function q(e, t, n, r) {
59
59
  return {
60
60
  name: e,
61
61
  description: t,
62
- inputSchema: U(n),
63
- ...r ? { outputSchema: U(r) } : {}
62
+ inputSchema: K(n),
63
+ ...r ? { outputSchema: K(r) } : {}
64
64
  };
65
65
  }
66
66
  //#endregion
67
67
  //#region src/domain/subagentUsageCard.ts
68
- function G(e) {
69
- let t = U(e.inputSchema), n = t.properties ?? {}, r = new Set(t.required ?? []);
68
+ function ne(e) {
69
+ let t = K(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 G(e) {
80
80
  }
81
81
  //#endregion
82
82
  //#region src/domain/prompts.ts
83
- var K = {
83
+ var J = {
84
84
  orchestratorIntro: "You are Agentico, the orchestrator of this application's tools. Your job is to understand what the user wants to achieve and, once every required parameter is collected, start the right tool among those listed below — do not carry it out yourself \"in words\", invoke it as a tool.",
85
85
  responseRules: [
86
86
  "BEFORE asking for any parameter, check the \"Page context\" below (if present): if a parameter required by the command is already there or can be deduced from it with reasonable certainty, USE it directly — do not ask the user again. Only ask for parameters that cannot be derived from the context.",
@@ -108,8 +108,9 @@ var K = {
108
108
  "needless repetition of the original task. The summary goes AFTER the JSON",
109
109
  "block requested above, never before it and never instead of it."
110
110
  ].join(" "),
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
- }, q = {
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
+ 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
+ }, Y = {
113
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.",
114
115
  responseRules: [
115
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.",
@@ -137,27 +138,28 @@ var K = {
137
138
  "ripetizioni superflue del compito originale. Il riepilogo va DOPO il blocco JSON",
138
139
  "richiesto sopra, mai prima e mai al posto suo."
139
140
  ].join(" "),
140
- multipleCandidates: "Più subagent sono candidati su questa pagina — chiedi all'utente quale intende se non è chiaro dal suo messaggio, prima di procedere."
141
- }, J = K;
142
- function te(e) {
143
- J = {
144
- ...J,
141
+ multipleCandidates: "Più subagent sono candidati su questa pagina — chiedi all'utente quale intende se non è chiaro dal suo messaggio, prima di procedere.",
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
+ }, re = J;
144
+ function ie(e) {
145
+ re = {
146
+ ...re,
145
147
  ...e
146
148
  };
147
149
  }
148
- function Y() {
149
- return J;
150
- }
151
150
  function X() {
152
- J = K;
151
+ return re;
152
+ }
153
+ function ae() {
154
+ re = J;
153
155
  }
154
156
  //#endregion
155
157
  //#region src/domain/cli/renderManifestCli.ts
156
- function ne(e, t) {
158
+ function oe(e, t) {
157
159
  return `${e} ${t.map((e) => e.required ? `--${e.key} <${e.type}>` : `[--${e.key} <${e.type}>]`).join(" ")}`.trim();
158
160
  }
159
- function Z(e, t) {
160
- let n = G(t), r = ne(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
161
+ function se(e, t) {
162
+ let n = ne(t), r = oe(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
161
163
  return [
162
164
  `COMMAND: ${e} ${t.name}`,
163
165
  ` ${t.summary}`,
@@ -169,46 +171,46 @@ function Z(e, t) {
169
171
  ...i,
170
172
  "",
171
173
  " OUTPUT",
172
- re(t.describeOutput(), 4),
174
+ Z(t.describeOutput(), 4),
173
175
  (t.example, ""),
174
176
  t.example ? " EXAMPLE" : "",
175
177
  t.example ? ` ${t.example}` : ""
176
178
  ].filter((e) => e !== "").join("\n");
177
179
  }
178
- function re(e, t) {
180
+ function Z(e, t) {
179
181
  let n = " ".repeat(t);
180
182
  return e.split("\n").map((e) => e && n + e).join("\n");
181
183
  }
182
- function ie(e) {
184
+ function ce(e) {
183
185
  return [
184
186
  "NAME",
185
187
  ` ${e.id} — ${e.label}`,
186
188
  "",
187
189
  "DESCRIPTION",
188
- re(e.description, 2),
190
+ Z(e.description, 2),
189
191
  "",
190
- ...e.commands.map((t) => Z(e.id, t))
192
+ ...e.commands.map((t) => se(e.id, t))
191
193
  ].join("\n");
192
194
  }
193
- function ae(e) {
194
- return e.length === 0 ? Y().noToolsAvailable : e.map((e) => `${e.id} [${e.commands.map((e) => e.name).join("|")}] — ${e.label}: ${e.commands.map((e) => e.summary).join(" / ")}`).join("\n");
195
+ function le(e) {
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");
195
197
  }
196
198
  //#endregion
197
199
  //#region src/domain/microPrompts.ts
198
- var oe = {
200
+ var ue = {
199
201
  id: "closing-summary",
200
202
  get text() {
201
- return Y().closingSummary;
203
+ return X().closingSummary;
202
204
  }
203
- }, se = { [oe.id]: oe };
204
- function ce(e, t) {
205
+ }, de = { [ue.id]: ue };
206
+ function fe(e, t) {
205
207
  if (!t || t.length === 0) return e;
206
- let n = t.map((e) => se[e]?.text).filter((e) => !!e);
208
+ let n = t.map((e) => de[e]?.text).filter((e) => !!e);
207
209
  return n.length === 0 ? e : `${e}\n\n${n.join("\n")}`;
208
210
  }
209
211
  //#endregion
210
212
  //#region src/domain/extractErrorMessage.ts
211
- function le(e) {
213
+ function pe(e) {
212
214
  if (e instanceof Error) return e.message;
213
215
  if (typeof e == "object" && e) {
214
216
  let t = e;
@@ -227,13 +229,13 @@ function le(e) {
227
229
  }
228
230
  //#endregion
229
231
  //#region src/domain/extractJsonBlock.ts
230
- function ue(e) {
232
+ function me(e) {
231
233
  let t = e.match(/```(?:json)?\s*\n?([\s\S]*?)```/i);
232
234
  if (t) return t[1].trim();
233
235
  let n = e.replace(/^```json\s*/i, "").replace(/^```\s*/i, "").replace(/```\s*$/, "").trim();
234
- return de(n) ?? n;
236
+ return he(n) ?? n;
235
237
  }
236
- function de(e) {
238
+ function he(e) {
237
239
  let t = e.search(/[{[]/);
238
240
  if (t === -1) return null;
239
241
  let n = e[t], r = n === "{" ? "}" : "]", i = 0, a = !1, o = !1;
@@ -254,8 +256,8 @@ function de(e) {
254
256
  }
255
257
  //#endregion
256
258
  //#region src/domain/jsonExportDestination.ts
257
- var fe = "json-export", pe = {
258
- id: fe,
259
+ var ge = "json-export", _e = {
260
+ id: ge,
259
261
  label: "Export as JSON",
260
262
  async apply(e) {
261
263
  let t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), n = URL.createObjectURL(t);
@@ -266,23 +268,23 @@ var fe = "json-export", pe = {
266
268
  URL.revokeObjectURL(n);
267
269
  }
268
270
  }
269
- }, me = {};
270
- function he(e) {
271
- me = e;
271
+ }, ve = {};
272
+ function ye(e) {
273
+ ve = e;
272
274
  }
273
- function ge() {
275
+ function be() {
274
276
  return {
275
- [pe.id]: pe,
276
- ...me
277
+ [_e.id]: _e,
278
+ ...ve
277
279
  };
278
280
  }
279
281
  //#endregion
280
282
  //#region src/domain/entityChatStore.ts
281
- var _e = "llmnative.agentico.entityChat";
282
- function ve(e) {
283
- _e = e.storageKey;
283
+ var xe = "llmnative.agentico.entityChat";
284
+ function Se(e) {
285
+ xe = e.storageKey;
284
286
  }
285
- function ye(e) {
287
+ function Ce(e) {
286
288
  if (!e || typeof e != "object") return null;
287
289
  let t = e;
288
290
  if (typeof t.entityId != "string") return null;
@@ -294,41 +296,65 @@ function ye(e) {
294
296
  scopeId: n
295
297
  };
296
298
  }
297
- function be() {
299
+ function we() {
298
300
  try {
299
- let e = localStorage.getItem(_e);
301
+ let e = localStorage.getItem(xe);
300
302
  if (!e) return [];
301
303
  let t = JSON.parse(e);
302
- return Array.isArray(t) ? t.map(ye).filter((e) => e !== null) : [];
304
+ return Array.isArray(t) ? t.map(Ce).filter((e) => e !== null) : [];
303
305
  } catch {
304
306
  return [];
305
307
  }
306
308
  }
307
- function xe(e) {
309
+ var Te = /* @__PURE__ */ new Set();
310
+ function Ee(e) {
311
+ return Te.add(e), () => {
312
+ Te.delete(e);
313
+ };
314
+ }
315
+ function De(e) {
308
316
  try {
309
- localStorage.setItem(_e, JSON.stringify(e));
317
+ localStorage.setItem(xe, JSON.stringify(e));
310
318
  } catch {}
319
+ for (let e of [...Te]) e();
311
320
  }
312
- var Se = (e, t, n) => `${e}:${t}:${n}`;
313
- function Ce(e, t, n) {
314
- let r = Se(e, t, n);
315
- return be().find((e) => Se(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
321
+ var Oe = (e, t, n) => `${e}:${t}:${n}`;
322
+ function ke(e, t, n) {
323
+ let r = Oe(e, t, n);
324
+ return we().find((e) => Oe(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
316
325
  }
317
- function we(e) {
318
- let t = Se(e.scopeId, e.subagentId, e.entityId), n = be().filter((e) => Se(e.scopeId, e.subagentId, e.entityId) !== t);
319
- n.push({
326
+ function Ae(e) {
327
+ let t = Oe(e.scopeId, e.subagentId, e.entityId), n = we(), r = n.find((e) => Oe(e.scopeId, e.subagentId, e.entityId) === t), i = Date.now(), a = n.filter((e) => e !== r);
328
+ a.push({
320
329
  ...e,
321
- savedAt: Date.now()
322
- }), xe(n);
330
+ savedAt: i,
331
+ startedAt: r ? Pe(r) : i,
332
+ ...r?.name ? {
333
+ name: r.name,
334
+ namedBy: r.namedBy
335
+ } : {}
336
+ }), De(a);
337
+ }
338
+ var je = (e) => e.name || e.title || e.entityId, Me = (e) => e.activity.some((e) => e.kind === "user" && !!e.detail?.trim());
339
+ function Ne(e, t, n, r, i = "person") {
340
+ let a = Oe(e, t, n), o = we(), s = o.find((e) => Oe(e.scopeId, e.subagentId, e.entityId) === a);
341
+ if (!s || i === "model" && s.namedBy === "person") return !1;
342
+ let c = r.trim().replace(/\s+/g, " ").slice(0, 120), { name: l, namedBy: u, ...d } = s, f = c ? {
343
+ ...d,
344
+ name: c,
345
+ namedBy: i
346
+ } : d;
347
+ return De(o.map((e) => e === s ? f : e)), !0;
348
+ }
349
+ var Pe = (e) => e.startedAt ?? e.savedAt;
350
+ function Fe(e, t, n) {
351
+ let r = Oe(e, t, n);
352
+ De(we().filter((e) => Oe(e.scopeId, e.subagentId, e.entityId) !== r));
323
353
  }
324
- function Te(e, t, n) {
325
- let r = Se(e, t, n);
326
- xe(be().filter((e) => Se(e.scopeId, e.subagentId, e.entityId) !== r));
327
- }
328
- function Ee(e) {
329
- return be().filter((t) => t.scopeId === e).sort((e, t) => t.savedAt - e.savedAt);
354
+ function Ie(e) {
355
+ return we().filter((t) => t.scopeId === e).sort((e, t) => Pe(t) - Pe(e));
330
356
  }
331
- var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
357
+ var Le = (e, t) => `entitychat-${e}-${t}`, Re = {
332
358
  modelLabel: "Modell",
333
359
  modelsLoading: "Wird geladen…",
334
360
  noModelsAvailable: "Keine Modelle verfügbar",
@@ -367,6 +393,11 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
367
393
  stepsLabel: "Schritte des Agenten",
368
394
  newInstance: "Neue Instanz von \"{label}\"",
369
395
  chatHistory: "Chatverlauf",
396
+ renameChat: "Umbenennen",
397
+ chatTitleLabel: "Titel",
398
+ chatTitleHint: "Leer: der aus dem Chat geschriebene Titel.",
399
+ chatStarted: "Begonnen am {at}",
400
+ chatLastMessage: "letzte Nachricht am {at}",
370
401
  newChat: "Neuer Chat",
371
402
  searchChats: "Chats durchsuchen…",
372
403
  messagePlaceholder: "Nachricht schreiben…",
@@ -384,7 +415,7 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
384
415
  resizePanelHint: "Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen",
385
416
  pendingQuestions: "Fragen des Agenten",
386
417
  stop: "Stoppen"
387
- }, ke = {
418
+ }, ze = {
388
419
  modelLabel: "Model",
389
420
  modelsLoading: "Loading…",
390
421
  noModelsAvailable: "No models available",
@@ -423,6 +454,11 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
423
454
  stepsLabel: "Steps of the agent",
424
455
  newInstance: "New \"{label}\" instance",
425
456
  chatHistory: "Chat history",
457
+ renameChat: "Rename",
458
+ chatTitleLabel: "Title",
459
+ chatTitleHint: "Empty: the title written from the chat.",
460
+ chatStarted: "Started {at}",
461
+ chatLastMessage: "last message {at}",
426
462
  newChat: "New chat",
427
463
  searchChats: "Search chats…",
428
464
  messagePlaceholder: "Write a message…",
@@ -440,7 +476,7 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
440
476
  resizePanelHint: "Drag to resize, double-click to reset",
441
477
  pendingQuestions: "Questions of the agent",
442
478
  stop: "Stop"
443
- }, Ae = {
479
+ }, Be = {
444
480
  modelLabel: "Modello",
445
481
  modelsLoading: "Caricamento…",
446
482
  noModelsAvailable: "Nessun modello disponibile",
@@ -479,6 +515,11 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
479
515
  stepsLabel: "Passi dell'agente",
480
516
  newInstance: "Nuova istanza di \"{label}\"",
481
517
  chatHistory: "Storico chat",
518
+ renameChat: "Rinomina",
519
+ chatTitleLabel: "Titolo",
520
+ chatTitleHint: "Vuoto: il titolo scritto dalla chat.",
521
+ chatStarted: "Iniziata il {at}",
522
+ chatLastMessage: "ultimo messaggio il {at}",
482
523
  newChat: "Nuova chat",
483
524
  searchChats: "Cerca nelle chat…",
484
525
  messagePlaceholder: "Scrivi un messaggio…",
@@ -496,27 +537,27 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
496
537
  resizePanelHint: "Trascina per ridimensionare, doppio clic per ripristinare",
497
538
  pendingQuestions: "Domande dell'agente",
498
539
  stop: "Ferma"
499
- }, je = {
500
- en: { agentico: ke },
501
- it: { agentico: Ae },
502
- de: { agentico: Oe }
540
+ }, Ve = {
541
+ en: { agentico: ze },
542
+ it: { agentico: Be },
543
+ de: { agentico: Re }
503
544
  };
504
545
  function Q() {
505
- let { dict: e } = v(), t = e.agentico;
546
+ let { dict: e } = S(), t = e.agentico;
506
547
  return t ? {
507
- ...ke,
548
+ ...ze,
508
549
  ...t
509
- } : ke;
550
+ } : ze;
510
551
  }
511
552
  //#endregion
512
553
  //#region src/presentation/AgenticoContext.tsx
513
- var Me = "agentico-orchestrator", Ne = b(null);
514
- function Pe({ children: e, scope: t = null }) {
515
- let [n, r] = D(null), i = E(null);
516
- C(() => {
554
+ var He = "agentico-orchestrator", Ue = w(null);
555
+ function We({ children: e, scope: t = null }) {
556
+ let [n, r] = j(null), i = A(null);
557
+ D(() => {
517
558
  i.current = n;
518
559
  }, [n]);
519
- let [a, o] = D(!1), s = x((e) => {
560
+ let [a, o] = j(!1), s = T((e) => {
520
561
  let t = i.current;
521
562
  t && t.id !== e.id && t.onDismiss();
522
563
  let n = t && t.id === e.id && t.savedToDisk && e.savedToDisk === void 0 ? {
@@ -524,10 +565,10 @@ function Pe({ children: e, scope: t = null }) {
524
565
  savedToDisk: !0
525
566
  } : e;
526
567
  r(n);
527
- }, []), c = x((e) => {
568
+ }, []), c = T((e) => {
528
569
  r((t) => t && t.id === e ? null : t);
529
- }, []), l = x(() => o((e) => !e), []), u = x(() => o(!0), []), [d, f] = D(null), [p, m] = D(void 0), [h, g] = D(void 0), [_, v] = D(void 0), [y, b] = D(null), [S, w] = D(null), [O, A] = D(void 0), [j, M] = D([]), N = x((e, t, n = null) => {
530
- M((r) => {
570
+ }, []), l = T(() => o((e) => !e), []), u = T(() => o(!0), []), [d, f] = j(null), [p, m] = j(void 0), [h, g] = j(void 0), [_, v] = j(void 0), [y, b] = j(null), [x, S] = j(null), [C, w] = j(void 0), [E, O] = j([]), M = T((e, t, n = null) => {
571
+ O((r) => {
531
572
  let i = r.filter((t) => t.id !== e);
532
573
  return t ? [...i, {
533
574
  id: e,
@@ -535,7 +576,7 @@ function Pe({ children: e, scope: t = null }) {
535
576
  card: n
536
577
  }] : i;
537
578
  });
538
- }, []), P = j.length > 0 ? j[j.length - 1] : null, [F, ee] = D([]), I = x((e, t) => {
579
+ }, []), P = E.length > 0 ? E[E.length - 1] : null, [F, ee] = j([]), I = T((e, t) => {
539
580
  ee((n) => {
540
581
  let r = n.filter((t) => t.id !== e);
541
582
  return t ? [...r, {
@@ -543,12 +584,12 @@ function Pe({ children: e, scope: t = null }) {
543
584
  ...t
544
585
  }] : r;
545
586
  });
546
- }, []), L = T(() => F.map((e) => ({
587
+ }, []), L = k(() => F.map((e) => ({
547
588
  subagentId: e.subagentId,
548
589
  componentKey: e.componentKey,
549
590
  onResult: e.onResult,
550
591
  pinnedEntityId: e.pinnedEntityId
551
- })), [F]), R = T(() => {
592
+ })), [F]), R = k(() => {
552
593
  let e = /* @__PURE__ */ new Map();
553
594
  for (let t of F) e.set(t.subagentId, {
554
595
  subagentId: t.subagentId,
@@ -557,8 +598,8 @@ function Pe({ children: e, scope: t = null }) {
557
598
  contextInfo: t.contextInfo
558
599
  });
559
600
  return [...e.values()];
560
- }, [F]), B = T(() => R.map((e) => {
561
- let t = z(e.subagentId)?.componentContexts?.[e.componentKey];
601
+ }, [F]), z = k(() => R.map((e) => {
602
+ let t = H(e.subagentId)?.componentContexts?.[e.componentKey];
562
603
  if (!t) return null;
563
604
  let n = e.contextInfo ? `${t.agenticoHint}\n${e.contextInfo}` : t.agenticoHint;
564
605
  return {
@@ -566,26 +607,26 @@ function Pe({ children: e, scope: t = null }) {
566
607
  agenticoHint: n,
567
608
  userMessage: t.userMessage
568
609
  };
569
- }).filter((e) => e !== null), [R]), V = T(() => B.map((e) => e.userMessage), [B]), H = T(() => {
570
- if (B.length === 0) return null;
571
- if (B.length === 1) return B[0].agenticoHint;
572
- let e = B.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
573
- return `${Y().multipleCandidates}\n\n${e}`;
574
- }, [B]) ?? P?.text ?? null, U = B.length > 0 ? null : P?.card ?? null, W = T(() => [...new Set(L.map((e) => e.subagentId))], [L]), G = W.length === 1 ? W[0] : W.length === 0 ? P?.card?.subagentId ?? null : null, K = x((e, t) => {
610
+ }).filter((e) => e !== null), [R]), B = k(() => z.map((e) => e.userMessage), [z]), te = k(() => {
611
+ if (z.length === 0) return null;
612
+ if (z.length === 1) return z[0].agenticoHint;
613
+ let e = z.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
614
+ return `${X().multipleCandidates}\n\n${e}`;
615
+ }, [z]) ?? P?.text ?? null, V = z.length > 0 ? null : P?.card ?? null, U = k(() => [...new Set(L.map((e) => e.subagentId))], [L]), W = U.length === 1 ? U[0] : U.length === 0 ? P?.card?.subagentId ?? null : null, G = T((e, t) => {
575
616
  u();
576
617
  let n = i.current;
577
618
  if (n?.id === "agentico-orchestrator") return;
578
- let r = G && n?.id.startsWith(`subagent-${G}-`) ? n : void 0;
579
- w(r ? {
619
+ let r = W && n?.id.startsWith(`subagent-${W}-`) ? n : void 0;
620
+ S(r ? {
580
621
  taskId: r.id,
581
622
  activity: [...r.precedingActivity ?? [], ...r.agent.activity]
582
- } : null), f(e), m(t?.extraDestinations), g(t?.attachments), v(t?.model), A(t?.scopedSubagentId), b(crypto.randomUUID());
583
- }, [u, G]), q = x((e, t, n, a, o, s) => {
623
+ } : null), f(e), m(t?.extraDestinations), g(t?.attachments), v(t?.model), w(t?.scopedSubagentId), b(crypto.randomUUID());
624
+ }, [u, W]), K = T((e, t, n, a, o, s) => {
584
625
  if (!n || !a) return;
585
626
  let c = i.current;
586
627
  if (!c || c.id !== n) return;
587
628
  let l = c.agent.snapshot();
588
- l && (we({
629
+ l && (Ae({
589
630
  scopeId: a,
590
631
  subagentId: e,
591
632
  entityId: t,
@@ -597,33 +638,33 @@ function Pe({ children: e, scope: t = null }) {
597
638
  ...e,
598
639
  savedToDisk: !0
599
640
  } : e));
600
- }, []), [J, te] = D(null), [X, ne] = D(null), Z = x((e, t, n) => {
601
- u(), te({
641
+ }, []), [q, ne] = j(null), [J, Y] = j(null), re = T((e, t, n) => {
642
+ u(), ne({
602
643
  subagentId: e,
603
644
  entityId: t,
604
645
  snapshot: n
605
- }), ne(crypto.randomUUID());
606
- }, [u]), [re, ie] = D(null), [ae, oe] = D(null), se = x((e, t) => {
607
- u(), c(Me), ie({
646
+ }), Y(crypto.randomUUID());
647
+ }, [u]), [ie, ae] = j(null), [oe, se] = j(null), Z = T((e, t) => {
648
+ u(), c(He), ae({
608
649
  subagentId: e,
609
650
  extraDestinations: t
610
- }), oe(crypto.randomUUID());
611
- }, [u, c]), [ce, le] = D(null), [ue, de] = D(null), fe = x((e, t, n) => {
612
- ie(null), le({
651
+ }), se(crypto.randomUUID());
652
+ }, [u, c]), [ce, le] = j(null), [ue, de] = j(null), fe = T((e, t, n) => {
653
+ ae(null), le({
613
654
  subagentId: e,
614
655
  params: t,
615
656
  extraDestinations: n
616
657
  }), de(crypto.randomUUID());
617
- }, []), [pe, me] = D(null), [he, ge] = D(null), _e = x((e, t, n) => {
658
+ }, []), [pe, me] = j(null), [he, ge] = j(null), _e = T((e, t, n) => {
618
659
  u(), me({
619
660
  subagentId: e,
620
661
  params: t,
621
662
  ...n
622
663
  }), ge(crypto.randomUUID());
623
- }, [u]), ve = x(() => {
664
+ }, [u]), ve = T(() => {
624
665
  let e = i.current;
625
666
  e && e.onDismiss();
626
- }, []), ye = T(() => ({
667
+ }, []), ye = k(() => ({
627
668
  scope: t,
628
669
  task: n,
629
670
  isOpen: a,
@@ -631,29 +672,29 @@ function Pe({ children: e, scope: t = null }) {
631
672
  closeTask: c,
632
673
  toggleOpen: l,
633
674
  pendingGoal: d,
634
- startOrchestrator: K,
635
- pageContext: H,
636
- pageContextCard: U,
637
- setPageContext: N,
638
- scopedSubagentId: G,
639
- pendingScopedSubagentId: O,
675
+ startOrchestrator: G,
676
+ pageContext: te,
677
+ pageContextCard: V,
678
+ setPageContext: M,
679
+ scopedSubagentId: W,
680
+ pendingScopedSubagentId: C,
640
681
  componentAnchors: L,
641
- anchoredUserMessages: V,
682
+ anchoredUserMessages: B,
642
683
  registerComponentAnchor: I,
643
684
  openPanel: u,
644
685
  pendingExtraDestinations: p,
645
686
  pendingAttachments: h,
646
687
  pendingModel: _,
647
688
  orchestratorRunId: y,
648
- pendingCarryOver: S,
649
- commitEntityChat: q,
650
- resumeEntityChat: Z,
651
- pendingResume: J,
652
- resumeRunId: X,
689
+ pendingCarryOver: x,
690
+ commitEntityChat: K,
691
+ resumeEntityChat: re,
692
+ pendingResume: q,
693
+ resumeRunId: J,
653
694
  dismissForeignTask: ve,
654
- pendingManualEntry: re,
655
- manualEntryRunId: ae,
656
- startManualEntry: se,
695
+ pendingManualEntry: ie,
696
+ manualEntryRunId: oe,
697
+ startManualEntry: Z,
657
698
  pendingResumeWithAI: ce,
658
699
  resumeWithAIRunId: ue,
659
700
  resumeWithAI: fe,
@@ -668,29 +709,29 @@ function Pe({ children: e, scope: t = null }) {
668
709
  c,
669
710
  l,
670
711
  d,
671
- K,
672
- H,
673
- U,
674
- N,
675
712
  G,
676
- O,
677
- L,
713
+ te,
678
714
  V,
715
+ M,
716
+ W,
717
+ C,
718
+ L,
719
+ B,
679
720
  I,
680
721
  u,
681
722
  p,
682
723
  h,
683
724
  _,
684
725
  y,
685
- S,
726
+ x,
727
+ K,
728
+ re,
686
729
  q,
687
- Z,
688
730
  J,
689
- X,
690
731
  ve,
691
- re,
692
- ae,
693
- se,
732
+ ie,
733
+ oe,
734
+ Z,
694
735
  ce,
695
736
  ue,
696
737
  fe,
@@ -698,19 +739,19 @@ function Pe({ children: e, scope: t = null }) {
698
739
  pe,
699
740
  he
700
741
  ]);
701
- return /* @__PURE__ */ k(Ne.Provider, {
742
+ return /* @__PURE__ */ N(Ue.Provider, {
702
743
  value: ye,
703
744
  children: e
704
745
  });
705
746
  }
706
747
  function $() {
707
- let e = S(Ne);
748
+ let e = E(Ue);
708
749
  if (!e) throw Error("useAgentico must be used inside AgenticoProvider");
709
750
  return e;
710
751
  }
711
752
  //#endregion
712
753
  //#region src/presentation/AgentActivityLog.tsx
713
- function Fe(e) {
754
+ function Ge(e) {
714
755
  let t = e.search(/[{[]/);
715
756
  if (t === -1) return [{
716
757
  type: "text",
@@ -756,97 +797,97 @@ function Fe(e) {
756
797
  language: "json"
757
798
  });
758
799
  let u = e.slice(s + 1);
759
- return u.trim() && l.push(...Fe(u)), l;
800
+ return u.trim() && l.push(...Ge(u)), l;
760
801
  }
761
- function Ie(e) {
802
+ function Ke(e) {
762
803
  let t = [], n = /```(\w+)?\n?([\s\S]*?)```/g, r = 0, i;
763
- for (; i = n.exec(e);) i.index > r && t.push(...Fe(e.slice(r, i.index))), t.push({
804
+ for (; i = n.exec(e);) i.index > r && t.push(...Ge(e.slice(r, i.index))), t.push({
764
805
  type: "code",
765
806
  content: i[2].replace(/\n$/, ""),
766
807
  language: i[1]
767
808
  }), r = n.lastIndex;
768
- return r < e.length && t.push(...Fe(e.slice(r))), t;
809
+ return r < e.length && t.push(...Ge(e.slice(r))), t;
769
810
  }
770
- function Le({ content: e, language: t }) {
771
- let [n, r] = D(!1);
772
- return /* @__PURE__ */ A("div", {
811
+ function qe({ content: e, language: t }) {
812
+ let [n, r] = j(!1);
813
+ return /* @__PURE__ */ P("div", {
773
814
  className: `relative cursor-pointer rounded-md ${n ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
774
815
  onClick: () => r((e) => !e),
775
816
  title: n ? "Clic per comprimere" : "Clic per espandere",
776
- children: [/* @__PURE__ */ k(s, {
817
+ children: [/* @__PURE__ */ N(s, {
777
818
  language: t,
778
819
  showCopy: n,
779
820
  background: "transparent",
780
821
  className: "!text-[11px]",
781
822
  children: e
782
- }), !n && /* @__PURE__ */ k("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
823
+ }), !n && /* @__PURE__ */ N("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
783
824
  });
784
825
  }
785
- function Re({ text: e, tone: t }) {
786
- let n = Ie(e);
787
- return /* @__PURE__ */ k(O, { children: n.map((e, n) => e.type === "code" ? /* @__PURE__ */ k(Le, {
826
+ function Je({ text: e, tone: t }) {
827
+ let n = Ke(e);
828
+ return /* @__PURE__ */ N(M, { children: n.map((e, n) => e.type === "code" ? /* @__PURE__ */ N(qe, {
788
829
  content: e.content,
789
830
  language: e.language
790
- }, n) : e.content.trim() && /* @__PURE__ */ k(r, {
831
+ }, n) : e.content.trim() && /* @__PURE__ */ N(r, {
791
832
  content: e.content.trim(),
792
833
  tone: t,
793
834
  className: "break-words text-xs leading-relaxed"
794
835
  }, n)) });
795
836
  }
796
- function ze({ status: e }) {
797
- return e === "running" ? /* @__PURE__ */ k("span", { className: "inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" }) : e === "done" ? /* @__PURE__ */ k(u, {
837
+ function Ye({ status: e }) {
838
+ return e === "running" ? /* @__PURE__ */ N("span", { className: "inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" }) : e === "done" ? /* @__PURE__ */ N(d, {
798
839
  name: "check",
799
840
  size: 12,
800
841
  className: "shrink-0 text-green-600"
801
- }) : e === "stopped" ? /* @__PURE__ */ k(u, {
842
+ }) : e === "stopped" ? /* @__PURE__ */ N(d, {
802
843
  name: "circle-slash",
803
844
  size: 12,
804
845
  className: "shrink-0 text-muted-foreground"
805
- }) : /* @__PURE__ */ k(u, {
846
+ }) : /* @__PURE__ */ N(d, {
806
847
  name: "x",
807
848
  size: 12,
808
849
  className: "shrink-0 text-destructive"
809
850
  });
810
851
  }
811
- function Be(e, t) {
852
+ function Xe(e, t) {
812
853
  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;
813
854
  }
814
- var Ve = 96;
815
- function He({ entry: e, pinned: t = !0 }) {
816
- let n = E(null), [r, i] = D(!1), [a, o] = D(!1);
817
- w(() => {
855
+ var Ze = 96;
856
+ function Qe({ entry: e, pinned: t = !0 }) {
857
+ let n = A(null), [r, i] = j(!1), [a, o] = j(!1);
858
+ O(() => {
818
859
  let e = n.current;
819
860
  e && o(e.scrollHeight > 97);
820
861
  }, [e.detail, e.attachmentNames]);
821
862
  let s = a && !r;
822
- return /* @__PURE__ */ k("div", {
863
+ return /* @__PURE__ */ N("div", {
823
864
  className: `${t ? "sticky top-0 z-20 border-b border-border/40" : ""} flex justify-end bg-background py-1.5`,
824
- children: /* @__PURE__ */ A("div", {
865
+ children: /* @__PURE__ */ P("div", {
825
866
  className: "max-w-[85%] rounded-lg bg-primary/10 text-xs text-foreground",
826
- children: [/* @__PURE__ */ A("div", {
867
+ children: [/* @__PURE__ */ P("div", {
827
868
  ref: n,
828
869
  className: `space-y-1 px-2.5 pt-1.5 ${s ? "overflow-hidden" : ""}`,
829
- style: s ? { maxHeight: Ve } : void 0,
830
- children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ k("div", {
870
+ style: s ? { maxHeight: Ze } : void 0,
871
+ children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ N("div", {
831
872
  className: "flex flex-wrap gap-1",
832
- children: e.attachmentNames.map((e, t) => /* @__PURE__ */ A("span", {
873
+ children: e.attachmentNames.map((e, t) => /* @__PURE__ */ P("span", {
833
874
  className: "inline-flex items-center gap-1 rounded-md bg-primary/15 px-1.5 py-0.5 text-[11px] text-foreground",
834
- children: [/* @__PURE__ */ k(u, {
875
+ children: [/* @__PURE__ */ N(d, {
835
876
  name: "paperclip",
836
877
  size: 10,
837
878
  className: "shrink-0"
838
- }), /* @__PURE__ */ k("span", {
879
+ }), /* @__PURE__ */ N("span", {
839
880
  className: "max-w-[160px] truncate",
840
881
  children: e
841
882
  })]
842
883
  }, t))
843
- }), /* @__PURE__ */ k(Re, { text: e.detail ?? "" })]
844
- }), a && /* @__PURE__ */ A("button", {
884
+ }), /* @__PURE__ */ N(Je, { text: e.detail ?? "" })]
885
+ }), a && /* @__PURE__ */ P("button", {
845
886
  type: "button",
846
887
  onClick: () => i((e) => !e),
847
888
  className: "relative flex w-full items-center justify-center rounded-b-lg py-1 text-muted-foreground hover:bg-primary/15",
848
889
  title: r ? "Comprimi" : "Espandi",
849
- children: [s && /* @__PURE__ */ k("div", { className: "pointer-events-none absolute inset-x-0 -top-4 h-4 bg-gradient-to-t from-primary/10 to-transparent" }), /* @__PURE__ */ k(u, {
890
+ children: [s && /* @__PURE__ */ N("div", { className: "pointer-events-none absolute inset-x-0 -top-4 h-4 bg-gradient-to-t from-primary/10 to-transparent" }), /* @__PURE__ */ N(d, {
850
891
  name: r ? "chevron-up" : "chevron-down",
851
892
  size: 12
852
893
  })]
@@ -854,15 +895,15 @@ function He({ entry: e, pinned: t = !0 }) {
854
895
  })
855
896
  });
856
897
  }
857
- var Ue = {
898
+ var $e = {
858
899
  running: "loader-circle",
859
900
  done: "check",
860
901
  error: "x",
861
902
  stopped: "circle-slash"
862
903
  };
863
- function We({ steps: e }) {
864
- let t = Q(), n = e.filter((e) => e.status === "running").at(-1), r = e.some((e) => e.status === "error"), i = n?.label ?? (e.length === 1 ? t.oneStep : m(t.steps, { count: e.length }));
865
- return /* @__PURE__ */ k(f, {
904
+ function et({ steps: e }) {
905
+ let t = Q(), n = e.filter((e) => e.status === "running").at(-1), r = e.some((e) => e.status === "error"), i = n?.label ?? (e.length === 1 ? t.oneStep : _(t.steps, { count: e.length }));
906
+ return /* @__PURE__ */ N(h, {
866
907
  ariaLabel: t.stepsLabel,
867
908
  selectedId: null,
868
909
  itemClassName: "py-0.5 text-xs text-muted-foreground",
@@ -872,16 +913,16 @@ function We({ steps: e }) {
872
913
  icon: n ? "loader-circle" : r ? "circle-alert" : "list-checks",
873
914
  children: e.map((e) => ({
874
915
  id: e.id,
875
- label: /* @__PURE__ */ k("span", {
916
+ label: /* @__PURE__ */ N("span", {
876
917
  className: e.status === "error" ? "text-destructive" : void 0,
877
918
  children: e.label
878
919
  }),
879
- icon: Ue[e.status]
920
+ icon: $e[e.status]
880
921
  }))
881
922
  }]
882
923
  });
883
924
  }
884
- function Ge(e, t) {
925
+ function tt(e, t) {
885
926
  let n = e.at(-1);
886
927
  if (!n || n.kind !== "thinking" || !n.parts || n.status === "stopped" || n.status === "error") return null;
887
928
  let r = [...n.parts].reverse().find((e) => e.type === "questions");
@@ -890,9 +931,9 @@ function Ge(e, t) {
890
931
  part: r
891
932
  };
892
933
  }
893
- function Ke({ entry: e, part: t, questions: n, autoFocus: r, className: a }) {
934
+ function nt({ entry: e, part: t, questions: n, autoFocus: r, className: a }) {
894
935
  let o = !!n?.canAnswer(e.id);
895
- return /* @__PURE__ */ k(i, {
936
+ return /* @__PURE__ */ N(i, {
896
937
  questions: t.questions,
897
938
  ...t.answers ? { answers: t.answers } : {},
898
939
  disabled: !t.answers && !o,
@@ -901,7 +942,7 @@ function Ke({ entry: e, part: t, questions: n, autoFocus: r, className: a }) {
901
942
  className: a ?? "text-xs"
902
943
  });
903
944
  }
904
- function qe({ entry: e, questions: t, hiddenPartId: n }) {
945
+ function rt({ entry: e, questions: t, hiddenPartId: n }) {
905
946
  let i = (e.parts ?? []).filter((e) => e.type !== "questions" || e.id !== n), o = [];
906
947
  for (let e of i) {
907
948
  let t = o.at(-1);
@@ -913,21 +954,21 @@ function qe({ entry: e, questions: t, hiddenPartId: n }) {
913
954
  part: e
914
955
  });
915
956
  }
916
- return /* @__PURE__ */ k("div", {
957
+ return /* @__PURE__ */ N("div", {
917
958
  className: "space-y-2",
918
959
  children: o.map((n) => {
919
- if ("steps" in n) return /* @__PURE__ */ k(We, { steps: n.steps }, n.key);
960
+ if ("steps" in n) return /* @__PURE__ */ N(et, { steps: n.steps }, n.key);
920
961
  let { part: i } = n;
921
- return i.type === "text" ? i.text.trim() ? /* @__PURE__ */ k(r, {
962
+ return i.type === "text" ? i.text.trim() ? /* @__PURE__ */ N(r, {
922
963
  content: i.text,
923
964
  streaming: i.streaming,
924
965
  className: "break-words text-xs leading-relaxed text-foreground"
925
- }, n.key) : null : i.type === "reasoning" ? /* @__PURE__ */ k(a, {
966
+ }, n.key) : null : i.type === "reasoning" ? /* @__PURE__ */ N(a, {
926
967
  content: i.text,
927
968
  streaming: i.streaming,
928
969
  duration: i.duration,
929
970
  className: "my-0"
930
- }, n.key) : /* @__PURE__ */ k(Ke, {
971
+ }, n.key) : /* @__PURE__ */ N(nt, {
931
972
  entry: e,
932
973
  part: i,
933
974
  questions: t
@@ -935,52 +976,52 @@ function qe({ entry: e, questions: t, hiddenPartId: n }) {
935
976
  })
936
977
  });
937
978
  }
938
- function Je({ entry: e, questions: t, hiddenPartId: n }) {
979
+ function it({ entry: e, questions: t, hiddenPartId: n }) {
939
980
  let i = Q();
940
981
  if (e.kind === "thinking" && e.parts) {
941
982
  let r = e.status === "error" || e.status === "stopped" || e.status === "running" && e.parts.length === 0;
942
- return /* @__PURE__ */ A("li", {
983
+ return /* @__PURE__ */ P("li", {
943
984
  className: "text-xs text-muted-foreground",
944
- children: [e.parts.length > 0 && /* @__PURE__ */ k(qe, {
985
+ children: [e.parts.length > 0 && /* @__PURE__ */ N(rt, {
945
986
  entry: e,
946
987
  questions: t,
947
988
  hiddenPartId: n
948
- }), r && /* @__PURE__ */ A("div", {
989
+ }), r && /* @__PURE__ */ P("div", {
949
990
  className: `flex items-start gap-1.5 ${e.parts.length > 0 ? "mt-1" : ""}`,
950
- children: [/* @__PURE__ */ k("span", {
991
+ children: [/* @__PURE__ */ N("span", {
951
992
  className: "pt-px",
952
- children: /* @__PURE__ */ k(ze, { status: e.status })
953
- }), /* @__PURE__ */ k("span", {
993
+ children: /* @__PURE__ */ N(Ye, { status: e.status })
994
+ }), /* @__PURE__ */ N("span", {
954
995
  className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
955
- children: Be(e, i)
996
+ children: Xe(e, i)
956
997
  })]
957
998
  })]
958
999
  });
959
1000
  }
960
- let a = e.kind === "thinking" && e.detail ? Ie(e.detail) : [], o = a.filter((e) => e.type === "code"), s = a.filter((e) => e.type === "text" && e.content.trim()), c = e.kind === "thinking" ? Be(e, i) : e.label;
961
- return /* @__PURE__ */ A("li", {
1001
+ let a = e.kind === "thinking" && e.detail ? Ke(e.detail) : [], o = a.filter((e) => e.type === "code"), s = a.filter((e) => e.type === "text" && e.content.trim()), c = e.kind === "thinking" ? Xe(e, i) : e.label;
1002
+ return /* @__PURE__ */ P("li", {
962
1003
  className: "text-xs text-muted-foreground",
963
1004
  children: [
964
- /* @__PURE__ */ A("div", {
1005
+ /* @__PURE__ */ P("div", {
965
1006
  className: "flex items-start gap-1.5",
966
- children: [/* @__PURE__ */ k("span", {
1007
+ children: [/* @__PURE__ */ N("span", {
967
1008
  className: "pt-px",
968
- children: /* @__PURE__ */ k(ze, { status: e.status })
969
- }), /* @__PURE__ */ k("span", {
1009
+ children: /* @__PURE__ */ N(Ye, { status: e.status })
1010
+ }), /* @__PURE__ */ N("span", {
970
1011
  className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
971
1012
  children: c
972
1013
  })]
973
1014
  }),
974
- o.length > 0 && /* @__PURE__ */ k("div", {
1015
+ o.length > 0 && /* @__PURE__ */ N("div", {
975
1016
  className: "mt-1 ml-[18px] space-y-1",
976
- children: o.map((e, t) => /* @__PURE__ */ k(Le, {
1017
+ children: o.map((e, t) => /* @__PURE__ */ N(qe, {
977
1018
  content: e.content,
978
1019
  language: e.language
979
1020
  }, t))
980
1021
  }),
981
- s.length > 0 && /* @__PURE__ */ k("div", {
1022
+ s.length > 0 && /* @__PURE__ */ N("div", {
982
1023
  className: "mt-1 ml-[18px] space-y-2",
983
- children: s.map((e, t) => /* @__PURE__ */ k(r, {
1024
+ children: s.map((e, t) => /* @__PURE__ */ N(r, {
984
1025
  content: e.content.trim(),
985
1026
  tone: "muted",
986
1027
  className: "break-words text-xs leading-relaxed"
@@ -989,21 +1030,21 @@ function Je({ entry: e, questions: t, hiddenPartId: n }) {
989
1030
  ]
990
1031
  });
991
1032
  }
992
- function Ye({ activity: e, questions: t, docked: n, pinUserMessages: r = !0 }) {
1033
+ function at({ activity: e, questions: t, docked: n, pinUserMessages: r = !0 }) {
993
1034
  if (e.length === 0) return null;
994
1035
  let i = [];
995
1036
  for (let t of e) t.kind === "user" || i.length === 0 ? i.push(t.kind === "user" ? {
996
1037
  user: t,
997
1038
  entries: []
998
1039
  } : { entries: [t] }) : i[i.length - 1].entries.push(t);
999
- return /* @__PURE__ */ k("ul", {
1040
+ return /* @__PURE__ */ N("ul", {
1000
1041
  className: "space-y-0.5",
1001
- children: i.map((e) => /* @__PURE__ */ A("li", { children: [e.user && /* @__PURE__ */ k(He, {
1042
+ children: i.map((e) => /* @__PURE__ */ P("li", { children: [e.user && /* @__PURE__ */ N(Qe, {
1002
1043
  entry: e.user,
1003
1044
  pinned: r
1004
- }), e.entries.length > 0 && /* @__PURE__ */ k("ul", {
1045
+ }), e.entries.length > 0 && /* @__PURE__ */ N("ul", {
1005
1046
  className: "space-y-0.5",
1006
- children: e.entries.map((e) => /* @__PURE__ */ k(Je, {
1047
+ children: e.entries.map((e) => /* @__PURE__ */ N(it, {
1007
1048
  entry: e,
1008
1049
  questions: t,
1009
1050
  hiddenPartId: n?.entry.id === e.id ? n.part.id : void 0
@@ -1013,56 +1054,56 @@ function Ye({ activity: e, questions: t, docked: n, pinUserMessages: r = !0 }) {
1013
1054
  }
1014
1055
  //#endregion
1015
1056
  //#region src/presentation/panelWidth.ts
1016
- var Xe = 420, Ze = 320, Qe = "60vw", $e = "agentico:panel-width";
1017
- function et(e, t) {
1057
+ var ot = 420, st = 320, ct = "60vw", lt = "agentico:panel-width";
1058
+ function ut(e, t) {
1018
1059
  if (typeof e == "number") return e;
1019
1060
  let n = Number.parseFloat(e);
1020
1061
  return Number.isFinite(n) ? Math.round(n / 100 * t) : Infinity;
1021
1062
  }
1022
- function tt(e, t, n) {
1063
+ function dt(e, t, n) {
1023
1064
  return Math.round(Math.min(Math.max(e, t), Math.max(t, n)));
1024
1065
  }
1025
- function nt() {
1066
+ function ft() {
1026
1067
  try {
1027
- let e = window.localStorage.getItem($e), t = e === null ? NaN : Number(e);
1068
+ let e = window.localStorage.getItem(lt), t = e === null ? NaN : Number(e);
1028
1069
  return Number.isFinite(t) && t > 0 ? t : null;
1029
1070
  } catch {
1030
1071
  return null;
1031
1072
  }
1032
1073
  }
1033
- function rt(e) {
1074
+ function pt(e) {
1034
1075
  try {
1035
- e === null ? window.localStorage.removeItem($e) : window.localStorage.setItem($e, String(e));
1076
+ e === null ? window.localStorage.removeItem(lt) : window.localStorage.setItem(lt, String(e));
1036
1077
  } catch {}
1037
1078
  }
1038
- function it() {
1079
+ function mt() {
1039
1080
  return typeof window > "u" ? Infinity : window.innerWidth;
1040
1081
  }
1041
- function at({ defaultWidth: e = 420, minWidth: t = 320, maxWidth: n = Qe, onWidthChange: r }) {
1042
- let [i, a] = D(it), [o, s] = D(() => nt() ?? e);
1043
- C(() => {
1082
+ function ht({ defaultWidth: e = 420, minWidth: t = 320, maxWidth: n = ct, onWidthChange: r }) {
1083
+ let [i, a] = j(mt), [o, s] = j(() => ft() ?? e);
1084
+ D(() => {
1044
1085
  if (typeof window > "u") return;
1045
1086
  let e = () => a(window.innerWidth);
1046
1087
  return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
1047
1088
  }, []);
1048
- let c = t, l = Math.max(c, et(n, i)), u = tt(o, c, l);
1049
- return C(() => {
1089
+ let c = t, l = Math.max(c, ut(n, i)), u = dt(o, c, l);
1090
+ return D(() => {
1050
1091
  r?.(u);
1051
1092
  }, [u]), {
1052
1093
  width: u,
1053
1094
  min: c,
1054
1095
  max: l,
1055
- set: x((e) => s(tt(e, c, l)), [c, l]),
1056
- commit: x((e) => rt(tt(e, c, l)), [c, l]),
1057
- reset: x(() => {
1058
- s(e), rt(null);
1096
+ set: T((e) => s(dt(e, c, l)), [c, l]),
1097
+ commit: T((e) => pt(dt(e, c, l)), [c, l]),
1098
+ reset: T(() => {
1099
+ s(e), pt(null);
1059
1100
  }, [e])
1060
1101
  };
1061
1102
  }
1062
1103
  //#endregion
1063
1104
  //#region src/presentation/AgenticoResizeHandle.tsx
1064
- function ot({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a }) {
1065
- let o = Q(), s = E(null), [c, l] = D(!1), u = (e) => Math.round(Math.min(Math.max(e, t), Math.max(t, n))), d = (e) => {
1105
+ function gt({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a }) {
1106
+ let o = Q(), s = A(null), [c, l] = j(!1), u = (e) => Math.round(Math.min(Math.max(e, t), Math.max(t, n))), d = (e) => {
1066
1107
  let t = s.current;
1067
1108
  if (t && t.pointerId === e.pointerId) {
1068
1109
  s.current = null, l(!1), document.body.style.removeProperty("cursor"), document.body.style.removeProperty("user-select");
@@ -1072,7 +1113,7 @@ function ot({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a })
1072
1113
  i(t.last);
1073
1114
  }
1074
1115
  };
1075
- return /* @__PURE__ */ k("div", {
1116
+ return /* @__PURE__ */ N("div", {
1076
1117
  role: "separator",
1077
1118
  "aria-orientation": "vertical",
1078
1119
  "aria-label": o.resizePanel,
@@ -1111,7 +1152,7 @@ function ot({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a })
1111
1152
  let c = u(s);
1112
1153
  r(c), i(c);
1113
1154
  },
1114
- children: /* @__PURE__ */ k("span", {
1155
+ children: /* @__PURE__ */ N("span", {
1115
1156
  "aria-hidden": !0,
1116
1157
  className: `h-full w-0.5 transition-colors ${c ? "bg-primary" : "bg-transparent group-hover:bg-primary/50 group-focus-visible:bg-primary"}`
1117
1158
  })
@@ -1119,9 +1160,9 @@ function ot({ width: e, min: t, max: n, onResize: r, onCommit: i, onReset: a })
1119
1160
  }
1120
1161
  //#endregion
1121
1162
  //#region src/presentation/AgenticoToggle.tsx
1122
- function st({ className: e = "" }) {
1163
+ function _t({ className: e = "" }) {
1123
1164
  let { isOpen: n, toggleOpen: r, task: i } = $(), a = Q(), o = i?.agent.running ?? !1;
1124
- return /* @__PURE__ */ k(t, {
1165
+ return /* @__PURE__ */ N(t, {
1125
1166
  icon: "bot",
1126
1167
  ariaLabel: n ? a.closePanel : a.openPanel,
1127
1168
  title: n ? a.closePanel : a.openPanel,
@@ -1132,32 +1173,32 @@ function st({ className: e = "" }) {
1132
1173
  }
1133
1174
  //#endregion
1134
1175
  //#region src/presentation/useAIModelCatalog.ts
1135
- var ct = "llmnative-cms.selectedAIModel";
1136
- function lt() {
1176
+ var vt = "llmnative-cms.selectedAIModel";
1177
+ function yt() {
1137
1178
  try {
1138
- return localStorage.getItem(ct) ?? "";
1179
+ return localStorage.getItem(vt) ?? "";
1139
1180
  } catch {
1140
1181
  return "";
1141
1182
  }
1142
1183
  }
1143
- function ut(e) {
1184
+ function bt(e) {
1144
1185
  try {
1145
- e ? localStorage.setItem(ct, e) : localStorage.removeItem(ct);
1186
+ e ? localStorage.setItem(vt, e) : localStorage.removeItem(vt);
1146
1187
  } catch {}
1147
1188
  }
1148
- function dt() {
1149
- let e = _()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = D({}), [i, a] = D(!1), [o, s] = D(lt);
1150
- return C(() => {
1189
+ function xt() {
1190
+ let e = b()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = j({}), [i, a] = j(!1), [o, s] = j(yt);
1191
+ return D(() => {
1151
1192
  if (!t) {
1152
1193
  r({});
1153
1194
  return;
1154
1195
  }
1155
1196
  let n = !1;
1156
- return a(!0), p(e).then((e) => {
1197
+ return a(!0), g(e).then((e) => {
1157
1198
  if (n) return;
1158
1199
  r(e.modelsByProvider);
1159
1200
  let t = Object.values(e.modelsByProvider).flat();
1160
- s((e) => t.some((t) => t.id === e) ? e : (ut(""), ""));
1201
+ s((e) => t.some((t) => t.id === e) ? e : (bt(""), ""));
1161
1202
  }).catch((e) => {
1162
1203
  console.error("useAIModelCatalog: getAIModelCatalog failed", e), n || r({});
1163
1204
  }).finally(() => {
@@ -1171,17 +1212,17 @@ function dt() {
1171
1212
  modelsLoading: i,
1172
1213
  selectedModel: o,
1173
1214
  setSelectedModel: (e) => {
1174
- ut(e), s(e);
1215
+ bt(e), s(e);
1175
1216
  }
1176
1217
  };
1177
1218
  }
1178
1219
  //#endregion
1179
1220
  //#region src/domain/approval.ts
1180
- var ft = "approval";
1181
- function pt(e, t) {
1221
+ var St = "approval";
1222
+ function Ct(e, t) {
1182
1223
  return typeof e.needsApproval == "function" ? e.needsApproval(t) : e.needsApproval === !0;
1183
1224
  }
1184
- function mt(e, t, n) {
1225
+ function wt(e, t, n) {
1185
1226
  let r = e[0]?.values ?? [], i = r.filter((e) => e !== t && e !== n).join(" ").trim();
1186
1227
  return {
1187
1228
  approved: r.includes(t) && !r.includes(n),
@@ -1190,30 +1231,39 @@ function mt(e, t, n) {
1190
1231
  }
1191
1232
  //#endregion
1192
1233
  //#region src/presentation/useAgent.ts
1193
- var ht = 20, gt = 26e4;
1194
- function _t(e) {
1195
- return e.filter((e) => !d.isTextAttachment(e.mimeType) || e.base64.length <= gt);
1234
+ var Tt = 20, Et = 26e4;
1235
+ function Dt(e) {
1236
+ return e.filter((e) => !m.isTextAttachment(e.mimeType) || e.base64.length <= Et);
1196
1237
  }
1197
- function vt(e, t = {}) {
1198
- let { defaultEnabled: n = !1 } = t, [r, i] = D(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: c, setSelectedModel: l } = dt(), [u, f] = D(!1), [p, m] = D(null), [g, v] = D(!1), [y, b] = D([]), x = E([]), S = (e) => {
1199
- b((t) => {
1238
+ function Ot(e, t = {}) {
1239
+ let { defaultEnabled: n = !1 } = t, [r, i] = j(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: c, setSelectedModel: l } = xt(), [u, d] = j(!1), [f, p] = j(null), [h, g] = j(!1), [_, y] = j([]), x = A([]), S = (e) => {
1240
+ y((t) => {
1200
1241
  let n = typeof e == "function" ? e(t) : e;
1201
1242
  return x.current = n, n;
1202
1243
  });
1203
- }, C = E(/* @__PURE__ */ new Map()), w = Q(), T = E(w);
1244
+ }, C = A(/* @__PURE__ */ new Map()), w = Q(), T = A(w);
1204
1245
  T.current = w;
1205
- let O = E(null), k = E(!1), A = E(null), M = () => {
1206
- A.current?.abort();
1207
- }, ee = _()?.registry ?? {}, I = r && c ? h(c) : null, L = I ? ee[I.provider] : null, R = e.executor, z = !!R?.alongside, B = !!R && !z, V = E([]), H = (e) => !!e && V.current.some((t) => t.value === e), W = E(!1), [G, K] = D([]), [q, J] = D(""), te = E(""), X = (e) => {
1208
- te.current = e, J(e);
1209
- }, ne = (e) => {
1210
- let t = R?.models?.(e) ?? [];
1211
- V.current = t, K(t), X(R?.defaultModel?.(e) ?? "");
1212
- }, Z = async (e, t, n, r) => {
1213
- let i = O.current;
1214
- if (!i || !R) return m(T.current.noActiveSession), null;
1246
+ let E = A(null), D = A(!1), O = A(null), M = () => {
1247
+ O.current?.abort();
1248
+ }, N = b()?.registry ?? {}, [P, ee] = j(void 0), z = A(void 0), B = (e, t) => {
1249
+ if (!t) return !1;
1250
+ if (!e) return !0;
1251
+ let n = v(t);
1252
+ return !!n && e.includes(n.provider);
1253
+ }, te = k(() => 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 = B(P, c) ? c : Object.values(te).flat()[0]?.id ?? "", H = r && V ? v(V) : null, U = H ? N[H.provider] : null, W = e.executor, G = !!W?.alongside, q = !!W && !G, ne = A([]), J = (e) => !!e && ne.current.some((t) => t.value === e), Y = A(!1), [re, ie] = j([]), [ae, oe] = j(""), se = A(""), Z = (e) => {
1254
+ se.current = e, oe(e);
1255
+ }, ce = (e) => {
1256
+ let t = W?.models?.(e) ?? [];
1257
+ ne.current = t, ie(t);
1258
+ let n = W?.catalogProviders?.(e);
1259
+ z.current = n, ee(n);
1260
+ let r = G && !B(n, c) ? t[0]?.value : void 0;
1261
+ Z(W?.defaultModel?.(e) ?? r ?? "");
1262
+ }, le = async (e, t, n, r) => {
1263
+ let i = E.current;
1264
+ if (!i || !W) return p(T.current.noActiveSession), null;
1215
1265
  let a = new AbortController();
1216
- A.current = a;
1266
+ O.current = a;
1217
1267
  let o = crypto.randomUUID();
1218
1268
  S((e) => [...e, {
1219
1269
  id: o,
@@ -1228,14 +1278,14 @@ function vt(e, t = {}) {
1228
1278
  duration: e.duration ?? c(e.id)
1229
1279
  }), u = (e, t) => S((n) => n.map((n) => {
1230
1280
  if (n.id !== o) return n;
1231
- let r = e(n.parts ?? []), i = P(r);
1281
+ let r = e(n.parts ?? []), i = L(r);
1232
1282
  return {
1233
1283
  ...n,
1234
1284
  parts: r,
1235
1285
  ...t ? { status: t } : {},
1236
1286
  ...i ? { detail: i } : {}
1237
1287
  };
1238
- })), d = (e) => u((t) => N(t, e, l)), f = !1, p = (e, t) => {
1288
+ })), d = (e) => u((t) => I(t, e, l)), f = !1, m = (e, t) => {
1239
1289
  t?.id && t.id !== "text" && (f = !0), d({
1240
1290
  type: "text",
1241
1291
  id: t?.id ?? "text",
@@ -1280,9 +1330,9 @@ function vt(e, t = {}) {
1280
1330
  });
1281
1331
  }));
1282
1332
  }, x = (e, t) => {
1283
- u((n) => (t && !f ? N(n, {
1333
+ u((n) => (t && !f ? I(n, {
1284
1334
  type: "text",
1285
- id: j,
1335
+ id: F,
1286
1336
  text: t,
1287
1337
  streaming: !1
1288
1338
  }, l) : n).map((t) => t.type === "reasoning" && t.streaming ? l(t) : t.type === "text" && t.streaming ? {
@@ -1296,18 +1346,18 @@ function vt(e, t = {}) {
1296
1346
  _.clear();
1297
1347
  }, w = e || r?.historyText || "";
1298
1348
  try {
1299
- let o = await R.turn({
1349
+ let o = await W.turn({
1300
1350
  params: i.params,
1301
1351
  context: i.context,
1302
1352
  text: e,
1303
1353
  first: t,
1304
1354
  signal: a.signal,
1305
- ...n || te.current ? { model: n || te.current } : {},
1355
+ ...n || se.current ? { model: n || se.current } : {},
1306
1356
  ...r ? { answers: {
1307
1357
  id: r.id,
1308
1358
  answers: r.answers
1309
1359
  } } : {},
1310
- onText: p,
1360
+ onText: m,
1311
1361
  onReasoning: h,
1312
1362
  onStep: g,
1313
1363
  onQuestions: b
@@ -1327,13 +1377,13 @@ function vt(e, t = {}) {
1327
1377
  return i.history = [...i.history, ...w ? [{
1328
1378
  role: "user",
1329
1379
  content: w
1330
- }] : []], a.signal.aborted ? (x("stopped"), null) : (x("error"), m(le(e)), null);
1380
+ }] : []], a.signal.aborted ? (x("stopped"), null) : (x("error"), p(pe(e)), null);
1331
1381
  } finally {
1332
- A.current = null;
1382
+ O.current = null;
1333
1383
  }
1334
- }, re = async (e, t, n) => {
1384
+ }, ue = async (e, t, n) => {
1335
1385
  let r = x.current.find((t) => t.id === e)?.parts?.find((e) => e.type === "questions" && e.id === t);
1336
- if (!r || r.type !== "questions") throw m(T.current.noActiveSession), Error(T.current.noActiveSession);
1386
+ if (!r || r.type !== "questions") throw p(T.current.noActiveSession), Error(T.current.noActiveSession);
1337
1387
  let i = () => S((r) => r.map((r) => r.id === e ? {
1338
1388
  ...r,
1339
1389
  parts: r.parts?.map((e) => e.type === "questions" && e.id === t ? {
@@ -1342,29 +1392,29 @@ function vt(e, t = {}) {
1342
1392
  } : e)
1343
1393
  } : r)), a = `${e}:${t}`, o = C.current.get(a);
1344
1394
  if (o) return C.current.delete(a), i(), o.resolve(n), null;
1345
- if (k.current) throw m(T.current.requestInProgress), Error(T.current.requestInProgress);
1346
- if (!B || !O.current) throw m(T.current.noActiveSession), Error(T.current.noActiveSession);
1347
- k.current = !0, f(!0), m(null), i();
1395
+ if (D.current) throw p(T.current.requestInProgress), Error(T.current.requestInProgress);
1396
+ if (!q || !E.current) throw p(T.current.noActiveSession), Error(T.current.noActiveSession);
1397
+ D.current = !0, d(!0), p(null), i();
1348
1398
  try {
1349
- return await Z("", !1, void 0, {
1399
+ return await le("", !1, void 0, {
1350
1400
  id: t,
1351
1401
  answers: n,
1352
- historyText: F(r.questions, n)
1402
+ historyText: R(r.questions, n)
1353
1403
  });
1354
1404
  } finally {
1355
- k.current = !1, f(!1);
1405
+ D.current = !1, d(!1);
1356
1406
  }
1357
- }, ie = async (t, n, r) => {
1358
- let i = O.current;
1359
- if (!i) return m(T.current.noActiveSession), null;
1360
- let a = r ? h(r) : I, o = a ? ee[a.provider] : null;
1361
- if (!o || !a) return m(T.current.noProviderAvailable), null;
1362
- n?.length && (i.attachmentsRef.current = [...i.attachmentsRef.current ?? [], ...n]);
1363
- let s = (n ?? []).filter((e) => d.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= gt ? `\n\n[File allegato: ${e.name}]\n${d.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(""), c = _t(n ?? []), l = i.tools.map((e) => ({
1407
+ }, de = async (t, n, r) => {
1408
+ let i = z.current, a = Object.values(o).flat().find((e) => !i || i.includes(e.provider))?.id, s = r && B(i, r) ? r : B(i, V) ? void 0 : a, c = E.current;
1409
+ if (!c) return p(T.current.noActiveSession), null;
1410
+ let l = s ? v(s) : H, u = l ? N[l.provider] : null;
1411
+ if (!u || !l) return p(T.current.noProviderAvailable), null;
1412
+ n?.length && (c.attachmentsRef.current = [...c.attachmentsRef.current ?? [], ...n]);
1413
+ let d = (n ?? []).filter((e) => m.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= Et ? `\n\n[File allegato: ${e.name}]\n${m.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(""), f = Dt(n ?? []), h = c.tools.map((e) => ({
1364
1414
  name: e.name,
1365
1415
  description: e.description,
1366
- inputSchema: U(e.inputSchema)
1367
- })), u = (e, t, n, r) => {
1416
+ inputSchema: K(e.inputSchema)
1417
+ })), g = (e, t, n, r) => {
1368
1418
  let i = T.current, a = `approval-${e}`, o = t.describeApproval?.(n) ?? t.describeInvocation?.(n) ?? t.name;
1369
1419
  S((e) => [...e, {
1370
1420
  id: a,
@@ -1373,7 +1423,7 @@ function vt(e, t = {}) {
1373
1423
  status: "running",
1374
1424
  parts: [{
1375
1425
  type: "questions",
1376
- id: ft,
1426
+ id: St,
1377
1427
  questions: [{
1378
1428
  header: i.approvalHeader,
1379
1429
  question: i.approveQuestion.replace("{action}", o),
@@ -1382,10 +1432,10 @@ function vt(e, t = {}) {
1382
1432
  }]
1383
1433
  }]
1384
1434
  }]);
1385
- let s = `${a}:${ft}`;
1435
+ let s = `${a}:${St}`;
1386
1436
  return new Promise((e, t) => {
1387
1437
  let n = () => {
1388
- C.current.delete(s), g(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
1438
+ C.current.delete(s), b(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
1389
1439
  };
1390
1440
  if (r.aborted) {
1391
1441
  n();
@@ -1393,88 +1443,88 @@ function vt(e, t = {}) {
1393
1443
  }
1394
1444
  r.addEventListener("abort", n, { once: !0 }), C.current.set(s, {
1395
1445
  resolve: (t) => {
1396
- r.removeEventListener("abort", n), g(a, "done"), e(mt(t, i.approve, i.reject));
1446
+ r.removeEventListener("abort", n), b(a, "done"), e(wt(t, i.approve, i.reject));
1397
1447
  },
1398
1448
  reject: t
1399
1449
  });
1400
1450
  });
1401
- }, f = new Map(i.tools.map((e) => [e.name, e])), p = new AbortController();
1402
- A.current = p;
1403
- let g = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
1451
+ }, _ = new Map(c.tools.map((e) => [e.name, e])), y = new AbortController();
1452
+ O.current = y;
1453
+ let b = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
1404
1454
  ...i,
1405
1455
  status: t,
1406
1456
  ...n === void 0 ? {} : { detail: n },
1407
1457
  ...r === void 0 ? {} : { toolNames: r }
1408
1458
  } : i));
1409
1459
  try {
1410
- let n = i.history, r = t;
1411
- for (let t = 0; t < ht; t++) {
1412
- let d = crypto.randomUUID();
1460
+ let n = c.history, r = t;
1461
+ for (let t = 0; t < Tt; t++) {
1462
+ let i = crypto.randomUUID();
1413
1463
  S((e) => [...e, {
1414
- id: d,
1464
+ id: i,
1415
1465
  kind: "thinking",
1416
1466
  label: T.current.thinking,
1417
1467
  status: "running"
1418
1468
  }]);
1419
- let h;
1469
+ let a;
1420
1470
  try {
1421
- h = await o.complete({
1471
+ a = await u.complete({
1422
1472
  prompt: r,
1423
- model: a.model,
1473
+ model: l.model,
1424
1474
  history: n,
1425
- tools: l.length ? l : void 0,
1426
- signal: p.signal,
1427
- attachments: t === 0 ? c : void 0,
1428
- logId: i.logId
1475
+ tools: h.length ? h : void 0,
1476
+ signal: y.signal,
1477
+ attachments: t === 0 ? f : void 0,
1478
+ logId: c.logId
1429
1479
  });
1430
1480
  } catch (t) {
1431
- return i.history = [...n, ...r ? [{
1481
+ return c.history = [...n, ...r ? [{
1432
1482
  role: "user",
1433
- content: r + s
1434
- }] : []], p.signal.aborted ? (g(d, "stopped"), e.fallback(i.params, i.context)) : (g(d, "error"), m(le(t)), null);
1483
+ content: r + d
1484
+ }] : []], y.signal.aborted ? (b(i, "stopped"), e.fallback(c.params, c.context)) : (b(i, "error"), p(pe(t)), null);
1435
1485
  }
1436
- if (i.history = [...n, ...r ? [{
1486
+ if (c.history = [...n, ...r ? [{
1437
1487
  role: "user",
1438
- content: r + s
1439
- }] : []], !h) return p.signal.aborted ? (g(d, "stopped"), e.fallback(i.params, i.context)) : (g(d, "error"), m(T.current.noProviderResponse), null);
1440
- if (h.type === "text") return g(d, "done", h.text), e.conversational && h.text.trim() && S((e) => e.map((e) => e.id === d ? {
1488
+ content: r + d
1489
+ }] : []], !a) return y.signal.aborted ? (b(i, "stopped"), e.fallback(c.params, c.context)) : (b(i, "error"), p(T.current.noProviderResponse), null);
1490
+ if (a.type === "text") return b(i, "done", a.text), e.conversational && a.text.trim() && S((e) => e.map((e) => e.id === i ? {
1441
1491
  ...e,
1442
1492
  parts: [{
1443
1493
  type: "text",
1444
1494
  id: "text",
1445
- text: h.text
1495
+ text: a.text
1446
1496
  }]
1447
- } : e)), i.history = [
1497
+ } : e)), c.history = [
1448
1498
  ...n,
1449
1499
  ...r ? [{
1450
1500
  role: "user",
1451
- content: r + s
1501
+ content: r + d
1452
1502
  }] : [],
1453
1503
  {
1454
1504
  role: "assistant",
1455
- content: h.text
1505
+ content: a.text
1456
1506
  }
1457
- ], e.parseResponse(h.text, i.params, i.context) || (console.error("[useAgent] parseResponse ha restituito null — la risposta del modello non è nel formato atteso da questo subagent. Uso il fallback deterministico.", {
1458
- responseLength: h.text.length,
1459
- responsePreview: h.text.length > 2e3 ? `${h.text.slice(0, 1e3)}\n…[troncato qui nel log, ${h.text.length} caratteri totali]…\n${h.text.slice(-1e3)}` : h.text,
1460
- params: i.params
1461
- }), m(T.current.invalidResponse), e.fallback(i.params, i.context));
1462
- let _ = h.toolCalls.map((e) => {
1463
- let t = f.get(e.name);
1507
+ ], e.parseResponse(a.text, c.params, c.context) || (console.error("[useAgent] parseResponse ha restituito null — la risposta del modello non è nel formato atteso da questo subagent. Uso il fallback deterministico.", {
1508
+ responseLength: a.text.length,
1509
+ 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,
1510
+ params: c.params
1511
+ }), p(T.current.invalidResponse), e.fallback(c.params, c.context));
1512
+ let o = a.toolCalls.map((e) => {
1513
+ let t = _.get(e.name);
1464
1514
  return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1465
1515
  });
1466
- g(d, "done", h.text || void 0, h.text ? void 0 : _);
1467
- let v = /* @__PURE__ */ new Map();
1468
- for (let t of h.toolCalls) {
1469
- let n = f.get(t.name);
1470
- if (n && pt(n, t.input)) try {
1471
- v.set(t.id, await u(t.id, n, t.input, p.signal));
1516
+ b(i, "done", a.text || void 0, a.text ? void 0 : o);
1517
+ let s = /* @__PURE__ */ new Map();
1518
+ for (let t of a.toolCalls) {
1519
+ let n = _.get(t.name);
1520
+ if (n && Ct(n, t.input)) try {
1521
+ s.set(t.id, await g(t.id, n, t.input, y.signal));
1472
1522
  } catch {
1473
- return e.fallback(i.params, i.context);
1523
+ return e.fallback(c.params, c.context);
1474
1524
  }
1475
1525
  }
1476
- let y = await Promise.all(h.toolCalls.map(async (e) => {
1477
- let t = f.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = v.get(e.id);
1526
+ let m = await Promise.all(a.toolCalls.map(async (e) => {
1527
+ let t = _.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = s.get(e.id);
1478
1528
  if (r && !r.approved) {
1479
1529
  S((t) => [...t, {
1480
1530
  id: e.id,
@@ -1482,7 +1532,7 @@ function vt(e, t = {}) {
1482
1532
  label: n,
1483
1533
  status: "stopped"
1484
1534
  }]);
1485
- let t = Y().toolRejected.replace("{reason}", r.reason ? ` (${r.reason})` : "");
1535
+ let t = X().toolRejected.replace("{reason}", r.reason ? ` (${r.reason})` : "");
1486
1536
  return {
1487
1537
  toolCallId: e.id,
1488
1538
  name: e.name,
@@ -1495,7 +1545,7 @@ function vt(e, t = {}) {
1495
1545
  kind: "tool",
1496
1546
  label: n,
1497
1547
  status: "running"
1498
- }]), !t) return g(e.id, "error"), {
1548
+ }]), !t) return b(e.id, "error"), {
1499
1549
  toolCallId: e.id,
1500
1550
  name: e.name,
1501
1551
  output: `Tool sconosciuto: ${e.name}`,
@@ -1503,16 +1553,16 @@ function vt(e, t = {}) {
1503
1553
  };
1504
1554
  try {
1505
1555
  let n = await t.execute(e.input);
1506
- return g(e.id, "done"), {
1556
+ return b(e.id, "done"), {
1507
1557
  toolCallId: e.id,
1508
1558
  name: e.name,
1509
1559
  output: n
1510
1560
  };
1511
1561
  } catch (t) {
1512
- return g(e.id, "error"), {
1562
+ return b(e.id, "error"), {
1513
1563
  toolCallId: e.id,
1514
1564
  name: e.name,
1515
- output: le(t),
1565
+ output: pe(t),
1516
1566
  isError: !0
1517
1567
  };
1518
1568
  }
@@ -1521,78 +1571,78 @@ function vt(e, t = {}) {
1521
1571
  ...n,
1522
1572
  ...r ? [{
1523
1573
  role: "user",
1524
- content: r + s
1574
+ content: r + d
1525
1575
  }] : [],
1526
1576
  {
1527
1577
  role: "assistant",
1528
- content: h.text,
1529
- toolCalls: h.toolCalls
1578
+ content: a.text,
1579
+ toolCalls: a.toolCalls
1530
1580
  },
1531
1581
  {
1532
1582
  role: "tool_result",
1533
- results: y
1583
+ results: m
1534
1584
  }
1535
1585
  ], r = "";
1536
1586
  }
1537
- let d = crypto.randomUUID();
1587
+ let i = crypto.randomUUID();
1538
1588
  S((e) => [...e, {
1539
- id: d,
1589
+ id: i,
1540
1590
  kind: "thinking",
1541
1591
  label: T.current.thinking,
1542
1592
  status: "running"
1543
1593
  }]);
1544
- let h;
1594
+ let a;
1545
1595
  try {
1546
- h = await o.complete({
1547
- prompt: ce(Y().stopCallingTools, e.microPromptIds),
1548
- model: a.model,
1596
+ a = await u.complete({
1597
+ prompt: fe(X().stopCallingTools, e.microPromptIds),
1598
+ model: l.model,
1549
1599
  history: n,
1550
- signal: p.signal,
1551
- logId: i.logId
1600
+ signal: y.signal,
1601
+ logId: c.logId
1552
1602
  });
1553
1603
  } catch {
1554
- h = null;
1604
+ a = null;
1555
1605
  }
1556
- if (h?.type === "text") {
1557
- g(d, "done", h.text), i.history = [...n, {
1606
+ if (a?.type === "text") {
1607
+ b(i, "done", a.text), c.history = [...n, {
1558
1608
  role: "assistant",
1559
- content: h.text
1609
+ content: a.text
1560
1610
  }];
1561
- let t = e.parseResponse(h.text, i.params, i.context);
1611
+ let t = e.parseResponse(a.text, c.params, c.context);
1562
1612
  if (t) return t;
1563
- } else g(d, p.signal.aborted ? "stopped" : "error"), i.history = n;
1564
- return p.signal.aborted || m(T.current.tooManyToolTurns), e.fallback(i.params, i.context);
1613
+ } else b(i, y.signal.aborted ? "stopped" : "error"), c.history = n;
1614
+ return y.signal.aborted || p(T.current.tooManyToolTurns), e.fallback(c.params, c.context);
1565
1615
  } finally {
1566
- A.current = null;
1616
+ O.current = null;
1567
1617
  }
1568
- }, ae = async (t, n) => {
1569
- if (k.current) return m(T.current.requestInProgress), null;
1570
- k.current = !0, m(null), S(n?.openingMessage ? [{
1618
+ }, me = async (t, n) => {
1619
+ if (D.current) return p(T.current.requestInProgress), null;
1620
+ D.current = !0, p(null), S(n?.openingMessage ? [{
1571
1621
  id: crypto.randomUUID(),
1572
1622
  kind: "user",
1573
1623
  label: "Tu",
1574
1624
  status: "done",
1575
1625
  detail: n.openingMessage,
1576
1626
  ...n.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
1577
- }] : []), f(!0);
1627
+ }] : []), d(!0);
1578
1628
  try {
1579
1629
  let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
1580
- if (O.current = {
1630
+ if (E.current = {
1581
1631
  params: t,
1582
1632
  context: i,
1583
1633
  tools: o,
1584
1634
  history: [],
1585
1635
  logId: crypto.randomUUID(),
1586
1636
  attachmentsRef: a
1587
- }, B) return v(!0), ne(t), await Z(n?.openingMessage ?? "", !0);
1588
- if (z) {
1589
- ne(t), W.current = !1;
1590
- let e = n?.model || te.current;
1591
- if (H(e)) return v(!0), W.current = !0, await Z(n?.openingMessage ?? "", !0, e);
1637
+ }, q) return g(!0), ce(t), await le(n?.openingMessage ?? "", !0);
1638
+ if (G) {
1639
+ ce(t), Y.current = !1;
1640
+ let e = n?.model || se.current;
1641
+ if (J(e)) return g(!0), Y.current = !0, await le(n?.openingMessage ?? "", !0, e);
1592
1642
  }
1593
- let s = n?.model || void 0, c = s ? !!ee[h(s)?.provider ?? ""] : !!L;
1643
+ let s = n?.model || void 0, c = s ? !!N[v(s)?.provider ?? ""] : !!U;
1594
1644
  if (!r || !c) {
1595
- v(!1);
1645
+ g(!1);
1596
1646
  let n = e.fallback(t, i);
1597
1647
  return S((t) => [...t, {
1598
1648
  id: crypto.randomUUID(),
@@ -1601,41 +1651,41 @@ function vt(e, t = {}) {
1601
1651
  label: e.describeFallback?.(n) ?? T.current.aiDisabledFallback
1602
1652
  }]), n;
1603
1653
  }
1604
- v(!0);
1605
- let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, u = ce(e.buildPrompt(t, i), e.microPromptIds);
1606
- return await ie(u, l, s);
1654
+ g(!0);
1655
+ let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => m.fileToAttachment(e))) : void 0, u = fe(e.buildPrompt(t, i), e.microPromptIds);
1656
+ return await de(u, l, s);
1607
1657
  } catch (e) {
1608
- return m(le(e)), null;
1658
+ return p(pe(e)), null;
1609
1659
  } finally {
1610
- k.current = !1, f(!1);
1660
+ D.current = !1, d(!1);
1611
1661
  }
1612
- }, oe = async (t, n) => {
1613
- if (k.current) {
1614
- m(T.current.requestInProgress);
1662
+ }, he = async (t, n) => {
1663
+ if (D.current) {
1664
+ p(T.current.requestInProgress);
1615
1665
  return;
1616
1666
  }
1617
- k.current = !0, m(null), S(n.activity), f(!0);
1667
+ D.current = !0, p(null), S(n.activity), d(!0);
1618
1668
  try {
1619
1669
  let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
1620
- O.current = {
1670
+ E.current = {
1621
1671
  params: t,
1622
1672
  context: i,
1623
1673
  tools: o,
1624
1674
  history: n.history,
1625
1675
  logId: crypto.randomUUID(),
1626
1676
  attachmentsRef: a
1627
- }, (B || z) && ne(t), W.current = !1, v(B || z || r && !!L);
1677
+ }, (q || G) && ce(t), Y.current = !1, g(q || G || r && !!U);
1628
1678
  } catch (e) {
1629
- m(le(e));
1679
+ p(pe(e));
1630
1680
  } finally {
1631
- k.current = !1, f(!1);
1681
+ D.current = !1, d(!1);
1632
1682
  }
1633
- }, se = async (t, n) => {
1634
- if (k.current) return m(T.current.requestInProgress), null;
1635
- if (m(null), !t.trim()) return m("Messaggio vuoto."), null;
1636
- let r = O.current;
1637
- if (!r) return m(T.current.noActiveSession), null;
1638
- k.current = !0, f(!0), S((e) => [...e, {
1683
+ }, ge = async (t, n) => {
1684
+ if (D.current) return p(T.current.requestInProgress), null;
1685
+ if (p(null), !t.trim()) return p("Messaggio vuoto."), null;
1686
+ let r = E.current;
1687
+ if (!r) return p(T.current.noActiveSession), null;
1688
+ D.current = !0, d(!0), S((e) => [...e, {
1639
1689
  id: crypto.randomUUID(),
1640
1690
  kind: "user",
1641
1691
  label: "Tu",
@@ -1644,23 +1694,23 @@ function vt(e, t = {}) {
1644
1694
  ...n?.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
1645
1695
  }]);
1646
1696
  try {
1647
- if (B) return await Z(t, !1, n?.model || void 0);
1648
- let i = n?.model || (z ? te.current : "");
1649
- if (z && H(i)) {
1650
- let e = !W.current;
1651
- return W.current = !0, await Z(t, e, i);
1697
+ if (q) return await le(t, !1, n?.model || void 0);
1698
+ let i = n?.model || (G ? se.current : "");
1699
+ if (G && J(i)) {
1700
+ let e = !Y.current;
1701
+ return Y.current = !0, await le(t, e, i);
1652
1702
  }
1653
- let a = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, o = ce(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
1654
- return await ie(o, a, n?.model || void 0);
1703
+ let a = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => m.fileToAttachment(e))) : void 0, o = fe(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
1704
+ return await de(o, a, n?.model || void 0);
1655
1705
  } catch (e) {
1656
- return m(le(e)), null;
1706
+ return p(pe(e)), null;
1657
1707
  } finally {
1658
- k.current = !1, f(!1);
1708
+ D.current = !1, d(!1);
1659
1709
  }
1660
- }, ue = () => {
1661
- let t = O.current;
1710
+ }, _e = () => {
1711
+ let t = E.current;
1662
1712
  if (!t) return null;
1663
- m(null);
1713
+ p(null);
1664
1714
  let n = e.fallback(t.params, t.context);
1665
1715
  return S((t) => [...t, {
1666
1716
  id: crypto.randomUUID(),
@@ -1668,56 +1718,56 @@ function vt(e, t = {}) {
1668
1718
  status: "done",
1669
1719
  label: e.describeFallback?.(n) ?? T.current.continueWithoutAiFallback
1670
1720
  }]), n;
1671
- }, de = () => O.current ? {
1672
- history: O.current.history,
1673
- activity: y
1721
+ }, ve = () => E.current ? {
1722
+ history: E.current.history,
1723
+ activity: _
1674
1724
  } : null;
1675
1725
  return {
1676
1726
  enabled: r,
1677
1727
  setEnabled: i,
1678
1728
  hasProviders: a,
1679
- selectedModel: B || z && q ? q : c,
1680
- setSelectedModel: B ? X : z ? (e) => {
1681
- H(e) ? X(e) : (X(""), l(e));
1729
+ selectedModel: q || G && ae ? ae : V,
1730
+ setSelectedModel: q ? Z : G ? (e) => {
1731
+ J(e) ? Z(e) : (Z(""), l(e));
1682
1732
  } : l,
1683
- modelsByProvider: o,
1733
+ modelsByProvider: te,
1684
1734
  modelsLoading: s,
1685
1735
  running: u,
1686
- error: p,
1687
- canContinue: g,
1688
- remote: B,
1689
- remoteModels: G,
1690
- alongside: z,
1691
- ...R?.catalogGroup ? { catalogGroup: R.catalogGroup } : {},
1692
- activity: y,
1693
- run: ae,
1694
- resume: oe,
1695
- sendMessage: se,
1736
+ error: f,
1737
+ canContinue: h,
1738
+ remote: q,
1739
+ remoteModels: re,
1740
+ alongside: G,
1741
+ ...W?.catalogGroup ? { catalogGroup: W.catalogGroup } : {},
1742
+ activity: _,
1743
+ run: me,
1744
+ resume: he,
1745
+ sendMessage: ge,
1696
1746
  stop: M,
1697
- runFallback: ue,
1698
- snapshot: de,
1699
- answerQuestions: re
1747
+ runFallback: _e,
1748
+ snapshot: ve,
1749
+ answerQuestions: ue
1700
1750
  };
1701
1751
  }
1702
1752
  //#endregion
1703
1753
  //#region src/domain/orchestrator/prompt.ts
1704
- function yt() {
1705
- let e = Y();
1754
+ function kt() {
1755
+ let e = X();
1706
1756
  return [e.responseRulesHeading, ...e.responseRules.map((e) => `- ${e}`)].join("\n");
1707
1757
  }
1708
- function bt(e, t, n) {
1709
- let r = Y(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
1758
+ function At(e, t, n) {
1759
+ let r = X(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
1710
1760
  return `${r.orchestratorIntro}
1711
1761
 
1712
1762
  ${r.toolsHeading}
1713
1763
  ${t}
1714
1764
  ${i}
1715
- ${yt()}
1765
+ ${kt()}
1716
1766
 
1717
1767
  ${r.userRequestHeading}
1718
1768
  ${e}`;
1719
1769
  }
1720
- function xt(e, t) {
1770
+ function jt(e, t) {
1721
1771
  return t ? {
1722
1772
  kind: "handoff",
1723
1773
  ...t
@@ -1728,27 +1778,27 @@ function xt(e, t) {
1728
1778
  }
1729
1779
  //#endregion
1730
1780
  //#region src/domain/orchestrator/agenticoOrchestratorAgent.ts
1731
- function St(e) {
1732
- return R().filter((t) => !t.onlyWhenAnchored || e === t.id);
1781
+ function Mt(e) {
1782
+ return V().filter((t) => !t.onlyWhenAnchored || e === t.id);
1733
1783
  }
1734
- function Ct(e) {
1784
+ function Nt(e) {
1735
1785
  return {
1736
1786
  buildContext(e) {
1737
1787
  return {
1738
- cliCatalog: ae(St(e.scopedSubagentId)),
1788
+ cliCatalog: le(Mt(e.scopedSubagentId)),
1739
1789
  handoff: { current: null },
1740
1790
  collected: {}
1741
1791
  };
1742
1792
  },
1743
1793
  buildPrompt({ userGoal: e, pageContext: t }, { cliCatalog: n }) {
1744
- return bt(e, n, t);
1794
+ return At(e, n, t);
1745
1795
  },
1746
1796
  buildFollowUpPrompt(e, t, { cliCatalog: n }) {
1747
- return `${e}\n\n${yt()}\n\n${Y().toolsHeading}\n${n}`;
1797
+ return `${e}\n\n${kt()}\n\n${X().toolsHeading}\n${n}`;
1748
1798
  },
1749
1799
  parseResponse(e, t, n) {
1750
1800
  let r = n.handoff.current;
1751
- return n.handoff.current = null, xt(e, r);
1801
+ return n.handoff.current = null, jt(e, r);
1752
1802
  },
1753
1803
  fallback() {
1754
1804
  return {
@@ -1760,16 +1810,16 @@ function Ct(e) {
1760
1810
  return t.kind === "chat" ? t.message : e.continueWithoutAi;
1761
1811
  },
1762
1812
  getTools(t, n, r) {
1763
- let i = H({
1813
+ let i = G({
1764
1814
  attachmentsRef: r,
1765
1815
  collected: n.collected,
1766
- proxyFetch: g
1767
- }), a = t.scopedSubagentId ? z(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = St(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
1816
+ proxyFetch: y
1817
+ }), a = t.scopedSubagentId ? H(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = Mt(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
1768
1818
  name: `${t.id}_${r.name}`,
1769
1819
  description: `${t.label}: ${r.summary}`,
1770
1820
  inputSchema: r.inputSchema,
1771
- describeInvocation: () => m(e.preparing, { label: t.label }),
1772
- describeIntent: m(e.collecting, { label: t.label }),
1821
+ describeInvocation: () => _(e.preparing, { label: t.label }),
1822
+ describeIntent: _(e.collecting, { label: t.label }),
1773
1823
  async execute(e) {
1774
1824
  let i = t.withCollected ? t.withCollected({ ...e }, n.collected) : e;
1775
1825
  return n.handoff.current = {
@@ -1778,7 +1828,7 @@ function Ct(e) {
1778
1828
  params: i
1779
1829
  }, {
1780
1830
  status: "queued",
1781
- note: m(Y().handoffQueued, { label: t.label })
1831
+ note: _(X().handoffQueued, { label: t.label })
1782
1832
  };
1783
1833
  }
1784
1834
  })));
@@ -1788,22 +1838,22 @@ function Ct(e) {
1788
1838
  }
1789
1839
  //#endregion
1790
1840
  //#region src/presentation/deriveHistoryTitle.ts
1791
- function wt(e, t) {
1841
+ function Pt(e, t) {
1792
1842
  return e.deriveHistoryTitle?.(t) ?? e.label;
1793
1843
  }
1794
1844
  //#endregion
1795
1845
  //#region src/presentation/ResultDestinationPicker.tsx
1796
- function Tt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
1797
- let s = Q(), c = $(), l = c.scope, u = y(), [d, f] = D(null), [p, h] = D(new Set(i ?? [])), [g, _] = D(null), v = ge(), b = /* @__PURE__ */ new Map();
1846
+ function Ft({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
1847
+ let s = Q(), c = $(), l = c.scope, u = C(), [d, f] = j(null), [p, m] = j(new Set(i ?? [])), [h, g] = j(null), v = be(), y = /* @__PURE__ */ new Map();
1798
1848
  e.destinationIds.forEach((e) => {
1799
1849
  let t = v[e];
1800
- t && b.set(e, t);
1801
- }), (o ?? []).forEach((e) => b.set(e.id, e)), b.set(pe.id, pe);
1802
- let x = Array.from(b.values()), S = async (i) => {
1803
- f(i), _(null);
1850
+ t && y.set(e, t);
1851
+ }), (o ?? []).forEach((e) => y.set(e.id, e)), y.set(_e.id, _e);
1852
+ let b = Array.from(y.values()), x = async (i) => {
1853
+ f(i), g(null);
1804
1854
  try {
1805
- let o = b.get(i);
1806
- if (!o) throw Error(m(s.unknownDestination, { id: i }));
1855
+ let o = y.get(i);
1856
+ if (!o) throw Error(_(s.unknownDestination, { id: i }));
1807
1857
  if (i !== "json-export" && !l) throw Error(s.destinationNoScope);
1808
1858
  let d = await o.apply(t, {
1809
1859
  scopeId: l?.id ?? "",
@@ -1811,66 +1861,66 @@ function Tt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
1811
1861
  storageProvider: l?.storageProvider ?? null,
1812
1862
  proxyFetch: u
1813
1863
  }, n);
1814
- h((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, wt(e, n));
1864
+ m((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, Pt(e, n));
1815
1865
  } catch (e) {
1816
- _(e instanceof Error ? e.message : String(e));
1866
+ g(e instanceof Error ? e.message : String(e));
1817
1867
  } finally {
1818
1868
  f(null);
1819
1869
  }
1820
1870
  };
1821
- return /* @__PURE__ */ A("div", {
1871
+ return /* @__PURE__ */ P("div", {
1822
1872
  className: "space-y-2",
1823
1873
  children: [
1824
- /* @__PURE__ */ k("p", {
1874
+ /* @__PURE__ */ N("p", {
1825
1875
  className: "text-xs font-medium text-muted-foreground",
1826
1876
  children: s.destinationPickerTitle
1827
1877
  }),
1828
- /* @__PURE__ */ k("div", {
1878
+ /* @__PURE__ */ N("div", {
1829
1879
  className: "flex flex-wrap gap-2",
1830
- children: x.map((e) => /* @__PURE__ */ k("button", {
1880
+ children: b.map((e) => /* @__PURE__ */ N("button", {
1831
1881
  type: "button",
1832
1882
  disabled: d !== null,
1833
- onClick: () => void S(e.id),
1883
+ onClick: () => void x(e.id),
1834
1884
  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",
1835
1885
  children: d === e.id ? s.destinationApplying : `${p.has(e.id) ? "✓ " : ""}${e.id === "json-export" ? s.exportJson : e.label}`
1836
1886
  }, e.id))
1837
1887
  }),
1838
- g && /* @__PURE__ */ k("p", {
1888
+ h && /* @__PURE__ */ N("p", {
1839
1889
  className: "text-xs text-destructive",
1840
- children: g
1890
+ children: h
1841
1891
  })
1842
1892
  ]
1843
1893
  });
1844
1894
  }
1845
1895
  //#endregion
1846
1896
  //#region src/presentation/reports/subagentReportRegistry.tsx
1847
- var Et = {};
1848
- function Dt(e) {
1849
- Object.assign(Et, e);
1897
+ var It = {};
1898
+ function Lt(e) {
1899
+ Object.assign(It, e);
1850
1900
  }
1851
- function Ot(e) {
1852
- return Et[e];
1901
+ function Rt(e) {
1902
+ return It[e];
1853
1903
  }
1854
1904
  //#endregion
1855
1905
  //#region src/presentation/reports/GenericResultPreview.tsx
1856
- function kt({ result: e }) {
1857
- let [t, n] = D(!1);
1858
- return /* @__PURE__ */ A("div", {
1906
+ function zt({ result: e }) {
1907
+ let [t, n] = j(!1);
1908
+ return /* @__PURE__ */ P("div", {
1859
1909
  className: `relative cursor-pointer rounded-md border border-border/60 ${t ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
1860
1910
  onClick: () => n((e) => !e),
1861
1911
  title: t ? "Clic per comprimere" : "Clic per espandere",
1862
- children: [/* @__PURE__ */ k(s, {
1912
+ children: [/* @__PURE__ */ N(s, {
1863
1913
  language: "json",
1864
1914
  showCopy: t,
1865
1915
  background: "transparent",
1866
1916
  className: "!text-[11px]",
1867
1917
  children: JSON.stringify(e, null, 2)
1868
- }), !t && /* @__PURE__ */ k("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
1918
+ }), !t && /* @__PURE__ */ N("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
1869
1919
  });
1870
1920
  }
1871
1921
  //#endregion
1872
1922
  //#region src/presentation/liveAnchorDestination.ts
1873
- function At(e, t, n) {
1923
+ function Bt(e, t, n) {
1874
1924
  return e.length === 0 ? null : {
1875
1925
  id: "live-component",
1876
1926
  label: "Applica al componente aperto",
@@ -1881,35 +1931,106 @@ function At(e, t, n) {
1881
1931
  }
1882
1932
  //#endregion
1883
1933
  //#region src/presentation/subagentControls.ts
1884
- var jt = {};
1885
- function Mt(e) {
1886
- Object.assign(jt, e);
1934
+ var Vt = {};
1935
+ function Ht(e) {
1936
+ Object.assign(Vt, e);
1887
1937
  }
1888
- function Nt(e) {
1889
- return jt[e];
1938
+ function Ut(e) {
1939
+ return Vt[e];
1890
1940
  }
1891
1941
  //#endregion
1892
- //#region src/presentation/SubagentRunner.tsx
1893
- var Pt = () => ({});
1894
- function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
1895
- let c = vt(e.definition, { defaultEnabled: !0 }), l = $(), u = l.scope, d = y(), f = E(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = D(null), h = (t) => {
1942
+ //#region src/presentation/chatTitles.ts
1943
+ function Wt(e, t = 6e3) {
1944
+ let n = e.filter((e) => (e.kind === "user" || e.kind === "thinking") && e.detail?.trim()).map((e) => `${e.kind === "user" ? "Person" : "Agent"}: ${e.detail.trim()}`).join("\n\n");
1945
+ return n.length > t ? `${n.slice(0, t * .7)}\n\n[…]\n\n${n.slice(-t * .3)}` : n;
1946
+ }
1947
+ function Gt(e) {
1948
+ 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);
1949
+ }
1950
+ function Kt(e, t) {
1951
+ try {
1952
+ return e.definition.executor?.catalogProviders?.(e.toParams(t));
1953
+ } catch {
1954
+ return;
1955
+ }
1956
+ }
1957
+ function qt(e, t, n, r, i) {
1958
+ let a = Kt(e, t), o = (e) => {
1959
+ let t = e ? v(e) : null;
1960
+ return !(!t || !i[t.provider] || a && !a.includes(t.provider));
1961
+ };
1962
+ return o(n) ? n : Object.values(r).flat().map((e) => e.id).find(o);
1963
+ }
1964
+ function Jt(e) {
1965
+ let t = b()?.registry ?? {}, { modelsByProvider: n, selectedModel: r } = xt(), i = A({
1966
+ registry: t,
1967
+ modelsByProvider: n,
1968
+ selectedModel: r
1969
+ });
1970
+ i.current = {
1971
+ registry: t,
1972
+ modelsByProvider: n,
1973
+ selectedModel: r
1974
+ };
1975
+ let a = A(/* @__PURE__ */ new Set()), o = T(async (t, n, r) => {
1976
+ if (!e) return !1;
1977
+ let o = ke(e, t, n), s = H(t), c = `${e}:${t}:${n}`;
1978
+ if (!o || !s?.autoTitle || o.name || !Me(o) || a.current.has(c)) return !1;
1979
+ let { registry: l, modelsByProvider: u, selectedModel: d } = i.current, f = qt(s, o.params, r ?? d, u, l), p = f ? v(f) : null;
1980
+ if (!p) return !1;
1981
+ a.current.add(c);
1982
+ try {
1983
+ let r = await l[p.provider].complete({
1984
+ prompt: X().chatTitle.replace("{chat}", Wt(o.activity)),
1985
+ model: p.model,
1986
+ history: []
1987
+ }), i = r && r.type === "text" ? Gt(r.text) : "";
1988
+ return i ? Ne(e, t, n, i, "model") : !1;
1989
+ } catch {
1990
+ return !1;
1991
+ } finally {
1992
+ a.current.delete(c);
1993
+ }
1994
+ }, [e]), s = Object.keys(n).length > 0;
1995
+ return D(() => {
1996
+ e && s && !Yt.has(e) && (Yt.add(e), (async () => {
1997
+ for (let t of Ie(e)) {
1998
+ let n = H(t.subagentId);
1999
+ if (n?.autoTitle) {
2000
+ if (n.definition.conversational && !Me(t)) {
2001
+ Fe(e, t.subagentId, t.entityId);
2002
+ continue;
2003
+ }
2004
+ t.name || await o(t.subagentId, t.entityId);
2005
+ }
2006
+ }
2007
+ })());
2008
+ }, [
2009
+ e,
2010
+ s,
2011
+ o
2012
+ ]), o;
2013
+ }
2014
+ var Yt = /* @__PURE__ */ new Set(), Xt = () => ({});
2015
+ function Zt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
2016
+ let c = Ot(e.definition, { defaultEnabled: !0 }), l = $(), u = l.scope, d = C(), f = A(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = j(null), h = (t) => {
1896
2017
  e.definition.conversational || m(t);
1897
- }, [g, _] = D([]), [v, b] = D(null), x = Ot(e.id), S = x?.kind === "selection" ? x : null, [w, j] = D(null), M = E(!1), N = E(0), P = E(null);
1898
- p && p !== P.current && (P.current = p, N.current = (r?.length ?? 0) + c.activity.length);
1899
- let F = E(!1), ee = c.remote || !c.hasProviders || c.selectedModel !== "";
1900
- C(() => {
1901
- !M.current && ee && (M.current = !0, a ? c.resume(e.toParams(t), a) : (o && c.setSelectedModel(o), c.run(e.toParams(t), {
2018
+ }, [g, _] = j([]), [v, y] = j(null), b = Rt(e.id), x = b?.kind === "selection" ? b : null, [S, w] = j(null), T = A(!1), E = A(0), O = A(null);
2019
+ p && p !== O.current && (O.current = p, E.current = (r?.length ?? 0) + c.activity.length);
2020
+ let F = A(!1), ee = c.remote || !c.hasProviders || c.selectedModel !== "";
2021
+ D(() => {
2022
+ !T.current && ee && (T.current = !0, a ? c.resume(e.toParams(t), a) : (o && c.setSelectedModel(o), c.run(e.toParams(t), {
1902
2023
  model: o,
1903
2024
  openingMessage: s
1904
2025
  }).then((e) => {
1905
2026
  e && h(e);
1906
2027
  })));
1907
- }, [ee]), C(() => {
2028
+ }, [ee]), D(() => {
1908
2029
  if (!p || !u) return;
1909
- let n = e.autoApplyDestinationIds ?? [], r = l.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = ge();
2030
+ let n = e.autoApplyDestinationIds ?? [], r = l.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = be();
1910
2031
  n.forEach((n) => {
1911
2032
  let a = i[n];
1912
- a && (b(null), a.apply(p, {
2033
+ a && (y(null), a.apply(p, {
1913
2034
  scopeId: u.id,
1914
2035
  dataProvider: u.dataProvider,
1915
2036
  storageProvider: u.storageProvider,
@@ -1918,47 +2039,49 @@ function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1918
2039
  ...t,
1919
2040
  pinnedEntityId: r
1920
2041
  }).then((n) => {
1921
- n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, wt(e, t));
1922
- }).catch((e) => b(e instanceof Error ? e.message : String(e))));
2042
+ n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, Pt(e, t));
2043
+ }).catch((e) => y(e instanceof Error ? e.message : String(e))));
1923
2044
  });
1924
2045
  }, [
1925
2046
  p,
1926
2047
  c.activity,
1927
2048
  u
1928
- ]), C(() => {
1929
- p && S && j(S.defaultSelection(p));
1930
- }, [p, S]);
2049
+ ]), D(() => {
2050
+ p && x && w(x.defaultSelection(p));
2051
+ }, [p, x]);
1931
2052
  let I = (e, t) => {
1932
- j((n) => n && {
2053
+ w((n) => n && {
1933
2054
  ...n,
1934
2055
  [e]: t
1935
2056
  });
1936
- }, L = (e) => h(e), R = T(() => p && S && w ? S.applySelection(p, w) : p, [
2057
+ }, L = (e) => h(e), R = k(() => p && x && S ? x.applySelection(p, S) : p, [
1937
2058
  p,
1938
- S,
1939
- w
1940
- ]), z = T(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), B = T(() => At(z, t, f), [
2059
+ x,
2060
+ S
2061
+ ]), z = k(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), B = k(() => Bt(z, t, f), [
1941
2062
  z,
1942
2063
  t,
1943
2064
  f
1944
- ]), V = T(() => B ? [B, ...n ?? []] : n, [B, n]), H = e.chatEntityId?.(t), U = E(!1);
1945
- C(() => {
2065
+ ]), te = k(() => B ? [B, ...n ?? []] : n, [B, n]), V = e.chatEntityId?.(t), H = Jt(u?.id), U = A(!1);
2066
+ D(() => {
1946
2067
  let n = U.current && !c.running;
1947
- if (U.current = c.running, !n || !H || !u) return;
2068
+ if (U.current = c.running, !n || !V || !u) return;
1948
2069
  let i = c.snapshot();
1949
- i && we({
2070
+ if (!i) return;
2071
+ let a = [...r ?? [], ...i.activity];
2072
+ e.autoTitle && e.definition.conversational && !Me({ activity: a }) || (Ae({
1950
2073
  scopeId: u.id,
1951
2074
  subagentId: e.id,
1952
- entityId: H,
2075
+ entityId: V,
1953
2076
  params: t,
1954
- title: wt(e, t),
2077
+ title: Pt(e, t),
1955
2078
  history: i.history,
1956
- activity: [...r ?? [], ...i.activity]
1957
- });
2079
+ activity: a
2080
+ }), e.autoTitle && H(e.id, V, c.selectedModel));
1958
2081
  }, [c.running]);
1959
2082
  let W = () => {
1960
2083
  F.current = !0, c.running && c.stop(), l.closeTask(f);
1961
- }, G = E(Nt(e.id) ?? Pt).current, K = G({
2084
+ }, G = A(Ut(e.id) ?? Xt).current, K = G({
1962
2085
  params: t,
1963
2086
  taskId: f,
1964
2087
  running: c.running,
@@ -1966,41 +2089,41 @@ function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1966
2089
  }), q = (e) => {
1967
2090
  _((t) => t.includes(e) ? t : [...t, e]);
1968
2091
  };
1969
- return C(() => {
2092
+ return D(() => {
1970
2093
  F.current || l.openTask({
1971
2094
  id: f,
1972
- title: wt(e, t),
2095
+ title: Pt(e, t),
1973
2096
  icon: e.icon,
1974
2097
  agent: c,
1975
2098
  onApplied: (e) => h(e),
1976
2099
  precedingActivity: r,
1977
- panelExtraAnchorIndex: N.current,
2100
+ panelExtraAnchorIndex: E.current,
1978
2101
  onDismiss: W,
1979
- ...H ? { savedToDisk: !0 } : {},
2102
+ ...V ? { savedToDisk: !0 } : {},
1980
2103
  panelActions: K.content,
1981
2104
  composerActions: K.actions,
1982
2105
  composerCommands: K.commands,
1983
- panelExtra: p ? /* @__PURE__ */ A(O, { children: [
1984
- S && w ? /* @__PURE__ */ k(S.Report, {
2106
+ panelExtra: p ? /* @__PURE__ */ P(M, { children: [
2107
+ x && S ? /* @__PURE__ */ N(x.Report, {
1985
2108
  result: p,
1986
- selection: w,
2109
+ selection: S,
1987
2110
  onChange: I
1988
- }) : x?.kind === "editable" ? /* @__PURE__ */ k(x.Report, {
2111
+ }) : b?.kind === "editable" ? /* @__PURE__ */ N(b.Report, {
1989
2112
  result: p,
1990
2113
  onResultChange: L
1991
- }) : /* @__PURE__ */ k(kt, { result: R }),
1992
- v && /* @__PURE__ */ A("p", {
2114
+ }) : /* @__PURE__ */ N(zt, { result: R }),
2115
+ v && /* @__PURE__ */ P("p", {
1993
2116
  className: "text-xs text-destructive",
1994
2117
  children: ["Salvataggio automatico non riuscito: ", v]
1995
2118
  }),
1996
- /* @__PURE__ */ k(Tt, {
2119
+ /* @__PURE__ */ N(Ft, {
1997
2120
  manifest: e,
1998
2121
  result: R,
1999
2122
  meta: t,
2000
2123
  taskId: f,
2001
2124
  initiallyApplied: g,
2002
2125
  onApplied: q,
2003
- extraDestinations: V
2126
+ extraDestinations: te
2004
2127
  })
2005
2128
  ] }) : void 0
2006
2129
  });
@@ -2020,7 +2143,7 @@ function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
2020
2143
  t,
2021
2144
  p,
2022
2145
  R,
2023
- w,
2146
+ S,
2024
2147
  g,
2025
2148
  n,
2026
2149
  r,
@@ -2028,22 +2151,22 @@ function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
2028
2151
  K.content,
2029
2152
  K.actions,
2030
2153
  K.commands
2031
- ]), C(() => () => {
2154
+ ]), D(() => () => {
2032
2155
  l.closeTask(f);
2033
2156
  }, [l.closeTask, f]), null;
2034
2157
  }
2035
2158
  //#endregion
2036
2159
  //#region src/presentation/OrchestratorRunner.tsx
2037
- function It({ userGoal: e }) {
2038
- let t = Q(), n = vt(T(() => Ct({
2160
+ function Qt({ userGoal: e }) {
2161
+ let t = Q(), n = Ot(k(() => Nt({
2039
2162
  unavailable: t.orchestratorUnavailable,
2040
2163
  continueWithoutAi: t.orchestratorContinueWithoutAi,
2041
2164
  preparing: t.orchestratorPreparing,
2042
2165
  collecting: t.orchestratorCollecting
2043
- }), []), { defaultEnabled: !0 }), r = $(), [i, a] = D(null), o = E(!1), s = !n.hasProviders || n.selectedModel !== "", c = E(r.pendingExtraDestinations), l = E(r.pendingAttachments), u = E(r.pendingModel), d = E(r.pendingScopedSubagentId ?? r.scopedSubagentId ?? void 0), f = E(r.pendingCarryOver), p = E(!1), m = (e) => {
2044
- e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask(Me));
2166
+ }), []), { defaultEnabled: !0 }), r = $(), [i, a] = j(null), o = A(!1), s = !n.hasProviders || n.selectedModel !== "", c = A(r.pendingExtraDestinations), l = A(r.pendingAttachments), u = A(r.pendingModel), d = A(r.pendingScopedSubagentId ?? r.scopedSubagentId ?? void 0), f = A(r.pendingCarryOver), p = A(!1), m = (e) => {
2167
+ e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask(He));
2045
2168
  };
2046
- C(() => {
2169
+ D(() => {
2047
2170
  !o.current && s && (o.current = !0, u.current && n.setSelectedModel(u.current), n.run({
2048
2171
  userGoal: e,
2049
2172
  pageContext: r.pageContext,
@@ -2055,9 +2178,9 @@ function It({ userGoal: e }) {
2055
2178
  }).then((e) => {
2056
2179
  e && m(e);
2057
2180
  }));
2058
- }, [s]), C(() => {
2181
+ }, [s]), D(() => {
2059
2182
  p.current || r.openTask({
2060
- id: Me,
2183
+ id: He,
2061
2184
  title: "Agentico",
2062
2185
  icon: "bot",
2063
2186
  agent: n,
@@ -2065,7 +2188,7 @@ function It({ userGoal: e }) {
2065
2188
  scopedSubagentId: d.current,
2066
2189
  precedingActivity: f.current?.activity,
2067
2190
  onDismiss: () => {
2068
- p.current = !0, n.running && n.stop(), r.closeTask(Me);
2191
+ p.current = !0, n.running && n.stop(), r.closeTask(He);
2069
2192
  }
2070
2193
  });
2071
2194
  }, [
@@ -2077,13 +2200,13 @@ function It({ userGoal: e }) {
2077
2200
  n.modelsByProvider,
2078
2201
  n.hasProviders,
2079
2202
  r.openTask
2080
- ]), C(() => () => {
2081
- r.closeTask(Me);
2203
+ ]), D(() => () => {
2204
+ r.closeTask(He);
2082
2205
  }, [r.closeTask]);
2083
- let h = T(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
2206
+ let h = k(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
2084
2207
  if (!i) return null;
2085
- let g = z(i.subagentId);
2086
- return g ? /* @__PURE__ */ k(Ft, {
2208
+ let g = H(i.subagentId);
2209
+ return g ? /* @__PURE__ */ N(Zt, {
2087
2210
  manifest: g,
2088
2211
  params: i.params,
2089
2212
  extraDestinations: c.current,
@@ -2094,8 +2217,8 @@ function It({ userGoal: e }) {
2094
2217
  }
2095
2218
  //#endregion
2096
2219
  //#region src/presentation/ManualEntryRunner.tsx
2097
- function Lt({ manifest: e, extraDestinations: n }) {
2098
- let r = vt(e.definition, { defaultEnabled: !1 }), i = Q(), a = $(), o = E(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = D(null), [l, u] = D([]), d = Ot(e.id), f = d?.kind === "selection" ? d : null, [p, m] = D(null), [h, g] = D(null), _ = E(!1), v = (t) => {
2220
+ function $t({ manifest: e, extraDestinations: n }) {
2221
+ let r = Ot(e.definition, { defaultEnabled: !1 }), i = Q(), a = $(), o = A(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = j(null), [l, u] = j([]), d = Rt(e.id), f = d?.kind === "selection" ? d : null, [p, m] = j(null), [h, g] = j(null), _ = A(!1), v = (t) => {
2099
2222
  if (!e.manualEntry) return;
2100
2223
  let n;
2101
2224
  try {
@@ -2108,7 +2231,7 @@ function Lt({ manifest: e, extraDestinations: n }) {
2108
2231
  e && c(e);
2109
2232
  });
2110
2233
  };
2111
- C(() => {
2234
+ D(() => {
2112
2235
  s && f && m(f.defaultSelection(s));
2113
2236
  }, [s, f]);
2114
2237
  let y = (e, t) => {
@@ -2116,18 +2239,18 @@ function Lt({ manifest: e, extraDestinations: n }) {
2116
2239
  ...n,
2117
2240
  [e]: t
2118
2241
  });
2119
- }, b = (e) => c(e), x = T(() => s && f && p ? f.applySelection(s, p) : s, [
2242
+ }, b = (e) => c(e), x = k(() => s && f && p ? f.applySelection(s, p) : s, [
2120
2243
  s,
2121
2244
  f,
2122
2245
  p
2123
2246
  ]), S = (e) => {
2124
2247
  u((t) => t.includes(e) ? t : [...t, e]);
2125
- }, w = T(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), O = T(() => h ? At(w, h, o) : null, [
2126
- w,
2248
+ }, C = k(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), w = k(() => h ? Bt(C, h, o) : null, [
2249
+ C,
2127
2250
  h,
2128
2251
  o
2129
- ]), j = T(() => O ? [O, ...n ?? []] : n, [O, n]);
2130
- return C(() => {
2252
+ ]), T = k(() => w ? [w, ...n ?? []] : n, [w, n]);
2253
+ return D(() => {
2131
2254
  _.current || a.openTask({
2132
2255
  id: o,
2133
2256
  title: e.label,
@@ -2141,27 +2264,27 @@ function Lt({ manifest: e, extraDestinations: n }) {
2141
2264
  onDismiss: () => {
2142
2265
  _.current = !0, r.running && r.stop(), a.closeTask(o);
2143
2266
  },
2144
- panelExtra: s ? /* @__PURE__ */ A("div", {
2267
+ panelExtra: s ? /* @__PURE__ */ P("div", {
2145
2268
  className: "space-y-2",
2146
2269
  children: [
2147
- f && p ? /* @__PURE__ */ k(f.Report, {
2270
+ f && p ? /* @__PURE__ */ N(f.Report, {
2148
2271
  result: s,
2149
2272
  selection: p,
2150
2273
  onChange: y
2151
- }) : d?.kind === "editable" ? /* @__PURE__ */ k(d.Report, {
2274
+ }) : d?.kind === "editable" ? /* @__PURE__ */ N(d.Report, {
2152
2275
  result: s,
2153
2276
  onResultChange: b
2154
- }) : /* @__PURE__ */ k(kt, { result: x }),
2155
- /* @__PURE__ */ k(Tt, {
2277
+ }) : /* @__PURE__ */ N(zt, { result: x }),
2278
+ /* @__PURE__ */ N(Ft, {
2156
2279
  manifest: e,
2157
2280
  result: x,
2158
2281
  meta: h ?? {},
2159
2282
  taskId: o,
2160
2283
  initiallyApplied: l,
2161
2284
  onApplied: S,
2162
- extraDestinations: j
2285
+ extraDestinations: T
2163
2286
  }),
2164
- r.hasProviders && /* @__PURE__ */ k(t, {
2287
+ r.hasProviders && /* @__PURE__ */ N(t, {
2165
2288
  label: i.resumeWithAi,
2166
2289
  variant: "outline-secondary",
2167
2290
  className: "text-xs",
@@ -2183,13 +2306,13 @@ function Lt({ manifest: e, extraDestinations: n }) {
2183
2306
  p,
2184
2307
  l,
2185
2308
  h
2186
- ]), C(() => () => {
2309
+ ]), D(() => () => {
2187
2310
  a.closeTask(o);
2188
2311
  }, []), null;
2189
2312
  }
2190
2313
  //#endregion
2191
2314
  //#region src/presentation/Agentico.tsx
2192
- function Rt(e, t) {
2315
+ function en(e, t) {
2193
2316
  return Object.values(e).flat().map((e) => {
2194
2317
  let n = t?.(e.provider, e.providerLabel ?? e.provider);
2195
2318
  return {
@@ -2201,8 +2324,8 @@ function Rt(e, t) {
2201
2324
  };
2202
2325
  });
2203
2326
  }
2204
- function zt({ task: e }) {
2205
- let t = Q(), [n, r] = D(""), { agent: i, onApplied: a, manualEntry: s } = e, c = i.running, l = (e) => {
2327
+ function tn({ task: e }) {
2328
+ let t = Q(), [n, r] = j(""), { agent: i, onApplied: a, manualEntry: s } = e, c = i.running, l = (e) => {
2206
2329
  if (r(""), s) {
2207
2330
  s.onSubmit(e.text);
2208
2331
  return;
@@ -2213,8 +2336,8 @@ function zt({ task: e }) {
2213
2336
  }).then((e) => {
2214
2337
  e && a(e);
2215
2338
  });
2216
- }, u = !!s || i.remote && i.remoteModels.length === 0, d = i.alongside && i.remoteModels.some((e) => e.value === i.selectedModel), f = !u && !i.remote && !d && i.hasProviders && !i.selectedModel, p = u ? [] : i.remote ? i.remoteModels : i.alongside ? [...i.remoteModels, ...Rt(i.modelsByProvider, i.catalogGroup)] : Rt(i.modelsByProvider);
2217
- return /* @__PURE__ */ k(o, {
2339
+ }, u = !!s || i.remote && i.remoteModels.length === 0, d = i.alongside && i.remoteModels.some((e) => e.value === i.selectedModel), f = !u && !i.remote && !d && i.hasProviders && !i.selectedModel, p = u ? [] : i.remote ? i.remoteModels : i.alongside ? [...i.remoteModels, ...en(i.modelsByProvider, i.catalogGroup)] : en(i.modelsByProvider);
2340
+ return /* @__PURE__ */ N(o, {
2218
2341
  value: n,
2219
2342
  onChange: r,
2220
2343
  placeholder: s?.prompt ?? t.messagePlaceholder,
@@ -2233,21 +2356,21 @@ function zt({ task: e }) {
2233
2356
  maxHeight: 220
2234
2357
  });
2235
2358
  }
2236
- function Bt() {
2237
- let { startOrchestrator: e } = $(), t = Q(), [n, r] = D(""), { hasProviders: i, modelsByProvider: a, selectedModel: s, setSelectedModel: c } = dt(), l = (t) => {
2359
+ function nn() {
2360
+ let { startOrchestrator: e } = $(), t = Q(), [n, r] = j(""), { hasProviders: i, modelsByProvider: a, selectedModel: s, setSelectedModel: c } = xt(), l = (t) => {
2238
2361
  t.text.trim() && (e(t.text.trim(), {
2239
2362
  attachments: t.files.length > 0 ? t.files : void 0,
2240
2363
  model: t.model || void 0
2241
2364
  }), r(""));
2242
2365
  }, u = i && !s;
2243
- return /* @__PURE__ */ k(o, {
2366
+ return /* @__PURE__ */ N(o, {
2244
2367
  value: n,
2245
2368
  onChange: r,
2246
2369
  placeholder: t.orchestratorStarterPlaceholder,
2247
2370
  disabled: !n.trim() || u,
2248
2371
  onSubmit: l,
2249
2372
  attachments: !0,
2250
- models: Rt(a),
2373
+ models: en(a),
2251
2374
  selectedModel: s,
2252
2375
  onModelChange: c,
2253
2376
  modelPlaceholder: t.selectModelPlaceholder,
@@ -2255,7 +2378,30 @@ function Bt() {
2255
2378
  maxHeight: 220
2256
2379
  });
2257
2380
  }
2258
- function Vt(e, t, n = Date.now()) {
2381
+ function rn({ chat: e, onClose: t }) {
2382
+ let n = Q(), r = x();
2383
+ return /* @__PURE__ */ N(p, {
2384
+ title: n.renameChat,
2385
+ size: "sm",
2386
+ onClose: t,
2387
+ onSave: () => (Ne(e.scopeId, e.subagentId, e.entityId, String(r.record?.title ?? je(e)), "person"), t(), Promise.resolve(!0)),
2388
+ children: /* @__PURE__ */ P(u, {
2389
+ appearance: "empty",
2390
+ controller: r,
2391
+ defaultValues: { title: je(e) },
2392
+ footer: !1,
2393
+ children: [/* @__PURE__ */ N(f, {
2394
+ name: "title",
2395
+ label: n.chatTitleLabel,
2396
+ placeholder: e.title
2397
+ }), /* @__PURE__ */ N("p", {
2398
+ className: "text-xs text-muted-foreground",
2399
+ children: n.chatTitleHint
2400
+ })]
2401
+ })
2402
+ });
2403
+ }
2404
+ function an(e, t, n = Date.now()) {
2259
2405
  let r = Math.round((e - n) / 1e3), i = new Intl.RelativeTimeFormat(t, {
2260
2406
  numeric: "auto",
2261
2407
  style: "short"
@@ -2267,55 +2413,55 @@ function Vt(e, t, n = Date.now()) {
2267
2413
  ]) if (Math.abs(r) >= t) return i.format(Math.round(r / t), e);
2268
2414
  return i.format(0, "minute");
2269
2415
  }
2270
- function Ht({ card: e }) {
2416
+ function on({ card: e }) {
2271
2417
  let t = Q();
2272
- return e.humanSummaryOnly ? /* @__PURE__ */ A("div", {
2418
+ return e.humanSummaryOnly ? /* @__PURE__ */ P("div", {
2273
2419
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2274
- children: [/* @__PURE__ */ A("p", {
2420
+ children: [/* @__PURE__ */ P("p", {
2275
2421
  className: "text-xs font-medium text-foreground",
2276
2422
  children: [
2277
2423
  "\"",
2278
2424
  e.label,
2279
2425
  "\""
2280
2426
  ]
2281
- }), /* @__PURE__ */ k("p", {
2427
+ }), /* @__PURE__ */ N("p", {
2282
2428
  className: "text-xs text-muted-foreground",
2283
2429
  children: e.humanSummary
2284
2430
  })]
2285
- }) : /* @__PURE__ */ A("div", {
2431
+ }) : /* @__PURE__ */ P("div", {
2286
2432
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2287
2433
  children: [
2288
- /* @__PURE__ */ k("p", {
2434
+ /* @__PURE__ */ N("p", {
2289
2435
  className: "text-xs font-medium text-foreground",
2290
- children: m(t.newInstance, { label: e.label })
2436
+ children: _(t.newInstance, { label: e.label })
2291
2437
  }),
2292
- /* @__PURE__ */ k("p", {
2438
+ /* @__PURE__ */ N("p", {
2293
2439
  className: "text-xs text-muted-foreground",
2294
2440
  children: e.humanSummary
2295
2441
  }),
2296
- e.fields.length > 0 && /* @__PURE__ */ k("ul", {
2442
+ e.fields.length > 0 && /* @__PURE__ */ N("ul", {
2297
2443
  className: "space-y-1",
2298
- children: e.fields.map((e) => /* @__PURE__ */ A("li", {
2444
+ children: e.fields.map((e) => /* @__PURE__ */ P("li", {
2299
2445
  className: "flex items-start gap-1.5 text-xs",
2300
- children: [/* @__PURE__ */ k(n, {
2446
+ children: [/* @__PURE__ */ N(n, {
2301
2447
  variant: e.required ? "primary" : "secondary",
2302
2448
  className: "mt-px shrink-0",
2303
2449
  children: e.required ? "richiesto" : "opzionale"
2304
- }), /* @__PURE__ */ A("span", {
2450
+ }), /* @__PURE__ */ P("span", {
2305
2451
  className: "min-w-0",
2306
- children: [/* @__PURE__ */ k("span", {
2452
+ children: [/* @__PURE__ */ N("span", {
2307
2453
  className: "font-mono text-foreground",
2308
2454
  children: e.key
2309
- }), e.humanDescription ? /* @__PURE__ */ A("span", {
2455
+ }), e.humanDescription ? /* @__PURE__ */ P("span", {
2310
2456
  className: "text-muted-foreground",
2311
2457
  children: [" — ", e.humanDescription]
2312
2458
  }) : null]
2313
2459
  })]
2314
2460
  }, e.key))
2315
2461
  }),
2316
- e.example && /* @__PURE__ */ A("p", {
2462
+ e.example && /* @__PURE__ */ P("p", {
2317
2463
  className: "text-xs text-muted-foreground",
2318
- children: ["Esempio: ", /* @__PURE__ */ k("span", {
2464
+ children: ["Esempio: ", /* @__PURE__ */ N("span", {
2319
2465
  className: "font-mono",
2320
2466
  children: e.example
2321
2467
  })]
@@ -2323,41 +2469,43 @@ function Ht({ card: e }) {
2323
2469
  ]
2324
2470
  });
2325
2471
  }
2326
- function Ut({ messages: e }) {
2327
- return /* @__PURE__ */ k("div", {
2472
+ function sn({ messages: e }) {
2473
+ return /* @__PURE__ */ N("div", {
2328
2474
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2329
- children: e.map((e, t) => /* @__PURE__ */ k("p", {
2475
+ children: e.map((e, t) => /* @__PURE__ */ N("p", {
2330
2476
  className: "text-xs text-muted-foreground",
2331
2477
  children: e
2332
2478
  }, t))
2333
2479
  });
2334
2480
  }
2335
- function Wt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2336
- let d = Q(), { locale: f } = v(), [p, m] = D(""), [h, g] = D(0), _ = T(() => r ? Ee(e) : [], [
2481
+ function cn({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2482
+ let u = Q(), { locale: f } = S(), [p, m] = j(""), [h, g] = j(0);
2483
+ D(() => Ee(() => g((e) => e + 1)), []);
2484
+ let _ = k(() => r ? Ie(e) : [], [
2337
2485
  e,
2338
2486
  r,
2339
2487
  h
2340
- ]), y = async (t) => {
2341
- let r = z(t.subagentId), i = await r?.confirmArchive?.(t.entityId, t.params);
2488
+ ]), [v, y] = j(null), b = async (t) => {
2489
+ let r = H(t.subagentId), i = await r?.confirmArchive?.(t.entityId, t.params);
2342
2490
  if (!i || window.confirm(i)) {
2343
2491
  try {
2344
2492
  await r?.onArchive?.(t.entityId, t.params);
2345
2493
  } catch {
2346
2494
  return;
2347
2495
  }
2348
- Te(e, t.subagentId, t.entityId), n === De(t.subagentId, t.entityId) && s(), g((e) => e + 1);
2496
+ Fe(e, t.subagentId, t.entityId), n === Le(t.subagentId, t.entityId) && s(), g((e) => e + 1);
2349
2497
  }
2350
- }, b = T(() => {
2498
+ }, x = k(() => {
2351
2499
  let e = p.trim().toLowerCase();
2352
2500
  return e ? _.filter((t) => {
2353
- let n = z(t.subagentId)?.label ?? t.subagentId;
2354
- return t.title.toLowerCase().includes(e) || n.toLowerCase().includes(e);
2501
+ let n = H(t.subagentId)?.label ?? t.subagentId;
2502
+ return je(t).toLowerCase().includes(e) || n.toLowerCase().includes(e);
2355
2503
  }) : _;
2356
2504
  }, [_, p]);
2357
- return /* @__PURE__ */ k(c, {
2505
+ return /* @__PURE__ */ P(M, { children: [/* @__PURE__ */ N(c, {
2358
2506
  trigger: {
2359
2507
  icon: "history",
2360
- title: d.chatHistory
2508
+ title: u.chatHistory
2361
2509
  },
2362
2510
  triggerClassName: "!h-9 !w-9 !p-0 rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground",
2363
2511
  open: r,
@@ -2365,142 +2513,153 @@ function Wt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
2365
2513
  position: "end",
2366
2514
  strategy: "absolute",
2367
2515
  menuClassName: "w-[380px] max-h-[70vh] overflow-y-auto",
2368
- header: /* @__PURE__ */ A("div", {
2516
+ header: /* @__PURE__ */ P("div", {
2369
2517
  className: "flex items-center gap-2 px-1 pb-1.5",
2370
2518
  children: [
2371
- /* @__PURE__ */ k(u, {
2519
+ /* @__PURE__ */ N(d, {
2372
2520
  name: "search",
2373
2521
  size: 14,
2374
2522
  className: "shrink-0 text-muted-foreground"
2375
2523
  }),
2376
- /* @__PURE__ */ k("input", {
2524
+ /* @__PURE__ */ N("input", {
2377
2525
  autoFocus: !0,
2378
2526
  value: p,
2379
2527
  onChange: (e) => m(e.target.value),
2380
- placeholder: d.searchChats,
2528
+ placeholder: u.searchChats,
2381
2529
  className: "min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
2382
2530
  }),
2383
- /* @__PURE__ */ k(t, {
2531
+ /* @__PURE__ */ N(t, {
2384
2532
  icon: "square-pen",
2385
- ariaLabel: d.newChat,
2386
- title: d.newChat,
2533
+ ariaLabel: u.newChat,
2534
+ title: u.newChat,
2387
2535
  variant: "link",
2388
2536
  className: "shrink-0",
2389
2537
  onClick: o
2390
2538
  })
2391
2539
  ]
2392
2540
  }),
2393
- children: b.length === 0 ? /* @__PURE__ */ k("p", {
2541
+ children: x.length === 0 ? /* @__PURE__ */ N("p", {
2394
2542
  className: "px-2 py-3 text-center text-xs text-muted-foreground",
2395
- children: _.length === 0 ? d.noSavedChats : d.noResults
2396
- }) : b.map((e) => {
2397
- let t = z(e.subagentId), r = n === De(e.subagentId, e.entityId);
2398
- return /* @__PURE__ */ k(l, {
2543
+ children: _.length === 0 ? u.noSavedChats : u.noResults
2544
+ }) : x.map((e) => {
2545
+ let t = H(e.subagentId), r = n === Le(e.subagentId, e.entityId);
2546
+ return /* @__PURE__ */ N(l, {
2399
2547
  icon: r ? "check" : t?.icon ?? "bot",
2400
2548
  className: r ? "bg-accent font-medium" : void 0,
2401
2549
  actions: [{
2550
+ icon: "pencil",
2551
+ label: u.renameChat,
2552
+ onClick: () => {
2553
+ i(!1), y(e);
2554
+ }
2555
+ }, {
2402
2556
  icon: "archive",
2403
- label: d.archiveChat,
2404
- onClick: () => void y(e)
2557
+ label: u.archiveChat,
2558
+ onClick: () => void b(e)
2405
2559
  }],
2406
2560
  onClick: () => a(e.subagentId, e.entityId, e),
2407
- children: /* @__PURE__ */ A("span", {
2561
+ children: /* @__PURE__ */ P("span", {
2408
2562
  className: "flex min-w-0 flex-1 items-center justify-between gap-2",
2409
- children: [/* @__PURE__ */ A("span", {
2563
+ children: [/* @__PURE__ */ P("span", {
2410
2564
  className: "min-w-0 truncate",
2411
2565
  children: [
2412
- /* @__PURE__ */ k("span", {
2566
+ /* @__PURE__ */ N("span", {
2413
2567
  className: "text-muted-foreground",
2414
2568
  children: t?.label ?? e.subagentId
2415
2569
  }),
2416
2570
  " · ",
2417
- e.title || e.entityId
2571
+ je(e)
2418
2572
  ]
2419
- }), /* @__PURE__ */ k("span", {
2573
+ }), /* @__PURE__ */ N("span", {
2420
2574
  className: "shrink-0 text-xs text-muted-foreground",
2421
- title: new Date(e.savedAt).toLocaleString(f),
2422
- children: Vt(e.savedAt, f)
2575
+ title: `${u.chatStarted.replace("{at}", new Date(Pe(e)).toLocaleString(f))} · ${u.chatLastMessage.replace("{at}", new Date(e.savedAt).toLocaleString(f))}`,
2576
+ children: an(Pe(e), f)
2423
2577
  })]
2424
2578
  })
2425
2579
  }, `${e.subagentId}:${e.entityId}`);
2426
2580
  })
2427
- });
2428
- }
2429
- function Gt({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
2430
- let { task: a, isOpen: o, pendingGoal: s, orchestratorRunId: c, pageContext: l, pageContextCard: u, anchoredUserMessages: d, pendingResume: f, resumeRunId: p, dismissForeignTask: m, resumeEntityChat: h, pendingManualEntry: g, manualEntryRunId: _, startManualEntry: v, pendingExtraDestinations: y, pendingResumeWithAI: b, resumeWithAIRunId: x, pendingStart: S, startRunId: w, scope: T } = $(), j = Q(), M = E(null), [N, P] = D(!1), F = at({
2581
+ }), v && /* @__PURE__ */ N(rn, {
2582
+ chat: v,
2583
+ onClose: () => y(null)
2584
+ })] });
2585
+ }
2586
+ function ln({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
2587
+ let { task: a, isOpen: o, pendingGoal: s, orchestratorRunId: c, pageContext: l, pageContextCard: u, anchoredUserMessages: d, pendingResume: f, resumeRunId: p, dismissForeignTask: m, resumeEntityChat: h, pendingManualEntry: g, manualEntryRunId: _, startManualEntry: v, pendingExtraDestinations: y, pendingResumeWithAI: b, resumeWithAIRunId: x, pendingStart: S, startRunId: C, scope: w } = $(), T = Q(), E = A(null), [O, k] = j(!1);
2588
+ Jt(w?.id);
2589
+ let F = ht({
2431
2590
  defaultWidth: e,
2432
2591
  minWidth: n,
2433
2592
  maxWidth: r,
2434
2593
  onWidthChange: i
2435
2594
  }), ee = () => {
2436
- (!a || a.agent.running || a.savedToDisk || window.confirm(j.unsavedConversationConfirm)) && (m(), P(!1));
2437
- }, I = a ? [...a.precedingActivity ?? [], ...a.agent.activity] : [], L = I.length, R = Math.max(0, Math.min(a?.panelExtraAnchorIndex ?? L, L)), B = I.slice(0, R), V = I.slice(R), H = !!(a && !a.agent.running && a.agent.error), U = new Set(a?.agent.activity.map((e) => e.id) ?? []), W = a ? {
2438
- canAnswer: (e) => U.has(e),
2595
+ (!a || a.agent.running || a.savedToDisk || window.confirm(T.unsavedConversationConfirm)) && (m(), k(!1));
2596
+ }, I = a ? [...a.precedingActivity ?? [], ...a.agent.activity] : [], L = I.length, R = Math.max(0, Math.min(a?.panelExtraAnchorIndex ?? L, L)), z = I.slice(0, R), B = I.slice(R), te = !!(a && !a.agent.running && a.agent.error), V = new Set(a?.agent.activity.map((e) => e.id) ?? []), U = a ? {
2597
+ canAnswer: (e) => V.has(e),
2439
2598
  onAnswer: (e, t, n) => a.agent.answerQuestions(e, t, n).then((e) => {
2440
2599
  e && a.onApplied(e);
2441
2600
  })
2442
- } : void 0, G = W ? Ge(I, W.canAnswer) : null, K = a?.id === "agentico-orchestrator" && a.scopedSubagentId ? z(a.scopedSubagentId) : void 0, q = K?.manualEntry ? K : null, J = E(!0);
2443
- C(() => {
2444
- let e = M.current;
2601
+ } : void 0, W = U ? tt(I, U.canAnswer) : null, G = a?.id === "agentico-orchestrator" && a.scopedSubagentId ? H(a.scopedSubagentId) : void 0, K = G?.manualEntry ? G : null, q = A(!0);
2602
+ D(() => {
2603
+ let e = E.current;
2445
2604
  if (!e) return;
2446
2605
  let t = () => {
2447
- J.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
2606
+ q.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
2448
2607
  };
2449
2608
  return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
2450
- }, [a?.id]), C(() => {
2451
- let e = M.current;
2452
- e && (J.current = !0, e.scrollTop = e.scrollHeight);
2609
+ }, [a?.id]), D(() => {
2610
+ let e = E.current;
2611
+ e && (q.current = !0, e.scrollTop = e.scrollHeight);
2453
2612
  }, [a?.id]);
2454
- let te = I.at(-1)?.detail?.length ?? 0;
2455
- C(() => {
2456
- let e = M.current;
2457
- e && J.current && (e.scrollTop = e.scrollHeight);
2613
+ let ne = I.at(-1)?.detail?.length ?? 0;
2614
+ D(() => {
2615
+ let e = E.current;
2616
+ e && q.current && (e.scrollTop = e.scrollHeight);
2458
2617
  }, [
2459
2618
  L,
2460
- H,
2461
- te
2619
+ te,
2620
+ ne
2462
2621
  ]);
2463
- let Y = E(null);
2464
- C(() => {
2465
- let e = M.current, t = Y.current;
2622
+ let J = A(null);
2623
+ D(() => {
2624
+ let e = E.current, t = J.current;
2466
2625
  if (!e || !t || typeof ResizeObserver > "u") return;
2467
2626
  let n = new ResizeObserver(() => {
2468
- J.current && (e.scrollTop = e.scrollHeight);
2627
+ q.current && (e.scrollTop = e.scrollHeight);
2469
2628
  });
2470
2629
  return n.observe(t), () => n.disconnect();
2471
2630
  }, [a?.id, o]);
2472
- let X = s ? /* @__PURE__ */ k(It, { userGoal: s }, c) : null, ne = f ? z(f.subagentId) : void 0, Z = f && ne ? /* @__PURE__ */ k(Ft, {
2473
- manifest: ne,
2631
+ let Y = s ? /* @__PURE__ */ N(Qt, { userGoal: s }, c) : null, re = f ? H(f.subagentId) : void 0, ie = f && re ? /* @__PURE__ */ N(Zt, {
2632
+ manifest: re,
2474
2633
  params: f.snapshot.params,
2475
- taskId: De(f.subagentId, f.entityId),
2634
+ taskId: Le(f.subagentId, f.entityId),
2476
2635
  resumeSeed: {
2477
2636
  history: f.snapshot.history,
2478
2637
  activity: f.snapshot.activity
2479
2638
  }
2480
- }, p) : null, re = g ? z(g.subagentId) : void 0, ie = g && re ? /* @__PURE__ */ k(Lt, {
2481
- manifest: re,
2639
+ }, p) : null, X = g ? H(g.subagentId) : void 0, ae = g && X ? /* @__PURE__ */ N($t, {
2640
+ manifest: X,
2482
2641
  extraDestinations: g.extraDestinations
2483
- }, _) : null, ae = b ? z(b.subagentId) : void 0, oe = b && ae ? /* @__PURE__ */ k(Ft, {
2484
- manifest: ae,
2642
+ }, _) : null, oe = b ? H(b.subagentId) : void 0, se = b && oe ? /* @__PURE__ */ N(Zt, {
2643
+ manifest: oe,
2485
2644
  params: b.params,
2486
2645
  extraDestinations: b.extraDestinations
2487
- }, x) : null, se = S ? z(S.subagentId) : void 0, ce = S && se ? /* @__PURE__ */ k(Ft, {
2488
- manifest: se,
2646
+ }, x) : null, Z = S ? H(S.subagentId) : void 0, ce = S && Z ? /* @__PURE__ */ N(Zt, {
2647
+ manifest: Z,
2489
2648
  params: S.params,
2490
2649
  taskId: S.taskId,
2491
2650
  openingMessage: S.openingMessage
2492
- }, w) : null;
2493
- return o ? /* @__PURE__ */ A(O, { children: [
2494
- X,
2495
- Z,
2651
+ }, C) : null;
2652
+ return o ? /* @__PURE__ */ P(M, { children: [
2653
+ Y,
2496
2654
  ie,
2497
- oe,
2655
+ ae,
2656
+ se,
2498
2657
  ce,
2499
- /* @__PURE__ */ A("div", {
2658
+ /* @__PURE__ */ P("div", {
2500
2659
  style: { width: F.width },
2501
2660
  className: "relative flex h-full shrink-0 flex-col border-l border-border bg-background",
2502
2661
  children: [
2503
- /* @__PURE__ */ k(ot, {
2662
+ /* @__PURE__ */ N(gt, {
2504
2663
  width: F.width,
2505
2664
  min: F.min,
2506
2665
  max: F.max,
@@ -2508,76 +2667,76 @@ function Gt({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2508
2667
  onCommit: F.commit,
2509
2668
  onReset: F.reset
2510
2669
  }),
2511
- /* @__PURE__ */ A("div", {
2670
+ /* @__PURE__ */ P("div", {
2512
2671
  className: "flex min-h-[60px] items-center gap-1 border-b border-border/60 px-4 py-3",
2513
2672
  children: [
2514
- /* @__PURE__ */ k("span", {
2673
+ /* @__PURE__ */ N("span", {
2515
2674
  className: "min-w-0 flex-1 truncate text-lg font-semibold leading-tight",
2516
2675
  children: a ? a.title : "Agentico"
2517
2676
  }),
2518
- T && /* @__PURE__ */ k(Wt, {
2519
- scopeId: T.id,
2677
+ w && /* @__PURE__ */ N(cn, {
2678
+ scopeId: w.id,
2520
2679
  currentTaskId: a?.id ?? null,
2521
- open: N,
2522
- onOpenChange: P,
2680
+ open: O,
2681
+ onOpenChange: k,
2523
2682
  onNewChat: ee,
2524
2683
  onSelect: (e, t, n) => h(e, t, n),
2525
2684
  onArchivedCurrent: m
2526
2685
  }),
2527
- /* @__PURE__ */ k(st, {})
2686
+ /* @__PURE__ */ N(_t, {})
2528
2687
  ]
2529
2688
  }),
2530
- /* @__PURE__ */ k("div", {
2531
- ref: M,
2532
- className: `flex-1 overflow-y-auto px-3 pb-2 ${G ? "min-h-24" : "min-h-0"}`,
2533
- children: /* @__PURE__ */ k("div", {
2534
- ref: Y,
2689
+ /* @__PURE__ */ N("div", {
2690
+ ref: E,
2691
+ className: `flex-1 overflow-y-auto px-3 pb-2 ${W ? "min-h-24" : "min-h-0"}`,
2692
+ children: /* @__PURE__ */ N("div", {
2693
+ ref: J,
2535
2694
  className: "pt-2",
2536
- children: a ? /* @__PURE__ */ A(O, { children: [
2537
- a.manualEntry && I.length === 0 && /* @__PURE__ */ k("p", {
2695
+ children: a ? /* @__PURE__ */ P(M, { children: [
2696
+ a.manualEntry && I.length === 0 && /* @__PURE__ */ N("p", {
2538
2697
  className: "text-xs text-muted-foreground",
2539
2698
  children: a.manualEntry.prompt
2540
2699
  }),
2541
- /* @__PURE__ */ k(Ye, {
2542
- activity: B,
2543
- questions: W,
2544
- docked: G,
2545
- pinUserMessages: !G
2700
+ /* @__PURE__ */ N(at, {
2701
+ activity: z,
2702
+ questions: U,
2703
+ docked: W,
2704
+ pinUserMessages: !W
2546
2705
  }),
2547
- a.panelExtra && /* @__PURE__ */ k("div", {
2706
+ a.panelExtra && /* @__PURE__ */ N("div", {
2548
2707
  className: "mt-3",
2549
2708
  children: a.panelExtra
2550
2709
  }),
2551
- V.length > 0 && /* @__PURE__ */ k(Ye, {
2552
- activity: V,
2553
- questions: W,
2554
- docked: G,
2555
- pinUserMessages: !G
2710
+ B.length > 0 && /* @__PURE__ */ N(at, {
2711
+ activity: B,
2712
+ questions: U,
2713
+ docked: W,
2714
+ pinUserMessages: !W
2556
2715
  }),
2557
- !a.agent.running && a.agent.error && /* @__PURE__ */ A("div", {
2716
+ !a.agent.running && a.agent.error && /* @__PURE__ */ P("div", {
2558
2717
  className: "mt-2 flex items-center gap-2",
2559
2718
  children: [
2560
- /* @__PURE__ */ k("p", {
2719
+ /* @__PURE__ */ N("p", {
2561
2720
  className: "flex-1 text-xs text-destructive",
2562
2721
  children: a.agent.error
2563
2722
  }),
2564
- /* @__PURE__ */ k(t, {
2565
- label: j.retry,
2723
+ /* @__PURE__ */ N(t, {
2724
+ label: T.retry,
2566
2725
  variant: "secondary",
2567
2726
  className: "shrink-0",
2568
2727
  onClick: () => {
2569
- a.agent.sendMessage(j.retryMessage).then((e) => {
2728
+ a.agent.sendMessage(T.retryMessage).then((e) => {
2570
2729
  e && a.onApplied(e);
2571
2730
  });
2572
2731
  }
2573
2732
  }),
2574
- !a.agent.remote && /* @__PURE__ */ k(t, {
2575
- label: j.continueWithoutAi,
2733
+ !a.agent.remote && /* @__PURE__ */ N(t, {
2734
+ label: T.continueWithoutAi,
2576
2735
  variant: "secondary",
2577
2736
  className: "shrink-0",
2578
2737
  onClick: () => {
2579
- if (q) {
2580
- v(q.id, y);
2738
+ if (K) {
2739
+ v(K.id, y);
2581
2740
  return;
2582
2741
  }
2583
2742
  let e = a.agent.runFallback();
@@ -2586,67 +2745,67 @@ function Gt({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2586
2745
  })
2587
2746
  ]
2588
2747
  })
2589
- ] }) : d.length > 0 ? /* @__PURE__ */ k(Ut, { messages: d }) : u ? /* @__PURE__ */ k(Ht, { card: u }) : /* @__PURE__ */ k("p", {
2748
+ ] }) : d.length > 0 ? /* @__PURE__ */ N(sn, { messages: d }) : u ? /* @__PURE__ */ N(on, { card: u }) : /* @__PURE__ */ N("p", {
2590
2749
  className: "text-xs text-muted-foreground",
2591
- children: l ?? j.orchestratorStarterHint
2750
+ children: l ?? T.orchestratorStarterHint
2592
2751
  })
2593
2752
  })
2594
2753
  }),
2595
- a && G ? /* @__PURE__ */ A("section", {
2596
- "aria-label": j.pendingQuestions,
2754
+ a && W ? /* @__PURE__ */ P("section", {
2755
+ "aria-label": T.pendingQuestions,
2597
2756
  className: "flex min-h-0 shrink flex-col border-t border-border/60",
2598
2757
  children: [
2599
- a.panelActions && /* @__PURE__ */ k("div", {
2758
+ a.panelActions && /* @__PURE__ */ N("div", {
2600
2759
  className: "shrink-0 px-4 pt-3",
2601
2760
  children: a.panelActions
2602
2761
  }),
2603
- /* @__PURE__ */ k("div", {
2762
+ /* @__PURE__ */ N("div", {
2604
2763
  className: "min-h-0 overflow-y-auto px-4 py-3",
2605
- children: /* @__PURE__ */ k(Ke, {
2606
- entry: G.entry,
2607
- part: G.part,
2608
- questions: W,
2764
+ children: /* @__PURE__ */ N(nt, {
2765
+ entry: W.entry,
2766
+ part: W.part,
2767
+ questions: U,
2609
2768
  autoFocus: !0
2610
- }, `${G.entry.id}:${G.part.id}`)
2769
+ }, `${W.entry.id}:${W.part.id}`)
2611
2770
  }),
2612
- a.agent.running && /* @__PURE__ */ k("div", {
2771
+ a.agent.running && /* @__PURE__ */ N("div", {
2613
2772
  className: "flex shrink-0 justify-end px-4 pb-3",
2614
- children: /* @__PURE__ */ k(t, {
2773
+ children: /* @__PURE__ */ N(t, {
2615
2774
  icon: "square",
2616
- label: j.stop,
2775
+ label: T.stop,
2617
2776
  variant: "secondary",
2618
2777
  onClick: a.agent.stop
2619
2778
  })
2620
2779
  })
2621
2780
  ]
2622
- }) : /* @__PURE__ */ A("div", {
2781
+ }) : /* @__PURE__ */ P("div", {
2623
2782
  className: "border-t border-border/60 px-4 py-3",
2624
- children: [a?.panelActions && /* @__PURE__ */ k("div", {
2783
+ children: [a?.panelActions && /* @__PURE__ */ N("div", {
2625
2784
  className: "mb-2",
2626
2785
  children: a.panelActions
2627
- }), a ? /* @__PURE__ */ k(zt, { task: a }, a.id) : /* @__PURE__ */ k(Bt, {})]
2786
+ }), a ? /* @__PURE__ */ N(tn, { task: a }, a.id) : /* @__PURE__ */ N(nn, {})]
2628
2787
  })
2629
2788
  ]
2630
2789
  })
2631
- ] }) : /* @__PURE__ */ A(O, { children: [
2632
- X,
2633
- Z,
2790
+ ] }) : /* @__PURE__ */ P(M, { children: [
2791
+ Y,
2634
2792
  ie,
2635
- oe,
2793
+ ae,
2794
+ se,
2636
2795
  ce
2637
2796
  ] });
2638
2797
  }
2639
2798
  //#endregion
2640
2799
  //#region src/presentation/useAgenticoPageContext.ts
2641
- function Kt(e, t) {
2642
- let { setPageContext: n } = $(), r = E(crypto.randomUUID()).current;
2643
- C(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
2800
+ function un(e, t) {
2801
+ let { setPageContext: n } = $(), r = A(crypto.randomUUID()).current;
2802
+ D(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
2644
2803
  }
2645
2804
  //#endregion
2646
2805
  //#region src/presentation/useSubagentComponentContext.ts
2647
- function qt(e, t, n, r, i = !0, a) {
2648
- let { registerComponentAnchor: o } = $(), s = E(crypto.randomUUID()).current, c = E(n);
2649
- c.current = n, C(() => {
2806
+ function dn(e, t, n, r, i = !0, a) {
2807
+ let { registerComponentAnchor: o } = $(), s = A(crypto.randomUUID()).current, c = A(n);
2808
+ c.current = n, D(() => {
2650
2809
  if (i) return o(s, {
2651
2810
  subagentId: e,
2652
2811
  componentKey: t,
@@ -2663,6 +2822,6 @@ function qt(e, t, n, r, i = !0, a) {
2663
2822
  ]);
2664
2823
  }
2665
2824
  //#endregion
2666
- export { Qe as AGENTICO_MAX_WIDTH, Ze as AGENTICO_MIN_WIDTH, Xe as AGENTICO_WIDTH, $e as AGENTICO_WIDTH_STORAGE_KEY, Gt as Agentico, Pe as AgenticoProvider, st as AgenticoToggle, M as DEFAULT_REASONING_PART_ID, j as DEFAULT_TEXT_PART_ID, fe as JSON_EXPORT_DESTINATION_ID, se as MICRO_PROMPT_REGISTRY, Me as ORCHESTRATOR_TASK_ID, oe as SUMMARY_MICRO_PROMPT, Oe as agenticoDe, ke as agenticoEn, Ae as agenticoIt, K as agenticoPromptsEn, q as agenticoPromptsIt, je as agenticoTranslations, ce as applyMicroPrompts, te as configureAgenticoPrompts, ve as configureEntityChatStore, H as createCrossAgentTools, ee as defineSubagent, De as entityChatTaskId, le as extractErrorMessage, ue as extractJsonBlock, z as findSubagentManifest, F as formatQuestionAnswers, Y as getAgenticoPrompts, ge as getDestinationRegistry, Ce as getEntityChat, Nt as getSubagentControls, R as getSubagentRegistry, Ot as getSubagentReport, pe as jsonExportDestination, Ee as listEntityChats, P as messagePartsText, V as registerCrossAgentTools, he as registerDestinations, Mt as registerSubagentControls, Dt as registerSubagentReports, L as registerSubagents, Te as removeEntityChat, ae as renderRegistryCli, ie as renderSubagentCli, X as resetAgenticoPrompts, we as saveEntityChat, U as toJsonSchema, W as toMcpTool, N as upsertMessagePart, vt as useAgent, $ as useAgentico, Q as useAgenticoI18n, Kt as useAgenticoPageContext, qt as useSubagentComponentContext };
2825
+ export { ct as AGENTICO_MAX_WIDTH, st as AGENTICO_MIN_WIDTH, ot as AGENTICO_WIDTH, lt as AGENTICO_WIDTH_STORAGE_KEY, ln as Agentico, We as AgenticoProvider, _t as AgenticoToggle, ee as DEFAULT_REASONING_PART_ID, F as DEFAULT_TEXT_PART_ID, ge as JSON_EXPORT_DESTINATION_ID, de as MICRO_PROMPT_REGISTRY, He as ORCHESTRATOR_TASK_ID, ue as SUMMARY_MICRO_PROMPT, Re as agenticoDe, ze as agenticoEn, Be as agenticoIt, J as agenticoPromptsEn, Y as agenticoPromptsIt, Ve as agenticoTranslations, fe as applyMicroPrompts, Me as chatHasPersonMessage, Pe as chatStartedAt, je as chatTitle, ie as configureAgenticoPrompts, Se as configureEntityChatStore, G as createCrossAgentTools, z as defineSubagent, Le as entityChatTaskId, pe as extractErrorMessage, me as extractJsonBlock, H as findSubagentManifest, R as formatQuestionAnswers, X as getAgenticoPrompts, be as getDestinationRegistry, ke as getEntityChat, Ut as getSubagentControls, V as getSubagentRegistry, Rt as getSubagentReport, _e as jsonExportDestination, Ie as listEntityChats, L as messagePartsText, Ee as onEntityChatsChange, W as registerCrossAgentTools, ye as registerDestinations, Ht as registerSubagentControls, Lt as registerSubagentReports, te as registerSubagents, Fe as removeEntityChat, Ne as renameEntityChat, le as renderRegistryCli, ce as renderSubagentCli, ae as resetAgenticoPrompts, Ae as saveEntityChat, K as toJsonSchema, q as toMcpTool, I as upsertMessagePart, Ot as useAgent, $ as useAgentico, Q as useAgenticoI18n, un as useAgenticoPageContext, dn as useSubagentComponentContext };
2667
2826
 
2668
2827
  //# sourceMappingURL=index.mjs.map