openclaw-multi-auto 1.6.2 → 1.6.6

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 (182) hide show
  1. package/dist/{accounts-L9ByEpnP.js → accounts-C9HcPI9h.js} +2 -2
  2. package/dist/{accounts-BOzyfwW4.js → accounts-C_lW3Ag9.js} +2 -2
  3. package/dist/{accounts-yfBeCZtS.js → accounts-Tgelvk0C.js} +17 -17
  4. package/dist/{active-listener-D1yqT1cw.js → active-listener-BEdprTkn.js} +2 -2
  5. package/dist/{api-key-rotation-DtsNS2Nb.js → api-key-rotation-BJpKWXy0.js} +2 -2
  6. package/dist/{audio-preflight-DoPfNXDz.js → audio-preflight-BMvgEQ5j.js} +32 -32
  7. package/dist/{audio-transcription-runner-CzjuH3uL.js → audio-transcription-runner-gLFfz8fr.js} +12 -12
  8. package/dist/{audit-membership-runtime-DWyHWAHM.js → audit-membership-runtime-Dntemq07.js} +4 -4
  9. package/dist/build-info.json +3 -3
  10. package/dist/bundled/boot-md/handler.js +51 -51
  11. package/dist/bundled/bootstrap-extra-files/handler.js +6 -6
  12. package/dist/bundled/command-logger/handler.js +2 -2
  13. package/dist/bundled/session-memory/handler.js +51 -51
  14. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  15. package/dist/{channel-activity-xHOMiarp.js → channel-activity-BDnjYF7B.js} +3 -3
  16. package/dist/{chrome-DlhJHqj8.js → chrome-DxxEKrY7.js} +26 -26
  17. package/dist/{commands-registry-V1zZ5pPC.js → commands-registry-D5qXbFJn.js} +4 -4
  18. package/dist/{deliver-CApVJA_l.js → deliver-DbdywYJE.js} +21 -21
  19. package/dist/deliver-runtime-BFs7iAZF.js +36 -0
  20. package/dist/deps-send-discord.runtime-DZUccI6Z.js +26 -0
  21. package/dist/deps-send-imessage.runtime-CF3OpoqY.js +25 -0
  22. package/dist/deps-send-signal.runtime-Cw4-ozeO.js +24 -0
  23. package/dist/deps-send-slack.runtime-BDsDhS1P.js +22 -0
  24. package/dist/deps-send-telegram.runtime-D_4xVasO.js +27 -0
  25. package/dist/deps-send-whatsapp.runtime-DK8jqd14.js +60 -0
  26. package/dist/{diagnostic-Bn4PZjMZ.js → diagnostic-Co6Kghr-.js} +2 -2
  27. package/dist/{errors-CCLeFWAg.js → errors-xt401nuk.js} +1 -1
  28. package/dist/{fetch-BlJWzEP6.js → fetch-DuraYswo.js} +5 -5
  29. package/dist/{fetch-guard-ChYBwfiy.js → fetch-guard-DWr0d00H.js} +2 -2
  30. package/dist/{frontmatter-CvaMP376.js → frontmatter-BkTfEZ93.js} +3 -3
  31. package/dist/{fs-safe-0jAo_Whb.js → fs-safe-CTYUrIgQ.js} +4 -4
  32. package/dist/{github-copilot-token-D13V9YBz.js → github-copilot-token-BDioPmd6.js} +7 -7
  33. package/dist/{image-B3Mz7N5I.js → image-eT7Y-nP5.js} +6 -6
  34. package/dist/{image-ops-CehkHxmW.js → image-ops-BuUnEOE0.js} +2 -2
  35. package/dist/image-runtime-BcAK3n8a.js +29 -0
  36. package/dist/{ir-DAP-B-Xw.js → ir-B83looB-.js} +8 -8
  37. package/dist/{legacy-names-TyzbVqa_.js → legacy-names-DOC03BkU.js} +1 -1
  38. package/dist/llm-slug-generator.js +51 -51
  39. package/dist/{logger-DMZQQtxK.js → logger-BfjWMCSD.js} +7 -7
  40. package/dist/{login-DiCctRo1.js → login-CrIwcrVI.js} +5 -5
  41. package/dist/{login-qr-MUbXgjtd.js → login-qr-BpPDZdl_.js} +10 -10
  42. package/dist/{manager-BW_NSIMl.js → manager-1bvuGrNR.js} +13 -13
  43. package/dist/manager-runtime-FO1Sx3W8.js +18 -0
  44. package/dist/{model-selection-idoqPmw0.js → model-selection-Dna0Gz1k.js} +43 -43
  45. package/dist/{outbound-C2kanETZ.js → outbound-ChDjtuD6.js} +6 -6
  46. package/dist/{outbound-attachment-DBrYWX8h.js → outbound-attachment-DqHlD21U.js} +2 -2
  47. package/dist/{path-alias-guards-DqXRZmsL.js → path-alias-guards-BzvdLvTI.js} +1 -1
  48. package/dist/{paths-CCxysrzL.js → paths-Bkr-BCxW.js} +4 -4
  49. package/dist/{paths-C6TxBCvO.js → paths-Cvc9EM8Y.js} +5 -5
  50. package/dist/{pi-embedded-bcjMe3wj.js → pi-embedded-BQQa91aA.js} +167 -167
  51. package/dist/{pi-embedded-helpers-D5yyGEvA.js → pi-embedded-helpers-CLXm10bV.js} +52 -52
  52. package/dist/{plugin-sdk/pi-model-discovery-v-XPUOOf.js → pi-model-discovery-Dymwdjt0.js} +2 -2
  53. package/dist/pi-model-discovery-runtime-BeY4EUPp.js +11 -0
  54. package/dist/{pi-tools.before-tool-call.runtime-BuLxSyx9.js → pi-tools.before-tool-call.runtime-Cwab_5W1.js} +9 -9
  55. package/dist/plugin-sdk/compat.js +50 -50
  56. package/dist/plugin-sdk/discord.js +6 -6
  57. package/dist/plugin-sdk/slack.js +2 -2
  58. package/dist/{plugins-CWkRQYDj.js → plugins-4Rj4OjLY.js} +11 -11
  59. package/dist/{proxy-env-Cq5gdrbj.js → proxy-env-DlmzDx8x.js} +1 -1
  60. package/dist/{proxy-fetch-CCjEYbFm.js → proxy-fetch-B2pEfjbR.js} +1 -1
  61. package/dist/{pw-ai-CDQDCfUa.js → pw-ai-DNMjFMqH.js} +14 -14
  62. package/dist/{qmd-manager-BsYsO9Ii.js → qmd-manager-BtIKUaO9.js} +10 -10
  63. package/dist/{query-expansion-DtLc3wjL.js → query-expansion-CX-1fS52.js} +6 -6
  64. package/dist/{plugin-sdk/redact-DjVX-1N3.js → redact-COik8ET1.js} +1 -1
  65. package/dist/{run-with-concurrency-D_ZpbgEG.js → run-with-concurrency-BgYfgkXT.js} +4 -4
  66. package/dist/runtime-whatsapp-login.runtime-DUb55byQ.js +13 -0
  67. package/dist/runtime-whatsapp-outbound.runtime-Bii_xSfI.js +22 -0
  68. package/dist/{send-Dx2RkUOZ.js → send-6lz6rNVP.js} +6 -6
  69. package/dist/{send-vmONuVgL.js → send-BHTiZcH3.js} +26 -26
  70. package/dist/{send-Bj776ESJ.js → send-L7gRiwyd.js} +7 -7
  71. package/dist/{send-DcxmcFi_.js → send-PE6cwoTe.js} +8 -8
  72. package/dist/{send-BQERFNyo.js → send-dfu6_rgf.js} +5 -5
  73. package/dist/{session-A4QhBRvH.js → session-D8ImowSs.js} +8 -8
  74. package/dist/{skill-commands-CMzBZKG2.js → skill-commands-DNqJ-kwn.js} +9 -9
  75. package/dist/{skills-CE_iqvM5.js → skills-7ODkHQYp.js} +22 -22
  76. package/dist/slash-commands.runtime-CVw6566g.js +16 -0
  77. package/dist/slash-dispatch.runtime-B9Ygtzi4.js +56 -0
  78. package/dist/slash-skill-commands.runtime-DxZ4z5h6.js +20 -0
  79. package/dist/{store--eR1R_UX.js → store-D89wDcz9.js} +2 -2
  80. package/dist/subagent-registry-runtime-DL1Wv7nA.js +56 -0
  81. package/dist/{subsystem-Di1z8l0Z.js → subsystem-B45WV3qB.js} +14 -14
  82. package/dist/{tables-d739Y1xW.js → tables-mE4cJBN2.js} +1 -1
  83. package/dist/{plugin-sdk/target-errors-Blia4S69.js → target-errors-mnlwhAjP.js} +2 -2
  84. package/dist/{thinking-DXYisHiZ.js → thinking-BeGmb5k6.js} +7 -7
  85. package/dist/{tokens-DxnY9ui_.js → tokens-q32vI39c.js} +1 -1
  86. package/dist/{tool-images-2cBx1W8h.js → tool-images-RZdHiZcG.js} +2 -2
  87. package/dist/{web-NWKn8ABz.js → web-Btj-e8kN.js} +55 -55
  88. package/dist/{whatsapp-actions-iEArE_Ez.js → whatsapp-actions-BHbJJyqw.js} +21 -21
  89. package/dist/{workspace-CUVC6GX1.js → workspace-U-DyR64O.js} +20 -20
  90. package/package.json +1 -1
  91. package/scripts/create-instance.sh +93 -96
  92. package/dist/deliver-runtime-D1z-h5eg.js +0 -36
  93. package/dist/deps-send-discord.runtime-DnbhTFX9.js +0 -26
  94. package/dist/deps-send-imessage.runtime-BOiQ6mDx.js +0 -25
  95. package/dist/deps-send-signal.runtime-CTcl388M.js +0 -24
  96. package/dist/deps-send-slack.runtime-CCqBz4Kg.js +0 -22
  97. package/dist/deps-send-telegram.runtime-DGSKTCpH.js +0 -27
  98. package/dist/deps-send-whatsapp.runtime-Dz_4fi2D.js +0 -60
  99. package/dist/image-runtime-DWjhow2W.js +0 -29
  100. package/dist/manager-runtime-BN6VevdC.js +0 -18
  101. package/dist/pi-model-discovery-BGgOlX8N.js +0 -134
  102. package/dist/pi-model-discovery-runtime-Bwmi4Ev8.js +0 -11
  103. package/dist/plugin-sdk/accounts-CJWOBzwB.js +0 -35
  104. package/dist/plugin-sdk/accounts-DP1-L-QS.js +0 -288
  105. package/dist/plugin-sdk/accounts-DZhWlEg3.js +0 -46
  106. package/dist/plugin-sdk/active-listener-B_sLJTXM.js +0 -50
  107. package/dist/plugin-sdk/api-key-rotation-BRE4X2tf.js +0 -181
  108. package/dist/plugin-sdk/audio-preflight-DGEUDxxR.js +0 -69
  109. package/dist/plugin-sdk/audio-transcription-runner-DkoPNPYt.js +0 -2176
  110. package/dist/plugin-sdk/audit-membership-runtime-DSBHHw7o.js +0 -58
  111. package/dist/plugin-sdk/channel-activity-F3d0yUwy.js +0 -94
  112. package/dist/plugin-sdk/channel-web-QF7EpjeP.js +0 -2256
  113. package/dist/plugin-sdk/chrome-BXoCyCkY.js +0 -2415
  114. package/dist/plugin-sdk/commands-registry-t7cXBTfN.js +0 -1125
  115. package/dist/plugin-sdk/config-BkEnz2Po.js +0 -17913
  116. package/dist/plugin-sdk/deliver-B6AG_l67.js +0 -1694
  117. package/dist/plugin-sdk/deliver-runtime-D585kJZc.js +0 -32
  118. package/dist/plugin-sdk/deps-send-discord.runtime-a_OKY2js.js +0 -23
  119. package/dist/plugin-sdk/deps-send-imessage.runtime-Baxy9TD4.js +0 -22
  120. package/dist/plugin-sdk/deps-send-signal.runtime-BwXoCrFl.js +0 -21
  121. package/dist/plugin-sdk/deps-send-slack.runtime-CLmKjgso.js +0 -19
  122. package/dist/plugin-sdk/deps-send-telegram.runtime-BKfdBKnZ.js +0 -24
  123. package/dist/plugin-sdk/deps-send-whatsapp.runtime-BOTwkbx_.js +0 -57
  124. package/dist/plugin-sdk/diagnostic-CsP-lEkI.js +0 -319
  125. package/dist/plugin-sdk/errors-DaiAM-yU.js +0 -54
  126. package/dist/plugin-sdk/fetch-guard-DETCcJzQ.js +0 -156
  127. package/dist/plugin-sdk/fs-safe-B8y811FR.js +0 -352
  128. package/dist/plugin-sdk/image-DjTEkYZE.js +0 -2310
  129. package/dist/plugin-sdk/image-ops-BSiMpAw4.js +0 -584
  130. package/dist/plugin-sdk/image-runtime-6xPp8m5a.js +0 -25
  131. package/dist/plugin-sdk/ir-DQ7_HbvK.js +0 -1296
  132. package/dist/plugin-sdk/local-roots-BUP4YBmR.js +0 -186
  133. package/dist/plugin-sdk/logger-CZY9KIoY.js +0 -1163
  134. package/dist/plugin-sdk/login-BxEKLlCo.js +0 -57
  135. package/dist/plugin-sdk/login-qr-BQIpMPr9.js +0 -320
  136. package/dist/plugin-sdk/manager-I6KbPihW.js +0 -3917
  137. package/dist/plugin-sdk/manager-runtime-CFfYYWIQ.js +0 -15
  138. package/dist/plugin-sdk/outbound-NS6UHnB6.js +0 -212
  139. package/dist/plugin-sdk/outbound-attachment-Dy6fyf6H.js +0 -19
  140. package/dist/plugin-sdk/path-alias-guards-DBjLbIX_.js +0 -43
  141. package/dist/plugin-sdk/paths-vTM3Lh3X.js +0 -166
  142. package/dist/plugin-sdk/pi-embedded-helpers-1R1gu7eX.js +0 -9627
  143. package/dist/plugin-sdk/pi-model-discovery-runtime-Do9o-dUd.js +0 -8
  144. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-D4sFsIks.js +0 -354
  145. package/dist/plugin-sdk/plugins-DeBZB9l_.js +0 -864
  146. package/dist/plugin-sdk/proxy-fetch-ChxOhWF4.js +0 -38
  147. package/dist/plugin-sdk/pw-ai-DEOmCSSC.js +0 -1938
  148. package/dist/plugin-sdk/qmd-manager-HyYKoEch.js +0 -1448
  149. package/dist/plugin-sdk/query-expansion-CeyKUeDW.js +0 -1011
  150. package/dist/plugin-sdk/reply-DAo_Jt8K.js +0 -97916
  151. package/dist/plugin-sdk/resolve-outbound-target-B42qgQS9.js +0 -40
  152. package/dist/plugin-sdk/run-with-concurrency-Bt_ks0Qa.js +0 -1994
  153. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-B6W989eF.js +0 -10
  154. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-c_GDFy37.js +0 -19
  155. package/dist/plugin-sdk/send-CQpMudwO.js +0 -2587
  156. package/dist/plugin-sdk/send-DQHLzVyO.js +0 -414
  157. package/dist/plugin-sdk/send-DTB24bEF.js +0 -3135
  158. package/dist/plugin-sdk/send-DfHadjZ_.js +0 -503
  159. package/dist/plugin-sdk/send-XXlW2iny.js +0 -540
  160. package/dist/plugin-sdk/session-6TF6MyaC.js +0 -169
  161. package/dist/plugin-sdk/skill-commands-CkGeFUMl.js +0 -342
  162. package/dist/plugin-sdk/skills-CBkHBYPq.js +0 -1428
  163. package/dist/plugin-sdk/slash-commands.runtime-CxliuGaP.js +0 -13
  164. package/dist/plugin-sdk/slash-dispatch.runtime-DFaeYlJQ.js +0 -52
  165. package/dist/plugin-sdk/slash-skill-commands.runtime-0M0OLCxq.js +0 -16
  166. package/dist/plugin-sdk/ssrf-cFtplYtS.js +0 -202
  167. package/dist/plugin-sdk/store-5nyxY3WU.js +0 -81
  168. package/dist/plugin-sdk/subagent-registry-runtime-DCtmDwna.js +0 -52
  169. package/dist/plugin-sdk/tables-C47P4GTN.js +0 -55
  170. package/dist/plugin-sdk/thinking-Bo2eosVa.js +0 -1206
  171. package/dist/plugin-sdk/tokens-DgNRBwIg.js +0 -52
  172. package/dist/plugin-sdk/tool-images-Gk_-0y2N.js +0 -274
  173. package/dist/plugin-sdk/web-CVxZbXyH.js +0 -56
  174. package/dist/plugin-sdk/whatsapp-actions-Bw0H9g-n.js +0 -80
  175. package/dist/redact-ClbcYG1J.js +0 -319
  176. package/dist/runtime-whatsapp-login.runtime-IeylZEl4.js +0 -13
  177. package/dist/runtime-whatsapp-outbound.runtime-ClBRuLsq.js +0 -22
  178. package/dist/slash-commands.runtime-Cpn2tYW4.js +0 -16
  179. package/dist/slash-dispatch.runtime-CWbpp23S.js +0 -56
  180. package/dist/slash-skill-commands.runtime-DKMvvdDW.js +0 -20
  181. package/dist/subagent-registry-runtime-DEVpAaAP.js +0 -56
  182. package/dist/target-errors-CBI2Ga0y.js +0 -195
