@nordhavnhq/runner 0.95.0 → 0.96.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/agent.d.ts +5 -5
- package/dist/cli/agent.js +19 -60
- package/dist/cli/lifecycle.js +6 -6
- package/dist/cli/link.d.ts +0 -22
- package/dist/cli/link.js +37 -39
- package/dist/cli/logs.js +2 -5
- package/dist/cli/ps.js +4 -5
- package/dist/index.js +23 -33
- package/dist/runtime/up.js +8 -9
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/format.js +2 -2
- package/dist/version.json +3 -3
- package/node_modules/@nordhavnhq/runner-browser/package.json +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/dist/constants.js +1 -1
- package/node_modules/@nordhavnhq/runner-runtime/package.json +1 -1
- package/package.json +3 -3
package/dist/cli/agent.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type CliCtx } from './prompts.js';
|
|
2
2
|
/**
|
|
3
|
-
* `agent add` and `agent
|
|
4
|
-
* `nordhavn link <code>`
|
|
5
|
-
* Kept as commands that say so, for muscle memory.
|
|
3
|
+
* `agent add`, `agent relink` and `agent remove` are gone: a runner hosts one
|
|
4
|
+
* agent, `nordhavn link <code>` connects (or replaces) it and `nordhavn unlink`
|
|
5
|
+
* removes it with the pairing. Kept as commands that say so, for muscle memory.
|
|
6
6
|
*/
|
|
7
7
|
export declare function removedAgentCommand(): Promise<void>;
|
|
8
|
-
|
|
9
|
-
export declare function
|
|
8
|
+
/** `nordhavn agent`: the one agent this runner hosts. */
|
|
9
|
+
export declare function show(ctx: CliCtx): Promise<void>;
|
package/dist/cli/agent.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { loadConfig,
|
|
2
|
-
import { dim, green, red, bold, showHelp
|
|
1
|
+
import { loadConfig, agentHomeDir, agentRef } from '../config.js';
|
|
2
|
+
import { dim, green, red, bold, showHelp } from '../utils/format.js';
|
|
3
3
|
import { wantsHelp } from './prompts.js';
|
|
4
4
|
/**
|
|
5
|
-
* `agent add` and `agent
|
|
6
|
-
* `nordhavn link <code>`
|
|
7
|
-
* Kept as commands that say so, for muscle memory.
|
|
5
|
+
* `agent add`, `agent relink` and `agent remove` are gone: a runner hosts one
|
|
6
|
+
* agent, `nordhavn link <code>` connects (or replaces) it and `nordhavn unlink`
|
|
7
|
+
* removes it with the pairing. Kept as commands that say so, for muscle memory.
|
|
8
8
|
*/
|
|
9
9
|
export async function removedAgentCommand() {
|
|
10
10
|
console.log('');
|
|
11
|
-
console.log(red(' Removed: a runner hosts one agent
|
|
11
|
+
console.log(red(' Removed: a runner hosts one agent.'));
|
|
12
|
+
console.log(dim(' Connect or replace it: `nordhavn link <code>` with a code from the agent\'s page in the studio.'));
|
|
13
|
+
console.log(dim(' Remove it: `nordhavn unlink`.\n'));
|
|
12
14
|
process.exit(1);
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
/** `nordhavn agent`: the one agent this runner hosts. */
|
|
17
|
+
export async function show(ctx) {
|
|
15
18
|
if (wantsHelp(ctx)) {
|
|
16
|
-
showHelp('nordhavn agent
|
|
19
|
+
showHelp('nordhavn agent', 'Show the agent of this runner', [], ['nordhavn agent']);
|
|
17
20
|
return;
|
|
18
21
|
}
|
|
19
22
|
console.log('');
|
|
@@ -22,59 +25,15 @@ export async function remove(ctx) {
|
|
|
22
25
|
console.log(red(' Not configured. Run `nordhavn init` first.\n'));
|
|
23
26
|
process.exit(1);
|
|
24
27
|
}
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
console.log(
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
const agent = requireAgent(config, ref);
|
|
31
|
-
const removedRef = agentRef(config, agent);
|
|
32
|
-
const updated = removeAgent(config, agent);
|
|
33
|
-
await saveConfig(updated);
|
|
34
|
-
console.log(green(` ✓ Agent "${removedRef}" removed.`));
|
|
35
|
-
console.log(dim(` ${updated.agents.length} agent(s) remaining.\n`));
|
|
36
|
-
}
|
|
37
|
-
export async function list(ctx) {
|
|
38
|
-
if (wantsHelp(ctx)) {
|
|
39
|
-
showHelp('nordhavn agent ls', 'List all configured agents', [], ['nordhavn agent ls']);
|
|
28
|
+
const agent = config.agents[0];
|
|
29
|
+
if (!agent) {
|
|
30
|
+
console.log(dim(' No agent yet. Run `nordhavn link <code>` with a code from the agent\'s page in the studio.\n'));
|
|
40
31
|
return;
|
|
41
32
|
}
|
|
33
|
+
const state = agent.enabled ? green('●') : dim('○');
|
|
34
|
+
const org = agent.organisationSlug ? dim(` · ${agent.organisationSlug}`) : '';
|
|
35
|
+
console.log(` ${state} ${bold(agentRef(config, agent))}${org}${agent.enabled ? '' : dim(' · disabled')}`);
|
|
36
|
+
console.log(dim(` home: ${agentHomeDir(config, agent)}`));
|
|
42
37
|
console.log('');
|
|
43
|
-
|
|
44
|
-
if (!config) {
|
|
45
|
-
console.log(red(' Not configured. Run `nordhavn init` first.\n'));
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
if (config.agents.length === 0) {
|
|
49
|
-
console.log(dim(' No agent configured. Run `nordhavn link <code>` with a code from the agent\'s page in the studio.\n'));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// Organisation is noise while there is only one pairing, and essential once
|
|
53
|
-
// there are several - so it only appears when it can actually differ.
|
|
54
|
-
const showOrg = config.hosts.length > 1;
|
|
55
|
-
console.log(bold(' Agents\n'));
|
|
56
|
-
for (const agent of config.agents) {
|
|
57
|
-
const state = agent.enabled ? green('●') : dim('○');
|
|
58
|
-
const home = agentHomeDir(config, agent).replace(config.home, '').replace(/^[/\\]/, '');
|
|
59
|
-
const org = showOrg ? dim(` · ${agent.organisationSlug ?? 'unknown organisation'}`) : '';
|
|
60
|
-
console.log(` ${state} ${bold(agentRef(config, agent))} ${dim(`· ${home}/`)}${org}`);
|
|
61
|
-
}
|
|
62
|
-
console.log('');
|
|
63
|
-
console.log(dim(` Home: ${config.home}`));
|
|
64
|
-
console.log(dim(` ${config.agents.length} agent(s) configured.\n`));
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Resolve a user-typed agent reference or exit with a readable error. A bare
|
|
68
|
-
* slug that names several agents is refused rather than guessed at.
|
|
69
|
-
*/
|
|
70
|
-
function requireAgent(config, ref) {
|
|
71
|
-
const found = resolveAgentRef(config, ref);
|
|
72
|
-
if ('agent' in found)
|
|
73
|
-
return found.agent;
|
|
74
|
-
if ('ambiguous' in found) {
|
|
75
|
-
printAmbiguous(config, ref, found.ambiguous);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
console.log(red(` Agent "${ref}" not found.\n`));
|
|
79
|
-
process.exit(1);
|
|
38
|
+
console.log(dim(' Replace it: `nordhavn link <code>` · remove it: `nordhavn unlink`.\n'));
|
|
80
39
|
}
|
package/dist/cli/lifecycle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { loadConfig, agentRef, resolveAgentRef } from '../config.js';
|
|
2
2
|
import { liveStatus, readAllStatuses, isAlive, isStatusAlive, spawnDetachedAgent, } from '../runtime/daemon.js';
|
|
3
|
-
import { dim, green, red, showHelp,
|
|
3
|
+
import { dim, green, red, showHelp, printAmbiguous } from '../utils/format.js';
|
|
4
4
|
import { wantsHelp } from './prompts.js';
|
|
5
5
|
function wantsDebug(ctx) {
|
|
6
6
|
return ctx.cmdArgs.includes('--debug') || ctx.cmdArgs.includes('-v');
|
|
@@ -39,7 +39,7 @@ async function waitForExit(pid, timeoutMs) {
|
|
|
39
39
|
}
|
|
40
40
|
export async function down(ctx) {
|
|
41
41
|
if (wantsHelp(ctx)) {
|
|
42
|
-
showHelp('nordhavn down
|
|
42
|
+
showHelp('nordhavn down', 'Take the agent of this runner offline', [], ['nordhavn down']);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
console.log('');
|
|
@@ -50,7 +50,7 @@ export async function down(ctx) {
|
|
|
50
50
|
if (isStatusAlive(s))
|
|
51
51
|
pids.add(s.pid);
|
|
52
52
|
if (pids.size === 0) {
|
|
53
|
-
console.log(dim('
|
|
53
|
+
console.log(dim(' The agent is not running.\n'));
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
let killed = 0;
|
|
@@ -63,7 +63,7 @@ export async function down(ctx) {
|
|
|
63
63
|
console.log(red(` Failed to signal pid ${pid}: ${err.message}`));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
console.log(green(` ✓ Stopped ${killed} runtime
|
|
66
|
+
console.log(green(killed > 1 ? ` ✓ Stopped ${killed} runtime processes.\n` : ' ✓ Agent stopped.\n'));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
const config = await loadConfig();
|
|
@@ -98,7 +98,7 @@ export async function down(ctx) {
|
|
|
98
98
|
}
|
|
99
99
|
export async function restart(ctx) {
|
|
100
100
|
if (wantsHelp(ctx)) {
|
|
101
|
-
showHelp('nordhavn restart
|
|
101
|
+
showHelp('nordhavn restart', 'Restart the agent of this runner in the background', [], ['nordhavn restart']);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
console.log('');
|
|
@@ -112,7 +112,7 @@ export async function restart(ctx) {
|
|
|
112
112
|
? [resolveRefOrExit(config, ctx.subarg)]
|
|
113
113
|
: readAllStatuses().filter(s => isStatusAlive(s)).map(s => s.ref);
|
|
114
114
|
if (targets.length === 0) {
|
|
115
|
-
console.log(dim('
|
|
115
|
+
console.log(dim(' The agent is not running. Start it with `nordhavn up -d`.\n'));
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
const knownRefs = new Set(config.agents.map(a => agentRef(config, a)));
|
package/dist/cli/link.d.ts
CHANGED
|
@@ -17,26 +17,4 @@ import { type CliCtx } from './prompts.js';
|
|
|
17
17
|
* `projectsRoots` describe this machine, not an organisation.
|
|
18
18
|
*/
|
|
19
19
|
export declare function link(ctx: CliCtx): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Remove a pairing and every agent that belongs to it - the inverse of `link`,
|
|
22
|
-
* for a client whose work is finished or a studio this machine should no longer
|
|
23
|
-
* answer to.
|
|
24
|
-
*
|
|
25
|
-
* Refuses while any of the organisation's agents are still running. Their host
|
|
26
|
-
* token disappears with the pairing, so the process would keep spinning on a
|
|
27
|
-
* connection it can no longer make instead of failing where the operator can
|
|
28
|
-
* see it. Stopping them from here is tempting but wrong: a foreground session
|
|
29
|
-
* can drive agents from several organisations at once, and killing it would
|
|
30
|
-
* take the others down too - which is exactly why `down` refuses that case as
|
|
31
|
-
* well.
|
|
32
|
-
*
|
|
33
|
-
* The studio-side `Runner` row is left alone: there is no local endpoint to
|
|
34
|
-
* revoke it, and unlike a re-pair there is no code being redeemed that could
|
|
35
|
-
* carry the proof of ownership along (see `pairingProofs`), so this says
|
|
36
|
-
* so rather than pretending the machine is gone from the organisation.
|
|
37
|
-
*
|
|
38
|
-
* Agent home directories are left on disk, matching `agent remove`. That is why
|
|
39
|
-
* `flatHomeOrg` is not cleared here - see `removePairing` and
|
|
40
|
-
* `canClaimFlatHome` for how the flat layout is protected afterwards.
|
|
41
|
-
*/
|
|
42
20
|
export declare function unlink(ctx: CliCtx): Promise<void>;
|
package/dist/cli/link.js
CHANGED
|
@@ -233,9 +233,34 @@ export async function link(ctx) {
|
|
|
233
233
|
* `flatHomeOrg` is not cleared here - see `removePairing` and
|
|
234
234
|
* `canClaimFlatHome` for how the flat layout is protected afterwards.
|
|
235
235
|
*/
|
|
236
|
+
/** One pairing per runner, so `unlink` needs no argument: the organisation of
|
|
237
|
+
* that pairing. An explicit argument still works (old configs, scripts). */
|
|
238
|
+
function pairedOrganisation(config) {
|
|
239
|
+
if (config.hosts.length !== 1)
|
|
240
|
+
return undefined;
|
|
241
|
+
return config.hosts[0].organisationSlug ?? NAMELESS_ORG_LABEL;
|
|
242
|
+
}
|
|
243
|
+
/** The agent of `org` that is still running, if any. Matched on the ref the
|
|
244
|
+
* status file was written under and on the organisation it recorded: a status
|
|
245
|
+
* file written before a rename or by an older runner can carry the other one. */
|
|
246
|
+
function runningAgentOf(config, org) {
|
|
247
|
+
const target = config.hosts.find(h => h.organisationSlug === org)
|
|
248
|
+
?? (org === NAMELESS_ORG_LABEL ? config.hosts.find(h => h.organisationSlug === null) : undefined);
|
|
249
|
+
if (!target)
|
|
250
|
+
return undefined;
|
|
251
|
+
const live = readAllStatuses().filter(s => isStatusAlive(s));
|
|
252
|
+
for (const agent of config.agents.filter(a => a.organisationSlug === target.organisationSlug)) {
|
|
253
|
+
const ref = agentRef(config, agent);
|
|
254
|
+
const status = live.find(s => s.ref === ref)
|
|
255
|
+
?? live.find(s => s.slug === agent.slug && s.organisationSlug === agent.organisationSlug);
|
|
256
|
+
if (status)
|
|
257
|
+
return { ref, status };
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
236
261
|
export async function unlink(ctx) {
|
|
237
262
|
if (wantsHelp(ctx)) {
|
|
238
|
-
showHelp('nordhavn unlink
|
|
263
|
+
showHelp('nordhavn unlink', 'Remove the pairing and its agent from this runner', [], ['nordhavn unlink']);
|
|
239
264
|
return;
|
|
240
265
|
}
|
|
241
266
|
console.log('');
|
|
@@ -245,48 +270,22 @@ export async function unlink(ctx) {
|
|
|
245
270
|
process.exit(1);
|
|
246
271
|
return;
|
|
247
272
|
}
|
|
248
|
-
const org = ctx.subarg;
|
|
273
|
+
const org = ctx.subarg ?? pairedOrganisation(config);
|
|
249
274
|
if (!org) {
|
|
250
|
-
console.log(
|
|
251
|
-
console.log(dim(' `nordhavn ps` names the organisations this machine is paired with.\n'));
|
|
252
|
-
process.exit(1);
|
|
275
|
+
console.log(dim(' This runner is not paired.\n'));
|
|
253
276
|
return;
|
|
254
277
|
}
|
|
255
278
|
// Refuse before mutating anything: a running agent means the operator has a
|
|
256
279
|
// process to deal with first, and a half-applied unlink would leave it
|
|
257
280
|
// holding a token no host backs any more.
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// organisation it recorded - a status file written before a rename or by
|
|
267
|
-
// an older runner can carry the other one.
|
|
268
|
-
.map(({ ref, agent }) => ({
|
|
269
|
-
ref,
|
|
270
|
-
status: live.find(s => s.ref === ref)
|
|
271
|
-
?? live.find(s => s.slug === agent.slug && s.organisationSlug === agent.organisationSlug),
|
|
272
|
-
}))
|
|
273
|
-
.filter((r) => r.status !== undefined);
|
|
274
|
-
if (running.length > 0) {
|
|
275
|
-
const shared = running.some(r => r.status.mode === 'foreground');
|
|
276
|
-
console.log(red(` ${running.length} agent(s) from "${org}" are still running:`));
|
|
277
|
-
for (const r of running)
|
|
278
|
-
console.log(red(` ${r.ref} ${dim(`(${r.status.mode}, pid ${r.status.pid})`)}`));
|
|
279
|
-
console.log('');
|
|
280
|
-
console.log(dim(' Stop them first, then unlink again:'));
|
|
281
|
-
console.log(dim(` nordhavn down ${running[0].ref}${running.length > 1 ? ' (repeat per agent)' : ''}`));
|
|
282
|
-
if (shared) {
|
|
283
|
-
console.log(dim(' A foreground session can drive other organisations\' agents too - `down` will'));
|
|
284
|
-
console.log(dim(' refuse it and tell you to Ctrl+C that session instead.'));
|
|
285
|
-
}
|
|
286
|
-
console.log('');
|
|
287
|
-
process.exit(1);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
281
|
+
const running = runningAgentOf(config, org);
|
|
282
|
+
if (running) {
|
|
283
|
+
console.log(red(` ${running.ref} is still running ${dim(`(${running.status.mode}, pid ${running.status.pid})`)}.`));
|
|
284
|
+
console.log(dim(running.status.mode === 'foreground'
|
|
285
|
+
? ' Stop it first (Ctrl+C in its terminal), then unlink again.\n'
|
|
286
|
+
: ' Stop it first with `nordhavn down`, then unlink again.\n'));
|
|
287
|
+
process.exit(1);
|
|
288
|
+
return;
|
|
290
289
|
}
|
|
291
290
|
const result = removePairing(config, org);
|
|
292
291
|
if ('missing' in result) {
|
|
@@ -300,8 +299,7 @@ export async function unlink(ctx) {
|
|
|
300
299
|
const name = result.host.organisationSlug ?? NAMELESS_ORG_LABEL;
|
|
301
300
|
console.log(green(` ✓ Unlinked "${name}" (${result.host.name}).`));
|
|
302
301
|
if (result.removedAgents.length > 0) {
|
|
303
|
-
console.log(dim(` Removed
|
|
304
|
-
console.log(dim(' Their home directories are left on disk, as `agent remove` leaves them.'));
|
|
302
|
+
console.log(dim(` Removed agent ${result.removedAgents.map(a => a.slug).join(', ')}; its home directory stays on disk.`));
|
|
305
303
|
}
|
|
306
304
|
// Only worth explaining when the flat layer is actually still occupied -
|
|
307
305
|
// otherwise the next `link` simply reclaims it and there is nothing to know.
|
package/dist/cli/logs.js
CHANGED
|
@@ -93,10 +93,7 @@ function follow(target, multi) {
|
|
|
93
93
|
}
|
|
94
94
|
export async function logs(ctx) {
|
|
95
95
|
if (wantsHelp(ctx)) {
|
|
96
|
-
showHelp('nordhavn logs [
|
|
97
|
-
helpOpt(dim('[agent]'), 'Agent to show; every agent with logs if omitted. Use slug@organisation when a slug exists in more than one'),
|
|
98
|
-
helpOpt(dim('--once'), 'Print the recent lines and exit instead of following'),
|
|
99
|
-
], ['nordhavn logs', 'nordhavn logs atlas', 'nordhavn logs atlas@klant-x', 'nordhavn logs --once']);
|
|
96
|
+
showHelp('nordhavn logs [--once]', 'Tail the log of the agent when it runs in the background', [helpOpt(dim('--once'), 'Print the recent lines and exit instead of following')], ['nordhavn logs', 'nordhavn logs --once']);
|
|
100
97
|
return;
|
|
101
98
|
}
|
|
102
99
|
// Follow live by default; --once is the one-shot dump (for piping/scrollback).
|
|
@@ -127,7 +124,7 @@ export async function logs(ctx) {
|
|
|
127
124
|
.filter(f => f.endsWith('.log'))
|
|
128
125
|
.map(f => ({ ref: f.slice(0, -4), file: join(logsDir(), f) }));
|
|
129
126
|
if (targets.length === 0) {
|
|
130
|
-
console.log(dim(' No agent
|
|
127
|
+
console.log(dim(' No agent log yet. Start the agent with `nordhavn up -d`.\n'));
|
|
131
128
|
return;
|
|
132
129
|
}
|
|
133
130
|
}
|
package/dist/cli/ps.js
CHANGED
|
@@ -32,7 +32,7 @@ function cellFor(status) {
|
|
|
32
32
|
}
|
|
33
33
|
export async function ps(ctx) {
|
|
34
34
|
if (wantsHelp(ctx)) {
|
|
35
|
-
showHelp('nordhavn ps', 'Show the runtime status of
|
|
35
|
+
showHelp('nordhavn ps', 'Show the runtime status of the agent', [], ['nordhavn ps']);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
console.log('');
|
|
@@ -73,9 +73,8 @@ export async function ps(ctx) {
|
|
|
73
73
|
console.log(` ${dot} ${pad(bold(ref), refWidth)}${org}${pad(label, 16)}${pad(dim(uptime), 10)}${pad(dim(mode), 13)}${dim(pid)}`);
|
|
74
74
|
}
|
|
75
75
|
console.log('');
|
|
76
|
-
console.log(dim(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
76
|
+
console.log(dim(live.size > 0
|
|
77
|
+
? ' `nordhavn logs` to follow output · `nordhavn down` to stop'
|
|
78
|
+
: ' `nordhavn up` to start'));
|
|
80
79
|
console.log('');
|
|
81
80
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// First: maps pre-rename env names (JUSTMADE_*, HAVEN_*) before anything reads them.
|
|
3
3
|
import './legacy-env.js';
|
|
4
|
-
import { dim, bold, cyan, red, accent, logo,
|
|
4
|
+
import { dim, bold, cyan, red, accent, logo, stripAnsi, VERSION } from './utils/format.js';
|
|
5
5
|
import { init } from './cli/init.js';
|
|
6
6
|
import { link, unlink } from './cli/link.js';
|
|
7
|
-
import { removedAgentCommand,
|
|
7
|
+
import { removedAgentCommand, show } from './cli/agent.js';
|
|
8
8
|
import { folderCommand } from './cli/folder.js';
|
|
9
9
|
import { up } from './runtime/up.js';
|
|
10
10
|
import { ps } from './cli/ps.js';
|
|
@@ -21,15 +21,10 @@ const args = process.argv.slice(2);
|
|
|
21
21
|
const command = args[0] ?? '';
|
|
22
22
|
let resolvedCommand = command;
|
|
23
23
|
let cmdArgs = args.slice(1);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
resolvedCommand = `agent:${args[1]}`;
|
|
31
|
-
cmdArgs = args.slice(2);
|
|
32
|
-
}
|
|
24
|
+
// `nordhavn agent` shows the runner's agent; `agent ls` is the old spelling.
|
|
25
|
+
if (command === 'agent' && args[1] && args[1] !== '-h' && args[1] !== '--help') {
|
|
26
|
+
resolvedCommand = `agent:${args[1]}`;
|
|
27
|
+
cmdArgs = args.slice(2);
|
|
33
28
|
}
|
|
34
29
|
if (command === 'folder' && args[1]) {
|
|
35
30
|
if (args[1] === '-h' || args[1] === '--help') {
|
|
@@ -44,8 +39,10 @@ if (command === 'folder' && args[1]) {
|
|
|
44
39
|
const aliases = {
|
|
45
40
|
add: 'agent:add',
|
|
46
41
|
remove: 'agent:remove',
|
|
47
|
-
ls: 'agent
|
|
48
|
-
list: 'agent
|
|
42
|
+
ls: 'agent',
|
|
43
|
+
list: 'agent',
|
|
44
|
+
'agent:ls': 'agent',
|
|
45
|
+
'agent:list': 'agent',
|
|
49
46
|
'-h': 'help',
|
|
50
47
|
'--help': 'help',
|
|
51
48
|
'--version': 'version',
|
|
@@ -65,21 +62,15 @@ const commands = {
|
|
|
65
62
|
init,
|
|
66
63
|
link,
|
|
67
64
|
unlink,
|
|
65
|
+
agent: show,
|
|
68
66
|
'agent:add': removedAgentCommand,
|
|
69
|
-
'agent:remove':
|
|
67
|
+
'agent:remove': removedAgentCommand,
|
|
70
68
|
'agent:relink': removedAgentCommand,
|
|
71
|
-
'agent:ls': list,
|
|
72
69
|
folder: folderCommand,
|
|
73
70
|
'folder:add': folderCommand,
|
|
74
71
|
'folder:rm': folderCommand,
|
|
75
72
|
'folder:ls': folderCommand,
|
|
76
73
|
'folder:help': folderCommand,
|
|
77
|
-
'agent:help': async () => {
|
|
78
|
-
showHelp('nordhavn agent <action> [args]', 'Manage agents', [
|
|
79
|
-
helpOpt(cyan('ls'), 'List the agent of this runner'),
|
|
80
|
-
helpOpt(`${cyan('remove')} ${dim('<slug>')}`, 'Remove an agent'),
|
|
81
|
-
], ['nordhavn agent ls', 'nordhavn link AB7F2QXR']);
|
|
82
|
-
},
|
|
83
74
|
up: (c) => up({ ref: c.subarg, wantsHelp: wantsHelpFlag(c), debug: wantsDebug(c), detach: wantsDetach(c) }),
|
|
84
75
|
ps,
|
|
85
76
|
down,
|
|
@@ -105,25 +96,22 @@ function printRootHelp() {
|
|
|
105
96
|
// padding to drift out of sync.
|
|
106
97
|
const sections = [
|
|
107
98
|
{ title: 'Runtime', rows: [
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
111
|
-
[cyan('ps'), 'Show
|
|
112
|
-
[
|
|
113
|
-
[
|
|
99
|
+
[cyan('up'), 'Bring the agent online (foreground)'],
|
|
100
|
+
[cyan('up -d'), 'Bring the agent online in the background'],
|
|
101
|
+
[cyan('down'), 'Take the agent offline'],
|
|
102
|
+
[cyan('ps'), 'Show the agent\'s status'],
|
|
103
|
+
[cyan('logs'), 'Tail the agent\'s log live (--once to dump)'],
|
|
104
|
+
[cyan('restart'), 'Restart the agent in the background'],
|
|
114
105
|
[`${cyan('relay')} ${dim('[off]')}`, 'Git relay: push for you from here (off disconnects)'],
|
|
115
106
|
] },
|
|
116
107
|
{ title: 'Setup', rows: [
|
|
117
108
|
[cyan('init'), 'Configure this runner (studio URL + home)'],
|
|
118
|
-
[`${cyan('link')} ${dim('<code>')}`, 'Pair this
|
|
119
|
-
[
|
|
109
|
+
[`${cyan('link')} ${dim('<code>')}`, 'Pair this runner with an agent (replaces the current one)'],
|
|
110
|
+
[cyan('unlink'), 'Remove the pairing and its agent'],
|
|
111
|
+
[cyan('agent'), 'Show the agent of this runner'],
|
|
120
112
|
[`${cyan('update')} ${dim('[--check]')}`, 'Install the latest runner release'],
|
|
121
113
|
[cyan('--version'), 'Print the installed version'],
|
|
122
114
|
] },
|
|
123
|
-
{ title: 'Agents', rows: [
|
|
124
|
-
[cyan('agent ls'), 'List the agent of this runner'],
|
|
125
|
-
[`${cyan('agent remove')} ${dim('<slug>')}`, 'Remove an agent'],
|
|
126
|
-
] },
|
|
127
115
|
{ title: 'Folders', rows: [
|
|
128
116
|
[cyan('folder ls'), 'List folders and the projects they expose'],
|
|
129
117
|
[`${cyan('folder add')} ${dim('<path>')}`, 'Let the runner open projects from a folder'],
|
|
@@ -142,4 +130,6 @@ function printRootHelp() {
|
|
|
142
130
|
}
|
|
143
131
|
console.log('');
|
|
144
132
|
}
|
|
133
|
+
console.log(dim(' One runner hosts one agent. Another agent on this machine gets its own profile:'));
|
|
134
|
+
console.log(dim(` ${cyan('NORDHAVN_PROFILE=<name> nordhavn init')}, then ${cyan('nordhavn link <code>')}.`) + '\n');
|
|
145
135
|
}
|
package/dist/runtime/up.js
CHANGED
|
@@ -40,11 +40,10 @@ import { UPDATE_CHECK_INTERVAL_MS } from '../update/updater.js';
|
|
|
40
40
|
const toolProvider = withSonarPrewarm(hostToolProvider);
|
|
41
41
|
export async function up(opts) {
|
|
42
42
|
if (opts.wantsHelp) {
|
|
43
|
-
showHelp('nordhavn up [
|
|
44
|
-
helpOpt(dim('[agent]'), 'Bring only this agent up (optional, all enabled if omitted). Use slug@organisation when a slug exists in more than one'),
|
|
43
|
+
showHelp('nordhavn up [-d] [--debug]', 'Bring the agent of this runner online in the studio', [
|
|
45
44
|
helpOpt(dim('--detach, -d'), 'Run in the background; the terminal returns immediately'),
|
|
46
45
|
helpOpt(dim('--debug, -v'), 'Verbose event log (inference + tool timings, reconnect details)'),
|
|
47
|
-
], ['nordhavn up', 'nordhavn up
|
|
46
|
+
], ['nordhavn up', 'nordhavn up -d']);
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
49
|
// A foreground run of a release install is a thin supervisor around the real
|
|
@@ -98,7 +97,7 @@ export async function up(opts) {
|
|
|
98
97
|
if (config.agents.length === 0)
|
|
99
98
|
console.log(red(' No agent configured. Run `nordhavn link <code>` with a code from the agent\'s page in the studio.\n'));
|
|
100
99
|
else
|
|
101
|
-
console.log(red('
|
|
100
|
+
console.log(red(' The agent of this runner is disabled.\n'));
|
|
102
101
|
process.exit(1);
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
@@ -116,7 +115,7 @@ export async function up(opts) {
|
|
|
116
115
|
console.log(dim(` Run \`nordhavn link <code>\` with a code from that organisation.`));
|
|
117
116
|
}
|
|
118
117
|
if (pairable.length === 0) {
|
|
119
|
-
console.log(red('\n
|
|
118
|
+
console.log(red('\n The agent has no matching pairing on this runner.\n'));
|
|
120
119
|
process.exit(1);
|
|
121
120
|
return;
|
|
122
121
|
}
|
|
@@ -142,7 +141,7 @@ export async function up(opts) {
|
|
|
142
141
|
runnable.push(agent);
|
|
143
142
|
}
|
|
144
143
|
if (runnable.length === 0) {
|
|
145
|
-
console.log(red('\n
|
|
144
|
+
console.log(red('\n The agent is already running. See `nordhavn ps`.\n'));
|
|
146
145
|
process.exit(1);
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
@@ -340,7 +339,7 @@ export async function up(opts) {
|
|
|
340
339
|
if (live <= 0 || connectedCount < live)
|
|
341
340
|
return;
|
|
342
341
|
welcomeShown = true;
|
|
343
|
-
welcome(
|
|
342
|
+
welcome(agentRef(config, runnable[0]));
|
|
344
343
|
};
|
|
345
344
|
for (const agent of runnable) {
|
|
346
345
|
// Local identity for everything file- and map-keyed. Tracked in a mutable
|
|
@@ -671,7 +670,7 @@ export async function up(opts) {
|
|
|
671
670
|
// looks healthy in `ps` while doing nothing at all.
|
|
672
671
|
if (stoppedAgents.size >= totalAgents && !shuttingDown) {
|
|
673
672
|
console.log('');
|
|
674
|
-
console.log(red(
|
|
673
|
+
console.log(red(' The agent stopped - nothing left to run.\n'));
|
|
675
674
|
process.exit(1);
|
|
676
675
|
}
|
|
677
676
|
// The remaining agents may already all be connected, in which case this
|
|
@@ -1253,7 +1252,7 @@ function launchDetached(config, agents, debug) {
|
|
|
1253
1252
|
}
|
|
1254
1253
|
console.log('');
|
|
1255
1254
|
if (started > 0) {
|
|
1256
|
-
console.log(` ${green(
|
|
1255
|
+
console.log(` ${green('The agent runs in the background.')}`);
|
|
1257
1256
|
console.log(dim(' `nordhavn ps` to view status · `nordhavn logs` to follow output · `nordhavn down` to stop.\n'));
|
|
1258
1257
|
}
|
|
1259
1258
|
else {
|
package/dist/utils/format.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function isNewerVersion(a: string, b: string): boolean;
|
|
|
24
24
|
* that updates this kind of install (see update/policy.ts). */
|
|
25
25
|
export declare function updateNotice(current: string, latest: string, how?: string): void;
|
|
26
26
|
export declare function contractNotice(ours: string, studios: string): void;
|
|
27
|
-
export declare function welcome(
|
|
27
|
+
export declare function welcome(agent: string): void;
|
|
28
28
|
export declare function log(sym: LogSymbol, agent: string, msg: string): void;
|
|
29
29
|
export declare function truncate(s: string, len?: number): string;
|
|
30
30
|
export declare function formatCost(micros: number): string;
|
package/dist/utils/format.js
CHANGED
|
@@ -74,8 +74,8 @@ export function contractNotice(ours, studios) {
|
|
|
74
74
|
console.log(` ${dim('one of the two is behind; update the runner with')} ${cyan('nordhavn update')}`);
|
|
75
75
|
console.log('');
|
|
76
76
|
}
|
|
77
|
-
export function welcome(
|
|
78
|
-
const agentStr = `${
|
|
77
|
+
export function welcome(agent) {
|
|
78
|
+
const agentStr = `${agent} online`;
|
|
79
79
|
console.log('');
|
|
80
80
|
console.log(` ${dim('─'.repeat(54))}`);
|
|
81
81
|
console.log(` ${green('◆')} ${accent('welcome to nordhavn')} ${dim('·')} ${cyan(agentStr)}`);
|
package/dist/version.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordhavnhq/runner-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0",
|
|
4
4
|
"description": "Nordhavn OS agent browser: Playwright sessions, the browser tools, the confirm-first guard and the live view, for the runner and the browser host",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -85,7 +85,7 @@ export function fatalCloseHint(code, reason) {
|
|
|
85
85
|
case CLOSE_HOST_REVOKED:
|
|
86
86
|
return `this runner was revoked in the studio - pair again with \`nordhavn link <code>\``;
|
|
87
87
|
case CLOSE_AGENT_DELETED:
|
|
88
|
-
return `this agent no longer exists in the studio - remove it with \`nordhavn
|
|
88
|
+
return `this agent no longer exists in the studio - connect another one with \`nordhavn link <code>\`, or remove it with \`nordhavn unlink\``;
|
|
89
89
|
default:
|
|
90
90
|
return reason || `closed with code ${code}`;
|
|
91
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordhavnhq/runner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0",
|
|
4
4
|
"description": "Nordhavn OS runner CLI: runs agents headless on a host and supplies the host tools",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
26
26
|
"@vscode/ripgrep": "^1.18.0",
|
|
27
27
|
"mysql2": "^3.24.6",
|
|
28
|
-
"@nordhavnhq/runner-runtime": "0.
|
|
29
|
-
"@nordhavnhq/runner-browser": "0.
|
|
28
|
+
"@nordhavnhq/runner-runtime": "0.96.0",
|
|
29
|
+
"@nordhavnhq/runner-browser": "0.96.0"
|
|
30
30
|
},
|
|
31
31
|
"bundleDependencies": [
|
|
32
32
|
"@nordhavnhq/runner-runtime",
|