@a5c-ai/babysitter-sdk 0.0.183 → 0.0.184-staging.a035b8d6
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/harnessPhase1.d.ts.map +1 -1
- package/dist/cli/commands/harnessPhase1.js +15 -5
- package/dist/cli/commands/harnessPhase2.d.ts.map +1 -1
- package/dist/cli/commands/harnessPhase2.js +27 -11
- package/dist/cli/commands/harnessPrompts.d.ts +2 -2
- package/dist/cli/commands/harnessPrompts.d.ts.map +1 -1
- package/dist/cli/commands/harnessPrompts.js +40 -39
- package/dist/cli/commands/hookRun.d.ts.map +1 -1
- package/dist/cli/commands/hookRun.js +32 -4
- package/dist/cli/commands/instructions.d.ts +19 -0
- package/dist/cli/commands/instructions.d.ts.map +1 -0
- package/dist/cli/commands/instructions.js +158 -0
- package/dist/cli/commands/log.d.ts +22 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +99 -0
- package/dist/cli/commands/session.d.ts +1 -0
- package/dist/cli/commands/session.d.ts.map +1 -1
- package/dist/cli/commands/session.js +50 -10
- package/dist/cli/commands/templates/process-generation-prompt.md +80 -3
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +143 -76
- package/dist/harness/claudeCode.d.ts.map +1 -1
- package/dist/harness/claudeCode.js +4 -0
- package/dist/harness/codex.d.ts.map +1 -1
- package/dist/harness/codex.js +4 -0
- package/dist/harness/cursor.d.ts +35 -0
- package/dist/harness/cursor.d.ts.map +1 -0
- package/dist/harness/cursor.js +799 -0
- package/dist/harness/discovery.d.ts.map +1 -1
- package/dist/harness/discovery.js +14 -2
- package/dist/harness/githubCopilot.d.ts +35 -0
- package/dist/harness/githubCopilot.d.ts.map +1 -0
- package/dist/harness/githubCopilot.js +629 -0
- package/dist/harness/index.d.ts +2 -0
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +5 -1
- package/dist/harness/invoker.d.ts.map +1 -1
- package/dist/harness/invoker.js +2 -1
- package/dist/harness/pi.d.ts.map +1 -1
- package/dist/harness/pi.js +4 -0
- package/dist/harness/registry.d.ts.map +1 -1
- package/dist/harness/registry.js +4 -0
- package/dist/harness/types.d.ts +8 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +11 -0
- package/dist/logging/runLogger.d.ts +83 -0
- package/dist/logging/runLogger.d.ts.map +1 -0
- package/dist/logging/runLogger.js +177 -0
- package/dist/mcp/tools/runs.d.ts.map +1 -1
- package/dist/mcp/tools/runs.js +2 -0
- package/dist/prompts/compose.d.ts +28 -0
- package/dist/prompts/compose.d.ts.map +1 -0
- package/dist/prompts/compose.js +165 -0
- package/dist/prompts/context.d.ts +27 -0
- package/dist/prompts/context.d.ts.map +1 -0
- package/dist/prompts/context.js +198 -0
- package/dist/prompts/index.d.ts +11 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +47 -0
- package/dist/prompts/parts/breakpointHandling.d.ts +8 -0
- package/dist/prompts/parts/breakpointHandling.d.ts.map +1 -0
- package/dist/prompts/parts/breakpointHandling.js +12 -0
- package/dist/prompts/parts/completionProof.d.ts +6 -0
- package/dist/prompts/parts/completionProof.d.ts.map +1 -0
- package/dist/prompts/parts/completionProof.js +10 -0
- package/dist/prompts/parts/criticalRules.d.ts +7 -0
- package/dist/prompts/parts/criticalRules.d.ts.map +1 -0
- package/dist/prompts/parts/criticalRules.js +16 -0
- package/dist/prompts/parts/dependencies.d.ts +6 -0
- package/dist/prompts/parts/dependencies.d.ts.map +1 -0
- package/dist/prompts/parts/dependencies.js +10 -0
- package/dist/prompts/parts/effects.d.ts +6 -0
- package/dist/prompts/parts/effects.d.ts.map +1 -0
- package/dist/prompts/parts/effects.js +10 -0
- package/dist/prompts/parts/index.d.ts +26 -0
- package/dist/prompts/parts/index.d.ts.map +1 -0
- package/dist/prompts/parts/index.js +48 -0
- package/dist/prompts/parts/intentFidelityChecks.d.ts +7 -0
- package/dist/prompts/parts/intentFidelityChecks.d.ts.map +1 -0
- package/dist/prompts/parts/intentFidelityChecks.js +14 -0
- package/dist/prompts/parts/interview.d.ts +6 -0
- package/dist/prompts/parts/interview.d.ts.map +1 -0
- package/dist/prompts/parts/interview.js +18 -0
- package/dist/prompts/parts/iteration.d.ts +6 -0
- package/dist/prompts/parts/iteration.d.ts.map +1 -0
- package/dist/prompts/parts/iteration.js +15 -0
- package/dist/prompts/parts/loopControl.d.ts +11 -0
- package/dist/prompts/parts/loopControl.d.ts.map +1 -0
- package/dist/prompts/parts/loopControl.js +22 -0
- package/dist/prompts/parts/nonNegotiables.d.ts +7 -0
- package/dist/prompts/parts/nonNegotiables.d.ts.map +1 -0
- package/dist/prompts/parts/nonNegotiables.js +14 -0
- package/dist/prompts/parts/processCreation.d.ts +6 -0
- package/dist/prompts/parts/processCreation.d.ts.map +1 -0
- package/dist/prompts/parts/processCreation.js +24 -0
- package/dist/prompts/parts/processGuidelines.d.ts +7 -0
- package/dist/prompts/parts/processGuidelines.d.ts.map +1 -0
- package/dist/prompts/parts/processGuidelines.js +11 -0
- package/dist/prompts/parts/quickReference.d.ts +6 -0
- package/dist/prompts/parts/quickReference.d.ts.map +1 -0
- package/dist/prompts/parts/quickReference.js +17 -0
- package/dist/prompts/parts/recovery.d.ts +7 -0
- package/dist/prompts/parts/recovery.d.ts.map +1 -0
- package/dist/prompts/parts/recovery.js +11 -0
- package/dist/prompts/parts/resultsPosting.d.ts +7 -0
- package/dist/prompts/parts/resultsPosting.d.ts.map +1 -0
- package/dist/prompts/parts/resultsPosting.js +11 -0
- package/dist/prompts/parts/runCreation.d.ts +7 -0
- package/dist/prompts/parts/runCreation.d.ts.map +1 -0
- package/dist/prompts/parts/runCreation.js +53 -0
- package/dist/prompts/parts/seeAlso.d.ts +7 -0
- package/dist/prompts/parts/seeAlso.d.ts.map +1 -0
- package/dist/prompts/parts/seeAlso.js +11 -0
- package/dist/prompts/parts/taskExamples.d.ts +7 -0
- package/dist/prompts/parts/taskExamples.d.ts.map +1 -0
- package/dist/prompts/parts/taskExamples.js +11 -0
- package/dist/prompts/parts/taskKinds.d.ts +6 -0
- package/dist/prompts/parts/taskKinds.d.ts.map +1 -0
- package/dist/prompts/parts/taskKinds.js +17 -0
- package/dist/prompts/parts/userProfile.d.ts +7 -0
- package/dist/prompts/parts/userProfile.d.ts.map +1 -0
- package/dist/prompts/parts/userProfile.js +11 -0
- package/dist/prompts/templateRenderer.d.ts +18 -0
- package/dist/prompts/templateRenderer.d.ts.map +1 -0
- package/dist/prompts/templateRenderer.js +131 -0
- package/dist/prompts/templates/breakpoint-handling.md +101 -0
- package/dist/prompts/templates/completion-proof.md +13 -0
- package/dist/prompts/templates/critical-rules.md +57 -0
- package/dist/prompts/templates/dependencies.md +9 -0
- package/dist/prompts/templates/effects.md +39 -0
- package/dist/prompts/templates/intent-fidelity-checks.md +14 -0
- package/dist/prompts/templates/interview.md +65 -0
- package/dist/prompts/templates/iteration.md +41 -0
- package/dist/prompts/templates/loop-control.md +54 -0
- package/dist/prompts/templates/non-negotiables.md +11 -0
- package/dist/prompts/templates/process-creation.md +61 -0
- package/dist/prompts/templates/process-guidelines.md +88 -0
- package/dist/prompts/templates/quick-reference.md +35 -0
- package/dist/prompts/templates/recovery.md +20 -0
- package/dist/prompts/templates/results-posting.md +69 -0
- package/dist/prompts/templates/run-creation.md +36 -0
- package/dist/prompts/templates/see-also.md +4 -0
- package/dist/prompts/templates/task-examples.md +72 -0
- package/dist/prompts/templates/task-kinds.md +60 -0
- package/dist/prompts/templates/user-profile.md +48 -0
- package/dist/prompts/types.d.ts +105 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +7 -0
- package/dist/runtime/commitEffectResult.js +3 -0
- package/dist/runtime/intrinsics/breakpoint.d.ts +2 -2
- package/dist/runtime/intrinsics/breakpoint.d.ts.map +1 -1
- package/dist/runtime/intrinsics/breakpoint.js +25 -1
- package/dist/runtime/intrinsics/parallel.d.ts.map +1 -1
- package/dist/runtime/intrinsics/parallel.js +9 -0
- package/dist/runtime/intrinsics/task.js +1 -1
- package/dist/runtime/processContext.d.ts +14 -0
- package/dist/runtime/processContext.d.ts.map +1 -1
- package/dist/runtime/processContext.js +91 -5
- package/dist/runtime/replay/createReplayEngine.d.ts.map +1 -1
- package/dist/runtime/replay/createReplayEngine.js +82 -1
- package/dist/runtime/replay/effectIndex.d.ts +3 -1
- package/dist/runtime/replay/effectIndex.d.ts.map +1 -1
- package/dist/runtime/replay/effectIndex.js +9 -2
- package/dist/runtime/types.d.ts +20 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/storage/lock.d.ts.map +1 -1
- package/dist/storage/lock.js +11 -0
- package/dist/tasks/types.d.ts +9 -0
- package/dist/tasks/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/cli/commands/runExecuteTasks.d.ts +0 -42
- package/dist/cli/commands/runExecuteTasks.d.ts.map +0 -1
- package/dist/cli/commands/runExecuteTasks.js +0 -377
|
@@ -1 +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;
|
|
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;AA85BD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAmDzE;AAED,wBAAgB,sCAAsC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAU/F;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgBrE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAwBhG;AAwGD,wBAAgB,oCAAoC,CAAC,IAAI,EAAE;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,0BAA0B,CAAC;IAC1C,mBAAmB,EAAE,2BAA2B,CAAC;CAClD,GAAG,MAAM,CA+ET;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CA4BT;AAkND,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,EAAE,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,aAAa,EAAE,0BAA0B,CAAC;IAC1C,mBAAmB,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,CAAC,CAygBlB"}
|
|
@@ -742,7 +742,7 @@ async function validateProcessExport(filePath) {
|
|
|
742
742
|
category: harnessUtils_1.ErrorCategory.Validation,
|
|
743
743
|
nextSteps: [
|
|
744
744
|
"Every TaskDef returned from defineTask(...) must include a top-level kind string",
|
|
745
|
-
"Use kind: \"agent\" with agent: { ... }, kind: \"shell\" with shell: { command: ... }, or kind
|
|
745
|
+
"Use kind: \"agent\" with agent: { ... }, kind: \"shell\" with shell: { command: ... }, or another supported effect kind that the agent will execute and post manually",
|
|
746
746
|
],
|
|
747
747
|
});
|
|
748
748
|
}
|
|
@@ -754,7 +754,7 @@ async function validateProcessExport(filePath) {
|
|
|
754
754
|
category: harnessUtils_1.ErrorCategory.Validation,
|
|
755
755
|
nextSteps: [
|
|
756
756
|
"Match each task's kind to its body shape",
|
|
757
|
-
"Agent tasks must use kind: \"agent\"
|
|
757
|
+
"Agent tasks must use kind: \"agent\" and shell tasks must use kind: \"shell\". Do not generate node task definitions in authored processes",
|
|
758
758
|
],
|
|
759
759
|
});
|
|
760
760
|
}
|
|
@@ -768,6 +768,16 @@ async function validateProcessExport(filePath) {
|
|
|
768
768
|
],
|
|
769
769
|
});
|
|
770
770
|
}
|
|
771
|
+
const nodeTaskIds = getDefineTaskIdsByKind(source, "node");
|
|
772
|
+
if (nodeTaskIds.length > 0) {
|
|
773
|
+
throw new harnessUtils_1.BabysitterRuntimeError("InvalidProcessSourceError", `Process file at ${filePath} defines forbidden node tasks: ${nodeTaskIds.join(", ")}`, {
|
|
774
|
+
category: harnessUtils_1.ErrorCategory.Validation,
|
|
775
|
+
nextSteps: [
|
|
776
|
+
"Replace each node task with an agent or skill task",
|
|
777
|
+
"If the work is a concrete existing CLI command, use a shell task and have the orchestrating agent execute it and post the result",
|
|
778
|
+
],
|
|
779
|
+
});
|
|
780
|
+
}
|
|
771
781
|
const invalidCtxTaskTargets = getInvalidCtxTaskTargets(source);
|
|
772
782
|
if (invalidCtxTaskTargets.length > 0) {
|
|
773
783
|
throw new harnessUtils_1.BabysitterRuntimeError("InvalidProcessSourceError", `Process file at ${filePath} calls ctx.task(...) with values that are not DefinedTask bindings created via defineTask(...): ${invalidCtxTaskTargets.join(", ")}`, {
|
|
@@ -1195,7 +1205,7 @@ function buildExternalProcessConformancePrompt(args) {
|
|
|
1195
1205
|
"- Put instructions inside `agent.prompt.task`, `agent.prompt.instructions`, and related prompt fields rather than top-level `instructions` fields.",
|
|
1196
1206
|
"- Agent tasks must use `kind: \"agent\"` with `agent: { name, prompt, outputSchema }`.",
|
|
1197
1207
|
"- Shell tasks must use `kind: \"shell\"` with `shell: { command: \"...\" }`.",
|
|
1198
|
-
"-
|
|
1208
|
+
"- Do not introduce `kind: \"node\"` task definitions in generated or repaired processes. If logic would have been a node task, convert it to an `agent` or `skill` task instead.",
|
|
1199
1209
|
"- Any task passed to `ctx.task(...)` must be a DefinedTask created via `defineTask(...)`; do not pass plain object task definitions or ad-hoc task objects.",
|
|
1200
1210
|
"- The exported `process(inputs, ctx)` function must run tasks with `await ctx.task(definedTask, args)`; do not invent alternate task runners.",
|
|
1201
1211
|
"- Inside the named `process(inputs, ctx)` export, never reference Node's global process object as `process.*`; use `globalThis.process` or an imported alias like `nodeProcess` instead.",
|
|
@@ -1229,7 +1239,7 @@ function buildInternalProcessConformancePrompt(args) {
|
|
|
1229
1239
|
"- If the process needs the workspace root, do not assume `ctx.workspaceDir` or `ctx.cwd` exists. Resolve it from the module location using `import.meta.url`, for example with `path.dirname(fileURLToPath(import.meta.url))`.",
|
|
1230
1240
|
"- Agent tasks must use `kind: \"agent\"` with `agent: { name, prompt, outputSchema }`.",
|
|
1231
1241
|
"- Shell tasks must use `kind: \"shell\"` with `shell: { command: \"...\" }`.",
|
|
1232
|
-
"-
|
|
1242
|
+
"- Do not introduce `kind: \"node\"` task definitions in generated or repaired processes. If logic would have been a node task, convert it to an `agent` or `skill` task instead.",
|
|
1233
1243
|
"- The exported `process(inputs, ctx)` function must call tasks with `await ctx.task(definedTask, args)`.",
|
|
1234
1244
|
"- Use `babysitter_write_process_definition` to rewrite the full file to the exact target path.",
|
|
1235
1245
|
"- After rewriting the file, call `babysitter_report_process_definition` exactly once with the same path.",
|
|
@@ -1502,7 +1512,7 @@ async function runProcessDefinitionPhase(args) {
|
|
|
1502
1512
|
})));
|
|
1503
1513
|
const workspaceAssessment = await assessWorkspaceForExternalAuthoring(args.workspace);
|
|
1504
1514
|
writeVerboseData("phase1 workspace assessment", workspaceAssessment);
|
|
1505
|
-
const processDefinitionSystemPrompt = (0, harnessPrompts_1.buildProcessDefinitionSystemPrompt)(args.outputPath, args.promptContext);
|
|
1515
|
+
const processDefinitionSystemPrompt = await (0, harnessPrompts_1.buildProcessDefinitionSystemPrompt)(args.outputPath, args.promptContext, args.interactive);
|
|
1506
1516
|
const initialMetaPrompt = (0, harnessPrompts_1.buildProcessDefinitionUserPrompt)(args.prompt, args.outputPath, {
|
|
1507
1517
|
interactive: args.interactive,
|
|
1508
1518
|
workspaceAssessment: workspaceAssessment.kind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harnessPhase2.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPhase2.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAkB1C,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAI3B,KAAK,oBAAoB,IAAI,0BAA0B,EACvD,KAAK,YAAY,EA8BjB,eAAe,EAIhB,MAAM,gBAAgB,CAAC;AAaxB,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IACP,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC9C,EACD,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,EAClC,UAAU,CAAC,EAAE,sBAAsB,EAAE,EACrC,EAAE,CAAC,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,EAC9B,IAAI,CAAC,EAAE,OAAO,EACd,sBAAsB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,GACtE,OAAO,CAAC,mBAAmB,CAAC,CAwO9B;
|
|
1
|
+
{"version":3,"file":"harnessPhase2.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPhase2.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAkB1C,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAI3B,KAAK,oBAAoB,IAAI,0BAA0B,EACvD,KAAK,YAAY,EA8BjB,eAAe,EAIhB,MAAM,gBAAgB,CAAC;AAaxB,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IACP,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC9C,EACD,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,EAClC,UAAU,CAAC,EAAE,sBAAsB,EAAE,EACrC,EAAE,CAAC,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,EAC9B,IAAI,CAAC,EAAE,OAAO,EACd,sBAAsB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,GACtE,OAAO,CAAC,mBAAmB,CAAC,CAwO9B;AAkOD,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,EAAE,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,sBAAsB,EAAE,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,aAAa,EAAE,0BAA0B,CAAC;IAC1C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,CA22ClB"}
|
|
@@ -396,6 +396,9 @@ function parseExplicitToolResultValue(args) {
|
|
|
396
396
|
}
|
|
397
397
|
return undefined;
|
|
398
398
|
}
|
|
399
|
+
function hasExplicitToolResultValue(args) {
|
|
400
|
+
return args.valueJson !== undefined || args.valueText !== undefined;
|
|
401
|
+
}
|
|
399
402
|
// ── Main Phase 2 Entry Point ─────────────────────────────────────────
|
|
400
403
|
async function runOrchestrationPhase(args) {
|
|
401
404
|
const processId = path.basename(args.processPath, path.extname(args.processPath));
|
|
@@ -430,6 +433,7 @@ async function runOrchestrationPhase(args) {
|
|
|
430
433
|
},
|
|
431
434
|
prompt: args.prompt,
|
|
432
435
|
inputs: args.prompt ? { prompt: args.prompt } : undefined,
|
|
436
|
+
...(args.interactive === false ? { metadata: { nonInteractive: true } } : {}),
|
|
433
437
|
});
|
|
434
438
|
state.runId = created.runId;
|
|
435
439
|
state.runDir = created.runDir;
|
|
@@ -673,6 +677,7 @@ async function runOrchestrationPhase(args) {
|
|
|
673
677
|
inputs: effectivePrompt
|
|
674
678
|
? { prompt: effectivePrompt }
|
|
675
679
|
: undefined,
|
|
680
|
+
...(args.interactive === false ? { metadata: { nonInteractive: true } } : {}),
|
|
676
681
|
});
|
|
677
682
|
state.runId = result.runId;
|
|
678
683
|
state.runDir = result.runDir;
|
|
@@ -1056,23 +1061,34 @@ async function runOrchestrationPhase(args) {
|
|
|
1056
1061
|
const startedAt = new Date().toISOString();
|
|
1057
1062
|
let effectResult = state.pendingEffectResults.get(params.effectId);
|
|
1058
1063
|
if (params.status) {
|
|
1059
|
-
const
|
|
1060
|
-
params.
|
|
1064
|
+
const explicitValueProvided = hasExplicitToolResultValue({
|
|
1065
|
+
valueJson: params.valueJson,
|
|
1066
|
+
valueText: params.valueText,
|
|
1067
|
+
});
|
|
1068
|
+
const explicitValue = explicitValueProvided
|
|
1069
|
+
? parseExplicitToolResultValue({
|
|
1070
|
+
valueJson: params.valueJson,
|
|
1071
|
+
valueText: params.valueText,
|
|
1072
|
+
})
|
|
1073
|
+
: undefined;
|
|
1074
|
+
const hasExplicitPayload = explicitValueProvided ||
|
|
1061
1075
|
params.error !== undefined ||
|
|
1062
1076
|
params.stdout !== undefined ||
|
|
1063
1077
|
params.stderr !== undefined;
|
|
1064
1078
|
if (!effectResult || hasExplicitPayload) {
|
|
1079
|
+
const nextValue = explicitValueProvided ? explicitValue : effectResult?.value;
|
|
1080
|
+
if (params.status === "ok" && nextValue === undefined) {
|
|
1081
|
+
throw new harnessUtils_1.BabysitterRuntimeError("EffectResultValueMissing", `Explicit ok result for ${params.effectId} is missing a value payload.`, { category: harnessUtils_1.ErrorCategory.Validation });
|
|
1082
|
+
}
|
|
1065
1083
|
effectResult = {
|
|
1066
1084
|
status: params.status,
|
|
1067
|
-
value:
|
|
1068
|
-
valueJson: params.valueJson,
|
|
1069
|
-
valueText: params.valueText,
|
|
1070
|
-
}),
|
|
1085
|
+
value: nextValue,
|
|
1071
1086
|
error: params.status === "error"
|
|
1072
|
-
? new Error(params.error ??
|
|
1087
|
+
? new Error(params.error ??
|
|
1088
|
+
(effectResult?.error instanceof Error ? effectResult.error.message : "Effect failed"))
|
|
1073
1089
|
: undefined,
|
|
1074
|
-
stdout: params.stdout,
|
|
1075
|
-
stderr: params.stderr,
|
|
1090
|
+
stdout: params.stdout ?? effectResult?.stdout,
|
|
1091
|
+
stderr: params.stderr ?? effectResult?.stderr,
|
|
1076
1092
|
};
|
|
1077
1093
|
}
|
|
1078
1094
|
else if (params.status !== effectResult.status) {
|
|
@@ -1275,7 +1291,7 @@ async function runOrchestrationPhase(args) {
|
|
|
1275
1291
|
uiContext: args.interactive && args.rl
|
|
1276
1292
|
? (0, harnessUtils_1.createReadlineAskUserQuestionUiContext)(args.rl)
|
|
1277
1293
|
: undefined,
|
|
1278
|
-
appendSystemPrompt: [(0, harnessPrompts_1.buildOrchestrationSystemPrompt)(args.selectedHarnessName, args.promptContext)],
|
|
1294
|
+
appendSystemPrompt: [(0, harnessPrompts_1.buildOrchestrationSystemPrompt)(args.selectedHarnessName, args.promptContext, args.interactive)],
|
|
1279
1295
|
ephemeral: true,
|
|
1280
1296
|
});
|
|
1281
1297
|
writeVerbose(`[phase2 setup] harness=${args.selectedHarnessName} workspace=${path.resolve(args.workspace ?? process.cwd())} model=${args.model ?? "(default)"} processPath=${path.resolve(args.processPath)}`);
|
|
@@ -1283,7 +1299,7 @@ async function runOrchestrationPhase(args) {
|
|
|
1283
1299
|
name: tool.name,
|
|
1284
1300
|
label: tool.label,
|
|
1285
1301
|
})));
|
|
1286
|
-
writeVerboseData("phase2 system prompt", (0, harnessPrompts_1.buildOrchestrationSystemPrompt)(args.selectedHarnessName, args.promptContext));
|
|
1302
|
+
writeVerboseData("phase2 system prompt", (0, harnessPrompts_1.buildOrchestrationSystemPrompt)(args.selectedHarnessName, args.promptContext, args.interactive));
|
|
1287
1303
|
(0, harnessUtils_1.emitProgress)({ phase: "2", status: "started", harness: args.selectedHarnessName }, args.json, args.verbose);
|
|
1288
1304
|
let unsubscribe = null;
|
|
1289
1305
|
try {
|
|
@@ -23,9 +23,9 @@ export interface ProcessDefinitionUserPromptOptions {
|
|
|
23
23
|
workspaceAssessment?: "empty" | "non-empty";
|
|
24
24
|
workspaceEntries?: string[];
|
|
25
25
|
}
|
|
26
|
-
export declare function buildProcessDefinitionSystemPrompt(outputPath: string, context: HarnessPromptContext): string
|
|
26
|
+
export declare function buildProcessDefinitionSystemPrompt(outputPath: string, context: HarnessPromptContext, interactive?: boolean | undefined): Promise<string>;
|
|
27
27
|
export declare function buildProcessDefinitionUserPrompt(userPrompt: string, outputPath: string, options?: ProcessDefinitionUserPromptOptions): string;
|
|
28
|
-
export declare function buildOrchestrationSystemPrompt(selectedHarnessName: string, context: HarnessPromptContext): string;
|
|
28
|
+
export declare function buildOrchestrationSystemPrompt(selectedHarnessName: string, context: HarnessPromptContext, interactive?: boolean | undefined): string;
|
|
29
29
|
export declare function buildOrchestrationBootstrapPrompt(processPath: string, userPrompt: string | undefined, maxIterations: number): string;
|
|
30
30
|
export declare function buildOrchestrationTurnPrompt(args: {
|
|
31
31
|
processPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harnessPrompts.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPrompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"harnessPrompts.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/harnessPrompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAQlE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAC9C,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAED,mDAAmD;AACnD,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE9D,MAAM,WAAW,kCAAkC;IACjD,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAkFD,wBAAsB,kCAAkC,CACtD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,GAChC,OAAO,CAAC,MAAM,CAAC,CA4DjB;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,kCAAkC,GAC3C,MAAM,CAyDR;AAED,wBAAgB,8BAA8B,CAC5C,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,oBAAoB,EAC7B,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,GAChC,MAAM,CA8BR;AAED,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,MAAM,GACpB,MAAM,CAWR;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAgDT"}
|
|
@@ -5,6 +5,9 @@ exports.buildProcessDefinitionUserPrompt = buildProcessDefinitionUserPrompt;
|
|
|
5
5
|
exports.buildOrchestrationSystemPrompt = buildOrchestrationSystemPrompt;
|
|
6
6
|
exports.buildOrchestrationBootstrapPrompt = buildOrchestrationBootstrapPrompt;
|
|
7
7
|
exports.buildOrchestrationTurnPrompt = buildOrchestrationTurnPrompt;
|
|
8
|
+
const context_1 = require("../../prompts/context");
|
|
9
|
+
const compose_1 = require("../../prompts/compose");
|
|
10
|
+
const active_1 = require("../../processLibrary/active");
|
|
8
11
|
function formatHarnessCatalog(context) {
|
|
9
12
|
const lines = ["Discovered harnesses:"];
|
|
10
13
|
for (const harness of context.discoveredHarnesses) {
|
|
@@ -55,12 +58,14 @@ function formatHarnessAssignmentGuidance(context) {
|
|
|
55
58
|
return [
|
|
56
59
|
"Harness assignment guidance:",
|
|
57
60
|
`- Only assign installed harness names. Installed harnesses: ${installedList}.`,
|
|
58
|
-
"- Default `agent`, `node`, and `orchestrator_task` work to the internal PI worker.
|
|
61
|
+
"- Default `agent`, legacy `node`, and `orchestrator_task` work to the internal PI worker. Prefer `task.execution.harness` to route a task to a specific installed harness. The legacy `task.metadata.harness` field is still supported but `execution.harness` takes precedence when both are present.",
|
|
59
62
|
"- Treat `pi` / `oh-my-pi` as the internal harness. Its default worker mode is native/local PI execution with isolation disabled unless the task opts into stronger guardrails.",
|
|
63
|
+
"- Shell and legacy node effects must be executed intentionally by the orchestrating agent and then posted via `task:post`; never assume a host-side auto-executor exists.",
|
|
60
64
|
"- Shell effects run through the internal PI worker even when orchestration is bound to an external CLI harness. Keep shell work on that worker by default.",
|
|
61
65
|
"- Do not set `task.metadata.bashSandbox`, `task.metadata.isolated`, or `task.metadata.enableCompaction` for ordinary internal PI work. Leave them unset unless the task truly requires stronger guardrails or long-running compaction.",
|
|
62
66
|
"- For risky shell or system-changing subtasks that truly need stronger guardrails, encode them explicitly in task metadata: `bashSandbox: \"secure\"` to opt into AgentSH, `isolated: true` to disable repo/global extensions and skills, and `enableCompaction: true` when a long-running internal worker needs compaction.",
|
|
63
67
|
"- Treat `claude-code`, `codex`, `gemini-cli`, and other external CLIs as text-agent harnesses. Use them only when their behavior is materially better for that task.",
|
|
68
|
+
"- Tasks may include an `execution` field with `model`, `harness`, and `permissions`. `execution.model` is universal (plugins and internal harness). `execution.harness` and `execution.permissions` are only used by the internal harness (`harness:create-run`) and ignored by plugins.",
|
|
64
69
|
"- External CLI harnesses do not inherit AgentSH protection for their own internal shell or tool execution. Route security-sensitive shell work through the internal PI worker instead of assuming the external harness is guarded.",
|
|
65
70
|
context.selectedHarnessName
|
|
66
71
|
? `- The selected orchestration binding harness for this run is ${context.selectedHarnessName}.`
|
|
@@ -77,7 +82,26 @@ function formatSharedContext(context) {
|
|
|
77
82
|
...formatHarnessAssignmentGuidance(context),
|
|
78
83
|
];
|
|
79
84
|
}
|
|
80
|
-
function buildProcessDefinitionSystemPrompt(outputPath, context) {
|
|
85
|
+
async function buildProcessDefinitionSystemPrompt(outputPath, context, interactive) {
|
|
86
|
+
// Resolve the active process-library root for the PI context
|
|
87
|
+
let processLibraryRoot;
|
|
88
|
+
let processLibraryReferenceRoot;
|
|
89
|
+
try {
|
|
90
|
+
const resolved = await (0, active_1.resolveActiveProcessLibrary)();
|
|
91
|
+
if (resolved.binding?.dir) {
|
|
92
|
+
processLibraryRoot = resolved.binding.dir;
|
|
93
|
+
processLibraryReferenceRoot = (0, active_1.getDefaultProcessLibrarySpec)().referenceRoot;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// No binding — templates will fall back to manual instructions
|
|
98
|
+
}
|
|
99
|
+
const piCtx = (0, context_1.createPiContext)({
|
|
100
|
+
interactive,
|
|
101
|
+
processLibraryRoot,
|
|
102
|
+
processLibraryReferenceRoot,
|
|
103
|
+
});
|
|
104
|
+
const composedInstructions = (0, compose_1.composeProcessCreatePrompt)(piCtx);
|
|
81
105
|
return [
|
|
82
106
|
"You are the babysitter harness:create-run phase 1 agent.",
|
|
83
107
|
"Your job is to turn the user's intent into a concrete babysitter process definition before any run is created or bound.",
|
|
@@ -88,33 +112,21 @@ function buildProcessDefinitionSystemPrompt(outputPath, context) {
|
|
|
88
112
|
"- Use the AskUserQuestion tool when clarification is useful. Ask focused, high-signal questions in batches when possible.",
|
|
89
113
|
"- Before authoring the process in any mode, resolve the active shared process-library and conduct a real search against it. In this built-in PI path, use `babysitter_resolve_process_library`, `babysitter_search_process_library`, and `babysitter_read_process_library_file`; those tools are the internal `harness:create-run` harness surface for process-library work. Outside this built-in path, use `babysitter process-library:active --json`, then search the returned `binding.dir`. Do not skip this process-library search step.",
|
|
90
114
|
"- Treat `binding.dir` as the active process-library root that must be searched first. If you need the cloned repo root itself for adjacent material, use `defaultSpec.cloneDir`. Treat `reference/` under the active root or `defaultSpec.referenceRoot` as the canonical reference area.",
|
|
91
|
-
"- In interactive mode, follow a real interview phase: inspect the repo/workspace state first, inspect the most relevant process-library references through the active binding, then ask only the next highest-signal AskUserQuestion when material ambiguity remains. Do not plan more than one interview step ahead.",
|
|
92
|
-
"- In non-interactive mode, skip user questions but still parse the request, inspect the repo/workspace structure, resolve the active process-library root, and search that active library for the most relevant specialization or methodology before authoring the process.",
|
|
93
115
|
"- Research the workspace before finalizing the process. Use your available read/search/bash/write tools as needed.",
|
|
94
116
|
"- Treat the provided workspace as the only relevant filesystem root unless the user explicitly points you somewhere else.",
|
|
95
117
|
"- You may inspect local babysitter process references when they materially improve the process design. Prefer project `.a5c/processes/`, the active process-library root returned in `binding.dir`, the cloned repo root returned in `defaultSpec.cloneDir` when you need adjacent reference material, local plugin paths such as `plugins/babysitter/skills/babysit/process/`, repository `library/` materials, and local babysitter discover/profile CLI commands when available.",
|
|
96
|
-
"- If you use user profile context, read it through the babysitter CLI only, for example `babysitter profile:read --user --json`. Never import or call SDK profile helpers directly from generated processes or task instructions.",
|
|
97
118
|
"- Use babysitter_write_process_definition to write the final JavaScript process file to the exact output path provided below.",
|
|
98
119
|
"- The module must export a named `async function process(inputs, ctx)`.",
|
|
99
120
|
"- The process must orchestrate the work through babysitter tasks instead of doing the main implementation directly in `process(inputs, ctx)`.",
|
|
100
121
|
"- Define at least one task with `defineTask(...)`, and invoke tasks from `process(inputs, ctx)` via `await ctx.task(...)`.",
|
|
101
|
-
"- Default every task to the internal PI worker. Omit `task.metadata.harness` unless a task must explicitly override that default.",
|
|
102
|
-
"- If you define tasks with `defineTask(...)`, every returned TaskDef must include a top-level `kind` field.",
|
|
103
|
-
"- Agent tasks must use `kind: \"agent\"` with `agent: { name, prompt, outputSchema }`; shell tasks must use `kind: \"shell\"` with `shell: { command: \"...\" }`; node tasks must use `kind: \"node\"` with `node: { entry, args? }`.",
|
|
104
|
-
"- Call defined tasks with `await ctx.task(definedTask, args)`; do not invent alternate task runners.",
|
|
105
|
-
"- At least one defined task must be an `agent` task for the main work. Shell tasks are for concrete runnable commands only.",
|
|
106
122
|
"- Any task passed to `ctx.task(...)` must be a DefinedTask created via `defineTask(...)`; never pass plain object task definitions or ad-hoc task objects.",
|
|
107
123
|
"- Inside that named `process(inputs, ctx)` export, do not reference Node's global process object as `process.*`; use `globalThis.process` or an imported alias like `nodeProcess` instead.",
|
|
108
124
|
"- If the process needs the workspace root, do not assume `ctx.workspaceDir` or `ctx.cwd` exists in runtime context. Resolve it from the module location using `import.meta.url`, for example with `path.dirname(fileURLToPath(import.meta.url))`.",
|
|
109
125
|
"- Keep the generated module syntactically valid ESM. If you embed HTML/CSS/JS asset contents inside the process source, do not use raw nested template literals; prefer arrays joined with \"\\n\", String.raw, or escaped inner backticks and \\${...} sequences.",
|
|
110
126
|
"- The generated process must directly execute the user's requested work. Do not generate a meta-process that writes another babysitter process unless the user explicitly asked for process authoring.",
|
|
111
|
-
"- Prefer modular, reusable process composition when possible. Reference relevant methodologies, skills, agents, or prior processes before inventing a process structure from scratch.",
|
|
112
|
-
"- Prefer processes with explicit milestones, quality gates, verification loops, and convergence on the actual user request.",
|
|
113
127
|
"- After the file is written through babysitter_write_process_definition, call babysitter_report_process_definition exactly once with the final path and a concise summary.",
|
|
114
128
|
"- Do not claim completion in plain text without calling babysitter_report_process_definition.",
|
|
115
129
|
"- If different tasks should run on different harnesses, encode that in the process definition rather than leaving it implicit.",
|
|
116
|
-
"- Do not set `task.metadata.bashSandbox`, `task.metadata.isolated`, or `task.metadata.enableCompaction` for ordinary internal PI tasks. Leave them unset unless the task truly requires stronger guardrails or long-running compaction.",
|
|
117
|
-
"- If a task truly needs stronger internal guardrails, encode them explicitly in task metadata instead of assuming every internal task is secure or isolated by default.",
|
|
118
130
|
"",
|
|
119
131
|
"Process Library Activation:",
|
|
120
132
|
"- You MUST call `babysitter_resolve_process_library` to bootstrap and resolve the active process-library root before authoring the process. This is non-optional.",
|
|
@@ -122,22 +134,9 @@ function buildProcessDefinitionSystemPrompt(outputPath, context) {
|
|
|
122
134
|
"- If the cloned repo root is needed for adjacent reference material, use `defaultSpec.cloneDir`.",
|
|
123
135
|
"- Use `babysitter_search_process_library` and `babysitter_read_process_library_file` to search the library. Do not skip the search step.",
|
|
124
136
|
"",
|
|
125
|
-
"
|
|
126
|
-
"- In interactive mode, follow a structured multi-step interview: first inspect the repo/workspace state, then search the process library for relevant specializations, methodologies, skills, and agents. Use babysitter discover commands at various stages.",
|
|
127
|
-
"- After each interview step, decide what the next highest-signal step is. Do not plan more than one step ahead. The same step type can repeat.",
|
|
128
|
-
"- Interview steps can include: research the repo, search the process library, ask the user a question via AskUserQuestion, research online, inspect local processes.",
|
|
137
|
+
"--- Shared Process Creation Instructions ---",
|
|
129
138
|
"",
|
|
130
|
-
|
|
131
|
-
"- Before writing the process, scan methodologies and processes in the active process library to find relevant patterns to use as reference. Also scan `.a5c/processes/` for project-level reusable processes.",
|
|
132
|
-
"- Search for process files (.js), skills (SKILL.md), and agents (AGENT.md) during the process building phase. Search paths: `.a5c/processes/` (project level), `specializations/` under active root, `methodologies/` under active root.",
|
|
133
|
-
"- When creating the process file, include `@skill` and `@agent` JSDoc markers in the file header listing skills and agents relevant to this process. The SDK reads these markers to provide targeted discovery results instead of scanning all available skills.",
|
|
134
|
-
"- JSDoc marker format: `@skill <name> <path-relative-to-binding.dir>`, `@agent <name> <path-relative-to-binding.dir>`.",
|
|
135
|
-
"- Prefer modular, reusable process composition. If a generic reusable part is identified, build it modularly in `.a5c/processes/` for future composition.",
|
|
136
|
-
"- Processes should include: explicit milestones, quality gates with executable verification, iterative convergence loops, integration phases with integration tests.",
|
|
137
|
-
"- Test-driven approach where quality gate agents can use executable tools, scripts, and tests to verify accuracy and completeness.",
|
|
138
|
-
"",
|
|
139
|
-
"Non-interactive Mode Enhancement:",
|
|
140
|
-
"- In non-interactive mode, still parse the request, inspect the workspace, resolve the active process-library root, and search for the most relevant specialization or methodology before authoring. Do not skip the search step just because it is non-interactive.",
|
|
139
|
+
composedInstructions,
|
|
141
140
|
"",
|
|
142
141
|
`Required output path: ${outputPath}`,
|
|
143
142
|
...formatSharedContext(context),
|
|
@@ -174,7 +173,9 @@ function buildProcessDefinitionUserPrompt(userPrompt, outputPath, options) {
|
|
|
174
173
|
lines.push("Before writing the process, you MUST resolve and search the active process-library. Use babysitter_resolve_process_library, then babysitter_search_process_library to find relevant patterns.", "The generated process must directly execute the user's requested work rather than write another babysitter process.", "Use babysitter_write_process_definition to write the file now, then call babysitter_report_process_definition exactly once.");
|
|
175
174
|
return lines.join("\n");
|
|
176
175
|
}
|
|
177
|
-
function buildOrchestrationSystemPrompt(selectedHarnessName, context) {
|
|
176
|
+
function buildOrchestrationSystemPrompt(selectedHarnessName, context, interactive) {
|
|
177
|
+
const piCtx = (0, context_1.createPiContext)({ interactive });
|
|
178
|
+
const composedInstructions = (0, compose_1.composeOrchestrationPrompt)(piCtx);
|
|
178
179
|
return [
|
|
179
180
|
"You are the babysitter harness:create-run phase 2 orchestration agent.",
|
|
180
181
|
"Your job is to run the babysitter orchestration loop through tools, not by narrating what should happen.",
|
|
@@ -187,18 +188,17 @@ function buildOrchestrationSystemPrompt(selectedHarnessName, context) {
|
|
|
187
188
|
"- Call babysitter_run_create to create the run if it does not already exist.",
|
|
188
189
|
"- Immediately call babysitter_bind_session after run creation and before the first orchestration iteration.",
|
|
189
190
|
"- Work in bounded turns. In each turn, call babysitter_run_iterate at most once unless the prompt explicitly tells you otherwise.",
|
|
190
|
-
"- When babysitter_run_iterate reports pending effects, resolve each effect through tools.",
|
|
191
|
-
"- For breakpoint effects, use AskUserQuestion in interactive mode with explicit approval options, then call babysitter_task_post_result. Never auto-approve or fabricate an approval response. In non-interactive mode, select the best option according to the user intent and current context, then call babysitter_task_post_result.",
|
|
192
|
-
"- For `shell` effects, prefer `babysitter_run_shell_effect` so the command executes on an internal PI worker that respects task metadata. Use raw bash/coding tools only when the effect payload clearly requires manual inspection or direct intervention before posting the explicit outcome with babysitter_task_post_result.",
|
|
193
|
-
"- For `agent`, `node`, and `orchestrator_task` effects, prefer babysitter_dispatch_effect_harness so the pending effect is fulfilled through the intended harness wrapper. These babysitter effect tools are the built-in internal `harness:create-run` harness surface for phase 2. If you fulfill an effect directly with your own coding tools, you must still call babysitter_task_post_result with the explicit outcome.",
|
|
194
191
|
"- Do not rely on a hidden host-side effect executor. Perform or dispatch each effect intentionally based on the effect payload you received from babysitter_run_iterate.",
|
|
195
|
-
"- Shell effects are first-class pending effects. Do not skip them, narrate them, or assume the host will run them for you.",
|
|
192
|
+
"- Shell and legacy node effects are first-class pending effects. Do not skip them, narrate them, or assume the host will run them for you.",
|
|
193
|
+
"- Whenever a shell or node effect is requested, execute that work intentionally through the available tools or a delegated worker, then post the outcome yourself.",
|
|
196
194
|
"- When choosing how to execute pending work, respect task-level harness metadata and the installed harness catalog provided below.",
|
|
197
|
-
"- Shell effects execute on internal PI worker sessions. Respect `task.metadata.bashSandbox`, `task.metadata.isolated`, and `task.metadata.enableCompaction` when the process encoded stronger guardrails for that worker.",
|
|
198
|
-
"- Internal secure execution is available through opt-in PI worker sessions; prefer that path for shell or security-sensitive work instead of assuming an external CLI harness is guarded.",
|
|
199
195
|
"- Stay in the orchestration loop until the run completes, fails, or reaches a hard limit reported by the tools.",
|
|
200
196
|
"- When the run reaches a terminal state, call babysitter_finish_orchestration exactly once.",
|
|
201
197
|
"",
|
|
198
|
+
"--- Shared Orchestration Instructions ---",
|
|
199
|
+
"",
|
|
200
|
+
composedInstructions,
|
|
201
|
+
"",
|
|
202
202
|
"This phase is the bound orchestration phase. Preserve the hook-style loop semantics by always continuing through the babysitter tools.",
|
|
203
203
|
...formatSharedContext(context),
|
|
204
204
|
].join("\n");
|
|
@@ -247,8 +247,9 @@ function buildOrchestrationTurnPrompt(args) {
|
|
|
247
247
|
lines.push("");
|
|
248
248
|
lines.push("Resolve every listed pending effect and post its result in this turn. Do not call babysitter_run_iterate again after posting them.");
|
|
249
249
|
lines.push("Handling rules:");
|
|
250
|
-
lines.push("- For `shell` effects,
|
|
251
|
-
lines.push("- For
|
|
250
|
+
lines.push("- For `shell` effects, execute the requested command intentionally, capture the outcome, then call babysitter_task_post_result with explicit status/stdout/stderr/value fields.");
|
|
251
|
+
lines.push("- For legacy `node` effects, execute the requested work intentionally through the available tools or a delegated worker, capture the outcome, then call babysitter_task_post_result yourself.");
|
|
252
|
+
lines.push("- For `agent` or `orchestrator_task` effects, prefer babysitter_dispatch_effect_harness unless direct coding-tool execution is clearly better for the requested effect.");
|
|
252
253
|
lines.push("- For `breakpoint` effects, use AskUserQuestion in interactive mode with explicit approval options or choose the best option non-interactively, then post the result.");
|
|
253
254
|
}
|
|
254
255
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hookRun.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/hookRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"hookRun.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/hookRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,wGAAwG;IACxG,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAmJD,wBAAsB,aAAa,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0F7E"}
|
|
@@ -16,6 +16,7 @@ exports.handleHookRun = handleHookRun;
|
|
|
16
16
|
const harness_1 = require("../../harness");
|
|
17
17
|
const config_loader_1 = require("../../compression/config-loader");
|
|
18
18
|
const density_filter_1 = require("../../compression/density-filter");
|
|
19
|
+
const runLogger_1 = require("../../logging/runLogger");
|
|
19
20
|
// ---------------------------------------------------------------------------
|
|
20
21
|
// Stdin reader
|
|
21
22
|
// ---------------------------------------------------------------------------
|
|
@@ -130,6 +131,20 @@ async function handlePreToolUse() {
|
|
|
130
131
|
// ---------------------------------------------------------------------------
|
|
131
132
|
// Main dispatcher
|
|
132
133
|
// ---------------------------------------------------------------------------
|
|
134
|
+
/** Fire-and-forget log to the structured run log facility. */
|
|
135
|
+
function logHookEvent(hookType, message, context) {
|
|
136
|
+
void (0, runLogger_1.appendRunLog)({
|
|
137
|
+
timestamp: new Date().toISOString(),
|
|
138
|
+
level: "info",
|
|
139
|
+
type: "hook",
|
|
140
|
+
label: `hook:${hookType}`,
|
|
141
|
+
message,
|
|
142
|
+
source: "hook:run",
|
|
143
|
+
context,
|
|
144
|
+
}).catch(() => {
|
|
145
|
+
// Never let logging break hook execution.
|
|
146
|
+
});
|
|
147
|
+
}
|
|
133
148
|
async function handleHookRun(args) {
|
|
134
149
|
const { hookType, harness, json } = args;
|
|
135
150
|
if (!hookType) {
|
|
@@ -145,12 +160,17 @@ async function handleHookRun(args) {
|
|
|
145
160
|
}
|
|
146
161
|
return 1;
|
|
147
162
|
}
|
|
163
|
+
logHookEvent(hookType, "Hook invoked", { harness });
|
|
148
164
|
// harness-agnostic hook types — handle before adapter lookup
|
|
149
165
|
if (hookType === "user-prompt-submit") {
|
|
150
|
-
|
|
166
|
+
const code = await handleUserPromptSubmit();
|
|
167
|
+
logHookEvent(hookType, `Hook completed with code=${code}`);
|
|
168
|
+
return code;
|
|
151
169
|
}
|
|
152
170
|
if (hookType === "pre-tool-use") {
|
|
153
|
-
|
|
171
|
+
const code = await handlePreToolUse();
|
|
172
|
+
logHookEvent(hookType, `Hook completed with code=${code}`);
|
|
173
|
+
return code;
|
|
154
174
|
}
|
|
155
175
|
const adapter = (0, harness_1.getAdapterByName)(harness);
|
|
156
176
|
if (!adapter) {
|
|
@@ -159,6 +179,7 @@ async function handleHookRun(args) {
|
|
|
159
179
|
error: "UNSUPPORTED_HARNESS",
|
|
160
180
|
message: `Unsupported harness: "${harness}". Supported: ${supported.join(", ")}`,
|
|
161
181
|
};
|
|
182
|
+
logHookEvent(hookType, `Unsupported harness: ${harness}`, { error: error.error });
|
|
162
183
|
if (json) {
|
|
163
184
|
process.stderr.write(JSON.stringify(error, null, 2) + "\n");
|
|
164
185
|
}
|
|
@@ -175,6 +196,7 @@ async function handleHookRun(args) {
|
|
|
175
196
|
error: "UNSUPPORTED_HOOK_TYPE",
|
|
176
197
|
message,
|
|
177
198
|
};
|
|
199
|
+
logHookEvent(hookType, message, { error: error.error });
|
|
178
200
|
if (json) {
|
|
179
201
|
process.stderr.write(JSON.stringify(error, null, 2) + "\n");
|
|
180
202
|
}
|
|
@@ -183,16 +205,20 @@ async function handleHookRun(args) {
|
|
|
183
205
|
}
|
|
184
206
|
return 1;
|
|
185
207
|
}
|
|
208
|
+
let exitCode;
|
|
186
209
|
switch (hookType) {
|
|
187
210
|
case "stop":
|
|
188
|
-
|
|
211
|
+
exitCode = await adapter.handleStopHook(args);
|
|
212
|
+
break;
|
|
189
213
|
case "session-start":
|
|
190
|
-
|
|
214
|
+
exitCode = await adapter.handleSessionStartHook(args);
|
|
215
|
+
break;
|
|
191
216
|
default: {
|
|
192
217
|
const error = {
|
|
193
218
|
error: "UNKNOWN_HOOK_TYPE",
|
|
194
219
|
message: `Unknown hook type: ${hookType}. Supported: stop, session-start, user-prompt-submit`,
|
|
195
220
|
};
|
|
221
|
+
logHookEvent(hookType, error.message, { error: error.error });
|
|
196
222
|
if (json) {
|
|
197
223
|
process.stderr.write(JSON.stringify(error, null, 2) + "\n");
|
|
198
224
|
}
|
|
@@ -202,4 +228,6 @@ async function handleHookRun(args) {
|
|
|
202
228
|
return 1;
|
|
203
229
|
}
|
|
204
230
|
}
|
|
231
|
+
logHookEvent(hookType, `Hook completed with code=${exitCode}`, { harness });
|
|
232
|
+
return exitCode;
|
|
205
233
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI handlers for `instructions:*` commands.
|
|
3
|
+
*
|
|
4
|
+
* Each subcommand resolves a PromptContext for the given harness,
|
|
5
|
+
* calls the appropriate composer, and outputs the result.
|
|
6
|
+
*
|
|
7
|
+
* @module cli/commands/instructions
|
|
8
|
+
*/
|
|
9
|
+
export interface InstructionsCommandArgs {
|
|
10
|
+
subcommand: "babysit-skill" | "process-create" | "orchestrate" | "breakpoint-handling";
|
|
11
|
+
harness: string;
|
|
12
|
+
interactive: boolean | undefined;
|
|
13
|
+
json: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Route and handle an `instructions:*` subcommand.
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleInstructionsCommand(args: InstructionsCommandArgs): Promise<number>;
|
|
19
|
+
//# sourceMappingURL=instructions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,qBAAqB,CAAC;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;CACf;AA4GD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAiEjB"}
|