@a5c-ai/babysitter-sdk 0.0.182 → 0.0.183-staging.c0c2541e

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.
@@ -1 +1 @@
1
- {"version":3,"file":"hookRun.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/hookRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgID,wBAAsB,aAAa,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2D7E"}
1
+ {"version":3,"file":"hookRun.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/hookRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgID,wBAAsB,aAAa,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E7E"}
@@ -167,6 +167,22 @@ async function handleHookRun(args) {
167
167
  }
168
168
  return 1;
169
169
  }
170
+ if (adapter.supportsHookType && !adapter.supportsHookType(hookType)) {
171
+ const message = adapter.getUnsupportedHookMessage
172
+ ? adapter.getUnsupportedHookMessage(hookType)
173
+ : `Harness "${harness}" does not support hook type "${hookType}".`;
174
+ const error = {
175
+ error: "UNSUPPORTED_HOOK_TYPE",
176
+ message,
177
+ };
178
+ if (json) {
179
+ process.stderr.write(JSON.stringify(error, null, 2) + "\n");
180
+ }
181
+ else {
182
+ process.stderr.write(`Error: ${message}\n`);
183
+ }
184
+ return 1;
185
+ }
170
186
  switch (hookType) {
171
187
  case "stop":
172
188
  return await adapter.handleStopHook(args);
@@ -0,0 +1,16 @@
1
+ export interface ProcessLibraryCommandArgs {
2
+ subcommand: "clone" | "update" | "use" | "active";
3
+ repo?: string;
4
+ dir?: string;
5
+ ref?: string;
6
+ runId?: string;
7
+ sessionId?: string;
8
+ stateDir?: string;
9
+ json: boolean;
10
+ }
11
+ export declare function handleProcessLibraryClone(args: ProcessLibraryCommandArgs): Promise<number>;
12
+ export declare function handleProcessLibraryUpdate(args: ProcessLibraryCommandArgs): Promise<number>;
13
+ export declare function handleProcessLibraryUse(args: ProcessLibraryCommandArgs): Promise<number>;
14
+ export declare function handleProcessLibraryActive(args: ProcessLibraryCommandArgs): Promise<number>;
15
+ export declare function handleProcessLibraryCommand(args: ProcessLibraryCommandArgs): Promise<number>;
16
+ //# sourceMappingURL=processLibrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processLibrary.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/processLibrary.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;CACf;AAoBD,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA0BjB;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleProcessLibraryClone = handleProcessLibraryClone;
4
+ exports.handleProcessLibraryUpdate = handleProcessLibraryUpdate;
5
+ exports.handleProcessLibraryUse = handleProcessLibraryUse;
6
+ exports.handleProcessLibraryActive = handleProcessLibraryActive;
7
+ exports.handleProcessLibraryCommand = handleProcessLibraryCommand;
8
+ const active_1 = require("../../processLibrary/active");
9
+ function requireArg(value, name, command, json) {
10
+ if (!value) {
11
+ const message = `[${command}] ${name} is required`;
12
+ if (json) {
13
+ console.log(JSON.stringify({ error: "missing_argument", message }));
14
+ }
15
+ else {
16
+ console.error(message);
17
+ }
18
+ return null;
19
+ }
20
+ return value;
21
+ }
22
+ async function handleProcessLibraryClone(args) {
23
+ const repo = requireArg(args.repo, "--repo", "process-library:clone", args.json);
24
+ if (!repo)
25
+ return 1;
26
+ const dir = requireArg(args.dir, "--dir", "process-library:clone", args.json);
27
+ if (!dir)
28
+ return 1;
29
+ try {
30
+ const result = await (0, active_1.cloneProcessLibrary)({ repo, dir, ref: args.ref });
31
+ if (args.json) {
32
+ console.log(JSON.stringify({ success: true, ...result }, null, 2));
33
+ }
34
+ else {
35
+ console.log(`Process library cloned.\n Repo: ${result.repo}\n Dir: ${result.dir}\n Revision: ${result.revision}`);
36
+ }
37
+ return 0;
38
+ }
39
+ catch (error) {
40
+ const message = error instanceof Error ? error.message : String(error);
41
+ if (args.json) {
42
+ console.log(JSON.stringify({ error: "clone_failed", message }));
43
+ }
44
+ else {
45
+ console.error(`[process-library:clone] ${message}`);
46
+ }
47
+ return 1;
48
+ }
49
+ }
50
+ async function handleProcessLibraryUpdate(args) {
51
+ const dir = requireArg(args.dir, "--dir", "process-library:update", args.json);
52
+ if (!dir)
53
+ return 1;
54
+ try {
55
+ const result = await (0, active_1.updateProcessLibrary)({ dir, ref: args.ref });
56
+ if (args.json) {
57
+ console.log(JSON.stringify({ success: true, ...result }, null, 2));
58
+ }
59
+ else {
60
+ console.log(`Process library updated.\n Dir: ${result.dir}\n Revision: ${result.revision}`);
61
+ }
62
+ return 0;
63
+ }
64
+ catch (error) {
65
+ const message = error instanceof Error ? error.message : String(error);
66
+ if (args.json) {
67
+ console.log(JSON.stringify({ error: "update_failed", message }));
68
+ }
69
+ else {
70
+ console.error(`[process-library:update] ${message}`);
71
+ }
72
+ return 1;
73
+ }
74
+ }
75
+ async function handleProcessLibraryUse(args) {
76
+ const dir = requireArg(args.dir, "--dir", "process-library:use", args.json);
77
+ if (!dir)
78
+ return 1;
79
+ try {
80
+ const result = await (0, active_1.bindActiveProcessLibrary)({
81
+ dir,
82
+ stateDir: args.stateDir,
83
+ runId: args.runId,
84
+ sessionId: args.sessionId,
85
+ ref: args.ref,
86
+ });
87
+ if (args.json) {
88
+ console.log(JSON.stringify({ success: true, ...result }, null, 2));
89
+ }
90
+ else {
91
+ console.log(`Active process library updated.\n Scope: ${result.bindingScope}\n Dir: ${result.binding.dir}\n State: ${result.stateFile}`);
92
+ }
93
+ return 0;
94
+ }
95
+ catch (error) {
96
+ const message = error instanceof Error ? error.message : String(error);
97
+ if (args.json) {
98
+ console.log(JSON.stringify({ error: "bind_failed", message }));
99
+ }
100
+ else {
101
+ console.error(`[process-library:use] ${message}`);
102
+ }
103
+ return 1;
104
+ }
105
+ }
106
+ async function handleProcessLibraryActive(args) {
107
+ try {
108
+ const result = await (0, active_1.resolveActiveProcessLibrary)({
109
+ stateDir: args.stateDir,
110
+ runId: args.runId,
111
+ sessionId: args.sessionId,
112
+ });
113
+ if (args.json) {
114
+ console.log(JSON.stringify(result, null, 2));
115
+ }
116
+ else if (!result.binding) {
117
+ console.log(`No active process-library binding found.\n State: ${result.stateFile}`);
118
+ }
119
+ else {
120
+ console.log(`Active process library.\n Scope: ${result.bindingScope}\n Dir: ${result.binding.dir}\n Revision: ${result.binding.revision ?? "unknown"}`);
121
+ }
122
+ return 0;
123
+ }
124
+ catch (error) {
125
+ const message = error instanceof Error ? error.message : String(error);
126
+ if (args.json) {
127
+ console.log(JSON.stringify({ error: "active_failed", message }));
128
+ }
129
+ else {
130
+ console.error(`[process-library:active] ${message}`);
131
+ }
132
+ return 1;
133
+ }
134
+ }
135
+ async function handleProcessLibraryCommand(args) {
136
+ switch (args.subcommand) {
137
+ case "clone":
138
+ return handleProcessLibraryClone(args);
139
+ case "update":
140
+ return handleProcessLibraryUpdate(args);
141
+ case "use":
142
+ return handleProcessLibraryUse(args);
143
+ case "active":
144
+ return handleProcessLibraryActive(args);
145
+ default: {
146
+ const _exhaustive = args.subcommand;
147
+ void _exhaustive;
148
+ console.error("[process-library] Unknown subcommand");
149
+ return 1;
150
+ }
151
+ }
152
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AAklB/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AAg/C7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA+TpD,MAAM;EAIvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAoB,MAAM,oBAAoB,CAAC;AAwmB/G;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BlE;AAOD,2EAA2E;AAC3E,QAAA,MAAM,sBAAsB,sCAAgC,CAAC;AA2/C7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA8UpD,MAAM;EAIvB"}
package/dist/cli/main.js CHANGED
@@ -60,6 +60,7 @@ const mcpServe_1 = require("./commands/mcpServe");
60
60
  const hookLog_1 = require("./commands/hookLog");
61
61
  const hookRun_1 = require("./commands/hookRun");
62
62
  const profile_1 = require("./commands/profile");
63
+ const processLibrary_1 = require("./commands/processLibrary");
63
64
  const plugin_1 = require("./commands/plugin");
64
65
  const tokensStats_1 = require("./commands/tokensStats");
65
66
  const compressionStatus_1 = require("./commands/compressionStatus");
@@ -92,9 +93,13 @@ const USAGE = `Usage:
92
93
  babysitter session:iteration-message --iteration <n> [--run-id <id>] [--runs-dir <dir>] [--plugin-root <dir>] [--json]
93
94
  babysitter skill:discover --plugin-root <dir> [--run-id <id>] [--cache-ttl <seconds>] [--runs-dir <dir>] [--include-remote] [--summary-only] [--process-path <path>] [--json]
94
95
  babysitter hook:log --hook-type <type> --log-file <path> [--json]
95
- babysitter hook:run --hook-type <stop|session-start|user-prompt-submit|pre-tool-use> [--harness <claude-code|codex|gemini-cli>] [--plugin-root <dir>] [--state-dir <dir>] [--runs-dir <dir>] [--json] [--verbose]
96
+ babysitter hook:run --hook-type <stop|session-start|user-prompt-submit|pre-tool-use> [--harness <claude-code|gemini-cli>] [--plugin-root <dir>] [--state-dir <dir>] [--runs-dir <dir>] [--json] [--verbose]
96
97
  babysitter compress-output <command and args...>
97
98
  babysitter skill:fetch-remote --source-type <github|well-known> --url <url> [--json]
99
+ babysitter process-library:clone --repo <url> --dir <path> [--ref <ref>] [--json]
100
+ babysitter process-library:update --dir <path> [--ref <ref>] [--json]
101
+ babysitter process-library:use --dir <path> [--run-id <id>] [--session-id <id>] [--state-dir <dir>] [--ref <ref>] [--json]
102
+ babysitter process-library:active [--run-id <id>] [--session-id <id>] [--state-dir <dir>] [--json]
98
103
  babysitter profile:read --user|--project [--dir <dir>] [--json]
99
104
  babysitter profile:write --user|--project --input <file> [--dir <dir>] [--json]
100
105
  babysitter profile:merge --user|--project --input <file> [--dir <dir>] [--json]
@@ -372,6 +377,14 @@ function parseArgs(argv) {
372
377
  parsed.url = expectFlagValue(rest, ++i, "--url");
373
378
  continue;
374
379
  }
380
+ if (arg === "--repo") {
381
+ parsed.processLibraryRepo = expectFlagValue(rest, ++i, "--repo");
382
+ continue;
383
+ }
384
+ if (arg === "--ref") {
385
+ parsed.processLibraryRef = expectFlagValue(rest, ++i, "--ref");
386
+ continue;
387
+ }
375
388
  if (arg === "--include-remote") {
376
389
  parsed.includeRemote = true;
377
390
  continue;
@@ -399,7 +412,9 @@ function parseArgs(argv) {
399
412
  continue;
400
413
  }
401
414
  if (arg === "--dir") {
402
- parsed.profileDir = expectFlagValue(rest, ++i, "--dir");
415
+ const dir = expectFlagValue(rest, ++i, "--dir");
416
+ parsed.profileDir = dir;
417
+ parsed.processLibraryDir = dir;
403
418
  continue;
404
419
  }
405
420
  // Plugin command flags
@@ -883,11 +898,12 @@ async function handleRunCreate(parsed) {
883
898
  });
884
899
  const entrySpec = formatEntrypointSpecifier(result.metadata.entrypoint);
885
900
  // --- Harness-specific session binding ---
886
- // When --harness is explicitly specified, use that adapter directly.
887
- // Otherwise auto-detect from env vars (CLAUDE_SESSION_ID, CLAUDE_ENV_FILE).
901
+ // Bind only when the caller is explicit about harness/session context.
902
+ // Ambient harness env inside editor/test hosts should not silently mutate
903
+ // generic CLI runs.
888
904
  const adapter = parsed.harness
889
905
  ? (0, harness_1.getAdapterByName)(parsed.harness)
890
- : (0, harness_1.getAdapter)();
906
+ : (parsed.sessionId ? (0, harness_1.getAdapter)() : undefined);
891
907
  let sessionBound;
892
908
  if (adapter) {
893
909
  const sessionId = adapter.resolveSessionId(parsed);
@@ -898,6 +914,7 @@ async function handleRunCreate(parsed) {
898
914
  runDir: result.runDir,
899
915
  pluginRoot: adapter.resolvePluginRoot(parsed),
900
916
  stateDir: parsed.stateDir,
917
+ runsDir: parsed.runsDir,
901
918
  maxIterations: parsed.maxIterations,
902
919
  prompt: parsed.prompt ?? "",
903
920
  verbose: parsed.verbose,
@@ -909,7 +926,8 @@ async function handleRunCreate(parsed) {
909
926
  sessionBound = {
910
927
  harness: parsed.harness,
911
928
  sessionId: "",
912
- error: "No session ID provided. Use --session-id or set CLAUDE_SESSION_ID.",
929
+ error: (adapter.getMissingSessionIdHint?.() ??
930
+ "No session ID provided. Use --session-id or set CLAUDE_SESSION_ID."),
913
931
  };
914
932
  }
915
933
  }
@@ -925,7 +943,8 @@ async function handleRunCreate(parsed) {
925
943
  // Try process-driven discovery first (reads @skill/@agent markers from process file)
926
944
  let discoveredSkills;
927
945
  let discoveredAgents;
928
- const discoverPluginRoot = adapter?.resolvePluginRoot(parsed) ?? (0, harness_1.getAdapter)().resolvePluginRoot(parsed);
946
+ const discoverPluginRoot = parsed.pluginRoot ??
947
+ adapter?.resolvePluginRoot(parsed);
929
948
  if (discoverPluginRoot) {
930
949
  try {
931
950
  const processDiscovery = (0, skill_1.discoverFromProcessFile)({
@@ -977,7 +996,7 @@ async function handleRunCreate(parsed) {
977
996
  console.log(`[run:create] session=${sessionBound.sessionId} bound via ${sessionBound.harness} stateFile=${sessionBound.stateFile}`);
978
997
  }
979
998
  }
980
- return 0;
999
+ return sessionBound?.fatal ? 1 : 0;
981
1000
  }
982
1001
  async function handleRunStatus(parsed) {
983
1002
  if (!parsed.runDirArg) {
@@ -1850,6 +1869,10 @@ const VALID_COMMANDS = [
1850
1869
  "hook:run",
1851
1870
  "skill:discover",
1852
1871
  "skill:fetch-remote",
1872
+ "process-library:clone",
1873
+ "process-library:update",
1874
+ "process-library:use",
1875
+ "process-library:active",
1853
1876
  "profile:read",
1854
1877
  "profile:write",
1855
1878
  "profile:merge",
@@ -2118,6 +2141,21 @@ function createBabysitterCli() {
2118
2141
  json: parsed.json,
2119
2142
  });
2120
2143
  }
2144
+ // Process-library commands
2145
+ if (parsed.command?.startsWith("process-library:")) {
2146
+ const subcommand = parsed.command.split(":")[1];
2147
+ const processLibraryArgs = {
2148
+ subcommand: subcommand,
2149
+ repo: parsed.processLibraryRepo,
2150
+ dir: parsed.processLibraryDir,
2151
+ ref: parsed.processLibraryRef,
2152
+ runId: parsed.runIdOverride,
2153
+ sessionId: parsed.sessionId,
2154
+ stateDir: parsed.stateDir,
2155
+ json: parsed.json,
2156
+ };
2157
+ return await (0, processLibrary_1.handleProcessLibraryCommand)(processLibraryArgs);
2158
+ }
2121
2159
  // Profile commands
2122
2160
  if (parsed.command === "profile:read" ||
2123
2161
  parsed.command === "profile:write" ||
@@ -1 +1 @@
1
- {"version":3,"file":"claudeCode.d.ts","sourceRoot":"","sources":["../../src/harness/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2BH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AAi2BjB,wBAAgB,uBAAuB,IAAI,cAAc,CA4DxD"}
1
+ {"version":3,"file":"claudeCode.d.ts","sourceRoot":"","sources":["../../src/harness/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA2BH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AA83BjB,wBAAgB,uBAAuB,IAAI,cAAc,CA4DxD"}
@@ -708,7 +708,7 @@ async function handleSessionStartHookImpl(args) {
708
708
  // Session binding (run:create flow)
709
709
  // ---------------------------------------------------------------------------
710
710
  async function bindSessionImpl(opts) {
711
- const { sessionId, runId, pluginRoot, maxIterations = 256, prompt, verbose } = opts;
711
+ const { sessionId, runId, pluginRoot, runsDir, maxIterations = 256, prompt, verbose } = opts;
712
712
  // Resolve state directory (always resolve to absolute paths)
713
713
  const resolvedPluginRoot = pluginRoot ? path.resolve(pluginRoot) : "";
714
714
  let stateDir = opts.stateDir ? path.resolve(opts.stateDir) : "";
@@ -728,22 +728,50 @@ async function bindSessionImpl(opts) {
728
728
  try {
729
729
  const existing = await (0, session_1.readSessionFile)(filePath);
730
730
  if (existing.state.runId && existing.state.runId !== runId) {
731
- return {
732
- harness: "claude-code",
733
- sessionId,
734
- stateFile: filePath,
735
- error: `Session already associated with run: ${existing.state.runId}`,
736
- };
731
+ const oldRunId = existing.state.runId;
732
+ let isTerminal = false;
733
+ // If runsDir is provided, check whether the old run is in a terminal state
734
+ if (runsDir) {
735
+ try {
736
+ const oldRunDir = path.join(runsDir, oldRunId);
737
+ const journal = await (0, journal_1.loadJournal)(oldRunDir);
738
+ const hasCompleted = journal.some((e) => e.type === "RUN_COMPLETED");
739
+ const hasFailed = journal.some((e) => e.type === "RUN_FAILED");
740
+ isTerminal = hasCompleted || hasFailed;
741
+ }
742
+ catch {
743
+ // Journal unreadable — treat as non-terminal (safe default)
744
+ }
745
+ }
746
+ if (isTerminal) {
747
+ // Auto-release: old run is finished, delete stale session and proceed
748
+ if (verbose) {
749
+ process.stderr.write(`[run:create] Auto-releasing stale session ${sessionId} from terminal run ${oldRunId}\n`);
750
+ }
751
+ await (0, session_1.deleteSessionFile)(filePath);
752
+ // Fall through to create new session file below (skip update block)
753
+ }
754
+ else {
755
+ return {
756
+ harness: "claude-code",
757
+ sessionId,
758
+ stateFile: filePath,
759
+ error: `Session bound to active run: ${oldRunId}. Complete or fail that run first, or manually remove the session state file at ${filePath}`,
760
+ fatal: true,
761
+ };
762
+ }
737
763
  }
738
- // Session exists but has no run or same run — update it
739
- await (0, session_1.updateSessionState)(filePath, { runId, active: true }, {
740
- state: existing.state,
741
- prompt: existing.prompt,
742
- });
743
- if (verbose) {
744
- process.stderr.write(`[run:create] Updated existing session ${sessionId} with run ${runId}\n`);
764
+ else {
765
+ // Session exists but has no run or same run — update it
766
+ await (0, session_1.updateSessionState)(filePath, { runId, active: true }, {
767
+ state: existing.state,
768
+ prompt: existing.prompt,
769
+ });
770
+ if (verbose) {
771
+ process.stderr.write(`[run:create] Updated existing session ${sessionId} with run ${runId}\n`);
772
+ }
773
+ return { harness: "claude-code", sessionId, stateFile: filePath };
745
774
  }
746
- return { harness: "claude-code", sessionId, stateFile: filePath };
747
775
  }
748
776
  catch {
749
777
  // Corrupted state file — overwrite it
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Codex harness adapter.
3
3
  *
4
- * Extends the SDK harness layer with "codex" support while reusing the
5
- * mature Claude stop/session-start hook handlers. The Codex adapter maps
6
- * Codex-specific environment conventions to the generic adapter interface.
4
+ * Codex can participate in session binding and state resolution, but it does
5
+ * not expose the Claude-style blocking stop/session-start hook contract.
6
+ * Keep this adapter honest: support explicit run binding and env detection,
7
+ * but reject fictional hook-driven orchestration.
7
8
  */
8
9
  import type { HarnessAdapter } from "./types";
9
10
  export declare function createCodexAdapter(): HarnessAdapter;
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/harness/codex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AA+CjB,wBAAgB,kBAAkB,IAAI,cAAc,CAgFnD"}
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/harness/codex.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AA+CjB,wBAAgB,kBAAkB,IAAI,cAAc,CAiFnD"}
@@ -2,9 +2,10 @@
2
2
  /**
3
3
  * Codex harness adapter.
4
4
  *
5
- * Extends the SDK harness layer with "codex" support while reusing the
6
- * mature Claude stop/session-start hook handlers. The Codex adapter maps
7
- * Codex-specific environment conventions to the generic adapter interface.
5
+ * Codex can participate in session binding and state resolution, but it does
6
+ * not expose the Claude-style blocking stop/session-start hook contract.
7
+ * Keep this adapter honest: support explicit run binding and env detection,
8
+ * but reject fictional hook-driven orchestration.
8
9
  */
9
10
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
11
  if (k2 === undefined) k2 = k;
@@ -83,6 +84,9 @@ function resolveCodexSessionId(parsed) {
83
84
  }
84
85
  function createCodexAdapter() {
85
86
  const claude = (0, claudeCode_1.createClaudeCodeAdapter)();
87
+ const unsupportedHookMessage = (hookType) => (`Codex does not support the babysitter "${hookType}" hook contract. ` +
88
+ `Use explicit --session-id binding plus the external Codex supervisor ` +
89
+ `or notify-based monitoring instead.`);
86
90
  return {
87
91
  name: "codex",
88
92
  isActive() {
@@ -100,50 +104,39 @@ function createCodexAdapter() {
100
104
  resolvePluginRoot(args) {
101
105
  return resolveCodexPluginRoot(args);
102
106
  },
103
- bindSession(opts) {
107
+ getMissingSessionIdHint() {
108
+ return ("Use --session-id explicitly, or launch through the Codex babysitter " +
109
+ "supervisor so it can provide a stable session/thread ID.");
110
+ },
111
+ supportsHookType(hookType) {
112
+ return hookType !== "stop" && hookType !== "session-start";
113
+ },
114
+ getUnsupportedHookMessage(hookType) {
115
+ return unsupportedHookMessage(hookType);
116
+ },
117
+ async bindSession(opts) {
104
118
  const stateDir = resolveCodexStateDir({
105
119
  stateDir: opts.stateDir,
106
120
  pluginRoot: opts.pluginRoot,
107
121
  });
108
- return claude.bindSession({
122
+ const result = await claude.bindSession({
109
123
  ...opts,
110
124
  stateDir,
111
125
  });
126
+ return {
127
+ ...result,
128
+ harness: "codex",
129
+ };
112
130
  },
113
- handleStopHook(args) {
114
- const pluginRoot = resolveCodexPluginRoot(args);
115
- const stateDir = resolveCodexStateDir({
116
- stateDir: args.stateDir,
117
- pluginRoot,
118
- });
119
- return claude.handleStopHook({
120
- ...args,
121
- pluginRoot,
122
- stateDir,
123
- });
131
+ handleStopHook(_args) {
132
+ process.stderr.write(`${unsupportedHookMessage("stop")}\n`);
133
+ return Promise.resolve(1);
124
134
  },
125
- handleSessionStartHook(args) {
126
- const pluginRoot = resolveCodexPluginRoot(args);
127
- const stateDir = resolveCodexStateDir({
128
- stateDir: args.stateDir,
129
- pluginRoot,
130
- });
131
- return claude.handleSessionStartHook({
132
- ...args,
133
- pluginRoot,
134
- stateDir,
135
- });
135
+ handleSessionStartHook(_args) {
136
+ process.stderr.write(`${unsupportedHookMessage("session-start")}\n`);
137
+ return Promise.resolve(1);
136
138
  },
137
- findHookDispatcherPath(startCwd) {
138
- const pluginRoot = resolveCodexPluginRoot();
139
- if (pluginRoot) {
140
- const candidate = path.join(pluginRoot, "hooks", "hook-dispatcher.sh");
141
- if ((0, node_fs_1.existsSync)(candidate))
142
- return candidate;
143
- }
144
- const local = path.join(path.resolve(startCwd), ".codex", "hooks", "hook-dispatcher.sh");
145
- if ((0, node_fs_1.existsSync)(local))
146
- return local;
139
+ findHookDispatcherPath(_startCwd) {
147
140
  return null;
148
141
  },
149
142
  };
@@ -1,4 +1,5 @@
1
- export type { HarnessAdapter, SessionBindOptions, SessionBindResult, HookHandlerArgs, } from "./types";
1
+ export type { HarnessAdapter, SessionBindOptions, SessionBindResult, HookHandlerArgs, HarnessDiscoveryResult, HarnessInvokeOptions, HarnessInvokeResult, PiSessionOptions, PiPromptResult, } from "./types";
2
+ export { HarnessCapability } from "./types";
2
3
  export { createClaudeCodeAdapter } from "./claudeCode";
3
4
  export { createCodexAdapter } from "./codex";
4
5
  export { createGeminiCliAdapter } from "./geminiCli";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/harness/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/harness/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resetAdapter = exports.setAdapter = exports.getAdapter = exports.listSupportedHarnesses = exports.getAdapterByName = exports.detectAdapter = exports.createNullAdapter = exports.createPiAdapter = exports.createGeminiCliAdapter = exports.createCodexAdapter = exports.createClaudeCodeAdapter = void 0;
3
+ exports.resetAdapter = exports.setAdapter = exports.getAdapter = exports.listSupportedHarnesses = exports.getAdapterByName = exports.detectAdapter = exports.createNullAdapter = exports.createPiAdapter = exports.createGeminiCliAdapter = exports.createCodexAdapter = exports.createClaudeCodeAdapter = exports.HarnessCapability = void 0;
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "HarnessCapability", { enumerable: true, get: function () { return types_1.HarnessCapability; } });
4
6
  var claudeCode_1 = require("./claudeCode");
5
7
  Object.defineProperty(exports, "createClaudeCodeAdapter", { enumerable: true, get: function () { return claudeCode_1.createClaudeCodeAdapter; } });
6
8
  var codex_1 = require("./codex");
@@ -6,12 +6,99 @@
6
6
  * hook input/output formats. The adapter interface abstracts these differences
7
7
  * so the SDK core remains harness-agnostic.
8
8
  */
9
+ /** Capabilities that a harness adapter may support. */
10
+ export declare enum HarnessCapability {
11
+ /** Harness supports programmatic (non-interactive) invocation. */
12
+ Programmatic = "programmatic",
13
+ /** Harness can bind a babysitter run to a host session. */
14
+ SessionBinding = "session-binding",
15
+ /** Harness implements the stop-hook lifecycle event. */
16
+ StopHook = "stop-hook",
17
+ /** Harness exposes an MCP (Model Context Protocol) server. */
18
+ Mcp = "mcp",
19
+ /** Harness can accept a prompt without a TTY (headless mode). */
20
+ HeadlessPrompt = "headless-prompt"
21
+ }
22
+ /** Result of probing the local environment for a specific harness CLI. */
23
+ export interface HarnessDiscoveryResult {
24
+ /** Harness identifier (matches HarnessAdapter.name). */
25
+ name: string;
26
+ /** Whether the CLI binary was found on the system. */
27
+ installed: boolean;
28
+ /** Semantic version reported by the CLI, if obtainable. */
29
+ version?: string;
30
+ /** Absolute path to the CLI binary, if resolved. */
31
+ cliPath?: string;
32
+ /** Shell command used to invoke the CLI. */
33
+ cliCommand: string;
34
+ /** Whether the harness currently has an active session. */
35
+ activeSession: boolean;
36
+ /** Whether harness-specific configuration was found on disk. */
37
+ configFound: boolean;
38
+ /** Capabilities advertised by this harness. */
39
+ capabilities: HarnessCapability[];
40
+ /** Platform identifier (e.g. "win32", "linux", "darwin"). */
41
+ platform: string;
42
+ }
43
+ /** Options for programmatically invoking a harness CLI. */
44
+ export interface HarnessInvokeOptions {
45
+ /** The prompt to send to the harness. */
46
+ prompt: string;
47
+ /** Working directory for the invocation. */
48
+ workspace?: string;
49
+ /** Model override (harness-specific). */
50
+ model?: string;
51
+ /** Maximum execution time in milliseconds. */
52
+ timeout?: number;
53
+ /** Whether to use RPC/structured-output mode. */
54
+ rpc?: boolean;
55
+ /** Additional environment variables passed to the child process. */
56
+ env?: Record<string, string>;
57
+ }
58
+ /** Result returned after a harness CLI invocation completes. */
59
+ export interface HarnessInvokeResult {
60
+ /** Whether the invocation completed without error. */
61
+ success: boolean;
62
+ /** Combined stdout/stderr output from the CLI. */
63
+ output: string;
64
+ /** Process exit code. */
65
+ exitCode: number;
66
+ /** Wall-clock duration of the invocation in milliseconds. */
67
+ duration: number;
68
+ /** Name of the harness that was invoked. */
69
+ harness: string;
70
+ }
71
+ /** Options for creating a Pi harness session. */
72
+ export interface PiSessionOptions {
73
+ /** Working directory for the session. */
74
+ workspace?: string;
75
+ /** Model override. */
76
+ model?: string;
77
+ /** Maximum execution time in milliseconds. */
78
+ timeout?: number;
79
+ /** Additional environment variables. */
80
+ env?: Record<string, string>;
81
+ /** Explicit path to the Pi CLI binary. */
82
+ cliPath?: string;
83
+ }
84
+ /** Result of sending a prompt through a Pi session. */
85
+ export interface PiPromptResult {
86
+ /** Raw output from the Pi CLI. */
87
+ output: string;
88
+ /** Process exit code. */
89
+ exitCode: number;
90
+ /** Wall-clock duration in milliseconds. */
91
+ duration: number;
92
+ /** Whether the prompt completed without error. */
93
+ success: boolean;
94
+ }
9
95
  export interface SessionBindOptions {
10
96
  sessionId: string;
11
97
  runId: string;
12
98
  runDir: string;
13
99
  pluginRoot?: string;
14
100
  stateDir?: string;
101
+ runsDir?: string;
15
102
  maxIterations?: number;
16
103
  prompt: string;
17
104
  verbose: boolean;
@@ -22,6 +109,8 @@ export interface SessionBindResult {
22
109
  sessionId: string;
23
110
  stateFile?: string;
24
111
  error?: string;
112
+ /** When true, the error is fatal and run:create should exit non-zero. */
113
+ fatal?: boolean;
25
114
  }
26
115
  export interface HookHandlerArgs {
27
116
  pluginRoot?: string;
@@ -48,6 +137,12 @@ export interface HarnessAdapter {
48
137
  resolvePluginRoot(args: {
49
138
  pluginRoot?: string;
50
139
  }): string | undefined;
140
+ /** Guidance shown when a harness-specific session ID is required but missing. */
141
+ getMissingSessionIdHint?(): string;
142
+ /** Whether this harness truthfully supports a given SDK hook entrypoint. */
143
+ supportsHookType?(hookType: string): boolean;
144
+ /** Message shown when a hook type is requested but unsupported by the harness. */
145
+ getUnsupportedHookMessage?(hookType: string): string;
51
146
  /** Bind a run to the caller's session (run:create flow) */
52
147
  bindSession(opts: SessionBindOptions): Promise<SessionBindResult>;
53
148
  /** Handle the stop hook (decision: approve/block) */
@@ -56,5 +151,15 @@ export interface HarnessAdapter {
56
151
  handleSessionStartHook(args: HookHandlerArgs): Promise<number>;
57
152
  /** Find hook dispatcher path (for shell hook execution) */
58
153
  findHookDispatcherPath(startCwd: string): string | null;
154
+ /** Check whether the harness CLI binary is installed and reachable. */
155
+ isCliInstalled?(): Promise<boolean>;
156
+ /** Return CLI metadata (command name, version, resolved path). */
157
+ getCliInfo?(): Promise<{
158
+ command: string;
159
+ version?: string;
160
+ path?: string;
161
+ }>;
162
+ /** List capabilities supported by this harness adapter. */
163
+ getCapabilities?(): HarnessCapability[];
59
164
  }
60
165
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot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AErE,iFAAiF;IACjF,uBAAuB,CAAC,IAAI,MAAM,CAAC;IAEnC,4EAA4E;IAC5E,gBAAgB,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7C,kFAAkF;IAClF,yBAAyB,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAErD,2DAA2D;IAC3D,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAElE,qDAAqD;IACrD,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvD,kEAAkE;IAClE,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/D,2DAA2D;IAC3D,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAExD,uEAAuE;IACvE,cAAc,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC,kEAAkE;IAClE,UAAU,CAAC,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE7E,2DAA2D;IAC3D,eAAe,CAAC,IAAI,iBAAiB,EAAE,CAAC;CACzC"}
@@ -8,3 +8,21 @@
8
8
  * so the SDK core remains harness-agnostic.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.HarnessCapability = void 0;
12
+ // ---------------------------------------------------------------------------
13
+ // Harness capability enum
14
+ // ---------------------------------------------------------------------------
15
+ /** Capabilities that a harness adapter may support. */
16
+ var HarnessCapability;
17
+ (function (HarnessCapability) {
18
+ /** Harness supports programmatic (non-interactive) invocation. */
19
+ HarnessCapability["Programmatic"] = "programmatic";
20
+ /** Harness can bind a babysitter run to a host session. */
21
+ HarnessCapability["SessionBinding"] = "session-binding";
22
+ /** Harness implements the stop-hook lifecycle event. */
23
+ HarnessCapability["StopHook"] = "stop-hook";
24
+ /** Harness exposes an MCP (Model Context Protocol) server. */
25
+ HarnessCapability["Mcp"] = "mcp";
26
+ /** Harness can accept a prompt without a TTY (headless mode). */
27
+ HarnessCapability["HeadlessPrompt"] = "headless-prompt";
28
+ })(HarnessCapability || (exports.HarnessCapability = HarnessCapability = {}));
@@ -0,0 +1,65 @@
1
+ export interface ProcessLibraryBinding {
2
+ dir: string;
3
+ repoUrl?: string;
4
+ ref?: string;
5
+ revision?: string;
6
+ boundAt: string;
7
+ }
8
+ export interface ProcessLibraryState {
9
+ version: 1;
10
+ updatedAt: string;
11
+ defaultBinding?: ProcessLibraryBinding;
12
+ runBindings?: Record<string, ProcessLibraryBinding>;
13
+ sessionBindings?: Record<string, ProcessLibraryBinding>;
14
+ }
15
+ export interface CloneProcessLibraryOptions {
16
+ repo: string;
17
+ dir: string;
18
+ ref?: string;
19
+ }
20
+ export interface CloneProcessLibraryResult {
21
+ dir: string;
22
+ repo: string;
23
+ ref?: string;
24
+ revision: string;
25
+ }
26
+ export interface UpdateProcessLibraryOptions {
27
+ dir: string;
28
+ ref?: string;
29
+ }
30
+ export interface UpdateProcessLibraryResult {
31
+ dir: string;
32
+ repo?: string;
33
+ ref?: string;
34
+ revision: string;
35
+ }
36
+ export interface BindProcessLibraryOptions {
37
+ stateDir?: string;
38
+ dir: string;
39
+ runId?: string;
40
+ sessionId?: string;
41
+ ref?: string;
42
+ }
43
+ export interface BindProcessLibraryResult {
44
+ stateFile: string;
45
+ bindingScope: "default" | "run" | "session" | "run+session";
46
+ bindingKey?: string;
47
+ binding: ProcessLibraryBinding;
48
+ }
49
+ export interface ResolveActiveProcessLibraryOptions {
50
+ stateDir?: string;
51
+ runId?: string;
52
+ sessionId?: string;
53
+ }
54
+ export interface ResolveActiveProcessLibraryResult {
55
+ stateFile: string;
56
+ bindingScope: "default" | "run" | "session" | null;
57
+ bindingKey?: string;
58
+ binding: ProcessLibraryBinding | null;
59
+ }
60
+ export declare function getActiveProcessLibraryStatePath(stateDir?: string): string;
61
+ export declare function cloneProcessLibrary(options: CloneProcessLibraryOptions): Promise<CloneProcessLibraryResult>;
62
+ export declare function updateProcessLibrary(options: UpdateProcessLibraryOptions): Promise<UpdateProcessLibraryResult>;
63
+ export declare function bindActiveProcessLibrary(options: BindProcessLibraryOptions): Promise<BindProcessLibraryResult>;
64
+ export declare function resolveActiveProcessLibrary(options?: ResolveActiveProcessLibraryOptions): Promise<ResolveActiveProcessLibraryResult>;
65
+ //# sourceMappingURL=active.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active.d.ts","sourceRoot":"","sources":["../../src/processLibrary/active.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AA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AAC,0BAA0B,CAAC,CAkBrC;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CA+BnC;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,GAAE,kCAAuC,GAC/C,OAAO,CAAC,iCAAiC,CAAC,CA2B5C"}
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getActiveProcessLibraryStatePath = getActiveProcessLibraryStatePath;
7
+ exports.cloneProcessLibrary = cloneProcessLibrary;
8
+ exports.updateProcessLibrary = updateProcessLibrary;
9
+ exports.bindActiveProcessLibrary = bindActiveProcessLibrary;
10
+ exports.resolveActiveProcessLibrary = resolveActiveProcessLibrary;
11
+ const node_fs_1 = require("node:fs");
12
+ const node_path_1 = __importDefault(require("node:path"));
13
+ const node_child_process_1 = require("node:child_process");
14
+ const node_util_1 = require("node:util");
15
+ const execFile = (0, node_util_1.promisify)(node_child_process_1.execFile);
16
+ const ACTIVE_PROCESS_LIBRARY_FILENAME = "process-library.json";
17
+ function resolveStateDir(stateDir) {
18
+ if (stateDir && stateDir.trim()) {
19
+ return node_path_1.default.resolve(stateDir);
20
+ }
21
+ return node_path_1.default.resolve(process.cwd(), ".a5c");
22
+ }
23
+ function getActiveProcessLibraryStatePath(stateDir) {
24
+ return node_path_1.default.join(resolveStateDir(stateDir), "active", ACTIVE_PROCESS_LIBRARY_FILENAME);
25
+ }
26
+ async function readState(stateDir) {
27
+ const stateFile = getActiveProcessLibraryStatePath(stateDir);
28
+ try {
29
+ const raw = await node_fs_1.promises.readFile(stateFile, "utf8");
30
+ return JSON.parse(raw);
31
+ }
32
+ catch (error) {
33
+ const code = error?.code;
34
+ if (code === "ENOENT") {
35
+ return {
36
+ version: 1,
37
+ updatedAt: new Date().toISOString(),
38
+ runBindings: {},
39
+ sessionBindings: {},
40
+ };
41
+ }
42
+ throw error;
43
+ }
44
+ }
45
+ async function writeState(stateDir, state) {
46
+ const stateFile = getActiveProcessLibraryStatePath(stateDir);
47
+ await node_fs_1.promises.mkdir(node_path_1.default.dirname(stateFile), { recursive: true });
48
+ await node_fs_1.promises.writeFile(stateFile, JSON.stringify(state, null, 2), "utf8");
49
+ return stateFile;
50
+ }
51
+ function normalizeBinding(dir, repoUrl, ref, revision) {
52
+ return {
53
+ dir: node_path_1.default.resolve(dir),
54
+ ...(repoUrl ? { repoUrl } : {}),
55
+ ...(ref ? { ref } : {}),
56
+ ...(revision ? { revision } : {}),
57
+ boundAt: new Date().toISOString(),
58
+ };
59
+ }
60
+ async function ensureDirectoryExists(dir) {
61
+ const resolved = node_path_1.default.resolve(dir);
62
+ try {
63
+ const stat = await node_fs_1.promises.stat(resolved);
64
+ if (!stat.isDirectory()) {
65
+ throw new Error(`Process-library path is not a directory: ${resolved}`);
66
+ }
67
+ }
68
+ catch (error) {
69
+ const code = error?.code;
70
+ if (code === "ENOENT") {
71
+ throw new Error(`Process-library directory not found: ${resolved}`);
72
+ }
73
+ throw error;
74
+ }
75
+ return resolved;
76
+ }
77
+ async function runGit(args, cwd) {
78
+ return execFile("git", args, {
79
+ ...(cwd ? { cwd } : {}),
80
+ encoding: "utf8",
81
+ });
82
+ }
83
+ async function getGitOutput(args, cwd) {
84
+ try {
85
+ const { stdout } = await runGit(args, cwd);
86
+ const value = stdout.trim();
87
+ return value || undefined;
88
+ }
89
+ catch {
90
+ return undefined;
91
+ }
92
+ }
93
+ async function readGitMetadata(dir) {
94
+ const repoUrl = await getGitOutput(["config", "--get", "remote.origin.url"], dir);
95
+ const revision = await getGitOutput(["rev-parse", "HEAD"], dir);
96
+ return { repoUrl, revision };
97
+ }
98
+ async function cloneProcessLibrary(options) {
99
+ const dir = node_path_1.default.resolve(options.dir);
100
+ await node_fs_1.promises.mkdir(node_path_1.default.dirname(dir), { recursive: true });
101
+ try {
102
+ await node_fs_1.promises.access(dir);
103
+ }
104
+ catch (error) {
105
+ const code = error?.code;
106
+ if (code === "ENOENT") {
107
+ // Directory does not exist yet.
108
+ }
109
+ else if (code) {
110
+ throw error;
111
+ }
112
+ else {
113
+ throw new Error(`Process-library directory already exists at ${dir}. Choose a new --dir or update it instead.`);
114
+ }
115
+ }
116
+ const cloneArgs = ["clone", "--depth", "1"];
117
+ if (options.ref) {
118
+ cloneArgs.push("--branch", options.ref);
119
+ }
120
+ cloneArgs.push(options.repo, dir);
121
+ await runGit(cloneArgs);
122
+ const { revision } = await readGitMetadata(dir);
123
+ if (!revision) {
124
+ throw new Error(`Unable to determine cloned revision for ${dir}`);
125
+ }
126
+ return {
127
+ dir,
128
+ repo: options.repo,
129
+ ...(options.ref ? { ref: options.ref } : {}),
130
+ revision,
131
+ };
132
+ }
133
+ async function updateProcessLibrary(options) {
134
+ const dir = await ensureDirectoryExists(options.dir);
135
+ if (options.ref) {
136
+ await runGit(["fetch", "--depth", "1", "origin", options.ref], dir);
137
+ await runGit(["checkout", "--force", "FETCH_HEAD"], dir);
138
+ }
139
+ else {
140
+ await runGit(["pull", "--ff-only"], dir);
141
+ }
142
+ const { repoUrl, revision } = await readGitMetadata(dir);
143
+ if (!revision) {
144
+ throw new Error(`Unable to determine updated revision for ${dir}`);
145
+ }
146
+ return {
147
+ dir,
148
+ ...(repoUrl ? { repo: repoUrl } : {}),
149
+ ...(options.ref ? { ref: options.ref } : {}),
150
+ revision,
151
+ };
152
+ }
153
+ async function bindActiveProcessLibrary(options) {
154
+ const dir = await ensureDirectoryExists(options.dir);
155
+ const state = await readState(options.stateDir);
156
+ const { repoUrl, revision } = await readGitMetadata(dir);
157
+ const binding = normalizeBinding(dir, repoUrl, options.ref, revision);
158
+ let bindingScope = "default";
159
+ let bindingKey;
160
+ if (options.runId) {
161
+ state.runBindings = state.runBindings ?? {};
162
+ state.runBindings[options.runId] = binding;
163
+ bindingScope = "run";
164
+ bindingKey = options.runId;
165
+ }
166
+ if (options.sessionId) {
167
+ state.sessionBindings = state.sessionBindings ?? {};
168
+ state.sessionBindings[options.sessionId] = binding;
169
+ bindingScope = options.runId ? "run+session" : "session";
170
+ bindingKey = options.runId
171
+ ? `${options.runId}:${options.sessionId}`
172
+ : options.sessionId;
173
+ }
174
+ if (!options.runId && !options.sessionId) {
175
+ state.defaultBinding = binding;
176
+ }
177
+ state.updatedAt = new Date().toISOString();
178
+ const stateFile = await writeState(options.stateDir, state);
179
+ return { stateFile, bindingScope, ...(bindingKey ? { bindingKey } : {}), binding };
180
+ }
181
+ async function resolveActiveProcessLibrary(options = {}) {
182
+ const stateFile = getActiveProcessLibraryStatePath(options.stateDir);
183
+ const state = await readState(options.stateDir);
184
+ if (options.runId && state.runBindings?.[options.runId]) {
185
+ return {
186
+ stateFile,
187
+ bindingScope: "run",
188
+ bindingKey: options.runId,
189
+ binding: state.runBindings[options.runId],
190
+ };
191
+ }
192
+ if (options.sessionId && state.sessionBindings?.[options.sessionId]) {
193
+ return {
194
+ stateFile,
195
+ bindingScope: "session",
196
+ bindingKey: options.sessionId,
197
+ binding: state.sessionBindings[options.sessionId],
198
+ };
199
+ }
200
+ return {
201
+ stateFile,
202
+ bindingScope: state.defaultBinding ? "default" : null,
203
+ binding: state.defaultBinding ?? null,
204
+ };
205
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/tasks/serializer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAI1D,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;IAC3E,IAAI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,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,6BAA6B,CAAC,CAQxC;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CAkCnC;AAED,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAepC;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,gBAAgB,CAAC,CAgC3B"}
@@ -28,7 +28,9 @@ async function serializeAndWriteTaskDefinition(options) {
28
28
  }
29
29
  async function serializeTaskDefinition(options) {
30
30
  const normalized = normalizeTaskDef(options.task);
31
+ const preservedTaskDef = stableClone(options.task);
31
32
  const serialized = {
33
+ ...preservedTaskDef,
32
34
  schemaVersion: exports.TASK_SCHEMA_VERSION,
33
35
  effectId: options.effectId,
34
36
  taskId: options.taskId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a5c-ai/babysitter-sdk",
3
- "version": "0.0.182",
3
+ "version": "0.0.183-staging.c0c2541e",
4
4
  "description": "Storage and run-registry primitives for event-sourced babysitter workflows.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "commonjs",
@@ -23,6 +23,7 @@
23
23
  "smoke:cli": "node scripts/smoke-cli.js --runs-dir packages/sdk/test-fixtures/cli/runs/smoke"
24
24
  },
25
25
  "dependencies": {
26
+ "@mariozechner/pi-coding-agent": "*",
26
27
  "@modelcontextprotocol/sdk": "^1.12.1",
27
28
  "fs-extra": "^11.2.0",
28
29
  "ulid": "^2.3.0"