@a5c-ai/babysitter-sdk 0.0.184 → 0.0.185

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.
Files changed (52) hide show
  1. package/dist/cli/commands/instructions.d.ts.map +1 -1
  2. package/dist/cli/commands/instructions.js +41 -0
  3. package/dist/cli/main.js +2 -2
  4. package/dist/config/defaults.d.ts +11 -0
  5. package/dist/config/defaults.d.ts.map +1 -1
  6. package/dist/config/defaults.js +55 -0
  7. package/dist/config/index.d.ts +1 -1
  8. package/dist/config/index.d.ts.map +1 -1
  9. package/dist/config/index.js +2 -1
  10. package/dist/harness/claudeCode.d.ts +2 -2
  11. package/dist/harness/claudeCode.d.ts.map +1 -1
  12. package/dist/harness/claudeCode.js +47 -72
  13. package/dist/harness/codex.d.ts.map +1 -1
  14. package/dist/harness/codex.js +10 -49
  15. package/dist/harness/cursor.d.ts.map +1 -1
  16. package/dist/harness/cursor.js +23 -34
  17. package/dist/harness/customAdapter.d.ts.map +1 -1
  18. package/dist/harness/customAdapter.js +8 -3
  19. package/dist/harness/discovery.js +7 -7
  20. package/dist/harness/geminiCli.d.ts.map +1 -1
  21. package/dist/harness/geminiCli.js +20 -27
  22. package/dist/harness/githubCopilot.d.ts.map +1 -1
  23. package/dist/harness/githubCopilot.js +17 -40
  24. package/dist/harness/index.d.ts +1 -0
  25. package/dist/harness/index.d.ts.map +1 -1
  26. package/dist/harness/index.js +3 -1
  27. package/dist/harness/installSupport.d.ts +1 -0
  28. package/dist/harness/installSupport.d.ts.map +1 -1
  29. package/dist/harness/installSupport.js +7 -3
  30. package/dist/harness/invoker.js +1 -1
  31. package/dist/harness/ohMyPi.d.ts +0 -14
  32. package/dist/harness/ohMyPi.d.ts.map +1 -1
  33. package/dist/harness/ohMyPi.js +163 -24
  34. package/dist/harness/opencode.d.ts +28 -0
  35. package/dist/harness/opencode.d.ts.map +1 -0
  36. package/dist/harness/opencode.js +578 -0
  37. package/dist/harness/pi.d.ts +1 -11
  38. package/dist/harness/pi.d.ts.map +1 -1
  39. package/dist/harness/pi.js +81 -105
  40. package/dist/harness/registry.d.ts.map +1 -1
  41. package/dist/harness/registry.js +2 -0
  42. package/dist/prompts/context.d.ts +9 -0
  43. package/dist/prompts/context.d.ts.map +1 -1
  44. package/dist/prompts/context.js +128 -20
  45. package/dist/prompts/index.d.ts +1 -1
  46. package/dist/prompts/index.d.ts.map +1 -1
  47. package/dist/prompts/index.js +2 -1
  48. package/dist/prompts/templates/completion-proof.md +8 -0
  49. package/dist/prompts/templates/critical-rules.md +5 -5
  50. package/dist/prompts/types.d.ts +4 -5
  51. package/dist/prompts/types.d.ts.map +1 -1
  52. package/package.json +1 -1
@@ -1,31 +1,167 @@
1
1
  "use strict";
2
- /**
3
- * Oh-My-Pi harness adapter.
4
- *
5
- * Oh-my-pi (omp) is a fork of pi that shares the same environment variables,
6
- * session conventions, and hook mechanisms. This adapter wraps the pi adapter
7
- * with a different name so the registry can distinguish between the two when
8
- * both are installed.
9
- */
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
10
35
  Object.defineProperty(exports, "__esModule", { value: true });
11
36
  exports.createOhMyPiAdapter = createOhMyPiAdapter;
12
- const pi_1 = require("./pi");
37
+ const path = __importStar(require("node:path"));
38
+ const types_1 = require("./types");
39
+ const context_1 = require("../prompts/context");
40
+ const config_1 = require("../config");
41
+ const session_1 = require("../session");
13
42
  const installSupport_1 = require("./installSupport");
