@ours.network/fleet 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -187,7 +187,7 @@ for the reference implementation.
187
187
  ours-fleet is part of [ours.network](https://ours.network) — free, source-available
188
188
  software built by a small independent team, running the broker and relay services
189
189
  at their own cost. If this is useful to you, please consider chipping in:
190
- **→ https://ours.network/donate**
190
+ **→ https://github.com/adapt-toolkit/ours-donate**
191
191
 
192
192
  ## License
193
193
 
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, new Tmux(), binPath);
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, tmux: Tmux, binPath: string): Promise<string>;
20
+ export declare function spawnTemp(o: SpawnOpts, binPath: string, launch?: SupervisorLauncher): Promise<string>;
package/dist/spawn.js CHANGED
@@ -1,10 +1,10 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
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, tmux, binPath) {
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
- await tmux.newSession(o.name, dir, `${shq(binPath)} _run-temp ${shq(o.name)}`);
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.0",
3
+ "version": "0.1.2",
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": { "type": "git", "url": "https://github.com/adapt-toolkit/ours-fleet.git" },
8
- "bin": { "ours-fleet": "dist/cli.js" },
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": ["dist", "README.md", "LICENSE"],
11
- "engines": { "node": ">=20" },
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": { "commander": "^12.1.0", "yaml": "^2.5.0" },
18
- "devDependencies": { "@types/node": "^20.14.0", "typescript": "^5.5.0", "vitest": "^2.0.0" }
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
  }