tokmon 0.28.1 → 0.28.2
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/{bootstrap-ink-L7QSJBMS.js → bootstrap-ink-IMT3S5HU.js} +5 -4
- package/dist/{chunk-FMP3P2WV.js → chunk-44ZSQEOS.js} +1 -1
- package/dist/{chunk-S33XIUAW.js → chunk-6ZEW2M6P.js} +158 -30
- package/dist/{chunk-XDA5RJST.js → chunk-J3JW3RFP.js} +9 -6
- package/dist/{chunk-CVKCVHS7.js → chunk-LCAHTRGP.js} +14 -281
- package/dist/{chunk-4HU4EI5T.js → chunk-LKYOWBD4.js} +15 -15
- package/dist/{chunk-3RTWFGGD.js → chunk-M7XMV36F.js} +1 -1
- package/dist/chunk-WUK3MQUB.js +249 -0
- package/dist/{cli-command-75LP4IDS.js → cli-command-DCENRCO3.js} +5 -5
- package/dist/cli.js +5 -5
- package/dist/{daemon-CL4FJW26.js → daemon-6Y4O7NXS.js} +35 -13
- package/dist/{daemon-handle-QQLJE46Y.js → daemon-handle-GVCYVDPO.js} +3 -3
- package/dist/server-GXXOWUVZ.js +11 -0
- package/package.json +1 -1
- package/dist/chunk-SMPY52EV.js +0 -125
- package/dist/server-EUO7CWYH.js +0 -11
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
attachOrSpawn
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-SMPY52EV.js";
|
|
4
|
+
} from "./chunk-LKYOWBD4.js";
|
|
5
|
+
import "./chunk-J3JW3RFP.js";
|
|
7
6
|
import {
|
|
8
7
|
createDaemonRpcClient
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-M7XMV36F.js";
|
|
10
9
|
import {
|
|
11
10
|
PROVIDERS,
|
|
12
11
|
antigravityStateDb,
|
|
@@ -26,7 +25,8 @@ import {
|
|
|
26
25
|
startOfMonth,
|
|
27
26
|
startOfWeek,
|
|
28
27
|
withTimeout
|
|
29
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-LCAHTRGP.js";
|
|
29
|
+
import "./chunk-WUK3MQUB.js";
|
|
30
30
|
import {
|
|
31
31
|
PROVIDER_IDS,
|
|
32
32
|
configLocation
|
package/dist/cli.js
CHANGED
|
@@ -41,7 +41,7 @@ function validateServeArgs(serveArgs) {
|
|
|
41
41
|
}
|
|
42
42
|
async function main() {
|
|
43
43
|
if (subcommand && ["usage", "models", "query", "providers", "snapshot", "config"].includes(subcommand)) {
|
|
44
|
-
const { runQueryCommand } = await import("./cli-command-
|
|
44
|
+
const { runQueryCommand } = await import("./cli-command-DCENRCO3.js");
|
|
45
45
|
try {
|
|
46
46
|
const output = await runQueryCommand(
|
|
47
47
|
subcommand,
|
|
@@ -60,14 +60,14 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (subcommand === "__daemon") {
|
|
63
|
-
const { runDaemon } = await import("./daemon-
|
|
63
|
+
const { runDaemon } = await import("./daemon-6Y4O7NXS.js");
|
|
64
64
|
await runDaemon(args.slice(1), { foreground: false });
|
|
65
65
|
process.exitCode ??= 0;
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (subcommand === "serve" || subcommand === "web") {
|
|
69
69
|
validateServeArgs(args.slice(1));
|
|
70
|
-
const { runDaemon } = await import("./daemon-
|
|
70
|
+
const { runDaemon } = await import("./daemon-6Y4O7NXS.js");
|
|
71
71
|
await runDaemon(args.slice(1), { foreground: true });
|
|
72
72
|
process.exitCode ??= 0;
|
|
73
73
|
return;
|
|
@@ -117,7 +117,7 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
117
117
|
}
|
|
118
118
|
const { loadConfig } = await import("./config-HXFJTNLM.js");
|
|
119
119
|
const { resolveGlyphs, setGlyphs } = await import("./glyphs-NKCSZLGO.js");
|
|
120
|
-
const { attachOrSpawn } = await import("./daemon-handle-
|
|
120
|
+
const { attachOrSpawn } = await import("./daemon-handle-GVCYVDPO.js");
|
|
121
121
|
const config = await loadConfig();
|
|
122
122
|
setGlyphs(resolveGlyphs({
|
|
123
123
|
flag: asciiFlag,
|
|
@@ -128,7 +128,7 @@ Run tokmon ${subcommand} --help for usage.
|
|
|
128
128
|
}));
|
|
129
129
|
const daemon = await attachOrSpawn();
|
|
130
130
|
const mode = daemon.kind === "spawned" ? "connected" : "degraded";
|
|
131
|
-
const { bootstrapInk } = await import("./bootstrap-ink-
|
|
131
|
+
const { bootstrapInk } = await import("./bootstrap-ink-IMT3S5HU.js");
|
|
132
132
|
await bootstrapInk({ interval, config, daemon, mode });
|
|
133
133
|
}
|
|
134
134
|
void main().catch((error) => {
|
|
@@ -8,17 +8,19 @@ import {
|
|
|
8
8
|
unlinkLock,
|
|
9
9
|
verifyLock,
|
|
10
10
|
writeLock
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-J3JW3RFP.js";
|
|
12
12
|
import {
|
|
13
|
+
appVersion,
|
|
13
14
|
startWebServer
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import
|
|
16
|
-
appVersion
|
|
17
|
-
} from "./chunk-SMPY52EV.js";
|
|
18
|
-
import "./chunk-FMP3P2WV.js";
|
|
15
|
+
} from "./chunk-6ZEW2M6P.js";
|
|
16
|
+
import "./chunk-44ZSQEOS.js";
|
|
19
17
|
import {
|
|
20
18
|
flushDisk
|
|
21
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-LCAHTRGP.js";
|
|
20
|
+
import {
|
|
21
|
+
TOKMON_CAPABILITIES,
|
|
22
|
+
TOKMON_PROTOCOL_VERSION
|
|
23
|
+
} from "./chunk-WUK3MQUB.js";
|
|
22
24
|
import {
|
|
23
25
|
loadConfig
|
|
24
26
|
} from "./chunk-HP5UZCXP.js";
|
|
@@ -75,7 +77,16 @@ Options:
|
|
|
75
77
|
-h, --help Show this help
|
|
76
78
|
`;
|
|
77
79
|
function handshake(lock) {
|
|
78
|
-
process.stdout.write(JSON.stringify({
|
|
80
|
+
process.stdout.write(JSON.stringify({
|
|
81
|
+
ready: 1,
|
|
82
|
+
url: lock.url,
|
|
83
|
+
port: lock.port,
|
|
84
|
+
wsToken: lock.wsToken,
|
|
85
|
+
version: lock.version,
|
|
86
|
+
protocolVersion: lock.protocolVersion,
|
|
87
|
+
capabilities: lock.capabilities,
|
|
88
|
+
ownerKind: lock.ownerKind
|
|
89
|
+
}) + "\n");
|
|
79
90
|
}
|
|
80
91
|
function describeExisting(lock, open) {
|
|
81
92
|
process.stdout.write(`
|
|
@@ -96,16 +107,16 @@ async function runDaemon(args, opts) {
|
|
|
96
107
|
const version = appVersion();
|
|
97
108
|
let current = readLock();
|
|
98
109
|
if (!current && reclaimAbandonedLock()) current = readLock();
|
|
99
|
-
const live = await verifyLock(current,
|
|
110
|
+
const live = await verifyLock(current, TOKMON_PROTOCOL_VERSION);
|
|
100
111
|
if (live) {
|
|
101
112
|
if (opts.foreground) describeExisting(live, open);
|
|
102
113
|
else handshake(live);
|
|
103
114
|
return;
|
|
104
115
|
}
|
|
105
|
-
if (current?.state === "starting" && current.
|
|
116
|
+
if (current?.state === "starting" && current.protocolVersion === TOKMON_PROTOCOL_VERSION && isAlive(current.pid)) {
|
|
106
117
|
for (let attempt = 0; attempt < 60; attempt++) {
|
|
107
118
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
108
|
-
const winner = await verifyLock(readLock(),
|
|
119
|
+
const winner = await verifyLock(readLock(), TOKMON_PROTOCOL_VERSION, 250);
|
|
109
120
|
if (winner) {
|
|
110
121
|
if (opts.foreground) describeExisting(winner, open);
|
|
111
122
|
else handshake(winner);
|
|
@@ -130,6 +141,9 @@ async function runDaemon(args, opts) {
|
|
|
130
141
|
url: "",
|
|
131
142
|
wsToken: token,
|
|
132
143
|
version,
|
|
144
|
+
protocolVersion: TOKMON_PROTOCOL_VERSION,
|
|
145
|
+
capabilities: [...TOKMON_CAPABILITIES],
|
|
146
|
+
ownerKind: "cli",
|
|
133
147
|
startedAt: Date.now(),
|
|
134
148
|
ownerId,
|
|
135
149
|
state: "starting"
|
|
@@ -137,7 +151,7 @@ async function runDaemon(args, opts) {
|
|
|
137
151
|
if (!acquireLock(reservation)) {
|
|
138
152
|
for (let attempt = 0; attempt < 60; attempt++) {
|
|
139
153
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
140
|
-
const winner = await verifyLock(readLock(),
|
|
154
|
+
const winner = await verifyLock(readLock(), TOKMON_PROTOCOL_VERSION, 250);
|
|
141
155
|
if (winner) {
|
|
142
156
|
if (opts.foreground) describeExisting(winner, open);
|
|
143
157
|
else handshake(winner);
|
|
@@ -153,7 +167,15 @@ async function runDaemon(args, opts) {
|
|
|
153
167
|
let controller = null;
|
|
154
168
|
try {
|
|
155
169
|
const config = await loadConfig();
|
|
156
|
-
controller = await startWebServer({
|
|
170
|
+
controller = await startWebServer({
|
|
171
|
+
config,
|
|
172
|
+
port,
|
|
173
|
+
log: opts.foreground,
|
|
174
|
+
wsToken: token,
|
|
175
|
+
ownerKind: reservation.ownerKind,
|
|
176
|
+
protocolVersion: reservation.protocolVersion,
|
|
177
|
+
capabilities: reservation.capabilities
|
|
178
|
+
});
|
|
157
179
|
const ready = {
|
|
158
180
|
...reservation,
|
|
159
181
|
port: controller.port,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
attachOrSpawn
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-LKYOWBD4.js";
|
|
5
|
+
import "./chunk-J3JW3RFP.js";
|
|
6
|
+
import "./chunk-WUK3MQUB.js";
|
|
7
7
|
import "./chunk-HP5UZCXP.js";
|
|
8
8
|
export {
|
|
9
9
|
attachOrSpawn
|
package/package.json
CHANGED
package/dist/chunk-SMPY52EV.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/web/static.ts
|
|
4
|
-
import { createReadStream, existsSync, readFileSync } from "fs";
|
|
5
|
-
import { stat } from "fs/promises";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
import { extname, join, normalize, sep } from "path";
|
|
8
|
-
var MIME = {
|
|
9
|
-
".html": "text/html; charset=utf-8",
|
|
10
|
-
".js": "text/javascript; charset=utf-8",
|
|
11
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
12
|
-
".css": "text/css; charset=utf-8",
|
|
13
|
-
".json": "application/json; charset=utf-8",
|
|
14
|
-
".svg": "image/svg+xml",
|
|
15
|
-
".png": "image/png",
|
|
16
|
-
".jpg": "image/jpeg",
|
|
17
|
-
".jpeg": "image/jpeg",
|
|
18
|
-
".gif": "image/gif",
|
|
19
|
-
".ico": "image/x-icon",
|
|
20
|
-
".woff": "font/woff",
|
|
21
|
-
".woff2": "font/woff2",
|
|
22
|
-
".ttf": "font/ttf",
|
|
23
|
-
".otf": "font/otf",
|
|
24
|
-
".map": "application/json; charset=utf-8",
|
|
25
|
-
".webmanifest": "application/manifest+json"
|
|
26
|
-
};
|
|
27
|
-
function findWebRoot() {
|
|
28
|
-
const candidates = ["./web/", "../web/", "../dist/web/", "../../dist/web/"];
|
|
29
|
-
for (const rel of candidates) {
|
|
30
|
-
try {
|
|
31
|
-
const dir = fileURLToPath(new URL(rel, import.meta.url));
|
|
32
|
-
if (existsSync(join(dir, "index.html"))) return dir.replace(/[\\/]+$/, "");
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
function resolveStaticPath(webRoot, urlPath) {
|
|
39
|
-
let clean;
|
|
40
|
-
try {
|
|
41
|
-
clean = decodeURIComponent(urlPath.split("?")[0]);
|
|
42
|
-
} catch {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const rel = normalize(clean).replace(/^(\.\.[/\\])+/, "").replace(/^[/\\]+/, "");
|
|
46
|
-
const full = join(webRoot, rel);
|
|
47
|
-
if (full !== webRoot && !full.startsWith(webRoot + sep)) return null;
|
|
48
|
-
return full;
|
|
49
|
-
}
|
|
50
|
-
function send(res, status, type, body) {
|
|
51
|
-
res.writeHead(status, {
|
|
52
|
-
"Content-Type": type,
|
|
53
|
-
"Cache-Control": "no-store",
|
|
54
|
-
"Referrer-Policy": "no-referrer",
|
|
55
|
-
"X-Content-Type-Options": "nosniff"
|
|
56
|
-
});
|
|
57
|
-
res.end(body);
|
|
58
|
-
}
|
|
59
|
-
function sendJson(res, status, data) {
|
|
60
|
-
send(res, status, "application/json; charset=utf-8", JSON.stringify(data));
|
|
61
|
-
}
|
|
62
|
-
function serveStatic(webRoot, urlPath, res) {
|
|
63
|
-
const path = urlPath.split("?")[0];
|
|
64
|
-
const filePath = resolveStaticPath(webRoot, path === "/" ? "/index.html" : path);
|
|
65
|
-
if (!filePath) {
|
|
66
|
-
send(res, 403, "text/plain", "forbidden");
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
void stat(filePath).then((st) => {
|
|
70
|
-
if (st.isFile()) {
|
|
71
|
-
const type = MIME[extname(filePath).toLowerCase()] || "application/octet-stream";
|
|
72
|
-
const immutable = filePath.includes(`${sep}assets${sep}`);
|
|
73
|
-
res.writeHead(200, {
|
|
74
|
-
"Content-Type": type,
|
|
75
|
-
"Cache-Control": immutable ? "public, max-age=31536000, immutable" : "no-cache",
|
|
76
|
-
"Referrer-Policy": "no-referrer",
|
|
77
|
-
"X-Content-Type-Options": "nosniff"
|
|
78
|
-
});
|
|
79
|
-
createReadStream(filePath).pipe(res);
|
|
80
|
-
} else {
|
|
81
|
-
throw new Error("not a file");
|
|
82
|
-
}
|
|
83
|
-
}).catch(() => {
|
|
84
|
-
if (extname(path)) {
|
|
85
|
-
send(res, 404, "text/plain", "not found");
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const indexPath = join(webRoot, "index.html");
|
|
89
|
-
if (!existsSync(indexPath)) {
|
|
90
|
-
send(res, 404, "text/plain", "not found");
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
res.writeHead(200, {
|
|
94
|
-
"Content-Type": MIME[".html"],
|
|
95
|
-
"Cache-Control": "no-cache",
|
|
96
|
-
"Referrer-Policy": "no-referrer",
|
|
97
|
-
"X-Content-Type-Options": "nosniff"
|
|
98
|
-
});
|
|
99
|
-
createReadStream(indexPath).on("error", () => {
|
|
100
|
-
try {
|
|
101
|
-
res.destroy();
|
|
102
|
-
} catch {
|
|
103
|
-
}
|
|
104
|
-
}).pipe(res);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function appVersion() {
|
|
108
|
-
for (const rel of ["../package.json", "../../package.json"]) {
|
|
109
|
-
try {
|
|
110
|
-
const p = fileURLToPath(new URL(rel, import.meta.url));
|
|
111
|
-
const pkg = JSON.parse(readFileSync(p, "utf-8"));
|
|
112
|
-
if (typeof pkg.version === "string") return pkg.version;
|
|
113
|
-
} catch {
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return "";
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export {
|
|
120
|
-
findWebRoot,
|
|
121
|
-
send,
|
|
122
|
-
sendJson,
|
|
123
|
-
serveStatic,
|
|
124
|
-
appVersion
|
|
125
|
-
};
|
package/dist/server-EUO7CWYH.js
DELETED