@llmnative/agentico 0.6.0 → 0.8.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 +2 -0
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +423 -319
- package/dist/index.mjs.map +1 -1
- package/dist/types/domain/agentDefinition.d.ts +31 -5
- package/dist/types/domain/approval.d.ts +13 -0
- package/dist/types/domain/prompts.d.ts +2 -0
- package/dist/types/i18n/types.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/presentation/useAgent.d.ts +10 -7
- package/llms.txt +3 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -22,29 +22,29 @@ function F(e, t) {
|
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/domain/defineSubagent.ts
|
|
25
|
-
function
|
|
25
|
+
function ee(e) {
|
|
26
26
|
return e;
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/domain/subagentRegistry.ts
|
|
30
|
-
var
|
|
31
|
-
function
|
|
32
|
-
|
|
30
|
+
var I = [];
|
|
31
|
+
function L(e) {
|
|
32
|
+
I = e;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function R() {
|
|
35
|
+
return I.length === 0 && typeof console < "u" && console.warn("[agentico] getSubagentRegistry() letto a registro vuoto — registerSubagents() non è ancora stato chiamato?"), I;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return
|
|
37
|
+
function z(e) {
|
|
38
|
+
return I.find((t) => t.id === e);
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/domain/crossAgentTools.ts
|
|
42
|
-
var
|
|
43
|
-
function
|
|
44
|
-
|
|
42
|
+
var B = [];
|
|
43
|
+
function V(...e) {
|
|
44
|
+
B = e;
|
|
45
45
|
}
|
|
46
46
|
function H(e) {
|
|
47
|
-
return
|
|
47
|
+
return B.flatMap((t) => t(e));
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
50
|
//#region src/domain/mcpTool.ts
|
|
@@ -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),",
|
|
@@ -146,16 +148,16 @@ function te(e) {
|
|
|
146
148
|
function Y() {
|
|
147
149
|
return J;
|
|
148
150
|
}
|
|
149
|
-
function
|
|
151
|
+
function X() {
|
|
150
152
|
J = K;
|
|
151
153
|
}
|
|
152
154
|
//#endregion
|
|
153
155
|
//#region src/domain/cli/renderManifestCli.ts
|
|
154
|
-
function
|
|
156
|
+
function ne(e, t) {
|
|
155
157
|
return `${e} ${t.map((e) => e.required ? `--${e.key} <${e.type}>` : `[--${e.key} <${e.type}>]`).join(" ")}`.trim();
|
|
156
158
|
}
|
|
157
|
-
function
|
|
158
|
-
let n = G(t), r =
|
|
159
|
+
function Z(e, t) {
|
|
160
|
+
let n = G(t), r = ne(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
|
|
159
161
|
return [
|
|
160
162
|
`COMMAND: ${e} ${t.name}`,
|
|
161
163
|
` ${t.summary}`,
|
|
@@ -167,46 +169,46 @@ function ie(e, t) {
|
|
|
167
169
|
...i,
|
|
168
170
|
"",
|
|
169
171
|
" OUTPUT",
|
|
170
|
-
|
|
172
|
+
re(t.describeOutput(), 4),
|
|
171
173
|
(t.example, ""),
|
|
172
174
|
t.example ? " EXAMPLE" : "",
|
|
173
175
|
t.example ? ` ${t.example}` : ""
|
|
174
176
|
].filter((e) => e !== "").join("\n");
|
|
175
177
|
}
|
|
176
|
-
function
|
|
178
|
+
function re(e, t) {
|
|
177
179
|
let n = " ".repeat(t);
|
|
178
180
|
return e.split("\n").map((e) => e && n + e).join("\n");
|
|
179
181
|
}
|
|
180
|
-
function
|
|
182
|
+
function ie(e) {
|
|
181
183
|
return [
|
|
182
184
|
"NAME",
|
|
183
185
|
` ${e.id} — ${e.label}`,
|
|
184
186
|
"",
|
|
185
187
|
"DESCRIPTION",
|
|
186
|
-
|
|
188
|
+
re(e.description, 2),
|
|
187
189
|
"",
|
|
188
|
-
...e.commands.map((t) =>
|
|
190
|
+
...e.commands.map((t) => Z(e.id, t))
|
|
189
191
|
].join("\n");
|
|
190
192
|
}
|
|
191
|
-
function
|
|
193
|
+
function ae(e) {
|
|
192
194
|
return e.length === 0 ? Y().noToolsAvailable : e.map((e) => `${e.id} [${e.commands.map((e) => e.name).join("|")}] — ${e.label}: ${e.commands.map((e) => e.summary).join(" / ")}`).join("\n");
|
|
193
195
|
}
|
|
194
196
|
//#endregion
|
|
195
197
|
//#region src/domain/microPrompts.ts
|
|
196
|
-
var
|
|
198
|
+
var oe = {
|
|
197
199
|
id: "closing-summary",
|
|
198
200
|
get text() {
|
|
199
201
|
return Y().closingSummary;
|
|
200
202
|
}
|
|
201
|
-
},
|
|
202
|
-
function
|
|
203
|
+
}, se = { [oe.id]: oe };
|
|
204
|
+
function ce(e, t) {
|
|
203
205
|
if (!t || t.length === 0) return e;
|
|
204
|
-
let n = t.map((e) =>
|
|
206
|
+
let n = t.map((e) => se[e]?.text).filter((e) => !!e);
|
|
205
207
|
return n.length === 0 ? e : `${e}\n\n${n.join("\n")}`;
|
|
206
208
|
}
|
|
207
209
|
//#endregion
|
|
208
210
|
//#region src/domain/extractErrorMessage.ts
|
|
209
|
-
function
|
|
211
|
+
function le(e) {
|
|
210
212
|
if (e instanceof Error) return e.message;
|
|
211
213
|
if (typeof e == "object" && e) {
|
|
212
214
|
let t = e;
|
|
@@ -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",
|
|
@@ -521,20 +535,20 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
521
535
|
card: n
|
|
522
536
|
}] : i;
|
|
523
537
|
});
|
|
524
|
-
}, []), P = j.length > 0 ? j[j.length - 1] : null, [F,
|
|
525
|
-
|
|
538
|
+
}, []), P = j.length > 0 ? j[j.length - 1] : null, [F, ee] = D([]), I = x((e, t) => {
|
|
539
|
+
ee((n) => {
|
|
526
540
|
let r = n.filter((t) => t.id !== e);
|
|
527
541
|
return t ? [...r, {
|
|
528
542
|
id: e,
|
|
529
543
|
...t
|
|
530
544
|
}] : r;
|
|
531
545
|
});
|
|
532
|
-
}, []),
|
|
546
|
+
}, []), L = T(() => F.map((e) => ({
|
|
533
547
|
subagentId: e.subagentId,
|
|
534
548
|
componentKey: e.componentKey,
|
|
535
549
|
onResult: e.onResult,
|
|
536
550
|
pinnedEntityId: e.pinnedEntityId
|
|
537
|
-
})), [F]),
|
|
551
|
+
})), [F]), R = T(() => {
|
|
538
552
|
let e = /* @__PURE__ */ new Map();
|
|
539
553
|
for (let t of F) e.set(t.subagentId, {
|
|
540
554
|
subagentId: t.subagentId,
|
|
@@ -543,8 +557,8 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
543
557
|
contextInfo: t.contextInfo
|
|
544
558
|
});
|
|
545
559
|
return [...e.values()];
|
|
546
|
-
}, [F]),
|
|
547
|
-
let t =
|
|
560
|
+
}, [F]), B = T(() => R.map((e) => {
|
|
561
|
+
let t = z(e.subagentId)?.componentContexts?.[e.componentKey];
|
|
548
562
|
if (!t) return null;
|
|
549
563
|
let n = e.contextInfo ? `${t.agenticoHint}\n${e.contextInfo}` : t.agenticoHint;
|
|
550
564
|
return {
|
|
@@ -552,12 +566,12 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
552
566
|
agenticoHint: n,
|
|
553
567
|
userMessage: t.userMessage
|
|
554
568
|
};
|
|
555
|
-
}).filter((e) => e !== null), [
|
|
556
|
-
if (
|
|
557
|
-
if (
|
|
558
|
-
let e =
|
|
569
|
+
}).filter((e) => e !== null), [R]), V = T(() => B.map((e) => e.userMessage), [B]), H = T(() => {
|
|
570
|
+
if (B.length === 0) return null;
|
|
571
|
+
if (B.length === 1) return B[0].agenticoHint;
|
|
572
|
+
let e = B.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
|
|
559
573
|
return `${Y().multipleCandidates}\n\n${e}`;
|
|
560
|
-
}, [
|
|
574
|
+
}, [B]) ?? P?.text ?? null, U = B.length > 0 ? null : P?.card ?? null, W = T(() => [...new Set(L.map((e) => e.subagentId))], [L]), G = W.length === 1 ? W[0] : W.length === 0 ? P?.card?.subagentId ?? null : null, K = x((e, t) => {
|
|
561
575
|
u();
|
|
562
576
|
let n = i.current;
|
|
563
577
|
if (n?.id === "agentico-orchestrator") return;
|
|
@@ -583,19 +597,19 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
583
597
|
...e,
|
|
584
598
|
savedToDisk: !0
|
|
585
599
|
} : e));
|
|
586
|
-
}, []), [J, te] = D(null), [
|
|
600
|
+
}, []), [J, te] = D(null), [X, ne] = D(null), Z = x((e, t, n) => {
|
|
587
601
|
u(), te({
|
|
588
602
|
subagentId: e,
|
|
589
603
|
entityId: t,
|
|
590
604
|
snapshot: n
|
|
591
|
-
}),
|
|
592
|
-
}, [u]), [
|
|
593
|
-
u(), c(Me),
|
|
605
|
+
}), ne(crypto.randomUUID());
|
|
606
|
+
}, [u]), [re, ie] = D(null), [ae, oe] = D(null), se = x((e, t) => {
|
|
607
|
+
u(), c(Me), ie({
|
|
594
608
|
subagentId: e,
|
|
595
609
|
extraDestinations: t
|
|
596
|
-
}),
|
|
597
|
-
}, [u, c]), [
|
|
598
|
-
|
|
610
|
+
}), oe(crypto.randomUUID());
|
|
611
|
+
}, [u, c]), [ce, le] = D(null), [ue, de] = D(null), fe = x((e, t, n) => {
|
|
612
|
+
ie(null), le({
|
|
599
613
|
subagentId: e,
|
|
600
614
|
params: t,
|
|
601
615
|
extraDestinations: n
|
|
@@ -623,9 +637,9 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
623
637
|
setPageContext: N,
|
|
624
638
|
scopedSubagentId: G,
|
|
625
639
|
pendingScopedSubagentId: O,
|
|
626
|
-
componentAnchors:
|
|
627
|
-
anchoredUserMessages:
|
|
628
|
-
registerComponentAnchor:
|
|
640
|
+
componentAnchors: L,
|
|
641
|
+
anchoredUserMessages: V,
|
|
642
|
+
registerComponentAnchor: I,
|
|
629
643
|
openPanel: u,
|
|
630
644
|
pendingExtraDestinations: p,
|
|
631
645
|
pendingAttachments: h,
|
|
@@ -633,14 +647,14 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
633
647
|
orchestratorRunId: y,
|
|
634
648
|
pendingCarryOver: S,
|
|
635
649
|
commitEntityChat: q,
|
|
636
|
-
resumeEntityChat:
|
|
650
|
+
resumeEntityChat: Z,
|
|
637
651
|
pendingResume: J,
|
|
638
|
-
resumeRunId:
|
|
652
|
+
resumeRunId: X,
|
|
639
653
|
dismissForeignTask: ve,
|
|
640
|
-
pendingManualEntry:
|
|
641
|
-
manualEntryRunId:
|
|
642
|
-
startManualEntry:
|
|
643
|
-
pendingResumeWithAI:
|
|
654
|
+
pendingManualEntry: re,
|
|
655
|
+
manualEntryRunId: ae,
|
|
656
|
+
startManualEntry: se,
|
|
657
|
+
pendingResumeWithAI: ce,
|
|
644
658
|
resumeWithAIRunId: ue,
|
|
645
659
|
resumeWithAI: fe,
|
|
646
660
|
startSubagent: _e,
|
|
@@ -660,9 +674,9 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
660
674
|
N,
|
|
661
675
|
G,
|
|
662
676
|
O,
|
|
663
|
-
R,
|
|
664
|
-
ee,
|
|
665
677
|
L,
|
|
678
|
+
V,
|
|
679
|
+
I,
|
|
666
680
|
u,
|
|
667
681
|
p,
|
|
668
682
|
h,
|
|
@@ -670,14 +684,14 @@ function Pe({ children: e, scope: t = null }) {
|
|
|
670
684
|
y,
|
|
671
685
|
S,
|
|
672
686
|
q,
|
|
673
|
-
|
|
687
|
+
Z,
|
|
674
688
|
J,
|
|
675
|
-
|
|
689
|
+
X,
|
|
676
690
|
ve,
|
|
691
|
+
re,
|
|
677
692
|
ae,
|
|
678
693
|
se,
|
|
679
|
-
|
|
680
|
-
X,
|
|
694
|
+
ce,
|
|
681
695
|
ue,
|
|
682
696
|
fe,
|
|
683
697
|
_e,
|
|
@@ -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
|
|
1167
|
-
function
|
|
1168
|
-
return e.filter((e) => !d.isTextAttachment(e.mimeType) || e.base64.length <=
|
|
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
|
|
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;
|
|
@@ -1177,13 +1204,14 @@ function ht(e, t = {}) {
|
|
|
1177
1204
|
T.current = w;
|
|
1178
1205
|
let O = E(null), k = E(!1), A = E(null), M = () => {
|
|
1179
1206
|
A.current?.abort();
|
|
1180
|
-
},
|
|
1181
|
-
|
|
1182
|
-
},
|
|
1183
|
-
|
|
1184
|
-
|
|
1207
|
+
}, ee = _()?.registry ?? {}, I = r && c ? h(c) : null, L = I ? ee[I.provider] : null, R = e.executor, z = !!R?.alongside, B = !!R && !z, V = E([]), H = (e) => !!e && V.current.some((t) => t.value === e), W = E(!1), [G, K] = D([]), [q, J] = D(""), te = E(""), X = (e) => {
|
|
1208
|
+
te.current = e, J(e);
|
|
1209
|
+
}, ne = (e) => {
|
|
1210
|
+
let t = R?.models?.(e) ?? [];
|
|
1211
|
+
V.current = t, K(t), X(R?.defaultModel?.(e) ?? "");
|
|
1212
|
+
}, Z = async (e, t, n, r) => {
|
|
1185
1213
|
let i = O.current;
|
|
1186
|
-
if (!i || !
|
|
1214
|
+
if (!i || !R) return m(T.current.noActiveSession), null;
|
|
1187
1215
|
let a = new AbortController();
|
|
1188
1216
|
A.current = a;
|
|
1189
1217
|
let o = crypto.randomUUID();
|
|
@@ -1268,13 +1296,13 @@ function ht(e, t = {}) {
|
|
|
1268
1296
|
_.clear();
|
|
1269
1297
|
}, w = e || r?.historyText || "";
|
|
1270
1298
|
try {
|
|
1271
|
-
let o = await
|
|
1299
|
+
let o = await R.turn({
|
|
1272
1300
|
params: i.params,
|
|
1273
1301
|
context: i.context,
|
|
1274
1302
|
text: e,
|
|
1275
1303
|
first: t,
|
|
1276
1304
|
signal: a.signal,
|
|
1277
|
-
...n ||
|
|
1305
|
+
...n || te.current ? { model: n || te.current } : {},
|
|
1278
1306
|
...r ? { answers: {
|
|
1279
1307
|
id: r.id,
|
|
1280
1308
|
answers: r.answers
|
|
@@ -1299,11 +1327,11 @@ function ht(e, t = {}) {
|
|
|
1299
1327
|
return i.history = [...i.history, ...w ? [{
|
|
1300
1328
|
role: "user",
|
|
1301
1329
|
content: w
|
|
1302
|
-
}] : []], a.signal.aborted ? (x("stopped"), null) : (x("error"), m(
|
|
1330
|
+
}] : []], a.signal.aborted ? (x("stopped"), null) : (x("error"), m(le(e)), null);
|
|
1303
1331
|
} finally {
|
|
1304
1332
|
A.current = null;
|
|
1305
1333
|
}
|
|
1306
|
-
},
|
|
1334
|
+
}, re = async (e, t, n) => {
|
|
1307
1335
|
let r = x.current.find((t) => t.id === e)?.parts?.find((e) => e.type === "questions" && e.id === t);
|
|
1308
1336
|
if (!r || r.type !== "questions") throw m(T.current.noActiveSession), Error(T.current.noActiveSession);
|
|
1309
1337
|
let i = () => S((r) => r.map((r) => r.id === e ? {
|
|
@@ -1318,7 +1346,7 @@ function ht(e, t = {}) {
|
|
|
1318
1346
|
if (!B || !O.current) throw m(T.current.noActiveSession), Error(T.current.noActiveSession);
|
|
1319
1347
|
k.current = !0, f(!0), m(null), i();
|
|
1320
1348
|
try {
|
|
1321
|
-
return await
|
|
1349
|
+
return await Z("", !1, void 0, {
|
|
1322
1350
|
id: t,
|
|
1323
1351
|
answers: n,
|
|
1324
1352
|
historyText: F(r.questions, n)
|
|
@@ -1326,19 +1354,53 @@ function ht(e, t = {}) {
|
|
|
1326
1354
|
} finally {
|
|
1327
1355
|
k.current = !1, f(!1);
|
|
1328
1356
|
}
|
|
1329
|
-
},
|
|
1357
|
+
}, ie = async (t, n, r) => {
|
|
1330
1358
|
let i = O.current;
|
|
1331
1359
|
if (!i) return m(T.current.noActiveSession), null;
|
|
1332
|
-
let a = r ? h(r) :
|
|
1360
|
+
let a = r ? h(r) : I, o = a ? ee[a.provider] : null;
|
|
1333
1361
|
if (!o || !a) return m(T.current.noProviderAvailable), null;
|
|
1334
1362
|
n?.length && (i.attachmentsRef.current = [...i.attachmentsRef.current ?? [], ...n]);
|
|
1335
|
-
let s = (n ?? []).filter((e) => d.isTextAttachment(e.mimeType)).map((e) => e.base64.length <=
|
|
1363
|
+
let s = (n ?? []).filter((e) => d.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= gt ? `\n\n[File allegato: ${e.name}]\n${d.decodeBase64Text(e.base64)}` : `\n\n[File allegato: ${e.name} — troppo grande per essere incollato qui. Usa uno dei tool di lettura file disponibili (es. list_csv_columns/extract_csv_column) per leggerne il contenuto prima di chiedere altro all'utente.]`).join(""), c = _t(n ?? []), l = i.tools.map((e) => ({
|
|
1336
1364
|
name: e.name,
|
|
1337
1365
|
description: e.description,
|
|
1338
1366
|
inputSchema: U(e.inputSchema)
|
|
1339
|
-
})), u =
|
|
1340
|
-
|
|
1341
|
-
|
|
1367
|
+
})), u = (e, t, n, r) => {
|
|
1368
|
+
let i = T.current, a = `approval-${e}`, o = t.describeApproval?.(n) ?? t.describeInvocation?.(n) ?? t.name;
|
|
1369
|
+
S((e) => [...e, {
|
|
1370
|
+
id: a,
|
|
1371
|
+
kind: "thinking",
|
|
1372
|
+
label: i.approvalHeader,
|
|
1373
|
+
status: "running",
|
|
1374
|
+
parts: [{
|
|
1375
|
+
type: "questions",
|
|
1376
|
+
id: ft,
|
|
1377
|
+
questions: [{
|
|
1378
|
+
header: i.approvalHeader,
|
|
1379
|
+
question: i.approveQuestion.replace("{action}", o),
|
|
1380
|
+
options: [{ label: i.approve }, { label: i.reject }],
|
|
1381
|
+
custom: !0
|
|
1382
|
+
}]
|
|
1383
|
+
}]
|
|
1384
|
+
}]);
|
|
1385
|
+
let s = `${a}:${ft}`;
|
|
1386
|
+
return new Promise((e, t) => {
|
|
1387
|
+
let n = () => {
|
|
1388
|
+
C.current.delete(s), g(a, "stopped"), t(new DOMException("The turn was stopped.", "AbortError"));
|
|
1389
|
+
};
|
|
1390
|
+
if (r.aborted) {
|
|
1391
|
+
n();
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
r.addEventListener("abort", n, { once: !0 }), C.current.set(s, {
|
|
1395
|
+
resolve: (t) => {
|
|
1396
|
+
r.removeEventListener("abort", n), g(a, "done"), e(mt(t, i.approve, i.reject));
|
|
1397
|
+
},
|
|
1398
|
+
reject: t
|
|
1399
|
+
});
|
|
1400
|
+
});
|
|
1401
|
+
}, f = new Map(i.tools.map((e) => [e.name, e])), p = new AbortController();
|
|
1402
|
+
A.current = p;
|
|
1403
|
+
let g = (e, t, n, r) => S((i) => i.map((i) => i.id === e ? {
|
|
1342
1404
|
...i,
|
|
1343
1405
|
status: t,
|
|
1344
1406
|
...n === void 0 ? {} : { detail: n },
|
|
@@ -1346,7 +1408,7 @@ function ht(e, t = {}) {
|
|
|
1346
1408
|
} : i));
|
|
1347
1409
|
try {
|
|
1348
1410
|
let n = i.history, r = t;
|
|
1349
|
-
for (let t = 0; t <
|
|
1411
|
+
for (let t = 0; t < ht; t++) {
|
|
1350
1412
|
let d = crypto.randomUUID();
|
|
1351
1413
|
S((e) => [...e, {
|
|
1352
1414
|
id: d,
|
|
@@ -1361,7 +1423,7 @@ function ht(e, t = {}) {
|
|
|
1361
1423
|
model: a.model,
|
|
1362
1424
|
history: n,
|
|
1363
1425
|
tools: l.length ? l : void 0,
|
|
1364
|
-
signal:
|
|
1426
|
+
signal: p.signal,
|
|
1365
1427
|
attachments: t === 0 ? c : void 0,
|
|
1366
1428
|
logId: i.logId
|
|
1367
1429
|
});
|
|
@@ -1369,13 +1431,13 @@ function ht(e, t = {}) {
|
|
|
1369
1431
|
return i.history = [...n, ...r ? [{
|
|
1370
1432
|
role: "user",
|
|
1371
1433
|
content: r + s
|
|
1372
|
-
}] : []],
|
|
1434
|
+
}] : []], p.signal.aborted ? (g(d, "stopped"), e.fallback(i.params, i.context)) : (g(d, "error"), m(le(t)), null);
|
|
1373
1435
|
}
|
|
1374
1436
|
if (i.history = [...n, ...r ? [{
|
|
1375
1437
|
role: "user",
|
|
1376
1438
|
content: r + s
|
|
1377
|
-
}] : []], !h) return
|
|
1378
|
-
if (h.type === "text") return
|
|
1439
|
+
}] : []], !h) return p.signal.aborted ? (g(d, "stopped"), e.fallback(i.params, i.context)) : (g(d, "error"), m(T.current.noProviderResponse), null);
|
|
1440
|
+
if (h.type === "text") return g(d, "done", h.text), e.conversational && h.text.trim() && S((e) => e.map((e) => e.id === d ? {
|
|
1379
1441
|
...e,
|
|
1380
1442
|
parts: [{
|
|
1381
1443
|
type: "text",
|
|
@@ -1397,19 +1459,43 @@ function ht(e, t = {}) {
|
|
|
1397
1459
|
responsePreview: h.text.length > 2e3 ? `${h.text.slice(0, 1e3)}\n…[troncato qui nel log, ${h.text.length} caratteri totali]…\n${h.text.slice(-1e3)}` : h.text,
|
|
1398
1460
|
params: i.params
|
|
1399
1461
|
}), m(T.current.invalidResponse), e.fallback(i.params, i.context));
|
|
1400
|
-
let
|
|
1401
|
-
let t =
|
|
1462
|
+
let _ = h.toolCalls.map((e) => {
|
|
1463
|
+
let t = f.get(e.name);
|
|
1402
1464
|
return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
|
|
1403
1465
|
});
|
|
1404
|
-
|
|
1405
|
-
let
|
|
1406
|
-
|
|
1466
|
+
g(d, "done", h.text || void 0, h.text ? void 0 : _);
|
|
1467
|
+
let v = /* @__PURE__ */ new Map();
|
|
1468
|
+
for (let t of h.toolCalls) {
|
|
1469
|
+
let n = f.get(t.name);
|
|
1470
|
+
if (n && pt(n, t.input)) try {
|
|
1471
|
+
v.set(t.id, await u(t.id, n, t.input, p.signal));
|
|
1472
|
+
} catch {
|
|
1473
|
+
return e.fallback(i.params, i.context);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
let y = await Promise.all(h.toolCalls.map(async (e) => {
|
|
1477
|
+
let t = f.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`, r = v.get(e.id);
|
|
1478
|
+
if (r && !r.approved) {
|
|
1479
|
+
S((t) => [...t, {
|
|
1480
|
+
id: e.id,
|
|
1481
|
+
kind: "tool",
|
|
1482
|
+
label: n,
|
|
1483
|
+
status: "stopped"
|
|
1484
|
+
}]);
|
|
1485
|
+
let t = Y().toolRejected.replace("{reason}", r.reason ? ` (${r.reason})` : "");
|
|
1486
|
+
return {
|
|
1487
|
+
toolCallId: e.id,
|
|
1488
|
+
name: e.name,
|
|
1489
|
+
output: t,
|
|
1490
|
+
isError: !0
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1407
1493
|
if (S((t) => [...t, {
|
|
1408
1494
|
id: e.id,
|
|
1409
1495
|
kind: "tool",
|
|
1410
1496
|
label: n,
|
|
1411
1497
|
status: "running"
|
|
1412
|
-
}]), !t) return
|
|
1498
|
+
}]), !t) return g(e.id, "error"), {
|
|
1413
1499
|
toolCallId: e.id,
|
|
1414
1500
|
name: e.name,
|
|
1415
1501
|
output: `Tool sconosciuto: ${e.name}`,
|
|
@@ -1417,16 +1503,16 @@ function ht(e, t = {}) {
|
|
|
1417
1503
|
};
|
|
1418
1504
|
try {
|
|
1419
1505
|
let n = await t.execute(e.input);
|
|
1420
|
-
return
|
|
1506
|
+
return g(e.id, "done"), {
|
|
1421
1507
|
toolCallId: e.id,
|
|
1422
1508
|
name: e.name,
|
|
1423
1509
|
output: n
|
|
1424
1510
|
};
|
|
1425
1511
|
} catch (t) {
|
|
1426
|
-
return
|
|
1512
|
+
return g(e.id, "error"), {
|
|
1427
1513
|
toolCallId: e.id,
|
|
1428
1514
|
name: e.name,
|
|
1429
|
-
output:
|
|
1515
|
+
output: le(t),
|
|
1430
1516
|
isError: !0
|
|
1431
1517
|
};
|
|
1432
1518
|
}
|
|
@@ -1444,7 +1530,7 @@ function ht(e, t = {}) {
|
|
|
1444
1530
|
},
|
|
1445
1531
|
{
|
|
1446
1532
|
role: "tool_result",
|
|
1447
|
-
results:
|
|
1533
|
+
results: y
|
|
1448
1534
|
}
|
|
1449
1535
|
], r = "";
|
|
1450
1536
|
}
|
|
@@ -1458,166 +1544,180 @@ function ht(e, t = {}) {
|
|
|
1458
1544
|
let h;
|
|
1459
1545
|
try {
|
|
1460
1546
|
h = await o.complete({
|
|
1461
|
-
prompt:
|
|
1547
|
+
prompt: ce(Y().stopCallingTools, e.microPromptIds),
|
|
1462
1548
|
model: a.model,
|
|
1463
1549
|
history: n,
|
|
1464
|
-
signal:
|
|
1550
|
+
signal: p.signal,
|
|
1465
1551
|
logId: i.logId
|
|
1466
1552
|
});
|
|
1467
1553
|
} catch {
|
|
1468
1554
|
h = null;
|
|
1469
1555
|
}
|
|
1470
1556
|
if (h?.type === "text") {
|
|
1471
|
-
|
|
1557
|
+
g(d, "done", h.text), i.history = [...n, {
|
|
1472
1558
|
role: "assistant",
|
|
1473
1559
|
content: h.text
|
|
1474
1560
|
}];
|
|
1475
1561
|
let t = e.parseResponse(h.text, i.params, i.context);
|
|
1476
1562
|
if (t) return t;
|
|
1477
|
-
} else
|
|
1478
|
-
return
|
|
1563
|
+
} else g(d, p.signal.aborted ? "stopped" : "error"), i.history = n;
|
|
1564
|
+
return p.signal.aborted || m(T.current.tooManyToolTurns), e.fallback(i.params, i.context);
|
|
1479
1565
|
} finally {
|
|
1480
1566
|
A.current = null;
|
|
1481
1567
|
}
|
|
1482
|
-
}
|
|
1568
|
+
}, ae = async (t, n) => {
|
|
1569
|
+
if (k.current) return m(T.current.requestInProgress), null;
|
|
1570
|
+
k.current = !0, m(null), S(n?.openingMessage ? [{
|
|
1571
|
+
id: crypto.randomUUID(),
|
|
1572
|
+
kind: "user",
|
|
1573
|
+
label: "Tu",
|
|
1574
|
+
status: "done",
|
|
1575
|
+
detail: n.openingMessage,
|
|
1576
|
+
...n.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
|
|
1577
|
+
}] : []), f(!0);
|
|
1578
|
+
try {
|
|
1579
|
+
let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
|
|
1580
|
+
if (O.current = {
|
|
1581
|
+
params: t,
|
|
1582
|
+
context: i,
|
|
1583
|
+
tools: o,
|
|
1584
|
+
history: [],
|
|
1585
|
+
logId: crypto.randomUUID(),
|
|
1586
|
+
attachmentsRef: a
|
|
1587
|
+
}, B) return v(!0), ne(t), await Z(n?.openingMessage ?? "", !0);
|
|
1588
|
+
if (z) {
|
|
1589
|
+
ne(t), W.current = !1;
|
|
1590
|
+
let e = n?.model || te.current;
|
|
1591
|
+
if (H(e)) return v(!0), W.current = !0, await Z(n?.openingMessage ?? "", !0, e);
|
|
1592
|
+
}
|
|
1593
|
+
let s = n?.model || void 0, c = s ? !!ee[h(s)?.provider ?? ""] : !!L;
|
|
1594
|
+
if (!r || !c) {
|
|
1595
|
+
v(!1);
|
|
1596
|
+
let n = e.fallback(t, i);
|
|
1597
|
+
return S((t) => [...t, {
|
|
1598
|
+
id: crypto.randomUUID(),
|
|
1599
|
+
kind: "tool",
|
|
1600
|
+
status: "done",
|
|
1601
|
+
label: e.describeFallback?.(n) ?? T.current.aiDisabledFallback
|
|
1602
|
+
}]), n;
|
|
1603
|
+
}
|
|
1604
|
+
v(!0);
|
|
1605
|
+
let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, u = ce(e.buildPrompt(t, i), e.microPromptIds);
|
|
1606
|
+
return await ie(u, l, s);
|
|
1607
|
+
} catch (e) {
|
|
1608
|
+
return m(le(e)), null;
|
|
1609
|
+
} finally {
|
|
1610
|
+
k.current = !1, f(!1);
|
|
1611
|
+
}
|
|
1612
|
+
}, oe = async (t, n) => {
|
|
1613
|
+
if (k.current) {
|
|
1614
|
+
m(T.current.requestInProgress);
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
k.current = !0, m(null), S(n.activity), f(!0);
|
|
1618
|
+
try {
|
|
1619
|
+
let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
|
|
1620
|
+
O.current = {
|
|
1621
|
+
params: t,
|
|
1622
|
+
context: i,
|
|
1623
|
+
tools: o,
|
|
1624
|
+
history: n.history,
|
|
1625
|
+
logId: crypto.randomUUID(),
|
|
1626
|
+
attachmentsRef: a
|
|
1627
|
+
}, (B || z) && ne(t), W.current = !1, v(B || z || r && !!L);
|
|
1628
|
+
} catch (e) {
|
|
1629
|
+
m(le(e));
|
|
1630
|
+
} finally {
|
|
1631
|
+
k.current = !1, f(!1);
|
|
1632
|
+
}
|
|
1633
|
+
}, se = async (t, n) => {
|
|
1634
|
+
if (k.current) return m(T.current.requestInProgress), null;
|
|
1635
|
+
if (m(null), !t.trim()) return m("Messaggio vuoto."), null;
|
|
1636
|
+
let r = O.current;
|
|
1637
|
+
if (!r) return m(T.current.noActiveSession), null;
|
|
1638
|
+
k.current = !0, f(!0), S((e) => [...e, {
|
|
1639
|
+
id: crypto.randomUUID(),
|
|
1640
|
+
kind: "user",
|
|
1641
|
+
label: "Tu",
|
|
1642
|
+
status: "done",
|
|
1643
|
+
detail: t,
|
|
1644
|
+
...n?.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
|
|
1645
|
+
}]);
|
|
1646
|
+
try {
|
|
1647
|
+
if (B) return await Z(t, !1, n?.model || void 0);
|
|
1648
|
+
let i = n?.model || (z ? te.current : "");
|
|
1649
|
+
if (z && H(i)) {
|
|
1650
|
+
let e = !W.current;
|
|
1651
|
+
return W.current = !0, await Z(t, e, i);
|
|
1652
|
+
}
|
|
1653
|
+
let a = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, o = ce(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
|
|
1654
|
+
return await ie(o, a, n?.model || void 0);
|
|
1655
|
+
} catch (e) {
|
|
1656
|
+
return m(le(e)), null;
|
|
1657
|
+
} finally {
|
|
1658
|
+
k.current = !1, f(!1);
|
|
1659
|
+
}
|
|
1660
|
+
}, ue = () => {
|
|
1661
|
+
let t = O.current;
|
|
1662
|
+
if (!t) return null;
|
|
1663
|
+
m(null);
|
|
1664
|
+
let n = e.fallback(t.params, t.context);
|
|
1665
|
+
return S((t) => [...t, {
|
|
1666
|
+
id: crypto.randomUUID(),
|
|
1667
|
+
kind: "tool",
|
|
1668
|
+
status: "done",
|
|
1669
|
+
label: e.describeFallback?.(n) ?? T.current.continueWithoutAiFallback
|
|
1670
|
+
}]), n;
|
|
1671
|
+
}, de = () => O.current ? {
|
|
1672
|
+
history: O.current.history,
|
|
1673
|
+
activity: y
|
|
1674
|
+
} : null;
|
|
1483
1675
|
return {
|
|
1484
1676
|
enabled: r,
|
|
1485
1677
|
setEnabled: i,
|
|
1486
1678
|
hasProviders: a,
|
|
1487
|
-
selectedModel: B ?
|
|
1488
|
-
setSelectedModel: B ?
|
|
1679
|
+
selectedModel: B || z && q ? q : c,
|
|
1680
|
+
setSelectedModel: B ? X : z ? (e) => {
|
|
1681
|
+
H(e) ? X(e) : (X(""), l(e));
|
|
1682
|
+
} : l,
|
|
1489
1683
|
modelsByProvider: o,
|
|
1490
1684
|
modelsLoading: s,
|
|
1491
1685
|
running: u,
|
|
1492
1686
|
error: p,
|
|
1493
1687
|
canContinue: g,
|
|
1494
1688
|
remote: B,
|
|
1495
|
-
remoteModels:
|
|
1689
|
+
remoteModels: G,
|
|
1690
|
+
alongside: z,
|
|
1691
|
+
...R?.catalogGroup ? { catalogGroup: R.catalogGroup } : {},
|
|
1496
1692
|
activity: y,
|
|
1497
|
-
run:
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
id: crypto.randomUUID(),
|
|
1501
|
-
kind: "user",
|
|
1502
|
-
label: "Tu",
|
|
1503
|
-
status: "done",
|
|
1504
|
-
detail: n.openingMessage,
|
|
1505
|
-
...n.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
|
|
1506
|
-
}] : []), f(!0);
|
|
1507
|
-
try {
|
|
1508
|
-
let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
|
|
1509
|
-
if (O.current = {
|
|
1510
|
-
params: t,
|
|
1511
|
-
context: i,
|
|
1512
|
-
tools: o,
|
|
1513
|
-
history: [],
|
|
1514
|
-
logId: crypto.randomUUID(),
|
|
1515
|
-
attachmentsRef: a
|
|
1516
|
-
}, B) return v(!0), q(t), await J(n?.openingMessage ?? "", !0);
|
|
1517
|
-
let s = n?.model || void 0, c = s ? !!I[h(s)?.provider ?? ""] : !!R;
|
|
1518
|
-
if (!r || !c) {
|
|
1519
|
-
v(!1);
|
|
1520
|
-
let n = e.fallback(t, i);
|
|
1521
|
-
return S((t) => [...t, {
|
|
1522
|
-
id: crypto.randomUUID(),
|
|
1523
|
-
kind: "tool",
|
|
1524
|
-
status: "done",
|
|
1525
|
-
label: e.describeFallback?.(n) ?? T.current.aiDisabledFallback
|
|
1526
|
-
}]), n;
|
|
1527
|
-
}
|
|
1528
|
-
v(!0);
|
|
1529
|
-
let l = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, u = X(e.buildPrompt(t, i), e.microPromptIds);
|
|
1530
|
-
return await ne(u, l, s);
|
|
1531
|
-
} catch (e) {
|
|
1532
|
-
return m(Z(e)), null;
|
|
1533
|
-
} finally {
|
|
1534
|
-
k.current = !1, f(!1);
|
|
1535
|
-
}
|
|
1536
|
-
},
|
|
1537
|
-
resume: async (t, n) => {
|
|
1538
|
-
if (k.current) {
|
|
1539
|
-
m(T.current.requestInProgress);
|
|
1540
|
-
return;
|
|
1541
|
-
}
|
|
1542
|
-
k.current = !0, m(null), S(n.activity), f(!0);
|
|
1543
|
-
try {
|
|
1544
|
-
let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
|
|
1545
|
-
O.current = {
|
|
1546
|
-
params: t,
|
|
1547
|
-
context: i,
|
|
1548
|
-
tools: o,
|
|
1549
|
-
history: n.history,
|
|
1550
|
-
logId: crypto.randomUUID(),
|
|
1551
|
-
attachmentsRef: a
|
|
1552
|
-
}, B && q(t), v(B || r && !!R);
|
|
1553
|
-
} catch (e) {
|
|
1554
|
-
m(Z(e));
|
|
1555
|
-
} finally {
|
|
1556
|
-
k.current = !1, f(!1);
|
|
1557
|
-
}
|
|
1558
|
-
},
|
|
1559
|
-
sendMessage: async (t, n) => {
|
|
1560
|
-
if (k.current) return m(T.current.requestInProgress), null;
|
|
1561
|
-
if (m(null), !t.trim()) return m("Messaggio vuoto."), null;
|
|
1562
|
-
let r = O.current;
|
|
1563
|
-
if (!r) return m(T.current.noActiveSession), null;
|
|
1564
|
-
k.current = !0, f(!0), S((e) => [...e, {
|
|
1565
|
-
id: crypto.randomUUID(),
|
|
1566
|
-
kind: "user",
|
|
1567
|
-
label: "Tu",
|
|
1568
|
-
status: "done",
|
|
1569
|
-
detail: t,
|
|
1570
|
-
...n?.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
|
|
1571
|
-
}]);
|
|
1572
|
-
try {
|
|
1573
|
-
if (B) return await J(t, !1, n?.model || void 0);
|
|
1574
|
-
let i = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => d.fileToAttachment(e))) : void 0, a = X(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
|
|
1575
|
-
return await ne(a, i, n?.model || void 0);
|
|
1576
|
-
} catch (e) {
|
|
1577
|
-
return m(Z(e)), null;
|
|
1578
|
-
} finally {
|
|
1579
|
-
k.current = !1, f(!1);
|
|
1580
|
-
}
|
|
1581
|
-
},
|
|
1693
|
+
run: ae,
|
|
1694
|
+
resume: oe,
|
|
1695
|
+
sendMessage: se,
|
|
1582
1696
|
stop: M,
|
|
1583
|
-
runFallback:
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
m(null);
|
|
1587
|
-
let n = e.fallback(t.params, t.context);
|
|
1588
|
-
return S((t) => [...t, {
|
|
1589
|
-
id: crypto.randomUUID(),
|
|
1590
|
-
kind: "tool",
|
|
1591
|
-
status: "done",
|
|
1592
|
-
label: e.describeFallback?.(n) ?? T.current.continueWithoutAiFallback
|
|
1593
|
-
}]), n;
|
|
1594
|
-
},
|
|
1595
|
-
snapshot: () => O.current ? {
|
|
1596
|
-
history: O.current.history,
|
|
1597
|
-
activity: y
|
|
1598
|
-
} : null,
|
|
1599
|
-
answerQuestions: te
|
|
1697
|
+
runFallback: ue,
|
|
1698
|
+
snapshot: de,
|
|
1699
|
+
answerQuestions: re
|
|
1600
1700
|
};
|
|
1601
1701
|
}
|
|
1602
1702
|
//#endregion
|
|
1603
1703
|
//#region src/domain/orchestrator/prompt.ts
|
|
1604
|
-
function
|
|
1704
|
+
function yt() {
|
|
1605
1705
|
let e = Y();
|
|
1606
1706
|
return [e.responseRulesHeading, ...e.responseRules.map((e) => `- ${e}`)].join("\n");
|
|
1607
1707
|
}
|
|
1608
|
-
function
|
|
1708
|
+
function bt(e, t, n) {
|
|
1609
1709
|
let r = Y(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
|
|
1610
1710
|
return `${r.orchestratorIntro}
|
|
1611
1711
|
|
|
1612
1712
|
${r.toolsHeading}
|
|
1613
1713
|
${t}
|
|
1614
1714
|
${i}
|
|
1615
|
-
${
|
|
1715
|
+
${yt()}
|
|
1616
1716
|
|
|
1617
1717
|
${r.userRequestHeading}
|
|
1618
1718
|
${e}`;
|
|
1619
1719
|
}
|
|
1620
|
-
function
|
|
1720
|
+
function xt(e, t) {
|
|
1621
1721
|
return t ? {
|
|
1622
1722
|
kind: "handoff",
|
|
1623
1723
|
...t
|
|
@@ -1628,27 +1728,27 @@ function vt(e, t) {
|
|
|
1628
1728
|
}
|
|
1629
1729
|
//#endregion
|
|
1630
1730
|
//#region src/domain/orchestrator/agenticoOrchestratorAgent.ts
|
|
1631
|
-
function
|
|
1632
|
-
return
|
|
1731
|
+
function St(e) {
|
|
1732
|
+
return R().filter((t) => !t.onlyWhenAnchored || e === t.id);
|
|
1633
1733
|
}
|
|
1634
|
-
function
|
|
1734
|
+
function Ct(e) {
|
|
1635
1735
|
return {
|
|
1636
1736
|
buildContext(e) {
|
|
1637
1737
|
return {
|
|
1638
|
-
cliCatalog:
|
|
1738
|
+
cliCatalog: ae(St(e.scopedSubagentId)),
|
|
1639
1739
|
handoff: { current: null },
|
|
1640
1740
|
collected: {}
|
|
1641
1741
|
};
|
|
1642
1742
|
},
|
|
1643
1743
|
buildPrompt({ userGoal: e, pageContext: t }, { cliCatalog: n }) {
|
|
1644
|
-
return
|
|
1744
|
+
return bt(e, n, t);
|
|
1645
1745
|
},
|
|
1646
1746
|
buildFollowUpPrompt(e, t, { cliCatalog: n }) {
|
|
1647
|
-
return `${e}\n\n${
|
|
1747
|
+
return `${e}\n\n${yt()}\n\n${Y().toolsHeading}\n${n}`;
|
|
1648
1748
|
},
|
|
1649
1749
|
parseResponse(e, t, n) {
|
|
1650
1750
|
let r = n.handoff.current;
|
|
1651
|
-
return n.handoff.current = null,
|
|
1751
|
+
return n.handoff.current = null, xt(e, r);
|
|
1652
1752
|
},
|
|
1653
1753
|
fallback() {
|
|
1654
1754
|
return {
|
|
@@ -1664,7 +1764,7 @@ function bt(e) {
|
|
|
1664
1764
|
attachmentsRef: r,
|
|
1665
1765
|
collected: n.collected,
|
|
1666
1766
|
proxyFetch: g
|
|
1667
|
-
}), a = t.scopedSubagentId ?
|
|
1767
|
+
}), a = t.scopedSubagentId ? z(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = St(t.scopedSubagentId).flatMap((t) => t.commands.map((r) => ({
|
|
1668
1768
|
name: `${t.id}_${r.name}`,
|
|
1669
1769
|
description: `${t.label}: ${r.summary}`,
|
|
1670
1770
|
inputSchema: r.inputSchema,
|
|
@@ -1688,12 +1788,12 @@ function bt(e) {
|
|
|
1688
1788
|
}
|
|
1689
1789
|
//#endregion
|
|
1690
1790
|
//#region src/presentation/deriveHistoryTitle.ts
|
|
1691
|
-
function
|
|
1791
|
+
function wt(e, t) {
|
|
1692
1792
|
return e.deriveHistoryTitle?.(t) ?? e.label;
|
|
1693
1793
|
}
|
|
1694
1794
|
//#endregion
|
|
1695
1795
|
//#region src/presentation/ResultDestinationPicker.tsx
|
|
1696
|
-
function
|
|
1796
|
+
function Tt({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
|
|
1697
1797
|
let s = Q(), c = $(), l = c.scope, u = y(), [d, f] = D(null), [p, h] = D(new Set(i ?? [])), [g, _] = D(null), v = ge(), b = /* @__PURE__ */ new Map();
|
|
1698
1798
|
e.destinationIds.forEach((e) => {
|
|
1699
1799
|
let t = v[e];
|
|
@@ -1711,7 +1811,7 @@ function St({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
|
|
|
1711
1811
|
storageProvider: l?.storageProvider ?? null,
|
|
1712
1812
|
proxyFetch: u
|
|
1713
1813
|
}, n);
|
|
1714
|
-
h((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n,
|
|
1814
|
+
h((e) => new Set(e).add(i)), a?.(i), d?.id && c.commitEntityChat(e.id, d.id, r, l?.id, n, wt(e, n));
|
|
1715
1815
|
} catch (e) {
|
|
1716
1816
|
_(e instanceof Error ? e.message : String(e));
|
|
1717
1817
|
} finally {
|
|
@@ -1744,16 +1844,16 @@ function St({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, o
|
|
|
1744
1844
|
}
|
|
1745
1845
|
//#endregion
|
|
1746
1846
|
//#region src/presentation/reports/subagentReportRegistry.tsx
|
|
1747
|
-
var
|
|
1748
|
-
function
|
|
1749
|
-
Object.assign(
|
|
1847
|
+
var Et = {};
|
|
1848
|
+
function Dt(e) {
|
|
1849
|
+
Object.assign(Et, e);
|
|
1750
1850
|
}
|
|
1751
|
-
function
|
|
1752
|
-
return
|
|
1851
|
+
function Ot(e) {
|
|
1852
|
+
return Et[e];
|
|
1753
1853
|
}
|
|
1754
1854
|
//#endregion
|
|
1755
1855
|
//#region src/presentation/reports/GenericResultPreview.tsx
|
|
1756
|
-
function
|
|
1856
|
+
function kt({ result: e }) {
|
|
1757
1857
|
let [t, n] = D(!1);
|
|
1758
1858
|
return /* @__PURE__ */ A("div", {
|
|
1759
1859
|
className: `relative cursor-pointer rounded-md border border-border/60 ${t ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
|
|
@@ -1770,7 +1870,7 @@ function Et({ result: e }) {
|
|
|
1770
1870
|
}
|
|
1771
1871
|
//#endregion
|
|
1772
1872
|
//#region src/presentation/liveAnchorDestination.ts
|
|
1773
|
-
function
|
|
1873
|
+
function At(e, t, n) {
|
|
1774
1874
|
return e.length === 0 ? null : {
|
|
1775
1875
|
id: "live-component",
|
|
1776
1876
|
label: "Applica al componente aperto",
|
|
@@ -1781,30 +1881,30 @@ function Dt(e, t, n) {
|
|
|
1781
1881
|
}
|
|
1782
1882
|
//#endregion
|
|
1783
1883
|
//#region src/presentation/subagentControls.ts
|
|
1784
|
-
var
|
|
1785
|
-
function
|
|
1786
|
-
Object.assign(
|
|
1884
|
+
var jt = {};
|
|
1885
|
+
function Mt(e) {
|
|
1886
|
+
Object.assign(jt, e);
|
|
1787
1887
|
}
|
|
1788
|
-
function
|
|
1789
|
-
return
|
|
1888
|
+
function Nt(e) {
|
|
1889
|
+
return jt[e];
|
|
1790
1890
|
}
|
|
1791
1891
|
//#endregion
|
|
1792
1892
|
//#region src/presentation/SubagentRunner.tsx
|
|
1793
|
-
var
|
|
1794
|
-
function
|
|
1795
|
-
let c =
|
|
1893
|
+
var Pt = () => ({});
|
|
1894
|
+
function Ft({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o, openingMessage: s }) {
|
|
1895
|
+
let c = vt(e.definition, { defaultEnabled: !0 }), l = $(), u = l.scope, d = y(), f = E(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [p, m] = D(null), h = (t) => {
|
|
1796
1896
|
e.definition.conversational || m(t);
|
|
1797
|
-
}, [g, _] = D([]), [v, b] = D(null), x =
|
|
1897
|
+
}, [g, _] = D([]), [v, b] = D(null), x = Ot(e.id), S = x?.kind === "selection" ? x : null, [w, j] = D(null), M = E(!1), N = E(0), P = E(null);
|
|
1798
1898
|
p && p !== P.current && (P.current = p, N.current = (r?.length ?? 0) + c.activity.length);
|
|
1799
|
-
let F = E(!1),
|
|
1899
|
+
let F = E(!1), ee = c.remote || !c.hasProviders || c.selectedModel !== "";
|
|
1800
1900
|
C(() => {
|
|
1801
|
-
!M.current &&
|
|
1901
|
+
!M.current && ee && (M.current = !0, a ? c.resume(e.toParams(t), a) : (o && c.setSelectedModel(o), c.run(e.toParams(t), {
|
|
1802
1902
|
model: o,
|
|
1803
1903
|
openingMessage: s
|
|
1804
1904
|
}).then((e) => {
|
|
1805
1905
|
e && h(e);
|
|
1806
1906
|
})));
|
|
1807
|
-
}, [
|
|
1907
|
+
}, [ee]), C(() => {
|
|
1808
1908
|
if (!p || !u) return;
|
|
1809
1909
|
let n = e.autoApplyDestinationIds ?? [], r = l.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = ge();
|
|
1810
1910
|
n.forEach((n) => {
|
|
@@ -1818,7 +1918,7 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1818
1918
|
...t,
|
|
1819
1919
|
pinnedEntityId: r
|
|
1820
1920
|
}).then((n) => {
|
|
1821
|
-
n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t,
|
|
1921
|
+
n?.id && l.commitEntityChat(e.id, n.id, f, u.id, t, wt(e, t));
|
|
1822
1922
|
}).catch((e) => b(e instanceof Error ? e.message : String(e))));
|
|
1823
1923
|
});
|
|
1824
1924
|
}, [
|
|
@@ -1828,20 +1928,20 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1828
1928
|
]), C(() => {
|
|
1829
1929
|
p && S && j(S.defaultSelection(p));
|
|
1830
1930
|
}, [p, S]);
|
|
1831
|
-
let
|
|
1931
|
+
let I = (e, t) => {
|
|
1832
1932
|
j((n) => n && {
|
|
1833
1933
|
...n,
|
|
1834
1934
|
[e]: t
|
|
1835
1935
|
});
|
|
1836
|
-
},
|
|
1936
|
+
}, L = (e) => h(e), R = T(() => p && S && w ? S.applySelection(p, w) : p, [
|
|
1837
1937
|
p,
|
|
1838
1938
|
S,
|
|
1839
1939
|
w
|
|
1840
|
-
]),
|
|
1841
|
-
|
|
1940
|
+
]), z = T(() => l.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [l.componentAnchors, e.id]), B = T(() => At(z, t, f), [
|
|
1941
|
+
z,
|
|
1842
1942
|
t,
|
|
1843
1943
|
f
|
|
1844
|
-
]),
|
|
1944
|
+
]), V = T(() => B ? [B, ...n ?? []] : n, [B, n]), H = e.chatEntityId?.(t), U = E(!1);
|
|
1845
1945
|
C(() => {
|
|
1846
1946
|
let n = U.current && !c.running;
|
|
1847
1947
|
if (U.current = c.running, !n || !H || !u) return;
|
|
@@ -1851,14 +1951,14 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1851
1951
|
subagentId: e.id,
|
|
1852
1952
|
entityId: H,
|
|
1853
1953
|
params: t,
|
|
1854
|
-
title:
|
|
1954
|
+
title: wt(e, t),
|
|
1855
1955
|
history: i.history,
|
|
1856
1956
|
activity: [...r ?? [], ...i.activity]
|
|
1857
1957
|
});
|
|
1858
1958
|
}, [c.running]);
|
|
1859
1959
|
let W = () => {
|
|
1860
1960
|
F.current = !0, c.running && c.stop(), l.closeTask(f);
|
|
1861
|
-
}, G = E(
|
|
1961
|
+
}, G = E(Nt(e.id) ?? Pt).current, K = G({
|
|
1862
1962
|
params: t,
|
|
1863
1963
|
taskId: f,
|
|
1864
1964
|
running: c.running,
|
|
@@ -1869,7 +1969,7 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1869
1969
|
return C(() => {
|
|
1870
1970
|
F.current || l.openTask({
|
|
1871
1971
|
id: f,
|
|
1872
|
-
title:
|
|
1972
|
+
title: wt(e, t),
|
|
1873
1973
|
icon: e.icon,
|
|
1874
1974
|
agent: c,
|
|
1875
1975
|
onApplied: (e) => h(e),
|
|
@@ -1884,23 +1984,23 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1884
1984
|
S && w ? /* @__PURE__ */ k(S.Report, {
|
|
1885
1985
|
result: p,
|
|
1886
1986
|
selection: w,
|
|
1887
|
-
onChange:
|
|
1987
|
+
onChange: I
|
|
1888
1988
|
}) : x?.kind === "editable" ? /* @__PURE__ */ k(x.Report, {
|
|
1889
1989
|
result: p,
|
|
1890
|
-
onResultChange:
|
|
1891
|
-
}) : /* @__PURE__ */ k(
|
|
1990
|
+
onResultChange: L
|
|
1991
|
+
}) : /* @__PURE__ */ k(kt, { result: R }),
|
|
1892
1992
|
v && /* @__PURE__ */ A("p", {
|
|
1893
1993
|
className: "text-xs text-destructive",
|
|
1894
1994
|
children: ["Salvataggio automatico non riuscito: ", v]
|
|
1895
1995
|
}),
|
|
1896
|
-
/* @__PURE__ */ k(
|
|
1996
|
+
/* @__PURE__ */ k(Tt, {
|
|
1897
1997
|
manifest: e,
|
|
1898
|
-
result:
|
|
1998
|
+
result: R,
|
|
1899
1999
|
meta: t,
|
|
1900
2000
|
taskId: f,
|
|
1901
2001
|
initiallyApplied: g,
|
|
1902
2002
|
onApplied: q,
|
|
1903
|
-
extraDestinations:
|
|
2003
|
+
extraDestinations: V
|
|
1904
2004
|
})
|
|
1905
2005
|
] }) : void 0
|
|
1906
2006
|
});
|
|
@@ -1919,7 +2019,7 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1919
2019
|
e,
|
|
1920
2020
|
t,
|
|
1921
2021
|
p,
|
|
1922
|
-
|
|
2022
|
+
R,
|
|
1923
2023
|
w,
|
|
1924
2024
|
g,
|
|
1925
2025
|
n,
|
|
@@ -1934,8 +2034,8 @@ function Mt({ manifest: e, params: t, extraDestinations: n, precedingActivity: r
|
|
|
1934
2034
|
}
|
|
1935
2035
|
//#endregion
|
|
1936
2036
|
//#region src/presentation/OrchestratorRunner.tsx
|
|
1937
|
-
function
|
|
1938
|
-
let t = Q(), n =
|
|
2037
|
+
function It({ userGoal: e }) {
|
|
2038
|
+
let t = Q(), n = vt(T(() => Ct({
|
|
1939
2039
|
unavailable: t.orchestratorUnavailable,
|
|
1940
2040
|
continueWithoutAi: t.orchestratorContinueWithoutAi,
|
|
1941
2041
|
preparing: t.orchestratorPreparing,
|
|
@@ -1982,8 +2082,8 @@ function Nt({ userGoal: e }) {
|
|
|
1982
2082
|
}, [r.closeTask]);
|
|
1983
2083
|
let h = T(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
|
|
1984
2084
|
if (!i) return null;
|
|
1985
|
-
let g =
|
|
1986
|
-
return g ? /* @__PURE__ */ k(
|
|
2085
|
+
let g = z(i.subagentId);
|
|
2086
|
+
return g ? /* @__PURE__ */ k(Ft, {
|
|
1987
2087
|
manifest: g,
|
|
1988
2088
|
params: i.params,
|
|
1989
2089
|
extraDestinations: c.current,
|
|
@@ -1994,8 +2094,8 @@ function Nt({ userGoal: e }) {
|
|
|
1994
2094
|
}
|
|
1995
2095
|
//#endregion
|
|
1996
2096
|
//#region src/presentation/ManualEntryRunner.tsx
|
|
1997
|
-
function
|
|
1998
|
-
let r =
|
|
2097
|
+
function Lt({ manifest: e, extraDestinations: n }) {
|
|
2098
|
+
let r = vt(e.definition, { defaultEnabled: !1 }), i = Q(), a = $(), o = E(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = D(null), [l, u] = D([]), d = Ot(e.id), f = d?.kind === "selection" ? d : null, [p, m] = D(null), [h, g] = D(null), _ = E(!1), v = (t) => {
|
|
1999
2099
|
if (!e.manualEntry) return;
|
|
2000
2100
|
let n;
|
|
2001
2101
|
try {
|
|
@@ -2022,7 +2122,7 @@ function Pt({ manifest: e, extraDestinations: n }) {
|
|
|
2022
2122
|
p
|
|
2023
2123
|
]), S = (e) => {
|
|
2024
2124
|
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 ?
|
|
2125
|
+
}, w = T(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), O = T(() => h ? At(w, h, o) : null, [
|
|
2026
2126
|
w,
|
|
2027
2127
|
h,
|
|
2028
2128
|
o
|
|
@@ -2051,8 +2151,8 @@ function Pt({ manifest: e, extraDestinations: n }) {
|
|
|
2051
2151
|
}) : d?.kind === "editable" ? /* @__PURE__ */ k(d.Report, {
|
|
2052
2152
|
result: s,
|
|
2053
2153
|
onResultChange: b
|
|
2054
|
-
}) : /* @__PURE__ */ k(
|
|
2055
|
-
/* @__PURE__ */ k(
|
|
2154
|
+
}) : /* @__PURE__ */ k(kt, { result: x }),
|
|
2155
|
+
/* @__PURE__ */ k(Tt, {
|
|
2056
2156
|
manifest: e,
|
|
2057
2157
|
result: x,
|
|
2058
2158
|
meta: h ?? {},
|
|
@@ -2089,15 +2189,19 @@ function Pt({ manifest: e, extraDestinations: n }) {
|
|
|
2089
2189
|
}
|
|
2090
2190
|
//#endregion
|
|
2091
2191
|
//#region src/presentation/Agentico.tsx
|
|
2092
|
-
function
|
|
2093
|
-
return Object.values(e).flat().map((e) =>
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2192
|
+
function Rt(e, t) {
|
|
2193
|
+
return Object.values(e).flat().map((e) => {
|
|
2194
|
+
let n = t?.(e.provider, e.providerLabel ?? e.provider);
|
|
2195
|
+
return {
|
|
2196
|
+
label: e.model,
|
|
2197
|
+
value: e.id,
|
|
2198
|
+
pricing: e.pricing ?? null,
|
|
2199
|
+
group: n?.group ?? e.providerLabel ?? e.provider,
|
|
2200
|
+
...n?.badge ? { groupBadge: n.badge } : {}
|
|
2201
|
+
};
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
function zt({ task: e }) {
|
|
2101
2205
|
let t = Q(), [n, r] = D(""), { agent: i, onApplied: a, manualEntry: s } = e, c = i.running, l = (e) => {
|
|
2102
2206
|
if (r(""), s) {
|
|
2103
2207
|
s.onSubmit(e.text);
|
|
@@ -2109,17 +2213,17 @@ function It({ task: e }) {
|
|
|
2109
2213
|
}).then((e) => {
|
|
2110
2214
|
e && a(e);
|
|
2111
2215
|
});
|
|
2112
|
-
}, u = !!s || i.remote && i.remoteModels.length === 0, d = !u && !i.remote && i.hasProviders && !i.selectedModel,
|
|
2216
|
+
}, u = !!s || i.remote && i.remoteModels.length === 0, d = i.alongside && i.remoteModels.some((e) => e.value === i.selectedModel), f = !u && !i.remote && !d && i.hasProviders && !i.selectedModel, p = u ? [] : i.remote ? i.remoteModels : i.alongside ? [...i.remoteModels, ...Rt(i.modelsByProvider, i.catalogGroup)] : Rt(i.modelsByProvider);
|
|
2113
2217
|
return /* @__PURE__ */ k(o, {
|
|
2114
2218
|
value: n,
|
|
2115
2219
|
onChange: r,
|
|
2116
2220
|
placeholder: s?.prompt ?? t.messagePlaceholder,
|
|
2117
2221
|
running: c,
|
|
2118
2222
|
onStop: i.stop,
|
|
2119
|
-
disabled: !n.trim() ||
|
|
2223
|
+
disabled: !n.trim() || f,
|
|
2120
2224
|
onSubmit: l,
|
|
2121
|
-
attachments: !s && !i.remote,
|
|
2122
|
-
models:
|
|
2225
|
+
attachments: !s && !i.remote && !d,
|
|
2226
|
+
models: p,
|
|
2123
2227
|
selectedModel: u ? "" : i.selectedModel,
|
|
2124
2228
|
actions: e.composerActions,
|
|
2125
2229
|
commands: e.composerCommands,
|
|
@@ -2129,7 +2233,7 @@ function It({ task: e }) {
|
|
|
2129
2233
|
maxHeight: 220
|
|
2130
2234
|
});
|
|
2131
2235
|
}
|
|
2132
|
-
function
|
|
2236
|
+
function Bt() {
|
|
2133
2237
|
let { startOrchestrator: e } = $(), t = Q(), [n, r] = D(""), { hasProviders: i, modelsByProvider: a, selectedModel: s, setSelectedModel: c } = dt(), l = (t) => {
|
|
2134
2238
|
t.text.trim() && (e(t.text.trim(), {
|
|
2135
2239
|
attachments: t.files.length > 0 ? t.files : void 0,
|
|
@@ -2143,7 +2247,7 @@ function Lt() {
|
|
|
2143
2247
|
disabled: !n.trim() || u,
|
|
2144
2248
|
onSubmit: l,
|
|
2145
2249
|
attachments: !0,
|
|
2146
|
-
models:
|
|
2250
|
+
models: Rt(a),
|
|
2147
2251
|
selectedModel: s,
|
|
2148
2252
|
onModelChange: c,
|
|
2149
2253
|
modelPlaceholder: t.selectModelPlaceholder,
|
|
@@ -2151,7 +2255,7 @@ function Lt() {
|
|
|
2151
2255
|
maxHeight: 220
|
|
2152
2256
|
});
|
|
2153
2257
|
}
|
|
2154
|
-
function
|
|
2258
|
+
function Vt(e, t, n = Date.now()) {
|
|
2155
2259
|
let r = Math.round((e - n) / 1e3), i = new Intl.RelativeTimeFormat(t, {
|
|
2156
2260
|
numeric: "auto",
|
|
2157
2261
|
style: "short"
|
|
@@ -2163,7 +2267,7 @@ function Rt(e, t, n = Date.now()) {
|
|
|
2163
2267
|
]) if (Math.abs(r) >= t) return i.format(Math.round(r / t), e);
|
|
2164
2268
|
return i.format(0, "minute");
|
|
2165
2269
|
}
|
|
2166
|
-
function
|
|
2270
|
+
function Ht({ card: e }) {
|
|
2167
2271
|
let t = Q();
|
|
2168
2272
|
return e.humanSummaryOnly ? /* @__PURE__ */ A("div", {
|
|
2169
2273
|
className: "space-y-2 rounded-lg border border-border/60 p-3",
|
|
@@ -2219,7 +2323,7 @@ function zt({ card: e }) {
|
|
|
2219
2323
|
]
|
|
2220
2324
|
});
|
|
2221
2325
|
}
|
|
2222
|
-
function
|
|
2326
|
+
function Ut({ messages: e }) {
|
|
2223
2327
|
return /* @__PURE__ */ k("div", {
|
|
2224
2328
|
className: "space-y-2 rounded-lg border border-border/60 p-3",
|
|
2225
2329
|
children: e.map((e, t) => /* @__PURE__ */ k("p", {
|
|
@@ -2228,13 +2332,13 @@ function Bt({ messages: e }) {
|
|
|
2228
2332
|
}, t))
|
|
2229
2333
|
});
|
|
2230
2334
|
}
|
|
2231
|
-
function
|
|
2335
|
+
function Wt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect: a, onNewChat: o, onArchivedCurrent: s }) {
|
|
2232
2336
|
let d = Q(), { locale: f } = v(), [p, m] = D(""), [h, g] = D(0), _ = T(() => r ? Ee(e) : [], [
|
|
2233
2337
|
e,
|
|
2234
2338
|
r,
|
|
2235
2339
|
h
|
|
2236
2340
|
]), y = async (t) => {
|
|
2237
|
-
let r =
|
|
2341
|
+
let r = z(t.subagentId), i = await r?.confirmArchive?.(t.entityId, t.params);
|
|
2238
2342
|
if (!i || window.confirm(i)) {
|
|
2239
2343
|
try {
|
|
2240
2344
|
await r?.onArchive?.(t.entityId, t.params);
|
|
@@ -2246,7 +2350,7 @@ function Vt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
|
|
|
2246
2350
|
}, b = T(() => {
|
|
2247
2351
|
let e = p.trim().toLowerCase();
|
|
2248
2352
|
return e ? _.filter((t) => {
|
|
2249
|
-
let n =
|
|
2353
|
+
let n = z(t.subagentId)?.label ?? t.subagentId;
|
|
2250
2354
|
return t.title.toLowerCase().includes(e) || n.toLowerCase().includes(e);
|
|
2251
2355
|
}) : _;
|
|
2252
2356
|
}, [_, p]);
|
|
@@ -2290,7 +2394,7 @@ function Vt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
|
|
|
2290
2394
|
className: "px-2 py-3 text-center text-xs text-muted-foreground",
|
|
2291
2395
|
children: _.length === 0 ? d.noSavedChats : d.noResults
|
|
2292
2396
|
}) : b.map((e) => {
|
|
2293
|
-
let t =
|
|
2397
|
+
let t = z(e.subagentId), r = n === De(e.subagentId, e.entityId);
|
|
2294
2398
|
return /* @__PURE__ */ k(l, {
|
|
2295
2399
|
icon: r ? "check" : t?.icon ?? "bot",
|
|
2296
2400
|
className: r ? "bg-accent font-medium" : void 0,
|
|
@@ -2315,27 +2419,27 @@ function Vt({ scopeId: e, currentTaskId: n, open: r, onOpenChange: i, onSelect:
|
|
|
2315
2419
|
}), /* @__PURE__ */ k("span", {
|
|
2316
2420
|
className: "shrink-0 text-xs text-muted-foreground",
|
|
2317
2421
|
title: new Date(e.savedAt).toLocaleString(f),
|
|
2318
|
-
children:
|
|
2422
|
+
children: Vt(e.savedAt, f)
|
|
2319
2423
|
})]
|
|
2320
2424
|
})
|
|
2321
2425
|
}, `${e.subagentId}:${e.entityId}`);
|
|
2322
2426
|
})
|
|
2323
2427
|
});
|
|
2324
2428
|
}
|
|
2325
|
-
function
|
|
2429
|
+
function Gt({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}) {
|
|
2326
2430
|
let { task: a, isOpen: o, pendingGoal: s, orchestratorRunId: c, pageContext: l, pageContextCard: u, anchoredUserMessages: d, pendingResume: f, resumeRunId: p, dismissForeignTask: m, resumeEntityChat: h, pendingManualEntry: g, manualEntryRunId: _, startManualEntry: v, pendingExtraDestinations: y, pendingResumeWithAI: b, resumeWithAIRunId: x, pendingStart: S, startRunId: w, scope: T } = $(), j = Q(), M = E(null), [N, P] = D(!1), F = at({
|
|
2327
2431
|
defaultWidth: e,
|
|
2328
2432
|
minWidth: n,
|
|
2329
2433
|
maxWidth: r,
|
|
2330
2434
|
onWidthChange: i
|
|
2331
|
-
}),
|
|
2435
|
+
}), ee = () => {
|
|
2332
2436
|
(!a || a.agent.running || a.savedToDisk || window.confirm(j.unsavedConversationConfirm)) && (m(), P(!1));
|
|
2333
|
-
},
|
|
2437
|
+
}, I = a ? [...a.precedingActivity ?? [], ...a.agent.activity] : [], L = I.length, R = Math.max(0, Math.min(a?.panelExtraAnchorIndex ?? L, L)), B = I.slice(0, R), V = I.slice(R), H = !!(a && !a.agent.running && a.agent.error), U = new Set(a?.agent.activity.map((e) => e.id) ?? []), W = a ? {
|
|
2334
2438
|
canAnswer: (e) => U.has(e),
|
|
2335
2439
|
onAnswer: (e, t, n) => a.agent.answerQuestions(e, t, n).then((e) => {
|
|
2336
2440
|
e && a.onApplied(e);
|
|
2337
2441
|
})
|
|
2338
|
-
} : void 0, G = W ? Ge(
|
|
2442
|
+
} : void 0, G = W ? Ge(I, W.canAnswer) : null, K = a?.id === "agentico-orchestrator" && a.scopedSubagentId ? z(a.scopedSubagentId) : void 0, q = K?.manualEntry ? K : null, J = E(!0);
|
|
2339
2443
|
C(() => {
|
|
2340
2444
|
let e = M.current;
|
|
2341
2445
|
if (!e) return;
|
|
@@ -2347,12 +2451,12 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2347
2451
|
let e = M.current;
|
|
2348
2452
|
e && (J.current = !0, e.scrollTop = e.scrollHeight);
|
|
2349
2453
|
}, [a?.id]);
|
|
2350
|
-
let te =
|
|
2454
|
+
let te = I.at(-1)?.detail?.length ?? 0;
|
|
2351
2455
|
C(() => {
|
|
2352
2456
|
let e = M.current;
|
|
2353
2457
|
e && J.current && (e.scrollTop = e.scrollHeight);
|
|
2354
2458
|
}, [
|
|
2355
|
-
|
|
2459
|
+
L,
|
|
2356
2460
|
H,
|
|
2357
2461
|
te
|
|
2358
2462
|
]);
|
|
@@ -2365,33 +2469,33 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2365
2469
|
});
|
|
2366
2470
|
return n.observe(t), () => n.disconnect();
|
|
2367
2471
|
}, [a?.id, o]);
|
|
2368
|
-
let
|
|
2369
|
-
manifest:
|
|
2472
|
+
let X = s ? /* @__PURE__ */ k(It, { userGoal: s }, c) : null, ne = f ? z(f.subagentId) : void 0, Z = f && ne ? /* @__PURE__ */ k(Ft, {
|
|
2473
|
+
manifest: ne,
|
|
2370
2474
|
params: f.snapshot.params,
|
|
2371
2475
|
taskId: De(f.subagentId, f.entityId),
|
|
2372
2476
|
resumeSeed: {
|
|
2373
2477
|
history: f.snapshot.history,
|
|
2374
2478
|
activity: f.snapshot.activity
|
|
2375
2479
|
}
|
|
2376
|
-
}, p) : null,
|
|
2377
|
-
manifest:
|
|
2480
|
+
}, p) : null, re = g ? z(g.subagentId) : void 0, ie = g && re ? /* @__PURE__ */ k(Lt, {
|
|
2481
|
+
manifest: re,
|
|
2378
2482
|
extraDestinations: g.extraDestinations
|
|
2379
|
-
}, _) : null,
|
|
2380
|
-
manifest:
|
|
2483
|
+
}, _) : null, ae = b ? z(b.subagentId) : void 0, oe = b && ae ? /* @__PURE__ */ k(Ft, {
|
|
2484
|
+
manifest: ae,
|
|
2381
2485
|
params: b.params,
|
|
2382
2486
|
extraDestinations: b.extraDestinations
|
|
2383
|
-
}, x) : null,
|
|
2384
|
-
manifest:
|
|
2487
|
+
}, x) : null, se = S ? z(S.subagentId) : void 0, ce = S && se ? /* @__PURE__ */ k(Ft, {
|
|
2488
|
+
manifest: se,
|
|
2385
2489
|
params: S.params,
|
|
2386
2490
|
taskId: S.taskId,
|
|
2387
2491
|
openingMessage: S.openingMessage
|
|
2388
2492
|
}, w) : null;
|
|
2389
2493
|
return o ? /* @__PURE__ */ A(O, { children: [
|
|
2390
|
-
|
|
2494
|
+
X,
|
|
2495
|
+
Z,
|
|
2391
2496
|
ie,
|
|
2392
2497
|
oe,
|
|
2393
2498
|
ce,
|
|
2394
|
-
X,
|
|
2395
2499
|
/* @__PURE__ */ A("div", {
|
|
2396
2500
|
style: { width: F.width },
|
|
2397
2501
|
className: "relative flex h-full shrink-0 flex-col border-l border-border bg-background",
|
|
@@ -2411,12 +2515,12 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2411
2515
|
className: "min-w-0 flex-1 truncate text-lg font-semibold leading-tight",
|
|
2412
2516
|
children: a ? a.title : "Agentico"
|
|
2413
2517
|
}),
|
|
2414
|
-
T && /* @__PURE__ */ k(
|
|
2518
|
+
T && /* @__PURE__ */ k(Wt, {
|
|
2415
2519
|
scopeId: T.id,
|
|
2416
2520
|
currentTaskId: a?.id ?? null,
|
|
2417
2521
|
open: N,
|
|
2418
2522
|
onOpenChange: P,
|
|
2419
|
-
onNewChat:
|
|
2523
|
+
onNewChat: ee,
|
|
2420
2524
|
onSelect: (e, t, n) => h(e, t, n),
|
|
2421
2525
|
onArchivedCurrent: m
|
|
2422
2526
|
}),
|
|
@@ -2430,12 +2534,12 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2430
2534
|
ref: Y,
|
|
2431
2535
|
className: "pt-2",
|
|
2432
2536
|
children: a ? /* @__PURE__ */ A(O, { children: [
|
|
2433
|
-
a.manualEntry &&
|
|
2537
|
+
a.manualEntry && I.length === 0 && /* @__PURE__ */ k("p", {
|
|
2434
2538
|
className: "text-xs text-muted-foreground",
|
|
2435
2539
|
children: a.manualEntry.prompt
|
|
2436
2540
|
}),
|
|
2437
2541
|
/* @__PURE__ */ k(Ye, {
|
|
2438
|
-
activity:
|
|
2542
|
+
activity: B,
|
|
2439
2543
|
questions: W,
|
|
2440
2544
|
docked: G,
|
|
2441
2545
|
pinUserMessages: !G
|
|
@@ -2444,8 +2548,8 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2444
2548
|
className: "mt-3",
|
|
2445
2549
|
children: a.panelExtra
|
|
2446
2550
|
}),
|
|
2447
|
-
|
|
2448
|
-
activity:
|
|
2551
|
+
V.length > 0 && /* @__PURE__ */ k(Ye, {
|
|
2552
|
+
activity: V,
|
|
2449
2553
|
questions: W,
|
|
2450
2554
|
docked: G,
|
|
2451
2555
|
pinUserMessages: !G
|
|
@@ -2482,7 +2586,7 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2482
2586
|
})
|
|
2483
2587
|
]
|
|
2484
2588
|
})
|
|
2485
|
-
] }) : d.length > 0 ? /* @__PURE__ */ k(
|
|
2589
|
+
] }) : d.length > 0 ? /* @__PURE__ */ k(Ut, { messages: d }) : u ? /* @__PURE__ */ k(Ht, { card: u }) : /* @__PURE__ */ k("p", {
|
|
2486
2590
|
className: "text-xs text-muted-foreground",
|
|
2487
2591
|
children: l ?? j.orchestratorStarterHint
|
|
2488
2592
|
})
|
|
@@ -2520,27 +2624,27 @@ function Ht({ defaultWidth: e, minWidth: n, maxWidth: r, onWidthChange: i } = {}
|
|
|
2520
2624
|
children: [a?.panelActions && /* @__PURE__ */ k("div", {
|
|
2521
2625
|
className: "mb-2",
|
|
2522
2626
|
children: a.panelActions
|
|
2523
|
-
}), a ? /* @__PURE__ */ k(
|
|
2627
|
+
}), a ? /* @__PURE__ */ k(zt, { task: a }, a.id) : /* @__PURE__ */ k(Bt, {})]
|
|
2524
2628
|
})
|
|
2525
2629
|
]
|
|
2526
2630
|
})
|
|
2527
2631
|
] }) : /* @__PURE__ */ A(O, { children: [
|
|
2528
|
-
|
|
2632
|
+
X,
|
|
2633
|
+
Z,
|
|
2529
2634
|
ie,
|
|
2530
2635
|
oe,
|
|
2531
|
-
ce
|
|
2532
|
-
X
|
|
2636
|
+
ce
|
|
2533
2637
|
] });
|
|
2534
2638
|
}
|
|
2535
2639
|
//#endregion
|
|
2536
2640
|
//#region src/presentation/useAgenticoPageContext.ts
|
|
2537
|
-
function
|
|
2641
|
+
function Kt(e, t) {
|
|
2538
2642
|
let { setPageContext: n } = $(), r = E(crypto.randomUUID()).current;
|
|
2539
2643
|
C(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
|
|
2540
2644
|
}
|
|
2541
2645
|
//#endregion
|
|
2542
2646
|
//#region src/presentation/useSubagentComponentContext.ts
|
|
2543
|
-
function
|
|
2647
|
+
function qt(e, t, n, r, i = !0, a) {
|
|
2544
2648
|
let { registerComponentAnchor: o } = $(), s = E(crypto.randomUUID()).current, c = E(n);
|
|
2545
2649
|
c.current = n, C(() => {
|
|
2546
2650
|
if (i) return o(s, {
|
|
@@ -2559,6 +2663,6 @@ function Wt(e, t, n, r, i = !0, a) {
|
|
|
2559
2663
|
]);
|
|
2560
2664
|
}
|
|
2561
2665
|
//#endregion
|
|
2562
|
-
export { Qe as AGENTICO_MAX_WIDTH, Ze as AGENTICO_MIN_WIDTH, Xe as AGENTICO_WIDTH, $e as AGENTICO_WIDTH_STORAGE_KEY,
|
|
2666
|
+
export { Qe as AGENTICO_MAX_WIDTH, Ze as AGENTICO_MIN_WIDTH, Xe as AGENTICO_WIDTH, $e as AGENTICO_WIDTH_STORAGE_KEY, Gt as Agentico, Pe as AgenticoProvider, st as AgenticoToggle, M as DEFAULT_REASONING_PART_ID, j as DEFAULT_TEXT_PART_ID, fe as JSON_EXPORT_DESTINATION_ID, se as MICRO_PROMPT_REGISTRY, Me as ORCHESTRATOR_TASK_ID, oe as SUMMARY_MICRO_PROMPT, Oe as agenticoDe, ke as agenticoEn, Ae as agenticoIt, K as agenticoPromptsEn, q as agenticoPromptsIt, je as agenticoTranslations, ce as applyMicroPrompts, te as configureAgenticoPrompts, ve as configureEntityChatStore, H as createCrossAgentTools, ee as defineSubagent, De as entityChatTaskId, le as extractErrorMessage, ue as extractJsonBlock, z as findSubagentManifest, F as formatQuestionAnswers, Y as getAgenticoPrompts, ge as getDestinationRegistry, Ce as getEntityChat, Nt as getSubagentControls, R as getSubagentRegistry, Ot as getSubagentReport, pe as jsonExportDestination, Ee as listEntityChats, P as messagePartsText, V as registerCrossAgentTools, he as registerDestinations, Mt as registerSubagentControls, Dt as registerSubagentReports, L as registerSubagents, Te as removeEntityChat, ae as renderRegistryCli, ie as renderSubagentCli, X as resetAgenticoPrompts, we as saveEntityChat, U as toJsonSchema, W as toMcpTool, N as upsertMessagePart, vt as useAgent, $ as useAgentico, Q as useAgenticoI18n, Kt as useAgenticoPageContext, qt as useSubagentComponentContext };
|
|
2563
2667
|
|
|
2564
2668
|
//# sourceMappingURL=index.mjs.map
|