@schlenkr/ragents 0.1.13 → 0.1.15
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/apps/server/package.json +1 -1
- package/apps/server/src/api/contracts.ts +19 -1
- package/apps/server/src/api/core-methods.ts +12 -0
- package/apps/server/src/chat-handler.ts +19 -0
- package/apps/server/src/host-api.json +2 -0
- package/apps/server/src/host-api.ts +2 -2
- package/apps/server/src/plugin-build/build.ts +1 -1
- package/apps/server/src/plugin-support/actor-programs/app-project.ts +61 -17
- package/apps/server/src/plugin-support/actor-programs/contract.ts +18 -1
- package/apps/server/src/plugin-support/actor-programs/service.ts +22 -1
- package/apps/server/src/plugin-support/plugin-folder.ts +14 -1
- package/apps/server/src/plugin-support/run-scripts.ts +27 -2
- package/apps/server/src/profile/compose.ts +2 -0
- package/apps/server/src/provider.ts +31 -6
- package/apps/server/src/ragents/chat-projection.ts +7 -0
- package/apps/server/src/ragents/global-chat.ts +5 -1
- package/apps/server/src/ragents/run-script-tools.ts +66 -0
- package/apps/server/src/ragents/session.ts +122 -60
- package/apps/server/src/title-compactor.ts +1 -1
- package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-CpPi6QLr.js → highlighted-body-KPVGNVTW-BwD4uYEe.js} +1 -1
- package/apps/web/dist/assets/main-KBrc5Q77.js +11 -0
- package/apps/web/dist/assets/{mermaid-HWGCJPDP-q-mf1kLN.js → mermaid-HWGCJPDP-CSCkaArr.js} +88 -88
- package/apps/web/dist/assets/runPanel-BjG5NBKm.js +26 -0
- package/apps/web/dist/help/guide-clients.html +21 -4
- package/apps/web/dist/help/guide-clients.md +23 -4
- package/apps/web/dist/help/guide-plugins.html +12 -2
- package/apps/web/dist/help/guide-plugins.md +9 -2
- package/apps/web/dist/help/guide-programs.html +8 -2
- package/apps/web/dist/help/guide-programs.md +9 -2
- package/apps/web/dist/help/guide-runtime.html +3 -2
- package/apps/web/dist/help/guide-runtime.md +3 -2
- package/apps/web/dist/help/index.html +1 -1
- package/apps/web/dist/help/mini-app.css +16 -2
- package/apps/web/dist/host-web.json +13 -13
- package/apps/web/dist/index.html +2 -2
- package/apps/web/dist/run-panel.html +2 -2
- package/apps/web/package.json +1 -1
- package/apps/web/src/App.tsx +12 -1
- package/apps/web/src/PluginRegistry.tsx +2 -2
- package/apps/web/src/SessionList.tsx +7 -6
- package/apps/web/src/SettingsModal.tsx +3 -3
- package/apps/web/src/actor-programs/client-ui/FilePicker.tsx +1 -1
- package/apps/web/src/api.ts +2 -0
- package/apps/web/src/run-overview.ts +1 -1
- package/apps/web/src/run-panel/RunPanelApp.tsx +1 -1
- package/apps/web/src/run-panel/RunPanelMenu.tsx +47 -11
- package/apps/web/src/ui/relative-time.ts +1 -1
- package/bundles/ragents.activity/ragents-bundle.json +1 -1
- package/bundles/ragents.actor-programs/ragents-bundle.json +4 -2
- package/bundles/ragents.actor-programs/server/index.js +437 -24
- package/bundles/ragents.actor-programs/server/index.js.map +4 -4
- package/bundles/ragents.actor-programs/web/index.js.map +1 -1
- package/bundles/ragents.ask/ragents-bundle.json +2 -2
- package/bundles/ragents.ask/server/index.js +1 -0
- package/bundles/ragents.ask/server/index.js.map +2 -2
- package/bundles/ragents.browser/ragents-bundle.json +1 -1
- package/bundles/ragents.documents/ragents-bundle.json +2 -2
- package/bundles/ragents.documents/web/classes.json +1 -1
- package/bundles/ragents.documents/web/index.js +1 -1
- package/bundles/ragents.documents/web/index.js.map +2 -2
- package/bundles/ragents.lsp-fsharp/ragents-bundle.json +1 -1
- package/bundles/ragents.lsp-roslyn/ragents-bundle.json +1 -1
- package/bundles/ragents.lsp-typescript/ragents-bundle.json +1 -1
- package/bundles/ragents.model-relay/ragents-bundle.json +1 -1
- package/bundles/ragents.orchestration/ragents-bundle.json +7 -4
- package/bundles/ragents.orchestration/server/chunks/chunk-QS3WJ3D7.js +11 -0
- package/bundles/ragents.orchestration/server/chunks/chunk-QS3WJ3D7.js.map +7 -0
- package/bundles/ragents.orchestration/server/exports/server/contract.js +9 -0
- package/bundles/ragents.orchestration/server/exports/server/contract.js.map +7 -0
- package/bundles/ragents.orchestration/server/index.js +49 -3
- package/bundles/ragents.orchestration/server/index.js.map +2 -2
- package/bundles/ragents.orchestration/surface.hbs +5 -0
- package/bundles/ragents.orchestration/web/index.js +3 -3
- package/bundles/ragents.orchestration/web/index.js.map +2 -2
- package/bundles/ragents.overseer/ragents-bundle.json +4 -3
- package/bundles/ragents.overseer/web/classes.json +1 -1
- package/bundles/ragents.overseer/web/index.js +1 -1
- package/bundles/ragents.overseer/web/index.js.map +4 -4
- package/bundles/ragents.processes/ragents-bundle.json +2 -2
- package/bundles/ragents.processes/web/classes.json +1 -1
- package/bundles/ragents.processes/web/index.js +1 -1
- package/bundles/ragents.processes/web/index.js.map +2 -2
- package/bundles/ragents.product/ragents-bundle.json +1 -1
- package/bundles/ragents.profile-distribution/ragents-bundle.json +1 -1
- package/bundles/ragents.reference/actors/notebook/package.json +16 -0
- package/bundles/ragents.reference/actors/notebook/src/client.tsx +31 -0
- package/bundles/ragents.reference/actors/notebook/src/server.ts +27 -0
- package/bundles/ragents.reference/actors/notebook/tests/program.test.ts +27 -0
- package/bundles/ragents.reference/ragents-bundle.json +4 -3
- package/bundles/ragents.reference/run-scripts/quick-note/RUN.md +14 -0
- package/bundles/ragents.reference/run-scripts/quick-note/package.json +9 -0
- package/bundles/ragents.reference/run-scripts/quick-note/src/server.ts +29 -0
- package/bundles/ragents.reference/run-scripts/quick-note/tests/program.test.ts +43 -0
- package/bundles/ragents.reference/run-scripts/run-roster/RUN.md +19 -0
- package/bundles/ragents.reference/run-scripts/run-roster/package.json +9 -0
- package/bundles/ragents.reference/run-scripts/run-roster/src/server.ts +26 -0
- package/bundles/ragents.reference/run-scripts/run-roster/tests/program.test.ts +47 -0
- package/bundles/ragents.todo/ragents-bundle.json +1 -1
- package/bundles/ragents.transcript/ragents-bundle.json +1 -1
- package/bundles/ragents.watch/ragents-bundle.json +1 -1
- package/bundles/ragents.workspace/ragents-bundle.json +2 -2
- package/bundles/ragents.workspace/web/classes.json +1 -1
- package/bundles/ragents.workspace/web/index.js +1 -1
- package/bundles/ragents.workspace/web/index.js.map +2 -2
- package/package.json +3 -3
- package/packages/ragents/src/domain/vocabulary.ts +4 -0
- package/packages/ragents/src/index.ts +3 -1
- package/packages/ragents/src/plugin-host.ts +62 -10
- package/packages/ragents/src/plugin-types.ts +11 -0
- package/packages/ragents/src/runtime/guards.ts +2 -1
- package/packages/ragents/src/typescript/async-compiler.ts +11 -1
- package/plugins/ragents.actor-programs/server/index.ts +3 -0
- package/plugins/ragents.actor-programs/server/runtime.ts +424 -28
- package/plugins/ragents.actor-programs/server/script-state.ts +54 -0
- package/plugins/ragents.actor-programs/server/tool-contributor.ts +2 -0
- package/plugins/ragents.ask/server/ask-tool.ts +1 -0
- package/plugins/ragents.documents/web/DocumentViewer.tsx +2 -2
- package/plugins/ragents.orchestration/ragents-plugin.json +1 -0
- package/plugins/ragents.orchestration/server/contract.ts +14 -0
- package/plugins/ragents.orchestration/server/index.ts +4 -1
- package/plugins/ragents.orchestration/server/surface-tool.ts +58 -2
- package/plugins/ragents.orchestration/surface.hbs +5 -0
- package/plugins/ragents.orchestration/web/ExecutionsPanel.tsx +1 -1
- package/plugins/ragents.orchestration/web/FlowInspector.tsx +1 -1
- package/plugins/ragents.orchestration/web/JournalStatus.tsx +1 -1
- package/plugins/ragents.orchestration/web/format.ts +1 -1
- package/plugins/ragents.overseer/web/index.tsx +51 -3
- package/plugins/ragents.processes/web/processes.ts +1 -1
- package/plugins/ragents.reference/actors/notebook/package.json +16 -0
- package/plugins/ragents.reference/actors/notebook/src/client.tsx +31 -0
- package/plugins/ragents.reference/actors/notebook/src/server.ts +27 -0
- package/plugins/ragents.reference/actors/notebook/tests/program.test.ts +27 -0
- package/plugins/ragents.reference/run-scripts/quick-note/RUN.md +14 -0
- package/plugins/ragents.reference/run-scripts/quick-note/package.json +9 -0
- package/plugins/ragents.reference/run-scripts/quick-note/src/server.ts +29 -0
- package/plugins/ragents.reference/run-scripts/quick-note/tests/program.test.ts +43 -0
- package/plugins/ragents.reference/run-scripts/run-roster/RUN.md +19 -0
- package/plugins/ragents.reference/run-scripts/run-roster/package.json +9 -0
- package/plugins/ragents.reference/run-scripts/run-roster/src/server.ts +26 -0
- package/plugins/ragents.reference/run-scripts/run-roster/tests/program.test.ts +47 -0
- package/plugins/ragents.workspace/web/FileBrowser.tsx +1 -1
- package/scripts/agent/agent-cli.ts +46 -2
- package/scripts/package/ragents.mjs +3 -1
- package/apps/web/dist/assets/main-DJmCHGzM.js +0 -11
- package/apps/web/dist/assets/runPanel-nk_aMxSn.js +0 -21
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { createTestContext } from "@ragents/server/testing";
|
|
4
|
+
import program from "../src/server.ts";
|
|
5
|
+
|
|
6
|
+
const start = { input: null, options: {}, embedded: true, startedBy: "owner-id", count: 1 };
|
|
7
|
+
const actor = (handle: string, kind: "human" | "agent" | "script", lifecycle = "idle") =>
|
|
8
|
+
({ id: `id-${handle}`, handle, displayName: handle, kind, lifecycle, createdBy: null, description: null, toolCount: null });
|
|
9
|
+
|
|
10
|
+
const roster = (actors: ReturnType<typeof actor>[], state: { reports?: number } = {}) => {
|
|
11
|
+
const calls: { name: string; input: unknown }[] = [];
|
|
12
|
+
const record = <T>(name: string, answer: T) => (input: unknown): T => { calls.push({ name, input }); return answer; };
|
|
13
|
+
const context = createTestContext<{ reports?: number }>({ state, functions: {
|
|
14
|
+
actor_list: record("actor_list", actors),
|
|
15
|
+
actor_program_ensure: record("actor_program_ensure", { actorId: "id-notebook", handle: "notebook", status: "active" as const }),
|
|
16
|
+
actor_input: record("actor_input", []),
|
|
17
|
+
canvas_layout_place: record("canvas_layout_place", { placed: true }),
|
|
18
|
+
} });
|
|
19
|
+
return { calls, context };
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
test("reports the other participants as result and summary and notes them in the shared notebook", async () => {
|
|
23
|
+
const { calls, context } = roster([actor("owner", "human"), actor("coordinator", "agent", "running"), actor("helper", "agent"), actor("test", "script")]);
|
|
24
|
+
await program.onStart!(start, context);
|
|
25
|
+
assert.deepEqual(context.finished, [{
|
|
26
|
+
result: { actors: [{ handle: "coordinator", kind: "agent", lifecycle: "running" }, { handle: "helper", kind: "agent", lifecycle: "idle" }] },
|
|
27
|
+
summary: "2 participants: @coordinator, @helper.",
|
|
28
|
+
}]);
|
|
29
|
+
assert.deepEqual(calls.slice(1).map((call) => [call.name, call.input]), [
|
|
30
|
+
["actor_program_ensure", { name: "notebook" }],
|
|
31
|
+
["actor_input", { actor: "@notebook", content: "Roster: 2 participants: @coordinator, @helper." }],
|
|
32
|
+
["canvas_layout_place", { entity: "app:notebook/main" }],
|
|
33
|
+
]);
|
|
34
|
+
assert.deepEqual(context.state.read(), { reports: 1 });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("a run without other participants still gets a result, and every start counts", async () => {
|
|
38
|
+
const { context } = roster([actor("owner", "human"), actor("test", "script")], { reports: 2 });
|
|
39
|
+
await program.onStart!({ ...start, embedded: false, count: 3 }, context);
|
|
40
|
+
assert.deepEqual(context.finished, [{ result: { actors: [] }, summary: "No other participants yet." }]);
|
|
41
|
+
assert.deepEqual(context.state.read(), { reports: 3 });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("an ordinary message is refused", async () => {
|
|
45
|
+
const { context } = roster([]);
|
|
46
|
+
await assert.rejects(async () => program.onInput!({ id: "input-1", content: "hello", artifactIds: [], sourceEventIds: [], subscriptionId: null, event: null }, context), /answers only starts/);
|
|
47
|
+
});
|
|
@@ -41,7 +41,7 @@ const sizeLabel = (bytes: number): string => {
|
|
|
41
41
|
|
|
42
42
|
const timeLabel = (value: string): string => {
|
|
43
43
|
const at = new Date(value);
|
|
44
|
-
return Number.isNaN(at.getTime()) ? value : at.toLocaleString(
|
|
44
|
+
return Number.isNaN(at.getTime()) ? value : at.toLocaleString();
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
interface BrowserMemory {
|
|
@@ -47,6 +47,11 @@ export const usage = (): string => `Usage: ragents <command> [arguments]
|
|
|
47
47
|
stop <run> --run [--profile <p>]
|
|
48
48
|
Emergency stop: cancel all turns and stop all actors of the run
|
|
49
49
|
stop --host [--profile <p>] stop the remembered host
|
|
50
|
+
script <run> [--profile <p>] [--json]
|
|
51
|
+
List the run scripts of the profile and whether each can start in the running run.
|
|
52
|
+
script <run> <entry> [--input <json>] [--profile <p>] [--json]
|
|
53
|
+
Start the run script inside the run, as its owner; prints its actor and which start of it
|
|
54
|
+
this is. Only a script whose RUN.md sets embeddable: true joins a running run.
|
|
50
55
|
plugin build <folder...> [--out <o>] [--watch] [--no-typecheck]
|
|
51
56
|
Build plugin source folders into bundles; details with plugin --help.
|
|
52
57
|
|
|
@@ -67,12 +72,14 @@ export type AgentCommand =
|
|
|
67
72
|
| { readonly kind: "journal"; readonly profile: string; readonly runId: string; readonly json: boolean; readonly tools: boolean }
|
|
68
73
|
| { readonly kind: "stop"; readonly profile: string; readonly runId: string }
|
|
69
74
|
| { readonly kind: "stop-run"; readonly profile: string; readonly runId: string }
|
|
70
|
-
| { readonly kind: "stop-host"; readonly profile: string }
|
|
75
|
+
| { readonly kind: "stop-host"; readonly profile: string }
|
|
76
|
+
| { readonly kind: "script"; readonly profile: string; readonly runId: string; readonly entry: string | undefined; readonly input: unknown; readonly json: boolean };
|
|
71
77
|
|
|
72
78
|
interface Flags {
|
|
73
79
|
readonly profile: string;
|
|
74
80
|
readonly entry: string | undefined;
|
|
75
81
|
readonly workstation: string | undefined;
|
|
82
|
+
readonly input: string | undefined;
|
|
76
83
|
readonly json: boolean;
|
|
77
84
|
readonly tools: boolean;
|
|
78
85
|
readonly host: boolean;
|
|
@@ -80,7 +87,7 @@ interface Flags {
|
|
|
80
87
|
readonly positional: readonly string[];
|
|
81
88
|
}
|
|
82
89
|
|
|
83
|
-
const VALUE_FLAGS = new Set(["--profile", "--entry", "--workstation"]);
|
|
90
|
+
const VALUE_FLAGS = new Set(["--profile", "--entry", "--workstation", "--input"]);
|
|
84
91
|
|
|
85
92
|
const scan = (argv: readonly string[], allowed: readonly string[]): Flags => {
|
|
86
93
|
const positional: string[] = [];
|
|
@@ -106,6 +113,7 @@ const scan = (argv: readonly string[], allowed: readonly string[]): Flags => {
|
|
|
106
113
|
profile: values.get("--profile") ?? defaultProfile(),
|
|
107
114
|
entry: values.get("--entry"),
|
|
108
115
|
workstation: values.get("--workstation"),
|
|
116
|
+
input: values.get("--input"),
|
|
109
117
|
json: switches.has("--json"),
|
|
110
118
|
tools: switches.has("--tools"),
|
|
111
119
|
host: switches.has("--host"),
|
|
@@ -158,9 +166,26 @@ export const parseArguments = (argv: readonly string[]): AgentCommand => {
|
|
|
158
166
|
if (!RUN_ID_PATTERN.test(runId)) throw new Error(`Invalid run id: ${runId}`);
|
|
159
167
|
return { kind: flags.run ? "stop-run" : "stop", profile: flags.profile, runId };
|
|
160
168
|
}
|
|
169
|
+
if (command === "script") {
|
|
170
|
+
const flags = scan(rest, ["--profile", "--input", "--json"]);
|
|
171
|
+
const [runId, entry, ...extra] = flags.positional;
|
|
172
|
+
if (!runId) throw new Error(`script needs <run>, optionally followed by <entry>.\n\n${usage()}`);
|
|
173
|
+
if (extra.length > 0) throw new Error(`script takes at most two values, not ${flags.positional.length}.`);
|
|
174
|
+
if (!RUN_ID_PATTERN.test(runId)) throw new Error(`Invalid run id: ${runId}`);
|
|
175
|
+
if (flags.input !== undefined && entry === undefined) throw new Error("--input needs <entry>, the run script it starts.");
|
|
176
|
+
return { kind: "script", profile: flags.profile, runId, entry, input: flags.input === undefined ? null : parsedInput(flags.input), json: flags.json };
|
|
177
|
+
}
|
|
161
178
|
throw new Error(command ? `Unknown command: ${command}\n\n${usage()}` : usage());
|
|
162
179
|
};
|
|
163
180
|
|
|
181
|
+
const parsedInput = (text: string): unknown => {
|
|
182
|
+
try {
|
|
183
|
+
return JSON.parse(text);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
throw new Error(`--input is not JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
164
189
|
export const loadProfile = (selection: string, root = hostRoot()): Promise<ProfileTarget> => selectProfileTarget(selection, root);
|
|
165
190
|
|
|
166
191
|
const delay = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -544,6 +569,24 @@ const stopCommand = async (command: Extract<AgentCommand, { kind: "stop" | "stop
|
|
|
544
569
|
return 0;
|
|
545
570
|
};
|
|
546
571
|
|
|
572
|
+
const scriptCommand = async (command: Extract<AgentCommand, { kind: "script" }>, write: LineWriter): Promise<number> => {
|
|
573
|
+
const target = await loadProfile(command.profile);
|
|
574
|
+
const baseUrl = await addressOf(target);
|
|
575
|
+
if (!await healthy(baseUrl)) throw new Error(`No RAgents server responds at ${baseUrl}; start it with ragents run.`);
|
|
576
|
+
const rpc = client(baseUrl);
|
|
577
|
+
if (command.entry === undefined) {
|
|
578
|
+
const scripts = await withLoginHint(() => rpc.call(coreContracts.runs.scripts, { runId: command.runId }));
|
|
579
|
+
for (const script of scripts) {
|
|
580
|
+
write(command.json ? JSON.stringify(script) : `${script.id} ${script.title}${script.available ? "" : ` (not available: ${script.reason ?? "no reason given"})`}`);
|
|
581
|
+
}
|
|
582
|
+
return 0;
|
|
583
|
+
}
|
|
584
|
+
const started = await withLoginHint(() => rpc.call(coreContracts.runs.startScript, { runId: command.runId, entry: command.entry!, input: command.input }));
|
|
585
|
+
write(command.json ? JSON.stringify(started) : `script: @${started.handle}, start ${started.count}`);
|
|
586
|
+
write(`run: ${command.runId}`);
|
|
587
|
+
return 0;
|
|
588
|
+
};
|
|
589
|
+
|
|
547
590
|
const alive = (pid: number): boolean => {
|
|
548
591
|
try {
|
|
549
592
|
process.kill(pid, 0);
|
|
@@ -596,6 +639,7 @@ export const execute = async (command: AgentCommand, write: LineWriter = toStdou
|
|
|
596
639
|
if (command.kind === "send") return sendCommand(command, write);
|
|
597
640
|
if (command.kind === "journal") return journalCommand(command, write);
|
|
598
641
|
if (command.kind === "stop" || command.kind === "stop-run") return stopCommand(command);
|
|
642
|
+
if (command.kind === "script") return scriptCommand(command, write);
|
|
599
643
|
return stopHostCommand(command);
|
|
600
644
|
};
|
|
601
645
|
|
|
@@ -17,6 +17,7 @@ export const commands = {
|
|
|
17
17
|
send: AGENT_CLI,
|
|
18
18
|
journal: AGENT_CLI,
|
|
19
19
|
stop: AGENT_CLI,
|
|
20
|
+
script: AGENT_CLI,
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const usage = `Usage: ragents <command> [arguments]
|
|
@@ -25,6 +26,7 @@ const usage = `Usage: ragents <command> [arguments]
|
|
|
25
26
|
send <run> "<text>" follow-up task in the same run
|
|
26
27
|
journal <run> [--tools] read the history of a run
|
|
27
28
|
stop <run> | stop --host cancel the running turn or stop the remembered host
|
|
29
|
+
script <run> [<entry>] list the run scripts or start one inside the run (--input <json>)
|
|
28
30
|
connect <server-url> fetch the client profile with its bundles and start the local server with it
|
|
29
31
|
start <profile|path> start a profile of the package, an own profile file or a
|
|
30
32
|
fetched revision; the UI comes prebuilt
|
|
@@ -33,7 +35,7 @@ const usage = `Usage: ragents <command> [arguments]
|
|
|
33
35
|
plugin build <folder...> build plugin source folders into bundles (--out, --watch)
|
|
34
36
|
--help, help this usage
|
|
35
37
|
|
|
36
|
-
run, send, journal and
|
|
38
|
+
run, send, journal, stop and script take another profile with --profile <profile|path>: a name
|
|
37
39
|
next to the host or the path to an own ragents.config.<profile>.ts. RAGENTS_PROFILE sets
|
|
38
40
|
the same for all commands of a shell; if the profile requires sign-in, the user's
|
|
39
41
|
personal token goes into RAGENTS_TOKEN.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{a as le,r as t,j as e,D as ce,b as de,d as G,B as b,X as Me,M as Pe,C as ue,e as Le,f as Ie,g as _e,h as He,u as Be,i as Ue,k as Fe,l as qe,m as Te,A as Ke,n as $e,o as We,U as Qe,P as Ve,W as Ge,R as Xe,p as re,q as V,s as Ye,t as Je,v as Ze,w as et,x as tt,y as st,z as nt,Q as at,F as rt,G as ot}from"./mermaid-HWGCJPDP-q-mf1kLN.js";/**
|
|
2
|
-
* @license lucide-react v1.46.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const fe={name:"circle-question-mark",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["help-circle","circle-help"]};fe.node;const it=le(fe);/**
|
|
7
|
-
* @license lucide-react v1.46.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const pe={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};pe.node;const lt=le(pe);function ct(n,a,r,u){if(!a||n.source!==a||n.origin!==r)return;const o=n.data;if(!(!o||typeof o!="object"||Array.isArray(o))&&"type"in o){if(o.type==="ragents:help-ready")return{type:"ready"};if(o.type==="ragents:start-sample"&&"entry"in o&&typeof o.entry=="string"&&u.includes(o.entry))return{type:"start",entry:o.entry}}}function dt({onClose:n,sampleEntries:a,onStartSample:r}){const u=t.useRef(null),o=t.useRef(null),p=t.useRef(void 0),m=t.useRef(!1);t.useEffect(()=>()=>{var i;return(i=p.current)==null?void 0:i.call(p)},[]),t.useEffect(()=>{var y;const i=(y=o.current)==null?void 0:y.contentWindow;if(!i)return;const l=()=>i.postMessage({type:"ragents:help-context",canStartSamples:a.length>0,entries:a},window.location.origin),h=C=>{const c=ct(C,i,window.location.origin,a);(c==null?void 0:c.type)==="ready"&&l(),(c==null?void 0:c.type)==="start"&&!m.current&&(m.current=!0,r(c.entry))};return window.addEventListener("message",h),l(),()=>window.removeEventListener("message",h)},[r,a]);const x=()=>{var C;(C=p.current)==null||C.call(p);const i=o.current,l=i==null?void 0:i.contentDocument,h=l==null?void 0:l.defaultView;if(!i||!l||!h)return;l.documentElement.dataset.helpEmbedded="true";for(const c of l.querySelectorAll("a[href]"))new URL(c.href).origin!==window.location.origin&&(c.target="_blank",c.rel="noopener noreferrer");const y=c=>{var v;if(!c.defaultPrevented){if(c.key==="Escape")c.preventDefault(),n();else if(c.key==="Tab"){const g=[...l.querySelectorAll("a[href], button, input, select, textarea, summary, [tabindex]")].filter(j=>j.tabIndex>=0&&!j.matches(":disabled")&&j.getClientRects().length>0),L=c.shiftKey?g[0]:g.at(-1);if(!g.length||l.activeElement===L||l.activeElement===l.body){if(!c.shiftKey&&l.activeElement===l.body&&g.length)return;c.preventDefault(),(v=u.current)==null||v.focus()}}}};h.addEventListener("keydown",y),p.current=()=>h.removeEventListener("keydown",y)};return e.jsx(ce,{open:!0,onOpenChange:i=>{i||n()},children:e.jsxs(de,{className:"gap-0 p-0",initialFocus:u,scope:"page",showCloseButton:!1,size:"full",children:[e.jsx(G,{className:"sr-only",children:"Help"}),e.jsx(b,{"aria-label":"Close help",className:"absolute top-3 right-4.5 z-1 rounded-full",onClick:n,ref:u,size:"icon",variant:"outline",children:e.jsx(Me,{})}),e.jsx("iframe",{className:"min-h-0 w-full min-w-0 flex-[1_1_0] bg-background",onLoad:x,ref:o,src:"/help/index.html",tabIndex:0,title:"RAgents: homepage and documentation"})]})})}const ut="button:not([disabled]), a[href], input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])",xe="pointer-events-auto shadow-pop";function ft({onBusy:n,onClose:a,onOpen:r,open:u,panels:o,registry:p,runs:m}){const x=t.useRef(null);return t.useEffect(()=>{if(!u)return;const i=requestAnimationFrame(()=>{var h;const l=x.current;!l||l.contains(document.activeElement)||(h=l.querySelector(ut))==null||h.focus({preventScroll:!0})});return()=>cancelAnimationFrame(i)},[u]),e.jsxs(Pe,{className:"pointer-events-none flex h-[min(900px,100%)] w-[min(1440px,100%)] flex-col rounded-none bg-transparent p-0 ring-0",keepMounted:!0,onClose:a,open:u,scope:"workspace",size:"full",children:[e.jsx(G,{className:"sr-only",children:"Overview"}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 gap-4 max-[900px]:flex-col",id:"app-overview",ref:x,children:[o.map(({id:i,Panel:l})=>e.jsx(pt,{id:i,onBusy:n,onClose:a,onOpen:r,open:u,Panel:l,registry:p},i)),m&&e.jsx(xt,{...m})]})]})}function pt({id:n,onBusy:a,onClose:r,onOpen:u,open:o,Panel:p,registry:m}){const x=t.useCallback(i=>a(n,i),[n,a]);return t.useEffect(()=>()=>a(n,!1),[n,a]),e.jsx(ue,{className:`${xe} min-h-0 min-w-0 flex-1 gap-0 p-0`,children:e.jsx(p,{onBusy:x,onClose:r,onOpen:u,open:o,registry:m})})}function xt({activeId:n,canCreate:a,canDelete:r,onCreate:u,onDelete:o,onOpen:p,registry:m,sessions:x,seenRevisions:i,unreachable:l}){const[h,y]=t.useState(),[C,c]=t.useState(!1),[v,g]=t.useState(()=>new Set),[L,j]=t.useState(!1),[R,H]=t.useState(!1),B=()=>{c(!1),g(new Set)},w=f=>{g(D=>{const I=new Set(D);return I.delete(f)||I.add(f),I})},E=async f=>{H(!0),y(void 0);try{await o(f)}catch(D){y(D instanceof Error?D.message:String(D))}finally{H(!1)}},S=async()=>{await E(x.filter(f=>v.has(f.id)).map(f=>f.id)),j(!1),B()};return e.jsx("section",{"aria-labelledby":"overview-runs-title",className:"flex min-h-0 min-w-0 flex-1 flex-col max-[900px]:flex-[1_1_50%]",children:e.jsxs(ue,{className:`${xe} min-h-0 flex-1 gap-workspace-inset overflow-y-auto overscroll-contain pt-workspace-inset pr-6 pb-6 pl-6 max-[900px]:px-3 max-[900px]:pt-3.5 max-[900px]:pb-4`,children:[e.jsxs("header",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-2.5",children:[e.jsxs("h2",{className:"text-[0.95rem] font-semibold",id:"overview-runs-title",children:["Runs ",e.jsx("span",{className:"ml-1 text-[0.8rem] font-medium tabular-nums text-muted-foreground",children:x.length})]}),l&&e.jsx("span",{className:"text-[0.72rem] font-medium text-destructive",role:"alert",children:"Server unreachable"}),r&&x.length>0&&e.jsx("div",{className:"ml-auto flex flex-wrap items-center gap-1",children:C?e.jsxs(e.Fragment,{children:[e.jsx(b,{onClick:()=>g(new Set(x.map(f=>f.id))),size:"sm",variant:"ghost",children:"All"}),e.jsx(b,{onClick:()=>g(new Set),size:"sm",variant:"ghost",children:"None"}),e.jsxs(b,{className:"ml-auto",disabled:v.size===0||R,onClick:()=>j(!0),size:"sm",variant:"destructive",children:["Delete (",v.size,")"]}),e.jsx(b,{onClick:B,size:"sm",variant:"ghost",children:"Done"})]}):e.jsx(b,{onClick:()=>c(!0),size:"sm",variant:"ghost",children:"Select"})})]}),h&&e.jsx("p",{className:"text-[0.72rem] font-medium text-destructive",role:"alert",children:h}),e.jsx("p",{className:"mb-5.5 text-[0.75rem] text-muted-foreground",children:"By last activity in the run. New activity has come in since you last viewed it."}),e.jsx(Le,{seenRevisions:i,activeId:n,onCreate:a?u:void 0,onDelete:r?f=>void E([f]):void 0,onSelect:p,onToggleSelected:w,registry:m,selectMode:C,selectedIds:v,sessions:x}),L&&e.jsx(ce,{open:!0,onOpenChange:f=>{!f&&!R&&j(!1)},children:e.jsxs(de,{scope:"page",showCloseButton:!1,size:"small",children:[e.jsxs(Ie,{children:[e.jsx(G,{children:"Delete runs"}),e.jsx(_e,{children:v.size===1?"One run will be permanently deleted.":`${v.size} runs will be permanently deleted.`})]}),e.jsxs(He,{children:[e.jsx(b,{disabled:R,onClick:()=>j(!1),variant:"outline",children:"Cancel"}),e.jsx(b,{disabled:R,onClick:()=>void S(),children:R?"Deleting ...":`Delete (${v.size})`})]})]})})]})})}const oe="flex min-h-0 min-w-0 flex-1 flex-col",mt="inline-flex w-header min-h-header items-center justify-center border-r border-border text-primary transition-colors duration-100 not-disabled:cursor-pointer hover:not-disabled:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-3 aria-expanded:bg-primary aria-expanded:text-primary-foreground aria-pressed:bg-primary aria-pressed:text-primary-foreground disabled:opacity-45";function ht(){var ae;const n=Be(),a=Ue((ae=n.user)==null?void 0:ae.id),r=n.can("runs.read"),u=r&&n.can("runs.write"),o=n.can("runs.inspect"),p=r&&n.can("runs.delete"),m=Fe(),x=t.useRef(null),i=t.useRef(null),[l,h]=t.useState(null),[y,C]=t.useState(null),[c,v]=t.useState(null),[g,L]=t.useState(null),[j,R]=t.useState(null),[H,B]=t.useState([]),[w,E]=t.useState(),[S,f]=t.useState(),[D,I]=t.useState(),[F,X]=t.useState(!1),[q,T]=t.useState(!1),[O,Y]=t.useState(!1),[J,z]=t.useState(),[he,ve]=t.useState(!1),[be,ge]=t.useState(()=>new Set),[we,Z]=t.useState(!1),_=t.useRef(void 0),K=t.useRef(!1),M=t.useCallback(()=>{if(!r)return Promise.resolve();if(_.current)return K.current=!0,_.current;const s=async()=>{do{K.current=!1;try{B(await Je()),Z(!1)}catch{Z(!0)}}while(K.current)};return _.current=s().finally(()=>{_.current=void 0}),_.current},[r]);t.useEffect(()=>{if(!r||w)return;M();const s=qe.subscribe(Te.channels.runs,{},()=>void M()),d=setInterval(()=>void M(),5e3);return()=>{s(),clearInterval(d)}},[w,r,M]);const A=t.useCallback((s=!1)=>{var d;Y(!1),s&&((d=x.current)==null||d.focus({preventScroll:!0}))},[]),$=t.useCallback(()=>{z(void 0),ve(!0),Y(!0)},[]),W=t.useCallback(()=>{O?A(!0):$()},[A,$,O]);t.useEffect(()=>{const s=d=>{if(d.defaultPrevented||d.repeat||d.altKey||d.shiftKey||d.key.toLowerCase()!=="i"||d.metaKey===d.ctrlKey)return;const N=x.current;!N||N.closest("[inert]")||(d.preventDefault(),W())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[W]);const ee=t.useCallback((s,d)=>ge(N=>{if(N.has(s)===d)return N;const P=new Set(N);return d?P.add(s):P.delete(s),P}),[]),te=H,ye=te.find(s=>s.id===S),je=t.useCallback(()=>{z(void 0),X(!0)},[]),Se=t.useCallback(()=>T(!1),[]),ke=t.useCallback(()=>{X(!1),requestAnimationFrame(()=>{var s;return(s=i.current)==null?void 0:s.focus()})},[]),Ce=e.jsx(b,{"aria-label":"Open settings",onClick:je,ref:i,size:"icon-lg",title:"Settings",variant:"ghost",children:e.jsx(Ze,{})}),Ne=s=>{f(s),A(!0)},Re=()=>{z(void 0),A(!0),E({id:crypto.randomUUID(),title:"New run",updatedAt:Date.now()})},Ee=async s=>{const d=await Promise.allSettled(s.map(U=>et(U))),N=s.filter((U,Ae)=>d[Ae].status==="fulfilled");S!==void 0&&N.includes(S)&&f(void 0),await M();const P=d.find(U=>U.status==="rejected");if(P)throw P.reason};if(m.status==="loading")return e.jsx("div",{className:"m-auto p-6 text-muted-foreground",children:"Loading profile."});if(m.status==="failed")return e.jsx("div",{className:"flex h-full",children:e.jsx("main",{className:"relative z-1 flex min-h-0 min-w-0 flex-1 bg-[image:var(--surface-backdrop)]",children:e.jsxs("div",{className:oe,children:[e.jsx("header",{className:"flex min-h-[42px] flex-none items-center gap-3 border-b border-border-soft pr-0.5 pb-2 pl-2.5",children:e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3 text-[0.82rem] font-semibold text-foreground",children:"Profile unavailable"})}),e.jsxs(Ke,{className:"m-auto max-w-[560px] gap-3 p-6",variant:"destructive",children:[e.jsx("p",{children:m.error}),e.jsx(b,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload"})]})]})})});const k=m.registry,se=k.overviewPanels.filter(s=>s.readRight===void 0||n.can(s.readRight)),Q=se.filter(s=>s.placement!=="toolbar"),De=se.filter(s=>s.placement==="toolbar"),Oe=r||Q.length>0,ne=Q.some(s=>be.has(s.id)),ze=$e(r?S:void 0,O,D);return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("header",{className:"relative z-[80] flex h-header flex-none items-stretch border-b border-border bg-shell shadow-bar",children:[Oe&&e.jsx("div",{className:"relative flex flex-none self-stretch",children:e.jsx("button",{"aria-controls":"app-overview","aria-expanded":O,"aria-haspopup":"dialog","aria-keyshortcuts":"Meta+I Control+I","aria-label":O?"Close overview":"Open overview",className:mt,onClick:W,ref:x,title:`Overview (Cmd+I / Ctrl+I)${ne?": processing":""}`,type:"button",children:ne?e.jsx(We,{"aria-hidden":!0,className:"size-[18px]"}):e.jsx(lt,{size:22})})}),De.map(({id:s,Panel:d})=>e.jsx(vt,{id:s,onBusy:ee,onClose:()=>z(void 0),onOpen:()=>{!F&&!q&&!w&&(A(),z(s))},open:J===s,Panel:d,registry:k,userLocation:ze},s)),e.jsx("div",{"aria-label":"Run title bar",className:"flex min-w-0 flex-1 items-stretch overflow-x-auto no-scrollbar focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-3 max-md:in-[header:has([data-slot=overseer-toolbar][data-open=true])]:flex-[0_1_0]",ref:h,role:"region",tabIndex:0}),e.jsx(Qe,{}),e.jsxs("div",{className:"flex min-w-0 flex-[0_1_auto] items-stretch bg-shell has-data-[workspace-state=expanded]:w-[var(--workspace-panel-width,560px)] has-data-[workspace-state=expanded]:border-l has-data-[workspace-state=expanded]:border-border",children:[e.jsx("div",{className:"flex min-w-0 flex-1 empty:hidden",ref:C}),e.jsxs("div",{className:"flex flex-none items-center gap-1.5 px-2 max-md:gap-0.5 max-md:px-1",children:[n.can("settings.read")&&Ce,o&&e.jsx(b,{"aria-haspopup":"dialog","aria-label":"Open help",onClick:()=>{z(void 0),T(!0)},size:"icon-lg",title:"Help",variant:"ghost",children:e.jsx(it,{})})]})]})]}),e.jsx(Ve,{failures:m.failures}),e.jsx(Ge.Provider,{value:g,children:e.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col",ref:L,children:e.jsxs(Xe.Provider,{value:j,children:[e.jsxs("div",{className:"relative flex h-auto min-h-0 flex-1",ref:R,children:[e.jsx("main",{className:"relative z-1 flex min-h-0 min-w-0 flex-1 bg-[image:var(--surface-backdrop)] @container/chat-content",children:r&&S?e.jsx(re,{headerContainer:l,workspaceHeaderContainer:y,statusContainer:c,onLocationChange:I,onViewed:a.markViewed,viewing:!O&&!F&&!q&&!w&&!J,registry:k,session:ye??{id:S,title:"New run",updatedAt:Date.now()}},S):e.jsx("div",{className:oe,children:e.jsx("div",{className:"m-auto text-center text-muted-foreground",children:r?u?"Open the overview at the top left to choose a run or start a new one.":"Open the overview at the top left to choose a run. You have read access.":"No runs are shared with this user account."})})}),he&&e.jsx(ft,{onOpen:$,onBusy:ee,onClose:()=>A(!0),open:O,panels:Q,registry:k,runs:r?{activeId:S,canCreate:u&&(n.can("runs.create")||k.scriptEntries.some(s=>V(n,s.id))),canDelete:p,onCreate:Re,onDelete:Ee,onOpen:Ne,registry:k,sessions:te,seenRevisions:a.revisions,unreachable:we}:void 0}),w&&e.jsx(re,{onStarted:()=>{f(w.id),E(void 0),M()},registry:k,session:w,startDialog:{onClose:()=>E(void 0),initialEntryId:w.startEntryId}},w.id),F&&e.jsx(Ye,{onClose:ke,registry:k}),o&&q&&e.jsx(dt,{onClose:Se,sampleEntries:k.scriptEntries.filter(s=>V(n,s.id)).map(s=>s.id),onStartSample:s=>{!V(n,s)||!k.scriptEntries.some(d=>d.id===s)||(T(!1),z(void 0),A(),E({id:crypto.randomUUID(),title:"New run",updatedAt:Date.now(),startEntryId:s}))}})]}),e.jsx("footer",{"aria-label":"Run status bar",className:"relative flex h-statusbar w-full flex-none items-stretch pl-3 before:pointer-events-none before:absolute before:inset-0 before:z-[2] before:border-t before:border-border before:bg-shell before:shadow-status before:backdrop-blur-[16px] before:content-['']",ref:v})]})})})]})}function vt({id:n,onBusy:a,Panel:r,...u}){const o=t.useCallback(p=>a(n,p),[n,a]);return t.useEffect(()=>()=>a(n,!1),[n,a]),e.jsx(r,{...u,onBusy:o})}tt();const me=document.getElementById("root");if(!me)throw new Error("Root element is missing");const ie=st.createRoot(me);try{const n=nt(window);ie.render(e.jsx(t.StrictMode,{children:e.jsx(at,{children:e.jsx(rt,{children:e.jsx(ht,{})})})}))}catch(n){ie.render(e.jsxs(ot,{children:[e.jsx("h1",{className:"my-3 text-[1.5rem]",children:"The view could not be loaded"}),e.jsx("p",{className:"mb-6 leading-normal",role:"alert",children:n instanceof Error?n.message:String(n)}),e.jsx(b,{onClick:()=>window.location.reload(),variant:"outline",children:"Reload"})]}))}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{a as U,H as D,u as G,r as o,j as e,B as k,I as Te,J as Ae,v as _e,l as ze,m as Fe,t as Me,k as Ue,P as De,G as ce,K as He,p as J,q as de,i as $e,L as ue,N as re,O as Be,T as Ve,A as oe,V as qe,Y as Je,Z as Ge,_ as Ke,s as Qe,$ as We,e as Ye,a0 as Ze,a1 as Xe,x as et,y as tt,a2 as nt,a3 as st,a4 as rt,z as ot,Q as at,a5 as it,a6 as lt,F as ct}from"./mermaid-HWGCJPDP-q-mf1kLN.js";/**
|
|
2
|
-
* @license lucide-react v1.46.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const he={name:"ellipsis-vertical",size:24,node:[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],aliases:["more-vertical"]};he.node;const dt=U(he);/**
|
|
7
|
-
* @license lucide-react v1.46.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const fe={name:"external-link",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]};fe.node;const ut=U(fe);/**
|
|
12
|
-
* @license lucide-react v1.46.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const pe={name:"layout-grid",size:24,node:[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]};pe.node;const ht=U(pe);/**
|
|
17
|
-
* @license lucide-react v1.46.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const xe={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]};xe.node;const ft=U(xe),V="flex w-full cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:-outline-offset-2 disabled:cursor-default disabled:opacity-50 [&>svg]:size-4 [&>svg]:flex-none [&>svg]:text-muted-foreground";function q({onOpenSettings:t}){const a=D(),r=G(),[s,i]=o.useState(!1),[l,c]=o.useState(!1),[h,p]=o.useState(),S=o.useRef(null),u=o.useId(),N=d=>{var b;return d.reason==="outside-press"&&d.event.target instanceof Node&&((b=S.current)==null?void 0:b.contains(d.event.target))===!0},R=()=>{if(a.kind==="vscode"){a.requestLogout(),i(!1);return}c(!0),p(void 0),r.logout().then(()=>i(!1)).catch(d=>p(d instanceof Error?d.message:String(d))).finally(()=>c(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(k,{"aria-controls":s?u:void 0,"aria-expanded":s,"aria-haspopup":"dialog","aria-label":"Panel menu",className:"self-center",onClick:()=>i(d=>!d),ref:S,size:"icon-lg",title:"Menu",variant:"ghost",children:e.jsx(dt,{})}),e.jsx(Te,{onOpenChange:(d,b)=>{!d&&N(b)||i(d)},open:s,children:e.jsxs(Ae,{align:"end",anchor:S,"aria-label":"Panel menu",className:"w-[220px] gap-0 p-1 text-[0.8rem]",collisionPadding:8,dim:!0,id:u,role:"dialog",side:"bottom",children:[e.jsxs("button",{className:V,onClick:()=>{i(!1),t()},type:"button",children:[e.jsx(_e,{}),"Settings"]}),a.kind==="vscode"&&e.jsxs("button",{className:V,onClick:()=>{i(!1),a.openExternal(new URL("/",window.location.href).toString())},type:"button",children:[e.jsx(ut,{}),"Open in browser"]}),r.enabled&&r.user&&e.jsxs("button",{className:V,disabled:l,onClick:R,title:r.user.id,type:"button",children:[e.jsx(ft,{}),e.jsxs("span",{className:"grid min-w-0",children:[e.jsx("span",{children:"Sign out"}),e.jsx("span",{className:"truncate text-[0.68rem] text-muted-foreground",children:r.user.label})]})]}),h&&e.jsx("p",{className:"px-2 py-1.5 text-[0.72rem] text-destructive",role:"alert",children:h})]})})]})}const pt=5e3;function me(t){const[a,r]=o.useState([]),[s,i]=o.useState(!1),l=o.useRef(void 0),c=o.useRef(!1),h=o.useCallback(()=>{if(!t)return Promise.resolve();if(l.current)return c.current=!0,l.current;const p=async()=>{do{c.current=!1;try{r(await Me()),i(!1)}catch{i(!0)}}while(c.current)};return l.current=p().finally(()=>{l.current=void 0}),l.current},[t]);return o.useEffect(()=>{if(!t)return;h();const p=ze.subscribe(Fe.channels.runs,{},()=>void h()),S=setInterval(()=>void h(),pt);return()=>{p(),clearInterval(S)}},[t,h]),{sessions:a,unreachable:s,refresh:h}}const ge="relative z-[80] flex h-header flex-none items-stretch border-b border-border bg-shell shadow-bar",ae="max-w-[120px] self-center truncate rounded-full bg-secondary px-2 py-0.5 text-[0.66rem] font-semibold text-muted-foreground",xt="min-w-0 flex-1 self-center truncate px-1.5 text-[0.82rem] font-semibold",mt="Stopped in the run panel",gt=5e3,v="New run",vt="relative z-[80] flex h-header flex-none items-center gap-2 border-b border-border bg-shell px-3 shadow-bar",ve="m-auto max-w-[420px] p-6 text-center text-muted-foreground",wt=new Set,St=()=>({id:crypto.randomUUID(),title:v,updatedAt:Date.now()}),we=(t,a="Run")=>({id:t,title:a,updatedAt:Date.now()}),bt={kind:"working",title:"Loading profile",detail:"Loading the server's interface."},jt={kind:"working",title:"Starting run",detail:"Creating the new run."},ie={kind:"working",title:"Starting run",detail:"Starting the template."},yt={kind:"waiting",title:"No run selected",detail:"On the Start page you start a new run or open an existing one."},kt={kind:"error",title:"No runs enabled",detail:"No runs are enabled for this user account."};function Nt({location:t}){const a=Ue(),r=t.layout==="app";if(a.status==="loading")return e.jsx(w,{headless:r,state:bt});if(a.status==="failed")return e.jsx(w,{headless:r,state:{kind:"error",title:"The profile could not be loaded",detail:a.error},children:e.jsx(k,{onClick:()=>window.location.reload(),size:"sm",variant:"outline",children:"Reload"})});const s=t.layout==="app"?e.jsx(It,{elementId:t.elementId,registry:a.registry,runId:t.runId}):e.jsx(Rt,{connection:t.connection,initialRunId:t.runId,registry:a.registry});return a.failures.length===0?s:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx(De,{failures:a.failures}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:s})]})}function Rt({connection:t,initialRunId:a,registry:r}){var se;const s=D(),i=G(),l=i.can("runs.read"),c=l&&i.can("runs.write"),h=c&&i.can("runs.create"),p=h||c&&r.scriptEntries.some(n=>de(i,n.id)),S=$e((se=i.user)==null?void 0:se.id),[u,N]=o.useState(a),[R,d]=o.useState(),[b,I]=o.useState(),m=o.useCallback(()=>I(n=>n===u?void 0:n),[u]),[be,K]=o.useState(),[f,C]=o.useState(),[T,Q]=o.useState(),H=o.useRef(void 0),g=o.useCallback(n=>{H.current=n==null?void 0:n.runId,Q(n)},[]),[W,$]=o.useState(),[O,Y]=o.useState(!1),[Z,X]=o.useState(),B=o.useCallback(()=>Y(!0),[]),{sessions:ee,unreachable:je,refresh:ye}=me(l&&!f&&!T),[ke,Ne]=o.useState(null),[Re,Ce]=o.useState(null),P=o.useCallback((n,x)=>{var M;const j=(M=r.startEntries.find(Le=>Le.id===x))==null?void 0:M.fixedStartOptions;C({session:St(),startOptions:n&&ue(n,j),entryId:x})},[r]),Ee=o.useCallback(()=>P(),[P]),L=o.useCallback((n,x)=>{C(void 0),g(void 0),K(x),N(n),I(s.kind==="vscode"?n:void 0)},[s.kind,g]),te=o.useCallback(n=>{C(void 0),g(n),Ct(n,r,i).then(()=>{H.current===n.runId&&L(n.runId)},x=>{H.current===n.runId&&Q({...n,error:x instanceof Error?x.message:String(x)})})},[i,L,r,g]),Ie=o.useCallback(n=>{I(void 0),d(void 0),N(n)},[]),A=o.useCallback(()=>{I(void 0),C(void 0),g(void 0),$(void 0),s.kind==="vscode"?s.notify({type:"showStart"}):N(void 0)},[s,g]);o.useLayoutEffect(()=>{if(b){if(O||f){m();return}return window.addEventListener("pointerdown",m,!0),window.addEventListener("keydown",m,!0),window.addEventListener("blur",m),()=>{window.removeEventListener("pointerdown",m,!0),window.removeEventListener("keydown",m,!0),window.removeEventListener("blur",m)}}},[f,b,O,m]),o.useEffect(()=>s.onCommand(n=>{if(n.type==="selectRun"&&(I(void 0),C(void 0),g(void 0),$(void 0),K(void 0),d(void 0),N(n.runId??void 0)),n.type!=="newRun")return;if(s.kind!=="vscode"){p&&P(n.startOptions,n.entryId);return}const x=p?n.entryId===void 0&&!h?"Free runs are not enabled for this user account.":void 0:"New runs are not enabled for this user account.";if($(x),x!==void 0)return;const j=r.startEntries.find(M=>M.id===n.entryId);if(d((j==null?void 0:j.title)??v),n.entryId===void 0){L(crypto.randomUUID(),n.startOptions);return}if(j!==void 0&&r.guideFor(j)!==void 0){g(void 0),P(n.startOptions,j.id);return}te({runId:crypto.randomUUID(),entryId:n.entryId,startOptions:n.startOptions})}),[p,h,s,L,r,g,P,te]),o.useEffect(()=>{s.notify({type:"ready"})},[s]),o.useEffect(()=>{s.notify({type:"runChanged",runId:u??null})},[s,u]);const _=O&&e.jsx(Qe,{onClose:()=>Y(!1),registry:r}),E=n=>e.jsxs(e.Fragment,{children:[e.jsx(k,{"aria-label":"Back to Start",className:"self-center",onClick:A,size:"icon-lg",title:"Back to Start",variant:"ghost",children:e.jsx(re,{})}),e.jsx("strong",{className:xt,children:n}),t&&e.jsx("span",{className:ae,title:`Server ${t}`,children:t}),e.jsx(q,{onOpenSettings:B})]}),z=e.jsx(k,{onClick:A,size:"sm",variant:"outline",children:"Back to Start"}),ne=f&&e.jsx(J,{initialStartOptions:f.startOptions,onStarted:()=>{L(f.session.id),d(n=>n??v),ye()},registry:r,session:f.session,startDialog:{onClose:s.kind==="vscode"?A:()=>C(void 0),initialEntryId:f.entryId}},f.session.id);if(T)return e.jsxs(e.Fragment,{children:[T.error===void 0?e.jsx(w,{header:E(R??v),state:ie}):e.jsx(w,{header:E(R??v),state:{kind:"error",title:"The run could not be started",detail:T.error},children:z}),_]});if(s.kind==="vscode"&&f)return e.jsxs(e.Fragment,{children:[e.jsx(w,{header:E(R??v),state:ie}),ne,_]});if(s.kind==="vscode"&&!(l&&u))return e.jsxs(e.Fragment,{children:[l?W!==void 0?e.jsx(w,{header:E(v),state:{kind:"error",title:"No new run possible",detail:W},children:z}):e.jsx(Et,{header:E(v),children:z}):e.jsx(w,{header:E(v),state:kt,children:z}),_]});const F=ee.find(n=>n.id===u),Oe=()=>{u!==void 0&&(X(void 0),We(u,mt).catch(n=>X(`Stop failed: ${n instanceof Error?n.message:String(n)}`)))},Pe=l?e.jsx(Ye,{activeId:u,onCreate:p?Ee:void 0,onSelect:Ie,onToggleSelected:()=>{},registry:r,seenRevisions:S.revisions,selectMode:!1,selectedIds:wt,sessions:ee}):e.jsx("p",{className:ve,children:"No runs are enabled for this user account."});return e.jsxs("div",{className:"flex h-full flex-col bg-[image:var(--surface-backdrop)]",children:[l&&u?e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:ge,children:[e.jsx(k,{"aria-label":"Back to Start",className:"self-center",onClick:A,size:"icon-lg",title:"Back to Start",variant:"ghost",children:e.jsx(re,{})}),e.jsx("div",{"aria-label":"Run title bar",className:"flex min-w-0 flex-1 items-stretch overflow-x-auto no-scrollbar",ref:Ne,role:"region"}),t&&e.jsx("span",{className:ae,title:`Server ${t}`,children:t}),e.jsx(Be,{className:"self-center px-1.5",state:F!=null&&F.running?"running":"idle"}),e.jsx(Ve,{className:"self-center",disabled:!c,label:"Stop run",onClick:Oe,size:"icon-lg",title:"Stop the run with all agents and flows"}),e.jsx("div",{"aria-label":"Panel tools",className:"flex flex-none items-center empty:hidden",ref:Ce,role:"toolbar"}),e.jsx(q,{onOpenSettings:B})]}),Z&&e.jsx(oe,{variant:"destructive",children:Z}),e.jsx("main",{className:"relative z-1 flex min-h-0 min-w-0 flex-1 @container/chat-content",children:e.jsx(J,{autoFocusChat:b===u&&!O&&!f,onAutoFocusChatSettled:m,toolbarContainer:Re,headerContainer:ke,initialStartOptions:be,layout:"panel",onViewed:S.markViewed,registry:r,session:F??we(u,R),viewing:!f&&!O},u)})]}):e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:vt,children:[e.jsx(ht,{"aria-hidden":!0,className:"size-4 flex-none text-muted-foreground"}),e.jsx("strong",{className:"min-w-0 flex-1 truncate text-[0.82rem] font-semibold",children:r.brand.title}),e.jsx(q,{onOpenSettings:B})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:[je&&e.jsx(oe,{className:"mb-3",variant:"destructive",children:"The server is unreachable."}),Pe]})]}),_,ne]})}async function Ct(t,a,r){const s=a.startEntries.find(i=>i.id===t.entryId);if(!s)throw new Error("This template does not exist in this profile.");if(!de(r,s.id))throw new Error(`${s.title} is not enabled for this user account.`);if(t.startOptions){const i=await qe(t.runId),l=ue(t.startOptions,s.fixedStartOptions);for(const[c,h]of Je(i,l))await Ge(t.runId,c,h)}await Ke(t.runId,s,null)}function Et({children:t,header:a}){const[r,s]=o.useState(!1);return o.useEffect(()=>{const i=window.setTimeout(()=>s(!0),gt);return()=>window.clearTimeout(i)},[]),r?e.jsx(w,{header:a,state:yt,children:t}):e.jsx(w,{header:a,state:jt})}function w({children:t,header:a,headless:r=!1,state:s}){return e.jsxs("div",{className:"flex h-full flex-col bg-[image:var(--surface-backdrop)]",children:[!r&&e.jsx("header",{className:ge,children:a}),e.jsx("main",{className:"grid min-h-0 flex-1 place-items-center overflow-hidden p-6",children:e.jsx(He,{state:s,children:t})})]})}function It({elementId:t,registry:a,runId:r}){const s=D(),i=G().can("runs.read"),{sessions:l}=me(i);return o.useEffect(()=>{s.notify({type:"ready"})},[s]),i?e.jsx("main",{className:"relative flex h-full min-h-0 min-w-0 flex-1 bg-background @container/chat-content",children:e.jsx(J,{layout:{element:t},registry:a,session:l.find(c=>c.id===r)??we(r)},r)}):e.jsx("p",{className:ve,children:"No runs are enabled for this user account."})}function Ot(){const t=D();return e.jsxs(ce,{children:[e.jsx("h1",{className:"my-3 text-[1.5rem]",children:"Sign-in required"}),e.jsx("p",{className:"mb-6 leading-normal text-muted-foreground",children:"Sign-in goes through VS Code. The panel then reloads."}),e.jsx(k,{className:"w-full",onClick:()=>t.requestLogin(),children:"Sign in with VS Code"})]})}const y=t=>t!=null&&t.trim()?t.trim():void 0,Pt=t=>{if(t==="browser"||t==="vscode")return t;throw new Error(`Unknown host ${JSON.stringify(t)}. Allowed are browser and vscode.`)};function Lt(t){const a=new URLSearchParams(t),r=y(a.get("layout"))??"panel";if(r!=="panel"&&r!=="app")throw new Error(`Unknown layout ${JSON.stringify(r)}. Allowed are panel and app.`);const s=y(a.get("theme"));if(s!==void 0&&!Ze(s))throw new Error(`Unknown theme ${JSON.stringify(s)}. Allowed are light and dark.`);const i={host:Pt(y(a.get("host"))??"browser"),connection:y(a.get("connection")),theme:s,access:y(a.get(Xe))},l=y(a.get("run"));if(r==="panel")return{layout:r,runId:l,...i};const c=y(a.get("element"));if(!l||!c)throw new Error("The app layout needs run and element.");return{layout:r,runId:l,elementId:c,...i}}et();const Se=document.getElementById("root");if(!Se)throw new Error("Root element is missing");const le=tt.createRoot(Se);try{const t=Lt(window.location.search);t.access!==void 0&&nt(t.access);const a=st(t.host,window);if(t.host==="vscode"){const s=rt(window)}const r=ot(window);t.theme!==void 0&&r.setPreference(t.theme),a.onCommand(s=>{s.type==="theme"&&r.setPreference(s.theme)}),le.render(e.jsx(o.StrictMode,{children:e.jsx(at,{children:e.jsx(it,{value:a,children:e.jsx(lt,{value:t.host==="vscode"?{open:a.openPage}:void 0,children:e.jsx(ct,{Login:t.host==="vscode"?Ot:void 0,children:e.jsx(Nt,{location:t})})})})})}))}catch(t){le.render(e.jsxs(ce,{children:[e.jsx("h1",{className:"my-3 text-[1.5rem]",children:"The RAgents panel could not be loaded"}),e.jsx("p",{className:"mb-6 leading-normal",role:"alert",children:t instanceof Error?t.message:String(t)}),e.jsx(k,{onClick:()=>window.location.reload(),variant:"outline",children:"Reload"})]}))}
|