@vibe-lark/larkpal 0.1.85 → 0.1.86

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.
Files changed (106) hide show
  1. package/dist/account-id-BM1T6029-DYjVxojW.mjs +46 -0
  2. package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +172 -0
  3. package/dist/anthropic-TH8ERTXK.mjs +5962 -0
  4. package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +596 -0
  5. package/dist/azure-openai-responses-Bt_Ag9Er.mjs +166 -0
  6. package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +594 -0
  7. package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +60 -0
  8. package/dist/build-DgTrEpge.mjs +3333 -0
  9. package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +5216 -0
  10. package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +258 -0
  11. package/dist/call-DimWbpgJ-ColD4W-y.mjs +9993 -0
  12. package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +2 -0
  13. package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +33 -0
  14. package/dist/chunk-D6SyT4dJ.mjs +36 -0
  15. package/dist/cli.mjs +6 -6
  16. package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +685 -0
  17. package/dist/config-Bim2pi8a-BQUdfiEi.mjs +9 -0
  18. package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +72 -0
  19. package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +140 -0
  20. package/dist/dist-CEGw8-2W.mjs +429 -0
  21. package/dist/dist-DD2aJ2UL.mjs +125135 -0
  22. package/dist/env-api-keys-BVvSg7T2.mjs +68 -0
  23. package/dist/event-stream-xaQWmyas.mjs +15226 -0
  24. package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +194 -0
  25. package/dist/from-DF7cl2wz.mjs +3842 -0
  26. package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +28 -0
  27. package/dist/github-copilot-headers-DjqWtUoP.mjs +22 -0
  28. package/dist/google-C2pVrgBZ.mjs +336 -0
  29. package/dist/google-gemini-cli-BBxgS5Ho.mjs +623 -0
  30. package/dist/google-shared-BsWgwEk1.mjs +22791 -0
  31. package/dist/google-vertex-BsVLJrrC.mjs +358 -0
  32. package/dist/hash-DAFtW_W7.mjs +16 -0
  33. package/dist/headers-R3HdCbAE.mjs +8 -0
  34. package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +93 -0
  35. package/dist/ids-BPsM98Uu-CwuxvUai.mjs +77 -0
  36. package/dist/image-2w3cApg7-CxpHvoB5.mjs +207 -0
  37. package/dist/io-CH2g3vsv-BOGlLlB8.mjs +26218 -0
  38. package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +5049 -0
  39. package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +108 -0
  40. package/dist/json-parse-v_HIJjjI.mjs +381 -0
  41. package/dist/jws-GFcTvvVT.mjs +2291 -0
  42. package/dist/{lark-cli-provider-7LvtOIF_.mjs → lark-cli-provider-BARgbbmo.mjs} +1 -1
  43. package/dist/{live-smoke-nvTUPtrv.mjs → live-smoke-BhkBOcH9.mjs} +3 -3
  44. package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +29 -0
  45. package/dist/loader-708jrx4Y-BOswuvpe.mjs +5053 -0
  46. package/dist/main.mjs +56550 -205
  47. package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +3512 -0
  48. package/dist/mcp-server.mjs +1 -1
  49. package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +50 -0
  50. package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +29 -0
  51. package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +2 -0
  52. package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +2 -0
  53. package/dist/mistral-CaR4DiLu.mjs +28657 -0
  54. package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +1306 -0
  55. package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +1282 -0
  56. package/dist/models-config.runtime-BsU_22xk.mjs +2 -0
  57. package/dist/multipart-parser-DedmaB5g.mjs +294 -0
  58. package/dist/oauth-DOJeGfcE.mjs +6392 -0
  59. package/dist/openai-BDtIh3Ja.mjs +6693 -0
  60. package/dist/openai-codex-responses-C5EORu31.mjs +664 -0
  61. package/dist/openai-completions-CR_cS6gX.mjs +669 -0
  62. package/dist/openai-responses-oGxwZyuC.mjs +184 -0
  63. package/dist/openai-responses-shared-BixMSDZE.mjs +398 -0
  64. package/dist/paths-D6msg0S1-C2lYuisN.mjs +189 -0
  65. package/dist/paths-D92DjaZ--CTOESW2b.mjs +192 -0
  66. package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +227 -0
  67. package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +2 -0
  68. package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +399 -0
  69. package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +1456 -0
  70. package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +61 -0
  71. package/dist/provider-discovery.runtime-BPzz1PFj.mjs +58 -0
  72. package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +118 -0
  73. package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +2 -0
  74. package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +573 -0
  75. package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +35449 -0
  76. package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +219 -0
  77. package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +117 -0
  78. package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +1041 -0
  79. package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +120 -0
  80. package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +19 -0
  81. package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +677 -0
  82. package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +10 -0
  83. package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +39 -0
  84. package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +2 -0
  85. package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +2 -0
  86. package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +2 -0
  87. package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +82 -0
  88. package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +147 -0
  89. package/dist/src-BgCX0MLG.mjs +813 -0
  90. package/dist/src-DYbqlAqf.mjs +1177 -0
  91. package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +344 -0
  92. package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +28 -0
  93. package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +211 -0
  94. package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +3061 -0
  95. package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +1002 -0
  96. package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +2950 -0
  97. package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +2 -0
  98. package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +2 -0
  99. package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +2019 -0
  100. package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +2 -0
  101. package/dist/transform-messages-DbhIzTxq.mjs +207 -0
  102. package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +295 -0
  103. package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +200 -0
  104. package/package.json +3 -3
  105. package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
  106. /package/dist/{interactive-init-B6j8j_Ap.mjs → interactive-init-BXQBalNr.mjs} +0 -0
