@openclaw/discord 2026.8.1-beta.2 → 2026.8.1-beta.3

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 (100) hide show
  1. package/dist/{account-inspect-CqzrH14k.js → account-inspect-D5xmUpnj.js} +1 -1
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/accounts-DNl-oCEw.js +371 -0
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/{activities-api-DS7vpdtp.js → activities-api-KCBAmWxD.js} +133 -175
  6. package/dist/activities-api.js +1 -1
  7. package/dist/api.js +17 -17
  8. package/dist/{approval-handler.runtime-B6yEV79q.js → approval-handler.runtime-B12RCYr8.js} +6 -6
  9. package/dist/{approval-message-safety-AcIxvrf3.js → approval-message-safety-XGFPbDoI.js} +89 -3
  10. package/dist/{audit-Db-rlntl.js → audit-Yc7eZDd6.js} +5 -5
  11. package/dist/{channel-actions-5s_hjYKd.js → channel-actions-Dr2QI8Bf.js} +10 -6
  12. package/dist/{channel-actions.runtime-CLKrx6tr.js → channel-actions.runtime-CODTvo7c.js} +53 -68
  13. package/dist/{channel-CnnbJSt5.js → channel-cXYzGc4L.js} +74 -50
  14. package/dist/channel-config-api.js +1 -1
  15. package/dist/channel-plugin-api.js +1 -1
  16. package/dist/{channel.setup-BFAO-V1P.js → channel.setup-CSiwnMgs.js} +5 -5
  17. package/dist/{outbound-session-route-DxLkrgKQ.js → components-ezGKo_Yh.js} +3 -49
  18. package/dist/{config-schema-BgEskFAs.js → config-schema-DC5kDtQ5.js} +33 -7
  19. package/dist/conversation-binding-route-D6rCQ5S0.js +43 -0
  20. package/dist/{directory-config-BVX7Cflc.js → directory-config-XyCfoqLg.js} +2 -2
  21. package/dist/directory-contract-api.js +1 -1
  22. package/dist/{directory-live-DGIGxpIo.js → directory-live-Df0NbFJB.js} +3 -3
  23. package/dist/{doctor-BzC-TLnB.js → doctor-DYY31GrO.js} +33 -12
  24. package/dist/doctor-contract-api.js +3 -3
  25. package/dist/{handle-action.guild-admin-BNVTUISF.js → handle-action.guild-admin-6Tvvinsa.js} +2 -2
  26. package/dist/index.js +3 -4
  27. package/dist/{message-handler-Unk_f10F.js → message-handler-B61q5MOF.js} +82 -6
  28. package/dist/{message-handler.preflight-C9zecxR9.js → message-handler.preflight-Bzg_Hawz.js} +36 -46
  29. package/dist/{message-handler.process-DWQ6UHHu.js → message-handler.process--4_712Ec.js} +159 -183
  30. package/dist/{message-utils-BSCPVgy0.js → message-utils-BXLLnFl6.js} +31 -32
  31. package/dist/{outbound-adapter-D9nRivT1.js → outbound-adapter-DxHTOqiN.js} +83 -53
  32. package/dist/{outbound-components-cTzwBJ60.js → outbound-components-B2PL0ooH.js} +3 -3
  33. package/dist/owner-access-Bg41VzAf.js +107 -0
  34. package/dist/{pluralkit-DdiJ9KMK.js → pluralkit-dUl4v1X3.js} +1 -1
  35. package/dist/{probe-Bl-k5_Ku.js → probe-BTdtVRwU.js} +1 -1
  36. package/dist/{probe.runtime-M9fREKvp.js → probe.runtime-Dq5-PRKT.js} +1 -1
  37. package/dist/{provider-DvSNb-2v.js → provider-DlK_ynqt.js} +356 -967
  38. package/dist/{provider-session.runtime-BUEqD0rA.js → provider-session.runtime-CvvphHvs.js} +3 -3
  39. package/dist/provider.runtime-CzKGRiAF.js +2 -0
  40. package/dist/{realtime-session.runtime-C7wen-aF.js → realtime-session.runtime-ysbMG8v7.js} +24 -13
  41. package/dist/{resolve-allowlist-common-D04lpEzb.js → resolve-allowlist-common-DIVXbD1P.js} +2 -2
  42. package/dist/{resolve-channels-Dm7jEeg6.js → resolve-channels-CGeUoIqb.js} +3 -3
  43. package/dist/{resolve-users-bktrCUUU.js → resolve-users-BtKxLUZv.js} +2 -2
  44. package/dist/{retry-CLpJcXXf.js → retry-DNsVTeTo.js} +18 -64
  45. package/dist/{runtime-DoHjckYm.js → runtime-CQovMsH3.js} +9 -10
  46. package/dist/{runtime-DGsSyDTS.js → runtime-D71_VFLr.js} +29 -43
  47. package/dist/runtime-api.actions.js +2 -2
  48. package/dist/runtime-api.js +22 -21
  49. package/dist/runtime-api.lookup.js +5 -5
  50. package/dist/runtime-api.monitor-CzeTYF32.js +6 -0
  51. package/dist/runtime-api.monitor.js +6 -5
  52. package/dist/runtime-api.send.js +6 -6
  53. package/dist/runtime-api.threads.js +4 -4
  54. package/dist/{sdk-runtime-QpY8PvCh.js → sdk-runtime-37OU6_Yh.js} +3 -4
  55. package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
  56. package/dist/secret-contract-api.js +1 -1
  57. package/dist/security-audit-contract-api.js +1 -1
  58. package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-BVKF9VtY.js} +1 -1
  59. package/dist/{send-B7Q6Oc1I.js → send-rQIffSYu.js} +10 -10
  60. package/dist/{send.components-iJyFXw9L.js → send.components-ChK1wS7w.js} +14 -24
  61. package/dist/{send.outbound-DS5tHwfR.js → send.outbound-HIkgji_7.js} +26 -16
  62. package/dist/{send.reactions-BAn0iiVQ.js → send.reactions-gmJ6yFPo.js} +2 -2
  63. package/dist/{send.receipt-IPI1p-SP.js → send.receipt-Cnhoautb.js} +11 -1
  64. package/dist/{send.shared-BmwFjW6T.js → send.shared-B3fpaLWJ.js} +104 -104
  65. package/dist/{sender-identity-QtalnCYv.js → sender-identity-BJtfyise.js} +1 -1
  66. package/dist/setup-plugin-api.js +1 -1
  67. package/dist/{shared-BIXIX6uJ.js → shared-CaAaoksy.js} +15 -10
  68. package/dist/subagent-hooks-CNT2ZJTJ.js +49 -0
  69. package/dist/subagent-hooks-api.js +2 -2
  70. package/dist/{subagent-progress-DhaE_h8a.js → subagent-progress-FPLqBY1s.js} +5 -4
  71. package/dist/{system-events-CTqDf6_s.js → system-events-Nuwoq_au.js} +2 -2
  72. package/dist/{target-resolver-maOKSqO0.js → target-resolver-DIXShHaZ.js} +3 -3
  73. package/dist/targets-B2pf49zc.js +3 -0
  74. package/dist/{thread-bindings-3L8p82GV.js → thread-bindings-VlymUnbz.js} +29 -26
  75. package/dist/{thread-bindings.manager-DCIH6WDC.js → thread-bindings.manager-CngsgErq.js} +9 -8
  76. package/dist/{thread-bindings.session-updates-bJ2KQFY6.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
  77. package/dist/{thread-bindings.state-aeV8HNgV.js → thread-bindings.state-D8OMdk4O.js} +1 -1
  78. package/dist/threading-DU6pgeGm.js +456 -0
  79. package/dist/transcripts-source-DeIMNbRh.js +265 -0
  80. package/dist/transcripts-source-api.js +7 -2
  81. package/dist/{typing-CS-nNVoe.js → typing-oLiS5Z13.js} +1 -1
  82. package/dist/{voice-runtime-BEdqNcST.js → voice-runtime-CjNFaynA.js} +181 -91
  83. package/openclaw.plugin.json +12 -6
  84. package/package.json +4 -6
  85. package/dist/accounts-DJTf1LtA.js +0 -219
  86. package/dist/channel-api-CAJ0wMoV.js +0 -21
  87. package/dist/provider.runtime-C9PnJZbZ.js +0 -2
  88. package/dist/runtime-api.monitor-CHxrFPnW.js +0 -5
  89. package/dist/subagent-hooks-CTt5KCJr.js +0 -120
  90. package/dist/targets-yUFTHoAx.js +0 -3
  91. package/dist/transcripts-source-CfFMexGt.js +0 -123
  92. package/node_modules/p-map/index.d.ts +0 -155
  93. package/node_modules/p-map/index.js +0 -285
  94. package/node_modules/p-map/license +0 -9
  95. package/node_modules/p-map/package.json +0 -57
  96. package/node_modules/p-map/readme.md +0 -190
  97. package/dist/{allow-list-DnxIlPP2.js → allow-list-BDMimASD.js} +1 -1
  98. package/dist/{audit-core-xwjIczO0.js → audit-core-BCX8UeFH.js} +1 -1
  99. package/dist/{doctor-contract-DLa-BTiU.js → doctor-contract-DsWvKIXF.js} +1 -1
  100. package/dist/{security-audit-jGnJF__m.js → security-audit-BfJhAXZp.js} +1 -1
@@ -1,219 +0,0 @@
1
- import { createAccountActionGate, createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
2
- import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
3
- import { mapAllowFromEntries, normalizeChannelDmPolicy } from "openclaw/plugin-sdk/channel-config-helpers";
4
- import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$1, resolveAccountEntry } from "openclaw/plugin-sdk/routing";
5
- import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
- import { getRuntimeConfigSnapshot, getRuntimeConfigSourceSnapshot, selectApplicableRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
7
- import { normalizeResolvedSecretInputString, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
8
- //#region extensions/discord/src/runtime-config.ts
9
- function selectDiscordRuntimeConfig(inputConfig) {
10
- return selectApplicableRuntimeConfig({
11
- inputConfig,
12
- runtimeConfig: getRuntimeConfigSnapshot(),
13
- runtimeSourceConfig: getRuntimeConfigSourceSnapshot()
14
- }) ?? inputConfig;
15
- }
16
- //#endregion
17
- //#region extensions/discord/src/token.ts
18
- function stripDiscordBotPrefix(token) {
19
- return token.replace(/^Bot\s+/i, "");
20
- }
21
- function normalizeDiscordToken(raw, path) {
22
- const trimmed = normalizeResolvedSecretInputString({
23
- value: raw,
24
- path
25
- });
26
- if (!trimmed) return;
27
- return stripDiscordBotPrefix(trimmed);
28
- }
29
- function resolveDiscordTokenValue(params) {
30
- const resolved = resolveSecretInputString({
31
- value: params.value,
32
- path: params.path,
33
- defaults: params.cfg.secrets?.defaults,
34
- mode: "inspect"
35
- });
36
- if (resolved.status === "available") return {
37
- status: "available",
38
- value: stripDiscordBotPrefix(resolved.value)
39
- };
40
- if (resolved.status === "configured_unavailable") return { status: "configured_unavailable" };
41
- return { status: "missing" };
42
- }
43
- function resolveDiscordToken(cfg, opts = {}) {
44
- const selectedCfg = selectDiscordRuntimeConfig(cfg);
45
- const accountId = normalizeAccountId$1(opts.accountId);
46
- const discordCfg = selectedCfg?.channels?.discord;
47
- const accountCfg = resolveAccountEntry(discordCfg?.accounts, accountId);
48
- const hasAccountToken = Boolean(accountCfg && Object.hasOwn(accountCfg, "token"));
49
- const accountToken = resolveDiscordTokenValue({
50
- cfg: selectedCfg,
51
- value: accountCfg?.token,
52
- path: `channels.discord.accounts.${accountId}.token`
53
- });
54
- if (accountToken.status === "available" && accountToken.value) return {
55
- token: accountToken.value,
56
- source: "config",
57
- tokenStatus: "available"
58
- };
59
- if (accountToken.status === "configured_unavailable") return {
60
- token: "",
61
- source: "config",
62
- tokenStatus: "configured_unavailable"
63
- };
64
- if (hasAccountToken) return {
65
- token: "",
66
- source: "none",
67
- tokenStatus: "missing"
68
- };
69
- const configToken = resolveDiscordTokenValue({
70
- cfg: selectedCfg,
71
- value: discordCfg?.token,
72
- path: "channels.discord.token"
73
- });
74
- if (configToken.status === "available" && configToken.value) return {
75
- token: configToken.value,
76
- source: "config",
77
- tokenStatus: "available"
78
- };
79
- if (configToken.status === "configured_unavailable") return {
80
- token: "",
81
- source: "config",
82
- tokenStatus: "configured_unavailable"
83
- };
84
- const envToken = accountId === DEFAULT_ACCOUNT_ID$1 ? normalizeDiscordToken(opts.envToken ?? process.env.DISCORD_BOT_TOKEN, "DISCORD_BOT_TOKEN") : void 0;
85
- if (envToken) return {
86
- token: envToken,
87
- source: "env",
88
- tokenStatus: "available"
89
- };
90
- return {
91
- token: "",
92
- source: "none",
93
- tokenStatus: "missing"
94
- };
95
- }
96
- //#endregion
97
- //#region extensions/discord/src/accounts.ts
98
- const { listAccountIds, resolveDefaultAccountId, resolveAccountConfig: resolveMergedDiscordAccountConfig } = createAccountListHelpers("discord", {
99
- implicitDefaultAccount: {
100
- channelKeys: ["token"],
101
- envVars: ["DISCORD_BOT_TOKEN"]
102
- },
103
- nestedObjectKeys: [
104
- "activities",
105
- "agentComponents",
106
- "botLoopProtection"
107
- ]
108
- });
109
- const listDiscordAccountIds = listAccountIds;
110
- const resolveDefaultDiscordAccountId = resolveDefaultAccountId;
111
- function resolveDiscordAccountConfig(cfg, accountId) {
112
- return resolveAccountEntry(cfg.channels?.discord?.accounts, accountId);
113
- }
114
- function mergeDiscordAccountConfig(cfg, accountId) {
115
- return resolveMergedDiscordAccountConfig(cfg, accountId);
116
- }
117
- function resolveDiscordAccountAllowFrom(params) {
118
- const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordAccountId(params.cfg));
119
- const accountConfig = resolveDiscordAccountConfig(params.cfg, accountId);
120
- const rootConfig = params.cfg.channels?.discord;
121
- const allowFrom = accountConfig?.allowFrom ?? rootConfig?.allowFrom;
122
- return allowFrom ? mapAllowFromEntries(allowFrom) : void 0;
123
- }
124
- function resolveDiscordAccountDmPolicy(params) {
125
- const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordAccountId(params.cfg));
126
- const accountConfig = resolveDiscordAccountConfig(params.cfg, accountId);
127
- const rootConfig = params.cfg.channels?.discord;
128
- return normalizeChannelDmPolicy(accountConfig?.dmPolicy ?? rootConfig?.dmPolicy ?? "pairing");
129
- }
130
- function createDiscordActionGate(params) {
131
- const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordAccountId(params.cfg));
132
- return createAccountActionGate({
133
- baseActions: params.cfg.channels?.discord?.actions,
134
- accountActions: resolveDiscordAccountConfig(params.cfg, accountId)?.actions
135
- });
136
- }
137
- function resolveDiscordAccount(params) {
138
- const cfg = selectDiscordRuntimeConfig(params.cfg);
139
- const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordAccountId(cfg));
140
- const baseEnabled = cfg.channels?.discord?.enabled !== false;
141
- const merged = mergeDiscordAccountConfig(cfg, accountId);
142
- const accountEnabled = merged.enabled !== false;
143
- const enabled = baseEnabled && accountEnabled;
144
- const tokenResolution = resolveDiscordToken(cfg, { accountId });
145
- return {
146
- accountId,
147
- enabled,
148
- name: normalizeOptionalString(merged.name),
149
- token: tokenResolution.token,
150
- tokenSource: tokenResolution.source,
151
- tokenStatus: tokenResolution.tokenStatus,
152
- config: merged
153
- };
154
- }
155
- function resolveDiscordMaxLinesPerMessage(params) {
156
- if (typeof params.discordConfig?.maxLinesPerMessage === "number") return params.discordConfig.maxLinesPerMessage;
157
- return resolveDiscordAccount({
158
- cfg: params.cfg,
159
- accountId: params.accountId
160
- }).config.maxLinesPerMessage;
161
- }
162
- function resolveDiscordAccountTokenOwner(params) {
163
- const token = params.token.trim();
164
- if (!token) return;
165
- let owner;
166
- const accountIds = listDiscordAccountIds(params.cfg);
167
- for (const [index, accountId] of accountIds.entries()) {
168
- const account = resolveDiscordAccount({
169
- cfg: params.cfg,
170
- accountId
171
- });
172
- const accountToken = account.token.trim();
173
- if (!account.enabled || accountToken !== token) continue;
174
- const priority = account.tokenSource === "config" ? 2 : account.tokenSource === "env" ? 1 : 0;
175
- if (!owner || priority > owner.priority) {
176
- owner = {
177
- accountId: account.accountId,
178
- priority,
179
- index
180
- };
181
- continue;
182
- }
183
- if (priority === owner.priority && index < owner.index) owner = {
184
- accountId: account.accountId,
185
- priority,
186
- index
187
- };
188
- }
189
- return owner?.accountId;
190
- }
191
- function resolveDiscordDuplicateTokenOwner(params) {
192
- const owner = resolveDiscordAccountTokenOwner({
193
- cfg: params.cfg,
194
- token: params.account.token
195
- });
196
- return owner && owner !== params.account.accountId ? owner : void 0;
197
- }
198
- function isDiscordAccountEnabledForRuntime(account, cfg) {
199
- return account.enabled && !resolveDiscordDuplicateTokenOwner({
200
- cfg,
201
- account
202
- });
203
- }
204
- function resolveDiscordAccountDisabledReason(account, cfg) {
205
- if (!account.enabled) return "disabled";
206
- const owner = resolveDiscordDuplicateTokenOwner({
207
- cfg,
208
- account
209
- });
210
- return owner ? `duplicate bot token; using account "${owner}"` : "disabled";
211
- }
212
- function listEnabledDiscordAccounts(cfg) {
213
- return listDiscordAccountIds(cfg).map((accountId) => resolveDiscordAccount({
214
- cfg,
215
- accountId
216
- })).filter((account) => isDiscordAccountEnabledForRuntime(account, cfg));
217
- }
218
- //#endregion
219
- export { mergeDiscordAccountConfig as a, resolveDiscordAccountAllowFrom as c, resolveDiscordAccountDmPolicy as d, resolveDiscordMaxLinesPerMessage as f, listEnabledDiscordAccounts as i, resolveDiscordAccountConfig as l, resolveDiscordToken as m, isDiscordAccountEnabledForRuntime as n, resolveDefaultDiscordAccountId as o, normalizeDiscordToken as p, listDiscordAccountIds as r, resolveDiscordAccount as s, createDiscordActionGate as t, resolveDiscordAccountDisabledReason as u };
@@ -1,21 +0,0 @@
1
- import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1 } from "openclaw/plugin-sdk/account-id";
2
- import { PAIRING_APPROVED_MESSAGE, buildTokenChannelStatusSummary, projectCredentialSnapshotFields, resolveConfiguredFromCredentialStatuses } from "openclaw/plugin-sdk/channel-status";
3
- //#region extensions/discord/src/channel-api.ts
4
- const DISCORD_CHANNEL_META = {
5
- id: "discord",
6
- label: "Discord",
7
- selectionLabel: "Discord (Bot API)",
8
- detailLabel: "Discord Bot",
9
- docsPath: "/channels/discord",
10
- docsLabel: "discord",
11
- blurb: "very well supported right now.",
12
- systemImage: "bubble.left.and.bubble.right",
13
- markdownCapable: true,
14
- preferSessionLookupForAnnounceTarget: true
15
- };
16
- function getChatChannelMeta(id) {
17
- if (id !== DISCORD_CHANNEL_META.id) throw new Error(`Unsupported Discord channel meta lookup: ${id}`);
18
- return DISCORD_CHANNEL_META;
19
- }
20
- //#endregion
21
- export { projectCredentialSnapshotFields as a, getChatChannelMeta as i, PAIRING_APPROVED_MESSAGE as n, resolveConfiguredFromCredentialStatuses as o, buildTokenChannelStatusSummary as r, DEFAULT_ACCOUNT_ID$1 as t };
@@ -1,2 +0,0 @@
1
- import { t as monitorDiscordProvider } from "./provider-DvSNb-2v.js";
2
- export { monitorDiscordProvider };
@@ -1,5 +0,0 @@
1
- import "./allow-list-DnxIlPP2.js";
2
- import "./timeouts-B9cy6RvQ.js";
3
- import "./provider-DvSNb-2v.js";
4
- import "./message-handler-Unk_f10F.js";
5
- export {};
@@ -1,120 +0,0 @@
1
- import { tn as __exportAll } from "./retry-CLpJcXXf.js";
2
- import { s as resolveDiscordAccount } from "./accounts-DJTf1LtA.js";
3
- import { n as autoBindSpawnedDiscordSubagent, o as unbindThreadBindingsBySessionKey, r as listThreadBindingsBySessionKey } from "./thread-bindings-3L8p82GV.js";
4
- import { normalizeOptionalLowercaseString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
5
- import { formatThreadBindingDisabledError, formatThreadBindingSpawnDisabledError, resolveThreadBindingSpawnPolicy } from "openclaw/plugin-sdk/conversation-runtime";
6
- //#region extensions/discord/src/subagent-hooks.ts
7
- var subagent_hooks_exports = /* @__PURE__ */ __exportAll({
8
- handleDiscordSubagentDeliveryTarget: () => handleDiscordSubagentDeliveryTarget,
9
- handleDiscordSubagentEnded: () => handleDiscordSubagentEnded,
10
- handleDiscordSubagentSpawning: () => handleDiscordSubagentSpawning
11
- });
12
- function summarizeError(err) {
13
- if (err instanceof Error) return err.message;
14
- if (typeof err === "string") return err;
15
- return "error";
16
- }
17
- function normalizeThreadBindingTargetKind(raw) {
18
- const normalized = normalizeOptionalLowercaseString(raw);
19
- if (normalized === "subagent" || normalized === "acp") return normalized;
20
- }
21
- async function handleDiscordSubagentSpawning(api, event) {
22
- if (!event.threadRequested) return;
23
- if (normalizeOptionalLowercaseString(event.requester?.channel) !== "discord") return;
24
- const account = resolveDiscordAccount({
25
- cfg: api.config,
26
- accountId: event.requester?.accountId
27
- });
28
- const threadBindingPolicy = resolveThreadBindingSpawnPolicy({
29
- cfg: api.config,
30
- channel: "discord",
31
- accountId: account.accountId,
32
- kind: "subagent"
33
- });
34
- if (!threadBindingPolicy.enabled) return {
35
- status: "error",
36
- error: formatThreadBindingDisabledError({
37
- channel: threadBindingPolicy.channel,
38
- accountId: threadBindingPolicy.accountId,
39
- kind: "subagent"
40
- })
41
- };
42
- if (!threadBindingPolicy.spawnEnabled) return {
43
- status: "error",
44
- error: formatThreadBindingSpawnDisabledError({
45
- channel: threadBindingPolicy.channel,
46
- accountId: threadBindingPolicy.accountId,
47
- kind: "subagent"
48
- })
49
- };
50
- try {
51
- const agentId = event.agentId?.trim() || "subagent";
52
- const binding = await autoBindSpawnedDiscordSubagent({
53
- cfg: api.config,
54
- accountId: account.accountId,
55
- channel: event.requester?.channel,
56
- to: event.requester?.to,
57
- threadId: event.requester?.threadId,
58
- childSessionKey: event.childSessionKey,
59
- agentId,
60
- label: event.label,
61
- boundBy: "system"
62
- });
63
- if (!binding) return {
64
- status: "error",
65
- error: "Unable to create or bind a Discord thread for this subagent session. Session mode is unavailable for this target."
66
- };
67
- return {
68
- status: "ok",
69
- threadBindingReady: true,
70
- deliveryOrigin: {
71
- channel: "discord",
72
- accountId: account.accountId,
73
- to: `channel:${binding.threadId}`,
74
- threadId: binding.threadId
75
- }
76
- };
77
- } catch (err) {
78
- return {
79
- status: "error",
80
- error: `Discord thread bind failed: ${summarizeError(err)}`
81
- };
82
- }
83
- }
84
- function handleDiscordSubagentEnded(event) {
85
- unbindThreadBindingsBySessionKey({
86
- targetSessionKey: event.targetSessionKey,
87
- accountId: event.accountId,
88
- targetKind: normalizeThreadBindingTargetKind(event.targetKind),
89
- reason: event.reason,
90
- sendFarewell: event.sendFarewell
91
- });
92
- }
93
- function handleDiscordSubagentDeliveryTarget(event) {
94
- if (!event.expectsCompletionMessage) return;
95
- if (normalizeOptionalLowercaseString(event.requesterOrigin?.channel) !== "discord") return;
96
- const requesterAccountId = event.requesterOrigin?.accountId?.trim();
97
- const requesterThreadId = event.requesterOrigin?.threadId != null && event.requesterOrigin.threadId !== "" ? normalizeOptionalStringifiedId(event.requesterOrigin.threadId) ?? "" : "";
98
- const bindings = listThreadBindingsBySessionKey({
99
- targetSessionKey: event.childSessionKey,
100
- ...requesterAccountId ? { accountId: requesterAccountId } : {},
101
- targetKind: "subagent"
102
- });
103
- if (bindings.length === 0) return;
104
- let binding;
105
- if (requesterThreadId) binding = bindings.find((entry) => {
106
- if (entry.threadId !== requesterThreadId) return false;
107
- if (requesterAccountId && entry.accountId !== requesterAccountId) return false;
108
- return true;
109
- });
110
- if (!binding && bindings.length === 1) binding = bindings[0];
111
- if (!binding) return;
112
- return { origin: {
113
- channel: "discord",
114
- accountId: binding.accountId,
115
- to: `channel:${binding.threadId}`,
116
- threadId: binding.threadId
117
- } };
118
- }
119
- //#endregion
120
- export { subagent_hooks_exports as i, handleDiscordSubagentEnded as n, handleDiscordSubagentSpawning as r, handleDiscordSubagentDeliveryTarget as t };
@@ -1,3 +0,0 @@
1
- import "./retry-CLpJcXXf.js";
2
- import "./target-resolver-maOKSqO0.js";
3
- export {};
@@ -1,123 +0,0 @@
1
- import { tn as __exportAll } from "./retry-CLpJcXXf.js";
2
- //#region extensions/discord/src/voice/transcripts-source.ts
3
- var transcripts_source_exports = /* @__PURE__ */ __exportAll({
4
- discordVoiceTranscriptsSourceProvider: () => discordVoiceTranscriptsSourceProvider,
5
- setDiscordTranscriptsVoiceManager: () => setDiscordTranscriptsVoiceManager
6
- });
7
- const managersByAccountId = /* @__PURE__ */ new Map();
8
- const managerWaiters = /* @__PURE__ */ new Set();
9
- function setDiscordTranscriptsVoiceManager(params) {
10
- if (params.manager) {
11
- managersByAccountId.set(params.accountId, params.manager);
12
- for (const waiter of managerWaiters) if (!waiter.accountId || waiter.accountId === params.accountId) waiter.resolve();
13
- } else managersByAccountId.delete(params.accountId);
14
- }
15
- function resolveManager(request) {
16
- const accountId = request.session.source.accountId?.trim();
17
- if (accountId) return managersByAccountId.get(accountId);
18
- return [...managersByAccountId.values()][0];
19
- }
20
- async function waitForManager(request) {
21
- const existing = resolveManager(request);
22
- if (existing) return existing;
23
- if (request.abortSignal?.aborted) return;
24
- const startupWaitMs = request.startupWaitMs ?? 0;
25
- if (startupWaitMs <= 0) return;
26
- const accountId = request.session.source.accountId?.trim() || void 0;
27
- await new Promise((resolve) => {
28
- const waiter = {
29
- accountId,
30
- resolve: () => {
31
- clearTimeout(timer);
32
- request.abortSignal?.removeEventListener("abort", waiter.resolve);
33
- managerWaiters.delete(waiter);
34
- resolve();
35
- }
36
- };
37
- const timer = setTimeout(waiter.resolve, startupWaitMs);
38
- timer.unref?.();
39
- request.abortSignal?.addEventListener("abort", waiter.resolve, { once: true });
40
- managerWaiters.add(waiter);
41
- });
42
- if (request.abortSignal?.aborted) return;
43
- return resolveManager(request);
44
- }
45
- const discordVoiceTranscriptsSourceProvider = {
46
- id: "discord-voice",
47
- aliases: ["discord"],
48
- name: "Discord Voice",
49
- sourceKinds: ["live-audio"],
50
- async start(request) {
51
- const manager = await waitForManager(request);
52
- if (!manager) return {
53
- ok: false,
54
- error: "Discord voice manager is not available."
55
- };
56
- if (request.abortSignal?.aborted) return {
57
- ok: false,
58
- error: "Discord transcripts start aborted."
59
- };
60
- const guildId = request.session.source.guildId?.trim();
61
- const channelId = request.session.source.channelId?.trim();
62
- if (!guildId || !channelId) return {
63
- ok: false,
64
- error: "Discord transcripts require guildId and channelId."
65
- };
66
- const joined = await manager.join({
67
- guildId,
68
- channelId
69
- }, { transcripts: {
70
- sessionId: request.session.sessionId,
71
- onUtterance: request.onUtterance
72
- } });
73
- if (!joined.ok) return {
74
- ok: false,
75
- error: joined.message
76
- };
77
- return {
78
- ok: true,
79
- session: request.session
80
- };
81
- },
82
- async stop(request) {
83
- const accountId = request.source.accountId?.trim();
84
- const manager = accountId ? managersByAccountId.get(accountId) : [...managersByAccountId.values()][0];
85
- if (!manager) return {
86
- ok: false,
87
- error: "Discord voice manager is not available."
88
- };
89
- const guildId = request.source.guildId?.trim();
90
- if (!guildId) return {
91
- ok: false,
92
- error: "Discord transcripts require guildId."
93
- };
94
- const result = await manager.leave({
95
- guildId,
96
- channelId: request.source.channelId
97
- }, { transcriptsSessionId: request.sessionId });
98
- if (!result.ok) return {
99
- ok: false,
100
- error: result.message
101
- };
102
- return {
103
- ok: true,
104
- sessionId: request.sessionId,
105
- stoppedAt: (/* @__PURE__ */ new Date()).toISOString()
106
- };
107
- },
108
- async status(source) {
109
- const accountId = source.accountId?.trim();
110
- return (accountId ? managersByAccountId.get(accountId) : [...managersByAccountId.values()][0])?.status().map((entry) => ({
111
- active: entry.ok,
112
- message: entry.message,
113
- source: {
114
- providerId: "discord-voice",
115
- accountId,
116
- guildId: entry.guildId,
117
- channelId: entry.channelId
118
- }
119
- })) ?? [];
120
- }
121
- };
122
- //#endregion
123
- export { transcripts_source_exports as n, discordVoiceTranscriptsSourceProvider as t };
@@ -1,155 +0,0 @@
1
- type BaseOptions = {
2
- /**
3
- Number of concurrently pending promises returned by `mapper`.
4
-
5
- Must be an integer from 1 and up or `Infinity`.
6
-
7
- @default Infinity
8
- */
9
- readonly concurrency?: number;
10
- };
11
-
12
- export type Options = BaseOptions & {
13
- /**
14
- When `true`, the first mapper rejection will be rejected back to the consumer.
15
-
16
- When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) containing all the errors from the rejected promises.
17
-
18
- Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. Use the `signal` option for abort control.
19
-
20
- @default true
21
- */
22
- readonly stopOnError?: boolean;
23
-
24
- /**
25
- You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
26
-
27
- @example
28
- ```
29
- import pMap from 'p-map';
30
- import delay from 'delay';
31
-
32
- const abortController = new AbortController();
33
-
34
- setTimeout(() => {
35
- abortController.abort();
36
- }, 500);
37
-
38
- const mapper = async value => value;
39
-
40
- await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
41
- // Throws AbortError (DOMException) after 500 ms.
42
- ```
43
- */
44
- readonly signal?: AbortSignal | undefined;
45
- };
46
-
47
- export type IterableOptions = BaseOptions & {
48
- /**
49
- Maximum number of promises returned by `mapper` that have resolved but not yet collected by the consumer of the async iterable. Calls to `mapper` will be limited so that there is never too much backpressure.
50
-
51
- Useful whenever you are consuming the iterable slower than what the mapper function can produce concurrently. For example, to avoid making an overwhelming number of HTTP requests if you are saving each of the results to a database.
52
-
53
- Default: `options.concurrency`
54
- */
55
- readonly backpressure?: number;
56
- };
57
-
58
- type MaybePromise<T> = T | Promise<T>;
59
-
60
- /**
61
- Function which is called for every item in `input`. Expected to return a `Promise` or value.
62
-
63
- @param element - Iterated element.
64
- @param index - Index of the element in the source array.
65
- */
66
- export type Mapper<Element = any, NewElement = unknown> = (
67
- element: Element,
68
- index: number
69
- ) => MaybePromise<NewElement | typeof pMapSkip>;
70
-
71
- /**
72
- @param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
73
- @param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
74
- @returns A `Promise` that is fulfilled when all promises in `input` and the ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
75
-
76
- @example
77
- ```
78
- import pMap from 'p-map';
79
- import got from 'got';
80
-
81
- const sites = [
82
- getWebsiteFromUsername('sindresorhus'), //=> Promise
83
- 'https://avajs.dev',
84
- 'https://github.com'
85
- ];
86
-
87
- const mapper = async site => {
88
- const {requestUrl} = await got.head(site);
89
- return requestUrl;
90
- };
91
-
92
- const result = await pMap(sites, mapper, {concurrency: 2});
93
-
94
- console.log(result);
95
- //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
96
- ```
97
- */
98
- export default function pMap<Element, NewElement>(
99
- input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
100
- mapper: Mapper<Element, NewElement>,
101
- options?: Options
102
- ): Promise<Array<Exclude<NewElement, typeof pMapSkip>>>;
103
-
104
- /**
105
- @param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
106
- @param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
107
- @returns An async iterable that streams each return value from `mapper` in order.
108
-
109
- @example
110
- ```
111
- import {pMapIterable} from 'p-map';
112
-
113
- // Multiple posts are fetched concurrently, with limited concurrency and backpressure
114
- for await (const post of pMapIterable(postIds, getPostMetadata, {concurrency: 8})) {
115
- console.log(post);
116
- };
117
- ```
118
- */
119
- export function pMapIterable<Element, NewElement>(
120
- input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
121
- mapper: Mapper<Element, NewElement>,
122
- options?: IterableOptions
123
- ): AsyncIterable<Exclude<NewElement, typeof pMapSkip>>;
124
-
125
- /**
126
- Return this value from a `mapper` function to skip including the value in the returned array.
127
-
128
- @example
129
- ```
130
- import pMap, {pMapSkip} from 'p-map';
131
- import got from 'got';
132
-
133
- const sites = [
134
- getWebsiteFromUsername('sindresorhus'), //=> Promise
135
- 'https://avajs.dev',
136
- 'https://example.invalid',
137
- 'https://github.com'
138
- ];
139
-
140
- const mapper = async site => {
141
- try {
142
- const {requestUrl} = await got.head(site);
143
- return requestUrl;
144
- } catch {
145
- return pMapSkip;
146
- }
147
- };
148
-
149
- const result = await pMap(sites, mapper, {concurrency: 2});
150
-
151
- console.log(result);
152
- //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
153
- ```
154
- */
155
- export const pMapSkip: unique symbol;