agent-director 0.4.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.
Files changed (2) hide show
  1. package/README.md +137 -0
  2. package/package.json +42 -0
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # agent-director
2
+
3
+ TypeScript/Bun client for the agent-director CLI (FFI-backed; shares the Go API surface 1:1).
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ bun add agent-director
9
+ ```
10
+
11
+ Requires Bun >=1.0.21. The package ships a prebuilt shared library for each supported platform via optional dependencies — they install automatically on `bun add`.
12
+
13
+ ## Quick start
14
+
15
+ `using` block (preferred):
16
+
17
+ ```ts
18
+ using client = new Client({ storePath: "~/.agent-director/state.db" });
19
+ const v = await client.version({});
20
+ console.log(v.version);
21
+ ```
22
+
23
+ Explicit `try/finally` (portable fallback):
24
+
25
+ ```ts
26
+ const client = new Client({ storePath: "~/.agent-director/state.db" });
27
+ try {
28
+ const v = await client.version({});
29
+ console.log(v.version);
30
+ } finally {
31
+ client.close();
32
+ }
33
+ ```
34
+
35
+ `storePath` is the only required constructor option. Tilde expansion (`~` → home directory) is handled automatically before paths cross the FFI boundary. The `using` form calls `client.close()` automatically at block exit and requires Bun >=1.0.21 (or a TypeScript project with `"lib": ["ESNext.Disposable"]`).
36
+
37
+ ## Verb examples
38
+
39
+ ### spawn
40
+
41
+ Launch a tracked Claude Code instance in a new tmux session.
42
+
43
+ ```sh
44
+ agent-director spawn --cwd ~/my-project
45
+ ```
46
+
47
+ ```ts
48
+ const result = await client.spawn({ cwd: "~/my-project" });
49
+ console.log(result.claude_instance_id);
50
+ ```
51
+
52
+ ### status
53
+
54
+ Get the current lifecycle state of a Spawn.
55
+
56
+ ```sh
57
+ agent-director status --claude-instance-id <id>
58
+ ```
59
+
60
+ ```ts
61
+ const result = await client.status({ claude_instance_id: "<id>" });
62
+ console.log(result.state);
63
+ ```
64
+
65
+ ### list
66
+
67
+ Query Spawns with optional filters.
68
+
69
+ ```sh
70
+ agent-director list --state waiting
71
+ ```
72
+
73
+ ```ts
74
+ const result = await client.list({ state: ["waiting"] });
75
+ for (const spawn of result.spawns) {
76
+ console.log(spawn.claude_instance_id, spawn.state);
77
+ }
78
+ ```
79
+
80
+ ### sendKeys
81
+
82
+ Send text to a Spawn's tmux pane.
83
+
84
+ ```sh
85
+ agent-director send-keys --claude-instance-id <id> --text "what is 2+2?"
86
+ ```
87
+
88
+ ```ts
89
+ await client.sendKeys({ claude_instance_id: "<id>", text: "what is 2+2?" });
90
+ ```
91
+
92
+ ### kill
93
+
94
+ Terminate a Spawn's tmux session.
95
+
96
+ ```sh
97
+ agent-director kill --claude-instance-id <id>
98
+ ```
99
+
100
+ ```ts
101
+ await client.kill({ claude_instance_id: "<id>" });
102
+ ```
103
+
104
+ ## Versioning
105
+
106
+ The library version equals the agent-director release tag — released in lockstep:
107
+
108
+ | npm package | CLI binary |
109
+ |---|---|
110
+ | `agent-director@v0.5.0` | `agent-director CLI v0.5.0` |
111
+
112
+ ## Supported Bun versions
113
+
114
+ Minimum: `>=1.0.21` (set in `engines.bun`). Tested on Bun 1.3.x as of this release. The `using` block syntax (Explicit Resource Management) requires Bun 1.0.21+.
115
+
116
+ ## Errors
117
+
118
+ Every error thrown by this package extends `AgentDirectorError`. A typed subclass is generated for each `err_name` in the shared catalog so you can catch by subclass:
119
+
120
+ ```ts
121
+ import { Client, ErrSpawnNotFound } from "agent-director";
122
+ try {
123
+ await client.status({ claude_instance_id: "bogus" });
124
+ } catch (e) {
125
+ if (e instanceof ErrSpawnNotFound) {
126
+ // recover
127
+ } else {
128
+ throw e;
129
+ }
130
+ }
131
+ ```
132
+
133
+ The full `err_name` catalog is in [`../../pkg/api/errnames/catalog.json`](../../pkg/api/errnames/catalog.json).
134
+
135
+ ## Architecture
136
+
137
+ See [`../../docs/architecture.md`](../../docs/architecture.md) for the internal design. Dedicated subsections cover: Client lifecycle, FFI call recipe, Per-platform packaging, Error mapping, TS smoke-test harness, and TS envelope-diff regression.
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "agent-director",
3
+ "version": "0.4.0",
4
+ "type": "module",
5
+ "engines": {
6
+ "bun": ">=1.0.21"
7
+ },
8
+ "files": [
9
+ "dist/**/*.js",
10
+ "dist/**/*.d.ts",
11
+ "!dist/**/*.test.*",
12
+ "README.md"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "bun run build.ts",
22
+ "lint": "eslint src/ --ext .ts",
23
+ "typecheck": "tsc --noEmit --project tsconfig.typecheck.json",
24
+ "test": "bun test",
25
+ "smoke": "bun test test/smoke/ test/smoke-invariants.test.ts",
26
+ "envelope-diff": "bun test test/envelope-diff.test.ts test/envelope-diff-invariants.test.ts",
27
+ "prepare-platforms": "bun run scripts/prepare-platforms.ts",
28
+ "version-bump-publish": "bun run scripts/version-bump.ts",
29
+ "prepublishOnly": "bun run scripts/check-not-placeholder.ts"
30
+ },
31
+ "optionalDependencies": {
32
+ "@agent-director/linux-x64": "^0.4.0",
33
+ "@agent-director/darwin-arm64": "^0.4.0"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": ">=5.2.0",
37
+ "bun-types": "latest",
38
+ "eslint": "^8.0.0",
39
+ "@typescript-eslint/parser": "^7.0.0",
40
+ "@typescript-eslint/eslint-plugin": "^7.0.0"
41
+ }
42
+ }