cclawd 1.0.1 → 1.0.2

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 (121) hide show
  1. package/dist/{active-listener-Dkhmfuwx.js → active-listener-BLd27Pxd.js} +1 -1
  2. package/dist/{api-key-rotation-BOfI3cG3.js → api-key-rotation-Dg3JlNDQ.js} +1 -1
  3. package/dist/{audio-preflight-CtkZ5SAs.js → audio-preflight-eV5m9mMp.js} +6 -6
  4. package/dist/{audio-transcription-runner-CbPqoiHX.js → audio-transcription-runner-CQU4Eg1M.js} +6 -6
  5. package/dist/build-info.json +3 -3
  6. package/dist/bundled/boot-md/handler.js +23 -23
  7. package/dist/bundled/session-memory/handler.js +23 -23
  8. package/dist/{channel-activity-DWAER4wd.js → channel-activity-dT3cYb0e.js} +1 -1
  9. package/dist/{commands-registry-BUyiA7nE.js → commands-registry-CyLMCPuP.js} +1 -1
  10. package/dist/compact.runtime-DGRl4st4.js +39 -0
  11. package/dist/{deliver-aHOaRbkt.js → deliver-B6eTtXSk.js} +4 -4
  12. package/dist/{deliver-runtime-D4bCsr6d.js → deliver-runtime-CLDpY6AW.js} +7 -7
  13. package/dist/{deps-send-discord.runtime-BziKU-pE.js → deps-send-discord.runtime-CxADlame.js} +7 -7
  14. package/dist/{deps-send-imessage.runtime-CFRnDTqp.js → deps-send-imessage.runtime-Wi79xm6H.js} +7 -7
  15. package/dist/{deps-send-signal.runtime-BuOtABJm.js → deps-send-signal.runtime-BDtzvsnR.js} +6 -6
  16. package/dist/{deps-send-slack.runtime-BOLqvMxW.js → deps-send-slack.runtime-CgX24hgT.js} +5 -5
  17. package/dist/{deps-send-telegram.runtime-DeEoFLv5.js → deps-send-telegram.runtime-CEWc7ePn.js} +6 -6
  18. package/dist/deps-send-whatsapp.runtime-B1KJ7YOp.js +43 -0
  19. package/dist/{diagnostic-BdcXX9iJ.js → diagnostic-BZmAxdu9.js} +1 -1
  20. package/dist/{fetch-D9NUULbj.js → fetch-CMLoICyN.js} +2 -2
  21. package/dist/{fetch-guard-B5ZMnGaN.js → fetch-guard-DCj3k042.js} +1 -1
  22. package/dist/{image-4x07m4Jl.js → image-Bt49ybRv.js} +2 -2
  23. package/dist/{image-runtime-smkMrIol.js → image-runtime-Cilhq73U.js} +2 -2
  24. package/dist/{ir-CsgNUpOU.js → ir-CVtBjUiL.js} +2 -2
  25. package/dist/llm-slug-generator.js +23 -23
  26. package/dist/{login-p_O59TVQ.js → login-D0fUoX-p.js} +2 -2
  27. package/dist/{login-qr-BCJpDsAy.js → login-qr-ClBxstxZ.js} +2 -2
  28. package/dist/{manager-CwYv8O3T.js → manager-DSfEj66R.js} +3 -3
  29. package/dist/{manager-runtime-D_jEoBr9.js → manager-runtime-BrZlGJsj.js} +4 -4
  30. package/dist/{model-selection-Cv2Puf5z.js → model-selection-CMEj8bpy.js} +11 -11
  31. package/dist/{outbound-Chpiwybe.js → outbound-BxIJyMzV.js} +4 -4
  32. package/dist/{outbound-attachment-BnAVJDLe.js → outbound-attachment-CVJwpypG.js} +2 -2
  33. package/dist/{pi-embedded-CJVNBk0y.js → pi-embedded-CHNPEUAv.js} +57 -57
  34. package/dist/{pi-model-discovery-7IzK0Uc3.js → pi-model-discovery-D-r5y7kV.js} +1 -1
  35. package/dist/{pi-model-discovery-runtime-DABef3qy.js → pi-model-discovery-runtime-DZQXYmdu.js} +2 -2
  36. package/dist/{pi-tools.before-tool-call.runtime-BP2UvGJb.js → pi-tools.before-tool-call.runtime-DagGpfw0.js} +2 -2
  37. package/dist/plugin-sdk/compat.js +35 -35
  38. package/dist/{pw-ai-DwH5GpEO.js → pw-ai-CoIUdns_.js} +1 -1
  39. package/dist/{runtime-whatsapp-login.runtime-BI3U306v.js → runtime-whatsapp-login.runtime-ChqE9BkX.js} +3 -3
  40. package/dist/{runtime-whatsapp-outbound.runtime-Bsc2uD09.js → runtime-whatsapp-outbound.runtime-yiy6jzKk.js} +6 -6
  41. package/dist/{send-DtBvCnPQ.js → send-4rRrSKp9.js} +4 -4
  42. package/dist/{send-ORtn50qg.js → send-BKO1-P1t.js} +3 -3
  43. package/dist/{send-C-Q_WPMf.js → send-EDBPXjTT.js} +3 -3
  44. package/dist/{send-DUibfNQD.js → send-K2mAG7KC.js} +4 -4
  45. package/dist/{send-BDnOgWIp.js → send-V1MRV7QF.js} +3 -3
  46. package/dist/{session-B7imi6T5.js → session-CuVCho2m.js} +1 -1
  47. package/dist/{skill-commands-B9brPuiL.js → skill-commands-B55LOaMB.js} +2 -2
  48. package/dist/{slash-commands.runtime-Cf6ygfBp.js → slash-commands.runtime-BchS0VkW.js} +2 -2
  49. package/dist/{slash-dispatch.runtime-CsmvhO5K.js → slash-dispatch.runtime-BIKRY3fr.js} +23 -23
  50. package/dist/{slash-skill-commands.runtime-CX7stIEP.js → slash-skill-commands.runtime-BP4jBHU9.js} +3 -3
  51. package/dist/{subagent-registry-runtime-B_S1nf7y.js → subagent-registry-runtime-DjEYzSyM.js} +23 -23
  52. package/dist/{tables-CjQqTOdD.js → tables-BAGqh2XD.js} +1 -1
  53. package/dist/{target-errors-BZE1mc-W.js → target-errors-CeBF8Pws.js} +1 -1
  54. package/dist/{web-Cd8yK1Zq.js → web-BRSmQdtm.js} +27 -27
  55. package/dist/{whatsapp-actions-CYEzUMBI.js → whatsapp-actions-Dxb2K2Xh.js} +7 -7
  56. package/extensions/mfa-auth/index.ts +3 -3
  57. package/extensions/mfa-auth/src/notification-service.ts +2 -2
  58. package/package.json +458 -458
  59. package/dist/compact.runtime-DpcZpcTl.js +0 -39
  60. package/dist/deps-send-whatsapp.runtime-CG1uXYLY.js +0 -43
  61. package/dist/plugin-sdk/active-listener-CN-tMEvN.js +0 -35
  62. package/dist/plugin-sdk/api-key-rotation-CimGYMBc.js +0 -176
  63. package/dist/plugin-sdk/audio-preflight-C-xXBoE2.js +0 -51
  64. package/dist/plugin-sdk/audio-transcription-runner-CTIHpebA.js +0 -2173
  65. package/dist/plugin-sdk/audit-membership-runtime-BFatB2LJ.js +0 -58
  66. package/dist/plugin-sdk/channel-activity-DO0FEzyj.js +0 -95
  67. package/dist/plugin-sdk/channel-web-Da-__nUF.js +0 -2238
  68. package/dist/plugin-sdk/commands-registry-6no2NNrY.js +0 -1118
  69. package/dist/plugin-sdk/compact.runtime-CCoclu5e.js +0 -35
  70. package/dist/plugin-sdk/config-B9ODwgpz.js +0 -37426
  71. package/dist/plugin-sdk/deliver-B1fFpKjV.js +0 -1757
  72. package/dist/plugin-sdk/deliver-runtime-DB-VRMe1.js +0 -15
  73. package/dist/plugin-sdk/deps-send-discord.runtime-DklqycYG.js +0 -15
  74. package/dist/plugin-sdk/deps-send-imessage.runtime-Chs8zeon.js +0 -14
  75. package/dist/plugin-sdk/deps-send-signal.runtime-clW9aSJP.js +0 -13
  76. package/dist/plugin-sdk/deps-send-slack.runtime-BUx0LYY1.js +0 -13
  77. package/dist/plugin-sdk/deps-send-telegram.runtime-LECSHgMG.js +0 -16
  78. package/dist/plugin-sdk/deps-send-whatsapp.runtime-D2d65fw0.js +0 -40
  79. package/dist/plugin-sdk/diagnostic-CxIvS-C2.js +0 -315
  80. package/dist/plugin-sdk/dispatch-BqlR4dPx.js +0 -105863
  81. package/dist/plugin-sdk/env-b9k1PHMI.js +0 -34
  82. package/dist/plugin-sdk/fetch-PoxzAANT.js +0 -326
  83. package/dist/plugin-sdk/fetch-guard-4UVSZ0uS.js +0 -164
  84. package/dist/plugin-sdk/image-Ch6M4tnJ.js +0 -2420
  85. package/dist/plugin-sdk/image-runtime-CSh2o5wY.js +0 -8
  86. package/dist/plugin-sdk/ir-CugsqGH8.js +0 -1312
  87. package/dist/plugin-sdk/local-roots-adnEg9zb.js +0 -217
  88. package/dist/plugin-sdk/logger-D6zRubj0.js +0 -1164
  89. package/dist/plugin-sdk/login-CYvkQ0At.js +0 -54
  90. package/dist/plugin-sdk/login-qr-ll4NtaT5.js +0 -316
  91. package/dist/plugin-sdk/manager-CHy8IclH.js +0 -3959
  92. package/dist/plugin-sdk/manager-runtime-C70EkEr7.js +0 -11
  93. package/dist/plugin-sdk/outbound-Wzs2iN7X.js +0 -216
  94. package/dist/plugin-sdk/outbound-attachment-khXJwucX.js +0 -17
  95. package/dist/plugin-sdk/paths-BtVqCdw4.js +0 -3063
  96. package/dist/plugin-sdk/pi-model-discovery-Dh4ziodY.js +0 -131
  97. package/dist/plugin-sdk/pi-model-discovery-runtime-b83Xe-HT.js +0 -8
  98. package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-C1z5CDBF.js +0 -349
  99. package/dist/plugin-sdk/proxy-fetch-CJEmoBxi.js +0 -54
  100. package/dist/plugin-sdk/pw-ai-Dj3Cvlzl.js +0 -1990
  101. package/dist/plugin-sdk/qmd-manager-egHUAseQ.js +0 -1581
  102. package/dist/plugin-sdk/resolve-outbound-target-BiICvIKs.js +0 -38
  103. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-DNApufzW.js +0 -9
  104. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-CBmtfIQ8.js +0 -13
  105. package/dist/plugin-sdk/send-CScblaI4.js +0 -532
  106. package/dist/plugin-sdk/send-CeHhnld6.js +0 -407
  107. package/dist/plugin-sdk/send-DP_c8JfR.js +0 -3277
  108. package/dist/plugin-sdk/send-Dc5fI6e8.js +0 -495
  109. package/dist/plugin-sdk/send-l-77_s1_.js +0 -2507
  110. package/dist/plugin-sdk/session-CkOKZaqa.js +0 -166
  111. package/dist/plugin-sdk/skill-commands-BohYCgkq.js +0 -336
  112. package/dist/plugin-sdk/slash-commands.runtime-DpLfVTM6.js +0 -8
  113. package/dist/plugin-sdk/slash-dispatch.runtime-CASMHwpm.js +0 -35
  114. package/dist/plugin-sdk/slash-skill-commands.runtime-D7rrJEci.js +0 -9
  115. package/dist/plugin-sdk/sqlite-CJE3X7Mv.js +0 -1005
  116. package/dist/plugin-sdk/subagent-registry-runtime-B1oo5bih.js +0 -35
  117. package/dist/plugin-sdk/tables-D5VgpTmm.js +0 -53
  118. package/dist/plugin-sdk/target-errors-C6zZ_OpA.js +0 -191
  119. package/dist/plugin-sdk/tokens-DUnJnpMS.js +0 -50
  120. package/dist/plugin-sdk/web-TfUM1nSi.js +0 -39
  121. package/dist/plugin-sdk/whatsapp-actions-DuWJ0j1r.js +0 -71
