@opencode/client 2.0.23 → 2.0.25
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/chunks/{service-version-02j88w0z.js → service-probe-1thtawyv.js} +1 -1
- package/dist/chunks/{service-version-1y4a697q.js → service-probe-1y4a697q.js} +1 -1
- package/dist/chunks/service-probe-2ny4vxct.js +92 -0
- package/dist/chunks/{service-version-z6qdwcsf.js → service-probe-65kht65h.js} +5 -5
- package/dist/chunks/{service-version-nyqggzs9.js → service-probe-9h52wrcy.js} +11 -2
- package/dist/chunks/{service-version-frbwqjmf.js → service-probe-frbwqjmf.js} +1 -1
- package/dist/chunks/{service-version-t1xa31vm.js → service-probe-t1xa31vm.js} +1 -1
- package/dist/chunks/{service-version-e5ea35j7.js → service-probe-trz7kcxd.js} +23 -1
- package/dist/chunks/{service-version-6f43cgzz.js → service-probe-ve4aws36.js} +47 -2
- package/dist/chunks/{service-version-7yt87z36.js → service-probe-vnspkrex.js} +12 -7
- package/dist/chunks/{service-version-21favj1f.js → service-probe-y99g37y2.js} +9 -9
- package/dist/chunks/{service-version-gah0fg5v.js → service-probe-z1hcmzxa.js} +4 -4
- package/dist/contract.js +1 -1
- package/dist/effect/api/api.d.ts +12 -0
- package/dist/effect/client.d.ts +1 -0
- package/dist/effect/client.js +8 -8
- package/dist/effect/generated/client-error.js +1 -1
- package/dist/effect/generated/client.d.ts +2 -1
- package/dist/effect/generated/client.js +5 -5
- package/dist/effect/generated/index.js +4 -4
- package/dist/effect/index.js +8 -8
- package/dist/effect/rpc.js +4 -4
- package/dist/effect/service.d.ts +19 -7
- package/dist/effect/service.js +49 -137
- package/dist/promise/client.d.ts +1 -0
- package/dist/promise/client.js +7 -7
- package/dist/promise/generated/client-error.js +1 -1
- package/dist/promise/generated/client.d.ts +2 -1
- package/dist/promise/generated/client.js +2 -2
- package/dist/promise/generated/index.js +8 -8
- package/dist/promise/generated/types.d.ts +81 -4
- package/dist/promise/generated/types.js +1 -1
- package/dist/promise/index.js +10 -10
- package/dist/promise/rpc.js +2 -2
- package/dist/promise/service.d.ts +2 -4
- package/dist/promise/service.js +43 -134
- package/dist/pty-handoff.js +1 -1
- package/dist/rpc-runtime.js +1 -1
- package/dist/service-contender.d.ts +27 -1
- package/dist/service-contender.js +3 -3
- package/dist/service-probe.d.ts +70 -0
- package/dist/service-probe.js +16 -0
- package/dist/service-timing.js +1 -1
- package/dist/service-version.js +1 -1
- package/dist/service.js +1 -1
- package/dist/shared-events.js +1 -1
- package/dist/solid/connection.js +1 -1
- package/dist/solid/data.d.ts +10 -0
- package/dist/solid/data.js +9 -9
- package/dist/solid/index.js +11 -11
- package/dist/solid/pty.js +1 -1
- package/package.json +5 -6
- /package/dist/chunks/{service-version-6mptkzbc.js → service-probe-6mptkzbc.js} +0 -0
- /package/dist/chunks/{service-version-9rqn6x4v.js → service-probe-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{service-version-gne7h7mq.js → service-probe-gne7h7mq.js} +0 -0
- /package/dist/chunks/{service-version-m2eywc8w.js → service-probe-m2eywc8w.js} +0 -0
- /package/dist/chunks/{service-version-nwcpakzx.js → service-probe-nwcpakzx.js} +0 -0
- /package/dist/chunks/{service-version-qav6mfdz.js → service-probe-qav6mfdz.js} +0 -0
- /package/dist/chunks/{service-version-sxt88q69.js → service-probe-sxt88q69.js} +0 -0
- /package/dist/chunks/{service-version-vmytr4q8.js → service-probe-vmytr4q8.js} +0 -0
- /package/dist/chunks/{service-version-vt9jbch8.js → service-probe-vt9jbch8.js} +0 -0
- /package/dist/chunks/{service-version-vyas3vgt.js → service-probe-vyas3vgt.js} +0 -0
- /package/dist/chunks/{service-version-xgnj2w4v.js → service-probe-xgnj2w4v.js} +0 -0
- /package/dist/chunks/{service-version-y2etg5bs.js → service-probe-y2etg5bs.js} +0 -0
- /package/dist/chunks/{service-version-ydhz1zrh.js → service-probe-ydhz1zrh.js} +0 -0
package/dist/promise/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import"../chunks/service-
|
|
1
|
+
import"../chunks/service-probe-m2eywc8w.js";
|
|
2
2
|
import {
|
|
3
3
|
exports_client3
|
|
4
|
-
} from "../chunks/service-
|
|
5
|
-
import"../chunks/service-
|
|
6
|
-
import"../chunks/service-
|
|
7
|
-
import {
|
|
8
|
-
ClientError3
|
|
9
|
-
} from "../chunks/service-version-nwcpakzx.js";
|
|
10
|
-
import"../chunks/service-version-1y4a697q.js";
|
|
4
|
+
} from "../chunks/service-probe-z1hcmzxa.js";
|
|
5
|
+
import"../chunks/service-probe-vyas3vgt.js";
|
|
6
|
+
import"../chunks/service-probe-1y4a697q.js";
|
|
11
7
|
import {
|
|
12
8
|
isInvalidRequestError2,
|
|
13
9
|
isUnauthorizedError2,
|
|
@@ -42,8 +38,12 @@ import {
|
|
|
42
38
|
isShellNotFoundError2,
|
|
43
39
|
isWorktreeError2,
|
|
44
40
|
isVcsInitNotSupportedError2
|
|
45
|
-
} from "../chunks/service-
|
|
46
|
-
import"../chunks/service-
|
|
41
|
+
} from "../chunks/service-probe-vt9jbch8.js";
|
|
42
|
+
import"../chunks/service-probe-9h52wrcy.js";
|
|
43
|
+
import {
|
|
44
|
+
ClientError3
|
|
45
|
+
} from "../chunks/service-probe-nwcpakzx.js";
|
|
46
|
+
import"../chunks/service-probe-frbwqjmf.js";
|
|
47
47
|
export {
|
|
48
48
|
ClientError3 as ClientError,
|
|
49
49
|
exports_client3 as OpenCode,
|
package/dist/promise/rpc.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { DiscoverOptions, Endpoint, EnsureOptions, StopOptions } from "../service.js";
|
|
2
|
+
import { headers } from "../service-probe.js";
|
|
2
3
|
export * from "../service.js";
|
|
4
|
+
export { headers };
|
|
3
5
|
/** Discover a healthy, compatible local service without starting one. */
|
|
4
6
|
export declare function discover(options?: DiscoverOptions): Promise<{
|
|
5
7
|
url: string;
|
|
@@ -13,10 +15,6 @@ export declare function discover(options?: DiscoverOptions): Promise<{
|
|
|
13
15
|
export declare function ensure(options?: EnsureOptions): Promise<Endpoint>;
|
|
14
16
|
/** Stop the registered local service. */
|
|
15
17
|
export declare function stop(options?: StopOptions): Promise<void>;
|
|
16
|
-
/** Create HTTP authentication headers for a service endpoint. */
|
|
17
|
-
export declare function headers(endpoint: Endpoint): {
|
|
18
|
-
authorization: string;
|
|
19
|
-
} | undefined;
|
|
20
18
|
/** Promise-based local service lifecycle operations. */
|
|
21
19
|
export declare const Service: {
|
|
22
20
|
discover: typeof discover;
|
package/dist/promise/service.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
spawnServiceContender2,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "../chunks/service-version-6f43cgzz.js";
|
|
3
|
+
contenderPool2
|
|
4
|
+
} from "../chunks/service-probe-ve4aws36.js";
|
|
6
5
|
import {
|
|
7
6
|
defaultEnsureTiming2,
|
|
8
7
|
ensureTiming2
|
|
9
|
-
} from "../chunks/service-
|
|
8
|
+
} from "../chunks/service-probe-xgnj2w4v.js";
|
|
10
9
|
import {
|
|
11
10
|
matchesVersion2
|
|
12
|
-
} from "../chunks/service-
|
|
11
|
+
} from "../chunks/service-probe-sxt88q69.js";
|
|
13
12
|
import {
|
|
14
13
|
prepare2,
|
|
15
14
|
environment2,
|
|
16
15
|
complete2,
|
|
17
16
|
clear2
|
|
18
|
-
} from "../chunks/service-
|
|
19
|
-
import
|
|
17
|
+
} from "../chunks/service-probe-1thtawyv.js";
|
|
18
|
+
import {
|
|
19
|
+
decide2,
|
|
20
|
+
fallback2,
|
|
21
|
+
same2,
|
|
22
|
+
probeResult2,
|
|
23
|
+
headers2
|
|
24
|
+
} from "../chunks/service-probe-2ny4vxct.js";
|
|
25
|
+
import"../chunks/service-probe-qav6mfdz.js";
|
|
20
26
|
|
|
21
27
|
// src/promise/service.ts
|
|
22
28
|
import { readFile, rm } from "node:fs/promises";
|
|
23
|
-
import { homedir } from "node:os";
|
|
24
|
-
import { join } from "node:path";
|
|
25
29
|
async function discover(options = {}) {
|
|
26
30
|
const found = (await registered(options.file)).service;
|
|
27
31
|
if (found?.state !== "ready")
|
|
@@ -35,12 +39,9 @@ async function discover(options = {}) {
|
|
|
35
39
|
async function ensure(options = {}) {
|
|
36
40
|
const timing = ensureTiming2(options);
|
|
37
41
|
const deadline = Date.now() + timing.promiseTimeout;
|
|
38
|
-
const
|
|
42
|
+
const pool = contenderPool2(timing);
|
|
39
43
|
let timeouts;
|
|
40
44
|
let announced = false;
|
|
41
|
-
let lastSpawn = 0;
|
|
42
|
-
let spawnDelay = timing.spawnDelay;
|
|
43
|
-
let failure;
|
|
44
45
|
const announce = (reason, previousVersion) => {
|
|
45
46
|
if (announced)
|
|
46
47
|
return;
|
|
@@ -52,7 +53,7 @@ async function ensure(options = {}) {
|
|
|
52
53
|
if (command === undefined)
|
|
53
54
|
throw new Error("Missing service command");
|
|
54
55
|
try {
|
|
55
|
-
return spawnServiceContender2(command, args, await environment2(options.file ??
|
|
56
|
+
return spawnServiceContender2(command, args, await environment2(options.file ?? fallback2(), options.env));
|
|
56
57
|
} catch (cause) {
|
|
57
58
|
throw new Error("Failed to start server", { cause });
|
|
58
59
|
}
|
|
@@ -60,103 +61,66 @@ async function ensure(options = {}) {
|
|
|
60
61
|
try {
|
|
61
62
|
while (true) {
|
|
62
63
|
if (Date.now() >= deadline)
|
|
63
|
-
throw failure ?? new Error("Timed out waiting for the background service to start");
|
|
64
|
+
throw pool.failure() ?? new Error("Timed out waiting for the background service to start");
|
|
64
65
|
const registration = await registered(options.file, timing.requestTimeout);
|
|
65
66
|
if (registration.timedOut && registration.info !== undefined) {
|
|
66
67
|
timeouts = {
|
|
67
68
|
info: registration.info,
|
|
68
|
-
count: timeouts !== undefined &&
|
|
69
|
+
count: timeouts !== undefined && same2(timeouts.info, registration.info) ? timeouts.count + 1 : 1
|
|
69
70
|
};
|
|
70
71
|
if (timeouts.count >= 3) {
|
|
71
72
|
announce("missing");
|
|
72
73
|
console.warn("Background service is unresponsive; recovery cannot preserve persistent terminals");
|
|
73
|
-
await clear2(options.file ??
|
|
74
|
+
await clear2(options.file ?? fallback2());
|
|
74
75
|
await terminate(registration.info, options, timing);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
item.release();
|
|
78
|
-
contenders.delete(item);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
failure = undefined;
|
|
76
|
+
pool.evict(registration.info.pid);
|
|
77
|
+
pool.recruitNow();
|
|
82
78
|
timeouts = undefined;
|
|
83
|
-
lastSpawn = Date.now() - spawnDelay;
|
|
84
79
|
}
|
|
85
80
|
} else
|
|
86
81
|
timeouts = undefined;
|
|
87
82
|
if (registration.service !== undefined) {
|
|
88
|
-
|
|
83
|
+
pool.serviceAnswered();
|
|
89
84
|
const service2 = registration.service;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await complete2(options.file ?? fallback(), service2.info);
|
|
85
|
+
const decision = decide2(service2, options);
|
|
86
|
+
if (decision._tag === "fail")
|
|
87
|
+
throw decision.error;
|
|
88
|
+
if (decision._tag === "reuse") {
|
|
89
|
+
await complete2(options.file ?? fallback2(), service2.info);
|
|
96
90
|
return service2.endpoint;
|
|
97
91
|
}
|
|
98
|
-
if (
|
|
99
|
-
throw new Error("Background service failed to start");
|
|
100
|
-
if (!compatible) {
|
|
92
|
+
if (decision._tag === "replace") {
|
|
101
93
|
announce("version-mismatch", service2.version);
|
|
102
94
|
if (service2.state !== "ready")
|
|
103
95
|
console.warn("Background service is not ready; replacement cannot preserve persistent terminals");
|
|
104
|
-
await stop({
|
|
105
|
-
file: options.file,
|
|
106
|
-
pty: service2.state === "ready" ? "handoff" : "clear"
|
|
107
|
-
}).catch(() => {
|
|
96
|
+
await stop({ file: options.file, pty: decision.pty }).catch(() => {
|
|
108
97
|
return;
|
|
109
98
|
});
|
|
110
|
-
|
|
111
|
-
if (item.child.pid === service2.info.pid || contenderFinished2(item)) {
|
|
112
|
-
item.release();
|
|
113
|
-
contenders.delete(item);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
failure = undefined;
|
|
117
|
-
lastSpawn = 0;
|
|
99
|
+
pool.evict(service2.info.pid);
|
|
118
100
|
}
|
|
119
101
|
} else {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (finished.some((item) => item.child.exitCode === 0)) {
|
|
125
|
-
spawnDelay = Math.min(spawnDelay * 2, timing.maxSpawnDelay);
|
|
126
|
-
}
|
|
127
|
-
finished.forEach((item) => contenders.delete(item));
|
|
128
|
-
if (failure !== undefined && contenders.size === 0)
|
|
129
|
-
throw failure;
|
|
130
|
-
if (failure === undefined && contenders.size < 2 && Date.now() - lastSpawn >= spawnDelay) {
|
|
102
|
+
const failed = pool.reap();
|
|
103
|
+
if (failed !== undefined)
|
|
104
|
+
throw failed;
|
|
105
|
+
if (pool.shouldRecruit(registration.info !== undefined)) {
|
|
131
106
|
announce("missing");
|
|
132
|
-
|
|
133
|
-
lastSpawn = Date.now();
|
|
107
|
+
pool.add(await spawnContender());
|
|
134
108
|
}
|
|
135
109
|
}
|
|
136
110
|
await delay(timing.pollInterval);
|
|
137
111
|
}
|
|
138
112
|
} finally {
|
|
139
|
-
|
|
113
|
+
pool.releaseAll();
|
|
140
114
|
}
|
|
141
115
|
}
|
|
142
116
|
async function stop(options = {}) {
|
|
143
117
|
const info = await read(options.file);
|
|
144
|
-
await (options.pty === "handoff" && info !== undefined ? prepare2(options.file ??
|
|
118
|
+
await (options.pty === "handoff" && info !== undefined ? prepare2(options.file ?? fallback2(), info, defaultEnsureTiming2.requestTimeout) : clear2(options.file ?? fallback2())).catch((cause) => console.warn("Failed to prepare persistent terminals for replacement", cause));
|
|
145
119
|
if (info !== undefined)
|
|
146
120
|
await terminate(info, options, ensureTiming2(options));
|
|
147
121
|
}
|
|
148
|
-
function fallback() {
|
|
149
|
-
return join(process.env["XDG_STATE_HOME"] ?? join(homedir(), ".local", "state"), "opencode", "service.json");
|
|
150
|
-
}
|
|
151
|
-
function headers(endpoint) {
|
|
152
|
-
if (endpoint.auth === undefined)
|
|
153
|
-
return;
|
|
154
|
-
return {
|
|
155
|
-
authorization: "Basic " + Buffer.from(endpoint.auth.username + ":" + endpoint.auth.password).toString("base64")
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
122
|
async function read(file) {
|
|
159
|
-
const text = await readFile(file ??
|
|
123
|
+
const text = await readFile(file ?? fallback2(), "utf8").catch(() => {
|
|
160
124
|
return;
|
|
161
125
|
});
|
|
162
126
|
if (text === undefined)
|
|
@@ -167,63 +131,11 @@ async function read(file) {
|
|
|
167
131
|
return;
|
|
168
132
|
}
|
|
169
133
|
}
|
|
170
|
-
async function probeResult(info, timeout = defaultEnsureTiming2.requestTimeout) {
|
|
171
|
-
const endpoint = {
|
|
172
|
-
url: info.url,
|
|
173
|
-
auth: info.password === undefined ? undefined : { type: "basic", username: "opencode", password: info.password }
|
|
174
|
-
};
|
|
175
|
-
const signal = AbortSignal.timeout(timeout);
|
|
176
|
-
const result = await fetch(new URL("/api/info", info.url), { headers: headers(endpoint), signal }).then(async (response) => ({
|
|
177
|
-
response,
|
|
178
|
-
body: response.status === 404 ? undefined : await response.json()
|
|
179
|
-
})).then((value) => ({ value }), (cause) => ({ cause }));
|
|
180
|
-
if ("cause" in result)
|
|
181
|
-
return { service: undefined, timedOut: signal.aborted };
|
|
182
|
-
const response = result.value.response;
|
|
183
|
-
if (response.status === 404)
|
|
184
|
-
return {
|
|
185
|
-
service: {
|
|
186
|
-
info,
|
|
187
|
-
endpoint,
|
|
188
|
-
version: info.version,
|
|
189
|
-
state: "ready",
|
|
190
|
-
compatible: false
|
|
191
|
-
},
|
|
192
|
-
timedOut: false
|
|
193
|
-
};
|
|
194
|
-
const serverInfo = decodeInfo(result.value.body);
|
|
195
|
-
if (serverInfo !== undefined) {
|
|
196
|
-
if (serverInfo.pid !== info.pid)
|
|
197
|
-
return { service: undefined, timedOut: false };
|
|
198
|
-
if (info.version !== undefined && serverInfo.version !== info.version)
|
|
199
|
-
return { service: undefined, timedOut: false };
|
|
200
|
-
return {
|
|
201
|
-
service: {
|
|
202
|
-
info,
|
|
203
|
-
endpoint,
|
|
204
|
-
version: serverInfo.version,
|
|
205
|
-
state: response.ok ? "ready" : response.status === 500 ? "failed" : "waiting",
|
|
206
|
-
compatible: true
|
|
207
|
-
},
|
|
208
|
-
timedOut: false
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
return { service: undefined, timedOut: false };
|
|
212
|
-
}
|
|
213
|
-
function decodeInfo(input) {
|
|
214
|
-
if (typeof input !== "object" || input === null)
|
|
215
|
-
return;
|
|
216
|
-
if (!("version" in input) || typeof input.version !== "string")
|
|
217
|
-
return;
|
|
218
|
-
if (!("pid" in input) || typeof input.pid !== "number" || !Number.isInteger(input.pid) || input.pid < 0)
|
|
219
|
-
return;
|
|
220
|
-
return { version: input.version, pid: input.pid };
|
|
221
|
-
}
|
|
222
134
|
async function registered(file, timeout) {
|
|
223
135
|
const info = await read(file);
|
|
224
136
|
if (info === undefined)
|
|
225
137
|
return { info: undefined, service: undefined, timedOut: false };
|
|
226
|
-
return { info, ...await
|
|
138
|
+
return { info, ...await probeResult2(info, timeout) };
|
|
227
139
|
}
|
|
228
140
|
function signal(pid, name) {
|
|
229
141
|
try {
|
|
@@ -247,12 +159,9 @@ async function waitUntilStopped(pid, timing) {
|
|
|
247
159
|
}
|
|
248
160
|
return false;
|
|
249
161
|
}
|
|
250
|
-
function same(left, right) {
|
|
251
|
-
return left.id === right.id && left.version === right.version && left.url === right.url && left.pid === right.pid;
|
|
252
|
-
}
|
|
253
162
|
async function terminate(info, options, timing) {
|
|
254
163
|
const current = await read(options.file);
|
|
255
|
-
if (current === undefined || !
|
|
164
|
+
if (current === undefined || !same2(current, info))
|
|
256
165
|
return;
|
|
257
166
|
signal(info.pid, "SIGTERM");
|
|
258
167
|
if (!await waitUntilStopped(info.pid, timing)) {
|
|
@@ -261,18 +170,18 @@ async function terminate(info, options, timing) {
|
|
|
261
170
|
throw new Error(`Server process ${info.pid} is still running`);
|
|
262
171
|
}
|
|
263
172
|
const latest = await read(options.file);
|
|
264
|
-
if (latest === undefined || !
|
|
173
|
+
if (latest === undefined || !same2(latest, info))
|
|
265
174
|
return;
|
|
266
|
-
await rm(options.file ??
|
|
175
|
+
await rm(options.file ?? fallback2(), { force: true });
|
|
267
176
|
}
|
|
268
177
|
function delay(milliseconds) {
|
|
269
178
|
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
270
179
|
}
|
|
271
|
-
var Service = { discover, ensure, stop, headers };
|
|
180
|
+
var Service = { discover, ensure, stop, headers: headers2 };
|
|
272
181
|
export {
|
|
273
182
|
Service,
|
|
274
183
|
discover,
|
|
275
184
|
ensure,
|
|
276
|
-
headers,
|
|
185
|
+
headers2 as headers,
|
|
277
186
|
stop
|
|
278
187
|
};
|
package/dist/pty-handoff.js
CHANGED
package/dist/rpc-runtime.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import type { EnsureTiming } from "./service-timing.js";
|
|
2
3
|
export type ServiceContender = {
|
|
3
4
|
readonly child: ChildProcess;
|
|
4
5
|
readonly error: () => Error | undefined;
|
|
@@ -7,5 +8,30 @@ export type ServiceContender = {
|
|
|
7
8
|
readonly release: () => void;
|
|
8
9
|
};
|
|
9
10
|
export declare function spawnServiceContender(command: string, args: ReadonlyArray<string>, env?: Readonly<Record<string, string | undefined>>): ServiceContender;
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The startup attempts of one `ensure()` call. It keeps at most two attempts alive, remembers
|
|
13
|
+
* the first startup failure, and backs off when attempts exit cleanly because another one won.
|
|
14
|
+
*/
|
|
15
|
+
export declare function contenderPool(timing: EnsureTiming): {
|
|
16
|
+
/** The first startup failure seen since the last eviction. */
|
|
17
|
+
failure: () => Error | undefined;
|
|
18
|
+
/** A registered service answered, so the next attempt waits the base delay again. */
|
|
19
|
+
serviceAnswered(): void;
|
|
20
|
+
/**
|
|
21
|
+
* The owner `pid` was replaced. Drop its attempt and any finished ones, forget their
|
|
22
|
+
* failure, and restart the spawn clock.
|
|
23
|
+
*/
|
|
24
|
+
evict(pid: number): void;
|
|
25
|
+
/** Let the next attempt start without waiting a spawn delay. */
|
|
26
|
+
recruitNow(): void;
|
|
27
|
+
/** Collect finished attempts. Returns the startup failure once no attempt is left alive. */
|
|
28
|
+
reap(): Error | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to start another attempt now. A registration that has not answered yet gets one
|
|
31
|
+
* spawn delay before an attempt competes with it.
|
|
32
|
+
*/
|
|
33
|
+
shouldRecruit(registered: boolean): boolean;
|
|
34
|
+
add(contender: ServiceContender): void;
|
|
35
|
+
releaseAll(): void;
|
|
36
|
+
};
|
|
11
37
|
export declare function contenderFinished(contender: ServiceContender): boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
spawnServiceContender2,
|
|
3
|
-
|
|
3
|
+
contenderPool2,
|
|
4
4
|
contenderFinished2
|
|
5
|
-
} from "./chunks/service-
|
|
5
|
+
} from "./chunks/service-probe-ve4aws36.js";
|
|
6
6
|
export {
|
|
7
|
-
contenderFailure2 as contenderFailure,
|
|
8
7
|
contenderFinished2 as contenderFinished,
|
|
8
|
+
contenderPool2 as contenderPool,
|
|
9
9
|
spawnServiceContender2 as spawnServiceContender
|
|
10
10
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { DiscoverOptions, Endpoint, Info } from "./service.js";
|
|
2
|
+
export type LocalService = {
|
|
3
|
+
readonly info: Info;
|
|
4
|
+
readonly endpoint: Endpoint;
|
|
5
|
+
readonly version?: string;
|
|
6
|
+
readonly state: "ready" | "waiting" | "failed";
|
|
7
|
+
readonly compatible: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* What `ensure()` does with a registered service that answered: return it, keep polling while
|
|
11
|
+
* it starts, replace it because its version does not meet the requirement, or fail.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decide(service: LocalService, options: DiscoverOptions): {
|
|
14
|
+
_tag: "fail";
|
|
15
|
+
error: Error;
|
|
16
|
+
} | {
|
|
17
|
+
readonly _tag: "replace";
|
|
18
|
+
readonly pty: "clear" | "handoff";
|
|
19
|
+
} | {
|
|
20
|
+
readonly _tag: "reuse";
|
|
21
|
+
readonly pty?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
readonly _tag: "wait";
|
|
24
|
+
readonly pty?: undefined;
|
|
25
|
+
};
|
|
26
|
+
/** The default registration file. */
|
|
27
|
+
export declare function fallback(): string;
|
|
28
|
+
/** Whether two registrations describe the same service instance. */
|
|
29
|
+
export declare function same(left: Info, right: Info): boolean;
|
|
30
|
+
/** Ask a registered owner for its health and classify the answer. */
|
|
31
|
+
export declare function probeResult(info: Info, timeout?: number): Promise<{
|
|
32
|
+
service: undefined;
|
|
33
|
+
timedOut: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
service: {
|
|
36
|
+
info: Info;
|
|
37
|
+
endpoint: {
|
|
38
|
+
url: string;
|
|
39
|
+
auth: {
|
|
40
|
+
type: "basic";
|
|
41
|
+
username: string;
|
|
42
|
+
password: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
};
|
|
45
|
+
version: string | undefined;
|
|
46
|
+
state: "ready";
|
|
47
|
+
compatible: false;
|
|
48
|
+
};
|
|
49
|
+
timedOut: boolean;
|
|
50
|
+
} | {
|
|
51
|
+
service: {
|
|
52
|
+
info: Info;
|
|
53
|
+
endpoint: {
|
|
54
|
+
url: string;
|
|
55
|
+
auth: {
|
|
56
|
+
type: "basic";
|
|
57
|
+
username: string;
|
|
58
|
+
password: string;
|
|
59
|
+
} | undefined;
|
|
60
|
+
};
|
|
61
|
+
version: string;
|
|
62
|
+
state: "failed" | "ready" | "waiting";
|
|
63
|
+
compatible: true;
|
|
64
|
+
};
|
|
65
|
+
timedOut: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
/** Create HTTP authentication headers for a service endpoint. */
|
|
68
|
+
export declare function headers(endpoint: Endpoint): {
|
|
69
|
+
authorization: string;
|
|
70
|
+
} | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decide2,
|
|
3
|
+
fallback2,
|
|
4
|
+
same2,
|
|
5
|
+
probeResult2,
|
|
6
|
+
headers2
|
|
7
|
+
} from "./chunks/service-probe-2ny4vxct.js";
|
|
8
|
+
import"./chunks/service-probe-sxt88q69.js";
|
|
9
|
+
import"./chunks/service-probe-xgnj2w4v.js";
|
|
10
|
+
export {
|
|
11
|
+
decide2 as decide,
|
|
12
|
+
fallback2 as fallback,
|
|
13
|
+
headers2 as headers,
|
|
14
|
+
probeResult2 as probeResult,
|
|
15
|
+
same2 as same
|
|
16
|
+
};
|
package/dist/service-timing.js
CHANGED
package/dist/service-version.js
CHANGED
package/dist/service.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunks/service-
|
|
1
|
+
import"./chunks/service-probe-qav6mfdz.js";
|
package/dist/shared-events.js
CHANGED
package/dist/solid/connection.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
defaultIdleTimeout2,
|
|
3
3
|
foregroundIdleThreshold2,
|
|
4
4
|
createClientConnection2
|
|
5
|
-
} from "../chunks/service-
|
|
5
|
+
} from "../chunks/service-probe-ydhz1zrh.js";
|
|
6
6
|
export {
|
|
7
7
|
createClientConnection2 as createClientConnection,
|
|
8
8
|
defaultIdleTimeout2 as defaultIdleTimeout,
|
package/dist/solid/data.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { AgentInfo, CommandInfo, ConfigEntry, SessionFormCancelInput, FormInfo, SessionFormReplyInput, IntegrationInfo, LocationRef, McpResource, McpServer, ModelInfo, ModelRef, PermissionSavedInfo, PermissionRequest, PermissionReplyInput, Project, ProviderInfo, ReferenceInfo, SessionMessageInfo, SessionInfo, SessionInboxInfo, SessionInboxCompaction, ShellInfo, SkillInfo, VcsInfo, OpenCodeEvent, OpenCodeClient, WebSearchProvider } from "../promise";
|
|
2
2
|
import { type SessionPromptInput } from "../promise";
|
|
3
3
|
export type DataSessionStatus = "idle" | "running";
|
|
4
|
+
/**
|
|
5
|
+
* Where a pending user prompt stands relative to the runner: `starting` is promoted at the next idle boundary,
|
|
6
|
+
* `steering` waits for the next step boundary of an execution that already delivered input, `stranded` outlived an
|
|
7
|
+
* execution that ended without delivering it, and `queued` waits for every steer to drain.
|
|
8
|
+
*/
|
|
9
|
+
export type DataPendingStatus = "starting" | "steering" | "stranded" | "queued";
|
|
4
10
|
type OpenCodeEventMap = {
|
|
5
11
|
[Type in OpenCodeEvent["type"]]: Extract<OpenCodeEvent, {
|
|
6
12
|
type: Type;
|
|
@@ -50,12 +56,14 @@ export declare function createData(config: CreateDataInput): {
|
|
|
50
56
|
evict(sessionID: string): void;
|
|
51
57
|
cost(sessionID: string): number;
|
|
52
58
|
status(sessionID: string): DataSessionStatus;
|
|
59
|
+
active(): string[];
|
|
53
60
|
input: {
|
|
54
61
|
list(sessionID: string): string[];
|
|
55
62
|
has(sessionID: string, inboxID: string): boolean;
|
|
56
63
|
};
|
|
57
64
|
pending: {
|
|
58
65
|
list(sessionID: string): SessionInboxInfo[];
|
|
66
|
+
status(sessionID: string, inboxID: string): DataPendingStatus | undefined;
|
|
59
67
|
sync(sessionID: string): Promise<void>;
|
|
60
68
|
invalidate(sessionID: string): void;
|
|
61
69
|
};
|
|
@@ -98,12 +106,14 @@ export declare function createData(config: CreateDataInput): {
|
|
|
98
106
|
};
|
|
99
107
|
permission: {
|
|
100
108
|
list(sessionID: string): PermissionRequest[];
|
|
109
|
+
sessions(): string[];
|
|
101
110
|
sync(sessionID: string): Promise<void>;
|
|
102
111
|
invalidate(sessionID: string): void;
|
|
103
112
|
reply(input: PermissionReplyInput): Promise<void>;
|
|
104
113
|
};
|
|
105
114
|
form: {
|
|
106
115
|
list(sessionID: string, ref?: LocationRef): FormWithLocation[] | undefined;
|
|
116
|
+
sessions(): string[];
|
|
107
117
|
sync(sessionID: string, ref?: LocationRef): Promise<void>;
|
|
108
118
|
invalidate(sessionID: string, ref?: LocationRef): void;
|
|
109
119
|
reply(input: SessionFormReplyInput, ref?: LocationRef): Promise<void>;
|
package/dist/solid/data.js
CHANGED
|
@@ -2,15 +2,15 @@ import {
|
|
|
2
2
|
settleMs2,
|
|
3
3
|
locationKey2,
|
|
4
4
|
createData2
|
|
5
|
-
} from "../chunks/service-
|
|
6
|
-
import"../chunks/service-
|
|
7
|
-
import"../chunks/service-
|
|
8
|
-
import"../chunks/service-
|
|
9
|
-
import"../chunks/service-
|
|
10
|
-
import"../chunks/service-
|
|
11
|
-
import"../chunks/service-
|
|
12
|
-
import"../chunks/service-
|
|
13
|
-
import"../chunks/service-
|
|
5
|
+
} from "../chunks/service-probe-trz7kcxd.js";
|
|
6
|
+
import"../chunks/service-probe-m2eywc8w.js";
|
|
7
|
+
import"../chunks/service-probe-z1hcmzxa.js";
|
|
8
|
+
import"../chunks/service-probe-vyas3vgt.js";
|
|
9
|
+
import"../chunks/service-probe-1y4a697q.js";
|
|
10
|
+
import"../chunks/service-probe-vt9jbch8.js";
|
|
11
|
+
import"../chunks/service-probe-9h52wrcy.js";
|
|
12
|
+
import"../chunks/service-probe-nwcpakzx.js";
|
|
13
|
+
import"../chunks/service-probe-frbwqjmf.js";
|
|
14
14
|
export {
|
|
15
15
|
createData2 as createData,
|
|
16
16
|
locationKey2 as locationKey,
|