@a5c-ai/babysitter-sdk 0.0.182-staging.d2efc4ae → 0.0.183-staging.0c58dfe8
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/commands/processLibrary.d.ts +16 -0
- package/dist/cli/commands/processLibrary.d.ts.map +1 -0
- package/dist/cli/commands/processLibrary.js +152 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +41 -5
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +3 -1
- package/dist/harness/types.d.ts +96 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js +18 -0
- package/dist/processLibrary/active.d.ts +65 -0
- package/dist/processLibrary/active.d.ts.map +1 -0
- package/dist/processLibrary/active.js +205 -0
- package/package.json +2 -1
|
@@ -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
|
+
}
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -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;
|
|
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");
|
|
@@ -95,6 +96,10 @@ const USAGE = `Usage:
|
|
|
95
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
|
-
|
|
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
|
-
//
|
|
887
|
-
//
|
|
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);
|
|
@@ -927,7 +943,8 @@ async function handleRunCreate(parsed) {
|
|
|
927
943
|
// Try process-driven discovery first (reads @skill/@agent markers from process file)
|
|
928
944
|
let discoveredSkills;
|
|
929
945
|
let discoveredAgents;
|
|
930
|
-
const discoverPluginRoot =
|
|
946
|
+
const discoverPluginRoot = parsed.pluginRoot ??
|
|
947
|
+
adapter?.resolvePluginRoot(parsed);
|
|
931
948
|
if (discoverPluginRoot) {
|
|
932
949
|
try {
|
|
933
950
|
const processDiscovery = (0, skill_1.discoverFromProcessFile)({
|
|
@@ -1852,6 +1869,10 @@ const VALID_COMMANDS = [
|
|
|
1852
1869
|
"hook:run",
|
|
1853
1870
|
"skill:discover",
|
|
1854
1871
|
"skill:fetch-remote",
|
|
1872
|
+
"process-library:clone",
|
|
1873
|
+
"process-library:update",
|
|
1874
|
+
"process-library:use",
|
|
1875
|
+
"process-library:active",
|
|
1855
1876
|
"profile:read",
|
|
1856
1877
|
"profile:write",
|
|
1857
1878
|
"profile:merge",
|
|
@@ -2120,6 +2141,21 @@ function createBabysitterCli() {
|
|
|
2120
2141
|
json: parsed.json,
|
|
2121
2142
|
});
|
|
2122
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
|
+
}
|
|
2123
2159
|
// Profile commands
|
|
2124
2160
|
if (parsed.command === "profile:read" ||
|
|
2125
2161
|
parsed.command === "profile:write" ||
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/harness/index.js
CHANGED
|
@@ -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");
|
package/dist/harness/types.d.ts
CHANGED
|
@@ -6,6 +6,92 @@
|
|
|
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;
|
|
@@ -65,5 +151,15 @@ export interface HarnessAdapter {
|
|
|
65
151
|
handleSessionStartHook(args: HookHandlerArgs): Promise<number>;
|
|
66
152
|
/** Find hook dispatcher path (for shell hook execution) */
|
|
67
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[];
|
|
68
164
|
}
|
|
69
165
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAMD,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC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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"}
|
package/dist/harness/types.js
CHANGED
|
@@ -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;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M,CAAC;IACpB,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACvC;AASD,wBAAgB,gCAAgC,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1E;AA+FD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAmCpC;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a5c-ai/babysitter-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.183-staging.0c58dfe8",
|
|
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"
|