ai-lab-bridge 0.1.3 → 0.1.4
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/index.js +10 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -136,6 +136,7 @@ const BRIDGE_VERSION = (() => {
|
|
|
136
136
|
// 连接参数由各子命令解析填充(connect/daemon 需要,status/stop 不需要)
|
|
137
137
|
let SERVER = "";
|
|
138
138
|
let TOKEN = "";
|
|
139
|
+
let sessionCwd = ""; // 当前任务的实际工作目录(emitSession 回传用)
|
|
139
140
|
|
|
140
141
|
// ---------------------------------------------------------------------------
|
|
141
142
|
// CLI 能力探测
|
|
@@ -234,7 +235,11 @@ class Session {
|
|
|
234
235
|
emitSession(cliSessionId) {
|
|
235
236
|
if (!cliSessionId || this.cliSessionId) return;
|
|
236
237
|
this.cliSessionId = cliSessionId;
|
|
237
|
-
this.emitEvent("session", {
|
|
238
|
+
this.emitEvent("session", {
|
|
239
|
+
cli_session_id: cliSessionId,
|
|
240
|
+
// 设备实际执行的工作目录(CLI cwd 或 bridge 进程启动目录),平台前端展示用
|
|
241
|
+
working_dir: sessionCwd || null,
|
|
242
|
+
});
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
/**
|
|
@@ -720,6 +725,8 @@ function startSession(message) {
|
|
|
720
725
|
|
|
721
726
|
const timeoutSeconds = Number(options.timeout_seconds) > 0 ? Number(options.timeout_seconds) : 0;
|
|
722
727
|
const cwd = typeof options.cwd === "string" && options.cwd ? options.cwd : process.cwd();
|
|
728
|
+
// 供 emitSession 回传实际工作目录(Session 构造在 cwd 解析之前,用模块级变量传递)
|
|
729
|
+
sessionCwd = cwd;
|
|
723
730
|
let argv;
|
|
724
731
|
|
|
725
732
|
let promptViaStdin = true;
|
|
@@ -942,7 +949,8 @@ async function connect() {
|
|
|
942
949
|
for (const cap of capabilities) {
|
|
943
950
|
console.log(`[bridge] ${cap.cli}: ${cap.available ? `可用 (${cap.version})` : "未安装"}`);
|
|
944
951
|
}
|
|
945
|
-
|
|
952
|
+
// working_dir:bridge 进程启动目录,作为未配置 cwd 时任务的默认工作目录(平台前端展示)
|
|
953
|
+
send({ type: "register", capabilities, working_dir: process.cwd() });
|
|
946
954
|
startHeartbeat();
|
|
947
955
|
} else if (message.type === "registered") {
|
|
948
956
|
console.log("[bridge] 能力注册完成,等待任务下发");
|