copilotoffice 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilotoffice",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A 2D pixel-art game where you interact with AI agents in a virtual office",
5
5
  "main": "dist/electron/main.js",
6
6
  "bin": {
@@ -1,198 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // electron/events-watcher.ts
31
- var events_watcher_exports = {};
32
- __export(events_watcher_exports, {
33
- EventsWatcher: () => EventsWatcher,
34
- formatToolStatus: () => formatToolStatus
35
- });
36
- module.exports = __toCommonJS(events_watcher_exports);
37
- var fs = __toESM(require("fs"));
38
- var path = __toESM(require("path"));
39
- var os = __toESM(require("os"));
40
- var EventsWatcher = class _EventsWatcher {
41
- constructor(sessionId) {
42
- this.fileOffset = 0;
43
- this.lineBuffer = "";
44
- this.watcher = null;
45
- this.pollTimer = null;
46
- this.fileExistsTimer = null;
47
- this.callback = null;
48
- this.stopped = false;
49
- this.reading = false;
50
- this.sessionId = sessionId;
51
- this.filePath = path.join(
52
- os.homedir(),
53
- ".copilot",
54
- "session-state",
55
- sessionId,
56
- "events.jsonl"
57
- );
58
- }
59
- static {
60
- this.POLL_INTERVAL_MS = 500;
61
- }
62
- static {
63
- this.FILE_CHECK_INTERVAL_MS = 200;
64
- }
65
- static {
66
- this.MAX_FILE_WAIT_MS = 6e4;
67
- }
68
- getSessionId() {
69
- return this.sessionId;
70
- }
71
- getFilePath() {
72
- return this.filePath;
73
- }
74
- start(onEvent) {
75
- this.callback = onEvent;
76
- this.stopped = false;
77
- fs.promises.access(this.filePath, fs.constants.F_OK).then(() => this.startWatching()).catch(() => {
78
- console.log(`[EventsWatcher] Waiting for events.jsonl: ${this.filePath}`);
79
- const startTime = Date.now();
80
- this.fileExistsTimer = setInterval(() => {
81
- if (this.stopped) {
82
- if (this.fileExistsTimer) clearInterval(this.fileExistsTimer);
83
- return;
84
- }
85
- if (Date.now() - startTime > _EventsWatcher.MAX_FILE_WAIT_MS) {
86
- console.warn(`[EventsWatcher] Timed out waiting for events.jsonl after ${_EventsWatcher.MAX_FILE_WAIT_MS / 1e3}s`);
87
- if (this.fileExistsTimer) clearInterval(this.fileExistsTimer);
88
- this.fileExistsTimer = null;
89
- return;
90
- }
91
- fs.promises.access(this.filePath, fs.constants.F_OK).then(() => {
92
- console.log(`[EventsWatcher] Found events.jsonl`);
93
- if (this.fileExistsTimer) clearInterval(this.fileExistsTimer);
94
- this.fileExistsTimer = null;
95
- this.startWatching();
96
- }).catch(() => {
97
- });
98
- }, _EventsWatcher.FILE_CHECK_INTERVAL_MS);
99
- });
100
- }
101
- startWatching() {
102
- this.readNewLines();
103
- try {
104
- this.watcher = fs.watch(this.filePath, () => {
105
- if (!this.stopped) this.readNewLines();
106
- });
107
- } catch (e) {
108
- console.log(`[EventsWatcher] fs.watch failed: ${e}`);
109
- }
110
- this.pollTimer = setInterval(() => {
111
- if (!this.stopped) this.readNewLines();
112
- }, _EventsWatcher.POLL_INTERVAL_MS);
113
- }
114
- async readNewLines() {
115
- if (this.reading) return;
116
- this.reading = true;
117
- try {
118
- const stat = await fs.promises.stat(this.filePath);
119
- if (stat.size <= this.fileOffset) return;
120
- const handle = await fs.promises.open(this.filePath, "r");
121
- try {
122
- const buf = Buffer.alloc(stat.size - this.fileOffset);
123
- await handle.read(buf, 0, buf.length, this.fileOffset);
124
- this.fileOffset = stat.size;
125
- const text = this.lineBuffer + buf.toString("utf-8");
126
- const lines = text.split("\n");
127
- this.lineBuffer = lines.pop() || "";
128
- for (const line of lines) {
129
- if (!line.trim()) continue;
130
- try {
131
- const event = JSON.parse(line);
132
- if (this.callback) {
133
- this.callback(event);
134
- }
135
- } catch (e) {
136
- console.log(`[EventsWatcher] Failed to parse line: ${e}`);
137
- }
138
- }
139
- } finally {
140
- await handle.close();
141
- }
142
- } catch (e) {
143
- } finally {
144
- this.reading = false;
145
- }
146
- }
147
- stop() {
148
- this.stopped = true;
149
- if (this.fileExistsTimer) {
150
- clearInterval(this.fileExistsTimer);
151
- this.fileExistsTimer = null;
152
- }
153
- if (this.watcher) {
154
- this.watcher.close();
155
- this.watcher = null;
156
- }
157
- if (this.pollTimer) {
158
- clearInterval(this.pollTimer);
159
- this.pollTimer = null;
160
- }
161
- this.callback = null;
162
- }
163
- };
164
- function formatToolStatus(toolName, args) {
165
- const base = (p) => typeof p === "string" ? path.basename(p) : "";
166
- switch (toolName) {
167
- case "view":
168
- return `Reading ${base(args.path)}`;
169
- case "edit":
170
- return `Editing ${base(args.path)}`;
171
- case "create":
172
- return `Creating ${base(args.path)}`;
173
- case "powershell":
174
- const cmd = args.command || "";
175
- return `Running: ${cmd.length > 40 ? cmd.slice(0, 40) + "\u2026" : cmd}`;
176
- case "glob":
177
- return `Finding files: ${args.pattern || ""}`;
178
- case "grep":
179
- return `Searching: ${args.pattern || ""}`;
180
- case "web_fetch":
181
- return `Fetching: ${args.url || ""}`;
182
- case "task":
183
- return `Subtask: ${args.description || "running"}`;
184
- case "ask_user":
185
- return "Waiting for your answer";
186
- case "report_intent":
187
- return `${args.intent || "Working"}`;
188
- case "sql":
189
- return `Query: ${args.description || "running"}`;
190
- default:
191
- return `Using ${toolName}`;
192
- }
193
- }
194
- // Annotate the CommonJS export names for ESM import in node:
195
- 0 && (module.exports = {
196
- EventsWatcher,
197
- formatToolStatus
198
- });
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // electron/preload.ts
17
- var preload_exports = {};
18
- module.exports = __toCommonJS(preload_exports);
19
- var import_electron = require("electron");
20
- import_electron.contextBridge.exposeInMainWorld("copilotBridge", {
21
- // Terminal management
22
- terminalStart: (agentId, workingDir) => {
23
- return import_electron.ipcRenderer.invoke("terminal-start", agentId, workingDir);
24
- },
25
- terminalWrite: (agentId, data) => {
26
- return import_electron.ipcRenderer.invoke("terminal-write", agentId, data);
27
- },
28
- terminalResize: (agentId, cols, rows) => {
29
- return import_electron.ipcRenderer.invoke("terminal-resize", agentId, cols, rows);
30
- },
31
- terminalKill: (agentId) => {
32
- return import_electron.ipcRenderer.invoke("terminal-kill", agentId);
33
- },
34
- terminalExists: (agentId) => {
35
- return import_electron.ipcRenderer.invoke("terminal-exists", agentId);
36
- },
37
- terminalAttach: (agentId) => {
38
- return import_electron.ipcRenderer.invoke("terminal-attach", agentId);
39
- },
40
- terminalDetach: (agentId) => {
41
- return import_electron.ipcRenderer.invoke("terminal-detach", agentId);
42
- },
43
- terminalPopOut: (agentId) => {
44
- return import_electron.ipcRenderer.invoke("terminal-pop-out", agentId);
45
- },
46
- // Session persistence
47
- saveSessionId: (agentId, sessionId) => {
48
- return import_electron.ipcRenderer.invoke("save-session-id", agentId, sessionId);
49
- },
50
- getSessionId: (agentId) => {
51
- return import_electron.ipcRenderer.invoke("get-session-id", agentId);
52
- },
53
- // Terminal event listeners
54
- onTerminalData: (callback) => {
55
- import_electron.ipcRenderer.on("terminal-data", (_event, agentId, data) => callback(agentId, data));
56
- },
57
- onTerminalExit: (callback) => {
58
- import_electron.ipcRenderer.on("terminal-exit", (_event, agentId, exitCode) => callback(agentId, exitCode));
59
- },
60
- onTerminalPreloadStatus: (callback) => {
61
- import_electron.ipcRenderer.on("terminal-preload-status", (_event, agentId, status) => callback(agentId, status));
62
- },
63
- // Copilot activity event listeners
64
- onCopilotEvent: (callback) => {
65
- import_electron.ipcRenderer.on("copilot-event", (_event, agentId, copilotEvent) => callback(agentId, copilotEvent));
66
- },
67
- onCopilotToolStart: (callback) => {
68
- import_electron.ipcRenderer.on("copilot-tool-start", (_event, agentId, toolName, toolId, status) => callback(agentId, toolName, toolId, status));
69
- },
70
- onCopilotToolComplete: (callback) => {
71
- import_electron.ipcRenderer.on("copilot-tool-complete", (_event, agentId, toolId, success) => callback(agentId, toolId, success));
72
- },
73
- onCopilotTurnEnd: (callback) => {
74
- import_electron.ipcRenderer.on("copilot-turn-end", (_event, agentId) => callback(agentId));
75
- },
76
- onCopilotUserMessage: (callback) => {
77
- import_electron.ipcRenderer.on("copilot-user-message", (_event, agentId) => callback(agentId));
78
- },
79
- removeTerminalListeners: () => {
80
- import_electron.ipcRenderer.removeAllListeners("terminal-data");
81
- import_electron.ipcRenderer.removeAllListeners("terminal-exit");
82
- },
83
- removeCopilotListeners: () => {
84
- import_electron.ipcRenderer.removeAllListeners("copilot-event");
85
- import_electron.ipcRenderer.removeAllListeners("copilot-tool-start");
86
- import_electron.ipcRenderer.removeAllListeners("copilot-tool-complete");
87
- import_electron.ipcRenderer.removeAllListeners("copilot-turn-end");
88
- import_electron.ipcRenderer.removeAllListeners("copilot-user-message");
89
- }
90
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // electron/terminal-protocol.ts
17
- var terminal_protocol_exports = {};
18
- module.exports = __toCommonJS(terminal_protocol_exports);