@kilocode/client 0.0.0-stage → 0.0.0-v2-9
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/README.md +26 -2
- package/dist/chunks/contract-15p82y03.js +62 -0
- package/dist/chunks/contract-1x65x4hv.js +1701 -0
- package/dist/chunks/contract-5bf0yjkp.js +111 -0
- package/dist/chunks/contract-6mptkzbc.js +0 -0
- package/dist/chunks/contract-8bbb028w.js +145 -0
- package/dist/chunks/contract-8s2anffy.js +11 -0
- package/dist/chunks/contract-8ye1ye6f.js +92 -0
- package/dist/chunks/contract-9rqn6x4v.js +16 -0
- package/dist/chunks/contract-c46qzyff.js +37 -0
- package/dist/chunks/contract-gne7h7mq.js +50 -0
- package/dist/chunks/contract-hjez4bfs.js +52 -0
- package/dist/chunks/contract-m2eywc8w.js +0 -0
- package/dist/chunks/contract-nwcpakzx.js +12 -0
- package/dist/chunks/contract-qav6mfdz.js +0 -0
- package/dist/chunks/contract-ryy6kscr.js +39 -0
- package/dist/chunks/contract-s2hya144.js +1524 -0
- package/dist/chunks/contract-skhp7hxc.js +81 -0
- package/dist/chunks/contract-sxt88q69.js +12 -0
- package/dist/chunks/contract-ve4aws36.js +103 -0
- package/dist/chunks/contract-vmytr4q8.js +4 -0
- package/dist/chunks/contract-vwtmm97t.js +30 -0
- package/dist/chunks/contract-vyas3vgt.js +0 -0
- package/dist/chunks/contract-w10x3kfx.js +658 -0
- package/dist/chunks/contract-xgnj2w4v.js +20 -0
- package/dist/chunks/contract-y2etg5bs.js +9 -0
- package/dist/chunks/contract-ydhz1zrh.js +238 -0
- package/dist/contract.d.ts +1 -0
- package/dist/contract.js +12 -0
- package/dist/effect/api/api.d.ts +2927 -0
- package/dist/effect/api/api.js +0 -0
- package/dist/effect/api.d.ts +4 -0
- package/dist/effect/api.js +0 -0
- package/dist/effect/client.d.ts +2569 -0
- package/dist/effect/client.js +15 -0
- package/dist/effect/generated/client-error.d.ts +7 -0
- package/dist/effect/generated/client-error.js +6 -0
- package/dist/effect/generated/client.d.ts +2568 -0
- package/dist/effect/generated/client.js +8 -0
- package/dist/effect/generated/index.d.ts +2 -0
- package/dist/effect/generated/index.js +12 -0
- package/dist/effect/index.d.ts +35 -0
- package/dist/effect/index.js +75 -0
- package/dist/effect/rpc.d.ts +20 -0
- package/dist/effect/rpc.js +11 -0
- package/dist/effect/service.d.ts +90 -0
- package/dist/effect/service.js +187 -0
- package/dist/mcp.d.ts +44 -0
- package/dist/mcp.js +110 -0
- package/dist/promise/api.d.ts +21 -0
- package/dist/promise/api.js +0 -0
- package/dist/promise/client.d.ts +270 -0
- package/dist/promise/client.js +14 -0
- package/dist/promise/generated/client-error.d.ts +8 -0
- package/dist/promise/generated/client-error.js +6 -0
- package/dist/promise/generated/client.d.ts +277 -0
- package/dist/promise/generated/client.js +7 -0
- package/dist/promise/generated/index.d.ts +3 -0
- package/dist/promise/generated/index.js +81 -0
- package/dist/promise/generated/types.d.ts +7877 -0
- package/dist/promise/generated/types.js +72 -0
- package/dist/promise/index.d.ts +6 -0
- package/dist/promise/index.js +85 -0
- package/dist/promise/rpc.d.ts +32 -0
- package/dist/promise/rpc.js +7 -0
- package/dist/promise/service.d.ts +24 -0
- package/dist/promise/service.js +187 -0
- package/dist/pty-handoff.d.ts +12 -0
- package/dist/pty-handoff.js +17 -0
- package/dist/rpc-runtime.d.ts +20 -0
- package/dist/rpc-runtime.js +14 -0
- package/dist/service-contender.d.ts +37 -0
- package/dist/service-contender.js +10 -0
- package/dist/service-probe.d.ts +70 -0
- package/dist/service-probe.js +16 -0
- package/dist/service-timing.d.ts +12 -0
- package/dist/service-timing.js +10 -0
- package/dist/service-version.d.ts +2 -0
- package/dist/service-version.js +6 -0
- package/dist/service.d.ts +52 -0
- package/dist/service.js +1 -0
- package/dist/shared-events.d.ts +11 -0
- package/dist/shared-events.js +8 -0
- package/dist/solid/connection.d.ts +37 -0
- package/dist/solid/connection.js +10 -0
- package/dist/solid/data.d.ts +211 -0
- package/dist/solid/data.js +18 -0
- package/dist/solid/index.d.ts +4 -0
- package/dist/solid/index.js +36 -0
- package/dist/solid/pty.d.ts +22 -0
- package/dist/solid/pty.js +8 -0
- package/dist/solid/usage.d.ts +9 -0
- package/dist/solid/usage.js +6 -0
- package/package.json +88 -4
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/service-timing.ts
|
|
2
|
+
var timings = new WeakMap;
|
|
3
|
+
var defaultEnsureTiming2 = {
|
|
4
|
+
pollInterval: 25,
|
|
5
|
+
requestTimeout: 2000,
|
|
6
|
+
spawnDelay: 5000,
|
|
7
|
+
maxSpawnDelay: 30000,
|
|
8
|
+
promiseTimeout: 120000,
|
|
9
|
+
stopPollInterval: 50,
|
|
10
|
+
stopPollAttempts: 100
|
|
11
|
+
};
|
|
12
|
+
function ensureTiming2(options) {
|
|
13
|
+
return timings.get(options) ?? defaultEnsureTiming2;
|
|
14
|
+
}
|
|
15
|
+
function withEnsureTiming2(options, overrides) {
|
|
16
|
+
timings.set(options, { ...defaultEnsureTiming2, ...overrides });
|
|
17
|
+
return options;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { defaultEnsureTiming2, ensureTiming2, withEnsureTiming2 };
|
|
@@ -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 @@
|
|
|
1
|
+
export { ClientApi, effectOmitEndpoints, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client";
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientApi2,
|
|
3
|
+
effectOmitEndpoints2,
|
|
4
|
+
groupNames2,
|
|
5
|
+
promiseOmitEndpoints2
|
|
6
|
+
} from "./chunks/contract-vmytr4q8.js";
|
|
7
|
+
export {
|
|
8
|
+
ClientApi2 as ClientApi,
|
|
9
|
+
effectOmitEndpoints2 as effectOmitEndpoints,
|
|
10
|
+
groupNames2 as groupNames,
|
|
11
|
+
promiseOmitEndpoints2 as promiseOmitEndpoints
|
|
12
|
+
};
|