@alisio/server 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/host/agents.d.ts +14 -0
- package/dist/host/agents.js +44 -0
- package/dist/host/sessions.js +6 -1
- package/dist/host/workspace-host.d.ts +2 -2
- package/dist/host/workspace-host.js +2 -2
- package/dist/index.js +2 -0
- package/dist/routes/agent-definitions.d.ts +3 -0
- package/dist/routes/agent-definitions.js +235 -0
- package/dist/routes/commands.js +12 -1
- package/dist/routes/management.js +32 -2
- package/dist/routes/sessions.js +3 -0
- package/dist/web/alisio-wordmark.png +0 -0
- package/dist/web/assets/AgentPicker-BzsxeGrb.js +1 -0
- package/dist/web/assets/AgentsModal-D1s3oppR.js +2 -0
- package/dist/web/assets/BtwPanel-CYNn71oh.js +1 -0
- package/dist/web/assets/SettingsModal-KnWaRNOw.js +1 -0
- package/dist/web/assets/{abnfDiagram-VCTEODGH-CdMLAOHV.js → abnfDiagram-VCTEODGH-CxVXrbZW.js} +1 -1
- package/dist/web/assets/agents-Dxr4qHaV.css +1 -0
- package/dist/web/assets/agents.module-sVh_Peep.js +2 -0
- package/dist/web/assets/architecture-7GRP2DOG-p4TPeJrY.js +1 -0
- package/dist/web/assets/{architectureDiagram-5GKGNRK7-TrGBbaos.js → architectureDiagram-5GKGNRK7-BD1FmL7L.js} +1 -1
- package/dist/web/assets/{blockDiagram-I7D4REHJ-B9scKXxk.js → blockDiagram-I7D4REHJ-BPqena70.js} +1 -1
- package/dist/web/assets/{c4Diagram-7LVT6UL2-z7xiy-E6.js → c4Diagram-7LVT6UL2-DYIeEZfH.js} +1 -1
- package/dist/web/assets/channel-CjpGwobl.js +1 -0
- package/dist/web/assets/{chunk-4HAMMTFA-Dq63FzYl.js → chunk-4HAMMTFA-B5M6pb5t.js} +1 -1
- package/dist/web/assets/{chunk-75Z2AOVW-BT6TREWr.js → chunk-75Z2AOVW-DWF2nQHG.js} +1 -1
- package/dist/web/assets/{chunk-DU6HZSFF-CiEf2R73.js → chunk-DU6HZSFF-ChH-oACD.js} +1 -1
- package/dist/web/assets/{chunk-F27PBJKO-BMFNI8ug.js → chunk-F27PBJKO-CL-aM0PB.js} +1 -1
- package/dist/web/assets/{chunk-GMAD6QVW-DqCLvsWp.js → chunk-GMAD6QVW-BwJnb03E.js} +1 -1
- package/dist/web/assets/{chunk-GVQU2GXP-C_5aAo2i.js → chunk-GVQU2GXP-BTIrRRX6.js} +1 -1
- package/dist/web/assets/{chunk-IMKFNOWR-Dbn935K4.js → chunk-IMKFNOWR-B7THW288.js} +1 -1
- package/dist/web/assets/{chunk-L3NEJ4N5-Ty0QAkpx.js → chunk-L3NEJ4N5-Dy1UkpNV.js} +1 -1
- package/dist/web/assets/{chunk-OSK3NFVY-CsCeITcp.js → chunk-OSK3NFVY-C-SR1-xh.js} +1 -1
- package/dist/web/assets/{chunk-P2QGCYS3-DNG4HLVr.js → chunk-P2QGCYS3-B-rSovsw.js} +1 -1
- package/dist/web/assets/{chunk-POPQ4Y6H-0q4O6Mg_.js → chunk-POPQ4Y6H-hzzEs6Bq.js} +1 -1
- package/dist/web/assets/{chunk-PWAF6VOD-BuLr7HUT.js → chunk-PWAF6VOD-DONieR7n.js} +1 -1
- package/dist/web/assets/{chunk-SHT3W25Y-D91olgB5.js → chunk-SHT3W25Y-V5mrMWL7.js} +1 -1
- package/dist/web/assets/{chunk-SVP7TREG-D0Fe6lPJ.js → chunk-SVP7TREG-Bbvu5LYe.js} +1 -1
- package/dist/web/assets/{chunk-TICWLB2K-BFK4nhdZ.js → chunk-TICWLB2K-C8oODMHb.js} +1 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-u4vOX55O.js +1 -0
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-u4vOX55O.js +1 -0
- package/dist/web/assets/{cynefin-OW5HDTMX-Dt-QubHU.js → cynefin-OW5HDTMX-DbRyQtRu.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-CQbunXV_.js → cynefinDiagram-5FMLGOSQ-DZZJkc1Z.js} +1 -1
- package/dist/web/assets/{dagre-GXQ25YYZ-C2huSTIT.js → dagre-GXQ25YYZ-OzSVamw_.js} +1 -1
- package/dist/web/assets/{diagram-S7CK7UJ4-BPxQOCma.js → diagram-S7CK7UJ4-tQhLHKYv.js} +1 -1
- package/dist/web/assets/{diagram-UQ7AKVKN-BaT6-3_2.js → diagram-UQ7AKVKN-C-a_VhG0.js} +1 -1
- package/dist/web/assets/{diagram-VSXAHHWV-D4Le0B2C.js → diagram-VSXAHHWV-mINhIbtj.js} +1 -1
- package/dist/web/assets/{diagram-VX7I27RA-Bz5GOxIV.js → diagram-VX7I27RA-DcgAY7Mz.js} +1 -1
- package/dist/web/assets/{diagram-Z3DM3KII-CfWsOBAr.js → diagram-Z3DM3KII-B3Nf4ZvN.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-PWID7BFC-xOzDedc9.js → ebnfDiagram-PWID7BFC-DR48pWlN.js} +1 -1
- package/dist/web/assets/{engine-CEuQoCXI.js → engine-DFDJxPdV.js} +4 -4
- package/dist/web/assets/{erDiagram-RLTQ6QDP-CKj_nwDd.js → erDiagram-RLTQ6QDP-BqV1uE8d.js} +1 -1
- package/dist/web/assets/eventmodeling-NTZA5JFV-BorMxd9K.js +1 -0
- package/dist/web/assets/flowDiagram-HODETNUW-tFfpz7LZ.js +1 -0
- package/dist/web/assets/{ganttDiagram-EL5Y4UJY-B5ZxKMT4.js → ganttDiagram-EL5Y4UJY-BIV4SOne.js} +1 -1
- package/dist/web/assets/{gitGraph-4MIJSDKK-D2LVxQeG.js → gitGraph-4MIJSDKK-CVBI_l9h.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-CbQwFqL8.js → gitGraphDiagram-WWUBYQGX-DE2kC2ER.js} +1 -1
- package/dist/web/assets/{highlight-D9sjt8IR.js → highlight-Bn8FNFbW.js} +1 -1
- package/dist/web/assets/icons-Bk2j3B6A.js +1 -0
- package/dist/web/assets/index-CpA8C_JP.js +75 -0
- package/dist/web/assets/index-Duk7lhBO.css +1 -0
- package/dist/web/assets/{info-A6RAGUB7-CQ7397S3.js → info-A6RAGUB7-DbP2NipJ.js} +1 -1
- package/dist/web/assets/{infoDiagram-27XIBGKW-D_x14CY5.js → infoDiagram-27XIBGKW-VfLAJyXS.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-5VMMS53U-Be9A-0jk.js → ishikawaDiagram-5VMMS53U-D7xy0hvG.js} +1 -1
- package/dist/web/assets/{journeyDiagram-3NMN7TZE-BDntpssh.js → journeyDiagram-3NMN7TZE-BJkBycQX.js} +1 -1
- package/dist/web/assets/jsxRuntime-BjUOR156.js +5 -0
- package/dist/web/assets/{kanban-definition-UXKFOSKX-C3ZudHlh.js → kanban-definition-UXKFOSKX-pWjlS-pC.js} +1 -1
- package/dist/web/assets/{line-DfPl0PMY.js → line-BEbqIaTh.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-CeAwXXwS.js → mermaid-parser.core-DPUySrN0.js} +3 -3
- package/dist/web/assets/{mindmap-definition-YA3MSWOX-CPleRcWx.js → mindmap-definition-YA3MSWOX-DQZdGOpx.js} +1 -1
- package/dist/web/assets/{packet-AYTQ26CC-D2-c2w3t.js → packet-AYTQ26CC-C3xSEik3.js} +1 -1
- package/dist/web/assets/{pegDiagram-XKGWAZYB-CiBY1ZrC.js → pegDiagram-XKGWAZYB-CrsF684j.js} +1 -1
- package/dist/web/assets/{pie-WAS4IAKB-DGFMJoB9.js → pie-WAS4IAKB-DVRAPnp6.js} +1 -1
- package/dist/web/assets/{pieDiagram-E7YTZNPT-C6ZkCC9N.js → pieDiagram-E7YTZNPT-xhfaHo_M.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-AXDQQJYC-C0x4zE01.js → quadrantDiagram-AXDQQJYC-BjWw9YVH.js} +1 -1
- package/dist/web/assets/{radar-RG4KPBEZ-BsOxoW46.js → radar-RG4KPBEZ-BLTeLwDz.js} +1 -1
- package/dist/web/assets/{railroad-74A4TZTK-Bl6qkJg4.js → railroad-74A4TZTK-DGnZU35U.js} +1 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-Cfc2fXmI.js +1 -0
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-RG9yBsVZ.js +1 -0
- package/dist/web/assets/railroad-peg-WCYAUIDC-BNYIOSCQ.js +1 -0
- package/dist/web/assets/{railroadDiagram-O6MQD6OU-BuDRyns0.js → railroadDiagram-O6MQD6OU-CRFXeOME.js} +1 -1
- package/dist/web/assets/{requirementDiagram-BXWQKSXE-CLHddmkL.js → requirementDiagram-BXWQKSXE-oYA-ZhmU.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-P5KCCOFB-Bu2j44Sd.js → sankeyDiagram-P5KCCOFB-BEMM-fXI.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-dLAv1SXf.js → sequenceDiagram-WJ2MYXX4-CXrXm28n.js} +1 -1
- package/dist/web/assets/shared-CWxbpk_V.js +1 -0
- package/dist/web/assets/shared-DuS6eVxB.css +1 -0
- package/dist/web/assets/{stateDiagram-D77RDMKH-hglm1COC.js → stateDiagram-D77RDMKH-BbNsTqXv.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-CF_Pgx29.js +1 -0
- package/dist/web/assets/{swimlanes-42K2YHIH-CuolXFnz.js → swimlanes-42K2YHIH-CmlW2nAw.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-BfFYrubl.js +8 -0
- package/dist/web/assets/{timeline-definition-24CTP7MA-CVIw1EFJ.js → timeline-definition-24CTP7MA-CLIttOSn.js} +1 -1
- package/dist/web/assets/{treeView-Q6P3EWNA-B0ccyLuL.js → treeView-Q6P3EWNA-une3l1XS.js} +1 -1
- package/dist/web/assets/{treemap-WGGIJYW6-Bna1wFOm.js → treemap-WGGIJYW6-DTdh8v3f.js} +1 -1
- package/dist/web/assets/{vennDiagram-4TSXK5OY-C2qIEY57.js → vennDiagram-4TSXK5OY-z3PyhMbc.js} +1 -1
- package/dist/web/assets/{view-D22qUktG.js → view-1uSkVze0.js} +1 -1
- package/dist/web/assets/{view-Dmp5kTro.js → view-B7htXuLx.js} +1 -1
- package/dist/web/assets/{view-z1ooWSpI.js → view-BSbFYmb4.js} +1 -1
- package/dist/web/assets/{view-DfT40o97.js → view-CxL6adpY.js} +1 -1
- package/dist/web/assets/view-DLqaThG2.js +2 -0
- package/dist/web/assets/{view-DDORgGz9.js → view-DM1l64CF.js} +1 -1
- package/dist/web/assets/{view-anQzARGQ.js → view-E_m1saqy.js} +1 -1
- package/dist/web/assets/{view-tnVQhJvk.js → view-d91KeJ92.js} +1 -1
- package/dist/web/assets/{wardley-WFR3VGLG-BnlHicEO.js → wardley-WFR3VGLG-CY_frLgq.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-VM6X3IG4-CvS371Sn.js → wardleyDiagram-VM6X3IG4-6C-eiJTi.js} +1 -1
- package/dist/web/assets/{xychartDiagram-S5SC5T6Z-BtiIGPaq.js → xychartDiagram-S5SC5T6Z-BdCfX5QT.js} +1 -1
- package/dist/web/index.html +4 -3
- package/package.json +3 -3
- package/dist/web/assets/BtwPanel--63O9vdA.js +0 -1
- package/dist/web/assets/SettingsModal-DVn3oS7R.js +0 -1
- package/dist/web/assets/SettingsModal-YCahs6O5.css +0 -1
- package/dist/web/assets/architecture-7GRP2DOG-C3fGtLhS.js +0 -1
- package/dist/web/assets/channel-DYfMc47Q.js +0 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-6YLbTMi6.js +0 -1
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-6YLbTMi6.js +0 -1
- package/dist/web/assets/eventmodeling-NTZA5JFV-Mmcou1v_.js +0 -1
- package/dist/web/assets/flowDiagram-HODETNUW-Cwx1Xg40.js +0 -1
- package/dist/web/assets/index-CIahmmHM.js +0 -75
- package/dist/web/assets/index-CzMyejZ6.css +0 -1
- package/dist/web/assets/jsxRuntime-BQ364qXp.js +0 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-rtYTPCC2.js +0 -1
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-CjTF5wRJ.js +0 -1
- package/dist/web/assets/railroad-peg-WCYAUIDC-BmGWzkMT.js +0 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-DqeWwnvu.js +0 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-BKudR2uU.js +0 -8
- package/dist/web/assets/view-BP2JkhDG.js +0 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activating an agent in an existing web session (`/agent:<id>` and the `/agents` picker). The
|
|
3
|
+
* agent id is stored in the session options; its instructions (and default reasoning effort)
|
|
4
|
+
* apply from the session's next run, never mid-run, so tool call ids and persisted turns stay
|
|
5
|
+
* consistent. Its declared model is applied only when it belongs to the session's provider
|
|
6
|
+
* (`runner.setModel`); otherwise the session keeps its model and the answer says so.
|
|
7
|
+
*/
|
|
8
|
+
import { type Session } from "@alisio/core";
|
|
9
|
+
import type { CommandOutcome } from "@alisio/sdk";
|
|
10
|
+
import type { OpenWorkspace } from "./workspace-host.ts";
|
|
11
|
+
export declare function activateSessionAgent(opened: OpenWorkspace, session: Session, agentId: string, options: {
|
|
12
|
+
setAgent(id: string): void;
|
|
13
|
+
busy(): boolean;
|
|
14
|
+
}): Promise<CommandOutcome>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activating an agent in an existing web session (`/agent:<id>` and the `/agents` picker). The
|
|
3
|
+
* agent id is stored in the session options; its instructions (and default reasoning effort)
|
|
4
|
+
* apply from the session's next run, never mid-run, so tool call ids and persisted turns stay
|
|
5
|
+
* consistent. Its declared model is applied only when it belongs to the session's provider
|
|
6
|
+
* (`runner.setModel`); otherwise the session keeps its model and the answer says so.
|
|
7
|
+
*/
|
|
8
|
+
import { agentCatalogFromState, DEFAULT_AGENT_ID } from "@alisio/core";
|
|
9
|
+
export async function activateSessionAgent(opened, session, agentId, options) {
|
|
10
|
+
let state;
|
|
11
|
+
try {
|
|
12
|
+
state = opened.app.plugins.pluginState("subagents", "mainAgents");
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
/* contributions are best-effort */
|
|
16
|
+
}
|
|
17
|
+
const agent = agentCatalogFromState(state).find((candidate) => candidate.id === agentId);
|
|
18
|
+
if (!agent)
|
|
19
|
+
throw new Error(`Unknown agent "${agentId}". Open /agents to see the loaded agents.`);
|
|
20
|
+
options.setAgent(agent.id);
|
|
21
|
+
const effects = ["agent"];
|
|
22
|
+
const lines = [
|
|
23
|
+
`Active agent: **${agent.name}**${agent.id === DEFAULT_AGENT_ID ? " (default)" : ""}${agent.readOnly ? " · read-only" : ""}. Applies from the next prompt.`,
|
|
24
|
+
];
|
|
25
|
+
if (agent.model && agent.model !== session.model) {
|
|
26
|
+
let target;
|
|
27
|
+
try {
|
|
28
|
+
target = await opened.app.resolveModel(agent.model);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
/* not resolvable from the configured profiles */
|
|
32
|
+
}
|
|
33
|
+
if (target && target.provider === session.provider && !options.busy()) {
|
|
34
|
+
if (target.model.id !== session.model) {
|
|
35
|
+
opened.app.runner.setModel(session.id, target.model.id);
|
|
36
|
+
effects.push("model");
|
|
37
|
+
lines.push(`Model switched to \`${target.model.id}\`.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
lines.push(`This chat keeps \`${session.model}\`; start a new chat with ${agent.name} to use its model \`${agent.model}\`.`);
|
|
42
|
+
}
|
|
43
|
+
return { output: lines.join(" "), tone: "notice", effects };
|
|
44
|
+
}
|
package/dist/host/sessions.js
CHANGED
|
@@ -141,7 +141,12 @@ export class SessionService {
|
|
|
141
141
|
return {
|
|
142
142
|
policy: agent.policy ? { ...agent.policy } : policy,
|
|
143
143
|
approvals: agent.approvals ?? approvals,
|
|
144
|
-
|
|
144
|
+
// The session's own effort wins; otherwise the agent's default (`alisio.reasoning.effort`).
|
|
145
|
+
...(typeof effort === "string"
|
|
146
|
+
? { reasoningEffort: effort }
|
|
147
|
+
: agent.reasoningEffort
|
|
148
|
+
? { reasoningEffort: agent.reasoningEffort }
|
|
149
|
+
: {}),
|
|
145
150
|
...(agent.instructions ? { instructions: agent.instructions } : {}),
|
|
146
151
|
};
|
|
147
152
|
}
|
|
@@ -38,8 +38,8 @@ export declare function workspaceExists(path: string): Promise<boolean>;
|
|
|
38
38
|
export declare const workspaceId: (path: string) => string;
|
|
39
39
|
/**
|
|
40
40
|
* One lazily created `Application` per workspace (ADR-06), with LRU eviction of idle apps,
|
|
41
|
-
* a cap on open apps and trust resolved from the
|
|
42
|
-
*
|
|
41
|
+
* a cap on open apps and trust resolved from the shared trust store (granted by the terminal
|
|
42
|
+
* prompt or by an explicitly confirmed web request). All apps share the same session database.
|
|
43
43
|
*/
|
|
44
44
|
export declare class WorkspaceHost {
|
|
45
45
|
private options;
|
|
@@ -17,8 +17,8 @@ export async function workspaceExists(path) {
|
|
|
17
17
|
export const workspaceId = (path) => createHash("sha256").update(path).digest("hex").slice(0, 16);
|
|
18
18
|
/**
|
|
19
19
|
* One lazily created `Application` per workspace (ADR-06), with LRU eviction of idle apps,
|
|
20
|
-
* a cap on open apps and trust resolved from the
|
|
21
|
-
*
|
|
20
|
+
* a cap on open apps and trust resolved from the shared trust store (granted by the terminal
|
|
21
|
+
* prompt or by an explicitly confirmed web request). All apps share the same session database.
|
|
22
22
|
*/
|
|
23
23
|
export class WorkspaceHost {
|
|
24
24
|
options;
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { HttpError, toApiError } from "./http/errors.js";
|
|
|
17
17
|
import { Router } from "./http/router.js";
|
|
18
18
|
import { StaticAssets } from "./http/static.js";
|
|
19
19
|
import { createLogger } from "./log.js";
|
|
20
|
+
import { registerAgentDefinitionRoutes } from "./routes/agent-definitions.js";
|
|
20
21
|
import { registerApprovalRoutes } from "./routes/approvals.js";
|
|
21
22
|
import { registerBlobRoutes } from "./routes/blobs.js";
|
|
22
23
|
import { registerCommandRoutes } from "./routes/commands.js";
|
|
@@ -220,6 +221,7 @@ export async function startServer(options = {}) {
|
|
|
220
221
|
};
|
|
221
222
|
recycler = new WorkspaceRecycler(management);
|
|
222
223
|
registerManagementRoutes(router, management, recycler);
|
|
224
|
+
registerAgentDefinitionRoutes(router, management, recycler);
|
|
223
225
|
registerProviderRoutes(router, management, recycler);
|
|
224
226
|
registerEventRoutes(router, {
|
|
225
227
|
hub,
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User agent definitions (the web Agents window): CRUD over the `.agents/agents` Markdown files of
|
|
3
|
+
* a workspace (project scope) and of the user (`~/.agents/agents`, global scope), the shared
|
|
4
|
+
* templates, the configured models with their capabilities, and drafts written by the active
|
|
5
|
+
* model. Every write hot-reloads the agent registry of each open workspace application and
|
|
6
|
+
* broadcasts `catalog_changed` (`agents`) so open clients refresh; the answer's `live` says
|
|
7
|
+
* whether the running server already uses the change.
|
|
8
|
+
*/
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { AGENT_DRAFT_MAX_DESCRIPTION, AGENT_TEMPLATES, AgentDefinitionService, AgentNotFoundError, agentAuthoringGuidance, agentModelCapabilities, agentModelLabels, agentModelOptions, generateAgentDraft, resolveTrust, validateAgentDefinitionInput, } from "@alisio/core";
|
|
11
|
+
import { readJson } from "../http/body.js";
|
|
12
|
+
import { HttpError } from "../http/errors.js";
|
|
13
|
+
import { is, validate } from "../schemas.js";
|
|
14
|
+
import { workspaceApp } from "./management.js";
|
|
15
|
+
const SCOPES = ["project", "global"];
|
|
16
|
+
const message = (error) => (error instanceof Error ? error.message : String(error));
|
|
17
|
+
export function registerAgentDefinitionRoutes(router, ctx, recycler) {
|
|
18
|
+
/** The workspace application named by `reference`, or undefined (global scope only). */
|
|
19
|
+
const target = async (reference) => reference ? workspaceApp(ctx.workspaces, reference) : undefined;
|
|
20
|
+
const serviceOf = (opened) => opened?.app.agentDefinitions ?? new AgentDefinitionService({ home: homedir() });
|
|
21
|
+
const scopeOf = (value, service) => {
|
|
22
|
+
if (value === undefined || value === null || value === "")
|
|
23
|
+
return service.defaultScope;
|
|
24
|
+
if (!SCOPES.includes(value))
|
|
25
|
+
throw new HttpError("validation_failed", "scope must be project or global", {
|
|
26
|
+
fields: ["scope"],
|
|
27
|
+
});
|
|
28
|
+
if (!service.scopes.includes(value))
|
|
29
|
+
throw new HttpError("validation_failed", "The project scope needs a workspace", {
|
|
30
|
+
fields: ["scope", "workspace"],
|
|
31
|
+
});
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
34
|
+
const writable = () => {
|
|
35
|
+
if (ctx.base.readOnly)
|
|
36
|
+
throw new HttpError("capability_ceiling", "Agent changes are unavailable under --read-only");
|
|
37
|
+
};
|
|
38
|
+
const definition = (raw) => {
|
|
39
|
+
const result = validateAgentDefinitionInput(raw);
|
|
40
|
+
if (!result.ok)
|
|
41
|
+
throw new HttpError("validation_failed", result.errors.map((e) => e.message).join("; "), {
|
|
42
|
+
fields: result.errors.map((e) => e.field),
|
|
43
|
+
});
|
|
44
|
+
return result.value;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* After a write: every other open application rediscovers its agents, then the writing one
|
|
48
|
+
* again (the registry's published state is shared, so the writer's view is restored last), and
|
|
49
|
+
* every client hears `catalog_changed`. Without a writing application (no workspace named),
|
|
50
|
+
* the change is live when any open application loaded `path`.
|
|
51
|
+
*/
|
|
52
|
+
const propagate = async (writer, path, expectLoaded) => {
|
|
53
|
+
const others = ctx.workspaces.entries().filter((entry) => entry !== writer);
|
|
54
|
+
let loadedElsewhere = false;
|
|
55
|
+
for (const other of others) {
|
|
56
|
+
const reloaded = await other.app.agentDefinitions.reload();
|
|
57
|
+
if (reloaded && other.app.agentDefinitions.isLoaded(path) === expectLoaded)
|
|
58
|
+
loadedElsewhere = true;
|
|
59
|
+
}
|
|
60
|
+
if (writer)
|
|
61
|
+
await writer.app.agentDefinitions.reload();
|
|
62
|
+
for (const entry of ctx.workspaces.entries())
|
|
63
|
+
ctx.broadcast({ t: "catalog_changed", workspaceId: entry.id, scope: "agents" });
|
|
64
|
+
return loadedElsewhere;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A workspace opened untrusted only because it had no project resources yet becomes trusted
|
|
68
|
+
* once its first project agent exists (when the user trusted it before): reopen it so the
|
|
69
|
+
* registry loads the file. Busy workspaces are reopened when their runs finish.
|
|
70
|
+
*/
|
|
71
|
+
const refreshTrust = async (opened, scope) => {
|
|
72
|
+
if (!opened || opened.trusted || scope !== "project")
|
|
73
|
+
return opened;
|
|
74
|
+
const trust = await resolveTrust(opened.path).catch(() => undefined);
|
|
75
|
+
if (!trust?.trusted) {
|
|
76
|
+
// It now has project resources waiting for a trust decision (the sidebar shows it).
|
|
77
|
+
opened.untrustedResources = true;
|
|
78
|
+
return opened;
|
|
79
|
+
}
|
|
80
|
+
return (await recycler.request(opened.id)) ?? opened;
|
|
81
|
+
};
|
|
82
|
+
/** `live` on the (possibly reopened) writer: reload, then check the file is loaded. */
|
|
83
|
+
const liveOn = async (writer, path, loaded) => {
|
|
84
|
+
if (!writer)
|
|
85
|
+
return false;
|
|
86
|
+
return ((await writer.app.agentDefinitions.reload()) &&
|
|
87
|
+
writer.app.agentDefinitions.isLoaded(path) === loaded);
|
|
88
|
+
};
|
|
89
|
+
const notFound = (error) => {
|
|
90
|
+
if (error instanceof AgentNotFoundError)
|
|
91
|
+
throw new HttpError("not_found", "Agent not found");
|
|
92
|
+
throw error;
|
|
93
|
+
};
|
|
94
|
+
router.get("/api/agents/templates", () => ({ body: AGENT_TEMPLATES }));
|
|
95
|
+
router.get("/api/agents/definitions", async ({ url }) => {
|
|
96
|
+
const opened = await target(url.searchParams.get("workspace"));
|
|
97
|
+
const service = serviceOf(opened);
|
|
98
|
+
// Opening the list also picks up files edited outside Alisio (no file watcher).
|
|
99
|
+
await service.reload();
|
|
100
|
+
const body = {
|
|
101
|
+
agents: await service.list(),
|
|
102
|
+
scopes: service.scopes,
|
|
103
|
+
defaultScope: service.defaultScope,
|
|
104
|
+
dirs: Object.fromEntries(service.scopes.map((scope) => [scope, service.dir(scope)])),
|
|
105
|
+
trusted: opened?.trusted ?? false,
|
|
106
|
+
};
|
|
107
|
+
return { body };
|
|
108
|
+
});
|
|
109
|
+
router.get("/api/agents/models", async ({ url }) => {
|
|
110
|
+
const opened = await workspaceApp(ctx.workspaces, url.searchParams.get("workspace"));
|
|
111
|
+
const app = opened.app;
|
|
112
|
+
const active = {
|
|
113
|
+
...(app.providerInfo?.profileName ? { profile: app.providerInfo.profileName } : {}),
|
|
114
|
+
...(app.providerInfo?.id ? { provider: app.providerInfo.id } : {}),
|
|
115
|
+
model: app.provider.model,
|
|
116
|
+
};
|
|
117
|
+
let options = [];
|
|
118
|
+
try {
|
|
119
|
+
options = agentModelOptions(await app.listAvailableModels(AbortSignal.timeout(15_000)), active);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
/* configured catalogs unavailable: offer the running model only */
|
|
123
|
+
}
|
|
124
|
+
if (!options.some((option) => option.active) && app.provider.model) {
|
|
125
|
+
let info = { id: app.provider.model };
|
|
126
|
+
try {
|
|
127
|
+
info =
|
|
128
|
+
(await app.loadModels(AbortSignal.timeout(10_000))).find((m) => m.id === app.provider.model) ?? info;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
/* the active provider cannot list models */
|
|
132
|
+
}
|
|
133
|
+
const capabilities = agentModelCapabilities(info);
|
|
134
|
+
options.unshift({
|
|
135
|
+
reference: app.provider.model,
|
|
136
|
+
provider: app.provider.id,
|
|
137
|
+
profile: app.providerInfo?.profileName ?? "",
|
|
138
|
+
providerName: app.providers.get(app.providerInfo?.id ?? "")?.name ?? app.provider.id,
|
|
139
|
+
id: app.provider.model,
|
|
140
|
+
...(info.name ? { name: info.name } : {}),
|
|
141
|
+
active: true,
|
|
142
|
+
capabilities,
|
|
143
|
+
labels: agentModelLabels(capabilities),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return { body: options };
|
|
147
|
+
});
|
|
148
|
+
router.post("/api/agents/draft", async ({ req, res }) => {
|
|
149
|
+
const input = validate(await readJson(req), {
|
|
150
|
+
workspace: { check: is.nonEmpty(4096), required: true },
|
|
151
|
+
description: { check: is.string(AGENT_DRAFT_MAX_DESCRIPTION) },
|
|
152
|
+
base: {
|
|
153
|
+
check: (v) => is.object()(v) &&
|
|
154
|
+
["name", "description", "instructions"].every((key) => v[key] === undefined ||
|
|
155
|
+
(typeof v[key] === "string" &&
|
|
156
|
+
(v[key] ?? "").length <= 24_000)),
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
if (!input.description?.trim() && !input.base?.instructions?.trim())
|
|
160
|
+
throw new HttpError("validation_failed", "Describe the agent you want first", {
|
|
161
|
+
fields: ["description"],
|
|
162
|
+
});
|
|
163
|
+
const opened = await workspaceApp(ctx.workspaces, input.workspace);
|
|
164
|
+
// The client's Cancel closes the request: abort the model call with it.
|
|
165
|
+
const controller = new AbortController();
|
|
166
|
+
res.once("close", () => {
|
|
167
|
+
if (!res.writableFinished)
|
|
168
|
+
controller.abort(new Error("Cancelled"));
|
|
169
|
+
});
|
|
170
|
+
try {
|
|
171
|
+
return {
|
|
172
|
+
body: await generateAgentDraft(opened.app.provider, input.description ?? "", {
|
|
173
|
+
signal: controller.signal,
|
|
174
|
+
guidance: await agentAuthoringGuidance(opened.app.skills),
|
|
175
|
+
...(input.base ? { base: input.base } : {}),
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
throw new HttpError("provider_unavailable", `Draft failed: ${message(error)}`);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
router.post("/api/agents", async ({ req }) => {
|
|
184
|
+
writable();
|
|
185
|
+
const raw = (await readJson(req));
|
|
186
|
+
const opened = await target(typeof raw?.workspace === "string" ? raw.workspace : undefined);
|
|
187
|
+
const service = serviceOf(opened);
|
|
188
|
+
const scope = scopeOf(raw?.scope, service);
|
|
189
|
+
const saved = await service.create(scope, definition(raw));
|
|
190
|
+
const writer = await refreshTrust(opened, scope);
|
|
191
|
+
const reopened = writer !== opened && (await liveOn(writer, saved.result.path, true));
|
|
192
|
+
const elsewhere = await propagate(writer, saved.result.path, true);
|
|
193
|
+
const body = {
|
|
194
|
+
agent: saved.result,
|
|
195
|
+
live: saved.live || reopened || elsewhere,
|
|
196
|
+
};
|
|
197
|
+
return { status: 201, body };
|
|
198
|
+
});
|
|
199
|
+
router.get("/api/agents/:id", async ({ url, params }) => {
|
|
200
|
+
const service = serviceOf(await target(url.searchParams.get("workspace")));
|
|
201
|
+
const scope = scopeOf(url.searchParams.get("scope"), service);
|
|
202
|
+
const found = await service.get(scope, params.id ?? "");
|
|
203
|
+
if (!found)
|
|
204
|
+
throw new HttpError("not_found", "Agent not found");
|
|
205
|
+
return { body: found };
|
|
206
|
+
});
|
|
207
|
+
router.put("/api/agents/:id", async ({ req, params }) => {
|
|
208
|
+
writable();
|
|
209
|
+
const raw = (await readJson(req));
|
|
210
|
+
const opened = await target(typeof raw?.workspace === "string" ? raw.workspace : undefined);
|
|
211
|
+
const service = serviceOf(opened);
|
|
212
|
+
const scope = scopeOf(raw?.scope, service);
|
|
213
|
+
const saved = await service.update(scope, params.id ?? "", definition(raw)).catch(notFound);
|
|
214
|
+
const writer = await refreshTrust(opened, scope);
|
|
215
|
+
const reopened = writer !== opened && (await liveOn(writer, saved.result.path, true));
|
|
216
|
+
const elsewhere = await propagate(writer, saved.result.path, true);
|
|
217
|
+
const body = {
|
|
218
|
+
agent: saved.result,
|
|
219
|
+
live: saved.live || reopened || elsewhere,
|
|
220
|
+
};
|
|
221
|
+
return { body };
|
|
222
|
+
});
|
|
223
|
+
router.delete("/api/agents/:id", async ({ url, params }) => {
|
|
224
|
+
writable();
|
|
225
|
+
const opened = await target(url.searchParams.get("workspace"));
|
|
226
|
+
const service = serviceOf(opened);
|
|
227
|
+
const scope = scopeOf(url.searchParams.get("scope"), service);
|
|
228
|
+
const existing = await service.get(scope, params.id ?? "");
|
|
229
|
+
if (!existing)
|
|
230
|
+
throw new HttpError("not_found", "Agent not found");
|
|
231
|
+
const removed = await service.delete(scope, existing.id).catch(notFound);
|
|
232
|
+
const elsewhere = await propagate(opened, existing.path, false);
|
|
233
|
+
return { body: { deleted: removed.result, live: removed.live || elsewhere } };
|
|
234
|
+
});
|
|
235
|
+
}
|
package/dist/routes/commands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CommandCatalog } from "@alisio/core";
|
|
1
|
+
import { agentIdFromCommand, CommandCatalog } from "@alisio/core";
|
|
2
|
+
import { activateSessionAgent } from "../host/agents.js";
|
|
2
3
|
import { readJson } from "../http/body.js";
|
|
3
4
|
import { HttpError } from "../http/errors.js";
|
|
4
5
|
import { is, validate } from "../schemas.js";
|
|
@@ -98,6 +99,16 @@ export function registerCommandRoutes(router, ctx) {
|
|
|
98
99
|
const skill = await opened.app.skills.load(descriptor.name.slice("skill:".length));
|
|
99
100
|
return { prompt: { text: `${skill}\n\nUser request: ${args}`, display } };
|
|
100
101
|
}
|
|
102
|
+
if (descriptor.source === "agent") {
|
|
103
|
+
// `/agent:<id>`: stored on the session, applied from its next run.
|
|
104
|
+
const id = agentIdFromCommand(descriptor.name);
|
|
105
|
+
if (!id)
|
|
106
|
+
throw new HttpError("unknown_command", `Unknown command /${name}`);
|
|
107
|
+
return activateSessionAgent(opened, session, id, {
|
|
108
|
+
setAgent: (agent) => sessions.setOptions(session.id, { agent }),
|
|
109
|
+
busy,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
101
112
|
if (descriptor.name === "help")
|
|
102
113
|
return { output: helpText(catalog.list("web")) };
|
|
103
114
|
if (descriptor.name === "ask") {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* catalog broadcast `catalog_changed` so every open palette refreshes.
|
|
6
6
|
*/
|
|
7
7
|
import { isAbsolute, join } from "node:path";
|
|
8
|
-
import { agentCatalogFromState, CommandCatalog, configFile, configHome, isSettableSettingKey, pluginPrefix, resolveActiveAgent, settableSettings, } from "@alisio/core";
|
|
8
|
+
import { agentCatalogFromState, CommandCatalog, configFile, configHome, hashProjectConfig, isSettableSettingKey, pluginPrefix, resolveActiveAgent, setTrust, settableSettings, } from "@alisio/core";
|
|
9
9
|
import { readJson } from "../http/body.js";
|
|
10
10
|
import { HttpError } from "../http/errors.js";
|
|
11
11
|
import { is, validate } from "../schemas.js";
|
|
@@ -20,7 +20,7 @@ export async function workspaceApp(workspaces, reference) {
|
|
|
20
20
|
throw new HttpError("not_found", "Workspace not found");
|
|
21
21
|
return workspaces.openPath(path);
|
|
22
22
|
}
|
|
23
|
-
const UNTRUSTED = "Trust this workspace
|
|
23
|
+
const UNTRUSTED = "Trust this workspace (sidebar workspace menu, or run alisio in it) to manage its plugins here";
|
|
24
24
|
const message = (error) => (error instanceof Error ? error.message : String(error));
|
|
25
25
|
/**
|
|
26
26
|
* Plugin and skill toggles persist a project override; the running app reflects plugin changes
|
|
@@ -275,6 +275,36 @@ export function registerManagementRoutes(router, ctx, recycler) {
|
|
|
275
275
|
})),
|
|
276
276
|
};
|
|
277
277
|
});
|
|
278
|
+
// ---- Workspace trust ----------------------------------------------------------------------
|
|
279
|
+
/**
|
|
280
|
+
* Grants (or withdraws) project trust from the web: the same persisted, per-directory decision
|
|
281
|
+
* the terminal prompt stores (`trust.json`, bound to the `.alisio/config.json` hash), so a
|
|
282
|
+
* changed config file is never trusted silently. Trust lets the workspace load its project
|
|
283
|
+
* config, plugins (executable code), agents, skills and prompts; the request must carry an
|
|
284
|
+
* explicit confirmation. The workspace application is reopened so the decision applies now.
|
|
285
|
+
*/
|
|
286
|
+
router.post("/api/workspaces/:wid/trust", async ({ req, params }) => {
|
|
287
|
+
const input = validate(await readJson(req), {
|
|
288
|
+
trusted: { check: is.boolean(), required: true },
|
|
289
|
+
confirmed: { check: (v) => v === true, required: true },
|
|
290
|
+
});
|
|
291
|
+
if (ctx.base.readOnly)
|
|
292
|
+
throw new HttpError("capability_ceiling", "Trust changes are unavailable under --read-only");
|
|
293
|
+
if (ctx.base.trustProject || ctx.base.config)
|
|
294
|
+
throw new HttpError("not_manageable", "Trust is fixed for this server by --trust-project/--config");
|
|
295
|
+
const id = params.wid ?? "";
|
|
296
|
+
const path = await ctx.workspaces.pathOf(id);
|
|
297
|
+
if (!path)
|
|
298
|
+
throw new HttpError("not_found", "Workspace not found");
|
|
299
|
+
if (ctx.scheduler.busyWorkspace(id))
|
|
300
|
+
throw new HttpError("runs_active", "Wait for the workspace's runs to finish, then retry");
|
|
301
|
+
await setTrust(path, input.trusted, await hashProjectConfig(path));
|
|
302
|
+
if (ctx.workspaces.get(id))
|
|
303
|
+
await recycler.request(id);
|
|
304
|
+
else
|
|
305
|
+
recycler.announce(id, ["plugins", "commands", "skills", "agents", "mcp"]);
|
|
306
|
+
return { body: await ctx.workspaces.info(path) };
|
|
307
|
+
});
|
|
278
308
|
// ---- Settings -----------------------------------------------------------------------------
|
|
279
309
|
router.get("/api/settings", async ({ url }) => {
|
|
280
310
|
const opened = await open(url.searchParams.get("workspace"));
|
package/dist/routes/sessions.js
CHANGED
|
@@ -22,6 +22,8 @@ export function registerSessionRoutes(router, ctx) {
|
|
|
22
22
|
const { catalog, sessions } = ctx;
|
|
23
23
|
router.get("/api/sessions", ({ url }) => {
|
|
24
24
|
const workspace = url.searchParams.get("workspace");
|
|
25
|
+
// `?agent=<id>`: sessions started with (or switched to) that agent.
|
|
26
|
+
const agent = url.searchParams.get("agent");
|
|
25
27
|
const q = url.searchParams.get("q")?.trim().toLowerCase();
|
|
26
28
|
const archived = url.searchParams.get("archived") ?? "false";
|
|
27
29
|
if (!["true", "false", "all"].includes(archived))
|
|
@@ -32,6 +34,7 @@ export function registerSessionRoutes(router, ctx) {
|
|
|
32
34
|
const offset = queryInt(url, "cursor", 0) ?? 0;
|
|
33
35
|
const rows = catalog
|
|
34
36
|
.list()
|
|
37
|
+
.filter((session) => !agent || session.options?.agent === agent)
|
|
35
38
|
.map((session) => sessions.summary(session))
|
|
36
39
|
.filter((s) => (!workspace || s.workspaceId === workspace) &&
|
|
37
40
|
(!q || (s.title ?? "").toLowerCase().includes(q) || s.id.startsWith(q)) &&
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,g as n,p as r,t as i}from"./jsxRuntime-BjUOR156.js";import{t as a}from"./icons-Bk2j3B6A.js";import{b as o,g as s,h as c,m as l,p as u}from"./index-CpA8C_JP.js";import{b as d,t as f,u as p}from"./agents.module-sVh_Peep.js";import{a as m,c as h,i as g,l as _,r as v,u as y}from"./shared-CWxbpk_V.js";function b(){let b=h(),x=_(b?()=>s.agents(b.id):void 0,[b?.id],[`agents`]),S=_(()=>s.agentDefinitions(b?.id),[b?.id],[`agents`]),[C,w]=n(``),[T,E]=n(0),D=r(null);e(()=>{let e=document.activeElement;return D.current?.querySelector(`input`)?.focus(),()=>e?.focus()},[]);let O=()=>{l.value=!1},k=o.value?.agent??x.data?.find(e=>e.default)?.id,A=p(x.data??[],C),j=e=>{O(),u(e.id)},M=e=>{let n=d(e,S.data?.agents??[]);return n?i(v,{tone:n===`project`?`ok`:`off`,children:t(`agentsWin.scope.${n}`)}):i(v,{tone:`off`,children:e.source===`builtin`?t(`agentsWin.builtin`):t(`agentsWin.plugin`)})};return i(`div`,{class:y.backdrop,onMouseDown:e=>{e.target===e.currentTarget&&O()},children:i(`div`,{ref:D,class:`${y.dialog} ${f.picker}`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-picker-title`,onKeyDown:e=>{if(e.key===`Escape`)e.preventDefault(),O();else if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;E(e=>A.length?(e+t+A.length)%A.length:0)}else if(e.key===`Enter`&&e.target.tagName===`INPUT`){e.preventDefault();let t=A[Math.min(T,A.length-1)];t&&j(t)}},children:[i(`div`,{class:f.pickerHead,children:[i(`div`,{class:f.listHead,children:[i(`div`,{children:[i(`h3`,{class:y.pageTitle,id:`agent-picker-title`,children:t(`agentsWin.picker`)}),i(`p`,{class:y.note,children:t(`agentsWin.pickerLead`)})]}),i(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`common.close`),onClick:O,children:i(a,{name:`x`,size:18})})]}),i(g,{value:C,label:t(`agentsWin.pickerSearch`),onInput:e=>{w(e),E(0)}})]}),i(`div`,{style:{padding:`0 18px`},children:i(m,{loading:x.loading&&!x.data,error:x.error,empty:b?void 0:`settings.noWorkspace`})}),i(`ul`,{class:f.pickerList,"aria-label":t(`agentsWin.picker`),children:[x.data&&!A.length?i(`li`,{class:y.note,children:t(`agentsWin.pickerEmpty`,{query:C})}):null,A.map((e,n)=>i(`li`,{children:i(`button`,{type:`button`,class:f.pickerItem,"data-selected":n===T,"aria-current":e.id===k?`true`:void 0,onMouseEnter:()=>E(n),onClick:()=>j(e),children:[i(`span`,{class:f.pickerTitle,children:[e.name,M(e),e.id===k?i(v,{tone:`ok`,children:t(`agentsWin.current`)}):null,e.id===`build`?i(v,{tone:`off`,children:t(`agentsWin.defaultAgent`)}):null,e.readOnly?i(v,{tone:`warn`,children:t(`agents.readOnly`)}):null]}),i(`span`,{class:y.cardText,children:e.description})]})},e.id)),i(`li`,{children:i(`button`,{type:`button`,class:f.pickerItem,onClick:()=>{O(),c.value=!0},children:i(`span`,{class:f.pickerTitle,children:[i(a,{name:`users`,size:15}),t(`agentsWin.manage`)]})})})]})]})})}export{b as AgentPicker};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,g as r,m as i,p as a,t as o}from"./jsxRuntime-BjUOR156.js";import{t as s}from"./icons-Bk2j3B6A.js";import{C as c,E as l,O as u,d,g as f,h as p,k as m,w as h,x as g}from"./index-CpA8C_JP.js";import{S as _,_ as v,a as y,c as b,d as x,f as ee,g as S,h as C,i as w,l as T,m as E,n as D,o as O,p as te,r as ne,s as re,t as k,v as ie,x as ae,y as oe}from"./agents.module-sVh_Peep.js";import{a as A,c as j,l as M,r as N,u as P}from"./shared-CWxbpk_V.js";var F=new Set([`minimal`,`low`,`medium`,`high`,`xhigh`]),I=e=>F.has(e)?t(`agentsWin.level.${e}`):e;function L(e){let[t,n]=r(!0);return o(`section`,{class:k.section,children:[o(`button`,{type:`button`,class:k.sectionHead,"aria-expanded":t,onClick:()=>n(!t),children:[o(s,{name:t?`chevronDown`:`chevronRight`,size:15}),e.title]}),t?o(`div`,{class:k.sectionBody,children:e.children}):null]})}function R(e){return o(`label`,{class:k.field,children:[o(`span`,{class:k.fieldLabel,children:[e.label,e.hint?o(`span`,{class:k.fieldHint,children:e.hint}):null]}),e.children,e.error?o(`span`,{class:k.fieldError,children:e.error}):null]})}function se(e){let n=e.text.split(`
|
|
2
|
+
`);return o(`section`,{class:k.code,"aria-label":t(`agentsWin.config`),children:[o(`div`,{class:k.codeHead,children:[o(`span`,{children:t(`agentsWin.config`)}),o(d,{text:()=>e.text,label:t(`agentsWin.configCopy`)})]}),o(`p`,{class:P.note,style:{margin:`8px 16px 0`},children:t(`agentsWin.configLead`)}),o(`pre`,{class:k.codeBody,children:o(`code`,{children:n.map((e,t)=>o(`span`,{class:k.codeLine,children:[o(`span`,{class:k.lineNo,"aria-hidden":`true`,children:t+1}),o(`span`,{children:_(e).map((e,t)=>o(`span`,{class:k[`tok-${e.kind}`],children:e.text},t))})]},t))})})]})}function ce(n){let[i,s]=r(Date.now()),c=a(null);return e(()=>{c.current?.focus();let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]),o(`div`,{class:k.overlay,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`building-title`,"aria-describedby":`building-body`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),n.onCancel())},children:o(`div`,{class:k.overlayCard,children:[o(`div`,{class:k.spinner,"aria-hidden":`true`}),o(`h3`,{class:k.overlayTitle,id:`building-title`,children:t(`agentsWin.building`)}),o(`p`,{class:P.note,id:`building-body`,role:`status`,children:t(`agentsWin.buildingBody`,{model:n.model})}),o(`div`,{class:k.progress,"aria-hidden":`true`,children:o(`div`,{class:k.progressBar})}),o(`p`,{class:P.meta,children:t(`agentsWin.buildingElapsed`,{seconds:Math.max(0,Math.round((i-n.started)/1e3))})}),o(`div`,{class:k.overlayActions,children:o(`button`,{ref:c,type:`button`,class:P.secondary,onClick:n.onCancel,children:t(`common.cancel`)})})]})})}function le(n){let r=a(null);return e(()=>r.current?.focus(),[]),o(`div`,{class:k.overlay,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`created-title`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),n.onStay())},children:o(`div`,{class:k.overlayCard,children:[o(`h3`,{class:k.overlayTitle,id:`created-title`,children:t(`agentsWin.createdTitle`,{name:n.name})}),o(`p`,{class:P.note,children:n.live?t(`agentsWin.createdBody`):t(`agentsWin.createdRestart`)}),o(`div`,{class:k.overlayActions,children:[n.live?o(`button`,{ref:r,type:`button`,class:P.primary,onClick:n.onTry,children:t(`agentsWin.tryIt`)}):null,o(`button`,{ref:n.live?void 0:r,type:`button`,class:P.secondary,onClick:n.onStay,children:t(`agentsWin.stay`)})]})]})})}function z(a){let{workspace:d,models:_}=a,[T,E]=r(a.initial),[j,N]=r(a.saved),[F,z]=r(`setup`),[B,V]=r(``),[H,U]=r(),[W,G]=r(),[ue,K]=r(!1),[q,J]=r(),[de,fe]=r(!v());e(()=>{if(!T.model&&_?.length){let e=_.find(e=>e.active)??_[0];e&&E(t=>x({...t,model:e.reference},e.capabilities))}},[_]);let pe=!j||C(T)!==C(j);e(()=>a.onDirty(pe&&!!j),[pe,j]);let Y=re(_,T.model),X=M(j?.id?()=>f.agentSessions(j.id):void 0,[j?.id],[`agents`]),me=a.overview?.scopes??(d?[`project`,`global`]:[`global`]),Z=e=>E(t=>({...t,...e})),he=i(()=>y(T,{origin:typeof location<`u`?location.origin:`http://127.0.0.1:4096`,...d?{workspace:d.id}:{}}),[T,d?.id]),ge=_?.find(e=>e.active)?.id??`Alisio`,Q=!!T.instructions.trim(),_e=async e=>{K(!0);try{let n={...S(e),scope:e.scope,...d?{workspace:d.id}:{}},r=e.id?await f.updateAgent(e.id,n):await f.createAgent(n),i=ee(r.agent);E(i),N(i),a.onSaved(i),e.scope===`project`&&c(),l(t(r.live?`agentsWin.saved`:`agentsWin.savedRestart`)),e.id||J({form:i,live:r.live})}catch(e){l(t(`agentsWin.saveFailed`,{message:m(e)}))}finally{K(!1)}},ve=async()=>{if(!d)return;let e=new AbortController;G(void 0),U({controller:e,started:Date.now()});let n;try{let r=await f.draftAgent({workspace:d.id,description:B.trim(),...Q?{base:{name:T.name,description:T.description,instructions:T.instructions}}:{}},e.signal);n=x(te(T,r),Y),E(n),V(``),l(t(`agentsWin.buildDone`,{model:r.generatedBy,guidance:r.guidance}))}catch(t){e.signal.aborted||G(m(t))}finally{U(void 0)}n&&!n.id&&O(n,void 0)&&await _e(n)},$=oe(T.name),ye=ie({saved:!!j?.id,workspace:!!d,sessions:X.data?.items??[]}),be={define:[`agentsWin.step.define`,`agentsWin.step.defineBody`],runtime:[`agentsWin.step.runtime`,`agentsWin.step.runtimeBody`],session:[`agentsWin.step.session`,`agentsWin.step.sessionBody`],events:[`agentsWin.step.events`,`agentsWin.step.eventsBody`]},xe=async e=>{d&&e.id&&await u(d.id,e.id,e.model||void 0)&&(p.value=!1)};return o(`div`,{style:{position:`relative`},children:[o(`div`,{class:P.tabs,role:`tablist`,"aria-label":t(`agentsWin.title`),children:[`setup`,`sessions`].map(e=>o(`button`,{type:`button`,role:`tab`,class:P.tab,"aria-selected":F===e,onClick:()=>z(e),children:t(`agentsWin.${e}`)},e))}),F===`sessions`?o(`div`,{role:`tabpanel`,children:j?.id?o(n,{children:[o(A,{loading:X.loading&&!X.data,error:X.error}),X.data&&!X.data.items.length?o(`p`,{class:P.note,children:t(`agentsWin.sessionsEmpty`)}):null,o(`ul`,{class:P.rows,children:(X.data?.items??[]).map(e=>o(`li`,{class:P.row,children:o(`button`,{type:`button`,class:k.rowButton,onClick:()=>{p.value=!1,g(e.id)},children:[o(`span`,{class:P.cardName,children:e.title??t(`agentsWin.untitled`)}),o(`p`,{class:P.meta,children:[e.model,` · `,e.workspace]})]})},e.id))}),d?o(`button`,{type:`button`,class:`${P.primary} ${P.addButton}`,onClick:()=>void xe(j),children:t(`agentsWin.startSession`)}):o(`p`,{class:P.note,children:t(`agentsWin.noWorkspace`)})]}):o(`p`,{class:P.note,children:t(`agentsWin.sessionsUnsaved`)})}):o(`div`,{class:k.columns,role:`tabpanel`,children:[o(`div`,{class:k.column,children:[d?o(`section`,{class:k.assist,"aria-labelledby":`assist-title`,children:[o(`h4`,{class:k.assistTitle,id:`assist-title`,children:[o(s,{name:`sparkle`,size:16}),t(Q?`agentsWin.assistRefine`:`agentsWin.assistTitle`)]}),o(`p`,{class:P.note,children:t(Q?`agentsWin.assistRefineLead`:`agentsWin.assistLead`)}),o(`textarea`,{class:k.control,style:{minHeight:`64px`},value:B,placeholder:t(`agentsWin.assistPlaceholder`),"aria-label":t(`agentsWin.assistTitle`),maxLength:2e3,onInput:e=>V(e.target.value)}),W?o(`p`,{class:P.errorText,role:`alert`,children:t(`agentsWin.buildFailed`,{message:W})}):null,o(`div`,{class:k.assistActions,children:o(`button`,{type:`button`,class:P.primary,disabled:!!H||!Q&&!B.trim(),onClick:()=>void ve(),children:t(Q?`agentsWin.assistRefine`:`agentsWin.assistCreate`)})})]}):null,o(L,{title:t(`agentsWin.definition`),children:[o(R,{label:t(`agentsWin.name`),error:$?t(`agentsWin.nameError.${$}`):void 0,children:o(`input`,{class:k.control,value:T.name,maxLength:80,"aria-invalid":$?`true`:void 0,onInput:e=>Z({name:e.target.value})})}),o(R,{label:t(`agentsWin.description`),children:o(`input`,{class:k.control,value:T.description,maxLength:300,placeholder:t(`agentsWin.descriptionPlaceholder`),onInput:e=>Z({description:e.target.value})})}),o(R,{label:t(`agentsWin.instructions`),hint:`${T.instructions.length} / 24000`,children:o(`textarea`,{class:k.control,value:T.instructions,maxLength:24e3,placeholder:t(`agentsWin.instructionsPlaceholder`),onInput:e=>Z({instructions:e.target.value})})}),!T.id&&me.length>1?o(R,{label:t(`agentsWin.scope`),hint:t(`agentsWin.scopeHint`),children:o(`select`,{class:k.control,value:T.scope,title:a.overview?.dirs[T.scope]??``,onChange:e=>Z({scope:e.target.value}),children:me.map(e=>o(`option`,{value:e,title:a.overview?.dirs[e]??``,children:[t(`agentsWin.scope.${e}`),a.overview?.dirs[e]?` — ${ae(e,a.overview.dirs[e])}`:``]},e))})}):o(`p`,{class:P.meta,children:[t(`agentsWin.scope`),`: `,t(`agentsWin.scope.${T.scope}`)]}),T.scope===`project`&&a.overview&&!a.overview.trusted?o(`div`,{class:P.callout,role:`note`,children:[o(s,{name:`shield`,size:16}),o(`div`,{class:P.stack,children:[o(`span`,{children:t(`agentsWin.scopeUntrusted`)}),d?o(`button`,{type:`button`,class:P.secondary,style:{justifySelf:`start`},onClick:async()=>{await h(d,!0)&&a.onTrusted()},children:t(`trust.grant`)}):null]})]}):null]}),o(L,{title:t(`agentsWin.modelSection`),children:[o(R,{label:t(`agentsWin.model`),children:o(`select`,{class:k.control,value:T.model,onChange:e=>{let t=e.target.value;E(e=>x({...e,model:t},re(_,t)))},children:[o(`option`,{value:``,disabled:!0,children:t(`agentsWin.chooseModel`)}),T.model&&!_?.some(e=>e.reference===T.model)?o(`option`,{value:T.model,children:T.model}):null,(_??[]).map(e=>o(`option`,{value:e.reference,children:[e.active?t(`agentsWin.modelActive`,{name:e.name??e.id}):e.name??e.id,` `,`· `,e.providerName,e.labels.length?` — ${e.labels.join(` · `)}`:``]},e.reference))]})}),a.modelsError?o(`p`,{class:P.errorText,children:a.modelsError}):Y.known?null:o(`p`,{class:k.fieldHint,children:t(`agentsWin.capsUnknown`)}),o(`div`,{class:k.settingsGrid,children:[o(R,{label:t(`agentsWin.textFormat`),children:o(`select`,{class:k.control,value:T.format,onChange:e=>Z({format:e.target.value}),children:ne.filter(e=>Y.textFormats.includes(e)).map(e=>o(`option`,{value:e,children:t(`agentsWin.format.${e}`)},e))})}),o(R,{label:t(`agentsWin.effort`),hint:Y.reasoning?void 0:t(`agentsWin.unsupported`),children:o(`select`,{class:k.control,value:T.effort,disabled:!Y.reasoning,onChange:e=>Z({effort:e.target.value}),children:[o(`option`,{value:``,children:[t(`agentsWin.modelDefault`),Y.defaultEffort?` (${I(Y.defaultEffort)})`:``]}),Y.effortLevels.map(e=>o(`option`,{value:e,children:I(e)},e))]})}),o(R,{label:t(`agentsWin.verbosity`),hint:Y.verbosity?void 0:t(`agentsWin.unsupported`),children:o(`select`,{class:k.control,value:T.verbosity,disabled:!Y.verbosity,onChange:e=>Z({verbosity:e.target.value}),children:[o(`option`,{value:``,children:t(`agentsWin.modelDefault`)}),w.map(e=>o(`option`,{value:e,children:I(e)},e))]})}),o(R,{label:t(`agentsWin.summary`),hint:Y.summary?void 0:t(`agentsWin.unsupported`),children:o(`select`,{class:k.control,value:T.summary,disabled:!Y.summary,onChange:e=>Z({summary:e.target.value}),children:[o(`option`,{value:``,children:t(`agentsWin.modelDefault`)}),D.map(e=>o(`option`,{value:e,children:t(`agentsWin.summary.${e}`)},e))]})})]})]}),o(`button`,{type:`button`,class:`${P.primary} ${k.saveButton}`,disabled:ue||!!H||!O(T,j),onClick:()=>void _e(T),children:t(`agentsWin.save`)})]}),o(`div`,{class:k.column,children:[o(se,{text:he}),de?o(`section`,{class:k.stepper,"aria-labelledby":`getting-started`,children:[o(`h4`,{class:k.stepperHead,id:`getting-started`,children:[t(`agentsWin.gettingStarted`),o(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`agentsWin.dismiss`),title:t(`agentsWin.dismiss`),onClick:()=>{b(),fe(!1)},children:o(s,{name:`x`,size:15})})]}),o(`ol`,{class:k.steps,children:ye.map((e,n)=>{let[r,i]=be[e.id];return o(`li`,{class:k.step,"data-done":e.done,children:[o(`span`,{class:k.stepNode,"aria-hidden":`true`,children:e.done?`✓`:n+1}),o(`div`,{children:[o(`p`,{class:k.stepTitle,children:[t(r),o(`span`,{class:`sr-only`,children:e.done?` ✓`:``})]}),o(`p`,{class:k.stepText,children:t(i)})]})]},e.id)})})]}):null]})]}),H?o(ce,{model:ge,started:H.started,onCancel:()=>H.controller.abort()}):null,q?o(le,{name:q.form.name,live:q.live&&!!d,onTry:()=>{let e=q.form;J(void 0),xe(e)},onStay:()=>J(void 0)}):null]})}var B=`button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex='0']`;function V(e){let{agent:r}=e;return o(n,{children:[o(N,{tone:r.scope===`project`?`ok`:`off`,children:t(`agentsWin.scope.${r.scope}`)}),r.overridesGlobal?o(N,{tone:`warn`,children:t(`agentsWin.overrides`)}):null,r.overriddenByProject?o(N,{tone:`off`,children:t(`agentsWin.overridden`)}):null]})}function H(){let i=j(),[c,u]=r({kind:`list`}),[d,h]=r(!1),g=a(null),_=M(()=>f.agentDefinitions(i?.id),[i?.id],[`agents`]),v=M(()=>f.agentTemplates(),[]),y=M(i?()=>f.agentModels(i.id):void 0,[i?.id]);e(()=>{let e=document.activeElement;return g.current?.querySelector(`button`)?.focus(),()=>e?.focus()},[]);let b=_.data?.defaultScope??(i?`project`:`global`),x=()=>y.data?.find(e=>e.active)?.reference??``,S=()=>c.kind===`editor`&&d&&!window.confirm(t(`agentsWin.unsavedLeave`))?!1:(h(!1),u({kind:`list`}),!0),C=()=>{(c.kind!==`editor`||!d||window.confirm(t(`agentsWin.unsavedLeave`)))&&(p.value=!1)},w=e=>u({kind:`editor`,key:`template:${e.id}:${Date.now()}`,form:E(e,b,x()),assist:!0}),D=async e=>{if(window.confirm(t(`agentsWin.deleteConfirm`,{path:e.path})))try{let n=await f.deleteAgent(e.id,e.scope,i?.id);l(t(n.live?`agentsWin.deleted`:`agentsWin.deletedRestart`)),_.reload()}catch(e){l(m(e))}},O=_.data?.agents??[];return o(`div`,{class:P.backdrop,onMouseDown:e=>{e.target===e.currentTarget&&C()},children:o(`div`,{ref:g,class:`${P.dialog} ${k.shell}`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agents-title`,onKeyDown:e=>{if(e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),c.kind===`editor`?S():C()),e.key===`Tab`){let t=[...g.current?.querySelectorAll(B)??[]],n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())}},children:o(`div`,{class:P.content,children:[o(`div`,{class:P.topBar,children:[o(`nav`,{class:k.breadcrumb,"aria-label":t(`agentsWin.title`),children:c.kind===`editor`?o(n,{children:[o(`button`,{type:`button`,class:k.crumbLink,onClick:S,children:t(`agentsWin.back`)}),o(s,{name:`chevronRight`,size:14}),o(`span`,{class:k.crumbCurrent,id:`agents-title`,"aria-current":`page`,children:c.form.id?c.form.name:t(`agentsWin.newAgent`)})]}):o(`span`,{class:k.crumbCurrent,id:`agents-title`,children:t(`agentsWin.title`)})}),o(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`common.close`),onClick:C,children:o(s,{name:`x`,size:18})})]}),c.kind===`editor`?o(z,{initial:c.form,...c.saved?{saved:c.saved}:{},assist:c.assist,workspace:i,overview:_.data,models:y.data,modelsError:y.error,onDirty:h,onTrusted:()=>{_.reload(),y.reload()},onSaved:e=>{_.reload(),u(t=>t.kind===`editor`?{...t,form:e,saved:e}:t)}},c.key):o(n,{children:[o(`header`,{class:`${P.intro} ${k.listHead}`,children:[o(`div`,{children:[o(`h3`,{class:P.pageTitle,children:t(`agentsWin.title`)}),o(`p`,{class:P.lead,children:t(`agentsWin.lead`)}),i?null:o(`p`,{class:P.note,children:t(`agentsWin.noWorkspace`)})]}),o(`button`,{type:`button`,class:P.primary,onClick:()=>u({kind:`editor`,key:`new:${Date.now()}`,form:T(b,x()),assist:!0}),children:t(`agentsWin.create`)})]}),o(`h4`,{class:P.listTitle,children:[t(`agentsWin.yours`),o(`span`,{class:P.count,children:O.length})]}),o(A,{loading:_.loading&&!_.data,error:_.error}),_.data&&!O.length?o(`p`,{class:P.note,children:t(`agentsWin.none`)}):null,o(`ul`,{class:P.rows,children:O.map(e=>o(`li`,{class:P.row,"data-muted":e.overriddenByProject?`true`:void 0,children:[o(`button`,{type:`button`,class:k.rowButton,onClick:()=>{let t=ee(e);u({kind:`editor`,key:`${e.scope}:${e.id}`,form:t,saved:t,assist:!1})},children:[o(`span`,{class:P.rowTitle,children:[o(`span`,{class:P.cardName,children:e.name}),o(V,{agent:e})]}),o(`p`,{class:P.cardText,children:e.description}),o(`p`,{class:P.meta,children:[e.model||`—`,` · `,o(`code`,{children:e.id})]})]}),o(`div`,{class:P.rowActions,children:o(`button`,{type:`button`,class:`icon-btn`,"aria-label":`${t(`agentsWin.delete`)} ${e.name}`,title:t(`agentsWin.delete`),onClick:()=>void D(e),children:o(s,{name:`archive`,size:16})})})]},`${e.scope}:${e.id}`))}),o(`h4`,{class:P.listTitle,children:t(`agentsWin.templates`)}),o(A,{loading:v.loading&&!v.data,error:v.error}),o(`ul`,{class:P.grid,children:(v.data??[]).map(e=>o(`li`,{children:o(`button`,{type:`button`,class:k.templateCard,onClick:()=>w(e),children:[o(`span`,{class:k.templateName,children:e.name}),o(`span`,{class:k.templateText,children:e.description})]})},e.id))})]})]})})})}export{H as AgentsModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,p as r,t as i}from"./jsxRuntime-BjUOR156.js";import{t as a}from"./icons-Bk2j3B6A.js";import{A as o,M as s,N as c,_ as l,d as u,j as d,o as f,y as p}from"./index-CpA8C_JP.js";var m={panel:`_panel_ses4f_2`,rise:`_rise_ses4f_1`,head:`_head_ses4f_46`,badge:`_badge_ses4f_54`,titles:`_titles_ses4f_63`,title:`_title_ses4f_63`,eyebrow:`_eyebrow_ses4f_75`,nav:`_nav_ses4f_84`,position:`_position_ses4f_90`,flip:`_flip_ses4f_97`,body:`_body_ses4f_101`,question:`_question_ses4f_106`,answer:`_answer_ses4f_115`,pending:`_pending_ses4f_119`,spinner:`_spinner_ses4f_126`,cancel:`_cancel_ses4f_134`,error:`_error_ses4f_148`,usage:`_usage_ses4f_156`,foot:`_foot_ses4f_166`},h=e=>e instanceof HTMLElement&&(e.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(e.tagName));function g(){let g=l.value,_=r(null);if(e(()=>{_.current?.focus()},[g?.sessionId,g?.pending?.question]),e(()=>{let e=e=>{let t=l.value;t&&!e.defaultPrevented&&(e.key===`Escape`?(e.preventDefault(),p()):(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&!h(e.target)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),l.value=c(t,e.key===`ArrowLeft`?-1:1)))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),!g)return null;let v=d(g),y=s(g),b=g.pending?.question??g.error?.question??v?.question,x=e=>{l.value&&(l.value=c(l.value,e))};return i(`aside`,{ref:_,class:m.panel,role:`dialog`,"aria-modal":`false`,"aria-labelledby":`btw-title`,tabIndex:-1,children:[i(`header`,{class:m.head,children:[i(`span`,{class:m.badge,"aria-hidden":`true`,children:`btw`}),i(`div`,{class:m.titles,children:[i(`h2`,{id:`btw-title`,class:m.title,children:t(`btw.title`)}),i(`p`,{class:m.eyebrow,children:t(`btw.subtitle`)})]}),g.entries.length&&!g.usage?i(`nav`,{class:m.nav,"aria-label":t(`btw.history`),children:[i(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`btw.earlier`),title:t(`btw.earlier`),disabled:!y.earlier,onClick:()=>x(-1),children:i(a,{name:`chevronRight`,size:16,class:m.flip})}),i(`span`,{class:m.position,"aria-live":`polite`,children:v?t(`btw.position`,{n:g.index+1,total:g.entries.length}):``}),i(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`btw.later`),title:t(`btw.later`),disabled:!y.later,onClick:()=>x(1),children:i(a,{name:`chevronRight`,size:16})})]}):null,v?i(u,{text:()=>v.answer,label:t(`btw.copy`)}):null,i(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`common.close`),title:t(`common.close`),onClick:()=>p(),children:i(a,{name:`x`,size:16})})]}),i(`div`,{class:m.body,children:g.usage?i(`div`,{class:m.usage,children:[i(`code`,{children:o}),i(`p`,{children:t(`btw.usage`)})]}):i(n,{children:[b?i(`p`,{class:m.question,children:b}):null,g.pending?i(`div`,{class:m.pending,role:`status`,children:[i(`span`,{class:`${m.spinner} spin`,"aria-hidden":`true`}),i(`span`,{children:t(`btw.thinking`)}),i(`button`,{type:`button`,class:m.cancel,onClick:()=>p(),children:t(`common.cancel`)})]}):g.error?i(`p`,{class:m.error,role:`alert`,children:g.error.message}):v?i(`div`,{class:m.answer,children:i(f,{text:v.answer})}):null]})}),v?i(`footer`,{class:m.foot,children:[t(`btw.tokens`,{model:v.model,input:v.usage.input.toLocaleString(),output:v.usage.output.toLocaleString()}),v.truncated?` · ${t(`btw.truncated`)}`:``]}):null]})}export{g as BtwPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,g as r,i,n as a,p as o,r as s,t as c}from"./jsxRuntime-BjUOR156.js";import{t as l}from"./icons-Bk2j3B6A.js";import{E as u,S as d,T as f,a as p,b as m,d as h,g,i as _,r as v,t as y}from"./index-CpA8C_JP.js";import{a as b,c as x,i as S,l as C,n as w,o as T,r as E,s as D,t as O,u as k}from"./shared-CWxbpk_V.js";var A=`https://github.com/GustavoGutierrez/alisio`;function j(){return c(`section`,{class:k.about,children:[c(w,{title:t(`settings.about`)}),c(`img`,{class:k.aboutLogo,src:`/alisio-wordmark.png`,alt:`Alisio`,width:320,height:150}),c(`p`,{class:k.aboutDescription,children:t(`about.description`)}),c(`p`,{class:k.aboutAttribution,children:`Gustavo Gutiérrez · Bogotá, Colombia`}),c(`a`,{class:k.aboutLink,href:A,target:`_blank`,rel:`noopener noreferrer`,"aria-label":t(`about.repositoryLabel`),children:[c(l,{name:`github`,size:19}),t(`about.repository`)]})]})}function M(){let e=x(),[i,a]=r(),o=C(e?()=>g.agents(e.id):void 0,[e?.id],[`agents`,`plugins`]),s=m.value,u=s?.agent??o.data?.find(e=>e.default)?.id;return c(n,{children:[c(w,{title:t(`settings.agents`),body:t(`agents.lead`),workspace:e?.path}),c(b,{loading:o.loading&&!o.data,error:o.error,empty:e?void 0:`settings.noWorkspace`}),c(`ul`,{class:k.rows,children:(o.data??[]).map(e=>c(`li`,{class:k.row,"data-current":e.id===u,children:[c(`div`,{class:k.rowMain,children:[c(`div`,{class:k.rowTitle,children:[c(`span`,{class:k.cardName,children:e.name}),c(E,{tone:`off`,children:t(`agents.source.${e.source}`)}),e.readOnly?c(E,{tone:`warn`,children:t(`agents.readOnly`)}):null,e.default?c(E,{tone:`ok`,children:t(`agents.default`)}):null]}),c(`p`,{class:k.cardText,children:e.description}),e.model?c(`p`,{class:k.meta,children:t(`agents.model`,{model:e.model})}):null,e.instructions?c(n,{children:[c(`button`,{type:`button`,class:k.linkButton,"aria-expanded":i===e.id,onClick:()=>a(i===e.id?void 0:e.id),children:[c(l,{name:i===e.id?`chevronDown`:`chevronRight`,size:14}),t(`agents.instructions`)]}),i===e.id?c(`pre`,{class:k.instructions,children:e.instructions}):null]}):null]}),c(`div`,{class:k.rowActions,children:s&&!s.parentId?e.id===u?c(`span`,{class:k.meta,children:t(`agents.inUse`)}):c(`button`,{type:`button`,class:k.secondary,onClick:()=>void d({agent:e.id}),children:t(`agents.use`)}):null})]},e.id))})]})}function N(){return c(n,{children:[c(w,{title:t(`settings.appearance`),body:t(`appearance.lead`)}),c(O,{legend:t(`settings.theme`),value:p.value,options:[`dark`,`light`,`system`].map(e=>({id:e,label:t(`theme.${e}`)})),onChange:_}),c(O,{legend:t(`settings.density`),value:y.value,options:[`compact`,`detailed`].map(e=>({id:e,label:t(`density.${e}`)})),onChange:v})]})}var P=/^(tui|agents)\./;function F(e){let{setting:n}=e,[i,a]=r(),[o,s]=r(!1),l=async t=>{s(!0);try{await e.onSave(t),a(void 0)}finally{s(!1)}},u=t(`setting.${n.key}`),d=`setting-${n.key}`,f=()=>{if(i!==void 0){if(n.kind===`number`){let e=Number(i);if(i.trim()===``||!Number.isFinite(e))return a(void 0);l(e)}else l(i.trim()===``?null:i)}};return c(`li`,{class:k.settingRow,children:[c(`label`,{class:k.settingLabel,for:d,children:[c(`span`,{children:u}),c(`code`,{class:k.settingKey,children:n.key})]}),n.kind===`boolean`?c(T,{checked:n.value===!0,label:u,disabled:e.disabled,busy:o,onChange:e=>void l(e)}):n.kind===`enum`?c(`select`,{id:d,class:k.input,disabled:e.disabled||o,value:typeof n.value==`string`?n.value:``,onChange:e=>{let t=e.target.value;l(t===``?null:t)},children:[c(`option`,{value:``,children:t(`settings.default`)}),(n.options??[]).map(e=>c(`option`,{value:e,children:e},e))]}):c(`input`,{id:d,class:k.input,type:n.kind===`number`?`number`:`text`,disabled:e.disabled||o,value:i??(n.value===void 0?``:String(n.value)),onInput:e=>a(e.target.value),onBlur:f,onKeyDown:e=>{e.key===`Enter`&&f(),e.key===`Escape`&&i!==void 0&&(e.stopPropagation(),a(void 0))}})]})}function I(){let e=x(),r=C(e?()=>g.settings(e.id):void 0,[e?.id]),o=async(t,n)=>{if(e&&r.data)try{await g.setSetting(e.id,t,n),r.set({...r.data,settings:r.data.settings.map(e=>e.key===t?{...e,...n===null?{value:void 0}:{value:n}}:e)})}catch(e){throw u(D(e)),e}},l=(r.data?.settings??[]).filter(e=>!P.test(e.key));return c(n,{children:[c(w,{title:t(`settings.general`)}),c(O,{legend:t(`settings.language`),value:s.value,options:a.map(e=>({id:e,label:t(`language.${e}`)})),onChange:i}),c(`h4`,{class:k.sectionTitle,children:t(`settings.agentSettings`)}),c(`p`,{class:k.note,children:[t(`settings.agentSettingsLead`),r.data?c(n,{children:[` `,c(`code`,{children:r.data.settingsPath})]}):null]}),c(b,{loading:r.loading&&!r.data,error:r.error,empty:e?void 0:`settings.noWorkspace`}),r.data?.readOnly?c(`p`,{class:k.note,children:t(`settings.readOnly`)}):null,c(`ul`,{class:k.settingList,children:l.map(e=>c(F,{setting:e,disabled:!!r.data?.readOnly,onSave:t=>o(e.key,t)},e.key))})]})}var L={connected:`ok`,connecting:`warn`,failed:`danger`,"needs-authentication":`warn`,"restart-required":`warn`};function R(e){let[n,i]=r(!1);return c(`div`,{class:k.confirm,role:`alertdialog`,"aria-labelledby":`mcp-consent-title`,children:[c(`h4`,{id:`mcp-consent-title`,class:k.confirmTitle,children:[c(l,{name:`alert`,size:17}),t(`mcp.consentTitle`)]}),c(`p`,{class:k.cardText,children:t(`mcp.consentBody`)}),c(`label`,{class:k.checkRow,children:[c(`input`,{type:`checkbox`,checked:n,onChange:e=>i(e.target.checked)}),c(`span`,{children:t(`mcp.remember`)})]}),c(`div`,{class:k.actions,children:[c(`button`,{type:`button`,class:k.secondary,onClick:e.onCancel,children:t(`common.cancel`)}),c(`button`,{type:`button`,class:k.primary,onClick:()=>e.onGrant(n),children:t(`mcp.grant`)})]})]})}function z(){let e=x(),[i,a]=r(!1),[o,s]=r(),l=C(e?()=>g.mcp(e.id):void 0,[e?.id],[`mcp`]),d=l.data,f=e=>{d&&l.set({...d,servers:d.servers.map(t=>t.name===e.name?e:t)})},p=async(t,n,r)=>{if(e){s(t.name);try{let i=await g.setMcp(e.id,t.name,n,r);f(i),r&&i.status!==`connected`&&i.diagnostic&&u(i.diagnostic)}catch(e){u(D(e))}finally{s(void 0)}}},m=async t=>{if(e){a(!1);try{l.set(await g.mcpConsent(e.id,t))}catch(e){u(D(e))}}},h=d?.permission===`granted`;return c(n,{children:[c(w,{title:t(`settings.mcp`),body:t(`mcp.lead`),workspace:e?.path}),d?c(`div`,{class:k.banner,"data-tone":h?`ok`:`warn`,children:[c(`span`,{children:d.permission===`read-only`?t(`mcp.readOnly`):h?d.persisted?t(`mcp.grantedPersisted`):t(`mcp.granted`):t(`mcp.notGranted`)}),d.permission===`not-granted`&&!i?c(`button`,{type:`button`,class:k.primary,onClick:()=>a(!0),children:t(`mcp.grant`)}):null]}):null,i?c(R,{onCancel:()=>a(!1),onGrant:e=>void m(e)}):null,c(b,{loading:l.loading&&!d,error:l.error,empty:e?d&&!d.servers.length?`mcp.none`:void 0:`settings.noWorkspace`}),c(`ul`,{class:k.rows,children:(d?.servers??[]).map(e=>c(`li`,{class:k.row,children:[c(`div`,{class:k.rowMain,children:[c(`div`,{class:k.rowTitle,children:[c(`span`,{class:k.cardName,children:e.displayName}),c(E,{tone:L[e.status]??`off`,children:t(`mcp.status`,{status:e.status})})]}),c(`p`,{class:k.meta,children:t(`mcp.meta`,{transport:e.transport,source:e.source,tools:e.counts.tools,resources:e.counts.resources,prompts:e.counts.prompts})}),e.diagnostic?c(`p`,{class:k.diagnostic,children:e.diagnostic}):null]}),c(`div`,{class:k.rowActions,children:[e.enabled&&e.status!==`connected`?c(`button`,{type:`button`,class:k.secondary,disabled:!h||o===e.name,title:h?void 0:t(`mcp.needsGrant`),onClick:()=>void p(e,!0,!0),children:t(`mcp.connect`)}):null,c(T,{checked:e.enabled,label:t(`plugins.enableNamed`,{name:e.displayName}),disabled:d?.permission===`read-only`,busy:o===e.name,onChange:t=>void p(e,t,!1)})]})]},e.name))})]})}var B={apiKey:`API key`,bearerToken:`Bearer token`};function V(e){return e.configured?e.source===`env`?t(`models.credential.env`):e.tail?t(`models.credential.storedTail`,{tail:e.tail}):t(`models.credential.stored`):t(`models.credential.missing`)}function H(e){let[n,i]=r(``),[a,o]=r(!1),s=B[e.field]??e.field,l=`cred-${e.profile}-${e.field}`,d=async()=>{let r=n.trim();if(r){o(!0);try{let n=await g.setCredentials(e.profile,{[e.field]:r});e.onChange({...n,source:`file`}),i(``),u(t(`models.credential.saved`))}catch(e){u(D(e))}finally{o(!1)}}},f=async()=>{o(!0);try{await g.deleteCredentials(e.profile),e.onChange({configured:!1})}catch(e){u(D(e))}finally{o(!1)}};return c(`div`,{class:k.credential,children:[c(`label`,{for:l,class:k.settingLabel,children:[c(`span`,{children:s}),c(`span`,{class:k.meta,"data-configured":e.status.configured,children:V(e.status)})]}),c(`form`,{class:k.credentialForm,onSubmit:e=>{e.preventDefault(),d()},children:[c(`input`,{id:l,class:k.input,type:`password`,autocomplete:`off`,spellcheck:!1,placeholder:e.status.configured?t(`models.credential.replace`):t(`models.credential.enter`),value:n,disabled:a,onInput:e=>i(e.target.value)}),c(`button`,{type:`submit`,class:k.primary,disabled:a||!n.trim(),children:t(`models.credential.save`)}),e.status.configured&&e.status.source===`file`?c(`button`,{type:`button`,class:k.secondary,disabled:a,onClick:()=>void f(),children:t(`models.credential.remove`)}):null]})]})}function U(e){let[n,i]=r(e.initial?.name??``),[a,o]=r(e.initial?.provider??e.types[0]?.id??``),[s,l]=r(e.initial?.model??``),[d,f]=r(e.initial?.values??{}),[p,m]=r(!1),h=(e.types.find(e=>e.id===a)?.fields??[]).filter(e=>e.kind!==`secret`),_=(e,t)=>d[e]??t,v=async()=>{m(!0);try{let t={};for(let e of h){let n=_(e.key,e.defaultValue);n!==void 0&&n!==``&&(t[e.key]=n)}e.onSaved(await g.saveProfile(e.workspace,n.trim(),{provider:a,values:t,model:s}))}catch(e){u(D(e))}finally{m(!1)}};return c(`form`,{class:k.profileForm,onSubmit:e=>{e.preventDefault(),v()},children:[c(`label`,{class:k.formRow,children:[c(`span`,{children:t(`models.form.name`)}),c(`input`,{class:k.input,required:!0,pattern:`[A-Za-z0-9][A-Za-z0-9._\\-]{0,63}`,disabled:!!e.initial,value:n,onInput:e=>i(e.target.value)})]}),c(`label`,{class:k.formRow,children:[c(`span`,{children:t(`models.form.type`)}),c(`select`,{class:k.input,value:a,onChange:e=>o(e.target.value),children:e.types.map(e=>c(`option`,{value:e.id,children:e.name},e.id))})]}),h.map(e=>c(`label`,{class:k.formRow,title:e.description,children:[c(`span`,{children:e.label}),e.kind===`select`?c(`select`,{class:k.input,value:String(_(e.key,e.defaultValue)??``),onChange:t=>f({...d,[e.key]:t.target.value}),children:(e.options??[]).map(e=>c(`option`,{value:e.value,children:e.label},e.value))}):e.kind===`boolean`?c(`input`,{type:`checkbox`,checked:_(e.key,e.defaultValue)===!0,onChange:t=>f({...d,[e.key]:t.target.checked})}):c(`input`,{class:k.input,type:e.kind===`url`?`url`:`text`,required:e.required,value:String(_(e.key,e.defaultValue)??``),onInput:t=>f({...d,[e.key]:t.target.value})})]},e.key)),c(`label`,{class:k.formRow,children:[c(`span`,{children:t(`models.form.model`)}),c(`input`,{class:k.input,required:!0,value:s,onInput:e=>l(e.target.value)})]}),c(`p`,{class:k.note,children:t(`models.form.secretsNote`)}),c(`div`,{class:k.actions,children:[c(`button`,{type:`button`,class:k.secondary,onClick:e.onCancel,children:t(`common.cancel`)}),c(`button`,{type:`submit`,class:k.primary,disabled:p,children:t(`models.form.save`)})]})]})}function W(e){let{profile:i,overview:a}=e,[o,s]=r(!1),[d,f]=r(i.model),[p,m]=r(!1),h=a.types.find(e=>e.id===i.provider),_=a.current?.profile===i.name,v=async()=>{m(!0);try{let{changed:n}=await g.activateProvider(e.workspace,i.name,d);u(n?t(`models.activated`,{name:i.name}):t(`models.unchanged`)),e.onActivated()}catch(e){u(D(e))}finally{m(!1)}},y=e.catalog?.models??[];return c(`li`,{class:k.row,"data-current":_,children:c(`div`,{class:k.rowMain,children:[c(`div`,{class:k.rowTitle,children:[c(`span`,{class:k.cardName,children:i.name}),c(E,{tone:`off`,children:h?.name??i.provider}),i.active?c(E,{tone:`ok`,children:t(`models.activeGlobal`)}):null,_?c(E,{tone:`ok`,children:t(`models.current`)}):null,c(`button`,{type:`button`,class:k.linkButton,"aria-expanded":o,onClick:()=>s(!o),children:[c(l,{name:`edit`,size:14}),t(`models.edit`)]})]}),o?c(U,{types:a.types,initial:i,workspace:e.workspace,onCancel:()=>s(!1),onSaved:t=>{s(!1),e.onChange(t)}}):c(`dl`,{class:k.facts,children:[c(`dt`,{children:t(`models.form.model`)}),c(`dd`,{children:i.model}),Object.entries(i.values).map(([e,t])=>c(n,{children:[c(`dt`,{children:h?.fields.find(t=>t.key===e)?.label??e}),c(`dd`,{children:String(t)})]},e))]}),Object.entries(i.credentials).map(([t,n])=>c(H,{profile:i.name,field:t,status:n,onChange:n=>e.onChange({...i,credentials:{...i.credentials,[t]:n}})},t)),c(`form`,{class:k.credentialForm,onSubmit:e=>{e.preventDefault(),v()},children:[y.length?c(`select`,{class:k.input,"aria-label":t(`models.form.model`),value:d,onChange:e=>f(e.target.value),children:[y.some(e=>e.id===d)?null:c(`option`,{value:d,children:d}),y.map(e=>c(`option`,{value:e.id,children:e.name??e.id},e.id))]}):c(`input`,{class:k.input,"aria-label":t(`models.form.model`),value:d,onInput:e=>f(e.target.value)}),c(`button`,{type:`submit`,class:k.secondary,disabled:p||!d.trim(),children:t(`models.activate`)}),e.catalog?.unavailable?c(`span`,{class:k.meta,children:t(`composer.modelsUnavailable`)}):null]})]})})}function G(){let e=x(),[i,a]=r(!1),o=C(e?()=>g.providers(e.id):void 0,[e?.id],[`models`]),s=C(e?()=>g.providerModels(e.id).catch(()=>[]):void 0,[e?.id],[`models`]),l=o.data,u=e=>{if(!l)return;let t=l.profiles.some(t=>t.name===e.name);o.set({...l,profiles:t?l.profiles.map(t=>t.name===e.name?e:t):[...l.profiles,e]})};return c(n,{children:[c(w,{title:t(`settings.models`),body:t(`models.lead`),workspace:e?.path}),l?.current?c(`p`,{class:k.banner,"data-tone":`ok`,children:t(`models.running`,{provider:l.current.provider,model:l.current.model,profile:l.current.profile??`—`})}):null,c(b,{loading:o.loading&&!l,error:o.error,empty:e?l&&!l.profiles.length?`models.none`:void 0:`settings.noWorkspace`}),c(`ul`,{class:k.rows,children:(l?.profiles??[]).map(t=>c(W,{profile:t,overview:l,catalog:s.data?.find(e=>e.profile===t.name),workspace:e?.id??``,onChange:u,onActivated:()=>o.reload()},t.name))}),e&&l?.types.length?i?c(U,{types:l.types,workspace:e.id,onCancel:()=>a(!1),onSaved:e=>{a(!1),u(e)}}):c(`button`,{type:`button`,class:`${k.secondary} ${k.addButton}`,onClick:()=>a(!0),children:t(`models.add`)}):null]})}var K={active:`ok`,inactive:`off`,failed:`danger`,"restart-required":`warn`};function q(e){return e.status===`failed`?t(`plugins.status.failed`):e.status===`restart-required`?t(`plugins.status.restart`):e.enabled?t(`plugins.status.enabled`):t(`plugins.status.disabled`)}function J(e){let{plugin:i}=e,[a,o]=r(!1),s=`plugin-${i.id}`;return c(`li`,{class:k.card,"data-open":a,children:[c(`button`,{type:`button`,class:k.cardHead,"aria-expanded":a,"aria-controls":s,onClick:()=>o(!a),children:[c(`span`,{class:k.cardName,title:i.name,children:i.name}),c(E,{tone:K[i.status],children:q(i)}),c(l,{name:a?`chevronDown`:`chevronRight`,size:16,class:k.chevron})]}),a?c(`div`,{id:s,class:k.cardBody,children:[i.description?c(`p`,{class:k.cardText,children:i.description}):null,c(`dl`,{class:k.facts,children:[c(`dt`,{children:t(`plugins.id`)}),c(`dd`,{children:c(`code`,{children:i.id})}),i.version?c(n,{children:[c(`dt`,{children:t(`plugins.version`)}),c(`dd`,{children:i.version})]}):null,c(`dt`,{children:t(`plugins.source`)}),c(`dd`,{children:i.builtin?t(`plugins.builtin`):i.source}),i.categories.length?c(n,{children:[c(`dt`,{children:t(`plugins.categories`)}),c(`dd`,{children:i.categories.join(`, `)})]}):null,c(`dt`,{children:t(`plugins.tools`)}),c(`dd`,{children:i.tools.length?i.tools.join(`, `):`—`}),c(`dt`,{children:t(`plugins.commands`)}),c(`dd`,{children:i.commands.length?i.commands.map(e=>`/${e}`).join(`, `):`—`})]}),i.diagnostic?c(`p`,{class:k.diagnostic,children:i.diagnostic}):null,c(`div`,{class:k.toggleRow,children:[c(`span`,{children:t(`plugins.enable`)}),c(T,{checked:i.enabled,label:t(`plugins.enableNamed`,{name:i.name}),disabled:!i.manageable,busy:e.busy,onChange:e.onToggle})]})]}):null]})}function Y(){let e=x(),[i,a]=r(`list`),[o,s]=r(``),[d,f]=r(),p=C(e?()=>g.plugins(e.id):void 0,[e?.id],[`plugins`]),m=C(e&&i===`configuration`?()=>g.settings(e.id):void 0,[e?.id,i]),h=async(n,r)=>{if(e){f(n.id);try{let i=await g.setPlugin(e.id,n.id,r);p.set((p.data??[]).map(e=>e.id===i.id?i:e)),i.status===`restart-required`&&u(t(`plugins.deferred`))}catch(e){u(D(e))}finally{f(void 0)}}},_=o.trim().toLowerCase(),v=(p.data??[]).filter(e=>!_||e.name.toLowerCase().includes(_)||e.id.toLowerCase().includes(_)||e.description.toLowerCase().includes(_));return c(n,{children:[c(w,{title:t(`settings.plugins`),body:t(`plugins.lead`),workspace:e?.path}),c(`div`,{class:k.tabs,role:`tablist`,children:[`configuration`,`list`].map(e=>c(`button`,{type:`button`,role:`tab`,class:k.tab,"aria-selected":i===e,onClick:()=>a(e),children:t(e===`list`?`plugins.tab.list`:`plugins.tab.configuration`)},e))}),i===`configuration`?c(`div`,{class:k.stack,children:[c(`p`,{class:k.callout,children:[c(l,{name:`shield`,size:16}),c(`span`,{children:t(`plugins.notSandboxed`)})]}),c(`p`,{class:k.note,children:t(`plugins.howToInstall`)}),c(`p`,{class:k.note,children:t(`plugins.applyNote`)}),m.data?c(`p`,{class:k.note,children:[t(`plugins.projectFile`),` `,c(`code`,{children:m.data.configPath})]}):null]}):c(n,{children:[c(S,{value:o,label:t(`plugins.search`),onInput:s}),c(`h4`,{class:k.listTitle,children:[t(`plugins.tab.list`),` `,c(`span`,{class:k.count,children:v.length})]}),c(b,{loading:p.loading&&!p.data,error:p.error,empty:e?p.data&&!v.length?`plugins.none`:void 0:`settings.noWorkspace`}),c(`ul`,{class:k.grid,children:v.map(e=>c(J,{plugin:e,busy:d===e.id,onToggle:t=>void h(e,t)},e.id))})]})]})}function X(){let e=x(),[i,a]=r(``),[o,s]=r(),l=C(e?()=>g.skills(e.id):void 0,[e?.id],[`skills`]),d=async(t,n)=>{if(e){s(t.id);try{let r=await g.setSkill(e.id,t.id,n);l.set((l.data??[]).map(e=>e.id===r.id&&e.effective?r:e))}catch(e){u(D(e))}finally{s(void 0)}}},f=i.trim().toLowerCase(),p=(l.data??[]).filter(e=>!f||e.displayId.toLowerCase().includes(f)||e.description.toLowerCase().includes(f));return c(n,{children:[c(w,{title:t(`settings.skills`),body:t(`skills.lead`),workspace:e?.path}),c(S,{value:i,label:t(`skills.search`),onInput:a}),c(b,{loading:l.loading&&!l.data,error:l.error,empty:e?l.data&&!p.length?`skills.none`:void 0:`settings.noWorkspace`}),c(`ul`,{class:k.rows,children:p.map(e=>c(`li`,{class:k.row,"data-muted":!e.effective,children:[c(`div`,{class:k.rowMain,children:[c(`div`,{class:k.rowTitle,children:[c(`span`,{class:k.cardName,children:e.displayId}),c(E,{tone:e.enabled&&e.effective?`ok`:`off`,children:e.effective?e.enabled?t(`plugins.status.enabled`):t(`plugins.status.disabled`):t(`skills.shadowed`)})]}),c(`p`,{class:k.cardText,children:e.description}),c(`p`,{class:k.meta,children:[t(`skills.meta`,{scope:e.owner?`${e.scope} · ${e.owner.name}`:e.scope,tokens:e.approximateTokens}),e.shadowedBy?` · ${t(`skills.shadowedBy`,{id:e.shadowedBy})}`:``,e.locked?` · ${t(`skills.locked`)}`:``]})]}),c(T,{checked:e.enabled,label:t(`plugins.enableNamed`,{name:e.displayId}),disabled:!e.effective||!e.manageable||e.locked,busy:o===e.id,onChange:t=>void d(e,t)})]},`${e.id}:${e.source}`))})]})}var Z=[{id:`general`,icon:`settings`},{id:`models`,icon:`database`},{id:`plugins`,icon:`sliders`},{id:`skills`,icon:`book`},{id:`mcp`,icon:`plug`},{id:`agents`,icon:`users`},{id:`appearance`,icon:`palette`},{id:`about`,icon:`info`}],Q=`button:not(:disabled), input:not(:disabled), select:not(:disabled), [tabindex='0']`;function $(e){let n=x(),r=C(n?()=>g.settings(n.id):void 0,[n?.id]),i=r.data?[{label:t(`config.effective`),path:r.data.configPath},{label:t(`config.settings`),path:r.data.settingsPath},{label:t(`config.providers`),path:r.data.providersPath}]:[];return c(`div`,{class:k.popover,role:`dialog`,"aria-label":t(`config.open`),children:[c(`div`,{class:k.popoverHead,children:[c(`strong`,{children:t(`config.open`)}),c(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`common.close`),onClick:e.onClose,children:c(l,{name:`x`,size:16})})]}),c(`p`,{class:k.note,children:t(`config.lead`)}),n?null:c(`p`,{class:k.note,children:t(`settings.noWorkspace`)}),r.error?c(`p`,{class:k.errorText,children:r.error}):null,c(`ul`,{class:k.paths,children:i.map(e=>c(`li`,{children:[c(`span`,{class:k.meta,children:e.label}),c(`span`,{class:k.pathRow,children:[c(`code`,{class:k.path,children:e.path}),c(h,{text:()=>e.path,label:t(`config.copy`)})]})]},e.label))}),r.data&&!r.data.trusted?c(`p`,{class:k.note,children:t(`config.untrusted`)}):null]})}function ee(){let[n,i]=r(`general`),[a,s]=r(!1),u=o(null);e(()=>{let e=document.activeElement;return u.current?.querySelector(`nav button`)?.focus(),()=>e?.focus()},[]);let d=()=>{f.value=!1};return c(`div`,{class:k.backdrop,onMouseDown:e=>{e.target===e.currentTarget&&d()},children:c(`div`,{ref:u,class:k.dialog,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,onKeyDown:e=>{if(e.key===`Escape`&&(a?s(!1):d()),e.key===`Tab`){let t=[...u.current?.querySelectorAll(Q)??[]],n=t[0],r=t.at(-1);e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())}},children:[c(`nav`,{class:k.nav,"aria-label":t(`settings.title`),children:[c(`h2`,{id:`settings-title`,class:k.heading,children:t(`settings.title`)}),Z.map(({id:e,icon:r})=>c(`button`,{type:`button`,class:k.navItem,"aria-current":n===e?`page`:void 0,onClick:()=>i(e),children:[c(l,{name:r,size:17}),t(`settings.${e}`)]},e))]}),c(`div`,{class:k.content,children:[c(`div`,{class:k.topBar,children:[c(`button`,{type:`button`,class:k.outline,"aria-expanded":a,onClick:()=>s(!a),children:t(`config.open`)}),c(`button`,{type:`button`,class:`icon-btn`,"aria-label":t(`common.close`),onClick:d,children:c(l,{name:`x`,size:18})})]}),a?c($,{onClose:()=>s(!1)}):null,c(n===`general`?I:n===`models`?G:n===`plugins`?Y:n===`skills`?X:n===`mcp`?z:n===`agents`?M:n===`appearance`?N:j,{})]})]})})}export{ee as SettingsModal};
|
package/dist/web/assets/{abnfDiagram-VCTEODGH-CdMLAOHV.js → abnfDiagram-VCTEODGH-CxVXrbZW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e,t}from"./mermaid-parser.core-
|
|
1
|
+
import{m as e,t}from"./mermaid-parser.core-DPUySrN0.js";import{n}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as r}from"./src-B6xuSHsQ.js";import"./chunk-DU6HZSFF-ChH-oACD.js";import{n as i,r as a,t as o}from"./chunk-SVP7TREG-Bbvu5LYe.js";import{t as s}from"./chunk-JWPE2WC7-DVXcaiue.js";import"./engine-DFDJxPdV.js";var c=e().RailroadAbnf.parser.LangiumParser,l=n(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=n(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=n(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=n(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=n(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=n(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=n(e=>{s(e,o),e.title&&o.setTitle(e.title),e.rules.map(e=>o.addRule(m(e)))},`populateDb`),g={parser:{parse:n(e=>{o.clear(),r.debug(`[ABNF Parser] Starting Langium parse`);let n=c.parse(e);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new t(n);let i=n.value;r.debug(`[ABNF Parser] Parsed rules:`,i.rules.length),h(i),r.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:o}},db:o,renderer:a,styles:i};export{g as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._shell_b0prd_4._shell_b0prd_4{grid-template-rows:1fr;grid-template-columns:1fr}._breadcrumb_b0prd_9{flex:1;align-items:center;gap:6px;min-width:0;font-size:15px;display:flex}._crumbLink_b0prd_18{border-radius:var(--radius-sm);color:var(--muted);background:0 0;border:0;padding:2px 4px}._crumbLink_b0prd_18:hover{color:var(--text);background:var(--hover)}._crumbCurrent_b0prd_31{text-overflow:ellipsis;white-space:nowrap;font-weight:600;overflow:hidden}._listHead_b0prd_38{justify-content:space-between;align-items:flex-start;gap:16px;display:flex}._templateCard_b0prd_45{border:1px solid var(--border);background:var(--surface);text-align:left;border-radius:14px;gap:4px;width:100%;padding:14px 16px;display:grid}._templateCard_b0prd_45:hover,._templateCard_b0prd_45:focus-visible{border-color:var(--border-strong);background:var(--hover)}._templateName_b0prd_62{font-size:15px;font-weight:600}._templateText_b0prd_67{color:var(--muted);font-size:13.5px;line-height:1.45}._rowButton_b0prd_73{text-align:left;background:0 0;border:0;flex:1;min-width:0;padding:0}._columns_b0prd_82{grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);align-items:start;gap:20px;display:grid}._column_b0prd_82{gap:14px;min-width:0;display:grid}._section_b0prd_95{border:1px solid var(--border);background:var(--surface);border-radius:14px}._sectionHead_b0prd_101{text-align:left;background:0 0;border:0;align-items:center;gap:8px;width:100%;padding:12px 16px;font-size:15px;font-weight:600;display:flex}._sectionBody_b0prd_114{gap:12px;padding:0 16px 16px;display:grid}._field_b0prd_120{gap:6px;font-size:13.5px;display:grid}._fieldLabel_b0prd_126{color:var(--muted);justify-content:space-between;gap:8px;display:flex}._control_b0prd_133{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--panel);width:100%;min-height:36px;color:var(--text);font:inherit;padding:7px 10px;font-size:14px}._control_b0prd_133:focus{border-color:var(--accent);outline:0}._control_b0prd_133:disabled{opacity:.55}._control_b0prd_133[aria-invalid=true]{border-color:var(--danger)}textarea._control_b0prd_133{resize:vertical;min-height:180px;line-height:1.5}._settingsGrid_b0prd_164{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;display:grid}._fieldHint_b0prd_170{color:var(--faint);font-size:12.5px}._fieldError_b0prd_175{color:var(--danger);font-size:12.5px}._saveButton_b0prd_180{width:100%;height:40px}._assist_b0prd_185{border:1px dashed var(--border-strong);background:var(--accent-soft);border-radius:14px;gap:8px;padding:14px 16px;display:grid}._assistTitle_b0prd_194{align-items:center;gap:8px;margin:0;font-size:15px;display:flex}._assistActions_b0prd_202{justify-content:flex-end;display:flex}._code_b0prd_207{border:1px solid var(--border);background:var(--code-bg);border-radius:14px;position:relative;overflow:hidden}._codeHead_b0prd_215{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:8px;padding:8px 10px 8px 16px;font-size:14px;font-weight:600;display:flex}._codeBody_b0prd_226{max-height:340px;font-family:var(--mono);margin:0;padding:10px 0;font-size:12.5px;line-height:1.6;overflow:auto}._codeLine_b0prd_236{white-space:pre;display:flex}._lineNo_b0prd_241{width:3.2em;color:var(--faint);text-align:right;-webkit-user-select:none;user-select:none;flex:none;padding-right:12px}._tok-key_b0prd_250{color:var(--accent-strong)}._tok-string_b0prd_254{color:var(--ok)}._tok-number_b0prd_258,._tok-keyword_b0prd_259{color:var(--warn)}._tok-command_b0prd_263{color:var(--accent);font-weight:600}._tok-punct_b0prd_268{color:var(--muted)}._stepper_b0prd_272{border:1px solid var(--border);background:var(--surface);border-radius:14px;padding:14px 16px;position:relative}._stepperHead_b0prd_280{justify-content:space-between;align-items:center;margin:0 0 10px;font-size:15px;display:flex}._steps_b0prd_288{margin:0;padding:0;list-style:none;display:grid}._step_b0prd_272{grid-template-columns:26px 1fr;gap:10px;padding-bottom:14px;display:grid;position:relative}._step_b0prd_272:not(:last-child):before{content:"";background:var(--border);width:2px;position:absolute;top:24px;bottom:2px;left:11px}._stepNode_b0prd_313{border:2px solid var(--border-strong);background:var(--panel);width:24px;height:24px;color:var(--muted);border-radius:50%;place-items:center;font-size:12px;display:grid}._step_b0prd_272[data-done=true] ._stepNode_b0prd_313{border-color:var(--accent);background:var(--accent);color:var(--accent-contrast)}._stepTitle_b0prd_331{margin:2px 0;font-size:14px;font-weight:600}._stepText_b0prd_337{color:var(--muted);margin:0;font-size:13px}._overlay_b0prd_343{z-index:5;background:color-mix(in srgb, var(--panel) 72%, transparent);place-items:center;padding:16px;display:grid;position:absolute;inset:0}._overlayCard_b0prd_353{border:1px solid var(--border-strong);background:var(--panel);width:min(440px,100%);box-shadow:var(--shadow);text-align:center;border-radius:18px;gap:12px;padding:22px 24px;display:grid}._overlayTitle_b0prd_365{margin:0;font-size:18px}._spinner_b0prd_370{border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:34px;height:34px;margin:0 auto;animation:.9s linear infinite _spin_b0prd_370}._progress_b0prd_380{background:var(--border);border-radius:2px;height:4px;overflow:hidden}._progressBar_b0prd_387{background:var(--accent);width:40%;height:100%;animation:1.4s ease-in-out infinite _slide_b0prd_1}@keyframes _spin_b0prd_370{to{transform:rotate(360deg)}}@keyframes _slide_b0prd_1{0%{transform:translate(-100%)}to{transform:translate(250%)}}@media (prefers-reduced-motion:reduce){._spinner_b0prd_370,._progressBar_b0prd_387{animation:none}}._overlayActions_b0prd_416{justify-content:center;gap:8px;display:flex}._picker_b0prd_422._picker_b0prd_422{grid-template-rows:auto 1fr;grid-template-columns:1fr;width:min(560px,100%);height:auto;max-height:min(640px,90vh)}._pickerHead_b0prd_430{border-bottom:1px solid var(--border);gap:10px;padding:18px 18px 10px;display:grid}._pickerList_b0prd_437{margin:0;padding:8px;list-style:none;overflow-y:auto}._pickerItem_b0prd_444{border-radius:var(--radius);text-align:left;background:0 0;border:0;gap:2px;width:100%;padding:10px 12px;display:grid}._pickerItem_b0prd_444:hover,._pickerItem_b0prd_444[data-selected=true]{background:var(--hover)}._pickerItem_b0prd_444[aria-current=true]{box-shadow:inset 3px 0 0 var(--accent)}._pickerTitle_b0prd_464{flex-wrap:wrap;align-items:center;gap:6px;font-weight:600;display:flex}@media (max-width:860px){._columns_b0prd_82,._settingsGrid_b0prd_164{grid-template-columns:1fr}._listHead_b0prd_38{flex-wrap:wrap}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as e,s as t}from"./jsxRuntime-BjUOR156.js";var n=[`auto`,`none`,`concise`,`detailed`],r=[`low`,`medium`,`high`],i=[`text`,`json_object`,`json_schema`];function a(e,t=``){return{scope:e,name:`New agent`,description:``,instructions:``,model:t,effort:``,summary:``,verbosity:``,format:`text`}}var o=e=>({effort:e.reasoning?.effort??``,summary:e.reasoning?.summary??``,verbosity:e.text?.verbosity??``,format:e.text?.format?.type??`text`});function s(e,t,n){return{scope:t,name:e.name,description:e.description,instructions:e.instructions,model:n,...o(e)}}function c(e){return{scope:e.scope,id:e.id,name:e.name,description:e.description,instructions:e.instructions,model:e.model,...o(e)}}function l(e,t){return{...e,name:t.name,description:t.description,instructions:t.instructions,...o(t)}}var u={known:!1,reasoning:!0,effortLevels:[`low`,`medium`,`high`],summary:!0,verbosity:!0,textFormats:[...i]};function d(e,t){return e?.find(e=>e.reference===t||e.id===t)?.capabilities??u}function f(e,t){let n={...e};return t.reasoning?n.effort&&!t.effortLevels.includes(n.effort)&&(n.effort=t.defaultEffort??``):(n.effort=``,n.summary=``),t.summary||(n.summary=``),t.textFormats.includes(n.format)||(n.format=`text`),t.verbosity||(n.verbosity=``),n}function p(e){let t={...e.effort?{effort:e.effort}:{},...e.summary?{summary:e.summary}:{}};return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.instructions.trim()?{instructions:e.instructions.trim()}:{},model:e.model.trim(),...Object.keys(t).length?{reasoning:t}:{},text:{format:{type:e.format},...e.verbosity?{verbosity:e.verbosity}:{}}}}var m=e=>JSON.stringify({...p(e),scope:e.scope});function h(e){let t=e.trim();if(!t)return`required`;if(t.length>80)return`tooLong`;if(!/[\p{L}\p{N}]/u.test(t))return`noLetters`}function g(e,t){return h(e.name)||!e.model.trim()||e.instructions.length>24e3||e.description.length>300?!1:!t||m(e)!==m(t)}function _(e,t){let n={...t.workspace&&e.scope===`project`?{workspace:t.workspace}:{},scope:e.scope,...p(e)},r=JSON.stringify(n,null,2),i=e.id?`-X PUT ${t.origin}/api/agents/${encodeURIComponent(e.id)}`:`-X POST ${t.origin}/api/agents`,a=``;try{let e=new URL(t.origin);a=e.port||(e.protocol===`https:`?`443`:`80`)}catch{}return[`curl ${i} \\`,` -H "Content-Type: application/json" \\`,` -H "Origin: ${t.origin}" \\`,` -H "Cookie: alisio_session_${a||`<port>`}=<session cookie>" \\`,` -d '${r.replace(/'/g,`'\\''`)}'`].join(`
|
|
2
|
+
`)}function v(e){let t=[],n=/("(?:[^"\\]|\\.)*")(\s*:)?|(-?\b\d+(?:\.\d+)?\b)|\b(true|false|null)\b|(\bcurl\b|-X|-H|-d)\b|([{}[\],])/g,r=0;for(let i of e.matchAll(n)){let n=i.index??0;n>r&&t.push({kind:`plain`,text:e.slice(r,n)}),i[1]?(t.push({kind:i[2]?`key`:`string`,text:i[1]}),i[2]&&t.push({kind:`punct`,text:i[2]})):i[3]?t.push({kind:`number`,text:i[3]}):i[4]?t.push({kind:`keyword`,text:i[4]}):i[5]?t.push({kind:`command`,text:i[5]}):i[6]&&t.push({kind:`punct`,text:i[6]}),r=n+i[0].length}return r<e.length&&t.push({kind:`plain`,text:e.slice(r)}),t}function y(e){return[{id:`define`,done:e.saved},{id:`runtime`,done:e.workspace},{id:`session`,done:e.saved&&e.sessions.length>0},{id:`events`,done:e.saved&&e.sessions.some(e=>!!e.title)}]}var b=`alisio.agents.gettingStarted`,x=()=>t(b)===`dismissed`,S=()=>e(b,`dismissed`);function C(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length?e.filter(e=>{let t=`${e.id} ${e.name} ${e.description}`.toLowerCase();return n.every(e=>t.includes(e))}):[...e]}function w(e,t){if(e.source!==`user`)return;let n=t.filter(t=>t.id===e.id);return n.find(e=>e.scope===`project`)?.scope??n[0]?.scope}function T(e,t=36){if(e.length<=t)return e;let n=e.includes(`\\`)&&!e.includes(`/`)?`\\`:`/`,r=e.split(n).filter(Boolean),i=``;for(let e=r.length-1;e>=0;e--){let a=i?`${r[e]}${n}${i}`:r[e];if(a.length+2>t)break;i=a}return i?`…${n}${i}`:`…${e.slice(-(t-1))}`}function E(e,t,n=36){if(!t)return``;if(e===`global`){let e=t.includes(`\\`)&&!t.includes(`/`)?`\\`:`/`;return`~${e}.agents${e}agents`}return T(t,n)}var D={shell:`_shell_b0prd_4`,breadcrumb:`_breadcrumb_b0prd_9`,crumbLink:`_crumbLink_b0prd_18`,crumbCurrent:`_crumbCurrent_b0prd_31`,listHead:`_listHead_b0prd_38`,templateCard:`_templateCard_b0prd_45`,templateName:`_templateName_b0prd_62`,templateText:`_templateText_b0prd_67`,rowButton:`_rowButton_b0prd_73`,columns:`_columns_b0prd_82`,column:`_column_b0prd_82`,section:`_section_b0prd_95`,sectionHead:`_sectionHead_b0prd_101`,sectionBody:`_sectionBody_b0prd_114`,field:`_field_b0prd_120`,fieldLabel:`_fieldLabel_b0prd_126`,control:`_control_b0prd_133`,settingsGrid:`_settingsGrid_b0prd_164`,fieldHint:`_fieldHint_b0prd_170`,fieldError:`_fieldError_b0prd_175`,saveButton:`_saveButton_b0prd_180`,assist:`_assist_b0prd_185`,assistTitle:`_assistTitle_b0prd_194`,assistActions:`_assistActions_b0prd_202`,code:`_code_b0prd_207`,codeHead:`_codeHead_b0prd_215`,codeBody:`_codeBody_b0prd_226`,codeLine:`_codeLine_b0prd_236`,lineNo:`_lineNo_b0prd_241`,tokKey:`_tok-key_b0prd_250`,tokString:`_tok-string_b0prd_254`,tokNumber:`_tok-number_b0prd_258`,tokKeyword:`_tok-keyword_b0prd_259`,tokCommand:`_tok-command_b0prd_263`,tokPunct:`_tok-punct_b0prd_268`,stepper:`_stepper_b0prd_272`,stepperHead:`_stepperHead_b0prd_280`,steps:`_steps_b0prd_288`,step:`_step_b0prd_272`,stepNode:`_stepNode_b0prd_313`,stepTitle:`_stepTitle_b0prd_331`,stepText:`_stepText_b0prd_337`,overlay:`_overlay_b0prd_343`,overlayCard:`_overlayCard_b0prd_353`,overlayTitle:`_overlayTitle_b0prd_365`,spinner:`_spinner_b0prd_370`,spin:`_spin_b0prd_370`,progress:`_progress_b0prd_380`,progressBar:`_progressBar_b0prd_387`,slide:`_slide_b0prd_1`,overlayActions:`_overlayActions_b0prd_416`,picker:`_picker_b0prd_422`,pickerHead:`_pickerHead_b0prd_430`,pickerList:`_pickerList_b0prd_437`,pickerItem:`_pickerItem_b0prd_444`,pickerTitle:`_pickerTitle_b0prd_464`};export{v as S,x as _,_ as a,w as b,S as c,f as d,c as f,p as g,m as h,r as i,a as l,s as m,n,g as o,l as p,i as r,d as s,D as t,C as u,y as v,E as x,h as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-FOHPRMQF-DzxwRta7.js";import{M as e}from"./mermaid-parser.core-DPUySrN0.js";export{e as createArchitectureServices};
|