tokmon 0.28.2 → 0.28.4
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 +156 -234
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/dist/{bootstrap-ink-IMT3S5HU.js → bootstrap-ink-WG4WG3R2.js} +1579 -1136
- package/dist/chunk-5B3XCEMC.js +294 -0
- package/dist/chunk-7CH6S7BR.js +447 -0
- package/dist/{chunk-LCAHTRGP.js → chunk-CFKUZCMB.js} +56 -29
- package/dist/{chunk-LKYOWBD4.js → chunk-FLANGRI6.js} +21 -42
- package/dist/chunk-HNWEJ6MS.js +1094 -0
- package/dist/{chunk-WUK3MQUB.js → chunk-JZSZEHVD.js} +167 -10
- package/dist/{chunk-6ZEW2M6P.js → chunk-P57DVFNH.js} +125 -25
- package/dist/chunk-TN6V7XSL.js +512 -0
- package/dist/chunk-UYPDMVW5.js +21 -0
- package/dist/{cli-command-DCENRCO3.js → cli-command-I4GRR3MF.js} +249 -15
- package/dist/cli.js +6 -6
- package/dist/{config-HXFJTNLM.js → config-3DGZ47F7.js} +23 -3
- package/dist/daemon-ZXV3V5CS.js +384 -0
- package/dist/daemon-handle-G4OGPFR3.js +11 -0
- package/dist/server-EPSH52DR.js +12 -0
- package/dist/web/assets/{Area-CMXvOw33.js → Area-stRnp8Km.js} +1 -1
- package/dist/web/assets/analytics-moZZt9L_.js +2 -0
- package/dist/web/assets/breakdown-km9w7myU.js +4 -0
- package/dist/web/assets/button-DrX04Cc2.js +1 -0
- package/dist/web/assets/{chart-cZoLgpmG.js → chart-D0CtuL2k.js} +1 -1
- package/dist/web/assets/explore-B11uNJV1.js +22 -0
- package/dist/web/assets/index-RDhXsCNG.js +83 -0
- package/dist/web/assets/index-ZmOS8p9O.css +1 -0
- package/dist/web/assets/models-DYbZnY34.js +2 -0
- package/dist/web/assets/overview-CruICbfJ.js +2 -0
- package/dist/web/assets/panel-xckM3_GC.js +1 -0
- package/dist/web/assets/settings-sheet-G-BTSIF6.js +1 -0
- package/dist/web/assets/share-sheet-weIdd4DW.js +2 -0
- package/dist/web/assets/timeline-BHgniliZ.js +1 -0
- package/dist/web/index.html +30 -4
- package/package.json +13 -4
- package/site/THIRD_PARTY_NOTICES.md +83 -0
- package/site/public/fonts/OFL.txt +93 -0
- package/dist/chunk-44ZSQEOS.js +0 -299
- package/dist/chunk-HP5UZCXP.js +0 -436
- package/dist/chunk-J3JW3RFP.js +0 -196
- package/dist/chunk-M7XMV36F.js +0 -275
- package/dist/daemon-6Y4O7NXS.js +0 -241
- package/dist/daemon-handle-GVCYVDPO.js +0 -10
- package/dist/server-GXXOWUVZ.js +0 -11
- package/dist/web/assets/analytics-DqdZXOJL.js +0 -2
- package/dist/web/assets/breakdown-kOSSJ3mI.js +0 -4
- package/dist/web/assets/explore-vcsM8K9I.js +0 -22
- package/dist/web/assets/index-BErCXT7f.css +0 -1
- package/dist/web/assets/index-DH3dOnbg.js +0 -83
- package/dist/web/assets/models-B5ikm83_.js +0 -2
- package/dist/web/assets/overview-DD1kP8CP.js +0 -2
- package/dist/web/assets/panel-DTQBwExW.js +0 -1
- package/dist/web/assets/primitives-C36qJlA2.js +0 -1
- package/dist/web/assets/settings-sheet-_i2zTQjf.js +0 -1
- package/dist/web/assets/share-sheet-BLHmrFbm.js +0 -2
- package/dist/web/assets/timeline-B4uG-Emo.js +0 -1
- package/dist/web/assets/use-dialog-trap-bfaXEMz9.js +0 -1
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
isAlive,
|
|
4
|
-
probeHealth,
|
|
5
3
|
readLock,
|
|
6
|
-
|
|
4
|
+
retireIncompatibleCliOwner,
|
|
7
5
|
verifyLock
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5B3XCEMC.js";
|
|
7
|
+
import {
|
|
8
|
+
daemonChannelFromWire,
|
|
9
|
+
resolveDaemonChannel
|
|
10
|
+
} from "./chunk-UYPDMVW5.js";
|
|
9
11
|
import {
|
|
10
12
|
TOKMON_PROTOCOL_VERSION
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JZSZEHVD.js";
|
|
12
14
|
|
|
13
15
|
// src/client/daemon-handle.ts
|
|
14
16
|
import { spawn } from "child_process";
|
|
15
17
|
import { extname } from "path";
|
|
16
18
|
var HANDSHAKE_TIMEOUT_MS = process.platform === "win32" ? 15e3 : 1e4;
|
|
17
|
-
var UPGRADE_SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
18
19
|
function runtimeExecArgv(entry, override) {
|
|
19
20
|
if (override) return override;
|
|
20
21
|
const ext = extname(entry).toLowerCase();
|
|
@@ -37,7 +38,7 @@ function runtimeExecArgv(entry, override) {
|
|
|
37
38
|
function parseHandshake(line) {
|
|
38
39
|
try {
|
|
39
40
|
const value = JSON.parse(line);
|
|
40
|
-
return value?.ready === 1 && typeof value.url === "string" && typeof value.wsToken === "string" && typeof value.version === "string" && typeof value.protocolVersion === "number" && Array.isArray(value.capabilities) && value.capabilities.every((capability) => typeof capability === "string") && (value.ownerKind === "cli" || value.ownerKind === "desktop") ? value : null;
|
|
41
|
+
return value?.ready === 1 && typeof value.url === "string" && typeof value.wsToken === "string" && typeof value.version === "string" && typeof value.protocolVersion === "number" && Array.isArray(value.capabilities) && value.capabilities.every((capability) => typeof capability === "string") && (value.ownerKind === "cli" || value.ownerKind === "desktop") && daemonChannelFromWire(value.channel) !== null ? { ...value, channel: daemonChannelFromWire(value.channel) } : null;
|
|
41
42
|
} catch {
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
@@ -50,48 +51,26 @@ async function attach(opts, protocolVersion) {
|
|
|
50
51
|
const lock = await verifyLock(readLock(opts), protocolVersion);
|
|
51
52
|
return lock ? connected(lock.url) : null;
|
|
52
53
|
}
|
|
53
|
-
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
54
|
-
async function retireIncompatibleDaemon(opts, protocolVersion, timeoutMs) {
|
|
55
|
-
const lock = readLock(opts);
|
|
56
|
-
if (!lock || lock.state !== "ready" || lock.protocolVersion === protocolVersion || lock.ownerKind === "desktop" || lock.pid === process.pid || !isAlive(lock.pid)) return;
|
|
57
|
-
const authenticated = await probeHealth(
|
|
58
|
-
lock.url,
|
|
59
|
-
lock.wsToken,
|
|
60
|
-
lock,
|
|
61
|
-
Math.min(1e3, timeoutMs)
|
|
62
|
-
);
|
|
63
|
-
if (!authenticated) return;
|
|
64
|
-
try {
|
|
65
|
-
process.kill(lock.pid, "SIGTERM");
|
|
66
|
-
} catch {
|
|
67
|
-
if (!isAlive(lock.pid)) reclaimDeadLock(opts);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const deadline = Date.now() + Math.min(timeoutMs, UPGRADE_SHUTDOWN_TIMEOUT_MS);
|
|
71
|
-
while (Date.now() < deadline) {
|
|
72
|
-
const current = readLock(opts);
|
|
73
|
-
if (!current || current.ownerId !== lock.ownerId) return;
|
|
74
|
-
if (!isAlive(lock.pid)) {
|
|
75
|
-
reclaimDeadLock(opts);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
await delay(50);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
54
|
async function attachOrSpawn(opts = {}) {
|
|
82
55
|
const protocolVersion = TOKMON_PROTOCOL_VERSION;
|
|
83
56
|
const timeoutMs = opts.timeoutMs ?? HANDSHAKE_TIMEOUT_MS;
|
|
84
|
-
const
|
|
57
|
+
const baseEnv = opts.env ?? process.env;
|
|
58
|
+
const channel = resolveDaemonChannel(opts.channel, baseEnv);
|
|
59
|
+
const lockOpts = { cachePath: opts.cachePath, channel };
|
|
60
|
+
const existing = await attach(lockOpts, protocolVersion);
|
|
85
61
|
if (existing) return existing;
|
|
86
|
-
await
|
|
87
|
-
const upgraded = await attach(
|
|
62
|
+
await retireIncompatibleCliOwner(lockOpts, protocolVersion, timeoutMs);
|
|
63
|
+
const upgraded = await attach(lockOpts, protocolVersion);
|
|
88
64
|
if (upgraded) return upgraded;
|
|
89
65
|
const entry = opts.entry ?? process.argv[1];
|
|
90
66
|
if (!entry) return degraded();
|
|
91
67
|
const execPath = opts.execPath ?? process.execPath;
|
|
92
68
|
const args = ["__daemon", "--port", "0", "--no-open"];
|
|
93
|
-
const
|
|
94
|
-
|
|
69
|
+
const env = {
|
|
70
|
+
...baseEnv,
|
|
71
|
+
TOKMON_CHANNEL: channel,
|
|
72
|
+
...opts.cachePath ? { TOKMON_DAEMON_CACHE_DIR: opts.cachePath } : {}
|
|
73
|
+
};
|
|
95
74
|
return new Promise((resolve) => {
|
|
96
75
|
let child;
|
|
97
76
|
try {
|
|
@@ -117,7 +96,7 @@ async function attachOrSpawn(opts = {}) {
|
|
|
117
96
|
resolve(handle);
|
|
118
97
|
};
|
|
119
98
|
const tryAttach = (final = false) => {
|
|
120
|
-
void attach(
|
|
99
|
+
void attach(lockOpts, protocolVersion).then((found) => {
|
|
121
100
|
if (found) {
|
|
122
101
|
finish(found);
|
|
123
102
|
return;
|
|
@@ -143,7 +122,7 @@ async function attachOrSpawn(opts = {}) {
|
|
|
143
122
|
const line = stdout.slice(0, newline).trim();
|
|
144
123
|
stdout = stdout.slice(newline + 1);
|
|
145
124
|
const handshake = parseHandshake(line);
|
|
146
|
-
if (!handshake || handshake.protocolVersion !== protocolVersion) continue;
|
|
125
|
+
if (!handshake || handshake.protocolVersion !== protocolVersion || handshake.channel !== channel) continue;
|
|
147
126
|
tryAttach();
|
|
148
127
|
return;
|
|
149
128
|
}
|