@openclaw/tlon 2026.2.21 → 2026.5.1-beta.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/api.ts +16 -0
- package/channel-plugin-api.ts +1 -0
- package/doctor-contract-api.ts +1 -0
- package/index.ts +177 -11
- package/openclaw.plugin.json +189 -1
- package/package.json +57 -4
- package/runtime-api.ts +17 -0
- package/setup-api.ts +2 -0
- package/setup-entry.ts +9 -0
- package/src/account-fields.ts +9 -3
- package/src/channel.runtime.ts +248 -0
- package/src/channel.ts +152 -364
- package/src/config-schema.ts +22 -16
- package/src/core.test.ts +278 -0
- package/src/doctor-contract.ts +9 -0
- package/src/doctor.test.ts +40 -0
- package/src/doctor.ts +10 -0
- package/src/logger-runtime.ts +1 -0
- package/src/monitor/approval-runtime.ts +363 -0
- package/src/monitor/approval.test.ts +33 -0
- package/src/monitor/approval.ts +286 -0
- package/src/monitor/authorization.ts +30 -0
- package/src/monitor/cites.ts +54 -0
- package/src/monitor/discovery.ts +44 -54
- package/src/monitor/history.ts +155 -21
- package/src/monitor/index.ts +1290 -369
- package/src/monitor/media.test.ts +91 -0
- package/src/monitor/media.ts +172 -0
- package/src/monitor/processed-messages.test.ts +36 -1
- package/src/monitor/processed-messages.ts +62 -19
- package/src/monitor/settings-helpers.test.ts +113 -0
- package/src/monitor/settings-helpers.ts +158 -0
- package/src/monitor/utils.ts +311 -45
- package/src/runtime.ts +8 -13
- package/src/security.test.ts +622 -0
- package/src/session-route.ts +40 -0
- package/src/settings.ts +391 -0
- package/src/setup-core.ts +228 -0
- package/src/setup-surface.ts +103 -0
- package/src/targets.ts +29 -16
- package/src/tlon-api.test.ts +589 -0
- package/src/tlon-api.ts +402 -0
- package/src/types.ts +106 -45
- package/src/urbit/auth.ssrf.test.ts +3 -2
- package/src/urbit/auth.ts +2 -2
- package/src/urbit/base-url.test.ts +18 -11
- package/src/urbit/base-url.ts +9 -5
- package/src/urbit/channel-ops.ts +40 -59
- package/src/urbit/context.ts +13 -10
- package/src/urbit/errors.ts +2 -2
- package/src/urbit/fetch.ts +6 -3
- package/src/urbit/foreigns.ts +49 -0
- package/src/urbit/send.ts +59 -2
- package/src/urbit/sse-client.test.ts +184 -25
- package/src/urbit/sse-client.ts +123 -69
- package/src/urbit/story.ts +332 -0
- package/src/urbit/upload.test.ts +154 -0
- package/src/urbit/upload.ts +60 -0
- package/test-api.ts +1 -0
- package/tsconfig.json +16 -0
- package/src/config-schema.test.ts +0 -31
- package/src/onboarding.ts +0 -229
- package/src/urbit/channel-client.ts +0 -157
package/src/channel.ts
CHANGED
|
@@ -1,384 +1,172 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "openclaw/plugin-sdk";
|
|
1
|
+
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
2
|
+
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
3
|
+
import { createHybridChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
4
|
+
import { createChatChannelPlugin, type ChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
5
|
+
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
6
|
+
import { createRuntimeOutboundDelegates } from "openclaw/plugin-sdk/outbound-runtime";
|
|
8
7
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "openclaw/plugin-sdk";
|
|
13
|
-
import { buildTlonAccountFields } from "./account-fields.js";
|
|
8
|
+
createComputedAccountStatusAdapter,
|
|
9
|
+
createDefaultChannelRuntimeState,
|
|
10
|
+
} from "openclaw/plugin-sdk/status-helpers";
|
|
14
11
|
import { tlonChannelConfigSchema } from "./config-schema.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
import { tlonDoctor } from "./doctor.js";
|
|
13
|
+
import { resolveTlonOutboundSessionRoute } from "./session-route.js";
|
|
14
|
+
import { createTlonSetupWizardBase, tlonSetupAdapter } from "./setup-core.js";
|
|
15
|
+
import {
|
|
16
|
+
formatTargetHint,
|
|
17
|
+
normalizeShip,
|
|
18
|
+
parseTlonTarget,
|
|
19
|
+
resolveTlonOutboundTarget,
|
|
20
|
+
} from "./targets.js";
|
|
21
|
+
import { listTlonAccountIds, resolveTlonAccount } from "./types.js";
|
|
23
22
|
|
|
24
23
|
const TLON_CHANNEL_ID = "tlon" as const;
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
ship?: string;
|
|
28
|
-
url?: string;
|
|
29
|
-
code?: string;
|
|
30
|
-
allowPrivateNetwork?: boolean;
|
|
31
|
-
groupChannels?: string[];
|
|
32
|
-
dmAllowlist?: string[];
|
|
33
|
-
autoDiscoverChannels?: boolean;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function applyTlonSetupConfig(params: {
|
|
37
|
-
cfg: OpenClawConfig;
|
|
38
|
-
accountId: string;
|
|
39
|
-
input: TlonSetupInput;
|
|
40
|
-
}): OpenClawConfig {
|
|
41
|
-
const { cfg, accountId, input } = params;
|
|
42
|
-
const useDefault = accountId === DEFAULT_ACCOUNT_ID;
|
|
43
|
-
const namedConfig = applyAccountNameToChannelSection({
|
|
44
|
-
cfg,
|
|
45
|
-
channelKey: "tlon",
|
|
46
|
-
accountId,
|
|
47
|
-
name: input.name,
|
|
48
|
-
});
|
|
49
|
-
const base = namedConfig.channels?.tlon ?? {};
|
|
50
|
-
|
|
51
|
-
const payload = buildTlonAccountFields(input);
|
|
52
|
-
|
|
53
|
-
if (useDefault) {
|
|
54
|
-
return {
|
|
55
|
-
...namedConfig,
|
|
56
|
-
channels: {
|
|
57
|
-
...namedConfig.channels,
|
|
58
|
-
tlon: {
|
|
59
|
-
...base,
|
|
60
|
-
enabled: true,
|
|
61
|
-
...payload,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
...namedConfig,
|
|
69
|
-
channels: {
|
|
70
|
-
...namedConfig.channels,
|
|
71
|
-
tlon: {
|
|
72
|
-
...base,
|
|
73
|
-
enabled: base.enabled ?? true,
|
|
74
|
-
accounts: {
|
|
75
|
-
...(base as { accounts?: Record<string, unknown> }).accounts,
|
|
76
|
-
[accountId]: {
|
|
77
|
-
...(base as { accounts?: Record<string, Record<string, unknown>> }).accounts?.[
|
|
78
|
-
accountId
|
|
79
|
-
],
|
|
80
|
-
enabled: true,
|
|
81
|
-
...payload,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const tlonOutbound: ChannelOutboundAdapter = {
|
|
90
|
-
deliveryMode: "direct",
|
|
91
|
-
textChunkLimit: 10000,
|
|
92
|
-
resolveTarget: ({ to }) => {
|
|
93
|
-
const parsed = parseTlonTarget(to ?? "");
|
|
94
|
-
if (!parsed) {
|
|
95
|
-
return {
|
|
96
|
-
ok: false,
|
|
97
|
-
error: new Error(`Invalid Tlon target. Use ${formatTargetHint()}`),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
if (parsed.kind === "direct") {
|
|
101
|
-
return { ok: true, to: parsed.ship };
|
|
102
|
-
}
|
|
103
|
-
return { ok: true, to: parsed.nest };
|
|
104
|
-
},
|
|
105
|
-
sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => {
|
|
106
|
-
const account = resolveTlonAccount(cfg, accountId ?? undefined);
|
|
107
|
-
if (!account.configured || !account.ship || !account.url || !account.code) {
|
|
108
|
-
throw new Error("Tlon account not configured");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const parsed = parseTlonTarget(to);
|
|
112
|
-
if (!parsed) {
|
|
113
|
-
throw new Error(`Invalid Tlon target. Use ${formatTargetHint()}`);
|
|
114
|
-
}
|
|
25
|
+
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime.js"));
|
|
115
26
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const fromShip = normalizeShip(account.ship);
|
|
125
|
-
if (parsed.kind === "direct") {
|
|
126
|
-
return await sendDm({
|
|
127
|
-
api,
|
|
128
|
-
fromShip,
|
|
129
|
-
toShip: parsed.ship,
|
|
130
|
-
text,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
const replyId = (replyToId ?? threadId) ? String(replyToId ?? threadId) : undefined;
|
|
134
|
-
return await sendGroupMessage({
|
|
135
|
-
api,
|
|
136
|
-
fromShip,
|
|
137
|
-
hostShip: parsed.hostShip,
|
|
138
|
-
channelName: parsed.channelName,
|
|
139
|
-
text,
|
|
140
|
-
replyToId: replyId,
|
|
141
|
-
});
|
|
142
|
-
} finally {
|
|
143
|
-
await api.close();
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
sendMedia: async ({ cfg, to, text, mediaUrl, accountId, replyToId, threadId }) => {
|
|
147
|
-
const mergedText = buildMediaText(text, mediaUrl);
|
|
148
|
-
return await tlonOutbound.sendText!({
|
|
27
|
+
const tlonSetupWizardProxy = createTlonSetupWizardBase({
|
|
28
|
+
resolveConfigured: async ({ cfg, accountId }) =>
|
|
29
|
+
await (
|
|
30
|
+
await loadTlonChannelRuntime()
|
|
31
|
+
).tlonSetupWizard.status.resolveConfigured({
|
|
149
32
|
cfg,
|
|
150
|
-
to,
|
|
151
|
-
text: mergedText,
|
|
152
33
|
accountId,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
34
|
+
}),
|
|
35
|
+
resolveStatusLines: async ({ cfg, accountId, configured }) =>
|
|
36
|
+
(await (
|
|
37
|
+
await loadTlonChannelRuntime()
|
|
38
|
+
).tlonSetupWizard.status.resolveStatusLines?.({
|
|
39
|
+
cfg,
|
|
40
|
+
accountId,
|
|
41
|
+
configured,
|
|
42
|
+
})) ?? [],
|
|
43
|
+
finalize: async (params) =>
|
|
44
|
+
await (
|
|
45
|
+
await loadTlonChannelRuntime()
|
|
46
|
+
).tlonSetupWizard.finalize!(params),
|
|
47
|
+
}) satisfies NonNullable<ChannelPlugin["setupWizard"]>;
|
|
48
|
+
|
|
49
|
+
const tlonConfigAdapter = createHybridChannelConfigAdapter({
|
|
50
|
+
sectionKey: TLON_CHANNEL_ID,
|
|
51
|
+
listAccountIds: listTlonAccountIds,
|
|
52
|
+
resolveAccount: resolveTlonAccount,
|
|
53
|
+
defaultAccountId: () => DEFAULT_ACCOUNT_ID,
|
|
54
|
+
clearBaseFields: ["ship", "code", "url", "name"],
|
|
55
|
+
preserveSectionOnDefaultDelete: true,
|
|
56
|
+
resolveAllowFrom: (account) => account.dmAllowlist,
|
|
57
|
+
formatAllowFrom: (allowFrom) =>
|
|
58
|
+
allowFrom.map((entry) => normalizeShip(String(entry))).filter(Boolean),
|
|
59
|
+
});
|
|
158
60
|
|
|
159
|
-
export const tlonPlugin
|
|
160
|
-
|
|
161
|
-
meta: {
|
|
61
|
+
export const tlonPlugin = createChatChannelPlugin({
|
|
62
|
+
base: {
|
|
162
63
|
id: TLON_CHANNEL_ID,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
chatTypes: ["direct", "group", "thread"],
|
|
173
|
-
media: false,
|
|
174
|
-
reply: true,
|
|
175
|
-
threads: true,
|
|
176
|
-
},
|
|
177
|
-
onboarding: tlonOnboardingAdapter,
|
|
178
|
-
reload: { configPrefixes: ["channels.tlon"] },
|
|
179
|
-
configSchema: tlonChannelConfigSchema,
|
|
180
|
-
config: {
|
|
181
|
-
listAccountIds: (cfg) => listTlonAccountIds(cfg),
|
|
182
|
-
resolveAccount: (cfg, accountId) => resolveTlonAccount(cfg, accountId ?? undefined),
|
|
183
|
-
defaultAccountId: () => "default",
|
|
184
|
-
setAccountEnabled: ({ cfg, accountId, enabled }) => {
|
|
185
|
-
const useDefault = !accountId || accountId === "default";
|
|
186
|
-
if (useDefault) {
|
|
187
|
-
return {
|
|
188
|
-
...cfg,
|
|
189
|
-
channels: {
|
|
190
|
-
...cfg.channels,
|
|
191
|
-
tlon: {
|
|
192
|
-
...(cfg.channels?.tlon as Record<string, unknown>),
|
|
193
|
-
enabled,
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
} as OpenClawConfig;
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
...cfg,
|
|
200
|
-
channels: {
|
|
201
|
-
...cfg.channels,
|
|
202
|
-
tlon: {
|
|
203
|
-
...(cfg.channels?.tlon as Record<string, unknown>),
|
|
204
|
-
accounts: {
|
|
205
|
-
...cfg.channels?.tlon?.accounts,
|
|
206
|
-
[accountId]: {
|
|
207
|
-
...cfg.channels?.tlon?.accounts?.[accountId],
|
|
208
|
-
enabled,
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
} as OpenClawConfig;
|
|
64
|
+
meta: {
|
|
65
|
+
id: TLON_CHANNEL_ID,
|
|
66
|
+
label: "Tlon",
|
|
67
|
+
selectionLabel: "Tlon (Urbit)",
|
|
68
|
+
docsPath: "/channels/tlon",
|
|
69
|
+
docsLabel: "tlon",
|
|
70
|
+
blurb: "Decentralized messaging on Urbit",
|
|
71
|
+
aliases: ["urbit"],
|
|
72
|
+
order: 90,
|
|
214
73
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
string,
|
|
221
|
-
unknown
|
|
222
|
-
>;
|
|
223
|
-
return {
|
|
224
|
-
...cfg,
|
|
225
|
-
channels: {
|
|
226
|
-
...cfg.channels,
|
|
227
|
-
tlon: rest,
|
|
228
|
-
},
|
|
229
|
-
} as OpenClawConfig;
|
|
230
|
-
}
|
|
231
|
-
// oxlint-disable-next-line no-unused-vars
|
|
232
|
-
const { [accountId]: removed, ...remainingAccounts } = (cfg.channels?.tlon?.accounts ??
|
|
233
|
-
{}) as Record<string, unknown>;
|
|
234
|
-
return {
|
|
235
|
-
...cfg,
|
|
236
|
-
channels: {
|
|
237
|
-
...cfg.channels,
|
|
238
|
-
tlon: {
|
|
239
|
-
...(cfg.channels?.tlon as Record<string, unknown>),
|
|
240
|
-
accounts: remainingAccounts,
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
} as OpenClawConfig;
|
|
244
|
-
},
|
|
245
|
-
isConfigured: (account) => account.configured,
|
|
246
|
-
describeAccount: (account) => ({
|
|
247
|
-
accountId: account.accountId,
|
|
248
|
-
name: account.name,
|
|
249
|
-
enabled: account.enabled,
|
|
250
|
-
configured: account.configured,
|
|
251
|
-
ship: account.ship,
|
|
252
|
-
url: account.url,
|
|
253
|
-
}),
|
|
254
|
-
},
|
|
255
|
-
setup: {
|
|
256
|
-
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
|
257
|
-
applyAccountName: ({ cfg, accountId, name }) =>
|
|
258
|
-
applyAccountNameToChannelSection({
|
|
259
|
-
cfg: cfg,
|
|
260
|
-
channelKey: "tlon",
|
|
261
|
-
accountId,
|
|
262
|
-
name,
|
|
263
|
-
}),
|
|
264
|
-
validateInput: ({ cfg, accountId, input }) => {
|
|
265
|
-
const setupInput = input as TlonSetupInput;
|
|
266
|
-
const resolved = resolveTlonAccount(cfg, accountId ?? undefined);
|
|
267
|
-
const ship = setupInput.ship?.trim() || resolved.ship;
|
|
268
|
-
const url = setupInput.url?.trim() || resolved.url;
|
|
269
|
-
const code = setupInput.code?.trim() || resolved.code;
|
|
270
|
-
if (!ship) {
|
|
271
|
-
return "Tlon requires --ship.";
|
|
272
|
-
}
|
|
273
|
-
if (!url) {
|
|
274
|
-
return "Tlon requires --url.";
|
|
275
|
-
}
|
|
276
|
-
if (!code) {
|
|
277
|
-
return "Tlon requires --code.";
|
|
278
|
-
}
|
|
279
|
-
return null;
|
|
74
|
+
capabilities: {
|
|
75
|
+
chatTypes: ["direct", "group", "thread"],
|
|
76
|
+
media: true,
|
|
77
|
+
reply: true,
|
|
78
|
+
threads: true,
|
|
280
79
|
},
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return parsed.nest;
|
|
298
|
-
},
|
|
299
|
-
targetResolver: {
|
|
300
|
-
looksLikeId: (target) => Boolean(parseTlonTarget(target)),
|
|
301
|
-
hint: formatTargetHint(),
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
outbound: tlonOutbound,
|
|
305
|
-
status: {
|
|
306
|
-
defaultRuntime: {
|
|
307
|
-
accountId: "default",
|
|
308
|
-
running: false,
|
|
309
|
-
lastStartAt: null,
|
|
310
|
-
lastStopAt: null,
|
|
311
|
-
lastError: null,
|
|
80
|
+
setup: tlonSetupAdapter,
|
|
81
|
+
setupWizard: tlonSetupWizardProxy,
|
|
82
|
+
reload: { configPrefixes: ["channels.tlon"] },
|
|
83
|
+
configSchema: tlonChannelConfigSchema,
|
|
84
|
+
config: {
|
|
85
|
+
...tlonConfigAdapter,
|
|
86
|
+
isConfigured: (account) => account.configured,
|
|
87
|
+
describeAccount: (account) =>
|
|
88
|
+
describeAccountSnapshot({
|
|
89
|
+
account,
|
|
90
|
+
configured: account.configured,
|
|
91
|
+
extra: {
|
|
92
|
+
ship: account.ship,
|
|
93
|
+
url: account.url,
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
312
96
|
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
accountId: account.accountId,
|
|
320
|
-
kind: "config",
|
|
321
|
-
message: "Account not configured (missing ship, code, or url)",
|
|
322
|
-
},
|
|
323
|
-
];
|
|
97
|
+
doctor: tlonDoctor,
|
|
98
|
+
messaging: {
|
|
99
|
+
normalizeTarget: (target) => {
|
|
100
|
+
const parsed = parseTlonTarget(target);
|
|
101
|
+
if (!parsed) {
|
|
102
|
+
return target.trim();
|
|
324
103
|
}
|
|
325
|
-
|
|
326
|
-
|
|
104
|
+
if (parsed.kind === "dm") {
|
|
105
|
+
return parsed.ship;
|
|
106
|
+
}
|
|
107
|
+
return parsed.nest;
|
|
108
|
+
},
|
|
109
|
+
targetResolver: {
|
|
110
|
+
looksLikeId: (target) => Boolean(parseTlonTarget(target)),
|
|
111
|
+
hint: formatTargetHint(),
|
|
112
|
+
},
|
|
113
|
+
resolveOutboundSessionRoute: (params) => resolveTlonOutboundSessionRoute(params),
|
|
327
114
|
},
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
115
|
+
status: createComputedAccountStatusAdapter<ReturnType<typeof resolveTlonAccount>>({
|
|
116
|
+
defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID),
|
|
117
|
+
collectStatusIssues: (accounts) => {
|
|
118
|
+
return accounts.flatMap((account) => {
|
|
119
|
+
if (!account.configured) {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
channel: TLON_CHANNEL_ID,
|
|
123
|
+
accountId: account.accountId,
|
|
124
|
+
kind: "config",
|
|
125
|
+
message: "Account not configured (missing ship, code, or url)",
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
return [];
|
|
343
130
|
});
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
131
|
+
},
|
|
132
|
+
buildChannelSummary: ({ snapshot }) => {
|
|
133
|
+
const s = snapshot as { configured?: boolean; ship?: string; url?: string };
|
|
134
|
+
return {
|
|
135
|
+
configured: s.configured ?? false,
|
|
136
|
+
ship: s.ship ?? null,
|
|
137
|
+
url: s.url ?? null,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
probeAccount: async ({ account }) => {
|
|
141
|
+
if (!account.configured || !account.ship || !account.url || !account.code) {
|
|
142
|
+
return { ok: false, error: "Not configured" };
|
|
349
143
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
buildAccountSnapshot: ({ account, runtime, probe }) => ({
|
|
355
|
-
accountId: account.accountId,
|
|
356
|
-
name: account.name,
|
|
357
|
-
enabled: account.enabled,
|
|
358
|
-
configured: account.configured,
|
|
359
|
-
ship: account.ship,
|
|
360
|
-
url: account.url,
|
|
361
|
-
running: runtime?.running ?? false,
|
|
362
|
-
lastStartAt: runtime?.lastStartAt ?? null,
|
|
363
|
-
lastStopAt: runtime?.lastStopAt ?? null,
|
|
364
|
-
lastError: runtime?.lastError ?? null,
|
|
365
|
-
probe,
|
|
366
|
-
}),
|
|
367
|
-
},
|
|
368
|
-
gateway: {
|
|
369
|
-
startAccount: async (ctx) => {
|
|
370
|
-
const account = ctx.account;
|
|
371
|
-
ctx.setStatus({
|
|
372
|
-
accountId: account.accountId,
|
|
373
|
-
ship: account.ship,
|
|
374
|
-
url: account.url,
|
|
375
|
-
} as ChannelAccountSnapshot);
|
|
376
|
-
ctx.log?.info(`[${account.accountId}] starting Tlon provider for ${account.ship ?? "tlon"}`);
|
|
377
|
-
return monitorTlonProvider({
|
|
378
|
-
runtime: ctx.runtime,
|
|
379
|
-
abortSignal: ctx.abortSignal,
|
|
144
|
+
return await (await loadTlonChannelRuntime()).probeTlonAccount(account as never);
|
|
145
|
+
},
|
|
146
|
+
resolveAccountSnapshot: ({ account }) => ({
|
|
380
147
|
accountId: account.accountId,
|
|
381
|
-
|
|
148
|
+
name: account.name ?? undefined,
|
|
149
|
+
enabled: account.enabled,
|
|
150
|
+
configured: account.configured,
|
|
151
|
+
extra: {
|
|
152
|
+
ship: account.ship,
|
|
153
|
+
url: account.url,
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
}),
|
|
157
|
+
gateway: {
|
|
158
|
+
startAccount: async (ctx) =>
|
|
159
|
+
await (await loadTlonChannelRuntime()).startTlonGatewayAccount(ctx),
|
|
382
160
|
},
|
|
383
161
|
},
|
|
384
|
-
|
|
162
|
+
outbound: {
|
|
163
|
+
deliveryMode: "direct",
|
|
164
|
+
textChunkLimit: 10000,
|
|
165
|
+
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
166
|
+
...createRuntimeOutboundDelegates({
|
|
167
|
+
getRuntime: loadTlonChannelRuntime,
|
|
168
|
+
sendText: { resolve: (runtime) => runtime.tlonRuntimeOutbound.sendText },
|
|
169
|
+
sendMedia: { resolve: (runtime) => runtime.tlonRuntimeOutbound.sendMedia },
|
|
170
|
+
}),
|
|
171
|
+
},
|
|
172
|
+
});
|
package/src/config-schema.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { buildChannelConfigSchema } from "openclaw/plugin-sdk";
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
|
|
2
|
+
import { z } from "openclaw/plugin-sdk/zod";
|
|
3
3
|
|
|
4
4
|
const ShipSchema = z.string().min(1);
|
|
5
5
|
const ChannelNestSchema = z.string().min(1);
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const TlonChannelRuleSchema = z.object({
|
|
8
8
|
mode: z.enum(["restricted", "open"]).optional(),
|
|
9
9
|
allowedShips: z.array(ShipSchema).optional(),
|
|
10
10
|
});
|
|
@@ -13,32 +13,38 @@ export const TlonAuthorizationSchema = z.object({
|
|
|
13
13
|
channelRules: z.record(z.string(), TlonChannelRuleSchema).optional(),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const TlonNetworkSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
dangerouslyAllowPrivateNetwork: z.boolean().optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict()
|
|
21
|
+
.optional();
|
|
22
|
+
|
|
23
|
+
const tlonCommonConfigFields = {
|
|
17
24
|
name: z.string().optional(),
|
|
18
25
|
enabled: z.boolean().optional(),
|
|
19
26
|
ship: ShipSchema.optional(),
|
|
20
27
|
url: z.string().optional(),
|
|
21
28
|
code: z.string().optional(),
|
|
22
|
-
|
|
29
|
+
network: TlonNetworkSchema,
|
|
23
30
|
groupChannels: z.array(ChannelNestSchema).optional(),
|
|
24
31
|
dmAllowlist: z.array(ShipSchema).optional(),
|
|
25
32
|
autoDiscoverChannels: z.boolean().optional(),
|
|
26
33
|
showModelSignature: z.boolean().optional(),
|
|
27
34
|
responsePrefix: z.string().optional(),
|
|
35
|
+
// Auto-accept settings
|
|
36
|
+
autoAcceptDmInvites: z.boolean().optional(), // Auto-accept DMs from ships in dmAllowlist
|
|
37
|
+
autoAcceptGroupInvites: z.boolean().optional(), // Auto-accept all group invites
|
|
38
|
+
// Owner ship for approval system
|
|
39
|
+
ownerShip: ShipSchema.optional(), // Ship that receives approval requests and can approve/deny
|
|
40
|
+
} satisfies z.ZodRawShape;
|
|
41
|
+
|
|
42
|
+
const TlonAccountSchema = z.object({
|
|
43
|
+
...tlonCommonConfigFields,
|
|
28
44
|
});
|
|
29
45
|
|
|
30
46
|
export const TlonConfigSchema = z.object({
|
|
31
|
-
|
|
32
|
-
enabled: z.boolean().optional(),
|
|
33
|
-
ship: ShipSchema.optional(),
|
|
34
|
-
url: z.string().optional(),
|
|
35
|
-
code: z.string().optional(),
|
|
36
|
-
allowPrivateNetwork: z.boolean().optional(),
|
|
37
|
-
groupChannels: z.array(ChannelNestSchema).optional(),
|
|
38
|
-
dmAllowlist: z.array(ShipSchema).optional(),
|
|
39
|
-
autoDiscoverChannels: z.boolean().optional(),
|
|
40
|
-
showModelSignature: z.boolean().optional(),
|
|
41
|
-
responsePrefix: z.string().optional(),
|
|
47
|
+
...tlonCommonConfigFields,
|
|
42
48
|
authorization: TlonAuthorizationSchema.optional(),
|
|
43
49
|
defaultAuthorizedShips: z.array(ShipSchema).optional(),
|
|
44
50
|
accounts: z.record(z.string(), TlonAccountSchema).optional(),
|