@llmnative/agentico 0.10.2 → 0.11.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/README.md +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -61
- package/dist/index.mjs.map +1 -1
- package/dist/types/domain/agentDefinition.d.ts +5 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1412,16 +1412,16 @@ function Mt(e, t = {}) {
|
|
|
1412
1412
|
D.current = !1, d(!1);
|
|
1413
1413
|
}
|
|
1414
1414
|
}, de = async (t, n, r) => {
|
|
1415
|
-
let i = z.current, a = Object.values(o).flat().find((e) => !i || i.includes(e.provider))?.id, s = r && B(i, r) ? r : B(i, V) ? void 0 : a, c = E.current;
|
|
1416
|
-
if (!
|
|
1417
|
-
let
|
|
1418
|
-
if (!
|
|
1419
|
-
n?.length && (
|
|
1420
|
-
let
|
|
1415
|
+
let i = z.current, a = Object.values(o).flat().find((e) => !i || i.includes(e.provider))?.id, s = r && B(i, r) ? r : B(i, V) ? void 0 : a, c = s ? v(s) : H, l = c && E.current ? W?.catalogReasoning?.(E.current.params, c.provider) : void 0, u = l ? { reasoning: l } : {}, d = E.current;
|
|
1416
|
+
if (!d) return p(T.current.noActiveSession), null;
|
|
1417
|
+
let f = s ? v(s) : H, h = f ? N[f.provider] : null;
|
|
1418
|
+
if (!h || !f) return p(T.current.noProviderAvailable), null;
|
|
1419
|
+
n?.length && (d.attachmentsRef.current = [...d.attachmentsRef.current ?? [], ...n]);
|
|
1420
|
+
let g = (n ?? []).filter((e) => m.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= At ? `\n\n[File allegato: ${e.name}]\n${m.decodeBase64Text(e.base64)}` : `\n\n[File allegato: ${e.name} — troppo grande per essere incollato qui. Usa uno dei tool di lettura file disponibili (es. list_csv_columns/extract_csv_column) per leggerne il contenuto prima di chiedere altro all'utente.]`).join(""), _ = jt(n ?? []), y = d.tools.map((e) => ({
|
|
1421
1421
|
name: e.name,
|
|
1422
1422
|
description: e.description,
|
|
1423
1423
|
inputSchema: K(e.inputSchema)
|
|
1424
|
-
})),
|
|
1424
|
+
})), b = (e, t, n, r) => {
|
|
1425
1425
|
let i = T.current, a = `approval-${e}`, o = t.describeApproval?.(n) ?? t.describeInvocation?.(n) ?? t.name;
|
|
1426
1426
|
S((e) => [...e, {
|
|
1427
1427
|
id: a,
|
|
@@ -1442,7 +1442,7 @@ function Mt(e, t = {}) {
|
|
|
1442
1442
|
let s = `${a}:${Et}`;
|
|
1443
1443
|
return new Promise((e, t) => {
|
|
1444
1444
|
let n = () => {
|
|
1445
|
-
C.current.delete(s),
|
|
1445
|
+
C.current.delete(s), D(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
|
|
1446
1446
|
};
|
|
1447
1447
|
if (r.aborted) {
|
|
1448
1448
|
n();
|
|
@@ -1450,21 +1450,21 @@ function Mt(e, t = {}) {
|
|
|
1450
1450
|
}
|
|
1451
1451
|
r.addEventListener("abort", n, { once: !0 }), C.current.set(s, {
|
|
1452
1452
|
resolve: (t) => {
|
|
1453
|
-
r.removeEventListener("abort", n),
|
|
1453
|
+
r.removeEventListener("abort", n), D(a, "done"), e(Ot(t, i.approve, i.reject));
|
|
1454
1454
|
},
|
|
1455
1455
|
reject: t
|
|
1456
1456
|
});
|
|
1457
1457
|
});
|
|
1458
|
-
},
|
|
1459
|
-
O.current =
|
|
1460
|
-
let
|
|
1458
|
+
}, x = new Map(d.tools.map((e) => [e.name, e])), w = new AbortController();
|
|
1459
|
+
O.current = w;
|
|
1460
|
+
let D = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
|
|
1461
1461
|
...i,
|
|
1462
1462
|
status: t,
|
|
1463
1463
|
...n === void 0 ? {} : { detail: n },
|
|
1464
1464
|
...r === void 0 ? {} : { toolNames: r }
|
|
1465
1465
|
} : i));
|
|
1466
1466
|
try {
|
|
1467
|
-
let n =
|
|
1467
|
+
let n = d.history, r = t;
|
|
1468
1468
|
for (let t = 0; t < kt; t++) {
|
|
1469
1469
|
let i = crypto.randomUUID();
|
|
1470
1470
|
S((e) => [...e, {
|
|
@@ -1475,63 +1475,64 @@ function Mt(e, t = {}) {
|
|
|
1475
1475
|
}]);
|
|
1476
1476
|
let a;
|
|
1477
1477
|
try {
|
|
1478
|
-
a = await
|
|
1478
|
+
a = await h.complete({
|
|
1479
1479
|
prompt: r,
|
|
1480
|
-
model:
|
|
1480
|
+
model: f.model,
|
|
1481
|
+
...u,
|
|
1481
1482
|
history: n,
|
|
1482
|
-
tools:
|
|
1483
|
-
signal:
|
|
1484
|
-
attachments: t === 0 ?
|
|
1485
|
-
logId:
|
|
1483
|
+
tools: y.length ? y : void 0,
|
|
1484
|
+
signal: w.signal,
|
|
1485
|
+
attachments: t === 0 ? _ : void 0,
|
|
1486
|
+
logId: d.logId
|
|
1486
1487
|
});
|
|
1487
1488
|
} catch (t) {
|
|
1488
|
-
return
|
|
1489
|
+
return d.history = [...n, ...r ? [{
|
|
1489
1490
|
role: "user",
|
|
1490
|
-
content: r +
|
|
1491
|
-
}] : []],
|
|
1491
|
+
content: r + g
|
|
1492
|
+
}] : []], w.signal.aborted ? (D(i, "stopped"), e.fallback(d.params, d.context)) : (D(i, "error"), p(pe(t)), null);
|
|
1492
1493
|
}
|
|
1493
|
-
if (
|
|
1494
|
+
if (d.history = [...n, ...r ? [{
|
|
1494
1495
|
role: "user",
|
|
1495
|
-
content: r +
|
|
1496
|
-
}] : []], !a) return
|
|
1497
|
-
if (a.type === "text") return
|
|
1496
|
+
content: r + g
|
|
1497
|
+
}] : []], !a) return w.signal.aborted ? (D(i, "stopped"), e.fallback(d.params, d.context)) : (D(i, "error"), p(T.current.noProviderResponse), null);
|
|
1498
|
+
if (a.type === "text") return D(i, "done", a.text), e.conversational && a.text.trim() && S((e) => e.map((e) => e.id === i ? {
|
|
1498
1499
|
...e,
|
|
1499
1500
|
parts: [{
|
|
1500
1501
|
type: "text",
|
|
1501
1502
|
id: "text",
|
|
1502
1503
|
text: a.text
|
|
1503
1504
|
}]
|
|
1504
|
-
} : e)),
|
|
1505
|
+
} : e)), d.history = [
|
|
1505
1506
|
...n,
|
|
1506
1507
|
...r ? [{
|
|
1507
1508
|
role: "user",
|
|
1508
|
-
content: r +
|
|
1509
|
+
content: r + g
|
|
1509
1510
|
}] : [],
|
|
1510
1511
|
{
|
|
1511
1512
|
role: "assistant",
|
|
1512
1513
|
content: a.text
|
|
1513
1514
|
}
|
|
1514
|
-
], e.parseResponse(a.text,
|
|
1515
|
+
], e.parseResponse(a.text, d.params, d.context) || (console.error("[useAgent] parseResponse ha restituito null — la risposta del modello non è nel formato atteso da questo subagent. Uso il fallback deterministico.", {
|
|
1515
1516
|
responseLength: a.text.length,
|
|
1516
1517
|
responsePreview: a.text.length > 2e3 ? `${a.text.slice(0, 1e3)}\n…[troncato qui nel log, ${a.text.length} caratteri totali]…\n${a.text.slice(-1e3)}` : a.text,
|
|
1517
|
-
params:
|
|
1518
|
-
}), p(T.current.invalidResponse), e.fallback(
|
|
1518
|
+
params: d.params
|
|
1519
|
+
}), p(T.current.invalidResponse), e.fallback(d.params, d.context));
|
|
1519
1520
|
let o = a.toolCalls.map((e) => {
|
|
1520
|
-
let t =
|
|
1521
|
+
let t = x.get(e.name);
|
|
1521
1522
|
return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
|
|
1522
1523
|
});
|
|
1523
|
-
|
|
1524
|
+
D(i, "done", a.text || void 0, a.text ? void 0 : o);
|
|
1524
1525
|
let s = /* @__PURE__ */ new Map();
|
|
1525
1526
|
for (let t of a.toolCalls) {
|
|
1526
|
-
let n =
|
|
1527
|
+
let n = x.get(t.name);
|
|
1527
1528
|
if (n && Dt(n, t.input)) try {
|
|
1528
|
-
s.set(t.id, await
|
|
1529
|
+
s.set(t.id, await b(t.id, n, t.input, w.signal));
|
|
1529
1530
|
} catch {
|
|
1530
|
-
return e.fallback(
|
|
1531
|
+
return e.fallback(d.params, d.context);
|
|
1531
1532
|
}
|
|
1532
1533
|
}
|
|
1533
|
-
let
|
|
1534
|
-
let t =
|
|
1534
|
+
let c = await Promise.all(a.toolCalls.map(async (e) => {
|
|
1535
|
+
let t = x.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = s.get(e.id);
|
|
1535
1536
|
if (r && !r.approved) {
|
|
1536
1537
|
S((t) => [...t, {
|
|
1537
1538
|
id: e.id,
|
|
@@ -1552,7 +1553,7 @@ function Mt(e, t = {}) {
|
|
|
1552
1553
|
kind: "tool",
|
|
1553
1554
|
label: n,
|
|
1554
1555
|
status: "running"
|
|
1555
|
-
}]), !t) return
|
|
1556
|
+
}]), !t) return D(e.id, "error"), {
|
|
1556
1557
|
toolCallId: e.id,
|
|
1557
1558
|
name: e.name,
|
|
1558
1559
|
output: `Tool sconosciuto: ${e.name}`,
|
|
@@ -1560,13 +1561,13 @@ function Mt(e, t = {}) {
|
|
|
1560
1561
|
};
|
|
1561
1562
|
try {
|
|
1562
1563
|
let n = await t.execute(e.input);
|
|
1563
|
-
return
|
|
1564
|
+
return D(e.id, "done"), {
|
|
1564
1565
|
toolCallId: e.id,
|
|
1565
1566
|
name: e.name,
|
|
1566
1567
|
output: n
|
|
1567
1568
|
};
|
|
1568
1569
|
} catch (t) {
|
|
1569
|
-
return
|
|
1570
|
+
return D(e.id, "error"), {
|
|
1570
1571
|
toolCallId: e.id,
|
|
1571
1572
|
name: e.name,
|
|
1572
1573
|
output: pe(t),
|
|
@@ -1578,7 +1579,7 @@ function Mt(e, t = {}) {
|
|
|
1578
1579
|
...n,
|
|
1579
1580
|
...r ? [{
|
|
1580
1581
|
role: "user",
|
|
1581
|
-
content: r +
|
|
1582
|
+
content: r + g
|
|
1582
1583
|
}] : [],
|
|
1583
1584
|
{
|
|
1584
1585
|
role: "assistant",
|
|
@@ -1587,7 +1588,7 @@ function Mt(e, t = {}) {
|
|
|
1587
1588
|
},
|
|
1588
1589
|
{
|
|
1589
1590
|
role: "tool_result",
|
|
1590
|
-
results:
|
|
1591
|
+
results: c
|
|
1591
1592
|
}
|
|
1592
1593
|
], r = "";
|
|
1593
1594
|
}
|
|
@@ -1600,25 +1601,26 @@ function Mt(e, t = {}) {
|
|
|
1600
1601
|
}]);
|
|
1601
1602
|
let a;
|
|
1602
1603
|
try {
|
|
1603
|
-
a = await
|
|
1604
|
+
a = await h.complete({
|
|
1605
|
+
...u,
|
|
1604
1606
|
prompt: fe(X().stopCallingTools, e.microPromptIds),
|
|
1605
|
-
model:
|
|
1607
|
+
model: f.model,
|
|
1606
1608
|
history: n,
|
|
1607
|
-
signal:
|
|
1608
|
-
logId:
|
|
1609
|
+
signal: w.signal,
|
|
1610
|
+
logId: d.logId
|
|
1609
1611
|
});
|
|
1610
1612
|
} catch {
|
|
1611
1613
|
a = null;
|
|
1612
1614
|
}
|
|
1613
1615
|
if (a?.type === "text") {
|
|
1614
|
-
|
|
1616
|
+
D(i, "done", a.text), d.history = [...n, {
|
|
1615
1617
|
role: "assistant",
|
|
1616
1618
|
content: a.text
|
|
1617
1619
|
}];
|
|
1618
|
-
let t = e.parseResponse(a.text,
|
|
1620
|
+
let t = e.parseResponse(a.text, d.params, d.context);
|
|
1619
1621
|
if (t) return t;
|
|
1620
|
-
} else
|
|
1621
|
-
return
|
|
1622
|
+
} else D(i, w.signal.aborted ? "stopped" : "error"), d.history = n;
|
|
1623
|
+
return w.signal.aborted || p(T.current.tooManyToolTurns), e.fallback(d.params, d.context);
|
|
1622
1624
|
} finally {
|
|
1623
1625
|
O.current = null;
|
|
1624
1626
|
}
|
|
@@ -2072,24 +2074,24 @@ function tn({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
2072
2074
|
f
|
|
2073
2075
|
]), te = k(() => B ? [B, ...n ?? []] : n, [B, n]), V = e.chatEntityId?.(t), H = Qt(u?.id), U = A(!1), W = A(!1);
|
|
2074
2076
|
D(() => {
|
|
2075
|
-
let n = U.current && !c.running;
|
|
2076
|
-
if (U.current = c.running, !n || !V || !u) return;
|
|
2077
|
+
let n = !U.current && c.running, i = U.current && !c.running;
|
|
2078
|
+
if (U.current = c.running, !n && !i || !V || !u) return;
|
|
2077
2079
|
if (W.current) {
|
|
2078
|
-
W.current = !1;
|
|
2080
|
+
i && (W.current = !1);
|
|
2079
2081
|
return;
|
|
2080
2082
|
}
|
|
2081
|
-
let
|
|
2082
|
-
if (!
|
|
2083
|
-
let
|
|
2084
|
-
e.autoTitle && e.definition.conversational && !Re({ activity:
|
|
2083
|
+
let a = c.snapshot();
|
|
2084
|
+
if (!a) return;
|
|
2085
|
+
let o = [...r ?? [], ...a.activity];
|
|
2086
|
+
e.autoTitle && e.definition.conversational && !Re({ activity: o }) || (Ne({
|
|
2085
2087
|
scopeId: u.id,
|
|
2086
2088
|
subagentId: e.id,
|
|
2087
2089
|
entityId: V,
|
|
2088
2090
|
params: t,
|
|
2089
2091
|
title: Rt(e, t),
|
|
2090
|
-
history:
|
|
2091
|
-
activity:
|
|
2092
|
-
}), e.autoTitle && H(e.id, V, c.selectedModel));
|
|
2092
|
+
history: a.history,
|
|
2093
|
+
activity: o
|
|
2094
|
+
}), i && e.autoTitle && H(e.id, V, c.selectedModel));
|
|
2093
2095
|
}, [c.running]);
|
|
2094
2096
|
let G = () => {
|
|
2095
2097
|
F.current = !0, c.running && c.stop(), l.closeTask(f);
|