copilotoffice 1.0.4 → 1.1.1
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/electron/main.js +21 -3
- package/dist/electron/terminal/ipc-relay.js +19 -2
- package/dist/electron/terminal/preload.js +3 -0
- package/dist/electron/terminal/server.js +46 -18
- package/dist/game.bundle.js +1888 -369
- package/package.json +1 -1
package/dist/electron/main.js
CHANGED
|
@@ -33,7 +33,7 @@ var import_electron = require("electron");
|
|
|
33
33
|
var import_child_process = require("child_process");
|
|
34
34
|
var crypto = __toESM(require("crypto"));
|
|
35
35
|
var path = __toESM(require("path"));
|
|
36
|
-
var TerminalRelay = class {
|
|
36
|
+
var TerminalRelay = class _TerminalRelay {
|
|
37
37
|
constructor(getWindow) {
|
|
38
38
|
this.server = null;
|
|
39
39
|
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
@@ -43,6 +43,10 @@ var TerminalRelay = class {
|
|
|
43
43
|
this.queuedRequests = [];
|
|
44
44
|
this.getWindow = getWindow;
|
|
45
45
|
}
|
|
46
|
+
static {
|
|
47
|
+
/** Timeout for IPC request/response round-trips (ms). */
|
|
48
|
+
this.REQUEST_TIMEOUT_MS = 1e4;
|
|
49
|
+
}
|
|
46
50
|
// ── Server Lifecycle ──────────────────────────────────────────
|
|
47
51
|
spawnServer(distDir) {
|
|
48
52
|
return new Promise((resolve, reject) => {
|
|
@@ -141,7 +145,16 @@ var TerminalRelay = class {
|
|
|
141
145
|
});
|
|
142
146
|
}
|
|
143
147
|
return new Promise((resolve) => {
|
|
144
|
-
|
|
148
|
+
const timeout = setTimeout(() => {
|
|
149
|
+
if (this.pendingRequests.delete(msg.requestId)) {
|
|
150
|
+
console.warn(`[Relay] Request ${msg.type} (${msg.requestId}) timed out after ${_TerminalRelay.REQUEST_TIMEOUT_MS}ms`);
|
|
151
|
+
resolve({ success: false, error: "Request timed out" });
|
|
152
|
+
}
|
|
153
|
+
}, _TerminalRelay.REQUEST_TIMEOUT_MS);
|
|
154
|
+
this.pendingRequests.set(msg.requestId, (result) => {
|
|
155
|
+
clearTimeout(timeout);
|
|
156
|
+
resolve(result);
|
|
157
|
+
});
|
|
145
158
|
this.send(msg);
|
|
146
159
|
});
|
|
147
160
|
}
|
|
@@ -245,6 +258,10 @@ var TerminalRelay = class {
|
|
|
245
258
|
"get-session-id",
|
|
246
259
|
(_event, officeId, agentId) => this.request({ type: "get-session-id", requestId: this.id(), officeId, agentId })
|
|
247
260
|
);
|
|
261
|
+
import_electron.ipcMain.handle(
|
|
262
|
+
"set-session-id",
|
|
263
|
+
(_event, officeId, agentId, sessionId) => this.request({ type: "set-session-id", requestId: this.id(), officeId, agentId, sessionId })
|
|
264
|
+
);
|
|
248
265
|
import_electron.ipcMain.handle(
|
|
249
266
|
"reset-all-sessions",
|
|
250
267
|
(_event, officeId) => this.request({ type: "reset-all-sessions", requestId: this.id(), officeId })
|
|
@@ -380,7 +397,8 @@ function createWindow() {
|
|
|
380
397
|
webPreferences: {
|
|
381
398
|
preload: path2.join(__dirname, "terminal", "preload.js"),
|
|
382
399
|
contextIsolation: true,
|
|
383
|
-
nodeIntegration: false
|
|
400
|
+
nodeIntegration: false,
|
|
401
|
+
backgroundThrottling: false
|
|
384
402
|
}
|
|
385
403
|
});
|
|
386
404
|
mainWindow.maximize();
|
|
@@ -37,7 +37,7 @@ var import_electron = require("electron");
|
|
|
37
37
|
var import_child_process = require("child_process");
|
|
38
38
|
var crypto = __toESM(require("crypto"));
|
|
39
39
|
var path = __toESM(require("path"));
|
|
40
|
-
var TerminalRelay = class {
|
|
40
|
+
var TerminalRelay = class _TerminalRelay {
|
|
41
41
|
constructor(getWindow) {
|
|
42
42
|
this.server = null;
|
|
43
43
|
this.pendingRequests = /* @__PURE__ */ new Map();
|
|
@@ -47,6 +47,10 @@ var TerminalRelay = class {
|
|
|
47
47
|
this.queuedRequests = [];
|
|
48
48
|
this.getWindow = getWindow;
|
|
49
49
|
}
|
|
50
|
+
static {
|
|
51
|
+
/** Timeout for IPC request/response round-trips (ms). */
|
|
52
|
+
this.REQUEST_TIMEOUT_MS = 1e4;
|
|
53
|
+
}
|
|
50
54
|
// ── Server Lifecycle ──────────────────────────────────────────
|
|
51
55
|
spawnServer(distDir) {
|
|
52
56
|
return new Promise((resolve, reject) => {
|
|
@@ -145,7 +149,16 @@ var TerminalRelay = class {
|
|
|
145
149
|
});
|
|
146
150
|
}
|
|
147
151
|
return new Promise((resolve) => {
|
|
148
|
-
|
|
152
|
+
const timeout = setTimeout(() => {
|
|
153
|
+
if (this.pendingRequests.delete(msg.requestId)) {
|
|
154
|
+
console.warn(`[Relay] Request ${msg.type} (${msg.requestId}) timed out after ${_TerminalRelay.REQUEST_TIMEOUT_MS}ms`);
|
|
155
|
+
resolve({ success: false, error: "Request timed out" });
|
|
156
|
+
}
|
|
157
|
+
}, _TerminalRelay.REQUEST_TIMEOUT_MS);
|
|
158
|
+
this.pendingRequests.set(msg.requestId, (result) => {
|
|
159
|
+
clearTimeout(timeout);
|
|
160
|
+
resolve(result);
|
|
161
|
+
});
|
|
149
162
|
this.send(msg);
|
|
150
163
|
});
|
|
151
164
|
}
|
|
@@ -249,6 +262,10 @@ var TerminalRelay = class {
|
|
|
249
262
|
"get-session-id",
|
|
250
263
|
(_event, officeId, agentId) => this.request({ type: "get-session-id", requestId: this.id(), officeId, agentId })
|
|
251
264
|
);
|
|
265
|
+
import_electron.ipcMain.handle(
|
|
266
|
+
"set-session-id",
|
|
267
|
+
(_event, officeId, agentId, sessionId) => this.request({ type: "set-session-id", requestId: this.id(), officeId, agentId, sessionId })
|
|
268
|
+
);
|
|
252
269
|
import_electron.ipcMain.handle(
|
|
253
270
|
"reset-all-sessions",
|
|
254
271
|
(_event, officeId) => this.request({ type: "reset-all-sessions", requestId: this.id(), officeId })
|
|
@@ -47,6 +47,9 @@ import_electron.contextBridge.exposeInMainWorld("copilotBridge", {
|
|
|
47
47
|
getSessionId: (officeId, agentId) => {
|
|
48
48
|
return import_electron.ipcRenderer.invoke("get-session-id", officeId, agentId);
|
|
49
49
|
},
|
|
50
|
+
setSessionId: (officeId, agentId, sessionId) => {
|
|
51
|
+
return import_electron.ipcRenderer.invoke("set-session-id", officeId, agentId, sessionId);
|
|
52
|
+
},
|
|
50
53
|
resetAllSessions: (officeId) => {
|
|
51
54
|
return import_electron.ipcRenderer.invoke("reset-all-sessions", officeId);
|
|
52
55
|
},
|
|
@@ -5907,22 +5907,25 @@ async function startTerminalForAgent(officeId, agentId, workingDir, cols, rows,
|
|
|
5907
5907
|
} else if (event.type === "user.message") {
|
|
5908
5908
|
console.log(`[TermServer] Forwarding user_message for ${ck}, data keys: ${JSON.stringify(Object.keys(event.data || {}))}`);
|
|
5909
5909
|
send({ type: "copilot-user-message", agentId });
|
|
5910
|
-
|
|
5910
|
+
const existing = officeData.sessionMeta.get(agentId);
|
|
5911
|
+
const existingTitle = typeof existing?.title === "string" ? existing.title.trim() : "";
|
|
5912
|
+
if (existingTitle) {
|
|
5911
5913
|
hasAutoTitled.add(ck);
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5914
|
+
} else {
|
|
5915
|
+
const d = event.data;
|
|
5916
|
+
const msgText = d?.content || d?.message || d?.text || d?.input || d?.prompt || d?.body || "";
|
|
5917
|
+
const raw = String(msgText).trim();
|
|
5918
|
+
if (raw) {
|
|
5919
|
+
const title = raw.length > 80 ? raw.slice(0, 77) + "..." : raw;
|
|
5920
|
+
const meta = existing || { title: "" };
|
|
5921
|
+
meta.title = title;
|
|
5922
|
+
officeData.sessionMeta.set(agentId, meta);
|
|
5923
|
+
saveOfficeSessionFile(officeId);
|
|
5924
|
+
hasAutoTitled.add(ck);
|
|
5925
|
+
console.log(`[TermServer] Auto-titled ${ck}: "${title}"`);
|
|
5926
|
+
send({ type: "session-meta-updated", agentId, meta: { ...meta } });
|
|
5927
|
+
} else {
|
|
5928
|
+
hasAutoTitled.delete(ck);
|
|
5926
5929
|
}
|
|
5927
5930
|
}
|
|
5928
5931
|
} else if (event.type === "subagent.started") {
|
|
@@ -5985,8 +5988,8 @@ async function startTerminalForAgent(officeId, agentId, workingDir, cols, rows,
|
|
|
5985
5988
|
});
|
|
5986
5989
|
if (!shellOnlyMode && terminalBackend.name === "node-pty") {
|
|
5987
5990
|
setTimeout(() => {
|
|
5988
|
-
console.log(`[TermServer] Starting copilot --
|
|
5989
|
-
proc.write(`copilot --
|
|
5991
|
+
console.log(`[TermServer] Starting copilot --session-id for ${ck}: ${sessionId}`);
|
|
5992
|
+
proc.write(`copilot --session-id ${sessionId}\r`);
|
|
5990
5993
|
}, 500);
|
|
5991
5994
|
}
|
|
5992
5995
|
return { success: true, pid: proc.pid, sessionId };
|
|
@@ -6085,6 +6088,25 @@ async function handleMessage(msg) {
|
|
|
6085
6088
|
send({ type: "response", requestId: msg.requestId, result: officeData.sessionIds.get(msg.agentId) || null });
|
|
6086
6089
|
break;
|
|
6087
6090
|
}
|
|
6091
|
+
case "set-session-id": {
|
|
6092
|
+
const normalized = msg.sessionId.trim().toLowerCase();
|
|
6093
|
+
const officeData = getOfficeSession(msg.officeId);
|
|
6094
|
+
const current = officeData.sessionIds.get(msg.agentId);
|
|
6095
|
+
const changed = !!normalized && current !== normalized;
|
|
6096
|
+
if (changed) {
|
|
6097
|
+
archiveSessionId(msg.officeId, msg.agentId);
|
|
6098
|
+
officeData.sessionIds.set(msg.agentId, normalized);
|
|
6099
|
+
await saveOfficeSessionFile(msg.officeId);
|
|
6100
|
+
console.log(`[TermServer] Updated session ID for ${compositeKey(msg.officeId, msg.agentId)}: ${current ?? "(none)"} -> ${normalized}`);
|
|
6101
|
+
}
|
|
6102
|
+
const key = getTerminalKey(msg.officeId, msg.agentId);
|
|
6103
|
+
const proc = key ? ptyProcesses.get(key) : null;
|
|
6104
|
+
if (proc && changed) {
|
|
6105
|
+
proc.sessionId = normalized;
|
|
6106
|
+
}
|
|
6107
|
+
send({ type: "response", requestId: msg.requestId, result: { success: true } });
|
|
6108
|
+
break;
|
|
6109
|
+
}
|
|
6088
6110
|
case "pop-out": {
|
|
6089
6111
|
const ck = compositeKey(msg.officeId, msg.agentId);
|
|
6090
6112
|
const officeData = getOfficeSession(msg.officeId);
|
|
@@ -6105,7 +6127,7 @@ async function handleMessage(msg) {
|
|
|
6105
6127
|
}
|
|
6106
6128
|
}
|
|
6107
6129
|
try {
|
|
6108
|
-
(0, import_child_process2.spawn)("wt", ["-d", cwd, "copilot", "--
|
|
6130
|
+
(0, import_child_process2.spawn)("wt", ["-d", cwd, "copilot", "--session-id", sid], { detached: true, stdio: "ignore" }).unref();
|
|
6109
6131
|
send({ type: "response", requestId: msg.requestId, result: { success: true } });
|
|
6110
6132
|
} catch (error) {
|
|
6111
6133
|
send({ type: "response", requestId: msg.requestId, result: { success: false, error: String(error) } });
|
|
@@ -6224,6 +6246,12 @@ async function handleMessage(msg) {
|
|
|
6224
6246
|
const officeData = getOfficeSession(officeId);
|
|
6225
6247
|
const existing = officeData.sessionMeta.get(agentId) || { title: "" };
|
|
6226
6248
|
if (meta.title !== void 0) existing.title = meta.title;
|
|
6249
|
+
const ck = compositeKey(officeId, agentId);
|
|
6250
|
+
if ((existing.title || "").trim()) {
|
|
6251
|
+
hasAutoTitled.add(ck);
|
|
6252
|
+
} else {
|
|
6253
|
+
hasAutoTitled.delete(ck);
|
|
6254
|
+
}
|
|
6227
6255
|
officeData.sessionMeta.set(agentId, existing);
|
|
6228
6256
|
await saveOfficeSessionFile(officeId);
|
|
6229
6257
|
send({ type: "response", requestId: msg.requestId, result: { success: true } });
|