@netnodeag/kraftwerk 0.32.1 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/doctor.js +2 -3
- package/dist/cli/kraftwerk.js +3 -0
- package/dist/cli/projects.d.ts +2 -0
- package/dist/cli/projects.js +148 -0
- package/dist/cli/ui.js +28 -11
- package/dist/config.d.ts +2 -0
- package/dist/config.js +2 -1
- package/dist/inspector/instances.d.ts +104 -1
- package/dist/inspector/instances.js +376 -15
- package/dist/inspector/self-command.d.ts +15 -0
- package/dist/inspector/self-command.js +18 -0
- package/dist/inspector/server.js +60 -7
- package/inspector/dist/assets/{editor-DhNlc5vd.js → editor-CXrDJOv_.js} +3 -3
- package/inspector/dist/assets/{index-Dgi1UC16.js → index-7J4zAS6J.js} +1 -1
- package/inspector/dist/assets/index-B7rwNdVj.css +1 -0
- package/inspector/dist/assets/index-BBGjdXk1.js +213 -0
- package/inspector/dist/assets/{index-2RQVAOu3.js → index-BIDsfw8C.js} +1 -1
- package/inspector/dist/assets/{index-xM_-dBjg.js → index-BNcXQYbv.js} +1 -1
- package/inspector/dist/assets/{index-DmZE5psD.js → index-BQMgADlc.js} +1 -1
- package/inspector/dist/assets/{index-C22iDz8w.js → index-BULB2rC_.js} +1 -1
- package/inspector/dist/assets/{index-DYnto4lP.js → index-Bumwg9SM.js} +1 -1
- package/inspector/dist/assets/{index-BmdO9i46.js → index-BxEG-IdY.js} +1 -1
- package/inspector/dist/assets/{index-CT73nPrH.js → index-C3hpUVfp.js} +1 -1
- package/inspector/dist/assets/{index-CK6xHVuA.js → index-CMMYSoL3.js} +1 -1
- package/inspector/dist/assets/{index-BvrVgIw_.js → index-CNJyAniG.js} +1 -1
- package/inspector/dist/assets/{index-CWIXOY1D.js → index-CUCCMUMY.js} +1 -1
- package/inspector/dist/assets/{index-BWQugB-m.js → index-ChuqpBnv.js} +1 -1
- package/inspector/dist/assets/{index-BanLa7PQ.js → index-CszaAR9T.js} +1 -1
- package/inspector/dist/assets/{index-Dx4HOh5k.js → index-DAi1VtJ8.js} +1 -1
- package/inspector/dist/assets/{index--vNjDAEm.js → index-DrSWAGft.js} +1 -1
- package/inspector/dist/assets/{index-Hlokid_B.js → index-Upf-BEsx.js} +1 -1
- package/inspector/dist/assets/{index-C9y82Xkr.js → index-x5G6Np7T.js} +1 -1
- package/inspector/dist/index.html +2 -2
- package/package.json +1 -1
- package/inspector/dist/assets/index-IK4Vsg-q.js +0 -213
- package/inspector/dist/assets/index-iGaBYIin.css +0 -1
package/dist/cli/doctor.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { readFile
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
import { resolveProject } from "../config.js";
|
|
5
|
+
import { isDir, resolveProject } from "../config.js";
|
|
6
6
|
import { discoverWorkflows } from "../discover.js";
|
|
7
7
|
import { missingEnv } from "../yaml.js";
|
|
8
8
|
const ICONS = {
|
|
@@ -90,7 +90,6 @@ export async function runDoctor(cwd) {
|
|
|
90
90
|
report("ok", `${path.basename(project.configPath)} well-formed`, keys.length ? keys.map((k) => `${k}: ${cfg[k]}`).join(", ") : "empty — defaults apply");
|
|
91
91
|
if (!cfg.name)
|
|
92
92
|
report("info", "name not set in kraftwerk.yml", "inspector header falls back to the folder name");
|
|
93
|
-
const isDir = async (p) => (await stat(p).catch(() => null))?.isDirectory() ?? false;
|
|
94
93
|
for (const key of ["workflows", "knowledge", "agents", "output"]) {
|
|
95
94
|
const value = cfg[key];
|
|
96
95
|
if (!value)
|
package/dist/cli/kraftwerk.js
CHANGED
|
@@ -12,6 +12,7 @@ import { renderCreateBrief } from "./create-brief.js";
|
|
|
12
12
|
import { runDoctor } from "./doctor.js";
|
|
13
13
|
import { runInit } from "./init.js";
|
|
14
14
|
import { registerKnowledgeCommands } from "./knowledge.js";
|
|
15
|
+
import { registerProjectCommands } from "./projects.js";
|
|
15
16
|
import { registerRoutineCommands } from "./routines.js";
|
|
16
17
|
import { listRuns, showRun } from "./runs.js";
|
|
17
18
|
import { runUi } from "./ui.js";
|
|
@@ -25,6 +26,7 @@ import { runUi } from "./ui.js";
|
|
|
25
26
|
* kraftwerk knowledge ... Context & Knowledge: OKF bundles (list/get/put/verify/...)
|
|
26
27
|
* kraftwerk routines ... per-agent scheduled prompts (list/add/remove/enable/run)
|
|
27
28
|
* kraftwerk ui start the inspector web UI (localhost:1981)
|
|
29
|
+
* kraftwerk projects ... known projects on this machine (list/start/forget)
|
|
28
30
|
* kraftwerk doctor preflight: harness CLIs, docker, workflows, env
|
|
29
31
|
* kraftwerk validate [paths...] validate without executing
|
|
30
32
|
*
|
|
@@ -256,6 +258,7 @@ runs
|
|
|
256
258
|
});
|
|
257
259
|
registerKnowledgeCommands(program);
|
|
258
260
|
registerRoutineCommands(program);
|
|
261
|
+
registerProjectCommands(program);
|
|
259
262
|
program
|
|
260
263
|
.command("ui")
|
|
261
264
|
.description("Start the inspector web UI for this project's runs and workflows")
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import Table from "cli-table3";
|
|
4
|
+
import { discoverWorkspaces, forgetProject, startProject, stopProject, tildify, } from "../inspector/instances.js";
|
|
5
|
+
/**
|
|
6
|
+
* `kraftwerk projects` — every project that ever ran the inspector on this
|
|
7
|
+
* machine (~/.kraftwerk/projects), joined with what is running right now.
|
|
8
|
+
* The answer to "where did I start that UI, and how do I get it back":
|
|
9
|
+
*
|
|
10
|
+
* kraftwerk projects list: name, root, running/stopped
|
|
11
|
+
* kraftwerk projects start <ref> relaunch `kraftwerk ui` in that root, detached
|
|
12
|
+
* kraftwerk projects stop <ref> SIGTERM a running UI (also ones started in a terminal)
|
|
13
|
+
* kraftwerk projects forget <ref> drop the record (the folder stays)
|
|
14
|
+
*
|
|
15
|
+
* <ref> is a project name, the root's folder name, the root path, or a
|
|
16
|
+
* port / localhost:port for running instances that recorded no root.
|
|
17
|
+
*/
|
|
18
|
+
const fmtAgo = (iso) => {
|
|
19
|
+
if (!iso)
|
|
20
|
+
return "—";
|
|
21
|
+
const s = Math.max(0, (Date.now() - Date.parse(iso)) / 1000);
|
|
22
|
+
if (s < 90)
|
|
23
|
+
return "just now";
|
|
24
|
+
if (s < 5400)
|
|
25
|
+
return `${Math.round(s / 60)} min ago`;
|
|
26
|
+
if (s < 129600)
|
|
27
|
+
return `${Math.round(s / 3600)} h ago`;
|
|
28
|
+
return `${Math.round(s / 86400)} d ago`;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Running → its url. Not running: "stopped" after a clean shutdown, "died"
|
|
32
|
+
* when the last start has no matching stop (killed, crashed, terminal
|
|
33
|
+
* closed) — the case this command exists for.
|
|
34
|
+
*/
|
|
35
|
+
const status = (e) => {
|
|
36
|
+
if (e.live)
|
|
37
|
+
return chalk.green(`● ${e.url.replace(/^https?:\/\//, "")}`);
|
|
38
|
+
if (e.exists === false)
|
|
39
|
+
return chalk.red("path missing");
|
|
40
|
+
const clean = !!e.lastStopped && !!e.lastStarted && e.lastStopped >= e.lastStarted;
|
|
41
|
+
return clean ? chalk.dim("stopped") : chalk.yellow("died");
|
|
42
|
+
};
|
|
43
|
+
/** Match a ref against known workspaces; `needRoot` excludes rootless live instances (start/forget need a root). */
|
|
44
|
+
async function resolveRef(ref, needRoot = true) {
|
|
45
|
+
const all = (await discoverWorkspaces()).filter((e) => e.root || !needRoot);
|
|
46
|
+
const abs = path.resolve(ref);
|
|
47
|
+
const port = /^\d+$/.test(ref) ? `http://localhost:${ref}` : `http://${ref.replace(/^https?:\/\//, "")}`;
|
|
48
|
+
const hits = all.filter((e) => e.root === abs ||
|
|
49
|
+
e.root === ref ||
|
|
50
|
+
e.name === ref ||
|
|
51
|
+
(e.root && path.basename(e.root) === ref) ||
|
|
52
|
+
e.url === port);
|
|
53
|
+
if (hits.length === 1)
|
|
54
|
+
return hits[0];
|
|
55
|
+
if (hits.length === 0) {
|
|
56
|
+
console.error(chalk.red(`No known project "${ref}". See \`kraftwerk projects\`.`));
|
|
57
|
+
process.exit(2);
|
|
58
|
+
}
|
|
59
|
+
console.error(chalk.red(`"${ref}" is ambiguous — use the root path or port:`));
|
|
60
|
+
for (const h of hits)
|
|
61
|
+
console.error(` ${h.root ?? h.url}`);
|
|
62
|
+
process.exit(2);
|
|
63
|
+
}
|
|
64
|
+
export function registerProjectCommands(program) {
|
|
65
|
+
const projects = program
|
|
66
|
+
.command("projects")
|
|
67
|
+
.description("Known kraftwerk projects on this machine: list, start a stopped UI, forget");
|
|
68
|
+
projects
|
|
69
|
+
.command("list", { isDefault: true })
|
|
70
|
+
.description("List known projects with their root and whether the UI is running")
|
|
71
|
+
.option("--json", "Machine-readable output")
|
|
72
|
+
.action(async (opts) => {
|
|
73
|
+
const entries = await discoverWorkspaces();
|
|
74
|
+
if (opts.json) {
|
|
75
|
+
console.log(JSON.stringify(entries, null, 2));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (entries.length === 0) {
|
|
79
|
+
console.log(chalk.dim("No projects known yet — `kraftwerk ui` registers the current one."));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const table = new Table({
|
|
83
|
+
head: ["project", "root", "status", "last started"].map((h) => chalk.bold(h)),
|
|
84
|
+
wordWrap: true,
|
|
85
|
+
colWidths: [22, 48, 24, 14],
|
|
86
|
+
});
|
|
87
|
+
for (const e of entries) {
|
|
88
|
+
table.push([
|
|
89
|
+
`${e.icon ? e.icon + " " : ""}${chalk.cyan(e.name)}`,
|
|
90
|
+
e.rootLabel ?? chalk.dim("(no root recorded)"),
|
|
91
|
+
status(e),
|
|
92
|
+
fmtAgo(e.lastStarted),
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
console.log(table.toString());
|
|
96
|
+
});
|
|
97
|
+
projects
|
|
98
|
+
.command("start")
|
|
99
|
+
.description("Relaunch the UI of a stopped project (detached; logs in ~/.kraftwerk/logs)")
|
|
100
|
+
.argument("<ref>", "Project name, folder name, or root path")
|
|
101
|
+
.action(async (ref) => {
|
|
102
|
+
const entry = await resolveRef(ref);
|
|
103
|
+
if (entry.live) {
|
|
104
|
+
console.log(`${chalk.green("✔")} ${entry.name} already running: ${chalk.cyan(entry.url)}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const r = await startProject(entry.root);
|
|
108
|
+
if (!r.ok) {
|
|
109
|
+
console.error(chalk.red(`Could not start ${entry.name}: ${r.error}`));
|
|
110
|
+
if (r.log)
|
|
111
|
+
console.error(chalk.dim(`log: ${tildify(r.log)}`));
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
console.log(`${chalk.green("✔")} ${entry.name} ${r.live ? "running" : "starting"}: ${chalk.cyan(r.url)}` +
|
|
115
|
+
chalk.dim(` (pid ${r.pid}${r.log ? `, log ${tildify(r.log)}` : ""})`));
|
|
116
|
+
});
|
|
117
|
+
projects
|
|
118
|
+
.command("stop")
|
|
119
|
+
.description("Stop a running UI (SIGTERM to its server; works for terminal-started ones too)")
|
|
120
|
+
.argument("<ref>", "Project name, folder name, root path, or port")
|
|
121
|
+
.action(async (ref) => {
|
|
122
|
+
const entry = await resolveRef(ref, false);
|
|
123
|
+
if (!entry.live) {
|
|
124
|
+
console.log(chalk.dim(`${entry.name} is not running.`));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const r = await stopProject({ root: entry.root, url: entry.url });
|
|
128
|
+
if (!r.ok) {
|
|
129
|
+
console.error(chalk.red(`Could not stop ${entry.name}: ${r.error}`));
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
console.log(`${chalk.green("✔")} ${entry.name} stopped ${chalk.dim(`(${entry.url.replace(/^https?:\/\//, "")})`)}`);
|
|
133
|
+
});
|
|
134
|
+
projects
|
|
135
|
+
.command("forget")
|
|
136
|
+
.description("Remove a project from the registry (its folder is untouched)")
|
|
137
|
+
.argument("<ref>", "Project name, folder name, or root path")
|
|
138
|
+
.action(async (ref) => {
|
|
139
|
+
const entry = await resolveRef(ref);
|
|
140
|
+
if (await forgetProject(entry.root)) {
|
|
141
|
+
console.log(`${chalk.green("✔")} forgot ${entry.name} (${entry.rootLabel})`);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.error(chalk.red(`No record for ${entry.root}`));
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
package/dist/cli/ui.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { spawn, spawnSync } from "node:child_process";
|
|
5
6
|
import chalk from "chalk";
|
|
6
7
|
import { resolveProject } from "../config.js";
|
|
8
|
+
import { selfCommand } from "../inspector/self-command.js";
|
|
7
9
|
import { RESTART_EXIT_CODE, startInspector } from "../inspector/server.js";
|
|
8
10
|
/**
|
|
9
11
|
* `kraftwerk ui` — start the inspector web UI pointed at the current
|
|
@@ -59,27 +61,42 @@ export async function runUi(cwd, opts) {
|
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Respawn loop around the real server. Spawns this same bin script via the
|
|
62
|
-
* current node — works identically for global installs,
|
|
63
|
-
* npx, and a file: dev checkout. Any exit other than
|
|
64
|
-
*
|
|
64
|
+
* current node (selfCommand) — works identically for global installs,
|
|
65
|
+
* local node_modules, npx, and a file: dev checkout. Any exit other than
|
|
66
|
+
* RESTART_EXIT_CODE ends the loop. A SIGTERM/SIGINT to the supervisor is
|
|
67
|
+
* forwarded to the server, so `kill <supervisor pid>` (what `kraftwerk
|
|
68
|
+
* projects start` reports) takes the whole UI down; Ctrl-C signals the
|
|
69
|
+
* foreground group and reaches both anyway.
|
|
65
70
|
*/
|
|
66
71
|
async function superviseUi(opts) {
|
|
67
|
-
const args = [
|
|
68
|
-
process.argv[1],
|
|
72
|
+
const { cmd, args } = selfCommand([
|
|
69
73
|
"ui",
|
|
70
74
|
...(opts.port ? ["--port", opts.port] : []),
|
|
71
75
|
...(opts.output ? ["--output", opts.output] : []),
|
|
72
|
-
];
|
|
76
|
+
]);
|
|
73
77
|
for (;;) {
|
|
74
|
-
const child = spawn(
|
|
78
|
+
const child = spawn(cmd, args, {
|
|
75
79
|
stdio: "inherit",
|
|
76
80
|
env: { ...process.env, KRAFTWERK_UI_SUPERVISED: "1" },
|
|
77
81
|
});
|
|
78
|
-
const
|
|
79
|
-
child.
|
|
82
|
+
const forward = (sig) => () => {
|
|
83
|
+
child.kill(sig);
|
|
84
|
+
};
|
|
85
|
+
const handlers = { SIGTERM: forward("SIGTERM"), SIGINT: forward("SIGINT") };
|
|
86
|
+
process.on("SIGTERM", handlers.SIGTERM);
|
|
87
|
+
process.on("SIGINT", handlers.SIGINT);
|
|
88
|
+
const result = await new Promise((resolve) => {
|
|
89
|
+
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
80
90
|
});
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
process.off("SIGTERM", handlers.SIGTERM);
|
|
92
|
+
process.off("SIGINT", handlers.SIGINT);
|
|
93
|
+
if (result.code !== RESTART_EXIT_CODE) {
|
|
94
|
+
// A signal-killed server is not a clean exit — say so in the exit code
|
|
95
|
+
// (128 + signal, the shell convention) so callers can tell.
|
|
96
|
+
if (result.signal)
|
|
97
|
+
process.exit(128 + (os.constants.signals[result.signal] ?? 1));
|
|
98
|
+
process.exit(result.code ?? 1);
|
|
99
|
+
}
|
|
83
100
|
console.log(chalk.dim("↻ relaunching the UI with the current install ..."));
|
|
84
101
|
}
|
|
85
102
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -68,6 +68,8 @@ export interface Project {
|
|
|
68
68
|
/** Absolute run-artifact directory (may not exist yet). */
|
|
69
69
|
outputDir: string;
|
|
70
70
|
}
|
|
71
|
+
/** True when the path exists and is a directory. */
|
|
72
|
+
export declare const isDir: (p: string) => Promise<boolean>;
|
|
71
73
|
/**
|
|
72
74
|
* Resolve the project for a cwd: walk up until a kraftwerk.yml or a
|
|
73
75
|
* workflows root appears; a .git directory is the fallback root, the cwd
|
package/dist/config.js
CHANGED
|
@@ -32,7 +32,8 @@ export const CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/NETNODEAG/kr
|
|
|
32
32
|
export const CONFIG_FILENAMES = ["kraftwerk.yml", "kraftwerk.yaml"];
|
|
33
33
|
const WORKFLOW_ROOT_CANDIDATES = ["src/workflows", "workflows"];
|
|
34
34
|
const exists = async (p) => !!(await stat(p).catch(() => null));
|
|
35
|
-
|
|
35
|
+
/** True when the path exists and is a directory. */
|
|
36
|
+
export const isDir = async (p) => (await stat(p).catch(() => null))?.isDirectory() ?? false;
|
|
36
37
|
async function findConfigFile(dir) {
|
|
37
38
|
for (const name of CONFIG_FILENAMES) {
|
|
38
39
|
const candidate = path.join(dir, name);
|
|
@@ -1,13 +1,116 @@
|
|
|
1
|
+
/** Durable per-project record. The root is the key; everything else derives from it. */
|
|
2
|
+
export interface ProjectRecord {
|
|
3
|
+
root: string;
|
|
4
|
+
firstSeen: string;
|
|
5
|
+
lastStarted: string;
|
|
6
|
+
/** Set on clean shutdown; older than lastStarted means the last run died. */
|
|
7
|
+
lastStopped?: string;
|
|
8
|
+
startCount: number;
|
|
9
|
+
}
|
|
1
10
|
/** A verified running instance, shaped like a switcher entry. */
|
|
2
11
|
export interface DiscoveredInstance {
|
|
3
12
|
name: string;
|
|
4
13
|
url: string;
|
|
5
14
|
icon?: string;
|
|
6
15
|
live: true;
|
|
16
|
+
root?: string;
|
|
17
|
+
/** Server process id (what to signal to stop it). */
|
|
18
|
+
pid: number;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* One workspace as the switcher shows it: a known project (running or
|
|
22
|
+
* not) or a running instance the projects registry doesn't know yet.
|
|
23
|
+
*/
|
|
24
|
+
export interface WorkspaceEntry {
|
|
25
|
+
name: string;
|
|
26
|
+
/** Where the inspector answers (live) or would answer once started. */
|
|
27
|
+
url: string;
|
|
28
|
+
icon?: string;
|
|
29
|
+
live: boolean;
|
|
30
|
+
root?: string;
|
|
31
|
+
/** Root with ~ for the home dir — what the UI prints. */
|
|
32
|
+
rootLabel?: string;
|
|
33
|
+
/** False when the root directory is gone (or no longer a project of its own); start is impossible. */
|
|
34
|
+
exists?: boolean;
|
|
35
|
+
lastStarted?: string;
|
|
36
|
+
lastStopped?: string;
|
|
37
|
+
}
|
|
38
|
+
/** ~/… for display. */
|
|
39
|
+
export declare const tildify: (p: string) => string;
|
|
8
40
|
/** Write this instance's registry file (call once the server listens). */
|
|
9
|
-
export declare function registerInstance(port: number): Promise<void>;
|
|
41
|
+
export declare function registerInstance(port: number, root: string): Promise<void>;
|
|
10
42
|
/** Remove this instance's registry file. Sync so exit handlers can call it. */
|
|
11
43
|
export declare function unregisterInstance(): void;
|
|
12
44
|
/** All other running instances, verified live. Cached briefly — /api/meta is polled. */
|
|
13
45
|
export declare function discoverInstances(): Promise<DiscoveredInstance[]>;
|
|
46
|
+
/** Upsert the project record for a root (call on every inspector start). */
|
|
47
|
+
export declare function registerProject(root: string): Promise<void>;
|
|
48
|
+
/** Stamp lastStopped on clean shutdown. Sync so exit handlers can call it. */
|
|
49
|
+
export declare function markProjectStopped(): void;
|
|
50
|
+
/** All known projects, most recently started first. */
|
|
51
|
+
export declare function listProjects(): Promise<ProjectRecord[]>;
|
|
52
|
+
/** Drop a project record (the root itself is untouched). */
|
|
53
|
+
export declare function forgetProject(root: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* The switcher's view: every known project joined with the live instances,
|
|
56
|
+
* plus running instances with no project record yet. The calling instance
|
|
57
|
+
* itself is left out. Live entries first, then by last start. Cached like
|
|
58
|
+
* discoverInstances — /api/meta is polled and this stats every root.
|
|
59
|
+
*/
|
|
60
|
+
export declare function discoverWorkspaces(): Promise<WorkspaceEntry[]>;
|
|
61
|
+
export type WorkspaceState = "running" | "stopped" | "died" | "missing" | "orphaned";
|
|
62
|
+
/** A workspace with everything the admin screen shows. */
|
|
63
|
+
export interface WorkspaceDetail extends WorkspaceEntry {
|
|
64
|
+
/** The instance answering this request. */
|
|
65
|
+
current?: boolean;
|
|
66
|
+
/** kraftwerk.yml present in the root itself (not inherited from an ancestor). */
|
|
67
|
+
hasConfig?: boolean;
|
|
68
|
+
/** The root directory itself is gone (vs. still there but no longer a project). */
|
|
69
|
+
dirGone?: boolean;
|
|
70
|
+
state: WorkspaceState;
|
|
71
|
+
firstSeen?: string;
|
|
72
|
+
startCount?: number;
|
|
73
|
+
counts?: {
|
|
74
|
+
agents: number;
|
|
75
|
+
workflows: number;
|
|
76
|
+
runs: number;
|
|
77
|
+
chats: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Every workspace including this one, with config presence, counts of
|
|
82
|
+
* what lives in the root, and a single derived state. Not cached — the
|
|
83
|
+
* admin screen polls slowly and wants fresh counts.
|
|
84
|
+
*/
|
|
85
|
+
export declare function listWorkspacesDetailed(): Promise<WorkspaceDetail[]>;
|
|
86
|
+
export interface StartResult {
|
|
87
|
+
ok: boolean;
|
|
88
|
+
url?: string;
|
|
89
|
+
/** True once the new inspector answered its probe within the wait. */
|
|
90
|
+
live?: boolean;
|
|
91
|
+
pid?: number;
|
|
92
|
+
log?: string;
|
|
93
|
+
error?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Launch `kraftwerk ui` for a root as a detached process (selfCommand:
|
|
97
|
+
* the bin this process runs from), logging to ~/.kraftwerk/logs/<key>.log.
|
|
98
|
+
* The reported pid is the `kraftwerk ui` supervisor, which forwards
|
|
99
|
+
* SIGTERM/SIGINT to its server child, so `kill <pid>` stops the whole UI.
|
|
100
|
+
* Waits up to ~5s for the new inspector to answer so callers can link
|
|
101
|
+
* straight to it.
|
|
102
|
+
*/
|
|
103
|
+
export declare function startProject(root: string): Promise<StartResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Stop a running workspace: SIGTERM to its server process, which
|
|
106
|
+
* unregisters, stamps lastStopped and exits; the `kraftwerk ui` supervisor
|
|
107
|
+
* follows. Matched by root, or by url for instances from older versions
|
|
108
|
+
* that registered no root. Waits up to ~5s for the port to go quiet.
|
|
109
|
+
*/
|
|
110
|
+
export declare function stopProject(target: {
|
|
111
|
+
root?: string;
|
|
112
|
+
url?: string;
|
|
113
|
+
}): Promise<{
|
|
114
|
+
ok: boolean;
|
|
115
|
+
error?: string;
|
|
116
|
+
}>;
|