@a5c-ai/babysitter-sdk 0.0.183-staging.dd5dc0db → 0.0.183-staging.f079a57a
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/sessionCreate.d.ts.map +1 -1
- package/dist/cli/commands/sessionCreate.js +83 -16
- package/dist/cli/commands/sessionCreatePrompts.d.ts +20 -2
- package/dist/cli/commands/sessionCreatePrompts.d.ts.map +1 -1
- package/dist/cli/commands/sessionCreatePrompts.js +80 -2
- package/dist/cli/commands/templates/process-generation-prompt.md +8 -0
- package/dist/harness/piWrapper.d.ts.map +1 -1
- package/dist/harness/piWrapper.js +2 -1
- package/dist/harness/types.d.ts +1 -1
- package/dist/harness/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionCreate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/sessionCreate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,OAAO,KAAK,EACV,sBAAsB,
|
|
1
|
+
{"version":3,"file":"sessionCreate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/sessionCreate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,OAAO,KAAK,EACV,sBAAsB,EAIvB,MAAM,qBAAqB,CAAC;AAyB7B,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA8ID,wBAAgB,aAAa,CAC3B,UAAU,EAAE,sBAAsB,EAAE,EACpC,SAAS,CAAC,EAAE,MAAM,GACjB,sBAAsB,GAAG,SAAS,CAYpC;AAquCD,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,MAAM,CAAC,CA8EjB"}
|
|
@@ -91,6 +91,38 @@ function compressInternalHarnessPrompt(text, compressionConfig, taskKind = "agen
|
|
|
91
91
|
const targetReduction = layer.perTaskKind?.[taskKind] ?? layer.targetReduction;
|
|
92
92
|
return (0, density_filter_1.densityFilterText)(text, targetReduction);
|
|
93
93
|
}
|
|
94
|
+
function buildPromptContext(args) {
|
|
95
|
+
const envNames = [
|
|
96
|
+
"CI",
|
|
97
|
+
"BABYSITTER_COMPRESSION_ENABLED",
|
|
98
|
+
"BABYSITTER_PI_SANDBOX_IMAGE",
|
|
99
|
+
"AZURE_OPENAI_API_KEY",
|
|
100
|
+
"AZURE_OPENAI_PROJECT_NAME",
|
|
101
|
+
"AZURE_OPENAI_DEPLOYMENT",
|
|
102
|
+
"OPENAI_API_KEY",
|
|
103
|
+
"ANTHROPIC_API_KEY",
|
|
104
|
+
];
|
|
105
|
+
return {
|
|
106
|
+
platform: process.platform,
|
|
107
|
+
arch: process.arch,
|
|
108
|
+
nodeVersion: process.version,
|
|
109
|
+
cwd: process.cwd(),
|
|
110
|
+
workspace: path.resolve(args.workspace ?? process.cwd()),
|
|
111
|
+
selectedHarnessName: args.selectedHarnessName,
|
|
112
|
+
discoveredHarnesses: args.discovered,
|
|
113
|
+
compressionEnabled: Boolean(args.compressionConfig?.enabled &&
|
|
114
|
+
args.compressionConfig.layers.sdkContextHook.enabled),
|
|
115
|
+
secureSandboxImage: process.env.BABYSITTER_PI_SANDBOX_IMAGE || "node:22-bookworm",
|
|
116
|
+
piDefaultBashSandbox: "local",
|
|
117
|
+
piIsolationDefault: false,
|
|
118
|
+
envFlags: envNames.map((name) => ({
|
|
119
|
+
name,
|
|
120
|
+
value: process.env[name]
|
|
121
|
+
? (name.endsWith("_API_KEY") ? "set" : process.env[name])
|
|
122
|
+
: "unset",
|
|
123
|
+
})),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
94
126
|
const HARNESS_PRIORITY = [
|
|
95
127
|
"pi",
|
|
96
128
|
"oh-my-pi",
|
|
@@ -258,6 +290,43 @@ function resolveTaskHarness(action, defaultHarness, discovered) {
|
|
|
258
290
|
}
|
|
259
291
|
return defaultHarness;
|
|
260
292
|
}
|
|
293
|
+
function isPiHarness(harnessName) {
|
|
294
|
+
return harnessName === "pi" || harnessName === "oh-my-pi";
|
|
295
|
+
}
|
|
296
|
+
function readBooleanMetadata(metadata, key) {
|
|
297
|
+
const value = metadata?.[key];
|
|
298
|
+
if (typeof value === "boolean") {
|
|
299
|
+
return value;
|
|
300
|
+
}
|
|
301
|
+
if (value === "true") {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
if (value === "false") {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
function readBashSandboxMetadata(metadata) {
|
|
310
|
+
const value = metadata?.bashSandbox;
|
|
311
|
+
return value === "auto" || value === "secure" || value === "local"
|
|
312
|
+
? value
|
|
313
|
+
: undefined;
|
|
314
|
+
}
|
|
315
|
+
function buildPiWorkerSessionOptions(args) {
|
|
316
|
+
const metadata = args.action.taskDef?.metadata;
|
|
317
|
+
const isolated = readBooleanMetadata(metadata, "isolated");
|
|
318
|
+
const enableCompaction = readBooleanMetadata(metadata, "enableCompaction");
|
|
319
|
+
const bashSandbox = readBashSandboxMetadata(metadata);
|
|
320
|
+
return {
|
|
321
|
+
workspace: args.workspace,
|
|
322
|
+
model: args.model,
|
|
323
|
+
toolsMode: "coding",
|
|
324
|
+
ephemeral: true,
|
|
325
|
+
...(isolated !== undefined ? { isolated } : {}),
|
|
326
|
+
...(enableCompaction !== undefined ? { enableCompaction } : {}),
|
|
327
|
+
...(bashSandbox ? { bashSandbox } : {}),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
261
330
|
async function resolveEffect(action, harnessName, options, piSession, discovered, rl, json) {
|
|
262
331
|
const kind = action.kind;
|
|
263
332
|
if (kind === "node" || kind === "orchestrator_task") {
|
|
@@ -568,11 +637,8 @@ async function runProcessDefinitionPhase(args) {
|
|
|
568
637
|
model: args.model,
|
|
569
638
|
toolsMode: "coding",
|
|
570
639
|
customTools,
|
|
571
|
-
appendSystemPrompt: [(0, sessionCreatePrompts_1.buildProcessDefinitionSystemPrompt)(args.outputPath)],
|
|
572
|
-
isolated: true,
|
|
640
|
+
appendSystemPrompt: [(0, sessionCreatePrompts_1.buildProcessDefinitionSystemPrompt)(args.outputPath, args.promptContext)],
|
|
573
641
|
ephemeral: true,
|
|
574
|
-
bashSandbox: "secure",
|
|
575
|
-
enableCompaction: true,
|
|
576
642
|
});
|
|
577
643
|
try {
|
|
578
644
|
await session.initialize();
|
|
@@ -818,16 +884,12 @@ async function runOrchestrationPhase(args) {
|
|
|
818
884
|
}
|
|
819
885
|
const taskHarness = resolveTaskHarness(action, args.selectedHarnessName, args.discovered);
|
|
820
886
|
let workerSession = null;
|
|
821
|
-
if (action.kind === "shell" || taskHarness
|
|
822
|
-
workerSession = (0, piWrapper_1.createPiSession)({
|
|
887
|
+
if (action.kind === "shell" || isPiHarness(taskHarness)) {
|
|
888
|
+
workerSession = (0, piWrapper_1.createPiSession)(buildPiWorkerSessionOptions({
|
|
889
|
+
action,
|
|
823
890
|
workspace: args.workspace,
|
|
824
891
|
model: args.model,
|
|
825
|
-
|
|
826
|
-
isolated: true,
|
|
827
|
-
ephemeral: true,
|
|
828
|
-
bashSandbox: "secure",
|
|
829
|
-
enableCompaction: true,
|
|
830
|
-
});
|
|
892
|
+
}));
|
|
831
893
|
}
|
|
832
894
|
try {
|
|
833
895
|
const effectResult = await resolveEffect(action, args.selectedHarnessName, {
|
|
@@ -940,11 +1002,8 @@ async function runOrchestrationPhase(args) {
|
|
|
940
1002
|
model: args.model,
|
|
941
1003
|
toolsMode: "readonly",
|
|
942
1004
|
customTools,
|
|
943
|
-
appendSystemPrompt: [(0, sessionCreatePrompts_1.buildOrchestrationSystemPrompt)(args.selectedHarnessName)],
|
|
944
|
-
isolated: true,
|
|
1005
|
+
appendSystemPrompt: [(0, sessionCreatePrompts_1.buildOrchestrationSystemPrompt)(args.selectedHarnessName, args.promptContext)],
|
|
945
1006
|
ephemeral: true,
|
|
946
|
-
bashSandbox: "secure",
|
|
947
|
-
enableCompaction: true,
|
|
948
1007
|
});
|
|
949
1008
|
emitProgress({ phase: "2", status: "started", harness: args.selectedHarnessName }, args.json, args.verbose);
|
|
950
1009
|
try {
|
|
@@ -1015,6 +1074,12 @@ async function handleSessionCreate(parsed) {
|
|
|
1015
1074
|
const selected = selectHarness(discovered, preferredHarness);
|
|
1016
1075
|
const selectedHarnessName = selected?.name ?? "pi";
|
|
1017
1076
|
const compressionConfig = loadSessionCompressionConfig(workspace);
|
|
1077
|
+
const promptContext = buildPromptContext({
|
|
1078
|
+
workspace,
|
|
1079
|
+
selectedHarnessName,
|
|
1080
|
+
discovered,
|
|
1081
|
+
compressionConfig,
|
|
1082
|
+
});
|
|
1018
1083
|
let processPath = providedProcessPath;
|
|
1019
1084
|
if (processPath) {
|
|
1020
1085
|
emitProgress({ phase: "1", status: "skipped", processPath }, json, verbose);
|
|
@@ -1031,6 +1096,7 @@ async function handleSessionCreate(parsed) {
|
|
|
1031
1096
|
json,
|
|
1032
1097
|
verbose,
|
|
1033
1098
|
compressionConfig,
|
|
1099
|
+
promptContext,
|
|
1034
1100
|
});
|
|
1035
1101
|
}
|
|
1036
1102
|
return await runOrchestrationPhase({
|
|
@@ -1047,6 +1113,7 @@ async function handleSessionCreate(parsed) {
|
|
|
1047
1113
|
selectedHarnessName,
|
|
1048
1114
|
discovered,
|
|
1049
1115
|
compressionConfig,
|
|
1116
|
+
promptContext,
|
|
1050
1117
|
});
|
|
1051
1118
|
}
|
|
1052
1119
|
finally {
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import type { HarnessDiscoveryResult } from "../../harness/types";
|
|
2
|
+
export interface SessionCreatePromptContext {
|
|
3
|
+
platform: string;
|
|
4
|
+
arch: string;
|
|
5
|
+
nodeVersion: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
workspace: string;
|
|
8
|
+
selectedHarnessName?: string;
|
|
9
|
+
discoveredHarnesses: HarnessDiscoveryResult[];
|
|
10
|
+
compressionEnabled: boolean;
|
|
11
|
+
secureSandboxImage: string;
|
|
12
|
+
piDefaultBashSandbox: "local" | "auto" | "secure";
|
|
13
|
+
piIsolationDefault: boolean;
|
|
14
|
+
envFlags: Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export declare function buildProcessDefinitionSystemPrompt(outputPath: string, context: SessionCreatePromptContext): string;
|
|
2
20
|
export declare function buildProcessDefinitionUserPrompt(userPrompt: string, outputPath: string): string;
|
|
3
|
-
export declare function buildOrchestrationSystemPrompt(selectedHarnessName: string): string;
|
|
21
|
+
export declare function buildOrchestrationSystemPrompt(selectedHarnessName: string, context: SessionCreatePromptContext): string;
|
|
4
22
|
export declare function buildOrchestrationUserPrompt(processPath: string, userPrompt: string | undefined, maxIterations: number): string;
|
|
5
23
|
//# sourceMappingURL=sessionCreatePrompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionCreatePrompts.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/sessionCreatePrompts.ts"],"names":[],"mappings":"AAAA,wBAAgB,kCAAkC,
|
|
1
|
+
{"version":3,"file":"sessionCreatePrompts.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/sessionCreatePrompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,WAAW,0BAA0B;IACzC,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;AA+ED,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,0BAA0B,GAClC,MAAM,CAkBR;AAED,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,CAOR;AAED,wBAAgB,8BAA8B,CAC5C,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,0BAA0B,GAClC,MAAM,CAuBR;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,MAAM,GACpB,MAAM,CAQR"}
|
|
@@ -4,7 +4,78 @@ exports.buildProcessDefinitionSystemPrompt = buildProcessDefinitionSystemPrompt;
|
|
|
4
4
|
exports.buildProcessDefinitionUserPrompt = buildProcessDefinitionUserPrompt;
|
|
5
5
|
exports.buildOrchestrationSystemPrompt = buildOrchestrationSystemPrompt;
|
|
6
6
|
exports.buildOrchestrationUserPrompt = buildOrchestrationUserPrompt;
|
|
7
|
-
function
|
|
7
|
+
function formatHarnessCatalog(context) {
|
|
8
|
+
const lines = ["Discovered harnesses:"];
|
|
9
|
+
for (const harness of context.discoveredHarnesses) {
|
|
10
|
+
const parts = [
|
|
11
|
+
`${harness.name}`,
|
|
12
|
+
`installed=${harness.installed ? "yes" : "no"}`,
|
|
13
|
+
`cli=${harness.cliCommand}`,
|
|
14
|
+
`config=${harness.configFound ? "yes" : "no"}`,
|
|
15
|
+
];
|
|
16
|
+
if (harness.version) {
|
|
17
|
+
parts.push(`version=${harness.version}`);
|
|
18
|
+
}
|
|
19
|
+
if (harness.capabilities.length > 0) {
|
|
20
|
+
parts.push(`capabilities=${harness.capabilities.join(",")}`);
|
|
21
|
+
}
|
|
22
|
+
if (harness.name === "pi" || harness.name === "oh-my-pi") {
|
|
23
|
+
parts.push("profile=internal-programmatic");
|
|
24
|
+
}
|
|
25
|
+
else if (harness.installed) {
|
|
26
|
+
parts.push("profile=external-cli");
|
|
27
|
+
}
|
|
28
|
+
lines.push(`- ${parts.join(" | ")}`);
|
|
29
|
+
}
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
function formatRuntimeContext(context) {
|
|
33
|
+
return [
|
|
34
|
+
"Runtime environment:",
|
|
35
|
+
`- platform=${context.platform}`,
|
|
36
|
+
`- arch=${context.arch}`,
|
|
37
|
+
`- node=${context.nodeVersion}`,
|
|
38
|
+
`- cwd=${context.cwd}`,
|
|
39
|
+
`- workspace=${context.workspace}`,
|
|
40
|
+
`- compression=${context.compressionEnabled ? "enabled" : "disabled"}`,
|
|
41
|
+
`- secure_pi_sandbox_image=${context.secureSandboxImage}`,
|
|
42
|
+
`- pi_default_bash_sandbox=${context.piDefaultBashSandbox}`,
|
|
43
|
+
`- pi_default_isolated=${context.piIsolationDefault ? "true" : "false"}`,
|
|
44
|
+
...context.envFlags.map((flag) => `- env.${flag.name}=${flag.value}`),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
function formatHarnessAssignmentGuidance(context) {
|
|
48
|
+
const installedHarnesses = context.discoveredHarnesses
|
|
49
|
+
.filter((h) => h.installed)
|
|
50
|
+
.map((h) => h.name);
|
|
51
|
+
const installedList = installedHarnesses.length > 0
|
|
52
|
+
? installedHarnesses.join(", ")
|
|
53
|
+
: "(none)";
|
|
54
|
+
return [
|
|
55
|
+
"Harness assignment guidance:",
|
|
56
|
+
`- Only assign installed harness names. Installed harnesses: ${installedList}.`,
|
|
57
|
+
"- For `agent`, `node`, or `orchestrator_task` work that should run on a specific harness, set `task.metadata.harness` to that harness name.",
|
|
58
|
+
"- 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.",
|
|
59
|
+
"- 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.",
|
|
60
|
+
"- For risky shell or system-changing subtasks, encode guardrails 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.",
|
|
61
|
+
"- 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.",
|
|
62
|
+
"- 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.",
|
|
63
|
+
context.selectedHarnessName
|
|
64
|
+
? `- The selected orchestration binding harness for this run is ${context.selectedHarnessName}.`
|
|
65
|
+
: "- No orchestration binding harness has been selected yet.",
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function formatSharedContext(context) {
|
|
69
|
+
return [
|
|
70
|
+
"",
|
|
71
|
+
...formatRuntimeContext(context),
|
|
72
|
+
"",
|
|
73
|
+
...formatHarnessCatalog(context),
|
|
74
|
+
"",
|
|
75
|
+
...formatHarnessAssignmentGuidance(context),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
function buildProcessDefinitionSystemPrompt(outputPath, context) {
|
|
8
79
|
return [
|
|
9
80
|
"You are the babysitter session:create phase 1 agent.",
|
|
10
81
|
"Your job is to turn the user's intent into a concrete babysitter process definition before any run is created or bound.",
|
|
@@ -16,8 +87,11 @@ function buildProcessDefinitionSystemPrompt(outputPath) {
|
|
|
16
87
|
"- Write the final JavaScript process file to the exact output path provided below.",
|
|
17
88
|
"- After the file is written, call babysitter_report_process_definition exactly once with the final path and a concise summary.",
|
|
18
89
|
"- Do not claim completion in plain text without calling babysitter_report_process_definition.",
|
|
90
|
+
"- If different tasks should run on different harnesses, encode that in the process definition rather than leaving it implicit.",
|
|
91
|
+
"- Encode internal worker guardrails explicitly in task metadata when needed. Use `task.metadata.bashSandbox`, `task.metadata.isolated`, and `task.metadata.enableCompaction` instead of assuming every internal task is secure or isolated by default.",
|
|
19
92
|
"",
|
|
20
93
|
`Required output path: ${outputPath}`,
|
|
94
|
+
...formatSharedContext(context),
|
|
21
95
|
].join("\n");
|
|
22
96
|
}
|
|
23
97
|
function buildProcessDefinitionUserPrompt(userPrompt, outputPath) {
|
|
@@ -28,7 +102,7 @@ function buildProcessDefinitionUserPrompt(userPrompt, outputPath) {
|
|
|
28
102
|
`Output path: ${outputPath}`,
|
|
29
103
|
].join("\n");
|
|
30
104
|
}
|
|
31
|
-
function buildOrchestrationSystemPrompt(selectedHarnessName) {
|
|
105
|
+
function buildOrchestrationSystemPrompt(selectedHarnessName, context) {
|
|
32
106
|
return [
|
|
33
107
|
"You are the babysitter session:create phase 2 orchestration agent.",
|
|
34
108
|
"Your job is to run the babysitter orchestration loop through tools, not by narrating what should happen.",
|
|
@@ -42,10 +116,14 @@ function buildOrchestrationSystemPrompt(selectedHarnessName) {
|
|
|
42
116
|
"- For breakpoint effects, use AskUserQuestion to get the user decision, then call babysitter_task_post_result.",
|
|
43
117
|
"- For non-breakpoint effects, call babysitter_execute_effect, then persist the returned result with babysitter_task_post_result.",
|
|
44
118
|
"- Do not execute effect work directly with your own shell/write tools when a babysitter tool is available for it.",
|
|
119
|
+
"- When choosing how to execute pending work, respect task-level harness metadata and the installed harness catalog provided below.",
|
|
120
|
+
"- 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.",
|
|
121
|
+
"- 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.",
|
|
45
122
|
"- Stay in the orchestration loop until the run completes, fails, or reaches a hard limit reported by the tools.",
|
|
46
123
|
"- When the run reaches a terminal state, call babysitter_finish_orchestration exactly once.",
|
|
47
124
|
"",
|
|
48
125
|
"This phase is the bound orchestration phase. Preserve the hook-style loop semantics by always continuing through the babysitter tools.",
|
|
126
|
+
...formatSharedContext(context),
|
|
49
127
|
].join("\n");
|
|
50
128
|
}
|
|
51
129
|
function buildOrchestrationUserPrompt(processPath, userPrompt, maxIterations) {
|
|
@@ -10,6 +10,12 @@ import { defineTask } from "@a5c-ai/babysitter-sdk";
|
|
|
10
10
|
const myTask = defineTask('task-id', (args, taskCtx) => ({
|
|
11
11
|
kind: 'agent', // ALWAYS use 'agent' kind, never 'node'
|
|
12
12
|
title: 'Description of what this task does',
|
|
13
|
+
metadata: {
|
|
14
|
+
harness: 'pi', // optional: route a task to a specific harness
|
|
15
|
+
bashSandbox: 'secure', // optional: opt into AgentSH for risky shell work
|
|
16
|
+
isolated: true, // optional: disable repo/global PI skills/extensions
|
|
17
|
+
enableCompaction: true // optional: opt into PI compaction for long-lived workers
|
|
18
|
+
},
|
|
13
19
|
agent: {
|
|
14
20
|
name: 'general-purpose',
|
|
15
21
|
prompt: {
|
|
@@ -52,6 +58,8 @@ which bypasses the agent orchestration model entirely. Every task MUST use `agen
|
|
|
52
58
|
## Rules
|
|
53
59
|
- ALWAYS use kind: 'agent' for tasks (NEVER 'node')
|
|
54
60
|
- Use kind: 'shell' ONLY for running existing CLI tools, test suites, git commands
|
|
61
|
+
- Default internal PI execution is native/local and not isolated; opt into `metadata.bashSandbox = "secure"` and `metadata.isolated = true` only for subtasks that genuinely need AgentSH guardrails or stricter isolation
|
|
62
|
+
- External CLI harnesses do not inherit AgentSH guardrails; keep risky shell/system-changing work on the internal PI worker
|
|
55
63
|
- Use ctx.breakpoint() for human approval gates
|
|
56
64
|
- Use ctx.parallel.all() with thunks (arrow functions) for concurrent tasks
|
|
57
65
|
- Include quality gates and verification steps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piWrapper.d.ts","sourceRoot":"","sources":["../../src/harness/piWrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"piWrapper.d.ts","sourceRoot":"","sources":["../../src/harness/piWrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAWhF,sCAAsC;AACtC,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;AAqG9D;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyC;gBAE1D,OAAO,GAAE,gBAAqB;IAI1C;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAcjC;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgErE;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,IAAI;IAKhD;;OAEG;IACG,WAAW,CACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAChC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAUhF;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;OAEG;IACH,OAAO,IAAI,IAAI;IAcf,oDAAoD;IACpD,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,6DAA6D;IAC7D,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,gDAAgD;IAChD,IAAI,aAAa,IAAI,OAAO,CAE3B;YAMa,YAAY;IAiJ1B,OAAO,CAAC,cAAc;CAUvB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,eAAe,CAE3E"}
|
|
@@ -48,6 +48,7 @@ const exceptions_1 = require("../runtime/exceptions");
|
|
|
48
48
|
const config_loader_1 = require("../compression/config-loader");
|
|
49
49
|
const piSecureSandbox_1 = require("./piSecureSandbox");
|
|
50
50
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
51
|
+
const DEFAULT_BASH_SANDBOX_MODE = "local";
|
|
51
52
|
// Use a variable to prevent TypeScript from resolving the module at compile time.
|
|
52
53
|
// The package is optional — only needed when pi harness is actually used.
|
|
53
54
|
const PI_MODULE_ID = "@mariozechner/pi-coding-agent";
|
|
@@ -274,7 +275,7 @@ class PiSessionHandle {
|
|
|
274
275
|
const secureBashBackend = this.options.toolsMode === "coding" || this.options.toolsMode === "readonly"
|
|
275
276
|
? await (0, piSecureSandbox_1.createSecureBashBackend)({
|
|
276
277
|
workspace: cwd,
|
|
277
|
-
mode: this.options.bashSandbox ??
|
|
278
|
+
mode: this.options.bashSandbox ?? DEFAULT_BASH_SANDBOX_MODE,
|
|
278
279
|
})
|
|
279
280
|
: null;
|
|
280
281
|
if (secureBashBackend) {
|
package/dist/harness/types.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export interface PiSessionOptions {
|
|
|
104
104
|
isolated?: boolean;
|
|
105
105
|
/** Use an in-memory session manager instead of persistent session files. */
|
|
106
106
|
ephemeral?: boolean;
|
|
107
|
-
/** Bash tool execution backend. "secure"
|
|
107
|
+
/** Bash tool execution backend. Defaults to native/local PI execution; "secure" opts into the sandbox backend and "auto" falls back to local. */
|
|
108
108
|
bashSandbox?: "auto" | "secure" | "local";
|
|
109
109
|
/** Whether PI session compaction should be enabled for this session. */
|
|
110
110
|
enableCompaction?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/harness/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,uDAAuD;AACvD,oBAAY,iBAAiB;IAC3B,kEAAkE;IAClE,YAAY,iBAAiB;IAC7B,2DAA2D;IAC3D,cAAc,oBAAoB;IAClC,wDAAwD;IACxD,QAAQ,cAAc;IACtB,8DAA8D;IAC9D,GAAG,QAAQ;IACX,iEAAiE;IACjE,cAAc,oBAAoB;CACnC;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;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