14
- /**
15
- * Create an adapter for oh-my-pi.
16
- *
17
- * Reuses the pi adapter's implementation entirely — same env vars, same
18
- * session binding, same hook handling — but reports `name: "oh-my-pi"`.
19
- */
43
+ function resolveOhMyPiPluginRoot(args = {}) {
44
+ const root = args.pluginRoot || process.env.OMP_PLUGIN_ROOT;
45
+ return root ? path.resolve(root) : undefined;
46
+ }
47
+ function resolveOhMyPiStateDir(args) {
48
+ if (args.stateDir)
49
+ return path.resolve(args.stateDir);
50
+ return (0, config_1.getGlobalStateDir)();
51
+ }
52
+ function resolveOhMyPiSessionId(parsed) {
53
+ if (parsed.sessionId)
54
+ return parsed.sessionId;
55
+ if (process.env.BABYSITTER_SESSION_ID)
56
+ return process.env.BABYSITTER_SESSION_ID;
57
+ if (process.env.OMP_SESSION_ID)
58
+ return process.env.OMP_SESSION_ID;
59
+ return undefined;
60
+ }
61
+ async function bindOhMyPiSession(opts) {
62
+ const stateDir = resolveOhMyPiStateDir({
63
+ stateDir: opts.stateDir,
64
+ pluginRoot: opts.pluginRoot,
65
+ });
66
+ const stateFile = (0, session_1.getSessionFilePath)(stateDir, opts.sessionId);
67
+ if (await (0, session_1.sessionFileExists)(stateFile)) {
68
+ const existing = await (0, session_1.readSessionFile)(stateFile);
69
+ if (existing.state.runId && existing.state.runId !== opts.runId) {
70
+ return {
71
+ harness: "oh-my-pi",
72
+ sessionId: opts.sessionId,
73
+ stateFile,
74
+ error: `Session already associated with run ${existing.state.runId}`,
75
+ };
76
+ }
77
+ await (0, session_1.updateSessionState)(stateFile, { active: true, runId: opts.runId }, existing);
78
+ return {
79
+ harness: "oh-my-pi",
80
+ sessionId: opts.sessionId,
81
+ stateFile,
82
+ };
83
+ }
84
+ const now = (0, session_1.getCurrentTimestamp)();
85
+ const state = {
86
+ active: true,
87
+ iteration: 1,
88
+ maxIterations: opts.maxIterations ?? 256,
89
+ runId: opts.runId,
90
+ startedAt: now,
91
+ lastIterationAt: now,
92
+ iterationTimes: [],
93
+ };
94
+ await (0, session_1.writeSessionFile)(stateFile, state, opts.prompt);
95
+ return {
96
+ harness: "oh-my-pi",
97
+ sessionId: opts.sessionId,
98
+ stateFile,
99
+ };
100
+ }
101
+ function writeNoopHookResult() {
102
+ process.stdout.write("{}\n");
103
+ }
104
+ async function installOhMyPiPlugin(options) {
105
+ const packageArgs = ["install"];
106
+ if (options.workspace) {
107
+ packageArgs.push("--workspace", path.resolve(options.workspace));
108
+ }
109
+ else {
110
+ packageArgs.push("--global");
111
+ }
112
+ return (0, installSupport_1.runPackageBinaryViaNpx)({
113
+ harness: "oh-my-pi",
114
+ packageName: "@a5c-ai/babysitter-omp",
115
+ packageArgs,
116
+ summary: options.workspace
117
+ ? "Install the published Babysitter oh-my-pi package for the target workspace."
118
+ : "Install the published Babysitter oh-my-pi package into the user profile.",
119
+ options,
120
+ env: process.env,
121
+ });
122
+ }
20
123
  function createOhMyPiAdapter() {
21
- const piAdapter = (0, pi_1.createPiAdapter)();
22
124
  return {
23
- ...piAdapter,
24
125
  name: "oh-my-pi",
25
126
  isActive() {
26
- // oh-my-pi shares OMP_* env vars with pi, but we only claim active
27
- // if OMP_PLUGIN_ROOT or OMP_SESSION_ID is set (not PI_* variants)
28
- return !!(process.env.OMP_SESSION_ID || process.env.OMP_PLUGIN_ROOT);
127
+ return !!(process.env.BABYSITTER_SESSION_ID ||
128
+ process.env.OMP_SESSION_ID ||
129
+ process.env.OMP_PLUGIN_ROOT);
130
+ },
131
+ autoResolvesSessionId() {
132
+ return true;
133
+ },
134
+ getMissingSessionIdHint() {
135
+ return "oh-my-pi should provide OMP_SESSION_ID when the Babysitter package is active.";
136
+ },
137
+ supportsHookType(_hookType) {
138
+ return false;
139
+ },
140
+ getUnsupportedHookMessage(hookType) {
141
+ return `oh-my-pi does not use babysitter hook:run for "${hookType}". Use the oh-my-pi package skills and extension bridge instead.`;
142
+ },
143
+ resolveSessionId(parsed) {
144
+ return resolveOhMyPiSessionId(parsed);
145
+ },
146
+ resolveStateDir(args) {
147
+ return resolveOhMyPiStateDir(args);
148
+ },
149
+ resolvePluginRoot(args) {
150
+ return resolveOhMyPiPluginRoot(args);
151
+ },
152
+ bindSession(opts) {
153
+ return bindOhMyPiSession(opts);
154
+ },
155
+ handleStopHook(_args) {
156
+ writeNoopHookResult();
157
+ return Promise.resolve(0);
158
+ },
159
+ handleSessionStartHook(_args) {
160
+ writeNoopHookResult();
161
+ return Promise.resolve(0);
162
+ },
163
+ findHookDispatcherPath(_startCwd) {
164
+ return null;
29
165
  },
30
166
  installHarness(options) {
31
167
  return (0, installSupport_1.installCliViaNpm)({
@@ -37,10 +173,13 @@ function createOhMyPiAdapter() {
37
173
  });
38
174
  },
39
175
  installPlugin(options) {
40
- return (0, pi_1.installPiFamilyPlugin)({
41
- harness: "oh-my-pi",
42
- options,
43
- });
176
+ return installOhMyPiPlugin(options);
177
+ },
178
+ getCapabilities() {
179
+ return [types_1.HarnessCapability.Programmatic, types_1.HarnessCapability.SessionBinding, types_1.HarnessCapability.HeadlessPrompt, types_1.HarnessCapability.Mcp];
180
+ },
181
+ getPromptContext(opts) {
182
+ return (0, context_1.createOhMyPiContext)(opts);
44
183
  },
45
184
  };
46
185
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * OpenCode harness adapter.
3
+ *
4
+ * Centralizes all OpenCode-specific behaviors:
5
+ * - Session ID resolution (BABYSITTER_SESSION_ID, self-injected via shell.env hook)
6
+ * - State directory conventions (global state dir by default)
7
+ * - Session binding (run:create → state file with run association)
8
+ * - Minimal stop hook handler (no native stop hook — in-turn model)
9
+ * - Session-start hook handler (baseline state file creation)
10
+ *
11
+ * OpenCode characteristics:
12
+ * - Go binary, CLI command: `opencode`
13
+ * - Config directory: `.opencode/`
14
+ * - Plugin system: JS/TS modules in `.opencode/plugins/` with hooks for
15
+ * `tool.execute.before/after`, `session.idle`, `session.created`, `shell.env`
16
+ * - NO blocking stop hook — `session.idle` is fire-and-forget
17
+ * - Programmatic API: `@opencode-ai/sdk` with `session.create()`,
18
+ * `session.prompt()`, `event.subscribe()` (SSE)
19
+ * - Env vars: Does NOT inject distinctive env vars into plugins — weak
20
+ * caller detection. The babysitter plugin self-injects
21
+ * `BABYSITTER_SESSION_ID` via the `shell.env` hook.
22
+ * - Loop mechanism: in-turn (no stop-hook, must use SDK loop driver or
23
+ * in-turn orchestration)
24
+ * - Capabilities: [HeadlessPrompt] only
25
+ */
26
+ import type { HarnessAdapter } from "./types";
27
+ export declare function createOpenCodeAdapter(): HarnessAdapter;
28
+ //# sourceMappingURL=opencode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.d.ts","sourceRoot":"","sources":["../../src/harness/opencode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAkBH,OAAO,KAAK,EACV,cAAc,EAMf,MAAM,SAAS,CAAC;AA+fjB,wBAAgB,qBAAqB,IAAI,cAAc,CAsHtD"}