@kevisual/cnb 0.0.25 → 0.0.26
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/keep.d.ts +2 -0
- package/dist/keep.js +2947 -32
- package/dist/opencode.js +116 -56
- package/dist/routes.js +116 -56
- package/package.json +3 -3
- package/src/workspace/keep-live.ts +91 -31
package/dist/opencode.js
CHANGED
|
@@ -25,6 +25,7 @@ var __export = (target, all) => {
|
|
|
25
25
|
set: (newValue) => all[name] = () => newValue
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
28
29
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
29
30
|
|
|
30
31
|
// node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
|
|
@@ -2437,9 +2438,9 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2437
2438
|
emitErrorAndClose(websocket2, err);
|
|
2438
2439
|
});
|
|
2439
2440
|
req.on("response", (res) => {
|
|
2440
|
-
const
|
|
2441
|
+
const location = res.headers.location;
|
|
2441
2442
|
const statusCode = res.statusCode;
|
|
2442
|
-
if (
|
|
2443
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
2443
2444
|
if (++websocket2._redirects > opts.maxRedirects) {
|
|
2444
2445
|
abortHandshake(websocket2, req, "Maximum redirects exceeded");
|
|
2445
2446
|
return;
|
|
@@ -2447,9 +2448,9 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2447
2448
|
req.abort();
|
|
2448
2449
|
let addr;
|
|
2449
2450
|
try {
|
|
2450
|
-
addr = new URL2(
|
|
2451
|
+
addr = new URL2(location, address);
|
|
2451
2452
|
} catch (e) {
|
|
2452
|
-
const err = new SyntaxError(`Invalid URL: ${
|
|
2453
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
2453
2454
|
emitErrorAndClose(websocket2, err);
|
|
2454
2455
|
return;
|
|
2455
2456
|
}
|
|
@@ -3138,6 +3139,26 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
3138
3139
|
}
|
|
3139
3140
|
});
|
|
3140
3141
|
|
|
3142
|
+
// node_modules/.pnpm/@kevisual+ws@8.19.0/node_modules/@kevisual/ws/wrapper.mjs
|
|
3143
|
+
var exports_wrapper = {};
|
|
3144
|
+
__export(exports_wrapper, {
|
|
3145
|
+
default: () => wrapper_default,
|
|
3146
|
+
createWebSocketStream: () => import_stream.default,
|
|
3147
|
+
WebSocketServer: () => import_websocket_server.default,
|
|
3148
|
+
WebSocket: () => import_websocket.default,
|
|
3149
|
+
Sender: () => import_sender.default,
|
|
3150
|
+
Receiver: () => import_receiver.default
|
|
3151
|
+
});
|
|
3152
|
+
var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
|
|
3153
|
+
var init_wrapper = __esm(() => {
|
|
3154
|
+
import_stream = __toESM(require_stream(), 1);
|
|
3155
|
+
import_receiver = __toESM(require_receiver(), 1);
|
|
3156
|
+
import_sender = __toESM(require_sender(), 1);
|
|
3157
|
+
import_websocket = __toESM(require_websocket(), 1);
|
|
3158
|
+
import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
3159
|
+
wrapper_default = import_websocket.default;
|
|
3160
|
+
});
|
|
3161
|
+
|
|
3141
3162
|
// node_modules/.pnpm/@kevisual+router@0.0.70/node_modules/@kevisual/router/dist/router.js
|
|
3142
3163
|
import require$$1, { webcrypto } from "node:crypto";
|
|
3143
3164
|
import require$$2 from "node:http";
|
|
@@ -20177,9 +20198,9 @@ function requireWebsocket() {
|
|
|
20177
20198
|
emitErrorAndClose(websocket2, err);
|
|
20178
20199
|
});
|
|
20179
20200
|
req.on("response", (res) => {
|
|
20180
|
-
const
|
|
20201
|
+
const location = res.headers.location;
|
|
20181
20202
|
const statusCode = res.statusCode;
|
|
20182
|
-
if (
|
|
20203
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
20183
20204
|
if (++websocket2._redirects > opts.maxRedirects) {
|
|
20184
20205
|
abortHandshake(websocket2, req, "Maximum redirects exceeded");
|
|
20185
20206
|
return;
|
|
@@ -20187,9 +20208,9 @@ function requireWebsocket() {
|
|
|
20187
20208
|
req.abort();
|
|
20188
20209
|
let addr;
|
|
20189
20210
|
try {
|
|
20190
|
-
addr = new URL2(
|
|
20211
|
+
addr = new URL2(location, address);
|
|
20191
20212
|
} catch (e) {
|
|
20192
|
-
const err = new SyntaxError(`Invalid URL: ${
|
|
20213
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
20193
20214
|
emitErrorAndClose(websocket2, err);
|
|
20194
20215
|
return;
|
|
20195
20216
|
}
|
|
@@ -20893,8 +20914,7 @@ function requireWebsocketServer() {
|
|
|
20893
20914
|
}
|
|
20894
20915
|
var websocketServerExports = requireWebsocketServer();
|
|
20895
20916
|
|
|
20896
|
-
// node_modules/.pnpm/@kevisual+context@0.0.
|
|
20897
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
20917
|
+
// node_modules/.pnpm/@kevisual+context@0.0.6/node_modules/@kevisual/context/dist/app.js
|
|
20898
20918
|
function getDefaultExportFromCjs2(x) {
|
|
20899
20919
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
20900
20920
|
}
|
|
@@ -21427,6 +21447,7 @@ var useConfigKey = (key, init, isNew) => {
|
|
|
21427
21447
|
}
|
|
21428
21448
|
return useEnvKey(key, init, "config");
|
|
21429
21449
|
};
|
|
21450
|
+
|
|
21430
21451
|
class InitEnv {
|
|
21431
21452
|
static isInit = false;
|
|
21432
21453
|
static init(opts) {
|
|
@@ -21957,7 +21978,7 @@ var useKey = (key, opts) => {
|
|
|
21957
21978
|
}
|
|
21958
21979
|
return v;
|
|
21959
21980
|
};
|
|
21960
|
-
var
|
|
21981
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
21961
21982
|
function getDefaultExportFromCjs3(x) {
|
|
21962
21983
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
21963
21984
|
}
|
|
@@ -36603,7 +36624,7 @@ config3(en_default());
|
|
|
36603
36624
|
// node_modules/.pnpm/zod@4.3.6/node_modules/zod/index.js
|
|
36604
36625
|
var zod_default = exports_external;
|
|
36605
36626
|
|
|
36606
|
-
// node_modules/.pnpm/@opencode-ai+plugin@1.2.
|
|
36627
|
+
// node_modules/.pnpm/@opencode-ai+plugin@1.2.4/node_modules/@opencode-ai/plugin/dist/tool.js
|
|
36607
36628
|
function tool2(input) {
|
|
36608
36629
|
return input;
|
|
36609
36630
|
}
|
|
@@ -36859,15 +36880,15 @@ function nanoid4(size = 21) {
|
|
|
36859
36880
|
// agent/routes/workspace/keep.ts
|
|
36860
36881
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
36861
36882
|
|
|
36862
|
-
// node_modules/.pnpm/@kevisual+ws@8.19.0/node_modules/@kevisual/ws/wrapper.mjs
|
|
36863
|
-
var import_stream = __toESM(require_stream(), 1);
|
|
36864
|
-
var import_receiver = __toESM(require_receiver(), 1);
|
|
36865
|
-
var import_sender = __toESM(require_sender(), 1);
|
|
36866
|
-
var import_websocket = __toESM(require_websocket(), 1);
|
|
36867
|
-
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
36868
|
-
var wrapper_default = import_websocket.default;
|
|
36869
|
-
|
|
36870
36883
|
// src/workspace/keep-live.ts
|
|
36884
|
+
var WebSocketModule;
|
|
36885
|
+
if (typeof Bun !== "undefined") {
|
|
36886
|
+
WebSocketModule = { WebSocket: globalThis.WebSocket };
|
|
36887
|
+
} else {
|
|
36888
|
+
WebSocketModule = await Promise.resolve().then(() => (init_wrapper(), exports_wrapper));
|
|
36889
|
+
}
|
|
36890
|
+
var WebSocket2 = WebSocketModule.WebSocket;
|
|
36891
|
+
|
|
36871
36892
|
class WSKeepAlive {
|
|
36872
36893
|
ws = null;
|
|
36873
36894
|
config;
|
|
@@ -36875,6 +36896,7 @@ class WSKeepAlive {
|
|
|
36875
36896
|
pingTimer = null;
|
|
36876
36897
|
messageHandlers = new Set;
|
|
36877
36898
|
url;
|
|
36899
|
+
isBun;
|
|
36878
36900
|
constructor(config4) {
|
|
36879
36901
|
this.config = {
|
|
36880
36902
|
wsUrl: config4.wsUrl,
|
|
@@ -36891,6 +36913,7 @@ class WSKeepAlive {
|
|
|
36891
36913
|
debug: config4.debug ?? false
|
|
36892
36914
|
};
|
|
36893
36915
|
this.url = new URL(this.config.wsUrl);
|
|
36916
|
+
this.isBun = typeof Bun !== "undefined";
|
|
36894
36917
|
}
|
|
36895
36918
|
log(message) {
|
|
36896
36919
|
if (!this.config.debug)
|
|
@@ -36929,7 +36952,7 @@ class WSKeepAlive {
|
|
|
36929
36952
|
connect() {
|
|
36930
36953
|
const { wsUrl, cookie, debug } = this.config;
|
|
36931
36954
|
this.log(`Connecting to ${wsUrl}...`);
|
|
36932
|
-
this.ws = new
|
|
36955
|
+
this.ws = new WebSocket2(wsUrl, {
|
|
36933
36956
|
headers: {
|
|
36934
36957
|
Origin: this.url.origin,
|
|
36935
36958
|
Cookie: cookie,
|
|
@@ -36940,40 +36963,77 @@ class WSKeepAlive {
|
|
|
36940
36963
|
"Sec-WebSocket-Extensions": "permessage-deflate"
|
|
36941
36964
|
}
|
|
36942
36965
|
});
|
|
36943
|
-
this.
|
|
36944
|
-
|
|
36945
|
-
|
|
36946
|
-
|
|
36947
|
-
|
|
36948
|
-
|
|
36949
|
-
|
|
36950
|
-
|
|
36951
|
-
|
|
36952
|
-
|
|
36953
|
-
|
|
36954
|
-
|
|
36955
|
-
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
|
|
36963
|
-
|
|
36964
|
-
|
|
36965
|
-
|
|
36966
|
-
|
|
36967
|
-
|
|
36968
|
-
|
|
36969
|
-
|
|
36970
|
-
|
|
36966
|
+
if (this.isBun) {
|
|
36967
|
+
const ws = this.ws;
|
|
36968
|
+
ws.onopen = () => {
|
|
36969
|
+
debug && this.log("Connected!");
|
|
36970
|
+
this.reconnectAttempts = 0;
|
|
36971
|
+
this.config.onConnect();
|
|
36972
|
+
this.startPing();
|
|
36973
|
+
};
|
|
36974
|
+
ws.onmessage = async (event) => {
|
|
36975
|
+
let data;
|
|
36976
|
+
if (event.data instanceof Blob) {
|
|
36977
|
+
data = Buffer.from(await event.data.arrayBuffer());
|
|
36978
|
+
} else if (event.data instanceof ArrayBuffer) {
|
|
36979
|
+
data = Buffer.from(event.data);
|
|
36980
|
+
} else if (typeof event.data === "string") {
|
|
36981
|
+
data = event.data;
|
|
36982
|
+
} else {
|
|
36983
|
+
data = Buffer.from(event.data);
|
|
36984
|
+
}
|
|
36985
|
+
this.handleMessage(data);
|
|
36986
|
+
};
|
|
36987
|
+
ws.onclose = (event) => {
|
|
36988
|
+
debug && this.log(`Disconnected (code: ${event.code})`);
|
|
36989
|
+
this.stopPing();
|
|
36990
|
+
this.config.onDisconnect(event.code);
|
|
36991
|
+
this.handleReconnect();
|
|
36992
|
+
};
|
|
36993
|
+
ws.onerror = (event) => {
|
|
36994
|
+
debug && this.log(`Error: ${event}`);
|
|
36995
|
+
this.config.onError(new Error("WebSocket error"));
|
|
36996
|
+
};
|
|
36997
|
+
} else {
|
|
36998
|
+
const ws = this.ws;
|
|
36999
|
+
ws.on("open", () => {
|
|
37000
|
+
debug && this.log("Connected!");
|
|
37001
|
+
this.reconnectAttempts = 0;
|
|
37002
|
+
this.config.onConnect();
|
|
37003
|
+
this.startPing();
|
|
37004
|
+
});
|
|
37005
|
+
ws.on("message", (data) => {
|
|
37006
|
+
this.handleMessage(data);
|
|
37007
|
+
});
|
|
37008
|
+
ws.on("close", (code) => {
|
|
37009
|
+
debug && this.log(`Disconnected (code: ${code})`);
|
|
37010
|
+
this.stopPing();
|
|
37011
|
+
this.config.onDisconnect(code);
|
|
37012
|
+
this.handleReconnect();
|
|
37013
|
+
});
|
|
37014
|
+
ws.on("error", (err) => {
|
|
37015
|
+
debug && this.log(`Error: ${err.message}`);
|
|
37016
|
+
this.config.onError(err);
|
|
37017
|
+
});
|
|
37018
|
+
}
|
|
37019
|
+
}
|
|
37020
|
+
handleMessage(data) {
|
|
37021
|
+
if (Buffer.isBuffer(data)) {
|
|
37022
|
+
const parsed = this.parseMessage(data);
|
|
37023
|
+
this.config.onMessage(parsed?.raw ?? data);
|
|
37024
|
+
this.messageHandlers.forEach((handler) => {
|
|
37025
|
+
if (parsed)
|
|
37026
|
+
handler(parsed);
|
|
37027
|
+
});
|
|
37028
|
+
} else {
|
|
37029
|
+
this.config.onMessage(data);
|
|
37030
|
+
}
|
|
36971
37031
|
}
|
|
36972
37032
|
startPing() {
|
|
36973
37033
|
this.stopPing();
|
|
36974
37034
|
this.pingTimer = setInterval(() => {
|
|
36975
|
-
if (this.ws && this.ws.readyState ===
|
|
36976
|
-
this.ws.ping();
|
|
37035
|
+
if (this.ws && this.ws.readyState === WebSocket2.OPEN) {
|
|
37036
|
+
this.ws.send(JSON.stringify({ type: "ping", timestamp: Date.now() }));
|
|
36977
37037
|
this.log("Sent ping");
|
|
36978
37038
|
}
|
|
36979
37039
|
}, this.config.pingInterval);
|
|
@@ -37569,7 +37629,7 @@ var __export2 = (target, all) => {
|
|
|
37569
37629
|
set: (newValue) => all[name] = () => newValue
|
|
37570
37630
|
});
|
|
37571
37631
|
};
|
|
37572
|
-
var
|
|
37632
|
+
var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
37573
37633
|
var exports_buffer = {};
|
|
37574
37634
|
__export2(exports_buffer, {
|
|
37575
37635
|
transcode: () => transcode,
|
|
@@ -38284,7 +38344,7 @@ var isAscii = (str) => {
|
|
|
38284
38344
|
};
|
|
38285
38345
|
var transcode;
|
|
38286
38346
|
var buffer_default;
|
|
38287
|
-
var init_buffer =
|
|
38347
|
+
var init_buffer = __esm2(() => {
|
|
38288
38348
|
lookup = [];
|
|
38289
38349
|
revLookup = [];
|
|
38290
38350
|
for (i = 0, len = code.length;i < len; ++i)
|
|
@@ -39278,7 +39338,7 @@ var promisify;
|
|
|
39278
39338
|
var TextEncoder;
|
|
39279
39339
|
var TextDecoder2;
|
|
39280
39340
|
var util_default;
|
|
39281
|
-
var init_util =
|
|
39341
|
+
var init_util = __esm2(() => {
|
|
39282
39342
|
formatRegExp = /%[sdj%]/g;
|
|
39283
39343
|
debuglog = ((debugs = {}, debugEnvRegex = {}, debugEnv) => ((debugEnv = typeof process < "u" && false) && (debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase()), debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"), (set3) => {
|
|
39284
39344
|
if (set3 = set3.toUpperCase(), !debugs[set3])
|
|
@@ -39578,7 +39638,7 @@ var emitWithRejectionCapture = function(type2, ...args) {
|
|
|
39578
39638
|
};
|
|
39579
39639
|
var AbortError;
|
|
39580
39640
|
var events_default;
|
|
39581
|
-
var init_events =
|
|
39641
|
+
var init_events = __esm2(() => {
|
|
39582
39642
|
SymbolFor = Symbol.for;
|
|
39583
39643
|
kCapture = Symbol("kCapture");
|
|
39584
39644
|
kErrorMonitor = SymbolFor("events.errorMonitor");
|
|
@@ -43903,7 +43963,7 @@ var randomUUID = () => {
|
|
|
43903
43963
|
var hardcoded_curves;
|
|
43904
43964
|
var webcrypto2;
|
|
43905
43965
|
var crypto_default;
|
|
43906
|
-
var init_crypto =
|
|
43966
|
+
var init_crypto = __esm2(() => {
|
|
43907
43967
|
__create22 = Object.create;
|
|
43908
43968
|
({ getPrototypeOf: __getProtoOf22, defineProperty: __defProp22, getOwnPropertyNames: __getOwnPropNames22 } = Object);
|
|
43909
43969
|
__hasOwnProp22 = Object.prototype.hasOwnProperty;
|
package/dist/routes.js
CHANGED
|
@@ -25,6 +25,7 @@ var __export = (target, all) => {
|
|
|
25
25
|
set: (newValue) => all[name] = () => newValue
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
28
29
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
29
30
|
|
|
30
31
|
// node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.js
|
|
@@ -2437,9 +2438,9 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2437
2438
|
emitErrorAndClose(websocket2, err);
|
|
2438
2439
|
});
|
|
2439
2440
|
req.on("response", (res) => {
|
|
2440
|
-
const
|
|
2441
|
+
const location = res.headers.location;
|
|
2441
2442
|
const statusCode = res.statusCode;
|
|
2442
|
-
if (
|
|
2443
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
2443
2444
|
if (++websocket2._redirects > opts.maxRedirects) {
|
|
2444
2445
|
abortHandshake(websocket2, req, "Maximum redirects exceeded");
|
|
2445
2446
|
return;
|
|
@@ -2447,9 +2448,9 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2447
2448
|
req.abort();
|
|
2448
2449
|
let addr;
|
|
2449
2450
|
try {
|
|
2450
|
-
addr = new URL2(
|
|
2451
|
+
addr = new URL2(location, address);
|
|
2451
2452
|
} catch (e) {
|
|
2452
|
-
const err = new SyntaxError(`Invalid URL: ${
|
|
2453
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
2453
2454
|
emitErrorAndClose(websocket2, err);
|
|
2454
2455
|
return;
|
|
2455
2456
|
}
|
|
@@ -3138,6 +3139,26 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
3138
3139
|
}
|
|
3139
3140
|
});
|
|
3140
3141
|
|
|
3142
|
+
// node_modules/.pnpm/@kevisual+ws@8.19.0/node_modules/@kevisual/ws/wrapper.mjs
|
|
3143
|
+
var exports_wrapper = {};
|
|
3144
|
+
__export(exports_wrapper, {
|
|
3145
|
+
default: () => wrapper_default,
|
|
3146
|
+
createWebSocketStream: () => import_stream.default,
|
|
3147
|
+
WebSocketServer: () => import_websocket_server.default,
|
|
3148
|
+
WebSocket: () => import_websocket.default,
|
|
3149
|
+
Sender: () => import_sender.default,
|
|
3150
|
+
Receiver: () => import_receiver.default
|
|
3151
|
+
});
|
|
3152
|
+
var import_stream, import_receiver, import_sender, import_websocket, import_websocket_server, wrapper_default;
|
|
3153
|
+
var init_wrapper = __esm(() => {
|
|
3154
|
+
import_stream = __toESM(require_stream(), 1);
|
|
3155
|
+
import_receiver = __toESM(require_receiver(), 1);
|
|
3156
|
+
import_sender = __toESM(require_sender(), 1);
|
|
3157
|
+
import_websocket = __toESM(require_websocket(), 1);
|
|
3158
|
+
import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
3159
|
+
wrapper_default = import_websocket.default;
|
|
3160
|
+
});
|
|
3161
|
+
|
|
3141
3162
|
// node_modules/.pnpm/@kevisual+router@0.0.70/node_modules/@kevisual/router/dist/router.js
|
|
3142
3163
|
import require$$1, { webcrypto } from "node:crypto";
|
|
3143
3164
|
import require$$2 from "node:http";
|
|
@@ -20177,9 +20198,9 @@ function requireWebsocket() {
|
|
|
20177
20198
|
emitErrorAndClose(websocket2, err);
|
|
20178
20199
|
});
|
|
20179
20200
|
req.on("response", (res) => {
|
|
20180
|
-
const
|
|
20201
|
+
const location = res.headers.location;
|
|
20181
20202
|
const statusCode = res.statusCode;
|
|
20182
|
-
if (
|
|
20203
|
+
if (location && opts.followRedirects && statusCode >= 300 && statusCode < 400) {
|
|
20183
20204
|
if (++websocket2._redirects > opts.maxRedirects) {
|
|
20184
20205
|
abortHandshake(websocket2, req, "Maximum redirects exceeded");
|
|
20185
20206
|
return;
|
|
@@ -20187,9 +20208,9 @@ function requireWebsocket() {
|
|
|
20187
20208
|
req.abort();
|
|
20188
20209
|
let addr;
|
|
20189
20210
|
try {
|
|
20190
|
-
addr = new URL2(
|
|
20211
|
+
addr = new URL2(location, address);
|
|
20191
20212
|
} catch (e) {
|
|
20192
|
-
const err = new SyntaxError(`Invalid URL: ${
|
|
20213
|
+
const err = new SyntaxError(`Invalid URL: ${location}`);
|
|
20193
20214
|
emitErrorAndClose(websocket2, err);
|
|
20194
20215
|
return;
|
|
20195
20216
|
}
|
|
@@ -20893,8 +20914,7 @@ function requireWebsocketServer() {
|
|
|
20893
20914
|
}
|
|
20894
20915
|
var websocketServerExports = requireWebsocketServer();
|
|
20895
20916
|
|
|
20896
|
-
// node_modules/.pnpm/@kevisual+context@0.0.
|
|
20897
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
20917
|
+
// node_modules/.pnpm/@kevisual+context@0.0.6/node_modules/@kevisual/context/dist/app.js
|
|
20898
20918
|
function getDefaultExportFromCjs2(x) {
|
|
20899
20919
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
20900
20920
|
}
|
|
@@ -21427,6 +21447,7 @@ var useConfigKey = (key, init, isNew) => {
|
|
|
21427
21447
|
}
|
|
21428
21448
|
return useEnvKey(key, init, "config");
|
|
21429
21449
|
};
|
|
21450
|
+
|
|
21430
21451
|
class InitEnv {
|
|
21431
21452
|
static isInit = false;
|
|
21432
21453
|
static init(opts) {
|
|
@@ -21957,7 +21978,7 @@ var useKey = (key, opts) => {
|
|
|
21957
21978
|
}
|
|
21958
21979
|
return v;
|
|
21959
21980
|
};
|
|
21960
|
-
var
|
|
21981
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
21961
21982
|
function getDefaultExportFromCjs3(x) {
|
|
21962
21983
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
21963
21984
|
}
|
|
@@ -36603,7 +36624,7 @@ config3(en_default());
|
|
|
36603
36624
|
// node_modules/.pnpm/zod@4.3.6/node_modules/zod/index.js
|
|
36604
36625
|
var zod_default = exports_external;
|
|
36605
36626
|
|
|
36606
|
-
// node_modules/.pnpm/@opencode-ai+plugin@1.2.
|
|
36627
|
+
// node_modules/.pnpm/@opencode-ai+plugin@1.2.4/node_modules/@opencode-ai/plugin/dist/tool.js
|
|
36607
36628
|
function tool2(input) {
|
|
36608
36629
|
return input;
|
|
36609
36630
|
}
|
|
@@ -36859,15 +36880,15 @@ function nanoid4(size = 21) {
|
|
|
36859
36880
|
// agent/routes/workspace/keep.ts
|
|
36860
36881
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
36861
36882
|
|
|
36862
|
-
// node_modules/.pnpm/@kevisual+ws@8.19.0/node_modules/@kevisual/ws/wrapper.mjs
|
|
36863
|
-
var import_stream = __toESM(require_stream(), 1);
|
|
36864
|
-
var import_receiver = __toESM(require_receiver(), 1);
|
|
36865
|
-
var import_sender = __toESM(require_sender(), 1);
|
|
36866
|
-
var import_websocket = __toESM(require_websocket(), 1);
|
|
36867
|
-
var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
36868
|
-
var wrapper_default = import_websocket.default;
|
|
36869
|
-
|
|
36870
36883
|
// src/workspace/keep-live.ts
|
|
36884
|
+
var WebSocketModule;
|
|
36885
|
+
if (typeof Bun !== "undefined") {
|
|
36886
|
+
WebSocketModule = { WebSocket: globalThis.WebSocket };
|
|
36887
|
+
} else {
|
|
36888
|
+
WebSocketModule = await Promise.resolve().then(() => (init_wrapper(), exports_wrapper));
|
|
36889
|
+
}
|
|
36890
|
+
var WebSocket2 = WebSocketModule.WebSocket;
|
|
36891
|
+
|
|
36871
36892
|
class WSKeepAlive {
|
|
36872
36893
|
ws = null;
|
|
36873
36894
|
config;
|
|
@@ -36875,6 +36896,7 @@ class WSKeepAlive {
|
|
|
36875
36896
|
pingTimer = null;
|
|
36876
36897
|
messageHandlers = new Set;
|
|
36877
36898
|
url;
|
|
36899
|
+
isBun;
|
|
36878
36900
|
constructor(config4) {
|
|
36879
36901
|
this.config = {
|
|
36880
36902
|
wsUrl: config4.wsUrl,
|
|
@@ -36891,6 +36913,7 @@ class WSKeepAlive {
|
|
|
36891
36913
|
debug: config4.debug ?? false
|
|
36892
36914
|
};
|
|
36893
36915
|
this.url = new URL(this.config.wsUrl);
|
|
36916
|
+
this.isBun = typeof Bun !== "undefined";
|
|
36894
36917
|
}
|
|
36895
36918
|
log(message) {
|
|
36896
36919
|
if (!this.config.debug)
|
|
@@ -36929,7 +36952,7 @@ class WSKeepAlive {
|
|
|
36929
36952
|
connect() {
|
|
36930
36953
|
const { wsUrl, cookie, debug } = this.config;
|
|
36931
36954
|
this.log(`Connecting to ${wsUrl}...`);
|
|
36932
|
-
this.ws = new
|
|
36955
|
+
this.ws = new WebSocket2(wsUrl, {
|
|
36933
36956
|
headers: {
|
|
36934
36957
|
Origin: this.url.origin,
|
|
36935
36958
|
Cookie: cookie,
|
|
@@ -36940,40 +36963,77 @@ class WSKeepAlive {
|
|
|
36940
36963
|
"Sec-WebSocket-Extensions": "permessage-deflate"
|
|
36941
36964
|
}
|
|
36942
36965
|
});
|
|
36943
|
-
this.
|
|
36944
|
-
|
|
36945
|
-
|
|
36946
|
-
|
|
36947
|
-
|
|
36948
|
-
|
|
36949
|
-
|
|
36950
|
-
|
|
36951
|
-
|
|
36952
|
-
|
|
36953
|
-
|
|
36954
|
-
|
|
36955
|
-
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
|
|
36963
|
-
|
|
36964
|
-
|
|
36965
|
-
|
|
36966
|
-
|
|
36967
|
-
|
|
36968
|
-
|
|
36969
|
-
|
|
36970
|
-
|
|
36966
|
+
if (this.isBun) {
|
|
36967
|
+
const ws = this.ws;
|
|
36968
|
+
ws.onopen = () => {
|
|
36969
|
+
debug && this.log("Connected!");
|
|
36970
|
+
this.reconnectAttempts = 0;
|
|
36971
|
+
this.config.onConnect();
|
|
36972
|
+
this.startPing();
|
|
36973
|
+
};
|
|
36974
|
+
ws.onmessage = async (event) => {
|
|
36975
|
+
let data;
|
|
36976
|
+
if (event.data instanceof Blob) {
|
|
36977
|
+
data = Buffer.from(await event.data.arrayBuffer());
|
|
36978
|
+
} else if (event.data instanceof ArrayBuffer) {
|
|
36979
|
+
data = Buffer.from(event.data);
|
|
36980
|
+
} else if (typeof event.data === "string") {
|
|
36981
|
+
data = event.data;
|
|
36982
|
+
} else {
|
|
36983
|
+
data = Buffer.from(event.data);
|
|
36984
|
+
}
|
|
36985
|
+
this.handleMessage(data);
|
|
36986
|
+
};
|
|
36987
|
+
ws.onclose = (event) => {
|
|
36988
|
+
debug && this.log(`Disconnected (code: ${event.code})`);
|
|
36989
|
+
this.stopPing();
|
|
36990
|
+
this.config.onDisconnect(event.code);
|
|
36991
|
+
this.handleReconnect();
|
|
36992
|
+
};
|
|
36993
|
+
ws.onerror = (event) => {
|
|
36994
|
+
debug && this.log(`Error: ${event}`);
|
|
36995
|
+
this.config.onError(new Error("WebSocket error"));
|
|
36996
|
+
};
|
|
36997
|
+
} else {
|
|
36998
|
+
const ws = this.ws;
|
|
36999
|
+
ws.on("open", () => {
|
|
37000
|
+
debug && this.log("Connected!");
|
|
37001
|
+
this.reconnectAttempts = 0;
|
|
37002
|
+
this.config.onConnect();
|
|
37003
|
+
this.startPing();
|
|
37004
|
+
});
|
|
37005
|
+
ws.on("message", (data) => {
|
|
37006
|
+
this.handleMessage(data);
|
|
37007
|
+
});
|
|
37008
|
+
ws.on("close", (code) => {
|
|
37009
|
+
debug && this.log(`Disconnected (code: ${code})`);
|
|
37010
|
+
this.stopPing();
|
|
37011
|
+
this.config.onDisconnect(code);
|
|
37012
|
+
this.handleReconnect();
|
|
37013
|
+
});
|
|
37014
|
+
ws.on("error", (err) => {
|
|
37015
|
+
debug && this.log(`Error: ${err.message}`);
|
|
37016
|
+
this.config.onError(err);
|
|
37017
|
+
});
|
|
37018
|
+
}
|
|
37019
|
+
}
|
|
37020
|
+
handleMessage(data) {
|
|
37021
|
+
if (Buffer.isBuffer(data)) {
|
|
37022
|
+
const parsed = this.parseMessage(data);
|
|
37023
|
+
this.config.onMessage(parsed?.raw ?? data);
|
|
37024
|
+
this.messageHandlers.forEach((handler) => {
|
|
37025
|
+
if (parsed)
|
|
37026
|
+
handler(parsed);
|
|
37027
|
+
});
|
|
37028
|
+
} else {
|
|
37029
|
+
this.config.onMessage(data);
|
|
37030
|
+
}
|
|
36971
37031
|
}
|
|
36972
37032
|
startPing() {
|
|
36973
37033
|
this.stopPing();
|
|
36974
37034
|
this.pingTimer = setInterval(() => {
|
|
36975
|
-
if (this.ws && this.ws.readyState ===
|
|
36976
|
-
this.ws.ping();
|
|
37035
|
+
if (this.ws && this.ws.readyState === WebSocket2.OPEN) {
|
|
37036
|
+
this.ws.send(JSON.stringify({ type: "ping", timestamp: Date.now() }));
|
|
36977
37037
|
this.log("Sent ping");
|
|
36978
37038
|
}
|
|
36979
37039
|
}, this.config.pingInterval);
|
|
@@ -37569,7 +37629,7 @@ var __export2 = (target, all) => {
|
|
|
37569
37629
|
set: (newValue) => all[name] = () => newValue
|
|
37570
37630
|
});
|
|
37571
37631
|
};
|
|
37572
|
-
var
|
|
37632
|
+
var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
37573
37633
|
var exports_buffer = {};
|
|
37574
37634
|
__export2(exports_buffer, {
|
|
37575
37635
|
transcode: () => transcode,
|
|
@@ -38284,7 +38344,7 @@ var isAscii = (str) => {
|
|
|
38284
38344
|
};
|
|
38285
38345
|
var transcode;
|
|
38286
38346
|
var buffer_default;
|
|
38287
|
-
var init_buffer =
|
|
38347
|
+
var init_buffer = __esm2(() => {
|
|
38288
38348
|
lookup = [];
|
|
38289
38349
|
revLookup = [];
|
|
38290
38350
|
for (i = 0, len = code.length;i < len; ++i)
|
|
@@ -39278,7 +39338,7 @@ var promisify;
|
|
|
39278
39338
|
var TextEncoder;
|
|
39279
39339
|
var TextDecoder2;
|
|
39280
39340
|
var util_default;
|
|
39281
|
-
var init_util =
|
|
39341
|
+
var init_util = __esm2(() => {
|
|
39282
39342
|
formatRegExp = /%[sdj%]/g;
|
|
39283
39343
|
debuglog = ((debugs = {}, debugEnvRegex = {}, debugEnv) => ((debugEnv = typeof process < "u" && false) && (debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase()), debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"), (set3) => {
|
|
39284
39344
|
if (set3 = set3.toUpperCase(), !debugs[set3])
|
|
@@ -39578,7 +39638,7 @@ var emitWithRejectionCapture = function(type2, ...args) {
|
|
|
39578
39638
|
};
|
|
39579
39639
|
var AbortError;
|
|
39580
39640
|
var events_default;
|
|
39581
|
-
var init_events =
|
|
39641
|
+
var init_events = __esm2(() => {
|
|
39582
39642
|
SymbolFor = Symbol.for;
|
|
39583
39643
|
kCapture = Symbol("kCapture");
|
|
39584
39644
|
kErrorMonitor = SymbolFor("events.errorMonitor");
|
|
@@ -43903,7 +43963,7 @@ var randomUUID = () => {
|
|
|
43903
43963
|
var hardcoded_curves;
|
|
43904
43964
|
var webcrypto2;
|
|
43905
43965
|
var crypto_default;
|
|
43906
|
-
var init_crypto =
|
|
43966
|
+
var init_crypto = __esm2(() => {
|
|
43907
43967
|
__create22 = Object.create;
|
|
43908
43968
|
({ getPrototypeOf: __getProtoOf22, defineProperty: __defProp22, getOwnPropertyNames: __getOwnPropNames22 } = Object);
|
|
43909
43969
|
__hasOwnProp22 = Object.prototype.hasOwnProperty;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"@kevisual/ai": "^0.0.24",
|
|
23
23
|
"@kevisual/code-builder": "^0.0.6",
|
|
24
24
|
"@kevisual/dts": "^0.0.3",
|
|
25
|
-
"@kevisual/context": "^0.0.
|
|
25
|
+
"@kevisual/context": "^0.0.6",
|
|
26
26
|
"@kevisual/types": "^0.0.12",
|
|
27
|
-
"@opencode-ai/plugin": "^1.2.
|
|
27
|
+
"@opencode-ai/plugin": "^1.2.4",
|
|
28
28
|
"@types/bun": "^1.3.9",
|
|
29
29
|
"@types/node": "^25.2.3",
|
|
30
30
|
"@types/ws": "^8.18.1",
|