@opencode/client 0.0.0-dev-19794 → 0.0.0-dev-19808
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/rpc-runtime-1tbj6z39.js +81 -0
- package/dist/chunks/rpc-runtime-4tveyqeh.js +34 -0
- package/dist/chunks/rpc-runtime-65kht65h.js +62 -0
- package/dist/chunks/rpc-runtime-6mptkzbc.js +0 -0
- package/dist/chunks/rpc-runtime-9rqn6x4v.js +16 -0
- package/dist/chunks/rpc-runtime-atpwm825.js +1638 -0
- package/dist/chunks/rpc-runtime-bssvn03b.js +594 -0
- package/dist/chunks/rpc-runtime-epez1aze.js +30 -0
- package/dist/chunks/rpc-runtime-fcxvjmkt.js +52 -0
- package/dist/chunks/rpc-runtime-frbwqjmf.js +145 -0
- package/dist/chunks/rpc-runtime-g7m14arh.js +112 -0
- package/dist/chunks/rpc-runtime-m2eywc8w.js +0 -0
- package/dist/chunks/rpc-runtime-n3c99vt5.js +11 -0
- package/dist/chunks/rpc-runtime-qav6mfdz.js +0 -0
- package/dist/chunks/rpc-runtime-radw39tv.js +1402 -0
- package/dist/chunks/rpc-runtime-sxt88q69.js +12 -0
- package/dist/chunks/rpc-runtime-t1xa31vm.js +39 -0
- package/dist/chunks/rpc-runtime-tr4b6894.js +21 -0
- package/dist/chunks/rpc-runtime-txckps9j.js +57 -0
- package/dist/chunks/rpc-runtime-vmytr4q8.js +4 -0
- package/dist/chunks/rpc-runtime-vyas3vgt.js +0 -0
- package/dist/chunks/rpc-runtime-y2etg5bs.js +9 -0
- package/dist/chunks/rpc-runtime-ydhz1zrh.js +238 -0
- package/dist/chunks/rpc-runtime-yepdgb80.js +44 -0
- package/dist/contract.js +12 -1
- package/dist/effect/client.js +15 -29
- package/dist/effect/generated/client-error.js +6 -5
- package/dist/effect/generated/client.js +8 -582
- package/dist/effect/generated/index.js +12 -2
- package/dist/effect/index.js +75 -30
- package/dist/effect/rpc.js +11 -49
- package/dist/effect/service.js +238 -245
- package/dist/promise/client.js +14 -13
- package/dist/promise/generated/client-error.js +6 -8
- package/dist/promise/generated/client.js +7 -1396
- package/dist/promise/generated/index.js +75 -3
- package/dist/promise/generated/types.js +66 -34
- package/dist/promise/index.js +79 -2
- package/dist/promise/rpc.js +7 -86
- package/dist/promise/service.js +230 -227
- package/dist/pty-handoff.js +14 -121
- package/dist/rpc-runtime.js +14 -32
- package/dist/service-contender.js +10 -56
- package/dist/service-timing.js +9 -18
- package/dist/service-version.js +6 -9
- package/dist/service.js +1 -0
- package/dist/shared-events.js +8 -137
- package/dist/solid/connection.js +10 -246
- package/dist/solid/data.js +18 -1774
- package/dist/solid/index.js +32 -3
- package/dist/solid/pty.js +8 -41
- package/package.json +4 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/service-version.ts
|
|
2
|
+
function matchesVersion2(version, options) {
|
|
3
|
+
if (options.version === undefined)
|
|
4
|
+
return true;
|
|
5
|
+
if (version === undefined)
|
|
6
|
+
return false;
|
|
7
|
+
if (typeof options.version === "function")
|
|
8
|
+
return options.version(version);
|
|
9
|
+
return version === options.version;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { matchesVersion2 };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./rpc-runtime-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/rpc-runtime.ts
|
|
6
|
+
var exports_rpc_runtime = {};
|
|
7
|
+
__export(exports_rpc_runtime, {
|
|
8
|
+
RpcRuntime: () => exports_rpc_runtime,
|
|
9
|
+
event: () => event2,
|
|
10
|
+
eventType: () => eventType2,
|
|
11
|
+
read: () => read2,
|
|
12
|
+
readError: () => readError2
|
|
13
|
+
});
|
|
14
|
+
import { RpcError, RpcInternalError } from "@opencode/protocol/errors";
|
|
15
|
+
import { Effect, Schema } from "effect";
|
|
16
|
+
function read2(schema, value) {
|
|
17
|
+
return Schema.isSchema(schema) ? Schema.decodeUnknownEffect(schema)(value) : Effect.succeed(value);
|
|
18
|
+
}
|
|
19
|
+
function readError2(method, error) {
|
|
20
|
+
if (!(error instanceof RpcError) && !(error instanceof RpcInternalError))
|
|
21
|
+
return Effect.fail(error);
|
|
22
|
+
if (!method.errors || !Object.hasOwn(method.errors, error.type)) {
|
|
23
|
+
return Effect.fail(error.data === undefined ? { type: error.type, message: error.message } : { type: error.type, message: error.message, data: error.data });
|
|
24
|
+
}
|
|
25
|
+
return read2(method.errors[error.type], error.data).pipe(Effect.catch((cause) => Effect.die(cause)), Effect.flatMap((data) => Effect.fail(data === undefined ? { type: error.type, message: error.message } : { type: error.type, message: error.message, data })));
|
|
26
|
+
}
|
|
27
|
+
var event2 = Effect.fn("Client.Rpc.event")(function* (definition, name, schema, event) {
|
|
28
|
+
const data = yield* read2(schema.schema, event.data);
|
|
29
|
+
return {
|
|
30
|
+
...event,
|
|
31
|
+
type: eventType2(definition, name),
|
|
32
|
+
data
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
function eventType2(definition, name) {
|
|
36
|
+
return `rpc.${definition.id}.${name}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { read2, readError2, event2, eventType2, exports_rpc_runtime };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/service-timing.ts
|
|
2
|
+
var timings = new WeakMap;
|
|
3
|
+
var defaultEnsureTiming2 = {
|
|
4
|
+
pollInterval: 100,
|
|
5
|
+
attempts: 1200,
|
|
6
|
+
requestTimeout: 2000,
|
|
7
|
+
spawnDelay: 5000,
|
|
8
|
+
maxSpawnDelay: 30000,
|
|
9
|
+
promiseTimeout: 120000,
|
|
10
|
+
stopPollInterval: 50,
|
|
11
|
+
stopPollAttempts: 100
|
|
12
|
+
};
|
|
13
|
+
function ensureTiming2(options) {
|
|
14
|
+
return timings.get(options) ?? defaultEnsureTiming2;
|
|
15
|
+
}
|
|
16
|
+
function withEnsureTiming2(options, overrides) {
|
|
17
|
+
timings.set(options, { ...defaultEnsureTiming2, ...overrides });
|
|
18
|
+
return options;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { defaultEnsureTiming2, ensureTiming2, withEnsureTiming2 };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/service-contender.ts
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
var stderrLimit = 8 * 1024;
|
|
4
|
+
function spawnServiceContender2(command, args, env) {
|
|
5
|
+
const child = spawn(command, args, {
|
|
6
|
+
detached: true,
|
|
7
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
8
|
+
env: { ...process.env, ...env }
|
|
9
|
+
});
|
|
10
|
+
let error;
|
|
11
|
+
let closed = false;
|
|
12
|
+
let stderr = Buffer.alloc(0);
|
|
13
|
+
const onStderr = (chunk) => {
|
|
14
|
+
const tail = chunk.subarray(-stderrLimit);
|
|
15
|
+
stderr = tail.length === stderrLimit ? Buffer.from(tail) : Buffer.concat([stderr.subarray(-(stderrLimit - tail.length)), tail]);
|
|
16
|
+
};
|
|
17
|
+
child.stderr?.on("data", onStderr);
|
|
18
|
+
if (child.stderr !== null && "unref" in child.stderr && typeof child.stderr.unref === "function")
|
|
19
|
+
child.stderr.unref();
|
|
20
|
+
child.once("error", (cause) => {
|
|
21
|
+
error = new Error("Failed to start server", { cause });
|
|
22
|
+
});
|
|
23
|
+
child.once("close", () => {
|
|
24
|
+
closed = true;
|
|
25
|
+
});
|
|
26
|
+
child.unref();
|
|
27
|
+
return {
|
|
28
|
+
child,
|
|
29
|
+
error: () => error,
|
|
30
|
+
closed: () => closed,
|
|
31
|
+
stderr: () => stderr.toString("utf8").trim(),
|
|
32
|
+
release: () => {
|
|
33
|
+
child.stderr?.off("data", onStderr);
|
|
34
|
+
child.stderr?.resume();
|
|
35
|
+
stderr = Buffer.alloc(0);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function contenderFailure2(contender) {
|
|
40
|
+
const error = contender.error();
|
|
41
|
+
if (error !== undefined)
|
|
42
|
+
return error;
|
|
43
|
+
if (contender.child.exitCode !== null && contender.child.exitCode !== 0)
|
|
44
|
+
return startupError(`Server process exited with code ${contender.child.exitCode}`, contender.stderr());
|
|
45
|
+
if (contender.child.signalCode !== null)
|
|
46
|
+
return startupError(`Server process terminated by ${contender.child.signalCode}`, contender.stderr());
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
function contenderFinished2(contender) {
|
|
50
|
+
return contender.error() !== undefined || contender.closed();
|
|
51
|
+
}
|
|
52
|
+
function startupError(message, stderr) {
|
|
53
|
+
return new Error(stderr ? `${message}
|
|
54
|
+
${stderr}` : message);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { spawnServiceContender2, contenderFailure2, contenderFinished2 };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// src/contract.ts
|
|
2
|
+
import { ClientApi as ClientApi2, effectOmitEndpoints as effectOmitEndpoints2, groupNames as groupNames2, promiseOmitEndpoints as promiseOmitEndpoints2 } from "@opencode/protocol/client";
|
|
3
|
+
|
|
4
|
+
export { ClientApi2, effectOmitEndpoints2, groupNames2, promiseOmitEndpoints2 };
|
|
File without changes
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// src/solid/connection.ts
|
|
2
|
+
import { batch, onCleanup } from "solid-js";
|
|
3
|
+
import { createStore } from "solid-js/store";
|
|
4
|
+
var connectTimeout = 2000;
|
|
5
|
+
var reconnectDelay = 1000;
|
|
6
|
+
var connectionHistoryLimit = 50;
|
|
7
|
+
var defaultIdleTimeout2 = 45000;
|
|
8
|
+
var foregroundIdleThreshold2 = 20000;
|
|
9
|
+
function createClientConnection2(initialApi, options) {
|
|
10
|
+
const abort = new AbortController;
|
|
11
|
+
const history = [];
|
|
12
|
+
const idleTimeout = options.idleTimeout ?? defaultIdleTimeout2;
|
|
13
|
+
const [connection, setConnection] = createStore({ status: "connecting", attempt: 0 });
|
|
14
|
+
let api = initialApi;
|
|
15
|
+
let pending = [];
|
|
16
|
+
let flushTimer;
|
|
17
|
+
let stream;
|
|
18
|
+
let current;
|
|
19
|
+
let run;
|
|
20
|
+
let started = false;
|
|
21
|
+
let generation = 0;
|
|
22
|
+
let lastActivity = 0;
|
|
23
|
+
let forced = false;
|
|
24
|
+
function record(status, attempt, error) {
|
|
25
|
+
history.push({ type: "client.connection", created: Date.now(), data: { status, attempt, error } });
|
|
26
|
+
if (history.length > connectionHistoryLimit)
|
|
27
|
+
history.shift();
|
|
28
|
+
}
|
|
29
|
+
function publish(event) {
|
|
30
|
+
pending.push(event);
|
|
31
|
+
if (flushTimer)
|
|
32
|
+
return;
|
|
33
|
+
flushTimer = setTimeout(() => {
|
|
34
|
+
flushTimer = undefined;
|
|
35
|
+
const events = pending;
|
|
36
|
+
pending = [];
|
|
37
|
+
batch(() => events.forEach(options.onEvent));
|
|
38
|
+
}, options.flushInterval ?? 10);
|
|
39
|
+
}
|
|
40
|
+
async function connect(signal, attempt) {
|
|
41
|
+
let connectedAt;
|
|
42
|
+
const request = new AbortController;
|
|
43
|
+
current = request;
|
|
44
|
+
const cancel = () => request.abort(signal.reason);
|
|
45
|
+
const timeout = setTimeout(() => request.abort(new Error("Timed out connecting to server")), connectTimeout);
|
|
46
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
47
|
+
let watchdog;
|
|
48
|
+
const touch = () => {
|
|
49
|
+
lastActivity = Date.now();
|
|
50
|
+
if (connectedAt === undefined)
|
|
51
|
+
return;
|
|
52
|
+
clearTimeout(watchdog);
|
|
53
|
+
watchdog = setTimeout(() => request.abort(new Error("Event stream stalled")), idleTimeout);
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
record(attempt === 0 ? "connecting" : "reconnecting", attempt);
|
|
57
|
+
options.log?.info?.("event stream connecting", { attempt });
|
|
58
|
+
const iterator = api.event.subscribe({ signal: request.signal, onActivity: touch })[Symbol.asyncIterator]();
|
|
59
|
+
const first = await iterator.next();
|
|
60
|
+
if (signal.aborted)
|
|
61
|
+
return { error: undefined, connectedAt };
|
|
62
|
+
if (first.done)
|
|
63
|
+
return {
|
|
64
|
+
error: request.signal.reason instanceof Error ? request.signal.reason : new Error("Event stream disconnected"),
|
|
65
|
+
connectedAt
|
|
66
|
+
};
|
|
67
|
+
if (first.value.type !== "server.connected")
|
|
68
|
+
return { error: new Error("Event stream did not start with server.connected"), connectedAt };
|
|
69
|
+
clearTimeout(timeout);
|
|
70
|
+
record("connected", attempt);
|
|
71
|
+
connectedAt = Date.now();
|
|
72
|
+
touch();
|
|
73
|
+
options.log?.info?.("event stream connected");
|
|
74
|
+
publish(first.value);
|
|
75
|
+
setConnection({ status: "connected", attempt: 0, error: undefined });
|
|
76
|
+
while (!signal.aborted) {
|
|
77
|
+
const event = await iterator.next();
|
|
78
|
+
if (signal.aborted)
|
|
79
|
+
return { error: undefined, connectedAt };
|
|
80
|
+
if (event.done)
|
|
81
|
+
return {
|
|
82
|
+
error: request.signal.reason instanceof Error ? request.signal.reason : new Error("Event stream disconnected"),
|
|
83
|
+
connectedAt
|
|
84
|
+
};
|
|
85
|
+
touch();
|
|
86
|
+
if ("durable" in event.value && event.value.durable)
|
|
87
|
+
options.log?.debug?.("event", {
|
|
88
|
+
type: event.value.type,
|
|
89
|
+
aggregateID: event.value.durable.aggregateID,
|
|
90
|
+
seq: event.value.durable.seq
|
|
91
|
+
});
|
|
92
|
+
publish(event.value);
|
|
93
|
+
}
|
|
94
|
+
return { error: undefined, connectedAt };
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return { error, connectedAt };
|
|
97
|
+
} finally {
|
|
98
|
+
request.abort();
|
|
99
|
+
if (current === request)
|
|
100
|
+
current = undefined;
|
|
101
|
+
clearTimeout(timeout);
|
|
102
|
+
clearTimeout(watchdog);
|
|
103
|
+
signal.removeEventListener("abort", cancel);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function runStream(active) {
|
|
107
|
+
let attempt = 0;
|
|
108
|
+
while (!abort.signal.aborted && started && generation === active) {
|
|
109
|
+
setConnection({ status: attempt === 0 ? "connecting" : "reconnecting", attempt });
|
|
110
|
+
const controller = new AbortController;
|
|
111
|
+
stream = controller;
|
|
112
|
+
const cancel = () => controller.abort(abort.signal.reason);
|
|
113
|
+
abort.signal.addEventListener("abort", cancel);
|
|
114
|
+
const result = await connect(controller.signal, attempt);
|
|
115
|
+
abort.signal.removeEventListener("abort", cancel);
|
|
116
|
+
if (abort.signal.aborted || !started || generation !== active)
|
|
117
|
+
return;
|
|
118
|
+
if (result.connectedAt !== undefined && Date.now() - result.connectedAt >= reconnectDelay)
|
|
119
|
+
attempt = 0;
|
|
120
|
+
attempt += 1;
|
|
121
|
+
const message = errorMessage(result.error);
|
|
122
|
+
record("disconnected", attempt, message);
|
|
123
|
+
options.log?.info?.("event stream disconnected", { attempt, error: message });
|
|
124
|
+
setConnection({ status: "reconnecting", attempt, error: message });
|
|
125
|
+
if (options.reconnect) {
|
|
126
|
+
const next = await options.reconnect(controller.signal).catch((error) => {
|
|
127
|
+
if (!controller.signal.aborted)
|
|
128
|
+
options.log?.info?.("server resolution failed", { attempt, error: errorMessage(error) });
|
|
129
|
+
});
|
|
130
|
+
if (abort.signal.aborted || controller.signal.aborted || !started || generation !== active)
|
|
131
|
+
return;
|
|
132
|
+
if (next) {
|
|
133
|
+
api = next;
|
|
134
|
+
if (attempt === 1)
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (forced) {
|
|
139
|
+
forced = false;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
await wait(reconnectDelay, controller.signal);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function start() {
|
|
146
|
+
if (started)
|
|
147
|
+
return run;
|
|
148
|
+
started = true;
|
|
149
|
+
forced = false;
|
|
150
|
+
const active = ++generation;
|
|
151
|
+
const previous = run;
|
|
152
|
+
const current = (async () => {
|
|
153
|
+
if (previous)
|
|
154
|
+
await previous;
|
|
155
|
+
await runStream(active);
|
|
156
|
+
})().finally(() => {
|
|
157
|
+
if (run !== current)
|
|
158
|
+
return;
|
|
159
|
+
run = undefined;
|
|
160
|
+
});
|
|
161
|
+
run = current;
|
|
162
|
+
return run;
|
|
163
|
+
}
|
|
164
|
+
function stop() {
|
|
165
|
+
if (!started)
|
|
166
|
+
return;
|
|
167
|
+
started = false;
|
|
168
|
+
generation += 1;
|
|
169
|
+
stream?.abort();
|
|
170
|
+
setConnection({ status: "connecting", attempt: 0, error: undefined });
|
|
171
|
+
}
|
|
172
|
+
function resync(reason) {
|
|
173
|
+
if (!started || connection.status !== "connected")
|
|
174
|
+
return;
|
|
175
|
+
options.log?.info?.("event stream resync", { reason, idle: Date.now() - lastActivity });
|
|
176
|
+
forced = true;
|
|
177
|
+
current?.abort(new Error(reason));
|
|
178
|
+
}
|
|
179
|
+
if (options.pageLifecycle) {
|
|
180
|
+
const pagehide = () => stop();
|
|
181
|
+
const pageshow = () => void start();
|
|
182
|
+
const visibility = () => {
|
|
183
|
+
if (document.visibilityState !== "visible")
|
|
184
|
+
return;
|
|
185
|
+
if (Date.now() - lastActivity < foregroundIdleThreshold2)
|
|
186
|
+
return;
|
|
187
|
+
resync("Page returned to the foreground after the event stream went quiet");
|
|
188
|
+
};
|
|
189
|
+
const online = () => resync("Network connection restored");
|
|
190
|
+
window.addEventListener("pagehide", pagehide);
|
|
191
|
+
window.addEventListener("pageshow", pageshow);
|
|
192
|
+
window.addEventListener("online", online);
|
|
193
|
+
document.addEventListener("visibilitychange", visibility);
|
|
194
|
+
onCleanup(() => {
|
|
195
|
+
window.removeEventListener("pagehide", pagehide);
|
|
196
|
+
window.removeEventListener("pageshow", pageshow);
|
|
197
|
+
window.removeEventListener("online", online);
|
|
198
|
+
document.removeEventListener("visibilitychange", visibility);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
start();
|
|
202
|
+
onCleanup(() => {
|
|
203
|
+
stop();
|
|
204
|
+
abort.abort();
|
|
205
|
+
if (flushTimer)
|
|
206
|
+
clearTimeout(flushTimer);
|
|
207
|
+
pending = [];
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
status: () => connection.status,
|
|
211
|
+
attempt: () => connection.attempt,
|
|
212
|
+
error: () => connection.error,
|
|
213
|
+
internal: {
|
|
214
|
+
history: () => history.slice(),
|
|
215
|
+
resync
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function errorMessage(error) {
|
|
220
|
+
if (error === undefined)
|
|
221
|
+
return;
|
|
222
|
+
if (error instanceof Error)
|
|
223
|
+
return error.message;
|
|
224
|
+
return String(error);
|
|
225
|
+
}
|
|
226
|
+
function wait(delay, signal) {
|
|
227
|
+
return new Promise((resolve) => {
|
|
228
|
+
const timer = setTimeout(done, delay);
|
|
229
|
+
signal.addEventListener("abort", done, { once: true });
|
|
230
|
+
function done() {
|
|
231
|
+
clearTimeout(timer);
|
|
232
|
+
signal.removeEventListener("abort", done);
|
|
233
|
+
resolve();
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export { defaultIdleTimeout2, foregroundIdleThreshold2, createClientConnection2 };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/solid/pty.ts
|
|
2
|
+
function createPtyClient2(api, options) {
|
|
3
|
+
return {
|
|
4
|
+
async connect(input) {
|
|
5
|
+
const result = await api.pty.connect.token({
|
|
6
|
+
ptyID: input.ptyID,
|
|
7
|
+
location: input.location,
|
|
8
|
+
"x-opencode-ticket": "1"
|
|
9
|
+
});
|
|
10
|
+
const url = new URL(`/api/pty/${encodeURIComponent(input.ptyID)}/connect`, options.url);
|
|
11
|
+
if (input.location?.directory)
|
|
12
|
+
url.searchParams.set("location[directory]", input.location.directory);
|
|
13
|
+
if (input.cursor !== undefined)
|
|
14
|
+
url.searchParams.set("cursor", String(input.cursor));
|
|
15
|
+
url.searchParams.set("ticket", result.data.ticket);
|
|
16
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
17
|
+
const socket = options.openSocket?.(url) ?? new WebSocket(url);
|
|
18
|
+
socket.binaryType = "arraybuffer";
|
|
19
|
+
return socket;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createPersistentPtyClient2(api, options) {
|
|
24
|
+
return {
|
|
25
|
+
async connect(input) {
|
|
26
|
+
const token = await api.experimental.persistentPty.connectToken({
|
|
27
|
+
ptyID: input.ptyID,
|
|
28
|
+
"x-opencode-ticket": "1"
|
|
29
|
+
});
|
|
30
|
+
const url = new URL(`/api/experimental/persistent-pty/${encodeURIComponent(input.ptyID)}/connect`, options.url);
|
|
31
|
+
url.searchParams.set("ticket", token.ticket);
|
|
32
|
+
url.searchParams.set("cursor", String(input.cursor));
|
|
33
|
+
url.searchParams.set("attachment_id", input.attachmentID);
|
|
34
|
+
url.searchParams.set("takeover", String(input.takeover ?? false));
|
|
35
|
+
url.searchParams.set("input_protocol", "1");
|
|
36
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
37
|
+
const socket = options.openSocket?.(url) ?? new WebSocket(url);
|
|
38
|
+
socket.binaryType = "arraybuffer";
|
|
39
|
+
return socket;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { createPtyClient2, createPersistentPtyClient2 };
|
package/dist/contract.js
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
ClientApi2,
|
|
3
|
+
effectOmitEndpoints2,
|
|
4
|
+
groupNames2,
|
|
5
|
+
promiseOmitEndpoints2
|
|
6
|
+
} from "./chunks/rpc-runtime-vmytr4q8.js";
|
|
7
|
+
export {
|
|
8
|
+
ClientApi2 as ClientApi,
|
|
9
|
+
effectOmitEndpoints2 as effectOmitEndpoints,
|
|
10
|
+
groupNames2 as groupNames,
|
|
11
|
+
promiseOmitEndpoints2 as promiseOmitEndpoints
|
|
12
|
+
};
|
package/dist/effect/client.js
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class EventFailure {
|
|
17
|
-
cause;
|
|
18
|
-
constructor(cause) {
|
|
19
|
-
this.cause = cause;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const shared = SharedEvents.make((signal) => Stream.toAsyncIterableWith(native.pipe(Stream.interruptWhen(RpcClientRuntime.aborted(signal)), Stream.catchCause((cause) => Stream.fail(new EventFailure(cause)))), context));
|
|
23
|
-
const subscribe = () => Stream.fromAsyncIterable(shared.subscribe(), (error) => error).pipe(Stream.catch((error) => Stream.failCause(error instanceof EventFailure ? error.cause : Cause.fail(new ClientError({ cause: error })))));
|
|
24
|
-
return {
|
|
25
|
-
...raw,
|
|
26
|
-
event: { ...raw.event, subscribe },
|
|
27
|
-
rpc: Object.assign(RpcClientRuntime.make((input, options) => raw.rpc.call(input).pipe(Effect.provideService(CurrentHeaders, options?.headers)), subscribe), raw.rpc),
|
|
28
|
-
};
|
|
29
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
make2,
|
|
3
|
+
exports_client
|
|
4
|
+
} from "../chunks/rpc-runtime-fcxvjmkt.js";
|
|
5
|
+
import"../chunks/rpc-runtime-65kht65h.js";
|
|
6
|
+
import"../chunks/rpc-runtime-6mptkzbc.js";
|
|
7
|
+
import"../chunks/rpc-runtime-bssvn03b.js";
|
|
8
|
+
import"../chunks/rpc-runtime-y2etg5bs.js";
|
|
9
|
+
import"../chunks/rpc-runtime-t1xa31vm.js";
|
|
10
|
+
import"../chunks/rpc-runtime-vmytr4q8.js";
|
|
11
|
+
import"../chunks/rpc-runtime-frbwqjmf.js";
|
|
12
|
+
export {
|
|
13
|
+
exports_client as OpenCode,
|
|
14
|
+
make2 as make
|
|
15
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
ClientError2
|
|
3
|
+
} from "../../chunks/rpc-runtime-y2etg5bs.js";
|
|
4
|
+
export {
|
|
5
|
+
ClientError2 as ClientError
|
|
6
|
+
};
|