@llmnative/agentico 0.1.0 → 0.3.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,53 +1,72 @@
1
1
  import { zodToJsonSchema as e } from "zod-to-json-schema";
2
- import { ActionButton as t, Badge as n, Chatbot as r, Code as i, Dropdown as a, DropdownItem as o, Icon as s, PromptUtils as c, getAIModelCatalog as l, interpolate as u, parseAIModelRef as d, proxyFetch as f, useAIProviderRegistry as p, useI18n as m, useProxy as h } from "@llmnative/react";
3
- import g, { createContext as _, useCallback as v, useContext as y, useEffect as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
4
- import { Fragment as T, jsx as E, jsxs as D } 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, 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";
5
+ //#region src/domain/messageParts.ts
6
+ var j = "text", M = "reasoning";
7
+ function N(e, t, n) {
8
+ let r = e.findIndex((e) => e.type === t.type && e.id === t.id);
9
+ if (r >= 0) return e.map((e, n) => n === r ? t : e);
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");
11
+ return (t.type === "tool" || t.type === "reasoning") && a >= 0 ? [
12
+ ...i.slice(0, a),
13
+ t,
14
+ ...i.slice(a)
15
+ ] : [...i, t];
16
+ }
17
+ function P(e) {
18
+ return e.filter((e) => e.type === "text").map((e) => e.text).filter(Boolean).join("\n\n");
19
+ }
20
+ function F(e, t) {
21
+ return t.map((t, n) => `${t.header ?? e[n]?.header ?? e[n]?.question ?? t.id ?? `${n + 1}`}: ${t.values.join(", ")}`).join("\n");
22
+ }
23
+ //#endregion
5
24
  //#region src/domain/defineSubagent.ts
6
- function O(e) {
25
+ function I(e) {
7
26
  return e;
8
27
  }
9
28
  //#endregion
10
29
  //#region src/domain/subagentRegistry.ts
11
- var k = [];
12
- function A(e) {
13
- k = e;
30
+ var L = [];
31
+ function R(e) {
32
+ L = e;
14
33
  }
15
- function j() {
16
- return k.length === 0 && typeof console < "u" && console.warn("[agentico] getSubagentRegistry() letto a registro vuoto — registerSubagents() non è ancora stato chiamato?"), k;
34
+ function z() {
35
+ return L.length === 0 && typeof console < "u" && console.warn("[agentico] getSubagentRegistry() letto a registro vuoto — registerSubagents() non è ancora stato chiamato?"), L;
17
36
  }
18
- function M(e) {
19
- return k.find((t) => t.id === e);
37
+ function B(e) {
38
+ return L.find((t) => t.id === e);
20
39
  }
21
40
  //#endregion
22
41
  //#region src/domain/crossAgentTools.ts
23
- var N = [];
24
- function P(...e) {
25
- N = e;
42
+ var V = [];
43
+ function H(...e) {
44
+ V = e;
26
45
  }
27
- function F(e) {
28
- return N.flatMap((t) => t(e));
46
+ function U(e) {
47
+ return V.flatMap((t) => t(e));
29
48
  }
30
49
  //#endregion
31
50
  //#region src/domain/mcpTool.ts
32
- function I(t) {
51
+ function W(t) {
33
52
  let { $schema: n, ...r } = e(t, {
34
53
  target: "jsonSchema7",
35
54
  $refStrategy: "none"
36
55
  });
37
56
  return r;
38
57
  }
39
- function L(e, t, n, r) {
58
+ function G(e, t, n, r) {
40
59
  return {
41
60
  name: e,
42
61
  description: t,
43
- inputSchema: I(n),
44
- ...r ? { outputSchema: I(r) } : {}
62
+ inputSchema: W(n),
63
+ ...r ? { outputSchema: W(r) } : {}
45
64
  };
46
65
  }
47
66
  //#endregion
48
67
  //#region src/domain/subagentUsageCard.ts
49
- function R(e) {
50
- let t = I(e.inputSchema), n = t.properties ?? {}, r = new Set(t.required ?? []);
68
+ function K(e) {
69
+ let t = W(e.inputSchema), n = t.properties ?? {}, r = new Set(t.required ?? []);
51
70
  return Object.entries(n).map(([t, n]) => {
52
71
  let i = typeof n.description == "string" ? n.description : "";
53
72
  return {
@@ -61,7 +80,7 @@ function R(e) {
61
80
  }
62
81
  //#endregion
63
82
  //#region src/domain/prompts.ts
64
- var z = {
83
+ var q = {
65
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.",
66
85
  responseRules: [
67
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.",
@@ -89,7 +108,7 @@ var z = {
89
108
  "block requested above, never before it and never instead of it."
90
109
  ].join(" "),
91
110
  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."
92
- }, B = {
111
+ }, J = {
93
112
  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.",
94
113
  responseRules: [
95
114
  "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.",
@@ -117,26 +136,26 @@ var z = {
117
136
  "richiesto sopra, mai prima e mai al posto suo."
118
137
  ].join(" "),
119
138
  multipleCandidates: "Più subagent sono candidati su questa pagina — chiedi all'utente quale intende se non è chiaro dal suo messaggio, prima di procedere."
120
- }, V = z;
139
+ }, Y = q;
121
140
  function ee(e) {
122
- V = {
123
- ...V,
141
+ Y = {
142
+ ...Y,
124
143
  ...e
125
144
  };
126
145
  }
127
- function H() {
128
- return V;
146
+ function X() {
147
+ return Y;
129
148
  }
130
149
  function te() {
131
- V = z;
150
+ Y = q;
132
151
  }
133
152
  //#endregion
134
153
  //#region src/domain/cli/renderManifestCli.ts
135
154
  function ne(e, t) {
136
155
  return `${e} ${t.map((e) => e.required ? `--${e.key} <${e.type}>` : `[--${e.key} <${e.type}>]`).join(" ")}`.trim();
137
156
  }
138
- function U(e, t) {
139
- let n = R(t), r = ne(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
157
+ function re(e, t) {
158
+ let n = K(t), r = ne(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
140
159
  return [
141
160
  `COMMAND: ${e} ${t.name}`,
142
161
  ` ${t.summary}`,
@@ -148,46 +167,46 @@ function U(e, t) {
148
167
  ...i,
149
168
  "",
150
169
  " OUTPUT",
151
- W(t.describeOutput(), 4),
170
+ ie(t.describeOutput(), 4),
152
171
  (t.example, ""),
153
172
  t.example ? " EXAMPLE" : "",
154
173
  t.example ? ` ${t.example}` : ""
155
174
  ].filter((e) => e !== "").join("\n");
156
175
  }
157
- function W(e, t) {
176
+ function ie(e, t) {
158
177
  let n = " ".repeat(t);
159
178
  return e.split("\n").map((e) => e && n + e).join("\n");
160
179
  }
161
- function re(e) {
180
+ function ae(e) {
162
181
  return [
163
182
  "NAME",
164
183
  ` ${e.id} — ${e.label}`,
165
184
  "",
166
185
  "DESCRIPTION",
167
- W(e.description, 2),
186
+ ie(e.description, 2),
168
187
  "",
169
- ...e.commands.map((t) => U(e.id, t))
188
+ ...e.commands.map((t) => re(e.id, t))
170
189
  ].join("\n");
171
190
  }
172
- function ie(e) {
173
- return e.length === 0 ? H().noToolsAvailable : e.map((e) => `${e.id} [${e.commands.map((e) => e.name).join("|")}] — ${e.label}: ${e.commands.map((e) => e.summary).join(" / ")}`).join("\n");
191
+ function oe(e) {
192
+ 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");
174
193
  }
175
194
  //#endregion
176
195
  //#region src/domain/microPrompts.ts
177
- var ae = {
196
+ var se = {
178
197
  id: "closing-summary",
179
198
  get text() {
180
- return H().closingSummary;
199
+ return X().closingSummary;
181
200
  }
182
- }, oe = { [ae.id]: ae };
183
- function G(e, t) {
201
+ }, ce = { [se.id]: se };
202
+ function le(e, t) {
184
203
  if (!t || t.length === 0) return e;
185
- let n = t.map((e) => oe[e]?.text).filter((e) => !!e);
204
+ let n = t.map((e) => ce[e]?.text).filter((e) => !!e);
186
205
  return n.length === 0 ? e : `${e}\n\n${n.join("\n")}`;
187
206
  }
188
207
  //#endregion
189
208
  //#region src/domain/extractErrorMessage.ts
190
- function K(e) {
209
+ function Z(e) {
191
210
  if (e instanceof Error) return e.message;
192
211
  if (typeof e == "object" && e) {
193
212
  let t = e;
@@ -206,13 +225,13 @@ function K(e) {
206
225
  }
207
226
  //#endregion
208
227
  //#region src/domain/extractJsonBlock.ts
209
- function se(e) {
228
+ function ue(e) {
210
229
  let t = e.match(/```(?:json)?\s*\n?([\s\S]*?)```/i);
211
230
  if (t) return t[1].trim();
212
231
  let n = e.replace(/^```json\s*/i, "").replace(/^```\s*/i, "").replace(/```\s*$/, "").trim();
213
- return ce(n) ?? n;
232
+ return de(n) ?? n;
214
233
  }
215
- function ce(e) {
234
+ function de(e) {
216
235
  let t = e.search(/[{[]/);
217
236
  if (t === -1) return null;
218
237
  let n = e[t], r = n === "{" ? "}" : "]", i = 0, a = !1, o = !1;
@@ -233,8 +252,8 @@ function ce(e) {
233
252
  }
234
253
  //#endregion
235
254
  //#region src/domain/jsonExportDestination.ts
236
- var le = "json-export", q = {
237
- id: le,
255
+ var fe = "json-export", pe = {
256
+ id: fe,
238
257
  label: "Export as JSON",
239
258
  async apply(e) {
240
259
  let t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), n = URL.createObjectURL(t);
@@ -245,23 +264,23 @@ var le = "json-export", q = {
245
264
  URL.revokeObjectURL(n);
246
265
  }
247
266
  }
248
- }, ue = {};
249
- function de(e) {
250
- ue = e;
267
+ }, me = {};
268
+ function he(e) {
269
+ me = e;
251
270
  }
252
- function J() {
271
+ function ge() {
253
272
  return {
254
- [q.id]: q,
255
- ...ue
273
+ [pe.id]: pe,
274
+ ...me
256
275
  };
257
276
  }
258
277
  //#endregion
259
278
  //#region src/domain/entityChatStore.ts
260
- var fe = "llmnative.agentico.entityChat";
261
- function pe(e) {
262
- fe = e.storageKey;
279
+ var _e = "llmnative.agentico.entityChat";
280
+ function ve(e) {
281
+ _e = e.storageKey;
263
282
  }
264
- function me(e) {
283
+ function ye(e) {
265
284
  if (!e || typeof e != "object") return null;
266
285
  let t = e;
267
286
  if (typeof t.entityId != "string") return null;
@@ -273,43 +292,41 @@ function me(e) {
273
292
  scopeId: n
274
293
  };
275
294
  }
276
- function Y() {
295
+ function be() {
277
296
  try {
278
- let e = localStorage.getItem(fe);
297
+ let e = localStorage.getItem(_e);
279
298
  if (!e) return [];
280
299
  let t = JSON.parse(e);
281
- return Array.isArray(t) ? t.map(me).filter((e) => e !== null) : [];
300
+ return Array.isArray(t) ? t.map(ye).filter((e) => e !== null) : [];
282
301
  } catch {
283
302
  return [];
284
303
  }
285
304
  }
286
- function he(e) {
305
+ function xe(e) {
287
306
  try {
288
- localStorage.setItem(fe, JSON.stringify(e));
307
+ localStorage.setItem(_e, JSON.stringify(e));
289
308
  } catch {}
290
309
  }
291
- var X = (e, t, n) => `${e}:${t}:${n}`;
292
- function ge(e, t, n) {
293
- let r = X(e, t, n);
294
- return Y().find((e) => X(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
310
+ var Se = (e, t, n) => `${e}:${t}:${n}`;
311
+ function Ce(e, t, n) {
312
+ let r = Se(e, t, n);
313
+ return be().find((e) => Se(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
295
314
  }
296
- function _e(e) {
297
- let t = X(e.scopeId, e.subagentId, e.entityId), n = Y().filter((e) => X(e.scopeId, e.subagentId, e.entityId) !== t);
315
+ function we(e) {
316
+ let t = Se(e.scopeId, e.subagentId, e.entityId), n = be().filter((e) => Se(e.scopeId, e.subagentId, e.entityId) !== t);
298
317
  n.push({
299
318
  ...e,
300
319
  savedAt: Date.now()
301
- }), he(n);
320
+ }), xe(n);
302
321
  }
303
- function ve(e, t, n) {
304
- let r = X(e, t, n);
305
- he(Y().filter((e) => X(e.scopeId, e.subagentId, e.entityId) !== r));
322
+ function Te(e, t, n) {
323
+ let r = Se(e, t, n);
324
+ xe(be().filter((e) => Se(e.scopeId, e.subagentId, e.entityId) !== r));
306
325
  }
307
- function ye(e) {
308
- return Y().filter((t) => t.scopeId === e).sort((e, t) => t.savedAt - e.savedAt);
326
+ function Ee(e) {
327
+ return be().filter((t) => t.scopeId === e).sort((e, t) => t.savedAt - e.savedAt);
309
328
  }
310
- //#endregion
311
- //#region src/i18n/de.ts
312
- var be = {
329
+ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
313
330
  modelLabel: "Modell",
314
331
  modelsLoading: "Wird geladen…",
315
332
  noModelsAvailable: "Keine Modelle verfügbar",
@@ -339,6 +356,9 @@ var be = {
339
356
  tooManyToolTurns: "Zu viele aufeinanderfolgende Werkzeugaufrufe — das bisher gesammelte deterministische Ergebnis wird verwendet.",
340
357
  aiDisabledFallback: "AI deaktiviert — das deterministische Ergebnis wird verwendet.",
341
358
  continueWithoutAiFallback: "Weiter ohne AI — das deterministische Ergebnis wird verwendet.",
359
+ oneStep: "1 Schritt",
360
+ steps: "{count} Schritte",
361
+ stepsLabel: "Schritte des Agenten",
342
362
  newInstance: "Neue Instanz von \"{label}\"",
343
363
  chatHistory: "Chatverlauf",
344
364
  newChat: "Neuer Chat",
@@ -346,6 +366,7 @@ var be = {
346
366
  messagePlaceholder: "Nachricht schreiben…",
347
367
  unsavedConversationConfirm: "Diese Unterhaltung wurde nicht gespeichert und geht verloren. Fortfahren?",
348
368
  noSavedChats: "Noch keine gespeicherten Chats.",
369
+ archiveChat: "Archivieren",
349
370
  noResults: "Keine Ergebnisse.",
350
371
  retry: "Erneut versuchen",
351
372
  retryMessage: "Erneut versuchen.",
@@ -353,7 +374,7 @@ var be = {
353
374
  resumeWithAi: "Mit AI fortsetzen",
354
375
  openPanel: "Agentenbereich öffnen",
355
376
  closePanel: "Agentenbereich schließen"
356
- }, xe = {
377
+ }, ke = {
357
378
  modelLabel: "Model",
358
379
  modelsLoading: "Loading…",
359
380
  noModelsAvailable: "No models available",
@@ -383,6 +404,9 @@ var be = {
383
404
  tooManyToolTurns: "Too many consecutive tool-calling turns — using the deterministic result collected so far.",
384
405
  aiDisabledFallback: "AI disabled — using the deterministic result.",
385
406
  continueWithoutAiFallback: "Continuing without AI — using the deterministic result.",
407
+ oneStep: "1 step",
408
+ steps: "{count} steps",
409
+ stepsLabel: "Steps of the agent",
386
410
  newInstance: "New \"{label}\" instance",
387
411
  chatHistory: "Chat history",
388
412
  newChat: "New chat",
@@ -390,6 +414,7 @@ var be = {
390
414
  messagePlaceholder: "Write a message…",
391
415
  unsavedConversationConfirm: "This conversation has not been saved and will be lost. Continue?",
392
416
  noSavedChats: "No saved chats yet.",
417
+ archiveChat: "Archive",
393
418
  noResults: "No results.",
394
419
  retry: "Retry",
395
420
  retryMessage: "Retry.",
@@ -397,7 +422,7 @@ var be = {
397
422
  resumeWithAi: "Resume with AI",
398
423
  openPanel: "Open agent panel",
399
424
  closePanel: "Close agent panel"
400
- }, Se = {
425
+ }, Ae = {
401
426
  modelLabel: "Modello",
402
427
  modelsLoading: "Caricamento…",
403
428
  noModelsAvailable: "Nessun modello disponibile",
@@ -427,6 +452,9 @@ var be = {
427
452
  tooManyToolTurns: "Troppi turni di tool-calling consecutivi — uso il risultato deterministico raccolto finora.",
428
453
  aiDisabledFallback: "AI disabilitata — uso il risultato deterministico.",
429
454
  continueWithoutAiFallback: "Continuo senza AI — uso il risultato deterministico.",
455
+ oneStep: "1 passo",
456
+ steps: "{count} passi",
457
+ stepsLabel: "Passi dell'agente",
430
458
  newInstance: "Nuova istanza di \"{label}\"",
431
459
  chatHistory: "Storico chat",
432
460
  newChat: "Nuova chat",
@@ -434,6 +462,7 @@ var be = {
434
462
  messagePlaceholder: "Scrivi un messaggio…",
435
463
  unsavedConversationConfirm: "Questa conversazione non è stata salvata e andrà persa. Continuare?",
436
464
  noSavedChats: "Nessuna chat salvata ancora.",
465
+ archiveChat: "Archivia",
437
466
  noResults: "Nessun risultato.",
438
467
  retry: "Riprova",
439
468
  retryMessage: "Riprova.",
@@ -441,27 +470,27 @@ var be = {
441
470
  resumeWithAi: "Riprendi con AI",
442
471
  openPanel: "Apri pannello agente",
443
472
  closePanel: "Chiudi pannello agente"
444
- }, Ce = {
445
- en: { agentico: xe },
446
- it: { agentico: Se },
447
- de: { agentico: be }
473
+ }, je = {
474
+ en: { agentico: ke },
475
+ it: { agentico: Ae },
476
+ de: { agentico: Oe }
448
477
  };
449
- function Z() {
450
- let { dict: e } = m(), t = e.agentico;
478
+ function Q() {
479
+ let { dict: e } = v(), t = e.agentico;
451
480
  return t ? {
452
- ...xe,
481
+ ...ke,
453
482
  ...t
454
- } : xe;
483
+ } : ke;
455
484
  }
456
485
  //#endregion
457
486
  //#region src/presentation/AgenticoContext.tsx
458
- var Q = "agentico-orchestrator", we = _(null);
459
- function Te({ children: e, scope: t = null }) {
460
- let [n, r] = w(null), i = C(null);
461
- b(() => {
487
+ var Me = "agentico-orchestrator", Ne = b(null);
488
+ function Pe({ children: e, scope: t = null }) {
489
+ let [n, r] = D(null), i = E(null);
490
+ C(() => {
462
491
  i.current = n;
463
492
  }, [n]);
464
- let [a, o] = w(!1), s = v((e) => {
493
+ let [a, o] = D(!1), s = x((e) => {
465
494
  let t = i.current;
466
495
  t && t.id !== e.id && t.onDismiss();
467
496
  let n = t && t.id === e.id && t.savedToDisk && e.savedToDisk === void 0 ? {
@@ -469,10 +498,10 @@ function Te({ children: e, scope: t = null }) {
469
498
  savedToDisk: !0
470
499
  } : e;
471
500
  r(n);
472
- }, []), c = v((e) => {
501
+ }, []), c = x((e) => {
473
502
  r((t) => t && t.id === e ? null : t);
474
- }, []), l = v(() => o((e) => !e), []), u = v(() => o(!0), []), [d, f] = w(null), [p, m] = w(void 0), [h, g] = w(void 0), [_, y] = w(void 0), [x, T] = w(null), [D, O] = w(null), [k, A] = w(void 0), [j, N] = w([]), P = v((e, t, n = null) => {
475
- N((r) => {
503
+ }, []), 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) => {
504
+ M((r) => {
476
505
  let i = r.filter((t) => t.id !== e);
477
506
  return t ? [...i, {
478
507
  id: e,
@@ -480,30 +509,30 @@ function Te({ children: e, scope: t = null }) {
480
509
  card: n
481
510
  }] : i;
482
511
  });
483
- }, []), F = j.length > 0 ? j[j.length - 1] : null, [I, L] = w([]), R = v((e, t) => {
484
- L((n) => {
512
+ }, []), P = j.length > 0 ? j[j.length - 1] : null, [F, I] = D([]), L = x((e, t) => {
513
+ I((n) => {
485
514
  let r = n.filter((t) => t.id !== e);
486
515
  return t ? [...r, {
487
516
  id: e,
488
517
  ...t
489
518
  }] : r;
490
519
  });
491
- }, []), z = S(() => I.map((e) => ({
520
+ }, []), R = T(() => F.map((e) => ({
492
521
  subagentId: e.subagentId,
493
522
  componentKey: e.componentKey,
494
523
  onResult: e.onResult,
495
524
  pinnedEntityId: e.pinnedEntityId
496
- })), [I]), B = S(() => {
525
+ })), [F]), z = T(() => {
497
526
  let e = /* @__PURE__ */ new Map();
498
- for (let t of I) e.set(t.subagentId, {
527
+ for (let t of F) e.set(t.subagentId, {
499
528
  subagentId: t.subagentId,
500
529
  componentKey: t.componentKey,
501
530
  onResult: t.onResult,
502
531
  contextInfo: t.contextInfo
503
532
  });
504
533
  return [...e.values()];
505
- }, [I]), V = S(() => B.map((e) => {
506
- let t = M(e.subagentId)?.componentContexts?.[e.componentKey];
534
+ }, [F]), V = T(() => z.map((e) => {
535
+ let t = B(e.subagentId)?.componentContexts?.[e.componentKey];
507
536
  if (!t) return null;
508
537
  let n = e.contextInfo ? `${t.agenticoHint}\n${e.contextInfo}` : t.agenticoHint;
509
538
  return {
@@ -511,26 +540,26 @@ function Te({ children: e, scope: t = null }) {
511
540
  agenticoHint: n,
512
541
  userMessage: t.userMessage
513
542
  };
514
- }).filter((e) => e !== null), [B]), ee = S(() => V.map((e) => e.userMessage), [V]), te = S(() => {
543
+ }).filter((e) => e !== null), [z]), H = T(() => V.map((e) => e.userMessage), [V]), U = T(() => {
515
544
  if (V.length === 0) return null;
516
545
  if (V.length === 1) return V[0].agenticoHint;
517
546
  let e = V.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
518
- return `${H().multipleCandidates}\n\n${e}`;
519
- }, [V]) ?? F?.text ?? null, ne = V.length > 0 ? null : F?.card ?? null, U = S(() => [...new Set(z.map((e) => e.subagentId))], [z]), W = U.length === 1 ? U[0] : U.length === 0 ? F?.card?.subagentId ?? null : null, re = v((e, t) => {
547
+ return `${X().multipleCandidates}\n\n${e}`;
548
+ }, [V]) ?? P?.text ?? null, W = V.length > 0 ? null : P?.card ?? null, G = T(() => [...new Set(R.map((e) => e.subagentId))], [R]), K = G.length === 1 ? G[0] : G.length === 0 ? P?.card?.subagentId ?? null : null, q = x((e, t) => {
520
549
  u();
521
550
  let n = i.current;
522
551
  if (n?.id === "agentico-orchestrator") return;
523
- let r = W && n?.id.startsWith(`subagent-${W}-`) ? n : void 0;
524
- O(r ? {
552
+ let r = K && n?.id.startsWith(`subagent-${K}-`) ? n : void 0;
553
+ w(r ? {
525
554
  taskId: r.id,
526
555
  activity: [...r.precedingActivity ?? [], ...r.agent.activity]
527
- } : null), f(e), m(t?.extraDestinations), g(t?.attachments), y(t?.model), A(t?.scopedSubagentId), T(crypto.randomUUID());
528
- }, [u, W]), ie = v((e, t, n, a, o, s) => {
556
+ } : null), f(e), m(t?.extraDestinations), g(t?.attachments), v(t?.model), A(t?.scopedSubagentId), b(crypto.randomUUID());
557
+ }, [u, K]), J = x((e, t, n, a, o, s) => {
529
558
  if (!n || !a) return;
530
559
  let c = i.current;
531
560
  if (!c || c.id !== n) return;
532
561
  let l = c.agent.snapshot();
533
- l && (_e({
562
+ l && (we({
534
563
  scopeId: a,
535
564
  subagentId: e,
536
565
  entityId: t,
@@ -542,27 +571,33 @@ function Te({ children: e, scope: t = null }) {
542
571
  ...e,
543
572
  savedToDisk: !0
544
573
  } : e));
545
- }, []), [ae, oe] = w(null), [G, K] = w(null), se = v((e, t, n) => {
546
- u(), oe({
574
+ }, []), [Y, ee] = D(null), [te, ne] = D(null), re = x((e, t, n) => {
575
+ u(), ee({
547
576
  subagentId: e,
548
577
  entityId: t,
549
578
  snapshot: n
550
- }), K(crypto.randomUUID());
551
- }, [u]), [ce, le] = w(null), [q, ue] = w(null), de = v((e, t) => {
552
- u(), c(Q), le({
579
+ }), ne(crypto.randomUUID());
580
+ }, [u]), [ie, ae] = D(null), [oe, se] = D(null), ce = x((e, t) => {
581
+ u(), c(Me), ae({
553
582
  subagentId: e,
554
583
  extraDestinations: t
555
- }), ue(crypto.randomUUID());
556
- }, [u, c]), [J, fe] = w(null), [pe, me] = w(null), Y = v((e, t, n) => {
557
- le(null), fe({
584
+ }), se(crypto.randomUUID());
585
+ }, [u, c]), [le, Z] = D(null), [ue, de] = D(null), fe = x((e, t, n) => {
586
+ ae(null), Z({
558
587
  subagentId: e,
559
588
  params: t,
560
589
  extraDestinations: n
561
- }), me(crypto.randomUUID());
562
- }, []), he = v(() => {
590
+ }), de(crypto.randomUUID());
591
+ }, []), [pe, me] = D(null), [he, ge] = D(null), _e = x((e, t, n) => {
592
+ u(), me({
593
+ subagentId: e,
594
+ params: t,
595
+ ...n
596
+ }), ge(crypto.randomUUID());
597
+ }, [u]), ve = x(() => {
563
598
  let e = i.current;
564
599
  e && e.onDismiss();
565
- }, []), X = S(() => ({
600
+ }, []), ye = T(() => ({
566
601
  scope: t,
567
602
  task: n,
568
603
  isOpen: a,
@@ -570,32 +605,35 @@ function Te({ children: e, scope: t = null }) {
570
605
  closeTask: c,
571
606
  toggleOpen: l,
572
607
  pendingGoal: d,
573
- startOrchestrator: re,
574
- pageContext: te,
575
- pageContextCard: ne,
576
- setPageContext: P,
577
- scopedSubagentId: W,
578
- pendingScopedSubagentId: k,
579
- componentAnchors: z,
580
- anchoredUserMessages: ee,
581
- registerComponentAnchor: R,
608
+ startOrchestrator: q,
609
+ pageContext: U,
610
+ pageContextCard: W,
611
+ setPageContext: N,
612
+ scopedSubagentId: K,
613
+ pendingScopedSubagentId: O,
614
+ componentAnchors: R,
615
+ anchoredUserMessages: H,
616
+ registerComponentAnchor: L,
582
617
  openPanel: u,
583
618
  pendingExtraDestinations: p,
584
619
  pendingAttachments: h,
585
620
  pendingModel: _,
586
- orchestratorRunId: x,
587
- pendingCarryOver: D,
588
- commitEntityChat: ie,
589
- resumeEntityChat: se,
590
- pendingResume: ae,
591
- resumeRunId: G,
592
- dismissForeignTask: he,
593
- pendingManualEntry: ce,
594
- manualEntryRunId: q,
595
- startManualEntry: de,
596
- pendingResumeWithAI: J,
597
- resumeWithAIRunId: pe,
598
- resumeWithAI: Y
621
+ orchestratorRunId: y,
622
+ pendingCarryOver: S,
623
+ commitEntityChat: J,
624
+ resumeEntityChat: re,
625
+ pendingResume: Y,
626
+ resumeRunId: te,
627
+ dismissForeignTask: ve,
628
+ pendingManualEntry: ie,
629
+ manualEntryRunId: oe,
630
+ startManualEntry: ce,
631
+ pendingResumeWithAI: le,
632
+ resumeWithAIRunId: ue,
633
+ resumeWithAI: fe,
634
+ startSubagent: _e,
635
+ pendingStart: pe,
636
+ startRunId: he
599
637
  }), [
600
638
  t,
601
639
  n,
@@ -604,46 +642,49 @@ function Te({ children: e, scope: t = null }) {
604
642
  c,
605
643
  l,
606
644
  d,
607
- re,
608
- te,
609
- ne,
610
- P,
645
+ q,
646
+ U,
611
647
  W,
612
- k,
613
- z,
614
- ee,
648
+ N,
649
+ K,
650
+ O,
615
651
  R,
652
+ H,
653
+ L,
616
654
  u,
617
655
  p,
618
656
  h,
619
657
  _,
620
- x,
621
- D,
658
+ y,
659
+ S,
660
+ J,
661
+ re,
662
+ Y,
663
+ te,
664
+ ve,
622
665
  ie,
623
- se,
624
- ae,
625
- G,
626
- he,
666
+ oe,
627
667
  ce,
628
- q,
629
- de,
630
- J,
668
+ le,
669
+ ue,
670
+ fe,
671
+ _e,
631
672
  pe,
632
- Y
673
+ he
633
674
  ]);
634
- return /* @__PURE__ */ E(we.Provider, {
635
- value: X,
675
+ return /* @__PURE__ */ k(Ne.Provider, {
676
+ value: ye,
636
677
  children: e
637
678
  });
638
679
  }
639
680
  function $() {
640
- let e = y(we);
681
+ let e = S(Ne);
641
682
  if (!e) throw Error("useAgentico must be used inside AgenticoProvider");
642
683
  return e;
643
684
  }
644
685
  //#endregion
645
686
  //#region src/presentation/AgentActivityLog.tsx
646
- function Ee(e) {
687
+ function Fe(e) {
647
688
  let t = e.search(/[{[]/);
648
689
  if (t === -1) return [{
649
690
  type: "text",
@@ -689,132 +730,97 @@ function Ee(e) {
689
730
  language: "json"
690
731
  });
691
732
  let u = e.slice(s + 1);
692
- return u.trim() && l.push(...Ee(u)), l;
733
+ return u.trim() && l.push(...Fe(u)), l;
693
734
  }
694
- function De(e) {
735
+ function Ie(e) {
695
736
  let t = [], n = /```(\w+)?\n?([\s\S]*?)```/g, r = 0, i;
696
- for (; i = n.exec(e);) i.index > r && t.push(...Ee(e.slice(r, i.index))), t.push({
737
+ for (; i = n.exec(e);) i.index > r && t.push(...Fe(e.slice(r, i.index))), t.push({
697
738
  type: "code",
698
739
  content: i[2].replace(/\n$/, ""),
699
740
  language: i[1]
700
741
  }), r = n.lastIndex;
701
- return r < e.length && t.push(...Ee(e.slice(r))), t;
742
+ return r < e.length && t.push(...Fe(e.slice(r))), t;
702
743
  }
703
- function Oe({ content: e, language: t }) {
704
- let [n, r] = w(!1);
705
- return /* @__PURE__ */ D("div", {
744
+ function Le({ content: e, language: t }) {
745
+ let [n, r] = D(!1);
746
+ return /* @__PURE__ */ A("div", {
706
747
  className: `relative cursor-pointer rounded-md ${n ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
707
748
  onClick: () => r((e) => !e),
708
749
  title: n ? "Clic per comprimere" : "Clic per espandere",
709
- children: [/* @__PURE__ */ E(i, {
750
+ children: [/* @__PURE__ */ k(s, {
710
751
  language: t,
711
752
  showCopy: n,
712
753
  background: "transparent",
713
754
  className: "!text-[11px]",
714
755
  children: e
715
- }), !n && /* @__PURE__ */ E("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
756
+ }), !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" })]
716
757
  });
717
758
  }
718
- function ke(e) {
719
- let t = [], n = /\*\*(.+?)\*\*|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)/g, r = 0, i;
720
- for (; i = n.exec(e);) i.index > r && t.push({
721
- type: "text",
722
- content: e.slice(r, i.index)
723
- }), i[1] === void 0 ? i[2] === void 0 ? i[3] !== void 0 && t.push({
724
- type: "link",
725
- content: i[3],
726
- href: i[4]
727
- }) : t.push({
728
- type: "code",
729
- content: i[2]
730
- }) : t.push({
731
- type: "bold",
732
- content: i[1]
733
- }), r = n.lastIndex;
734
- return r < e.length && t.push({
735
- type: "text",
736
- content: e.slice(r)
737
- }), t;
738
- }
739
- function Ae({ text: e }) {
740
- return /* @__PURE__ */ E(T, { children: ke(e).map((e, t) => e.type === "bold" ? /* @__PURE__ */ E("strong", {
741
- className: "font-semibold text-foreground",
742
- children: e.content
743
- }, t) : e.type === "code" ? /* @__PURE__ */ E("code", {
744
- className: "rounded bg-muted px-1 py-0.5 font-mono text-[11px] break-words",
745
- children: e.content
746
- }, t) : e.type === "link" ? /* @__PURE__ */ E("a", {
747
- href: e.href,
748
- target: "_blank",
749
- rel: "noreferrer",
750
- className: "text-primary underline underline-offset-2",
751
- children: e.content
752
- }, t) : /* @__PURE__ */ E(g.Fragment, { children: e.content }, t)) });
753
- }
754
- function je({ text: e }) {
755
- let t = De(e);
756
- return /* @__PURE__ */ E(T, { children: t.map((e, t) => e.type === "code" ? /* @__PURE__ */ E(Oe, {
759
+ function Re({ text: e, tone: t }) {
760
+ let n = Ie(e);
761
+ return /* @__PURE__ */ k(O, { children: n.map((e, n) => e.type === "code" ? /* @__PURE__ */ k(Le, {
757
762
  content: e.content,
758
763
  language: e.language
759
- }, t) : e.content.trim() && /* @__PURE__ */ E("p", {
760
- className: "whitespace-pre-wrap break-words",
761
- children: /* @__PURE__ */ E(Ae, { text: e.content })
762
- }, t)) });
763
- }
764
- function Me({ status: e }) {
765
- return e === "running" ? /* @__PURE__ */ E("span", { className: "inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" }) : e === "done" ? /* @__PURE__ */ E(s, {
764
+ }, n) : e.content.trim() && /* @__PURE__ */ k(r, {
765
+ content: e.content.trim(),
766
+ tone: t,
767
+ className: "break-words text-xs leading-relaxed"
768
+ }, n)) });
769
+ }
770
+ function ze({ status: e }) {
771
+ 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, {
766
772
  name: "check",
767
773
  size: 12,
768
774
  className: "shrink-0 text-green-600"
769
- }) : e === "stopped" ? /* @__PURE__ */ E(s, {
775
+ }) : e === "stopped" ? /* @__PURE__ */ k(u, {
770
776
  name: "circle-slash",
771
777
  size: 12,
772
778
  className: "shrink-0 text-muted-foreground"
773
- }) : /* @__PURE__ */ E(s, {
779
+ }) : /* @__PURE__ */ k(u, {
774
780
  name: "x",
775
781
  size: 12,
776
782
  className: "shrink-0 text-destructive"
777
783
  });
778
784
  }
779
- function Ne(e, t) {
785
+ function Be(e, t) {
780
786
  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;
781
787
  }
782
- var Pe = 96;
783
- function Fe({ entry: e }) {
784
- let t = C(null), [n, r] = w(!1), [i, a] = w(!1);
785
- x(() => {
788
+ var Ve = 96;
789
+ function He({ entry: e }) {
790
+ let t = E(null), [n, r] = D(!1), [i, a] = D(!1);
791
+ w(() => {
786
792
  let e = t.current;
787
793
  e && a(e.scrollHeight > 97);
788
794
  }, [e.detail, e.attachmentNames]);
789
795
  let o = i && !n;
790
- return /* @__PURE__ */ E("li", {
791
- className: "sticky top-0 z-10 flex justify-end border-b border-border/40 bg-background py-1.5",
792
- children: /* @__PURE__ */ D("div", {
796
+ return /* @__PURE__ */ k("div", {
797
+ className: "sticky top-0 z-20 flex justify-end border-b border-border/40 bg-background py-1.5",
798
+ children: /* @__PURE__ */ A("div", {
793
799
  className: "max-w-[85%] rounded-lg bg-primary/10 text-xs text-foreground",
794
- children: [/* @__PURE__ */ D("div", {
800
+ children: [/* @__PURE__ */ A("div", {
795
801
  ref: t,
796
802
  className: `space-y-1 px-2.5 pt-1.5 ${o ? "overflow-hidden" : ""}`,
797
- style: o ? { maxHeight: Pe } : void 0,
798
- children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ E("div", {
803
+ style: o ? { maxHeight: Ve } : void 0,
804
+ children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ k("div", {
799
805
  className: "flex flex-wrap gap-1",
800
- children: e.attachmentNames.map((e, t) => /* @__PURE__ */ D("span", {
806
+ children: e.attachmentNames.map((e, t) => /* @__PURE__ */ A("span", {
801
807
  className: "inline-flex items-center gap-1 rounded-md bg-primary/15 px-1.5 py-0.5 text-[11px] text-foreground",
802
- children: [/* @__PURE__ */ E(s, {
808
+ children: [/* @__PURE__ */ k(u, {
803
809
  name: "paperclip",
804
810
  size: 10,
805
811
  className: "shrink-0"
806
- }), /* @__PURE__ */ E("span", {
812
+ }), /* @__PURE__ */ k("span", {
807
813
  className: "max-w-[160px] truncate",
808
814
  children: e
809
815
  })]
810
816
  }, t))
811
- }), /* @__PURE__ */ E(je, { text: e.detail ?? "" })]
812
- }), i && /* @__PURE__ */ D("button", {
817
+ }), /* @__PURE__ */ k(Re, { text: e.detail ?? "" })]
818
+ }), i && /* @__PURE__ */ A("button", {
813
819
  type: "button",
814
820
  onClick: () => r((e) => !e),
815
821
  className: "relative flex w-full items-center justify-center rounded-b-lg py-1 text-muted-foreground hover:bg-primary/15",
816
822
  title: n ? "Comprimi" : "Espandi",
817
- children: [o && /* @__PURE__ */ E("div", { className: "pointer-events-none absolute inset-x-0 -top-4 h-4 bg-gradient-to-t from-primary/10 to-transparent" }), /* @__PURE__ */ E(s, {
823
+ children: [o && /* @__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, {
818
824
  name: n ? "chevron-up" : "chevron-down",
819
825
  size: 12
820
826
  })]
@@ -822,51 +828,146 @@ function Fe({ entry: e }) {
822
828
  })
823
829
  });
824
830
  }
825
- function Ie({ entry: e }) {
826
- let t = Z();
827
- if (e.kind === "user") return /* @__PURE__ */ E(Fe, { entry: e });
828
- let n = e.kind === "thinking" && e.detail ? De(e.detail) : [], r = n.filter((e) => e.type === "code"), i = n.filter((e) => e.type === "text" && e.content.trim()), a = e.kind === "thinking" ? Ne(e, t) : e.label;
829
- return /* @__PURE__ */ D("li", {
831
+ var Ue = {
832
+ running: "loader-circle",
833
+ done: "check",
834
+ error: "x",
835
+ stopped: "circle-slash"
836
+ };
837
+ function We({ steps: e }) {
838
+ 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 }));
839
+ return /* @__PURE__ */ k(f, {
840
+ ariaLabel: t.stepsLabel,
841
+ selectedId: null,
842
+ itemClassName: "py-0.5 text-xs text-muted-foreground",
843
+ nodes: [{
844
+ id: `steps-${e[0]?.id ?? ""}`,
845
+ label: i,
846
+ icon: n ? "loader-circle" : r ? "circle-alert" : "list-checks",
847
+ children: e.map((e) => ({
848
+ id: e.id,
849
+ label: /* @__PURE__ */ k("span", {
850
+ className: e.status === "error" ? "text-destructive" : void 0,
851
+ children: e.label
852
+ }),
853
+ icon: Ue[e.status]
854
+ }))
855
+ }]
856
+ });
857
+ }
858
+ function Ge({ entry: e, questions: t }) {
859
+ let n = e.parts ?? [], o = [];
860
+ for (let e of n) {
861
+ let t = o.at(-1);
862
+ e.type === "tool" ? t && "steps" in t ? t.steps.push(e) : o.push({
863
+ key: `tool-${e.id}`,
864
+ steps: [e]
865
+ }) : o.push({
866
+ key: `${e.type}-${e.id}`,
867
+ part: e
868
+ });
869
+ }
870
+ let s = !!t?.canAnswer(e.id);
871
+ return /* @__PURE__ */ k("div", {
872
+ className: "space-y-2",
873
+ children: o.map((n) => {
874
+ if ("steps" in n) return /* @__PURE__ */ k(We, { steps: n.steps }, n.key);
875
+ let { part: o } = n;
876
+ return o.type === "text" ? o.text.trim() ? /* @__PURE__ */ k(r, {
877
+ content: o.text,
878
+ streaming: o.streaming,
879
+ className: "break-words text-xs leading-relaxed text-foreground"
880
+ }, n.key) : null : o.type === "reasoning" ? /* @__PURE__ */ k(a, {
881
+ content: o.text,
882
+ streaming: o.streaming,
883
+ duration: o.duration,
884
+ className: "my-0"
885
+ }, n.key) : /* @__PURE__ */ k(i, {
886
+ questions: o.questions,
887
+ ...o.answers ? { answers: o.answers } : {},
888
+ disabled: !o.answers && !s,
889
+ onSubmit: t && s ? (n) => t.onAnswer(e.id, o.id, n) : void 0,
890
+ className: "text-xs"
891
+ }, n.key);
892
+ })
893
+ });
894
+ }
895
+ function Ke({ entry: e, questions: t }) {
896
+ let n = Q();
897
+ if (e.kind === "thinking" && e.parts) {
898
+ let r = e.status === "error" || e.status === "stopped" || e.status === "running" && e.parts.length === 0;
899
+ return /* @__PURE__ */ A("li", {
900
+ className: "text-xs text-muted-foreground",
901
+ children: [e.parts.length > 0 && /* @__PURE__ */ k(Ge, {
902
+ entry: e,
903
+ questions: t
904
+ }), r && /* @__PURE__ */ A("div", {
905
+ className: `flex items-start gap-1.5 ${e.parts.length > 0 ? "mt-1" : ""}`,
906
+ children: [/* @__PURE__ */ k("span", {
907
+ className: "pt-px",
908
+ children: /* @__PURE__ */ k(ze, { status: e.status })
909
+ }), /* @__PURE__ */ k("span", {
910
+ className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
911
+ children: Be(e, n)
912
+ })]
913
+ })]
914
+ });
915
+ }
916
+ let i = e.kind === "thinking" && e.detail ? Ie(e.detail) : [], a = i.filter((e) => e.type === "code"), o = i.filter((e) => e.type === "text" && e.content.trim()), s = e.kind === "thinking" ? Be(e, n) : e.label;
917
+ return /* @__PURE__ */ A("li", {
830
918
  className: "text-xs text-muted-foreground",
831
919
  children: [
832
- /* @__PURE__ */ D("div", {
920
+ /* @__PURE__ */ A("div", {
833
921
  className: "flex items-start gap-1.5",
834
- children: [/* @__PURE__ */ E("span", {
922
+ children: [/* @__PURE__ */ k("span", {
835
923
  className: "pt-px",
836
- children: /* @__PURE__ */ E(Me, { status: e.status })
837
- }), /* @__PURE__ */ E("span", {
924
+ children: /* @__PURE__ */ k(ze, { status: e.status })
925
+ }), /* @__PURE__ */ k("span", {
838
926
  className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
839
- children: a
927
+ children: s
840
928
  })]
841
929
  }),
842
- r.length > 0 && /* @__PURE__ */ E("div", {
930
+ a.length > 0 && /* @__PURE__ */ k("div", {
843
931
  className: "mt-1 ml-[18px] space-y-1",
844
- children: r.map((e, t) => /* @__PURE__ */ E(Oe, {
932
+ children: a.map((e, t) => /* @__PURE__ */ k(Le, {
845
933
  content: e.content,
846
934
  language: e.language
847
935
  }, t))
848
936
  }),
849
- i.length > 0 && /* @__PURE__ */ E("div", {
937
+ o.length > 0 && /* @__PURE__ */ k("div", {
850
938
  className: "mt-1 ml-[18px] space-y-2",
851
- children: i.map((e, t) => /* @__PURE__ */ E("p", {
852
- className: "whitespace-pre-wrap leading-relaxed text-muted-foreground",
853
- children: /* @__PURE__ */ E(Ae, { text: e.content.trim() })
939
+ children: o.map((e, t) => /* @__PURE__ */ k(r, {
940
+ content: e.content.trim(),
941
+ tone: "muted",
942
+ className: "break-words text-xs leading-relaxed"
854
943
  }, t))
855
944
  })
856
945
  ]
857
946
  });
858
947
  }
859
- function Le({ activity: e }) {
860
- return e.length === 0 ? null : /* @__PURE__ */ E("ul", {
948
+ function qe({ activity: e, questions: t }) {
949
+ if (e.length === 0) return null;
950
+ let n = [];
951
+ for (let t of e) t.kind === "user" || n.length === 0 ? n.push(t.kind === "user" ? {
952
+ user: t,
953
+ entries: []
954
+ } : { entries: [t] }) : n[n.length - 1].entries.push(t);
955
+ return /* @__PURE__ */ k("ul", {
861
956
  className: "space-y-0.5",
862
- children: e.map((e) => /* @__PURE__ */ E(Ie, { entry: e }, e.id))
957
+ children: n.map((e) => /* @__PURE__ */ A("li", { children: [e.user && /* @__PURE__ */ k(He, { entry: e.user }), e.entries.length > 0 && /* @__PURE__ */ k("ul", {
958
+ className: "space-y-0.5",
959
+ children: e.entries.map((e) => /* @__PURE__ */ k(Ke, {
960
+ entry: e,
961
+ questions: t
962
+ }, e.id))
963
+ })] }, e.user?.id ?? e.entries[0]?.id))
863
964
  });
864
965
  }
865
966
  //#endregion
866
967
  //#region src/presentation/AgenticoToggle.tsx
867
- function Re({ className: e = "" }) {
868
- let { isOpen: n, toggleOpen: r, task: i } = $(), a = Z(), o = i?.agent.running ?? !1;
869
- return /* @__PURE__ */ E(t, {
968
+ function Je({ className: e = "" }) {
969
+ let { isOpen: n, toggleOpen: r, task: i } = $(), a = Q(), o = i?.agent.running ?? !1;
970
+ return /* @__PURE__ */ k(t, {
870
971
  icon: "bot",
871
972
  ariaLabel: n ? a.closePanel : a.openPanel,
872
973
  title: n ? a.closePanel : a.openPanel,
@@ -877,32 +978,32 @@ function Re({ className: e = "" }) {
877
978
  }
878
979
  //#endregion
879
980
  //#region src/presentation/useAIModelCatalog.ts
880
- var ze = "llmnative-cms.selectedAIModel";
881
- function Be() {
981
+ var Ye = "llmnative-cms.selectedAIModel";
982
+ function Xe() {
882
983
  try {
883
- return localStorage.getItem(ze) ?? "";
984
+ return localStorage.getItem(Ye) ?? "";
884
985
  } catch {
885
986
  return "";
886
987
  }
887
988
  }
888
- function Ve(e) {
989
+ function Ze(e) {
889
990
  try {
890
- e ? localStorage.setItem(ze, e) : localStorage.removeItem(ze);
991
+ e ? localStorage.setItem(Ye, e) : localStorage.removeItem(Ye);
891
992
  } catch {}
892
993
  }
893
- function He() {
894
- let e = p()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = w({}), [i, a] = w(!1), [o, s] = w(Be);
895
- return b(() => {
994
+ function Qe() {
995
+ let e = _()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = D({}), [i, a] = D(!1), [o, s] = D(Xe);
996
+ return C(() => {
896
997
  if (!t) {
897
998
  r({});
898
999
  return;
899
1000
  }
900
1001
  let n = !1;
901
- return a(!0), l(e).then((e) => {
1002
+ return a(!0), p(e).then((e) => {
902
1003
  if (n) return;
903
1004
  r(e.modelsByProvider);
904
1005
  let t = Object.values(e.modelsByProvider).flat();
905
- s((e) => t.some((t) => t.id === e) ? e : (Ve(""), ""));
1006
+ s((e) => t.some((t) => t.id === e) ? e : (Ze(""), ""));
906
1007
  }).catch((e) => {
907
1008
  console.error("useAIModelCatalog: getAIModelCatalog failed", e), n || r({});
908
1009
  }).finally(() => {
@@ -916,34 +1017,188 @@ function He() {
916
1017
  modelsLoading: i,
917
1018
  selectedModel: o,
918
1019
  setSelectedModel: (e) => {
919
- Ve(e), s(e);
1020
+ Ze(e), s(e);
920
1021
  }
921
1022
  };
922
1023
  }
923
1024
  //#endregion
924
1025
  //#region src/presentation/useAgent.ts
925
- var Ue = 20, We = 26e4;
926
- function Ge(e) {
927
- return e.filter((e) => !c.isTextAttachment(e.mimeType) || e.base64.length <= We);
928
- }
929
- function Ke(e, t = {}) {
930
- let { defaultEnabled: n = !1 } = t, [r, i] = w(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: l, setSelectedModel: u } = He(), [f, m] = w(!1), [h, g] = w(null), [_, v] = w(!1), [y, b] = w([]), x = Z(), S = C(x);
931
- S.current = x;
932
- let T = C(null), E = C(!1), D = C(null), O = () => {
933
- D.current?.abort();
934
- }, k = p()?.registry ?? {}, A = r && l ? d(l) : null, j = A ? k[A.provider] : null, M = async (t, n, r) => {
935
- let i = T.current;
936
- if (!i) return g(S.current.noActiveSession), null;
937
- let a = r ? d(r) : A, o = a ? k[a.provider] : null;
938
- if (!o || !a) return g(S.current.noProviderAvailable), null;
1026
+ var $e = 20, et = 26e4;
1027
+ function tt(e) {
1028
+ return e.filter((e) => !d.isTextAttachment(e.mimeType) || e.base64.length <= et);
1029
+ }
1030
+ function nt(e, t = {}) {
1031
+ let { defaultEnabled: n = !1 } = t, [r, i] = D(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: c, setSelectedModel: l } = Qe(), [u, f] = D(!1), [p, m] = D(null), [g, v] = D(!1), [y, b] = D([]), x = E([]), S = (e) => {
1032
+ b((t) => {
1033
+ let n = typeof e == "function" ? e(t) : e;
1034
+ return x.current = n, n;
1035
+ });
1036
+ }, C = E(/* @__PURE__ */ new Map()), w = Q(), T = E(w);
1037
+ T.current = w;
1038
+ let O = E(null), k = E(!1), A = E(null), M = () => {
1039
+ A.current?.abort();
1040
+ }, I = _()?.registry ?? {}, L = r && c ? h(c) : null, R = L ? I[L.provider] : null, z = e.executor, B = !!z, [V, H] = D([]), [U, G] = D(""), K = E(""), q = (e) => {
1041
+ K.current = e, G(e);
1042
+ }, J = (e) => {
1043
+ H(z?.models?.(e) ?? []), q(z?.defaultModel?.(e) ?? "");
1044
+ }, Y = async (e, t, n, r) => {
1045
+ let i = O.current;
1046
+ if (!i || !z) return m(T.current.noActiveSession), null;
1047
+ let a = new AbortController();
1048
+ A.current = a;
1049
+ let o = crypto.randomUUID();
1050
+ S((e) => [...e, {
1051
+ id: o,
1052
+ kind: "thinking",
1053
+ label: T.current.thinking,
1054
+ status: "running",
1055
+ parts: []
1056
+ }]);
1057
+ let s = /* @__PURE__ */ new Map(), c = (e) => Math.max(1, Math.round((Date.now() - (s.get(e) ?? Date.now())) / 1e3)), l = (e) => ({
1058
+ ...e,
1059
+ streaming: !1,
1060
+ duration: e.duration ?? c(e.id)
1061
+ }), u = (e, t) => S((n) => n.map((n) => {
1062
+ if (n.id !== o) return n;
1063
+ let r = e(n.parts ?? []), i = P(r);
1064
+ return {
1065
+ ...n,
1066
+ parts: r,
1067
+ ...t ? { status: t } : {},
1068
+ ...i ? { detail: i } : {}
1069
+ };
1070
+ })), d = (e) => u((t) => N(t, e, l)), f = !1, p = (e, t) => {
1071
+ t?.id && t.id !== "text" && (f = !0), d({
1072
+ type: "text",
1073
+ id: t?.id ?? "text",
1074
+ text: e,
1075
+ streaming: !t?.done
1076
+ });
1077
+ }, h = (e, t) => {
1078
+ let n = t?.id ?? "reasoning";
1079
+ s.has(n) || s.set(n, Date.now()), d({
1080
+ type: "reasoning",
1081
+ id: n,
1082
+ text: e,
1083
+ streaming: !t?.done,
1084
+ ...t?.duration === void 0 ? t?.done ? { duration: c(n) } : {} : { duration: t.duration }
1085
+ });
1086
+ }, g = (e) => d({
1087
+ type: "tool",
1088
+ id: e.id,
1089
+ label: e.label,
1090
+ status: e.status
1091
+ }), _ = /* @__PURE__ */ new Set(), v = 0, y = () => {
1092
+ for (let e of _) {
1093
+ let t = C.current.get(e);
1094
+ C.current.delete(e), t?.reject(new DOMException("The turn was stopped.", "AbortError"));
1095
+ }
1096
+ _.clear();
1097
+ };
1098
+ a.signal.addEventListener("abort", y);
1099
+ let b = (e, t) => {
1100
+ v += 1;
1101
+ let n = t?.id ?? `questions-${v}`;
1102
+ d({
1103
+ type: "questions",
1104
+ id: n,
1105
+ questions: e
1106
+ });
1107
+ let r = `${o}:${n}`;
1108
+ return a.signal.aborted ? Promise.reject(new DOMException("The turn was stopped.", "AbortError")) : (_.add(r), new Promise((e, t) => {
1109
+ C.current.set(r, {
1110
+ resolve: e,
1111
+ reject: t
1112
+ });
1113
+ }));
1114
+ }, x = (e, t) => {
1115
+ u((n) => (t && !f ? N(n, {
1116
+ type: "text",
1117
+ id: j,
1118
+ text: t,
1119
+ streaming: !1
1120
+ }, l) : n).map((t) => t.type === "reasoning" && t.streaming ? l(t) : t.type === "text" && t.streaming ? {
1121
+ ...t,
1122
+ streaming: !1
1123
+ } : t.type === "tool" && t.status === "running" && e !== "done" ? {
1124
+ ...t,
1125
+ status: "stopped"
1126
+ } : t), e), a.signal.removeEventListener("abort", y);
1127
+ for (let e of _) C.current.delete(e);
1128
+ _.clear();
1129
+ }, w = e || r?.historyText || "";
1130
+ try {
1131
+ let o = await z.turn({
1132
+ params: i.params,
1133
+ context: i.context,
1134
+ text: e,
1135
+ first: t,
1136
+ signal: a.signal,
1137
+ ...n || K.current ? { model: n || K.current } : {},
1138
+ ...r ? { answers: {
1139
+ id: r.id,
1140
+ answers: r.answers
1141
+ } } : {},
1142
+ onText: p,
1143
+ onReasoning: h,
1144
+ onStep: g,
1145
+ onQuestions: b
1146
+ });
1147
+ return x("done", o.text), i.history = [
1148
+ ...i.history,
1149
+ ...w ? [{
1150
+ role: "user",
1151
+ content: w
1152
+ }] : [],
1153
+ {
1154
+ role: "assistant",
1155
+ content: o.text
1156
+ }
1157
+ ], o.result ?? null;
1158
+ } catch (e) {
1159
+ return i.history = [...i.history, ...w ? [{
1160
+ role: "user",
1161
+ content: w
1162
+ }] : []], a.signal.aborted ? (x("stopped"), null) : (x("error"), m(Z(e)), null);
1163
+ } finally {
1164
+ A.current = null;
1165
+ }
1166
+ }, ee = async (e, t, n) => {
1167
+ let r = x.current.find((t) => t.id === e)?.parts?.find((e) => e.type === "questions" && e.id === t);
1168
+ if (!r || r.type !== "questions") throw m(T.current.noActiveSession), Error(T.current.noActiveSession);
1169
+ let i = () => S((r) => r.map((r) => r.id === e ? {
1170
+ ...r,
1171
+ parts: r.parts?.map((e) => e.type === "questions" && e.id === t ? {
1172
+ ...e,
1173
+ answers: n
1174
+ } : e)
1175
+ } : r)), a = `${e}:${t}`, o = C.current.get(a);
1176
+ if (o) return C.current.delete(a), i(), o.resolve(n), null;
1177
+ if (k.current) throw m(T.current.requestInProgress), Error(T.current.requestInProgress);
1178
+ if (!B || !O.current) throw m(T.current.noActiveSession), Error(T.current.noActiveSession);
1179
+ k.current = !0, f(!0), m(null), i();
1180
+ try {
1181
+ return await Y("", !1, void 0, {
1182
+ id: t,
1183
+ answers: n,
1184
+ historyText: F(r.questions, n)
1185
+ });
1186
+ } finally {
1187
+ k.current = !1, f(!1);
1188
+ }
1189
+ }, te = async (t, n, r) => {
1190
+ let i = O.current;
1191
+ if (!i) return m(T.current.noActiveSession), null;
1192
+ let a = r ? h(r) : L, o = a ? I[a.provider] : null;
1193
+ if (!o || !a) return m(T.current.noProviderAvailable), null;
939
1194
  n?.length && (i.attachmentsRef.current = [...i.attachmentsRef.current ?? [], ...n]);
940
- let s = (n ?? []).filter((e) => c.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= We ? `\n\n[File allegato: ${e.name}]\n${c.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(""), l = Ge(n ?? []), u = i.tools.map((e) => ({
1195
+ let s = (n ?? []).filter((e) => d.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= et ? `\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 = tt(n ?? []), l = i.tools.map((e) => ({
941
1196
  name: e.name,
942
1197
  description: e.description,
943
- inputSchema: I(e.inputSchema)
944
- })), f = new Map(i.tools.map((e) => [e.name, e])), p = new AbortController();
945
- D.current = p;
946
- let m = (e, t, n, r) => b((i) => i.map((i) => i.id === e ? {
1198
+ inputSchema: W(e.inputSchema)
1199
+ })), u = new Map(i.tools.map((e) => [e.name, e])), f = new AbortController();
1200
+ A.current = f;
1201
+ let p = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
947
1202
  ...i,
948
1203
  status: t,
949
1204
  ...n === void 0 ? {} : { detail: n },
@@ -951,36 +1206,36 @@ function Ke(e, t = {}) {
951
1206
  } : i));
952
1207
  try {
953
1208
  let n = i.history, r = t;
954
- for (let t = 0; t < Ue; t++) {
955
- let c = crypto.randomUUID();
956
- b((e) => [...e, {
957
- id: c,
1209
+ for (let t = 0; t < $e; t++) {
1210
+ let d = crypto.randomUUID();
1211
+ S((e) => [...e, {
1212
+ id: d,
958
1213
  kind: "thinking",
959
- label: S.current.thinking,
1214
+ label: T.current.thinking,
960
1215
  status: "running"
961
1216
  }]);
962
- let d;
1217
+ let h;
963
1218
  try {
964
- d = await o.complete({
1219
+ h = await o.complete({
965
1220
  prompt: r,
966
1221
  model: a.model,
967
1222
  history: n,
968
- tools: u.length ? u : void 0,
969
- signal: p.signal,
970
- attachments: t === 0 ? l : void 0,
1223
+ tools: l.length ? l : void 0,
1224
+ signal: f.signal,
1225
+ attachments: t === 0 ? c : void 0,
971
1226
  logId: i.logId
972
1227
  });
973
1228
  } catch (t) {
974
1229
  return i.history = [...n, ...r ? [{
975
1230
  role: "user",
976
1231
  content: r + s
977
- }] : []], p.signal.aborted ? (m(c, "stopped"), e.fallback(i.params, i.context)) : (m(c, "error"), g(K(t)), null);
1232
+ }] : []], f.signal.aborted ? (p(d, "stopped"), e.fallback(i.params, i.context)) : (p(d, "error"), m(Z(t)), null);
978
1233
  }
979
1234
  if (i.history = [...n, ...r ? [{
980
1235
  role: "user",
981
1236
  content: r + s
982
- }] : []], !d) return p.signal.aborted ? (m(c, "stopped"), e.fallback(i.params, i.context)) : (m(c, "error"), g(S.current.noProviderResponse), null);
983
- if (d.type === "text") return m(c, "done", d.text), i.history = [
1237
+ }] : []], !h) return f.signal.aborted ? (p(d, "stopped"), e.fallback(i.params, i.context)) : (p(d, "error"), m(T.current.noProviderResponse), null);
1238
+ if (h.type === "text") return p(d, "done", h.text), i.history = [
984
1239
  ...n,
985
1240
  ...r ? [{
986
1241
  role: "user",
@@ -988,26 +1243,26 @@ function Ke(e, t = {}) {
988
1243
  }] : [],
989
1244
  {
990
1245
  role: "assistant",
991
- content: d.text
1246
+ content: h.text
992
1247
  }
993
- ], e.parseResponse(d.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.", {
994
- responseLength: d.text.length,
995
- responsePreview: d.text.length > 2e3 ? `${d.text.slice(0, 1e3)}\n…[troncato qui nel log, ${d.text.length} caratteri totali]…\n${d.text.slice(-1e3)}` : d.text,
1248
+ ], 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.", {
1249
+ responseLength: h.text.length,
1250
+ 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,
996
1251
  params: i.params
997
- }), g(S.current.invalidResponse), e.fallback(i.params, i.context));
998
- let h = d.toolCalls.map((e) => {
999
- let t = f.get(e.name);
1252
+ }), m(T.current.invalidResponse), e.fallback(i.params, i.context));
1253
+ let g = h.toolCalls.map((e) => {
1254
+ let t = u.get(e.name);
1000
1255
  return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1001
1256
  });
1002
- m(c, "done", d.text || void 0, d.text ? void 0 : h);
1003
- let _ = await Promise.all(d.toolCalls.map(async (e) => {
1004
- let t = f.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1005
- if (b((t) => [...t, {
1257
+ p(d, "done", h.text || void 0, h.text ? void 0 : g);
1258
+ let _ = await Promise.all(h.toolCalls.map(async (e) => {
1259
+ let t = u.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1260
+ if (S((t) => [...t, {
1006
1261
  id: e.id,
1007
1262
  kind: "tool",
1008
1263
  label: n,
1009
1264
  status: "running"
1010
- }]), !t) return m(e.id, "error"), {
1265
+ }]), !t) return p(e.id, "error"), {
1011
1266
  toolCallId: e.id,
1012
1267
  name: e.name,
1013
1268
  output: `Tool sconosciuto: ${e.name}`,
@@ -1015,16 +1270,16 @@ function Ke(e, t = {}) {
1015
1270
  };
1016
1271
  try {
1017
1272
  let n = await t.execute(e.input);
1018
- return m(e.id, "done"), {
1273
+ return p(e.id, "done"), {
1019
1274
  toolCallId: e.id,
1020
1275
  name: e.name,
1021
1276
  output: n
1022
1277
  };
1023
1278
  } catch (t) {
1024
- return m(e.id, "error"), {
1279
+ return p(e.id, "error"), {
1025
1280
  toolCallId: e.id,
1026
1281
  name: e.name,
1027
- output: K(t),
1282
+ output: Z(t),
1028
1283
  isError: !0
1029
1284
  };
1030
1285
  }
@@ -1037,8 +1292,8 @@ function Ke(e, t = {}) {
1037
1292
  }] : [],
1038
1293
  {
1039
1294
  role: "assistant",
1040
- content: d.text,
1041
- toolCalls: d.toolCalls
1295
+ content: h.text,
1296
+ toolCalls: h.toolCalls
1042
1297
  },
1043
1298
  {
1044
1299
  role: "tool_result",
@@ -1046,118 +1301,120 @@ function Ke(e, t = {}) {
1046
1301
  }
1047
1302
  ], r = "";
1048
1303
  }
1049
- let c = crypto.randomUUID();
1050
- b((e) => [...e, {
1051
- id: c,
1304
+ let d = crypto.randomUUID();
1305
+ S((e) => [...e, {
1306
+ id: d,
1052
1307
  kind: "thinking",
1053
- label: S.current.thinking,
1308
+ label: T.current.thinking,
1054
1309
  status: "running"
1055
1310
  }]);
1056
- let d;
1311
+ let h;
1057
1312
  try {
1058
- d = await o.complete({
1059
- prompt: G(H().stopCallingTools, e.microPromptIds),
1313
+ h = await o.complete({
1314
+ prompt: le(X().stopCallingTools, e.microPromptIds),
1060
1315
  model: a.model,
1061
1316
  history: n,
1062
- signal: p.signal,
1317
+ signal: f.signal,
1063
1318
  logId: i.logId
1064
1319
  });
1065
1320
  } catch {
1066
- d = null;
1321
+ h = null;
1067
1322
  }
1068
- if (d?.type === "text") {
1069
- m(c, "done", d.text), i.history = [...n, {
1323
+ if (h?.type === "text") {
1324
+ p(d, "done", h.text), i.history = [...n, {
1070
1325
  role: "assistant",
1071
- content: d.text
1326
+ content: h.text
1072
1327
  }];
1073
- let t = e.parseResponse(d.text, i.params, i.context);
1328
+ let t = e.parseResponse(h.text, i.params, i.context);
1074
1329
  if (t) return t;
1075
- } else m(c, p.signal.aborted ? "stopped" : "error"), i.history = n;
1076
- return p.signal.aborted || g(S.current.tooManyToolTurns), e.fallback(i.params, i.context);
1330
+ } else p(d, f.signal.aborted ? "stopped" : "error"), i.history = n;
1331
+ return f.signal.aborted || m(T.current.tooManyToolTurns), e.fallback(i.params, i.context);
1077
1332
  } finally {
1078
- D.current = null;
1333
+ A.current = null;
1079
1334
  }
1080
1335
  };
1081
1336
  return {
1082
1337
  enabled: r,
1083
1338
  setEnabled: i,
1084
1339
  hasProviders: a,
1085
- selectedModel: l,
1086
- setSelectedModel: u,
1340
+ selectedModel: B ? U : c,
1341
+ setSelectedModel: B ? q : l,
1087
1342
  modelsByProvider: o,
1088
1343
  modelsLoading: s,
1089
- running: f,
1090
- error: h,
1091
- canContinue: _,
1344
+ running: u,
1345
+ error: p,
1346
+ canContinue: g,
1347
+ remote: B,
1348
+ remoteModels: V,
1092
1349
  activity: y,
1093
1350
  run: async (t, n) => {
1094
- if (E.current) return g(S.current.requestInProgress), null;
1095
- E.current = !0, g(null), b(n?.openingMessage ? [{
1351
+ if (k.current) return m(T.current.requestInProgress), null;
1352
+ k.current = !0, m(null), S(n?.openingMessage ? [{
1096
1353
  id: crypto.randomUUID(),
1097
1354
  kind: "user",
1098
1355
  label: "Tu",
1099
1356
  status: "done",
1100
1357
  detail: n.openingMessage,
1101
1358
  ...n.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
1102
- }] : []), m(!0);
1359
+ }] : []), f(!0);
1103
1360
  try {
1104
1361
  let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
1105
- T.current = {
1362
+ if (O.current = {
1106
1363
  params: t,
1107
1364
  context: i,
1108
1365
  tools: o,
1109
1366
  history: [],
1110
1367
  logId: crypto.randomUUID(),
1111
1368
  attachmentsRef: a
1112
- };
1113
- let s = n?.model || void 0, l = s ? !!k[d(s)?.provider ?? ""] : !!j;
1114
- if (!r || !l) {
1369
+ }, B) return v(!0), J(t), await Y(n?.openingMessage ?? "", !0);
1370
+ let s = n?.model || void 0, c = s ? !!I[h(s)?.provider ?? ""] : !!R;
1371
+ if (!r || !c) {
1115
1372
  v(!1);
1116
1373
  let n = e.fallback(t, i);
1117
- return b((t) => [...t, {
1374
+ return S((t) => [...t, {
1118
1375
  id: crypto.randomUUID(),
1119
1376
  kind: "tool",
1120
1377
  status: "done",
1121
- label: e.describeFallback?.(n) ?? S.current.aiDisabledFallback
1378
+ label: e.describeFallback?.(n) ?? T.current.aiDisabledFallback
1122
1379
  }]), n;
1123
1380
  }
1124
1381
  v(!0);
1125
- let u = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => c.fileToAttachment(e))) : void 0, f = G(e.buildPrompt(t, i), e.microPromptIds);
1126
- return await M(f, u, s);
1382
+ let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, u = le(e.buildPrompt(t, i), e.microPromptIds);
1383
+ return await te(u, l, s);
1127
1384
  } catch (e) {
1128
- return g(K(e)), null;
1385
+ return m(Z(e)), null;
1129
1386
  } finally {
1130
- E.current = !1, m(!1);
1387
+ k.current = !1, f(!1);
1131
1388
  }
1132
1389
  },
1133
1390
  resume: async (t, n) => {
1134
- if (E.current) {
1135
- g(S.current.requestInProgress);
1391
+ if (k.current) {
1392
+ m(T.current.requestInProgress);
1136
1393
  return;
1137
1394
  }
1138
- E.current = !0, g(null), b(n.activity), m(!0);
1395
+ k.current = !0, m(null), S(n.activity), f(!0);
1139
1396
  try {
1140
1397
  let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
1141
- T.current = {
1398
+ O.current = {
1142
1399
  params: t,
1143
1400
  context: i,
1144
1401
  tools: o,
1145
1402
  history: n.history,
1146
1403
  logId: crypto.randomUUID(),
1147
1404
  attachmentsRef: a
1148
- }, v(r && !!j);
1405
+ }, B && J(t), v(B || r && !!R);
1149
1406
  } catch (e) {
1150
- g(K(e));
1407
+ m(Z(e));
1151
1408
  } finally {
1152
- E.current = !1, m(!1);
1409
+ k.current = !1, f(!1);
1153
1410
  }
1154
1411
  },
1155
1412
  sendMessage: async (t, n) => {
1156
- if (E.current) return g(S.current.requestInProgress), null;
1157
- if (g(null), !t.trim()) return g("Messaggio vuoto."), null;
1158
- let r = T.current;
1159
- if (!r) return g(S.current.noActiveSession), null;
1160
- E.current = !0, m(!0), b((e) => [...e, {
1413
+ if (k.current) return m(T.current.requestInProgress), null;
1414
+ if (m(null), !t.trim()) return m("Messaggio vuoto."), null;
1415
+ let r = O.current;
1416
+ if (!r) return m(T.current.noActiveSession), null;
1417
+ k.current = !0, f(!0), S((e) => [...e, {
1161
1418
  id: crypto.randomUUID(),
1162
1419
  kind: "user",
1163
1420
  label: "Tu",
@@ -1166,52 +1423,54 @@ function Ke(e, t = {}) {
1166
1423
  ...n?.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
1167
1424
  }]);
1168
1425
  try {
1169
- let i = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => c.fileToAttachment(e))) : void 0, a = G(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
1170
- return await M(a, i, n?.model || void 0);
1426
+ if (B) return await Y(t, !1, n?.model || void 0);
1427
+ let i = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, a = le(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
1428
+ return await te(a, i, n?.model || void 0);
1171
1429
  } catch (e) {
1172
- return g(K(e)), null;
1430
+ return m(Z(e)), null;
1173
1431
  } finally {
1174
- E.current = !1, m(!1);
1432
+ k.current = !1, f(!1);
1175
1433
  }
1176
1434
  },
1177
- stop: O,
1435
+ stop: M,
1178
1436
  runFallback: () => {
1179
- let t = T.current;
1437
+ let t = O.current;
1180
1438
  if (!t) return null;
1181
- g(null);
1439
+ m(null);
1182
1440
  let n = e.fallback(t.params, t.context);
1183
- return b((t) => [...t, {
1441
+ return S((t) => [...t, {
1184
1442
  id: crypto.randomUUID(),
1185
1443
  kind: "tool",
1186
1444
  status: "done",
1187
- label: e.describeFallback?.(n) ?? S.current.continueWithoutAiFallback
1445
+ label: e.describeFallback?.(n) ?? T.current.continueWithoutAiFallback
1188
1446
  }]), n;
1189
1447
  },
1190
- snapshot: () => T.current ? {
1191
- history: T.current.history,
1448
+ snapshot: () => O.current ? {
1449
+ history: O.current.history,
1192
1450
  activity: y
1193
- } : null
1451
+ } : null,
1452
+ answerQuestions: ee
1194
1453
  };
1195
1454
  }
1196
1455
  //#endregion
1197
1456
  //#region src/domain/orchestrator/prompt.ts
1198
- function qe() {
1199
- let e = H();
1457
+ function rt() {
1458
+ let e = X();
1200
1459
  return [e.responseRulesHeading, ...e.responseRules.map((e) => `- ${e}`)].join("\n");
1201
1460
  }
1202
- function Je(e, t, n) {
1203
- let r = H(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
1461
+ function it(e, t, n) {
1462
+ let r = X(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
1204
1463
  return `${r.orchestratorIntro}
1205
1464
 
1206
1465
  ${r.toolsHeading}
1207
1466
  ${t}
1208
1467
  ${i}
1209
- ${qe()}
1468
+ ${rt()}
1210
1469
 
1211
1470
  ${r.userRequestHeading}
1212
1471
  ${e}`;
1213
1472
  }
1214
- function Ye(e, t) {
1473
+ function at(e, t) {
1215
1474
  return t ? {
1216
1475
  kind: "handoff",
1217
1476
  ...t
@@ -1222,24 +1481,27 @@ function Ye(e, t) {
1222
1481
  }
1223
1482
  //#endregion
1224
1483
  //#region src/domain/orchestrator/agenticoOrchestratorAgent.ts
1225
- function Xe(e) {
1484
+ function ot(e) {
1485
+ return z().filter((t) => !t.onlyWhenAnchored || e === t.id);
1486
+ }
1487
+ function st(e) {
1226
1488
  return {
1227
- buildContext() {
1489
+ buildContext(e) {
1228
1490
  return {
1229
- cliCatalog: ie(j()),
1491
+ cliCatalog: oe(ot(e.scopedSubagentId)),
1230
1492
  handoff: { current: null },
1231
1493
  collected: {}
1232
1494
  };
1233
1495
  },
1234
1496
  buildPrompt({ userGoal: e, pageContext: t }, { cliCatalog: n }) {
1235
- return Je(e, n, t);
1497
+ return it(e, n, t);
1236
1498
  },
1237
1499
  buildFollowUpPrompt(e, t, { cliCatalog: n }) {
1238
- return `${e}\n\n${qe()}\n\n${H().toolsHeading}\n${n}`;
1500
+ return `${e}\n\n${rt()}\n\n${X().toolsHeading}\n${n}`;
1239
1501
  },
1240
1502
  parseResponse(e, t, n) {
1241
1503
  let r = n.handoff.current;
1242
- return n.handoff.current = null, Ye(e, r);
1504
+ return n.handoff.current = null, at(e, r);
1243
1505
  },
1244
1506
  fallback() {
1245
1507
  return {
@@ -1251,16 +1513,16 @@ function Xe(e) {
1251
1513
  return t.kind === "chat" ? t.message : e.continueWithoutAi;
1252
1514
  },
1253
1515
  getTools(t, n, r) {
1254
- let i = F({
1516
+ let i = U({
1255
1517
  attachmentsRef: r,
1256
1518
  collected: n.collected,
1257
- proxyFetch: f
1258
- }), a = t.scopedSubagentId ? M(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = j().flatMap((t) => t.commands.map((r) => ({
1519
+ proxyFetch: g
1520
+ }), a = t.scopedSubagentId ? B(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = ot(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
1259
1521
  name: `${t.id}_${r.name}`,
1260
1522
  description: `${t.label}: ${r.summary}`,
1261
1523
  inputSchema: r.inputSchema,
1262
- describeInvocation: () => u(e.preparing, { label: t.label }),
1263
- describeIntent: u(e.collecting, { label: t.label }),
1524
+ describeInvocation: () => m(e.preparing, { label: t.label }),
1525
+ describeIntent: m(e.collecting, { label: t.label }),
1264
1526
  async execute(e) {
1265
1527
  let i = t.withCollected ? t.withCollected({ ...e }, n.collected) : e;
1266
1528
  return n.handoff.current = {
@@ -1269,7 +1531,7 @@ function Xe(e) {
1269
1531
  params: i
1270
1532
  }, {
1271
1533
  status: "queued",
1272
- note: u(H().handoffQueued, { label: t.label })
1534
+ note: m(X().handoffQueued, { label: t.label })
1273
1535
  };
1274
1536
  }
1275
1537
  })));
@@ -1279,89 +1541,89 @@ function Xe(e) {
1279
1541
  }
1280
1542
  //#endregion
1281
1543
  //#region src/presentation/deriveHistoryTitle.ts
1282
- function Ze(e, t) {
1544
+ function ct(e, t) {
1283
1545
  return e.deriveHistoryTitle?.(t) ?? e.label;
1284
1546
  }
1285
1547
  //#endregion
1286
1548
  //#region src/presentation/ResultDestinationPicker.tsx
1287
- function Qe({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
1288
- let s = Z(), c = $(), l = c.scope, d = h(), [f, p] = w(null), [m, g] = w(new Set(i ?? [])), [_, v] = w(null), y = J(), b = /* @__PURE__ */ new Map();
1549
+ function lt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
1550
+ 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();
1289
1551
  e.destinationIds.forEach((e) => {
1290
- let t = y[e];
1552
+ let t = v[e];
1291
1553
  t && b.set(e, t);
1292
- }), (o ?? []).forEach((e) => b.set(e.id, e)), b.set(q.id, q);
1554
+ }), (o ?? []).forEach((e) => b.set(e.id, e)), b.set(pe.id, pe);
1293
1555
  let x = Array.from(b.values()), S = async (i) => {
1294
- p(i), v(null);
1556
+ f(i), _(null);
1295
1557
  try {
1296
1558
  let o = b.get(i);
1297
- if (!o) throw Error(u(s.unknownDestination, { id: i }));
1559
+ if (!o) throw Error(m(s.unknownDestination, { id: i }));
1298
1560
  if (i !== "json-export" && !l) throw Error(s.destinationNoScope);
1299
- let f = await o.apply(t, {
1561
+ let d = await o.apply(t, {
1300
1562
  scopeId: l?.id ?? "",
1301
1563
  dataProvider: l?.dataProvider,
1302
1564
  storageProvider: l?.storageProvider ?? null,
1303
- proxyFetch: d
1565
+ proxyFetch: u
1304
1566
  }, n);
1305
- g((e) => new Set(e).add(i)), a?.(i), f?.id && c.commitEntityChat(e.id, f.id, r, l?.id, n, Ze(e, n));
1567
+ h((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, ct(e, n));
1306
1568
  } catch (e) {
1307
- v(e instanceof Error ? e.message : String(e));
1569
+ _(e instanceof Error ? e.message : String(e));
1308
1570
  } finally {
1309
- p(null);
1571
+ f(null);
1310
1572
  }
1311
1573
  };
1312
- return /* @__PURE__ */ D("div", {
1574
+ return /* @__PURE__ */ A("div", {
1313
1575
  className: "space-y-2",
1314
1576
  children: [
1315
- /* @__PURE__ */ E("p", {
1577
+ /* @__PURE__ */ k("p", {
1316
1578
  className: "text-xs font-medium text-muted-foreground",
1317
1579
  children: s.destinationPickerTitle
1318
1580
  }),
1319
- /* @__PURE__ */ E("div", {
1581
+ /* @__PURE__ */ k("div", {
1320
1582
  className: "flex flex-wrap gap-2",
1321
- children: x.map((e) => /* @__PURE__ */ E("button", {
1583
+ children: x.map((e) => /* @__PURE__ */ k("button", {
1322
1584
  type: "button",
1323
- disabled: f !== null,
1585
+ disabled: d !== null,
1324
1586
  onClick: () => void S(e.id),
1325
1587
  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",
1326
- children: f === e.id ? s.destinationApplying : `${m.has(e.id) ? "✓ " : ""}${e.id === "json-export" ? s.exportJson : e.label}`
1588
+ children: d === e.id ? s.destinationApplying : `${p.has(e.id) ? "✓ " : ""}${e.id === "json-export" ? s.exportJson : e.label}`
1327
1589
  }, e.id))
1328
1590
  }),
1329
- _ && /* @__PURE__ */ E("p", {
1591
+ g && /* @__PURE__ */ k("p", {
1330
1592
  className: "text-xs text-destructive",
1331
- children: _
1593
+ children: g
1332
1594
  })
1333
1595
  ]
1334
1596
  });
1335
1597
  }
1336
1598
  //#endregion
1337
1599
  //#region src/presentation/reports/subagentReportRegistry.tsx
1338
- var $e = {};
1339
- function et(e) {
1340
- Object.assign($e, e);
1600
+ var ut = {};
1601
+ function dt(e) {
1602
+ Object.assign(ut, e);
1341
1603
  }
1342
- function tt(e) {
1343
- return $e[e];
1604
+ function ft(e) {
1605
+ return ut[e];
1344
1606
  }
1345
1607
  //#endregion
1346
1608
  //#region src/presentation/reports/GenericResultPreview.tsx
1347
- function nt({ result: e }) {
1348
- let [t, n] = w(!1);
1349
- return /* @__PURE__ */ D("div", {
1609
+ function pt({ result: e }) {
1610
+ let [t, n] = D(!1);
1611
+ return /* @__PURE__ */ A("div", {
1350
1612
  className: `relative cursor-pointer rounded-md border border-border/60 ${t ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
1351
1613
  onClick: () => n((e) => !e),
1352
1614
  title: t ? "Clic per comprimere" : "Clic per espandere",
1353
- children: [/* @__PURE__ */ E(i, {
1615
+ children: [/* @__PURE__ */ k(s, {
1354
1616
  language: "json",
1355
1617
  showCopy: t,
1356
1618
  background: "transparent",
1357
1619
  className: "!text-[11px]",
1358
1620
  children: JSON.stringify(e, null, 2)
1359
- }), !t && /* @__PURE__ */ E("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
1621
+ }), !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" })]
1360
1622
  });
1361
1623
  }
1362
1624
  //#endregion
1363
1625
  //#region src/presentation/liveAnchorDestination.ts
1364
- function rt(e, t, n) {
1626
+ function mt(e, t, n) {
1365
1627
  return e.length === 0 ? null : {
1366
1628
  id: "live-component",
1367
1629
  label: "Applica al componente aperto",
@@ -1371,127 +1633,166 @@ function rt(e, t, n) {
1371
1633
  };
1372
1634
  }
1373
1635
  //#endregion
1636
+ //#region src/presentation/subagentControls.ts
1637
+ var ht = {};
1638
+ function gt(e) {
1639
+ Object.assign(ht, e);
1640
+ }
1641
+ function _t(e) {
1642
+ return ht[e];
1643
+ }
1644
+ //#endregion
1374
1645
  //#region src/presentation/SubagentRunner.tsx
1375
- function it({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o }) {
1376
- let s = Ke(e.definition, { defaultEnabled: !0 }), c = $(), l = c.scope, u = h(), d = C(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [f, p] = w(null), [m, g] = w([]), [_, v] = w(null), y = tt(e.id), x = y?.kind === "selection" ? y : null, [O, k] = w(null), A = C(!1), j = C(0), M = C(null);
1377
- f && f !== M.current && (M.current = f, j.current = (r?.length ?? 0) + s.activity.length);
1378
- let N = C(!1), P = !s.hasProviders || s.selectedModel !== "";
1379
- b(() => {
1380
- !A.current && P && (A.current = !0, a ? s.resume(e.toParams(t), a) : (o && s.setSelectedModel(o), s.run(e.toParams(t), { model: o }).then((e) => {
1381
- e && p(e);
1646
+ var vt = () => ({});
1647
+ function yt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
1648
+ let c = nt(e.definition, { defaultEnabled: !0 }), l = $(), u = l.scope, d = y(), f = E(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = D(null), [h, g] = D([]), [_, v] = D(null), b = ft(e.id), x = b?.kind === "selection" ? b : null, [S, w] = D(null), j = E(!1), M = E(0), N = E(null);
1649
+ p && p !== N.current && (N.current = p, M.current = (r?.length ?? 0) + c.activity.length);
1650
+ let P = E(!1), F = c.remote || !c.hasProviders || c.selectedModel !== "";
1651
+ C(() => {
1652
+ !j.current && F && (j.current = !0, a ? c.resume(e.toParams(t), a) : (o && c.setSelectedModel(o), c.run(e.toParams(t), {
1653
+ model: o,
1654
+ openingMessage: s
1655
+ }).then((e) => {
1656
+ e && m(e);
1382
1657
  })));
1383
- }, [P]), b(() => {
1384
- if (!f || !l) return;
1385
- let n = e.autoApplyDestinationIds ?? [], r = c.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = J();
1658
+ }, [F]), C(() => {
1659
+ if (!p || !u) return;
1660
+ let n = e.autoApplyDestinationIds ?? [], r = l.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = ge();
1386
1661
  n.forEach((n) => {
1387
1662
  let a = i[n];
1388
- a && (v(null), a.apply(f, {
1389
- scopeId: l.id,
1390
- dataProvider: l.dataProvider,
1391
- storageProvider: l.storageProvider,
1392
- proxyFetch: u
1663
+ a && (v(null), a.apply(p, {
1664
+ scopeId: u.id,
1665
+ dataProvider: u.dataProvider,
1666
+ storageProvider: u.storageProvider,
1667
+ proxyFetch: d
1393
1668
  }, {
1394
1669
  ...t,
1395
1670
  pinnedEntityId: r
1396
1671
  }).then((n) => {
1397
- n?.id && c.commitEntityChat(e.id, n.id, d, l.id, t, Ze(e, t));
1672
+ n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, ct(e, t));
1398
1673
  }).catch((e) => v(e instanceof Error ? e.message : String(e))));
1399
1674
  });
1400
1675
  }, [
1401
- f,
1402
- s.activity,
1403
- l
1404
- ]), b(() => {
1405
- f && x && k(x.defaultSelection(f));
1406
- }, [f, x]);
1407
- let F = (e, t) => {
1408
- k((n) => n && {
1676
+ p,
1677
+ c.activity,
1678
+ u
1679
+ ]), C(() => {
1680
+ p && x && w(x.defaultSelection(p));
1681
+ }, [p, x]);
1682
+ let I = (e, t) => {
1683
+ w((n) => n && {
1409
1684
  ...n,
1410
1685
  [e]: t
1411
1686
  });
1412
- }, I = (e) => p(e), L = S(() => f && x && O ? x.applySelection(f, O) : f, [
1413
- f,
1687
+ }, L = (e) => m(e), R = T(() => p && x && S ? x.applySelection(p, S) : p, [
1688
+ p,
1414
1689
  x,
1415
- O
1416
- ]), R = S(() => c.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [c.componentAnchors, e.id]), z = S(() => rt(R, t, d), [
1417
- R,
1690
+ S
1691
+ ]), z = T(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), B = T(() => mt(z, t, f), [
1692
+ z,
1418
1693
  t,
1419
- d
1420
- ]), B = S(() => z ? [z, ...n ?? []] : n, [z, n]), V = (e) => {
1694
+ f
1695
+ ]), V = T(() => B ? [B, ...n ?? []] : n, [B, n]), H = e.chatEntityId?.(t), U = E(!1);
1696
+ C(() => {
1697
+ let n = U.current && !c.running;
1698
+ if (U.current = c.running, !n || !H || !u) return;
1699
+ let i = c.snapshot();
1700
+ i && we({
1701
+ scopeId: u.id,
1702
+ subagentId: e.id,
1703
+ entityId: H,
1704
+ params: t,
1705
+ title: ct(e, t),
1706
+ history: i.history,
1707
+ activity: [...r ?? [], ...i.activity]
1708
+ });
1709
+ }, [c.running]);
1710
+ let W = () => {
1711
+ P.current = !0, c.running && c.stop(), l.closeTask(f);
1712
+ }, G = E(_t(e.id) ?? vt).current, K = G({
1713
+ params: t,
1714
+ taskId: f,
1715
+ running: c.running,
1716
+ close: W
1717
+ }), q = (e) => {
1421
1718
  g((t) => t.includes(e) ? t : [...t, e]);
1422
1719
  };
1423
- return b(() => {
1424
- N.current || c.openTask({
1425
- id: d,
1426
- title: Ze(e, t),
1720
+ return C(() => {
1721
+ P.current || l.openTask({
1722
+ id: f,
1723
+ title: ct(e, t),
1427
1724
  icon: e.icon,
1428
- agent: s,
1429
- onApplied: (e) => p(e),
1725
+ agent: c,
1726
+ onApplied: (e) => m(e),
1430
1727
  precedingActivity: r,
1431
- panelExtraAnchorIndex: j.current,
1432
- onDismiss: () => {
1433
- N.current = !0, s.running && s.stop(), c.closeTask(d);
1434
- },
1435
- panelExtra: f ? /* @__PURE__ */ D(T, { children: [
1436
- x && O ? /* @__PURE__ */ E(x.Report, {
1437
- result: f,
1438
- selection: O,
1439
- onChange: F
1440
- }) : y?.kind === "editable" ? /* @__PURE__ */ E(y.Report, {
1441
- result: f,
1442
- onResultChange: I
1443
- }) : /* @__PURE__ */ E(nt, { result: L }),
1444
- _ && /* @__PURE__ */ D("p", {
1728
+ panelExtraAnchorIndex: M.current,
1729
+ onDismiss: W,
1730
+ ...H ? { savedToDisk: !0 } : {},
1731
+ panelActions: K.content,
1732
+ composerActions: K.actions,
1733
+ panelExtra: p ? /* @__PURE__ */ A(O, { children: [
1734
+ x && S ? /* @__PURE__ */ k(x.Report, {
1735
+ result: p,
1736
+ selection: S,
1737
+ onChange: I
1738
+ }) : b?.kind === "editable" ? /* @__PURE__ */ k(b.Report, {
1739
+ result: p,
1740
+ onResultChange: L
1741
+ }) : /* @__PURE__ */ k(pt, { result: R }),
1742
+ _ && /* @__PURE__ */ A("p", {
1445
1743
  className: "text-xs text-destructive",
1446
1744
  children: ["Salvataggio automatico non riuscito: ", _]
1447
1745
  }),
1448
- /* @__PURE__ */ E(Qe, {
1746
+ /* @__PURE__ */ k(lt, {
1449
1747
  manifest: e,
1450
- result: L,
1748
+ result: R,
1451
1749
  meta: t,
1452
- taskId: d,
1453
- initiallyApplied: m,
1454
- onApplied: V,
1455
- extraDestinations: B
1750
+ taskId: f,
1751
+ initiallyApplied: h,
1752
+ onApplied: q,
1753
+ extraDestinations: V
1456
1754
  })
1457
1755
  ] }) : void 0
1458
1756
  });
1459
1757
  }, [
1460
- s.activity,
1461
- s.running,
1462
- s.error,
1463
- s.canContinue,
1464
- s.selectedModel,
1465
- s.modelsByProvider,
1466
- s.hasProviders,
1467
- c.openTask,
1468
- c.componentAnchors,
1469
- d,
1758
+ c.activity,
1759
+ c.running,
1760
+ c.error,
1761
+ c.canContinue,
1762
+ c.selectedModel,
1763
+ c.modelsByProvider,
1764
+ c.hasProviders,
1765
+ c.remoteModels,
1766
+ l.openTask,
1767
+ l.componentAnchors,
1768
+ f,
1470
1769
  e,
1471
1770
  t,
1472
- f,
1473
- L,
1474
- O,
1475
- m,
1771
+ p,
1772
+ R,
1773
+ S,
1774
+ h,
1476
1775
  n,
1477
1776
  r,
1478
- _
1479
- ]), b(() => () => {
1480
- c.closeTask(d);
1481
- }, [c.closeTask, d]), null;
1777
+ _,
1778
+ K.content,
1779
+ K.actions
1780
+ ]), C(() => () => {
1781
+ l.closeTask(f);
1782
+ }, [l.closeTask, f]), null;
1482
1783
  }
1483
1784
  //#endregion
1484
1785
  //#region src/presentation/OrchestratorRunner.tsx
1485
- function at({ userGoal: e }) {
1486
- let t = Z(), n = Ke(S(() => Xe({
1786
+ function bt({ userGoal: e }) {
1787
+ let t = Q(), n = nt(T(() => st({
1487
1788
  unavailable: t.orchestratorUnavailable,
1488
1789
  continueWithoutAi: t.orchestratorContinueWithoutAi,
1489
1790
  preparing: t.orchestratorPreparing,
1490
1791
  collecting: t.orchestratorCollecting
1491
- }), []), { defaultEnabled: !0 }), r = $(), [i, a] = w(null), o = C(!1), s = !n.hasProviders || n.selectedModel !== "", c = C(r.pendingExtraDestinations), l = C(r.pendingAttachments), u = C(r.pendingModel), d = C(r.pendingScopedSubagentId ?? r.scopedSubagentId ?? void 0), f = C(r.pendingCarryOver), p = C(!1), m = (e) => {
1492
- e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask(Q));
1792
+ }), []), { 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) => {
1793
+ e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask(Me));
1493
1794
  };
1494
- b(() => {
1795
+ C(() => {
1495
1796
  !o.current && s && (o.current = !0, u.current && n.setSelectedModel(u.current), n.run({
1496
1797
  userGoal: e,
1497
1798
  pageContext: r.pageContext,
@@ -1503,9 +1804,9 @@ function at({ userGoal: e }) {
1503
1804
  }).then((e) => {
1504
1805
  e && m(e);
1505
1806
  }));
1506
- }, [s]), b(() => {
1807
+ }, [s]), C(() => {
1507
1808
  p.current || r.openTask({
1508
- id: Q,
1809
+ id: Me,
1509
1810
  title: "Agentico",
1510
1811
  icon: "bot",
1511
1812
  agent: n,
@@ -1513,7 +1814,7 @@ function at({ userGoal: e }) {
1513
1814
  scopedSubagentId: d.current,
1514
1815
  precedingActivity: f.current?.activity,
1515
1816
  onDismiss: () => {
1516
- p.current = !0, n.running && n.stop(), r.closeTask(Q);
1817
+ p.current = !0, n.running && n.stop(), r.closeTask(Me);
1517
1818
  }
1518
1819
  });
1519
1820
  }, [
@@ -1525,13 +1826,13 @@ function at({ userGoal: e }) {
1525
1826
  n.modelsByProvider,
1526
1827
  n.hasProviders,
1527
1828
  r.openTask
1528
- ]), b(() => () => {
1529
- r.closeTask(Q);
1829
+ ]), C(() => () => {
1830
+ r.closeTask(Me);
1530
1831
  }, [r.closeTask]);
1531
- let h = S(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
1832
+ let h = T(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
1532
1833
  if (!i) return null;
1533
- let g = M(i.subagentId);
1534
- return g ? /* @__PURE__ */ E(it, {
1834
+ let g = B(i.subagentId);
1835
+ return g ? /* @__PURE__ */ k(yt, {
1535
1836
  manifest: g,
1536
1837
  params: i.params,
1537
1838
  extraDestinations: c.current,
@@ -1542,8 +1843,8 @@ function at({ userGoal: e }) {
1542
1843
  }
1543
1844
  //#endregion
1544
1845
  //#region src/presentation/ManualEntryRunner.tsx
1545
- function ot({ manifest: e, extraDestinations: n }) {
1546
- let r = Ke(e.definition, { defaultEnabled: !1 }), i = Z(), a = $(), o = C(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = w(null), [l, u] = w([]), d = tt(e.id), f = d?.kind === "selection" ? d : null, [p, m] = w(null), [h, g] = w(null), _ = C(!1), v = (t) => {
1846
+ function xt({ manifest: e, extraDestinations: n }) {
1847
+ let r = nt(e.definition, { defaultEnabled: !1 }), i = Q(), a = $(), o = E(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = D(null), [l, u] = D([]), d = ft(e.id), f = d?.kind === "selection" ? d : null, [p, m] = D(null), [h, g] = D(null), _ = E(!1), v = (t) => {
1547
1848
  if (!e.manualEntry) return;
1548
1849
  let n;
1549
1850
  try {
@@ -1556,7 +1857,7 @@ function ot({ manifest: e, extraDestinations: n }) {
1556
1857
  e && c(e);
1557
1858
  });
1558
1859
  };
1559
- b(() => {
1860
+ C(() => {
1560
1861
  s && f && m(f.defaultSelection(s));
1561
1862
  }, [s, f]);
1562
1863
  let y = (e, t) => {
@@ -1564,18 +1865,18 @@ function ot({ manifest: e, extraDestinations: n }) {
1564
1865
  ...n,
1565
1866
  [e]: t
1566
1867
  });
1567
- }, x = (e) => c(e), T = S(() => s && f && p ? f.applySelection(s, p) : s, [
1868
+ }, b = (e) => c(e), x = T(() => s && f && p ? f.applySelection(s, p) : s, [
1568
1869
  s,
1569
1870
  f,
1570
1871
  p
1571
- ]), O = (e) => {
1872
+ ]), S = (e) => {
1572
1873
  u((t) => t.includes(e) ? t : [...t, e]);
1573
- }, k = S(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), A = S(() => h ? rt(k, h, o) : null, [
1574
- k,
1874
+ }, w = T(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), O = T(() => h ? mt(w, h, o) : null, [
1875
+ w,
1575
1876
  h,
1576
1877
  o
1577
- ]), j = S(() => A ? [A, ...n ?? []] : n, [A, n]);
1578
- return b(() => {
1878
+ ]), j = T(() => O ? [O, ...n ?? []] : n, [O, n]);
1879
+ return C(() => {
1579
1880
  _.current || a.openTask({
1580
1881
  id: o,
1581
1882
  title: e.label,
@@ -1589,27 +1890,27 @@ function ot({ manifest: e, extraDestinations: n }) {
1589
1890
  onDismiss: () => {
1590
1891
  _.current = !0, r.running && r.stop(), a.closeTask(o);
1591
1892
  },
1592
- panelExtra: s ? /* @__PURE__ */ D("div", {
1893
+ panelExtra: s ? /* @__PURE__ */ A("div", {
1593
1894
  className: "space-y-2",
1594
1895
  children: [
1595
- f && p ? /* @__PURE__ */ E(f.Report, {
1896
+ f && p ? /* @__PURE__ */ k(f.Report, {
1596
1897
  result: s,
1597
1898
  selection: p,
1598
1899
  onChange: y
1599
- }) : d?.kind === "editable" ? /* @__PURE__ */ E(d.Report, {
1900
+ }) : d?.kind === "editable" ? /* @__PURE__ */ k(d.Report, {
1600
1901
  result: s,
1601
- onResultChange: x
1602
- }) : /* @__PURE__ */ E(nt, { result: T }),
1603
- /* @__PURE__ */ E(Qe, {
1902
+ onResultChange: b
1903
+ }) : /* @__PURE__ */ k(pt, { result: x }),
1904
+ /* @__PURE__ */ k(lt, {
1604
1905
  manifest: e,
1605
- result: T,
1906
+ result: x,
1606
1907
  meta: h ?? {},
1607
1908
  taskId: o,
1608
1909
  initiallyApplied: l,
1609
- onApplied: O,
1910
+ onApplied: S,
1610
1911
  extraDestinations: j
1611
1912
  }),
1612
- r.hasProviders && /* @__PURE__ */ E(t, {
1913
+ r.hasProviders && /* @__PURE__ */ k(t, {
1613
1914
  label: i.resumeWithAi,
1614
1915
  variant: "outline-secondary",
1615
1916
  className: "text-xs",
@@ -1627,18 +1928,18 @@ function ot({ manifest: e, extraDestinations: n }) {
1627
1928
  r.hasProviders,
1628
1929
  a.componentAnchors,
1629
1930
  s,
1630
- T,
1931
+ x,
1631
1932
  p,
1632
1933
  l,
1633
1934
  h
1634
- ]), b(() => () => {
1935
+ ]), C(() => () => {
1635
1936
  a.closeTask(o);
1636
1937
  }, []), null;
1637
1938
  }
1638
1939
  //#endregion
1639
1940
  //#region src/presentation/Agentico.tsx
1640
- var st = 420;
1641
- function ct(e) {
1941
+ var St = 420;
1942
+ function Ct(e) {
1642
1943
  return Object.values(e).flat().map((e) => ({
1643
1944
  label: e.model,
1644
1945
  value: e.id,
@@ -1646,51 +1947,52 @@ function ct(e) {
1646
1947
  group: e.providerLabel ?? e.provider
1647
1948
  }));
1648
1949
  }
1649
- function lt({ task: e }) {
1650
- let t = Z(), [n, i] = w(""), { agent: a, onApplied: o, manualEntry: s } = e, c = a.running, l = (e) => {
1651
- if (i(""), s) {
1950
+ function wt({ task: e }) {
1951
+ let t = Q(), [n, r] = D(""), { agent: i, onApplied: a, manualEntry: s } = e, c = i.running, l = (e) => {
1952
+ if (r(""), s) {
1652
1953
  s.onSubmit(e.text);
1653
1954
  return;
1654
1955
  }
1655
- a.sendMessage(e.text, {
1956
+ i.sendMessage(e.text, {
1656
1957
  attachments: e.files,
1657
1958
  model: e.model
1658
1959
  }).then((e) => {
1659
- e && o(e);
1960
+ e && a(e);
1660
1961
  });
1661
- }, u = !s && a.hasProviders && !a.selectedModel;
1662
- return /* @__PURE__ */ E(r, {
1962
+ }, u = !!s || i.remote && i.remoteModels.length === 0, d = !u && !i.remote && i.hasProviders && !i.selectedModel, f = u ? [] : i.remote ? i.remoteModels : Ct(i.modelsByProvider);
1963
+ return /* @__PURE__ */ k(o, {
1663
1964
  value: n,
1664
- onChange: i,
1965
+ onChange: r,
1665
1966
  placeholder: s?.prompt ?? t.messagePlaceholder,
1666
1967
  running: c,
1667
- onStop: a.stop,
1668
- disabled: !n.trim() || u,
1968
+ onStop: i.stop,
1969
+ disabled: !n.trim() || d,
1669
1970
  onSubmit: l,
1670
- attachments: !s,
1671
- models: s ? [] : ct(a.modelsByProvider),
1672
- selectedModel: s ? "" : a.selectedModel,
1673
- onModelChange: a.setSelectedModel,
1971
+ attachments: !s && !i.remote,
1972
+ models: f,
1973
+ selectedModel: u ? "" : i.selectedModel,
1974
+ actions: e.composerActions,
1975
+ onModelChange: i.setSelectedModel,
1674
1976
  modelPlaceholder: t.selectModelPlaceholder,
1675
1977
  minHeight: 44,
1676
1978
  maxHeight: 220
1677
1979
  });
1678
1980
  }
1679
- function ut() {
1680
- let { startOrchestrator: e } = $(), t = Z(), [n, i] = w(""), { hasProviders: a, modelsByProvider: o, selectedModel: s, setSelectedModel: c } = He(), l = (t) => {
1981
+ function Tt() {
1982
+ let { startOrchestrator: e } = $(), t = Q(), [n, r] = D(""), { hasProviders: i, modelsByProvider: a, selectedModel: s, setSelectedModel: c } = Qe(), l = (t) => {
1681
1983
  t.text.trim() && (e(t.text.trim(), {
1682
1984
  attachments: t.files.length > 0 ? t.files : void 0,
1683
1985
  model: t.model || void 0
1684
- }), i(""));
1685
- }, u = a && !s;
1686
- return /* @__PURE__ */ E(r, {
1986
+ }), r(""));
1987
+ }, u = i && !s;
1988
+ return /* @__PURE__ */ k(o, {
1687
1989
  value: n,
1688
- onChange: i,
1990
+ onChange: r,
1689
1991
  placeholder: t.orchestratorStarterPlaceholder,
1690
1992
  disabled: !n.trim() || u,
1691
1993
  onSubmit: l,
1692
1994
  attachments: !0,
1693
- models: ct(o),
1995
+ models: Ct(a),
1694
1996
  selectedModel: s,
1695
1997
  onModelChange: c,
1696
1998
  modelPlaceholder: t.selectModelPlaceholder,
@@ -1698,55 +2000,67 @@ function ut() {
1698
2000
  maxHeight: 220
1699
2001
  });
1700
2002
  }
1701
- function dt({ card: e }) {
1702
- let t = Z();
1703
- return e.humanSummaryOnly ? /* @__PURE__ */ D("div", {
2003
+ function Et(e, t, n = Date.now()) {
2004
+ let r = Math.round((e - n) / 1e3), i = new Intl.RelativeTimeFormat(t, {
2005
+ numeric: "auto",
2006
+ style: "short"
2007
+ });
2008
+ for (let [e, t] of [
2009
+ ["day", 86400],
2010
+ ["hour", 3600],
2011
+ ["minute", 60]
2012
+ ]) if (Math.abs(r) >= t) return i.format(Math.round(r / t), e);
2013
+ return i.format(0, "minute");
2014
+ }
2015
+ function Dt({ card: e }) {
2016
+ let t = Q();
2017
+ return e.humanSummaryOnly ? /* @__PURE__ */ A("div", {
1704
2018
  className: "space-y-2 rounded-lg border border-border/60 p-3",
1705
- children: [/* @__PURE__ */ D("p", {
2019
+ children: [/* @__PURE__ */ A("p", {
1706
2020
  className: "text-xs font-medium text-foreground",
1707
2021
  children: [
1708
2022
  "\"",
1709
2023
  e.label,
1710
2024
  "\""
1711
2025
  ]
1712
- }), /* @__PURE__ */ E("p", {
2026
+ }), /* @__PURE__ */ k("p", {
1713
2027
  className: "text-xs text-muted-foreground",
1714
2028
  children: e.humanSummary
1715
2029
  })]
1716
- }) : /* @__PURE__ */ D("div", {
2030
+ }) : /* @__PURE__ */ A("div", {
1717
2031
  className: "space-y-2 rounded-lg border border-border/60 p-3",
1718
2032
  children: [
1719
- /* @__PURE__ */ E("p", {
2033
+ /* @__PURE__ */ k("p", {
1720
2034
  className: "text-xs font-medium text-foreground",
1721
- children: u(t.newInstance, { label: e.label })
2035
+ children: m(t.newInstance, { label: e.label })
1722
2036
  }),
1723
- /* @__PURE__ */ E("p", {
2037
+ /* @__PURE__ */ k("p", {
1724
2038
  className: "text-xs text-muted-foreground",
1725
2039
  children: e.humanSummary
1726
2040
  }),
1727
- e.fields.length > 0 && /* @__PURE__ */ E("ul", {
2041
+ e.fields.length > 0 && /* @__PURE__ */ k("ul", {
1728
2042
  className: "space-y-1",
1729
- children: e.fields.map((e) => /* @__PURE__ */ D("li", {
2043
+ children: e.fields.map((e) => /* @__PURE__ */ A("li", {
1730
2044
  className: "flex items-start gap-1.5 text-xs",
1731
- children: [/* @__PURE__ */ E(n, {
2045
+ children: [/* @__PURE__ */ k(n, {
1732
2046
  variant: e.required ? "primary" : "secondary",
1733
2047
  className: "mt-px shrink-0",
1734
2048
  children: e.required ? "richiesto" : "opzionale"
1735
- }), /* @__PURE__ */ D("span", {
2049
+ }), /* @__PURE__ */ A("span", {
1736
2050
  className: "min-w-0",
1737
- children: [/* @__PURE__ */ E("span", {
2051
+ children: [/* @__PURE__ */ k("span", {
1738
2052
  className: "font-mono text-foreground",
1739
2053
  children: e.key
1740
- }), e.humanDescription ? /* @__PURE__ */ D("span", {
2054
+ }), e.humanDescription ? /* @__PURE__ */ A("span", {
1741
2055
  className: "text-muted-foreground",
1742
2056
  children: [" — ", e.humanDescription]
1743
2057
  }) : null]
1744
2058
  })]
1745
2059
  }, e.key))
1746
2060
  }),
1747
- e.example && /* @__PURE__ */ D("p", {
2061
+ e.example && /* @__PURE__ */ A("p", {
1748
2062
  className: "text-xs text-muted-foreground",
1749
- children: ["Esempio: ", /* @__PURE__ */ E("span", {
2063
+ children: ["Esempio: ", /* @__PURE__ */ k("span", {
1750
2064
  className: "font-mono",
1751
2065
  children: e.example
1752
2066
  })]
@@ -1754,188 +2068,244 @@ function dt({ card: e }) {
1754
2068
  ]
1755
2069
  });
1756
2070
  }
1757
- function ft({ messages: e }) {
1758
- return /* @__PURE__ */ E("div", {
2071
+ function Ot({ messages: e }) {
2072
+ return /* @__PURE__ */ k("div", {
1759
2073
  className: "space-y-2 rounded-lg border border-border/60 p-3",
1760
- children: e.map((e, t) => /* @__PURE__ */ E("p", {
2074
+ children: e.map((e, t) => /* @__PURE__ */ k("p", {
1761
2075
  className: "text-xs text-muted-foreground",
1762
2076
  children: e
1763
2077
  }, t))
1764
2078
  });
1765
2079
  }
1766
- function pt({ scopeId: e, open: n, onOpenChange: r, onSelect: i, onNewChat: c }) {
1767
- let l = Z(), [u, d] = w(""), f = S(() => n ? ye(e) : [], [e, n]), p = S(() => {
1768
- let e = u.trim().toLowerCase();
1769
- return e ? f.filter((t) => {
1770
- let n = M(t.subagentId)?.label ?? t.subagentId;
2080
+ function kt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2081
+ let d = Q(), { locale: f } = v(), [p, m] = D(""), [h, g] = D(0), _ = T(() => r ? Ee(e) : [], [
2082
+ e,
2083
+ r,
2084
+ h
2085
+ ]), y = async (t) => {
2086
+ let r = B(t.subagentId), i = await r?.confirmArchive?.(t.entityId, t.params);
2087
+ if (!i || window.confirm(i)) {
2088
+ try {
2089
+ await r?.onArchive?.(t.entityId, t.params);
2090
+ } catch {
2091
+ return;
2092
+ }
2093
+ Te(e, t.subagentId, t.entityId), n === De(t.subagentId, t.entityId) && s(), g((e) => e + 1);
2094
+ }
2095
+ }, b = T(() => {
2096
+ let e = p.trim().toLowerCase();
2097
+ return e ? _.filter((t) => {
2098
+ let n = B(t.subagentId)?.label ?? t.subagentId;
1771
2099
  return t.title.toLowerCase().includes(e) || n.toLowerCase().includes(e);
1772
- }) : f;
1773
- }, [f, u]);
1774
- return /* @__PURE__ */ E(a, {
2100
+ }) : _;
2101
+ }, [_, p]);
2102
+ return /* @__PURE__ */ k(c, {
1775
2103
  trigger: {
1776
2104
  icon: "history",
1777
- title: l.chatHistory
2105
+ title: d.chatHistory
1778
2106
  },
1779
2107
  triggerClassName: "!h-9 !w-9 !p-0 rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground",
1780
- open: n,
1781
- onOpenChange: r,
2108
+ open: r,
2109
+ onOpenChange: i,
1782
2110
  position: "end",
1783
2111
  strategy: "absolute",
1784
2112
  menuClassName: "w-[380px] max-h-[70vh] overflow-y-auto",
1785
- header: /* @__PURE__ */ D("div", {
2113
+ header: /* @__PURE__ */ A("div", {
1786
2114
  className: "flex items-center gap-2 px-1 pb-1.5",
1787
2115
  children: [
1788
- /* @__PURE__ */ E(s, {
2116
+ /* @__PURE__ */ k(u, {
1789
2117
  name: "search",
1790
2118
  size: 14,
1791
2119
  className: "shrink-0 text-muted-foreground"
1792
2120
  }),
1793
- /* @__PURE__ */ E("input", {
2121
+ /* @__PURE__ */ k("input", {
1794
2122
  autoFocus: !0,
1795
- value: u,
1796
- onChange: (e) => d(e.target.value),
1797
- placeholder: l.searchChats,
2123
+ value: p,
2124
+ onChange: (e) => m(e.target.value),
2125
+ placeholder: d.searchChats,
1798
2126
  className: "min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
1799
2127
  }),
1800
- /* @__PURE__ */ E(t, {
2128
+ /* @__PURE__ */ k(t, {
1801
2129
  icon: "square-pen",
1802
- ariaLabel: l.newChat,
1803
- title: l.newChat,
2130
+ ariaLabel: d.newChat,
2131
+ title: d.newChat,
1804
2132
  variant: "link",
1805
2133
  className: "shrink-0",
1806
- onClick: c
2134
+ onClick: o
1807
2135
  })
1808
2136
  ]
1809
2137
  }),
1810
- children: p.length === 0 ? /* @__PURE__ */ E("p", {
2138
+ children: b.length === 0 ? /* @__PURE__ */ k("p", {
1811
2139
  className: "px-2 py-3 text-center text-xs text-muted-foreground",
1812
- children: f.length === 0 ? l.noSavedChats : l.noResults
1813
- }) : p.map((e) => {
1814
- let t = M(e.subagentId);
1815
- return /* @__PURE__ */ E(o, {
1816
- icon: t?.icon ?? "bot",
1817
- onClick: () => i(e.subagentId, e.entityId, e),
1818
- children: /* @__PURE__ */ D("span", {
2140
+ children: _.length === 0 ? d.noSavedChats : d.noResults
2141
+ }) : b.map((e) => {
2142
+ let t = B(e.subagentId), r = n === De(e.subagentId, e.entityId);
2143
+ return /* @__PURE__ */ k(l, {
2144
+ icon: r ? "check" : t?.icon ?? "bot",
2145
+ className: r ? "bg-accent font-medium" : void 0,
2146
+ actions: [{
2147
+ icon: "archive",
2148
+ label: d.archiveChat,
2149
+ onClick: () => void y(e)
2150
+ }],
2151
+ onClick: () => a(e.subagentId, e.entityId, e),
2152
+ children: /* @__PURE__ */ A("span", {
1819
2153
  className: "flex min-w-0 flex-1 items-center justify-between gap-2",
1820
- children: [/* @__PURE__ */ D("span", {
2154
+ children: [/* @__PURE__ */ A("span", {
1821
2155
  className: "min-w-0 truncate",
1822
2156
  children: [
1823
- /* @__PURE__ */ E("span", {
2157
+ /* @__PURE__ */ k("span", {
1824
2158
  className: "text-muted-foreground",
1825
2159
  children: t?.label ?? e.subagentId
1826
2160
  }),
1827
2161
  " · ",
1828
2162
  e.title || e.entityId
1829
2163
  ]
1830
- }), /* @__PURE__ */ E("span", {
2164
+ }), /* @__PURE__ */ k("span", {
1831
2165
  className: "shrink-0 text-xs text-muted-foreground",
1832
- children: new Date(e.savedAt).toLocaleString()
2166
+ title: new Date(e.savedAt).toLocaleString(f),
2167
+ children: Et(e.savedAt, f)
1833
2168
  })]
1834
2169
  })
1835
2170
  }, `${e.subagentId}:${e.entityId}`);
1836
2171
  })
1837
2172
  });
1838
2173
  }
1839
- function mt() {
1840
- let { task: e, isOpen: n, pendingGoal: r, orchestratorRunId: i, pageContext: a, pageContextCard: o, anchoredUserMessages: s, pendingResume: c, resumeRunId: l, dismissForeignTask: u, resumeEntityChat: d, pendingManualEntry: f, manualEntryRunId: p, startManualEntry: m, pendingExtraDestinations: h, pendingResumeWithAI: g, resumeWithAIRunId: _, scope: v } = $(), y = Z(), x = C(null), [S, O] = w(!1), k = () => {
1841
- (!e || e.agent.running || e.savedToDisk || window.confirm(y.unsavedConversationConfirm)) && (u(), O(!1));
1842
- }, A = e ? [...e.precedingActivity ?? [], ...e.agent.activity] : [], j = A.length, N = Math.max(0, Math.min(e?.panelExtraAnchorIndex ?? j, j)), P = A.slice(0, N), F = A.slice(N), I = !!(e && !e.agent.running && e.agent.error), L = e?.id === "agentico-orchestrator" && e.scopedSubagentId ? M(e.scopedSubagentId) : void 0, R = L?.manualEntry ? L : null, z = C(!0);
1843
- b(() => {
1844
- let e = x.current;
2174
+ function At() {
2175
+ let { task: e, isOpen: n, pendingGoal: r, orchestratorRunId: i, pageContext: a, pageContextCard: o, anchoredUserMessages: s, pendingResume: c, resumeRunId: l, dismissForeignTask: u, resumeEntityChat: d, pendingManualEntry: f, manualEntryRunId: p, startManualEntry: m, pendingExtraDestinations: h, pendingResumeWithAI: g, resumeWithAIRunId: _, pendingStart: v, startRunId: y, scope: b } = $(), x = Q(), S = E(null), [w, T] = D(!1), j = () => {
2176
+ (!e || e.agent.running || e.savedToDisk || window.confirm(x.unsavedConversationConfirm)) && (u(), T(!1));
2177
+ }, M = e ? [...e.precedingActivity ?? [], ...e.agent.activity] : [], N = M.length, P = Math.max(0, Math.min(e?.panelExtraAnchorIndex ?? N, N)), F = M.slice(0, P), I = M.slice(P), L = !!(e && !e.agent.running && e.agent.error), R = new Set(e?.agent.activity.map((e) => e.id) ?? []), z = e ? {
2178
+ canAnswer: (e) => R.has(e),
2179
+ onAnswer: (t, n, r) => e.agent.answerQuestions(t, n, r).then((t) => {
2180
+ t && e.onApplied(t);
2181
+ })
2182
+ } : void 0, V = e?.id === "agentico-orchestrator" && e.scopedSubagentId ? B(e.scopedSubagentId) : void 0, H = V?.manualEntry ? V : null, U = E(!0);
2183
+ C(() => {
2184
+ let e = S.current;
1845
2185
  if (!e) return;
1846
2186
  let t = () => {
1847
- z.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
2187
+ U.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
1848
2188
  };
1849
2189
  return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
1850
- }, [e?.id]), b(() => {
1851
- let e = x.current;
1852
- e && (z.current = !0, e.scrollTop = e.scrollHeight);
1853
- }, [e?.id]), b(() => {
1854
- let e = x.current;
1855
- e && z.current && (e.scrollTop = e.scrollHeight);
1856
- }, [j, I]);
1857
- let B = r ? /* @__PURE__ */ E(at, { userGoal: r }, i) : null, V = c ? M(c.subagentId) : void 0, ee = c && V ? /* @__PURE__ */ E(it, {
1858
- manifest: V,
2190
+ }, [e?.id]), C(() => {
2191
+ let e = S.current;
2192
+ e && (U.current = !0, e.scrollTop = e.scrollHeight);
2193
+ }, [e?.id]);
2194
+ let W = M.at(-1)?.detail?.length ?? 0;
2195
+ C(() => {
2196
+ let e = S.current;
2197
+ e && U.current && (e.scrollTop = e.scrollHeight);
2198
+ }, [
2199
+ N,
2200
+ L,
2201
+ W
2202
+ ]);
2203
+ let G = E(null);
2204
+ C(() => {
2205
+ let e = S.current, t = G.current;
2206
+ if (!e || !t || typeof ResizeObserver > "u") return;
2207
+ let n = new ResizeObserver(() => {
2208
+ U.current && (e.scrollTop = e.scrollHeight);
2209
+ });
2210
+ return n.observe(t), () => n.disconnect();
2211
+ }, [e?.id, n]);
2212
+ let K = r ? /* @__PURE__ */ k(bt, { userGoal: r }, i) : null, q = c ? B(c.subagentId) : void 0, J = c && q ? /* @__PURE__ */ k(yt, {
2213
+ manifest: q,
1859
2214
  params: c.snapshot.params,
1860
- taskId: `entitychat-${c.subagentId}-${c.entityId}`,
2215
+ taskId: De(c.subagentId, c.entityId),
1861
2216
  resumeSeed: {
1862
2217
  history: c.snapshot.history,
1863
2218
  activity: c.snapshot.activity
1864
2219
  }
1865
- }, l) : null, H = f ? M(f.subagentId) : void 0, te = f && H ? /* @__PURE__ */ E(ot, {
1866
- manifest: H,
2220
+ }, l) : null, Y = f ? B(f.subagentId) : void 0, ee = f && Y ? /* @__PURE__ */ k(xt, {
2221
+ manifest: Y,
1867
2222
  extraDestinations: f.extraDestinations
1868
- }, p) : null, ne = g ? M(g.subagentId) : void 0, U = g && ne ? /* @__PURE__ */ E(it, {
1869
- manifest: ne,
2223
+ }, p) : null, X = g ? B(g.subagentId) : void 0, te = g && X ? /* @__PURE__ */ k(yt, {
2224
+ manifest: X,
1870
2225
  params: g.params,
1871
2226
  extraDestinations: g.extraDestinations
1872
- }, _) : null;
1873
- return n ? /* @__PURE__ */ D(T, { children: [
1874
- B,
2227
+ }, _) : null, ne = v ? B(v.subagentId) : void 0, re = v && ne ? /* @__PURE__ */ k(yt, {
2228
+ manifest: ne,
2229
+ params: v.params,
2230
+ taskId: v.taskId,
2231
+ openingMessage: v.openingMessage
2232
+ }, y) : null;
2233
+ return n ? /* @__PURE__ */ A(O, { children: [
2234
+ K,
2235
+ J,
1875
2236
  ee,
1876
2237
  te,
1877
- U,
1878
- /* @__PURE__ */ D("div", {
2238
+ re,
2239
+ /* @__PURE__ */ A("div", {
1879
2240
  style: { width: 420 },
1880
2241
  className: "relative flex h-full shrink-0 flex-col border-l border-border bg-background",
1881
2242
  children: [
1882
- /* @__PURE__ */ D("div", {
2243
+ /* @__PURE__ */ A("div", {
1883
2244
  className: "flex min-h-[60px] items-center gap-1 border-b border-border/60 px-4 py-3",
1884
2245
  children: [
1885
- /* @__PURE__ */ E("span", {
2246
+ /* @__PURE__ */ k("span", {
1886
2247
  className: "min-w-0 flex-1 truncate text-lg font-semibold leading-tight",
1887
2248
  children: e ? e.title : "Agentico"
1888
2249
  }),
1889
- v && /* @__PURE__ */ E(pt, {
1890
- scopeId: v.id,
1891
- open: S,
1892
- onOpenChange: O,
1893
- onNewChat: k,
1894
- onSelect: (e, t, n) => d(e, t, n)
2250
+ b && /* @__PURE__ */ k(kt, {
2251
+ scopeId: b.id,
2252
+ currentTaskId: e?.id ?? null,
2253
+ open: w,
2254
+ onOpenChange: T,
2255
+ onNewChat: j,
2256
+ onSelect: (e, t, n) => d(e, t, n),
2257
+ onArchivedCurrent: u
1895
2258
  }),
1896
- /* @__PURE__ */ E(Re, {})
2259
+ /* @__PURE__ */ k(Je, {})
1897
2260
  ]
1898
2261
  }),
1899
- /* @__PURE__ */ E("div", {
1900
- ref: x,
2262
+ /* @__PURE__ */ k("div", {
2263
+ ref: S,
1901
2264
  className: "flex-1 overflow-y-auto px-3 pb-2",
1902
- children: /* @__PURE__ */ E("div", {
2265
+ children: /* @__PURE__ */ k("div", {
2266
+ ref: G,
1903
2267
  className: "pt-2",
1904
- children: e ? /* @__PURE__ */ D(T, { children: [
1905
- e.manualEntry && A.length === 0 && /* @__PURE__ */ E("p", {
2268
+ children: e ? /* @__PURE__ */ A(O, { children: [
2269
+ e.manualEntry && M.length === 0 && /* @__PURE__ */ k("p", {
1906
2270
  className: "text-xs text-muted-foreground",
1907
2271
  children: e.manualEntry.prompt
1908
2272
  }),
1909
- /* @__PURE__ */ E(Le, { activity: P }),
1910
- e.panelExtra && /* @__PURE__ */ E("div", {
2273
+ /* @__PURE__ */ k(qe, {
2274
+ activity: F,
2275
+ questions: z
2276
+ }),
2277
+ e.panelExtra && /* @__PURE__ */ k("div", {
1911
2278
  className: "mt-3",
1912
2279
  children: e.panelExtra
1913
2280
  }),
1914
- F.length > 0 && /* @__PURE__ */ E(Le, { activity: F }),
1915
- !e.agent.running && e.agent.error && /* @__PURE__ */ D("div", {
2281
+ I.length > 0 && /* @__PURE__ */ k(qe, {
2282
+ activity: I,
2283
+ questions: z
2284
+ }),
2285
+ !e.agent.running && e.agent.error && /* @__PURE__ */ A("div", {
1916
2286
  className: "mt-2 flex items-center gap-2",
1917
2287
  children: [
1918
- /* @__PURE__ */ E("p", {
2288
+ /* @__PURE__ */ k("p", {
1919
2289
  className: "flex-1 text-xs text-destructive",
1920
2290
  children: e.agent.error
1921
2291
  }),
1922
- /* @__PURE__ */ E(t, {
1923
- label: y.retry,
2292
+ /* @__PURE__ */ k(t, {
2293
+ label: x.retry,
1924
2294
  variant: "secondary",
1925
2295
  className: "shrink-0",
1926
2296
  onClick: () => {
1927
- e.agent.sendMessage(y.retryMessage).then((t) => {
2297
+ e.agent.sendMessage(x.retryMessage).then((t) => {
1928
2298
  t && e.onApplied(t);
1929
2299
  });
1930
2300
  }
1931
2301
  }),
1932
- /* @__PURE__ */ E(t, {
1933
- label: y.continueWithoutAi,
2302
+ !e.agent.remote && /* @__PURE__ */ k(t, {
2303
+ label: x.continueWithoutAi,
1934
2304
  variant: "secondary",
1935
2305
  className: "shrink-0",
1936
2306
  onClick: () => {
1937
- if (R) {
1938
- m(R.id, h);
2307
+ if (H) {
2308
+ m(H.id, h);
1939
2309
  return;
1940
2310
  }
1941
2311
  let t = e.agent.runFallback();
@@ -1944,36 +2314,40 @@ function mt() {
1944
2314
  })
1945
2315
  ]
1946
2316
  })
1947
- ] }) : s.length > 0 ? /* @__PURE__ */ E(ft, { messages: s }) : o ? /* @__PURE__ */ E(dt, { card: o }) : /* @__PURE__ */ E("p", {
2317
+ ] }) : s.length > 0 ? /* @__PURE__ */ k(Ot, { messages: s }) : o ? /* @__PURE__ */ k(Dt, { card: o }) : /* @__PURE__ */ k("p", {
1948
2318
  className: "text-xs text-muted-foreground",
1949
- children: a ?? y.orchestratorStarterHint
2319
+ children: a ?? x.orchestratorStarterHint
1950
2320
  })
1951
2321
  })
1952
2322
  }),
1953
- /* @__PURE__ */ E("div", {
2323
+ /* @__PURE__ */ A("div", {
1954
2324
  className: "border-t border-border/60 px-4 py-3",
1955
- children: e ? /* @__PURE__ */ E(lt, { task: e }, e.id) : /* @__PURE__ */ E(ut, {})
2325
+ children: [e?.panelActions && /* @__PURE__ */ k("div", {
2326
+ className: "mb-2",
2327
+ children: e.panelActions
2328
+ }), e ? /* @__PURE__ */ k(wt, { task: e }, e.id) : /* @__PURE__ */ k(Tt, {})]
1956
2329
  })
1957
2330
  ]
1958
2331
  })
1959
- ] }) : /* @__PURE__ */ D(T, { children: [
1960
- B,
2332
+ ] }) : /* @__PURE__ */ A(O, { children: [
2333
+ K,
2334
+ J,
1961
2335
  ee,
1962
2336
  te,
1963
- U
2337
+ re
1964
2338
  ] });
1965
2339
  }
1966
2340
  //#endregion
1967
2341
  //#region src/presentation/useAgenticoPageContext.ts
1968
- function ht(e, t) {
1969
- let { setPageContext: n } = $(), r = C(crypto.randomUUID()).current;
1970
- b(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
2342
+ function jt(e, t) {
2343
+ let { setPageContext: n } = $(), r = E(crypto.randomUUID()).current;
2344
+ C(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
1971
2345
  }
1972
2346
  //#endregion
1973
2347
  //#region src/presentation/useSubagentComponentContext.ts
1974
- function gt(e, t, n, r, i = !0, a) {
1975
- let { registerComponentAnchor: o } = $(), s = C(crypto.randomUUID()).current, c = C(n);
1976
- c.current = n, b(() => {
2348
+ function Mt(e, t, n, r, i = !0, a) {
2349
+ let { registerComponentAnchor: o } = $(), s = E(crypto.randomUUID()).current, c = E(n);
2350
+ c.current = n, C(() => {
1977
2351
  if (i) return o(s, {
1978
2352
  subagentId: e,
1979
2353
  componentKey: t,
@@ -1990,6 +2364,6 @@ function gt(e, t, n, r, i = !0, a) {
1990
2364
  ]);
1991
2365
  }
1992
2366
  //#endregion
1993
- export { st as AGENTICO_WIDTH, mt as Agentico, Te as AgenticoProvider, Re as AgenticoToggle, le as JSON_EXPORT_DESTINATION_ID, oe as MICRO_PROMPT_REGISTRY, Q as ORCHESTRATOR_TASK_ID, ae as SUMMARY_MICRO_PROMPT, be as agenticoDe, xe as agenticoEn, Se as agenticoIt, z as agenticoPromptsEn, B as agenticoPromptsIt, Ce as agenticoTranslations, G as applyMicroPrompts, ee as configureAgenticoPrompts, pe as configureEntityChatStore, F as createCrossAgentTools, O as defineSubagent, K as extractErrorMessage, se as extractJsonBlock, M as findSubagentManifest, H as getAgenticoPrompts, J as getDestinationRegistry, ge as getEntityChat, j as getSubagentRegistry, tt as getSubagentReport, q as jsonExportDestination, ye as listEntityChats, P as registerCrossAgentTools, de as registerDestinations, et as registerSubagentReports, A as registerSubagents, ve as removeEntityChat, ie as renderRegistryCli, re as renderSubagentCli, te as resetAgenticoPrompts, _e as saveEntityChat, I as toJsonSchema, L as toMcpTool, Ke as useAgent, $ as useAgentico, Z as useAgenticoI18n, ht as useAgenticoPageContext, gt as useSubagentComponentContext };
2367
+ export { St as AGENTICO_WIDTH, At as Agentico, Pe as AgenticoProvider, Je as AgenticoToggle, M as DEFAULT_REASONING_PART_ID, j as DEFAULT_TEXT_PART_ID, fe as JSON_EXPORT_DESTINATION_ID, ce as MICRO_PROMPT_REGISTRY, Me as ORCHESTRATOR_TASK_ID, se as SUMMARY_MICRO_PROMPT, Oe as agenticoDe, ke as agenticoEn, Ae as agenticoIt, q as agenticoPromptsEn, J as agenticoPromptsIt, je as agenticoTranslations, le as applyMicroPrompts, ee as configureAgenticoPrompts, ve as configureEntityChatStore, U as createCrossAgentTools, I as defineSubagent, De as entityChatTaskId, Z as extractErrorMessage, ue as extractJsonBlock, B as findSubagentManifest, F as formatQuestionAnswers, X as getAgenticoPrompts, ge as getDestinationRegistry, Ce as getEntityChat, _t as getSubagentControls, z as getSubagentRegistry, ft as getSubagentReport, pe as jsonExportDestination, Ee as listEntityChats, P as messagePartsText, H as registerCrossAgentTools, he as registerDestinations, gt as registerSubagentControls, dt as registerSubagentReports, R as registerSubagents, Te as removeEntityChat, oe as renderRegistryCli, ae as renderSubagentCli, te as resetAgenticoPrompts, we as saveEntityChat, W as toJsonSchema, G as toMcpTool, N as upsertMessagePart, nt as useAgent, $ as useAgentico, Q as useAgenticoI18n, jt as useAgenticoPageContext, Mt as useSubagentComponentContext };
1994
2368
 
1995
2369
  //# sourceMappingURL=index.mjs.map