@melaya/runner 1.0.106 → 1.0.108
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/connection.js +15 -0
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -1030,6 +1030,13 @@ export async function connect(opts) {
|
|
|
1030
1030
|
activeAssistants.set(sid, session);
|
|
1031
1031
|
console.log(chalk.hex("#7c6ff0")(` ◆ Assistant session ${sid.slice(0, 10)}… (${payload.provider})`));
|
|
1032
1032
|
proc.stdout?.on("data", (data) => {
|
|
1033
|
+
// ANY host output means the turn is actively working — refresh the idle
|
|
1034
|
+
// clock. Without this, lastActivity was set ONLY at turn start (assistant_turn),
|
|
1035
|
+
// so a SINGLE long turn (a phone task is one turn with ~100 tool calls streaming
|
|
1036
|
+
// for >15 min) was reaped mid-action by the idle sweep despite continuous
|
|
1037
|
+
// activity ("idle-swept" while properly working). Now only a genuinely silent
|
|
1038
|
+
// host (no output for ASSISTANT_IDLE_MS) is swept.
|
|
1039
|
+
session.lastActivity = Date.now();
|
|
1033
1040
|
session.stdoutBuf += data.toString();
|
|
1034
1041
|
let idx;
|
|
1035
1042
|
while ((idx = session.stdoutBuf.indexOf("\n")) >= 0) {
|
|
@@ -1170,6 +1177,14 @@ export async function connect(opts) {
|
|
|
1170
1177
|
activeAssistants.delete(String(payload.sessionId));
|
|
1171
1178
|
}
|
|
1172
1179
|
});
|
|
1180
|
+
// Keepalive: the server is blocked waiting on the user's behalf (a HITL approval
|
|
1181
|
+
// poll, a slow phone action) so the host emits no stdout, but the turn is ALIVE.
|
|
1182
|
+
// Refresh the idle clock so the idle sweep doesn't reap a host mid-approval.
|
|
1183
|
+
socket.on("runner:assistant_keepalive", (payload) => {
|
|
1184
|
+
const s = activeAssistants.get(String(payload.sessionId || ""));
|
|
1185
|
+
if (s)
|
|
1186
|
+
s.lastActivity = Date.now();
|
|
1187
|
+
});
|
|
1173
1188
|
// Cooperative cancel: the user pressed STOP in chat. Write a cancel line to the
|
|
1174
1189
|
// host's stdin — its stdin reader thread flips a flag the running turn's
|
|
1175
1190
|
// hooks poll, so the agent loop aborts BETWEEN steps (right where the next
|