@opencode/client 2.0.22 → 2.0.24
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-contender-1tbj6z39.js → pty-handoff-1y4a697q.js} +1 -1
- package/dist/chunks/{service-contender-mxz277s4.js → pty-handoff-5yf5aaev.js} +12 -10
- package/dist/chunks/{service-contender-1kn39gq3.js → pty-handoff-71wkqa80.js} +14 -21
- package/dist/chunks/{service-contender-y2etg5bs.js → pty-handoff-7f0py9js.js} +2 -2
- package/dist/chunks/pty-handoff-ank0d71z.js +75 -0
- package/dist/chunks/pty-handoff-cqfz2qxq.js +30 -0
- package/dist/chunks/{service-contender-frbwqjmf.js → pty-handoff-frbwqjmf.js} +1 -1
- package/dist/chunks/{service-contender-nwcpakzx.js → pty-handoff-js54wxgp.js} +2 -2
- package/dist/chunks/{service-contender-krgmp8b6.js → pty-handoff-myyn5x39.js} +17 -17
- package/dist/chunks/{service-contender-50fct660.js → pty-handoff-qzsnm4q8.js} +77 -63
- package/dist/chunks/{service-contender-h11j9btw.js → pty-handoff-src6by76.js} +10 -1
- package/dist/chunks/{service-contender-t1xa31vm.js → pty-handoff-t1xa31vm.js} +1 -1
- package/dist/chunks/{service-contender-txckps9j.js → pty-handoff-ve4aws36.js} +48 -2
- package/dist/chunks/{service-contender-4tveyqeh.js → pty-handoff-vt9jbch8.js} +4 -2
- package/dist/chunks/{service-contender-z6qdwcsf.js → pty-handoff-w1w809zr.js} +5 -5
- package/dist/contract.js +1 -1
- package/dist/effect/api/api.d.ts +12 -0
- package/dist/effect/client.d.ts +93 -92
- package/dist/effect/client.js +12 -12
- package/dist/effect/generated/client-error.js +3 -3
- package/dist/effect/generated/client.d.ts +93 -92
- package/dist/effect/generated/client.js +5 -5
- package/dist/effect/generated/index.js +8 -8
- package/dist/effect/index.js +12 -12
- package/dist/effect/rpc.js +4 -4
- package/dist/effect/service.d.ts +5 -7
- package/dist/effect/service.js +44 -115
- package/dist/promise/client.d.ts +1 -0
- package/dist/promise/client.js +11 -11
- package/dist/promise/generated/client-error.js +3 -3
- package/dist/promise/generated/client.d.ts +2 -1
- package/dist/promise/generated/client.js +4 -4
- package/dist/promise/generated/index.js +13 -9
- package/dist/promise/generated/types.d.ts +33 -0
- package/dist/promise/generated/types.js +6 -2
- package/dist/promise/index.js +17 -13
- package/dist/promise/rpc.js +2 -2
- package/dist/promise/service.d.ts +2 -4
- package/dist/promise/service.js +41 -115
- package/dist/pty-handoff.d.ts +4 -1
- 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 +53 -0
- package/dist/service-probe.js +13 -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 +3 -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 +4 -4
- package/dist/chunks/service-contender-992ffpa9.js +0 -30
- /package/dist/chunks/{service-contender-6mptkzbc.js → pty-handoff-6mptkzbc.js} +0 -0
- /package/dist/chunks/{service-contender-9rqn6x4v.js → pty-handoff-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{service-contender-gne7h7mq.js → pty-handoff-gne7h7mq.js} +0 -0
- /package/dist/chunks/{service-contender-m2eywc8w.js → pty-handoff-m2eywc8w.js} +0 -0
- /package/dist/chunks/{service-contender-qav6mfdz.js → pty-handoff-qav6mfdz.js} +0 -0
- /package/dist/chunks/{service-contender-sxt88q69.js → pty-handoff-sxt88q69.js} +0 -0
- /package/dist/chunks/{service-contender-vmytr4q8.js → pty-handoff-vmytr4q8.js} +0 -0
- /package/dist/chunks/{service-contender-vyas3vgt.js → pty-handoff-vyas3vgt.js} +0 -0
- /package/dist/chunks/{service-contender-xgnj2w4v.js → pty-handoff-xgnj2w4v.js} +0 -0
- /package/dist/chunks/{service-contender-ydhz1zrh.js → pty-handoff-ydhz1zrh.js} +0 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientApi2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./pty-handoff-vmytr4q8.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./
|
|
5
|
+
ClientError3
|
|
6
|
+
} from "./pty-handoff-7f0py9js.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./pty-handoff-9rqn6x4v.js";
|
|
10
10
|
|
|
11
11
|
// src/effect/generated/client.ts
|
|
12
|
-
var
|
|
13
|
-
__export(
|
|
14
|
-
make: () =>
|
|
12
|
+
var exports_client4 = {};
|
|
13
|
+
__export(exports_client4, {
|
|
14
|
+
make: () => make5
|
|
15
15
|
});
|
|
16
16
|
import { Effect, Stream, Schema } from "effect";
|
|
17
17
|
import { Sse } from "effect/unstable/encoding";
|
|
18
18
|
import { HttpClientError } from "effect/unstable/http";
|
|
19
19
|
import { HttpApiClient } from "effect/unstable/httpapi";
|
|
20
|
-
var mapClientError = (error) => HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error) ? new
|
|
20
|
+
var mapClientError = (error) => HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error) ? new ClientError3({ cause: error }) : error;
|
|
21
21
|
var preserveEffect = () => (effect) => effect;
|
|
22
22
|
var preserveStream = () => (stream) => stream;
|
|
23
23
|
var EndpointServerInfo = (raw) => () => preserveEffect()(raw["server.info"]({}).pipe(Effect.mapError(mapClientError)));
|
|
@@ -539,6 +539,7 @@ var adaptGroupWorktree = (raw) => ({
|
|
|
539
539
|
remove: EndpointWorktreeRemove(raw),
|
|
540
540
|
refresh: EndpointWorktreeRefresh(raw)
|
|
541
541
|
});
|
|
542
|
+
var EndpointVcsInit = (raw) => (input) => preserveEffect()(raw["vcs.init"]({ query: { location: input?.["location"], provider: input?.["provider"] } }).pipe(Effect.mapError(mapClientError)));
|
|
542
543
|
var EndpointVcsGet = (raw) => (input) => preserveEffect()(raw["vcs.get"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)));
|
|
543
544
|
var EndpointVcsBase = (raw) => (input) => preserveEffect()(raw["vcs.base"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)));
|
|
544
545
|
var EndpointVcsStatus = (raw) => (input) => preserveEffect()(raw["vcs.status"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)));
|
|
@@ -549,6 +550,7 @@ var EndpointVcsDiff = (raw) => (input) => preserveEffect()(raw["vcs.diff"]({
|
|
|
549
550
|
query: { location: input["location"], mode: input["mode"], base: input["base"], context: input["context"] }
|
|
550
551
|
}).pipe(Effect.mapError(mapClientError)));
|
|
551
552
|
var adaptGroupVcs = (raw) => ({
|
|
553
|
+
init: EndpointVcsInit(raw),
|
|
552
554
|
get: EndpointVcsGet(raw),
|
|
553
555
|
base: EndpointVcsBase(raw),
|
|
554
556
|
status: EndpointVcsStatus(raw),
|
|
@@ -611,6 +613,6 @@ var adaptClient = (raw) => ({
|
|
|
611
613
|
websearch: adaptGroupWebsearch(raw["server.websearch"]),
|
|
612
614
|
config: adaptGroupConfig(raw["server.config"])
|
|
613
615
|
});
|
|
614
|
-
var
|
|
616
|
+
var make5 = (options) => HttpApiClient.make(ClientApi2, options).pipe(Effect.map(adaptClient));
|
|
615
617
|
|
|
616
|
-
export {
|
|
618
|
+
export { make5, exports_client4 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./pty-handoff-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/pty-handoff.ts
|
|
6
6
|
var exports_pty_handoff = {};
|
|
@@ -16,38 +16,31 @@ async function prepare2(file, info, timeout) {
|
|
|
16
16
|
const existing = await read(file);
|
|
17
17
|
if (existing !== undefined && existing.expiresAt > Date.now() && same(existing.source, info))
|
|
18
18
|
return;
|
|
19
|
-
const {
|
|
19
|
+
const { OpenCode } = await import("../promise/index.js");
|
|
20
20
|
const client = OpenCode.make({
|
|
21
21
|
baseUrl: info.url,
|
|
22
22
|
headers: info.password === undefined ? undefined : { authorization: "Basic " + Buffer.from(`opencode:${info.password}`).toString("base64") }
|
|
23
23
|
});
|
|
24
|
-
const
|
|
25
|
-
const result = await client.experimental.persistentPty.handoff({ signal: AbortSignal.timeout(timeout) }).then((value) => ({ value }), (cause) => ({ cause }));
|
|
26
|
-
if ("cause" in result) {
|
|
24
|
+
const handoff = await client.experimental.persistentPty.handoff({ signal: AbortSignal.timeout(timeout) }).then(parse).catch(async (cause) => {
|
|
27
25
|
const concurrent = await read(file);
|
|
28
26
|
if (concurrent !== undefined && concurrent.expiresAt > Date.now() && same(concurrent.source, info))
|
|
29
27
|
return;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return;
|
|
36
|
-
throw new Error("Failed to shut down persistent terminals before service replacement", { cause });
|
|
37
|
-
});
|
|
38
|
-
await publish(file, info, null);
|
|
28
|
+
console.warn("Background service cannot hand off persistent terminals; shutting them down before replacement", cause);
|
|
29
|
+
await client.experimental.persistentPty.shutdown({ signal: AbortSignal.timeout(timeout) }).catch(() => {});
|
|
30
|
+
return null;
|
|
31
|
+
});
|
|
32
|
+
if (handoff === undefined)
|
|
39
33
|
return;
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
await publish(file, info, handoff).catch((cause) => console.warn("Failed to publish persistent terminal handoff", cause));
|
|
35
|
+
}
|
|
36
|
+
function parse(body) {
|
|
42
37
|
if (typeof body !== "object" || body === null || !("handoff" in body))
|
|
43
38
|
throw new Error("Invalid persistent terminal handoff response");
|
|
44
|
-
if (body.handoff === null)
|
|
45
|
-
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
39
|
+
if (body.handoff === null)
|
|
40
|
+
return null;
|
|
48
41
|
if (!isHandoff(body.handoff) || body.handoff.expiresAt <= Date.now())
|
|
49
42
|
throw new Error("Invalid or expired persistent terminal handoff");
|
|
50
|
-
|
|
43
|
+
return body.handoff;
|
|
51
44
|
}
|
|
52
45
|
async function publish(file, info, handoff) {
|
|
53
46
|
const temporary = `${file}.pty-handoff.${crypto.randomUUID()}.tmp`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/effect/generated/client-error.ts
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class ClientError3 extends Schema.TaggedError()("ClientError", {
|
|
5
5
|
cause: Schema.Defect()
|
|
6
6
|
}) {
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { ClientError3 };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultEnsureTiming2
|
|
3
|
+
} from "./pty-handoff-xgnj2w4v.js";
|
|
4
|
+
|
|
5
|
+
// src/service-probe.ts
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
function fallback2() {
|
|
9
|
+
return join(process.env["XDG_STATE_HOME"] ?? join(homedir(), ".local", "state"), "opencode", "service.json");
|
|
10
|
+
}
|
|
11
|
+
function same2(left, right) {
|
|
12
|
+
return left.id === right.id && left.version === right.version && left.url === right.url && left.pid === right.pid;
|
|
13
|
+
}
|
|
14
|
+
async function probeResult2(info, timeout = defaultEnsureTiming2.requestTimeout) {
|
|
15
|
+
const endpoint = {
|
|
16
|
+
url: info.url,
|
|
17
|
+
auth: info.password === undefined ? undefined : { type: "basic", username: "opencode", password: info.password }
|
|
18
|
+
};
|
|
19
|
+
const signal = AbortSignal.timeout(timeout);
|
|
20
|
+
const result = await fetch(new URL("/api/info", info.url), { headers: headers2(endpoint), signal }).then(async (response) => ({
|
|
21
|
+
response,
|
|
22
|
+
body: response.status === 404 ? undefined : await response.json()
|
|
23
|
+
})).catch(() => {
|
|
24
|
+
return;
|
|
25
|
+
});
|
|
26
|
+
if (result === undefined)
|
|
27
|
+
return { service: undefined, timedOut: signal.aborted };
|
|
28
|
+
const response = result.response;
|
|
29
|
+
if (response.status === 404)
|
|
30
|
+
return {
|
|
31
|
+
service: {
|
|
32
|
+
info,
|
|
33
|
+
endpoint,
|
|
34
|
+
version: info.version,
|
|
35
|
+
state: "ready",
|
|
36
|
+
compatible: false
|
|
37
|
+
},
|
|
38
|
+
timedOut: false
|
|
39
|
+
};
|
|
40
|
+
const serverInfo = decodeInfo(result.body);
|
|
41
|
+
if (serverInfo === undefined)
|
|
42
|
+
return { service: undefined, timedOut: false };
|
|
43
|
+
if (serverInfo.pid !== info.pid)
|
|
44
|
+
return { service: undefined, timedOut: false };
|
|
45
|
+
if (info.version !== undefined && serverInfo.version !== info.version)
|
|
46
|
+
return { service: undefined, timedOut: false };
|
|
47
|
+
return {
|
|
48
|
+
service: {
|
|
49
|
+
info,
|
|
50
|
+
endpoint,
|
|
51
|
+
version: serverInfo.version,
|
|
52
|
+
state: response.ok ? "ready" : response.status === 500 ? "failed" : "waiting",
|
|
53
|
+
compatible: true
|
|
54
|
+
},
|
|
55
|
+
timedOut: false
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function headers2(endpoint) {
|
|
59
|
+
if (endpoint.auth === undefined)
|
|
60
|
+
return;
|
|
61
|
+
return {
|
|
62
|
+
authorization: "Basic " + Buffer.from(endpoint.auth.username + ":" + endpoint.auth.password).toString("base64")
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function decodeInfo(input) {
|
|
66
|
+
if (typeof input !== "object" || input === null)
|
|
67
|
+
return;
|
|
68
|
+
if (!("version" in input) || typeof input.version !== "string")
|
|
69
|
+
return;
|
|
70
|
+
if (!("pid" in input) || typeof input.pid !== "number" || !Number.isInteger(input.pid) || input.pid < 0)
|
|
71
|
+
return;
|
|
72
|
+
return { version: input.version, pid: input.pid };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { fallback2, same2, probeResult2, headers2 };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
make7
|
|
3
|
+
} from "./pty-handoff-frbwqjmf.js";
|
|
4
|
+
import {
|
|
5
|
+
make3
|
|
6
|
+
} from "./pty-handoff-qzsnm4q8.js";
|
|
7
|
+
import {
|
|
8
|
+
makeRpc2
|
|
9
|
+
} from "./pty-handoff-1y4a697q.js";
|
|
10
|
+
import {
|
|
11
|
+
__export
|
|
12
|
+
} from "./pty-handoff-9rqn6x4v.js";
|
|
13
|
+
|
|
14
|
+
// src/promise/client.ts
|
|
15
|
+
var exports_client = {};
|
|
16
|
+
__export(exports_client, {
|
|
17
|
+
OpenCode: () => exports_client,
|
|
18
|
+
make: () => make2
|
|
19
|
+
});
|
|
20
|
+
function make2(options) {
|
|
21
|
+
const raw = make3(options);
|
|
22
|
+
const events = make7((signal, onActivity) => raw.event.subscribe({ signal, onActivity }));
|
|
23
|
+
return {
|
|
24
|
+
...raw,
|
|
25
|
+
rpc: Object.assign(makeRpc2(raw, events), raw.rpc),
|
|
26
|
+
event: events
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { make2, exports_client };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/promise/generated/client-error.ts
|
|
2
|
-
class
|
|
2
|
+
class ClientError2 extends Error {
|
|
3
3
|
reason;
|
|
4
4
|
name = "ClientError";
|
|
5
5
|
constructor(reason, options) {
|
|
@@ -9,4 +9,4 @@ class ClientError3 extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { ClientError2 };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
make7
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./pty-handoff-frbwqjmf.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./
|
|
5
|
+
ClientError3
|
|
6
|
+
} from "./pty-handoff-7f0py9js.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./
|
|
8
|
+
make5
|
|
9
|
+
} from "./pty-handoff-5yf5aaev.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
make6,
|
|
12
12
|
aborted2
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./pty-handoff-w1w809zr.js";
|
|
14
14
|
import {
|
|
15
15
|
__export
|
|
16
|
-
} from "./
|
|
16
|
+
} from "./pty-handoff-9rqn6x4v.js";
|
|
17
17
|
|
|
18
18
|
// src/effect/client.ts
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
OpenCode: () =>
|
|
22
|
-
make: () =>
|
|
19
|
+
var exports_client3 = {};
|
|
20
|
+
__export(exports_client3, {
|
|
21
|
+
OpenCode: () => exports_client3,
|
|
22
|
+
make: () => make4
|
|
23
23
|
});
|
|
24
24
|
import { Cause, Context, Effect, Stream } from "effect";
|
|
25
25
|
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
@@ -28,9 +28,9 @@ var CurrentHeaders = Context.Reference("@opencode/client/effect/rpc/headers", {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
var
|
|
31
|
+
var make4 = Effect.fn("OpenCode.make")(function* (options) {
|
|
32
32
|
const httpClient = yield* HttpClient.HttpClient;
|
|
33
|
-
const raw = yield*
|
|
33
|
+
const raw = yield* make5(options).pipe(Effect.provideService(HttpClient.HttpClient, HttpClient.mapRequestEffect(httpClient, (request) => Effect.map(CurrentHeaders, (headers) => headers ? HttpClientRequest.setHeaders(request, new Headers(headers)) : request))));
|
|
34
34
|
const context = yield* Effect.context();
|
|
35
35
|
const native = raw.event.subscribe();
|
|
36
36
|
|
|
@@ -41,12 +41,12 @@ var make2 = Effect.fn("OpenCode.make")(function* (options) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
const shared = make7((signal) => Stream.toAsyncIterableWith(native.pipe(Stream.interruptWhen(aborted2(signal)), Stream.catchCause((cause) => Stream.fail(new EventFailure(cause)))), context));
|
|
44
|
-
const subscribe = () => Stream.fromAsyncIterable(shared.subscribe(), (error) => error).pipe(Stream.catch((error) => Stream.failCause(error instanceof EventFailure ? error.cause : Cause.fail(new
|
|
44
|
+
const subscribe = () => Stream.fromAsyncIterable(shared.subscribe(), (error) => error).pipe(Stream.catch((error) => Stream.failCause(error instanceof EventFailure ? error.cause : Cause.fail(new ClientError3({ cause: error })))));
|
|
45
45
|
return {
|
|
46
46
|
...raw,
|
|
47
47
|
event: { ...raw.event, subscribe },
|
|
48
|
-
rpc: Object.assign(
|
|
48
|
+
rpc: Object.assign(make6((input, options) => raw.rpc.call(input).pipe(Effect.provideService(CurrentHeaders, options?.headers)), subscribe), raw.rpc)
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
export {
|
|
52
|
+
export { make4, exports_client3 };
|