@phronesis-io/openclaw-eigenflux 0.0.1
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/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/agent-prompt-templates.d.ts +16 -0
- package/dist/agent-prompt-templates.d.ts.map +1 -0
- package/dist/agent-prompt-templates.js +67 -0
- package/dist/agent-prompt-templates.js.map +1 -0
- package/dist/config.d.ts +161 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +324 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials-loader.d.ts +28 -0
- package/dist/credentials-loader.d.ts.map +1 -0
- package/dist/credentials-loader.js +121 -0
- package/dist/credentials-loader.js.map +1 -0
- package/dist/gateway-rpc-client.d.ts +26 -0
- package/dist/gateway-rpc-client.d.ts.map +1 -0
- package/dist/gateway-rpc-client.js +288 -0
- package/dist/gateway-rpc-client.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +12 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +25 -0
- package/dist/logger.js.map +1 -0
- package/dist/notification-route-resolver.d.ts +21 -0
- package/dist/notification-route-resolver.d.ts.map +1 -0
- package/dist/notification-route-resolver.js +318 -0
- package/dist/notification-route-resolver.js.map +1 -0
- package/dist/notifier.d.ts +63 -0
- package/dist/notifier.d.ts.map +1 -0
- package/dist/notifier.js +366 -0
- package/dist/notifier.js.map +1 -0
- package/dist/pm-polling-client.d.ts +51 -0
- package/dist/pm-polling-client.d.ts.map +1 -0
- package/dist/pm-polling-client.js +175 -0
- package/dist/pm-polling-client.js.map +1 -0
- package/dist/polling-client.d.ts +73 -0
- package/dist/polling-client.d.ts.map +1 -0
- package/dist/polling-client.js +176 -0
- package/dist/polling-client.js.map +1 -0
- package/dist/session-route-memory.d.ts +13 -0
- package/dist/session-route-memory.d.ts.map +1 -0
- package/dist/session-route-memory.js +114 -0
- package/dist/session-route-memory.js.map +1 -0
- package/index.ts +1 -0
- package/openclaw.plugin.json +90 -0
- package/package.json +50 -0
- package/src/agent-prompt-templates.ts +91 -0
- package/src/config.test.ts +188 -0
- package/src/config.ts +410 -0
- package/src/credentials-loader.test.ts +78 -0
- package/src/credentials-loader.ts +121 -0
- package/src/gateway-rpc-client.test.ts +190 -0
- package/src/gateway-rpc-client.ts +373 -0
- package/src/index.integration.test.ts +437 -0
- package/src/index.test.ts +454 -0
- package/src/index.ts +758 -0
- package/src/logger.ts +27 -0
- package/src/notification-route-resolver.test.ts +136 -0
- package/src/notification-route-resolver.ts +430 -0
- package/src/notifier.test.ts +374 -0
- package/src/notifier.ts +558 -0
- package/src/openclaw-plugin-sdk.d.ts +121 -0
- package/src/pm-polling-client.test.ts +390 -0
- package/src/pm-polling-client.ts +257 -0
- package/src/polling-client.test.ts +279 -0
- package/src/polling-client.ts +283 -0
- package/src/session-route-memory.ts +106 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OpenClawGatewayRpcClient = void 0;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const ws_1 = __importDefault(require("ws"));
|
|
9
|
+
const GATEWAY_PROTOCOL_VERSION = 3;
|
|
10
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 8000;
|
|
11
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 10000;
|
|
12
|
+
const DEFAULT_SESSION_KEY = 'main';
|
|
13
|
+
const DEFAULT_AGENT_ID = 'main';
|
|
14
|
+
class OpenClawGatewayRpcClient {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
async sendAgentMessage(message) {
|
|
19
|
+
return this.withConnection(async (conn) => {
|
|
20
|
+
const sessionKey = this.options.sessionKey || (await this.resolveSessionKey(conn));
|
|
21
|
+
const agentId = this.options.agentId?.trim() || this.resolveAgentIdFromSessionKey(sessionKey);
|
|
22
|
+
const idempotencyKey = (0, node_crypto_1.randomUUID)();
|
|
23
|
+
const response = await conn.request('agent', {
|
|
24
|
+
sessionKey,
|
|
25
|
+
agentId,
|
|
26
|
+
message,
|
|
27
|
+
deliver: true,
|
|
28
|
+
...(this.options.replyChannel ? { replyChannel: this.options.replyChannel } : {}),
|
|
29
|
+
...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),
|
|
30
|
+
...(this.options.replyAccountId
|
|
31
|
+
? { replyAccountId: this.options.replyAccountId }
|
|
32
|
+
: {}),
|
|
33
|
+
idempotencyKey,
|
|
34
|
+
});
|
|
35
|
+
const runId = String(response?.runId || idempotencyKey);
|
|
36
|
+
return { sessionKey, runId };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
resolveAgentIdFromSessionKey(sessionKey) {
|
|
40
|
+
const trimmed = sessionKey?.trim() || '';
|
|
41
|
+
const parts = trimmed.split(':').filter((part) => part.length > 0);
|
|
42
|
+
if (parts[0]?.toLowerCase() === 'agent' && typeof parts[1] === 'string' && parts[1].trim()) {
|
|
43
|
+
return parts[1].trim().toLowerCase();
|
|
44
|
+
}
|
|
45
|
+
return DEFAULT_AGENT_ID;
|
|
46
|
+
}
|
|
47
|
+
async resolveSessionKey(conn) {
|
|
48
|
+
try {
|
|
49
|
+
const response = await conn.request('sessions.list', {
|
|
50
|
+
limit: 20,
|
|
51
|
+
includeGlobal: true,
|
|
52
|
+
includeUnknown: true,
|
|
53
|
+
includeLastMessage: false,
|
|
54
|
+
});
|
|
55
|
+
const sessions = Array.isArray(response?.sessions)
|
|
56
|
+
? response.sessions
|
|
57
|
+
: [];
|
|
58
|
+
const byMainKey = sessions.find((entry) => entry && entry.key === DEFAULT_SESSION_KEY);
|
|
59
|
+
if (byMainKey && typeof byMainKey.key === 'string') {
|
|
60
|
+
return DEFAULT_SESSION_KEY;
|
|
61
|
+
}
|
|
62
|
+
const byMainKind = sessions.find((entry) => entry && typeof entry.key === 'string' && String(entry.kind || '').toLowerCase() === 'main');
|
|
63
|
+
if (byMainKind && typeof byMainKind.key === 'string') {
|
|
64
|
+
return byMainKind.key;
|
|
65
|
+
}
|
|
66
|
+
const byActive = sessions.find((entry) => entry && typeof entry.key === 'string' && entry.active === true);
|
|
67
|
+
if (byActive && typeof byActive.key === 'string') {
|
|
68
|
+
return byActive.key;
|
|
69
|
+
}
|
|
70
|
+
const first = sessions.find((entry) => entry && typeof entry.key === 'string');
|
|
71
|
+
if (first && typeof first.key === 'string') {
|
|
72
|
+
return first.key;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
this.options.logger.warn(`sessions.list failed, fallback to "${DEFAULT_SESSION_KEY}": ${this.formatError(error)}`);
|
|
77
|
+
}
|
|
78
|
+
return DEFAULT_SESSION_KEY;
|
|
79
|
+
}
|
|
80
|
+
async withConnection(fn) {
|
|
81
|
+
const conn = new GatewayConnection({
|
|
82
|
+
gatewayUrl: this.options.gatewayUrl,
|
|
83
|
+
gatewayToken: this.options.gatewayToken,
|
|
84
|
+
logger: this.options.logger,
|
|
85
|
+
connectTimeoutMs: this.options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS,
|
|
86
|
+
requestTimeoutMs: this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
await conn.connect();
|
|
90
|
+
return await fn(conn);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await conn.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
formatError(error) {
|
|
97
|
+
if (error instanceof Error) {
|
|
98
|
+
return `${error.name}: ${error.message}`;
|
|
99
|
+
}
|
|
100
|
+
return String(error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.OpenClawGatewayRpcClient = OpenClawGatewayRpcClient;
|
|
104
|
+
class GatewayConnection {
|
|
105
|
+
constructor(options) {
|
|
106
|
+
this.ws = null;
|
|
107
|
+
this.connectNonce = null;
|
|
108
|
+
this.connected = false;
|
|
109
|
+
this.pending = new Map();
|
|
110
|
+
this.options = options;
|
|
111
|
+
}
|
|
112
|
+
async connect() {
|
|
113
|
+
if (this.connected) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.ws = new ws_1.default(this.options.gatewayUrl, {
|
|
117
|
+
maxPayload: 25 * 1024 * 1024,
|
|
118
|
+
});
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
let settled = false;
|
|
121
|
+
let connectRequested = false;
|
|
122
|
+
const connectTimer = setTimeout(() => {
|
|
123
|
+
onConnectError(new Error(`Gateway connect timeout after ${this.options.connectTimeoutMs}ms`));
|
|
124
|
+
}, this.options.connectTimeoutMs);
|
|
125
|
+
const cleanup = () => {
|
|
126
|
+
clearTimeout(connectTimer);
|
|
127
|
+
};
|
|
128
|
+
const settle = (fn) => {
|
|
129
|
+
if (settled) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
settled = true;
|
|
133
|
+
cleanup();
|
|
134
|
+
fn();
|
|
135
|
+
};
|
|
136
|
+
const onConnectError = (error) => {
|
|
137
|
+
settle(() => {
|
|
138
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
139
|
+
void this.close();
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
this.ws?.on('error', onConnectError);
|
|
143
|
+
this.ws?.on('close', () => {
|
|
144
|
+
if (!this.connected) {
|
|
145
|
+
onConnectError(new Error('Gateway closed before connect'));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.rejectAllPending(new Error('Gateway connection closed'));
|
|
149
|
+
});
|
|
150
|
+
this.ws?.on('message', (data) => {
|
|
151
|
+
const raw = data.toString();
|
|
152
|
+
let frame = null;
|
|
153
|
+
try {
|
|
154
|
+
frame = JSON.parse(raw);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (!frame || typeof frame !== 'object') {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (frame.type === 'event') {
|
|
163
|
+
try {
|
|
164
|
+
this.handleEventFrame(frame);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
onConnectError(error);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (frame.event === 'connect.challenge' && !connectRequested) {
|
|
171
|
+
connectRequested = true;
|
|
172
|
+
void this.request('connect', this.buildConnectParams())
|
|
173
|
+
.then(() => {
|
|
174
|
+
this.connected = true;
|
|
175
|
+
settle(() => resolve());
|
|
176
|
+
})
|
|
177
|
+
.catch(onConnectError);
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (frame.type === 'res') {
|
|
182
|
+
try {
|
|
183
|
+
this.handleResponseFrame(frame);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
onConnectError(error);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async close() {
|
|
193
|
+
this.rejectAllPending(new Error('Gateway request cancelled: connection closed'));
|
|
194
|
+
if (!this.ws) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const ws = this.ws;
|
|
198
|
+
this.ws = null;
|
|
199
|
+
this.connected = false;
|
|
200
|
+
await new Promise((resolve) => {
|
|
201
|
+
ws.once('close', () => resolve());
|
|
202
|
+
ws.close(1000);
|
|
203
|
+
setTimeout(() => resolve(), 1000);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async request(method, params) {
|
|
207
|
+
if (!this.ws || this.ws.readyState !== ws_1.default.OPEN) {
|
|
208
|
+
throw new Error(`Gateway request failed (${method}): websocket is not open`);
|
|
209
|
+
}
|
|
210
|
+
const id = (0, node_crypto_1.randomUUID)();
|
|
211
|
+
const frame = {
|
|
212
|
+
type: 'req',
|
|
213
|
+
id,
|
|
214
|
+
method,
|
|
215
|
+
params,
|
|
216
|
+
};
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
const timer = setTimeout(() => {
|
|
219
|
+
this.pending.delete(id);
|
|
220
|
+
reject(new Error(`Gateway request timeout (${method}) after ${this.options.requestTimeoutMs}ms`));
|
|
221
|
+
}, this.options.requestTimeoutMs);
|
|
222
|
+
this.pending.set(id, { timer, resolve, reject });
|
|
223
|
+
this.ws?.send(JSON.stringify(frame), (error) => {
|
|
224
|
+
if (!error) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
clearTimeout(timer);
|
|
228
|
+
this.pending.delete(id);
|
|
229
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
handleEventFrame(frame) {
|
|
234
|
+
if (frame.event !== 'connect.challenge') {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const nonce = frame.payload?.nonce;
|
|
238
|
+
if (typeof nonce !== 'string' || nonce.trim().length === 0) {
|
|
239
|
+
throw new Error('Gateway connect.challenge missing nonce');
|
|
240
|
+
}
|
|
241
|
+
this.connectNonce = nonce.trim();
|
|
242
|
+
}
|
|
243
|
+
handleResponseFrame(frame) {
|
|
244
|
+
const pending = this.pending.get(frame.id);
|
|
245
|
+
if (!pending) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
clearTimeout(pending.timer);
|
|
249
|
+
this.pending.delete(frame.id);
|
|
250
|
+
if (frame.ok) {
|
|
251
|
+
pending.resolve(frame.payload);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const message = frame.error?.message || 'unknown gateway error';
|
|
255
|
+
pending.reject(new Error(message));
|
|
256
|
+
}
|
|
257
|
+
buildConnectParams() {
|
|
258
|
+
if (!this.connectNonce) {
|
|
259
|
+
throw new Error('Gateway connect failed: missing challenge nonce');
|
|
260
|
+
}
|
|
261
|
+
const authToken = typeof this.options.gatewayToken === 'string' ? this.options.gatewayToken.trim() : '';
|
|
262
|
+
const params = {
|
|
263
|
+
minProtocol: GATEWAY_PROTOCOL_VERSION,
|
|
264
|
+
maxProtocol: GATEWAY_PROTOCOL_VERSION,
|
|
265
|
+
client: {
|
|
266
|
+
id: 'eigenflux-gateway-client',
|
|
267
|
+
displayName: 'eigenflux',
|
|
268
|
+
version: '1.0.0',
|
|
269
|
+
platform: process.platform,
|
|
270
|
+
mode: 'backend',
|
|
271
|
+
},
|
|
272
|
+
role: 'operator',
|
|
273
|
+
scopes: ['operator.admin'],
|
|
274
|
+
};
|
|
275
|
+
if (authToken) {
|
|
276
|
+
params.auth = { token: authToken };
|
|
277
|
+
}
|
|
278
|
+
return params;
|
|
279
|
+
}
|
|
280
|
+
rejectAllPending(error) {
|
|
281
|
+
for (const [id, pending] of this.pending.entries()) {
|
|
282
|
+
clearTimeout(pending.timer);
|
|
283
|
+
this.pending.delete(id);
|
|
284
|
+
pending.reject(error);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=gateway-rpc-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-rpc-client.js","sourceRoot":"","sources":["../src/gateway-rpc-client.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAyC;AACzC,4CAA2B;AAG3B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AACzC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AA6ChC,MAAa,wBAAwB;IAGnC,YAAY,OAAw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,EAAE,SAAS,EAAE,CAAC;QACrC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,gBAAgB,CAAC,KAAY;QACnC,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
2
|
+
declare function register(api: OpenClawPluginApi): void;
|
|
3
|
+
declare const plugin: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
configSchema: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly additionalProperties: false;
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly gatewayUrl: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "OpenClaw Gateway WebSocket URL used for Gateway RPC fallback";
|
|
14
|
+
readonly default: "ws://127.0.0.1:18789";
|
|
15
|
+
};
|
|
16
|
+
readonly gatewayToken: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly description: "Optional gateway token override used for Gateway RPC fallback";
|
|
19
|
+
};
|
|
20
|
+
readonly openclawCliBin: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "OpenClaw CLI binary used by runtime command and spawn fallbacks";
|
|
23
|
+
readonly default: "openclaw";
|
|
24
|
+
};
|
|
25
|
+
readonly servers: {
|
|
26
|
+
readonly type: "array";
|
|
27
|
+
readonly description: "Server list. When empty or when no server named eigenflux is provided, the plugin prepends a default eigenflux server.";
|
|
28
|
+
readonly default: readonly [];
|
|
29
|
+
readonly items: {
|
|
30
|
+
readonly type: "object";
|
|
31
|
+
readonly additionalProperties: false;
|
|
32
|
+
readonly properties: {
|
|
33
|
+
readonly enabled: {
|
|
34
|
+
readonly type: "boolean";
|
|
35
|
+
readonly description: "Enable or disable background polling for this server";
|
|
36
|
+
readonly default: true;
|
|
37
|
+
};
|
|
38
|
+
readonly name: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly description: "Server name used for routing, workdir defaults, and diagnostics";
|
|
41
|
+
readonly default: "eigenflux";
|
|
42
|
+
};
|
|
43
|
+
readonly endpoint: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly description: "EigenFlux API base URL for this server";
|
|
46
|
+
readonly default: "https://www.eigenflux.ai";
|
|
47
|
+
};
|
|
48
|
+
readonly workdir: {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
readonly description: "Directory used to store server credentials and remembered session state";
|
|
51
|
+
};
|
|
52
|
+
readonly pollInterval: {
|
|
53
|
+
readonly type: "integer";
|
|
54
|
+
readonly minimum: 1;
|
|
55
|
+
readonly description: "Feed polling interval in seconds for this server";
|
|
56
|
+
readonly default: 300;
|
|
57
|
+
};
|
|
58
|
+
readonly pmPollInterval: {
|
|
59
|
+
readonly type: "integer";
|
|
60
|
+
readonly minimum: 1;
|
|
61
|
+
readonly description: "Private message polling interval in seconds for this server";
|
|
62
|
+
readonly default: 60;
|
|
63
|
+
};
|
|
64
|
+
readonly sessionKey: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly description: "Target session key used by runtime.subagent and heartbeat fallback";
|
|
67
|
+
readonly default: "main";
|
|
68
|
+
};
|
|
69
|
+
readonly agentId: {
|
|
70
|
+
readonly type: "string";
|
|
71
|
+
readonly description: "Agent id used by Gateway agent and CLI fallbacks";
|
|
72
|
+
readonly default: "main";
|
|
73
|
+
};
|
|
74
|
+
readonly replyChannel: {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
readonly description: "Explicit reply channel used by Gateway agent and CLI fallbacks";
|
|
77
|
+
};
|
|
78
|
+
readonly replyTo: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly description: "Explicit reply target used by Gateway agent and CLI fallbacks";
|
|
81
|
+
};
|
|
82
|
+
readonly replyAccountId: {
|
|
83
|
+
readonly type: "string";
|
|
84
|
+
readonly description: "Optional reply account id for multi-account channel delivery";
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
register: typeof register;
|
|
92
|
+
};
|
|
93
|
+
export default plugin;
|
|
94
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyF7D,iBAAS,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CA0B9C;AAED,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|