agent-director 0.4.0 → 0.4.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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * expandTilde resolves a leading `~` or `~/` to the user's home directory.
3
+ *
4
+ * Resolution order:
5
+ * 1. `process.env.HOME` if set and non-empty.
6
+ * 2. `os.homedir()` from node:os as fallback.
7
+ *
8
+ * Behaviour by input:
9
+ * - `""` → `""` (empty string unchanged)
10
+ * - `"~"` → `"/home/user"` (bare tilde → home directory)
11
+ * - `"~/foo"` → `"/home/user/foo"` (tilde-prefix → home + rest)
12
+ * - `"/abs/path"` → `"/abs/path"` (absolute path unchanged)
13
+ * - `"relative/path"` → `"relative/path"` (relative path unchanged)
14
+ * - `"foo~bar"` → `"foo~bar"` (tilde not at start → unchanged)
15
+ */
16
+ export declare function expandTilde(p: string): string;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * tsOnlyErrors.ts — centralized allow-list for TS-only AgentDirectorError
3
+ * subclasses that have no counterpart in pkg/api/errnames/catalog.json.
4
+ *
5
+ * The catalog-drift regression test (T10) imports this constant so it never
6
+ * flags these classes as unexpected. Each name must also have a corresponding
7
+ * subclass in src/errors.ts with a comment cross-referencing this module.
8
+ */
9
+ /**
10
+ * TS_ONLY_ERROR_NAMES lists every AgentDirectorError subclass that is defined
11
+ * in this package but intentionally absent from the shared Go err_name catalog
12
+ * at pkg/api/errnames/catalog.json.
13
+ *
14
+ * Membership criteria:
15
+ * - ErrClientClosed — client lifecycle error, no Go equivalent.
16
+ * - ErrUnsupportedPlatform — platform detection error, raised before any IPC.
17
+ * - ErrPlatformPackageMissing — optional sub-package absent; no Go equivalent.
18
+ * - ErrBunVersionTooOld — runtime version guard; no Go equivalent.
19
+ *
20
+ * When adding a new TS-only subclass: add its name here AND add a comment in
21
+ * src/errors.ts near the subclass cross-referencing this allow-list.
22
+ */
23
+ export declare const TS_ONLY_ERROR_NAMES: readonly ["ErrClientClosed", "ErrUnsupportedPlatform", "ErrPlatformPackageMissing", "ErrBunVersionTooOld"];
24
+ /** Type alias for the individual allow-listed names. */
25
+ export type TsOnlyErrorName = (typeof TS_ONLY_ERROR_NAMES)[number];
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Canonical callable verb list — source of truth for all TS/Bun client code
3
+ * that needs to iterate, type-check, or map verb names.
4
+ *
5
+ * This list is hand-authored from `manifest.CallableVerbs()` in
6
+ * pkg/api/manifest/manifest.go. It includes every verb where `Callable: true`
7
+ * and excludes the three non-callable verbs (help, serve, hook).
8
+ *
9
+ * Currently 15 callable verbs: spawn, status, get, send-keys, read-pane,
10
+ * kill, decide, resume, find-missing, expire, delete, make-template, list,
11
+ * pause, version.
12
+ *
13
+ * NOTE: `help` has `Callable: false` in manifest.go (source of truth); it is
14
+ * intentionally excluded here even though earlier epic-spec drafts assumed
15
+ * otherwise. The .go source wins.
16
+ */
17
+ /** All callable verbs in their canonical kebab form (matches manifest). */
18
+ export declare const VERBS: readonly ["spawn", "status", "get", "send-keys", "read-pane", "kill", "decide", "resume", "find-missing", "expire", "delete", "make-template", "list", "pause", "version"];
19
+ /** Union type of every callable verb name. */
20
+ export type VerbName = (typeof VERBS)[number];
21
+ /**
22
+ * kebabToUnderscore converts a kebab-case verb name to the underscore form
23
+ * used in the C-ABI symbol name.
24
+ *
25
+ * Examples:
26
+ * "send-keys" → "send_keys"
27
+ * "find-missing" → "find_missing"
28
+ * "make-template" → "make_template"
29
+ * "read-pane" → "read_pane"
30
+ * "version" → "version"
31
+ */
32
+ export declare function kebabToUnderscore(v: string): string;
33
+ /**
34
+ * kebabToCamel converts a kebab-case verb name to the camelCase form used
35
+ * as a method name on the Client class.
36
+ *
37
+ * Examples:
38
+ * "send-keys" → "sendKeys"
39
+ * "find-missing" → "findMissing"
40
+ * "make-template" → "makeTemplate"
41
+ * "read-pane" → "readPane"
42
+ * "version" → "version"
43
+ */
44
+ export declare function kebabToCamel(v: string): string;
45
+ /**
46
+ * KEBAB_TO_CAMEL is a static map from every VerbName to its camelCase form.
47
+ * Prefer this over calling kebabToCamel() at runtime when the input is always
48
+ * a VerbName (avoids a string scan in hot code paths).
49
+ */
50
+ export declare const KEBAB_TO_CAMEL: Record<VerbName, string>;
51
+ /**
52
+ * HANDLE_FREE_VERBS is the set of verbs that do not require a Client handle.
53
+ * Currently only "version". Mirrors pkg/cabi/dispatch.go's handleFreeVerbs map.
54
+ */
55
+ export declare const HANDLE_FREE_VERBS: ReadonlySet<string>;
56
+ /** Returns true if the given verb does not require a Client handle. */
57
+ export declare function isHandleFree(verb: string): boolean;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * worker.ts — worker-thread entry-point for all C-ABI FFI calls.
3
+ *
4
+ * This module runs INSIDE a node:worker_threads Worker. It is never imported
5
+ * by the main thread. Its sole job is:
6
+ *
7
+ * 1. At startup: resolve the native library path via loadNative(), post {type:"ready"}.
8
+ * 2. On every message: receive {id, op, handle, paramsJSON}, build the
9
+ * single-arg JSON for the C symbol, call it, copy the returned C string
10
+ * to JS, free the native pointer (try/finally so the error path also
11
+ * frees), and post the raw JSON string back to the main thread.
12
+ *
13
+ * WHY a dedicated worker?
14
+ * ───────────────────────
15
+ * Bun's dlopen has no per-symbol `async: true` marker. Calling a C function
16
+ * directly on the main thread blocks the JS event loop for the duration of
17
+ * that call. By running all FFI in a dedicated worker, verb calls are truly
18
+ * off-main-thread — the event loop remains responsive during long-running
19
+ * Go-side operations.
20
+ *
21
+ * One worker per process (singleton, not a pool): the Go runtime inside the
22
+ * shared library carries process-global state (the handle registry). Multiple
23
+ * parallel dlopen handles would split that state and break audit-trail
24
+ * invariants. A single serialized worker is the correct model.
25
+ *
26
+ * Wire format for C calls
27
+ * ───────────────────────
28
+ * Every C-ABI function takes exactly ONE `char* params_json` argument and
29
+ * returns `char* result_json` (which the caller must release via
30
+ * ad_free_cstring). The handle field is embedded inside the JSON:
31
+ * - ad_open → paramsJSON (no handle)
32
+ * - ad_close → {"handle":"<token>"}
33
+ * - ad_<verb> → {"handle":"<token>", ...verb-params}
34
+ * - ad_version → {} (handle-free)
35
+ */
36
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * workerProxy.ts — main-thread singleton proxy for the FFI worker.
3
+ *
4
+ * The six-step C-ABI call recipe splits across two files:
5
+ * worker.ts → steps 1–4: encode JSON → call C symbol → copy CString →
6
+ * free pointer (try/finally)
7
+ * workerProxy.ts → steps 5–6: parse raw JSON string → check err_name →
8
+ * throw typed error (via errorFromEnvelope) or return result
9
+ *
10
+ * See src/ffi.ts for the public callVerb facade that drives this module.
11
+ *
12
+ * Architecture
13
+ * ────────────
14
+ * A single dedicated Worker is spawned lazily on the first call to dispatch.
15
+ * The Worker lives for the lifetime of the process (or until shutdown() is
16
+ * called). All Client instances in the process share the same worker.
17
+ *
18
+ * Correlation IDs
19
+ * ───────────────
20
+ * Each dispatch call mints a monotonically increasing id and inserts a
21
+ * {resolve, reject} pair into `_pending`. The worker echoes the id back in
22
+ * every response so the correct Promise can be settled.
23
+ *
24
+ * Error envelope decoding
25
+ * ───────────────────────
26
+ * The worker returns raw JSON strings only. This module parses them and, if
27
+ * `err_name` is present, calls errorFromEnvelope() so the error-class graph
28
+ * is loaded once (on the main thread), not inside every worker thread.
29
+ */
30
+ /**
31
+ * workerProxy is the mutable singleton used by callVerb (and tests).
32
+ * Exporting an object (rather than a bare function) allows tests to replace
33
+ * `workerProxy.dispatch` without module-level mocking:
34
+ *
35
+ * import { workerProxy } from "../src/internal/workerProxy.js";
36
+ * workerProxy.dispatch = mock(async () => '{"version":"test"}');
37
+ */
38
+ export declare const workerProxy: {
39
+ dispatch: (op: string, handle: string | null, params: unknown) => Promise<unknown>;
40
+ };
41
+ /**
42
+ * shutdown terminates the worker and rejects all pending dispatches. Call
43
+ * this in tests (afterAll) to prevent lingering worker threads.
44
+ */
45
+ export declare function shutdown(): void;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * platform — native library resolver for agent-director.
3
+ *
4
+ * Implements the five-step resolution sequence:
5
+ * 1. Check Bun.version against MIN_BUN_VERSION → ErrBunVersionTooOld
6
+ * 2. Map process.platform + process.arch to an npm sub-package name →
7
+ * ErrUnsupportedPlatform for unknown tuples
8
+ * 3. Locate the sub-package on disk via import.meta.resolve →
9
+ * ErrPlatformPackageMissing when not installed
10
+ * 4. Compute binary path inside the package and verify existence →
11
+ * ErrPlatformPackageMissing when binary absent (e.g. CI host mismatch)
12
+ * 5. dlopen with the full binding spec → return { lib: symbols, libPath }
13
+ *
14
+ * resolveNativePath() exports just the path (used by bootstrapFfi.ts which
15
+ * keeps its own minimal dlopen).
16
+ *
17
+ * loadNative() / _loadNativeInternal() dlopen the full binding spec and return
18
+ * the symbols object together with the resolved path.
19
+ *
20
+ * _loadNativeInternal() accepts a PlatformLoadOpts bag for test injection
21
+ * (override platform, arch, bunVersion without monkey-patching globals).
22
+ *
23
+ * Internal — NOT re-exported from src/index.ts.
24
+ */
25
+ /** Minimum Bun runtime version required by this package (from T1). */
26
+ export declare const MIN_BUN_VERSION = "1.0.21";
27
+ /**
28
+ * PlatformLoadOpts — dependency-injection bag for loadNative / resolveNativePath.
29
+ *
30
+ * All fields are optional; missing fields fall back to the real process
31
+ * globals. Pass these in unit tests to exercise error branches without
32
+ * monkey-patching process.platform or Bun.version.
33
+ */
34
+ export interface PlatformLoadOpts {
35
+ /** Override process.platform (e.g. "linux", "darwin"). */
36
+ platform?: string;
37
+ /** Override process.arch (e.g. "x64", "arm64"). */
38
+ arch?: string;
39
+ /** Override Bun.version (e.g. "1.0.0" to trigger ErrBunVersionTooOld). */
40
+ bunVersion?: string;
41
+ }
42
+ /**
43
+ * resolveNativePath performs the platform check and sub-package lookup,
44
+ * returning the absolute path to the native shared library.
45
+ *
46
+ * If process.env.AD_CABI_DIR is set, the binary is loaded from
47
+ * "${AD_CABI_DIR}/libagent_director.{so,dylib}" instead of the npm
48
+ * sub-package. release.sh's verify_phase exports this so smoke tests
49
+ * can run before the cabi artifacts have been staged into platforms/.
50
+ *
51
+ * Throws one of:
52
+ * ErrBunVersionTooOld — Bun version < MIN_BUN_VERSION
53
+ * ErrUnsupportedPlatform — platform/arch tuple not in SUPPORTED_TUPLES
54
+ * ErrPlatformPackageMissing — sub-package not installed or binary absent
55
+ */
56
+ export declare function resolveNativePath(opts?: PlatformLoadOpts): string;
57
+ /** Symbols returned by dlopen with the full binding spec. */
58
+ export type NativeLib = Record<string, unknown>;
59
+ /**
60
+ * _loadNativeInternal is the testable core of loadNative().
61
+ *
62
+ * Accepts PlatformLoadOpts for dependency injection of platform / arch /
63
+ * Bun.version so tests can exercise every error branch without live binaries.
64
+ *
65
+ * @returns { lib, libPath } — lib is the dlopen symbols object; libPath is the
66
+ * absolute path to the .so/.dylib that was loaded (useful for logging).
67
+ */
68
+ export declare function _loadNativeInternal(opts?: PlatformLoadOpts): {
69
+ lib: NativeLib;
70
+ libPath: string;
71
+ };
72
+ /**
73
+ * loadNative is the public entry point called by worker.ts at startup.
74
+ *
75
+ * Uses the real process.platform, process.arch, and Bun.version.
76
+ */
77
+ export declare function loadNative(): {
78
+ lib: NativeLib;
79
+ libPath: string;
80
+ };
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Structural logger interface — mirrors the four conventional log levels.
3
+ * All methods are optional; callers may pass any object that implements the
4
+ * subset they care about (e.g., `console`).
5
+ */
6
+ export interface Logger {
7
+ debug?: (message: string, ...args: unknown[]) => void;
8
+ info?: (message: string, ...args: unknown[]) => void;
9
+ warn?: (message: string, ...args: unknown[]) => void;
10
+ error?: (message: string, ...args: unknown[]) => void;
11
+ }
12
+ /**
13
+ * Options accepted by the `Client` constructor (SRD SR-1.2).
14
+ *
15
+ * `storePath` is the only required field. The others are optional overrides;
16
+ * absent fields fall back to the same three-tier defaults as `pkg/api.Options`
17
+ * (config-file value, then hardcoded fallback).
18
+ *
19
+ * Tilde expansion is handled TS-side by `src/internal/tilde.ts` before paths
20
+ * cross the FFI boundary, so the C-ABI never receives a leading `~`.
21
+ */
22
+ export interface ClientOptions {
23
+ /** Path to the SQLite store file. Tilde-expanded before crossing FFI. */
24
+ storePath: string;
25
+ /** Path to the TOML config file. Tilde-expanded before crossing FFI. */
26
+ configPath?: string;
27
+ /** Override the tmux binary. Defaults to the binary on PATH. */
28
+ tmuxCommand?: string;
29
+ /**
30
+ * When `true`, create the store and initialize the database schema if the
31
+ * store file does not yet exist. When `false` (the default), opening a
32
+ * non-existent store returns an error. Mirrors `pkg/api.Options.CreateIfMissing`.
33
+ */
34
+ createIfMissing?: boolean;
35
+ /** Optional logger for client-side warnings (e.g., non-fatal close errors). */
36
+ logger?: Logger;
37
+ }
38
+ /** Mirrors pkg/api.VerbSummary — one entry in the `help` verb result. */
39
+ export interface VerbSummary {
40
+ /** Canonical CLI/MCP verb name (e.g. "spawn", "send-keys"). */
41
+ name: string;
42
+ /** One-line verb description from the manifest. */
43
+ description: string;
44
+ }
45
+ /** Mirrors pkg/api/get.go::PermissionRequestInfo — embedded in GetResult when state=check_permission. */
46
+ export interface PermissionRequestInfo {
47
+ /** Autoincrement primary key of the permission_requests row. */
48
+ request_id: number;
49
+ /** Claude Code tool that triggered the permission request (e.g. "Bash"). */
50
+ tool_name: string;
51
+ /** Raw JSON string of the tool input as stored in the DB. NOT a nested object. */
52
+ tool_input: string;
53
+ /** RFC3339 timestamp when the permission request row was created. */
54
+ requested_at: string;
55
+ }
56
+ /** Mirrors pkg/api/list.go::ListRow — one Spawn row returned by the list verb. */
57
+ export interface ListRow {
58
+ /** Stable Spawn id. */
59
+ claude_instance_id: string;
60
+ /** Parent Spawn id (omitted when launched from a plain shell). */
61
+ parent_id?: string;
62
+ /** Current lifecycle state. */
63
+ state: string;
64
+ /** Canonicalized working directory. */
65
+ cwd: string;
66
+ /** tmux session name. */
67
+ tmux_session_name: string;
68
+ /** "on" or "off". */
69
+ relay_mode: string;
70
+ /** Caller-supplied key-value tags. */
71
+ labels: Record<string, string>;
72
+ /** Row insert time (RFC3339). */
73
+ started_at: string;
74
+ /** Most recent hook UPSERT time (RFC3339). */
75
+ last_seen_at: string;
76
+ /** Set when state moves to ended (omitted while live). */
77
+ ended_at?: string | null;
78
+ }
79
+ /** Mirrors pkg/cabi/verbs_read.go::ad_spawn params */
80
+ export interface SpawnParams {
81
+ /** Absolute (or ~/-prefixed) path the Spawn's Claude starts in. Required. */
82
+ cwd: string;
83
+ /** Named template under ~/.agent-director/templates/. */
84
+ template?: string;
85
+ /** Explicit instance id (UUID4 minted when absent). */
86
+ claude_instance_id?: string;
87
+ /** KEY=VALUE label pairs. */
88
+ label?: string[];
89
+ /** permissions.allow entries. */
90
+ allow?: string[];
91
+ /** permissions.deny entries. */
92
+ deny?: string[];
93
+ /** permissions.ask entries. */
94
+ ask?: string[];
95
+ /** "on" | "off" | "" (use config default). */
96
+ relay_mode?: string;
97
+ /** KEY→VALUE env-var overrides injected on the tmux session. */
98
+ extra_env?: Record<string, string>;
99
+ /** Pass-through argv to `claude` after --settings. */
100
+ claude_args?: string[];
101
+ /** Skip pre-writing workspace-trust into ~/.claude.json. Default false. */
102
+ no_pre_trust?: boolean;
103
+ /** Explicit tmux session name. Auto-derived when absent. */
104
+ tmux_session_name?: string;
105
+ }
106
+ /** Mirrors pkg/api/spawn.go::SpawnResult */
107
+ export interface SpawnResult {
108
+ /** The id the new Spawn is tracked under. */
109
+ claude_instance_id: string;
110
+ }
111
+ /** Mirrors pkg/cabi/verbs_read.go::ad_status params */
112
+ export interface StatusParams {
113
+ /** Id of the Spawn to inspect. */
114
+ claude_instance_id: string;
115
+ }
116
+ /** Mirrors pkg/api/status.go::StatusResult */
117
+ export interface StatusResult {
118
+ /** Current lifecycle state (pending/waiting/working/ask_user/check_permission/ended/missing). */
119
+ state: string;
120
+ }
121
+ /** Mirrors pkg/cabi/verbs_read.go::ad_get params */
122
+ export interface GetParams {
123
+ /** Id of the Spawn to fetch. */
124
+ claude_instance_id: string;
125
+ }
126
+ /** Mirrors pkg/api/get.go::SpawnRow */
127
+ export interface GetResult {
128
+ claude_instance_id: string;
129
+ parent_id: string;
130
+ state: string;
131
+ cwd: string;
132
+ tmux_session_name: string;
133
+ claude_args: string[];
134
+ relay_mode: string;
135
+ jsonl_path: string;
136
+ claude_session_id: string;
137
+ labels: Record<string, string>;
138
+ /** Row insert time (RFC3339). */
139
+ started_at: string;
140
+ /** Last hook UPSERT time (RFC3339). */
141
+ last_seen_at: string;
142
+ /** Set when state moves to ended; omitted while live. */
143
+ ended_at?: string | null;
144
+ /** Open permission request; present only when state=check_permission with an undecided row. */
145
+ permission_request?: PermissionRequestInfo | null;
146
+ }
147
+ /** Mirrors pkg/cabi/verbs_read.go::ad_send_keys params (pkg/api.SendKeysParams json tags) */
148
+ export interface SendKeysParams {
149
+ /** Id of the Spawn whose pane will receive the text. */
150
+ claude_instance_id: string;
151
+ /** Text to deliver to the pane. CR bytes stripped; LF preserved; Enter appended. */
152
+ text: string;
153
+ }
154
+ /** Mirrors pkg/api/sendkeys.go::SendKeysResult (empty; reserved for future fields). */
155
+ export interface SendKeysResult {
156
+ }
157
+ /** Mirrors pkg/cabi/verbs_read.go::ad_read_pane params (pkg/api.ReadPaneParams json tags) */
158
+ export interface ReadPaneParams {
159
+ /** Id of the Spawn whose pane will be captured. */
160
+ claude_instance_id: string;
161
+ /** Trailing lines to return. Defaults to 25 when 0/omitted. */
162
+ n_lines?: number;
163
+ /** When true return raw bytes (ANSI preserved); when false strip ANSI (default). */
164
+ ansi?: boolean;
165
+ }
166
+ /** Mirrors pkg/api/readpane.go::ReadPaneResult */
167
+ export interface ReadPaneResult {
168
+ /** Captured pane text. */
169
+ pane: string;
170
+ }
171
+ /** Mirrors pkg/cabi/verbs_control.go::ad_kill params (pkg/api.KillParams json tags) */
172
+ export interface KillParams {
173
+ /** Id of the Spawn to kill. */
174
+ claude_instance_id: string;
175
+ }
176
+ /** Mirrors pkg/api/kill.go::KillResult (empty; reserved for future fields). */
177
+ export interface KillResult {
178
+ }
179
+ /** Mirrors pkg/cabi/verbs_control.go::ad_decide params (pkg/api.DecideParams json tags) */
180
+ export interface DecideParams {
181
+ /** Id of the Spawn whose open permission request is being decided. */
182
+ claude_instance_id: string;
183
+ /** Orchestrator verdict. */
184
+ decision: "allow" | "deny";
185
+ /** Optional free-text message surfaced to Claude on deny. */
186
+ reason?: string;
187
+ }
188
+ /** Mirrors pkg/api/decide.go::DecideResult (empty; reserved for future fields). */
189
+ export interface DecideResult {
190
+ }
191
+ /** Mirrors pkg/cabi/verbs_control.go::ad_resume params (pkg/api.ResumeParams json tags) */
192
+ export interface ResumeParams {
193
+ /** Id of the terminated Spawn to resurrect. */
194
+ claude_instance_id: string;
195
+ }
196
+ /** Mirrors pkg/api/resume.go::ResumeResult */
197
+ export interface ResumeResult {
198
+ /** Same id that was passed in (preserved across resurrection). */
199
+ claude_instance_id: string;
200
+ }
201
+ /** Mirrors pkg/cabi/verbs_control.go::ad_find_missing params */
202
+ export interface FindMissingParams {
203
+ /** Optional deadline for the OS probe sweep (milliseconds). 0/omitted = no deadline. */
204
+ timeout_ms?: number;
205
+ }
206
+ /** Mirrors pkg/api/find_missing.go::FindMissingResult */
207
+ export interface FindMissingResult {
208
+ /** Number of rows transitioned to missing on this sweep. */
209
+ count: number;
210
+ /** Sorted ids of rows transitioned to missing. */
211
+ ids: string[];
212
+ }
213
+ /** Mirrors pkg/cabi/verbs_admin.go::ad_expire params */
214
+ export interface ExpireParams {
215
+ /**
216
+ * Duration override (e.g. "7d", "2h", "0d"). When omitted, the config
217
+ * default (defaults.expire_retention_days) applies.
218
+ */
219
+ older_than?: string;
220
+ }
221
+ /** Mirrors pkg/api/expire.go::ExpireResult */
222
+ export interface ExpireResult {
223
+ /** Number of terminal rows removed. */
224
+ count: number;
225
+ /** Sorted ids of rows removed. */
226
+ ids: string[];
227
+ }
228
+ /** Mirrors pkg/cabi/verbs_admin.go::ad_delete params */
229
+ export interface DeleteParams {
230
+ /** Id(s) to delete. */
231
+ claude_instance_id: string[];
232
+ }
233
+ /** Mirrors pkg/api/delete.go::DeleteResult */
234
+ export interface DeleteResult {
235
+ /** Per-id outcome: "ok" on success, err_name on failure. */
236
+ results: Record<string, string>;
237
+ }
238
+ /** Mirrors pkg/cabi/verbs_admin.go::ad_make_template params */
239
+ export interface MakeTemplateParams {
240
+ /** Template filename (without extension). Must be filename-safe. Required. */
241
+ name: string;
242
+ /** Default working directory to bake in. */
243
+ cwd?: string;
244
+ /** Default relay mode: "on" | "off" | "" (inherit). */
245
+ relay_mode?: string;
246
+ /** Default claude argv. Per-call --claude-args replaces wholesale. */
247
+ claude_args?: string[];
248
+ /** Env-var overrides to bake in. */
249
+ extra_env?: Record<string, string>;
250
+ /** Label k=v entries to bake in. */
251
+ label?: string[];
252
+ /** permissions.allow entries. */
253
+ allow?: string[];
254
+ /** permissions.deny entries. */
255
+ deny?: string[];
256
+ /** permissions.ask entries. */
257
+ ask?: string[];
258
+ }
259
+ /** Mirrors pkg/api/make_template.go::MakeTemplateResult */
260
+ export interface MakeTemplateResult {
261
+ /** Absolute path of the written template TOML file. */
262
+ path: string;
263
+ }
264
+ /** Mirrors pkg/cabi/verbs_read.go::ad_list params */
265
+ export interface ListParams {
266
+ /** Filter by state (multiple values OR together). */
267
+ state?: string[];
268
+ /** Filter by label k=v pairs (multiple entries AND together). */
269
+ label?: string[];
270
+ /** Filter by parent_id exact match. */
271
+ parent?: string;
272
+ /** Filter by canonicalized cwd exact match. */
273
+ cwd?: string;
274
+ /** Filter by tmux session name exact match. */
275
+ tmux_session_name?: string;
276
+ /** Cap result count. 0/omitted means no cap. */
277
+ limit?: number;
278
+ }
279
+ /** Mirrors pkg/api/list.go::ListResult */
280
+ export interface ListResult {
281
+ /** Matching Spawn rows. Empty array when none match. */
282
+ spawns: ListRow[];
283
+ }
284
+ /** Mirrors pkg/cabi/verbs_control.go::ad_pause params (pkg/api.PauseParams json tags) */
285
+ export interface PauseParams {
286
+ /** Id of the Spawn to pause gracefully. */
287
+ claude_instance_id: string;
288
+ }
289
+ /** Mirrors pkg/api/pause.go::PauseResult (empty; reserved for future fields). */
290
+ export interface PauseResult {
291
+ }
292
+ /** Mirrors pkg/cabi/verbs_admin.go::ad_version params (handle-free; no user params). */
293
+ export interface VersionParams {
294
+ }
295
+ /** Mirrors pkg/api/version.go::VersionResult */
296
+ export interface VersionResult {
297
+ /** Human-readable version stamp. "dev" for unstamped builds. */
298
+ version: string;
299
+ /** Full git SHA. "unknown" for unstamped builds. */
300
+ commit: string;
301
+ }
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "agent-director",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
+ "os": [
6
+ "linux",
7
+ "darwin"
8
+ ],
9
+ "cpu": [
10
+ "x64",
11
+ "arm64"
12
+ ],
5
13
  "engines": {
6
14
  "bun": ">=1.0.21"
7
15
  },
