@a5c-ai/babysitter-sdk 0.0.177-staging.c53a9469 → 0.0.177-staging.ec3ce00a
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/plugin.d.ts +3 -3
- package/dist/cli/commands/plugin.d.ts.map +1 -1
- package/dist/cli/commands/plugin.js +12 -6
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +21 -3
- package/dist/cli/resolveInputPath.d.ts.map +1 -1
- package/dist/cli/resolveInputPath.js +10 -5
- package/dist/harness/codex.d.ts +10 -0
- package/dist/harness/codex.d.ts.map +1 -0
- package/dist/harness/codex.js +150 -0
- 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/registry.d.ts.map +1 -1
- package/dist/harness/registry.js +2 -0
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* plugin:* commands — Manage plugins and marketplaces.
|
|
3
3
|
*
|
|
4
4
|
* Marketplace commands:
|
|
5
|
-
* plugin:add-marketplace --marketplace-url <url> --
|
|
6
|
-
* plugin:update-marketplace --marketplace-name <name> --
|
|
7
|
-
* plugin:list-plugins --marketplace-name <name> --
|
|
5
|
+
* plugin:add-marketplace --marketplace-url <url> [--global|--project] [--json]
|
|
6
|
+
* plugin:update-marketplace --marketplace-name <name> [--global|--project] [--json]
|
|
7
|
+
* plugin:list-plugins --marketplace-name <name> [--global|--project] [--json]
|
|
8
8
|
*
|
|
9
9
|
* Plugin commands:
|
|
10
10
|
* plugin:install, plugin:uninstall, plugin:update, plugin:configure,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8BH,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,qBAAqB,CAAC;AAM7B,MAAM,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wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAgDjB;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAiDjB;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAoFjB;AAMD,2CAA2C;AAC3C,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAsGjB;AAED,+CAA+C;AAC/C,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAoFjB;AAED,qDAAqD;AACrD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CA8IjB;AAED,qCAAqC;AACrC,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAsFjB;AAED,oDAAoD;AACpD,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAsEjB;AAED,qDAAqD;AACrD,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CAsFjB;AAED,+CAA+C;AAC/C,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,MAAM,CAAC,CA0CjB"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* plugin:* commands — Manage plugins and marketplaces.
|
|
4
4
|
*
|
|
5
5
|
* Marketplace commands:
|
|
6
|
-
* plugin:add-marketplace --marketplace-url <url> --
|
|
7
|
-
* plugin:update-marketplace --marketplace-name <name> --
|
|
8
|
-
* plugin:list-plugins --marketplace-name <name> --
|
|
6
|
+
* plugin:add-marketplace --marketplace-url <url> [--global|--project] [--json]
|
|
7
|
+
* plugin:update-marketplace --marketplace-name <name> [--global|--project] [--json]
|
|
8
|
+
* plugin:list-plugins --marketplace-name <name> [--global|--project] [--json]
|
|
9
9
|
*
|
|
10
10
|
* Plugin commands:
|
|
11
11
|
* plugin:install, plugin:uninstall, plugin:update, plugin:configure,
|
|
@@ -54,7 +54,7 @@ function requireArg(value, name, command, json) {
|
|
|
54
54
|
}
|
|
55
55
|
function requireScope(scope, command, json) {
|
|
56
56
|
if (!validateScope(scope)) {
|
|
57
|
-
const msg = `[${command}] --
|
|
57
|
+
const msg = `[${command}] --global or --project is required`;
|
|
58
58
|
if (json) {
|
|
59
59
|
console.log(JSON.stringify({ error: "missing_argument", message: msg }));
|
|
60
60
|
}
|
|
@@ -609,8 +609,14 @@ async function handlePluginUpdateRegistry(args) {
|
|
|
609
609
|
const projectDir = scope === "project" ? process.cwd() : undefined;
|
|
610
610
|
try {
|
|
611
611
|
const registry = await (0, registry_1.readPluginRegistry)(scope, projectDir);
|
|
612
|
-
//
|
|
613
|
-
|
|
612
|
+
// Try to resolve the plugin package path, but don't fail if marketplace is unavailable
|
|
613
|
+
let packagePath = "";
|
|
614
|
+
try {
|
|
615
|
+
packagePath = await (0, marketplace_1.resolvePluginPackagePath)(marketplaceName, pluginName, scope, projectDir);
|
|
616
|
+
}
|
|
617
|
+
catch {
|
|
618
|
+
// Marketplace may not exist or plugin may not be listed yet — that's OK
|
|
619
|
+
}
|
|
614
620
|
const now = new Date().toISOString();
|
|
615
621
|
const existingEntry = (0, registry_1.getPluginEntry)(registry, pluginName);
|
|
616
622
|
const entry = {
|
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;AAmiB/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;AAy+C7D,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;AAE9F,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA6QpD,MAAM;EAIvB"}
|
package/dist/cli/main.js
CHANGED
|
@@ -85,7 +85,7 @@ const USAGE = `Usage:
|
|
|
85
85
|
babysitter session:iteration-message --iteration <n> [--run-id <id>] [--runs-dir <dir>] [--plugin-root <dir>] [--json]
|
|
86
86
|
babysitter skill:discover --plugin-root <dir> [--run-id <id>] [--cache-ttl <seconds>] [--runs-dir <dir>] [--include-remote] [--summary-only] [--process-path <path>] [--json]
|
|
87
87
|
babysitter hook:log --hook-type <type> --log-file <path> [--json]
|
|
88
|
-
babysitter hook:run --hook-type <stop|session-start> [--harness <claude-code>] [--plugin-root <dir>] [--state-dir <dir>] [--runs-dir <dir>] [--json] [--verbose]
|
|
88
|
+
babysitter hook:run --hook-type <stop|session-start> [--harness <claude-code|codex|gemini-cli>] [--plugin-root <dir>] [--state-dir <dir>] [--runs-dir <dir>] [--json] [--verbose]
|
|
89
89
|
babysitter skill:fetch-remote --source-type <github|well-known> --url <url> [--json]
|
|
90
90
|
babysitter profile:read --user|--project [--dir <dir>] [--json]
|
|
91
91
|
babysitter profile:write --user|--project --input <file> [--dir <dir>] [--json]
|
|
@@ -275,7 +275,13 @@ function parseArgs(argv) {
|
|
|
275
275
|
}
|
|
276
276
|
// Session command flags
|
|
277
277
|
if (arg === "--session-id") {
|
|
278
|
-
|
|
278
|
+
// Tolerate empty/missing value — the harness adapter can auto-detect
|
|
279
|
+
// session ID from CLAUDE_ENV_FILE or CLAUDE_SESSION_ID env var.
|
|
280
|
+
const next = rest[i + 1];
|
|
281
|
+
if (next && !next.startsWith("-")) {
|
|
282
|
+
parsed.sessionId = next;
|
|
283
|
+
i++;
|
|
284
|
+
}
|
|
279
285
|
continue;
|
|
280
286
|
}
|
|
281
287
|
if (arg === "--state-dir") {
|
|
@@ -1939,7 +1945,19 @@ function createBabysitterCli() {
|
|
|
1939
1945
|
if (parsed.command === "task:show") {
|
|
1940
1946
|
return await handleTaskShow(parsed);
|
|
1941
1947
|
}
|
|
1942
|
-
// Session commands
|
|
1948
|
+
// Session commands — auto-resolve sessionId via harness adapter if not
|
|
1949
|
+
// explicitly provided (e.g. from CLAUDE_ENV_FILE written by session-start hook).
|
|
1950
|
+
if (!parsed.sessionId && parsed.command?.startsWith("session:")) {
|
|
1951
|
+
const sessionAdapter = parsed.harness
|
|
1952
|
+
? (0, harness_1.getAdapterByName)(parsed.harness)
|
|
1953
|
+
: (0, harness_1.getAdapter)();
|
|
1954
|
+
if (sessionAdapter) {
|
|
1955
|
+
const resolved = sessionAdapter.resolveSessionId(parsed);
|
|
1956
|
+
if (resolved) {
|
|
1957
|
+
parsed.sessionId = resolved;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1943
1961
|
if (parsed.command === "session:init") {
|
|
1944
1962
|
return await (0, session_1.handleSessionInit)({
|
|
1945
1963
|
sessionId: parsed.sessionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveInputPath.d.ts","sourceRoot":"","sources":["../../src/cli/resolveInputPath.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"resolveInputPath.d.ts","sourceRoot":"","sources":["../../src/cli/resolveInputPath.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAiBxD;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgC1D"}
|
|
@@ -57,12 +57,17 @@ const node_fs_1 = require("node:fs");
|
|
|
57
57
|
* // => "C:\\project\\.a5c\\runs\\01RUN"
|
|
58
58
|
*/
|
|
59
59
|
function collapseDoubledA5cRuns(p) {
|
|
60
|
-
// Match both forward and back-slash variants
|
|
61
|
-
const pattern = /([/\\]?\.a5c[/\\]runs)[/\\]\.a5c[/\\]runs([/\\]|$)/;
|
|
62
60
|
let result = p;
|
|
63
|
-
// Collapse
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
// Collapse .a5c/runs/.a5c/runs/ → .a5c/runs/
|
|
62
|
+
const runsPattern = /([/\\]?\.a5c[/\\]runs)[/\\]\.a5c[/\\]runs([/\\]|$)/;
|
|
63
|
+
while (runsPattern.test(result)) {
|
|
64
|
+
result = result.replace(runsPattern, "$1$2");
|
|
65
|
+
}
|
|
66
|
+
// Collapse .a5c/.a5c/ → .a5c/ (e.g. when CLI runs from .a5c/ with relative
|
|
67
|
+
// --runs-dir .a5c/runs, producing /project/.a5c/.a5c/runs/)
|
|
68
|
+
const a5cPattern = /([/\\]\.a5c)[/\\]\.a5c([/\\])/;
|
|
69
|
+
while (a5cPattern.test(result)) {
|
|
70
|
+
result = result.replace(a5cPattern, "$1$2");
|
|
66
71
|
}
|
|
67
72
|
return result;
|
|
68
73
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex harness adapter.
|
|
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.
|
|
7
|
+
*/
|
|
8
|
+
import type { HarnessAdapter } from "./types";
|
|
9
|
+
export declare function createCodexAdapter(): HarnessAdapter;
|
|
10
|
+
//# sourceMappingURL=codex.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Codex harness adapter.
|
|
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.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.createCodexAdapter = createCodexAdapter;
|
|
44
|
+
const path = __importStar(require("node:path"));
|
|
45
|
+
const node_fs_1 = require("node:fs");
|
|
46
|
+
const claudeCode_1 = require("./claudeCode");
|
|
47
|
+
function resolveCodexPluginRoot(args = {}) {
|
|
48
|
+
const root = args.pluginRoot || process.env.CODEX_PLUGIN_ROOT;
|
|
49
|
+
return root ? path.resolve(root) : undefined;
|
|
50
|
+
}
|
|
51
|
+
function resolveCodexStateDir(args) {
|
|
52
|
+
if (args.stateDir)
|
|
53
|
+
return path.resolve(args.stateDir);
|
|
54
|
+
if (process.env.BABYSITTER_STATE_DIR) {
|
|
55
|
+
return path.resolve(process.env.BABYSITTER_STATE_DIR);
|
|
56
|
+
}
|
|
57
|
+
const pluginRoot = resolveCodexPluginRoot(args);
|
|
58
|
+
if (pluginRoot) {
|
|
59
|
+
// Codex plugins conventionally live under ".codex", while state is in ".a5c".
|
|
60
|
+
return path.resolve(pluginRoot, "..", ".a5c");
|
|
61
|
+
}
|
|
62
|
+
return path.resolve(".a5c");
|
|
63
|
+
}
|
|
64
|
+
function resolveCodexSessionId(parsed) {
|
|
65
|
+
if (parsed.sessionId)
|
|
66
|
+
return parsed.sessionId;
|
|
67
|
+
// Codex injects CODEX_THREAD_ID; keep CODEX_SESSION_ID as legacy fallback.
|
|
68
|
+
if (process.env.CODEX_THREAD_ID)
|
|
69
|
+
return process.env.CODEX_THREAD_ID;
|
|
70
|
+
if (process.env.CODEX_SESSION_ID)
|
|
71
|
+
return process.env.CODEX_SESSION_ID;
|
|
72
|
+
const envFile = process.env.CODEX_ENV_FILE;
|
|
73
|
+
if (!envFile)
|
|
74
|
+
return undefined;
|
|
75
|
+
try {
|
|
76
|
+
const content = (0, node_fs_1.readFileSync)(envFile, "utf-8");
|
|
77
|
+
const match = content.match(/(?:^|\n)\s*(?:export\s+)?(?:CODEX_THREAD_ID|CODEX_SESSION_ID)="([^"]+)"/);
|
|
78
|
+
return match?.[1] || undefined;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function createCodexAdapter() {
|
|
85
|
+
const claude = (0, claudeCode_1.createClaudeCodeAdapter)();
|
|
86
|
+
return {
|
|
87
|
+
name: "codex",
|
|
88
|
+
isActive() {
|
|
89
|
+
return !!(process.env.CODEX_THREAD_ID ||
|
|
90
|
+
process.env.CODEX_SESSION_ID ||
|
|
91
|
+
process.env.CODEX_ENV_FILE ||
|
|
92
|
+
process.env.CODEX_PLUGIN_ROOT);
|
|
93
|
+
},
|
|
94
|
+
resolveSessionId(parsed) {
|
|
95
|
+
return resolveCodexSessionId(parsed);
|
|
96
|
+
},
|
|
97
|
+
resolveStateDir(args) {
|
|
98
|
+
return resolveCodexStateDir(args);
|
|
99
|
+
},
|
|
100
|
+
resolvePluginRoot(args) {
|
|
101
|
+
return resolveCodexPluginRoot(args);
|
|
102
|
+
},
|
|
103
|
+
bindSession(opts) {
|
|
104
|
+
const stateDir = resolveCodexStateDir({
|
|
105
|
+
stateDir: opts.stateDir,
|
|
106
|
+
pluginRoot: opts.pluginRoot,
|
|
107
|
+
});
|
|
108
|
+
return claude.bindSession({
|
|
109
|
+
...opts,
|
|
110
|
+
stateDir,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
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
|
+
});
|
|
124
|
+
},
|
|
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
|
+
});
|
|
136
|
+
},
|
|
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;
|
|
147
|
+
return null;
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { HarnessAdapter, SessionBindOptions, SessionBindResult, HookHandlerArgs, } from "./types";
|
|
2
2
|
export { createClaudeCodeAdapter } from "./claudeCode";
|
|
3
|
+
export { createCodexAdapter } from "./codex";
|
|
3
4
|
export { createGeminiCliAdapter } from "./geminiCli";
|
|
4
5
|
export { createNullAdapter } from "./nullAdapter";
|
|
5
6
|
export { detectAdapter, getAdapterByName, listSupportedHarnesses, getAdapter, setAdapter, resetAdapter, } from "./registry";
|
|
@@ -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,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,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,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,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,8 +1,10 @@
|
|
|
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.createGeminiCliAdapter = exports.createClaudeCodeAdapter = void 0;
|
|
3
|
+
exports.resetAdapter = exports.setAdapter = exports.getAdapter = exports.listSupportedHarnesses = exports.getAdapterByName = exports.detectAdapter = exports.createNullAdapter = exports.createGeminiCliAdapter = exports.createCodexAdapter = exports.createClaudeCodeAdapter = void 0;
|
|
4
4
|
var claudeCode_1 = require("./claudeCode");
|
|
5
5
|
Object.defineProperty(exports, "createClaudeCodeAdapter", { enumerable: true, get: function () { return claudeCode_1.createClaudeCodeAdapter; } });
|
|
6
|
+
var codex_1 = require("./codex");
|
|
7
|
+
Object.defineProperty(exports, "createCodexAdapter", { enumerable: true, get: function () { return codex_1.createCodexAdapter; } });
|
|
6
8
|
var geminiCli_1 = require("./geminiCli");
|
|
7
9
|
Object.defineProperty(exports, "createGeminiCliAdapter", { enumerable: true, get: function () { return geminiCli_1.createGeminiCliAdapter; } });
|
|
8
10
|
var nullAdapter_1 = require("./nullAdapter");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/harness/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/harness/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAoB9C;;;GAGG;AACH,wBAAgB,aAAa,IAAI,cAAc,CAK9C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAKpE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD;AAQD;;GAEG;AACH,wBAAgB,UAAU,IAAI,cAAc,CAK3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}
|
package/dist/harness/registry.js
CHANGED
|
@@ -14,12 +14,14 @@ exports.getAdapter = getAdapter;
|
|
|
14
14
|
exports.setAdapter = setAdapter;
|
|
15
15
|
exports.resetAdapter = resetAdapter;
|
|
16
16
|
const claudeCode_1 = require("./claudeCode");
|
|
17
|
+
const codex_1 = require("./codex");
|
|
17
18
|
const geminiCli_1 = require("./geminiCli");
|
|
18
19
|
const nullAdapter_1 = require("./nullAdapter");
|
|
19
20
|
// ---------------------------------------------------------------------------
|
|
20
21
|
// Registry of known adapters (ordered by priority)
|
|
21
22
|
// ---------------------------------------------------------------------------
|
|
22
23
|
const knownAdapters = [
|
|
24
|
+
(0, codex_1.createCodexAdapter)(),
|
|
23
25
|
(0, claudeCode_1.createClaudeCodeAdapter)(),
|
|
24
26
|
(0, geminiCli_1.createGeminiCliAdapter)(),
|
|
25
27
|
];
|
package/package.json
CHANGED