@a5c-ai/babysitter-sdk 0.0.187-staging.97cd55f1 → 0.0.187-staging.9fa55ea5
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.
|
@@ -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,EA+BjB,eAAe,EAIhB,MAAM,gBAAgB,CAAC;AAQxB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;
|
|
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,EA+BjB,eAAe,EAIhB,MAAM,gBAAgB,CAAC;AAQxB;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AA+D1C,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;AAwOD,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,CAggDlB"}
|
|
@@ -66,6 +66,64 @@ const PROCESS_MODULE_LOAD_RETRY_DELAYS_MS = process.env.VITEST
|
|
|
66
66
|
exports.MAX_CONSECUTIVE_TIMEOUTS = 3;
|
|
67
67
|
// For tests
|
|
68
68
|
const EFFECT_RETRY_DELAYS_OVERRIDE = process.env.VITEST ? [0, 0, 0] : undefined;
|
|
69
|
+
// ── Verbose Pi Event Logging ─────────────────────────────────────────
|
|
70
|
+
/**
|
|
71
|
+
* Subscribe to a Pi session's events and emit verbose logs for intermediate
|
|
72
|
+
* lifecycle events (tool executions, turns, messages, agent lifecycle).
|
|
73
|
+
*
|
|
74
|
+
* Returns an unsubscribe function. No-ops when verbose is disabled or json
|
|
75
|
+
* mode is active (no stderr noise).
|
|
76
|
+
*/
|
|
77
|
+
function subscribeVerbosePiEvents(session, label, opts) {
|
|
78
|
+
if (!opts.verbose || opts.json)
|
|
79
|
+
return null;
|
|
80
|
+
// We subscribe *after* the session is initialized. If it isn't initialized
|
|
81
|
+
// yet, the caller will call initialize() and this subscription will fire
|
|
82
|
+
// once events start flowing.
|
|
83
|
+
try {
|
|
84
|
+
return session.subscribe((event) => {
|
|
85
|
+
const t = event.type;
|
|
86
|
+
if (t === "tool_execution_start") {
|
|
87
|
+
const name = event.name ?? event.toolName ?? "unknown";
|
|
88
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} tool:start] ${name}${harnessUtils_1.RESET}\n`);
|
|
89
|
+
}
|
|
90
|
+
else if (t === "tool_execution_end") {
|
|
91
|
+
const name = event.name ?? event.toolName ?? "unknown";
|
|
92
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} tool:end] ${name}${harnessUtils_1.RESET}\n`);
|
|
93
|
+
}
|
|
94
|
+
else if (t === "turn_start") {
|
|
95
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} turn:start]${harnessUtils_1.RESET}\n`);
|
|
96
|
+
}
|
|
97
|
+
else if (t === "turn_end") {
|
|
98
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} turn:end]${harnessUtils_1.RESET}\n`);
|
|
99
|
+
}
|
|
100
|
+
else if (t === "message_start") {
|
|
101
|
+
const role = event.role
|
|
102
|
+
?? event.message?.role ?? "";
|
|
103
|
+
if (role) {
|
|
104
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} message:start] role=${role}${harnessUtils_1.RESET}\n`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (t === "agent_start") {
|
|
108
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} agent:start]${harnessUtils_1.RESET}\n`);
|
|
109
|
+
}
|
|
110
|
+
else if (t === "agent_end") {
|
|
111
|
+
process.stderr.write(`${harnessUtils_1.DIM}[${label} agent:end]${harnessUtils_1.RESET}\n`);
|
|
112
|
+
}
|
|
113
|
+
else if (t === "text_delta") {
|
|
114
|
+
const text = event.text;
|
|
115
|
+
if (text)
|
|
116
|
+
process.stderr.write(text);
|
|
117
|
+
}
|
|
118
|
+
// tool_execution_update and message_update are high-frequency streaming
|
|
119
|
+
// events; skip them to avoid drowning stderr.
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Session not yet initialized — caller should retry after initialize().
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
69
127
|
// ── Effect Resolution ────────────────────────────────────────────────
|
|
70
128
|
async function resolveEffect(action, harnessName, options, piSession, discovered, rl, json, askUserQuestionHandler) {
|
|
71
129
|
const kind = action.kind;
|
|
@@ -577,6 +635,7 @@ async function runOrchestrationPhase(args) {
|
|
|
577
635
|
for (const action of result.nextActions) {
|
|
578
636
|
const taskHarness = (0, harnessUtils_1.resolveTaskHarness)(action, args.selectedHarnessName, args.discovered);
|
|
579
637
|
let workerSession = null;
|
|
638
|
+
let workerUnsub = null;
|
|
580
639
|
if (action.kind === "shell" || (0, harnessUtils_1.isInternalHarness)(taskHarness)) {
|
|
581
640
|
workerSession = registerPiSession((0, harnessUtils_1.createPiSession)((0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
582
641
|
action,
|
|
@@ -585,12 +644,20 @@ async function runOrchestrationPhase(args) {
|
|
|
585
644
|
})));
|
|
586
645
|
}
|
|
587
646
|
const piSessionFactory = (action.kind === "shell" || (0, harnessUtils_1.isInternalHarness)(taskHarness))
|
|
588
|
-
? () =>
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
647
|
+
? () => {
|
|
648
|
+
const s = registerPiSession((0, harnessUtils_1.createPiSession)((0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
649
|
+
action,
|
|
650
|
+
workspace: args.workspace,
|
|
651
|
+
model: args.model,
|
|
652
|
+
})));
|
|
653
|
+
workerUnsub?.();
|
|
654
|
+
workerUnsub = subscribeVerbosePiEvents(s, `worker:${action.effectId.slice(-8)}`, args);
|
|
655
|
+
return s;
|
|
656
|
+
}
|
|
593
657
|
: undefined;
|
|
658
|
+
if (workerSession) {
|
|
659
|
+
workerUnsub = subscribeVerbosePiEvents(workerSession, `worker:${action.effectId.slice(-8)}`, args);
|
|
660
|
+
}
|
|
594
661
|
try {
|
|
595
662
|
const effectResult = await resolveEffectWithRetry(action, args.selectedHarnessName, {
|
|
596
663
|
workspace: args.workspace,
|
|
@@ -630,6 +697,7 @@ async function runOrchestrationPhase(args) {
|
|
|
630
697
|
}, args.json, args.verbose);
|
|
631
698
|
}
|
|
632
699
|
finally {
|
|
700
|
+
workerUnsub?.();
|
|
633
701
|
await shutdownPiSession(workerSession);
|
|
634
702
|
}
|
|
635
703
|
}
|
|
@@ -929,12 +997,19 @@ async function runOrchestrationPhase(args) {
|
|
|
929
997
|
});
|
|
930
998
|
writeVerboseData("phase2 worker session options", workerSessionOptions);
|
|
931
999
|
const workerSession = registerPiSession((0, harnessUtils_1.createPiSession)(workerSessionOptions));
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1000
|
+
const shellLabel = `shell-worker:${params.effectId.slice(-8)}`;
|
|
1001
|
+
let shellUnsub = subscribeVerbosePiEvents(workerSession, shellLabel, args);
|
|
1002
|
+
const piSessionFactory = () => {
|
|
1003
|
+
const s = registerPiSession((0, harnessUtils_1.createPiSession)((0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
1004
|
+
action,
|
|
1005
|
+
workspace: args.workspace,
|
|
1006
|
+
model: args.model,
|
|
1007
|
+
customTools: phase2AgenticTools,
|
|
1008
|
+
})));
|
|
1009
|
+
shellUnsub?.();
|
|
1010
|
+
shellUnsub = subscribeVerbosePiEvents(s, shellLabel, args);
|
|
1011
|
+
return s;
|
|
1012
|
+
};
|
|
938
1013
|
try {
|
|
939
1014
|
const effectResult = await resolveEffectWithRetry(action, "pi", {
|
|
940
1015
|
workspace: args.workspace,
|
|
@@ -950,10 +1025,7 @@ async function runOrchestrationPhase(args) {
|
|
|
950
1025
|
return (0, harnessUtils_1.formatToolResult)({ effectId: params.effectId, effectResult }, "Shell effect executed on the internal PI worker and staged for task posting.");
|
|
951
1026
|
}
|
|
952
1027
|
finally {
|
|
953
|
-
|
|
954
|
-
// session is disposed inside resolveEffectWithRetry on the next retry
|
|
955
|
-
// or returned as currentPiSession. The original workerSession may have
|
|
956
|
-
// been disposed during retry. This dispose is a safety net.
|
|
1028
|
+
shellUnsub?.();
|
|
957
1029
|
await shutdownPiSession(workerSession);
|
|
958
1030
|
}
|
|
959
1031
|
},
|
|
@@ -1028,13 +1100,20 @@ async function runOrchestrationPhase(args) {
|
|
|
1028
1100
|
});
|
|
1029
1101
|
writeVerboseData("phase2 worker session options", workerSessionOptions);
|
|
1030
1102
|
const workerSession = registerPiSession((0, harnessUtils_1.createPiSession)(workerSessionOptions));
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1103
|
+
const dispShellLabel = `dispatch-shell:${params.effectId.slice(-8)}`;
|
|
1104
|
+
let dispShellUnsub = subscribeVerbosePiEvents(workerSession, dispShellLabel, args);
|
|
1105
|
+
const shellPiSessionFactory = () => {
|
|
1106
|
+
const s = registerPiSession((0, harnessUtils_1.createPiSession)((0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
1107
|
+
action,
|
|
1108
|
+
workspace: args.workspace,
|
|
1109
|
+
model: args.model,
|
|
1110
|
+
customTools: phase2AgenticTools,
|
|
1111
|
+
delegationConfig,
|
|
1112
|
+
})));
|
|
1113
|
+
dispShellUnsub?.();
|
|
1114
|
+
dispShellUnsub = subscribeVerbosePiEvents(s, dispShellLabel, args);
|
|
1115
|
+
return s;
|
|
1116
|
+
};
|
|
1038
1117
|
try {
|
|
1039
1118
|
const effectResult = await resolveEffectWithRetry(action, requestedHarness ?? "pi", {
|
|
1040
1119
|
workspace: args.workspace,
|
|
@@ -1051,6 +1130,7 @@ async function runOrchestrationPhase(args) {
|
|
|
1051
1130
|
return (0, harnessUtils_1.formatToolResult)({ effectId: params.effectId, selectedHarness: "pi", effectResult }, "Shell effect executed on the internal PI worker and staged for task posting.");
|
|
1052
1131
|
}
|
|
1053
1132
|
finally {
|
|
1133
|
+
dispShellUnsub?.();
|
|
1054
1134
|
await shutdownPiSession(workerSession);
|
|
1055
1135
|
}
|
|
1056
1136
|
}
|
|
@@ -1065,14 +1145,21 @@ async function runOrchestrationPhase(args) {
|
|
|
1065
1145
|
delegationConfig,
|
|
1066
1146
|
});
|
|
1067
1147
|
let workerSession = null;
|
|
1148
|
+
let dispatchUnsub = null;
|
|
1149
|
+
const dispatchLabel = `dispatch:${params.effectId.slice(-8)}`;
|
|
1068
1150
|
const dispatchPiSessionFactory = (0, harnessUtils_1.isInternalHarness)(taskHarness)
|
|
1069
|
-
? () =>
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1151
|
+
? () => {
|
|
1152
|
+
const s = registerPiSession((0, harnessUtils_1.createPiSession)((0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
1153
|
+
action,
|
|
1154
|
+
workspace: args.workspace,
|
|
1155
|
+
model: args.model,
|
|
1156
|
+
customTools: phase2AgenticTools,
|
|
1157
|
+
delegationConfig,
|
|
1158
|
+
})));
|
|
1159
|
+
dispatchUnsub?.();
|
|
1160
|
+
dispatchUnsub = subscribeVerbosePiEvents(s, dispatchLabel, args);
|
|
1161
|
+
return s;
|
|
1162
|
+
}
|
|
1076
1163
|
: undefined;
|
|
1077
1164
|
if ((0, harnessUtils_1.isInternalHarness)(taskHarness)) {
|
|
1078
1165
|
workerSession = registerPiSession((0, harnessUtils_1.createPiSession)((0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
@@ -1082,6 +1169,7 @@ async function runOrchestrationPhase(args) {
|
|
|
1082
1169
|
customTools: phase2AgenticTools,
|
|
1083
1170
|
delegationConfig,
|
|
1084
1171
|
})));
|
|
1172
|
+
dispatchUnsub = subscribeVerbosePiEvents(workerSession, dispatchLabel, args);
|
|
1085
1173
|
writeVerboseData("phase2 worker session options", (0, harnessUtils_1.buildPiWorkerSessionOptions)({
|
|
1086
1174
|
action,
|
|
1087
1175
|
workspace: args.workspace,
|
|
@@ -1106,6 +1194,7 @@ async function runOrchestrationPhase(args) {
|
|
|
1106
1194
|
return (0, harnessUtils_1.formatToolResult)({ effectId: params.effectId, selectedHarness: taskHarness, effectResult }, "Effect dispatched through the selected harness and staged for task posting.");
|
|
1107
1195
|
}
|
|
1108
1196
|
finally {
|
|
1197
|
+
dispatchUnsub?.();
|
|
1109
1198
|
await shutdownPiSession(workerSession);
|
|
1110
1199
|
}
|
|
1111
1200
|
},
|
|
@@ -1396,13 +1485,7 @@ async function runOrchestrationPhase(args) {
|
|
|
1396
1485
|
try {
|
|
1397
1486
|
await orchestrationSession.initialize();
|
|
1398
1487
|
if (!args.json && args.verbose) {
|
|
1399
|
-
unsubscribe = orchestrationSession
|
|
1400
|
-
if (event.type === "text_delta") {
|
|
1401
|
-
const text = event.text;
|
|
1402
|
-
if (text)
|
|
1403
|
-
process.stderr.write(text);
|
|
1404
|
-
}
|
|
1405
|
-
});
|
|
1488
|
+
unsubscribe = subscribeVerbosePiEvents(orchestrationSession, "orchestrator", args);
|
|
1406
1489
|
}
|
|
1407
1490
|
await completeBootstrapAgentically();
|
|
1408
1491
|
if (!state.runId || !state.runDir) {
|
package/package.json
CHANGED