@@ -1,39 +0,0 @@
1
- import "./paths-CehYKFsO.js";
2
- import "./paths-DkxwiA8g.js";
3
- import "./subsystem-DfXy5gUB.js";
4
- import "./workspace-DGIcKCCW.js";
5
- import "./logger-CbUVl62f.js";
6
- import "./model-selection-Cv2Puf5z.js";
7
- import "./github-copilot-token-8N63GdbE.js";
8
- import "./boolean-C7Ct_klp.js";
9
- import "./env-lw2hsIUY.js";
10
- import "./frontmatter-C_obXuTp.js";
11
- import "./send-ORtn50qg.js";
12
- import "./send-DtBvCnPQ.js";
13
- import { n as compactEmbeddedPiSessionDirect } from "./pi-embedded-CJVNBk0y.js";
14
- import "./tokens-6ul2IrzG.js";
15
- import "./deliver-aHOaRbkt.js";
16
- import "./diagnostic-BdcXX9iJ.js";
17
- import "./send-BDnOgWIp.js";
18
- import "./pi-model-discovery-7IzK0Uc3.js";
19
- import "./image-4x07m4Jl.js";
20
- import "./audio-transcription-runner-CbPqoiHX.js";
21
- import "./fetch-D9NUULbj.js";
22
- import "./fetch-guard-B5ZMnGaN.js";
23
- import "./api-key-rotation-BOfI3cG3.js";
24
- import "./proxy-fetch-BOh1PLOW.js";
25
- import "./ir-CsgNUpOU.js";
26
- import "./render-IRnn-2gt.js";
27
- import "./target-errors-BZE1mc-W.js";
28
- import "./commands-registry-BUyiA7nE.js";
29
- import "./skill-commands-B9brPuiL.js";
30
- import "./fetch-CeWULXBI.js";
31
- import "./channel-activity-DWAER4wd.js";
32
- import "./tables-CjQqTOdD.js";
33
- import "./send-C-Q_WPMf.js";
34
- import "./outbound-attachment-BnAVJDLe.js";
35
- import "./send-DUibfNQD.js";
36
- import "./fetch-C0iyt-Iz.js";
37
- import "./manager-CwYv8O3T.js";
38
- import "./query-expansion-BErUY8P2.js";
39
- export { compactEmbeddedPiSessionDirect };
@@ -1,43 +0,0 @@
1
- import "./paths-CehYKFsO.js";
2
- import "./paths-DkxwiA8g.js";
3
- import "./subsystem-DfXy5gUB.js";
4
- import "./workspace-DGIcKCCW.js";
5
- import "./logger-CbUVl62f.js";
6
- import "./model-selection-Cv2Puf5z.js";
7
- import "./github-copilot-token-8N63GdbE.js";
8
- import "./boolean-C7Ct_klp.js";
9
- import "./env-lw2hsIUY.js";
10
- import "./frontmatter-C_obXuTp.js";
11
- import "./send-ORtn50qg.js";
12
- import "./send-DtBvCnPQ.js";
13
- import "./pi-embedded-CJVNBk0y.js";
14
- import "./tokens-6ul2IrzG.js";
15
- import "./deliver-aHOaRbkt.js";
16
- import "./diagnostic-BdcXX9iJ.js";
17
- import "./send-BDnOgWIp.js";
18
- import "./pi-model-discovery-7IzK0Uc3.js";
19
- import "./image-4x07m4Jl.js";
20
- import "./audio-transcription-runner-CbPqoiHX.js";
21
- import "./fetch-D9NUULbj.js";
22
- import "./fetch-guard-B5ZMnGaN.js";
23
- import "./api-key-rotation-BOfI3cG3.js";
24
- import "./proxy-fetch-BOh1PLOW.js";
25
- import "./ir-CsgNUpOU.js";
26
- import "./render-IRnn-2gt.js";
27
- import "./target-errors-BZE1mc-W.js";
28
- import "./commands-registry-BUyiA7nE.js";
29
- import "./skill-commands-B9brPuiL.js";
30
- import "./fetch-CeWULXBI.js";
31
- import "./channel-activity-DWAER4wd.js";
32
- import "./tables-CjQqTOdD.js";
33
- import "./send-C-Q_WPMf.js";
34
- import "./outbound-attachment-BnAVJDLe.js";
35
- import "./send-DUibfNQD.js";
36
- import "./fetch-C0iyt-Iz.js";
37
- import "./manager-CwYv8O3T.js";
38
- import "./query-expansion-BErUY8P2.js";
39
- import { t as sendMessageWhatsApp } from "./outbound-Chpiwybe.js";
40
- import "./session-B7imi6T5.js";
41
- import "./login-p_O59TVQ.js";
42
- import "./web-Cd8yK1Zq.js";
43
- export { sendMessageWhatsApp };
@@ -1,35 +0,0 @@
1
- import { Ft as DEFAULT_ACCOUNT_ID } from "./paths-BtVqCdw4.js";
2
- import { Ul as formatCliCommand } from "./config-B9ODwgpz.js";
3
- //#region src/web/active-listener.ts
4
- const listeners = /* @__PURE__ */ new Map();
5
- function resolveWebAccountId(accountId) {
6
- return (accountId ?? "").trim() || "default";
7
- }
8
- function requireActiveWebListener(accountId) {
9
- const id = resolveWebAccountId(accountId);
10
- const listener = listeners.get(id) ?? null;
11
- 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}`)}.`);
12
- return {
13
- accountId: id,
14
- listener
15
- };
16
- }
17
- function setActiveWebListener(accountIdOrListener, maybeListener) {
18
- const { accountId, listener } = typeof accountIdOrListener === "string" ? {
19
- accountId: accountIdOrListener,
20
- listener: maybeListener ?? null
21
- } : {
22
- accountId: DEFAULT_ACCOUNT_ID,
23
- listener: accountIdOrListener ?? null
24
- };
25
- const id = resolveWebAccountId(accountId);
26
- if (!listener) listeners.delete(id);
27
- else listeners.set(id, listener);
28
- if (id === "default") {}
29
- }
30
- function getActiveWebListener(accountId) {
31
- const id = resolveWebAccountId(accountId);
32
- return listeners.get(id) ?? null;
33
- }
34
- //#endregion
35
- export { requireActiveWebListener as n, setActiveWebListener as r, getActiveWebListener as t };
@@ -1,176 +0,0 @@
1
- import { Hs as formatErrorMessage, Vt as normalizeProviderId } from "./config-B9ODwgpz.js";
2
- //#region src/infra/gemini-auth.ts
3
- /**
4
- * Shared Gemini authentication utilities.
5
- *
6
- * Supports both traditional API keys and OAuth JSON format.
7
- */
8
- /**
9
- * Parse Gemini API key and return appropriate auth headers.
10
- *
11
- * OAuth format: `{"token": "...", "projectId": "..."}`
12
- *
13
- * @param apiKey - Either a traditional API key string or OAuth JSON
14
- * @returns Headers object with appropriate authentication
15
- */
16
- function parseGeminiAuth(apiKey) {
17
- if (apiKey.startsWith("{")) try {
18
- const parsed = JSON.parse(apiKey);
19
- if (typeof parsed.token === "string" && parsed.token) return { headers: {
20
- Authorization: `Bearer ${parsed.token}`,
21
- "Content-Type": "application/json"
22
- } };
23
- } catch {}
24
- return { headers: {
25
- "x-goog-api-key": apiKey,
26
- "Content-Type": "application/json"
27
- } };
28
- }
29
- //#endregion
30
- //#region src/agents/live-auth-keys.ts
31
- const KEY_SPLIT_RE = /[\s,;]+/g;
32
- const GOOGLE_LIVE_SINGLE_KEY = "OPENCLAW_LIVE_GEMINI_KEY";
33
- const PROVIDER_PREFIX_OVERRIDES = {
34
- google: "GEMINI",
35
- "google-vertex": "GEMINI"
36
- };
37
- const PROVIDER_API_KEY_CONFIG = {
38
- anthropic: {
39
- liveSingle: "OPENCLAW_LIVE_ANTHROPIC_KEY",
40
- listVar: "OPENCLAW_LIVE_ANTHROPIC_KEYS",
41
- primaryVar: "ANTHROPIC_API_KEY",
42
- prefixedVar: "ANTHROPIC_API_KEY_"
43
- },
44
- google: {
45
- liveSingle: GOOGLE_LIVE_SINGLE_KEY,
46
- listVar: "GEMINI_API_KEYS",
47
- primaryVar: "GEMINI_API_KEY",
48
- prefixedVar: "GEMINI_API_KEY_"
49
- },
50
- "google-vertex": {
51
- liveSingle: GOOGLE_LIVE_SINGLE_KEY,
52
- listVar: "GEMINI_API_KEYS",
53
- primaryVar: "GEMINI_API_KEY",
54
- prefixedVar: "GEMINI_API_KEY_"
55
- },
56
- openai: {
57
- liveSingle: "OPENCLAW_LIVE_OPENAI_KEY",
58
- listVar: "OPENAI_API_KEYS",
59
- primaryVar: "OPENAI_API_KEY",
60
- prefixedVar: "OPENAI_API_KEY_"
61
- }
62
- };
63
- function parseKeyList(raw) {
64
- if (!raw) return [];
65
- return raw.split(KEY_SPLIT_RE).map((value) => value.trim()).filter(Boolean);
66
- }
67
- function collectEnvPrefixedKeys(prefix) {
68
- const keys = [];
69
- for (const [name, value] of Object.entries(process.env)) {
70
- if (!name.startsWith(prefix)) continue;
71
- const trimmed = value?.trim();
72
- if (!trimmed) continue;
73
- keys.push(trimmed);
74
- }
75
- return keys;
76
- }
77
- function resolveProviderApiKeyConfig(provider) {
78
- const normalized = normalizeProviderId(provider);
79
- const custom = PROVIDER_API_KEY_CONFIG[normalized];
80
- const base = PROVIDER_PREFIX_OVERRIDES[normalized] ?? normalized.toUpperCase().replace(/-/g, "_");
81
- const liveSingle = custom?.liveSingle ?? `OPENCLAW_LIVE_${base}_KEY`;
82
- const listVar = custom?.listVar ?? `${base}_API_KEYS`;
83
- const primaryVar = custom?.primaryVar ?? `${base}_API_KEY`;
84
- const prefixedVar = custom?.prefixedVar ?? `${base}_API_KEY_`;
85
- if (normalized === "google" || normalized === "google-vertex") return {
86
- liveSingle,
87
- listVar,
88
- primaryVar,
89
- prefixedVar,
90
- fallbackVars: ["GOOGLE_API_KEY"]
91
- };
92
- return {
93
- liveSingle,
94
- listVar,
95
- primaryVar,
96
- prefixedVar,
97
- fallbackVars: []
98
- };
99
- }
100
- function collectProviderApiKeys(provider) {
101
- const config = resolveProviderApiKeyConfig(provider);
102
- const forcedSingle = config.liveSingle ? process.env[config.liveSingle]?.trim() : void 0;
103
- if (forcedSingle) return [forcedSingle];
104
- const fromList = parseKeyList(config.listVar ? process.env[config.listVar] : void 0);
105
- const primary = config.primaryVar ? process.env[config.primaryVar]?.trim() : void 0;
106
- const fromPrefixed = config.prefixedVar ? collectEnvPrefixedKeys(config.prefixedVar) : [];
107
- const fallback = config.fallbackVars.map((envVar) => process.env[envVar]?.trim()).filter(Boolean);
108
- const seen = /* @__PURE__ */ new Set();
109
- const add = (value) => {
110
- if (!value) return;
111
- if (seen.has(value)) return;
112
- seen.add(value);
113
- };
114
- for (const value of fromList) add(value);
115
- add(primary);
116
- for (const value of fromPrefixed) add(value);
117
- for (const value of fallback) add(value);
118
- return Array.from(seen);
119
- }
120
- function isApiKeyRateLimitError(message) {
121
- const lower = message.toLowerCase();
122
- if (lower.includes("rate_limit")) return true;
123
- if (lower.includes("rate limit")) return true;
124
- if (lower.includes("429")) return true;
125
- if (lower.includes("quota exceeded") || lower.includes("quota_exceeded")) return true;
126
- if (lower.includes("resource exhausted") || lower.includes("resource_exhausted")) return true;
127
- if (lower.includes("too many requests")) return true;
128
- return false;
129
- }
130
- //#endregion
131
- //#region src/agents/api-key-rotation.ts
132
- function dedupeApiKeys(raw) {
133
- const seen = /* @__PURE__ */ new Set();
134
- const keys = [];
135
- for (const value of raw) {
136
- const apiKey = value.trim();
137
- if (!apiKey || seen.has(apiKey)) continue;
138
- seen.add(apiKey);
139
- keys.push(apiKey);
140
- }
141
- return keys;
142
- }
143
- function collectProviderApiKeysForExecution(params) {
144
- const { primaryApiKey, provider } = params;
145
- return dedupeApiKeys([primaryApiKey?.trim() ?? "", ...collectProviderApiKeys(provider)]);
146
- }
147
- async function executeWithApiKeyRotation(params) {
148
- const keys = dedupeApiKeys(params.apiKeys);
149
- if (keys.length === 0) throw new Error(`No API keys configured for provider "${params.provider}".`);
150
- let lastError;
151
- for (let attempt = 0; attempt < keys.length; attempt += 1) {
152
- const apiKey = keys[attempt];
153
- try {
154
- return await params.execute(apiKey);
155
- } catch (error) {
156
- lastError = error;
157
- const message = formatErrorMessage(error);
158
- if (!(params.shouldRetry ? params.shouldRetry({
159
- apiKey,
160
- error,
161
- attempt,
162
- message
163
- }) : isApiKeyRateLimitError(message)) || attempt + 1 >= keys.length) break;
164
- params.onRetry?.({
165
- apiKey,
166
- error,
167
- attempt,
168
- message
169
- });
170
- }
171
- }
172
- if (lastError === void 0) throw new Error(`Failed to run API request for ${params.provider}.`);
173
- throw lastError;
174
- }
175
- //#endregion
176
- export { executeWithApiKeyRotation as n, parseGeminiAuth as r, collectProviderApiKeysForExecution as t };
@@ -1,51 +0,0 @@
1
- import "./paths-BtVqCdw4.js";
2
- import "./config-B9ODwgpz.js";
3
- import "./paths-eFexkPEh.js";
4
- import "./github-copilot-token-Cxf8QYZb.js";
5
- import { B as shouldLogVerbose, R as logVerbose } from "./logger-D6zRubj0.js";
6
- import "./env-b9k1PHMI.js";
7
- import "./fetch-guard-4UVSZ0uS.js";
8
- import "./local-roots-adnEg9zb.js";
9
- import { i as normalizeMediaAttachments, m as isAudioAttachment, o as resolveMediaAttachmentLocalRoots, t as runAudioTranscription } from "./audio-transcription-runner-CTIHpebA.js";
10
- import "./image-Ch6M4tnJ.js";
11
- import "./api-key-rotation-CimGYMBc.js";
12
- import "./proxy-fetch-CJEmoBxi.js";
13
- //#region src/media-understanding/audio-preflight.ts
14
- /**
15
- * Transcribes the first audio attachment BEFORE mention checking.
16
- * This allows voice notes to be processed in group chats with requireMention: true.
17
- * Returns the transcript or undefined if transcription fails or no audio is found.
18
- */
19
- async function transcribeFirstAudio(params) {
20
- const { ctx, cfg } = params;
21
- const audioConfig = cfg.tools?.media?.audio;
22
- if (!audioConfig || audioConfig.enabled === false) return;
23
- const attachments = normalizeMediaAttachments(ctx);
24
- if (!attachments || attachments.length === 0) return;
25
- const firstAudio = attachments.find((att) => att && isAudioAttachment(att) && !att.alreadyTranscribed);
26
- if (!firstAudio) return;
27
- if (shouldLogVerbose()) logVerbose(`audio-preflight: transcribing attachment ${firstAudio.index} for mention check`);
28
- try {
29
- const { transcript } = await runAudioTranscription({
30
- ctx,
31
- cfg,
32
- attachments,
33
- agentDir: params.agentDir,
34
- providers: params.providers,
35
- activeModel: params.activeModel,
36
- localPathRoots: resolveMediaAttachmentLocalRoots({
37
- cfg,
38
- ctx
39
- })
40
- });
41
- if (!transcript) return;
42
- firstAudio.alreadyTranscribed = true;
43
- if (shouldLogVerbose()) logVerbose(`audio-preflight: transcribed ${transcript.length} chars from attachment ${firstAudio.index}`);
44
- return transcript;
45
- } catch (err) {
46
- if (shouldLogVerbose()) logVerbose(`audio-preflight: transcription failed: ${String(err)}`);
47
- return;
48
- }
49
- }
50
- //#endregion
51
- export { transcribeFirstAudio };