@@ -0,0 +1,9 @@
1
+ import "./paths-D92DjaZ--CTOESW2b.mjs";
2
+ import "./bundled-dir-U738ay4K-DXK0q_TV.mjs";
3
+ import "./io-CH2g3vsv-BOGlLlB8.mjs";
4
+ import "./bundled-compat-BpaDaAAu-D7oazKjD.mjs";
5
+ import "node:path";
6
+ import "node:fs/promises";
7
+ import "node:crypto";
8
+ import "node:util";
9
+ export {};
@@ -0,0 +1,72 @@
1
+ import { c as normalizeOptionalString } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
2
+ import { r as normalizeOptionalAccountId } from "./account-id-BM1T6029-DYjVxojW.mjs";
3
+ import { n as normalizeMessageChannel } from "./message-channel-core-DTA--Gjh-CY4Tkb7N.mjs";
4
+ //#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/delivery-context.shared-j5hC5qb1.js
5
+ function normalizeAccountId(value) {
6
+ return normalizeOptionalAccountId(value);
7
+ }
8
+ function normalizeDeliveryContext(context) {
9
+ if (!context) return;
10
+ const channel = typeof context.channel === "string" ? normalizeMessageChannel(context.channel) ?? context.channel.trim() : void 0;
11
+ const to = normalizeOptionalString(context.to);
12
+ const accountId = normalizeAccountId(context.accountId);
13
+ const threadId = typeof context.threadId === "number" && Number.isFinite(context.threadId) ? Math.trunc(context.threadId) : typeof context.threadId === "string" ? normalizeOptionalString(context.threadId) : void 0;
14
+ const normalizedThreadId = typeof threadId === "string" ? threadId ? threadId : void 0 : threadId;
15
+ if (!channel && !to && !accountId && normalizedThreadId == null) return;
16
+ const normalized = {
17
+ channel: channel || void 0,
18
+ to: to || void 0,
19
+ accountId
20
+ };
21
+ if (normalizedThreadId != null) normalized.threadId = normalizedThreadId;
22
+ return normalized;
23
+ }
24
+ function normalizeSessionDeliveryFields(source) {
25
+ if (!source) return {
26
+ deliveryContext: void 0,
27
+ lastChannel: void 0,
28
+ lastTo: void 0,
29
+ lastAccountId: void 0,
30
+ lastThreadId: void 0
31
+ };
32
+ const merged = mergeDeliveryContext(normalizeDeliveryContext({
33
+ channel: source.lastChannel ?? source.channel,
34
+ to: source.lastTo,
35
+ accountId: source.lastAccountId,
36
+ threadId: source.lastThreadId
37
+ }), normalizeDeliveryContext(source.deliveryContext));
38
+ if (!merged) return {
39
+ deliveryContext: void 0,
40
+ lastChannel: void 0,
41
+ lastTo: void 0,
42
+ lastAccountId: void 0,
43
+ lastThreadId: void 0
44
+ };
45
+ return {
46
+ deliveryContext: merged,
47
+ lastChannel: merged.channel,
48
+ lastTo: merged.to,
49
+ lastAccountId: merged.accountId,
50
+ lastThreadId: merged.threadId
51
+ };
52
+ }
53
+ function mergeDeliveryContext(primary, fallback) {
54
+ const normalizedPrimary = normalizeDeliveryContext(primary);
55
+ const normalizedFallback = normalizeDeliveryContext(fallback);
56
+ if (!normalizedPrimary && !normalizedFallback) return;
57
+ const channelsConflict = normalizedPrimary?.channel && normalizedFallback?.channel && normalizedPrimary.channel !== normalizedFallback.channel;
58
+ return normalizeDeliveryContext({
59
+ channel: normalizedPrimary?.channel ?? normalizedFallback?.channel,
60
+ to: channelsConflict ? normalizedPrimary?.to : normalizedPrimary?.to ?? normalizedFallback?.to,
61
+ accountId: channelsConflict ? normalizedPrimary?.accountId : normalizedPrimary?.accountId ?? normalizedFallback?.accountId,
62
+ threadId: channelsConflict ? normalizedPrimary?.threadId : normalizedPrimary?.threadId ?? normalizedFallback?.threadId
63
+ });
64
+ }
65
+ function deliveryContextKey(context) {
66
+ const normalized = normalizeDeliveryContext(context);
67
+ if (!normalized?.channel || !normalized?.to) return;
68
+ const threadId = normalized.threadId != null && normalized.threadId !== "" ? String(normalized.threadId) : "";
69
+ return `${normalized.channel}|${normalized.to}|${normalized.accountId ?? ""}|${threadId}`;
70
+ }
71
+ //#endregion
72
+ export { normalizeSessionDeliveryFields as i, mergeDeliveryContext as n, normalizeDeliveryContext as r, deliveryContextKey as t };
@@ -0,0 +1,140 @@
1
+ import "./paths-D92DjaZ--CTOESW2b.mjs";
2
+ import "./io-CH2g3vsv-BOGlLlB8.mjs";
3
+ import { St as createSubsystemLogger } from "./bundled-compat-BpaDaAAu-D7oazKjD.mjs";
4
+ import "./config-Bim2pi8a-BQUdfiEi.mjs";
5
+ import "node:fs";
6
+ import "node:path";
7
+ import "node:process";
8
+ //#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/diagnostic-events-DU0Yv8MX.js
9
+ function getDiagnosticEventsState() {
10
+ const globalStore = globalThis;
11
+ if (!globalStore.__openclawDiagnosticEventsState) globalStore.__openclawDiagnosticEventsState = {
12
+ enabled: true,
13
+ seq: 0,
14
+ listeners: /* @__PURE__ */ new Set(),
15
+ dispatchDepth: 0
16
+ };
17
+ return globalStore.__openclawDiagnosticEventsState;
18
+ }
19
+ function areDiagnosticsEnabledForProcess() {
20
+ return getDiagnosticEventsState().enabled;
21
+ }
22
+ function emitDiagnosticEvent(event) {
23
+ const state = getDiagnosticEventsState();
24
+ if (!state.enabled) return;
25
+ if (state.dispatchDepth > 100) {
26
+ console.error(`[diagnostic-events] recursion guard tripped at depth=${state.dispatchDepth}, dropping type=${event.type}`);
27
+ return;
28
+ }
29
+ const enriched = {
30
+ ...event,
31
+ seq: state.seq += 1,
32
+ ts: Date.now()
33
+ };
34
+ state.dispatchDepth += 1;
35
+ for (const listener of state.listeners) try {
36
+ listener(enriched);
37
+ } catch (err) {
38
+ const errorMessage = err instanceof Error ? err.stack ?? err.message : typeof err === "string" ? err : String(err);
39
+ console.error(`[diagnostic-events] listener error type=${enriched.type} seq=${enriched.seq}: ${errorMessage}`);
40
+ }
41
+ state.dispatchDepth -= 1;
42
+ }
43
+ const diagnosticLogger = createSubsystemLogger("diagnostic");
44
+ function markDiagnosticActivity() {}
45
+ //#endregion
46
+ //#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/diagnostic-session-state-CnRAerRs.js
47
+ const diagnosticSessionStates = /* @__PURE__ */ new Map();
48
+ const SESSION_STATE_TTL_MS = 1800 * 1e3;
49
+ const SESSION_STATE_PRUNE_INTERVAL_MS = 60 * 1e3;
50
+ const SESSION_STATE_MAX_ENTRIES = 2e3;
51
+ let lastSessionPruneAt = 0;
52
+ function pruneDiagnosticSessionStates(now = Date.now(), force = false) {
53
+ const shouldPruneForSize = diagnosticSessionStates.size > SESSION_STATE_MAX_ENTRIES;
54
+ if (!force && !shouldPruneForSize && now - lastSessionPruneAt < SESSION_STATE_PRUNE_INTERVAL_MS) return;
55
+ lastSessionPruneAt = now;
56
+ for (const [key, state] of diagnosticSessionStates.entries()) {
57
+ const ageMs = now - state.lastActivity;
58
+ if (state.state === "idle" && state.queueDepth <= 0 && ageMs > SESSION_STATE_TTL_MS) diagnosticSessionStates.delete(key);
59
+ }
60
+ if (diagnosticSessionStates.size <= SESSION_STATE_MAX_ENTRIES) return;
61
+ const excess = diagnosticSessionStates.size - SESSION_STATE_MAX_ENTRIES;
62
+ const ordered = Array.from(diagnosticSessionStates.entries()).toSorted((a, b) => a[1].lastActivity - b[1].lastActivity);
63
+ for (let i = 0; i < excess; i += 1) {
64
+ const key = ordered[i]?.[0];
65
+ if (!key) break;
66
+ diagnosticSessionStates.delete(key);
67
+ }
68
+ }
69
+ function resolveSessionKey({ sessionKey, sessionId }) {
70
+ return sessionKey ?? sessionId ?? "unknown";
71
+ }
72
+ function findStateBySessionId(sessionId) {
73
+ for (const state of diagnosticSessionStates.values()) if (state.sessionId === sessionId) return state;
74
+ }
75
+ function getDiagnosticSessionState(ref) {
76
+ pruneDiagnosticSessionStates();
77
+ const key = resolveSessionKey(ref);
78
+ const existing = diagnosticSessionStates.get(key) ?? (ref.sessionId && findStateBySessionId(ref.sessionId));
79
+ if (existing) {
80
+ if (ref.sessionId) existing.sessionId = ref.sessionId;
81
+ if (ref.sessionKey) existing.sessionKey = ref.sessionKey;
82
+ return existing;
83
+ }
84
+ const created = {
85
+ sessionId: ref.sessionId,
86
+ sessionKey: ref.sessionKey,
87
+ lastActivity: Date.now(),
88
+ state: "idle",
89
+ queueDepth: 0
90
+ };
91
+ diagnosticSessionStates.set(key, created);
92
+ pruneDiagnosticSessionStates(Date.now(), true);
93
+ return created;
94
+ }
95
+ //#endregion
96
+ //#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/diagnostic-ClMwNnUA.js
97
+ const MB = 1024 * 1024;
98
+ 1536 * MB;
99
+ 3072 * MB;
100
+ 1024 * MB;
101
+ 2048 * MB;
102
+ 512 * MB;
103
+ 1024 * MB;
104
+ function logMessageQueued(params) {
105
+ if (!areDiagnosticsEnabledForProcess()) return;
106
+ const state = getDiagnosticSessionState(params);
107
+ state.queueDepth += 1;
108
+ state.lastActivity = Date.now();
109
+ if (diagnosticLogger.isEnabled("debug")) diagnosticLogger.debug(`message queued: sessionId=${state.sessionId ?? "unknown"} sessionKey=${state.sessionKey ?? "unknown"} source=${params.source} queueDepth=${state.queueDepth} sessionState=${state.state}`);
110
+ emitDiagnosticEvent({
111
+ type: "message.queued",
112
+ sessionId: state.sessionId,
113
+ sessionKey: state.sessionKey,
114
+ channel: params.channel,
115
+ source: params.source,
116
+ queueDepth: state.queueDepth
117
+ });
118
+ markDiagnosticActivity();
119
+ }
120
+ function logToolLoopAction(params) {
121
+ if (!areDiagnosticsEnabledForProcess()) return;
122
+ const payload = `tool loop: sessionId=${params.sessionId ?? "unknown"} sessionKey=${params.sessionKey ?? "unknown"} tool=${params.toolName} level=${params.level} action=${params.action} detector=${params.detector} count=${params.count}${params.pairedToolName ? ` pairedTool=${params.pairedToolName}` : ""} message="${params.message}"`;
123
+ if (params.level === "critical") diagnosticLogger.error(payload);
124
+ else diagnosticLogger.warn(payload);
125
+ emitDiagnosticEvent({
126
+ type: "tool.loop",
127
+ sessionId: params.sessionId,
128
+ sessionKey: params.sessionKey,
129
+ toolName: params.toolName,
130
+ level: params.level,
131
+ action: params.action,
132
+ detector: params.detector,
133
+ count: params.count,
134
+ message: params.message,
135
+ pairedToolName: params.pairedToolName
136
+ });
137
+ markDiagnosticActivity();
138
+ }
139
+ //#endregion
140
+ export { diagnosticLogger as i, logToolLoopAction as n, getDiagnosticSessionState as r, logMessageQueued as t };
@@ -0,0 +1,429 @@
1
+ import { i as __require, t as __commonJSMin } from "./chunk-D6SyT4dJ.mjs";
2
+ import { t as require_src } from "./src-BgCX0MLG.mjs";
3
+ //#region node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js
4
+ var require_helpers = /* @__PURE__ */ __commonJSMin(((exports) => {
5
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === void 0) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
9
+ enumerable: true,
10
+ get: function() {
11
+ return m[k];
12
+ }
13
+ };
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === void 0) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", {
21
+ enumerable: true,
22
+ value: v
23
+ });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = exports && exports.__importStar || function(mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) {
31
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
+ }
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.req = exports.json = exports.toBuffer = void 0;
38
+ const http$1 = __importStar(__require("http"));
39
+ const https = __importStar(__require("https"));
40
+ async function toBuffer(stream) {
41
+ let length = 0;
42
+ const chunks = [];
43
+ for await (const chunk of stream) {
44
+ length += chunk.length;
45
+ chunks.push(chunk);
46
+ }
47
+ return Buffer.concat(chunks, length);
48
+ }
49
+ exports.toBuffer = toBuffer;
50
+ async function json(stream) {
51
+ const str = (await toBuffer(stream)).toString("utf8");
52
+ try {
53
+ return JSON.parse(str);
54
+ } catch (_err) {
55
+ const err = _err;
56
+ err.message += ` (input: ${str})`;
57
+ throw err;
58
+ }
59
+ }
60
+ exports.json = json;
61
+ function req(url, opts = {}) {
62
+ const req = ((typeof url === "string" ? url : url.href).startsWith("https:") ? https : http$1).request(url, opts);
63
+ const promise = new Promise((resolve, reject) => {
64
+ req.once("response", resolve).once("error", reject).end();
65
+ });
66
+ req.then = promise.then.bind(promise);
67
+ return req;
68
+ }
69
+ exports.req = req;
70
+ }));
71
+ //#endregion
72
+ //#region node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js
73
+ var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
74
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
75
+ if (k2 === void 0) k2 = k;
76
+ var desc = Object.getOwnPropertyDescriptor(m, k);
77
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
78
+ enumerable: true,
79
+ get: function() {
80
+ return m[k];
81
+ }
82
+ };
83
+ Object.defineProperty(o, k2, desc);
84
+ }) : (function(o, m, k, k2) {
85
+ if (k2 === void 0) k2 = k;
86
+ o[k2] = m[k];
87
+ }));
88
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
89
+ Object.defineProperty(o, "default", {
90
+ enumerable: true,
91
+ value: v
92
+ });
93
+ }) : function(o, v) {
94
+ o["default"] = v;
95
+ });
96
+ var __importStar = exports && exports.__importStar || function(mod) {
97
+ if (mod && mod.__esModule) return mod;
98
+ var result = {};
99
+ if (mod != null) {
100
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
101
+ }
102
+ __setModuleDefault(result, mod);
103
+ return result;
104
+ };
105
+ var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
106
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
107
+ };
108
+ Object.defineProperty(exports, "__esModule", { value: true });
109
+ exports.Agent = void 0;
110
+ const net$1 = __importStar(__require("net"));
111
+ const http = __importStar(__require("http"));
112
+ const https_1 = __require("https");
113
+ __exportStar(require_helpers(), exports);
114
+ const INTERNAL = Symbol("AgentBaseInternalState");
115
+ var Agent = class extends http.Agent {
116
+ constructor(opts) {
117
+ super(opts);
118
+ this[INTERNAL] = {};
119
+ }
120
+ /**
121
+ * Determine whether this is an `http` or `https` request.
122
+ */
123
+ isSecureEndpoint(options) {
124
+ if (options) {
125
+ if (typeof options.secureEndpoint === "boolean") return options.secureEndpoint;
126
+ if (typeof options.protocol === "string") return options.protocol === "https:";
127
+ }
128
+ const { stack } = /* @__PURE__ */ new Error();
129
+ if (typeof stack !== "string") return false;
130
+ return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
131
+ }
132
+ incrementSockets(name) {
133
+ if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) return null;
134
+ if (!this.sockets[name]) this.sockets[name] = [];
135
+ const fakeSocket = new net$1.Socket({ writable: false });
136
+ this.sockets[name].push(fakeSocket);
137
+ this.totalSocketCount++;
138
+ return fakeSocket;
139
+ }
140
+ decrementSockets(name, socket) {
141
+ if (!this.sockets[name] || socket === null) return;
142
+ const sockets = this.sockets[name];
143
+ const index = sockets.indexOf(socket);
144
+ if (index !== -1) {
145
+ sockets.splice(index, 1);
146
+ this.totalSocketCount--;
147
+ if (sockets.length === 0) delete this.sockets[name];
148
+ }
149
+ }
150
+ getName(options) {
151
+ if (this.isSecureEndpoint(options)) return https_1.Agent.prototype.getName.call(this, options);
152
+ return super.getName(options);
153
+ }
154
+ createSocket(req, options, cb) {
155
+ const connectOpts = {
156
+ ...options,
157
+ secureEndpoint: this.isSecureEndpoint(options)
158
+ };
159
+ const name = this.getName(connectOpts);
160
+ const fakeSocket = this.incrementSockets(name);
161
+ Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
162
+ this.decrementSockets(name, fakeSocket);
163
+ if (socket instanceof http.Agent) try {
164
+ return socket.addRequest(req, connectOpts);
165
+ } catch (err) {
166
+ return cb(err);
167
+ }
168
+ this[INTERNAL].currentSocket = socket;
169
+ super.createSocket(req, options, cb);
170
+ }, (err) => {
171
+ this.decrementSockets(name, fakeSocket);
172
+ cb(err);
173
+ });
174
+ }
175
+ createConnection() {
176
+ const socket = this[INTERNAL].currentSocket;
177
+ this[INTERNAL].currentSocket = void 0;
178
+ if (!socket) throw new Error("No socket was returned in the `connect()` function");
179
+ return socket;
180
+ }
181
+ get defaultPort() {
182
+ return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
183
+ }
184
+ set defaultPort(v) {
185
+ if (this[INTERNAL]) this[INTERNAL].defaultPort = v;
186
+ }
187
+ get protocol() {
188
+ return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
189
+ }
190
+ set protocol(v) {
191
+ if (this[INTERNAL]) this[INTERNAL].protocol = v;
192
+ }
193
+ };
194
+ exports.Agent = Agent;
195
+ }));
196
+ //#endregion
197
+ //#region node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/parse-proxy-response.js
198
+ var require_parse_proxy_response = /* @__PURE__ */ __commonJSMin(((exports) => {
199
+ var __importDefault = exports && exports.__importDefault || function(mod) {
200
+ return mod && mod.__esModule ? mod : { "default": mod };
201
+ };
202
+ Object.defineProperty(exports, "__esModule", { value: true });
203
+ exports.parseProxyResponse = void 0;
204
+ const debug = (0, __importDefault(require_src()).default)("https-proxy-agent:parse-proxy-response");
205
+ function parseProxyResponse(socket) {
206
+ return new Promise((resolve, reject) => {
207
+ let buffersLength = 0;
208
+ const buffers = [];
209
+ function read() {
210
+ const b = socket.read();
211
+ if (b) ondata(b);
212
+ else socket.once("readable", read);
213
+ }
214
+ function cleanup() {
215
+ socket.removeListener("end", onend);
216
+ socket.removeListener("error", onerror);
217
+ socket.removeListener("readable", read);
218
+ }
219
+ function onend() {
220
+ cleanup();
221
+ debug("onend");
222
+ reject(/* @__PURE__ */ new Error("Proxy connection ended before receiving CONNECT response"));
223
+ }
224
+ function onerror(err) {
225
+ cleanup();
226
+ debug("onerror %o", err);
227
+ reject(err);
228
+ }
229
+ function ondata(b) {
230
+ buffers.push(b);
231
+ buffersLength += b.length;
232
+ const buffered = Buffer.concat(buffers, buffersLength);
233
+ const endOfHeaders = buffered.indexOf("\r\n\r\n");
234
+ if (endOfHeaders === -1) {
235
+ debug("have not received end of HTTP headers yet...");
236
+ read();
237
+ return;
238
+ }
239
+ const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
240
+ const firstLine = headerParts.shift();
241
+ if (!firstLine) {
242
+ socket.destroy();
243
+ return reject(/* @__PURE__ */ new Error("No header received from proxy CONNECT response"));
244
+ }
245
+ const firstLineParts = firstLine.split(" ");
246
+ const statusCode = +firstLineParts[1];
247
+ const statusText = firstLineParts.slice(2).join(" ");
248
+ const headers = {};
249
+ for (const header of headerParts) {
250
+ if (!header) continue;
251
+ const firstColon = header.indexOf(":");
252
+ if (firstColon === -1) {
253
+ socket.destroy();
254
+ return reject(/* @__PURE__ */ new Error(`Invalid header from proxy CONNECT response: "${header}"`));
255
+ }
256
+ const key = header.slice(0, firstColon).toLowerCase();
257
+ const value = header.slice(firstColon + 1).trimStart();
258
+ const current = headers[key];
259
+ if (typeof current === "string") headers[key] = [current, value];
260
+ else if (Array.isArray(current)) current.push(value);
261
+ else headers[key] = value;
262
+ }
263
+ debug("got proxy server response: %o %o", firstLine, headers);
264
+ cleanup();
265
+ resolve({
266
+ connect: {
267
+ statusCode,
268
+ statusText,
269
+ headers
270
+ },
271
+ buffered
272
+ });
273
+ }
274
+ socket.on("error", onerror);
275
+ socket.on("end", onend);
276
+ read();
277
+ });
278
+ }
279
+ exports.parseProxyResponse = parseProxyResponse;
280
+ }));
281
+ //#endregion
282
+ //#region node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js
283
+ var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
284
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
285
+ if (k2 === void 0) k2 = k;
286
+ var desc = Object.getOwnPropertyDescriptor(m, k);
287
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
288
+ enumerable: true,
289
+ get: function() {
290
+ return m[k];
291
+ }
292
+ };
293
+ Object.defineProperty(o, k2, desc);
294
+ }) : (function(o, m, k, k2) {
295
+ if (k2 === void 0) k2 = k;
296
+ o[k2] = m[k];
297
+ }));
298
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
299
+ Object.defineProperty(o, "default", {
300
+ enumerable: true,
301
+ value: v
302
+ });
303
+ }) : function(o, v) {
304
+ o["default"] = v;
305
+ });
306
+ var __importStar = exports && exports.__importStar || function(mod) {
307
+ if (mod && mod.__esModule) return mod;
308
+ var result = {};
309
+ if (mod != null) {
310
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
311
+ }
312
+ __setModuleDefault(result, mod);
313
+ return result;
314
+ };
315
+ var __importDefault = exports && exports.__importDefault || function(mod) {
316
+ return mod && mod.__esModule ? mod : { "default": mod };
317
+ };
318
+ Object.defineProperty(exports, "__esModule", { value: true });
319
+ exports.HttpsProxyAgent = void 0;
320
+ const net = __importStar(__require("net"));
321
+ const tls = __importStar(__require("tls"));
322
+ const assert_1 = __importDefault(__require("assert"));
323
+ const debug_1 = __importDefault(require_src());
324
+ const agent_base_1 = require_dist$1();
325
+ const url_1 = __require("url");
326
+ const parse_proxy_response_1 = require_parse_proxy_response();
327
+ const debug = (0, debug_1.default)("https-proxy-agent");
328
+ const setServernameFromNonIpHost = (options) => {
329
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) return {
330
+ ...options,
331
+ servername: options.host
332
+ };
333
+ return options;
334
+ };
335
+ /**
336
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
337
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
338
+ *
339
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
340
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
341
+ * and then the proxy server connects to the destination target and issues the
342
+ * HTTP request from the proxy server.
343
+ *
344
+ * `https:` requests have their socket connection upgraded to TLS once
345
+ * the connection to the proxy server has been established.
346
+ */
347
+ var HttpsProxyAgent = class extends agent_base_1.Agent {
348
+ constructor(proxy, opts) {
349
+ super(opts);
350
+ this.options = { path: void 0 };
351
+ this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
352
+ this.proxyHeaders = opts?.headers ?? {};
353
+ debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
354
+ const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
355
+ const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
356
+ this.connectOpts = {
357
+ ALPNProtocols: ["http/1.1"],
358
+ ...opts ? omit(opts, "headers") : null,
359
+ host,
360
+ port
361
+ };
362
+ }
363
+ /**
364
+ * Called when the node-core HTTP client library is creating a
365
+ * new HTTP request.
366
+ */
367
+ async connect(req, opts) {
368
+ const { proxy } = this;
369
+ if (!opts.host) throw new TypeError("No \"host\" provided");
370
+ let socket;
371
+ if (proxy.protocol === "https:") {
372
+ debug("Creating `tls.Socket`: %o", this.connectOpts);
373
+ socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
374
+ } else {
375
+ debug("Creating `net.Socket`: %o", this.connectOpts);
376
+ socket = net.connect(this.connectOpts);
377
+ }
378
+ const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
379
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
380
+ let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`;
381
+ if (proxy.username || proxy.password) {
382
+ const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
383
+ headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
384
+ }
385
+ headers.Host = `${host}:${opts.port}`;
386
+ if (!headers["Proxy-Connection"]) headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
387
+ for (const name of Object.keys(headers)) payload += `${name}: ${headers[name]}\r\n`;
388
+ const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
389
+ socket.write(`${payload}\r\n`);
390
+ const { connect, buffered } = await proxyResponsePromise;
391
+ req.emit("proxyConnect", connect);
392
+ this.emit("proxyConnect", connect, req);
393
+ if (connect.statusCode === 200) {
394
+ req.once("socket", resume);
395
+ if (opts.secureEndpoint) {
396
+ debug("Upgrading socket connection to TLS");
397
+ return tls.connect({
398
+ ...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
399
+ socket
400
+ });
401
+ }
402
+ return socket;
403
+ }
404
+ socket.destroy();
405
+ const fakeSocket = new net.Socket({ writable: false });
406
+ fakeSocket.readable = true;
407
+ req.once("socket", (s) => {
408
+ debug("Replaying proxy buffer for failed request");
409
+ (0, assert_1.default)(s.listenerCount("data") > 0);
410
+ s.push(buffered);
411
+ s.push(null);
412
+ });
413
+ return fakeSocket;
414
+ }
415
+ };
416
+ HttpsProxyAgent.protocols = ["http", "https"];
417
+ exports.HttpsProxyAgent = HttpsProxyAgent;
418
+ function resume(socket) {
419
+ socket.resume();
420
+ }
421
+ function omit(obj, ...keys) {
422
+ const ret = {};
423
+ let key;
424
+ for (key in obj) if (!keys.includes(key)) ret[key] = obj[key];
425
+ return ret;
426
+ }
427
+ }));
428
+ //#endregion
429
+ export { require_dist as t };