groove-dev 0.27.207 → 0.27.209
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/node_modules/@groove-dev/cli/package.json +1 -1
- package/node_modules/@groove-dev/daemon/package.json +1 -1
- package/node_modules/@groove-dev/daemon/src/axom-connector.js +50 -2
- package/node_modules/@groove-dev/daemon/src/axom-remote.js +16 -14
- package/node_modules/@groove-dev/daemon/src/axom-runtimes.js +498 -0
- package/node_modules/@groove-dev/daemon/src/axom-server.js +25 -4
- package/node_modules/@groove-dev/daemon/src/index.js +3 -1
- package/node_modules/@groove-dev/daemon/src/routes/axom.js +113 -0
- package/node_modules/@groove-dev/daemon/src/routes/watch.js +11 -0
- package/node_modules/@groove-dev/daemon/src/watcher.js +55 -2
- package/node_modules/@groove-dev/daemon/test/axom-connector.test.js +44 -1
- package/node_modules/@groove-dev/daemon/test/axom-runtimes.test.js +367 -0
- package/node_modules/@groove-dev/daemon/test/watcher.test.js +68 -2
- package/node_modules/@groove-dev/gui/dist/assets/{index-OzNfp6-Y.js → index-217ZVIOc.js} +242 -237
- package/node_modules/@groove-dev/gui/dist/assets/index-DdCadtGL.css +1 -0
- package/node_modules/@groove-dev/gui/dist/index.html +2 -2
- package/node_modules/@groove-dev/gui/package.json +1 -1
- package/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/daemon/package.json +1 -1
- package/packages/daemon/src/axom-connector.js +50 -2
- package/packages/daemon/src/axom-remote.js +16 -14
- package/packages/daemon/src/axom-runtimes.js +498 -0
- package/packages/daemon/src/axom-server.js +25 -4
- package/packages/daemon/src/index.js +3 -1
- package/packages/daemon/src/routes/axom.js +113 -0
- package/packages/daemon/src/routes/watch.js +11 -0
- package/packages/daemon/src/watcher.js +55 -2
- package/packages/gui/dist/assets/{index-OzNfp6-Y.js → index-217ZVIOc.js} +242 -237
- package/packages/gui/dist/assets/index-DdCadtGL.css +1 -0
- package/packages/gui/dist/index.html +2 -2
- package/packages/gui/package.json +1 -1
- package/node_modules/@groove-dev/gui/dist/assets/index-DG6yq4dB.css +0 -1
- package/packages/gui/dist/assets/index-DG6yq4dB.css +0 -1
|
@@ -122,6 +122,119 @@ export function registerAxomRoutes(app, daemon) {
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
+
// ── Runtimes — the one entity (plans/axom-runtime-flow-redesign.md) ─────
|
|
126
|
+
// The GUI reasons about runtimes only; endpoints/instances/ssh are backends.
|
|
127
|
+
|
|
128
|
+
app.get('/api/axom/runtimes', async (req, res) => {
|
|
129
|
+
res.json(await daemon.axomRuntimes.status());
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
app.post('/api/axom/runtimes', (req, res) => {
|
|
133
|
+
try {
|
|
134
|
+
const rt = daemon.axomRuntimes.add(req.body);
|
|
135
|
+
if (req.body?.activate) daemon.axomRuntimes.activate(rt.id);
|
|
136
|
+
daemon.audit.log('axom.runtime.add', { id: rt.id, control: rt.control });
|
|
137
|
+
res.json(rt);
|
|
138
|
+
} catch (err) {
|
|
139
|
+
res.status(400).json({ error: err.message });
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
app.patch('/api/axom/runtimes/:id', (req, res) => {
|
|
144
|
+
try {
|
|
145
|
+
res.json(daemon.axomRuntimes.update(req.params.id, req.body || {}));
|
|
146
|
+
} catch (err) {
|
|
147
|
+
res.status(400).json({ error: err.message });
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
app.delete('/api/axom/runtimes/:id', (req, res) => {
|
|
152
|
+
try {
|
|
153
|
+
daemon.axomRuntimes.remove(req.params.id);
|
|
154
|
+
daemon.audit.log('axom.runtime.remove', { id: req.params.id });
|
|
155
|
+
res.json({ ok: true });
|
|
156
|
+
} catch (err) {
|
|
157
|
+
res.status(400).json({ error: err.message });
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Mono-Axom (§10): a hook is a fresh session on the ONE runtime — never a
|
|
162
|
+
// second process. Used by the agent selector, new tabs, and new chats alike.
|
|
163
|
+
// Chats are named hooks, persisted daemon-side so the list survives a
|
|
164
|
+
// refresh. Removing one HIDES it — the conversation is the user's memory and
|
|
165
|
+
// lives in the runtime's ledger; GROOVE tidying its list never destroys it.
|
|
166
|
+
app.get('/api/axom/chats', (req, res) => {
|
|
167
|
+
res.json({ chats: daemon.axomRuntimes.chats() });
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
app.patch('/api/axom/chats/:session', (req, res) => {
|
|
171
|
+
try {
|
|
172
|
+
res.json(daemon.axomRuntimes.renameChat(req.params.session, req.body?.label));
|
|
173
|
+
} catch (err) {
|
|
174
|
+
res.status(400).json({ error: err.message });
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
app.delete('/api/axom/chats/:session', (req, res) => {
|
|
179
|
+
try {
|
|
180
|
+
const result = daemon.axomRuntimes.hideChat(req.params.session);
|
|
181
|
+
daemon.audit.log('axom.chat.hide', { session: req.params.session });
|
|
182
|
+
res.json(result);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
res.status(400).json({ error: err.message });
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
app.post('/api/axom/hook', async (req, res) => {
|
|
189
|
+
try {
|
|
190
|
+
const result = await daemon.axomRuntimes.hook(req.body?.runtimeId, {
|
|
191
|
+
session: req.body?.session,
|
|
192
|
+
label: req.body?.label,
|
|
193
|
+
});
|
|
194
|
+
daemon.audit.log('axom.hook', { runtime: result.runtimeId, session: result.session });
|
|
195
|
+
res.json(result);
|
|
196
|
+
} catch (err) {
|
|
197
|
+
res.status(502).json({ error: err.message });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
app.post('/api/axom/runtimes/:id/activate', (req, res) => {
|
|
202
|
+
try {
|
|
203
|
+
daemon.axomRuntimes.activate(req.params.id);
|
|
204
|
+
res.json({ ok: true, activeRuntimeId: req.params.id });
|
|
205
|
+
} catch (err) {
|
|
206
|
+
res.status(400).json({ error: err.message });
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
app.post('/api/axom/runtimes/:id/start', async (req, res) => {
|
|
211
|
+
try {
|
|
212
|
+
const result = await daemon.axomRuntimes.startRuntime(req.params.id);
|
|
213
|
+
daemon.audit.log('axom.runtime.start', { id: req.params.id });
|
|
214
|
+
res.json(result);
|
|
215
|
+
} catch (err) {
|
|
216
|
+
res.status(502).json({ error: err.message });
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
app.post('/api/axom/runtimes/:id/stop', async (req, res) => {
|
|
221
|
+
try {
|
|
222
|
+
const result = await daemon.axomRuntimes.stopRuntime(req.params.id, { force: !!req.body?.force });
|
|
223
|
+
daemon.audit.log('axom.runtime.stop', { id: req.params.id });
|
|
224
|
+
res.json(result);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
res.status(502).json({ error: err.message });
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
app.post('/api/axom/runtimes/:id/heal', async (req, res) => {
|
|
231
|
+
try {
|
|
232
|
+
res.json(await daemon.axomRuntimes.heal(req.params.id));
|
|
233
|
+
} catch (err) {
|
|
234
|
+
res.status(502).json({ error: err.message });
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
125
238
|
// ── Remote runtime control over SSH (manual only, never automatic) ──────
|
|
126
239
|
|
|
127
240
|
app.get('/api/axom/remote', async (req, res) => {
|
|
@@ -20,6 +20,17 @@ export function registerWatchRoutes(app, daemon) {
|
|
|
20
20
|
if (!who) return res.status(404).json({ error: `Unknown agent: ${agent}` });
|
|
21
21
|
|
|
22
22
|
const watch = daemon.watcher.create(who.id, { command, until, label, timeoutMs, intervalMs });
|
|
23
|
+
if (watch.reattached) {
|
|
24
|
+
return res.json({
|
|
25
|
+
ok: true,
|
|
26
|
+
watchId: watch.id,
|
|
27
|
+
reattached: true,
|
|
28
|
+
message: `That command is ALREADY RUNNING under watch ${watch.id} ("${watch.label}") — `
|
|
29
|
+
+ 'this request re-attached to it instead of starting a second copy. '
|
|
30
|
+
+ 'Do NOT launch it again by hand. You will be resumed with the result when it finishes; '
|
|
31
|
+
+ 'you can end your turn now.',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
23
34
|
res.json({
|
|
24
35
|
ok: true,
|
|
25
36
|
watchId: watch.id,
|
|
@@ -59,6 +59,28 @@ export class Watcher {
|
|
|
59
59
|
if (!command && !until) throw new Error('Provide either "command" (run it) or "until" (poll it)');
|
|
60
60
|
if (command && until) throw new Error('Provide only one of "command" or "until"');
|
|
61
61
|
|
|
62
|
+
// Re-attach, never re-execute. A daemon restart resumes the agent mid-turn,
|
|
63
|
+
// so it re-issues the watch it thinks never completed — and a second copy of
|
|
64
|
+
// a long job (training, benchmark) launched against the same working dir
|
|
65
|
+
// corrupts the first one's output and competes for the GPU. If an identical
|
|
66
|
+
// command is still running for this agent, hand back the existing watch.
|
|
67
|
+
// This is the daemon-side equivalent of an flock, and it has to live here
|
|
68
|
+
// because the agent cannot know a duplicate already exists.
|
|
69
|
+
if (command) {
|
|
70
|
+
const dup = [...this.watches.values()].find(
|
|
71
|
+
(w) => w.status === 'active'
|
|
72
|
+
&& w.mode === 'command'
|
|
73
|
+
&& w.command === command
|
|
74
|
+
&& (w.agentName === agent.name || w.agentId === agentId)
|
|
75
|
+
&& this._jobAlive(w),
|
|
76
|
+
);
|
|
77
|
+
if (dup) {
|
|
78
|
+
this.daemon.audit?.log('watch.duplicate', { id: dup.id, agent: agentId, label: dup.label });
|
|
79
|
+
console.log(`[Groove:Watcher] Re-attached to running watch ${dup.id} instead of re-running: ${dup.label}`);
|
|
80
|
+
return { ...this._public(dup), reattached: true };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
62
84
|
const active = [...this.watches.values()].filter((w) => w.agentId === agentId && w.status === 'active');
|
|
63
85
|
if (active.length >= MAX_WATCHES_PER_AGENT) {
|
|
64
86
|
throw new Error(`You already have ${MAX_WATCHES_PER_AGENT} active watches — cancel one before adding another`);
|
|
@@ -118,11 +140,14 @@ export class Watcher {
|
|
|
118
140
|
// Run the command in a SUBSHELL so its own `exit N` can't kill the wrapper
|
|
119
141
|
// before the sentinel is written; tee output to a file, then atomically
|
|
120
142
|
// publish the exit code so the poller never sees a half-written value.
|
|
143
|
+
// Append rather than truncate: if this script is ever run twice, `>` would
|
|
144
|
+
// erase the first run's record — exactly the evidence you need to work out
|
|
145
|
+
// what happened. Appending keeps both.
|
|
121
146
|
const script = [
|
|
122
147
|
'#!/bin/sh',
|
|
123
148
|
'(',
|
|
124
149
|
watch.command,
|
|
125
|
-
`)
|
|
150
|
+
`) >> ${shq(watch.outFile)} 2>&1`,
|
|
126
151
|
`echo $? > ${shq(watch.statusFile)}.tmp && mv ${shq(watch.statusFile)}.tmp ${shq(watch.statusFile)}`,
|
|
127
152
|
'',
|
|
128
153
|
].join('\n');
|
|
@@ -143,6 +168,16 @@ export class Watcher {
|
|
|
143
168
|
}
|
|
144
169
|
}
|
|
145
170
|
|
|
171
|
+
// Is this watch's detached job still running? Signal 0 tests for existence
|
|
172
|
+
// without delivering anything. A finished job (sentinel present) is not alive
|
|
173
|
+
// even if the pid happens to have been recycled by another process.
|
|
174
|
+
_jobAlive(watch) {
|
|
175
|
+
if (watch.mode !== 'command') return false;
|
|
176
|
+
if (watch.statusFile && existsSync(watch.statusFile)) return false; // already exited
|
|
177
|
+
if (!watch.pid) return false;
|
|
178
|
+
try { process.kill(watch.pid, 0); return true; } catch { return false; }
|
|
179
|
+
}
|
|
180
|
+
|
|
146
181
|
// One poll iteration — checks for completion (sentinel for command mode, the
|
|
147
182
|
// `until` command for until mode) and wakes the agent when it's met.
|
|
148
183
|
_tick(watch) {
|
|
@@ -257,6 +292,7 @@ export class Watcher {
|
|
|
257
292
|
if (!Array.isArray(data)) return 0;
|
|
258
293
|
|
|
259
294
|
let rearmed = 0;
|
|
295
|
+
let lost = 0;
|
|
260
296
|
const now = Date.now();
|
|
261
297
|
for (const w of data) {
|
|
262
298
|
// Drop stale finished watches; keep recent ones for history.
|
|
@@ -268,10 +304,27 @@ export class Watcher {
|
|
|
268
304
|
}
|
|
269
305
|
const watch = { ...w, _poll: null, _deadline: null };
|
|
270
306
|
this.watches.set(watch.id, watch);
|
|
307
|
+
|
|
308
|
+
// A command watch whose job is gone with no exit sentinel died while the
|
|
309
|
+
// daemon was down. Polling it would just burn until the timeout and then
|
|
310
|
+
// report "may still be running" — say what actually happened instead.
|
|
311
|
+
if (watch.mode === 'command' && watch.pid
|
|
312
|
+
&& !existsSync(watch.statusFile || '') && !this._jobAlive(watch)) {
|
|
313
|
+
lost++;
|
|
314
|
+
this._wake(watch, {
|
|
315
|
+
outcome: 'error',
|
|
316
|
+
summary: `The job for "${watch.label}" is no longer running and never recorded an exit code — `
|
|
317
|
+
+ 'it was lost while the daemon was down. Check its output before assuming it finished.',
|
|
318
|
+
output: tailFile(watch.outFile, OUTPUT_TAIL),
|
|
319
|
+
});
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
|
|
271
323
|
this._arm(watch);
|
|
272
324
|
rearmed++;
|
|
273
325
|
}
|
|
274
|
-
if (rearmed > 0) console.log(`[Groove:Watcher]
|
|
326
|
+
if (rearmed > 0) console.log(`[Groove:Watcher] Re-attached to ${rearmed} running watch(es) after restart`);
|
|
327
|
+
if (lost > 0) console.log(`[Groove:Watcher] ${lost} watch(es) lost their job while the daemon was down`);
|
|
275
328
|
this._persist();
|
|
276
329
|
return rearmed;
|
|
277
330
|
}
|