@llmnative/agentico 0.1.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/LICENSE +201 -0
- package/README.md +78 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1995 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/domain/agentDefinition.d.ts +83 -0
- package/dist/types/domain/cli/renderManifestCli.d.ts +7 -0
- package/dist/types/domain/crossAgentTools.d.ts +13 -0
- package/dist/types/domain/defineSubagent.d.ts +5 -0
- package/dist/types/domain/destinationRegistry.d.ts +5 -0
- package/dist/types/domain/entityChatStore.d.ts +48 -0
- package/dist/types/domain/extractErrorMessage.d.ts +1 -0
- package/dist/types/domain/extractJsonBlock.d.ts +1 -0
- package/dist/types/domain/jsonExportDestination.d.ts +3 -0
- package/dist/types/domain/mcpTool.d.ts +9 -0
- package/dist/types/domain/microPrompts.d.ts +20 -0
- package/dist/types/domain/orchestrator/agenticoOrchestratorAgent.d.ts +34 -0
- package/dist/types/domain/orchestrator/prompt.d.ts +17 -0
- package/dist/types/domain/prompts.d.ts +29 -0
- package/dist/types/domain/resultDestination.d.ts +24 -0
- package/dist/types/domain/subagentManifest.d.ts +172 -0
- package/dist/types/domain/subagentRegistry.d.ts +11 -0
- package/dist/types/domain/subagentUsageCard.d.ts +37 -0
- package/dist/types/i18n/de.d.ts +2 -0
- package/dist/types/i18n/en.d.ts +2 -0
- package/dist/types/i18n/index.d.ts +20 -0
- package/dist/types/i18n/it.d.ts +2 -0
- package/dist/types/i18n/types.d.ts +55 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/presentation/AgentActivityLog.d.ts +9 -0
- package/dist/types/presentation/AgentControls.d.ts +26 -0
- package/dist/types/presentation/Agentico.d.ts +23 -0
- package/dist/types/presentation/AgenticoContext.d.ts +305 -0
- package/dist/types/presentation/AgenticoToggle.d.ts +17 -0
- package/dist/types/presentation/ManualEntryRunner.d.ts +22 -0
- package/dist/types/presentation/OrchestratorRunner.d.ts +12 -0
- package/dist/types/presentation/ResultDestinationPicker.d.ts +29 -0
- package/dist/types/presentation/SubagentRunner.d.ts +48 -0
- package/dist/types/presentation/deriveHistoryTitle.d.ts +10 -0
- package/dist/types/presentation/liveAnchorDestination.d.ts +10 -0
- package/dist/types/presentation/reports/GenericResultPreview.d.ts +11 -0
- package/dist/types/presentation/reports/subagentReportRegistry.d.ts +58 -0
- package/dist/types/presentation/useAIModelCatalog.d.ts +9 -0
- package/dist/types/presentation/useAgent.d.ts +140 -0
- package/dist/types/presentation/useAgenticoPageContext.d.ts +12 -0
- package/dist/types/presentation/useSubagentComponentContext.d.ts +44 -0
- package/llms.txt +35 -0
- package/package.json +79 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1995 @@
|
|
|
1
|
+
import { zodToJsonSchema as e } from "zod-to-json-schema";
|
|
2
|
+
import { ActionButton as t, Badge as n, Chatbot as r, Code as i, Dropdown as a, DropdownItem as o, Icon as s, PromptUtils as c, getAIModelCatalog as l, interpolate as u, parseAIModelRef as d, proxyFetch as f, useAIProviderRegistry as p, useI18n as m, useProxy as h } from "@llmnative/react";
|
|
3
|
+
import g, { createContext as _, useCallback as v, useContext as y, useEffect as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
|
|
4
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
5
|
+
//#region src/domain/defineSubagent.ts
|
|
6
|
+
function O(e) {
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/domain/subagentRegistry.ts
|
|
11
|
+
var k = [];
|
|
12
|
+
function A(e) {
|
|
13
|
+
k = e;
|
|
14
|
+
}
|
|
15
|
+
function j() {
|
|
16
|
+
return k.length === 0 && typeof console < "u" && console.warn("[agentico] getSubagentRegistry() letto a registro vuoto — registerSubagents() non è ancora stato chiamato?"), k;
|
|
17
|
+
}
|
|
18
|
+
function M(e) {
|
|
19
|
+
return k.find((t) => t.id === e);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/domain/crossAgentTools.ts
|
|
23
|
+
var N = [];
|
|
24
|
+
function P(...e) {
|
|
25
|
+
N = e;
|
|
26
|
+
}
|
|
27
|
+
function F(e) {
|
|
28
|
+
return N.flatMap((t) => t(e));
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/domain/mcpTool.ts
|
|
32
|
+
function I(t) {
|
|
33
|
+
let { $schema: n, ...r } = e(t, {
|
|
34
|
+
target: "jsonSchema7",
|
|
35
|
+
$refStrategy: "none"
|
|
36
|
+
});
|
|
37
|
+
return r;
|
|
38
|
+
}
|
|
39
|
+
function L(e, t, n, r) {
|
|
40
|
+
return {
|
|
41
|
+
name: e,
|
|
42
|
+
description: t,
|
|
43
|
+
inputSchema: I(n),
|
|
44
|
+
...r ? { outputSchema: I(r) } : {}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/domain/subagentUsageCard.ts
|
|
49
|
+
function R(e) {
|
|
50
|
+
let t = I(e.inputSchema), n = t.properties ?? {}, r = new Set(t.required ?? []);
|
|
51
|
+
return Object.entries(n).map(([t, n]) => {
|
|
52
|
+
let i = typeof n.description == "string" ? n.description : "";
|
|
53
|
+
return {
|
|
54
|
+
key: t,
|
|
55
|
+
type: typeof n.type == "string" ? n.type : "string",
|
|
56
|
+
required: r.has(t),
|
|
57
|
+
description: i,
|
|
58
|
+
humanDescription: e.humanFieldHints?.[t] ?? i
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/domain/prompts.ts
|
|
64
|
+
var z = {
|
|
65
|
+
orchestratorIntro: "You are Agentico, the orchestrator of this application's tools. Your job is to understand what the user wants to achieve and, once every required parameter is collected, start the right tool among those listed below — do not carry it out yourself \"in words\", invoke it as a tool.",
|
|
66
|
+
responseRules: [
|
|
67
|
+
"BEFORE asking for any parameter, check the \"Page context\" below (if present): if a parameter required by the command is already there or can be deduced from it with reasonable certainty, USE it directly — do not ask the user again. Only ask for parameters that cannot be derived from the context.",
|
|
68
|
+
"The \"<subagent>_<command>\" command you close with is the one that does the real work (analysis, matching, generation, extraction — whatever its description says) — NEVER try to produce that result yourself in chat once the raw data is collected.",
|
|
69
|
+
"If parameters are really missing (not deducible from the context nor from a data-collection tool) for one of the listed commands, ask in natural language, one question at a time, until you have everything.",
|
|
70
|
+
"When you have ALL required parameters of ONE command, actually invoke the tool with that name (\"<subagent>_<command>\") passing the parameters — do not just describe it, and do not replace the work that command is designed to do.",
|
|
71
|
+
"Invoke at most one command per turn.",
|
|
72
|
+
"If the user's request is not covered by any of the listed tools, say so clearly instead of inventing one.",
|
|
73
|
+
"IMPORTANT: when you invoke a \"<subagent>_<command>\" command, your comment in THIS turn must only announce the START of the work — NEVER describe its outcome as already obtained, and NEVER say that something \"opened\" or \"is ready to review\". The real work starts AFTER this turn, in a session you will never see: any description of the outcome at this point would be invented, even if the tool answered without errors.",
|
|
74
|
+
"After invoking a command, do not spontaneously suggest other subagents unrelated to the current request — the user will open a new conversation if they need something else."
|
|
75
|
+
],
|
|
76
|
+
responseRulesHeading: "## How to answer",
|
|
77
|
+
toolsHeading: "## Available tools",
|
|
78
|
+
pageContextHeading: "## Page context",
|
|
79
|
+
pageContextIntro: "The user is interacting from this point of the app — use it to understand what they refer to when the request is not explicit:",
|
|
80
|
+
userRequestHeading: "## User request",
|
|
81
|
+
noToolsAvailable: "No tools available.",
|
|
82
|
+
stopCallingTools: "Stop calling tools. Answer NOW with the final result, in the required format, using everything collected so far.",
|
|
83
|
+
handoffQueued: "{label} has been queued for the real execution — the result is not available in this conversation yet.",
|
|
84
|
+
closingSummary: [
|
|
85
|
+
"When you are done answering (with or without tools in this turn),",
|
|
86
|
+
"ALWAYS close your text answer with a concise but complete summary of what",
|
|
87
|
+
"you did — a few lines, a bullet list when there is more than one action, no",
|
|
88
|
+
"needless repetition of the original task. The summary goes AFTER the JSON",
|
|
89
|
+
"block requested above, never before it and never instead of it."
|
|
90
|
+
].join(" "),
|
|
91
|
+
multipleCandidates: "Several subagents are candidates on this page — ask the user which one they mean if their message does not make it clear, before going on."
|
|
92
|
+
}, B = {
|
|
93
|
+
orchestratorIntro: "Sei Agentico, l'orchestratore dei tool di questa applicazione. Il tuo compito è capire cosa vuole ottenere l'utente e, una volta raccolti tutti i parametri necessari, avviare il tool giusto tra quelli elencati sotto — non eseguirlo tu stesso \"a parole\", invocalo come strumento.",
|
|
94
|
+
responseRules: [
|
|
95
|
+
"PRIMA di chiedere qualunque parametro, controlla il \"Contesto pagina\" (se presente) qui sotto: se un parametro richiesto dal comando è già lì o si può dedurre da lì con ragionevole certezza (es. l'utente sta guardando lo storico di un tool specifico, o un'esecuzione passata con parametri simili), USALO direttamente — non chiederlo di nuovo all'utente. Chiedi solo i parametri che NON emergono in nessun modo dal contesto.",
|
|
96
|
+
"Il comando \"<subagent>_<comando>\" con cui chiudi è quello che fa il lavoro di analisi vero (matching, generazione, estrazione — qualunque cosa il suo comando descriva) — MAI provare a produrlo tu stesso in chat una volta raccolti i dati grezzi.",
|
|
97
|
+
"Se mancano davvero parametri (non deducibili dal contesto né da un tool di raccolta dati) per uno dei comandi elencati, fai domande in linguaggio naturale, una alla volta, finché non hai raccolto tutto.",
|
|
98
|
+
"Quando hai TUTTI i parametri richiesti di UN comando (raccolti dall'utente, dedotti dal contesto, o ottenuti da un tool di raccolta dati), invoca davvero lo strumento con quel nome (\"<subagent>_<comando>\") passandogli i parametri — non limitarti a descriverlo a parole, e non sostituirti al lavoro che quel comando è progettato per fare.",
|
|
99
|
+
"Invoca al massimo un comando per turno.",
|
|
100
|
+
"Se la richiesta dell'utente non è coperta da nessuno dei tool elencati, dillo chiaramente invece di inventarne uno.",
|
|
101
|
+
"IMPORTANTE: quando invochi un comando \"<subagent>_<comando>\", il tuo commento in QUESTO turno deve annunciare solo l'AVVIO del lavoro (es. \"Avvio l'estrazione…\", \"Sto preparando il mapping…\") — MAI descriverne l'esito come già ottenuto (colori, font, loghi, mapping, o qualunque altro dato del risultato) e MAI dire che qualcosa \"si è aperto\" o \"è pronto da rivedere\". Il vero lavoro parte DOPO questo turno, in una sessione che tu non vedrai mai: qualunque tua descrizione dell'esito a questo punto sarebbe un'invenzione, anche se il tool ha risposto senza errori.",
|
|
102
|
+
"Dopo aver invocato un comando, non proporre spontaneamente altri subagent scollegati dalla richiesta corrente — l'utente aprirà lui una nuova conversazione se gli servirà altro."
|
|
103
|
+
],
|
|
104
|
+
responseRulesHeading: "## Come rispondere",
|
|
105
|
+
toolsHeading: "## Tool disponibili",
|
|
106
|
+
pageContextHeading: "## Contesto pagina",
|
|
107
|
+
pageContextIntro: "L'utente sta interagendo da questo punto dell'app — usalo per capire a cosa si riferisce se non è esplicito nella richiesta:",
|
|
108
|
+
userRequestHeading: "## Richiesta dell'utente",
|
|
109
|
+
noToolsAvailable: "Nessun tool disponibile.",
|
|
110
|
+
stopCallingTools: "Basta chiamare tool. Rispondi ORA con il risultato finale, nel formato richiesto, usando tutte le informazioni raccolte finora.",
|
|
111
|
+
handoffQueued: "{label} è stato messo in coda per l'esecuzione reale — il risultato non è ancora disponibile in questa conversazione.",
|
|
112
|
+
closingSummary: [
|
|
113
|
+
"Quando hai finito di rispondere (con o senza aver usato dei tool in questo turno),",
|
|
114
|
+
"chiudi SEMPRE la tua risposta testuale con un riepilogo conciso ma esaustivo di cosa",
|
|
115
|
+
"hai fatto — poche righe, elenco puntato se le azioni sono più di una, niente",
|
|
116
|
+
"ripetizioni superflue del compito originale. Il riepilogo va DOPO il blocco JSON",
|
|
117
|
+
"richiesto sopra, mai prima e mai al posto suo."
|
|
118
|
+
].join(" "),
|
|
119
|
+
multipleCandidates: "Più subagent sono candidati su questa pagina — chiedi all'utente quale intende se non è chiaro dal suo messaggio, prima di procedere."
|
|
120
|
+
}, V = z;
|
|
121
|
+
function ee(e) {
|
|
122
|
+
V = {
|
|
123
|
+
...V,
|
|
124
|
+
...e
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function H() {
|
|
128
|
+
return V;
|
|
129
|
+
}
|
|
130
|
+
function te() {
|
|
131
|
+
V = z;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/domain/cli/renderManifestCli.ts
|
|
135
|
+
function ne(e, t) {
|
|
136
|
+
return `${e} ${t.map((e) => e.required ? `--${e.key} <${e.type}>` : `[--${e.key} <${e.type}>]`).join(" ")}`.trim();
|
|
137
|
+
}
|
|
138
|
+
function U(e, t) {
|
|
139
|
+
let n = R(t), r = ne(t.name, n), i = n.map((e) => ` --${e.key} <${e.type}> (${e.required ? "required" : "optional"})${e.description ? ` — ${e.description}` : ""}`);
|
|
140
|
+
return [
|
|
141
|
+
`COMMAND: ${e} ${t.name}`,
|
|
142
|
+
` ${t.summary}`,
|
|
143
|
+
"",
|
|
144
|
+
" USAGE",
|
|
145
|
+
` ${e} ${r}`,
|
|
146
|
+
(i.length, ""),
|
|
147
|
+
i.length ? " PARAMS" : "",
|
|
148
|
+
...i,
|
|
149
|
+
"",
|
|
150
|
+
" OUTPUT",
|
|
151
|
+
W(t.describeOutput(), 4),
|
|
152
|
+
(t.example, ""),
|
|
153
|
+
t.example ? " EXAMPLE" : "",
|
|
154
|
+
t.example ? ` ${t.example}` : ""
|
|
155
|
+
].filter((e) => e !== "").join("\n");
|
|
156
|
+
}
|
|
157
|
+
function W(e, t) {
|
|
158
|
+
let n = " ".repeat(t);
|
|
159
|
+
return e.split("\n").map((e) => e && n + e).join("\n");
|
|
160
|
+
}
|
|
161
|
+
function re(e) {
|
|
162
|
+
return [
|
|
163
|
+
"NAME",
|
|
164
|
+
` ${e.id} — ${e.label}`,
|
|
165
|
+
"",
|
|
166
|
+
"DESCRIPTION",
|
|
167
|
+
W(e.description, 2),
|
|
168
|
+
"",
|
|
169
|
+
...e.commands.map((t) => U(e.id, t))
|
|
170
|
+
].join("\n");
|
|
171
|
+
}
|
|
172
|
+
function ie(e) {
|
|
173
|
+
return e.length === 0 ? H().noToolsAvailable : e.map((e) => `${e.id} [${e.commands.map((e) => e.name).join("|")}] — ${e.label}: ${e.commands.map((e) => e.summary).join(" / ")}`).join("\n");
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/domain/microPrompts.ts
|
|
177
|
+
var ae = {
|
|
178
|
+
id: "closing-summary",
|
|
179
|
+
get text() {
|
|
180
|
+
return H().closingSummary;
|
|
181
|
+
}
|
|
182
|
+
}, oe = { [ae.id]: ae };
|
|
183
|
+
function G(e, t) {
|
|
184
|
+
if (!t || t.length === 0) return e;
|
|
185
|
+
let n = t.map((e) => oe[e]?.text).filter((e) => !!e);
|
|
186
|
+
return n.length === 0 ? e : `${e}\n\n${n.join("\n")}`;
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/domain/extractErrorMessage.ts
|
|
190
|
+
function K(e) {
|
|
191
|
+
if (e instanceof Error) return e.message;
|
|
192
|
+
if (typeof e == "object" && e) {
|
|
193
|
+
let t = e;
|
|
194
|
+
if (typeof t.error == "string") return t.error;
|
|
195
|
+
if (t.error && typeof t.error == "object") {
|
|
196
|
+
let e = t.error;
|
|
197
|
+
if (typeof e.message == "string") return e.message;
|
|
198
|
+
}
|
|
199
|
+
if (typeof t.message == "string") return t.message;
|
|
200
|
+
if (typeof t.status == "number") return `HTTP ${t.status}`;
|
|
201
|
+
try {
|
|
202
|
+
return JSON.stringify(e);
|
|
203
|
+
} catch {}
|
|
204
|
+
}
|
|
205
|
+
return String(e);
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/domain/extractJsonBlock.ts
|
|
209
|
+
function se(e) {
|
|
210
|
+
let t = e.match(/```(?:json)?\s*\n?([\s\S]*?)```/i);
|
|
211
|
+
if (t) return t[1].trim();
|
|
212
|
+
let n = e.replace(/^```json\s*/i, "").replace(/^```\s*/i, "").replace(/```\s*$/, "").trim();
|
|
213
|
+
return ce(n) ?? n;
|
|
214
|
+
}
|
|
215
|
+
function ce(e) {
|
|
216
|
+
let t = e.search(/[{[]/);
|
|
217
|
+
if (t === -1) return null;
|
|
218
|
+
let n = e[t], r = n === "{" ? "}" : "]", i = 0, a = !1, o = !1;
|
|
219
|
+
for (let s = t; s < e.length; s++) {
|
|
220
|
+
let c = e[s];
|
|
221
|
+
if (a) {
|
|
222
|
+
o ? o = !1 : c === "\\" ? o = !0 : c === "\"" && (a = !1);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (c === "\"") {
|
|
226
|
+
a = !0;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (c === n) i++;
|
|
230
|
+
else if (c === r && (i--, i === 0)) return e.slice(t, s + 1);
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/domain/jsonExportDestination.ts
|
|
236
|
+
var le = "json-export", q = {
|
|
237
|
+
id: le,
|
|
238
|
+
label: "Export as JSON",
|
|
239
|
+
async apply(e) {
|
|
240
|
+
let t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), n = URL.createObjectURL(t);
|
|
241
|
+
try {
|
|
242
|
+
let e = document.createElement("a");
|
|
243
|
+
e.href = n, e.download = `tool-result-${Date.now()}.json`, e.click();
|
|
244
|
+
} finally {
|
|
245
|
+
URL.revokeObjectURL(n);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}, ue = {};
|
|
249
|
+
function de(e) {
|
|
250
|
+
ue = e;
|
|
251
|
+
}
|
|
252
|
+
function J() {
|
|
253
|
+
return {
|
|
254
|
+
[q.id]: q,
|
|
255
|
+
...ue
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/domain/entityChatStore.ts
|
|
260
|
+
var fe = "llmnative.agentico.entityChat";
|
|
261
|
+
function pe(e) {
|
|
262
|
+
fe = e.storageKey;
|
|
263
|
+
}
|
|
264
|
+
function me(e) {
|
|
265
|
+
if (!e || typeof e != "object") return null;
|
|
266
|
+
let t = e;
|
|
267
|
+
if (typeof t.entityId != "string") return null;
|
|
268
|
+
let n = t.scopeId ?? t.tenantId;
|
|
269
|
+
if (typeof n != "string") return null;
|
|
270
|
+
let { tenantId: r, ...i } = t;
|
|
271
|
+
return {
|
|
272
|
+
...i,
|
|
273
|
+
scopeId: n
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function Y() {
|
|
277
|
+
try {
|
|
278
|
+
let e = localStorage.getItem(fe);
|
|
279
|
+
if (!e) return [];
|
|
280
|
+
let t = JSON.parse(e);
|
|
281
|
+
return Array.isArray(t) ? t.map(me).filter((e) => e !== null) : [];
|
|
282
|
+
} catch {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function he(e) {
|
|
287
|
+
try {
|
|
288
|
+
localStorage.setItem(fe, JSON.stringify(e));
|
|
289
|
+
} catch {}
|
|
290
|
+
}
|
|
291
|
+
var X = (e, t, n) => `${e}:${t}:${n}`;
|
|
292
|
+
function ge(e, t, n) {
|
|
293
|
+
let r = X(e, t, n);
|
|
294
|
+
return Y().find((e) => X(e.scopeId, e.subagentId, e.entityId) === r) ?? null;
|
|
295
|
+
}
|
|
296
|
+
function _e(e) {
|
|
297
|
+
let t = X(e.scopeId, e.subagentId, e.entityId), n = Y().filter((e) => X(e.scopeId, e.subagentId, e.entityId) !== t);
|
|
298
|
+
n.push({
|
|
299
|
+
...e,
|
|
300
|
+
savedAt: Date.now()
|
|
301
|
+
}), he(n);
|
|
302
|
+
}
|
|
303
|
+
function ve(e, t, n) {
|
|
304
|
+
let r = X(e, t, n);
|
|
305
|
+
he(Y().filter((e) => X(e.scopeId, e.subagentId, e.entityId) !== r));
|
|
306
|
+
}
|
|
307
|
+
function ye(e) {
|
|
308
|
+
return Y().filter((t) => t.scopeId === e).sort((e, t) => t.savedAt - e.savedAt);
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/i18n/de.ts
|
|
312
|
+
var be = {
|
|
313
|
+
modelLabel: "Modell",
|
|
314
|
+
modelsLoading: "Wird geladen…",
|
|
315
|
+
noModelsAvailable: "Keine Modelle verfügbar",
|
|
316
|
+
noProviderConnected: "Kein AI-Provider verbunden",
|
|
317
|
+
selectModelPlaceholder: "Modell wählen…",
|
|
318
|
+
orchestratorStarterHint: "Sag Agentico, was du erreichen willst — es wählt das passende Werkzeug und fragt nach den nötigen Angaben.",
|
|
319
|
+
orchestratorStarterPlaceholder: "Beschreibe, was du tun möchtest…",
|
|
320
|
+
destinationPickerTitle: "Ergebnis speichern in…",
|
|
321
|
+
destinationApplying: "Wird gespeichert…",
|
|
322
|
+
destinationNoScope: "Kein Ziel ausgewählt — vor dem Speichern eines auswählen.",
|
|
323
|
+
unknownDestination: "Unbekanntes Ziel: {id}",
|
|
324
|
+
exportJson: "Als JSON exportieren",
|
|
325
|
+
orchestratorUnavailable: "AI nicht verfügbar — öffne das benötigte Werkzeug direkt auf seiner Seite.",
|
|
326
|
+
orchestratorContinueWithoutAi: "Weiter ohne AI.",
|
|
327
|
+
orchestratorPreparing: "{label} wird vorbereitet…",
|
|
328
|
+
orchestratorCollecting: "Parameter für {label} werden gesammelt…",
|
|
329
|
+
thinking: "Denke nach…",
|
|
330
|
+
stopped: "Vom Benutzer abgebrochen.",
|
|
331
|
+
toolRequest: "Werkzeugausführung angefordert",
|
|
332
|
+
modelRequestError: "Fehler bei der Anfrage an das Modell",
|
|
333
|
+
noProviderResponse: "Keine Antwort vom AI-Provider.",
|
|
334
|
+
noActiveSession: "Keine aktive Sitzung — zuerst run() aufrufen.",
|
|
335
|
+
requestInProgress: "Eine andere Anfrage läuft bereits.",
|
|
336
|
+
invalidResponse: "Ungültige AI-Antwort.",
|
|
337
|
+
responseReceived: "Antwort erhalten",
|
|
338
|
+
noProviderAvailable: "Kein AI-Provider verfügbar.",
|
|
339
|
+
tooManyToolTurns: "Zu viele aufeinanderfolgende Werkzeugaufrufe — das bisher gesammelte deterministische Ergebnis wird verwendet.",
|
|
340
|
+
aiDisabledFallback: "AI deaktiviert — das deterministische Ergebnis wird verwendet.",
|
|
341
|
+
continueWithoutAiFallback: "Weiter ohne AI — das deterministische Ergebnis wird verwendet.",
|
|
342
|
+
newInstance: "Neue Instanz von \"{label}\"",
|
|
343
|
+
chatHistory: "Chatverlauf",
|
|
344
|
+
newChat: "Neuer Chat",
|
|
345
|
+
searchChats: "Chats durchsuchen…",
|
|
346
|
+
messagePlaceholder: "Nachricht schreiben…",
|
|
347
|
+
unsavedConversationConfirm: "Diese Unterhaltung wurde nicht gespeichert und geht verloren. Fortfahren?",
|
|
348
|
+
noSavedChats: "Noch keine gespeicherten Chats.",
|
|
349
|
+
noResults: "Keine Ergebnisse.",
|
|
350
|
+
retry: "Erneut versuchen",
|
|
351
|
+
retryMessage: "Erneut versuchen.",
|
|
352
|
+
continueWithoutAi: "Ohne AI fortfahren",
|
|
353
|
+
resumeWithAi: "Mit AI fortsetzen",
|
|
354
|
+
openPanel: "Agentenbereich öffnen",
|
|
355
|
+
closePanel: "Agentenbereich schließen"
|
|
356
|
+
}, xe = {
|
|
357
|
+
modelLabel: "Model",
|
|
358
|
+
modelsLoading: "Loading…",
|
|
359
|
+
noModelsAvailable: "No models available",
|
|
360
|
+
noProviderConnected: "No AI provider connected",
|
|
361
|
+
selectModelPlaceholder: "Choose a model…",
|
|
362
|
+
orchestratorStarterHint: "Tell Agentico what you want to do — it will pick the right tool and ask for what it needs.",
|
|
363
|
+
orchestratorStarterPlaceholder: "Describe what you want to do…",
|
|
364
|
+
destinationPickerTitle: "Save result to…",
|
|
365
|
+
destinationApplying: "Saving…",
|
|
366
|
+
destinationNoScope: "Nothing selected to save into — select one before saving.",
|
|
367
|
+
unknownDestination: "Unknown destination: {id}",
|
|
368
|
+
exportJson: "Export as JSON",
|
|
369
|
+
orchestratorUnavailable: "AI not available — open the tool you need directly from its page.",
|
|
370
|
+
orchestratorContinueWithoutAi: "Continuing without AI.",
|
|
371
|
+
orchestratorPreparing: "Preparing {label}…",
|
|
372
|
+
orchestratorCollecting: "Collecting the parameters for {label}…",
|
|
373
|
+
thinking: "Thinking…",
|
|
374
|
+
stopped: "Stopped by the user.",
|
|
375
|
+
toolRequest: "Requested to run some tools",
|
|
376
|
+
modelRequestError: "Error in the request to the model",
|
|
377
|
+
noProviderResponse: "No response from the AI provider.",
|
|
378
|
+
noActiveSession: "No active session — call run() first.",
|
|
379
|
+
requestInProgress: "Another request is already running.",
|
|
380
|
+
invalidResponse: "Invalid AI response.",
|
|
381
|
+
responseReceived: "Response received",
|
|
382
|
+
noProviderAvailable: "No AI provider available.",
|
|
383
|
+
tooManyToolTurns: "Too many consecutive tool-calling turns — using the deterministic result collected so far.",
|
|
384
|
+
aiDisabledFallback: "AI disabled — using the deterministic result.",
|
|
385
|
+
continueWithoutAiFallback: "Continuing without AI — using the deterministic result.",
|
|
386
|
+
newInstance: "New \"{label}\" instance",
|
|
387
|
+
chatHistory: "Chat history",
|
|
388
|
+
newChat: "New chat",
|
|
389
|
+
searchChats: "Search chats…",
|
|
390
|
+
messagePlaceholder: "Write a message…",
|
|
391
|
+
unsavedConversationConfirm: "This conversation has not been saved and will be lost. Continue?",
|
|
392
|
+
noSavedChats: "No saved chats yet.",
|
|
393
|
+
noResults: "No results.",
|
|
394
|
+
retry: "Retry",
|
|
395
|
+
retryMessage: "Retry.",
|
|
396
|
+
continueWithoutAi: "Continue without AI",
|
|
397
|
+
resumeWithAi: "Resume with AI",
|
|
398
|
+
openPanel: "Open agent panel",
|
|
399
|
+
closePanel: "Close agent panel"
|
|
400
|
+
}, Se = {
|
|
401
|
+
modelLabel: "Modello",
|
|
402
|
+
modelsLoading: "Caricamento…",
|
|
403
|
+
noModelsAvailable: "Nessun modello disponibile",
|
|
404
|
+
noProviderConnected: "Nessun provider AI connesso",
|
|
405
|
+
selectModelPlaceholder: "Scegli un modello…",
|
|
406
|
+
orchestratorStarterHint: "Dì ad Agentico cosa vuoi fare — sceglierà lo strumento giusto e ti chiederà cosa serve.",
|
|
407
|
+
orchestratorStarterPlaceholder: "Descrivi cosa vuoi fare…",
|
|
408
|
+
destinationPickerTitle: "Salva risultato in…",
|
|
409
|
+
destinationApplying: "Salvataggio…",
|
|
410
|
+
destinationNoScope: "Nessuna destinazione selezionata — selezionane una prima di salvare.",
|
|
411
|
+
unknownDestination: "Destinazione sconosciuta: {id}",
|
|
412
|
+
exportJson: "Esporta come JSON",
|
|
413
|
+
orchestratorUnavailable: "AI non disponibile — apri il tool che ti serve direttamente dalla sua pagina.",
|
|
414
|
+
orchestratorContinueWithoutAi: "Continuo senza AI.",
|
|
415
|
+
orchestratorPreparing: "Preparo {label}…",
|
|
416
|
+
orchestratorCollecting: "Sto raccogliendo i parametri per {label}…",
|
|
417
|
+
thinking: "Sto pensando…",
|
|
418
|
+
stopped: "Interrotto dall'utente.",
|
|
419
|
+
toolRequest: "Richiesta di eseguire dei tool",
|
|
420
|
+
modelRequestError: "Errore nella richiesta al modello",
|
|
421
|
+
noProviderResponse: "Nessuna risposta dal provider AI.",
|
|
422
|
+
noActiveSession: "Nessuna sessione attiva — chiama prima run().",
|
|
423
|
+
requestInProgress: "Un'altra richiesta è già in corso.",
|
|
424
|
+
invalidResponse: "Risposta AI non valida.",
|
|
425
|
+
responseReceived: "Risposta ricevuta",
|
|
426
|
+
noProviderAvailable: "Nessun provider AI disponibile.",
|
|
427
|
+
tooManyToolTurns: "Troppi turni di tool-calling consecutivi — uso il risultato deterministico raccolto finora.",
|
|
428
|
+
aiDisabledFallback: "AI disabilitata — uso il risultato deterministico.",
|
|
429
|
+
continueWithoutAiFallback: "Continuo senza AI — uso il risultato deterministico.",
|
|
430
|
+
newInstance: "Nuova istanza di \"{label}\"",
|
|
431
|
+
chatHistory: "Storico chat",
|
|
432
|
+
newChat: "Nuova chat",
|
|
433
|
+
searchChats: "Cerca nelle chat…",
|
|
434
|
+
messagePlaceholder: "Scrivi un messaggio…",
|
|
435
|
+
unsavedConversationConfirm: "Questa conversazione non è stata salvata e andrà persa. Continuare?",
|
|
436
|
+
noSavedChats: "Nessuna chat salvata ancora.",
|
|
437
|
+
noResults: "Nessun risultato.",
|
|
438
|
+
retry: "Riprova",
|
|
439
|
+
retryMessage: "Riprova.",
|
|
440
|
+
continueWithoutAi: "Continua senza AI",
|
|
441
|
+
resumeWithAi: "Riprendi con AI",
|
|
442
|
+
openPanel: "Apri pannello agente",
|
|
443
|
+
closePanel: "Chiudi pannello agente"
|
|
444
|
+
}, Ce = {
|
|
445
|
+
en: { agentico: xe },
|
|
446
|
+
it: { agentico: Se },
|
|
447
|
+
de: { agentico: be }
|
|
448
|
+
};
|
|
449
|
+
function Z() {
|
|
450
|
+
let { dict: e } = m(), t = e.agentico;
|
|
451
|
+
return t ? {
|
|
452
|
+
...xe,
|
|
453
|
+
...t
|
|
454
|
+
} : xe;
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/presentation/AgenticoContext.tsx
|
|
458
|
+
var Q = "agentico-orchestrator", we = _(null);
|
|
459
|
+
function Te({ children: e, scope: t = null }) {
|
|
460
|
+
let [n, r] = w(null), i = C(null);
|
|
461
|
+
b(() => {
|
|
462
|
+
i.current = n;
|
|
463
|
+
}, [n]);
|
|
464
|
+
let [a, o] = w(!1), s = v((e) => {
|
|
465
|
+
let t = i.current;
|
|
466
|
+
t && t.id !== e.id && t.onDismiss();
|
|
467
|
+
let n = t && t.id === e.id && t.savedToDisk && e.savedToDisk === void 0 ? {
|
|
468
|
+
...e,
|
|
469
|
+
savedToDisk: !0
|
|
470
|
+
} : e;
|
|
471
|
+
r(n);
|
|
472
|
+
}, []), c = v((e) => {
|
|
473
|
+
r((t) => t && t.id === e ? null : t);
|
|
474
|
+
}, []), l = v(() => o((e) => !e), []), u = v(() => o(!0), []), [d, f] = w(null), [p, m] = w(void 0), [h, g] = w(void 0), [_, y] = w(void 0), [x, T] = w(null), [D, O] = w(null), [k, A] = w(void 0), [j, N] = w([]), P = v((e, t, n = null) => {
|
|
475
|
+
N((r) => {
|
|
476
|
+
let i = r.filter((t) => t.id !== e);
|
|
477
|
+
return t ? [...i, {
|
|
478
|
+
id: e,
|
|
479
|
+
text: t,
|
|
480
|
+
card: n
|
|
481
|
+
}] : i;
|
|
482
|
+
});
|
|
483
|
+
}, []), F = j.length > 0 ? j[j.length - 1] : null, [I, L] = w([]), R = v((e, t) => {
|
|
484
|
+
L((n) => {
|
|
485
|
+
let r = n.filter((t) => t.id !== e);
|
|
486
|
+
return t ? [...r, {
|
|
487
|
+
id: e,
|
|
488
|
+
...t
|
|
489
|
+
}] : r;
|
|
490
|
+
});
|
|
491
|
+
}, []), z = S(() => I.map((e) => ({
|
|
492
|
+
subagentId: e.subagentId,
|
|
493
|
+
componentKey: e.componentKey,
|
|
494
|
+
onResult: e.onResult,
|
|
495
|
+
pinnedEntityId: e.pinnedEntityId
|
|
496
|
+
})), [I]), B = S(() => {
|
|
497
|
+
let e = /* @__PURE__ */ new Map();
|
|
498
|
+
for (let t of I) e.set(t.subagentId, {
|
|
499
|
+
subagentId: t.subagentId,
|
|
500
|
+
componentKey: t.componentKey,
|
|
501
|
+
onResult: t.onResult,
|
|
502
|
+
contextInfo: t.contextInfo
|
|
503
|
+
});
|
|
504
|
+
return [...e.values()];
|
|
505
|
+
}, [I]), V = S(() => B.map((e) => {
|
|
506
|
+
let t = M(e.subagentId)?.componentContexts?.[e.componentKey];
|
|
507
|
+
if (!t) return null;
|
|
508
|
+
let n = e.contextInfo ? `${t.agenticoHint}\n${e.contextInfo}` : t.agenticoHint;
|
|
509
|
+
return {
|
|
510
|
+
subagentId: e.subagentId,
|
|
511
|
+
agenticoHint: n,
|
|
512
|
+
userMessage: t.userMessage
|
|
513
|
+
};
|
|
514
|
+
}).filter((e) => e !== null), [B]), ee = S(() => V.map((e) => e.userMessage), [V]), te = S(() => {
|
|
515
|
+
if (V.length === 0) return null;
|
|
516
|
+
if (V.length === 1) return V[0].agenticoHint;
|
|
517
|
+
let e = V.map((e, t) => `${t + 1}. ${e.agenticoHint}`).join("\n");
|
|
518
|
+
return `${H().multipleCandidates}\n\n${e}`;
|
|
519
|
+
}, [V]) ?? F?.text ?? null, ne = V.length > 0 ? null : F?.card ?? null, U = S(() => [...new Set(z.map((e) => e.subagentId))], [z]), W = U.length === 1 ? U[0] : U.length === 0 ? F?.card?.subagentId ?? null : null, re = v((e, t) => {
|
|
520
|
+
u();
|
|
521
|
+
let n = i.current;
|
|
522
|
+
if (n?.id === "agentico-orchestrator") return;
|
|
523
|
+
let r = W && n?.id.startsWith(`subagent-${W}-`) ? n : void 0;
|
|
524
|
+
O(r ? {
|
|
525
|
+
taskId: r.id,
|
|
526
|
+
activity: [...r.precedingActivity ?? [], ...r.agent.activity]
|
|
527
|
+
} : null), f(e), m(t?.extraDestinations), g(t?.attachments), y(t?.model), A(t?.scopedSubagentId), T(crypto.randomUUID());
|
|
528
|
+
}, [u, W]), ie = v((e, t, n, a, o, s) => {
|
|
529
|
+
if (!n || !a) return;
|
|
530
|
+
let c = i.current;
|
|
531
|
+
if (!c || c.id !== n) return;
|
|
532
|
+
let l = c.agent.snapshot();
|
|
533
|
+
l && (_e({
|
|
534
|
+
scopeId: a,
|
|
535
|
+
subagentId: e,
|
|
536
|
+
entityId: t,
|
|
537
|
+
params: o,
|
|
538
|
+
title: s,
|
|
539
|
+
history: l.history,
|
|
540
|
+
activity: [...c.precedingActivity ?? [], ...l.activity]
|
|
541
|
+
}), r((e) => e && e.id === n ? {
|
|
542
|
+
...e,
|
|
543
|
+
savedToDisk: !0
|
|
544
|
+
} : e));
|
|
545
|
+
}, []), [ae, oe] = w(null), [G, K] = w(null), se = v((e, t, n) => {
|
|
546
|
+
u(), oe({
|
|
547
|
+
subagentId: e,
|
|
548
|
+
entityId: t,
|
|
549
|
+
snapshot: n
|
|
550
|
+
}), K(crypto.randomUUID());
|
|
551
|
+
}, [u]), [ce, le] = w(null), [q, ue] = w(null), de = v((e, t) => {
|
|
552
|
+
u(), c(Q), le({
|
|
553
|
+
subagentId: e,
|
|
554
|
+
extraDestinations: t
|
|
555
|
+
}), ue(crypto.randomUUID());
|
|
556
|
+
}, [u, c]), [J, fe] = w(null), [pe, me] = w(null), Y = v((e, t, n) => {
|
|
557
|
+
le(null), fe({
|
|
558
|
+
subagentId: e,
|
|
559
|
+
params: t,
|
|
560
|
+
extraDestinations: n
|
|
561
|
+
}), me(crypto.randomUUID());
|
|
562
|
+
}, []), he = v(() => {
|
|
563
|
+
let e = i.current;
|
|
564
|
+
e && e.onDismiss();
|
|
565
|
+
}, []), X = S(() => ({
|
|
566
|
+
scope: t,
|
|
567
|
+
task: n,
|
|
568
|
+
isOpen: a,
|
|
569
|
+
openTask: s,
|
|
570
|
+
closeTask: c,
|
|
571
|
+
toggleOpen: l,
|
|
572
|
+
pendingGoal: d,
|
|
573
|
+
startOrchestrator: re,
|
|
574
|
+
pageContext: te,
|
|
575
|
+
pageContextCard: ne,
|
|
576
|
+
setPageContext: P,
|
|
577
|
+
scopedSubagentId: W,
|
|
578
|
+
pendingScopedSubagentId: k,
|
|
579
|
+
componentAnchors: z,
|
|
580
|
+
anchoredUserMessages: ee,
|
|
581
|
+
registerComponentAnchor: R,
|
|
582
|
+
openPanel: u,
|
|
583
|
+
pendingExtraDestinations: p,
|
|
584
|
+
pendingAttachments: h,
|
|
585
|
+
pendingModel: _,
|
|
586
|
+
orchestratorRunId: x,
|
|
587
|
+
pendingCarryOver: D,
|
|
588
|
+
commitEntityChat: ie,
|
|
589
|
+
resumeEntityChat: se,
|
|
590
|
+
pendingResume: ae,
|
|
591
|
+
resumeRunId: G,
|
|
592
|
+
dismissForeignTask: he,
|
|
593
|
+
pendingManualEntry: ce,
|
|
594
|
+
manualEntryRunId: q,
|
|
595
|
+
startManualEntry: de,
|
|
596
|
+
pendingResumeWithAI: J,
|
|
597
|
+
resumeWithAIRunId: pe,
|
|
598
|
+
resumeWithAI: Y
|
|
599
|
+
}), [
|
|
600
|
+
t,
|
|
601
|
+
n,
|
|
602
|
+
a,
|
|
603
|
+
s,
|
|
604
|
+
c,
|
|
605
|
+
l,
|
|
606
|
+
d,
|
|
607
|
+
re,
|
|
608
|
+
te,
|
|
609
|
+
ne,
|
|
610
|
+
P,
|
|
611
|
+
W,
|
|
612
|
+
k,
|
|
613
|
+
z,
|
|
614
|
+
ee,
|
|
615
|
+
R,
|
|
616
|
+
u,
|
|
617
|
+
p,
|
|
618
|
+
h,
|
|
619
|
+
_,
|
|
620
|
+
x,
|
|
621
|
+
D,
|
|
622
|
+
ie,
|
|
623
|
+
se,
|
|
624
|
+
ae,
|
|
625
|
+
G,
|
|
626
|
+
he,
|
|
627
|
+
ce,
|
|
628
|
+
q,
|
|
629
|
+
de,
|
|
630
|
+
J,
|
|
631
|
+
pe,
|
|
632
|
+
Y
|
|
633
|
+
]);
|
|
634
|
+
return /* @__PURE__ */ E(we.Provider, {
|
|
635
|
+
value: X,
|
|
636
|
+
children: e
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function $() {
|
|
640
|
+
let e = y(we);
|
|
641
|
+
if (!e) throw Error("useAgentico must be used inside AgenticoProvider");
|
|
642
|
+
return e;
|
|
643
|
+
}
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/presentation/AgentActivityLog.tsx
|
|
646
|
+
function Ee(e) {
|
|
647
|
+
let t = e.search(/[{[]/);
|
|
648
|
+
if (t === -1) return [{
|
|
649
|
+
type: "text",
|
|
650
|
+
content: e
|
|
651
|
+
}];
|
|
652
|
+
let n = e[t], r = n === "{" ? "}" : "]", i = 0, a = !1, o = !1, s = -1;
|
|
653
|
+
for (let c = t; c < e.length; c++) {
|
|
654
|
+
let t = e[c];
|
|
655
|
+
if (a) {
|
|
656
|
+
o ? o = !1 : t === "\\" ? o = !0 : t === "\"" && (a = !1);
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (t === "\"") {
|
|
660
|
+
a = !0;
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (t === n) i++;
|
|
664
|
+
else if (t === r && (i--, i === 0)) {
|
|
665
|
+
s = c;
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
let c = s === -1 ? null : e.slice(t, s + 1);
|
|
670
|
+
if (!c || c.length < 60) return [{
|
|
671
|
+
type: "text",
|
|
672
|
+
content: e
|
|
673
|
+
}];
|
|
674
|
+
try {
|
|
675
|
+
JSON.parse(c);
|
|
676
|
+
} catch {
|
|
677
|
+
return [{
|
|
678
|
+
type: "text",
|
|
679
|
+
content: e
|
|
680
|
+
}];
|
|
681
|
+
}
|
|
682
|
+
let l = [];
|
|
683
|
+
t > 0 && l.push({
|
|
684
|
+
type: "text",
|
|
685
|
+
content: e.slice(0, t)
|
|
686
|
+
}), l.push({
|
|
687
|
+
type: "code",
|
|
688
|
+
content: c,
|
|
689
|
+
language: "json"
|
|
690
|
+
});
|
|
691
|
+
let u = e.slice(s + 1);
|
|
692
|
+
return u.trim() && l.push(...Ee(u)), l;
|
|
693
|
+
}
|
|
694
|
+
function De(e) {
|
|
695
|
+
let t = [], n = /```(\w+)?\n?([\s\S]*?)```/g, r = 0, i;
|
|
696
|
+
for (; i = n.exec(e);) i.index > r && t.push(...Ee(e.slice(r, i.index))), t.push({
|
|
697
|
+
type: "code",
|
|
698
|
+
content: i[2].replace(/\n$/, ""),
|
|
699
|
+
language: i[1]
|
|
700
|
+
}), r = n.lastIndex;
|
|
701
|
+
return r < e.length && t.push(...Ee(e.slice(r))), t;
|
|
702
|
+
}
|
|
703
|
+
function Oe({ content: e, language: t }) {
|
|
704
|
+
let [n, r] = w(!1);
|
|
705
|
+
return /* @__PURE__ */ D("div", {
|
|
706
|
+
className: `relative cursor-pointer rounded-md ${n ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
|
|
707
|
+
onClick: () => r((e) => !e),
|
|
708
|
+
title: n ? "Clic per comprimere" : "Clic per espandere",
|
|
709
|
+
children: [/* @__PURE__ */ E(i, {
|
|
710
|
+
language: t,
|
|
711
|
+
showCopy: n,
|
|
712
|
+
background: "transparent",
|
|
713
|
+
className: "!text-[11px]",
|
|
714
|
+
children: e
|
|
715
|
+
}), !n && /* @__PURE__ */ E("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function ke(e) {
|
|
719
|
+
let t = [], n = /\*\*(.+?)\*\*|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\)/g, r = 0, i;
|
|
720
|
+
for (; i = n.exec(e);) i.index > r && t.push({
|
|
721
|
+
type: "text",
|
|
722
|
+
content: e.slice(r, i.index)
|
|
723
|
+
}), i[1] === void 0 ? i[2] === void 0 ? i[3] !== void 0 && t.push({
|
|
724
|
+
type: "link",
|
|
725
|
+
content: i[3],
|
|
726
|
+
href: i[4]
|
|
727
|
+
}) : t.push({
|
|
728
|
+
type: "code",
|
|
729
|
+
content: i[2]
|
|
730
|
+
}) : t.push({
|
|
731
|
+
type: "bold",
|
|
732
|
+
content: i[1]
|
|
733
|
+
}), r = n.lastIndex;
|
|
734
|
+
return r < e.length && t.push({
|
|
735
|
+
type: "text",
|
|
736
|
+
content: e.slice(r)
|
|
737
|
+
}), t;
|
|
738
|
+
}
|
|
739
|
+
function Ae({ text: e }) {
|
|
740
|
+
return /* @__PURE__ */ E(T, { children: ke(e).map((e, t) => e.type === "bold" ? /* @__PURE__ */ E("strong", {
|
|
741
|
+
className: "font-semibold text-foreground",
|
|
742
|
+
children: e.content
|
|
743
|
+
}, t) : e.type === "code" ? /* @__PURE__ */ E("code", {
|
|
744
|
+
className: "rounded bg-muted px-1 py-0.5 font-mono text-[11px] break-words",
|
|
745
|
+
children: e.content
|
|
746
|
+
}, t) : e.type === "link" ? /* @__PURE__ */ E("a", {
|
|
747
|
+
href: e.href,
|
|
748
|
+
target: "_blank",
|
|
749
|
+
rel: "noreferrer",
|
|
750
|
+
className: "text-primary underline underline-offset-2",
|
|
751
|
+
children: e.content
|
|
752
|
+
}, t) : /* @__PURE__ */ E(g.Fragment, { children: e.content }, t)) });
|
|
753
|
+
}
|
|
754
|
+
function je({ text: e }) {
|
|
755
|
+
let t = De(e);
|
|
756
|
+
return /* @__PURE__ */ E(T, { children: t.map((e, t) => e.type === "code" ? /* @__PURE__ */ E(Oe, {
|
|
757
|
+
content: e.content,
|
|
758
|
+
language: e.language
|
|
759
|
+
}, t) : e.content.trim() && /* @__PURE__ */ E("p", {
|
|
760
|
+
className: "whitespace-pre-wrap break-words",
|
|
761
|
+
children: /* @__PURE__ */ E(Ae, { text: e.content })
|
|
762
|
+
}, t)) });
|
|
763
|
+
}
|
|
764
|
+
function Me({ status: e }) {
|
|
765
|
+
return e === "running" ? /* @__PURE__ */ E("span", { className: "inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" }) : e === "done" ? /* @__PURE__ */ E(s, {
|
|
766
|
+
name: "check",
|
|
767
|
+
size: 12,
|
|
768
|
+
className: "shrink-0 text-green-600"
|
|
769
|
+
}) : e === "stopped" ? /* @__PURE__ */ E(s, {
|
|
770
|
+
name: "circle-slash",
|
|
771
|
+
size: 12,
|
|
772
|
+
className: "shrink-0 text-muted-foreground"
|
|
773
|
+
}) : /* @__PURE__ */ E(s, {
|
|
774
|
+
name: "x",
|
|
775
|
+
size: 12,
|
|
776
|
+
className: "shrink-0 text-destructive"
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
function Ne(e, t) {
|
|
780
|
+
return e.status === "running" ? t.thinking : e.status === "error" ? t.modelRequestError : e.status === "stopped" ? t.stopped : e.detail ? t.responseReceived : e.toolNames && e.toolNames.length > 0 ? e.toolNames.join(" · ") : t.toolRequest;
|
|
781
|
+
}
|
|
782
|
+
var Pe = 96;
|
|
783
|
+
function Fe({ entry: e }) {
|
|
784
|
+
let t = C(null), [n, r] = w(!1), [i, a] = w(!1);
|
|
785
|
+
x(() => {
|
|
786
|
+
let e = t.current;
|
|
787
|
+
e && a(e.scrollHeight > 97);
|
|
788
|
+
}, [e.detail, e.attachmentNames]);
|
|
789
|
+
let o = i && !n;
|
|
790
|
+
return /* @__PURE__ */ E("li", {
|
|
791
|
+
className: "sticky top-0 z-10 flex justify-end border-b border-border/40 bg-background py-1.5",
|
|
792
|
+
children: /* @__PURE__ */ D("div", {
|
|
793
|
+
className: "max-w-[85%] rounded-lg bg-primary/10 text-xs text-foreground",
|
|
794
|
+
children: [/* @__PURE__ */ D("div", {
|
|
795
|
+
ref: t,
|
|
796
|
+
className: `space-y-1 px-2.5 pt-1.5 ${o ? "overflow-hidden" : ""}`,
|
|
797
|
+
style: o ? { maxHeight: Pe } : void 0,
|
|
798
|
+
children: [e.attachmentNames && e.attachmentNames.length > 0 && /* @__PURE__ */ E("div", {
|
|
799
|
+
className: "flex flex-wrap gap-1",
|
|
800
|
+
children: e.attachmentNames.map((e, t) => /* @__PURE__ */ D("span", {
|
|
801
|
+
className: "inline-flex items-center gap-1 rounded-md bg-primary/15 px-1.5 py-0.5 text-[11px] text-foreground",
|
|
802
|
+
children: [/* @__PURE__ */ E(s, {
|
|
803
|
+
name: "paperclip",
|
|
804
|
+
size: 10,
|
|
805
|
+
className: "shrink-0"
|
|
806
|
+
}), /* @__PURE__ */ E("span", {
|
|
807
|
+
className: "max-w-[160px] truncate",
|
|
808
|
+
children: e
|
|
809
|
+
})]
|
|
810
|
+
}, t))
|
|
811
|
+
}), /* @__PURE__ */ E(je, { text: e.detail ?? "" })]
|
|
812
|
+
}), i && /* @__PURE__ */ D("button", {
|
|
813
|
+
type: "button",
|
|
814
|
+
onClick: () => r((e) => !e),
|
|
815
|
+
className: "relative flex w-full items-center justify-center rounded-b-lg py-1 text-muted-foreground hover:bg-primary/15",
|
|
816
|
+
title: n ? "Comprimi" : "Espandi",
|
|
817
|
+
children: [o && /* @__PURE__ */ E("div", { className: "pointer-events-none absolute inset-x-0 -top-4 h-4 bg-gradient-to-t from-primary/10 to-transparent" }), /* @__PURE__ */ E(s, {
|
|
818
|
+
name: n ? "chevron-up" : "chevron-down",
|
|
819
|
+
size: 12
|
|
820
|
+
})]
|
|
821
|
+
})]
|
|
822
|
+
})
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function Ie({ entry: e }) {
|
|
826
|
+
let t = Z();
|
|
827
|
+
if (e.kind === "user") return /* @__PURE__ */ E(Fe, { entry: e });
|
|
828
|
+
let n = e.kind === "thinking" && e.detail ? De(e.detail) : [], r = n.filter((e) => e.type === "code"), i = n.filter((e) => e.type === "text" && e.content.trim()), a = e.kind === "thinking" ? Ne(e, t) : e.label;
|
|
829
|
+
return /* @__PURE__ */ D("li", {
|
|
830
|
+
className: "text-xs text-muted-foreground",
|
|
831
|
+
children: [
|
|
832
|
+
/* @__PURE__ */ D("div", {
|
|
833
|
+
className: "flex items-start gap-1.5",
|
|
834
|
+
children: [/* @__PURE__ */ E("span", {
|
|
835
|
+
className: "pt-px",
|
|
836
|
+
children: /* @__PURE__ */ E(Me, { status: e.status })
|
|
837
|
+
}), /* @__PURE__ */ E("span", {
|
|
838
|
+
className: "min-w-0 flex-1 whitespace-pre-wrap break-words",
|
|
839
|
+
children: a
|
|
840
|
+
})]
|
|
841
|
+
}),
|
|
842
|
+
r.length > 0 && /* @__PURE__ */ E("div", {
|
|
843
|
+
className: "mt-1 ml-[18px] space-y-1",
|
|
844
|
+
children: r.map((e, t) => /* @__PURE__ */ E(Oe, {
|
|
845
|
+
content: e.content,
|
|
846
|
+
language: e.language
|
|
847
|
+
}, t))
|
|
848
|
+
}),
|
|
849
|
+
i.length > 0 && /* @__PURE__ */ E("div", {
|
|
850
|
+
className: "mt-1 ml-[18px] space-y-2",
|
|
851
|
+
children: i.map((e, t) => /* @__PURE__ */ E("p", {
|
|
852
|
+
className: "whitespace-pre-wrap leading-relaxed text-muted-foreground",
|
|
853
|
+
children: /* @__PURE__ */ E(Ae, { text: e.content.trim() })
|
|
854
|
+
}, t))
|
|
855
|
+
})
|
|
856
|
+
]
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function Le({ activity: e }) {
|
|
860
|
+
return e.length === 0 ? null : /* @__PURE__ */ E("ul", {
|
|
861
|
+
className: "space-y-0.5",
|
|
862
|
+
children: e.map((e) => /* @__PURE__ */ E(Ie, { entry: e }, e.id))
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
//#endregion
|
|
866
|
+
//#region src/presentation/AgenticoToggle.tsx
|
|
867
|
+
function Re({ className: e = "" }) {
|
|
868
|
+
let { isOpen: n, toggleOpen: r, task: i } = $(), a = Z(), o = i?.agent.running ?? !1;
|
|
869
|
+
return /* @__PURE__ */ E(t, {
|
|
870
|
+
icon: "bot",
|
|
871
|
+
ariaLabel: n ? a.closePanel : a.openPanel,
|
|
872
|
+
title: n ? a.closePanel : a.openPanel,
|
|
873
|
+
onClick: r,
|
|
874
|
+
iconClassName: o ? "animate-pulse" : void 0,
|
|
875
|
+
className: `!h-9 !w-9 !p-0 rounded-md ${n ? "bg-primary/10 text-primary hover:bg-primary/15" : "bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground"} ${e}`
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
//#endregion
|
|
879
|
+
//#region src/presentation/useAIModelCatalog.ts
|
|
880
|
+
var ze = "llmnative-cms.selectedAIModel";
|
|
881
|
+
function Be() {
|
|
882
|
+
try {
|
|
883
|
+
return localStorage.getItem(ze) ?? "";
|
|
884
|
+
} catch {
|
|
885
|
+
return "";
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
function Ve(e) {
|
|
889
|
+
try {
|
|
890
|
+
e ? localStorage.setItem(ze, e) : localStorage.removeItem(ze);
|
|
891
|
+
} catch {}
|
|
892
|
+
}
|
|
893
|
+
function He() {
|
|
894
|
+
let e = p()?.registry ?? {}, t = Object.keys(e).length > 0, [n, r] = w({}), [i, a] = w(!1), [o, s] = w(Be);
|
|
895
|
+
return b(() => {
|
|
896
|
+
if (!t) {
|
|
897
|
+
r({});
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
let n = !1;
|
|
901
|
+
return a(!0), l(e).then((e) => {
|
|
902
|
+
if (n) return;
|
|
903
|
+
r(e.modelsByProvider);
|
|
904
|
+
let t = Object.values(e.modelsByProvider).flat();
|
|
905
|
+
s((e) => t.some((t) => t.id === e) ? e : (Ve(""), ""));
|
|
906
|
+
}).catch((e) => {
|
|
907
|
+
console.error("useAIModelCatalog: getAIModelCatalog failed", e), n || r({});
|
|
908
|
+
}).finally(() => {
|
|
909
|
+
n || a(!1);
|
|
910
|
+
}), () => {
|
|
911
|
+
n = !0;
|
|
912
|
+
};
|
|
913
|
+
}, [t, JSON.stringify(Object.keys(e).sort())]), {
|
|
914
|
+
hasProviders: t,
|
|
915
|
+
modelsByProvider: n,
|
|
916
|
+
modelsLoading: i,
|
|
917
|
+
selectedModel: o,
|
|
918
|
+
setSelectedModel: (e) => {
|
|
919
|
+
Ve(e), s(e);
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region src/presentation/useAgent.ts
|
|
925
|
+
var Ue = 20, We = 26e4;
|
|
926
|
+
function Ge(e) {
|
|
927
|
+
return e.filter((e) => !c.isTextAttachment(e.mimeType) || e.base64.length <= We);
|
|
928
|
+
}
|
|
929
|
+
function Ke(e, t = {}) {
|
|
930
|
+
let { defaultEnabled: n = !1 } = t, [r, i] = w(n), { hasProviders: a, modelsByProvider: o, modelsLoading: s, selectedModel: l, setSelectedModel: u } = He(), [f, m] = w(!1), [h, g] = w(null), [_, v] = w(!1), [y, b] = w([]), x = Z(), S = C(x);
|
|
931
|
+
S.current = x;
|
|
932
|
+
let T = C(null), E = C(!1), D = C(null), O = () => {
|
|
933
|
+
D.current?.abort();
|
|
934
|
+
}, k = p()?.registry ?? {}, A = r && l ? d(l) : null, j = A ? k[A.provider] : null, M = async (t, n, r) => {
|
|
935
|
+
let i = T.current;
|
|
936
|
+
if (!i) return g(S.current.noActiveSession), null;
|
|
937
|
+
let a = r ? d(r) : A, o = a ? k[a.provider] : null;
|
|
938
|
+
if (!o || !a) return g(S.current.noProviderAvailable), null;
|
|
939
|
+
n?.length && (i.attachmentsRef.current = [...i.attachmentsRef.current ?? [], ...n]);
|
|
940
|
+
let s = (n ?? []).filter((e) => c.isTextAttachment(e.mimeType)).map((e) => e.base64.length <= We ? `\n\n[File allegato: ${e.name}]\n${c.decodeBase64Text(e.base64)}` : `\n\n[File allegato: ${e.name} — troppo grande per essere incollato qui. Usa uno dei tool di lettura file disponibili (es. list_csv_columns/extract_csv_column) per leggerne il contenuto prima di chiedere altro all'utente.]`).join(""), l = Ge(n ?? []), u = i.tools.map((e) => ({
|
|
941
|
+
name: e.name,
|
|
942
|
+
description: e.description,
|
|
943
|
+
inputSchema: I(e.inputSchema)
|
|
944
|
+
})), f = new Map(i.tools.map((e) => [e.name, e])), p = new AbortController();
|
|
945
|
+
D.current = p;
|
|
946
|
+
let m = (e, t, n, r) => b((i) => i.map((i) => i.id === e ? {
|
|
947
|
+
...i,
|
|
948
|
+
status: t,
|
|
949
|
+
...n === void 0 ? {} : { detail: n },
|
|
950
|
+
...r === void 0 ? {} : { toolNames: r }
|
|
951
|
+
} : i));
|
|
952
|
+
try {
|
|
953
|
+
let n = i.history, r = t;
|
|
954
|
+
for (let t = 0; t < Ue; t++) {
|
|
955
|
+
let c = crypto.randomUUID();
|
|
956
|
+
b((e) => [...e, {
|
|
957
|
+
id: c,
|
|
958
|
+
kind: "thinking",
|
|
959
|
+
label: S.current.thinking,
|
|
960
|
+
status: "running"
|
|
961
|
+
}]);
|
|
962
|
+
let d;
|
|
963
|
+
try {
|
|
964
|
+
d = await o.complete({
|
|
965
|
+
prompt: r,
|
|
966
|
+
model: a.model,
|
|
967
|
+
history: n,
|
|
968
|
+
tools: u.length ? u : void 0,
|
|
969
|
+
signal: p.signal,
|
|
970
|
+
attachments: t === 0 ? l : void 0,
|
|
971
|
+
logId: i.logId
|
|
972
|
+
});
|
|
973
|
+
} catch (t) {
|
|
974
|
+
return i.history = [...n, ...r ? [{
|
|
975
|
+
role: "user",
|
|
976
|
+
content: r + s
|
|
977
|
+
}] : []], p.signal.aborted ? (m(c, "stopped"), e.fallback(i.params, i.context)) : (m(c, "error"), g(K(t)), null);
|
|
978
|
+
}
|
|
979
|
+
if (i.history = [...n, ...r ? [{
|
|
980
|
+
role: "user",
|
|
981
|
+
content: r + s
|
|
982
|
+
}] : []], !d) return p.signal.aborted ? (m(c, "stopped"), e.fallback(i.params, i.context)) : (m(c, "error"), g(S.current.noProviderResponse), null);
|
|
983
|
+
if (d.type === "text") return m(c, "done", d.text), i.history = [
|
|
984
|
+
...n,
|
|
985
|
+
...r ? [{
|
|
986
|
+
role: "user",
|
|
987
|
+
content: r + s
|
|
988
|
+
}] : [],
|
|
989
|
+
{
|
|
990
|
+
role: "assistant",
|
|
991
|
+
content: d.text
|
|
992
|
+
}
|
|
993
|
+
], e.parseResponse(d.text, i.params, i.context) || (console.error("[useAgent] parseResponse ha restituito null — la risposta del modello non è nel formato atteso da questo subagent. Uso il fallback deterministico.", {
|
|
994
|
+
responseLength: d.text.length,
|
|
995
|
+
responsePreview: d.text.length > 2e3 ? `${d.text.slice(0, 1e3)}\n…[troncato qui nel log, ${d.text.length} caratteri totali]…\n${d.text.slice(-1e3)}` : d.text,
|
|
996
|
+
params: i.params
|
|
997
|
+
}), g(S.current.invalidResponse), e.fallback(i.params, i.context));
|
|
998
|
+
let h = d.toolCalls.map((e) => {
|
|
999
|
+
let t = f.get(e.name);
|
|
1000
|
+
return t?.describeIntent ?? t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
|
|
1001
|
+
});
|
|
1002
|
+
m(c, "done", d.text || void 0, d.text ? void 0 : h);
|
|
1003
|
+
let _ = await Promise.all(d.toolCalls.map(async (e) => {
|
|
1004
|
+
let t = f.get(e.name), n = t?.describeInvocation?.(e.input) ?? `Chiamata: ${e.name}`;
|
|
1005
|
+
if (b((t) => [...t, {
|
|
1006
|
+
id: e.id,
|
|
1007
|
+
kind: "tool",
|
|
1008
|
+
label: n,
|
|
1009
|
+
status: "running"
|
|
1010
|
+
}]), !t) return m(e.id, "error"), {
|
|
1011
|
+
toolCallId: e.id,
|
|
1012
|
+
name: e.name,
|
|
1013
|
+
output: `Tool sconosciuto: ${e.name}`,
|
|
1014
|
+
isError: !0
|
|
1015
|
+
};
|
|
1016
|
+
try {
|
|
1017
|
+
let n = await t.execute(e.input);
|
|
1018
|
+
return m(e.id, "done"), {
|
|
1019
|
+
toolCallId: e.id,
|
|
1020
|
+
name: e.name,
|
|
1021
|
+
output: n
|
|
1022
|
+
};
|
|
1023
|
+
} catch (t) {
|
|
1024
|
+
return m(e.id, "error"), {
|
|
1025
|
+
toolCallId: e.id,
|
|
1026
|
+
name: e.name,
|
|
1027
|
+
output: K(t),
|
|
1028
|
+
isError: !0
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
}));
|
|
1032
|
+
n = [
|
|
1033
|
+
...n,
|
|
1034
|
+
...r ? [{
|
|
1035
|
+
role: "user",
|
|
1036
|
+
content: r + s
|
|
1037
|
+
}] : [],
|
|
1038
|
+
{
|
|
1039
|
+
role: "assistant",
|
|
1040
|
+
content: d.text,
|
|
1041
|
+
toolCalls: d.toolCalls
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
role: "tool_result",
|
|
1045
|
+
results: _
|
|
1046
|
+
}
|
|
1047
|
+
], r = "";
|
|
1048
|
+
}
|
|
1049
|
+
let c = crypto.randomUUID();
|
|
1050
|
+
b((e) => [...e, {
|
|
1051
|
+
id: c,
|
|
1052
|
+
kind: "thinking",
|
|
1053
|
+
label: S.current.thinking,
|
|
1054
|
+
status: "running"
|
|
1055
|
+
}]);
|
|
1056
|
+
let d;
|
|
1057
|
+
try {
|
|
1058
|
+
d = await o.complete({
|
|
1059
|
+
prompt: G(H().stopCallingTools, e.microPromptIds),
|
|
1060
|
+
model: a.model,
|
|
1061
|
+
history: n,
|
|
1062
|
+
signal: p.signal,
|
|
1063
|
+
logId: i.logId
|
|
1064
|
+
});
|
|
1065
|
+
} catch {
|
|
1066
|
+
d = null;
|
|
1067
|
+
}
|
|
1068
|
+
if (d?.type === "text") {
|
|
1069
|
+
m(c, "done", d.text), i.history = [...n, {
|
|
1070
|
+
role: "assistant",
|
|
1071
|
+
content: d.text
|
|
1072
|
+
}];
|
|
1073
|
+
let t = e.parseResponse(d.text, i.params, i.context);
|
|
1074
|
+
if (t) return t;
|
|
1075
|
+
} else m(c, p.signal.aborted ? "stopped" : "error"), i.history = n;
|
|
1076
|
+
return p.signal.aborted || g(S.current.tooManyToolTurns), e.fallback(i.params, i.context);
|
|
1077
|
+
} finally {
|
|
1078
|
+
D.current = null;
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
return {
|
|
1082
|
+
enabled: r,
|
|
1083
|
+
setEnabled: i,
|
|
1084
|
+
hasProviders: a,
|
|
1085
|
+
selectedModel: l,
|
|
1086
|
+
setSelectedModel: u,
|
|
1087
|
+
modelsByProvider: o,
|
|
1088
|
+
modelsLoading: s,
|
|
1089
|
+
running: f,
|
|
1090
|
+
error: h,
|
|
1091
|
+
canContinue: _,
|
|
1092
|
+
activity: y,
|
|
1093
|
+
run: async (t, n) => {
|
|
1094
|
+
if (E.current) return g(S.current.requestInProgress), null;
|
|
1095
|
+
E.current = !0, g(null), b(n?.openingMessage ? [{
|
|
1096
|
+
id: crypto.randomUUID(),
|
|
1097
|
+
kind: "user",
|
|
1098
|
+
label: "Tu",
|
|
1099
|
+
status: "done",
|
|
1100
|
+
detail: n.openingMessage,
|
|
1101
|
+
...n.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
|
|
1102
|
+
}] : []), m(!0);
|
|
1103
|
+
try {
|
|
1104
|
+
let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
|
|
1105
|
+
T.current = {
|
|
1106
|
+
params: t,
|
|
1107
|
+
context: i,
|
|
1108
|
+
tools: o,
|
|
1109
|
+
history: [],
|
|
1110
|
+
logId: crypto.randomUUID(),
|
|
1111
|
+
attachmentsRef: a
|
|
1112
|
+
};
|
|
1113
|
+
let s = n?.model || void 0, l = s ? !!k[d(s)?.provider ?? ""] : !!j;
|
|
1114
|
+
if (!r || !l) {
|
|
1115
|
+
v(!1);
|
|
1116
|
+
let n = e.fallback(t, i);
|
|
1117
|
+
return b((t) => [...t, {
|
|
1118
|
+
id: crypto.randomUUID(),
|
|
1119
|
+
kind: "tool",
|
|
1120
|
+
status: "done",
|
|
1121
|
+
label: e.describeFallback?.(n) ?? S.current.aiDisabledFallback
|
|
1122
|
+
}]), n;
|
|
1123
|
+
}
|
|
1124
|
+
v(!0);
|
|
1125
|
+
let u = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => c.fileToAttachment(e))) : void 0, f = G(e.buildPrompt(t, i), e.microPromptIds);
|
|
1126
|
+
return await M(f, u, s);
|
|
1127
|
+
} catch (e) {
|
|
1128
|
+
return g(K(e)), null;
|
|
1129
|
+
} finally {
|
|
1130
|
+
E.current = !1, m(!1);
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
resume: async (t, n) => {
|
|
1134
|
+
if (E.current) {
|
|
1135
|
+
g(S.current.requestInProgress);
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
E.current = !0, g(null), b(n.activity), m(!0);
|
|
1139
|
+
try {
|
|
1140
|
+
let i = await e.buildContext(t), a = { current: void 0 }, o = e.getTools?.(t, i, a) ?? [];
|
|
1141
|
+
T.current = {
|
|
1142
|
+
params: t,
|
|
1143
|
+
context: i,
|
|
1144
|
+
tools: o,
|
|
1145
|
+
history: n.history,
|
|
1146
|
+
logId: crypto.randomUUID(),
|
|
1147
|
+
attachmentsRef: a
|
|
1148
|
+
}, v(r && !!j);
|
|
1149
|
+
} catch (e) {
|
|
1150
|
+
g(K(e));
|
|
1151
|
+
} finally {
|
|
1152
|
+
E.current = !1, m(!1);
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
sendMessage: async (t, n) => {
|
|
1156
|
+
if (E.current) return g(S.current.requestInProgress), null;
|
|
1157
|
+
if (g(null), !t.trim()) return g("Messaggio vuoto."), null;
|
|
1158
|
+
let r = T.current;
|
|
1159
|
+
if (!r) return g(S.current.noActiveSession), null;
|
|
1160
|
+
E.current = !0, m(!0), b((e) => [...e, {
|
|
1161
|
+
id: crypto.randomUUID(),
|
|
1162
|
+
kind: "user",
|
|
1163
|
+
label: "Tu",
|
|
1164
|
+
status: "done",
|
|
1165
|
+
detail: t,
|
|
1166
|
+
...n?.attachments?.length ? { attachmentNames: n.attachments.map((e) => e.name) } : {}
|
|
1167
|
+
}]);
|
|
1168
|
+
try {
|
|
1169
|
+
let i = n?.attachments?.length ? await Promise.all(n.attachments.map((e) => c.fileToAttachment(e))) : void 0, a = G(e.buildFollowUpPrompt(t, r.params, r.context), e.microPromptIds);
|
|
1170
|
+
return await M(a, i, n?.model || void 0);
|
|
1171
|
+
} catch (e) {
|
|
1172
|
+
return g(K(e)), null;
|
|
1173
|
+
} finally {
|
|
1174
|
+
E.current = !1, m(!1);
|
|
1175
|
+
}
|
|
1176
|
+
},
|
|
1177
|
+
stop: O,
|
|
1178
|
+
runFallback: () => {
|
|
1179
|
+
let t = T.current;
|
|
1180
|
+
if (!t) return null;
|
|
1181
|
+
g(null);
|
|
1182
|
+
let n = e.fallback(t.params, t.context);
|
|
1183
|
+
return b((t) => [...t, {
|
|
1184
|
+
id: crypto.randomUUID(),
|
|
1185
|
+
kind: "tool",
|
|
1186
|
+
status: "done",
|
|
1187
|
+
label: e.describeFallback?.(n) ?? S.current.continueWithoutAiFallback
|
|
1188
|
+
}]), n;
|
|
1189
|
+
},
|
|
1190
|
+
snapshot: () => T.current ? {
|
|
1191
|
+
history: T.current.history,
|
|
1192
|
+
activity: y
|
|
1193
|
+
} : null
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region src/domain/orchestrator/prompt.ts
|
|
1198
|
+
function qe() {
|
|
1199
|
+
let e = H();
|
|
1200
|
+
return [e.responseRulesHeading, ...e.responseRules.map((e) => `- ${e}`)].join("\n");
|
|
1201
|
+
}
|
|
1202
|
+
function Je(e, t, n) {
|
|
1203
|
+
let r = H(), i = n ? `\n${r.pageContextHeading}\n${r.pageContextIntro}\n${n}\n` : "";
|
|
1204
|
+
return `${r.orchestratorIntro}
|
|
1205
|
+
|
|
1206
|
+
${r.toolsHeading}
|
|
1207
|
+
${t}
|
|
1208
|
+
${i}
|
|
1209
|
+
${qe()}
|
|
1210
|
+
|
|
1211
|
+
${r.userRequestHeading}
|
|
1212
|
+
${e}`;
|
|
1213
|
+
}
|
|
1214
|
+
function Ye(e, t) {
|
|
1215
|
+
return t ? {
|
|
1216
|
+
kind: "handoff",
|
|
1217
|
+
...t
|
|
1218
|
+
} : {
|
|
1219
|
+
kind: "chat",
|
|
1220
|
+
message: e
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
//#endregion
|
|
1224
|
+
//#region src/domain/orchestrator/agenticoOrchestratorAgent.ts
|
|
1225
|
+
function Xe(e) {
|
|
1226
|
+
return {
|
|
1227
|
+
buildContext() {
|
|
1228
|
+
return {
|
|
1229
|
+
cliCatalog: ie(j()),
|
|
1230
|
+
handoff: { current: null },
|
|
1231
|
+
collected: {}
|
|
1232
|
+
};
|
|
1233
|
+
},
|
|
1234
|
+
buildPrompt({ userGoal: e, pageContext: t }, { cliCatalog: n }) {
|
|
1235
|
+
return Je(e, n, t);
|
|
1236
|
+
},
|
|
1237
|
+
buildFollowUpPrompt(e, t, { cliCatalog: n }) {
|
|
1238
|
+
return `${e}\n\n${qe()}\n\n${H().toolsHeading}\n${n}`;
|
|
1239
|
+
},
|
|
1240
|
+
parseResponse(e, t, n) {
|
|
1241
|
+
let r = n.handoff.current;
|
|
1242
|
+
return n.handoff.current = null, Ye(e, r);
|
|
1243
|
+
},
|
|
1244
|
+
fallback() {
|
|
1245
|
+
return {
|
|
1246
|
+
kind: "chat",
|
|
1247
|
+
message: e.unavailable
|
|
1248
|
+
};
|
|
1249
|
+
},
|
|
1250
|
+
describeFallback(t) {
|
|
1251
|
+
return t.kind === "chat" ? t.message : e.continueWithoutAi;
|
|
1252
|
+
},
|
|
1253
|
+
getTools(t, n, r) {
|
|
1254
|
+
let i = F({
|
|
1255
|
+
attachmentsRef: r,
|
|
1256
|
+
collected: n.collected,
|
|
1257
|
+
proxyFetch: f
|
|
1258
|
+
}), a = t.scopedSubagentId ? M(t.scopedSubagentId) : null, o = a ? i.filter((e) => (a.crossAgentToolIds ?? []).includes(e.name)) : i, s = j().flatMap((t) => t.commands.map((r) => ({
|
|
1259
|
+
name: `${t.id}_${r.name}`,
|
|
1260
|
+
description: `${t.label}: ${r.summary}`,
|
|
1261
|
+
inputSchema: r.inputSchema,
|
|
1262
|
+
describeInvocation: () => u(e.preparing, { label: t.label }),
|
|
1263
|
+
describeIntent: u(e.collecting, { label: t.label }),
|
|
1264
|
+
async execute(e) {
|
|
1265
|
+
let i = t.withCollected ? t.withCollected({ ...e }, n.collected) : e;
|
|
1266
|
+
return n.handoff.current = {
|
|
1267
|
+
subagentId: t.id,
|
|
1268
|
+
command: r.name,
|
|
1269
|
+
params: i
|
|
1270
|
+
}, {
|
|
1271
|
+
status: "queued",
|
|
1272
|
+
note: u(H().handoffQueued, { label: t.label })
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
})));
|
|
1276
|
+
return [...o, ...s];
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region src/presentation/deriveHistoryTitle.ts
|
|
1282
|
+
function Ze(e, t) {
|
|
1283
|
+
return e.deriveHistoryTitle?.(t) ?? e.label;
|
|
1284
|
+
}
|
|
1285
|
+
//#endregion
|
|
1286
|
+
//#region src/presentation/ResultDestinationPicker.tsx
|
|
1287
|
+
function Qe({ manifest: e, result: t, meta: n, taskId: r, initiallyApplied: i, onApplied: a, extraDestinations: o }) {
|
|
1288
|
+
let s = Z(), c = $(), l = c.scope, d = h(), [f, p] = w(null), [m, g] = w(new Set(i ?? [])), [_, v] = w(null), y = J(), b = /* @__PURE__ */ new Map();
|
|
1289
|
+
e.destinationIds.forEach((e) => {
|
|
1290
|
+
let t = y[e];
|
|
1291
|
+
t && b.set(e, t);
|
|
1292
|
+
}), (o ?? []).forEach((e) => b.set(e.id, e)), b.set(q.id, q);
|
|
1293
|
+
let x = Array.from(b.values()), S = async (i) => {
|
|
1294
|
+
p(i), v(null);
|
|
1295
|
+
try {
|
|
1296
|
+
let o = b.get(i);
|
|
1297
|
+
if (!o) throw Error(u(s.unknownDestination, { id: i }));
|
|
1298
|
+
if (i !== "json-export" && !l) throw Error(s.destinationNoScope);
|
|
1299
|
+
let f = await o.apply(t, {
|
|
1300
|
+
scopeId: l?.id ?? "",
|
|
1301
|
+
dataProvider: l?.dataProvider,
|
|
1302
|
+
storageProvider: l?.storageProvider ?? null,
|
|
1303
|
+
proxyFetch: d
|
|
1304
|
+
}, n);
|
|
1305
|
+
g((e) => new Set(e).add(i)), a?.(i), f?.id && c.commitEntityChat(e.id, f.id, r, l?.id, n, Ze(e, n));
|
|
1306
|
+
} catch (e) {
|
|
1307
|
+
v(e instanceof Error ? e.message : String(e));
|
|
1308
|
+
} finally {
|
|
1309
|
+
p(null);
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
return /* @__PURE__ */ D("div", {
|
|
1313
|
+
className: "space-y-2",
|
|
1314
|
+
children: [
|
|
1315
|
+
/* @__PURE__ */ E("p", {
|
|
1316
|
+
className: "text-xs font-medium text-muted-foreground",
|
|
1317
|
+
children: s.destinationPickerTitle
|
|
1318
|
+
}),
|
|
1319
|
+
/* @__PURE__ */ E("div", {
|
|
1320
|
+
className: "flex flex-wrap gap-2",
|
|
1321
|
+
children: x.map((e) => /* @__PURE__ */ E("button", {
|
|
1322
|
+
type: "button",
|
|
1323
|
+
disabled: f !== null,
|
|
1324
|
+
onClick: () => void S(e.id),
|
|
1325
|
+
className: "cursor-pointer rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:cursor-not-allowed disabled:opacity-60",
|
|
1326
|
+
children: f === e.id ? s.destinationApplying : `${m.has(e.id) ? "✓ " : ""}${e.id === "json-export" ? s.exportJson : e.label}`
|
|
1327
|
+
}, e.id))
|
|
1328
|
+
}),
|
|
1329
|
+
_ && /* @__PURE__ */ E("p", {
|
|
1330
|
+
className: "text-xs text-destructive",
|
|
1331
|
+
children: _
|
|
1332
|
+
})
|
|
1333
|
+
]
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
//#endregion
|
|
1337
|
+
//#region src/presentation/reports/subagentReportRegistry.tsx
|
|
1338
|
+
var $e = {};
|
|
1339
|
+
function et(e) {
|
|
1340
|
+
Object.assign($e, e);
|
|
1341
|
+
}
|
|
1342
|
+
function tt(e) {
|
|
1343
|
+
return $e[e];
|
|
1344
|
+
}
|
|
1345
|
+
//#endregion
|
|
1346
|
+
//#region src/presentation/reports/GenericResultPreview.tsx
|
|
1347
|
+
function nt({ result: e }) {
|
|
1348
|
+
let [t, n] = w(!1);
|
|
1349
|
+
return /* @__PURE__ */ D("div", {
|
|
1350
|
+
className: `relative cursor-pointer rounded-md border border-border/60 ${t ? "max-h-80 overflow-y-auto" : "max-h-28 overflow-hidden"}`,
|
|
1351
|
+
onClick: () => n((e) => !e),
|
|
1352
|
+
title: t ? "Clic per comprimere" : "Clic per espandere",
|
|
1353
|
+
children: [/* @__PURE__ */ E(i, {
|
|
1354
|
+
language: "json",
|
|
1355
|
+
showCopy: t,
|
|
1356
|
+
background: "transparent",
|
|
1357
|
+
className: "!text-[11px]",
|
|
1358
|
+
children: JSON.stringify(e, null, 2)
|
|
1359
|
+
}), !t && /* @__PURE__ */ E("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-muted/30 to-transparent" })]
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/presentation/liveAnchorDestination.ts
|
|
1364
|
+
function rt(e, t, n) {
|
|
1365
|
+
return e.length === 0 ? null : {
|
|
1366
|
+
id: "live-component",
|
|
1367
|
+
label: "Applica al componente aperto",
|
|
1368
|
+
async apply(r) {
|
|
1369
|
+
e.forEach((e) => e.onResult?.(r, t, n));
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region src/presentation/SubagentRunner.tsx
|
|
1375
|
+
function it({ manifest: e, params: t, extraDestinations: n, precedingActivity: r, taskId: i, resumeSeed: a, model: o }) {
|
|
1376
|
+
let s = Ke(e.definition, { defaultEnabled: !0 }), c = $(), l = c.scope, u = h(), d = C(i ?? `subagent-${e.id}-${crypto.randomUUID()}`).current, [f, p] = w(null), [m, g] = w([]), [_, v] = w(null), y = tt(e.id), x = y?.kind === "selection" ? y : null, [O, k] = w(null), A = C(!1), j = C(0), M = C(null);
|
|
1377
|
+
f && f !== M.current && (M.current = f, j.current = (r?.length ?? 0) + s.activity.length);
|
|
1378
|
+
let N = C(!1), P = !s.hasProviders || s.selectedModel !== "";
|
|
1379
|
+
b(() => {
|
|
1380
|
+
!A.current && P && (A.current = !0, a ? s.resume(e.toParams(t), a) : (o && s.setSelectedModel(o), s.run(e.toParams(t), { model: o }).then((e) => {
|
|
1381
|
+
e && p(e);
|
|
1382
|
+
})));
|
|
1383
|
+
}, [P]), b(() => {
|
|
1384
|
+
if (!f || !l) return;
|
|
1385
|
+
let n = e.autoApplyDestinationIds ?? [], r = c.componentAnchors.find((t) => t.subagentId === e.id && t.pinnedEntityId)?.pinnedEntityId, i = J();
|
|
1386
|
+
n.forEach((n) => {
|
|
1387
|
+
let a = i[n];
|
|
1388
|
+
a && (v(null), a.apply(f, {
|
|
1389
|
+
scopeId: l.id,
|
|
1390
|
+
dataProvider: l.dataProvider,
|
|
1391
|
+
storageProvider: l.storageProvider,
|
|
1392
|
+
proxyFetch: u
|
|
1393
|
+
}, {
|
|
1394
|
+
...t,
|
|
1395
|
+
pinnedEntityId: r
|
|
1396
|
+
}).then((n) => {
|
|
1397
|
+
n?.id && c.commitEntityChat(e.id, n.id, d, l.id, t, Ze(e, t));
|
|
1398
|
+
}).catch((e) => v(e instanceof Error ? e.message : String(e))));
|
|
1399
|
+
});
|
|
1400
|
+
}, [
|
|
1401
|
+
f,
|
|
1402
|
+
s.activity,
|
|
1403
|
+
l
|
|
1404
|
+
]), b(() => {
|
|
1405
|
+
f && x && k(x.defaultSelection(f));
|
|
1406
|
+
}, [f, x]);
|
|
1407
|
+
let F = (e, t) => {
|
|
1408
|
+
k((n) => n && {
|
|
1409
|
+
...n,
|
|
1410
|
+
[e]: t
|
|
1411
|
+
});
|
|
1412
|
+
}, I = (e) => p(e), L = S(() => f && x && O ? x.applySelection(f, O) : f, [
|
|
1413
|
+
f,
|
|
1414
|
+
x,
|
|
1415
|
+
O
|
|
1416
|
+
]), R = S(() => c.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [c.componentAnchors, e.id]), z = S(() => rt(R, t, d), [
|
|
1417
|
+
R,
|
|
1418
|
+
t,
|
|
1419
|
+
d
|
|
1420
|
+
]), B = S(() => z ? [z, ...n ?? []] : n, [z, n]), V = (e) => {
|
|
1421
|
+
g((t) => t.includes(e) ? t : [...t, e]);
|
|
1422
|
+
};
|
|
1423
|
+
return b(() => {
|
|
1424
|
+
N.current || c.openTask({
|
|
1425
|
+
id: d,
|
|
1426
|
+
title: Ze(e, t),
|
|
1427
|
+
icon: e.icon,
|
|
1428
|
+
agent: s,
|
|
1429
|
+
onApplied: (e) => p(e),
|
|
1430
|
+
precedingActivity: r,
|
|
1431
|
+
panelExtraAnchorIndex: j.current,
|
|
1432
|
+
onDismiss: () => {
|
|
1433
|
+
N.current = !0, s.running && s.stop(), c.closeTask(d);
|
|
1434
|
+
},
|
|
1435
|
+
panelExtra: f ? /* @__PURE__ */ D(T, { children: [
|
|
1436
|
+
x && O ? /* @__PURE__ */ E(x.Report, {
|
|
1437
|
+
result: f,
|
|
1438
|
+
selection: O,
|
|
1439
|
+
onChange: F
|
|
1440
|
+
}) : y?.kind === "editable" ? /* @__PURE__ */ E(y.Report, {
|
|
1441
|
+
result: f,
|
|
1442
|
+
onResultChange: I
|
|
1443
|
+
}) : /* @__PURE__ */ E(nt, { result: L }),
|
|
1444
|
+
_ && /* @__PURE__ */ D("p", {
|
|
1445
|
+
className: "text-xs text-destructive",
|
|
1446
|
+
children: ["Salvataggio automatico non riuscito: ", _]
|
|
1447
|
+
}),
|
|
1448
|
+
/* @__PURE__ */ E(Qe, {
|
|
1449
|
+
manifest: e,
|
|
1450
|
+
result: L,
|
|
1451
|
+
meta: t,
|
|
1452
|
+
taskId: d,
|
|
1453
|
+
initiallyApplied: m,
|
|
1454
|
+
onApplied: V,
|
|
1455
|
+
extraDestinations: B
|
|
1456
|
+
})
|
|
1457
|
+
] }) : void 0
|
|
1458
|
+
});
|
|
1459
|
+
}, [
|
|
1460
|
+
s.activity,
|
|
1461
|
+
s.running,
|
|
1462
|
+
s.error,
|
|
1463
|
+
s.canContinue,
|
|
1464
|
+
s.selectedModel,
|
|
1465
|
+
s.modelsByProvider,
|
|
1466
|
+
s.hasProviders,
|
|
1467
|
+
c.openTask,
|
|
1468
|
+
c.componentAnchors,
|
|
1469
|
+
d,
|
|
1470
|
+
e,
|
|
1471
|
+
t,
|
|
1472
|
+
f,
|
|
1473
|
+
L,
|
|
1474
|
+
O,
|
|
1475
|
+
m,
|
|
1476
|
+
n,
|
|
1477
|
+
r,
|
|
1478
|
+
_
|
|
1479
|
+
]), b(() => () => {
|
|
1480
|
+
c.closeTask(d);
|
|
1481
|
+
}, [c.closeTask, d]), null;
|
|
1482
|
+
}
|
|
1483
|
+
//#endregion
|
|
1484
|
+
//#region src/presentation/OrchestratorRunner.tsx
|
|
1485
|
+
function at({ userGoal: e }) {
|
|
1486
|
+
let t = Z(), n = Ke(S(() => Xe({
|
|
1487
|
+
unavailable: t.orchestratorUnavailable,
|
|
1488
|
+
continueWithoutAi: t.orchestratorContinueWithoutAi,
|
|
1489
|
+
preparing: t.orchestratorPreparing,
|
|
1490
|
+
collecting: t.orchestratorCollecting
|
|
1491
|
+
}), []), { defaultEnabled: !0 }), r = $(), [i, a] = w(null), o = C(!1), s = !n.hasProviders || n.selectedModel !== "", c = C(r.pendingExtraDestinations), l = C(r.pendingAttachments), u = C(r.pendingModel), d = C(r.pendingScopedSubagentId ?? r.scopedSubagentId ?? void 0), f = C(r.pendingCarryOver), p = C(!1), m = (e) => {
|
|
1492
|
+
e && typeof e == "object" && e.kind === "handoff" && (a(e), r.closeTask(Q));
|
|
1493
|
+
};
|
|
1494
|
+
b(() => {
|
|
1495
|
+
!o.current && s && (o.current = !0, u.current && n.setSelectedModel(u.current), n.run({
|
|
1496
|
+
userGoal: e,
|
|
1497
|
+
pageContext: r.pageContext,
|
|
1498
|
+
scopedSubagentId: d.current ?? null
|
|
1499
|
+
}, {
|
|
1500
|
+
attachments: l.current,
|
|
1501
|
+
model: u.current,
|
|
1502
|
+
openingMessage: e
|
|
1503
|
+
}).then((e) => {
|
|
1504
|
+
e && m(e);
|
|
1505
|
+
}));
|
|
1506
|
+
}, [s]), b(() => {
|
|
1507
|
+
p.current || r.openTask({
|
|
1508
|
+
id: Q,
|
|
1509
|
+
title: "Agentico",
|
|
1510
|
+
icon: "bot",
|
|
1511
|
+
agent: n,
|
|
1512
|
+
onApplied: m,
|
|
1513
|
+
scopedSubagentId: d.current,
|
|
1514
|
+
precedingActivity: f.current?.activity,
|
|
1515
|
+
onDismiss: () => {
|
|
1516
|
+
p.current = !0, n.running && n.stop(), r.closeTask(Q);
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
}, [
|
|
1520
|
+
n.activity,
|
|
1521
|
+
n.running,
|
|
1522
|
+
n.error,
|
|
1523
|
+
n.canContinue,
|
|
1524
|
+
n.selectedModel,
|
|
1525
|
+
n.modelsByProvider,
|
|
1526
|
+
n.hasProviders,
|
|
1527
|
+
r.openTask
|
|
1528
|
+
]), b(() => () => {
|
|
1529
|
+
r.closeTask(Q);
|
|
1530
|
+
}, [r.closeTask]);
|
|
1531
|
+
let h = S(() => [...f.current?.activity ?? [], ...n.activity], [n.activity]);
|
|
1532
|
+
if (!i) return null;
|
|
1533
|
+
let g = M(i.subagentId);
|
|
1534
|
+
return g ? /* @__PURE__ */ E(it, {
|
|
1535
|
+
manifest: g,
|
|
1536
|
+
params: i.params,
|
|
1537
|
+
extraDestinations: c.current,
|
|
1538
|
+
model: u.current || void 0,
|
|
1539
|
+
taskId: f.current?.taskId,
|
|
1540
|
+
precedingActivity: h
|
|
1541
|
+
}) : null;
|
|
1542
|
+
}
|
|
1543
|
+
//#endregion
|
|
1544
|
+
//#region src/presentation/ManualEntryRunner.tsx
|
|
1545
|
+
function ot({ manifest: e, extraDestinations: n }) {
|
|
1546
|
+
let r = Ke(e.definition, { defaultEnabled: !1 }), i = Z(), a = $(), o = C(`manual-${e.id}-${crypto.randomUUID()}`).current, [s, c] = w(null), [l, u] = w([]), d = tt(e.id), f = d?.kind === "selection" ? d : null, [p, m] = w(null), [h, g] = w(null), _ = C(!1), v = (t) => {
|
|
1547
|
+
if (!e.manualEntry) return;
|
|
1548
|
+
let n;
|
|
1549
|
+
try {
|
|
1550
|
+
n = e.manualEntry.fromRawText(t);
|
|
1551
|
+
} catch (e) {
|
|
1552
|
+
console.error("[ManualEntryRunner] manualEntry.fromRawText ha rifiutato il testo:", e);
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
g(n), u([]), r.run(n, { openingMessage: t }).then((e) => {
|
|
1556
|
+
e && c(e);
|
|
1557
|
+
});
|
|
1558
|
+
};
|
|
1559
|
+
b(() => {
|
|
1560
|
+
s && f && m(f.defaultSelection(s));
|
|
1561
|
+
}, [s, f]);
|
|
1562
|
+
let y = (e, t) => {
|
|
1563
|
+
m((n) => n && {
|
|
1564
|
+
...n,
|
|
1565
|
+
[e]: t
|
|
1566
|
+
});
|
|
1567
|
+
}, x = (e) => c(e), T = S(() => s && f && p ? f.applySelection(s, p) : s, [
|
|
1568
|
+
s,
|
|
1569
|
+
f,
|
|
1570
|
+
p
|
|
1571
|
+
]), O = (e) => {
|
|
1572
|
+
u((t) => t.includes(e) ? t : [...t, e]);
|
|
1573
|
+
}, k = S(() => a.componentAnchors.filter((t) => t.subagentId === e.id && t.onResult), [a.componentAnchors, e.id]), A = S(() => h ? rt(k, h, o) : null, [
|
|
1574
|
+
k,
|
|
1575
|
+
h,
|
|
1576
|
+
o
|
|
1577
|
+
]), j = S(() => A ? [A, ...n ?? []] : n, [A, n]);
|
|
1578
|
+
return b(() => {
|
|
1579
|
+
_.current || a.openTask({
|
|
1580
|
+
id: o,
|
|
1581
|
+
title: e.label,
|
|
1582
|
+
icon: e.icon,
|
|
1583
|
+
agent: r,
|
|
1584
|
+
onApplied: (e) => c(e),
|
|
1585
|
+
manualEntry: e.manualEntry ? {
|
|
1586
|
+
prompt: e.manualEntry.prompt,
|
|
1587
|
+
onSubmit: v
|
|
1588
|
+
} : void 0,
|
|
1589
|
+
onDismiss: () => {
|
|
1590
|
+
_.current = !0, r.running && r.stop(), a.closeTask(o);
|
|
1591
|
+
},
|
|
1592
|
+
panelExtra: s ? /* @__PURE__ */ D("div", {
|
|
1593
|
+
className: "space-y-2",
|
|
1594
|
+
children: [
|
|
1595
|
+
f && p ? /* @__PURE__ */ E(f.Report, {
|
|
1596
|
+
result: s,
|
|
1597
|
+
selection: p,
|
|
1598
|
+
onChange: y
|
|
1599
|
+
}) : d?.kind === "editable" ? /* @__PURE__ */ E(d.Report, {
|
|
1600
|
+
result: s,
|
|
1601
|
+
onResultChange: x
|
|
1602
|
+
}) : /* @__PURE__ */ E(nt, { result: T }),
|
|
1603
|
+
/* @__PURE__ */ E(Qe, {
|
|
1604
|
+
manifest: e,
|
|
1605
|
+
result: T,
|
|
1606
|
+
meta: h ?? {},
|
|
1607
|
+
taskId: o,
|
|
1608
|
+
initiallyApplied: l,
|
|
1609
|
+
onApplied: O,
|
|
1610
|
+
extraDestinations: j
|
|
1611
|
+
}),
|
|
1612
|
+
r.hasProviders && /* @__PURE__ */ E(t, {
|
|
1613
|
+
label: i.resumeWithAi,
|
|
1614
|
+
variant: "outline-secondary",
|
|
1615
|
+
className: "text-xs",
|
|
1616
|
+
onClick: () => {
|
|
1617
|
+
h && a.resumeWithAI(e.id, h, n);
|
|
1618
|
+
}
|
|
1619
|
+
})
|
|
1620
|
+
]
|
|
1621
|
+
}) : void 0
|
|
1622
|
+
});
|
|
1623
|
+
}, [
|
|
1624
|
+
r.activity,
|
|
1625
|
+
r.running,
|
|
1626
|
+
r.error,
|
|
1627
|
+
r.hasProviders,
|
|
1628
|
+
a.componentAnchors,
|
|
1629
|
+
s,
|
|
1630
|
+
T,
|
|
1631
|
+
p,
|
|
1632
|
+
l,
|
|
1633
|
+
h
|
|
1634
|
+
]), b(() => () => {
|
|
1635
|
+
a.closeTask(o);
|
|
1636
|
+
}, []), null;
|
|
1637
|
+
}
|
|
1638
|
+
//#endregion
|
|
1639
|
+
//#region src/presentation/Agentico.tsx
|
|
1640
|
+
var st = 420;
|
|
1641
|
+
function ct(e) {
|
|
1642
|
+
return Object.values(e).flat().map((e) => ({
|
|
1643
|
+
label: e.model,
|
|
1644
|
+
value: e.id,
|
|
1645
|
+
pricing: e.pricing ?? null,
|
|
1646
|
+
group: e.providerLabel ?? e.provider
|
|
1647
|
+
}));
|
|
1648
|
+
}
|
|
1649
|
+
function lt({ task: e }) {
|
|
1650
|
+
let t = Z(), [n, i] = w(""), { agent: a, onApplied: o, manualEntry: s } = e, c = a.running, l = (e) => {
|
|
1651
|
+
if (i(""), s) {
|
|
1652
|
+
s.onSubmit(e.text);
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
a.sendMessage(e.text, {
|
|
1656
|
+
attachments: e.files,
|
|
1657
|
+
model: e.model
|
|
1658
|
+
}).then((e) => {
|
|
1659
|
+
e && o(e);
|
|
1660
|
+
});
|
|
1661
|
+
}, u = !s && a.hasProviders && !a.selectedModel;
|
|
1662
|
+
return /* @__PURE__ */ E(r, {
|
|
1663
|
+
value: n,
|
|
1664
|
+
onChange: i,
|
|
1665
|
+
placeholder: s?.prompt ?? t.messagePlaceholder,
|
|
1666
|
+
running: c,
|
|
1667
|
+
onStop: a.stop,
|
|
1668
|
+
disabled: !n.trim() || u,
|
|
1669
|
+
onSubmit: l,
|
|
1670
|
+
attachments: !s,
|
|
1671
|
+
models: s ? [] : ct(a.modelsByProvider),
|
|
1672
|
+
selectedModel: s ? "" : a.selectedModel,
|
|
1673
|
+
onModelChange: a.setSelectedModel,
|
|
1674
|
+
modelPlaceholder: t.selectModelPlaceholder,
|
|
1675
|
+
minHeight: 44,
|
|
1676
|
+
maxHeight: 220
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
function ut() {
|
|
1680
|
+
let { startOrchestrator: e } = $(), t = Z(), [n, i] = w(""), { hasProviders: a, modelsByProvider: o, selectedModel: s, setSelectedModel: c } = He(), l = (t) => {
|
|
1681
|
+
t.text.trim() && (e(t.text.trim(), {
|
|
1682
|
+
attachments: t.files.length > 0 ? t.files : void 0,
|
|
1683
|
+
model: t.model || void 0
|
|
1684
|
+
}), i(""));
|
|
1685
|
+
}, u = a && !s;
|
|
1686
|
+
return /* @__PURE__ */ E(r, {
|
|
1687
|
+
value: n,
|
|
1688
|
+
onChange: i,
|
|
1689
|
+
placeholder: t.orchestratorStarterPlaceholder,
|
|
1690
|
+
disabled: !n.trim() || u,
|
|
1691
|
+
onSubmit: l,
|
|
1692
|
+
attachments: !0,
|
|
1693
|
+
models: ct(o),
|
|
1694
|
+
selectedModel: s,
|
|
1695
|
+
onModelChange: c,
|
|
1696
|
+
modelPlaceholder: t.selectModelPlaceholder,
|
|
1697
|
+
minHeight: 44,
|
|
1698
|
+
maxHeight: 220
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
function dt({ card: e }) {
|
|
1702
|
+
let t = Z();
|
|
1703
|
+
return e.humanSummaryOnly ? /* @__PURE__ */ D("div", {
|
|
1704
|
+
className: "space-y-2 rounded-lg border border-border/60 p-3",
|
|
1705
|
+
children: [/* @__PURE__ */ D("p", {
|
|
1706
|
+
className: "text-xs font-medium text-foreground",
|
|
1707
|
+
children: [
|
|
1708
|
+
"\"",
|
|
1709
|
+
e.label,
|
|
1710
|
+
"\""
|
|
1711
|
+
]
|
|
1712
|
+
}), /* @__PURE__ */ E("p", {
|
|
1713
|
+
className: "text-xs text-muted-foreground",
|
|
1714
|
+
children: e.humanSummary
|
|
1715
|
+
})]
|
|
1716
|
+
}) : /* @__PURE__ */ D("div", {
|
|
1717
|
+
className: "space-y-2 rounded-lg border border-border/60 p-3",
|
|
1718
|
+
children: [
|
|
1719
|
+
/* @__PURE__ */ E("p", {
|
|
1720
|
+
className: "text-xs font-medium text-foreground",
|
|
1721
|
+
children: u(t.newInstance, { label: e.label })
|
|
1722
|
+
}),
|
|
1723
|
+
/* @__PURE__ */ E("p", {
|
|
1724
|
+
className: "text-xs text-muted-foreground",
|
|
1725
|
+
children: e.humanSummary
|
|
1726
|
+
}),
|
|
1727
|
+
e.fields.length > 0 && /* @__PURE__ */ E("ul", {
|
|
1728
|
+
className: "space-y-1",
|
|
1729
|
+
children: e.fields.map((e) => /* @__PURE__ */ D("li", {
|
|
1730
|
+
className: "flex items-start gap-1.5 text-xs",
|
|
1731
|
+
children: [/* @__PURE__ */ E(n, {
|
|
1732
|
+
variant: e.required ? "primary" : "secondary",
|
|
1733
|
+
className: "mt-px shrink-0",
|
|
1734
|
+
children: e.required ? "richiesto" : "opzionale"
|
|
1735
|
+
}), /* @__PURE__ */ D("span", {
|
|
1736
|
+
className: "min-w-0",
|
|
1737
|
+
children: [/* @__PURE__ */ E("span", {
|
|
1738
|
+
className: "font-mono text-foreground",
|
|
1739
|
+
children: e.key
|
|
1740
|
+
}), e.humanDescription ? /* @__PURE__ */ D("span", {
|
|
1741
|
+
className: "text-muted-foreground",
|
|
1742
|
+
children: [" — ", e.humanDescription]
|
|
1743
|
+
}) : null]
|
|
1744
|
+
})]
|
|
1745
|
+
}, e.key))
|
|
1746
|
+
}),
|
|
1747
|
+
e.example && /* @__PURE__ */ D("p", {
|
|
1748
|
+
className: "text-xs text-muted-foreground",
|
|
1749
|
+
children: ["Esempio: ", /* @__PURE__ */ E("span", {
|
|
1750
|
+
className: "font-mono",
|
|
1751
|
+
children: e.example
|
|
1752
|
+
})]
|
|
1753
|
+
})
|
|
1754
|
+
]
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
function ft({ messages: e }) {
|
|
1758
|
+
return /* @__PURE__ */ E("div", {
|
|
1759
|
+
className: "space-y-2 rounded-lg border border-border/60 p-3",
|
|
1760
|
+
children: e.map((e, t) => /* @__PURE__ */ E("p", {
|
|
1761
|
+
className: "text-xs text-muted-foreground",
|
|
1762
|
+
children: e
|
|
1763
|
+
}, t))
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
function pt({ scopeId: e, open: n, onOpenChange: r, onSelect: i, onNewChat: c }) {
|
|
1767
|
+
let l = Z(), [u, d] = w(""), f = S(() => n ? ye(e) : [], [e, n]), p = S(() => {
|
|
1768
|
+
let e = u.trim().toLowerCase();
|
|
1769
|
+
return e ? f.filter((t) => {
|
|
1770
|
+
let n = M(t.subagentId)?.label ?? t.subagentId;
|
|
1771
|
+
return t.title.toLowerCase().includes(e) || n.toLowerCase().includes(e);
|
|
1772
|
+
}) : f;
|
|
1773
|
+
}, [f, u]);
|
|
1774
|
+
return /* @__PURE__ */ E(a, {
|
|
1775
|
+
trigger: {
|
|
1776
|
+
icon: "history",
|
|
1777
|
+
title: l.chatHistory
|
|
1778
|
+
},
|
|
1779
|
+
triggerClassName: "!h-9 !w-9 !p-0 rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
1780
|
+
open: n,
|
|
1781
|
+
onOpenChange: r,
|
|
1782
|
+
position: "end",
|
|
1783
|
+
strategy: "absolute",
|
|
1784
|
+
menuClassName: "w-[380px] max-h-[70vh] overflow-y-auto",
|
|
1785
|
+
header: /* @__PURE__ */ D("div", {
|
|
1786
|
+
className: "flex items-center gap-2 px-1 pb-1.5",
|
|
1787
|
+
children: [
|
|
1788
|
+
/* @__PURE__ */ E(s, {
|
|
1789
|
+
name: "search",
|
|
1790
|
+
size: 14,
|
|
1791
|
+
className: "shrink-0 text-muted-foreground"
|
|
1792
|
+
}),
|
|
1793
|
+
/* @__PURE__ */ E("input", {
|
|
1794
|
+
autoFocus: !0,
|
|
1795
|
+
value: u,
|
|
1796
|
+
onChange: (e) => d(e.target.value),
|
|
1797
|
+
placeholder: l.searchChats,
|
|
1798
|
+
className: "min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
1799
|
+
}),
|
|
1800
|
+
/* @__PURE__ */ E(t, {
|
|
1801
|
+
icon: "square-pen",
|
|
1802
|
+
ariaLabel: l.newChat,
|
|
1803
|
+
title: l.newChat,
|
|
1804
|
+
variant: "link",
|
|
1805
|
+
className: "shrink-0",
|
|
1806
|
+
onClick: c
|
|
1807
|
+
})
|
|
1808
|
+
]
|
|
1809
|
+
}),
|
|
1810
|
+
children: p.length === 0 ? /* @__PURE__ */ E("p", {
|
|
1811
|
+
className: "px-2 py-3 text-center text-xs text-muted-foreground",
|
|
1812
|
+
children: f.length === 0 ? l.noSavedChats : l.noResults
|
|
1813
|
+
}) : p.map((e) => {
|
|
1814
|
+
let t = M(e.subagentId);
|
|
1815
|
+
return /* @__PURE__ */ E(o, {
|
|
1816
|
+
icon: t?.icon ?? "bot",
|
|
1817
|
+
onClick: () => i(e.subagentId, e.entityId, e),
|
|
1818
|
+
children: /* @__PURE__ */ D("span", {
|
|
1819
|
+
className: "flex min-w-0 flex-1 items-center justify-between gap-2",
|
|
1820
|
+
children: [/* @__PURE__ */ D("span", {
|
|
1821
|
+
className: "min-w-0 truncate",
|
|
1822
|
+
children: [
|
|
1823
|
+
/* @__PURE__ */ E("span", {
|
|
1824
|
+
className: "text-muted-foreground",
|
|
1825
|
+
children: t?.label ?? e.subagentId
|
|
1826
|
+
}),
|
|
1827
|
+
" · ",
|
|
1828
|
+
e.title || e.entityId
|
|
1829
|
+
]
|
|
1830
|
+
}), /* @__PURE__ */ E("span", {
|
|
1831
|
+
className: "shrink-0 text-xs text-muted-foreground",
|
|
1832
|
+
children: new Date(e.savedAt).toLocaleString()
|
|
1833
|
+
})]
|
|
1834
|
+
})
|
|
1835
|
+
}, `${e.subagentId}:${e.entityId}`);
|
|
1836
|
+
})
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
function mt() {
|
|
1840
|
+
let { task: e, isOpen: n, pendingGoal: r, orchestratorRunId: i, pageContext: a, pageContextCard: o, anchoredUserMessages: s, pendingResume: c, resumeRunId: l, dismissForeignTask: u, resumeEntityChat: d, pendingManualEntry: f, manualEntryRunId: p, startManualEntry: m, pendingExtraDestinations: h, pendingResumeWithAI: g, resumeWithAIRunId: _, scope: v } = $(), y = Z(), x = C(null), [S, O] = w(!1), k = () => {
|
|
1841
|
+
(!e || e.agent.running || e.savedToDisk || window.confirm(y.unsavedConversationConfirm)) && (u(), O(!1));
|
|
1842
|
+
}, A = e ? [...e.precedingActivity ?? [], ...e.agent.activity] : [], j = A.length, N = Math.max(0, Math.min(e?.panelExtraAnchorIndex ?? j, j)), P = A.slice(0, N), F = A.slice(N), I = !!(e && !e.agent.running && e.agent.error), L = e?.id === "agentico-orchestrator" && e.scopedSubagentId ? M(e.scopedSubagentId) : void 0, R = L?.manualEntry ? L : null, z = C(!0);
|
|
1843
|
+
b(() => {
|
|
1844
|
+
let e = x.current;
|
|
1845
|
+
if (!e) return;
|
|
1846
|
+
let t = () => {
|
|
1847
|
+
z.current = e.scrollHeight - e.scrollTop - e.clientHeight < 80;
|
|
1848
|
+
};
|
|
1849
|
+
return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
|
|
1850
|
+
}, [e?.id]), b(() => {
|
|
1851
|
+
let e = x.current;
|
|
1852
|
+
e && (z.current = !0, e.scrollTop = e.scrollHeight);
|
|
1853
|
+
}, [e?.id]), b(() => {
|
|
1854
|
+
let e = x.current;
|
|
1855
|
+
e && z.current && (e.scrollTop = e.scrollHeight);
|
|
1856
|
+
}, [j, I]);
|
|
1857
|
+
let B = r ? /* @__PURE__ */ E(at, { userGoal: r }, i) : null, V = c ? M(c.subagentId) : void 0, ee = c && V ? /* @__PURE__ */ E(it, {
|
|
1858
|
+
manifest: V,
|
|
1859
|
+
params: c.snapshot.params,
|
|
1860
|
+
taskId: `entitychat-${c.subagentId}-${c.entityId}`,
|
|
1861
|
+
resumeSeed: {
|
|
1862
|
+
history: c.snapshot.history,
|
|
1863
|
+
activity: c.snapshot.activity
|
|
1864
|
+
}
|
|
1865
|
+
}, l) : null, H = f ? M(f.subagentId) : void 0, te = f && H ? /* @__PURE__ */ E(ot, {
|
|
1866
|
+
manifest: H,
|
|
1867
|
+
extraDestinations: f.extraDestinations
|
|
1868
|
+
}, p) : null, ne = g ? M(g.subagentId) : void 0, U = g && ne ? /* @__PURE__ */ E(it, {
|
|
1869
|
+
manifest: ne,
|
|
1870
|
+
params: g.params,
|
|
1871
|
+
extraDestinations: g.extraDestinations
|
|
1872
|
+
}, _) : null;
|
|
1873
|
+
return n ? /* @__PURE__ */ D(T, { children: [
|
|
1874
|
+
B,
|
|
1875
|
+
ee,
|
|
1876
|
+
te,
|
|
1877
|
+
U,
|
|
1878
|
+
/* @__PURE__ */ D("div", {
|
|
1879
|
+
style: { width: 420 },
|
|
1880
|
+
className: "relative flex h-full shrink-0 flex-col border-l border-border bg-background",
|
|
1881
|
+
children: [
|
|
1882
|
+
/* @__PURE__ */ D("div", {
|
|
1883
|
+
className: "flex min-h-[60px] items-center gap-1 border-b border-border/60 px-4 py-3",
|
|
1884
|
+
children: [
|
|
1885
|
+
/* @__PURE__ */ E("span", {
|
|
1886
|
+
className: "min-w-0 flex-1 truncate text-lg font-semibold leading-tight",
|
|
1887
|
+
children: e ? e.title : "Agentico"
|
|
1888
|
+
}),
|
|
1889
|
+
v && /* @__PURE__ */ E(pt, {
|
|
1890
|
+
scopeId: v.id,
|
|
1891
|
+
open: S,
|
|
1892
|
+
onOpenChange: O,
|
|
1893
|
+
onNewChat: k,
|
|
1894
|
+
onSelect: (e, t, n) => d(e, t, n)
|
|
1895
|
+
}),
|
|
1896
|
+
/* @__PURE__ */ E(Re, {})
|
|
1897
|
+
]
|
|
1898
|
+
}),
|
|
1899
|
+
/* @__PURE__ */ E("div", {
|
|
1900
|
+
ref: x,
|
|
1901
|
+
className: "flex-1 overflow-y-auto px-3 pb-2",
|
|
1902
|
+
children: /* @__PURE__ */ E("div", {
|
|
1903
|
+
className: "pt-2",
|
|
1904
|
+
children: e ? /* @__PURE__ */ D(T, { children: [
|
|
1905
|
+
e.manualEntry && A.length === 0 && /* @__PURE__ */ E("p", {
|
|
1906
|
+
className: "text-xs text-muted-foreground",
|
|
1907
|
+
children: e.manualEntry.prompt
|
|
1908
|
+
}),
|
|
1909
|
+
/* @__PURE__ */ E(Le, { activity: P }),
|
|
1910
|
+
e.panelExtra && /* @__PURE__ */ E("div", {
|
|
1911
|
+
className: "mt-3",
|
|
1912
|
+
children: e.panelExtra
|
|
1913
|
+
}),
|
|
1914
|
+
F.length > 0 && /* @__PURE__ */ E(Le, { activity: F }),
|
|
1915
|
+
!e.agent.running && e.agent.error && /* @__PURE__ */ D("div", {
|
|
1916
|
+
className: "mt-2 flex items-center gap-2",
|
|
1917
|
+
children: [
|
|
1918
|
+
/* @__PURE__ */ E("p", {
|
|
1919
|
+
className: "flex-1 text-xs text-destructive",
|
|
1920
|
+
children: e.agent.error
|
|
1921
|
+
}),
|
|
1922
|
+
/* @__PURE__ */ E(t, {
|
|
1923
|
+
label: y.retry,
|
|
1924
|
+
variant: "secondary",
|
|
1925
|
+
className: "shrink-0",
|
|
1926
|
+
onClick: () => {
|
|
1927
|
+
e.agent.sendMessage(y.retryMessage).then((t) => {
|
|
1928
|
+
t && e.onApplied(t);
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
}),
|
|
1932
|
+
/* @__PURE__ */ E(t, {
|
|
1933
|
+
label: y.continueWithoutAi,
|
|
1934
|
+
variant: "secondary",
|
|
1935
|
+
className: "shrink-0",
|
|
1936
|
+
onClick: () => {
|
|
1937
|
+
if (R) {
|
|
1938
|
+
m(R.id, h);
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
let t = e.agent.runFallback();
|
|
1942
|
+
t && e.onApplied(t);
|
|
1943
|
+
}
|
|
1944
|
+
})
|
|
1945
|
+
]
|
|
1946
|
+
})
|
|
1947
|
+
] }) : s.length > 0 ? /* @__PURE__ */ E(ft, { messages: s }) : o ? /* @__PURE__ */ E(dt, { card: o }) : /* @__PURE__ */ E("p", {
|
|
1948
|
+
className: "text-xs text-muted-foreground",
|
|
1949
|
+
children: a ?? y.orchestratorStarterHint
|
|
1950
|
+
})
|
|
1951
|
+
})
|
|
1952
|
+
}),
|
|
1953
|
+
/* @__PURE__ */ E("div", {
|
|
1954
|
+
className: "border-t border-border/60 px-4 py-3",
|
|
1955
|
+
children: e ? /* @__PURE__ */ E(lt, { task: e }, e.id) : /* @__PURE__ */ E(ut, {})
|
|
1956
|
+
})
|
|
1957
|
+
]
|
|
1958
|
+
})
|
|
1959
|
+
] }) : /* @__PURE__ */ D(T, { children: [
|
|
1960
|
+
B,
|
|
1961
|
+
ee,
|
|
1962
|
+
te,
|
|
1963
|
+
U
|
|
1964
|
+
] });
|
|
1965
|
+
}
|
|
1966
|
+
//#endregion
|
|
1967
|
+
//#region src/presentation/useAgenticoPageContext.ts
|
|
1968
|
+
function ht(e, t) {
|
|
1969
|
+
let { setPageContext: n } = $(), r = C(crypto.randomUUID()).current;
|
|
1970
|
+
b(() => (n(r, e, t ?? null), () => n(r, null)), [e, t]);
|
|
1971
|
+
}
|
|
1972
|
+
//#endregion
|
|
1973
|
+
//#region src/presentation/useSubagentComponentContext.ts
|
|
1974
|
+
function gt(e, t, n, r, i = !0, a) {
|
|
1975
|
+
let { registerComponentAnchor: o } = $(), s = C(crypto.randomUUID()).current, c = C(n);
|
|
1976
|
+
c.current = n, b(() => {
|
|
1977
|
+
if (i) return o(s, {
|
|
1978
|
+
subagentId: e,
|
|
1979
|
+
componentKey: t,
|
|
1980
|
+
contextInfo: r,
|
|
1981
|
+
pinnedEntityId: a,
|
|
1982
|
+
onResult: (e, t, n) => c.current?.(e, t, n)
|
|
1983
|
+
}), () => o(s, null);
|
|
1984
|
+
}, [
|
|
1985
|
+
e,
|
|
1986
|
+
t,
|
|
1987
|
+
r,
|
|
1988
|
+
i,
|
|
1989
|
+
a
|
|
1990
|
+
]);
|
|
1991
|
+
}
|
|
1992
|
+
//#endregion
|
|
1993
|
+
export { st as AGENTICO_WIDTH, mt as Agentico, Te as AgenticoProvider, Re as AgenticoToggle, le as JSON_EXPORT_DESTINATION_ID, oe as MICRO_PROMPT_REGISTRY, Q as ORCHESTRATOR_TASK_ID, ae as SUMMARY_MICRO_PROMPT, be as agenticoDe, xe as agenticoEn, Se as agenticoIt, z as agenticoPromptsEn, B as agenticoPromptsIt, Ce as agenticoTranslations, G as applyMicroPrompts, ee as configureAgenticoPrompts, pe as configureEntityChatStore, F as createCrossAgentTools, O as defineSubagent, K as extractErrorMessage, se as extractJsonBlock, M as findSubagentManifest, H as getAgenticoPrompts, J as getDestinationRegistry, ge as getEntityChat, j as getSubagentRegistry, tt as getSubagentReport, q as jsonExportDestination, ye as listEntityChats, P as registerCrossAgentTools, de as registerDestinations, et as registerSubagentReports, A as registerSubagents, ve as removeEntityChat, ie as renderRegistryCli, re as renderSubagentCli, te as resetAgenticoPrompts, _e as saveEntityChat, I as toJsonSchema, L as toMcpTool, Ke as useAgent, $ as useAgentico, Z as useAgenticoI18n, ht as useAgenticoPageContext, gt as useSubagentComponentContext };
|
|
1994
|
+
|
|
1995
|
+
//# sourceMappingURL=index.mjs.map
|