@@ -1,134 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
- import { c as normalizeProviderId, nr as ensureAuthProfileStore } from "./model-selection-idoqPmw0.js";
3
- import path from "node:path";
4
- import syncFs from "node:fs";
5
- import * as PiCodingAgent from "@mariozechner/pi-coding-agent";
6
-
7
- //#region src/agents/pi-auth-credentials.ts
8
- function convertAuthProfileCredentialToPi(cred) {
9
- if (cred.type === "api_key") {
10
- const key = typeof cred.key === "string" ? cred.key.trim() : "";
11
- if (!key) return null;
12
- return {
13
- type: "api_key",
14
- key
15
- };
16
- }
17
- if (cred.type === "token") {
18
- const token = typeof cred.token === "string" ? cred.token.trim() : "";
19
- if (!token) return null;
20
- if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && Date.now() >= cred.expires) return null;
21
- return {
22
- type: "api_key",
23
- key: token
24
- };
25
- }
26
- if (cred.type === "oauth") {
27
- const access = typeof cred.access === "string" ? cred.access.trim() : "";
28
- const refresh = typeof cred.refresh === "string" ? cred.refresh.trim() : "";
29
- if (!access || !refresh || !Number.isFinite(cred.expires) || cred.expires <= 0) return null;
30
- return {
31
- type: "oauth",
32
- access,
33
- refresh,
34
- expires: cred.expires
35
- };
36
- }
37
- return null;
38
- }
39
- function resolvePiCredentialMapFromStore(store) {
40
- const credentials = {};
41
- for (const credential of Object.values(store.profiles)) {
42
- const provider = normalizeProviderId(String(credential.provider ?? "")).trim();
43
- if (!provider || credentials[provider]) continue;
44
- const converted = convertAuthProfileCredentialToPi(credential);
45
- if (converted) credentials[provider] = converted;
46
- }
47
- return credentials;
48
- }
49
-
50
- //#endregion
51
- //#region src/agents/pi-model-discovery.ts
52
- var pi_model_discovery_exports = /* @__PURE__ */ __exportAll({
53
- AuthStorage: () => PiAuthStorageClass,
54
- ModelRegistry: () => PiModelRegistryClass,
55
- discoverAuthStorage: () => discoverAuthStorage,
56
- discoverModels: () => discoverModels
57
- });
58
- const PiAuthStorageClass = PiCodingAgent.AuthStorage;
59
- const PiModelRegistryClass = PiCodingAgent.ModelRegistry;
60
- function createInMemoryAuthStorageBackend(initialData) {
61
- let snapshot = JSON.stringify(initialData, null, 2);
62
- return { withLock(update) {
63
- const { result, next } = update(snapshot);
64
- if (typeof next === "string") snapshot = next;
65
- return result;
66
- } };
67
- }
68
- function isRecord(value) {
69
- return typeof value === "object" && value !== null && !Array.isArray(value);
70
- }
71
- function scrubLegacyStaticAuthJsonEntries(pathname) {
72
- if (process.env.OPENCLAW_AUTH_STORE_READONLY === "1") return;
73
- if (!syncFs.existsSync(pathname)) return;
74
- let parsed;
75
- try {
76
- parsed = JSON.parse(syncFs.readFileSync(pathname, "utf8"));
77
- } catch {
78
- return;
79
- }
80
- if (!isRecord(parsed)) return;
81
- let changed = false;
82
- for (const [provider, value] of Object.entries(parsed)) {
83
- if (!isRecord(value)) continue;
84
- if (value.type !== "api_key") continue;
85
- delete parsed[provider];
86
- changed = true;
87
- }
88
- if (!changed) return;
89
- if (Object.keys(parsed).length === 0) {
90
- syncFs.rmSync(pathname, { force: true });
91
- return;
92
- }
93
- syncFs.writeFileSync(pathname, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
94
- syncFs.chmodSync(pathname, 384);
95
- }
96
- function createAuthStorage(AuthStorageLike, path, creds) {
97
- const withInMemory = AuthStorageLike;
98
- if (typeof withInMemory.inMemory === "function") return withInMemory.inMemory(creds);
99
- const withFromStorage = AuthStorageLike;
100
- if (typeof withFromStorage.fromStorage === "function") {
101
- const backendCtor = PiCodingAgent.InMemoryAuthStorageBackend;
102
- const backend = typeof backendCtor === "function" ? new backendCtor() : createInMemoryAuthStorageBackend(creds);
103
- backend.withLock(() => ({
104
- result: void 0,
105
- next: JSON.stringify(creds, null, 2)
106
- }));
107
- return withFromStorage.fromStorage(backend);
108
- }
109
- const withFactory = AuthStorageLike;
110
- const withRuntimeOverride = typeof withFactory.create === "function" ? withFactory.create(path) : new AuthStorageLike(path);
111
- if (typeof withRuntimeOverride.setRuntimeApiKey === "function") for (const [provider, credential] of Object.entries(creds)) {
112
- if (credential.type === "api_key") {
113
- withRuntimeOverride.setRuntimeApiKey(provider, credential.key);
114
- continue;
115
- }
116
- withRuntimeOverride.setRuntimeApiKey(provider, credential.access);
117
- }
118
- return withRuntimeOverride;
119
- }
120
- function resolvePiCredentials(agentDir) {
121
- return resolvePiCredentialMapFromStore(ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false }));
122
- }
123
- function discoverAuthStorage(agentDir) {
124
- const credentials = resolvePiCredentials(agentDir);
125
- const authPath = path.join(agentDir, "auth.json");
126
- scrubLegacyStaticAuthJsonEntries(authPath);
127
- return createAuthStorage(PiAuthStorageClass, authPath, credentials);
128
- }
129
- function discoverModels(authStorage, agentDir) {
130
- return new PiModelRegistryClass(authStorage, path.join(agentDir, "models.json"));
131
- }
132
-
133
- //#endregion
134
- export { discoverModels as n, pi_model_discovery_exports as r, discoverAuthStorage as t };
@@ -1,11 +0,0 @@
1
- import "./run-with-concurrency-D_ZpbgEG.js";
2
- import "./paths-C6TxBCvO.js";
3
- import "./subsystem-Di1z8l0Z.js";
4
- import "./workspace-CUVC6GX1.js";
5
- import "./logger-DMZQQtxK.js";
6
- import "./model-selection-idoqPmw0.js";
7
- import "./github-copilot-token-D13V9YBz.js";
8
- import "./legacy-names-TyzbVqa_.js";
9
- import { n as discoverModels, t as discoverAuthStorage } from "./pi-model-discovery-BGgOlX8N.js";
10
-
11
- export { discoverAuthStorage, discoverModels };
@@ -1,35 +0,0 @@
1
- import { ot as normalizeAccountId } from "./run-with-concurrency-Bt_ks0Qa.js";
2
- import { v as resolveAccountEntry, y as createAccountListHelpers } from "./accounts-DP1-L-QS.js";
3
-
4
- //#region src/imessage/accounts.ts
5
- const { listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("imessage");
6
- const listIMessageAccountIds = listAccountIds;
7
- const resolveDefaultIMessageAccountId = resolveDefaultAccountId;
8
- function resolveAccountConfig(cfg, accountId) {
9
- return resolveAccountEntry(cfg.channels?.imessage?.accounts, accountId);
10
- }
11
- function mergeIMessageAccountConfig(cfg, accountId) {
12
- const { accounts: _ignored, ...base } = cfg.channels?.imessage ?? {};
13
- const account = resolveAccountConfig(cfg, accountId) ?? {};
14
- return {
15
- ...base,
16
- ...account
17
- };
18
- }
19
- function resolveIMessageAccount(params) {
20
- const accountId = normalizeAccountId(params.accountId);
21
- const baseEnabled = params.cfg.channels?.imessage?.enabled !== false;
22
- const merged = mergeIMessageAccountConfig(params.cfg, accountId);
23
- const accountEnabled = merged.enabled !== false;
24
- const configured = Boolean(merged.cliPath?.trim() || merged.dbPath?.trim() || merged.service || merged.region?.trim() || merged.allowFrom && merged.allowFrom.length > 0 || merged.groupAllowFrom && merged.groupAllowFrom.length > 0 || merged.dmPolicy || merged.groupPolicy || typeof merged.includeAttachments === "boolean" || merged.attachmentRoots && merged.attachmentRoots.length > 0 || merged.remoteAttachmentRoots && merged.remoteAttachmentRoots.length > 0 || typeof merged.mediaMaxMb === "number" || typeof merged.textChunkLimit === "number" || merged.groups && Object.keys(merged.groups).length > 0);
25
- return {
26
- accountId,
27
- enabled: baseEnabled && accountEnabled,
28
- name: merged.name?.trim() || void 0,
29
- config: merged,
30
- configured
31
- };
32
- }
33
-
34
- //#endregion
35
- export { resolveDefaultIMessageAccountId as n, resolveIMessageAccount as r, listIMessageAccountIds as t };
@@ -1,288 +0,0 @@
1
- import { at as DEFAULT_ACCOUNT_ID, ot as normalizeAccountId, st as normalizeOptionalAccountId } from "./run-with-concurrency-Bt_ks0Qa.js";
2
- import { o as resolveOAuthDir } from "./paths-MKyEVmEb.js";
3
- import { Pr as formatCliCommand } from "./config-BkEnz2Po.js";
4
- import { B as success, E as resolveUserPath, G as getChildLogger, I as info, c as defaultRuntime, x as jidToE164 } from "./logger-CZY9KIoY.js";
5
- import fs from "node:fs";
6
- import path from "node:path";
7
- import fs$1 from "node:fs/promises";
8
-
9
- //#region src/channels/plugins/account-helpers.ts
10
- function createAccountListHelpers(channelKey) {
11
- function resolveConfiguredDefaultAccountId(cfg) {
12
- const channel = cfg.channels?.[channelKey];
13
- const preferred = normalizeOptionalAccountId(typeof channel?.defaultAccount === "string" ? channel.defaultAccount : void 0);
14
- if (!preferred) return;
15
- if (listAccountIds(cfg).some((id) => normalizeAccountId(id) === preferred)) return preferred;
16
- }
17
- function listConfiguredAccountIds(cfg) {
18
- const accounts = (cfg.channels?.[channelKey])?.accounts;
19
- if (!accounts || typeof accounts !== "object") return [];
20
- return Object.keys(accounts).filter(Boolean);
21
- }
22
- function listAccountIds(cfg) {
23
- const ids = listConfiguredAccountIds(cfg);
24
- if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
25
- return ids.toSorted((a, b) => a.localeCompare(b));
26
- }
27
- function resolveDefaultAccountId(cfg) {
28
- const preferred = resolveConfiguredDefaultAccountId(cfg);
29
- if (preferred) return preferred;
30
- const ids = listAccountIds(cfg);
31
- if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
32
- return ids[0] ?? DEFAULT_ACCOUNT_ID;
33
- }
34
- return {
35
- listConfiguredAccountIds,
36
- listAccountIds,
37
- resolveDefaultAccountId
38
- };
39
- }
40
-
41
- //#endregion
42
- //#region src/routing/account-lookup.ts
43
- function resolveAccountEntry(accounts, accountId) {
44
- if (!accounts || typeof accounts !== "object") return;
45
- if (Object.hasOwn(accounts, accountId)) return accounts[accountId];
46
- const normalized = accountId.toLowerCase();
47
- const matchKey = Object.keys(accounts).find((key) => key.toLowerCase() === normalized);
48
- return matchKey ? accounts[matchKey] : void 0;
49
- }
50
-
51
- //#endregion
52
- //#region src/web/auth-store.ts
53
- function resolveDefaultWebAuthDir() {
54
- return path.join(resolveOAuthDir(), "whatsapp", DEFAULT_ACCOUNT_ID);
55
- }
56
- const WA_WEB_AUTH_DIR = resolveDefaultWebAuthDir();
57
- function resolveWebCredsPath(authDir) {
58
- return path.join(authDir, "creds.json");
59
- }
60
- function resolveWebCredsBackupPath(authDir) {
61
- return path.join(authDir, "creds.json.bak");
62
- }
63
- function hasWebCredsSync(authDir) {
64
- try {
65
- const stats = fs.statSync(resolveWebCredsPath(authDir));
66
- return stats.isFile() && stats.size > 1;
67
- } catch {
68
- return false;
69
- }
70
- }
71
- function readCredsJsonRaw(filePath) {
72
- try {
73
- if (!fs.existsSync(filePath)) return null;
74
- const stats = fs.statSync(filePath);
75
- if (!stats.isFile() || stats.size <= 1) return null;
76
- return fs.readFileSync(filePath, "utf-8");
77
- } catch {
78
- return null;
79
- }
80
- }
81
- function maybeRestoreCredsFromBackup(authDir) {
82
- const logger = getChildLogger({ module: "web-session" });
83
- try {
84
- const credsPath = resolveWebCredsPath(authDir);
85
- const backupPath = resolveWebCredsBackupPath(authDir);
86
- const raw = readCredsJsonRaw(credsPath);
87
- if (raw) {
88
- JSON.parse(raw);
89
- return;
90
- }
91
- const backupRaw = readCredsJsonRaw(backupPath);
92
- if (!backupRaw) return;
93
- JSON.parse(backupRaw);
94
- fs.copyFileSync(backupPath, credsPath);
95
- try {
96
- fs.chmodSync(credsPath, 384);
97
- } catch {}
98
- logger.warn({ credsPath }, "restored corrupted WhatsApp creds.json from backup");
99
- } catch {}
100
- }
101
- async function webAuthExists(authDir = resolveDefaultWebAuthDir()) {
102
- const resolvedAuthDir = resolveUserPath(authDir);
103
- maybeRestoreCredsFromBackup(resolvedAuthDir);
104
- const credsPath = resolveWebCredsPath(resolvedAuthDir);
105
- try {
106
- await fs$1.access(resolvedAuthDir);
107
- } catch {
108
- return false;
109
- }
110
- try {
111
- const stats = await fs$1.stat(credsPath);
112
- if (!stats.isFile() || stats.size <= 1) return false;
113
- const raw = await fs$1.readFile(credsPath, "utf-8");
114
- JSON.parse(raw);
115
- return true;
116
- } catch {
117
- return false;
118
- }
119
- }
120
- async function clearLegacyBaileysAuthState(authDir) {
121
- const entries = await fs$1.readdir(authDir, { withFileTypes: true });
122
- const shouldDelete = (name) => {
123
- if (name === "oauth.json") return false;
124
- if (name === "creds.json" || name === "creds.json.bak") return true;
125
- if (!name.endsWith(".json")) return false;
126
- return /^(app-state-sync|session|sender-key|pre-key)-/.test(name);
127
- };
128
- await Promise.all(entries.map(async (entry) => {
129
- if (!entry.isFile()) return;
130
- if (!shouldDelete(entry.name)) return;
131
- await fs$1.rm(path.join(authDir, entry.name), { force: true });
132
- }));
133
- }
134
- async function logoutWeb(params) {
135
- const runtime = params.runtime ?? defaultRuntime;
136
- const resolvedAuthDir = resolveUserPath(params.authDir ?? resolveDefaultWebAuthDir());
137
- if (!await webAuthExists(resolvedAuthDir)) {
138
- runtime.log(info("No WhatsApp Web session found; nothing to delete."));
139
- return false;
140
- }
141
- if (params.isLegacyAuthDir) await clearLegacyBaileysAuthState(resolvedAuthDir);
142
- else await fs$1.rm(resolvedAuthDir, {
143
- recursive: true,
144
- force: true
145
- });
146
- runtime.log(success("Cleared WhatsApp Web credentials."));
147
- return true;
148
- }
149
- function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
150
- try {
151
- const credsPath = resolveWebCredsPath(resolveUserPath(authDir));
152
- if (!fs.existsSync(credsPath)) return {
153
- e164: null,
154
- jid: null
155
- };
156
- const raw = fs.readFileSync(credsPath, "utf-8");
157
- const jid = JSON.parse(raw)?.me?.id ?? null;
158
- return {
159
- e164: jid ? jidToE164(jid, { authDir }) : null,
160
- jid
161
- };
162
- } catch {
163
- return {
164
- e164: null,
165
- jid: null
166
- };
167
- }
168
- }
169
- /**
170
- * Return the age (in milliseconds) of the cached WhatsApp web auth state, or null when missing.
171
- * Helpful for heartbeats/observability to spot stale credentials.
172
- */
173
- function getWebAuthAgeMs(authDir = resolveDefaultWebAuthDir()) {
174
- try {
175
- const stats = fs.statSync(resolveWebCredsPath(resolveUserPath(authDir)));
176
- return Date.now() - stats.mtimeMs;
177
- } catch {
178
- return null;
179
- }
180
- }
181
- function logWebSelfId(authDir = resolveDefaultWebAuthDir(), runtime = defaultRuntime, includeChannelPrefix = false) {
182
- const { e164, jid } = readWebSelfId(authDir);
183
- const details = e164 || jid ? `${e164 ?? "unknown"}${jid ? ` (jid ${jid})` : ""}` : "unknown";
184
- const prefix = includeChannelPrefix ? "Web Channel: " : "";
185
- runtime.log(info(`${prefix}${details}`));
186
- }
187
- async function pickWebChannel(pref, authDir = resolveDefaultWebAuthDir()) {
188
- const choice = pref === "auto" ? "web" : pref;
189
- if (!await webAuthExists(authDir)) throw new Error(`No WhatsApp Web session found. Run \`${formatCliCommand("openclaw channels login --channel whatsapp --verbose")}\` to link.`);
190
- return choice;
191
- }
192
-
193
- //#endregion
194
- //#region src/web/accounts.ts
195
- const { listConfiguredAccountIds, listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("whatsapp");
196
- const listWhatsAppAccountIds = listAccountIds;
197
- const resolveDefaultWhatsAppAccountId = resolveDefaultAccountId;
198
- function listWhatsAppAuthDirs(cfg) {
199
- const oauthDir = resolveOAuthDir();
200
- const whatsappDir = path.join(oauthDir, "whatsapp");
201
- const authDirs = new Set([oauthDir, path.join(whatsappDir, DEFAULT_ACCOUNT_ID)]);
202
- const accountIds = listConfiguredAccountIds(cfg);
203
- for (const accountId of accountIds) authDirs.add(resolveWhatsAppAuthDir({
204
- cfg,
205
- accountId
206
- }).authDir);
207
- try {
208
- const entries = fs.readdirSync(whatsappDir, { withFileTypes: true });
209
- for (const entry of entries) {
210
- if (!entry.isDirectory()) continue;
211
- authDirs.add(path.join(whatsappDir, entry.name));
212
- }
213
- } catch {}
214
- return Array.from(authDirs);
215
- }
216
- function hasAnyWhatsAppAuth(cfg) {
217
- return listWhatsAppAuthDirs(cfg).some((authDir) => hasWebCredsSync(authDir));
218
- }
219
- function resolveAccountConfig(cfg, accountId) {
220
- return resolveAccountEntry(cfg.channels?.whatsapp?.accounts, accountId);
221
- }
222
- function resolveDefaultAuthDir(accountId) {
223
- return path.join(resolveOAuthDir(), "whatsapp", normalizeAccountId(accountId));
224
- }
225
- function resolveLegacyAuthDir() {
226
- return resolveOAuthDir();
227
- }
228
- function legacyAuthExists(authDir) {
229
- try {
230
- return fs.existsSync(path.join(authDir, "creds.json"));
231
- } catch {
232
- return false;
233
- }
234
- }
235
- function resolveWhatsAppAuthDir(params) {
236
- const accountId = params.accountId.trim() || DEFAULT_ACCOUNT_ID;
237
- const configured = resolveAccountConfig(params.cfg, accountId)?.authDir?.trim();
238
- if (configured) return {
239
- authDir: resolveUserPath(configured),
240
- isLegacy: false
241
- };
242
- const defaultDir = resolveDefaultAuthDir(accountId);
243
- if (accountId === DEFAULT_ACCOUNT_ID) {
244
- const legacyDir = resolveLegacyAuthDir();
245
- if (legacyAuthExists(legacyDir) && !legacyAuthExists(defaultDir)) return {
246
- authDir: legacyDir,
247
- isLegacy: true
248
- };
249
- }
250
- return {
251
- authDir: defaultDir,
252
- isLegacy: false
253
- };
254
- }
255
- function resolveWhatsAppAccount(params) {
256
- const rootCfg = params.cfg.channels?.whatsapp;
257
- const accountId = params.accountId?.trim() || resolveDefaultWhatsAppAccountId(params.cfg);
258
- const accountCfg = resolveAccountConfig(params.cfg, accountId);
259
- const enabled = accountCfg?.enabled !== false;
260
- const { authDir, isLegacy } = resolveWhatsAppAuthDir({
261
- cfg: params.cfg,
262
- accountId
263
- });
264
- return {
265
- accountId,
266
- name: accountCfg?.name?.trim() || void 0,
267
- enabled,
268
- sendReadReceipts: accountCfg?.sendReadReceipts ?? rootCfg?.sendReadReceipts ?? true,
269
- messagePrefix: accountCfg?.messagePrefix ?? rootCfg?.messagePrefix ?? params.cfg.messages?.messagePrefix,
270
- authDir,
271
- isLegacyAuthDir: isLegacy,
272
- selfChatMode: accountCfg?.selfChatMode ?? rootCfg?.selfChatMode,
273
- dmPolicy: accountCfg?.dmPolicy ?? rootCfg?.dmPolicy,
274
- allowFrom: accountCfg?.allowFrom ?? rootCfg?.allowFrom,
275
- groupAllowFrom: accountCfg?.groupAllowFrom ?? rootCfg?.groupAllowFrom,
276
- groupPolicy: accountCfg?.groupPolicy ?? rootCfg?.groupPolicy,
277
- textChunkLimit: accountCfg?.textChunkLimit ?? rootCfg?.textChunkLimit,
278
- chunkMode: accountCfg?.chunkMode ?? rootCfg?.chunkMode,
279
- mediaMaxMb: accountCfg?.mediaMaxMb ?? rootCfg?.mediaMaxMb,
280
- blockStreaming: accountCfg?.blockStreaming ?? rootCfg?.blockStreaming,
281
- ackReaction: accountCfg?.ackReaction ?? rootCfg?.ackReaction,
282
- groups: accountCfg?.groups ?? rootCfg?.groups,
283
- debounceMs: accountCfg?.debounceMs ?? rootCfg?.debounceMs
284
- };
285
- }
286
-
287
- //#endregion
288
- export { webAuthExists as _, resolveWhatsAppAuthDir as a, logWebSelfId as c, pickWebChannel as d, readCredsJsonRaw as f, resolveWebCredsPath as g, resolveWebCredsBackupPath as h, resolveWhatsAppAccount as i, logoutWeb as l, resolveDefaultWebAuthDir as m, listWhatsAppAccountIds as n, WA_WEB_AUTH_DIR as o, readWebSelfId as p, resolveDefaultWhatsAppAccountId as r, getWebAuthAgeMs as s, hasAnyWhatsAppAuth as t, maybeRestoreCredsFromBackup as u, resolveAccountEntry as v, createAccountListHelpers as y };
@@ -1,46 +0,0 @@
1
- import { ot as normalizeAccountId } from "./run-with-concurrency-Bt_ks0Qa.js";
2
- import { v as resolveAccountEntry, y as createAccountListHelpers } from "./accounts-DP1-L-QS.js";
3
-
4
- //#region src/signal/accounts.ts
5
- const { listAccountIds, resolveDefaultAccountId } = createAccountListHelpers("signal");
6
- const listSignalAccountIds = listAccountIds;
7
- const resolveDefaultSignalAccountId = resolveDefaultAccountId;
8
- function resolveAccountConfig(cfg, accountId) {
9
- return resolveAccountEntry(cfg.channels?.signal?.accounts, accountId);
10
- }
11
- function mergeSignalAccountConfig(cfg, accountId) {
12
- const { accounts: _ignored, ...base } = cfg.channels?.signal ?? {};
13
- const account = resolveAccountConfig(cfg, accountId) ?? {};
14
- return {
15
- ...base,
16
- ...account
17
- };
18
- }
19
- function resolveSignalAccount(params) {
20
- const accountId = normalizeAccountId(params.accountId);
21
- const baseEnabled = params.cfg.channels?.signal?.enabled !== false;
22
- const merged = mergeSignalAccountConfig(params.cfg, accountId);
23
- const accountEnabled = merged.enabled !== false;
24
- const enabled = baseEnabled && accountEnabled;
25
- const host = merged.httpHost?.trim() || "127.0.0.1";
26
- const port = merged.httpPort ?? 8080;
27
- const baseUrl = merged.httpUrl?.trim() || `http://${host}:${port}`;
28
- const configured = Boolean(merged.account?.trim() || merged.httpUrl?.trim() || merged.cliPath?.trim() || merged.httpHost?.trim() || typeof merged.httpPort === "number" || typeof merged.autoStart === "boolean");
29
- return {
30
- accountId,
31
- enabled,
32
- name: merged.name?.trim() || void 0,
33
- baseUrl,
34
- configured,
35
- config: merged
36
- };
37
- }
38
- function listEnabledSignalAccounts(cfg) {
39
- return listSignalAccountIds(cfg).map((accountId) => resolveSignalAccount({
40
- cfg,
41
- accountId
42
- })).filter((account) => account.enabled);
43
- }
44
-
45
- //#endregion
46
- export { resolveSignalAccount as i, listSignalAccountIds as n, resolveDefaultSignalAccountId as r, listEnabledSignalAccounts as t };
@@ -1,50 +0,0 @@
1
- import { at as DEFAULT_ACCOUNT_ID } from "./run-with-concurrency-Bt_ks0Qa.js";
2
- import { Pr as formatCliCommand } from "./config-BkEnz2Po.js";
3
- import crypto from "node:crypto";
4
-
5
- //#region src/logging/redact-identifier.ts
6
- function sha256HexPrefix(value, len = 12) {
7
- const safeLen = Number.isFinite(len) ? Math.max(1, Math.floor(len)) : 12;
8
- return crypto.createHash("sha256").update(value).digest("hex").slice(0, safeLen);
9
- }
10
- function redactIdentifier(value, opts) {
11
- const trimmed = value?.trim();
12
- if (!trimmed) return "-";
13
- return `sha256:${sha256HexPrefix(trimmed, opts?.len ?? 12)}`;
14
- }
15
-
16
- //#endregion
17
- //#region src/web/active-listener.ts
18
- const listeners = /* @__PURE__ */ new Map();
19
- function resolveWebAccountId(accountId) {
20
- return (accountId ?? "").trim() || DEFAULT_ACCOUNT_ID;
21
- }
22
- function requireActiveWebListener(accountId) {
23
- const id = resolveWebAccountId(accountId);
24
- const listener = listeners.get(id) ?? null;
25
- if (!listener) throw new Error(`No active WhatsApp Web listener (account: ${id}). Start the gateway, then link WhatsApp with: ${formatCliCommand(`openclaw channels login --channel whatsapp --account ${id}`)}.`);
26
- return {
27
- accountId: id,
28
- listener
29
- };
30
- }
31
- function setActiveWebListener(accountIdOrListener, maybeListener) {
32
- const { accountId, listener } = typeof accountIdOrListener === "string" ? {
33
- accountId: accountIdOrListener,
34
- listener: maybeListener ?? null
35
- } : {
36
- accountId: DEFAULT_ACCOUNT_ID,
37
- listener: accountIdOrListener ?? null
38
- };
39
- const id = resolveWebAccountId(accountId);
40
- if (!listener) listeners.delete(id);
41
- else listeners.set(id, listener);
42
- if (id === DEFAULT_ACCOUNT_ID) {}
43
- }
44
- function getActiveWebListener(accountId) {
45
- const id = resolveWebAccountId(accountId);
46
- return listeners.get(id) ?? null;
47
- }
48
-
49
- //#endregion
50
- export { redactIdentifier as i, requireActiveWebListener as n, setActiveWebListener as r, getActiveWebListener as t };