@vibe-lark/larkpal 0.1.86 → 0.1.87
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/account-id-BM1T6029-BzQ_cMoi.mjs +1 -0
- package/dist/activation-context--5yu1dPF-XV0Y0pTy.mjs +1 -0
- package/dist/anthropic-CFZUCb1w.mjs +39 -0
- package/dist/assistant-visible-text-DuFWokAt-BOJV_zwc.mjs +9 -0
- package/dist/azure-openai-responses-BEuiMaF-.mjs +1 -0
- package/dist/boundary-file-read-BSd9MXPy-gnNVhPKT.mjs +1 -0
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-BM97qA_M.mjs +1 -0
- package/dist/build-Bkj0hOS2.mjs +3 -0
- package/dist/bundled-compat-BpaDaAAu-DJtrIX6i.mjs +27 -0
- package/dist/bundled-dir-U738ay4K-BxbzrJOo.mjs +1 -0
- package/dist/call-DimWbpgJ-B4pv55RH.mjs +20 -0
- package/dist/channel-bootstrap.runtime-BVclcGv1-CEZ0-JP9.mjs +1 -0
- package/dist/channel-bootstrap.runtime-Cwcr38m2-Dt6QlQkX.mjs +1 -0
- package/dist/chunk-DHbaKqs-.mjs +1 -0
- package/dist/cli.mjs +7 -92
- package/dist/command-format-LSnUCVVF-Dn4h9IOh.mjs +16 -0
- package/dist/config-Bim2pi8a-03N-28sw.mjs +1 -0
- package/dist/delivery-context.shared-j5hC5qb1-BSLQG47q.mjs +1 -0
- package/dist/diagnostic-ClMwNnUA-BMKvPQJT.mjs +1 -0
- package/dist/dist-J5UB83Ws.mjs +601 -0
- package/dist/dist-coestTs9.mjs +5 -0
- package/dist/env-api-keys-Cuz5irWW.mjs +1 -0
- package/dist/event-stream-B7Ei41Bu.mjs +1 -0
- package/dist/facade-loader-DFzIYYt_-4bzFvy-b.mjs +1 -0
- package/dist/from-Ba69_5cR.mjs +14 -0
- package/dist/gateway-method-policy-C7rf0SeV-CTJcMQCE.mjs +1 -0
- package/dist/github-copilot-headers-BfhryVuU.mjs +1 -0
- package/dist/google-ABo-1guT.mjs +1 -0
- package/dist/google-gemini-cli-CGlN1zUA.mjs +2 -0
- package/dist/google-shared-C60sNhwd.mjs +301 -0
- package/dist/google-vertex-De0nAItu.mjs +1 -0
- package/dist/hash-Dw-N8Y9l.mjs +1 -0
- package/dist/headers-Bpsp70B9.mjs +1 -0
- package/dist/home-dir-C44RaPME-B5iLWwCq.mjs +1 -0
- package/dist/ids-BPsM98Uu-CJBJAeVC.mjs +1 -0
- package/dist/image-2w3cApg7-CrpUMCvm.mjs +3 -0
- package/dist/interactive-init-C5MFL5MW.mjs +8 -0
- package/dist/io-CH2g3vsv-JJtUIa_U.mjs +10 -0
- package/dist/jiti-loader-cache-Bat69wam-DNIteTtO.mjs +9 -0
- package/dist/json-file-BQRNuxmK-hRjIgOXI.mjs +1 -0
- package/dist/json-parse-BESd8UAM.mjs +3 -0
- package/dist/jws-YaZ38F_i.mjs +12 -0
- package/dist/lark-cli-provider-BLMxH6CN.mjs +4 -0
- package/dist/lark-logger-xpMKNNtY.mjs +1 -0
- package/dist/live-smoke-DpURW676.mjs +33 -0
- package/dist/load-context-mb7uvLSn-3xYwSnOZ.mjs +1 -0
- package/dist/loader-708jrx4Y-BbJRXNlQ.mjs +4 -0
- package/dist/main.mjs +153 -74571
- package/dist/manifest-registry-_hxKCS2K-OL8KK_o4.mjs +15 -0
- package/dist/mcp-server.mjs +4 -527
- package/dist/message-channel-Bk_YHfQg-n2Hw2Y0L.mjs +1 -0
- package/dist/message-channel-core-DTA--Gjh-CIh10vfo.mjs +1 -0
- package/dist/message.config.runtime-K-k4XOyq-F_h0Cgkl.mjs +1 -0
- package/dist/message.gateway.runtime-DqHOHRTQ-ge4c5p4s.mjs +1 -0
- package/dist/mistral-DyL3Zo1b.mjs +7 -0
- package/dist/model-auth-env-oyg2Hexc-DJbt9J3o.mjs +1 -0
- package/dist/models-config-BmpSQJQF-BL6S5qAo.mjs +1 -0
- package/dist/models-config.runtime-SOhLEw-f.mjs +1 -0
- package/dist/multipart-parser-B9dwXBqu.mjs +2 -0
- package/dist/oauth-25y2wc7K.mjs +75 -0
- package/dist/openai-C-rgGb7X.mjs +16 -0
- package/dist/openai-codex-responses-BbyAPsP1.mjs +7 -0
- package/dist/openai-completions-Bu5qvQzb.mjs +5 -0
- package/dist/openai-responses-pIdwQBc4.mjs +1 -0
- package/dist/openai-responses-shared-DqW1JSux.mjs +10 -0
- package/dist/paths-D6msg0S1-BO4XgM1u.mjs +1 -0
- package/dist/paths-D92DjaZ--DdtJ-zYp.mjs +1 -0
- package/dist/pi-model-discovery-Bd0TWzo8-DvSM0eWu.mjs +1 -0
- package/dist/pi-model-discovery-runtime-PrjWOmsV.mjs +1 -0
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-WPxU5oNX.mjs +2 -0
- package/dist/plugin-auto-enable-DdH3n9V8-Dr_bUXkG.mjs +1 -0
- package/dist/process-scoped-map-B2cWkYET-Co-i-MXA.mjs +1 -0
- package/dist/provider-discovery.runtime-DY0VWQ81.mjs +1 -0
- package/dist/provider-model-compat-CFqcq0it-BUwZENrz.mjs +1 -0
- package/dist/provider-runtime-C8rljsNs-BDvu6FW3.mjs +1 -0
- package/dist/provider-runtime-CT50mNIX-DImw7ZZu.mjs +79 -0
- package/dist/provider-stream-COLujAAo-Dpq1DSIk.mjs +248 -0
- package/dist/providers.runtime-Ba7tOlq7-B4t6ywCr.mjs +1 -0
- package/dist/public-surface-loader-BVl0NQAE-TfJ3izj1.mjs +1 -0
- package/dist/resolve-C33B7eeu-DZM_z6Wr.mjs +1 -0
- package/dist/runtime-Cym-fqI8-1GOIuRRQ.mjs +1 -0
- package/dist/runtime-channel-state-CohMybAh-BBzhl07Q.mjs +1 -0
- package/dist/runtime-snapshot-C54O1-gI-DxusscPf.mjs +1 -0
- package/dist/runtime-state-IBOIXKOx-Cw1GA1td.mjs +1 -0
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BsYE2gOd.mjs +1 -0
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-P6MKP9gQ.mjs +1 -0
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-5VoyjouO.mjs +1 -0
- package/dist/session-archive.runtime-B52_5vs4-cU2tYbBz.mjs +1 -0
- package/dist/session-key-Cn2QoOyX-QZeYmbxd.mjs +1 -0
- package/dist/session-transcript-files.fs-DEeFXruQ-CXIAFSsr.mjs +1 -0
- package/dist/src-CCDx_C-U.mjs +3 -0
- package/dist/src-DACmA9V6.mjs +5 -0
- package/dist/subagent-announce-L5WsQatW--rMn240x.mjs +2 -0
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-DNfNHsls.mjs +1 -0
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-XYS1_qwl.mjs +1 -0
- package/dist/subagent-system-prompt-C1qnN--K-CsU4f97T.mjs +23 -0
- package/dist/target-parsing-loaded-DKkb6jJY-B830OA1a.mjs +12 -0
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-B2Hj2k8C.mjs +16 -0
- package/dist/task-registry-delivery-runtime-ragbeVx5-Bdvo2Q5u.mjs +1 -0
- package/dist/thinking-Bh-7MqXz-uApNUe6g.mjs +1 -0
- package/dist/transcript-E_-ISOkD-VTwb782D.mjs +5 -0
- package/dist/transcript.runtime-BqhvZZdl-B4E0TiX5.mjs +1 -0
- package/dist/transform-messages-BTA3xbAI.mjs +1 -0
- package/dist/web-provider-public-artifacts-BlpRwIUS-DbVhDOrY.mjs +1 -0
- package/dist/web-search-providers.runtime--0aUtC3b-Bjh4Bmrz.mjs +1 -0
- package/package.json +2 -3
- package/dist/account-id-BM1T6029-DYjVxojW.mjs +0 -46
- package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +0 -172
- package/dist/anthropic-TH8ERTXK.mjs +0 -5962
- package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +0 -596
- package/dist/azure-openai-responses-Bt_Ag9Er.mjs +0 -166
- package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +0 -594
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +0 -60
- package/dist/build-DgTrEpge.mjs +0 -3333
- package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +0 -5216
- package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +0 -258
- package/dist/call-DimWbpgJ-ColD4W-y.mjs +0 -9993
- package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +0 -2
- package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +0 -33
- package/dist/chunk-D6SyT4dJ.mjs +0 -36
- package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +0 -685
- package/dist/config-Bim2pi8a-BQUdfiEi.mjs +0 -9
- package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +0 -72
- package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +0 -140
- package/dist/dist-CEGw8-2W.mjs +0 -429
- package/dist/dist-DD2aJ2UL.mjs +0 -125135
- package/dist/env-api-keys-BVvSg7T2.mjs +0 -68
- package/dist/event-stream-xaQWmyas.mjs +0 -15226
- package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +0 -194
- package/dist/from-DF7cl2wz.mjs +0 -3842
- package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +0 -28
- package/dist/github-copilot-headers-DjqWtUoP.mjs +0 -22
- package/dist/google-C2pVrgBZ.mjs +0 -336
- package/dist/google-gemini-cli-BBxgS5Ho.mjs +0 -623
- package/dist/google-shared-BsWgwEk1.mjs +0 -22791
- package/dist/google-vertex-BsVLJrrC.mjs +0 -358
- package/dist/hash-DAFtW_W7.mjs +0 -16
- package/dist/headers-R3HdCbAE.mjs +0 -8
- package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +0 -93
- package/dist/ids-BPsM98Uu-CwuxvUai.mjs +0 -77
- package/dist/image-2w3cApg7-CxpHvoB5.mjs +0 -207
- package/dist/interactive-init-BXQBalNr.mjs +0 -450
- package/dist/io-CH2g3vsv-BOGlLlB8.mjs +0 -26218
- package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +0 -5049
- package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +0 -108
- package/dist/json-parse-v_HIJjjI.mjs +0 -381
- package/dist/jws-GFcTvvVT.mjs +0 -2291
- package/dist/lark-cli-provider-BARgbbmo.mjs +0 -554
- package/dist/lark-logger-D7_pEVQc.mjs +0 -143
- package/dist/live-smoke-BhkBOcH9.mjs +0 -7135
- package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +0 -29
- package/dist/loader-708jrx4Y-BOswuvpe.mjs +0 -5053
- package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +0 -3512
- package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +0 -50
- package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +0 -29
- package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +0 -2
- package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +0 -2
- package/dist/mistral-CaR4DiLu.mjs +0 -28657
- package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +0 -1306
- package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +0 -1282
- package/dist/models-config.runtime-BsU_22xk.mjs +0 -2
- package/dist/multipart-parser-DedmaB5g.mjs +0 -294
- package/dist/oauth-DOJeGfcE.mjs +0 -6392
- package/dist/openai-BDtIh3Ja.mjs +0 -6693
- package/dist/openai-codex-responses-C5EORu31.mjs +0 -664
- package/dist/openai-completions-CR_cS6gX.mjs +0 -669
- package/dist/openai-responses-oGxwZyuC.mjs +0 -184
- package/dist/openai-responses-shared-BixMSDZE.mjs +0 -398
- package/dist/paths-D6msg0S1-C2lYuisN.mjs +0 -189
- package/dist/paths-D92DjaZ--CTOESW2b.mjs +0 -192
- package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +0 -227
- package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +0 -2
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +0 -399
- package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +0 -1456
- package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +0 -61
- package/dist/provider-discovery.runtime-BPzz1PFj.mjs +0 -58
- package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +0 -118
- package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +0 -2
- package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +0 -573
- package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +0 -35449
- package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +0 -219
- package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +0 -117
- package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +0 -1041
- package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +0 -120
- package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +0 -19
- package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +0 -677
- package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +0 -10
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +0 -39
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +0 -2
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +0 -2
- package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +0 -2
- package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +0 -82
- package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +0 -147
- package/dist/src-BgCX0MLG.mjs +0 -813
- package/dist/src-DYbqlAqf.mjs +0 -1177
- package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +0 -344
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +0 -28
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +0 -211
- package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +0 -3061
- package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +0 -1002
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +0 -2950
- package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +0 -2
- package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +0 -2
- package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +0 -2019
- package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +0 -2
- package/dist/transform-messages-DbhIzTxq.mjs +0 -207
- package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +0 -295
- package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +0 -200
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/json-file-BQRNuxmK.js
|
|
5
|
-
const JSON_FILE_MODE = 384;
|
|
6
|
-
const JSON_DIR_MODE = 448;
|
|
7
|
-
function trySetSecureMode(pathname) {
|
|
8
|
-
try {
|
|
9
|
-
fs.chmodSync(pathname, JSON_FILE_MODE);
|
|
10
|
-
} catch {}
|
|
11
|
-
}
|
|
12
|
-
function trySyncDirectory(pathname) {
|
|
13
|
-
let fd;
|
|
14
|
-
try {
|
|
15
|
-
fd = fs.openSync(path.dirname(pathname), "r");
|
|
16
|
-
fs.fsyncSync(fd);
|
|
17
|
-
} catch {} finally {
|
|
18
|
-
if (fd !== void 0) try {
|
|
19
|
-
fs.closeSync(fd);
|
|
20
|
-
} catch {}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function readSymlinkTargetPath(linkPath) {
|
|
24
|
-
const target = fs.readlinkSync(linkPath);
|
|
25
|
-
return path.resolve(path.dirname(linkPath), target);
|
|
26
|
-
}
|
|
27
|
-
function resolveJsonWriteTarget(pathname) {
|
|
28
|
-
let currentPath = pathname;
|
|
29
|
-
const visited = /* @__PURE__ */ new Set();
|
|
30
|
-
let followsSymlink = false;
|
|
31
|
-
for (;;) {
|
|
32
|
-
let stat;
|
|
33
|
-
try {
|
|
34
|
-
stat = fs.lstatSync(currentPath);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (error.code !== "ENOENT") throw error;
|
|
37
|
-
return {
|
|
38
|
-
targetPath: currentPath,
|
|
39
|
-
followsSymlink
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (!stat.isSymbolicLink()) return {
|
|
43
|
-
targetPath: currentPath,
|
|
44
|
-
followsSymlink
|
|
45
|
-
};
|
|
46
|
-
if (visited.has(currentPath)) {
|
|
47
|
-
const err = /* @__PURE__ */ new Error(`Too many symlink levels while resolving ${pathname}`);
|
|
48
|
-
err.code = "ELOOP";
|
|
49
|
-
throw err;
|
|
50
|
-
}
|
|
51
|
-
visited.add(currentPath);
|
|
52
|
-
followsSymlink = true;
|
|
53
|
-
currentPath = readSymlinkTargetPath(currentPath);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function renameJsonFileWithFallback(tmpPath, pathname) {
|
|
57
|
-
try {
|
|
58
|
-
fs.renameSync(tmpPath, pathname);
|
|
59
|
-
return;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
const code = error.code;
|
|
62
|
-
if (code === "EPERM" || code === "EEXIST") {
|
|
63
|
-
fs.copyFileSync(tmpPath, pathname);
|
|
64
|
-
fs.rmSync(tmpPath, { force: true });
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function writeTempJsonFile(pathname, payload) {
|
|
71
|
-
const fd = fs.openSync(pathname, "w", JSON_FILE_MODE);
|
|
72
|
-
try {
|
|
73
|
-
fs.writeFileSync(fd, payload, "utf8");
|
|
74
|
-
fs.fsyncSync(fd);
|
|
75
|
-
} finally {
|
|
76
|
-
fs.closeSync(fd);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function loadJsonFile(pathname) {
|
|
80
|
-
try {
|
|
81
|
-
const raw = fs.readFileSync(pathname, "utf8");
|
|
82
|
-
return JSON.parse(raw);
|
|
83
|
-
} catch {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function saveJsonFile(pathname, data) {
|
|
88
|
-
const { targetPath, followsSymlink } = resolveJsonWriteTarget(pathname);
|
|
89
|
-
const tmpPath = `${targetPath}.${randomUUID()}.tmp`;
|
|
90
|
-
const payload = `${JSON.stringify(data, null, 2)}\n`;
|
|
91
|
-
if (!followsSymlink) fs.mkdirSync(path.dirname(targetPath), {
|
|
92
|
-
recursive: true,
|
|
93
|
-
mode: JSON_DIR_MODE
|
|
94
|
-
});
|
|
95
|
-
try {
|
|
96
|
-
writeTempJsonFile(tmpPath, payload);
|
|
97
|
-
trySetSecureMode(tmpPath);
|
|
98
|
-
renameJsonFileWithFallback(tmpPath, targetPath);
|
|
99
|
-
trySetSecureMode(targetPath);
|
|
100
|
-
trySyncDirectory(targetPath);
|
|
101
|
-
} finally {
|
|
102
|
-
try {
|
|
103
|
-
fs.rmSync(tmpPath, { force: true });
|
|
104
|
-
} catch {}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
export { saveJsonFile as n, loadJsonFile as t };
|
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
import { t as __commonJSMin } from "./chunk-D6SyT4dJ.mjs";
|
|
2
|
-
//#region node_modules/.pnpm/partial-json@0.1.7/node_modules/partial-json/dist/options.js
|
|
3
|
-
var require_options = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
|
-
/**
|
|
5
|
-
* Sometimes you don't allow every type to be partially parsed.
|
|
6
|
-
* For example, you may not want a partial number because it may increase its size gradually before it's complete.
|
|
7
|
-
* In this case, you can use the `Allow` object to control what types you allow to be partially parsed.
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.Allow = exports.ALL = exports.COLLECTION = exports.ATOM = exports.SPECIAL = exports.INF = exports._INFINITY = exports.INFINITY = exports.NAN = exports.BOOL = exports.NULL = exports.OBJ = exports.ARR = exports.NUM = exports.STR = void 0;
|
|
12
|
-
/**
|
|
13
|
-
* allow partial strings like `"hello \u12` to be parsed as `"hello "`
|
|
14
|
-
*/
|
|
15
|
-
exports.STR = 1;
|
|
16
|
-
/**
|
|
17
|
-
* allow partial numbers like `123.` to be parsed as `123`
|
|
18
|
-
*/
|
|
19
|
-
exports.NUM = 2;
|
|
20
|
-
/**
|
|
21
|
-
* allow partial arrays like `[1, 2,` to be parsed as `[1, 2]`
|
|
22
|
-
*/
|
|
23
|
-
exports.ARR = 4;
|
|
24
|
-
/**
|
|
25
|
-
* allow partial objects like `{"a": 1, "b":` to be parsed as `{"a": 1}`
|
|
26
|
-
*/
|
|
27
|
-
exports.OBJ = 8;
|
|
28
|
-
/**
|
|
29
|
-
* allow `nu` to be parsed as `null`
|
|
30
|
-
*/
|
|
31
|
-
exports.NULL = 16;
|
|
32
|
-
/**
|
|
33
|
-
* allow `tr` to be parsed as `true`, and `fa` to be parsed as `false`
|
|
34
|
-
*/
|
|
35
|
-
exports.BOOL = 32;
|
|
36
|
-
/**
|
|
37
|
-
* allow `Na` to be parsed as `NaN`
|
|
38
|
-
*/
|
|
39
|
-
exports.NAN = 64;
|
|
40
|
-
/**
|
|
41
|
-
* allow `Inf` to be parsed as `Infinity`
|
|
42
|
-
*/
|
|
43
|
-
exports.INFINITY = 128;
|
|
44
|
-
/**
|
|
45
|
-
* allow `-Inf` to be parsed as `-Infinity`
|
|
46
|
-
*/
|
|
47
|
-
exports._INFINITY = 256;
|
|
48
|
-
exports.INF = exports.INFINITY | exports._INFINITY;
|
|
49
|
-
exports.SPECIAL = exports.NULL | exports.BOOL | exports.INF | exports.NAN;
|
|
50
|
-
exports.ATOM = exports.STR | exports.NUM | exports.SPECIAL;
|
|
51
|
-
exports.COLLECTION = exports.ARR | exports.OBJ;
|
|
52
|
-
exports.ALL = exports.ATOM | exports.COLLECTION;
|
|
53
|
-
/**
|
|
54
|
-
* Control what types you allow to be partially parsed.
|
|
55
|
-
* The default is to allow all types to be partially parsed, which in most casees is the best option.
|
|
56
|
-
* @example
|
|
57
|
-
* If you don't want to allow partial objects, you can use the following code:
|
|
58
|
-
* ```ts
|
|
59
|
-
* import { Allow, parse } from "partial-json";
|
|
60
|
-
* parse(`[{"a": 1, "b": 2}, {"a": 3,`, Allow.ARR); // [ { a: 1, b: 2 } ]
|
|
61
|
-
* ```
|
|
62
|
-
* Or you can use `~` to disallow a type:
|
|
63
|
-
* ```ts
|
|
64
|
-
* parse(`[{"a": 1, "b": 2}, {"a": 3,`, ~Allow.OBJ); // [ { a: 1, b: 2 } ]
|
|
65
|
-
* ```
|
|
66
|
-
* @example
|
|
67
|
-
* If you don't want to allow partial strings, you can use the following code:
|
|
68
|
-
* ```ts
|
|
69
|
-
* import { Allow, parse } from "partial-json";
|
|
70
|
-
* parse(`["complete string", "incompl`, ~Allow.STR); // [ 'complete string' ]
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
exports.Allow = {
|
|
74
|
-
STR: exports.STR,
|
|
75
|
-
NUM: exports.NUM,
|
|
76
|
-
ARR: exports.ARR,
|
|
77
|
-
OBJ: exports.OBJ,
|
|
78
|
-
NULL: exports.NULL,
|
|
79
|
-
BOOL: exports.BOOL,
|
|
80
|
-
NAN: exports.NAN,
|
|
81
|
-
INFINITY: exports.INFINITY,
|
|
82
|
-
_INFINITY: exports._INFINITY,
|
|
83
|
-
INF: exports.INF,
|
|
84
|
-
SPECIAL: exports.SPECIAL,
|
|
85
|
-
ATOM: exports.ATOM,
|
|
86
|
-
COLLECTION: exports.COLLECTION,
|
|
87
|
-
ALL: exports.ALL
|
|
88
|
-
};
|
|
89
|
-
exports.default = exports.Allow;
|
|
90
|
-
}));
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region node_modules/.pnpm/@mariozechner+pi-ai@0.69.0_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__ws@8.21.0_zod@4.3.6/node_modules/@mariozechner/pi-ai/dist/utils/json-parse.js
|
|
93
|
-
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
94
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
95
|
-
if (k2 === void 0) k2 = k;
|
|
96
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
97
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
98
|
-
enumerable: true,
|
|
99
|
-
get: function() {
|
|
100
|
-
return m[k];
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
Object.defineProperty(o, k2, desc);
|
|
104
|
-
}) : (function(o, m, k, k2) {
|
|
105
|
-
if (k2 === void 0) k2 = k;
|
|
106
|
-
o[k2] = m[k];
|
|
107
|
-
}));
|
|
108
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
|
|
109
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
110
|
-
};
|
|
111
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
112
|
-
exports.Allow = exports.MalformedJSON = exports.PartialJSON = exports.parseJSON = exports.parse = void 0;
|
|
113
|
-
const options_1 = require_options();
|
|
114
|
-
Object.defineProperty(exports, "Allow", {
|
|
115
|
-
enumerable: true,
|
|
116
|
-
get: function() {
|
|
117
|
-
return options_1.Allow;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
__exportStar(require_options(), exports);
|
|
121
|
-
var PartialJSON = class extends Error {};
|
|
122
|
-
exports.PartialJSON = PartialJSON;
|
|
123
|
-
var MalformedJSON = class extends Error {};
|
|
124
|
-
exports.MalformedJSON = MalformedJSON;
|
|
125
|
-
/**
|
|
126
|
-
* Parse incomplete JSON
|
|
127
|
-
* @param {string} jsonString Partial JSON to be parsed
|
|
128
|
-
* @param {number} allowPartial Specify what types are allowed to be partial, see {@link Allow} for details
|
|
129
|
-
* @returns The parsed JSON
|
|
130
|
-
* @throws {PartialJSON} If the JSON is incomplete (related to the `allow` parameter)
|
|
131
|
-
* @throws {MalformedJSON} If the JSON is malformed
|
|
132
|
-
*/
|
|
133
|
-
function parseJSON(jsonString, allowPartial = options_1.Allow.ALL) {
|
|
134
|
-
if (typeof jsonString !== "string") throw new TypeError(`expecting str, got ${typeof jsonString}`);
|
|
135
|
-
if (!jsonString.trim()) throw new Error(`${jsonString} is empty`);
|
|
136
|
-
return _parseJSON(jsonString.trim(), allowPartial);
|
|
137
|
-
}
|
|
138
|
-
exports.parseJSON = parseJSON;
|
|
139
|
-
const _parseJSON = (jsonString, allow) => {
|
|
140
|
-
const length = jsonString.length;
|
|
141
|
-
let index = 0;
|
|
142
|
-
const markPartialJSON = (msg) => {
|
|
143
|
-
throw new PartialJSON(`${msg} at position ${index}`);
|
|
144
|
-
};
|
|
145
|
-
const throwMalformedError = (msg) => {
|
|
146
|
-
throw new MalformedJSON(`${msg} at position ${index}`);
|
|
147
|
-
};
|
|
148
|
-
const parseAny = () => {
|
|
149
|
-
skipBlank();
|
|
150
|
-
if (index >= length) markPartialJSON("Unexpected end of input");
|
|
151
|
-
if (jsonString[index] === "\"") return parseStr();
|
|
152
|
-
if (jsonString[index] === "{") return parseObj();
|
|
153
|
-
if (jsonString[index] === "[") return parseArr();
|
|
154
|
-
if (jsonString.substring(index, index + 4) === "null" || options_1.Allow.NULL & allow && length - index < 4 && "null".startsWith(jsonString.substring(index))) {
|
|
155
|
-
index += 4;
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
if (jsonString.substring(index, index + 4) === "true" || options_1.Allow.BOOL & allow && length - index < 4 && "true".startsWith(jsonString.substring(index))) {
|
|
159
|
-
index += 4;
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
if (jsonString.substring(index, index + 5) === "false" || options_1.Allow.BOOL & allow && length - index < 5 && "false".startsWith(jsonString.substring(index))) {
|
|
163
|
-
index += 5;
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
if (jsonString.substring(index, index + 8) === "Infinity" || options_1.Allow.INFINITY & allow && length - index < 8 && "Infinity".startsWith(jsonString.substring(index))) {
|
|
167
|
-
index += 8;
|
|
168
|
-
return Infinity;
|
|
169
|
-
}
|
|
170
|
-
if (jsonString.substring(index, index + 9) === "-Infinity" || options_1.Allow._INFINITY & allow && 1 < length - index && length - index < 9 && "-Infinity".startsWith(jsonString.substring(index))) {
|
|
171
|
-
index += 9;
|
|
172
|
-
return -Infinity;
|
|
173
|
-
}
|
|
174
|
-
if (jsonString.substring(index, index + 3) === "NaN" || options_1.Allow.NAN & allow && length - index < 3 && "NaN".startsWith(jsonString.substring(index))) {
|
|
175
|
-
index += 3;
|
|
176
|
-
return NaN;
|
|
177
|
-
}
|
|
178
|
-
return parseNum();
|
|
179
|
-
};
|
|
180
|
-
const parseStr = () => {
|
|
181
|
-
const start = index;
|
|
182
|
-
let escape = false;
|
|
183
|
-
index++;
|
|
184
|
-
while (index < length && (jsonString[index] !== "\"" || escape && jsonString[index - 1] === "\\")) {
|
|
185
|
-
escape = jsonString[index] === "\\" ? !escape : false;
|
|
186
|
-
index++;
|
|
187
|
-
}
|
|
188
|
-
if (jsonString.charAt(index) == "\"") try {
|
|
189
|
-
return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
|
|
190
|
-
} catch (e) {
|
|
191
|
-
throwMalformedError(String(e));
|
|
192
|
-
}
|
|
193
|
-
else if (options_1.Allow.STR & allow) try {
|
|
194
|
-
return JSON.parse(jsonString.substring(start, index - Number(escape)) + "\"");
|
|
195
|
-
} catch (e) {
|
|
196
|
-
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + "\"");
|
|
197
|
-
}
|
|
198
|
-
markPartialJSON("Unterminated string literal");
|
|
199
|
-
};
|
|
200
|
-
const parseObj = () => {
|
|
201
|
-
index++;
|
|
202
|
-
skipBlank();
|
|
203
|
-
const obj = {};
|
|
204
|
-
try {
|
|
205
|
-
while (jsonString[index] !== "}") {
|
|
206
|
-
skipBlank();
|
|
207
|
-
if (index >= length && options_1.Allow.OBJ & allow) return obj;
|
|
208
|
-
const key = parseStr();
|
|
209
|
-
skipBlank();
|
|
210
|
-
index++;
|
|
211
|
-
try {
|
|
212
|
-
obj[key] = parseAny();
|
|
213
|
-
} catch (e) {
|
|
214
|
-
if (options_1.Allow.OBJ & allow) return obj;
|
|
215
|
-
else throw e;
|
|
216
|
-
}
|
|
217
|
-
skipBlank();
|
|
218
|
-
if (jsonString[index] === ",") index++;
|
|
219
|
-
}
|
|
220
|
-
} catch (e) {
|
|
221
|
-
if (options_1.Allow.OBJ & allow) return obj;
|
|
222
|
-
else markPartialJSON("Expected '}' at end of object");
|
|
223
|
-
}
|
|
224
|
-
index++;
|
|
225
|
-
return obj;
|
|
226
|
-
};
|
|
227
|
-
const parseArr = () => {
|
|
228
|
-
index++;
|
|
229
|
-
const arr = [];
|
|
230
|
-
try {
|
|
231
|
-
while (jsonString[index] !== "]") {
|
|
232
|
-
arr.push(parseAny());
|
|
233
|
-
skipBlank();
|
|
234
|
-
if (jsonString[index] === ",") index++;
|
|
235
|
-
}
|
|
236
|
-
} catch (e) {
|
|
237
|
-
if (options_1.Allow.ARR & allow) return arr;
|
|
238
|
-
markPartialJSON("Expected ']' at end of array");
|
|
239
|
-
}
|
|
240
|
-
index++;
|
|
241
|
-
return arr;
|
|
242
|
-
};
|
|
243
|
-
const parseNum = () => {
|
|
244
|
-
if (index === 0) {
|
|
245
|
-
if (jsonString === "-") throwMalformedError("Not sure what '-' is");
|
|
246
|
-
try {
|
|
247
|
-
return JSON.parse(jsonString);
|
|
248
|
-
} catch (e) {
|
|
249
|
-
if (options_1.Allow.NUM & allow) try {
|
|
250
|
-
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
|
|
251
|
-
} catch (e) {}
|
|
252
|
-
throwMalformedError(String(e));
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
const start = index;
|
|
256
|
-
if (jsonString[index] === "-") index++;
|
|
257
|
-
while (jsonString[index] && ",]}".indexOf(jsonString[index]) === -1) index++;
|
|
258
|
-
if (index == length && !(options_1.Allow.NUM & allow)) markPartialJSON("Unterminated number literal");
|
|
259
|
-
try {
|
|
260
|
-
return JSON.parse(jsonString.substring(start, index));
|
|
261
|
-
} catch (e) {
|
|
262
|
-
if (jsonString.substring(start, index) === "-") markPartialJSON("Not sure what '-' is");
|
|
263
|
-
try {
|
|
264
|
-
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("e")));
|
|
265
|
-
} catch (e) {
|
|
266
|
-
throwMalformedError(String(e));
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
const skipBlank = () => {
|
|
271
|
-
while (index < length && " \n\r ".includes(jsonString[index])) index++;
|
|
272
|
-
};
|
|
273
|
-
return parseAny();
|
|
274
|
-
};
|
|
275
|
-
exports.parse = parseJSON;
|
|
276
|
-
})))();
|
|
277
|
-
const VALID_JSON_ESCAPES = new Set([
|
|
278
|
-
"\"",
|
|
279
|
-
"\\",
|
|
280
|
-
"/",
|
|
281
|
-
"b",
|
|
282
|
-
"f",
|
|
283
|
-
"n",
|
|
284
|
-
"r",
|
|
285
|
-
"t",
|
|
286
|
-
"u"
|
|
287
|
-
]);
|
|
288
|
-
function isControlCharacter(char) {
|
|
289
|
-
const codePoint = char.codePointAt(0);
|
|
290
|
-
return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
|
|
291
|
-
}
|
|
292
|
-
function escapeControlCharacter(char) {
|
|
293
|
-
switch (char) {
|
|
294
|
-
case "\b": return "\\b";
|
|
295
|
-
case "\f": return "\\f";
|
|
296
|
-
case "\n": return "\\n";
|
|
297
|
-
case "\r": return "\\r";
|
|
298
|
-
case " ": return "\\t";
|
|
299
|
-
default: return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Repairs malformed JSON string literals by:
|
|
304
|
-
* - escaping raw control characters inside strings
|
|
305
|
-
* - doubling backslashes before invalid escape characters
|
|
306
|
-
*/
|
|
307
|
-
function repairJson(json) {
|
|
308
|
-
let repaired = "";
|
|
309
|
-
let inString = false;
|
|
310
|
-
for (let index = 0; index < json.length; index++) {
|
|
311
|
-
const char = json[index];
|
|
312
|
-
if (!inString) {
|
|
313
|
-
repaired += char;
|
|
314
|
-
if (char === "\"") inString = true;
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
if (char === "\"") {
|
|
318
|
-
repaired += char;
|
|
319
|
-
inString = false;
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
if (char === "\\") {
|
|
323
|
-
const nextChar = json[index + 1];
|
|
324
|
-
if (nextChar === void 0) {
|
|
325
|
-
repaired += "\\\\";
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
if (nextChar === "u") {
|
|
329
|
-
const unicodeDigits = json.slice(index + 2, index + 6);
|
|
330
|
-
if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
|
|
331
|
-
repaired += `\\u${unicodeDigits}`;
|
|
332
|
-
index += 5;
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (VALID_JSON_ESCAPES.has(nextChar)) {
|
|
337
|
-
repaired += `\\${nextChar}`;
|
|
338
|
-
index += 1;
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
repaired += "\\\\";
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
|
|
345
|
-
}
|
|
346
|
-
return repaired;
|
|
347
|
-
}
|
|
348
|
-
function parseJsonWithRepair(json) {
|
|
349
|
-
try {
|
|
350
|
-
return JSON.parse(json);
|
|
351
|
-
} catch (error) {
|
|
352
|
-
const repairedJson = repairJson(json);
|
|
353
|
-
if (repairedJson !== json) return JSON.parse(repairedJson);
|
|
354
|
-
throw error;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Attempts to parse potentially incomplete JSON during streaming.
|
|
359
|
-
* Always returns a valid object, even if the JSON is incomplete.
|
|
360
|
-
*
|
|
361
|
-
* @param partialJson The partial JSON string from streaming
|
|
362
|
-
* @returns Parsed object or empty object if parsing fails
|
|
363
|
-
*/
|
|
364
|
-
function parseStreamingJson(partialJson) {
|
|
365
|
-
if (!partialJson || partialJson.trim() === "") return {};
|
|
366
|
-
try {
|
|
367
|
-
return parseJsonWithRepair(partialJson);
|
|
368
|
-
} catch {
|
|
369
|
-
try {
|
|
370
|
-
return (0, import_dist.parse)(partialJson) ?? {};
|
|
371
|
-
} catch {
|
|
372
|
-
try {
|
|
373
|
-
return (0, import_dist.parse)(repairJson(partialJson)) ?? {};
|
|
374
|
-
} catch {
|
|
375
|
-
return {};
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
//#endregion
|
|
381
|
-
export { parseStreamingJson as n, parseJsonWithRepair as t };
|