@a5c-ai/babysitter-sdk 0.0.186 → 0.0.187-staging.049af60a
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/instructions.d.ts.map +1 -1
- package/dist/cli/commands/instructions.js +5 -3
- package/dist/config/defaults.d.ts +10 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +19 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -1
- package/dist/harness/claudeCode.js +1 -1
- package/dist/harness/cursor.js +1 -1
- package/dist/harness/discovery.d.ts.map +1 -1
- package/dist/harness/discovery.js +8 -1
- package/dist/harness/geminiCli.js +1 -1
- package/dist/harness/githubCopilot.js +1 -1
- package/dist/harness/index.d.ts +1 -0
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +3 -1
- package/dist/harness/invoker.d.ts.map +1 -1
- package/dist/harness/invoker.js +1 -0
- package/dist/harness/openclaw.d.ts +20 -0
- package/dist/harness/openclaw.d.ts.map +1 -0
- package/dist/harness/openclaw.js +338 -0
- package/dist/harness/opencode.d.ts.map +1 -1
- package/dist/harness/opencode.js +75 -5
- package/dist/harness/registry.d.ts.map +1 -1
- package/dist/harness/registry.js +2 -0
- package/dist/logging/runLogger.js +2 -2
- package/dist/prompts/babysitterMdDiscovery.d.ts +38 -0
- package/dist/prompts/babysitterMdDiscovery.d.ts.map +1 -0
- package/dist/prompts/babysitterMdDiscovery.js +150 -0
- package/dist/prompts/compose.d.ts.map +1 -1
- package/dist/prompts/compose.js +5 -0
- package/dist/prompts/context.d.ts +4 -0
- package/dist/prompts/context.d.ts.map +1 -1
- package/dist/prompts/context.js +37 -0
- package/dist/prompts/index.d.ts +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +2 -1
- package/dist/prompts/parts/index.d.ts +3 -0
- package/dist/prompts/parts/index.d.ts.map +1 -1
- package/dist/prompts/parts/index.js +7 -1
- package/dist/prompts/parts/parallelPhaseDetection.d.ts +6 -0
- package/dist/prompts/parts/parallelPhaseDetection.d.ts.map +1 -0
- package/dist/prompts/parts/parallelPhaseDetection.js +10 -0
- package/dist/prompts/parts/projectInstructions.d.ts +8 -0
- package/dist/prompts/parts/projectInstructions.d.ts.map +1 -0
- package/dist/prompts/parts/projectInstructions.js +28 -0
- package/dist/prompts/parts/runOverlapDetection.d.ts +6 -0
- package/dist/prompts/parts/runOverlapDetection.d.ts.map +1 -0
- package/dist/prompts/parts/runOverlapDetection.js +10 -0
- package/dist/prompts/templates/commands/doctor.md +9 -9
- package/dist/prompts/templates/parallel-phase-detection.md +59 -0
- package/dist/prompts/templates/run-overlap-detection.md +63 -0
- package/dist/session/types.d.ts +2 -0
- package/dist/session/types.d.ts.map +1 -1
- package/dist/storage/createRunDir.d.ts.map +1 -1
- package/dist/storage/createRunDir.js +2 -0
- package/dist/storage/icloudWarning.d.ts +6 -0
- package/dist/storage/icloudWarning.d.ts.map +1 -0
- package/dist/storage/icloudWarning.js +84 -0
- package/dist/storage/journal.d.ts.map +1 -1
- package/dist/storage/journal.js +2 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoBH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,qBAAqB,CAAC;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoBH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,qBAAqB,CAAC;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;CACf;AAqID;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAmFjB"}
|
|
@@ -30,11 +30,12 @@ const COMPOSERS = {
|
|
|
30
30
|
promptType: "babysit-skill",
|
|
31
31
|
partsIncluded: [
|
|
32
32
|
"non-negotiables", "dependencies", "interview", "user-profile",
|
|
33
|
-
"process-creation", "intent-fidelity-checks", "run-creation",
|
|
33
|
+
"process-creation", "intent-fidelity-checks", "run-overlap-detection", "run-creation",
|
|
34
34
|
"iteration", "effects", "breakpoint-handling", "results-posting",
|
|
35
35
|
"loop-control", "completion-proof", "task-kinds", "task-examples",
|
|
36
36
|
"quick-reference", "recovery", "process-guidelines", "critical-rules",
|
|
37
37
|
"see-also",
|
|
38
|
+
"project-instructions",
|
|
38
39
|
],
|
|
39
40
|
},
|
|
40
41
|
"process-create": {
|
|
@@ -43,14 +44,15 @@ const COMPOSERS = {
|
|
|
43
44
|
partsIncluded: [
|
|
44
45
|
"interview", "user-profile", "process-creation",
|
|
45
46
|
"intent-fidelity-checks", "process-guidelines",
|
|
46
|
-
"task-kinds", "task-examples",
|
|
47
|
+
"parallel-phase-detection", "task-kinds", "task-examples",
|
|
48
|
+
"project-instructions",
|
|
47
49
|
],
|
|
48
50
|
},
|
|
49
51
|
"orchestrate": {
|
|
50
52
|
fn: prompts_1.composeOrchestrationPrompt,
|
|
51
53
|
promptType: "orchestrate",
|
|
52
54
|
partsIncluded: [
|
|
53
|
-
"run-creation", "iteration", "effects", "breakpoint-handling",
|
|
55
|
+
"run-overlap-detection", "run-creation", "iteration", "effects", "breakpoint-handling",
|
|
54
56
|
"results-posting", "loop-control", "completion-proof",
|
|
55
57
|
"quick-reference", "recovery", "critical-rules",
|
|
56
58
|
],
|
|
@@ -122,6 +122,16 @@ export declare const DEFAULTS: Readonly<BabysitterConfig>;
|
|
|
122
122
|
* Override: set BABYSITTER_STATE_DIR to use a different path.
|
|
123
123
|
*/
|
|
124
124
|
export declare function getGlobalStateDir(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Returns the global babysitter log directory (~/.a5c/logs/).
|
|
127
|
+
*
|
|
128
|
+
* Structured hook/CLI/process logs are user-global by default so every
|
|
129
|
+
* harness entrypoint resolves the same log root regardless of plugin install
|
|
130
|
+
* location or current working directory.
|
|
131
|
+
*
|
|
132
|
+
* Override: set BABYSITTER_LOG_DIR to use a different path.
|
|
133
|
+
*/
|
|
134
|
+
export declare function getGlobalLogDir(): string;
|
|
125
135
|
/**
|
|
126
136
|
* Retrieves configuration with environment variable overrides merged in.
|
|
127
137
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,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C,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAEjE"}
|
package/dist/config/defaults.js
CHANGED
|
@@ -42,6 +42,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.DEFAULTS = exports.CONFIG_ENV_VARS = void 0;
|
|
44
44
|
exports.getGlobalStateDir = getGlobalStateDir;
|
|
45
|
+
exports.getGlobalLogDir = getGlobalLogDir;
|
|
45
46
|
exports.getConfig = getConfig;
|
|
46
47
|
exports.validateConfig = validateConfig;
|
|
47
48
|
exports.getDefaults = getDefaults;
|
|
@@ -148,6 +149,24 @@ function getGlobalStateDir() {
|
|
|
148
149
|
: path.join(os.homedir(), ".a5c");
|
|
149
150
|
return path.join(globalRoot, "state");
|
|
150
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Returns the global babysitter log directory (~/.a5c/logs/).
|
|
154
|
+
*
|
|
155
|
+
* Structured hook/CLI/process logs are user-global by default so every
|
|
156
|
+
* harness entrypoint resolves the same log root regardless of plugin install
|
|
157
|
+
* location or current working directory.
|
|
158
|
+
*
|
|
159
|
+
* Override: set BABYSITTER_LOG_DIR to use a different path.
|
|
160
|
+
*/
|
|
161
|
+
function getGlobalLogDir() {
|
|
162
|
+
if (process.env.BABYSITTER_LOG_DIR) {
|
|
163
|
+
return path.resolve(process.env.BABYSITTER_LOG_DIR);
|
|
164
|
+
}
|
|
165
|
+
const globalRoot = process.env.BABYSITTER_GLOBAL_STATE_DIR?.trim()
|
|
166
|
+
? path.resolve(process.env.BABYSITTER_GLOBAL_STATE_DIR)
|
|
167
|
+
: path.join(os.homedir(), ".a5c");
|
|
168
|
+
return path.join(globalRoot, "logs");
|
|
169
|
+
}
|
|
151
170
|
/**
|
|
152
171
|
* Valid log levels for validation
|
|
153
172
|
*/
|
package/dist/config/index.d.ts
CHANGED
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* }
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export { type LogLevel, type BabysitterConfig, type ConfigValidationResult, DEFAULTS, CONFIG_ENV_VARS, getConfig, getGlobalStateDir, validateConfig, getDefaults, isValidLogLevel, } from "./defaults";
|
|
24
|
+
export { type LogLevel, type BabysitterConfig, type ConfigValidationResult, DEFAULTS, CONFIG_ENV_VARS, getConfig, getGlobalLogDir, getGlobalStateDir, validateConfig, getDefaults, isValidLogLevel, } from "./defaults";
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAG3B,QAAQ,EACR,eAAe,EAGf,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAG3B,QAAQ,EACR,eAAe,EAGf,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.isValidLogLevel = exports.getDefaults = exports.validateConfig = exports.getGlobalStateDir = exports.getConfig = exports.CONFIG_ENV_VARS = exports.DEFAULTS = void 0;
|
|
26
|
+
exports.isValidLogLevel = exports.getDefaults = exports.validateConfig = exports.getGlobalStateDir = exports.getGlobalLogDir = exports.getConfig = exports.CONFIG_ENV_VARS = exports.DEFAULTS = void 0;
|
|
27
27
|
var defaults_1 = require("./defaults");
|
|
28
28
|
// Constants
|
|
29
29
|
Object.defineProperty(exports, "DEFAULTS", { enumerable: true, get: function () { return defaults_1.DEFAULTS; } });
|
|
30
30
|
Object.defineProperty(exports, "CONFIG_ENV_VARS", { enumerable: true, get: function () { return defaults_1.CONFIG_ENV_VARS; } });
|
|
31
31
|
// Functions
|
|
32
32
|
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return defaults_1.getConfig; } });
|
|
33
|
+
Object.defineProperty(exports, "getGlobalLogDir", { enumerable: true, get: function () { return defaults_1.getGlobalLogDir; } });
|
|
33
34
|
Object.defineProperty(exports, "getGlobalStateDir", { enumerable: true, get: function () { return defaults_1.getGlobalStateDir; } });
|
|
34
35
|
Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return defaults_1.validateConfig; } });
|
|
35
36
|
Object.defineProperty(exports, "getDefaults", { enumerable: true, get: function () { return defaults_1.getDefaults; } });
|
|
@@ -64,7 +64,7 @@ const density_filter_1 = require("../compression/density-filter");
|
|
|
64
64
|
const library_cache_1 = require("../compression/library-cache");
|
|
65
65
|
const installSupport_1 = require("./installSupport");
|
|
66
66
|
function createHookLogger(hookName) {
|
|
67
|
-
const logDir =
|
|
67
|
+
const logDir = (0, config_1.getGlobalLogDir)();
|
|
68
68
|
const logFile = logDir ? path.join(logDir, `${hookName}.log`) : null;
|
|
69
69
|
const context = {};
|
|
70
70
|
if (logFile) {
|
package/dist/harness/cursor.js
CHANGED
|
@@ -82,7 +82,7 @@ const config_1 = require("../config");
|
|
|
82
82
|
// ---------------------------------------------------------------------------
|
|
83
83
|
const HARNESS_NAME = "cursor";
|
|
84
84
|
function createHookLogger(hookName) {
|
|
85
|
-
const logDir =
|
|
85
|
+
const logDir = (0, config_1.getGlobalLogDir)();
|
|
86
86
|
const logFile = logDir ? path.join(logDir, `${hookName}.log`) : null;
|
|
87
87
|
const context = {};
|
|
88
88
|
if (logFile) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/harness/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAO9F,0DAA0D;AAC1D,UAAU,WAAW;IACnB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,+CAA+C;IAC/C,YAAY,EAAE,iBAAiB,EAAE,CAAC;CACnC;AAMD,mDAAmD;AACnD,eAAO,MAAM,eAAe,EAAE,SAAS,WAAW,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/harness/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAO9F,0DAA0D;AAC1D,UAAU,WAAW;IACnB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;OAKG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,+CAA+C;IAC/C,YAAY,EAAE,iBAAiB,EAAE,CAAC;CACnC;AAMD,mDAAmD;AACnD,eAAO,MAAM,eAAe,EAAE,SAAS,WAAW,EAkExC,CAAC;AA2CX;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BlE;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA6B3E;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,IAAI,mBAAmB,GAAG,IAAI,CAahE"}
|
|
@@ -100,7 +100,7 @@ exports.KNOWN_HARNESSES = [
|
|
|
100
100
|
{
|
|
101
101
|
name: "opencode",
|
|
102
102
|
cli: "opencode",
|
|
103
|
-
callerEnvVars: ["BABYSITTER_SESSION_ID", "OPENCODE_CONFIG"],
|
|
103
|
+
callerEnvVars: ["BABYSITTER_SESSION_ID", "OPENCODE_CONFIG", "ACCOMPLISH_TASK_ID", "OPENCODE_CONFIG_DIR"],
|
|
104
104
|
capabilities: [types_1.HarnessCapability.HeadlessPrompt],
|
|
105
105
|
},
|
|
106
106
|
{
|
|
@@ -109,6 +109,12 @@ exports.KNOWN_HARNESSES = [
|
|
|
109
109
|
callerEnvVars: ["OMP_SESSION_ID", "OMP_PLUGIN_ROOT"],
|
|
110
110
|
capabilities: [types_1.HarnessCapability.Programmatic, types_1.HarnessCapability.SessionBinding, types_1.HarnessCapability.HeadlessPrompt, types_1.HarnessCapability.Mcp],
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
name: "openclaw",
|
|
114
|
+
cli: "openclaw",
|
|
115
|
+
callerEnvVars: ["OPENCLAW_SHELL", "OPENCLAW_HOME"],
|
|
116
|
+
capabilities: [types_1.HarnessCapability.SessionBinding, types_1.HarnessCapability.Mcp, types_1.HarnessCapability.HeadlessPrompt],
|
|
117
|
+
},
|
|
112
118
|
{
|
|
113
119
|
name: "pi",
|
|
114
120
|
cli: "pi",
|
|
@@ -135,6 +141,7 @@ const CONFIG_PATHS = {
|
|
|
135
141
|
"github-copilot": [".copilot", ".github"],
|
|
136
142
|
cursor: [".cursor", ".cursorrules"],
|
|
137
143
|
opencode: [".opencode"],
|
|
144
|
+
openclaw: [".openclaw"],
|
|
138
145
|
};
|
|
139
146
|
/**
|
|
140
147
|
* Checks whether a harness config directory exists in cwd or home.
|
|
@@ -78,7 +78,7 @@ const config_1 = require("../config");
|
|
|
78
78
|
// ---------------------------------------------------------------------------
|
|
79
79
|
const HARNESS_NAME = "gemini-cli";
|
|
80
80
|
function createHookLogger(hookName) {
|
|
81
|
-
const logDir =
|
|
81
|
+
const logDir = (0, config_1.getGlobalLogDir)();
|
|
82
82
|
const logFile = logDir ? path.join(logDir, `${hookName}.log`) : null;
|
|
83
83
|
const context = {};
|
|
84
84
|
if (logFile) {
|
|
@@ -79,7 +79,7 @@ const config_1 = require("../config");
|
|
|
79
79
|
// ---------------------------------------------------------------------------
|
|
80
80
|
const HARNESS_NAME = "github-copilot";
|
|
81
81
|
function createHookLogger(hookName) {
|
|
82
|
-
const logDir =
|
|
82
|
+
const logDir = (0, config_1.getGlobalLogDir)();
|
|
83
83
|
const logFile = logDir ? path.join(logDir, `${hookName}.log`) : null;
|
|
84
84
|
const context = {};
|
|
85
85
|
if (logFile) {
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { createCursorAdapter } from "./cursor";
|
|
|
7
7
|
export { createGithubCopilotAdapter } from "./githubCopilot";
|
|
8
8
|
export { createPiAdapter } from "./pi";
|
|
9
9
|
export { createOhMyPiAdapter } from "./ohMyPi";
|
|
10
|
+
export { createOpenClawAdapter } from "./openclaw";
|
|
10
11
|
export { createOpenCodeAdapter } from "./opencode";
|
|
11
12
|
export { createInternalAdapter } from "./internal";
|
|
12
13
|
export { createPiSession, PiSessionHandle, type PiEventListener } from "./piWrapper";
|
|
@@ -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,EACf,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,mBA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AAM,WAAW,CAAC;AAE7E,OAAO,EACL,4BAA4B,EAC5B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC"}
|
package/dist/harness/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AGENTIC_TOOL_NAMES = exports.createAgenticToolDefinitions = exports.HARNESS_CLI_MAP = exports.buildHarnessArgs = exports.invokeHarness = exports.KNOWN_HARNESSES = exports.checkCliAvailable = exports.detectCallerHarness = exports.discoverHarnesses = exports.resetAdapter = exports.setAdapter = exports.getAdapter = exports.listSupportedHarnesses = exports.getAdapterByName = exports.detectAdapter = exports.createCustomAdapter = exports.createNullAdapter = exports.PiSessionHandle = exports.createPiSession = exports.createInternalAdapter = exports.createOpenCodeAdapter = exports.createOhMyPiAdapter = exports.createPiAdapter = exports.createGithubCopilotAdapter = exports.createCursorAdapter = exports.createGeminiCliAdapter = exports.createCodexAdapter = exports.createClaudeCodeAdapter = exports.HarnessCapability = void 0;
|
|
3
|
+
exports.AGENTIC_TOOL_NAMES = exports.createAgenticToolDefinitions = exports.HARNESS_CLI_MAP = exports.buildHarnessArgs = exports.invokeHarness = exports.KNOWN_HARNESSES = exports.checkCliAvailable = exports.detectCallerHarness = exports.discoverHarnesses = exports.resetAdapter = exports.setAdapter = exports.getAdapter = exports.listSupportedHarnesses = exports.getAdapterByName = exports.detectAdapter = exports.createCustomAdapter = exports.createNullAdapter = exports.PiSessionHandle = exports.createPiSession = exports.createInternalAdapter = exports.createOpenCodeAdapter = exports.createOpenClawAdapter = exports.createOhMyPiAdapter = exports.createPiAdapter = exports.createGithubCopilotAdapter = exports.createCursorAdapter = exports.createGeminiCliAdapter = exports.createCodexAdapter = exports.createClaudeCodeAdapter = exports.HarnessCapability = void 0;
|
|
4
4
|
var types_1 = require("./types");
|
|
5
5
|
Object.defineProperty(exports, "HarnessCapability", { enumerable: true, get: function () { return types_1.HarnessCapability; } });
|
|
6
6
|
var claudeCode_1 = require("./claudeCode");
|
|
@@ -17,6 +17,8 @@ var pi_1 = require("./pi");
|
|
|
17
17
|
Object.defineProperty(exports, "createPiAdapter", { enumerable: true, get: function () { return pi_1.createPiAdapter; } });
|
|
18
18
|
var ohMyPi_1 = require("./ohMyPi");
|
|
19
19
|
Object.defineProperty(exports, "createOhMyPiAdapter", { enumerable: true, get: function () { return ohMyPi_1.createOhMyPiAdapter; } });
|
|
20
|
+
var openclaw_1 = require("./openclaw");
|
|
21
|
+
Object.defineProperty(exports, "createOpenClawAdapter", { enumerable: true, get: function () { return openclaw_1.createOpenClawAdapter; } });
|
|
20
22
|
var opencode_1 = require("./opencode");
|
|
21
23
|
Object.defineProperty(exports, "createOpenCodeAdapter", { enumerable: true, get: function () { return opencode_1.createOpenCodeAdapter; } });
|
|
22
24
|
var internal_1 = require("./internal");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/harness/invoker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AASzE,wDAAwD;AACxD,UAAU,cAAc;IACtB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,aAAa,EAAE,OAAO,CAAC;IACvB,qEAAqE;IACrE,WAAW,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACpC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAQD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"invoker.d.ts","sourceRoot":"","sources":["../../src/harness/invoker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AASzE,wDAAwD;AACxD,UAAU,cAAc;IACtB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,aAAa,EAAE,OAAO,CAAC;IACvB,qEAAqE;IACrE,WAAW,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IACpC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAQD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAgB3D,CAAC;AAuDX;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,MAAM,EAAE,CA+BV;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAqI9B"}
|
package/dist/harness/invoker.js
CHANGED
|
@@ -67,6 +67,7 @@ exports.HARNESS_CLI_MAP = {
|
|
|
67
67
|
"gemini-cli": { cli: "gemini", supportsModel: true, promptStyle: "flag" },
|
|
68
68
|
"github-copilot": { cli: "copilot", supportsModel: true, promptStyle: "flag" },
|
|
69
69
|
cursor: { cli: "cursor", supportsModel: true, promptStyle: "positional", baseArgs: ["agent"], workspaceFlag: "--workspace" },
|
|
70
|
+
openclaw: { cli: "openclaw", workspaceFlag: undefined, supportsModel: false, promptStyle: "flag", baseArgs: [] },
|
|
70
71
|
opencode: { cli: "opencode", supportsModel: true, promptStyle: "positional", baseArgs: ["run"] },
|
|
71
72
|
};
|
|
72
73
|
const PROGRAMMATIC_ONLY_HARNESSES = ["internal"];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw harness adapter.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all OpenClaw-specific behaviors:
|
|
5
|
+
* - Session ID resolution (BABYSITTER_SESSION_ID, OPENCLAW_SHELL context)
|
|
6
|
+
* - State directory conventions (global state dir by default)
|
|
7
|
+
* - Session binding (run:create -> state file with run association)
|
|
8
|
+
* - No stop hook (OpenClaw is a daemon with no stop-hook model)
|
|
9
|
+
* - Session-start hook handler (baseline state file + skill discovery context)
|
|
10
|
+
*
|
|
11
|
+
* OpenClaw characteristics:
|
|
12
|
+
* - Daemon/gateway model, CLI command: `openclaw`
|
|
13
|
+
* - Env vars: OPENCLAW_SHELL, OPENCLAW_HOME
|
|
14
|
+
* - Sessions use composite keys: `agent:<agentId>:<channel>:<type>:<id>`
|
|
15
|
+
* - NO stop-hook model — hooks are registered programmatically
|
|
16
|
+
* - Capabilities: SessionBinding, Mcp, HeadlessPrompt (NOT StopHook, NOT Programmatic)
|
|
17
|
+
*/
|
|
18
|
+
import type { HarnessAdapter } from "./types";
|
|
19
|
+
export declare function createOpenClawAdapter(): HarnessAdapter;
|
|
20
|
+
//# sourceMappingURL=openclaw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw.d.ts","sourceRoot":"","sources":["../../src/harness/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,SAAS,CAAC;AAwPjB,wBAAgB,qBAAqB,IAAI,cAAc,CAgItD"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenClaw harness adapter.
|
|
4
|
+
*
|
|
5
|
+
* Centralizes all OpenClaw-specific behaviors:
|
|
6
|
+
* - Session ID resolution (BABYSITTER_SESSION_ID, OPENCLAW_SHELL context)
|
|
7
|
+
* - State directory conventions (global state dir by default)
|
|
8
|
+
* - Session binding (run:create -> state file with run association)
|
|
9
|
+
* - No stop hook (OpenClaw is a daemon with no stop-hook model)
|
|
10
|
+
* - Session-start hook handler (baseline state file + skill discovery context)
|
|
11
|
+
*
|
|
12
|
+
* OpenClaw characteristics:
|
|
13
|
+
* - Daemon/gateway model, CLI command: `openclaw`
|
|
14
|
+
* - Env vars: OPENCLAW_SHELL, OPENCLAW_HOME
|
|
15
|
+
* - Sessions use composite keys: `agent:<agentId>:<channel>:<type>:<id>`
|
|
16
|
+
* - NO stop-hook model — hooks are registered programmatically
|
|
17
|
+
* - Capabilities: SessionBinding, Mcp, HeadlessPrompt (NOT StopHook, NOT Programmatic)
|
|
18
|
+
*/
|
|
19
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}) : (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
o[k2] = m[k];
|
|
29
|
+
}));
|
|
30
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
31
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
32
|
+
}) : function(o, v) {
|
|
33
|
+
o["default"] = v;
|
|
34
|
+
});
|
|
35
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
36
|
+
var ownKeys = function(o) {
|
|
37
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
38
|
+
var ar = [];
|
|
39
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
+
return ar;
|
|
41
|
+
};
|
|
42
|
+
return ownKeys(o);
|
|
43
|
+
};
|
|
44
|
+
return function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.createOpenClawAdapter = createOpenClawAdapter;
|
|
54
|
+
const path = __importStar(require("node:path"));
|
|
55
|
+
const node_fs_1 = require("node:fs");
|
|
56
|
+
const session_1 = require("../session");
|
|
57
|
+
const types_1 = require("./types");
|
|
58
|
+
const context_1 = require("../prompts/context");
|
|
59
|
+
const config_1 = require("../config");
|
|
60
|
+
const discovery_1 = require("./discovery");
|
|
61
|
+
const installSupport_1 = require("./installSupport");
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Constants
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
const HARNESS_NAME = "openclaw";
|
|
66
|
+
function createHookLogger(hookName) {
|
|
67
|
+
const logDir = (0, config_1.getGlobalLogDir)();
|
|
68
|
+
const logFile = logDir ? path.join(logDir, `${hookName}.log`) : null;
|
|
69
|
+
const context = {};
|
|
70
|
+
if (logFile) {
|
|
71
|
+
try {
|
|
72
|
+
(0, node_fs_1.mkdirSync)(logDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Best-effort
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function write(level, message) {
|
|
79
|
+
if (!logFile)
|
|
80
|
+
return;
|
|
81
|
+
const ts = new Date().toISOString();
|
|
82
|
+
const ctxParts = Object.entries(context).map(([k, v]) => `${k}=${v}`);
|
|
83
|
+
const ctxStr = ctxParts.length > 0 ? ` [${ctxParts.join(" ")}]` : "";
|
|
84
|
+
const line = `[${level}] ${ts}${ctxStr} ${message}\n`;
|
|
85
|
+
try {
|
|
86
|
+
(0, node_fs_1.appendFileSync)(logFile, line);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Best-effort
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
info: (msg) => write("INFO", msg),
|
|
94
|
+
warn: (msg) => write("WARN", msg),
|
|
95
|
+
error: (msg) => write("ERROR", msg),
|
|
96
|
+
setContext: (key, value) => {
|
|
97
|
+
context[key] = value;
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// State directory resolution
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
function resolveStateDirInternal(args) {
|
|
105
|
+
if (args.stateDir)
|
|
106
|
+
return path.resolve(args.stateDir);
|
|
107
|
+
return (0, config_1.getGlobalStateDir)();
|
|
108
|
+
}
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Session ID resolution
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
function resolveSessionIdInternal(parsed) {
|
|
113
|
+
// 1. Explicit arg (highest priority)
|
|
114
|
+
if (parsed.sessionId)
|
|
115
|
+
return parsed.sessionId;
|
|
116
|
+
// 2. Cross-harness standard env var
|
|
117
|
+
if (process.env.BABYSITTER_SESSION_ID)
|
|
118
|
+
return process.env.BABYSITTER_SESSION_ID;
|
|
119
|
+
// 3. OpenClaw shell context — composite key provided by the gateway
|
|
120
|
+
if (process.env.OPENCLAW_SHELL)
|
|
121
|
+
return process.env.OPENCLAW_SHELL;
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// Stop hook handler (no-op — OpenClaw has no stop-hook model)
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
function writeNoopHookResult() {
|
|
128
|
+
process.stdout.write("{}\n");
|
|
129
|
+
}
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// SessionStart hook handler
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
async function handleSessionStartHookImpl(args) {
|
|
134
|
+
const { verbose } = args;
|
|
135
|
+
const log = createHookLogger("babysitter-openclaw-session-start-hook");
|
|
136
|
+
log.info("handleSessionStartHook started (openclaw)");
|
|
137
|
+
// OpenClaw is a daemon — session IDs come from the gateway env, not stdin.
|
|
138
|
+
const sessionId = process.env.BABYSITTER_SESSION_ID || process.env.OPENCLAW_SHELL || "";
|
|
139
|
+
if (!sessionId) {
|
|
140
|
+
log.info("No session ID — skipping state file creation");
|
|
141
|
+
process.stdout.write("{}\n");
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
log.setContext("session", sessionId);
|
|
145
|
+
log.info(`Session ID: ${sessionId}`);
|
|
146
|
+
// Resolve state directory and create baseline session file
|
|
147
|
+
const stateDir = resolveStateDirInternal(args);
|
|
148
|
+
log.info(`Resolved stateDir: ${stateDir}`);
|
|
149
|
+
const filePath = (0, session_1.getSessionFilePath)(stateDir, sessionId);
|
|
150
|
+
try {
|
|
151
|
+
if (!(await (0, session_1.sessionFileExists)(filePath))) {
|
|
152
|
+
const nowTs = (0, session_1.getCurrentTimestamp)();
|
|
153
|
+
const state = {
|
|
154
|
+
active: true,
|
|
155
|
+
iteration: 1,
|
|
156
|
+
maxIterations: 256,
|
|
157
|
+
runId: "",
|
|
158
|
+
startedAt: nowTs,
|
|
159
|
+
lastIterationAt: nowTs,
|
|
160
|
+
iterationTimes: [],
|
|
161
|
+
};
|
|
162
|
+
await (0, session_1.writeSessionFile)(filePath, state, "");
|
|
163
|
+
log.info(`Created session state: ${filePath}`);
|
|
164
|
+
if (verbose) {
|
|
165
|
+
process.stderr.write(`[hook:run session-start] Created session state: ${filePath}\n`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
log.info(`Session state already exists: ${filePath}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
174
|
+
log.warn(`Failed to create session state: ${msg}`);
|
|
175
|
+
if (verbose) {
|
|
176
|
+
process.stderr.write(`[hook:run session-start] Failed to create session state: ${msg}\n`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Output empty object
|
|
180
|
+
process.stdout.write("{}\n");
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
// ---------------------------------------------------------------------------
|
|
184
|
+
// Session binding (run:create flow)
|
|
185
|
+
// ---------------------------------------------------------------------------
|
|
186
|
+
async function bindSessionImpl(opts) {
|
|
187
|
+
const { sessionId, runId, maxIterations = 256, prompt, verbose } = opts;
|
|
188
|
+
// Resolve state directory
|
|
189
|
+
const stateDir = resolveStateDirInternal({
|
|
190
|
+
stateDir: opts.stateDir,
|
|
191
|
+
pluginRoot: opts.pluginRoot,
|
|
192
|
+
});
|
|
193
|
+
const filePath = (0, session_1.getSessionFilePath)(stateDir, sessionId);
|
|
194
|
+
// Check for existing session (prevent re-entrant runs)
|
|
195
|
+
if (await (0, session_1.sessionFileExists)(filePath)) {
|
|
196
|
+
try {
|
|
197
|
+
const existing = await (0, session_1.readSessionFile)(filePath);
|
|
198
|
+
if (existing.state.runId && existing.state.runId !== runId) {
|
|
199
|
+
return {
|
|
200
|
+
harness: HARNESS_NAME,
|
|
201
|
+
sessionId,
|
|
202
|
+
stateFile: filePath,
|
|
203
|
+
error: `Session already associated with run: ${existing.state.runId}`,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// Update existing session with run ID
|
|
207
|
+
await (0, session_1.updateSessionState)(filePath, { runId, active: true }, { state: existing.state, prompt: existing.prompt });
|
|
208
|
+
if (verbose) {
|
|
209
|
+
process.stderr.write(`[run:create] Updated existing session ${sessionId} with run ${runId}\n`);
|
|
210
|
+
}
|
|
211
|
+
return { harness: HARNESS_NAME, sessionId, stateFile: filePath };
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// Corrupted state file — overwrite
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Create new session state with run associated
|
|
218
|
+
const nowTs = (0, session_1.getCurrentTimestamp)();
|
|
219
|
+
const state = {
|
|
220
|
+
active: true,
|
|
221
|
+
iteration: 1,
|
|
222
|
+
maxIterations,
|
|
223
|
+
runId,
|
|
224
|
+
startedAt: nowTs,
|
|
225
|
+
lastIterationAt: nowTs,
|
|
226
|
+
iterationTimes: [],
|
|
227
|
+
};
|
|
228
|
+
try {
|
|
229
|
+
await (0, session_1.writeSessionFile)(filePath, state, prompt);
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
return {
|
|
233
|
+
harness: HARNESS_NAME,
|
|
234
|
+
sessionId,
|
|
235
|
+
error: `Failed to write session state: ${e instanceof Error ? e.message : String(e)}`,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (verbose) {
|
|
239
|
+
process.stderr.write(`[run:create] Session ${sessionId} initialized and bound to run ${runId}\n`);
|
|
240
|
+
}
|
|
241
|
+
return { harness: HARNESS_NAME, sessionId, stateFile: filePath };
|
|
242
|
+
}
|
|
243
|
+
// ---------------------------------------------------------------------------
|
|
244
|
+
// Adapter factory
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
function createOpenClawAdapter() {
|
|
247
|
+
return {
|
|
248
|
+
name: HARNESS_NAME,
|
|
249
|
+
isActive() {
|
|
250
|
+
return !!(process.env.OPENCLAW_SHELL || process.env.OPENCLAW_HOME);
|
|
251
|
+
},
|
|
252
|
+
autoResolvesSessionId() {
|
|
253
|
+
return true;
|
|
254
|
+
},
|
|
255
|
+
getMissingSessionIdHint() {
|
|
256
|
+
return ("Session ID is provided by the OpenClaw gateway. " +
|
|
257
|
+
"Ensure you're running inside an OpenClaw agent session.");
|
|
258
|
+
},
|
|
259
|
+
supportsHookType(hookType) {
|
|
260
|
+
// OpenClaw hooks are registered programmatically via the daemon.
|
|
261
|
+
// Only session-start is supported via the SDK hook:run path.
|
|
262
|
+
return hookType === "session-start";
|
|
263
|
+
},
|
|
264
|
+
getUnsupportedHookMessage(hookType) {
|
|
265
|
+
if (hookType === "stop") {
|
|
266
|
+
return ("OpenClaw does not support a blocking stop hook. " +
|
|
267
|
+
"The daemon manages agent lifecycle via agent_end signals. " +
|
|
268
|
+
"Use the OpenClaw gateway API instead.");
|
|
269
|
+
}
|
|
270
|
+
return `Hook type "${hookType}" is not supported by the OpenClaw adapter. OpenClaw hooks are registered programmatically.`;
|
|
271
|
+
},
|
|
272
|
+
getCapabilities() {
|
|
273
|
+
return [
|
|
274
|
+
types_1.HarnessCapability.SessionBinding,
|
|
275
|
+
types_1.HarnessCapability.Mcp,
|
|
276
|
+
types_1.HarnessCapability.HeadlessPrompt,
|
|
277
|
+
];
|
|
278
|
+
},
|
|
279
|
+
resolveSessionId(parsed) {
|
|
280
|
+
return resolveSessionIdInternal(parsed);
|
|
281
|
+
},
|
|
282
|
+
resolveStateDir(args) {
|
|
283
|
+
return resolveStateDirInternal(args);
|
|
284
|
+
},
|
|
285
|
+
resolvePluginRoot(_args) {
|
|
286
|
+
// OpenClaw has no OPENCLAW_PLUGIN_ROOT env var.
|
|
287
|
+
return undefined;
|
|
288
|
+
},
|
|
289
|
+
bindSession(opts) {
|
|
290
|
+
return bindSessionImpl(opts);
|
|
291
|
+
},
|
|
292
|
+
handleStopHook(_args) {
|
|
293
|
+
// No-op: OpenClaw has no stop-hook model.
|
|
294
|
+
writeNoopHookResult();
|
|
295
|
+
return Promise.resolve(0);
|
|
296
|
+
},
|
|
297
|
+
handleSessionStartHook(args) {
|
|
298
|
+
return handleSessionStartHookImpl(args);
|
|
299
|
+
},
|
|
300
|
+
findHookDispatcherPath(_startCwd) {
|
|
301
|
+
// OpenClaw hooks are registered programmatically via the daemon.
|
|
302
|
+
return null;
|
|
303
|
+
},
|
|
304
|
+
async isCliInstalled() {
|
|
305
|
+
const result = await (0, discovery_1.checkCliAvailable)("openclaw");
|
|
306
|
+
return result.available;
|
|
307
|
+
},
|
|
308
|
+
async getCliInfo() {
|
|
309
|
+
const result = await (0, discovery_1.checkCliAvailable)("openclaw");
|
|
310
|
+
return {
|
|
311
|
+
command: "openclaw",
|
|
312
|
+
version: result.version,
|
|
313
|
+
path: result.path,
|
|
314
|
+
};
|
|
315
|
+
},
|
|
316
|
+
installHarness(options) {
|
|
317
|
+
return (0, installSupport_1.installCliViaNpm)({
|
|
318
|
+
harness: HARNESS_NAME,
|
|
319
|
+
cliCommand: "openclaw",
|
|
320
|
+
packageName: "openclaw",
|
|
321
|
+
summary: "Install the OpenClaw CLI globally via npm.",
|
|
322
|
+
options,
|
|
323
|
+
});
|
|
324
|
+
},
|
|
325
|
+
installPlugin(options) {
|
|
326
|
+
return (0, installSupport_1.installCliViaNpm)({
|
|
327
|
+
harness: HARNESS_NAME,
|
|
328
|
+
cliCommand: "openclaw",
|
|
329
|
+
packageName: "@a5c-ai/babysitter-openclaw",
|
|
330
|
+
summary: "Install the Babysitter OpenClaw plugin package, then register it via `openclaw plugin install babysitter-openclaw`.",
|
|
331
|
+
options,
|
|
332
|
+
});
|
|
333
|
+
},
|
|
334
|
+
getPromptContext(opts) {
|
|
335
|
+
return (0, context_1.createOpenClawContext)(opts);
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/harness/opencode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;
|
|
1
|
+
{"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/harness/opencode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAmBH,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,SAAS,CAAC;AA4iBjB,wBAAgB,qBAAqB,IAAI,cAAc,CAkJtD"}
|