@a5c-ai/babysitter-sdk 0.0.183-staging.f48a64a2 → 0.0.183

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 (42) hide show
  1. package/dist/cli/commands/harnessCreateRun.d.ts +24 -0
  2. package/dist/cli/commands/harnessCreateRun.d.ts.map +1 -0
  3. package/dist/cli/commands/harnessCreateRun.js +118 -0
  4. package/dist/cli/commands/harnessPhase1.d.ts +43 -0
  5. package/dist/cli/commands/harnessPhase1.d.ts.map +1 -0
  6. package/dist/cli/commands/harnessPhase1.js +1743 -0
  7. package/dist/cli/commands/harnessPhase2.d.ts +34 -0
  8. package/dist/cli/commands/harnessPhase2.d.ts.map +1 -0
  9. package/dist/cli/commands/harnessPhase2.js +1386 -0
  10. package/dist/cli/commands/{sessionCreatePrompts.d.ts → harnessPrompts.d.ts} +6 -4
  11. package/dist/cli/commands/harnessPrompts.d.ts.map +1 -0
  12. package/dist/cli/commands/{sessionCreatePrompts.js → harnessPrompts.js} +42 -10
  13. package/dist/cli/commands/harnessResumeRun.d.ts +25 -0
  14. package/dist/cli/commands/harnessResumeRun.d.ts.map +1 -0
  15. package/dist/cli/commands/harnessResumeRun.js +500 -0
  16. package/dist/cli/commands/harnessUtils.d.ts +220 -0
  17. package/dist/cli/commands/harnessUtils.d.ts.map +1 -0
  18. package/dist/cli/commands/harnessUtils.js +576 -0
  19. package/dist/cli/main.d.ts.map +1 -1
  20. package/dist/cli/main.js +368 -6
  21. package/dist/harness/agenticTools.d.ts +47 -0
  22. package/dist/harness/agenticTools.d.ts.map +1 -0
  23. package/dist/harness/agenticTools.js +921 -0
  24. package/dist/harness/claudeCode.d.ts.map +1 -1
  25. package/dist/harness/claudeCode.js +34 -0
  26. package/dist/harness/geminiCli.d.ts.map +1 -1
  27. package/dist/harness/geminiCli.js +33 -0
  28. package/dist/harness/index.d.ts +1 -0
  29. package/dist/harness/index.d.ts.map +1 -1
  30. package/dist/harness/index.js +4 -1
  31. package/dist/harness/piWrapper.d.ts.map +1 -1
  32. package/dist/harness/piWrapper.js +3 -0
  33. package/dist/harness/types.d.ts +3 -0
  34. package/dist/harness/types.d.ts.map +1 -1
  35. package/dist/interaction/askUserQuestion.d.ts +9 -0
  36. package/dist/interaction/askUserQuestion.d.ts.map +1 -1
  37. package/dist/interaction/askUserQuestion.js +386 -18
  38. package/package.json +5 -1
  39. package/dist/cli/commands/sessionCreate.d.ts +0 -27
  40. package/dist/cli/commands/sessionCreate.d.ts.map +0 -1
  41. package/dist/cli/commands/sessionCreate.js +0 -3260
  42. package/dist/cli/commands/sessionCreatePrompts.d.ts.map +0 -1
