@strayl/agent 0.1.21 → 0.1.22
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/agent.js +17 -1
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -12380,6 +12380,10 @@ var StdinListener = class {
|
|
|
12380
12380
|
isCancelled() {
|
|
12381
12381
|
return this.cancelled;
|
|
12382
12382
|
}
|
|
12383
|
+
/** Put commands back at the front of the queue (for re-queuing unhandled commands) */
|
|
12384
|
+
requeue(...cmds) {
|
|
12385
|
+
this.queue.unshift(...cmds);
|
|
12386
|
+
}
|
|
12383
12387
|
stop() {
|
|
12384
12388
|
this.rl?.close();
|
|
12385
12389
|
this.rl = null;
|
|
@@ -13582,6 +13586,7 @@ ${config.previousSummary}`);
|
|
|
13582
13586
|
}
|
|
13583
13587
|
while (iteration < maxIterations) {
|
|
13584
13588
|
iteration++;
|
|
13589
|
+
emitter.emit({ type: "debug", message: `[LOOP] iteration=${iteration}/${maxIterations} mode=${currentMode} nudgedToContinue=${nudgedToContinue}` });
|
|
13585
13590
|
for (const cmd of stdin.drain()) {
|
|
13586
13591
|
switch (cmd.type) {
|
|
13587
13592
|
case "inject":
|
|
@@ -13750,13 +13755,17 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
|
|
|
13750
13755
|
});
|
|
13751
13756
|
}
|
|
13752
13757
|
if (completedToolCalls.length === 0) {
|
|
13758
|
+
emitter.emit({ type: "debug", message: `[LOOP] No tool calls. textLen=${assistantText.length} nudgedToContinue=${nudgedToContinue} text="${assistantText.slice(0, 200)}"` });
|
|
13753
13759
|
if (!nudgedToContinue) {
|
|
13754
13760
|
nudgedToContinue = true;
|
|
13761
|
+
emitter.emit({ type: "debug", message: `[LOOP] Sending nudge to continue...` });
|
|
13755
13762
|
context.addUser("[System: You responded with text but did not call any tools. If you are done, respond with your final message. Otherwise, use your tools to continue working.]");
|
|
13756
13763
|
continue;
|
|
13757
13764
|
}
|
|
13765
|
+
emitter.emit({ type: "debug", message: `[LOOP] Already nudged, breaking loop. Agent will terminate.` });
|
|
13758
13766
|
break;
|
|
13759
13767
|
}
|
|
13768
|
+
emitter.emit({ type: "debug", message: `[LOOP] Tool calls: ${completedToolCalls.map((tc) => tc.function.name).join(", ")}` });
|
|
13760
13769
|
nudgedToContinue = false;
|
|
13761
13770
|
for (const tc of completedToolCalls) {
|
|
13762
13771
|
if (stdin.isCancelled()) {
|
|
@@ -13777,12 +13786,15 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
|
|
|
13777
13786
|
emitter.emit({ type: "tool-call-start", id: tc.id, name: tc.function.name, args: parsedArgs });
|
|
13778
13787
|
const toolDef = registry.get(tc.function.name);
|
|
13779
13788
|
if (toolDef?.hitl) {
|
|
13789
|
+
emitter.emit({ type: "debug", message: `[HITL] Requesting HITL for tool=${tc.function.name} safeId=${hitl.safeId(tc.id)}` });
|
|
13780
13790
|
emitter.emit({ type: "hitl-request", id: tc.id, safe_id: hitl.safeId(tc.id), tool: tc.function.name, args: parsedArgs });
|
|
13781
13791
|
const response = await hitl.waitForResponse(tc.id, async () => {
|
|
13782
13792
|
for (const cmd of stdin.drain()) {
|
|
13783
13793
|
if (cmd.type === "hitl-response") {
|
|
13784
13794
|
await hitl.writeResponse(cmd.id, { decision: cmd.decision, data: cmd.data });
|
|
13785
13795
|
} else if (cmd.type === "cancel") {
|
|
13796
|
+
} else {
|
|
13797
|
+
stdin.requeue(cmd);
|
|
13786
13798
|
}
|
|
13787
13799
|
}
|
|
13788
13800
|
});
|
|
@@ -13795,7 +13807,9 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
|
|
|
13795
13807
|
if (response.decision === "edit" && response.data && typeof response.data === "object") {
|
|
13796
13808
|
parsedArgs = { ...parsedArgs, ...response.data };
|
|
13797
13809
|
}
|
|
13810
|
+
emitter.emit({ type: "debug", message: `[HITL] Got response: decision=${response.decision} dataKeys=${response.data ? Object.keys(response.data).join(",") : "none"}` });
|
|
13798
13811
|
emitter.emit({ type: "hitl-response", id: tc.id, decision: response.decision, data: response.data });
|
|
13812
|
+
nudgedToContinue = false;
|
|
13799
13813
|
}
|
|
13800
13814
|
const toolCtx = {
|
|
13801
13815
|
emitter,
|
|
@@ -13831,10 +13845,12 @@ ${PLAN_MODE_SYSTEM_PROMPT2}`);
|
|
|
13831
13845
|
});
|
|
13832
13846
|
}
|
|
13833
13847
|
stdin.stop();
|
|
13848
|
+
const exitReason = iteration >= maxIterations ? "max_iterations" : "complete";
|
|
13849
|
+
emitter.emit({ type: "debug", message: `[SESSION-END] reason=${exitReason} iteration=${iteration}/${maxIterations} mode=${currentMode}` });
|
|
13834
13850
|
emitter.emit({
|
|
13835
13851
|
type: "session-end",
|
|
13836
13852
|
usage: context.totalUsage(),
|
|
13837
|
-
exit_reason:
|
|
13853
|
+
exit_reason: exitReason
|
|
13838
13854
|
});
|
|
13839
13855
|
}
|
|
13840
13856
|
function toolToActivity(name, args) {
|