@a5c-ai/babysitter-sdk 0.0.29 → 0.0.30

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 (36) hide show
  1. package/dist/cli/commands/runIterate.d.ts +32 -0
  2. package/dist/cli/commands/runIterate.d.ts.map +1 -0
  3. package/dist/cli/commands/runIterate.js +143 -0
  4. package/dist/cli/main.d.ts.map +1 -1
  5. package/dist/cli/main.js +50 -485
  6. package/dist/cli/nodeTaskRunner.d.ts.map +1 -1
  7. package/dist/cli/nodeTaskRunner.js +39 -0
  8. package/dist/hooks/dispatcher.d.ts +10 -0
  9. package/dist/hooks/dispatcher.d.ts.map +1 -0
  10. package/dist/hooks/dispatcher.js +164 -0
  11. package/dist/hooks/index.d.ts +15 -0
  12. package/dist/hooks/index.d.ts.map +1 -0
  13. package/dist/hooks/index.js +19 -0
  14. package/dist/hooks/types.d.ts +154 -0
  15. package/dist/hooks/types.d.ts.map +1 -0
  16. package/dist/hooks/types.js +6 -0
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/runtime/createRun.d.ts.map +1 -1
  21. package/dist/runtime/createRun.js +18 -0
  22. package/dist/runtime/hooks/runtime.d.ts +31 -0
  23. package/dist/runtime/hooks/runtime.d.ts.map +1 -0
  24. package/dist/runtime/hooks/runtime.js +67 -0
  25. package/dist/runtime/intrinsics/hook.d.ts +26 -0
  26. package/dist/runtime/intrinsics/hook.d.ts.map +1 -0
  27. package/dist/runtime/intrinsics/hook.js +45 -0
  28. package/dist/runtime/orchestrateIteration.d.ts.map +1 -1
  29. package/dist/runtime/orchestrateIteration.js +42 -0
  30. package/dist/runtime/processContext.d.ts.map +1 -1
  31. package/dist/runtime/processContext.js +2 -0
  32. package/dist/runtime/types.d.ts +6 -0
  33. package/dist/runtime/types.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/skills/babysitter/SKILL.md +0 -203
  36. package/skills/babysitter-score/SKILL.md +0 -35
