@ours.network/fleet 0.1.0 → 0.1.1
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.js +1 -1
- package/dist/spawn.d.ts +3 -2
- package/dist/spawn.js +18 -4
- package/package.json +25 -7
package/dist/cli.js
CHANGED
|
@@ -158,7 +158,7 @@ cOpt(program.command('spawn <name>').description('spawn a new agent (permanent b
|
|
|
158
158
|
};
|
|
159
159
|
try {
|
|
160
160
|
if (o.temp) {
|
|
161
|
-
const dir = await spawnTemp(o,
|
|
161
|
+
const dir = await spawnTemp(o, binPath);
|
|
162
162
|
console.log(`spawned temp agent '${name}' (state: ${dir}; gone on exit/reboot)`);
|
|
163
163
|
}
|
|
164
164
|
else {
|
package/dist/spawn.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type OpsDeps } from './ops.js';
|
|
2
|
-
import type { Tmux } from './tmux.js';
|
|
3
2
|
export interface SpawnOpts {
|
|
4
3
|
name: string;
|
|
5
4
|
temp?: boolean;
|
|
@@ -15,5 +14,7 @@ export interface SpawnOpts {
|
|
|
15
14
|
}
|
|
16
15
|
/** Permanent spawn: persist to ~/fleet.d/<Name>.yaml, then bring it up. */
|
|
17
16
|
export declare function spawnPermanent(o: SpawnOpts, deps: OpsDeps): Promise<string>;
|
|
17
|
+
/** Launches the detached temp supervisor (`_run-temp <name>`). Injectable for tests. */
|
|
18
|
+
export type SupervisorLauncher = (binPath: string, args: string[], dir: string) => void;
|
|
18
19
|
/** Temp spawn: state under ~/.ours-fleet/tmp, plain tmux, auto-clean on exit. */
|
|
19
|
-
export declare function spawnTemp(o: SpawnOpts,
|
|
20
|
+
export declare function spawnTemp(o: SpawnOpts, binPath: string, launch?: SupervisorLauncher): Promise<string>;
|
package/dist/spawn.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn as spawnChild } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, openSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { stringify } from 'yaml';
|
|
4
5
|
import { agentDir, fleetDDir } from './paths.js';
|
|
5
6
|
import { loadConfig } from './config.js';
|
|
6
7
|
import { applyRole, up } from './ops.js';
|
|
7
|
-
import { shq } from './exec.js';
|
|
8
8
|
function roleFromOpts(o) {
|
|
9
9
|
const r = {};
|
|
10
10
|
if (o.harness)
|
|
@@ -39,8 +39,17 @@ export async function spawnPermanent(o, deps) {
|
|
|
39
39
|
await up(loadConfig(o.configPath), [o.name], deps);
|
|
40
40
|
return file;
|
|
41
41
|
}
|
|
42
|
+
const detachedSupervisor = (binPath, args, dir) => {
|
|
43
|
+
// Log to the temp dir; the fd stays valid even after runTemp removes the dir.
|
|
44
|
+
const out = openSync(join(dir, 'supervisor.log'), 'a');
|
|
45
|
+
const child = spawnChild(process.execPath, [binPath, ...args], {
|
|
46
|
+
detached: true,
|
|
47
|
+
stdio: ['ignore', out, out],
|
|
48
|
+
});
|
|
49
|
+
child.unref();
|
|
50
|
+
};
|
|
42
51
|
/** Temp spawn: state under ~/.ours-fleet/tmp, plain tmux, auto-clean on exit. */
|
|
43
|
-
export async function spawnTemp(o,
|
|
52
|
+
export async function spawnTemp(o, binPath, launch = detachedSupervisor) {
|
|
44
53
|
assertNameFree(o);
|
|
45
54
|
const cfg = loadConfig(o.configPath);
|
|
46
55
|
const role = {
|
|
@@ -52,6 +61,11 @@ export async function spawnTemp(o, tmux, binPath) {
|
|
|
52
61
|
};
|
|
53
62
|
const dir = applyRole(role, { temp: true });
|
|
54
63
|
writeFileSync(join(dir, 'role.yaml'), stringify(role));
|
|
55
|
-
|
|
64
|
+
// Run the supervisor DETACHED — NOT inside a tmux session named <name>.
|
|
65
|
+
// `_run-temp` -> runOnce() creates AND kills the tmux session <name> for the
|
|
66
|
+
// agent itself; a supervisor sharing that session name would SIGHUP its own
|
|
67
|
+
// process before the agent ever launches. Detaching mirrors how systemd hosts
|
|
68
|
+
// the supervisor for permanent roles, leaving runOnce to own the <name> session.
|
|
69
|
+
launch(binPath, ['_run-temp', o.name], dir);
|
|
56
70
|
return dir;
|
|
57
71
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/fleet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Harness-agnostic fleet of persistent, identity-bound AI agents. Declarative fleet.yaml, tmux consoles, systemd/launchd supervision, ours.network messaging.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|
|
7
|
-
"repository": {
|
|
8
|
-
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/adapt-toolkit/ours-fleet.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"ours-fleet": "dist/cli.js"
|
|
13
|
+
},
|
|
9
14
|
"main": "dist/index.js",
|
|
10
|
-
"files": [
|
|
11
|
-
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
12
23
|
"scripts": {
|
|
13
24
|
"build": "tsc -p tsconfig.json",
|
|
14
25
|
"test": "vitest run",
|
|
15
26
|
"prepublishOnly": "npm run build && npm test"
|
|
16
27
|
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"commander": "^12.1.0",
|
|
30
|
+
"yaml": "^2.5.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.14.0",
|
|
34
|
+
"typescript": "^5.5.0",
|
|
35
|
+
"vitest": "^2.0.0"
|
|
36
|
+
}
|
|
19
37
|
}
|