@melaya/runner 1.0.77 → 1.0.78
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 +13 -5
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -825,7 +825,10 @@ export async function connect(opts) {
|
|
|
825
825
|
emitEv({ kind: "error", message: "assistantHost.py not found — reinstall @melaya/runner" });
|
|
826
826
|
return;
|
|
827
827
|
}
|
|
828
|
-
|
|
828
|
+
// Sanitize the session id for a filesystem path — it is
|
|
829
|
+
// `userId:conversationId`, and ':' is illegal in a Windows dir name.
|
|
830
|
+
const safeSid = sid.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
831
|
+
const workDir = join(tmpdir(), `melaya-assistant-${safeSid}`);
|
|
829
832
|
mkdirSync(workDir, { recursive: true });
|
|
830
833
|
const stagedHost = join(workDir, "assistantHost.py");
|
|
831
834
|
copyFileSync(hostScript, stagedHost);
|
|
@@ -872,18 +875,23 @@ export async function connect(opts) {
|
|
|
872
875
|
}
|
|
873
876
|
}
|
|
874
877
|
});
|
|
878
|
+
const stderrTail = [];
|
|
875
879
|
proc.stderr?.on("data", (data) => {
|
|
876
|
-
if (!opts.verbose)
|
|
877
|
-
return;
|
|
878
880
|
for (const ln of data.toString().split("\n")) {
|
|
879
881
|
const t = ln.trimEnd();
|
|
880
|
-
if (t)
|
|
882
|
+
if (!t)
|
|
883
|
+
continue;
|
|
884
|
+
if (opts.verbose)
|
|
881
885
|
console.log(chalk.gray(` [assistant-stderr] ${t}`));
|
|
886
|
+
stderrTail.push(t);
|
|
887
|
+
if (stderrTail.length > 40)
|
|
888
|
+
stderrTail.shift();
|
|
882
889
|
}
|
|
883
890
|
});
|
|
884
891
|
proc.on("exit", (code) => {
|
|
885
892
|
activeAssistants.delete(sid);
|
|
886
|
-
|
|
893
|
+
const detail = code !== 0 && stderrTail.length ? stderrTail.slice(-12).join("\n") : "";
|
|
894
|
+
socket.emit("runner:assistant_event", { sessionId: sid, turnId: "", kind: "session_closed", code, detail });
|
|
887
895
|
console.log(chalk.gray(` ■ Assistant session ${sid.slice(0, 10)}… closed (exit ${code})`));
|
|
888
896
|
});
|
|
889
897
|
}
|