@a5c-ai/babysitter-sdk 0.0.28 → 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.
- package/dist/cli/commands/runIterate.d.ts +32 -0
- package/dist/cli/commands/runIterate.d.ts.map +1 -0
- package/dist/cli/commands/runIterate.js +143 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +50 -485
- package/dist/cli/nodeTaskRunner.d.ts.map +1 -1
- package/dist/cli/nodeTaskRunner.js +39 -0
- package/dist/hooks/dispatcher.d.ts +10 -0
- package/dist/hooks/dispatcher.d.ts.map +1 -0
- package/dist/hooks/dispatcher.js +164 -0
- package/dist/hooks/index.d.ts +15 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/types.d.ts +154 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/runtime/createRun.d.ts.map +1 -1
- package/dist/runtime/createRun.js +18 -0
- package/dist/runtime/hooks/runtime.d.ts +31 -0
- package/dist/runtime/hooks/runtime.d.ts.map +1 -0
- package/dist/runtime/hooks/runtime.js +67 -0
- package/dist/runtime/intrinsics/hook.d.ts +26 -0
- package/dist/runtime/intrinsics/hook.d.ts.map +1 -0
- package/dist/runtime/intrinsics/hook.js +45 -0
- package/dist/runtime/orchestrateIteration.d.ts.map +1 -1
- package/dist/runtime/orchestrateIteration.js +42 -0
- package/dist/runtime/processContext.d.ts.map +1 -1
- package/dist/runtime/processContext.js +2 -0
- package/dist/runtime/types.d.ts +6 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/babysitter/SKILL.md +0 -203
- package/skills/babysitter-score/SKILL.md +0 -35
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hook Intrinsic
|
|
4
|
+
* Allows process files to call hooks directly
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.runHookIntrinsic = runHookIntrinsic;
|
|
8
|
+
const dispatcher_1 = require("../../hooks/dispatcher");
|
|
9
|
+
/**
|
|
10
|
+
* Run a hook from within a process
|
|
11
|
+
* This is exposed as ctx.hook() in process files
|
|
12
|
+
*/
|
|
13
|
+
async function runHookIntrinsic(hookType, payload, context, options) {
|
|
14
|
+
// Add timestamp if not present
|
|
15
|
+
const fullPayload = {
|
|
16
|
+
...payload,
|
|
17
|
+
hookType,
|
|
18
|
+
timestamp: new Date().toISOString(),
|
|
19
|
+
};
|
|
20
|
+
// Add runId from context if not in payload
|
|
21
|
+
if (!("runId" in fullPayload) && context.runId) {
|
|
22
|
+
fullPayload.runId = context.runId;
|
|
23
|
+
}
|
|
24
|
+
// Log the hook invocation
|
|
25
|
+
const label = options?.label || `hook:${hookType}`;
|
|
26
|
+
context.logger?.(`[${label}] Calling hook: ${hookType}`);
|
|
27
|
+
try {
|
|
28
|
+
const result = await (0, dispatcher_1.callHook)({
|
|
29
|
+
hookType,
|
|
30
|
+
payload: fullPayload,
|
|
31
|
+
cwd: context.runDir,
|
|
32
|
+
timeout: options?.timeout,
|
|
33
|
+
throwOnFailure: options?.throwOnFailure,
|
|
34
|
+
});
|
|
35
|
+
// Log the result
|
|
36
|
+
const hookCount = result.executedHooks.length;
|
|
37
|
+
const successCount = result.executedHooks.filter((h) => h.status === "success").length;
|
|
38
|
+
context.logger?.(`[${label}] Hook execution complete: ${successCount}/${hookCount} hooks succeeded`);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
context.logger?.(`[${label}] Hook execution failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrateIteration.d.ts","sourceRoot":"","sources":["../../src/runtime/orchestrateIteration.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,eAAe,EACf,kBAAkB,EAGnB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"orchestrateIteration.d.ts","sourceRoot":"","sources":["../../src/runtime/orchestrateIteration.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,eAAe,EACf,kBAAkB,EAGnB,MAAM,SAAS,CAAC;AAYjB,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CA2HhG"}
|
|
@@ -13,6 +13,7 @@ const processContext_1 = require("./processContext");
|
|
|
13
13
|
const exceptions_1 = require("./exceptions");
|
|
14
14
|
const errorUtils_1 = require("./errorUtils");
|
|
15
15
|
const instrumentation_1 = require("./instrumentation");
|
|
16
|
+
const runtime_1 = require("./hooks/runtime");
|
|
16
17
|
// Use an indirect dynamic import so TypeScript does not downlevel to require() in CommonJS builds.
|
|
17
18
|
const dynamicImportModule = new Function("specifier", "return import(specifier);");
|
|
18
19
|
async function orchestrateIteration(options) {
|
|
@@ -27,6 +28,18 @@ async function orchestrateIteration(options) {
|
|
|
27
28
|
const inputs = options.inputs ?? engine.inputs;
|
|
28
29
|
let finalStatus = "failed";
|
|
29
30
|
const logger = engine.internalContext.logger ?? options.logger;
|
|
31
|
+
// Compute project root for hook calls (parent of .a5c dir where plugins/ is located)
|
|
32
|
+
// runDir is like: /path/to/project/.a5c/runs/<runId>
|
|
33
|
+
// So we need 3 levels up: runs -> .a5c -> project
|
|
34
|
+
const projectRoot = path_1.default.dirname(path_1.default.dirname(path_1.default.dirname(options.runDir)));
|
|
35
|
+
// Call on-iteration-start hook
|
|
36
|
+
await (0, runtime_1.callRuntimeHook)("on-iteration-start", {
|
|
37
|
+
runId: engine.runId,
|
|
38
|
+
iteration: engine.replayCursor.value,
|
|
39
|
+
}, {
|
|
40
|
+
cwd: projectRoot,
|
|
41
|
+
logger,
|
|
42
|
+
});
|
|
30
43
|
try {
|
|
31
44
|
const output = await (0, processContext_1.withProcessContext)(engine.internalContext, () => processFn(inputs, engine.context, options.context));
|
|
32
45
|
const outputRef = await (0, runFiles_1.writeRunOutput)(options.runDir, output);
|
|
@@ -37,6 +50,16 @@ async function orchestrateIteration(options) {
|
|
|
37
50
|
outputRef,
|
|
38
51
|
},
|
|
39
52
|
});
|
|
53
|
+
// Call on-run-complete hook
|
|
54
|
+
await (0, runtime_1.callRuntimeHook)("on-run-complete", {
|
|
55
|
+
runId: engine.runId,
|
|
56
|
+
status: "completed",
|
|
57
|
+
output,
|
|
58
|
+
duration: Date.now() - iterationStartedAt,
|
|
59
|
+
}, {
|
|
60
|
+
cwd: projectRoot,
|
|
61
|
+
logger,
|
|
62
|
+
});
|
|
40
63
|
const result = { status: "completed", output, metadata: createIterationMetadata(engine) };
|
|
41
64
|
finalStatus = result.status;
|
|
42
65
|
return result;
|
|
@@ -57,6 +80,16 @@ async function orchestrateIteration(options) {
|
|
|
57
80
|
eventType: "RUN_FAILED",
|
|
58
81
|
event: { error: failure },
|
|
59
82
|
});
|
|
83
|
+
// Call on-run-fail hook
|
|
84
|
+
await (0, runtime_1.callRuntimeHook)("on-run-fail", {
|
|
85
|
+
runId: engine.runId,
|
|
86
|
+
status: "failed",
|
|
87
|
+
error: failure.message || "Unknown error",
|
|
88
|
+
duration: Date.now() - iterationStartedAt,
|
|
89
|
+
}, {
|
|
90
|
+
cwd: projectRoot,
|
|
91
|
+
logger,
|
|
92
|
+
});
|
|
60
93
|
const result = {
|
|
61
94
|
status: "failed",
|
|
62
95
|
error: failure,
|
|
@@ -72,6 +105,15 @@ async function orchestrateIteration(options) {
|
|
|
72
105
|
runId: engine.runId,
|
|
73
106
|
stepCount: engine.replayCursor.value,
|
|
74
107
|
});
|
|
108
|
+
// Call on-iteration-end hook
|
|
109
|
+
await (0, runtime_1.callRuntimeHook)("on-iteration-end", {
|
|
110
|
+
runId: engine.runId,
|
|
111
|
+
iteration: engine.replayCursor.value,
|
|
112
|
+
status: finalStatus,
|
|
113
|
+
}, {
|
|
114
|
+
cwd: projectRoot,
|
|
115
|
+
logger,
|
|
116
|
+
});
|
|
75
117
|
}
|
|
76
118
|
}
|
|
77
119
|
async function loadProcessFunction(options, defaults, runDir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processContext.d.ts","sourceRoot":"","sources":["../../src/runtime/processContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"processContext.d.ts","sourceRoot":"","sources":["../../src/runtime/processContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAM3E,OAAO,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAC;AAG1D,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB;AAID,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,cAAc,CAAC;IACxB,eAAe,EAAE,sBAAsB,CAAC;CACzC;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,0BAA0B,CAgCzF;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE5G;AAED,wBAAgB,uBAAuB,IAAI,sBAAsB,GAAG,SAAS,CAE5E;AAED,wBAAgB,qBAAqB,IAAI,sBAAsB,CAM9D"}
|
|
@@ -9,6 +9,7 @@ const task_1 = require("./intrinsics/task");
|
|
|
9
9
|
const breakpoint_1 = require("./intrinsics/breakpoint");
|
|
10
10
|
const sleep_1 = require("./intrinsics/sleep");
|
|
11
11
|
const orchestratorTask_1 = require("./intrinsics/orchestratorTask");
|
|
12
|
+
const hook_1 = require("./intrinsics/hook");
|
|
12
13
|
const parallel_1 = require("./intrinsics/parallel");
|
|
13
14
|
const exceptions_1 = require("./exceptions");
|
|
14
15
|
const contextStorage = new async_hooks_1.AsyncLocalStorage();
|
|
@@ -32,6 +33,7 @@ function createProcessContext(init) {
|
|
|
32
33
|
breakpoint: (payload, options) => (0, breakpoint_1.runBreakpointIntrinsic)(payload, internal, options),
|
|
33
34
|
sleepUntil: (target, options) => (0, sleep_1.runSleepIntrinsic)(target, internal, options),
|
|
34
35
|
orchestratorTask: (payload, options) => (0, orchestratorTask_1.runOrchestratorTaskIntrinsic)(payload, internal, options),
|
|
36
|
+
hook: (hookType, payload, options) => (0, hook_1.runHookIntrinsic)(hookType, payload, internal, options),
|
|
35
37
|
parallel: parallelHelpers,
|
|
36
38
|
log: internal.logger,
|
|
37
39
|
};
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ export interface CreateRunOptions {
|
|
|
63
63
|
layoutVersion?: string;
|
|
64
64
|
metadata?: JsonRecord;
|
|
65
65
|
lockOwner?: string;
|
|
66
|
+
logger?: ProcessLogger;
|
|
66
67
|
}
|
|
67
68
|
export interface CreateRunResult {
|
|
68
69
|
runId: string;
|
|
@@ -85,6 +86,11 @@ export interface ProcessContext {
|
|
|
85
86
|
orchestratorTask<TArgs = unknown, TResult = unknown>(payload: TArgs, options?: {
|
|
86
87
|
label?: string;
|
|
87
88
|
}): Promise<TResult>;
|
|
89
|
+
hook(hookType: string, payload: Record<string, unknown>, options?: {
|
|
90
|
+
label?: string;
|
|
91
|
+
timeout?: number;
|
|
92
|
+
throwOnFailure?: boolean;
|
|
93
|
+
}): Promise<import("../hooks/types").HookResult>;
|
|
88
94
|
parallel: ParallelHelpers;
|
|
89
95
|
log?: ProcessLogger;
|
|
90
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAoB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChG,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SA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C;IAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAChF;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAEvE,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE;QACN,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;QACvB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/package.json
CHANGED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: babysitter
|
|
3
|
-
description: Orchestrate .a5c runs via @a5c-ai/babysitter-sdk CLI (create, continue, inspect, task ops). Use when the user asks to orchestrate or babysit a run; delegate breakpoint communication to the babysitter-breakpoint skill.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# babysitter
|
|
7
|
-
|
|
8
|
-
You are **babysitter**—the orchestrator that keeps `.a5c/runs/<runId>/` in a healthy, deterministic state. Follow an event-sourced workflow and use the `@a5c-ai/babysitter-sdk` CLI wherever possible instead of manual scripts. The CLI exposes the surface documented in `docs/cli-examples.md` (`run:create`, `run:status`, `run:events`, `run:continue`, `task:list`, `task:run`, etc.).
|
|
9
|
-
|
|
10
|
-
We operate in an **iterative, quality-gated loop**:
|
|
11
|
-
|
|
12
|
-
1. Run preflight checks (CLI version, global flags) before every session.
|
|
13
|
-
2. Execute a single CLI-driven orchestration step.
|
|
14
|
-
3. Verify the output against the SDK/CLI references (field names, metadata, redaction rules).
|
|
15
|
-
4. Repeat until the run converges (status `completed`/`failed`). Stop immediately if verification fails; fix the drift first.
|
|
16
|
-
|
|
17
|
-
> **CLI alias:** all examples use
|
|
18
|
-
> `CLI="npx -y @a5c-ai/babysitter-sdk"`
|
|
19
|
-
> so you can run commands from repo root like `"$CLI run:status .a5c/runs/<id>"`. Adjust if you install the binary globally.
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 1. Setup & quality gate
|
|
24
|
-
|
|
25
|
-
1. Verify CLI availability **and capture version** (quality gate)
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
$CLI --version
|
|
29
|
-
$CLI run:status .a5c/runs/example --help # sanity check output
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Ensure the help text matches the options documented in `docs/cli-examples.md` (global flags, redaction notes). Record the version in your notes.
|
|
33
|
-
2. Ensure the CLI orchestration output is accessible by running a quick
|
|
34
|
-
`run:status` or `run:events` check before you proceed.
|
|
35
|
-
|
|
36
|
-
Do **not** proceed if the CLI check fails; fix the issue (missing Node, npx resolution, command errors) first—this is your quality gate.
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 2. Core orchestration rules (self-contained)
|
|
41
|
-
|
|
42
|
-
- **CLI-first**: use the babysitter CLI for all run state and orchestration.
|
|
43
|
-
- **Run entry**: you are either resuming a run id or creating a new run from a high-level task.
|
|
44
|
-
- **Main.js approval**: when you create a new run, inspect `.a5c/processes/**` for a suitable starting point, generate `.a5c/runs/<runId>/code/main.js`, and create `.a5c/runs/<runId>/artifacts/process.md`. Before any orchestration, use the `babysitter-breakpoint` skill to request approval of the process, inputs, and `main.js`. Do not proceed until the breakpoint is released with approval. After approval, do not change `main.js` without explicit instruction.
|
|
45
|
-
- **Missing babysitter-breakpoint skill**: if the `babysitter-breakpoint` skill is unavailable, install it from npm by running `npm install -g @a5c-ai/babysitter-breakpoints`, then `breakpoints install-skill --target codex --scope global`. If the `breakpoints` CLI is not on PATH, run `npx -y @a5c-ai/babysitter-breakpoints install-skill --target codex --scope global`. Restart Codex after install.
|
|
46
|
-
- **Do the work**: execute the CLI-provided next action yourself; do not defer
|
|
47
|
-
to agent runners or function templates.
|
|
48
|
-
- **Follow the process**: execute exactly what `code/main.js` (and imported files) prescribe; only deviate when the user explicitly instructs it.
|
|
49
|
-
- **Helper scripts**: if needed, store them in `.a5c/orchestrator_scripts/` or `.a5c/runs/<runId>/orchestrator/`, never as whole-iteration automation.
|
|
50
|
-
- **Journal/state ownership**: do not edit `journal.jsonl` or `state.json` by hand; use the CLI and agent outputs so state stays deterministic.
|
|
51
|
-
- **Wrapper semantics**: if a function call is wrapped with `newRun` or `@run`, create a new run and orchestrate it separately, then report the result to the parent run. If a function list is wrapped with `parallel(...)`, orchestrate them in parallel and return once all are complete.
|
|
52
|
-
- **Sleep handling**: when encountering `sleep(...)`, record start/end via CLI events/notes so the process is resumable.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## 3. Inputs you may receive
|
|
59
|
-
|
|
60
|
-
- **Resume existing run**: user supplies run id (e.g., `run-20260109-101648-dev-build`). All artifacts live under `.a5c/runs/<runId>/`.
|
|
61
|
-
- **Create new run**: user provides a high-level task. You must initialize a fresh run id, craft `code/main.js`, update `inputs.json`, etc.
|
|
62
|
-
|
|
63
|
-
Regardless of the entry point, always:
|
|
64
|
-
|
|
65
|
-
1. Read/understand `.a5c/runs/<runId>/code/main.js` and referenced recipe files (`.a5c/processes/**`).
|
|
66
|
-
2. Review `inputs.json`, `state.json`, and the latest journal entries (via CLI).
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 4. CLI workflows
|
|
71
|
-
|
|
72
|
-
### 3.1 Inspecting a run
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
$CLI run:status .a5c/runs/<runId>
|
|
76
|
-
$CLI run:events .a5c/runs/<runId> --limit 50 --reverse # tail recent events
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Use `--json` when you need machine-readable data. These commands replace manual `tail` or ad-hoc scripts; they also echo deterministic metadata pairs (`stateVersion`, `journalHead`, `pending[...]`).
|
|
80
|
-
|
|
81
|
-
### 3.2 Creating a run
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
$CLI run:create \
|
|
85
|
-
--process-id dev/build \
|
|
86
|
-
--entry .a5c/processes/roles/development/recipes/full_project.js#fullProject \
|
|
87
|
-
--inputs examples/inputs/build.json \
|
|
88
|
-
--run-id "run-$(date -u +%Y%m%d-%H%M%S)-dev-build"
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
The CLI prints the new run id + directory. Immediately open `.a5c/runs/<runId>/code/main.js` to ensure it reflects the requested recipe; if you generate a custom `main.js`, still store it under `code/` and capture the narrative in `artifacts/process.md`. Mermaid diagrams are no longer required.
|
|
92
|
-
|
|
93
|
-
### 3.3 Driving iterations
|
|
94
|
-
|
|
95
|
-
Use `run:step` for single iterations or `run:continue` for full loops:
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
$CLI run:step .a5c/runs/<runId> --json
|
|
99
|
-
$CLI run:continue .a5c/runs/<runId> --auto-node-tasks \
|
|
100
|
-
--auto-node-max 5 \
|
|
101
|
-
--runs-dir .a5c/runs
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
CLI output tells you the status (`waiting/completed/failed`), pending effects, and metadata. If it hits a breakpoint or needs manual input, use the `babysitter-breakpoint` skill; wait for release before continuing. When auto-running node tasks, the CLI logs each `effectId` and scheduler hints so you don’t need to script those paths yourself.
|
|
105
|
-
|
|
106
|
-
> **Quality gate:** compare the JSON payload to the structure documented in `docs/cli-examples.md` §3–§6 (`pending`, `autoRun.executed/pending`, `metadata.stateVersion/pendingEffectsByKind`). If a field is missing or renamed, stop and reconcile with the SDK team before proceeding; otherwise documentation and harnesses will drift.
|
|
107
|
-
|
|
108
|
-
### 3.4 Working with tasks
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
$CLI task:list .a5c/runs/<runId> --pending
|
|
112
|
-
$CLI task:show .a5c/runs/<runId> <effectId> --json
|
|
113
|
-
$CLI task:run .a5c/runs/<runId> <effectId> --dry-run
|
|
114
|
-
$CLI task:run .a5c/runs/<runId> <effectId> \
|
|
115
|
-
--json --verbose \
|
|
116
|
-
-- env BABYSITTER_ALLOW_SECRET_LOGS=true
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Use these instead of manually inspecting `tasks/<effectId>`. Remember: raw payloads remain redacted unless `BABYSITTER_ALLOW_SECRET_LOGS` **and** `--json --verbose` are set. Verify the output includes `payloads: redacted…` whenever the guard is disabled; treat deviations as failures that must be investigated.
|
|
120
|
-
|
|
121
|
-
### 3.5 Journal utilities
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
$CLI run:events .a5c/runs/<runId> --limit 20
|
|
125
|
-
$CLI run:events .a5c/runs/<runId> --reverse --json > tmp/events.json
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
The CLI already writes events for actions, notes, artifacts, sleeps, etc.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## 5. Orchestration loop (CLI-first)
|
|
133
|
-
|
|
134
|
-
1. **Read process + state**
|
|
135
|
-
- `code/main.js`, imported recipes
|
|
136
|
-
- `state.json`, `inputs.json`, plus recent journal entries via `$CLI run:events …`
|
|
137
|
-
2. **Determine next action** from `code/main.js` and/or the CLI orchestration
|
|
138
|
-
output (pending effects, task payloads, or explicit next-step notes).
|
|
139
|
-
3. **Execute the next action** directly in the repo, following the CLI
|
|
140
|
-
instructions verbatim and updating artifacts as needed.
|
|
141
|
-
4. **Journal & state are auto-managed** by the CLI as long as you drive iterations with `run:step` / `run:continue`. Do not edit `journal.jsonl` or `state.json` directly.
|
|
142
|
-
5. **Breakpoints/sleep**: when CLI reports `Awaiting input`, use the `babysitter-breakpoint` skill to collect the missing information and wait for release. For sleeps, log start/end using CLI events; no manual timers.
|
|
143
|
-
|
|
144
|
-
Loop until `status` is `completed` or `failed`. Never edit `journal.jsonl` or `state.json` directly; use CLI commands or agent outputs that update them.
|
|
145
|
-
|
|
146
|
-
> **Iteration verification:** after every CLI loop, run `$CLI run:status .a5c/runs/<runId> --json` and confirm `stateVersion` increased (or stayed steady when waiting), pending counts match expectations, and metadata fields are present (for example `stateVersion`, `pendingEffectsByKind`, and `autoRun`). If not, pause and reconcile before issuing more actions.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## 6. Artifacts & documentation
|
|
151
|
-
|
|
152
|
-
- Store specs, summaries, and diagrams under `.a5c/runs/<runId>/artifacts/`. Reference them in CLI notes (e.g., `$CLI run:events … --note "uploaded part7_spec.md"` currently not supported; instead, add an `artifact` journal entry by running the documented helper script if needed, but prefer CLI notes once available).
|
|
153
|
-
- Provide an updated `process.md` for every `main.js` you craft (Mermaid diagrams have been retired, so no additional `.mermaid.md` artifact is needed).
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## 7. Troubleshooting
|
|
158
|
-
|
|
159
|
-
| Issue | Resolution |
|
|
160
|
-
| --- | --- |
|
|
161
|
-
| CLI missing / npx fails | Verify Node/npm are on PATH and retry `npx -y @a5c-ai/babysitter-sdk --version` |
|
|
162
|
-
| CLI command fails (bad args) | Run `$CLI help` or `$CLI <command> --help` and fix flags |
|
|
163
|
-
| Need alternate runs dir | Pass `--runs-dir <path>` on every CLI invocation |
|
|
164
|
-
| Want JSON output | Append `--json` (many commands support it) |
|
|
165
|
-
| Need to view CLI env | `env | grep BABYSITTER` |
|
|
166
|
-
|
|
167
|
-
If a CLI command crashes mid-iteration, capture the stderr, add a note to the run, and re-run `run:step` once fixed.
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
## 8. Next-action execution
|
|
172
|
-
|
|
173
|
-
When `code/main.js` or the CLI orchestration indicates a next action, execute it
|
|
174
|
-
immediately and record outputs through the CLI-driven workflow. Avoid any
|
|
175
|
-
function-template or agent-runner indirection.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## 9. Example session
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
CLI="npx -y @a5c-ai/babysitter-sdk"
|
|
183
|
-
|
|
184
|
-
# Start work on a new request
|
|
185
|
-
$CLI run:create --process-id dev/project --entry .a5c/processes/... --inputs ./inputs.json
|
|
186
|
-
# => runId=run-20260114-101500-dev-project
|
|
187
|
-
|
|
188
|
-
# Review latest instructions
|
|
189
|
-
$CLI run:status .a5c/runs/run-20260114-101500-dev-project
|
|
190
|
-
$CLI run:events .a5c/runs/run-20260114-101500-dev-project --limit 20 --reverse
|
|
191
|
-
|
|
192
|
-
# Drive the next iteration
|
|
193
|
-
$CLI run:continue .a5c/runs/run-20260114-101500-dev-project --auto-node-tasks --auto-node-max 3
|
|
194
|
-
|
|
195
|
-
# List and run pending tasks if needed
|
|
196
|
-
$CLI task:list .a5c/runs/run-20260114-101500-dev-project --pending
|
|
197
|
-
$CLI task:run .a5c/runs/run-20260114-101500-dev-project ef-node-123 --dry-run
|
|
198
|
-
|
|
199
|
-
# Resume after breakpoint release + feedback
|
|
200
|
-
$CLI run:continue .a5c/runs/run-20260114-101500-dev-project
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Use this pattern anytime the user says “babysit this run” or “orchestrate via babysitter.” Keep the process deterministic by staying inside the CLI wherever it offers a command; only fall back to manual scripts when the CLI surface truly lacks a capability.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: babysitter-score
|
|
3
|
-
allowed-tools: Bash(*) Read Write
|
|
4
|
-
description: Executes the next CLI-orchestrated action when a score step is requested.
|
|
5
|
-
metadata:
|
|
6
|
-
author: a5c-ai
|
|
7
|
-
version: "1.0"
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# babysitter-score
|
|
11
|
-
|
|
12
|
-
You are a next-action executor. The CLI orchestration output is the source of
|
|
13
|
-
truth for what to do next.
|
|
14
|
-
|
|
15
|
-
## Task
|
|
16
|
-
Execute the next action described by the CLI orchestration output. Treat any
|
|
17
|
-
inputs you receive as instructions for that next action.
|
|
18
|
-
|
|
19
|
-
## Constraints
|
|
20
|
-
- Make the smallest correct change set.
|
|
21
|
-
- Follow any `AGENTS.md` instructions in scope.
|
|
22
|
-
- Prefer adding a self-contained demo or runnable artifact when applicable.
|
|
23
|
-
- If there are tests that are cheap and relevant, run them and report results.
|
|
24
|
-
- Do not invent new steps beyond the CLI-provided action.
|
|
25
|
-
|
|
26
|
-
## Deliverable
|
|
27
|
-
- Apply changes directly to the working tree.
|
|
28
|
-
- Write a short work summary to stdout:
|
|
29
|
-
- What changed (files)
|
|
30
|
-
- Why
|
|
31
|
-
- How to run / verify
|
|
32
|
-
- Commands run (if any) and results
|
|
33
|
-
|
|
34
|
-
## Output
|
|
35
|
-
Return a summary of the work and files touched as the final message.
|