@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,189 +0,0 @@
|
|
|
1
|
-
import { i as resolveRequiredHomeDir, o as normalizeLowercaseStringOrEmpty, t as expandHomePrefix } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
-
import { o as resolveStateDir } from "./paths-D92DjaZ--CTOESW2b.mjs";
|
|
3
|
-
import { i as normalizeAgentId } from "./session-key-Cn2QoOyX-CuHbJMgR.mjs";
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import os from "node:os";
|
|
7
|
-
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/artifacts-Czkc6wYi.js
|
|
8
|
-
const ARCHIVE_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}(?:\.\d{3})?Z$/;
|
|
9
|
-
const LEGACY_STORE_BACKUP_RE = /^sessions\.json\.bak\.\d+$/;
|
|
10
|
-
function hasArchiveSuffix(fileName, reason) {
|
|
11
|
-
const marker = `.${reason}.`;
|
|
12
|
-
const index = fileName.lastIndexOf(marker);
|
|
13
|
-
if (index < 0) return false;
|
|
14
|
-
const raw = fileName.slice(index + marker.length);
|
|
15
|
-
return ARCHIVE_TIMESTAMP_RE.test(raw);
|
|
16
|
-
}
|
|
17
|
-
function isSessionArchiveArtifactName(fileName) {
|
|
18
|
-
if (LEGACY_STORE_BACKUP_RE.test(fileName)) return true;
|
|
19
|
-
return hasArchiveSuffix(fileName, "deleted") || hasArchiveSuffix(fileName, "reset") || hasArchiveSuffix(fileName, "bak");
|
|
20
|
-
}
|
|
21
|
-
function isPrimarySessionTranscriptFileName(fileName) {
|
|
22
|
-
if (fileName === "sessions.json") return false;
|
|
23
|
-
if (!fileName.endsWith(".jsonl")) return false;
|
|
24
|
-
return !isSessionArchiveArtifactName(fileName);
|
|
25
|
-
}
|
|
26
|
-
function formatSessionArchiveTimestamp(nowMs = Date.now()) {
|
|
27
|
-
return new Date(nowMs).toISOString().replaceAll(":", "-");
|
|
28
|
-
}
|
|
29
|
-
function restoreSessionArchiveTimestamp(raw) {
|
|
30
|
-
const [datePart, timePart] = raw.split("T");
|
|
31
|
-
if (!datePart || !timePart) return raw;
|
|
32
|
-
return `${datePart}T${timePart.replace(/-/g, ":")}`;
|
|
33
|
-
}
|
|
34
|
-
function parseSessionArchiveTimestamp(fileName, reason) {
|
|
35
|
-
const marker = `.${reason}.`;
|
|
36
|
-
const index = fileName.lastIndexOf(marker);
|
|
37
|
-
if (index < 0) return null;
|
|
38
|
-
const raw = fileName.slice(index + marker.length);
|
|
39
|
-
if (!raw) return null;
|
|
40
|
-
if (!ARCHIVE_TIMESTAMP_RE.test(raw)) return null;
|
|
41
|
-
const timestamp = Date.parse(restoreSessionArchiveTimestamp(raw));
|
|
42
|
-
return Number.isNaN(timestamp) ? null : timestamp;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/paths-D6msg0S1.js
|
|
46
|
-
function resolveAgentSessionsDir(agentId, env = process.env, homedir = () => resolveRequiredHomeDir(env, os.homedir)) {
|
|
47
|
-
const root = resolveStateDir(env, homedir);
|
|
48
|
-
const id = normalizeAgentId(agentId ?? "main");
|
|
49
|
-
return path.join(root, "agents", id, "sessions");
|
|
50
|
-
}
|
|
51
|
-
function resolveDefaultSessionStorePath(agentId) {
|
|
52
|
-
return path.join(resolveAgentSessionsDir(agentId), "sessions.json");
|
|
53
|
-
}
|
|
54
|
-
const SAFE_SESSION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/i;
|
|
55
|
-
function validateSessionId(sessionId) {
|
|
56
|
-
const trimmed = sessionId.trim();
|
|
57
|
-
if (!SAFE_SESSION_ID_RE.test(trimmed)) throw new Error(`Invalid session ID: ${sessionId}`);
|
|
58
|
-
return trimmed;
|
|
59
|
-
}
|
|
60
|
-
function resolveSessionsDir(opts) {
|
|
61
|
-
const sessionsDir = opts?.sessionsDir?.trim();
|
|
62
|
-
if (sessionsDir) return path.resolve(sessionsDir);
|
|
63
|
-
return resolveAgentSessionsDir(opts?.agentId);
|
|
64
|
-
}
|
|
65
|
-
function resolvePathFromAgentSessionsDir(agentSessionsDir, candidateAbsPath) {
|
|
66
|
-
const agentBase = safeRealpathSync(path.resolve(agentSessionsDir)) ?? path.resolve(agentSessionsDir);
|
|
67
|
-
const realCandidate = safeRealpathSync(candidateAbsPath) ?? candidateAbsPath;
|
|
68
|
-
const relative = path.relative(agentBase, realCandidate);
|
|
69
|
-
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return;
|
|
70
|
-
return path.resolve(agentBase, relative);
|
|
71
|
-
}
|
|
72
|
-
function resolveSiblingAgentSessionsDir(baseSessionsDir, agentId) {
|
|
73
|
-
const resolvedBase = path.resolve(baseSessionsDir);
|
|
74
|
-
if (path.basename(resolvedBase) !== "sessions") return;
|
|
75
|
-
const baseAgentDir = path.dirname(resolvedBase);
|
|
76
|
-
const baseAgentsDir = path.dirname(baseAgentDir);
|
|
77
|
-
if (path.basename(baseAgentsDir) !== "agents") return;
|
|
78
|
-
const rootDir = path.dirname(baseAgentsDir);
|
|
79
|
-
return path.join(rootDir, "agents", normalizeAgentId(agentId), "sessions");
|
|
80
|
-
}
|
|
81
|
-
function resolveAgentSessionsPathParts(candidateAbsPath) {
|
|
82
|
-
const parts = path.normalize(path.resolve(candidateAbsPath)).split(path.sep).filter(Boolean);
|
|
83
|
-
const sessionsIndex = parts.lastIndexOf("sessions");
|
|
84
|
-
if (sessionsIndex < 2 || parts[sessionsIndex - 2] !== "agents") return null;
|
|
85
|
-
return {
|
|
86
|
-
parts,
|
|
87
|
-
sessionsIndex
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function extractAgentIdFromAbsoluteSessionPath(candidateAbsPath) {
|
|
91
|
-
const parsed = resolveAgentSessionsPathParts(candidateAbsPath);
|
|
92
|
-
if (!parsed) return;
|
|
93
|
-
const { parts, sessionsIndex } = parsed;
|
|
94
|
-
return parts[sessionsIndex - 1] || void 0;
|
|
95
|
-
}
|
|
96
|
-
function resolveStructuralSessionFallbackPath(candidateAbsPath, expectedAgentId) {
|
|
97
|
-
const parsed = resolveAgentSessionsPathParts(candidateAbsPath);
|
|
98
|
-
if (!parsed) return;
|
|
99
|
-
const { parts, sessionsIndex } = parsed;
|
|
100
|
-
const agentIdPart = parts[sessionsIndex - 1];
|
|
101
|
-
if (!agentIdPart) return;
|
|
102
|
-
const normalizedAgentId = normalizeAgentId(agentIdPart);
|
|
103
|
-
if (normalizedAgentId !== normalizeLowercaseStringOrEmpty(agentIdPart)) return;
|
|
104
|
-
if (normalizedAgentId !== normalizeAgentId(expectedAgentId)) return;
|
|
105
|
-
const relativeSegments = parts.slice(sessionsIndex + 1);
|
|
106
|
-
if (relativeSegments.length !== 1) return;
|
|
107
|
-
const fileName = relativeSegments[0];
|
|
108
|
-
if (!fileName || fileName === "." || fileName === "..") return;
|
|
109
|
-
return path.normalize(path.resolve(candidateAbsPath));
|
|
110
|
-
}
|
|
111
|
-
function safeRealpathSync(filePath) {
|
|
112
|
-
try {
|
|
113
|
-
return fs.realpathSync(filePath);
|
|
114
|
-
} catch {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function resolvePathWithinSessionsDir(sessionsDir, candidate, opts) {
|
|
119
|
-
const trimmed = candidate.trim();
|
|
120
|
-
if (!trimmed) throw new Error("Session file path must not be empty");
|
|
121
|
-
const resolvedBase = path.resolve(sessionsDir);
|
|
122
|
-
const realBase = safeRealpathSync(resolvedBase) ?? resolvedBase;
|
|
123
|
-
const realTrimmed = path.isAbsolute(trimmed) ? safeRealpathSync(trimmed) ?? trimmed : trimmed;
|
|
124
|
-
const normalized = path.isAbsolute(realTrimmed) ? path.relative(realBase, realTrimmed) : realTrimmed;
|
|
125
|
-
if (normalized.startsWith("..") && path.isAbsolute(realTrimmed)) {
|
|
126
|
-
const tryAgentFallback = (agentId) => {
|
|
127
|
-
const normalizedAgentId = normalizeAgentId(agentId);
|
|
128
|
-
const siblingSessionsDir = resolveSiblingAgentSessionsDir(realBase, normalizedAgentId);
|
|
129
|
-
if (siblingSessionsDir) {
|
|
130
|
-
const siblingResolved = resolvePathFromAgentSessionsDir(siblingSessionsDir, realTrimmed);
|
|
131
|
-
if (siblingResolved) return siblingResolved;
|
|
132
|
-
}
|
|
133
|
-
return resolvePathFromAgentSessionsDir(resolveAgentSessionsDir(normalizedAgentId), realTrimmed);
|
|
134
|
-
};
|
|
135
|
-
const explicitAgentId = opts?.agentId?.trim();
|
|
136
|
-
if (explicitAgentId) {
|
|
137
|
-
const resolvedFromAgent = tryAgentFallback(explicitAgentId);
|
|
138
|
-
if (resolvedFromAgent) return resolvedFromAgent;
|
|
139
|
-
}
|
|
140
|
-
const extractedAgentId = extractAgentIdFromAbsoluteSessionPath(realTrimmed);
|
|
141
|
-
if (extractedAgentId) {
|
|
142
|
-
const resolvedFromPath = tryAgentFallback(extractedAgentId);
|
|
143
|
-
if (resolvedFromPath) return resolvedFromPath;
|
|
144
|
-
const structuralFallback = resolveStructuralSessionFallbackPath(realTrimmed, extractedAgentId);
|
|
145
|
-
if (structuralFallback) return structuralFallback;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (!normalized || normalized.startsWith("..") || path.isAbsolute(normalized)) throw new Error("Session file path must be within sessions directory");
|
|
149
|
-
return path.resolve(realBase, normalized);
|
|
150
|
-
}
|
|
151
|
-
function resolveSessionTranscriptPathInDir(sessionId, sessionsDir, topicId) {
|
|
152
|
-
const safeSessionId = validateSessionId(sessionId);
|
|
153
|
-
const safeTopicId = typeof topicId === "string" ? encodeURIComponent(topicId) : typeof topicId === "number" ? String(topicId) : void 0;
|
|
154
|
-
return resolvePathWithinSessionsDir(sessionsDir, safeTopicId !== void 0 ? `${safeSessionId}-topic-${safeTopicId}.jsonl` : `${safeSessionId}.jsonl`);
|
|
155
|
-
}
|
|
156
|
-
function resolveSessionTranscriptPath(sessionId, agentId, topicId) {
|
|
157
|
-
return resolveSessionTranscriptPathInDir(sessionId, resolveAgentSessionsDir(agentId), topicId);
|
|
158
|
-
}
|
|
159
|
-
function resolveSessionFilePath(sessionId, entry, opts) {
|
|
160
|
-
const sessionsDir = resolveSessionsDir(opts);
|
|
161
|
-
const candidate = entry?.sessionFile?.trim();
|
|
162
|
-
if (candidate) try {
|
|
163
|
-
return resolvePathWithinSessionsDir(sessionsDir, candidate, { agentId: opts?.agentId });
|
|
164
|
-
} catch {}
|
|
165
|
-
return resolveSessionTranscriptPathInDir(sessionId, sessionsDir);
|
|
166
|
-
}
|
|
167
|
-
function resolveStorePath(store, opts) {
|
|
168
|
-
const agentId = normalizeAgentId(opts?.agentId ?? "main");
|
|
169
|
-
const env = opts?.env ?? process.env;
|
|
170
|
-
const homedir = () => resolveRequiredHomeDir(env, os.homedir);
|
|
171
|
-
if (!store) return path.join(resolveAgentSessionsDir(agentId, env, homedir), "sessions.json");
|
|
172
|
-
if (store.includes("{agentId}")) {
|
|
173
|
-
const expanded = store.replaceAll("{agentId}", agentId);
|
|
174
|
-
if (expanded.startsWith("~")) return path.resolve(expandHomePrefix(expanded, {
|
|
175
|
-
home: resolveRequiredHomeDir(env, homedir),
|
|
176
|
-
env,
|
|
177
|
-
homedir
|
|
178
|
-
}));
|
|
179
|
-
return path.resolve(expanded);
|
|
180
|
-
}
|
|
181
|
-
if (store.startsWith("~")) return path.resolve(expandHomePrefix(store, {
|
|
182
|
-
home: resolveRequiredHomeDir(env, homedir),
|
|
183
|
-
env,
|
|
184
|
-
homedir
|
|
185
|
-
}));
|
|
186
|
-
return path.resolve(store);
|
|
187
|
-
}
|
|
188
|
-
//#endregion
|
|
189
|
-
export { resolveStorePath as a, isSessionArchiveArtifactName as c, resolveSessionTranscriptPathInDir as i, parseSessionArchiveTimestamp as l, resolveSessionFilePath as n, formatSessionArchiveTimestamp as o, resolveSessionTranscriptPath as r, isPrimarySessionTranscriptFileName as s, resolveDefaultSessionStorePath as t };
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { i as resolveRequiredHomeDir, r as resolveHomeRelativePath } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import os from "node:os";
|
|
5
|
-
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/prototype-keys-C_bmkCd2.js
|
|
6
|
-
const BLOCKED_OBJECT_KEYS = new Set([
|
|
7
|
-
"__proto__",
|
|
8
|
-
"prototype",
|
|
9
|
-
"constructor"
|
|
10
|
-
]);
|
|
11
|
-
function isBlockedObjectKey(key) {
|
|
12
|
-
return BLOCKED_OBJECT_KEYS.has(key);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/paths-D92DjaZ-.js
|
|
16
|
-
/**
|
|
17
|
-
* Nix mode detection: When OPENCLAW_NIX_MODE=1, the gateway is running under Nix.
|
|
18
|
-
* In this mode:
|
|
19
|
-
* - No auto-install flows should be attempted
|
|
20
|
-
* - Missing dependencies should produce actionable Nix-specific error messages
|
|
21
|
-
* - Config is managed externally (read-only from Nix perspective)
|
|
22
|
-
*/
|
|
23
|
-
function resolveIsNixMode(env = process.env) {
|
|
24
|
-
return env.OPENCLAW_NIX_MODE === "1";
|
|
25
|
-
}
|
|
26
|
-
resolveIsNixMode();
|
|
27
|
-
const LEGACY_STATE_DIRNAMES = [".clawdbot"];
|
|
28
|
-
const NEW_STATE_DIRNAME = ".openclaw";
|
|
29
|
-
const CONFIG_FILENAME = "openclaw.json";
|
|
30
|
-
const LEGACY_CONFIG_FILENAMES = ["clawdbot.json"];
|
|
31
|
-
function resolveDefaultHomeDir() {
|
|
32
|
-
return resolveRequiredHomeDir(process.env, os.homedir);
|
|
33
|
-
}
|
|
34
|
-
/** Build a homedir thunk that respects OPENCLAW_HOME for the given env. */
|
|
35
|
-
function envHomedir(env) {
|
|
36
|
-
return () => resolveRequiredHomeDir(env, os.homedir);
|
|
37
|
-
}
|
|
38
|
-
function legacyStateDirs(homedir = resolveDefaultHomeDir) {
|
|
39
|
-
return LEGACY_STATE_DIRNAMES.map((dir) => path.join(homedir(), dir));
|
|
40
|
-
}
|
|
41
|
-
function newStateDir(homedir = resolveDefaultHomeDir) {
|
|
42
|
-
return path.join(homedir(), NEW_STATE_DIRNAME);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* State directory for mutable data (sessions, logs, caches).
|
|
46
|
-
* Can be overridden via OPENCLAW_STATE_DIR.
|
|
47
|
-
* Default: ~/.openclaw
|
|
48
|
-
*/
|
|
49
|
-
function resolveStateDir(env = process.env, homedir = envHomedir(env)) {
|
|
50
|
-
const effectiveHomedir = () => resolveRequiredHomeDir(env, homedir);
|
|
51
|
-
const override = env.OPENCLAW_STATE_DIR?.trim();
|
|
52
|
-
if (override) return resolveUserPath(override, env, effectiveHomedir);
|
|
53
|
-
const newDir = newStateDir(effectiveHomedir);
|
|
54
|
-
if (env.OPENCLAW_TEST_FAST === "1") return newDir;
|
|
55
|
-
const legacyDirs = legacyStateDirs(effectiveHomedir);
|
|
56
|
-
if (fs.existsSync(newDir)) return newDir;
|
|
57
|
-
const existingLegacy = legacyDirs.find((dir) => {
|
|
58
|
-
try {
|
|
59
|
-
return fs.existsSync(dir);
|
|
60
|
-
} catch {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
if (existingLegacy) return existingLegacy;
|
|
65
|
-
return newDir;
|
|
66
|
-
}
|
|
67
|
-
function resolveUserPath(input, env = process.env, homedir = envHomedir(env)) {
|
|
68
|
-
return resolveHomeRelativePath(input, {
|
|
69
|
-
env,
|
|
70
|
-
homedir
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
const STATE_DIR = resolveStateDir();
|
|
74
|
-
/**
|
|
75
|
-
* Config file path (JSON or JSON5).
|
|
76
|
-
* Can be overridden via OPENCLAW_CONFIG_PATH.
|
|
77
|
-
* Default: ~/.openclaw/openclaw.json (or $OPENCLAW_STATE_DIR/openclaw.json)
|
|
78
|
-
*/
|
|
79
|
-
function resolveCanonicalConfigPath(env = process.env, stateDir = resolveStateDir(env, envHomedir(env))) {
|
|
80
|
-
const override = env.OPENCLAW_CONFIG_PATH?.trim();
|
|
81
|
-
if (override) return resolveUserPath(override, env, envHomedir(env));
|
|
82
|
-
return path.join(stateDir, CONFIG_FILENAME);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Resolve the active config path by preferring existing config candidates
|
|
86
|
-
* before falling back to the canonical path.
|
|
87
|
-
*/
|
|
88
|
-
function resolveConfigPathCandidate(env = process.env, homedir = envHomedir(env)) {
|
|
89
|
-
if (env.OPENCLAW_TEST_FAST === "1") return resolveCanonicalConfigPath(env, resolveStateDir(env, homedir));
|
|
90
|
-
const existing = resolveDefaultConfigCandidates(env, homedir).find((candidate) => {
|
|
91
|
-
try {
|
|
92
|
-
return fs.existsSync(candidate);
|
|
93
|
-
} catch {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
if (existing) return existing;
|
|
98
|
-
return resolveCanonicalConfigPath(env, resolveStateDir(env, homedir));
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Active config path (prefers existing config files).
|
|
102
|
-
*/
|
|
103
|
-
function resolveConfigPath(env = process.env, stateDir = resolveStateDir(env, envHomedir(env)), homedir = envHomedir(env)) {
|
|
104
|
-
const override = env.OPENCLAW_CONFIG_PATH?.trim();
|
|
105
|
-
if (override) return resolveUserPath(override, env, homedir);
|
|
106
|
-
if (env.OPENCLAW_TEST_FAST === "1") return path.join(stateDir, CONFIG_FILENAME);
|
|
107
|
-
const stateOverride = env.OPENCLAW_STATE_DIR?.trim();
|
|
108
|
-
const existing = [path.join(stateDir, CONFIG_FILENAME), ...LEGACY_CONFIG_FILENAMES.map((name) => path.join(stateDir, name))].find((candidate) => {
|
|
109
|
-
try {
|
|
110
|
-
return fs.existsSync(candidate);
|
|
111
|
-
} catch {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
if (existing) return existing;
|
|
116
|
-
if (stateOverride) return path.join(stateDir, CONFIG_FILENAME);
|
|
117
|
-
const defaultStateDir = resolveStateDir(env, homedir);
|
|
118
|
-
if (path.resolve(stateDir) === path.resolve(defaultStateDir)) return resolveConfigPathCandidate(env, homedir);
|
|
119
|
-
return path.join(stateDir, CONFIG_FILENAME);
|
|
120
|
-
}
|
|
121
|
-
resolveConfigPathCandidate();
|
|
122
|
-
/**
|
|
123
|
-
* Resolve default config path candidates across default locations.
|
|
124
|
-
* Order: explicit config path → state-dir-derived paths → new default.
|
|
125
|
-
*/
|
|
126
|
-
function resolveDefaultConfigCandidates(env = process.env, homedir = envHomedir(env)) {
|
|
127
|
-
const effectiveHomedir = () => resolveRequiredHomeDir(env, homedir);
|
|
128
|
-
const explicit = env.OPENCLAW_CONFIG_PATH?.trim();
|
|
129
|
-
if (explicit) return [resolveUserPath(explicit, env, effectiveHomedir)];
|
|
130
|
-
const candidates = [];
|
|
131
|
-
const openclawStateDir = env.OPENCLAW_STATE_DIR?.trim();
|
|
132
|
-
if (openclawStateDir) {
|
|
133
|
-
const resolved = resolveUserPath(openclawStateDir, env, effectiveHomedir);
|
|
134
|
-
candidates.push(path.join(resolved, CONFIG_FILENAME));
|
|
135
|
-
candidates.push(...LEGACY_CONFIG_FILENAMES.map((name) => path.join(resolved, name)));
|
|
136
|
-
}
|
|
137
|
-
const defaultDirs = [newStateDir(effectiveHomedir), ...legacyStateDirs(effectiveHomedir)];
|
|
138
|
-
for (const dir of defaultDirs) {
|
|
139
|
-
candidates.push(path.join(dir, CONFIG_FILENAME));
|
|
140
|
-
candidates.push(...LEGACY_CONFIG_FILENAMES.map((name) => path.join(dir, name)));
|
|
141
|
-
}
|
|
142
|
-
return candidates;
|
|
143
|
-
}
|
|
144
|
-
const DEFAULT_GATEWAY_PORT = 18789;
|
|
145
|
-
const OAUTH_FILENAME = "oauth.json";
|
|
146
|
-
/**
|
|
147
|
-
* OAuth credentials storage directory.
|
|
148
|
-
*
|
|
149
|
-
* Precedence:
|
|
150
|
-
* - `OPENCLAW_OAUTH_DIR` (explicit override)
|
|
151
|
-
* - `$*_STATE_DIR/credentials` (canonical server/default)
|
|
152
|
-
*/
|
|
153
|
-
function resolveOAuthDir(env = process.env, stateDir = resolveStateDir(env, envHomedir(env))) {
|
|
154
|
-
const override = env.OPENCLAW_OAUTH_DIR?.trim();
|
|
155
|
-
if (override) return resolveUserPath(override, env, envHomedir(env));
|
|
156
|
-
return path.join(stateDir, "credentials");
|
|
157
|
-
}
|
|
158
|
-
function resolveOAuthPath(env = process.env, stateDir = resolveStateDir(env, envHomedir(env))) {
|
|
159
|
-
return path.join(resolveOAuthDir(env, stateDir), OAUTH_FILENAME);
|
|
160
|
-
}
|
|
161
|
-
function parseGatewayPortEnvValue(raw) {
|
|
162
|
-
const trimmed = raw?.trim();
|
|
163
|
-
if (!trimmed) return null;
|
|
164
|
-
if (/^\d+$/.test(trimmed)) {
|
|
165
|
-
const parsed = Number.parseInt(trimmed, 10);
|
|
166
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
167
|
-
}
|
|
168
|
-
const bracketedIpv6Match = trimmed.match(/^\[[^\]]+\]:(\d+)$/);
|
|
169
|
-
if (bracketedIpv6Match?.[1]) {
|
|
170
|
-
const parsed = Number.parseInt(bracketedIpv6Match[1], 10);
|
|
171
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
172
|
-
}
|
|
173
|
-
const firstColon = trimmed.indexOf(":");
|
|
174
|
-
const lastColon = trimmed.lastIndexOf(":");
|
|
175
|
-
if (firstColon <= 0 || firstColon !== lastColon) return null;
|
|
176
|
-
const suffix = trimmed.slice(firstColon + 1);
|
|
177
|
-
if (!/^\d+$/.test(suffix)) return null;
|
|
178
|
-
const parsed = Number.parseInt(suffix, 10);
|
|
179
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
180
|
-
}
|
|
181
|
-
function resolveGatewayPort(cfg, env = process.env) {
|
|
182
|
-
const envRaw = env.OPENCLAW_GATEWAY_PORT?.trim();
|
|
183
|
-
const envPort = parseGatewayPortEnvValue(envRaw);
|
|
184
|
-
if (envPort !== null) return envPort;
|
|
185
|
-
const configPort = cfg?.gateway?.port;
|
|
186
|
-
if (typeof configPort === "number" && Number.isFinite(configPort)) {
|
|
187
|
-
if (configPort > 0) return configPort;
|
|
188
|
-
}
|
|
189
|
-
return DEFAULT_GATEWAY_PORT;
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
export { resolveOAuthPath as a, resolveGatewayPort as i, STATE_DIR as n, resolveStateDir as o, resolveConfigPath as r, isBlockedObjectKey as s, DEFAULT_GATEWAY_PORT as t };
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { c as normalizeOptionalString } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
-
import { s as isRecord } from "./bundled-dir-U738ay4K-DXK0q_TV.mjs";
|
|
3
|
-
import { l as normalizeProviderId } from "./bundled-compat-BpaDaAAu-D7oazKjD.mjs";
|
|
4
|
-
import { o as loadPluginManifestRegistry } from "./manifest-registry-_hxKCS2K-CZdeyN0f.mjs";
|
|
5
|
-
import { r as getPluginRegistryState } from "./runtime-state-IBOIXKOx-Bf9tcLvc.mjs";
|
|
6
|
-
import { R as resolveProviderSyntheticAuthWithPlugin, a as applyProviderResolvedTransportWithPlugin, i as applyProviderResolvedModelCompatWithPlugins, v as normalizeProviderResolvedModelWithPlugin } from "./provider-runtime-CT50mNIX-BwEV6GyO.mjs";
|
|
7
|
-
import { n as AuthStorage, r as InMemoryAuthStorageBackend, t as ModelRegistry } from "./dist-DD2aJ2UL.mjs";
|
|
8
|
-
import { g as ensureAuthProfileStore, l as resolveProviderEnvApiKeyCandidates, t as resolveEnvApiKey } from "./model-auth-env-oyg2Hexc-DU_rOUU5.mjs";
|
|
9
|
-
import { n as normalizeModelCompat } from "./provider-model-compat-CFqcq0it-BDDuBI3A.mjs";
|
|
10
|
-
import fs from "node:fs";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/pi-model-discovery-Bd0TWzo8.js
|
|
13
|
-
function uniqueProviderRefs(values) {
|
|
14
|
-
const seen = /* @__PURE__ */ new Set();
|
|
15
|
-
const next = [];
|
|
16
|
-
for (const raw of values) {
|
|
17
|
-
const trimmed = raw.trim();
|
|
18
|
-
const normalized = normalizeProviderId(trimmed);
|
|
19
|
-
if (!trimmed || seen.has(normalized)) continue;
|
|
20
|
-
seen.add(normalized);
|
|
21
|
-
next.push(trimmed);
|
|
22
|
-
}
|
|
23
|
-
return next;
|
|
24
|
-
}
|
|
25
|
-
function resolveManifestSyntheticAuthProviderRefs() {
|
|
26
|
-
return uniqueProviderRefs(loadPluginManifestRegistry({ cache: true }).plugins.flatMap((plugin) => plugin.syntheticAuthRefs ?? []));
|
|
27
|
-
}
|
|
28
|
-
function resolveRuntimeSyntheticAuthProviderRefs() {
|
|
29
|
-
const registry = getPluginRegistryState()?.activeRegistry;
|
|
30
|
-
if (registry) return uniqueProviderRefs([...(registry.providers ?? []).filter((entry) => "resolveSyntheticAuth" in entry.provider && typeof entry.provider.resolveSyntheticAuth === "function").map((entry) => entry.provider.id), ...(registry.cliBackends ?? []).filter((entry) => "resolveSyntheticAuth" in entry.backend && typeof entry.backend.resolveSyntheticAuth === "function").map((entry) => entry.backend.id)]);
|
|
31
|
-
return resolveManifestSyntheticAuthProviderRefs();
|
|
32
|
-
}
|
|
33
|
-
function convertAuthProfileCredentialToPi(cred) {
|
|
34
|
-
if (cred.type === "api_key") {
|
|
35
|
-
const key = normalizeOptionalString(cred.key) ?? "";
|
|
36
|
-
if (!key) return null;
|
|
37
|
-
return {
|
|
38
|
-
type: "api_key",
|
|
39
|
-
key
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (cred.type === "token") {
|
|
43
|
-
const token = normalizeOptionalString(cred.token) ?? "";
|
|
44
|
-
if (!token) return null;
|
|
45
|
-
if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && Date.now() >= cred.expires) return null;
|
|
46
|
-
return {
|
|
47
|
-
type: "api_key",
|
|
48
|
-
key: token
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
if (cred.type === "oauth") {
|
|
52
|
-
const access = normalizeOptionalString(cred.access) ?? "";
|
|
53
|
-
const refresh = normalizeOptionalString(cred.refresh) ?? "";
|
|
54
|
-
if (!access || !refresh || !Number.isFinite(cred.expires) || cred.expires <= 0) return null;
|
|
55
|
-
return {
|
|
56
|
-
type: "oauth",
|
|
57
|
-
access,
|
|
58
|
-
refresh,
|
|
59
|
-
expires: cred.expires
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
function resolvePiCredentialMapFromStore(store) {
|
|
65
|
-
const credentials = {};
|
|
66
|
-
for (const credential of Object.values(store.profiles)) {
|
|
67
|
-
const provider = normalizeProviderId(credential.provider ?? "");
|
|
68
|
-
if (!provider || credentials[provider]) continue;
|
|
69
|
-
const converted = convertAuthProfileCredentialToPi(credential);
|
|
70
|
-
if (converted) credentials[provider] = converted;
|
|
71
|
-
}
|
|
72
|
-
return credentials;
|
|
73
|
-
}
|
|
74
|
-
const PiAuthStorageClass = AuthStorage;
|
|
75
|
-
const PiModelRegistryClass = ModelRegistry;
|
|
76
|
-
function createInMemoryAuthStorageBackend(initialData) {
|
|
77
|
-
let snapshot = JSON.stringify(initialData, null, 2);
|
|
78
|
-
return { withLock(update) {
|
|
79
|
-
const { result, next } = update(snapshot);
|
|
80
|
-
if (typeof next === "string") snapshot = next;
|
|
81
|
-
return result;
|
|
82
|
-
} };
|
|
83
|
-
}
|
|
84
|
-
function normalizeDiscoveredPiModel(value, agentDir) {
|
|
85
|
-
if (!isRecord(value)) return value;
|
|
86
|
-
if (typeof value.id !== "string" || typeof value.name !== "string" || typeof value.provider !== "string") return value;
|
|
87
|
-
const model = value;
|
|
88
|
-
const pluginNormalized = normalizeProviderResolvedModelWithPlugin({
|
|
89
|
-
provider: model.provider,
|
|
90
|
-
context: {
|
|
91
|
-
provider: model.provider,
|
|
92
|
-
modelId: model.id,
|
|
93
|
-
model,
|
|
94
|
-
agentDir
|
|
95
|
-
}
|
|
96
|
-
}) ?? model;
|
|
97
|
-
const compatNormalized = applyProviderResolvedModelCompatWithPlugins({
|
|
98
|
-
provider: model.provider,
|
|
99
|
-
context: {
|
|
100
|
-
provider: model.provider,
|
|
101
|
-
modelId: model.id,
|
|
102
|
-
model: pluginNormalized,
|
|
103
|
-
agentDir
|
|
104
|
-
}
|
|
105
|
-
}) ?? pluginNormalized;
|
|
106
|
-
const transportNormalized = applyProviderResolvedTransportWithPlugin({
|
|
107
|
-
provider: model.provider,
|
|
108
|
-
context: {
|
|
109
|
-
provider: model.provider,
|
|
110
|
-
modelId: model.id,
|
|
111
|
-
model: compatNormalized,
|
|
112
|
-
agentDir
|
|
113
|
-
}
|
|
114
|
-
}) ?? compatNormalized;
|
|
115
|
-
if (!isRecord(transportNormalized) || typeof transportNormalized.id !== "string" || typeof transportNormalized.name !== "string" || typeof transportNormalized.provider !== "string" || typeof transportNormalized.api !== "string") return value;
|
|
116
|
-
return normalizeModelCompat(transportNormalized);
|
|
117
|
-
}
|
|
118
|
-
function instantiatePiModelRegistry(authStorage, modelsJsonPath) {
|
|
119
|
-
const Registry = PiModelRegistryClass;
|
|
120
|
-
if (typeof Registry.create === "function") return Registry.create(authStorage, modelsJsonPath);
|
|
121
|
-
return new Registry(authStorage, modelsJsonPath);
|
|
122
|
-
}
|
|
123
|
-
function createOpenClawModelRegistry(authStorage, modelsJsonPath, agentDir, options) {
|
|
124
|
-
const registry = instantiatePiModelRegistry(authStorage, modelsJsonPath);
|
|
125
|
-
const getAll = registry.getAll.bind(registry);
|
|
126
|
-
const getAvailable = registry.getAvailable.bind(registry);
|
|
127
|
-
const find = registry.find.bind(registry);
|
|
128
|
-
const providerFilter = options?.providerFilter ? normalizeProviderId(options.providerFilter) : "";
|
|
129
|
-
const matchesProviderFilter = (entry) => !providerFilter || normalizeProviderId(entry.provider) === providerFilter;
|
|
130
|
-
registry.getAll = () => getAll().filter((entry) => matchesProviderFilter(entry)).map((entry) => normalizeDiscoveredPiModel(entry, agentDir));
|
|
131
|
-
registry.getAvailable = () => getAvailable().filter((entry) => matchesProviderFilter(entry)).map((entry) => normalizeDiscoveredPiModel(entry, agentDir));
|
|
132
|
-
registry.find = (provider, modelId) => normalizeDiscoveredPiModel(find(provider, modelId), agentDir);
|
|
133
|
-
return registry;
|
|
134
|
-
}
|
|
135
|
-
function scrubLegacyStaticAuthJsonEntriesForDiscovery(pathname) {
|
|
136
|
-
if (process.env.OPENCLAW_AUTH_STORE_READONLY === "1") return;
|
|
137
|
-
if (!fs.existsSync(pathname)) return;
|
|
138
|
-
let parsed;
|
|
139
|
-
try {
|
|
140
|
-
parsed = JSON.parse(fs.readFileSync(pathname, "utf8"));
|
|
141
|
-
} catch {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (!isRecord(parsed)) return;
|
|
145
|
-
let changed = false;
|
|
146
|
-
for (const [provider, value] of Object.entries(parsed)) {
|
|
147
|
-
if (!isRecord(value)) continue;
|
|
148
|
-
if (value.type !== "api_key") continue;
|
|
149
|
-
delete parsed[provider];
|
|
150
|
-
changed = true;
|
|
151
|
-
}
|
|
152
|
-
if (!changed) return;
|
|
153
|
-
if (Object.keys(parsed).length === 0) {
|
|
154
|
-
fs.rmSync(pathname, { force: true });
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
fs.writeFileSync(pathname, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
|
|
158
|
-
fs.chmodSync(pathname, 384);
|
|
159
|
-
}
|
|
160
|
-
function createAuthStorage(AuthStorageLike, path, creds) {
|
|
161
|
-
const withInMemory = AuthStorageLike;
|
|
162
|
-
if (typeof withInMemory.inMemory === "function") return withInMemory.inMemory(creds);
|
|
163
|
-
const withFromStorage = AuthStorageLike;
|
|
164
|
-
if (typeof withFromStorage.fromStorage === "function") {
|
|
165
|
-
const backendCtor = InMemoryAuthStorageBackend;
|
|
166
|
-
const backend = typeof backendCtor === "function" ? new backendCtor() : createInMemoryAuthStorageBackend(creds);
|
|
167
|
-
backend.withLock(() => ({
|
|
168
|
-
result: void 0,
|
|
169
|
-
next: JSON.stringify(creds, null, 2)
|
|
170
|
-
}));
|
|
171
|
-
return withFromStorage.fromStorage(backend);
|
|
172
|
-
}
|
|
173
|
-
const withFactory = AuthStorageLike;
|
|
174
|
-
const withRuntimeOverride = typeof withFactory.create === "function" ? withFactory.create(path) : new AuthStorageLike(path);
|
|
175
|
-
if (typeof withRuntimeOverride.setRuntimeApiKey === "function") for (const [provider, credential] of Object.entries(creds)) {
|
|
176
|
-
if (credential.type === "api_key") {
|
|
177
|
-
withRuntimeOverride.setRuntimeApiKey(provider, credential.key);
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
withRuntimeOverride.setRuntimeApiKey(provider, credential.access);
|
|
181
|
-
}
|
|
182
|
-
return withRuntimeOverride;
|
|
183
|
-
}
|
|
184
|
-
function addEnvBackedPiCredentials(credentials, env = process.env) {
|
|
185
|
-
const next = { ...credentials };
|
|
186
|
-
for (const provider of Object.keys(resolveProviderEnvApiKeyCandidates({ env }))) {
|
|
187
|
-
if (next[provider]) continue;
|
|
188
|
-
const resolved = resolveEnvApiKey(provider, env);
|
|
189
|
-
if (!resolved?.apiKey) continue;
|
|
190
|
-
next[provider] = {
|
|
191
|
-
type: "api_key",
|
|
192
|
-
key: resolved.apiKey
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
return next;
|
|
196
|
-
}
|
|
197
|
-
function resolvePiCredentialsForDiscovery(agentDir) {
|
|
198
|
-
const credentials = addEnvBackedPiCredentials(resolvePiCredentialMapFromStore(ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false })));
|
|
199
|
-
for (const provider of resolveRuntimeSyntheticAuthProviderRefs()) {
|
|
200
|
-
if (credentials[provider]) continue;
|
|
201
|
-
const apiKey = resolveProviderSyntheticAuthWithPlugin({
|
|
202
|
-
provider,
|
|
203
|
-
context: {
|
|
204
|
-
config: void 0,
|
|
205
|
-
provider,
|
|
206
|
-
providerConfig: void 0
|
|
207
|
-
}
|
|
208
|
-
})?.apiKey?.trim();
|
|
209
|
-
if (!apiKey) continue;
|
|
210
|
-
credentials[provider] = {
|
|
211
|
-
type: "api_key",
|
|
212
|
-
key: apiKey
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return credentials;
|
|
216
|
-
}
|
|
217
|
-
function discoverAuthStorage(agentDir) {
|
|
218
|
-
const credentials = resolvePiCredentialsForDiscovery(agentDir);
|
|
219
|
-
const authPath = path.join(agentDir, "auth.json");
|
|
220
|
-
scrubLegacyStaticAuthJsonEntriesForDiscovery(authPath);
|
|
221
|
-
return createAuthStorage(PiAuthStorageClass, authPath, credentials);
|
|
222
|
-
}
|
|
223
|
-
function discoverModels(authStorage, agentDir, options) {
|
|
224
|
-
return createOpenClawModelRegistry(authStorage, path.join(agentDir, "models.json"), agentDir, options);
|
|
225
|
-
}
|
|
226
|
-
//#endregion
|
|
227
|
-
export { discoverModels as a, scrubLegacyStaticAuthJsonEntriesForDiscovery as c, discoverAuthStorage as i, PiModelRegistryClass as n, normalizeDiscoveredPiModel as o, addEnvBackedPiCredentials as r, resolvePiCredentialsForDiscovery as s, PiAuthStorageClass as t };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as discoverModels, c as scrubLegacyStaticAuthJsonEntriesForDiscovery, i as discoverAuthStorage, n as PiModelRegistryClass, o as normalizeDiscoveredPiModel, r as addEnvBackedPiCredentials, s as resolvePiCredentialsForDiscovery, t as PiAuthStorageClass } from "./pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs";
|
|
2
|
-
export { PiAuthStorageClass as AuthStorage, PiModelRegistryClass as ModelRegistry, addEnvBackedPiCredentials, discoverAuthStorage, discoverModels, normalizeDiscoveredPiModel, resolvePiCredentialsForDiscovery, scrubLegacyStaticAuthJsonEntriesForDiscovery };
|