tarsk 0.5.46 → 0.5.47
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/index.js +117 -33
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -2240,6 +2240,7 @@ var init_database = __esm({
|
|
|
2240
2240
|
|
|
2241
2241
|
// src/server.ts
|
|
2242
2242
|
init_dist();
|
|
2243
|
+
import { createAdaptorServer } from "@hono/node-server";
|
|
2243
2244
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
2244
2245
|
import fs3 from "fs";
|
|
2245
2246
|
import { Hono as Hono28 } from "hono";
|
|
@@ -31690,6 +31691,9 @@ function createSystemPermissionsRoutes() {
|
|
|
31690
31691
|
var __filename = fileURLToPath3(import.meta.url);
|
|
31691
31692
|
var __dirname = path5.dirname(__filename);
|
|
31692
31693
|
var startPromise = null;
|
|
31694
|
+
function isBunRuntime() {
|
|
31695
|
+
return typeof Bun !== "undefined" && typeof Bun.serve === "function";
|
|
31696
|
+
}
|
|
31693
31697
|
async function startTarskServer(options) {
|
|
31694
31698
|
if (startPromise) {
|
|
31695
31699
|
return startPromise;
|
|
@@ -31700,7 +31704,6 @@ async function startTarskServer(options) {
|
|
|
31700
31704
|
async function startTarskServerInternal(options) {
|
|
31701
31705
|
const { isDebug: isDebug2, publicDir: publicDirOverride } = options;
|
|
31702
31706
|
const initialPort = isDebug2 ? 462 : process.env.PORT ? parseInt(process.env.PORT) : 641;
|
|
31703
|
-
const { upgradeWebSocket, websocket } = (await import("hono/bun")).createBunWebSocket();
|
|
31704
31707
|
const app = new Hono28();
|
|
31705
31708
|
app.use("/*", cors());
|
|
31706
31709
|
app.use("/*", async (c, next) => {
|
|
@@ -31722,6 +31725,19 @@ async function startTarskServerInternal(options) {
|
|
|
31722
31725
|
}
|
|
31723
31726
|
return next();
|
|
31724
31727
|
});
|
|
31728
|
+
let upgradeWebSocket;
|
|
31729
|
+
let injectNodeWebSocket;
|
|
31730
|
+
let bunWebSocketSupport;
|
|
31731
|
+
if (isBunRuntime()) {
|
|
31732
|
+
const { createBunWebSocket } = await import("hono/bun");
|
|
31733
|
+
bunWebSocketSupport = createBunWebSocket();
|
|
31734
|
+
upgradeWebSocket = bunWebSocketSupport.upgradeWebSocket;
|
|
31735
|
+
} else {
|
|
31736
|
+
const { createNodeWebSocket } = await import("@hono/node-ws");
|
|
31737
|
+
const nodeWebSocket = createNodeWebSocket({ app });
|
|
31738
|
+
upgradeWebSocket = nodeWebSocket.upgradeWebSocket;
|
|
31739
|
+
injectNodeWebSocket = nodeWebSocket.injectWebSocket;
|
|
31740
|
+
}
|
|
31725
31741
|
const dataDir = getDataDir();
|
|
31726
31742
|
const metadataManager = new MetadataManager(dataDir);
|
|
31727
31743
|
const gitManager2 = new GitManagerImpl();
|
|
@@ -31872,46 +31888,114 @@ async function startTarskServerInternal(options) {
|
|
|
31872
31888
|
});
|
|
31873
31889
|
const serverBindMode = readServerBindMode();
|
|
31874
31890
|
const hostname2 = getServerBindHostname(serverBindMode);
|
|
31875
|
-
|
|
31876
|
-
|
|
31877
|
-
|
|
31878
|
-
|
|
31879
|
-
fetch: app.fetch,
|
|
31880
|
-
hostname: hostname2,
|
|
31881
|
-
port,
|
|
31882
|
-
websocket
|
|
31883
|
-
});
|
|
31884
|
-
listeningPort = server.port ?? port;
|
|
31885
|
-
process.stdout.write(`Tarsk started on http://localhost:${listeningPort}
|
|
31891
|
+
const onListening = (boundPort) => {
|
|
31892
|
+
listeningPort = boundPort;
|
|
31893
|
+
const url = `http://localhost:${boundPort}`;
|
|
31894
|
+
process.stdout.write(`Tarsk started on ${url}
|
|
31886
31895
|
`);
|
|
31887
|
-
|
|
31888
|
-
|
|
31889
|
-
|
|
31896
|
+
if (serverBindMode === "network") {
|
|
31897
|
+
for (const address of getLocalNetworkAddresses()) {
|
|
31898
|
+
process.stdout.write(` Network: http://${address}:${boundPort}
|
|
31890
31899
|
`);
|
|
31891
|
-
}
|
|
31892
31900
|
}
|
|
31893
|
-
|
|
31894
|
-
|
|
31901
|
+
}
|
|
31902
|
+
if (options.openBrowser) {
|
|
31903
|
+
open4(url).catch(() => {
|
|
31904
|
+
});
|
|
31905
|
+
}
|
|
31906
|
+
};
|
|
31907
|
+
if (isBunRuntime()) {
|
|
31908
|
+
if (!bunWebSocketSupport) {
|
|
31909
|
+
startPromise = null;
|
|
31910
|
+
throw new Error("Bun WebSocket support was not initialized.");
|
|
31911
|
+
}
|
|
31912
|
+
let port2 = initialPort;
|
|
31913
|
+
while (true) {
|
|
31914
|
+
try {
|
|
31915
|
+
const server = Bun.serve({
|
|
31916
|
+
fetch: app.fetch,
|
|
31917
|
+
hostname: hostname2,
|
|
31918
|
+
port: port2,
|
|
31919
|
+
websocket: bunWebSocketSupport.websocket
|
|
31895
31920
|
});
|
|
31896
|
-
|
|
31897
|
-
|
|
31898
|
-
|
|
31899
|
-
|
|
31900
|
-
|
|
31901
|
-
|
|
31902
|
-
|
|
31903
|
-
|
|
31904
|
-
|
|
31905
|
-
|
|
31906
|
-
|
|
31921
|
+
onListening(server.port ?? port2);
|
|
31922
|
+
return {
|
|
31923
|
+
url: `http://localhost:${server.port ?? port2}`,
|
|
31924
|
+
port: server.port ?? port2,
|
|
31925
|
+
bound: true,
|
|
31926
|
+
isDevMode: (server.port ?? port2) !== initialPort
|
|
31927
|
+
};
|
|
31928
|
+
} catch (error) {
|
|
31929
|
+
const errno = error;
|
|
31930
|
+
if (errno.code === "EADDRINUSE") {
|
|
31931
|
+
process.stdout.write(`Port ${port2} is already in use, trying ${port2 + 1}.
|
|
31907
31932
|
`);
|
|
31908
|
-
|
|
31909
|
-
|
|
31933
|
+
port2 += 1;
|
|
31934
|
+
continue;
|
|
31935
|
+
}
|
|
31936
|
+
startPromise = null;
|
|
31937
|
+
throw error;
|
|
31910
31938
|
}
|
|
31911
|
-
startPromise = null;
|
|
31912
|
-
throw error;
|
|
31913
31939
|
}
|
|
31914
31940
|
}
|
|
31941
|
+
if (!injectNodeWebSocket) {
|
|
31942
|
+
startPromise = null;
|
|
31943
|
+
throw new Error("Node.js WebSocket support was not initialized.");
|
|
31944
|
+
}
|
|
31945
|
+
const port = await listenForTarskServer({
|
|
31946
|
+
fetch: app.fetch,
|
|
31947
|
+
hostname: hostname2,
|
|
31948
|
+
injectWebSocket: injectNodeWebSocket,
|
|
31949
|
+
onPortConflict: (candidatePort) => {
|
|
31950
|
+
process.stdout.write(
|
|
31951
|
+
`Port ${candidatePort} is already in use, trying ${candidatePort + 1}.
|
|
31952
|
+
`
|
|
31953
|
+
);
|
|
31954
|
+
},
|
|
31955
|
+
onListening,
|
|
31956
|
+
port: initialPort
|
|
31957
|
+
});
|
|
31958
|
+
return {
|
|
31959
|
+
url: `http://localhost:${port}`,
|
|
31960
|
+
port,
|
|
31961
|
+
bound: true,
|
|
31962
|
+
isDevMode: port !== initialPort
|
|
31963
|
+
};
|
|
31964
|
+
}
|
|
31965
|
+
async function listenForTarskServer(options) {
|
|
31966
|
+
let port = options.port;
|
|
31967
|
+
while (true) {
|
|
31968
|
+
const server = createAdaptorServer({
|
|
31969
|
+
fetch: options.fetch,
|
|
31970
|
+
hostname: options.hostname,
|
|
31971
|
+
port
|
|
31972
|
+
});
|
|
31973
|
+
options.injectWebSocket(server);
|
|
31974
|
+
const result = await new Promise((resolve8, reject) => {
|
|
31975
|
+
server.once("error", (error) => {
|
|
31976
|
+
if (error.code === "EADDRINUSE") {
|
|
31977
|
+
resolve8("in-use");
|
|
31978
|
+
return;
|
|
31979
|
+
}
|
|
31980
|
+
startPromise = null;
|
|
31981
|
+
reject(error);
|
|
31982
|
+
});
|
|
31983
|
+
function onListening() {
|
|
31984
|
+
resolve8("listening");
|
|
31985
|
+
}
|
|
31986
|
+
if (options.hostname) {
|
|
31987
|
+
server.listen(port, options.hostname, onListening);
|
|
31988
|
+
} else {
|
|
31989
|
+
server.listen(port, onListening);
|
|
31990
|
+
}
|
|
31991
|
+
});
|
|
31992
|
+
if (result === "listening") {
|
|
31993
|
+
options.onListening(port);
|
|
31994
|
+
return port;
|
|
31995
|
+
}
|
|
31996
|
+
options.onPortConflict(port);
|
|
31997
|
+
port += 1;
|
|
31998
|
+
}
|
|
31915
31999
|
}
|
|
31916
32000
|
|
|
31917
32001
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tarsk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.47",
|
|
4
4
|
"description": "CLI for Tarsk - Project Threads Manager",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@earendil-works/pi-agent-core": "0.79.6",
|
|
43
43
|
"@earendil-works/pi-ai": "0.79.6",
|
|
44
44
|
"@hono/node-server": "1.19.13",
|
|
45
|
+
"@hono/node-ws": "1.3.1",
|
|
45
46
|
"@libsql/client": "0.17.2",
|
|
46
47
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
47
48
|
"@sinclair/typebox": "0.34.49",
|