@@ -9,7 +17,9 @@
9
17
  "dist/**/*.js",
10
18
  "dist/**/*.d.ts",
11
19
  "!dist/**/*.test.*",
12
- "README.md"
20
+ "README.md",
21
+ "scripts/postinstall.ts",
22
+ "skills/install-agent-director/**"
13
23
  ],
14
24
  "exports": {
15
25
  ".": {
@@ -25,12 +35,15 @@
25
35
  "smoke": "bun test test/smoke/ test/smoke-invariants.test.ts",
26
36
  "envelope-diff": "bun test test/envelope-diff.test.ts test/envelope-diff-invariants.test.ts",
27
37
  "prepare-platforms": "bun run scripts/prepare-platforms.ts",
38
+ "stage-skill": "bun run scripts/stage-skill.ts",
39
+ "prepack": "bun run build && bun run scripts/stage-skill.ts",
40
+ "postinstall": "bun run scripts/postinstall.ts",
28
41
  "version-bump-publish": "bun run scripts/version-bump.ts",
29
- "prepublishOnly": "bun run scripts/check-not-placeholder.ts"
42
+ "prepublishOnly": "bun run scripts/prepublish-guards.ts"
30
43
  },
31
44
  "optionalDependencies": {
32
- "@agent-director/linux-x64": "^0.4.0",
33
- "@agent-director/darwin-arm64": "^0.4.0"
45
+ "@agent-director/linux-x64": "^0.4.2",
46
+ "@agent-director/darwin-arm64": "^0.4.2"
34
47
  },
35
48
  "devDependencies": {
36
49
  "typescript": ">=5.2.0",