@getpaseo/server 0.1.98 → 0.1.100
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/server/server/agent/agent-manager.js +2 -2
- package/dist/server/server/agent/agent-sdk-types.d.ts +11 -6
- package/dist/server/server/agent/provider-registry.d.ts +6 -3
- package/dist/server/server/agent/provider-registry.js +49 -22
- package/dist/server/server/agent/provider-snapshot-manager.js +26 -14
- package/dist/server/server/agent/providers/acp-agent.d.ts +23 -3
- package/dist/server/server/agent/providers/acp-agent.js +139 -9
- package/dist/server/server/agent/providers/claude/agent.d.ts +2 -2
- package/dist/server/server/agent/providers/claude/agent.js +41 -77
- package/dist/server/server/agent/providers/codex-app-server-agent.d.ts +3 -2
- package/dist/server/server/agent/providers/codex-app-server-agent.js +6 -25
- package/dist/server/server/agent/providers/copilot-acp-agent.d.ts +2 -1
- package/dist/server/server/agent/providers/copilot-acp-agent.js +11 -31
- package/dist/server/server/agent/providers/generic-acp-agent.d.ts +0 -1
- package/dist/server/server/agent/providers/generic-acp-agent.js +2 -108
- package/dist/server/server/agent/providers/mock-load-test-agent.d.ts +2 -3
- package/dist/server/server/agent/providers/mock-load-test-agent.js +5 -5
- package/dist/server/server/agent/providers/mock-slow-provider.d.ts +2 -3
- package/dist/server/server/agent/providers/mock-slow-provider.js +2 -5
- package/dist/server/server/agent/providers/opencode/server-manager.d.ts +14 -11
- package/dist/server/server/agent/providers/opencode/server-manager.js +149 -91
- package/dist/server/server/agent/providers/opencode/test-server-manager.d.ts +6 -5
- package/dist/server/server/agent/providers/opencode/test-server-manager.js +13 -3
- package/dist/server/server/agent/providers/opencode/test-utils/{test-opencode-runtime.d.ts → test-opencode-harness.d.ts} +11 -11
- package/dist/server/server/agent/providers/opencode/test-utils/{test-opencode-runtime.js → test-opencode-harness.js} +23 -10
- package/dist/server/server/agent/providers/opencode-agent.d.ts +13 -6
- package/dist/server/server/agent/providers/opencode-agent.js +74 -137
- package/dist/server/server/agent/providers/pi/agent.d.ts +4 -4
- package/dist/server/server/agent/providers/pi/agent.js +13 -76
- package/dist/server/server/agent/providers/pi/cli-runtime.d.ts +3 -0
- package/dist/server/server/agent/providers/pi/cli-runtime.js +8 -5
- package/dist/server/server/agent/providers/pi/rpc-types.d.ts +2 -1
- package/dist/server/server/agent/providers/pi/runtime.d.ts +1 -1
- package/dist/server/server/agent/providers/pi/test-utils/fake-pi.d.ts +1 -1
- package/dist/server/server/agent/providers/pi/test-utils/fake-pi.js +1 -1
- package/dist/server/server/session/agent-config/agent-config-session.d.ts +50 -0
- package/dist/server/server/session/agent-config/agent-config-session.js +98 -0
- package/dist/server/server/session/chat/chat-schedule-loop-session.d.ts +120 -0
- package/dist/server/server/session/chat/chat-schedule-loop-session.js +489 -0
- package/dist/server/server/session/checkout/checkout-session.d.ts +142 -0
- package/dist/server/server/session/checkout/checkout-session.js +925 -0
- package/dist/server/server/session/daemon/daemon-session.d.ts +50 -0
- package/dist/server/server/session/daemon/daemon-session.js +98 -0
- package/dist/server/server/session/files/workspace-files-session.d.ts +43 -0
- package/dist/server/server/session/files/workspace-files-session.js +218 -0
- package/dist/server/server/session/project-config/project-config-session.d.ts +34 -0
- package/dist/server/server/session/project-config/project-config-session.js +125 -0
- package/dist/server/server/session/provider/provider-catalog-session.d.ts +74 -0
- package/dist/server/server/session/provider/provider-catalog-session.js +339 -0
- package/dist/server/server/session/voice/voice-session.d.ts +166 -0
- package/dist/server/server/session/voice/voice-session.js +893 -0
- package/dist/server/server/{voice → session/voice}/voice-turn-controller.d.ts +2 -2
- package/dist/server/server/{voice → session/voice}/voice-turn-controller.js +2 -2
- package/dist/server/server/session.d.ts +13 -208
- package/dist/server/server/session.js +2132 -5105
- package/dist/server/utils/checkout-git.d.ts +6 -0
- package/package.json +5 -5
- package/dist/server/server/agent/providers/opencode/runtime.d.ts +0 -28
- package/dist/server/server/agent/providers/opencode/runtime.js +0 -5
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { AgentCapabilityFlags, AgentClient, AgentLaunchContext,
|
|
1
|
+
import type { AgentCapabilityFlags, AgentClient, AgentLaunchContext, AgentPersistenceHandle, AgentProvider, AgentSession, AgentSessionConfig, FetchCatalogOptions, ProviderCatalog } from "../agent-sdk-types.js";
|
|
2
2
|
export declare const MOCK_SLOW_PROVIDER_ID = "mock-slow";
|
|
3
3
|
export declare class MockSlowProviderClient implements AgentClient {
|
|
4
4
|
readonly provider: AgentProvider;
|
|
5
5
|
readonly capabilities: AgentCapabilityFlags;
|
|
6
6
|
isAvailable(): Promise<boolean>;
|
|
7
|
-
|
|
8
|
-
listModes(_options: ListModesOptions): Promise<AgentMode[]>;
|
|
7
|
+
fetchCatalog(_options: FetchCatalogOptions): Promise<ProviderCatalog>;
|
|
9
8
|
getDiagnostic(): Promise<{
|
|
10
9
|
diagnostic: string;
|
|
11
10
|
}>;
|
|
@@ -21,15 +21,12 @@ export class MockSlowProviderClient {
|
|
|
21
21
|
async isAvailable() {
|
|
22
22
|
return process.env.PASEO_ENABLE_MOCK_SLOW === "true";
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
return neverResolves();
|
|
26
|
-
}
|
|
27
|
-
listModes(_options) {
|
|
24
|
+
async fetchCatalog(_options) {
|
|
28
25
|
return neverResolves();
|
|
29
26
|
}
|
|
30
27
|
async getDiagnostic() {
|
|
31
28
|
return {
|
|
32
|
-
diagnostic: "Mock slow provider: dev-only.
|
|
29
|
+
diagnostic: "Mock slow provider: dev-only. fetchCatalog() never resolves so the snapshot manager will time out.",
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
32
|
createSession(_config, _launchContext) {
|
|
@@ -16,10 +16,10 @@ export interface OpenCodeServerManagerLike {
|
|
|
16
16
|
port: number;
|
|
17
17
|
url: string;
|
|
18
18
|
}>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
acquireCurrent(): Promise<OpenCodeServerAcquisition>;
|
|
20
|
+
acquireNew(): Promise<OpenCodeServerAcquisition>;
|
|
21
|
+
acquireDedicated(env: Record<string, string>): Promise<OpenCodeServerAcquisition>;
|
|
22
|
+
shutdown(): Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
export interface OpenCodeServerGeneration {
|
|
25
25
|
process: ChildProcess;
|
|
@@ -27,7 +27,11 @@ export interface OpenCodeServerGeneration {
|
|
|
27
27
|
url: string;
|
|
28
28
|
refCount: number;
|
|
29
29
|
retired: boolean;
|
|
30
|
+
ready: Promise<void>;
|
|
30
31
|
managedProcessId?: string;
|
|
32
|
+
managedProcessRecord?: Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
} | null>;
|
|
31
35
|
}
|
|
32
36
|
export type OpenCodePortAllocator = () => Promise<number>;
|
|
33
37
|
export type OpenCodeCommandPrefixResolver = () => Promise<{
|
|
@@ -50,7 +54,7 @@ export declare class OpenCodeServerManager implements OpenCodeServerManagerLike
|
|
|
50
54
|
private currentServer;
|
|
51
55
|
private retiredServers;
|
|
52
56
|
private startPromise;
|
|
53
|
-
private
|
|
57
|
+
private newServerPromise;
|
|
54
58
|
private readonly logger;
|
|
55
59
|
private readonly runtimeSettings?;
|
|
56
60
|
private readonly runtimeSettingsKey;
|
|
@@ -66,21 +70,20 @@ export declare class OpenCodeServerManager implements OpenCodeServerManagerLike
|
|
|
66
70
|
port: number;
|
|
67
71
|
url: string;
|
|
68
72
|
}>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}): Promise<OpenCodeServerAcquisition>;
|
|
73
|
+
acquireCurrent(): Promise<OpenCodeServerAcquisition>;
|
|
74
|
+
acquireNew(): Promise<OpenCodeServerAcquisition>;
|
|
75
|
+
acquireDedicated(env: Record<string, string>): Promise<OpenCodeServerAcquisition>;
|
|
73
76
|
private acquireServer;
|
|
74
|
-
private
|
|
77
|
+
private getNewServer;
|
|
75
78
|
private getCurrentServer;
|
|
76
79
|
private rotateCurrentServer;
|
|
77
|
-
private startDedicatedServer;
|
|
78
80
|
private startServer;
|
|
79
81
|
shutdown(): Promise<void>;
|
|
80
82
|
private cleanupRetiredServers;
|
|
81
83
|
private killServer;
|
|
82
84
|
private recordManagedServerProcess;
|
|
83
85
|
private removeManagedProcessRecordWhenResolved;
|
|
86
|
+
private removeManagedServerRecord;
|
|
84
87
|
private removeManagedProcessId;
|
|
85
88
|
}
|
|
86
89
|
//# sourceMappingURL=server-manager.d.ts.map
|
|
@@ -11,7 +11,7 @@ export class OpenCodeServerManager {
|
|
|
11
11
|
this.currentServer = null;
|
|
12
12
|
this.retiredServers = new Set();
|
|
13
13
|
this.startPromise = null;
|
|
14
|
-
this.
|
|
14
|
+
this.newServerPromise = null;
|
|
15
15
|
this.logger = options.logger;
|
|
16
16
|
this.runtimeSettings = options.runtimeSettings;
|
|
17
17
|
this.runtimeSettingsKey = JSON.stringify(this.runtimeSettings ?? {});
|
|
@@ -55,20 +55,32 @@ export class OpenCodeServerManager {
|
|
|
55
55
|
process.on("SIGINT", cleanup);
|
|
56
56
|
}
|
|
57
57
|
async ensureRunning() {
|
|
58
|
-
const acquisition = await this.
|
|
58
|
+
const acquisition = await this.acquireCurrent();
|
|
59
59
|
acquisition.release();
|
|
60
60
|
return acquisition.server;
|
|
61
61
|
}
|
|
62
|
-
async
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const server =
|
|
68
|
-
? await this.getForcedRefreshServer()
|
|
69
|
-
: await this.getCurrentServer();
|
|
62
|
+
async acquireCurrent() {
|
|
63
|
+
const server = await this.getCurrentServer();
|
|
64
|
+
return this.acquireServer(server);
|
|
65
|
+
}
|
|
66
|
+
async acquireNew() {
|
|
67
|
+
const server = await this.getNewServer();
|
|
70
68
|
return this.acquireServer(server);
|
|
71
69
|
}
|
|
70
|
+
async acquireDedicated(env) {
|
|
71
|
+
const server = await this.startServer(env);
|
|
72
|
+
server.retired = true;
|
|
73
|
+
this.retiredServers.add(server);
|
|
74
|
+
const acquisition = this.acquireServer(server);
|
|
75
|
+
try {
|
|
76
|
+
await server.ready;
|
|
77
|
+
return acquisition;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
acquisition.release();
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
72
84
|
acquireServer(server) {
|
|
73
85
|
server.refCount += 1;
|
|
74
86
|
let released = false;
|
|
@@ -84,38 +96,52 @@ export class OpenCodeServerManager {
|
|
|
84
96
|
},
|
|
85
97
|
};
|
|
86
98
|
}
|
|
87
|
-
async
|
|
88
|
-
if (this.
|
|
89
|
-
return this.
|
|
99
|
+
async getNewServer() {
|
|
100
|
+
if (this.newServerPromise) {
|
|
101
|
+
return this.newServerPromise;
|
|
90
102
|
}
|
|
91
|
-
this.
|
|
103
|
+
this.newServerPromise = Promise.resolve()
|
|
92
104
|
.then(async () => {
|
|
93
105
|
await this.rotateCurrentServer();
|
|
94
|
-
|
|
106
|
+
const server = await this.startServer();
|
|
107
|
+
if (!server.retired) {
|
|
108
|
+
this.currentServer = server;
|
|
109
|
+
}
|
|
110
|
+
await server.ready;
|
|
111
|
+
return server;
|
|
95
112
|
})
|
|
96
113
|
.finally(() => {
|
|
97
|
-
this.
|
|
114
|
+
this.newServerPromise = null;
|
|
98
115
|
});
|
|
99
|
-
return this.
|
|
116
|
+
return this.newServerPromise;
|
|
100
117
|
}
|
|
101
118
|
async getCurrentServer() {
|
|
119
|
+
if (this.newServerPromise) {
|
|
120
|
+
return this.newServerPromise;
|
|
121
|
+
}
|
|
102
122
|
if (this.startPromise) {
|
|
103
|
-
|
|
123
|
+
const server = await this.startPromise;
|
|
124
|
+
await server.ready;
|
|
125
|
+
return server;
|
|
104
126
|
}
|
|
105
127
|
if (this.currentServer && !this.currentServer.process.killed) {
|
|
128
|
+
await this.currentServer.ready;
|
|
106
129
|
return this.currentServer;
|
|
107
130
|
}
|
|
108
|
-
this.startPromise = this.startServer()
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!result.retired) {
|
|
112
|
-
this.currentServer = result;
|
|
131
|
+
this.startPromise = this.startServer().then((server) => {
|
|
132
|
+
if (!server.retired) {
|
|
133
|
+
this.currentServer = server;
|
|
113
134
|
}
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
return server;
|
|
136
|
+
});
|
|
137
|
+
const currentStart = this.startPromise;
|
|
138
|
+
const result = await currentStart.finally(() => {
|
|
139
|
+
if (this.startPromise === currentStart) {
|
|
140
|
+
this.startPromise = null;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
await result.ready;
|
|
144
|
+
return result;
|
|
119
145
|
}
|
|
120
146
|
async rotateCurrentServer() {
|
|
121
147
|
const existing = this.currentServer;
|
|
@@ -133,79 +159,89 @@ export class OpenCodeServerManager {
|
|
|
133
159
|
this.cleanupRetiredServers();
|
|
134
160
|
}
|
|
135
161
|
}
|
|
136
|
-
async startDedicatedServer(env) {
|
|
137
|
-
const server = await this.startServer(env);
|
|
138
|
-
server.retired = true;
|
|
139
|
-
this.retiredServers.add(server);
|
|
140
|
-
return server;
|
|
141
|
-
}
|
|
142
162
|
async startServer(launchEnv) {
|
|
143
163
|
const port = await this.portAllocator();
|
|
144
164
|
const url = `http://127.0.0.1:${port}`;
|
|
145
165
|
const launchPrefix = await this.resolveCommandPrefix();
|
|
146
166
|
const serverArgs = [...launchPrefix.args, "serve", "--port", String(port)];
|
|
147
167
|
const serverCwd = os.homedir();
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
const serverProcess = this.spawnServerProcess(launchPrefix.command, serverArgs, {
|
|
169
|
+
cwd: serverCwd,
|
|
170
|
+
detached: process.platform !== "win32",
|
|
171
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
172
|
+
...createProviderEnvSpec({
|
|
173
|
+
runtimeSettings: this.runtimeSettings,
|
|
174
|
+
overlays: [launchEnv],
|
|
175
|
+
}),
|
|
176
|
+
});
|
|
177
|
+
const managedProcessRecord = this.recordManagedServerProcess({
|
|
178
|
+
process: serverProcess,
|
|
179
|
+
command: launchPrefix.command,
|
|
180
|
+
args: serverArgs,
|
|
181
|
+
port,
|
|
182
|
+
});
|
|
183
|
+
const server = {
|
|
184
|
+
process: serverProcess,
|
|
185
|
+
port,
|
|
186
|
+
url,
|
|
187
|
+
refCount: 0,
|
|
188
|
+
retired: false,
|
|
189
|
+
ready: Promise.resolve(),
|
|
190
|
+
managedProcessRecord,
|
|
191
|
+
};
|
|
192
|
+
void managedProcessRecord.then((record) => {
|
|
193
|
+
if (record && server.managedProcessRecord === managedProcessRecord) {
|
|
194
|
+
server.managedProcessId = record.id;
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
});
|
|
198
|
+
let started = false;
|
|
199
|
+
let settled = false;
|
|
200
|
+
let stderrBuffer = "";
|
|
201
|
+
let stdoutBuffer = "";
|
|
202
|
+
const STARTUP_BUFFER_CAP = 8192;
|
|
203
|
+
const appendCapped = (current, chunk) => {
|
|
204
|
+
if (current.length >= STARTUP_BUFFER_CAP) {
|
|
205
|
+
return current;
|
|
206
|
+
}
|
|
207
|
+
const remaining = STARTUP_BUFFER_CAP - current.length;
|
|
208
|
+
return current + chunk.slice(0, remaining);
|
|
209
|
+
};
|
|
210
|
+
const buildStartupErrorMessage = (headline) => {
|
|
211
|
+
const sections = [headline];
|
|
212
|
+
const stderrTrimmed = stderrBuffer.trim();
|
|
213
|
+
if (stderrTrimmed.length > 0) {
|
|
214
|
+
sections.push(`stderr: ${stderrTrimmed}`);
|
|
215
|
+
}
|
|
216
|
+
const stdoutTrimmed = stdoutBuffer.trim();
|
|
217
|
+
if (stdoutTrimmed.length > 0) {
|
|
218
|
+
sections.push(`stdout: ${stdoutTrimmed}`);
|
|
219
|
+
}
|
|
220
|
+
return sections.join("\n");
|
|
221
|
+
};
|
|
222
|
+
const ready = new Promise((resolve, reject) => {
|
|
223
|
+
let timeout;
|
|
224
|
+
const failStartup = (error) => {
|
|
225
|
+
if (settled) {
|
|
226
|
+
return;
|
|
184
227
|
}
|
|
185
|
-
|
|
228
|
+
settled = true;
|
|
229
|
+
clearTimeout(timeout);
|
|
230
|
+
reject(error);
|
|
186
231
|
};
|
|
187
|
-
|
|
232
|
+
timeout = setTimeout(() => {
|
|
188
233
|
if (!started) {
|
|
189
|
-
|
|
234
|
+
failStartup(new Error(buildStartupErrorMessage("OpenCode server startup timeout")));
|
|
190
235
|
}
|
|
191
236
|
}, 30000);
|
|
192
237
|
serverProcess.stdout?.on("data", (data) => {
|
|
193
238
|
const output = data.toString();
|
|
194
239
|
stdoutBuffer = appendCapped(stdoutBuffer, output);
|
|
195
|
-
if (output.includes("listening on") && !
|
|
240
|
+
if (output.includes("listening on") && !settled) {
|
|
196
241
|
started = true;
|
|
242
|
+
settled = true;
|
|
197
243
|
clearTimeout(timeout);
|
|
198
|
-
|
|
199
|
-
const record = await managedProcessRecord;
|
|
200
|
-
resolve({
|
|
201
|
-
process: serverProcess,
|
|
202
|
-
port,
|
|
203
|
-
url,
|
|
204
|
-
refCount: 0,
|
|
205
|
-
retired: false,
|
|
206
|
-
...(record ? { managedProcessId: record.id } : {}),
|
|
207
|
-
});
|
|
208
|
-
})();
|
|
244
|
+
resolve();
|
|
209
245
|
}
|
|
210
246
|
});
|
|
211
247
|
serverProcess.stderr?.on("data", (data) => {
|
|
@@ -214,16 +250,13 @@ export class OpenCodeServerManager {
|
|
|
214
250
|
this.logger.error({ stderr: output.trim() }, "OpenCode server stderr");
|
|
215
251
|
});
|
|
216
252
|
serverProcess.on("error", (error) => {
|
|
217
|
-
clearTimeout(timeout);
|
|
218
|
-
this.removeManagedProcessRecordWhenResolved(managedProcessRecord);
|
|
219
253
|
const headline = error instanceof Error ? error.message : String(error);
|
|
220
|
-
|
|
254
|
+
failStartup(new Error(buildStartupErrorMessage(headline)));
|
|
221
255
|
});
|
|
222
256
|
serverProcess.on("exit", (code) => {
|
|
223
|
-
this.
|
|
257
|
+
this.removeManagedServerRecord(server);
|
|
224
258
|
if (!started) {
|
|
225
|
-
|
|
226
|
-
reject(new Error(buildStartupErrorMessage(`OpenCode server exited with code ${code}`)));
|
|
259
|
+
failStartup(new Error(buildStartupErrorMessage(`OpenCode server exited with code ${code}`)));
|
|
227
260
|
}
|
|
228
261
|
if (this.currentServer?.process === serverProcess) {
|
|
229
262
|
this.currentServer = null;
|
|
@@ -235,6 +268,15 @@ export class OpenCodeServerManager {
|
|
|
235
268
|
}
|
|
236
269
|
});
|
|
237
270
|
});
|
|
271
|
+
server.ready = ready.catch(async (error) => {
|
|
272
|
+
await this.killServer(server);
|
|
273
|
+
if (this.currentServer === server) {
|
|
274
|
+
this.currentServer = null;
|
|
275
|
+
}
|
|
276
|
+
this.retiredServers.delete(server);
|
|
277
|
+
throw error;
|
|
278
|
+
});
|
|
279
|
+
return server;
|
|
238
280
|
}
|
|
239
281
|
async shutdown() {
|
|
240
282
|
const servers = [
|
|
@@ -271,6 +313,10 @@ export class OpenCodeServerManager {
|
|
|
271
313
|
if (server.managedProcessId) {
|
|
272
314
|
await this.removeManagedProcessId(server.managedProcessId);
|
|
273
315
|
server.managedProcessId = undefined;
|
|
316
|
+
server.managedProcessRecord = undefined;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
this.removeManagedServerRecord(server);
|
|
274
320
|
}
|
|
275
321
|
}
|
|
276
322
|
async recordManagedServerProcess(options) {
|
|
@@ -300,6 +346,18 @@ export class OpenCodeServerManager {
|
|
|
300
346
|
return undefined;
|
|
301
347
|
});
|
|
302
348
|
}
|
|
349
|
+
removeManagedServerRecord(server) {
|
|
350
|
+
const record = server.managedProcessRecord;
|
|
351
|
+
server.managedProcessRecord = undefined;
|
|
352
|
+
if (server.managedProcessId) {
|
|
353
|
+
void this.removeManagedProcessId(server.managedProcessId);
|
|
354
|
+
server.managedProcessId = undefined;
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (record) {
|
|
358
|
+
this.removeManagedProcessRecordWhenResolved(record);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
303
361
|
async removeManagedProcessId(id) {
|
|
304
362
|
try {
|
|
305
363
|
await this.managedProcesses?.remove(id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenCodeServerAcquisition, OpenCodeServerManagerLike } from "./server-manager.js";
|
|
2
2
|
export interface TestOpenCodeServerAcquisition {
|
|
3
|
-
|
|
3
|
+
kind: "current" | "new" | "dedicated";
|
|
4
4
|
env?: Record<string, string>;
|
|
5
5
|
released: boolean;
|
|
6
6
|
}
|
|
@@ -15,10 +15,11 @@ export declare class TestOpenCodeServerManager implements OpenCodeServerManagerL
|
|
|
15
15
|
port: number;
|
|
16
16
|
url: string;
|
|
17
17
|
}>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
acquireCurrent(): Promise<OpenCodeServerAcquisition>;
|
|
19
|
+
acquireNew(): Promise<OpenCodeServerAcquisition>;
|
|
20
|
+
acquireDedicated(env: Record<string, string>): Promise<OpenCodeServerAcquisition>;
|
|
21
|
+
private recordAcquisition;
|
|
22
|
+
shutdown(): Promise<void>;
|
|
22
23
|
}
|
|
23
24
|
export declare function createTestOpenCodeServerManager(): TestOpenCodeServerManager;
|
|
24
25
|
//# sourceMappingURL=test-server-manager.d.ts.map
|
|
@@ -8,11 +8,20 @@ export class TestOpenCodeServerManager {
|
|
|
8
8
|
this.ensureRunningCount += 1;
|
|
9
9
|
return this.server;
|
|
10
10
|
}
|
|
11
|
-
async
|
|
11
|
+
async acquireCurrent() {
|
|
12
|
+
return this.recordAcquisition({ kind: "current" });
|
|
13
|
+
}
|
|
14
|
+
async acquireNew() {
|
|
15
|
+
return this.recordAcquisition({ kind: "new" });
|
|
16
|
+
}
|
|
17
|
+
async acquireDedicated(env) {
|
|
18
|
+
return this.recordAcquisition({ kind: "dedicated", env });
|
|
19
|
+
}
|
|
20
|
+
recordAcquisition(input) {
|
|
12
21
|
const acquisition = {
|
|
13
|
-
|
|
14
|
-
env: options.env,
|
|
22
|
+
kind: input.kind,
|
|
15
23
|
released: false,
|
|
24
|
+
...(input.env ? { env: input.env } : {}),
|
|
16
25
|
};
|
|
17
26
|
this.acquisitions.push(acquisition);
|
|
18
27
|
return {
|
|
@@ -22,6 +31,7 @@ export class TestOpenCodeServerManager {
|
|
|
22
31
|
},
|
|
23
32
|
};
|
|
24
33
|
}
|
|
34
|
+
async shutdown() { }
|
|
25
35
|
}
|
|
26
36
|
export function createTestOpenCodeServerManager() {
|
|
27
37
|
return new TestOpenCodeServerManager();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { OpencodeClient } from "@opencode-ai/sdk/v2/client";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OpenCodeServerAcquisition, OpenCodeServerManagerLike } from "../server-manager.js";
|
|
3
3
|
interface OpenCodeResponse {
|
|
4
4
|
data?: unknown;
|
|
5
5
|
error?: unknown;
|
|
6
6
|
}
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class TestOpenCodeHarness implements OpenCodeServerManagerLike {
|
|
8
8
|
readonly acquisitions: Array<{
|
|
9
|
-
|
|
9
|
+
kind: "current" | "new" | "dedicated";
|
|
10
10
|
env?: Record<string, string>;
|
|
11
11
|
releaseCount: number;
|
|
12
12
|
}>;
|
|
@@ -20,18 +20,18 @@ export declare class TestOpenCodeRuntime implements OpenCodeRuntime {
|
|
|
20
20
|
url: string;
|
|
21
21
|
};
|
|
22
22
|
enqueueClient(client: TestOpenCodeClient): void;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
acquireCurrent(): Promise<OpenCodeServerAcquisition>;
|
|
24
|
+
acquireNew(): Promise<OpenCodeServerAcquisition>;
|
|
25
|
+
acquireDedicated(env: Record<string, string>): Promise<OpenCodeServerAcquisition>;
|
|
26
|
+
private recordAcquisition;
|
|
27
|
+
ensureRunning(): Promise<{
|
|
28
28
|
port: number;
|
|
29
29
|
url: string;
|
|
30
30
|
}>;
|
|
31
|
-
createClient(options: {
|
|
31
|
+
readonly createClient: (options: {
|
|
32
32
|
baseUrl: string;
|
|
33
33
|
directory: string;
|
|
34
|
-
})
|
|
34
|
+
}) => OpencodeClient;
|
|
35
35
|
shutdown(): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
export declare class TestOpenCodeClient {
|
|
@@ -89,4 +89,4 @@ export declare class TestOpenCodeClient {
|
|
|
89
89
|
export declare function createEventStream(events: unknown[]): AsyncGenerator<unknown>;
|
|
90
90
|
export declare function idleEvent(): unknown;
|
|
91
91
|
export {};
|
|
92
|
-
//# sourceMappingURL=test-opencode-
|
|
92
|
+
//# sourceMappingURL=test-opencode-harness.d.ts.map
|
|
@@ -1,15 +1,33 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class TestOpenCodeHarness {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.acquisitions = [];
|
|
4
4
|
this.clientCreations = [];
|
|
5
5
|
this.clients = [];
|
|
6
6
|
this.server = { port: 1234, url: "http://127.0.0.1:1234" };
|
|
7
|
+
this.createClient = (options) => {
|
|
8
|
+
this.clientCreations.push(options);
|
|
9
|
+
const client = this.clients.shift() ?? new TestOpenCodeClient();
|
|
10
|
+
return client.asSdkClient();
|
|
11
|
+
};
|
|
7
12
|
}
|
|
8
13
|
enqueueClient(client) {
|
|
9
14
|
this.clients.push(client);
|
|
10
15
|
}
|
|
11
|
-
async
|
|
12
|
-
|
|
16
|
+
async acquireCurrent() {
|
|
17
|
+
return this.recordAcquisition({ kind: "current" });
|
|
18
|
+
}
|
|
19
|
+
async acquireNew() {
|
|
20
|
+
return this.recordAcquisition({ kind: "new" });
|
|
21
|
+
}
|
|
22
|
+
async acquireDedicated(env) {
|
|
23
|
+
return this.recordAcquisition({ kind: "dedicated", env });
|
|
24
|
+
}
|
|
25
|
+
recordAcquisition(input) {
|
|
26
|
+
const acquisition = {
|
|
27
|
+
kind: input.kind,
|
|
28
|
+
releaseCount: 0,
|
|
29
|
+
...(input.env ? { env: input.env } : {}),
|
|
30
|
+
};
|
|
13
31
|
this.acquisitions.push(acquisition);
|
|
14
32
|
return {
|
|
15
33
|
server: this.server,
|
|
@@ -18,14 +36,9 @@ export class TestOpenCodeRuntime {
|
|
|
18
36
|
},
|
|
19
37
|
};
|
|
20
38
|
}
|
|
21
|
-
async
|
|
39
|
+
async ensureRunning() {
|
|
22
40
|
return this.server;
|
|
23
41
|
}
|
|
24
|
-
createClient(options) {
|
|
25
|
-
this.clientCreations.push(options);
|
|
26
|
-
const client = this.clients.shift() ?? new TestOpenCodeClient();
|
|
27
|
-
return client.asSdkClient();
|
|
28
|
-
}
|
|
29
42
|
async shutdown() { }
|
|
30
43
|
}
|
|
31
44
|
export class TestOpenCodeClient {
|
|
@@ -244,4 +257,4 @@ export function idleEvent() {
|
|
|
244
257
|
properties: { sessionID: "session-1" },
|
|
245
258
|
};
|
|
246
259
|
}
|
|
247
|
-
//# sourceMappingURL=test-opencode-
|
|
260
|
+
//# sourceMappingURL=test-opencode-harness.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type AssistantMessage as OpenCodeAssistantMessage, type Event as OpenCodeEvent, type FilePartInput as OpenCodeFilePartInput, type Message as OpenCodeMessage, type OpencodeClient, type Part as OpenCodePart, type TextPartInput as OpenCodeTextPartInput } from "@opencode-ai/sdk/v2/client";
|
|
2
2
|
import type { Logger } from "pino";
|
|
3
|
-
import { type AgentCapabilityFlags, type AgentClient, type AgentCreateSessionOptions, type AgentFeature, type AgentLaunchContext, type AgentMode, type AgentModelDefinition, type AgentPermissionRequest, type AgentPermissionResponse, type AgentPersistenceHandle, type AgentPromptInput, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type AgentTimelineItem, type AgentUsage, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ResolveAgentCreateConfigInput, type ResolveAgentCreateConfigResult, type
|
|
3
|
+
import { type AgentCapabilityFlags, type AgentClient, type AgentCreateSessionOptions, type AgentFeature, type AgentLaunchContext, type AgentMode, type AgentModelDefinition, type AgentPermissionRequest, type AgentPermissionResponse, type AgentPersistenceHandle, type AgentPromptInput, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type AgentTimelineItem, type AgentUsage, type FetchCatalogOptions, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ResolveAgentCreateConfigInput, type ResolveAgentCreateConfigResult, type ProviderCatalog, type ToolCallTimelineItem } from "../agent-sdk-types.js";
|
|
4
4
|
import { isDefaultAgentCreateConfigUnattended } from "../create-agent-mode.js";
|
|
5
5
|
import { type ProviderRuntimeSettings } from "../provider-launch-config.js";
|
|
6
|
-
import { type
|
|
6
|
+
import { type OpenCodeServerManagerLike } from "./opencode/server-manager.js";
|
|
7
7
|
import type { ManagedProcessRegistry } from "../../managed-processes/managed-processes.js";
|
|
8
8
|
declare function resolveOpenCodeCreateConfig(input: ResolveAgentCreateConfigInput): ResolveAgentCreateConfigResult;
|
|
9
9
|
declare function isOpenCodeCreateConfigUnattended(input: Parameters<typeof isDefaultAgentCreateConfigUnattended>[0]): boolean;
|
|
@@ -103,23 +103,28 @@ export declare const __openCodeInternals: {
|
|
|
103
103
|
readonly OpenCodeAgentSession: typeof OpenCodeAgentSession;
|
|
104
104
|
};
|
|
105
105
|
interface OpenCodeAgentClientDeps {
|
|
106
|
-
|
|
106
|
+
serverManager?: OpenCodeServerManagerLike;
|
|
107
|
+
createClient?: OpenCodeClientFactory;
|
|
107
108
|
managedProcesses?: ManagedProcessRegistry;
|
|
108
109
|
}
|
|
110
|
+
type OpenCodeClientFactory = (options: {
|
|
111
|
+
baseUrl: string;
|
|
112
|
+
directory: string;
|
|
113
|
+
}) => OpencodeClient;
|
|
109
114
|
export declare class OpenCodeAgentClient implements AgentClient {
|
|
110
115
|
readonly provider: "opencode";
|
|
111
116
|
readonly capabilities: AgentCapabilityFlags;
|
|
112
117
|
readonly resolveCreateConfig: typeof resolveOpenCodeCreateConfig;
|
|
113
118
|
readonly isCreateConfigUnattended: typeof isOpenCodeCreateConfigUnattended;
|
|
114
|
-
private readonly
|
|
119
|
+
private readonly serverManager;
|
|
120
|
+
private readonly createOpenCodeClient;
|
|
115
121
|
private readonly logger;
|
|
116
122
|
private readonly runtimeSettings?;
|
|
117
123
|
private readonly modelContextWindows;
|
|
118
124
|
constructor(logger: Logger, runtimeSettings?: ProviderRuntimeSettings, deps?: OpenCodeAgentClientDeps);
|
|
119
125
|
createSession(config: AgentSessionConfig, launchContext?: AgentLaunchContext, options?: AgentCreateSessionOptions): Promise<AgentSession>;
|
|
120
126
|
resumeSession(handle: AgentPersistenceHandle, overrides?: Partial<AgentSessionConfig>, launchContext?: AgentLaunchContext): Promise<AgentSession>;
|
|
121
|
-
|
|
122
|
-
listModes(options: ListModesOptions): Promise<AgentMode[]>;
|
|
127
|
+
fetchCatalog(options: FetchCatalogOptions): Promise<ProviderCatalog>;
|
|
123
128
|
listCommands(config: AgentSessionConfig): Promise<AgentSlashCommand[]>;
|
|
124
129
|
listFeatures(config: AgentSessionConfig): Promise<AgentFeature[]>;
|
|
125
130
|
listImportableSessions(options?: ListImportableSessionsOptions): Promise<ImportableProviderSession[]>;
|
|
@@ -129,6 +134,8 @@ export declare class OpenCodeAgentClient implements AgentClient {
|
|
|
129
134
|
getDiagnostic(): Promise<{
|
|
130
135
|
diagnostic: string;
|
|
131
136
|
}>;
|
|
137
|
+
private fetchModelsFromClient;
|
|
138
|
+
private fetchModesFromClient;
|
|
132
139
|
private assertConfig;
|
|
133
140
|
private populateModelContextWindowCache;
|
|
134
141
|
}
|