@llmnative/agentico 0.6.0 → 0.7.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
@@ -99,6 +99,7 @@ var K = {
99
99
  userRequestHeading: "## User request",
100
100
  noToolsAvailable: "No tools available.",
101
101
  stopCallingTools: "Stop calling tools. Answer NOW with the final result, in the required format, using everything collected so far.",
102
+ toolRejected: "Not done: the person rejected this action{reason}. Do not call it again unless they ask for it.",
102
103
  handoffQueued: "{label} has been queued for the real execution — the result is not available in this conversation yet.",
103
104
  closingSummary: [
104
105
  "When you are done answering (with or without tools in this turn),",
@@ -127,6 +128,7 @@ var K = {
127
128
  userRequestHeading: "## Richiesta dell'utente",
128
129
  noToolsAvailable: "Nessun tool disponibile.",
129
130
  stopCallingTools: "Basta chiamare tool. Rispondi ORA con il risultato finale, nel formato richiesto, usando tutte le informazioni raccolte finora.",
131
+ toolRejected: "Non fatto: la persona ha rifiutato questa azione{reason}. Non richiamarla se non te lo chiede.",
130
132
  handoffQueued: "{label} è stato messo in coda per l'esecuzione reale — il risultato non è ancora disponibile in questa conversazione.",
131
133
  closingSummary: [
132
134
  "Quando hai finito di rispondere (con o senza aver usato dei tool in questo turno),",
@@ -349,6 +351,10 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
349
351
  modelRequestError: "Fehler bei der Anfrage an das Modell",
350
352
  noProviderResponse: "Keine Antwort vom AI-Provider.",
351
353
  noActiveSession: "Keine aktive Sitzung — zuerst run() aufrufen.",
354
+ approvalHeader: "Freigabe",
355
+ approve: "Freigeben",
356
+ reject: "Ablehnen",
357
+ approveQuestion: "Freigeben? {action}",
352
358
  requestInProgress: "Eine andere Anfrage läuft bereits.",
353
359
  invalidResponse: "Ungültige AI-Antwort.",
354
360
  responseReceived: "Antwort erhalten",
@@ -401,6 +407,10 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
401
407
  modelRequestError: "Error in the request to the model",
402
408
  noProviderResponse: "No response from the AI provider.",
403
409
  noActiveSession: "No active session — call run() first.",
410
+ approvalHeader: "Approval",
411
+ approve: "Approve",
412
+ reject: "Reject",
413
+ approveQuestion: "Approve? {action}",
404
414
  requestInProgress: "Another request is already running.",
405
415
  invalidResponse: "Invalid AI response.",
406
416
  responseReceived: "Response received",
@@ -453,6 +463,10 @@ var De = (e, t) => `entitychat-${e}-${t}`, Oe = {
453
463
  modelRequestError: "Errore nella richiesta al modello",
454
464
  noProviderResponse: "Nessuna risposta dal provider AI.",
455
465
  noActiveSession: "Nessuna sessione attiva — chiama prima run().",
466
+ approvalHeader: "Approvazione",
467
+ approve: "Approva",
468
+ reject: "Rifiuta",
469
+ approveQuestion: "Approvi? {action}",
456
470
  requestInProgress: "Un'altra richiesta è già in corso.",
457
471
  invalidResponse: "Risposta AI non valida.",
458
472
  responseReceived: "Risposta ricevuta",
@@ -1162,12 +1176,25 @@ function dt() {
1162
1176
  };
1163
1177
  }
1164
1178
  //#endregion
1179
+ //#region src/domain/approval.ts
1180
+ var ft = "approval";
1181
+ function pt(e, t) {
1182
+ return typeof e.needsApproval == "function" ? e.needsApproval(t) : e.needsApproval === !0;
1183
+ }
1184
+ function mt(e, t, n) {
1185
+ let r = e[0]?.values ?? [], i = r.filter((e) => e !== t && e !== n).join(" ").trim();
1186
+ return {
1187
+ approved: r.includes(t) && !r.includes(n),
1188
+ ...i ? { reason: i } : {}
1189
+ };
1190
+ }
1191
+ //#endregion
1165
1192
  //#region src/presentation/useAgent.ts
1166
- var ft = 20, pt = 26e4;
1167
- function mt(e) {
1168
- return e.filter((e) => !d.isTextAttachment(e.mimeType) || e.base64.length <= pt);
1193
+ var ht = 20, gt = 26e4;
1194
+ function _t(e) {
1195
+ return e.filter((e) => !d.isTextAttachment(e.mimeType) || e.base64.length <= gt);
1169
1196
  }
1170
- function ht(e, t = {}) {
1197
+ function vt(e, t = {}) {
1171
1198
  let { defaultEnabled: n = !1 } = t, [r, i] = D(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: c, setSelectedModel: l } = dt(), [u, f] = D(!1), [p, m] = D(null), [g, v] = D(!1), [y, b] = D([]), x = E([]), S = (e) => {
1172
1199
  b((t) => {
1173
1200
  let n = typeof e == "function" ? e(t) : e;
@@ -1332,13 +1359,47 @@ function ht(e, t = {}) {
1332
1359
  let a = r ? h(r) : L, o = a ? I[a.provider] : null;
1333
1360
  if (!o || !a) return m(T.current.noProviderAvailable), null;
1334
1361
  n?.length && (i.attachmentsRef.current = [...i.attachmentsRef.current ?? [], ...n]);
1335
- let s = (n ?? []).filter((e) => d.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= pt ? `\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 = mt(n ?? []), l = i.tools.map((e) => ({
1362
+ let s = (n ?? []).filter((e) => d.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= gt ? `\n\n[File allegato: ${e.name}]\n${d.decodeBase64Text(e.base64)}` : `\n\n[File allegato: ${e.name} — troppo grande per essere incollato qui. Usa uno dei tool di lettura file disponibili (es. list_csv_columns/extract_csv_column) per leggerne il contenuto prima di chiedere altro all'utente.]`).join(""), c = _t(n ?? []), l = i.tools.map((e) => ({
1336
1363
  name: e.name,
1337
1364
  description: e.description,
1338
1365
  inputSchema: U(e.inputSchema)
1339
- })), u = new Map(i.tools.map((e) => [e.name, e])), f = new AbortController();
1340
- A.current = f;
1341
- let p = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
1366
+ })), u = (e, t, n, r) => {
1367
+ let i = T.current, a = `approval-${e}`, o = t.describeApproval?.(n) ?? t.describeInvocation?.(n) ?? t.name;
1368
+ S((e) => [...e, {
1369
+ id: a,
1370
+ kind: "thinking",
1371
+ label: i.approvalHeader,
1372
+ status: "running",
1373
+ parts: [{
1374
+ type: "questions",
1375
+ id: ft,
1376
+ questions: [{
1377
+ header: i.approvalHeader,
1378
+ question: i.approveQuestion.replace("{action}", o),
1379
+ options: [{ label: i.approve }, { label: i.reject }],
1380
+ custom: !0
1381
+ }]
1382
+ }]
1383
+ }]);
1384
+ let s = `${a}:${ft}`;
1385
+ return new Promise((e, t) => {
1386
+ let n = () => {
1387
+ C.current.delete(s), g(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
1388
+ };
1389
+ if (r.aborted) {
1390
+ n();
1391
+ return;
1392
+ }
1393
+ r.addEventListener("abort", n, { once: !0 }), C.current.set(s, {
1394
+ resolve: (t) => {
1395
+ r.removeEventListener("abort", n), g(a, "done"), e(mt(t, i.approve, i.reject));
1396
+ },
1397
+ reject: t
1398
+ });
1399
+ });
1400
+ }, f = new Map(i.tools.map((e) => [e.name, e])), p = new AbortController();
1401
+ A.current = p;
1402
+ let g = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
1342
1403
  ...i,
1343
1404
  status: t,
1344
1405
  ...n === void 0 ? {} : { detail: n },
@@ -1346,7 +1407,7 @@ function ht(e, t = {}) {
1346
1407
  } : i));
1347
1408
  try {
1348
1409
  let n = i.history, r = t;
1349
- for (let t = 0; t < ft; t++) {
1410
+ for (let t = 0; t < ht; t++) {
1350
1411
  let d = crypto.randomUUID();
1351
1412
  S((e) => [...e, {
1352
1413
  id: d,
@@ -1361,7 +1422,7 @@ function ht(e, t = {}) {
1361
1422
  model: a.model,
1362
1423
  history: n,
1363
1424
  tools: l.length ? l : void 0,
1364
- signal: f.signal,
1425
+ signal: p.signal,
1365
1426
  attachments: t === 0 ? c : void 0,
1366
1427
  logId: i.logId
1367
1428
  });
@@ -1369,13 +1430,13 @@ function ht(e, t = {}) {
1369
1430
  return i.history = [...n, ...r ? [{
1370
1431
  role: "user",
1371
1432
  content: r + s
1372
- }] : []], f.signal.aborted ? (p(d, "stopped"), e.fallback(i.params, i.context)) : (p(d, "error"), m(Z(t)), null);
1433
+ }] : []], p.signal.aborted ? (g(d, "stopped"), e.fallback(i.params, i.context)) : (g(d, "error"), m(Z(t)), null);
1373
1434
  }
1374
1435
  if (i.history = [...n, ...r ? [{
1375
1436
  role: "user",
1376
1437
  content: r + s
1377
- }] : []], !h) return f.signal.aborted ? (p(d, "stopped"), e.fallback(i.params, i.context)) : (p(d, "error"), m(T.current.noProviderResponse), null);
1378
- if (h.type === "text") return p(d, "done", h.text), e.conversational && h.text.trim() && S((e) => e.map((e) => e.id === d ? {
1438
+ }] : []], !h) return p.signal.aborted ? (g(d, "stopped"), e.fallback(i.params, i.context)) : (g(d, "error"), m(T.current.noProviderResponse), null);
1439
+ if (h.type === "text") return g(d, "done", h.text), e.conversational && h.text.trim() && S((e) => e.map((e) => e.id === d ? {
1379
1440
  ...e,
1380
1441
  parts: [{
1381
1442
  type: "text",
@@ -1397,19 +1458,43 @@ function ht(e, t = {}) {
1397
1458
  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,
1398
1459
  params: i.params
1399
1460
  }), m(T.current.invalidResponse), e.fallback(i.params, i.context));
1400
- let g = h.toolCalls.map((e) => {
1401
- let t = u.get(e.name);
1461
+ let _ = h.toolCalls.map((e) => {
1462
+ let t = f.get(e.name);
1402
1463
  return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1403
1464
  });
1404
- p(d, "done", h.text || void 0, h.text ? void 0 : g);
1405
- let _ = await Promise.all(h.toolCalls.map(async (e) => {
1406
- let t = u.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
1465
+ g(d, "done", h.text || void 0, h.text ? void 0 : _);
1466
+ let v = /* @__PURE__ */ new Map();
1467
+ for (let t of h.toolCalls) {
1468
+ let n = f.get(t.name);
1469
+ if (n && pt(n, t.input)) try {
1470
+ v.set(t.id, await u(t.id, n, t.input, p.signal));
1471
+ } catch {
1472
+ return e.fallback(i.params, i.context);
1473
+ }
1474
+ }
1475
+ let y = await Promise.all(h.toolCalls.map(async (e) => {
1476
+ let t = f.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = v.get(e.id);
1477
+ if (r && !r.approved) {
1478
+ S((t) => [...t, {
1479
+ id: e.id,
1480
+ kind: "tool",
1481
+ label: n,
1482
+ status: "stopped"
1483
+ }]);
1484
+ let t = Y().toolRejected.replace("{reason}", r.reason ? ` (${r.reason})` : "");
1485
+ return {
1486
+ toolCallId: e.id,
1487
+ name: e.name,
1488
+ output: t,
1489
+ isError: !0
1490
+ };
1491
+ }
1407
1492
  if (S((t) => [...t, {
1408
1493
  id: e.id,
1409
1494
  kind: "tool",
1410
1495
  label: n,
1411
1496
  status: "running"
1412
- }]), !t) return p(e.id, "error"), {
1497
+ }]), !t) return g(e.id, "error"), {
1413
1498
  toolCallId: e.id,
1414
1499
  name: e.name,
1415
1500
  output: `Tool sconosciuto: ${e.name}`,
@@ -1417,13 +1502,13 @@ function ht(e, t = {}) {
1417
1502
  };
1418
1503
  try {
1419
1504
  let n = await t.execute(e.input);
1420
- return p(e.id, "done"), {
1505
+ return g(e.id, "done"), {
1421
1506
  toolCallId: e.id,
1422
1507
  name: e.name,
1423
1508
  output: n
1424
1509
  };
1425
1510
  } catch (t) {
1426
- return p(e.id, "error"), {
1511
+ return g(e.id, "error"), {
1427
1512
  toolCallId: e.id,
1428
1513
  name: e.name,
1429
1514
  output: Z(t),
@@ -1444,7 +1529,7 @@ function ht(e, t = {}) {
1444
1529
  },
1445
1530
  {
1446
1531
  role: "tool_result",
1447
- results: _
1532
+ results: y
1448
1533
  }
1449
1534
  ], r = "";
1450
1535
  }
@@ -1461,21 +1546,21 @@ function ht(e, t = {}) {
1461
1546
  prompt: X(Y().stopCallingTools, e.microPromptIds),
1462
1547
  model: a.model,
1463
1548
  history: n,
1464
- signal: f.signal,
1549
+ signal: p.signal,
1465
1550
  logId: i.logId
1466
1551
  });
1467
1552
  } catch {
1468
1553
  h = null;
1469
1554
  }
1470
1555
  if (h?.type === "text") {
1471
- p(d, "done", h.text), i.history = [...n, {
1556
+ g(d, "done", h.text), i.history = [...n, {
1472
1557
  role: "assistant",
1473
1558
  content: h.text
1474
1559
  }];
1475
1560
  let t = e.parseResponse(h.text, i.params, i.context);
1476
1561
  if (t) return t;
1477
- } else p(d, f.signal.aborted ? "stopped" : "error"), i.history = n;
1478
- return f.signal.aborted || m(T.current.tooManyToolTurns), e.fallback(i.params, i.context);
1562
+ } else g(d, p.signal.aborted ? "stopped" : "error"), i.history = n;
1563
+ return p.signal.aborted || m(T.current.tooManyToolTurns), e.fallback(i.params, i.context);
1479
1564
  } finally {
1480
1565
  A.current = null;
1481
1566
  }
@@ -1601,23 +1686,23 @@ function ht(e, t = {}) {
1601
1686
  }
1602
1687
  //#endregion
1603
1688
  //#region src/domain/orchestrator/prompt.ts
1604
- function gt() {
1689
+ function yt() {
1605
1690
  let e = Y();
1606
1691
  return [e.responseRulesHeading, ...e.responseRules.map((e) => `- ${e}`)].join("\n");
1607
1692
  }
1608
- function _t(e, t, n) {
1693
+ function bt(e, t, n) {
1609
1694
  let r = Y(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
1610
1695
  return `${r.orchestratorIntro}
1611
1696
 
1612
1697
  ${r.toolsHeading}
1613
1698
  ${t}
1614
1699
  ${i}
1615
- ${gt()}
1700
+ ${yt()}
1616
1701
 
1617
1702
  ${r.userRequestHeading}
1618
1703
  ${e}`;
1619
1704
  }
1620
- function vt(e, t) {
1705
+ function xt(e, t) {
1621
1706
  return t ? {
1622
1707
  kind: "handoff",
1623
1708
  ...t
@@ -1628,27 +1713,27 @@ function vt(e, t) {
1628
1713
  }
1629
1714
  //#endregion
1630
1715
  //#region src/domain/orchestrator/agenticoOrchestratorAgent.ts
1631
- function yt(e) {
1716
+ function St(e) {
1632
1717
  return z().filter((t) => !t.onlyWhenAnchored || e === t.id);
1633
1718
  }
1634
- function bt(e) {
1719
+ function Ct(e) {
1635
1720
  return {
1636
1721
  buildContext(e) {
1637
1722
  return {
1638
- cliCatalog: se(yt(e.scopedSubagentId)),
1723
+ cliCatalog: se(St(e.scopedSubagentId)),
1639
1724
  handoff: { current: null },
1640
1725
  collected: {}
1641
1726
  };
1642
1727
  },
1643
1728
  buildPrompt({ userGoal: e, pageContext: t }, { cliCatalog: n }) {
1644
- return _t(e, n, t);
1729
+ return bt(e, n, t);
1645
1730
  },
1646
1731
  buildFollowUpPrompt(e, t, { cliCatalog: n }) {
1647
- return `${e}\n\n${gt()}\n\n${Y().toolsHeading}\n${n}`;
1732
+ return `${e}\n\n${yt()}\n\n${Y().toolsHeading}\n${n}`;
1648
1733
  },
1649
1734
  parseResponse(e, t, n) {
1650
1735
  let r = n.handoff.current;
1651
- return n.handoff.current = null, vt(e, r);
1736
+ return n.handoff.current = null, xt(e, r);
1652
1737
  },
1653
1738
  fallback() {
1654
1739
  return {
@@ -1664,7 +1749,7 @@ function bt(e) {
1664
1749
  attachmentsRef: r,
1665
1750
  collected: n.collected,
1666
1751
  proxyFetch: g
1667
- }), a = t.scopedSubagentId ? B(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = yt(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
1752
+ }), a = t.scopedSubagentId ? B(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = St(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
1668
1753
  name: `${t.id}_${r.name}`,
1669
1754
  description: `${t.label}: ${r.summary}`,
1670
1755
  inputSchema: r.inputSchema,
@@ -1688,12 +1773,12 @@ function bt(e) {
1688
1773
  }
1689
1774
  //#endregion
1690
1775
  //#region src/presentation/deriveHistoryTitle.ts
1691
- function xt(e, t) {
1776
+ function wt(e, t) {
1692
1777
  return e.deriveHistoryTitle?.(t) ?? e.label;
1693
1778
  }
1694
1779
  //#endregion
1695
1780
  //#region src/presentation/ResultDestinationPicker.tsx
1696
- function St({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
1781
+ function Tt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
1697
1782
  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();
1698
1783
  e.destinationIds.forEach((e) => {
1699
1784
  let t = v[e];
@@ -1711,7 +1796,7 @@ function St({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
1711
1796
  storageProvider: l?.storageProvider ?? null,
1712
1797
  proxyFetch: u
1713
1798
  }, n);
1714
- h((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, xt(e, n));
1799
+ h((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, wt(e, n));
1715
1800
  } catch (e) {
1716
1801
  _(e instanceof Error ? e.message : String(e));
1717
1802
  } finally {
@@ -1744,16 +1829,16 @@ function St({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
1744
1829
  }
1745
1830
  //#endregion
1746
1831
  //#region src/presentation/reports/subagentReportRegistry.tsx
1747
- var Ct = {};
1748
- function wt(e) {
1749
- Object.assign(Ct, e);
1832
+ var Et = {};
1833
+ function Dt(e) {
1834
+ Object.assign(Et, e);
1750
1835
  }
1751
- function Tt(e) {
1752
- return Ct[e];
1836
+ function Ot(e) {
1837
+ return Et[e];
1753
1838
  }
1754
1839
  //#endregion
1755
1840
  //#region src/presentation/reports/GenericResultPreview.tsx
1756
- function Et({ result: e }) {
1841
+ function kt({ result: e }) {
1757
1842
  let [t, n] = D(!1);
1758
1843
  return /* @__PURE__ */ A("div", {
1759
1844
  className: `relative cursor-pointer rounded-md border border-border/60 ${t ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
@@ -1770,7 +1855,7 @@ function Et({ result: e }) {
1770
1855
  }
1771
1856
  //#endregion
1772
1857
  //#region src/presentation/liveAnchorDestination.ts
1773
- function Dt(e, t, n) {
1858
+ function At(e, t, n) {
1774
1859
  return e.length === 0 ? null : {
1775
1860
  id: "live-component",
1776
1861
  label: "Applica al componente aperto",
@@ -1781,20 +1866,20 @@ function Dt(e, t, n) {
1781
1866
  }
1782
1867
  //#endregion
1783
1868
  //#region src/presentation/subagentControls.ts
1784
- var Ot = {};
1785
- function kt(e) {
1786
- Object.assign(Ot, e);
1869
+ var jt = {};
1870
+ function Mt(e) {
1871
+ Object.assign(jt, e);
1787
1872
  }
1788
- function At(e) {
1789
- return Ot[e];
1873
+ function Nt(e) {
1874
+ return jt[e];
1790
1875
  }
1791
1876
  //#endregion
1792
1877
  //#region src/presentation/SubagentRunner.tsx
1793
- var jt = () => ({});
1794
- function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
1795
- let c = ht(e.definition, { defaultEnabled: !0 }), l = $(), u = l.scope, d = y(), f = E(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = D(null), h = (t) => {
1878
+ var Pt = () => ({});
1879
+ function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
1880
+ let c = vt(e.definition, { defaultEnabled: !0 }), l = $(), u = l.scope, d = y(), f = E(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = D(null), h = (t) => {
1796
1881
  e.definition.conversational || m(t);
1797
- }, [g, _] = D([]), [v, b] = D(null), x = Tt(e.id), S = x?.kind === "selection" ? x : null, [w, j] = D(null), M = E(!1), N = E(0), P = E(null);
1882
+ }, [g, _] = D([]), [v, b] = D(null), x = Ot(e.id), S = x?.kind === "selection" ? x : null, [w, j] = D(null), M = E(!1), N = E(0), P = E(null);
1798
1883
  p && p !== P.current && (P.current = p, N.current = (r?.length ?? 0) + c.activity.length);
1799
1884
  let F = E(!1), I = c.remote || !c.hasProviders || c.selectedModel !== "";
1800
1885
  C(() => {
@@ -1818,7 +1903,7 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1818
1903
  ...t,
1819
1904
  pinnedEntityId: r
1820
1905
  }).then((n) => {
1821
- n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, xt(e, t));
1906
+ n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, wt(e, t));
1822
1907
  }).catch((e) => b(e instanceof Error ? e.message : String(e))));
1823
1908
  });
1824
1909
  }, [
@@ -1837,7 +1922,7 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1837
1922
  p,
1838
1923
  S,
1839
1924
  w
1840
- ]), B = T(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), V = T(() => Dt(B, t, f), [
1925
+ ]), B = T(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), V = T(() => At(B, t, f), [
1841
1926
  B,
1842
1927
  t,
1843
1928
  f
@@ -1851,14 +1936,14 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1851
1936
  subagentId: e.id,
1852
1937
  entityId: H,
1853
1938
  params: t,
1854
- title: xt(e, t),
1939
+ title: wt(e, t),
1855
1940
  history: i.history,
1856
1941
  activity: [...r ?? [], ...i.activity]
1857
1942
  });
1858
1943
  }, [c.running]);
1859
1944
  let W = () => {
1860
1945
  F.current = !0, c.running && c.stop(), l.closeTask(f);
1861
- }, G = E(At(e.id) ?? jt).current, K = G({
1946
+ }, G = E(Nt(e.id) ?? Pt).current, K = G({
1862
1947
  params: t,
1863
1948
  taskId: f,
1864
1949
  running: c.running,
@@ -1869,7 +1954,7 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1869
1954
  return C(() => {
1870
1955
  F.current || l.openTask({
1871
1956
  id: f,
1872
- title: xt(e, t),
1957
+ title: wt(e, t),
1873
1958
  icon: e.icon,
1874
1959
  agent: c,
1875
1960
  onApplied: (e) => h(e),
@@ -1888,12 +1973,12 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1888
1973
  }) : x?.kind === "editable" ? /* @__PURE__ */ k(x.Report, {
1889
1974
  result: p,
1890
1975
  onResultChange: R
1891
- }) : /* @__PURE__ */ k(Et, { result: z }),
1976
+ }) : /* @__PURE__ */ k(kt, { result: z }),
1892
1977
  v && /* @__PURE__ */ A("p", {
1893
1978
  className: "text-xs text-destructive",
1894
1979
  children: ["Salvataggio automatico non riuscito: ", v]
1895
1980
  }),
1896
- /* @__PURE__ */ k(St, {
1981
+ /* @__PURE__ */ k(Tt, {
1897
1982
  manifest: e,
1898
1983
  result: z,
1899
1984
  meta: t,
@@ -1934,8 +2019,8 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
1934
2019
  }
1935
2020
  //#endregion
1936
2021
  //#region src/presentation/OrchestratorRunner.tsx
1937
- function Nt({ userGoal: e }) {
1938
- let t = Q(), n = ht(T(() => bt({
2022
+ function It({ userGoal: e }) {
2023
+ let t = Q(), n = vt(T(() => Ct({
1939
2024
  unavailable: t.orchestratorUnavailable,
1940
2025
  continueWithoutAi: t.orchestratorContinueWithoutAi,
1941
2026
  preparing: t.orchestratorPreparing,
@@ -1983,7 +2068,7 @@ function Nt({ userGoal: e }) {
1983
2068
  let h = T(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
1984
2069
  if (!i) return null;
1985
2070
  let g = B(i.subagentId);
1986
- return g ? /* @__PURE__ */ k(Mt, {
2071
+ return g ? /* @__PURE__ */ k(Ft, {
1987
2072
  manifest: g,
1988
2073
  params: i.params,
1989
2074
  extraDestinations: c.current,
@@ -1994,8 +2079,8 @@ function Nt({ userGoal: e }) {
1994
2079
  }
1995
2080
  //#endregion
1996
2081
  //#region src/presentation/ManualEntryRunner.tsx
1997
- function Pt({ manifest: e, extraDestinations: n }) {
1998
- let r = ht(e.definition, { defaultEnabled: !1 }), i = Q(), a = $(), o = E(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = D(null), [l, u] = D([]), d = Tt(e.id), f = d?.kind === "selection" ? d : null, [p, m] = D(null), [h, g] = D(null), _ = E(!1), v = (t) => {
2082
+ function Lt({ manifest: e, extraDestinations: n }) {
2083
+ let r = vt(e.definition, { defaultEnabled: !1 }), i = Q(), a = $(), o = E(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = D(null), [l, u] = D([]), d = Ot(e.id), f = d?.kind === "selection" ? d : null, [p, m] = D(null), [h, g] = D(null), _ = E(!1), v = (t) => {
1999
2084
  if (!e.manualEntry) return;
2000
2085
  let n;
2001
2086
  try {
@@ -2022,7 +2107,7 @@ function Pt({ manifest: e, extraDestinations: n }) {
2022
2107
  p
2023
2108
  ]), S = (e) => {
2024
2109
  u((t) => t.includes(e) ? t : [...t, e]);
2025
- }, w = T(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), O = T(() => h ? Dt(w, h, o) : null, [
2110
+ }, w = T(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), O = T(() => h ? At(w, h, o) : null, [
2026
2111
  w,
2027
2112
  h,
2028
2113
  o
@@ -2051,8 +2136,8 @@ function Pt({ manifest: e, extraDestinations: n }) {
2051
2136
  }) : d?.kind === "editable" ? /* @__PURE__ */ k(d.Report, {
2052
2137
  result: s,
2053
2138
  onResultChange: b
2054
- }) : /* @__PURE__ */ k(Et, { result: x }),
2055
- /* @__PURE__ */ k(St, {
2139
+ }) : /* @__PURE__ */ k(kt, { result: x }),
2140
+ /* @__PURE__ */ k(Tt, {
2056
2141
  manifest: e,
2057
2142
  result: x,
2058
2143
  meta: h ?? {},
@@ -2089,7 +2174,7 @@ function Pt({ manifest: e, extraDestinations: n }) {
2089
2174
  }
2090
2175
  //#endregion
2091
2176
  //#region src/presentation/Agentico.tsx
2092
- function Ft(e) {
2177
+ function Rt(e) {
2093
2178
  return Object.values(e).flat().map((e) => ({
2094
2179
  label: e.model,
2095
2180
  value: e.id,
@@ -2097,7 +2182,7 @@ function Ft(e) {
2097
2182
  group: e.providerLabel ?? e.provider
2098
2183
  }));
2099
2184
  }
2100
- function It({ task: e }) {
2185
+ function zt({ task: e }) {
2101
2186
  let t = Q(), [n, r] = D(""), { agent: i, onApplied: a, manualEntry: s } = e, c = i.running, l = (e) => {
2102
2187
  if (r(""), s) {
2103
2188
  s.onSubmit(e.text);
@@ -2109,7 +2194,7 @@ function It({ task: e }) {
2109
2194
  }).then((e) => {
2110
2195
  e && a(e);
2111
2196
  });
2112
- }, u = !!s || i.remote && i.remoteModels.length === 0, d = !u && !i.remote && i.hasProviders && !i.selectedModel, f = u ? [] : i.remote ? i.remoteModels : Ft(i.modelsByProvider);
2197
+ }, u = !!s || i.remote && i.remoteModels.length === 0, d = !u && !i.remote && i.hasProviders && !i.selectedModel, f = u ? [] : i.remote ? i.remoteModels : Rt(i.modelsByProvider);
2113
2198
  return /* @__PURE__ */ k(o, {
2114
2199
  value: n,
2115
2200
  onChange: r,
@@ -2129,7 +2214,7 @@ function It({ task: e }) {
2129
2214
  maxHeight: 220
2130
2215
  });
2131
2216
  }
2132
- function Lt() {
2217
+ function Bt() {
2133
2218
  let { startOrchestrator: e } = $(), t = Q(), [n, r] = D(""), { hasProviders: i, modelsByProvider: a, selectedModel: s, setSelectedModel: c } = dt(), l = (t) => {
2134
2219
  t.text.trim() && (e(t.text.trim(), {
2135
2220
  attachments: t.files.length > 0 ? t.files : void 0,
@@ -2143,7 +2228,7 @@ function Lt() {
2143
2228
  disabled: !n.trim() || u,
2144
2229
  onSubmit: l,
2145
2230
  attachments: !0,
2146
- models: Ft(a),
2231
+ models: Rt(a),
2147
2232
  selectedModel: s,
2148
2233
  onModelChange: c,
2149
2234
  modelPlaceholder: t.selectModelPlaceholder,
@@ -2151,7 +2236,7 @@ function Lt() {
2151
2236
  maxHeight: 220
2152
2237
  });
2153
2238
  }
2154
- function Rt(e, t, n = Date.now()) {
2239
+ function Vt(e, t, n = Date.now()) {
2155
2240
  let r = Math.round((e - n) / 1e3), i = new Intl.RelativeTimeFormat(t, {
2156
2241
  numeric: "auto",
2157
2242
  style: "short"
@@ -2163,7 +2248,7 @@ function Rt(e, t, n = Date.now()) {
2163
2248
  ]) if (Math.abs(r) >= t) return i.format(Math.round(r / t), e);
2164
2249
  return i.format(0, "minute");
2165
2250
  }
2166
- function zt({ card: e }) {
2251
+ function Ht({ card: e }) {
2167
2252
  let t = Q();
2168
2253
  return e.humanSummaryOnly ? /* @__PURE__ */ A("div", {
2169
2254
  className: "space-y-2 rounded-lg border border-border/60 p-3",
@@ -2219,7 +2304,7 @@ function zt({ card: e }) {
2219
2304
  ]
2220
2305
  });
2221
2306
  }
2222
- function Bt({ messages: e }) {
2307
+ function Ut({ messages: e }) {
2223
2308
  return /* @__PURE__ */ k("div", {
2224
2309
  className: "space-y-2 rounded-lg border border-border/60 p-3",
2225
2310
  children: e.map((e, t) => /* @__PURE__ */ k("p", {
@@ -2228,7 +2313,7 @@ function Bt({ messages: e }) {
2228
2313
  }, t))
2229
2314
  });
2230
2315
  }
2231
- function Vt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2316
+ function Wt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
2232
2317
  let d = Q(), { locale: f } = v(), [p, m] = D(""), [h, g] = D(0), _ = T(() => r ? Ee(e) : [], [
2233
2318
  e,
2234
2319
  r,
@@ -2315,14 +2400,14 @@ function Vt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
2315
2400
  }), /* @__PURE__ */ k("span", {
2316
2401
  className: "shrink-0 text-xs text-muted-foreground",
2317
2402
  title: new Date(e.savedAt).toLocaleString(f),
2318
- children: Rt(e.savedAt, f)
2403
+ children: Vt(e.savedAt, f)
2319
2404
  })]
2320
2405
  })
2321
2406
  }, `${e.subagentId}:${e.entityId}`);
2322
2407
  })
2323
2408
  });
2324
2409
  }
2325
- function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
2410
+ function Gt({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
2326
2411
  let { task: a, isOpen: o, pendingGoal: s, orchestratorRunId: c, pageContext: l, pageContextCard: u, anchoredUserMessages: d, pendingResume: f, resumeRunId: p, dismissForeignTask: m, resumeEntityChat: h, pendingManualEntry: g, manualEntryRunId: _, startManualEntry: v, pendingExtraDestinations: y, pendingResumeWithAI: b, resumeWithAIRunId: x, pendingStart: S, startRunId: w, scope: T } = $(), j = Q(), M = E(null), [N, P] = D(!1), F = at({
2327
2412
  defaultWidth: e,
2328
2413
  minWidth: n,
@@ -2365,7 +2450,7 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2365
2450
  });
2366
2451
  return n.observe(t), () => n.disconnect();
2367
2452
  }, [a?.id, o]);
2368
- let ne = s ? /* @__PURE__ */ k(Nt, { userGoal: s }, c) : null, re = f ? B(f.subagentId) : void 0, ie = f && re ? /* @__PURE__ */ k(Mt, {
2453
+ let ne = s ? /* @__PURE__ */ k(It, { userGoal: s }, c) : null, re = f ? B(f.subagentId) : void 0, ie = f && re ? /* @__PURE__ */ k(Ft, {
2369
2454
  manifest: re,
2370
2455
  params: f.snapshot.params,
2371
2456
  taskId: De(f.subagentId, f.entityId),
@@ -2373,14 +2458,14 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2373
2458
  history: f.snapshot.history,
2374
2459
  activity: f.snapshot.activity
2375
2460
  }
2376
- }, p) : null, ae = g ? B(g.subagentId) : void 0, oe = g && ae ? /* @__PURE__ */ k(Pt, {
2461
+ }, p) : null, ae = g ? B(g.subagentId) : void 0, oe = g && ae ? /* @__PURE__ */ k(Lt, {
2377
2462
  manifest: ae,
2378
2463
  extraDestinations: g.extraDestinations
2379
- }, _) : null, se = b ? B(b.subagentId) : void 0, ce = b && se ? /* @__PURE__ */ k(Mt, {
2464
+ }, _) : null, se = b ? B(b.subagentId) : void 0, ce = b && se ? /* @__PURE__ */ k(Ft, {
2380
2465
  manifest: se,
2381
2466
  params: b.params,
2382
2467
  extraDestinations: b.extraDestinations
2383
- }, x) : null, le = S ? B(S.subagentId) : void 0, X = S && le ? /* @__PURE__ */ k(Mt, {
2468
+ }, x) : null, le = S ? B(S.subagentId) : void 0, X = S && le ? /* @__PURE__ */ k(Ft, {
2384
2469
  manifest: le,
2385
2470
  params: S.params,
2386
2471
  taskId: S.taskId,
@@ -2411,7 +2496,7 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2411
2496
  className: "min-w-0 flex-1 truncate text-lg font-semibold leading-tight",
2412
2497
  children: a ? a.title : "Agentico"
2413
2498
  }),
2414
- T && /* @__PURE__ */ k(Vt, {
2499
+ T && /* @__PURE__ */ k(Wt, {
2415
2500
  scopeId: T.id,
2416
2501
  currentTaskId: a?.id ?? null,
2417
2502
  open: N,
@@ -2482,7 +2567,7 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2482
2567
  })
2483
2568
  ]
2484
2569
  })
2485
- ] }) : d.length > 0 ? /* @__PURE__ */ k(Bt, { messages: d }) : u ? /* @__PURE__ */ k(zt, { card: u }) : /* @__PURE__ */ k("p", {
2570
+ ] }) : d.length > 0 ? /* @__PURE__ */ k(Ut, { messages: d }) : u ? /* @__PURE__ */ k(Ht, { card: u }) : /* @__PURE__ */ k("p", {
2486
2571
  className: "text-xs text-muted-foreground",
2487
2572
  children: l ?? j.orchestratorStarterHint
2488
2573
  })
@@ -2520,7 +2605,7 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2520
2605
  children: [a?.panelActions && /* @__PURE__ */ k("div", {
2521
2606
  className: "mb-2",
2522
2607
  children: a.panelActions
2523
- }), a ? /* @__PURE__ */ k(It, { task: a }, a.id) : /* @__PURE__ */ k(Lt, {})]
2608
+ }), a ? /* @__PURE__ */ k(zt, { task: a }, a.id) : /* @__PURE__ */ k(Bt, {})]
2524
2609
  })
2525
2610
  ]
2526
2611
  })
@@ -2534,13 +2619,13 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
2534
2619
  }
2535
2620
  //#endregion
2536
2621
  //#region src/presentation/useAgenticoPageContext.ts
2537
- function Ut(e, t) {
2622
+ function Kt(e, t) {
2538
2623
  let { setPageContext: n } = $(), r = E(crypto.randomUUID()).current;
2539
2624
  C(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
2540
2625
  }
2541
2626
  //#endregion
2542
2627
  //#region src/presentation/useSubagentComponentContext.ts
2543
- function Wt(e, t, n, r, i = !0, a) {
2628
+ function qt(e, t, n, r, i = !0, a) {
2544
2629
  let { registerComponentAnchor: o } = $(), s = E(crypto.randomUUID()).current, c = E(n);
2545
2630
  c.current = n, C(() => {
2546
2631
  if (i) return o(s, {
@@ -2559,6 +2644,6 @@ function Wt(e, t, n, r, i = !0, a) {
2559
2644
  ]);
2560
2645
  }
2561
2646
  //#endregion
2562
- export { Qe as AGENTICO_MAX_WIDTH, Ze as AGENTICO_MIN_WIDTH, Xe as AGENTICO_WIDTH, $e as AGENTICO_WIDTH_STORAGE_KEY, Ht as Agentico, Pe as AgenticoProvider, st as AgenticoToggle, M as DEFAULT_REASONING_PART_ID, j as DEFAULT_TEXT_PART_ID, fe as JSON_EXPORT_DESTINATION_ID, le as MICRO_PROMPT_REGISTRY, Me as ORCHESTRATOR_TASK_ID, ce as SUMMARY_MICRO_PROMPT, Oe as agenticoDe, ke as agenticoEn, Ae as agenticoIt, K as agenticoPromptsEn, q as agenticoPromptsIt, je as agenticoTranslations, X as applyMicroPrompts, te as configureAgenticoPrompts, ve as configureEntityChatStore, H as createCrossAgentTools, I as defineSubagent, De as entityChatTaskId, Z as extractErrorMessage, ue as extractJsonBlock, B as findSubagentManifest, F as formatQuestionAnswers, Y as getAgenticoPrompts, ge as getDestinationRegistry, Ce as getEntityChat, At as getSubagentControls, z as getSubagentRegistry, Tt as getSubagentReport, pe as jsonExportDestination, Ee as listEntityChats, P as messagePartsText, ee as registerCrossAgentTools, he as registerDestinations, kt as registerSubagentControls, wt as registerSubagentReports, R as registerSubagents, Te as removeEntityChat, se as renderRegistryCli, oe as renderSubagentCli, ne as resetAgenticoPrompts, we as saveEntityChat, U as toJsonSchema, W as toMcpTool, N as upsertMessagePart, ht as useAgent, $ as useAgentico, Q as useAgenticoI18n, Ut as useAgenticoPageContext, Wt as useSubagentComponentContext };
2647
+ export { Qe as AGENTICO_MAX_WIDTH, Ze as AGENTICO_MIN_WIDTH, Xe as AGENTICO_WIDTH, $e as AGENTICO_WIDTH_STORAGE_KEY, Gt as Agentico, Pe as AgenticoProvider, st as AgenticoToggle, M as DEFAULT_REASONING_PART_ID, j as DEFAULT_TEXT_PART_ID, fe as JSON_EXPORT_DESTINATION_ID, le as MICRO_PROMPT_REGISTRY, Me as ORCHESTRATOR_TASK_ID, ce as SUMMARY_MICRO_PROMPT, Oe as agenticoDe, ke as agenticoEn, Ae as agenticoIt, K as agenticoPromptsEn, q as agenticoPromptsIt, je as agenticoTranslations, X as applyMicroPrompts, te as configureAgenticoPrompts, ve as configureEntityChatStore, H as createCrossAgentTools, I as defineSubagent, De as entityChatTaskId, Z as extractErrorMessage, ue as extractJsonBlock, B as findSubagentManifest, F as formatQuestionAnswers, Y as getAgenticoPrompts, ge as getDestinationRegistry, Ce as getEntityChat, Nt as getSubagentControls, z as getSubagentRegistry, Ot as getSubagentReport, pe as jsonExportDestination, Ee as listEntityChats, P as messagePartsText, ee as registerCrossAgentTools, he as registerDestinations, Mt as registerSubagentControls, Dt as registerSubagentReports, R as registerSubagents, Te as removeEntityChat, se as renderRegistryCli, oe as renderSubagentCli, ne as resetAgenticoPrompts, we as saveEntityChat, U as toJsonSchema, W as toMcpTool, N as upsertMessagePart, vt as useAgent, $ as useAgentico, Q as useAgenticoI18n, Kt as useAgenticoPageContext, qt as useSubagentComponentContext };
2563
2648
 
2564
2649
  //# sourceMappingURL=index.mjs.map