@aiwg/cli 2026.10.15 → 2026.10.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
- package/dist/src/artifacts/citation-parser.js +7 -6
- package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
- package/dist/src/artifacts/corpus-tools/cli.js +8 -3
- package/dist/src/artifacts/corpus-tools/discovery-log.js +26 -24
- package/dist/src/artifacts/corpus-tools/expand-cli.js +3 -2
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +4 -1
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +17 -1
- package/dist/src/artifacts/corpus-tools/expand.js +16 -17
- package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
- package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
- package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +11 -3
- package/dist/src/artifacts/corpus-tools/resolve.js +23 -9
- package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
- package/dist/src/artifacts/graph-query.js +5 -3
- package/dist/src/artifacts/hybrid-query.js +11 -2
- package/dist/src/artifacts/index-refresh.js +2 -0
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +10 -5
- package/dist/src/cli/handlers/doctor-help.js +4 -1
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +3 -2
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands.js +8 -0
- package/dist/src/cli/handlers/update.js +157 -0
- package/dist/src/cli/handlers/use.js +14 -4
- package/dist/src/cli/handlers/utilities.js +3 -560
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +17 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +19 -0
- package/dist/src/config/host-resource-report.mjs +80 -0
- package/dist/src/config/host-resource-runtime.d.mts +34 -0
- package/dist/src/config/host-resource-runtime.mjs +293 -0
- package/dist/src/config/installed-selection.js +22 -0
- package/dist/src/config/worker-invocation-marker.d.mts +1 -0
- package/dist/src/config/worker-invocation-marker.mjs +2 -0
- package/dist/src/decision/heldout/access.js +74 -0
- package/dist/src/decision/heldout/calibration.js +1 -0
- package/dist/src/decision/heldout/collector.js +8 -1
- package/dist/src/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +115 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/gates/heldout.js +17 -7
- package/dist/src/lint/check-patterns.js +163 -0
- package/dist/src/lint/checks.js +268 -0
- package/dist/src/lint/reference-resolution.js +54 -0
- package/dist/src/lint/runner.js +3 -465
- package/dist/src/mcp/helpers.mjs +11 -1
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/models/worker-plan.js +36 -5
- package/dist/src/models/wrapper-deployment.js +25 -12
- package/dist/src/models/wrapper-enforcement.js +47 -7
- package/dist/src/network-analysis/research.js +2 -1
- package/dist/src/policy/hitl-check.js +14 -4
- package/dist/src/policy/hitl-consume.js +54 -0
- package/dist/src/policy/hitl-receipt.js +2 -0
- package/dist/src/policy/hitl.js +11 -3
- package/dist/src/providers/provider-context-contracts.js +162 -0
- package/dist/src/providers/provider-definition-schema.js +136 -0
- package/dist/src/providers/provider-definitions.js +8 -1298
- package/dist/src/providers/provider-seeds-1.js +360 -0
- package/dist/src/providers/provider-seeds-2.js +387 -0
- package/dist/src/providers/provider-seeds-3.js +262 -0
- package/dist/src/research/clients/arxiv.js +4 -30
- package/dist/src/research/clients/base.js +48 -22
- package/dist/src/research/identity.js +34 -2
- package/dist/src/research/query-cli.js +3 -87
- package/dist/src/research/query-options.js +87 -0
- package/dist/src/research/reference-match.js +70 -24
- package/dist/src/research/services/acquisition.js +9 -7
- package/dist/src/research/services/citation.js +5 -2
- package/dist/src/research/types.js +2 -0
- package/dist/src/serve/mission-conductor.js +48 -4
- package/dist/src/sessions/adapters/grok-build-native.js +23 -0
- package/dist/src/sessions/adapters/grok-build.js +14 -7
- package/dist/src/sessions/workspace-discovery.js +5 -5
- package/dist/src/smiths/context-pipeline/aiwg-md.js +16 -46
- package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +9 -10
- package/dist/src/smiths/context-pipeline/managed-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
- package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
- package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
- package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
- package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
- package/package.json +10 -1
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +10 -0
- package/tools/agents/providers/claude-post-deploy.mjs +12 -1
- package/tools/agents/providers/context-write.mjs +4 -0
- package/tools/agents/providers/pi.mjs +3 -1
- package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1144
- package/tools/agents/providers/rule-deployment-commit.mjs +144 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +452 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/daemon/README.md +511 -0
- package/tools/daemon/adapters/base-adapter.mjs +84 -0
- package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
- package/tools/daemon/agent-supervisor.mjs +299 -0
- package/tools/daemon/automation-engine.mjs +310 -0
- package/tools/daemon/autonomous-engine.mjs +346 -0
- package/tools/daemon/behavior-loader.mjs +316 -0
- package/tools/daemon/behavior.mjs +174 -0
- package/tools/daemon/concierge/intent-router.mjs +401 -0
- package/tools/daemon/concierge/orchestrator.mjs +272 -0
- package/tools/daemon/concierge/response-translator.mjs +462 -0
- package/tools/daemon/config.mjs +377 -0
- package/tools/daemon/cron-scheduler.mjs +178 -0
- package/tools/daemon/daemon-main.mjs +1169 -0
- package/tools/daemon/event-router.mjs +84 -0
- package/tools/daemon/file-watcher.mjs +383 -0
- package/tools/daemon/index.mjs +1181 -0
- package/tools/daemon/init-profile.mjs +124 -0
- package/tools/daemon/ipc-client.mjs +197 -0
- package/tools/daemon/ipc-ops-handlers.mjs +236 -0
- package/tools/daemon/ipc-server.mjs +275 -0
- package/tools/daemon/maintenance-owner.mjs +79 -0
- package/tools/daemon/memory-manager.mjs +386 -0
- package/tools/daemon/message-router.mjs +194 -0
- package/tools/daemon/provider-watcher.mjs +585 -0
- package/tools/daemon/pty-adapter.mjs +420 -0
- package/tools/daemon/repl-chat.mjs +359 -0
- package/tools/daemon/resource-bounds.mjs +88 -0
- package/tools/daemon/sandbox-transport.mjs +295 -0
- package/tools/daemon/scheduled-task-runner.mjs +535 -0
- package/tools/daemon/task-store.mjs +450 -0
- package/tools/daemon/tmux-manager.mjs +324 -0
- package/tools/daemon/update-policy.mjs +517 -0
- package/tools/daemon/web-server.mjs +399 -0
- package/tools/daemon/web-ui/index.html +585 -0
- package/tools/daemon/web-ui/styles.css +156 -0
- package/tools/docker/Dockerfile.daemon +35 -0
- package/tools/docker/container-manager.mjs +291 -0
- package/tools/messaging/adapter-registry.mjs +230 -0
- package/tools/messaging/adapters/base.mjs +326 -0
- package/tools/messaging/adapters/discord.mjs +462 -0
- package/tools/messaging/adapters/slack.mjs +402 -0
- package/tools/messaging/adapters/telegram.mjs +552 -0
- package/tools/messaging/chat-handler.mjs +297 -0
- package/tools/messaging/command-router.mjs +269 -0
- package/tools/messaging/event-bus.mjs +199 -0
- package/tools/messaging/index.mjs +456 -0
- package/tools/messaging/message-formatter.mjs +320 -0
- package/tools/messaging/room-manager.mjs +277 -0
- package/tools/messaging/types.mjs +94 -0
- package/tools/providers/pi-bridge-policy.mjs +4 -0
- package/tools/ralph-external/daemon-supervisor.mjs +394 -0
- package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +3 -2
- package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
- package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
- package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base adapter class for messaging platform integrations.
|
|
3
|
+
*
|
|
4
|
+
* All platform adapters (Slack, Discord, Telegram) extend this base class
|
|
5
|
+
* to implement the MessagingAdapter interface from the ADR.
|
|
6
|
+
*
|
|
7
|
+
* @implements @.aiwg/architecture/adrs/ADR-messaging-bot-mode.md
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} MessageResult
|
|
12
|
+
* @property {string} messageId - Platform message ID
|
|
13
|
+
* @property {string} channelId - Channel where message was sent
|
|
14
|
+
* @property {boolean} success
|
|
15
|
+
* @property {string} [error]
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} AdapterStatus
|
|
20
|
+
* @property {boolean} connected
|
|
21
|
+
* @property {string} platform
|
|
22
|
+
* @property {number} messagesSent
|
|
23
|
+
* @property {number} messagesReceived
|
|
24
|
+
* @property {number} errors
|
|
25
|
+
* @property {string} [lastError]
|
|
26
|
+
* @property {string} [connectedAt]
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export class BaseAdapter {
|
|
30
|
+
/** @type {string} */
|
|
31
|
+
platform;
|
|
32
|
+
|
|
33
|
+
/** @type {boolean} */
|
|
34
|
+
#connected = false;
|
|
35
|
+
|
|
36
|
+
/** @type {number} */
|
|
37
|
+
#messagesSent = 0;
|
|
38
|
+
|
|
39
|
+
/** @type {number} */
|
|
40
|
+
#messagesReceived = 0;
|
|
41
|
+
|
|
42
|
+
/** @type {number} */
|
|
43
|
+
#errors = 0;
|
|
44
|
+
|
|
45
|
+
/** @type {string|null} */
|
|
46
|
+
#lastError = null;
|
|
47
|
+
|
|
48
|
+
/** @type {string|null} */
|
|
49
|
+
#connectedAt = null;
|
|
50
|
+
|
|
51
|
+
/** @type {Function[]} */
|
|
52
|
+
#commandHandlers = [];
|
|
53
|
+
|
|
54
|
+
/** @type {Function[]} */
|
|
55
|
+
#messageHandlers = [];
|
|
56
|
+
|
|
57
|
+
/** @type {Map<string, Object>} Room registry keyed by platform room ID */
|
|
58
|
+
#rooms = new Map();
|
|
59
|
+
#sensitiveValues = [];
|
|
60
|
+
|
|
61
|
+
constructor(platform) {
|
|
62
|
+
if (new.target === BaseAdapter) {
|
|
63
|
+
throw new Error('BaseAdapter is abstract — instantiate a platform-specific adapter');
|
|
64
|
+
}
|
|
65
|
+
this.platform = platform;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Initialize the adapter (connect to platform).
|
|
70
|
+
* Must be implemented by subclasses.
|
|
71
|
+
*
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
async initialize() {
|
|
75
|
+
throw new Error('initialize() must be implemented');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Shutdown the adapter (disconnect from platform).
|
|
80
|
+
* Must be implemented by subclasses.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<void>}
|
|
83
|
+
*/
|
|
84
|
+
async shutdown() {
|
|
85
|
+
throw new Error('shutdown() must be implemented');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Send a formatted message to a channel.
|
|
90
|
+
* Must be implemented by subclasses.
|
|
91
|
+
*
|
|
92
|
+
* @param {import('../message-formatter.mjs').AiwgMessage} message
|
|
93
|
+
* @param {string} channel - Platform-specific channel identifier
|
|
94
|
+
* @returns {Promise<MessageResult>}
|
|
95
|
+
*/
|
|
96
|
+
async send(message, channel) {
|
|
97
|
+
throw new Error('send() must be implemented');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Update an existing message.
|
|
102
|
+
* Must be implemented by subclasses.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} messageId
|
|
105
|
+
* @param {import('../message-formatter.mjs').AiwgMessage} message
|
|
106
|
+
* @returns {Promise<void>}
|
|
107
|
+
*/
|
|
108
|
+
async update(messageId, message) {
|
|
109
|
+
throw new Error('update() must be implemented');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Register a command handler for inbound commands.
|
|
114
|
+
*
|
|
115
|
+
* @param {(command: string, args: string[], context: Object) => Promise<void>} handler
|
|
116
|
+
*/
|
|
117
|
+
onCommand(handler) {
|
|
118
|
+
this.#commandHandlers.push(handler);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Register a message handler for free-text (non-command) messages.
|
|
123
|
+
*
|
|
124
|
+
* @param {(text: string, context: Object) => Promise<void>} handler
|
|
125
|
+
*/
|
|
126
|
+
onMessage(handler) {
|
|
127
|
+
this.#messageHandlers.push(handler);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Check if adapter is connected.
|
|
132
|
+
*
|
|
133
|
+
* @returns {boolean}
|
|
134
|
+
*/
|
|
135
|
+
isConnected() {
|
|
136
|
+
return this.#connected;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get adapter status.
|
|
141
|
+
*
|
|
142
|
+
* @returns {AdapterStatus}
|
|
143
|
+
*/
|
|
144
|
+
getStatus() {
|
|
145
|
+
return {
|
|
146
|
+
connected: this.#connected,
|
|
147
|
+
platform: this.platform,
|
|
148
|
+
messagesSent: this.#messagesSent,
|
|
149
|
+
messagesReceived: this.#messagesReceived,
|
|
150
|
+
errors: this.#errors,
|
|
151
|
+
lastError: this.#lastError,
|
|
152
|
+
connectedAt: this.#connectedAt,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ========================================================================
|
|
157
|
+
// Protected methods for subclasses
|
|
158
|
+
// ========================================================================
|
|
159
|
+
|
|
160
|
+
/** Mark adapter as connected */
|
|
161
|
+
_setConnected() {
|
|
162
|
+
this.#connected = true;
|
|
163
|
+
this.#connectedAt = new Date().toISOString();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Mark adapter as disconnected */
|
|
167
|
+
_setDisconnected() {
|
|
168
|
+
this.#connected = false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Increment sent counter */
|
|
172
|
+
_recordSend() {
|
|
173
|
+
this.#messagesSent++;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Increment received counter */
|
|
177
|
+
_recordReceive() {
|
|
178
|
+
this.#messagesReceived++;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Record an error */
|
|
182
|
+
_recordError(error) {
|
|
183
|
+
this.#errors++;
|
|
184
|
+
this.#lastError = this._redactText(error?.message || String(error));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Recipient-local redaction also covers service responses reflecting credentials. */
|
|
188
|
+
_setSensitiveValues(...values) {
|
|
189
|
+
this.#sensitiveValues = values.filter(value => typeof value === 'string' && value)
|
|
190
|
+
.flatMap(value => [value, encodeURIComponent(value)]).sort((a, b) => b.length - a.length);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
_redactText(text) {
|
|
194
|
+
return this.#sensitiveValues.reduce((result, value) => result.split(value).join('[REDACTED]'), String(text));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_redactError(error) {
|
|
198
|
+
const safe = new Error(this._redactText(error?.message || String(error)));
|
|
199
|
+
safe.name = error?.name || 'Error';
|
|
200
|
+
return safe;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Dispatch a command to registered handlers.
|
|
205
|
+
*
|
|
206
|
+
* @param {string} command
|
|
207
|
+
* @param {string[]} args
|
|
208
|
+
* @param {Object} context
|
|
209
|
+
* @returns {Promise<void>}
|
|
210
|
+
*/
|
|
211
|
+
async _dispatchCommand(command, args, context) {
|
|
212
|
+
this._recordReceive();
|
|
213
|
+
for (const handler of this.#commandHandlers) {
|
|
214
|
+
try {
|
|
215
|
+
await handler(command, args, { ...context, platform: this.platform });
|
|
216
|
+
} catch (error) {
|
|
217
|
+
error = this._redactError(error);
|
|
218
|
+
this._recordError(error);
|
|
219
|
+
console.error(`[${this.platform}] Command handler error:`, error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Dispatch a free-text message to registered message handlers.
|
|
226
|
+
*
|
|
227
|
+
* @param {string} text - The message text
|
|
228
|
+
* @param {Object} context - Platform-specific context
|
|
229
|
+
* @returns {Promise<void>}
|
|
230
|
+
*/
|
|
231
|
+
async _dispatchMessage(text, context) {
|
|
232
|
+
this._recordReceive();
|
|
233
|
+
for (const handler of this.#messageHandlers) {
|
|
234
|
+
try {
|
|
235
|
+
await handler(text, { ...context, platform: this.platform });
|
|
236
|
+
} catch (error) {
|
|
237
|
+
error = this._redactError(error);
|
|
238
|
+
this._recordError(error);
|
|
239
|
+
console.error(`[${this.platform}] Message handler error:`, error);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Check if any message handlers are registered.
|
|
246
|
+
*
|
|
247
|
+
* @returns {boolean}
|
|
248
|
+
*/
|
|
249
|
+
hasMessageHandlers() {
|
|
250
|
+
return this.#messageHandlers.length > 0;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ========================================================================
|
|
254
|
+
// Multi-room methods
|
|
255
|
+
// ========================================================================
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Register a room with this adapter.
|
|
259
|
+
*
|
|
260
|
+
* @param {string} roomId - Platform-native room/channel ID
|
|
261
|
+
* @param {Object} [config] - Room configuration
|
|
262
|
+
* @param {string} [config.label] - Human-readable name
|
|
263
|
+
* @param {boolean} [config.isDefault] - Receives broadcast messages
|
|
264
|
+
* @param {string} [config.purpose] - "interactive" | "notifications" | "logs"
|
|
265
|
+
*/
|
|
266
|
+
addRoom(roomId, config = {}) {
|
|
267
|
+
this.#rooms.set(roomId, {
|
|
268
|
+
roomId,
|
|
269
|
+
label: config.label || roomId,
|
|
270
|
+
isDefault: config.isDefault ?? false,
|
|
271
|
+
purpose: config.purpose || 'interactive',
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Remove a room from this adapter.
|
|
277
|
+
*
|
|
278
|
+
* @param {string} roomId
|
|
279
|
+
* @returns {boolean}
|
|
280
|
+
*/
|
|
281
|
+
removeRoom(roomId) {
|
|
282
|
+
return this.#rooms.delete(roomId);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Get all registered rooms.
|
|
287
|
+
*
|
|
288
|
+
* @returns {Map<string, Object>}
|
|
289
|
+
*/
|
|
290
|
+
getRooms() {
|
|
291
|
+
return this.#rooms;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Send a message to a specific room.
|
|
296
|
+
* Delegates to send() with the room ID as channel.
|
|
297
|
+
*
|
|
298
|
+
* @param {import('../message-formatter.mjs').AiwgMessage} message
|
|
299
|
+
* @param {string} roomId
|
|
300
|
+
* @returns {Promise<MessageResult>}
|
|
301
|
+
*/
|
|
302
|
+
async sendToRoom(message, roomId) {
|
|
303
|
+
return this.send(message, roomId);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Broadcast a message to all default rooms.
|
|
308
|
+
*
|
|
309
|
+
* @param {import('../message-formatter.mjs').AiwgMessage} message
|
|
310
|
+
* @returns {Promise<MessageResult[]>}
|
|
311
|
+
*/
|
|
312
|
+
async broadcastToRooms(message) {
|
|
313
|
+
const results = [];
|
|
314
|
+
for (const [roomId, config] of this.#rooms) {
|
|
315
|
+
if (config.isDefault) {
|
|
316
|
+
try {
|
|
317
|
+
const result = await this.send(message, roomId);
|
|
318
|
+
results.push(result);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
this._recordError(error);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return results;
|
|
325
|
+
}
|
|
326
|
+
}
|