sylas-opencode-runner 0.2.21
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/OpenCodeRunner.d.ts +88 -0
- package/dist/OpenCodeRunner.d.ts.map +1 -0
- package/dist/OpenCodeRunner.js +394 -0
- package/dist/OpenCodeRunner.js.map +1 -0
- package/dist/adapters.d.ts +245 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +544 -0
- package/dist/adapters.js.map +1 -0
- package/dist/formatter.d.ts +28 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +251 -0
- package/dist/formatter.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/portAllocator.d.ts +117 -0
- package/dist/portAllocator.d.ts.map +1 -0
- package/dist/portAllocator.js +146 -0
- package/dist/portAllocator.js.map +1 -0
- package/dist/types.d.ts +346 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +48 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Runner
|
|
3
|
+
*
|
|
4
|
+
* Implements IAgentRunner for the OpenCode CLI agent.
|
|
5
|
+
* Spawns `opencode run --format json` as a child process,
|
|
6
|
+
* parses newline-delimited JSON events from stdout,
|
|
7
|
+
* and converts them to SDKMessages via the adapters module.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import { EventEmitter } from "node:events";
|
|
12
|
+
import type { IAgentRunner, IMessageFormatter, SDKMessage } from "sylas-core";
|
|
13
|
+
import type { OpenCodeRunnerConfig, OpenCodeRunnerEvents, OpenCodeSessionInfo } from "./types.js";
|
|
14
|
+
export declare interface OpenCodeRunner {
|
|
15
|
+
on<K extends keyof OpenCodeRunnerEvents>(event: K, listener: OpenCodeRunnerEvents[K]): this;
|
|
16
|
+
emit<K extends keyof OpenCodeRunnerEvents>(event: K, ...args: Parameters<OpenCodeRunnerEvents[K]>): boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* OpenCodeRunner manages OpenCode CLI sessions.
|
|
20
|
+
*
|
|
21
|
+
* It spawns `opencode run --format json` which outputs newline-delimited
|
|
22
|
+
* JSON events on stdout. These events are converted to SDKMessages using
|
|
23
|
+
* the adapters from adapters.ts.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const runner = new OpenCodeRunner({
|
|
28
|
+
* sylasHome: '/home/user/.sylas',
|
|
29
|
+
* workingDirectory: '/path/to/repo',
|
|
30
|
+
* autoApprove: true,
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* await runner.start("Fix the bug in auth.ts");
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class OpenCodeRunner extends EventEmitter implements IAgentRunner {
|
|
37
|
+
readonly supportsStreamingInput = false;
|
|
38
|
+
private config;
|
|
39
|
+
private childProcess;
|
|
40
|
+
private sessionInfo;
|
|
41
|
+
private logStream;
|
|
42
|
+
private readableLogStream;
|
|
43
|
+
private messages;
|
|
44
|
+
private sylasHome;
|
|
45
|
+
private lastAssistantMessage;
|
|
46
|
+
private lastAssistantInfo;
|
|
47
|
+
private formatter;
|
|
48
|
+
private readlineInterface;
|
|
49
|
+
private pendingResultMessage;
|
|
50
|
+
constructor(config: OpenCodeRunnerConfig);
|
|
51
|
+
/**
|
|
52
|
+
* Start a new OpenCode session with a string prompt.
|
|
53
|
+
*/
|
|
54
|
+
start(prompt: string): Promise<OpenCodeSessionInfo>;
|
|
55
|
+
/**
|
|
56
|
+
* Process an OpenCode event from the JSON stream.
|
|
57
|
+
*/
|
|
58
|
+
private processEvent;
|
|
59
|
+
/**
|
|
60
|
+
* Emit a message.
|
|
61
|
+
*/
|
|
62
|
+
private emitMessage;
|
|
63
|
+
/**
|
|
64
|
+
* Stop the current session.
|
|
65
|
+
*/
|
|
66
|
+
stop(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Check if the session is currently running.
|
|
69
|
+
*/
|
|
70
|
+
isRunning(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get all messages from the current session.
|
|
73
|
+
*/
|
|
74
|
+
getMessages(): SDKMessage[];
|
|
75
|
+
/**
|
|
76
|
+
* Get the message formatter.
|
|
77
|
+
*/
|
|
78
|
+
getFormatter(): IMessageFormatter;
|
|
79
|
+
/**
|
|
80
|
+
* Set up logging streams.
|
|
81
|
+
*/
|
|
82
|
+
private setupLogging;
|
|
83
|
+
/**
|
|
84
|
+
* Write a human-readable log entry.
|
|
85
|
+
*/
|
|
86
|
+
private writeReadableLogEntry;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=OpenCodeRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenCodeRunner.d.ts","sourceRoot":"","sources":["../src/OpenCodeRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,OAAO,KAAK,EACX,YAAY,EACZ,iBAAiB,EAEjB,UAAU,EAEV,MAAM,YAAY,CAAC;AAOpB,OAAO,KAAK,EACX,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,WAAW,cAAc;IACtC,EAAE,CAAC,CAAC,SAAS,MAAM,oBAAoB,EACtC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,IAAI,CAAC;IACR,IAAI,CAAC,CAAC,SAAS,MAAM,oBAAoB,EACxC,KAAK,EAAE,CAAC,EACR,GAAG,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAC1C,OAAO,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,cAAe,SAAQ,YAAa,YAAW,YAAY;IACvE,QAAQ,CAAC,sBAAsB,SAAS;IAExC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,iBAAiB,CAA4B;IACrD,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,oBAAoB,CAAoC;IAChE,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,iBAAiB,CAAmD;IAC5E,OAAO,CAAC,oBAAoB,CAA2B;gBAE3C,MAAM,EAAE,oBAAoB;IAaxC;;OAEG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgNzD;;OAEG;IACH,OAAO,CAAC,YAAY;IAmEpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAmBnB;;OAEG;IACH,IAAI,IAAI,IAAI;IAoBZ;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,WAAW,IAAI,UAAU,EAAE;IAI3B;;OAEG;IACH,YAAY,IAAI,iBAAiB;IAIjC;;OAEG;IACH,OAAO,CAAC,YAAY;IAuCpB;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAgB7B"}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Runner
|
|
3
|
+
*
|
|
4
|
+
* Implements IAgentRunner for the OpenCode CLI agent.
|
|
5
|
+
* Spawns `opencode run --format json` as a child process,
|
|
6
|
+
* parses newline-delimited JSON events from stdout,
|
|
7
|
+
* and converts them to SDKMessages via the adapters module.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
import crypto from "node:crypto";
|
|
13
|
+
import { EventEmitter } from "node:events";
|
|
14
|
+
import { createWriteStream, mkdirSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { createInterface } from "node:readline";
|
|
17
|
+
import { extractSessionId, openCodeEventToSDKMessage, synthesizeResultMessage, } from "./adapters.js";
|
|
18
|
+
import { OpenCodeMessageFormatter } from "./formatter.js";
|
|
19
|
+
/**
|
|
20
|
+
* OpenCodeRunner manages OpenCode CLI sessions.
|
|
21
|
+
*
|
|
22
|
+
* It spawns `opencode run --format json` which outputs newline-delimited
|
|
23
|
+
* JSON events on stdout. These events are converted to SDKMessages using
|
|
24
|
+
* the adapters from adapters.ts.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const runner = new OpenCodeRunner({
|
|
29
|
+
* sylasHome: '/home/user/.sylas',
|
|
30
|
+
* workingDirectory: '/path/to/repo',
|
|
31
|
+
* autoApprove: true,
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* await runner.start("Fix the bug in auth.ts");
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export class OpenCodeRunner extends EventEmitter {
|
|
38
|
+
supportsStreamingInput = false;
|
|
39
|
+
config;
|
|
40
|
+
childProcess = null;
|
|
41
|
+
sessionInfo = null;
|
|
42
|
+
logStream = null;
|
|
43
|
+
readableLogStream = null;
|
|
44
|
+
messages = [];
|
|
45
|
+
sylasHome;
|
|
46
|
+
lastAssistantMessage = null;
|
|
47
|
+
lastAssistantInfo = null;
|
|
48
|
+
formatter;
|
|
49
|
+
readlineInterface = null;
|
|
50
|
+
pendingResultMessage = null;
|
|
51
|
+
constructor(config) {
|
|
52
|
+
super();
|
|
53
|
+
this.config = config;
|
|
54
|
+
this.sylasHome = config.sylasHome;
|
|
55
|
+
this.formatter = new OpenCodeMessageFormatter();
|
|
56
|
+
if (config.onMessage)
|
|
57
|
+
this.on("message", config.onMessage);
|
|
58
|
+
if (config.onError)
|
|
59
|
+
this.on("error", config.onError);
|
|
60
|
+
if (config.onComplete)
|
|
61
|
+
this.on("complete", config.onComplete);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Start a new OpenCode session with a string prompt.
|
|
65
|
+
*/
|
|
66
|
+
async start(prompt) {
|
|
67
|
+
if (this.isRunning()) {
|
|
68
|
+
throw new Error("OpenCode session already running");
|
|
69
|
+
}
|
|
70
|
+
this.sessionInfo = {
|
|
71
|
+
sessionId: null,
|
|
72
|
+
startedAt: new Date(),
|
|
73
|
+
isRunning: true,
|
|
74
|
+
openCodeSessionId: null,
|
|
75
|
+
serverPort: null,
|
|
76
|
+
};
|
|
77
|
+
console.log("[OpenCodeRunner] Starting new session");
|
|
78
|
+
console.log("[OpenCodeRunner] Working directory:", this.config.workingDirectory);
|
|
79
|
+
if (this.config.workingDirectory) {
|
|
80
|
+
try {
|
|
81
|
+
mkdirSync(this.config.workingDirectory, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error("[OpenCodeRunner] Failed to create working directory:", err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.setupLogging();
|
|
88
|
+
this.messages = [];
|
|
89
|
+
try {
|
|
90
|
+
const opencodePath = this.config.serverConfig?.baseURL
|
|
91
|
+
? this.config.serverConfig.baseURL
|
|
92
|
+
: "opencode";
|
|
93
|
+
const args = ["run", "--format", "json"];
|
|
94
|
+
const opencodeAgent = this.config.opencodeAgent?.trim();
|
|
95
|
+
// Do not pass --model; let opencode.json / oh-my-opencode plugin control model selection
|
|
96
|
+
// Note: opencode CLI 1.x does not support --auto-approve, --system-prompt, --max-turns
|
|
97
|
+
// These are handled via opencode config or ignored
|
|
98
|
+
if (this.config.resumeSessionId) {
|
|
99
|
+
args.push("--session", this.config.resumeSessionId);
|
|
100
|
+
console.log(`[OpenCodeRunner] Resuming session: ${this.config.resumeSessionId}`);
|
|
101
|
+
}
|
|
102
|
+
if (opencodeAgent) {
|
|
103
|
+
args.push("--agent", opencodeAgent);
|
|
104
|
+
}
|
|
105
|
+
// Add the prompt as positional argument (opencode CLI uses positional args, not --prompt)
|
|
106
|
+
args.push(prompt);
|
|
107
|
+
// Prepare environment
|
|
108
|
+
const env = { ...process.env };
|
|
109
|
+
// Set working directory for opencode
|
|
110
|
+
if (this.config.workingDirectory) {
|
|
111
|
+
env.OPENCODE_CWD = this.config.workingDirectory;
|
|
112
|
+
}
|
|
113
|
+
console.log(`[OpenCodeRunner] Spawning: ${opencodePath} ${args.join(" ")}`);
|
|
114
|
+
this.childProcess = spawn(opencodePath, args, {
|
|
115
|
+
cwd: this.config.workingDirectory,
|
|
116
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
117
|
+
env,
|
|
118
|
+
});
|
|
119
|
+
// Set up stdout line reader for JSON events
|
|
120
|
+
this.readlineInterface = createInterface({
|
|
121
|
+
input: this.childProcess.stdout,
|
|
122
|
+
crlfDelay: Number.POSITIVE_INFINITY,
|
|
123
|
+
});
|
|
124
|
+
this.readlineInterface.on("line", (line) => {
|
|
125
|
+
const trimmed = line.trim();
|
|
126
|
+
if (!trimmed)
|
|
127
|
+
return;
|
|
128
|
+
try {
|
|
129
|
+
const event = JSON.parse(trimmed);
|
|
130
|
+
this.processEvent(event);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
console.error("[OpenCodeRunner] Failed to parse JSON event:", trimmed.substring(0, 200));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
// Handle stderr
|
|
137
|
+
this.childProcess.stderr?.on("data", (data) => {
|
|
138
|
+
console.error("[OpenCodeRunner] stderr:", data.toString());
|
|
139
|
+
});
|
|
140
|
+
// Wait for process to complete
|
|
141
|
+
await new Promise((resolve, reject) => {
|
|
142
|
+
if (!this.childProcess) {
|
|
143
|
+
reject(new Error("Process not started"));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.childProcess.on("close", (code) => {
|
|
147
|
+
console.log(`[OpenCodeRunner] Process exited with code ${code}`);
|
|
148
|
+
if (code === 0 || code === null) {
|
|
149
|
+
resolve();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
reject(new Error(`OpenCode CLI exited with code ${code}`));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
this.childProcess.on("error", (err) => {
|
|
156
|
+
console.error("[OpenCodeRunner] Process error:", err);
|
|
157
|
+
reject(err);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
// Session completed
|
|
161
|
+
console.log(`[OpenCodeRunner] Session completed with ${this.messages.length} messages`);
|
|
162
|
+
this.sessionInfo.isRunning = false;
|
|
163
|
+
// If no result message was emitted, synthesize one
|
|
164
|
+
if (this.pendingResultMessage) {
|
|
165
|
+
this.emitMessage(this.pendingResultMessage);
|
|
166
|
+
this.pendingResultMessage = null;
|
|
167
|
+
}
|
|
168
|
+
else if (!this.messages.some((m) => m.type === "result")) {
|
|
169
|
+
const resultMsg = synthesizeResultMessage(this.sessionInfo.sessionId, this.lastAssistantMessage, this.lastAssistantInfo);
|
|
170
|
+
this.emitMessage(resultMsg);
|
|
171
|
+
}
|
|
172
|
+
this.emit("complete", this.messages);
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.error("[OpenCodeRunner] Session error:", error);
|
|
176
|
+
if (this.sessionInfo) {
|
|
177
|
+
this.sessionInfo.isRunning = false;
|
|
178
|
+
}
|
|
179
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
180
|
+
const errorResult = {
|
|
181
|
+
type: "result",
|
|
182
|
+
subtype: "error_during_execution",
|
|
183
|
+
duration_ms: Date.now() - this.sessionInfo.startedAt.getTime(),
|
|
184
|
+
duration_api_ms: 0,
|
|
185
|
+
is_error: true,
|
|
186
|
+
num_turns: 0,
|
|
187
|
+
errors: [errorMessage],
|
|
188
|
+
stop_reason: null,
|
|
189
|
+
total_cost_usd: 0,
|
|
190
|
+
usage: {
|
|
191
|
+
input_tokens: 0,
|
|
192
|
+
output_tokens: 0,
|
|
193
|
+
cache_creation_input_tokens: 0,
|
|
194
|
+
cache_read_input_tokens: 0,
|
|
195
|
+
cache_creation: {
|
|
196
|
+
ephemeral_1h_input_tokens: 0,
|
|
197
|
+
ephemeral_5m_input_tokens: 0,
|
|
198
|
+
},
|
|
199
|
+
server_tool_use: {
|
|
200
|
+
web_fetch_requests: 0,
|
|
201
|
+
web_search_requests: 0,
|
|
202
|
+
},
|
|
203
|
+
service_tier: "standard",
|
|
204
|
+
inference_geo: "",
|
|
205
|
+
iterations: [],
|
|
206
|
+
},
|
|
207
|
+
modelUsage: {},
|
|
208
|
+
permission_denials: [],
|
|
209
|
+
uuid: crypto.randomUUID(),
|
|
210
|
+
session_id: this.sessionInfo?.sessionId || "pending",
|
|
211
|
+
};
|
|
212
|
+
this.emitMessage(errorResult);
|
|
213
|
+
this.emit("error", error instanceof Error ? error : new Error(String(error)));
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
this.childProcess = null;
|
|
217
|
+
this.pendingResultMessage = null;
|
|
218
|
+
if (this.logStream) {
|
|
219
|
+
this.logStream.end();
|
|
220
|
+
this.logStream = null;
|
|
221
|
+
}
|
|
222
|
+
if (this.readableLogStream) {
|
|
223
|
+
this.readableLogStream.end();
|
|
224
|
+
this.readableLogStream = null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return this.sessionInfo;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Process an OpenCode event from the JSON stream.
|
|
231
|
+
*/
|
|
232
|
+
processEvent(event) {
|
|
233
|
+
console.log(`[OpenCodeRunner] Event: ${event.type}`, JSON.stringify(event).substring(0, 200));
|
|
234
|
+
const sessionId = extractSessionId(event);
|
|
235
|
+
if (sessionId && this.sessionInfo && !this.sessionInfo.sessionId) {
|
|
236
|
+
this.sessionInfo.sessionId = sessionId;
|
|
237
|
+
this.sessionInfo.openCodeSessionId = sessionId;
|
|
238
|
+
console.log(`[OpenCodeRunner] Session ID assigned: ${sessionId}`);
|
|
239
|
+
this.setupLogging();
|
|
240
|
+
const reportedModel = this.config.opencodeReportedModel?.trim() ||
|
|
241
|
+
"managed-by-opencode-plugin";
|
|
242
|
+
const reportedPlugins = this.config.opencodePlugins || [];
|
|
243
|
+
const systemInitMessage = {
|
|
244
|
+
type: "system",
|
|
245
|
+
subtype: "init",
|
|
246
|
+
agents: undefined,
|
|
247
|
+
apiKeySource: "user",
|
|
248
|
+
claude_code_version: "opencode-adapter",
|
|
249
|
+
cwd: this.config.workingDirectory || process.cwd(),
|
|
250
|
+
tools: [],
|
|
251
|
+
mcp_servers: [],
|
|
252
|
+
model: reportedModel,
|
|
253
|
+
permissionMode: "default",
|
|
254
|
+
slash_commands: [],
|
|
255
|
+
output_style: "default",
|
|
256
|
+
skills: [],
|
|
257
|
+
plugins: reportedPlugins,
|
|
258
|
+
uuid: crypto.randomUUID(),
|
|
259
|
+
session_id: sessionId,
|
|
260
|
+
};
|
|
261
|
+
this.emitMessage(systemInitMessage);
|
|
262
|
+
}
|
|
263
|
+
// Track assistant message info for result synthesis
|
|
264
|
+
if (event.type === "message.updated") {
|
|
265
|
+
const msg = event.properties?.info;
|
|
266
|
+
if (msg?.role === "assistant") {
|
|
267
|
+
this.lastAssistantInfo = msg;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Convert to SDK message
|
|
271
|
+
const message = openCodeEventToSDKMessage(event, this.sessionInfo?.sessionId || null, this.lastAssistantMessage, this.lastAssistantInfo);
|
|
272
|
+
if (message) {
|
|
273
|
+
if (message.type === "assistant") {
|
|
274
|
+
this.lastAssistantMessage = message;
|
|
275
|
+
}
|
|
276
|
+
// Defer result message to after process exit
|
|
277
|
+
if (message.type === "result") {
|
|
278
|
+
this.pendingResultMessage = message;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
this.emitMessage(message);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Emit a message.
|
|
287
|
+
*/
|
|
288
|
+
emitMessage(message) {
|
|
289
|
+
this.messages.push(message);
|
|
290
|
+
if (this.logStream) {
|
|
291
|
+
const logEntry = {
|
|
292
|
+
type: "sdk-message",
|
|
293
|
+
message,
|
|
294
|
+
timestamp: new Date().toISOString(),
|
|
295
|
+
};
|
|
296
|
+
this.logStream.write(`${JSON.stringify(logEntry)}\n`);
|
|
297
|
+
}
|
|
298
|
+
if (this.readableLogStream) {
|
|
299
|
+
this.writeReadableLogEntry(message);
|
|
300
|
+
}
|
|
301
|
+
this.emit("message", message);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Stop the current session.
|
|
305
|
+
*/
|
|
306
|
+
stop() {
|
|
307
|
+
if (this.readlineInterface) {
|
|
308
|
+
if (typeof this.readlineInterface.close === "function") {
|
|
309
|
+
this.readlineInterface.close();
|
|
310
|
+
}
|
|
311
|
+
this.readlineInterface.removeAllListeners();
|
|
312
|
+
this.readlineInterface = null;
|
|
313
|
+
}
|
|
314
|
+
if (this.childProcess) {
|
|
315
|
+
console.log("[OpenCodeRunner] Stopping OpenCode process");
|
|
316
|
+
this.childProcess.kill("SIGTERM");
|
|
317
|
+
this.childProcess = null;
|
|
318
|
+
}
|
|
319
|
+
if (this.sessionInfo) {
|
|
320
|
+
this.sessionInfo.isRunning = false;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Check if the session is currently running.
|
|
325
|
+
*/
|
|
326
|
+
isRunning() {
|
|
327
|
+
return this.sessionInfo?.isRunning ?? false;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get all messages from the current session.
|
|
331
|
+
*/
|
|
332
|
+
getMessages() {
|
|
333
|
+
return [...this.messages];
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Get the message formatter.
|
|
337
|
+
*/
|
|
338
|
+
getFormatter() {
|
|
339
|
+
return this.formatter;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Set up logging streams.
|
|
343
|
+
*/
|
|
344
|
+
setupLogging() {
|
|
345
|
+
const logsDir = join(this.sylasHome, "logs");
|
|
346
|
+
const workspaceName = this.config.workspaceName ||
|
|
347
|
+
(this.config.workingDirectory
|
|
348
|
+
? this.config.workingDirectory.split("/").pop()
|
|
349
|
+
: "default") ||
|
|
350
|
+
"default";
|
|
351
|
+
const workspaceLogsDir = join(logsDir, workspaceName);
|
|
352
|
+
const sessionId = this.sessionInfo?.sessionId || "pending";
|
|
353
|
+
if (this.logStream)
|
|
354
|
+
this.logStream.end();
|
|
355
|
+
if (this.readableLogStream)
|
|
356
|
+
this.readableLogStream.end();
|
|
357
|
+
mkdirSync(workspaceLogsDir, { recursive: true });
|
|
358
|
+
const logPath = join(workspaceLogsDir, `${sessionId}.ndjson`);
|
|
359
|
+
const readableLogPath = join(workspaceLogsDir, `${sessionId}.log`);
|
|
360
|
+
console.log(`[OpenCodeRunner] Logging to: ${logPath}`);
|
|
361
|
+
this.logStream = createWriteStream(logPath, { flags: "a" });
|
|
362
|
+
this.readableLogStream = createWriteStream(readableLogPath, { flags: "a" });
|
|
363
|
+
const startEntry = {
|
|
364
|
+
type: "session-start",
|
|
365
|
+
sessionId,
|
|
366
|
+
timestamp: new Date().toISOString(),
|
|
367
|
+
config: {
|
|
368
|
+
model: this.config.model,
|
|
369
|
+
workingDirectory: this.config.workingDirectory,
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
this.logStream.write(`${JSON.stringify(startEntry)}\n`);
|
|
373
|
+
this.readableLogStream.write(`=== Session ${sessionId} started at ${new Date().toISOString()} ===\n\n`);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Write a human-readable log entry.
|
|
377
|
+
*/
|
|
378
|
+
writeReadableLogEntry(message) {
|
|
379
|
+
if (!this.readableLogStream)
|
|
380
|
+
return;
|
|
381
|
+
const timestamp = new Date().toISOString();
|
|
382
|
+
this.readableLogStream.write(`[${timestamp}] ${message.type}\n`);
|
|
383
|
+
if (message.type === "user" || message.type === "assistant") {
|
|
384
|
+
const content = typeof message.message.content === "string"
|
|
385
|
+
? message.message.content
|
|
386
|
+
: JSON.stringify(message.message.content, null, 2);
|
|
387
|
+
this.readableLogStream.write(`${content}\n\n`);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
this.readableLogStream.write(`${JSON.stringify(message, null, 2)}\n\n`);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=OpenCodeRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenCodeRunner.js","sourceRoot":"","sources":["../src/OpenCodeRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAoB,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAShD,OAAO,EACN,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAkB1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IACtC,sBAAsB,GAAG,KAAK,CAAC;IAEhC,MAAM,CAAuB;IAC7B,YAAY,GAAwB,IAAI,CAAC;IACzC,WAAW,GAA+B,IAAI,CAAC;IAC/C,SAAS,GAAuB,IAAI,CAAC;IACrC,iBAAiB,GAAuB,IAAI,CAAC;IAC7C,QAAQ,G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