inkmap-mcp 0.3.16 → 0.3.17
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/bundles/antigravity/plugin.json +1 -1
- package/dist/bundles/antigravity/sidecars/inkmap/bridge.js +7 -4
- package/dist/bundles/antigravity/sidecars/inkmap/main.mjs +131 -82
- package/dist/bundles/antigravity/sidecars/inkmap/sidecar.json +1 -6
- package/dist/bundles/codex/inkmap-codex/.codex-plugin/plugin.json +1 -1
- package/dist/bundles/codex/inkmap-codex/plugin.json +1 -1
- package/dist/bundles/harness/host.js +129 -58
- package/dist/bundles/harness/package.json +1 -1
- package/dist/bundles/vscode/dist/extension.js +172 -60
- package/dist/bundles/vscode/package.json +6 -1
- package/dist/cli.cjs +268 -131
- package/dist/codex.html +722 -669
- package/dist/web/app.js +23270 -22557
- package/dist/web/index.html +44 -4
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/harness/src/host.mjs
|
|
2
2
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3
3
|
import { lstat as lstat3, realpath as realpath3 } from "node:fs/promises";
|
|
4
|
-
import { isAbsolute as isAbsolute2, relative as relative3, sep as
|
|
4
|
+
import { isAbsolute as isAbsolute2, relative as relative3, sep as sep3 } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
7
|
// packages/core/dist/product.js
|
|
@@ -56,10 +56,10 @@ import { execFileSync } from "node:child_process";
|
|
|
56
56
|
import { link, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
57
57
|
import { randomUUID } from "node:crypto";
|
|
58
58
|
import { homedir, tmpdir } from "node:os";
|
|
59
|
-
import { dirname, join
|
|
59
|
+
import { dirname, join } from "node:path";
|
|
60
60
|
|
|
61
61
|
// packages/cli/dist/version.js
|
|
62
|
-
var INKMAP_VERSION = "0.3.
|
|
62
|
+
var INKMAP_VERSION = "0.3.17";
|
|
63
63
|
|
|
64
64
|
// packages/cli/dist/license.js
|
|
65
65
|
var ZH_LOCALE_RE = /^zh(?:[-_.]|$)/i;
|
|
@@ -70,6 +70,8 @@ var WAIT_SLOW_MS = 3e4;
|
|
|
70
70
|
var WAIT_FAST_FOR_MS = 30 * 6e4;
|
|
71
71
|
var WAIT_MAX_MS = 3 * 24 * 60 * 6e4;
|
|
72
72
|
var MAX_WAITING = 5;
|
|
73
|
+
var OFFLINE_PRO_GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
74
|
+
var PRO_RECHECK_STAMP_MS = 12 * 60 * 6e4;
|
|
73
75
|
function isWaitingToken(value) {
|
|
74
76
|
const w = value;
|
|
75
77
|
return Boolean(w) && typeof w.origin === "string" && typeof w.token === "string" && /^[A-Za-z0-9_-]{43}$/.test(w.token) && typeof w.email === "string" && typeof w.since === "number" && typeof w.fastUntil === "number";
|
|
@@ -154,6 +156,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
154
156
|
let detectedHost = defaultHost;
|
|
155
157
|
const pendingEvents = /* @__PURE__ */ new Map();
|
|
156
158
|
let lastCheck = 0;
|
|
159
|
+
let retryAfter = 0;
|
|
157
160
|
let fastPollUntil = 0;
|
|
158
161
|
const expectPurchase = () => void (fastPollUntil = Date.now() + 15 * 6e4);
|
|
159
162
|
let flowCreation;
|
|
@@ -355,6 +358,24 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
355
358
|
timer = setTimeout(() => void refresh(), delay);
|
|
356
359
|
timer.unref();
|
|
357
360
|
}
|
|
361
|
+
async function rememberProCheck(token, active, account) {
|
|
362
|
+
await writeSession(async () => {
|
|
363
|
+
let record;
|
|
364
|
+
try {
|
|
365
|
+
record = JSON.parse(await storage.read() || "{}");
|
|
366
|
+
} catch {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (record.token !== token)
|
|
370
|
+
return;
|
|
371
|
+
const at = typeof record.proVerifiedAt === "number" ? record.proVerifiedAt : void 0;
|
|
372
|
+
if (active ? at !== void 0 && Date.now() - at < PRO_RECHECK_STAMP_MS && at <= Date.now() : at === void 0)
|
|
373
|
+
return;
|
|
374
|
+
const { proVerifiedAt: _at, proAccount: _account, ...rest } = record;
|
|
375
|
+
await storage.write(JSON.stringify(active ? { ...rest, proVerifiedAt: Date.now(), ...account && { proAccount: account } } : rest));
|
|
376
|
+
}).catch(() => {
|
|
377
|
+
});
|
|
378
|
+
}
|
|
358
379
|
function refresh() {
|
|
359
380
|
if (connection)
|
|
360
381
|
return connection;
|
|
@@ -362,6 +383,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
362
383
|
connection = (async () => {
|
|
363
384
|
let token;
|
|
364
385
|
let delay = 6e4;
|
|
386
|
+
let offlinePro;
|
|
365
387
|
try {
|
|
366
388
|
const origin = billingOrigin(getOrigin());
|
|
367
389
|
if (origin !== activeOrigin) {
|
|
@@ -378,6 +400,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
378
400
|
if (record.origin !== origin || typeof record.token !== "string")
|
|
379
401
|
return update(false);
|
|
380
402
|
token = record.token;
|
|
403
|
+
const verifiedAt = record.proVerifiedAt;
|
|
404
|
+
if (typeof verifiedAt === "number" && verifiedAt <= Date.now() && Date.now() - verifiedAt < OFFLINE_PRO_GRACE_MS) {
|
|
405
|
+
offlinePro = { ...typeof record.proAccount === "string" && { account: record.proAccount.slice(0, 64) } };
|
|
406
|
+
}
|
|
381
407
|
const response = await entitlement(origin, record.token);
|
|
382
408
|
if (version !== generation || disposed)
|
|
383
409
|
return;
|
|
@@ -397,9 +423,14 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
397
423
|
if (version !== generation || disposed)
|
|
398
424
|
return;
|
|
399
425
|
applyEntitlement(state);
|
|
400
|
-
|
|
426
|
+
void rememberProCheck(record.token, current.pro, current.account);
|
|
427
|
+
delay = state.active !== true && (state.pending === true || Date.now() < fastPollUntil) ? 2500 : 6e4;
|
|
401
428
|
} catch {
|
|
402
|
-
if (version === generation
|
|
429
|
+
if (version === generation)
|
|
430
|
+
retryAfter = Date.now() + (Date.now() < fastPollUntil ? 2e3 : 3e4);
|
|
431
|
+
if (version === generation && offlinePro)
|
|
432
|
+
update(true, true, offlinePro.account);
|
|
433
|
+
else if (version === generation && Date.now() - lastCheck > 15 * 6e4)
|
|
403
434
|
update(false);
|
|
404
435
|
} finally {
|
|
405
436
|
if (version === generation && token)
|
|
@@ -438,7 +469,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
438
469
|
clearTimeout(waitTimer);
|
|
439
470
|
if (disposed || !waiting.length)
|
|
440
471
|
return;
|
|
441
|
-
waitTimer = setTimeout(() => void checkWaiting(), delay);
|
|
472
|
+
waitTimer = setTimeout(() => void checkWaiting().catch(() => scheduleWait(WAIT_SLOW_MS)), delay);
|
|
442
473
|
waitTimer.unref();
|
|
443
474
|
}
|
|
444
475
|
async function checkWaiting() {
|
|
@@ -479,8 +510,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
479
510
|
await writeSession(async () => {
|
|
480
511
|
if (disposed || round !== waitRound || w.origin !== billingOrigin(getOrigin()))
|
|
481
512
|
return;
|
|
482
|
-
|
|
513
|
+
if (w.email)
|
|
514
|
+
lastSignIn = w.email.trim().slice(0, 254);
|
|
483
515
|
await storage.write(sessionRecord({ origin: w.origin, token: w.token }));
|
|
516
|
+
clearWaiting();
|
|
484
517
|
++generation;
|
|
485
518
|
activeOrigin = w.origin;
|
|
486
519
|
applyEntitlement(body);
|
|
@@ -517,6 +550,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
517
550
|
}
|
|
518
551
|
if (typeof record.token !== "string" || typeof record.origin !== "string")
|
|
519
552
|
return;
|
|
553
|
+
if (typeof record.checkoutUrl === "string")
|
|
554
|
+
return;
|
|
520
555
|
const response = await entitlement(record.origin, record.token).catch(() => null);
|
|
521
556
|
if (!response?.ok)
|
|
522
557
|
return;
|
|
@@ -549,13 +584,20 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
549
584
|
return;
|
|
550
585
|
}
|
|
551
586
|
if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
|
|
552
|
-
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT)
|
|
553
|
-
return;
|
|
554
|
-
const customHome = process.env.INKMAP_HOME || "";
|
|
555
|
-
const sysTmp = tmpdir();
|
|
556
|
-
if (customHome && (customHome === sysTmp || customHome.startsWith(sysTmp + sep) || customHome.startsWith("/tmp/") || customHome.startsWith("/private/tmp/") || customHome.includes("/var/folders/") || customHome.includes("inkmap-npm-isolated-") || customHome.includes("inkmap-antigravity-mcp-") || customHome.includes("inkmap-local-editor-") || customHome.includes("inkmap-harness-"))) {
|
|
587
|
+
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT || process.env.VITEST || process.env.JEST_WORKER_ID || process.env.CI === "true" || process.env.CI === "1") {
|
|
557
588
|
return;
|
|
558
589
|
}
|
|
590
|
+
const norm = (p) => {
|
|
591
|
+
const clean = p.replace(/\\/g, "/");
|
|
592
|
+
return process.platform === "win32" ? clean.toLowerCase() : clean;
|
|
593
|
+
};
|
|
594
|
+
const sysTmp = norm(tmpdir()).replace(/\/+$/, "");
|
|
595
|
+
const homesToCheck = [process.env.INKMAP_HOME || "", homedir()].filter(Boolean).map(norm);
|
|
596
|
+
for (const h of homesToCheck) {
|
|
597
|
+
if (h === sysTmp || h.startsWith(sysTmp + "/") || h.startsWith("/tmp/") || h.startsWith("/private/tmp/") || h.includes("/var/folders/") || h.includes("/appdata/local/temp/") || h.includes("/temp/inkmap") || h.includes("inkmap-npm-isolated-") || h.includes("inkmap-antigravity-mcp-") || h.includes("inkmap-local-editor-") || h.includes("inkmap-harness-") || h.includes("inkmap-test-")) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
559
601
|
}
|
|
560
602
|
const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
|
|
561
603
|
if (disposed || !id || !pendingEvents.size)
|
|
@@ -589,8 +631,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
589
631
|
return {
|
|
590
632
|
async state() {
|
|
591
633
|
await (trial ??= startTrial());
|
|
592
|
-
const interval = !current.pro && Date.now() < fastPollUntil ?
|
|
593
|
-
if (Date.now() - lastCheck >= interval)
|
|
634
|
+
const interval = !current.pro && Date.now() < fastPollUntil ? 2e3 : 6e4;
|
|
635
|
+
if (Date.now() - lastCheck >= interval && Date.now() >= retryAfter)
|
|
594
636
|
await refresh();
|
|
595
637
|
await parkUnpaidSession();
|
|
596
638
|
return current;
|
|
@@ -659,7 +701,9 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
659
701
|
if (cachedOrder && cachedOrder.origin === origin && cachedOrder.locale === loc && Date.now() - cachedOrder.at < 8e3) {
|
|
660
702
|
const hit = cachedOrder.result;
|
|
661
703
|
cachedOrder = void 0;
|
|
662
|
-
|
|
704
|
+
if (current.pro)
|
|
705
|
+
return { status: "active", state: current };
|
|
706
|
+
schedule(hit.status === "qr" || hit.status === "redirect" ? 2500 : 6e4);
|
|
663
707
|
return hit;
|
|
664
708
|
}
|
|
665
709
|
const version = generation;
|
|
@@ -670,6 +714,17 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
670
714
|
record = JSON.parse(stored);
|
|
671
715
|
} catch {
|
|
672
716
|
}
|
|
717
|
+
if (record?.origin === origin && typeof record.token === "string") {
|
|
718
|
+
const rights = await entitlement(origin, record.token).catch(() => null);
|
|
719
|
+
if (rights?.ok) {
|
|
720
|
+
const ent = await rights.json().catch(() => null);
|
|
721
|
+
if (ent && ent.active === true) {
|
|
722
|
+
applyEntitlement(ent);
|
|
723
|
+
schedule(6e4);
|
|
724
|
+
return { status: "active", state: current };
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
673
728
|
const requestOrder = async (checkoutUrl, token, cookie, persist) => {
|
|
674
729
|
const res = await checkoutPost(checkoutUrl, "order", origin, {}, token, cookie, localeHint);
|
|
675
730
|
if (res.status === 401 || res.status === 403 || res.status === 404 || res.status === 410)
|
|
@@ -867,13 +922,16 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
867
922
|
if (version !== generation || disposed || origin !== billingOrigin(getOrigin()))
|
|
868
923
|
return phoneFailure();
|
|
869
924
|
clearWaiting();
|
|
925
|
+
const clean = phone.trim().slice(0, 254);
|
|
926
|
+
if (clean)
|
|
927
|
+
lastSignIn = clean;
|
|
870
928
|
await storage.write(sessionRecord({ origin, token, ...checkoutUrl && { checkoutUrl }, ...cookie && { cookie } }));
|
|
871
929
|
++generation;
|
|
872
930
|
activeOrigin = origin;
|
|
873
931
|
applyEntitlement(state);
|
|
874
932
|
if (cachedOrder?.result.status === "active")
|
|
875
933
|
cachedOrder.result.state = current;
|
|
876
|
-
schedule(cachedOrder?.result.status === "qr" ?
|
|
934
|
+
schedule(cachedOrder?.result.status === "qr" || cachedOrder?.result.status === "redirect" ? 2500 : 6e4);
|
|
877
935
|
return { ok: true, value: current };
|
|
878
936
|
});
|
|
879
937
|
} catch {
|
|
@@ -1027,18 +1085,50 @@ async function localTrialDeadline() {
|
|
|
1027
1085
|
}
|
|
1028
1086
|
|
|
1029
1087
|
// packages/cli/dist/server.js
|
|
1030
|
-
import { spawn } from "node:child_process";
|
|
1031
1088
|
import { createHash, randomBytes } from "node:crypto";
|
|
1032
1089
|
import { watch } from "node:fs";
|
|
1033
1090
|
import { lstat as lstat2, mkdir as mkdir2, readFile as readFile3, realpath as realpath2, rename as rename2, rm as rm2, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
1034
1091
|
import { createServer } from "node:http";
|
|
1035
1092
|
import { homedir as homedir3 } from "node:os";
|
|
1036
|
-
import { basename as basename2, delimiter as delimiter2, dirname as dirname3, extname, join as join3, normalize, relative as relative2, resolve as resolve2, sep as
|
|
1093
|
+
import { basename as basename2, delimiter as delimiter2, dirname as dirname3, extname, join as join3, normalize, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
1094
|
+
|
|
1095
|
+
// packages/cli/dist/open-browser.js
|
|
1096
|
+
import { spawn } from "node:child_process";
|
|
1097
|
+
function run(cmd, args, launched = false) {
|
|
1098
|
+
return new Promise((done) => {
|
|
1099
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
1100
|
+
child.on("error", () => done(false));
|
|
1101
|
+
if (launched)
|
|
1102
|
+
child.on("spawn", () => done(true));
|
|
1103
|
+
else
|
|
1104
|
+
child.on("exit", (code) => done(code === 0));
|
|
1105
|
+
child.unref();
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
async function openBrowserWindow(url) {
|
|
1109
|
+
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url))
|
|
1110
|
+
return;
|
|
1111
|
+
if (process.platform === "darwin") {
|
|
1112
|
+
if (await run("open", ["-a", "Google Chrome", url]))
|
|
1113
|
+
return;
|
|
1114
|
+
await run("open", [url]);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (process.platform === "win32") {
|
|
1118
|
+
if (await run("cmd", ["/c", "start", "", "chrome", url]))
|
|
1119
|
+
return;
|
|
1120
|
+
await run("cmd", ["/c", "start", "", url]);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
if (await run("google-chrome", [url], true))
|
|
1124
|
+
return;
|
|
1125
|
+
await run("xdg-open", [url], true);
|
|
1126
|
+
}
|
|
1037
1127
|
|
|
1038
1128
|
// packages/cli/dist/workspace-fs.js
|
|
1039
1129
|
import { lstat, readdir, readFile as readFile2, realpath } from "node:fs/promises";
|
|
1040
1130
|
import { homedir as homedir2 } from "node:os";
|
|
1041
|
-
import { basename, delimiter, dirname as dirname2, isAbsolute, join as join2, posix, relative, resolve, sep
|
|
1131
|
+
import { basename, delimiter, dirname as dirname2, isAbsolute, join as join2, posix, relative, resolve, sep, win32 } from "node:path";
|
|
1042
1132
|
var MAX_MARKDOWN_BYTES = 5 * 1024 * 1024;
|
|
1043
1133
|
var SKIP_SCAN_DIRS = /* @__PURE__ */ new Set([
|
|
1044
1134
|
".git",
|
|
@@ -1067,13 +1157,13 @@ function insideOrEqual(root, target) {
|
|
|
1067
1157
|
if (root === target)
|
|
1068
1158
|
return true;
|
|
1069
1159
|
const rel = relative(root, target);
|
|
1070
|
-
return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." +
|
|
1160
|
+
return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." + sep));
|
|
1071
1161
|
}
|
|
1072
1162
|
function hasHiddenSegment(root, target) {
|
|
1073
1163
|
const rel = relative(root, target);
|
|
1074
1164
|
if (!rel || rel === ".")
|
|
1075
1165
|
return false;
|
|
1076
|
-
return rel.split(
|
|
1166
|
+
return rel.split(sep).some((part) => part.startsWith("."));
|
|
1077
1167
|
}
|
|
1078
1168
|
async function findProjectRoot(filePath) {
|
|
1079
1169
|
const home = await realpath(homedir2()).catch(() => homedir2());
|
|
@@ -1205,13 +1295,18 @@ async function fileSource(file, log = () => {
|
|
|
1205
1295
|
log(`\u5DF2\u5199\u56DE ${path}`);
|
|
1206
1296
|
},
|
|
1207
1297
|
watch(onChange) {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1298
|
+
try {
|
|
1299
|
+
const watcher = watch(dir, (_, changed) => {
|
|
1300
|
+
if (!changed || changed === basename2(path))
|
|
1301
|
+
onChange();
|
|
1302
|
+
});
|
|
1303
|
+
watcher.on("error", () => {
|
|
1304
|
+
});
|
|
1305
|
+
return () => watcher.close();
|
|
1306
|
+
} catch {
|
|
1307
|
+
return () => {
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1215
1310
|
},
|
|
1216
1311
|
readView: () => readDiskViewState(path),
|
|
1217
1312
|
writeView: (state) => writeDiskViewState(path, state)
|
|
@@ -1225,37 +1320,12 @@ function within(root, rel, allowAbsoluteInRoot = false) {
|
|
|
1225
1320
|
return null;
|
|
1226
1321
|
}
|
|
1227
1322
|
const resolvedRoot = resolve2(root);
|
|
1228
|
-
const base = resolvedRoot.endsWith(
|
|
1323
|
+
const base = resolvedRoot.endsWith(sep2) ? resolvedRoot : resolvedRoot + sep2;
|
|
1229
1324
|
const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? normalize(decoded) : normalize(join3(resolvedRoot, decoded));
|
|
1230
1325
|
return full.startsWith(base) ? full : null;
|
|
1231
1326
|
}
|
|
1232
|
-
async function openBrowserWindow(url) {
|
|
1233
|
-
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url))
|
|
1234
|
-
return;
|
|
1235
|
-
const run = (cmd, args) => new Promise((done) => {
|
|
1236
|
-
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
1237
|
-
child.on("error", () => done(false));
|
|
1238
|
-
child.on("exit", (code) => done(code === 0));
|
|
1239
|
-
child.unref();
|
|
1240
|
-
});
|
|
1241
|
-
if (process.platform === "darwin") {
|
|
1242
|
-
if (await run("open", ["-a", "Google Chrome", url]))
|
|
1243
|
-
return;
|
|
1244
|
-
await run("open", [url]);
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
if (process.platform === "win32") {
|
|
1248
|
-
if (await run("cmd", ["/c", "start", "", "chrome", url]))
|
|
1249
|
-
return;
|
|
1250
|
-
await run("cmd", ["/c", "start", "", url]);
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
if (await run("google-chrome", [url]))
|
|
1254
|
-
return;
|
|
1255
|
-
await run("xdg-open", [url]);
|
|
1256
|
-
}
|
|
1257
1327
|
async function serve({ source: initialSource, webRoot: webRoot2, port = 4377, host = "127.0.0.1", log = () => {
|
|
1258
|
-
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false,
|
|
1328
|
+
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, workspaceRoots = [], confineToWorkspaceRoots = false, openSource = (path) => fileSource(path, log), allowPurchase = true }) {
|
|
1259
1329
|
if (sidebar && host !== "127.0.0.1")
|
|
1260
1330
|
throw new Error("The sidebar bridge requires loopback.");
|
|
1261
1331
|
const prefix2 = sidebar ? `/s/${randomBytes(24).toString("hex")}/` : "/";
|
|
@@ -1474,7 +1544,6 @@ data: ${JSON.stringify(data)}
|
|
|
1474
1544
|
if (url.pathname === "/api/capabilities" && req.method === "GET") {
|
|
1475
1545
|
return json2(res, 200, {
|
|
1476
1546
|
purchase: canPurchase,
|
|
1477
|
-
...ideWorkspace && { ideWorkspace: true },
|
|
1478
1547
|
...sidebarAccountNavigation && { accountNavigation: "host" }
|
|
1479
1548
|
});
|
|
1480
1549
|
}
|
|
@@ -1495,6 +1564,8 @@ data: ${JSON.stringify(data)}
|
|
|
1495
1564
|
const { md, baseVersion } = JSON.parse(await readBody2(req));
|
|
1496
1565
|
if (typeof md !== "string")
|
|
1497
1566
|
return json2(res, 400, { error: zh() ? "md \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3002" : "md must be a string." });
|
|
1567
|
+
if (Buffer.byteLength(md) > MAX_MARKDOWN_BYTES)
|
|
1568
|
+
return json2(res, 413, { error: zh() ? "\u6587\u6863\u8FC7\u5927\u3002" : "Document too large." });
|
|
1498
1569
|
if (!hasAccess(await license?.state() ?? { pro: false }))
|
|
1499
1570
|
return json2(res, 403, { error: "Inkmap trial expired" });
|
|
1500
1571
|
return await serialized(async () => {
|
|
@@ -1526,7 +1597,7 @@ data: ${JSON.stringify(data)}
|
|
|
1526
1597
|
if (!sameOriginWrite())
|
|
1527
1598
|
return json2(res, 403, { error: "forbidden" });
|
|
1528
1599
|
const { event } = JSON.parse(await readBody2(req));
|
|
1529
|
-
if (typeof event === "string" && event)
|
|
1600
|
+
if (typeof event === "string" && /^[a-z][a-z0-9_]{0,39}$/.test(event))
|
|
1530
1601
|
license?.track?.(event);
|
|
1531
1602
|
return json2(res, 200, { ok: true });
|
|
1532
1603
|
}
|
|
@@ -1725,7 +1796,7 @@ async function workspaceFile(ctx, address) {
|
|
|
1725
1796
|
};
|
|
1726
1797
|
const [root, path] = await Promise.all([local(header.cwd), local(file.path)]);
|
|
1727
1798
|
const child = relative3(root, path);
|
|
1728
|
-
if (!child || isAbsolute2(child) || child === ".." || child.startsWith(".." +
|
|
1799
|
+
if (!child || isAbsolute2(child) || child === ".." || child.startsWith(".." + sep3) || !/\.md$/i.test(path)) {
|
|
1729
1800
|
throw new FileUnavailable();
|
|
1730
1801
|
}
|
|
1731
1802
|
return { root, path };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-inkmap",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Inkmap 思维导图 — 在 DeepSeek Harness 中将本地 Markdown 实时渲染为可双向编辑的思维导图 (Markmap) 与 Mermaid 流程图 / Interactive two-way Markdown mind map & Mermaid flowchart editor for DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "./icon.svg",
|