@@ -0,0 +1,24 @@
1
+ /**
2
+ * harness:create-run command handler.
3
+ *
4
+ * Drives a full babysitter session lifecycle through two agentic phases:
5
+ * Phase 1 - Unbound interview / intent / process-definition
6
+ * Phase 2 - Bound orchestration loop with hook-style continuation semantics
7
+ *
8
+ * Both phases are driven through a Pi agent session and LLM-callable tools.
9
+ * Interactive user input is exposed through an AskUserQuestion tool instead of
10
+ * direct imperative prompts inside the host loop.
11
+ *
12
+ * This module is a thin coordinator that imports the phase implementations
13
+ * from separate modules and exports the public API.
14
+ */
15
+ import { type HarnessCreateRunArgs } from "./harnessUtils";
16
+ export type { HarnessCreateRunArgs } from "./harnessUtils";
17
+ /** @deprecated Use HarnessCreateRunArgs instead */
18
+ export type { HarnessCreateRunArgs as SessionCreateArgs } from "./harnessUtils";
19
+ export { selectHarness } from "./harnessUtils";
20
+ export { runOrchestrationPhase } from "./harnessPhase2";
21
+ export declare function handleHarnessCreateRun(parsed: HarnessCreateRunArgs): Promise<number>;
22
+ /** @deprecated Use handleHarnessCreateRun instead */
23
+ export declare const handleSessionCreate: typeof handleHarnessCreateRun;
24
+ //# sourceMappingURL=harnessCreateRun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harnessCreateRun.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessCreateRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,oBAAoB,EAY1B,MAAM,gBAAgB,CAAC;AAMxB,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,mDAAmD;AACnD,YAAY,EAAE,oBAAoB,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAIxD,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAsGjB;AAED,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,+BAAyB,CAAC"}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /**
3
+ * harness:create-run command handler.
4
+ *
5
+ * Drives a full babysitter session lifecycle through two agentic phases:
6
+ * Phase 1 - Unbound interview / intent / process-definition
7
+ * Phase 2 - Bound orchestration loop with hook-style continuation semantics
8
+ *
9
+ * Both phases are driven through a Pi agent session and LLM-callable tools.
10
+ * Interactive user input is exposed through an AskUserQuestion tool instead of
11
+ * direct imperative prompts inside the host loop.
12
+ *
13
+ * This module is a thin coordinator that imports the phase implementations
14
+ * from separate modules and exports the public API.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.handleSessionCreate = exports.runOrchestrationPhase = exports.selectHarness = void 0;
18
+ exports.handleHarnessCreateRun = handleHarnessCreateRun;
19
+ const harnessUtils_1 = require("./harnessUtils");
20
+ const harnessPhase1_1 = require("./harnessPhase1");
21
+ const harnessPhase2_1 = require("./harnessPhase2");
22
+ var harnessUtils_2 = require("./harnessUtils");
23
+ Object.defineProperty(exports, "selectHarness", { enumerable: true, get: function () { return harnessUtils_2.selectHarness; } });
24
+ var harnessPhase2_2 = require("./harnessPhase2");
25
+ Object.defineProperty(exports, "runOrchestrationPhase", { enumerable: true, get: function () { return harnessPhase2_2.runOrchestrationPhase; } });
26
+ // ── Main Entry Point ─────────────────────────────────────────────────
27
+ async function handleHarnessCreateRun(parsed) {
28
+ const { prompt: initialPrompt, harness: preferredHarness, processPath: providedProcessPath, workspace, model, maxIterations = 256, runsDir, json, verbose, } = parsed;
29
+ const interactive = parsed.interactive ?? (process.stdin.isTTY === true && !json);
30
+ const rl = interactive ? (0, harnessUtils_1.createReadlineInterface)() : null;
31
+ try {
32
+ let prompt = initialPrompt;
33
+ if (!prompt && !providedProcessPath) {
34
+ if (interactive && rl) {
35
+ const userPrompt = await (0, harnessUtils_1.readInteractivePrompt)(rl);
36
+ if (!userPrompt) {
37
+ return 0; // User cancelled
38
+ }
39
+ prompt = userPrompt;
40
+ }
41
+ else {
42
+ const error = "Either --prompt or --process must be provided";
43
+ if (json) {
44
+ console.error(JSON.stringify({ error: "MISSING_PROMPT", message: error }, null, 2));
45
+ }
46
+ else {
47
+ process.stderr.write(`${harnessUtils_1.RED}Error:${harnessUtils_1.RESET} ${error}\n`);
48
+ }
49
+ return 1;
50
+ }
51
+ }
52
+ const discovered = await (0, harnessUtils_1.discoverHarnesses)();
53
+ const selectedHarnessName = preferredHarness === "oh-my-pi"
54
+ ? "oh-my-pi"
55
+ : "pi";
56
+ const compressionConfig = (0, harnessUtils_1.loadSessionCompressionConfig)(workspace);
57
+ const promptContext = (0, harnessUtils_1.buildPromptContext)({
58
+ workspace,
59
+ selectedHarnessName,
60
+ discovered,
61
+ compressionConfig,
62
+ });
63
+ let processPath = providedProcessPath;
64
+ if (processPath) {
65
+ (0, harnessUtils_1.emitProgress)({ phase: "1", status: "skipped", processPath }, json, verbose);
66
+ }
67
+ else {
68
+ const workDir = workspace ?? process.cwd();
69
+ processPath = await (0, harnessPhase1_1.runProcessDefinitionPhase)({
70
+ prompt: prompt,
71
+ outputPath: (0, harnessPhase1_1.getGeneratedProcessPath)(workDir),
72
+ workspace: workDir,
73
+ model,
74
+ interactive,
75
+ rl,
76
+ json,
77
+ verbose,
78
+ compressionConfig,
79
+ promptContext,
80
+ selectedHarnessName,
81
+ });
82
+ }
83
+ if (parsed.planOnly) {
84
+ (0, harnessUtils_1.emitProgress)({ phase: "2", status: "skipped-plan-only", processPath }, json, verbose);
85
+ if (json) {
86
+ process.stdout.write(JSON.stringify({ ok: true, planOnly: true, processPath }) + "\n");
87
+ }
88
+ else {
89
+ process.stderr.write(`${harnessUtils_1.GREEN}Process definition created: ${harnessUtils_1.BOLD}${processPath}${harnessUtils_1.RESET}\n`);
90
+ process.stderr.write(`${harnessUtils_1.DIM}Run /babysitter:call or harness:create-run --process ${processPath} to execute.${harnessUtils_1.RESET}\n`);
91
+ }
92
+ return 0;
93
+ }
94
+ return await (0, harnessPhase2_1.runOrchestrationPhase)({
95
+ processPath,
96
+ prompt,
97
+ workspace,
98
+ model,
99
+ runsDir,
100
+ maxIterations,
101
+ json,
102
+ verbose,
103
+ interactive,
104
+ rl,
105
+ selectedHarnessName,
106
+ discovered,
107
+ compressionConfig,
108
+ promptContext,
109
+ existingRunId: parsed.existingRunId,
110
+ existingRunDir: parsed.existingRunDir,
111
+ });
112
+ }
113
+ finally {
114
+ rl?.close();
115
+ }
116
+ }
117
+ /** @deprecated Use handleHarnessCreateRun instead */
118
+ exports.handleSessionCreate = handleHarnessCreateRun;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Phase 1: Process definition — interview + process creation.
3
+ *
4
+ * Drives an agentic Pi session (or headless external harness) to author a
5
+ * babysitter process definition file from a user prompt.
6
+ */
7
+ import * as readline from "node:readline";
8
+ import { type ExternalWorkspaceAssessment, type CompressionConfig, type HarnessPromptContext as SessionCreatePromptContext } from "./harnessUtils";
9
+ export declare function getGeneratedProcessPath(workDir: string): string;
10
+ export declare function execShellEffect(command: string, args: string[], cwd?: string): Promise<{
11
+ stdout: string;
12
+ stderr: string;
13
+ exitCode: number;
14
+ }>;
15
+ export declare function buildAgentPrompt(taskDef: Record<string, unknown>): string;
16
+ export declare function buildStructuredAgentOutputInstructions(agent: Record<string, unknown>): string[];
17
+ export declare function extractJsonObjectFromText(text: string): string | null;
18
+ export declare function coerceAgentResultValue(taskDef: Record<string, unknown>, output: string): unknown;
19
+ export declare function buildExternalProcessDefinitionPrompt(args: {
20
+ prompt: string;
21
+ outputPath: string;
22
+ workspace?: string;
23
+ promptContext: SessionCreatePromptContext;
24
+ workspaceAssessment: ExternalWorkspaceAssessment;
25
+ }): string;
26
+ export declare function buildExternalProcessConformancePrompt(args: {
27
+ outputPath: string;
28
+ prompt: string;
29
+ }): string;
30
+ export declare function runProcessDefinitionPhase(args: {
31
+ prompt: string;
32
+ outputPath: string;
33
+ workspace?: string;
34
+ model?: string;
35
+ interactive: boolean;
36
+ rl: readline.Interface | null;
37
+ json: boolean;
38
+ verbose: boolean;
39
+ compressionConfig: CompressionConfig | null;
40
+ promptContext: SessionCreatePromptContext;
41
+ selectedHarnessName: string;
42
+ }): Promise<string>;
43
+ //# sourceMappingURL=harnessPhase1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harnessPhase1.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPhase1.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAa1C,OAAO,EAIL,KAAK,2BAA2B,EAEhC,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,IAAI,0BAA0B,EAwBxD,MAAM,gBAAgB,CAAC;AAkBxB,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAyHD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAyB/D;AAg5BD,wBAAgB,gBAAgB,CAAC,OAAO,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