@@ -0,0 +1,32 @@
1
+ /**
2
+ * run:iterate command - Execute one orchestration iteration
3
+ *
4
+ * This command:
5
+ * 1. Calls on-iteration-start hooks to get orchestration decisions
6
+ * 2. Returns effects to stdout as JSON
7
+ * 3. External orchestrator (skill) performs the effects
8
+ * 4. Calls on-iteration-end hooks for finalization
9
+ *
10
+ * The command does NOT loop - it handles exactly one iteration.
11
+ */
12
+ export interface RunIterateOptions {
13
+ runDir: string;
14
+ iteration?: number;
15
+ verbose?: boolean;
16
+ json?: boolean;
17
+ }
18
+ export interface RunIterateResult {
19
+ iteration: number;
20
+ status: "executed" | "waiting" | "completed" | "failed" | "none";
21
+ action?: string;
22
+ reason?: string;
23
+ count?: number;
24
+ until?: number;
25
+ metadata?: {
26
+ runId: string;
27
+ processId: string;
28
+ hookStatus?: string;
29
+ };
30
+ }
31
+ export declare function runIterate(options: RunIterateOptions): Promise<RunIterateResult>;
32
+ //# sourceMappingURL=runIterate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runIterate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/runIterate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA8GtF"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /**
3
+ * run:iterate command - Execute one orchestration iteration
4
+ *
5
+ * This command:
6
+ * 1. Calls on-iteration-start hooks to get orchestration decisions
7
+ * 2. Returns effects to stdout as JSON
8
+ * 3. External orchestrator (skill) performs the effects
9
+ * 4. Calls on-iteration-end hooks for finalization
10
+ *
11
+ * The command does NOT loop - it handles exactly one iteration.
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.runIterate = runIterate;
48
+ const path = __importStar(require("path"));
49
+ const runFiles_1 = require("../../storage/runFiles");
50
+ const runtime_1 = require("../../runtime/hooks/runtime");
51
+ async function runIterate(options) {
52
+ const { runDir, verbose } = options;
53
+ // Read run metadata
54
+ const metadata = await (0, runFiles_1.readRunMetadata)(runDir);
55
+ const runId = metadata.runId;
56
+ // Determine iteration number
57
+ // TODO: Read from state.json or journal
58
+ const iteration = options.iteration ?? 1;
59
+ const projectRoot = path.dirname(path.dirname(path.dirname(runDir)));
60
+ if (verbose) {
61
+ console.error(`[run:iterate] Starting iteration ${iteration} for run ${runId}`);
62
+ }
63
+ // === Call on-iteration-start hook ===
64
+ // Hook analyzes state and returns orchestration decisions
65
+ const iterationStartPayload = {
66
+ runId,
67
+ iteration,
68
+ timestamp: new Date().toISOString(),
69
+ };
70
+ const hookResult = await (0, runtime_1.callRuntimeHook)("on-iteration-start", iterationStartPayload, {
71
+ cwd: projectRoot,
72
+ logger: verbose ? ((msg) => console.error(msg)) : undefined,
73
+ });
74
+ // Parse hook output
75
+ let hookDecision = {};
76
+ if (hookResult.output) {
77
+ try {
78
+ hookDecision = typeof hookResult.output === "string"
79
+ ? JSON.parse(hookResult.output)
80
+ : hookResult.output;
81
+ }
82
+ catch (e) {
83
+ if (verbose) {
84
+ console.error(`[run:iterate] Warning: Could not parse hook output:`, hookResult.output);
85
+ }
86
+ }
87
+ }
88
+ const action = hookDecision.action || "none";
89
+ const reason = hookDecision.reason || "unknown";
90
+ const count = hookDecision.count;
91
+ const until = hookDecision.until;
92
+ if (verbose) {
93
+ console.error(`[run:iterate] Hook action: ${action}, reason: ${reason}${count ? `, count: ${count}` : ""}`);
94
+ }
95
+ // Determine result status based on hook action
96
+ let status;
97
+ // Check for terminal state first
98
+ if (reason === "terminal-state") {
99
+ status = hookDecision.status === "failed" ? "failed" : "completed";
100
+ }
101
+ else if (action === "executed-tasks") {
102
+ status = "executed";
103
+ }
104
+ else if (action === "waiting") {
105
+ status = "waiting";
106
+ }
107
+ else if (action === "none") {
108
+ status = "none";
109
+ }
110
+ else {
111
+ // Default to none for unknown actions
112
+ status = "none";
113
+ }
114
+ // === Call on-iteration-end hook ===
115
+ const iterationEndPayload = {
116
+ runId,
117
+ iteration,
118
+ action,
119
+ status,
120
+ reason,
121
+ count,
122
+ timestamp: new Date().toISOString(),
123
+ };
124
+ await (0, runtime_1.callRuntimeHook)("on-iteration-end", iterationEndPayload, {
125
+ cwd: projectRoot,
126
+ logger: verbose ? ((msg) => console.error(msg)) : undefined,
127
+ });
128
+ // Return result
129
+ const result = {
130
+ iteration,
131
+ status,
132
+ action,
133
+ reason,
134
+ count,
135
+ until,
136
+ metadata: {
137
+ runId,
138
+ processId: metadata.processId,
139
+ hookStatus: hookResult.executedHooks?.length > 0 ? "executed" : "none",
140
+ },
141
+ };
142
+ return result;
143
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AA+rDA,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA4CpD,MAAM;EAIvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AA4sCA,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBAyCpD,MAAM;EAIvB"}