@openclaw/tlon 2026.7.2-beta.7 → 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.
- package/dist/api.js +1 -1
- package/dist/{channel-DqQ3r1FI.js → channel-CoKm1n5s.js} +11 -5
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-D9SOTGdH.js → channel.runtime-BShnsKnQ.js} +314 -212
- package/dist/{doctor-contract-DhzowRcD.js → doctor-contract-CZ8OWBXt.js} +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/setup-api.js +2 -2
- package/dist/{setup-core-DUM2q1dE.js → setup-core-QCmS9Gmh.js} +2 -0
- package/dist/{setup-surface-1WtsAw4R.js → setup-surface-UgXzT7Tg.js} +1 -1
- package/openclaw.plugin.json +9 -0
- package/package.json +5 -5
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as ssrfPolicyFromDangerouslyAllowPrivateNetwork, i as isBlockedHostnameOrIp, n as createDedupeCache, o as createLoggerBackedRuntime, r as fetchWithSsrFGuard, t as SsrFBlockedError } from "./runtime-api-BXVe40nS.js";
|
|
2
|
-
import { t as tlonPlugin } from "./channel-
|
|
2
|
+
import { t as tlonPlugin } from "./channel-CoKm1n5s.js";
|
|
3
3
|
import { n as setTlonRuntime } from "./runtime-Ck3lNvST.js";
|
|
4
4
|
export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-
|
|
2
|
-
import {
|
|
1
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-CZ8OWBXt.js";
|
|
2
|
+
import { d as resolveTlonAccount, f as formatTargetHint, g as resolveTlonOutboundTarget, h as parseTlonTarget, n as createTlonSetupWizardBase, o as tlonSetupContract, p as normalizeShip, u as listTlonAccountIds } from "./setup-core-QCmS9Gmh.js";
|
|
3
3
|
import { buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/core";
|
|
4
4
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
5
5
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
@@ -8,7 +8,7 @@ import { createChannelConfigUiHints, createChatChannelPlugin } from "openclaw/pl
|
|
|
8
8
|
import { createChannelMessageAdapterFromOutbound, createRuntimeOutboundDelegates } from "openclaw/plugin-sdk/channel-outbound";
|
|
9
9
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
10
10
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
11
|
-
import { sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
11
|
+
import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
12
12
|
import { ChannelImplicitMentionsSchema, buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
//#region extensions/tlon/src/config-schema.ts
|
|
@@ -23,6 +23,7 @@ const TlonNetworkSchema = z.object({ dangerouslyAllowPrivateNetwork: z.boolean()
|
|
|
23
23
|
const tlonCommonConfigFields = {
|
|
24
24
|
name: z.string().optional(),
|
|
25
25
|
enabled: z.boolean().optional(),
|
|
26
|
+
configWrites: z.boolean().optional(),
|
|
26
27
|
ship: ShipSchema.optional(),
|
|
27
28
|
url: z.string().optional(),
|
|
28
29
|
code: z.string().optional(),
|
|
@@ -91,7 +92,7 @@ function resolveTlonOutboundSessionRoute(params) {
|
|
|
91
92
|
//#endregion
|
|
92
93
|
//#region extensions/tlon/src/channel.ts
|
|
93
94
|
const TLON_CHANNEL_ID = "tlon";
|
|
94
|
-
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
95
|
+
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-BShnsKnQ.js"));
|
|
95
96
|
const tlonSetupWizardProxy = createTlonSetupWizardBase({
|
|
96
97
|
resolveConfigured: async ({ cfg, accountId }) => await (await loadTlonChannelRuntime()).tlonSetupWizard.status.resolveConfigured({
|
|
97
98
|
cfg,
|
|
@@ -121,6 +122,8 @@ const tlonConfigAdapter = createHybridChannelConfigAdapter({
|
|
|
121
122
|
});
|
|
122
123
|
const tlonChannelOutbound = {
|
|
123
124
|
deliveryMode: "direct",
|
|
125
|
+
chunker: chunkTextForOutbound,
|
|
126
|
+
chunkerMode: "markdown",
|
|
124
127
|
textChunkLimit: 1e4,
|
|
125
128
|
sanitizeText: ({ text }) => sanitizeAssistantVisibleText(text),
|
|
126
129
|
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
@@ -164,7 +167,6 @@ const tlonPlugin = createChatChannelPlugin({
|
|
|
164
167
|
reply: true,
|
|
165
168
|
threads: true
|
|
166
169
|
},
|
|
167
|
-
setup: tlonSetupAdapter,
|
|
168
170
|
setupContract: tlonSetupContract,
|
|
169
171
|
setupWizard: tlonSetupWizardProxy,
|
|
170
172
|
reload: { configPrefixes: ["channels.tlon"] },
|
|
@@ -190,6 +192,10 @@ const tlonPlugin = createChatChannelPlugin({
|
|
|
190
192
|
if (parsed.kind === "dm") return parsed.ship;
|
|
191
193
|
return parsed.nest;
|
|
192
194
|
},
|
|
195
|
+
inferTargetChatType: ({ to }) => {
|
|
196
|
+
const target = parseTlonTarget(to);
|
|
197
|
+
return target ? target.kind === "dm" ? "direct" : "group" : void 0;
|
|
198
|
+
},
|
|
193
199
|
targetResolver: {
|
|
194
200
|
looksLikeId: (target) => Boolean(parseTlonTarget(target)),
|
|
195
201
|
hint: formatTargetHint()
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as tlonPlugin } from "./channel-
|
|
1
|
+
import { t as tlonPlugin } from "./channel-CoKm1n5s.js";
|
|
2
2
|
export { tlonPlugin };
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { n as createDedupeCache, o as createLoggerBackedRuntime } from "./runtime-api-BXVe40nS.js";
|
|
2
|
-
import { c as normalizeUrbitHostname, d as resolveTlonAccount, f as formatTargetHint, g as resolveTlonOutboundTarget, h as parseTlonTarget, l as validateUrbitBaseUrl, m as parseChannelNest, p as normalizeShip } from "./setup-core-
|
|
2
|
+
import { c as normalizeUrbitHostname, d as resolveTlonAccount, f as formatTargetHint, g as resolveTlonOutboundTarget, h as parseTlonTarget, l as validateUrbitBaseUrl, m as parseChannelNest, p as normalizeShip } from "./setup-core-QCmS9Gmh.js";
|
|
3
3
|
import { t as getTlonRuntime } from "./runtime-Ck3lNvST.js";
|
|
4
|
-
import { t as tlonSetupWizard } from "./setup-surface-
|
|
4
|
+
import { t as tlonSetupWizard } from "./setup-surface-UgXzT7Tg.js";
|
|
5
5
|
import { fetchWithSsrFGuard, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
6
6
|
import { bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createMessageReceiptFromOutboundResults, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
|
|
7
|
+
import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
|
|
7
8
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
8
|
-
import { asFiniteNumber, normalizeLowercaseStringOrEmpty, normalizeNullableString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
import { asFiniteNumber, asNullableRecord, filterStringEntries, normalizeLowercaseStringOrEmpty, normalizeNullableString, readStringField, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import crypto, { randomBytes, randomUUID } from "node:crypto";
|
|
10
11
|
import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
11
12
|
import { runChannelProbe, sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
12
13
|
import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
13
|
-
import { createChannelInboundEnvelopeBuilder, implicitMentionKindWhen, resolveInboundMentionDecision } from "openclaw/plugin-sdk/channel-inbound";
|
|
14
|
+
import { createChannelInboundEnvelopeBuilder, formatAgentEnvelope, formatInboundMediaUnavailableText, implicitMentionKindWhen, resolveEnvelopeFormatOptions, resolveInboundMentionDecision } from "openclaw/plugin-sdk/channel-inbound";
|
|
15
|
+
import { collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
16
|
+
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
14
17
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
15
18
|
import { da, scot } from "@urbit/aura";
|
|
16
19
|
import { Readable } from "node:stream";
|
|
17
20
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
18
21
|
import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
|
|
19
22
|
import { resolveChannelImplicitMentions, resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
20
|
-
import { collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
21
23
|
import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
22
24
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
23
25
|
import * as path from "node:path";
|
|
@@ -26,6 +28,16 @@ import { MAX_IMAGE_BYTES, readRemoteMediaBuffer, saveRemoteMedia } from "opencla
|
|
|
26
28
|
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
27
29
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
28
30
|
//#region extensions/tlon/src/settings.ts
|
|
31
|
+
/**
|
|
32
|
+
* Settings Store integration for hot-reloading Tlon plugin config.
|
|
33
|
+
*
|
|
34
|
+
* Settings are stored in Urbit's %settings agent under:
|
|
35
|
+
* desk: "moltbot"
|
|
36
|
+
* bucket: "tlon"
|
|
37
|
+
*
|
|
38
|
+
* This allows config changes via poke from any Landscape client
|
|
39
|
+
* without requiring a gateway restart.
|
|
40
|
+
*/
|
|
29
41
|
const SETTINGS_DESK = "moltbot";
|
|
30
42
|
const SETTINGS_BUCKET = "tlon";
|
|
31
43
|
/**
|
|
@@ -52,15 +64,15 @@ function parseSettingsResponse(raw) {
|
|
|
52
64
|
if (!bucket || typeof bucket !== "object") return {};
|
|
53
65
|
const settings = bucket;
|
|
54
66
|
return {
|
|
55
|
-
groupChannels: Array.isArray(settings.groupChannels) ? settings.groupChannels
|
|
56
|
-
dmAllowlist: Array.isArray(settings.dmAllowlist) ? settings.dmAllowlist
|
|
57
|
-
|
|
67
|
+
groupChannels: Array.isArray(settings.groupChannels) ? filterStringEntries(settings.groupChannels) : void 0,
|
|
68
|
+
dmAllowlist: Array.isArray(settings.dmAllowlist) ? filterStringEntries(settings.dmAllowlist) : void 0,
|
|
69
|
+
autoDiscoverChannels: typeof settings.autoDiscoverChannels === "boolean" ? settings.autoDiscoverChannels : void 0,
|
|
58
70
|
showModelSig: typeof settings.showModelSig === "boolean" ? settings.showModelSig : void 0,
|
|
59
71
|
autoAcceptDmInvites: typeof settings.autoAcceptDmInvites === "boolean" ? settings.autoAcceptDmInvites : void 0,
|
|
60
72
|
autoAcceptGroupInvites: typeof settings.autoAcceptGroupInvites === "boolean" ? settings.autoAcceptGroupInvites : void 0,
|
|
61
|
-
groupInviteAllowlist: Array.isArray(settings.groupInviteAllowlist) ? settings.groupInviteAllowlist
|
|
73
|
+
groupInviteAllowlist: Array.isArray(settings.groupInviteAllowlist) ? filterStringEntries(settings.groupInviteAllowlist) : void 0,
|
|
62
74
|
channelRules: parseChannelRules(settings.channelRules),
|
|
63
|
-
defaultAuthorizedShips: Array.isArray(settings.defaultAuthorizedShips) ? settings.defaultAuthorizedShips
|
|
75
|
+
defaultAuthorizedShips: Array.isArray(settings.defaultAuthorizedShips) ? filterStringEntries(settings.defaultAuthorizedShips) : void 0,
|
|
64
76
|
ownerShip: typeof settings.ownerShip === "string" ? settings.ownerShip : void 0,
|
|
65
77
|
pendingApprovals: parsePendingApprovals(settings.pendingApprovals)
|
|
66
78
|
};
|
|
@@ -120,13 +132,13 @@ function applySettingsUpdate(current, key, value) {
|
|
|
120
132
|
const next = { ...current };
|
|
121
133
|
switch (key) {
|
|
122
134
|
case "groupChannels":
|
|
123
|
-
next.groupChannels = Array.isArray(value) ? value
|
|
135
|
+
next.groupChannels = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
124
136
|
break;
|
|
125
137
|
case "dmAllowlist":
|
|
126
|
-
next.dmAllowlist = Array.isArray(value) ? value
|
|
138
|
+
next.dmAllowlist = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
127
139
|
break;
|
|
128
|
-
case "
|
|
129
|
-
next.
|
|
140
|
+
case "autoDiscoverChannels":
|
|
141
|
+
next.autoDiscoverChannels = typeof value === "boolean" ? value : void 0;
|
|
130
142
|
break;
|
|
131
143
|
case "showModelSig":
|
|
132
144
|
next.showModelSig = typeof value === "boolean" ? value : void 0;
|
|
@@ -138,13 +150,13 @@ function applySettingsUpdate(current, key, value) {
|
|
|
138
150
|
next.autoAcceptGroupInvites = typeof value === "boolean" ? value : void 0;
|
|
139
151
|
break;
|
|
140
152
|
case "groupInviteAllowlist":
|
|
141
|
-
next.groupInviteAllowlist = Array.isArray(value) ? value
|
|
153
|
+
next.groupInviteAllowlist = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
142
154
|
break;
|
|
143
155
|
case "channelRules":
|
|
144
156
|
next.channelRules = parseChannelRules(value);
|
|
145
157
|
break;
|
|
146
158
|
case "defaultAuthorizedShips":
|
|
147
|
-
next.defaultAuthorizedShips = Array.isArray(value) ? value
|
|
159
|
+
next.defaultAuthorizedShips = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
148
160
|
break;
|
|
149
161
|
case "ownerShip":
|
|
150
162
|
next.ownerShip = typeof value === "string" ? value : void 0;
|
|
@@ -274,7 +286,7 @@ var UrbitAuthError = class extends UrbitError {
|
|
|
274
286
|
async function urbitFetch(params) {
|
|
275
287
|
const validated = validateUrbitBaseUrl(params.baseUrl);
|
|
276
288
|
if (!validated.ok) throw new UrbitUrlError(validated.error);
|
|
277
|
-
|
|
289
|
+
const guarded = await fetchWithSsrFGuard({
|
|
278
290
|
url: new URL(params.path, validated.baseUrl).toString(),
|
|
279
291
|
fetchImpl: params.fetchImpl,
|
|
280
292
|
init: params.init,
|
|
@@ -286,6 +298,13 @@ async function urbitFetch(params) {
|
|
|
286
298
|
auditContext: params.auditContext,
|
|
287
299
|
pinDns: params.pinDns
|
|
288
300
|
});
|
|
301
|
+
return {
|
|
302
|
+
...guarded,
|
|
303
|
+
release: async () => {
|
|
304
|
+
if (!guarded.response.bodyUsed) guarded.response.body?.cancel().catch(() => void 0);
|
|
305
|
+
await guarded.release();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
289
308
|
}
|
|
290
309
|
//#endregion
|
|
291
310
|
//#region extensions/tlon/src/urbit/auth.ts
|
|
@@ -307,10 +326,7 @@ async function authenticate(url, code, options = {}) {
|
|
|
307
326
|
auditContext: "tlon-urbit-login"
|
|
308
327
|
});
|
|
309
328
|
try {
|
|
310
|
-
if (!response.ok) {
|
|
311
|
-
await response.body?.cancel().catch(() => void 0);
|
|
312
|
-
throw new UrbitAuthError("auth_failed", `Login failed with status ${response.status}`);
|
|
313
|
-
}
|
|
329
|
+
if (!response.ok) throw new UrbitAuthError("auth_failed", `Login failed with status ${response.status}`);
|
|
314
330
|
await readResponseTextLimited(response, MAX_AUTH_BODY_DRAIN_BYTES).catch(() => void 0);
|
|
315
331
|
const cookie = response.headers.get("set-cookie");
|
|
316
332
|
if (!cookie) throw new UrbitAuthError("missing_cookie", "No authentication cookie received");
|
|
@@ -399,7 +415,7 @@ function parseInlineMarkdown(text) {
|
|
|
399
415
|
}
|
|
400
416
|
const imageMatch = remaining.match(/^!\[([^\]]*)\]\(([^)]+)\)/);
|
|
401
417
|
if (imageMatch) {
|
|
402
|
-
result.push({
|
|
418
|
+
result.push({ imageBlock: {
|
|
403
419
|
src: expectDefined(imageMatch[2], "image URL capture"),
|
|
404
420
|
alt: expectDefined(imageMatch[1], "image alt capture")
|
|
405
421
|
} });
|
|
@@ -477,8 +493,8 @@ function isImageUrl(url) {
|
|
|
477
493
|
function processInlinesForImages(inlines) {
|
|
478
494
|
const cleanInlines = [];
|
|
479
495
|
const imageBlocks = [];
|
|
480
|
-
for (const inline of inlines) if (typeof inline === "object" && "
|
|
481
|
-
const img = inline
|
|
496
|
+
for (const inline of inlines) if (typeof inline === "object" && "imageBlock" in inline) {
|
|
497
|
+
const img = inline.imageBlock;
|
|
482
498
|
imageBlocks.push(createImageBlock(img.src, img.alt));
|
|
483
499
|
} else cleanInlines.push(inline);
|
|
484
500
|
return {
|
|
@@ -1311,18 +1327,14 @@ var UrbitSSEClient = class {
|
|
|
1311
1327
|
subscription: sub.id
|
|
1312
1328
|
}));
|
|
1313
1329
|
{
|
|
1314
|
-
const {
|
|
1330
|
+
const { release } = await this.putChannelPayload(unsubscribes, {
|
|
1315
1331
|
timeoutMs: 3e4,
|
|
1316
1332
|
auditContext: "tlon-urbit-unsubscribe"
|
|
1317
1333
|
});
|
|
1318
|
-
|
|
1319
|
-
response.body?.cancel().catch(() => void 0);
|
|
1320
|
-
} finally {
|
|
1321
|
-
await release();
|
|
1322
|
-
}
|
|
1334
|
+
await release();
|
|
1323
1335
|
}
|
|
1324
1336
|
{
|
|
1325
|
-
const {
|
|
1337
|
+
const { release } = await urbitFetch({
|
|
1326
1338
|
baseUrl: this.url,
|
|
1327
1339
|
path: `/~/channel/${this.channelId}`,
|
|
1328
1340
|
init: {
|
|
@@ -1335,11 +1347,7 @@ var UrbitSSEClient = class {
|
|
|
1335
1347
|
timeoutMs: 3e4,
|
|
1336
1348
|
auditContext: "tlon-urbit-channel-close"
|
|
1337
1349
|
});
|
|
1338
|
-
|
|
1339
|
-
response.body?.cancel().catch(() => void 0);
|
|
1340
|
-
} finally {
|
|
1341
|
-
await release();
|
|
1342
|
-
}
|
|
1350
|
+
await release();
|
|
1343
1351
|
}
|
|
1344
1352
|
} catch (error) {
|
|
1345
1353
|
this.logger.error?.(`Error closing channel: ${String(error)}`);
|
|
@@ -1865,19 +1873,30 @@ const tlonIngressIdentity = {
|
|
|
1865
1873
|
entryIdPrefix: "tlon-entry"
|
|
1866
1874
|
};
|
|
1867
1875
|
async function isDmAllowedWithIngress(senderShip, allowlist) {
|
|
1868
|
-
return (await
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
identity: tlonIngressIdentity,
|
|
1872
|
-
subject: { stableId: senderShip },
|
|
1876
|
+
return (await resolveTlonMessageIngress({
|
|
1877
|
+
senderShip,
|
|
1878
|
+
allowFrom: allowlist ?? [],
|
|
1873
1879
|
conversation: {
|
|
1874
1880
|
kind: "direct",
|
|
1875
1881
|
id: "direct"
|
|
1876
1882
|
},
|
|
1877
|
-
dmPolicy: "allowlist"
|
|
1878
|
-
allowFrom: allowlist ?? []
|
|
1883
|
+
dmPolicy: "allowlist"
|
|
1879
1884
|
})).senderAccess.allowed;
|
|
1880
1885
|
}
|
|
1886
|
+
async function resolveTlonMessageIngress(params) {
|
|
1887
|
+
return await resolveStableChannelMessageIngress({
|
|
1888
|
+
channelId: "tlon",
|
|
1889
|
+
accountId: params.accountId ?? "default",
|
|
1890
|
+
identity: tlonIngressIdentity,
|
|
1891
|
+
subject: { stableId: params.senderShip },
|
|
1892
|
+
conversation: params.conversation,
|
|
1893
|
+
contextBinding: params.contextBinding,
|
|
1894
|
+
dmPolicy: params.dmPolicy ?? "allowlist",
|
|
1895
|
+
groupPolicy: params.groupPolicy ?? "open",
|
|
1896
|
+
allowFrom: params.allowFrom,
|
|
1897
|
+
groupAllowFrom: params.allowFrom
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1881
1900
|
async function resolveTlonCommandAuthorizationWithIngress(params) {
|
|
1882
1901
|
const normalizedOwner = params.ownerShip ? normalizeShip(params.ownerShip) : null;
|
|
1883
1902
|
return await resolveStableChannelMessageIngress({
|
|
@@ -1937,21 +1956,11 @@ async function resolveAuthorizedMessageText(params) {
|
|
|
1937
1956
|
if (!authorizedForCites) return rawText;
|
|
1938
1957
|
return await resolveAllCites(content) + rawText;
|
|
1939
1958
|
}
|
|
1940
|
-
const asRecord = asNullableObjectRecord;
|
|
1941
|
-
const formatErrorMessage$1 = formatErrorMessage;
|
|
1942
|
-
const readString = readStringField;
|
|
1943
|
-
function asNullableObjectRecord(value) {
|
|
1944
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
1945
|
-
}
|
|
1946
|
-
function readStringField(record, field) {
|
|
1947
|
-
const value = record?.[field];
|
|
1948
|
-
return typeof value === "string" ? value : void 0;
|
|
1949
|
-
}
|
|
1950
1959
|
function renderInlineItem(item, options) {
|
|
1951
1960
|
if (typeof item === "string") return item;
|
|
1952
|
-
const record =
|
|
1961
|
+
const record = asNullableRecord(item);
|
|
1953
1962
|
if (!record) return "";
|
|
1954
|
-
const ship =
|
|
1963
|
+
const ship = readStringField(record, "ship");
|
|
1955
1964
|
if (ship) return ship;
|
|
1956
1965
|
if ("sect" in record) {
|
|
1957
1966
|
const sect = record.sect;
|
|
@@ -1959,14 +1968,14 @@ function renderInlineItem(item, options) {
|
|
|
1959
1968
|
if (sect === null) return "@all";
|
|
1960
1969
|
}
|
|
1961
1970
|
if (options?.allowBreak && "break" in record) return "\n";
|
|
1962
|
-
const inlineCode =
|
|
1971
|
+
const inlineCode = readStringField(record, "inline-code");
|
|
1963
1972
|
if (inlineCode) return `\`${inlineCode}\``;
|
|
1964
|
-
const code =
|
|
1973
|
+
const code = readStringField(record, "code");
|
|
1965
1974
|
if (code) return `\`${code}\``;
|
|
1966
|
-
const link =
|
|
1967
|
-
const linkHref = link ?
|
|
1975
|
+
const link = asNullableRecord(record.link);
|
|
1976
|
+
const linkHref = link ? readStringField(link, "href") : void 0;
|
|
1968
1977
|
if (link && linkHref) {
|
|
1969
|
-
const linkContent =
|
|
1978
|
+
const linkContent = readStringField(link, "content");
|
|
1970
1979
|
return options?.linkMode === "href" ? linkHref : linkContent || linkHref;
|
|
1971
1980
|
}
|
|
1972
1981
|
if (Array.isArray(record.bold)) return `**${extractInlineText(record.bold)}**`;
|
|
@@ -1981,50 +1990,50 @@ function extractInlineText(items) {
|
|
|
1981
1990
|
function extractMessageText(content) {
|
|
1982
1991
|
if (!content || !Array.isArray(content)) return "";
|
|
1983
1992
|
return content.map((verse) => {
|
|
1984
|
-
const verseRecord =
|
|
1993
|
+
const verseRecord = asNullableRecord(verse);
|
|
1985
1994
|
if (!verseRecord) return "";
|
|
1986
1995
|
if (Array.isArray(verseRecord.inline)) return verseRecord.inline.map((item) => renderInlineItem(item, {
|
|
1987
1996
|
linkMode: "href",
|
|
1988
1997
|
allowBreak: true,
|
|
1989
1998
|
allowBlockquote: true
|
|
1990
1999
|
})).join("");
|
|
1991
|
-
const block =
|
|
2000
|
+
const block = asNullableRecord(verseRecord.block);
|
|
1992
2001
|
if (block) {
|
|
1993
|
-
const image =
|
|
2002
|
+
const image = asNullableRecord(block.image);
|
|
1994
2003
|
if (image) {
|
|
1995
|
-
const imageSrc =
|
|
2004
|
+
const imageSrc = readStringField(image, "src");
|
|
1996
2005
|
if (imageSrc) {
|
|
1997
|
-
const altText =
|
|
2006
|
+
const altText = readStringField(image, "alt");
|
|
1998
2007
|
return `\n${imageSrc}${altText ? ` (${altText})` : ""}\n`;
|
|
1999
2008
|
}
|
|
2000
2009
|
}
|
|
2001
|
-
const codeBlock =
|
|
2002
|
-
if (codeBlock) return `\n\`\`\`${
|
|
2003
|
-
const header =
|
|
2010
|
+
const codeBlock = asNullableRecord(block.code);
|
|
2011
|
+
if (codeBlock) return `\n\`\`\`${readStringField(codeBlock, "lang") ?? ""}\n${readStringField(codeBlock, "code") ?? ""}\n\`\`\`\n`;
|
|
2012
|
+
const header = asNullableRecord(block.header);
|
|
2004
2013
|
if (header) return `\n## ${(Array.isArray(header.content) ? header.content : []).map((item) => typeof item === "string" ? item : "").join("") || ""}\n`;
|
|
2005
|
-
const cite =
|
|
2014
|
+
const cite = asNullableRecord(block.cite);
|
|
2006
2015
|
if (cite) {
|
|
2007
|
-
const chanCite =
|
|
2016
|
+
const chanCite = asNullableRecord(cite.chan);
|
|
2008
2017
|
if (chanCite) {
|
|
2009
|
-
const nest =
|
|
2010
|
-
const whereMatch =
|
|
2018
|
+
const nest = readStringField(chanCite, "nest");
|
|
2019
|
+
const whereMatch = readStringField(chanCite, "where")?.match(/\/msg\/(~[a-z-]+)\/(.+)/);
|
|
2011
2020
|
if (whereMatch) {
|
|
2012
2021
|
const [, author, _postId] = whereMatch;
|
|
2013
2022
|
return `\n> [quoted: ${author} in ${nest}]\n`;
|
|
2014
2023
|
}
|
|
2015
2024
|
return `\n> [quoted from ${nest}]\n`;
|
|
2016
2025
|
}
|
|
2017
|
-
const group =
|
|
2026
|
+
const group = readStringField(cite, "group");
|
|
2018
2027
|
if (group) return `\n> [ref: group ${group}]\n`;
|
|
2019
|
-
const desk =
|
|
2028
|
+
const desk = asNullableRecord(cite.desk);
|
|
2020
2029
|
if (desk) {
|
|
2021
|
-
const flag =
|
|
2030
|
+
const flag = readStringField(desk, "flag");
|
|
2022
2031
|
if (flag) return `\n> [ref: ${flag}]\n`;
|
|
2023
2032
|
}
|
|
2024
|
-
const bait =
|
|
2033
|
+
const bait = asNullableRecord(cite.bait);
|
|
2025
2034
|
if (bait) {
|
|
2026
|
-
const graph =
|
|
2027
|
-
const groupName =
|
|
2035
|
+
const graph = readStringField(bait, "graph");
|
|
2036
|
+
const groupName = readStringField(bait, "group");
|
|
2028
2037
|
if (graph && groupName) return `\n> [ref: ${graph} in ${groupName}]\n`;
|
|
2029
2038
|
}
|
|
2030
2039
|
return `\n> [quoted message]\n`;
|
|
@@ -2042,6 +2051,21 @@ function isSummarizationRequest(messageText) {
|
|
|
2042
2051
|
/tldr/i
|
|
2043
2052
|
].some((pattern) => pattern.test(messageText));
|
|
2044
2053
|
}
|
|
2054
|
+
/**
|
|
2055
|
+
* Formats channel history for a summarization request. Each entry is rendered
|
|
2056
|
+
* through the shared inbound envelope so timestamps honor the configured user
|
|
2057
|
+
* timezone instead of the host process zone (matches Mattermost/Feishu).
|
|
2058
|
+
*/
|
|
2059
|
+
function formatSummarizationHistoryText(history, cfg) {
|
|
2060
|
+
const envelopeOptions = resolveEnvelopeFormatOptions(cfg);
|
|
2061
|
+
return history.map((msg) => formatAgentEnvelope({
|
|
2062
|
+
channel: "Tlon",
|
|
2063
|
+
from: msg.author,
|
|
2064
|
+
timestamp: msg.timestamp,
|
|
2065
|
+
body: msg.content,
|
|
2066
|
+
envelope: envelopeOptions
|
|
2067
|
+
})).join("\n");
|
|
2068
|
+
}
|
|
2045
2069
|
//#endregion
|
|
2046
2070
|
//#region extensions/tlon/src/monitor/cites.ts
|
|
2047
2071
|
function createTlonCitationResolver(params) {
|
|
@@ -2051,7 +2075,7 @@ function createTlonCitationResolver(params) {
|
|
|
2051
2075
|
try {
|
|
2052
2076
|
const scryPath = `/channels/v4/${cite.nest}/posts/post/${cite.postId}.json`;
|
|
2053
2077
|
runtime.log?.(`[tlon] Fetching cited post: ${scryPath}`);
|
|
2054
|
-
const essay =
|
|
2078
|
+
const essay = asNullableRecord(asNullableRecord(await api.scry(scryPath))?.essay);
|
|
2055
2079
|
if (essay?.content) return extractMessageText(essay.content) || null;
|
|
2056
2080
|
return null;
|
|
2057
2081
|
} catch (err) {
|
|
@@ -2083,18 +2107,18 @@ function createTlonCitationResolver(params) {
|
|
|
2083
2107
|
async function fetchInitData(api, runtime) {
|
|
2084
2108
|
try {
|
|
2085
2109
|
runtime.log?.("[tlon] Fetching groups-ui init data...");
|
|
2086
|
-
const initData =
|
|
2110
|
+
const initData = asNullableRecord(await api.scry("/groups-ui/v6/init.json"));
|
|
2087
2111
|
const channels = [];
|
|
2088
|
-
const groups =
|
|
2112
|
+
const groups = asNullableRecord(initData?.groups);
|
|
2089
2113
|
if (groups) for (const groupData of Object.values(groups)) {
|
|
2090
|
-
const groupChannels =
|
|
2114
|
+
const groupChannels = asNullableRecord(asNullableRecord(groupData)?.channels);
|
|
2091
2115
|
if (groupChannels) {
|
|
2092
2116
|
for (const channelNest of Object.keys(groupChannels)) if (channelNest.startsWith("chat/")) channels.push(channelNest);
|
|
2093
2117
|
}
|
|
2094
2118
|
}
|
|
2095
2119
|
if (channels.length > 0) runtime.log?.(`[tlon] Auto-discovered ${channels.length} chat channel(s)`);
|
|
2096
2120
|
else runtime.log?.("[tlon] No chat channels found via auto-discovery");
|
|
2097
|
-
const foreignsValue =
|
|
2121
|
+
const foreignsValue = asNullableRecord(initData?.foreigns);
|
|
2098
2122
|
const foreigns = foreignsValue ? foreignsValue : null;
|
|
2099
2123
|
if (foreigns) {
|
|
2100
2124
|
const pendingCount = Object.values(foreigns).filter((f) => f.invites?.some((i) => i.valid)).length;
|
|
@@ -2105,7 +2129,7 @@ async function fetchInitData(api, runtime) {
|
|
|
2105
2129
|
foreigns
|
|
2106
2130
|
};
|
|
2107
2131
|
} catch (error) {
|
|
2108
|
-
runtime.log?.(`[tlon] Init data fetch failed: ${formatErrorMessage
|
|
2132
|
+
runtime.log?.(`[tlon] Init data fetch failed: ${formatErrorMessage(error)}`);
|
|
2109
2133
|
return {
|
|
2110
2134
|
channels: [],
|
|
2111
2135
|
foreigns: null
|
|
@@ -2155,16 +2179,16 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
|
|
|
2155
2179
|
let posts = [];
|
|
2156
2180
|
if (Array.isArray(data)) posts = data;
|
|
2157
2181
|
else {
|
|
2158
|
-
const dataRecord =
|
|
2159
|
-
const postMap =
|
|
2182
|
+
const dataRecord = asNullableRecord(data);
|
|
2183
|
+
const postMap = asNullableRecord(dataRecord?.posts);
|
|
2160
2184
|
if (postMap) posts = Object.values(postMap);
|
|
2161
2185
|
else if (dataRecord) posts = Object.values(dataRecord);
|
|
2162
2186
|
}
|
|
2163
2187
|
const messages = posts.map((item) => {
|
|
2164
|
-
const itemRecord =
|
|
2165
|
-
const replyPostSet =
|
|
2166
|
-
const essay =
|
|
2167
|
-
const seal =
|
|
2188
|
+
const itemRecord = asNullableRecord(item);
|
|
2189
|
+
const replyPostSet = asNullableRecord(asNullableRecord(itemRecord?.["r-post"])?.set);
|
|
2190
|
+
const essay = asNullableRecord(itemRecord?.essay) ?? asNullableRecord(replyPostSet?.essay);
|
|
2191
|
+
const seal = asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replyPostSet?.seal);
|
|
2168
2192
|
return {
|
|
2169
2193
|
author: typeof essay?.author === "string" ? essay.author : "unknown",
|
|
2170
2194
|
content: extractMessageText(essay?.content || []),
|
|
@@ -2175,7 +2199,7 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
|
|
|
2175
2199
|
runtime?.log?.(`[tlon] Extracted ${messages.length} messages from history`);
|
|
2176
2200
|
return messages;
|
|
2177
2201
|
} catch (error) {
|
|
2178
|
-
runtime?.log?.(`[tlon] Error fetching channel history: ${formatErrorMessage
|
|
2202
|
+
runtime?.log?.(`[tlon] Error fetching channel history: ${formatErrorMessage(error)}`);
|
|
2179
2203
|
return [];
|
|
2180
2204
|
}
|
|
2181
2205
|
}
|
|
@@ -2206,44 +2230,44 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
|
|
|
2206
2230
|
let replies = [];
|
|
2207
2231
|
if (Array.isArray(data)) replies = data;
|
|
2208
2232
|
else {
|
|
2209
|
-
const dataRecord =
|
|
2233
|
+
const dataRecord = asNullableRecord(data);
|
|
2210
2234
|
const replyValue = dataRecord?.replies;
|
|
2211
2235
|
if (Array.isArray(replyValue)) replies = replyValue;
|
|
2212
2236
|
else if (typeof replyValue === "object" && replyValue) replies = Object.values(replyValue);
|
|
2213
2237
|
else if (dataRecord) replies = Object.values(dataRecord);
|
|
2214
2238
|
}
|
|
2215
2239
|
const messages = replies.map((item) => {
|
|
2216
|
-
const itemRecord =
|
|
2217
|
-
const replySet =
|
|
2240
|
+
const itemRecord = asNullableRecord(item);
|
|
2241
|
+
const replySet = asNullableRecord(asNullableRecord(itemRecord?.["r-reply"])?.set);
|
|
2218
2242
|
return createHistoryEntryFromMemo({
|
|
2219
|
-
memo:
|
|
2220
|
-
seal:
|
|
2243
|
+
memo: asNullableRecord(itemRecord?.memo) ?? asNullableRecord(replySet?.memo) ?? itemRecord,
|
|
2244
|
+
seal: asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replySet?.seal),
|
|
2221
2245
|
fallbackId: itemRecord?.id
|
|
2222
2246
|
});
|
|
2223
2247
|
}).filter((msg) => msg.content);
|
|
2224
2248
|
runtime?.log?.(`[tlon] Extracted ${messages.length} thread replies from history`);
|
|
2225
2249
|
return messages;
|
|
2226
2250
|
} catch (error) {
|
|
2227
|
-
runtime?.log?.(`[tlon] Error fetching thread history: ${formatErrorMessage
|
|
2251
|
+
runtime?.log?.(`[tlon] Error fetching thread history: ${formatErrorMessage(error)}`);
|
|
2228
2252
|
try {
|
|
2229
2253
|
const altPath = `/channels/v4/${channelNest}/posts/post/id/${formatUd(parentId)}.json`;
|
|
2230
2254
|
runtime?.log?.(`[tlon] Trying alternate path: ${altPath}`);
|
|
2231
|
-
const data =
|
|
2232
|
-
const dataMeta =
|
|
2255
|
+
const data = asNullableRecord(await api.scry(altPath));
|
|
2256
|
+
const dataMeta = asNullableRecord(asNullableRecord(data?.seal)?.meta);
|
|
2233
2257
|
const repliesValue = data?.replies;
|
|
2234
2258
|
if (typeof dataMeta?.replyCount === "number" && dataMeta.replyCount > 0 && repliesValue) {
|
|
2235
2259
|
const messages = (Array.isArray(repliesValue) ? repliesValue : Object.values(repliesValue)).map((reply) => {
|
|
2236
|
-
const replyRecord =
|
|
2260
|
+
const replyRecord = asNullableRecord(reply);
|
|
2237
2261
|
return createHistoryEntryFromMemo({
|
|
2238
|
-
memo:
|
|
2239
|
-
seal:
|
|
2262
|
+
memo: asNullableRecord(replyRecord?.memo),
|
|
2263
|
+
seal: asNullableRecord(replyRecord?.seal)
|
|
2240
2264
|
});
|
|
2241
2265
|
}).filter((msg) => msg.content);
|
|
2242
2266
|
runtime?.log?.(`[tlon] Extracted ${messages.length} replies from post data`);
|
|
2243
2267
|
return messages;
|
|
2244
2268
|
}
|
|
2245
2269
|
} catch (altError) {
|
|
2246
|
-
runtime?.log?.(`[tlon] Alternate path also failed: ${formatErrorMessage
|
|
2270
|
+
runtime?.log?.(`[tlon] Alternate path also failed: ${formatErrorMessage(altError)}`);
|
|
2247
2271
|
}
|
|
2248
2272
|
return [];
|
|
2249
2273
|
}
|
|
@@ -2253,12 +2277,6 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
|
|
|
2253
2277
|
const TLON_INGRESS_PAYLOAD_VERSION = 1;
|
|
2254
2278
|
const TLON_INGRESS_POLL_INTERVAL_MS = 1e3;
|
|
2255
2279
|
const TlonIngressPermanentError = createChannelIngressError("TlonIngressPermanentError", { withReason: true });
|
|
2256
|
-
var TlonIngressShutdownError = class extends Error {
|
|
2257
|
-
constructor() {
|
|
2258
|
-
super("Tlon ingress stopped before dispatch adoption.");
|
|
2259
|
-
this.name = "TlonIngressShutdownError";
|
|
2260
|
-
}
|
|
2261
|
-
};
|
|
2262
2280
|
function inspectChannelsEvent(event) {
|
|
2263
2281
|
const envelope = isRecord(event) ? event : null;
|
|
2264
2282
|
const nest = normalizeNullableString(envelope?.nest);
|
|
@@ -2360,7 +2378,7 @@ function createTlonIngressMonitor(options) {
|
|
|
2360
2378
|
onLog: (message) => options.runtime.log?.(`tlon ${message}`)
|
|
2361
2379
|
},
|
|
2362
2380
|
...options.abortSignal ? { abortSignal: options.abortSignal } : {},
|
|
2363
|
-
createStoppedError: () => new
|
|
2381
|
+
createStoppedError: () => /* @__PURE__ */ new Error("Tlon ingress stopped before dispatch adoption."),
|
|
2364
2382
|
onError: (error) => options.runtime.error?.(`tlon ingress drain failed: ${formatErrorMessage(error)}`)
|
|
2365
2383
|
});
|
|
2366
2384
|
return {
|
|
@@ -2398,19 +2416,26 @@ function buildTlonInboundMediaPrompt(messageText, attachments) {
|
|
|
2398
2416
|
}
|
|
2399
2417
|
/**
|
|
2400
2418
|
* Extract image blocks from Tlon message content.
|
|
2401
|
-
* Returns
|
|
2419
|
+
* Returns up to the download cap plus the number omitted by that cap.
|
|
2402
2420
|
*/
|
|
2403
2421
|
function extractImageBlocks(content) {
|
|
2404
|
-
if (!content || !Array.isArray(content)) return
|
|
2422
|
+
if (!content || !Array.isArray(content)) return {
|
|
2423
|
+
images: [],
|
|
2424
|
+
unavailableCount: 0
|
|
2425
|
+
};
|
|
2405
2426
|
const images = [];
|
|
2427
|
+
let unavailableCount = 0;
|
|
2406
2428
|
for (const verse of content) if (verse?.block?.image?.src) {
|
|
2407
|
-
images.
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2429
|
+
if (images.length >= MAX_IMAGES_PER_MESSAGE) {
|
|
2430
|
+
unavailableCount++;
|
|
2431
|
+
continue;
|
|
2432
|
+
}
|
|
2433
|
+
images.push({ url: verse.block.image.src });
|
|
2412
2434
|
}
|
|
2413
|
-
return
|
|
2435
|
+
return {
|
|
2436
|
+
images,
|
|
2437
|
+
unavailableCount
|
|
2438
|
+
};
|
|
2414
2439
|
}
|
|
2415
2440
|
/**
|
|
2416
2441
|
* Download a media file from URL to local storage.
|
|
@@ -2434,8 +2459,7 @@ async function downloadMedia(url, mediaDir) {
|
|
|
2434
2459
|
const saved = await saveRemoteMedia(fetchOptions);
|
|
2435
2460
|
return {
|
|
2436
2461
|
localPath: saved.path,
|
|
2437
|
-
contentType: saved.contentType ?? "application/octet-stream"
|
|
2438
|
-
originalUrl: url
|
|
2462
|
+
contentType: saved.contentType ?? "application/octet-stream"
|
|
2439
2463
|
};
|
|
2440
2464
|
}
|
|
2441
2465
|
const fetched = await readRemoteMediaBuffer(fetchOptions);
|
|
@@ -2445,8 +2469,7 @@ async function downloadMedia(url, mediaDir) {
|
|
|
2445
2469
|
await writeFile(localPath, fetched.buffer);
|
|
2446
2470
|
return {
|
|
2447
2471
|
localPath,
|
|
2448
|
-
contentType: fetched.contentType ?? "application/octet-stream"
|
|
2449
|
-
originalUrl: url
|
|
2472
|
+
contentType: fetched.contentType ?? "application/octet-stream"
|
|
2450
2473
|
};
|
|
2451
2474
|
} catch (error) {
|
|
2452
2475
|
console.error(`[tlon-media] Error downloading ${url}: ${formatErrorMessage(error)}`);
|
|
@@ -2473,17 +2496,21 @@ function getExtensionFromUrl(url) {
|
|
|
2473
2496
|
* Format matches OpenClaw's expected attachment structure.
|
|
2474
2497
|
*/
|
|
2475
2498
|
async function downloadMessageImages(content, mediaDir) {
|
|
2476
|
-
const images = extractImageBlocks(content);
|
|
2477
|
-
if (images.length === 0) return [];
|
|
2499
|
+
const { images, unavailableCount: overCapCount } = extractImageBlocks(content);
|
|
2478
2500
|
const attachments = [];
|
|
2501
|
+
let unavailableCount = overCapCount;
|
|
2479
2502
|
for (const image of images) {
|
|
2480
2503
|
const downloaded = await downloadMedia(image.url, mediaDir);
|
|
2481
2504
|
if (downloaded) attachments.push({
|
|
2482
2505
|
path: downloaded.localPath,
|
|
2483
2506
|
contentType: downloaded.contentType
|
|
2484
2507
|
});
|
|
2508
|
+
else unavailableCount++;
|
|
2485
2509
|
}
|
|
2486
|
-
return
|
|
2510
|
+
return {
|
|
2511
|
+
attachments,
|
|
2512
|
+
unavailableCount
|
|
2513
|
+
};
|
|
2487
2514
|
}
|
|
2488
2515
|
//#endregion
|
|
2489
2516
|
//#region extensions/tlon/src/monitor/settings-helpers.ts
|
|
@@ -2621,9 +2648,6 @@ function createActiveSnapshotTracker() {
|
|
|
2621
2648
|
}
|
|
2622
2649
|
//#endregion
|
|
2623
2650
|
//#region extensions/tlon/src/monitor/index.ts
|
|
2624
|
-
function readNumber(record, key) {
|
|
2625
|
-
return asFiniteNumber(record?.[key]);
|
|
2626
|
-
}
|
|
2627
2651
|
async function monitorTlonProvider(opts = {}) {
|
|
2628
2652
|
const core = getTlonRuntime();
|
|
2629
2653
|
const cfg = core.config.current();
|
|
@@ -2639,20 +2663,27 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2639
2663
|
const accountUrl = account.url;
|
|
2640
2664
|
const accountCode = account.code;
|
|
2641
2665
|
async function authenticateWithRetry(maxAttempts = 10) {
|
|
2642
|
-
|
|
2666
|
+
let authAttempt = 0;
|
|
2667
|
+
return await retryAsync(async () => {
|
|
2668
|
+
authAttempt += 1;
|
|
2643
2669
|
if (opts.abortSignal?.aborted) throw new Error("Aborted while waiting to authenticate");
|
|
2644
2670
|
try {
|
|
2645
2671
|
runtime.log?.(`[tlon] Attempting authentication to ${accountUrl}...`);
|
|
2646
2672
|
return await authenticate(accountUrl, accountCode, { ssrfPolicy });
|
|
2647
2673
|
} catch (error) {
|
|
2648
|
-
runtime.error?.(`[tlon] Failed to authenticate (attempt ${
|
|
2649
|
-
|
|
2650
|
-
const delay = Math.min(3e4, 1e3 * 2 ** (attempt - 1));
|
|
2651
|
-
runtime.log?.(`[tlon] Retrying authentication in ${delay}ms...`);
|
|
2652
|
-
await sleepWithAbort(delay, opts.abortSignal);
|
|
2674
|
+
runtime.error?.(`[tlon] Failed to authenticate (attempt ${authAttempt}): ${formatErrorMessage(error)}`);
|
|
2675
|
+
throw error;
|
|
2653
2676
|
}
|
|
2654
|
-
}
|
|
2655
|
-
|
|
2677
|
+
}, {
|
|
2678
|
+
attempts: Math.max(1, maxAttempts),
|
|
2679
|
+
minDelayMs: 0,
|
|
2680
|
+
shouldRetry: () => !opts.abortSignal?.aborted,
|
|
2681
|
+
delayMs: ({ attempt }) => Math.min(3e4, 1e3 * 2 ** (attempt - 1)),
|
|
2682
|
+
onRetry: ({ delayMs }) => {
|
|
2683
|
+
runtime.log?.(`[tlon] Retrying authentication in ${delayMs}ms...`);
|
|
2684
|
+
},
|
|
2685
|
+
sleep: (delayMs) => sleepWithAbort(delayMs, opts.abortSignal)
|
|
2686
|
+
});
|
|
2656
2687
|
}
|
|
2657
2688
|
let api = null;
|
|
2658
2689
|
const cookie = await authenticateWithRetry();
|
|
@@ -2695,7 +2726,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2695
2726
|
if (botNickname) runtime.log?.(`[tlon] Bot nickname: ${botNickname}`);
|
|
2696
2727
|
}
|
|
2697
2728
|
} catch (error) {
|
|
2698
|
-
runtime.log?.(`[tlon] Could not fetch nickname: ${formatErrorMessage
|
|
2729
|
+
runtime.log?.(`[tlon] Could not fetch nickname: ${formatErrorMessage(error)}`);
|
|
2699
2730
|
}
|
|
2700
2731
|
let initForeigns = null;
|
|
2701
2732
|
async function migrateConfigToSettings() {
|
|
@@ -2732,7 +2763,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2732
2763
|
if (initData.channels.length > 0) groupChannels = initData.channels;
|
|
2733
2764
|
initForeigns = initData.foreigns;
|
|
2734
2765
|
} catch (error) {
|
|
2735
|
-
runtime.error?.(`[tlon] Auto-discovery failed: ${formatErrorMessage
|
|
2766
|
+
runtime.error?.(`[tlon] Auto-discovery failed: ${formatErrorMessage(error)}`);
|
|
2736
2767
|
}
|
|
2737
2768
|
if (account.groupChannels.length > 0) {
|
|
2738
2769
|
groupChannels = mergeUniqueStrings(groupChannels, account.groupChannels);
|
|
@@ -2755,15 +2786,16 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2755
2786
|
return /^~?[a-z-]+$/i.test(normalized) ? normalized : "";
|
|
2756
2787
|
}
|
|
2757
2788
|
const processMessage = async (params) => {
|
|
2758
|
-
const { messageId, senderShip, isGroup, channelNest, hostShip: _hostShip, channelName: _channelName, timestamp, parentId, isThreadReply, messageContent, turnAdoptionLifecycle } = params;
|
|
2789
|
+
const { messageId, senderShip, isGroup, channelNest, hostShip: _hostShip, channelName: _channelName, timestamp, parentId, isThreadReply, messageContent, turnAdoptionLifecycle, resolveChannelIngress } = params;
|
|
2759
2790
|
const groupChannel = channelNest;
|
|
2760
2791
|
let messageText = params.messageText;
|
|
2761
2792
|
let attachments = [];
|
|
2793
|
+
let unavailableMediaCount = 0;
|
|
2762
2794
|
if (messageContent) try {
|
|
2763
|
-
attachments = await downloadMessageImages(messageContent);
|
|
2795
|
+
({attachments, unavailableCount: unavailableMediaCount} = await downloadMessageImages(messageContent));
|
|
2764
2796
|
if (attachments.length > 0) runtime.log?.(`[tlon] Downloaded ${attachments.length} image(s) from message`);
|
|
2765
2797
|
} catch (error) {
|
|
2766
|
-
runtime.log?.(`[tlon] Failed to download images: ${formatErrorMessage
|
|
2798
|
+
runtime.log?.(`[tlon] Failed to download images: ${formatErrorMessage(error)}`);
|
|
2767
2799
|
}
|
|
2768
2800
|
if (isThreadReply && parentId && groupChannel) try {
|
|
2769
2801
|
const threadHistory = await fetchThreadHistory(api, groupChannel, parentId, 20, runtime);
|
|
@@ -2773,7 +2805,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2773
2805
|
runtime?.log?.(`[tlon] Added thread context (${threadHistory.length} replies) to message`);
|
|
2774
2806
|
}
|
|
2775
2807
|
} catch (error) {
|
|
2776
|
-
runtime?.log?.(`[tlon] Could not fetch thread context: ${formatErrorMessage
|
|
2808
|
+
runtime?.log?.(`[tlon] Could not fetch thread context: ${formatErrorMessage(error)}`);
|
|
2777
2809
|
}
|
|
2778
2810
|
if (isGroup && groupChannel && isSummarizationRequest(messageText)) try {
|
|
2779
2811
|
const history = await getChannelHistory(api, groupChannel, 50, runtime);
|
|
@@ -2796,14 +2828,14 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2796
2828
|
});
|
|
2797
2829
|
return;
|
|
2798
2830
|
}
|
|
2799
|
-
const historyText = history
|
|
2831
|
+
const historyText = formatSummarizationHistoryText(history, cfg);
|
|
2800
2832
|
messageText = `Please summarize this channel conversation (${history.length} recent messages):\n\n${historyText}\n\nProvide a concise summary highlighting:
|
|
2801
2833
|
1. Main topics discussed
|
|
2802
2834
|
2. Key decisions or conclusions
|
|
2803
2835
|
3. Action items if any
|
|
2804
2836
|
4. Notable participants`;
|
|
2805
2837
|
} catch (error) {
|
|
2806
|
-
const errorMsg = `Sorry, I encountered an error while fetching the channel history: ${formatErrorMessage
|
|
2838
|
+
const errorMsg = `Sorry, I encountered an error while fetching the channel history: ${formatErrorMessage(error)}`;
|
|
2807
2839
|
if (isGroup && groupChannel) {
|
|
2808
2840
|
const parsed = parseChannelNest(groupChannel);
|
|
2809
2841
|
if (parsed) await sendGroupMessage({
|
|
@@ -2830,6 +2862,16 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2830
2862
|
id: isGroup ? groupChannel ?? senderShip : senderShip
|
|
2831
2863
|
}
|
|
2832
2864
|
});
|
|
2865
|
+
const channelIngress = await resolveChannelIngress({
|
|
2866
|
+
agentId: route.agentId,
|
|
2867
|
+
sessionKey: route.sessionKey,
|
|
2868
|
+
messageId,
|
|
2869
|
+
inboundEventKind: "user_request"
|
|
2870
|
+
});
|
|
2871
|
+
if (!channelIngress.senderAccess.allowed) {
|
|
2872
|
+
runtime.log?.(`[tlon] Authorization changed before dispatch for ${senderShip}`);
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2833
2875
|
if (!isGroup) {
|
|
2834
2876
|
const sessionKey = route.sessionKey;
|
|
2835
2877
|
if (!dmSendersBySession.has(sessionKey)) dmSendersBySession.set(sessionKey, /* @__PURE__ */ new Set());
|
|
@@ -2843,7 +2885,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2843
2885
|
fromShip: botShipName,
|
|
2844
2886
|
toShip: effectiveOwnerShip,
|
|
2845
2887
|
text: "⚠️ Security Warning: Multiple users are sharing a DM session with this bot. This can leak conversation context between users.\n\nFix: Add to your OpenClaw config:\nsession:\n dmScope: \"per-channel-peer\"\n\nDocs: https://docs.openclaw.ai/concepts/session#secure-dm-mode"
|
|
2846
|
-
}).catch((err) => runtime.error?.(`[tlon] Failed to send security warning to owner: ${formatErrorMessage
|
|
2888
|
+
}).catch((err) => runtime.error?.(`[tlon] Failed to send security warning to owner: ${formatErrorMessage(err)}`));
|
|
2847
2889
|
}
|
|
2848
2890
|
}
|
|
2849
2891
|
senders.add(senderShip);
|
|
@@ -2871,6 +2913,10 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2871
2913
|
body: promptMedia.body
|
|
2872
2914
|
});
|
|
2873
2915
|
const commandBody = isGroup ? stripBotMention(messageText, botShipName) : messageText;
|
|
2916
|
+
const bodyForAgent = unavailableMediaCount > 0 ? formatInboundMediaUnavailableText({
|
|
2917
|
+
body: commandBody,
|
|
2918
|
+
notice: `[tlon ${unavailableMediaCount > 1 ? `${unavailableMediaCount} attachments` : "attachment"} unavailable]`
|
|
2919
|
+
}) : commandBody;
|
|
2874
2920
|
const tlonConversationId = isGroup ? groupChannel ?? channelNest ?? senderShip : senderShip;
|
|
2875
2921
|
const ctxPayload = core.channel.inbound.buildContext({
|
|
2876
2922
|
channel: "tlon",
|
|
@@ -2901,10 +2947,11 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2901
2947
|
},
|
|
2902
2948
|
message: {
|
|
2903
2949
|
body,
|
|
2904
|
-
bodyForAgent
|
|
2950
|
+
bodyForAgent,
|
|
2905
2951
|
rawBody: messageText,
|
|
2906
2952
|
commandBody
|
|
2907
2953
|
},
|
|
2954
|
+
channelIngress,
|
|
2908
2955
|
extra: {
|
|
2909
2956
|
GroupSubject: void 0,
|
|
2910
2957
|
SenderRole: senderRole,
|
|
@@ -3044,7 +3091,18 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3044
3091
|
messageText: approval.originalMessage.messageText,
|
|
3045
3092
|
messageContent: approval.originalMessage.messageContent,
|
|
3046
3093
|
isGroup: false,
|
|
3047
|
-
timestamp: approval.originalMessage.timestamp
|
|
3094
|
+
timestamp: approval.originalMessage.timestamp,
|
|
3095
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3096
|
+
senderShip: approval.requestingShip,
|
|
3097
|
+
accountId: account.accountId,
|
|
3098
|
+
conversation: {
|
|
3099
|
+
kind: "direct",
|
|
3100
|
+
id: approval.requestingShip
|
|
3101
|
+
},
|
|
3102
|
+
allowFrom: [approval.requestingShip],
|
|
3103
|
+
dmPolicy: "allowlist",
|
|
3104
|
+
contextBinding
|
|
3105
|
+
})
|
|
3048
3106
|
});
|
|
3049
3107
|
return;
|
|
3050
3108
|
}
|
|
@@ -3061,7 +3119,18 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3061
3119
|
channelName: parsedChannel?.channelName,
|
|
3062
3120
|
timestamp: approval.originalMessage.timestamp,
|
|
3063
3121
|
parentId: approval.originalMessage.parentId,
|
|
3064
|
-
isThreadReply: approval.originalMessage.isThreadReply
|
|
3122
|
+
isThreadReply: approval.originalMessage.isThreadReply,
|
|
3123
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3124
|
+
senderShip: approval.requestingShip,
|
|
3125
|
+
accountId: account.accountId,
|
|
3126
|
+
conversation: {
|
|
3127
|
+
kind: "group",
|
|
3128
|
+
id: approval.channelNest
|
|
3129
|
+
},
|
|
3130
|
+
allowFrom: [approval.requestingShip],
|
|
3131
|
+
groupPolicy: "allowlist",
|
|
3132
|
+
contextBinding
|
|
3133
|
+
})
|
|
3065
3134
|
});
|
|
3066
3135
|
}
|
|
3067
3136
|
},
|
|
@@ -3069,39 +3138,39 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3069
3138
|
});
|
|
3070
3139
|
const handleChannelsFirehose = async (event, turnAdoptionLifecycle) => {
|
|
3071
3140
|
try {
|
|
3072
|
-
const eventRecord =
|
|
3073
|
-
const nest =
|
|
3141
|
+
const eventRecord = asNullableRecord(event);
|
|
3142
|
+
const nest = readStringField(eventRecord, "nest");
|
|
3074
3143
|
if (!nest) return;
|
|
3075
3144
|
if (!watchedChannels.has(nest)) return;
|
|
3076
|
-
const response =
|
|
3145
|
+
const response = asNullableRecord(eventRecord?.response);
|
|
3077
3146
|
if (!response) return;
|
|
3078
|
-
const post =
|
|
3079
|
-
const rPost =
|
|
3080
|
-
const set =
|
|
3081
|
-
const reply =
|
|
3082
|
-
const replySet =
|
|
3083
|
-
const essay =
|
|
3084
|
-
const memo =
|
|
3147
|
+
const post = asNullableRecord(response.post);
|
|
3148
|
+
const rPost = asNullableRecord(post?.["r-post"]);
|
|
3149
|
+
const set = asNullableRecord(rPost?.set);
|
|
3150
|
+
const reply = asNullableRecord(rPost?.reply);
|
|
3151
|
+
const replySet = asNullableRecord(asNullableRecord(reply?.["r-reply"])?.set);
|
|
3152
|
+
const essay = asNullableRecord(set?.essay);
|
|
3153
|
+
const memo = asNullableRecord(replySet?.memo);
|
|
3085
3154
|
if (!essay && !memo) return;
|
|
3086
3155
|
const content = memo ?? essay;
|
|
3087
3156
|
if (!content) return;
|
|
3088
3157
|
const isThreadReply = Boolean(memo);
|
|
3089
|
-
const messageId = isThreadReply ?
|
|
3158
|
+
const messageId = isThreadReply ? readStringField(reply, "id") : readStringField(post, "id");
|
|
3090
3159
|
if (!messageId) return;
|
|
3091
|
-
const senderShip = normalizeShip(
|
|
3160
|
+
const senderShip = normalizeShip(readStringField(content, "author") ?? "");
|
|
3092
3161
|
if (!senderShip || senderShip === botShipName) return;
|
|
3093
3162
|
const rawText = extractMessageText(content.content);
|
|
3094
3163
|
if (!rawText.trim()) return;
|
|
3095
3164
|
const contentBody = content.content;
|
|
3096
|
-
const sentAt =
|
|
3165
|
+
const sentAt = asFiniteNumber(content?.sent) ?? Date.now();
|
|
3097
3166
|
cacheMessage(nest, {
|
|
3098
3167
|
author: senderShip,
|
|
3099
3168
|
content: rawText,
|
|
3100
3169
|
timestamp: sentAt,
|
|
3101
3170
|
id: messageId
|
|
3102
3171
|
});
|
|
3103
|
-
const seal = isThreadReply ?
|
|
3104
|
-
const parentId =
|
|
3172
|
+
const seal = isThreadReply ? asNullableRecord(replySet?.seal) : asNullableRecord(set?.seal);
|
|
3173
|
+
const parentId = readStringField(seal, "parent-id") ?? readStringField(seal, "parent") ?? null;
|
|
3105
3174
|
const mentioned = isBotMentioned(rawText, botShipName, botNickname ?? void 0);
|
|
3106
3175
|
const inParticipatedThread = isThreadReply && parentId && participatedThreads.has(parentId);
|
|
3107
3176
|
const mentionDecision = resolveTlonGroupMentionDecision({
|
|
@@ -3112,30 +3181,28 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3112
3181
|
});
|
|
3113
3182
|
if (mentionDecision.shouldSkip) return;
|
|
3114
3183
|
if (mentionDecision.implicitMention && !mentioned) runtime.log?.(`[tlon] Responding to thread we participated in (no mention): ${parentId}`);
|
|
3184
|
+
const { mode, allowedShips } = resolveChannelAuthorization(cfg, nest, currentSettings);
|
|
3115
3185
|
if (isOwner(senderShip)) runtime.log?.(`[tlon] Owner ${senderShip} is always allowed in channels`);
|
|
3116
|
-
else {
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
} else runtime.log?.(`[tlon] Access denied: ${senderShip} in ${nest} (allowed: ${allowedShips.join(", ")})`);
|
|
3137
|
-
return;
|
|
3138
|
-
}
|
|
3186
|
+
else if (mode === "restricted") {
|
|
3187
|
+
if (!allowedShips.map(normalizeShip).includes(senderShip)) {
|
|
3188
|
+
if (effectiveOwnerShip) {
|
|
3189
|
+
const approval = createPendingApproval({
|
|
3190
|
+
type: "channel",
|
|
3191
|
+
requestingShip: senderShip,
|
|
3192
|
+
channelNest: nest,
|
|
3193
|
+
messagePreview: sliceUtf16Safe(rawText, 0, 100),
|
|
3194
|
+
originalMessage: {
|
|
3195
|
+
messageId: messageId ?? "",
|
|
3196
|
+
messageText: rawText,
|
|
3197
|
+
messageContent: contentBody,
|
|
3198
|
+
timestamp: sentAt,
|
|
3199
|
+
parentId: parentId ?? void 0,
|
|
3200
|
+
isThreadReply
|
|
3201
|
+
}
|
|
3202
|
+
});
|
|
3203
|
+
await queueApprovalRequest(approval);
|
|
3204
|
+
} else runtime.log?.(`[tlon] Access denied: ${senderShip} in ${nest} (allowed: ${allowedShips.join(", ")})`);
|
|
3205
|
+
return;
|
|
3139
3206
|
}
|
|
3140
3207
|
}
|
|
3141
3208
|
const messageText = await resolveAuthorizedMessageText({
|
|
@@ -3157,10 +3224,21 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3157
3224
|
timestamp: sentAt,
|
|
3158
3225
|
parentId,
|
|
3159
3226
|
isThreadReply,
|
|
3160
|
-
turnAdoptionLifecycle
|
|
3227
|
+
turnAdoptionLifecycle,
|
|
3228
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3229
|
+
senderShip,
|
|
3230
|
+
accountId: account.accountId,
|
|
3231
|
+
conversation: {
|
|
3232
|
+
kind: "group",
|
|
3233
|
+
id: nest
|
|
3234
|
+
},
|
|
3235
|
+
allowFrom: [...allowedShips.map(normalizeShip), ...effectiveOwnerShip ? [normalizeShip(effectiveOwnerShip)] : []],
|
|
3236
|
+
groupPolicy: mode === "restricted" ? "allowlist" : "open",
|
|
3237
|
+
contextBinding
|
|
3238
|
+
})
|
|
3161
3239
|
});
|
|
3162
3240
|
} catch (error) {
|
|
3163
|
-
runtime.error?.(`[tlon] Error handling channel firehose event: ${formatErrorMessage
|
|
3241
|
+
runtime.error?.(`[tlon] Error handling channel firehose event: ${formatErrorMessage(error)}`);
|
|
3164
3242
|
throw error;
|
|
3165
3243
|
}
|
|
3166
3244
|
};
|
|
@@ -3218,15 +3296,15 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3218
3296
|
}
|
|
3219
3297
|
return;
|
|
3220
3298
|
}
|
|
3221
|
-
const eventRecord =
|
|
3299
|
+
const eventRecord = asNullableRecord(event);
|
|
3222
3300
|
if (!eventRecord) return;
|
|
3223
3301
|
const whom = eventRecord.whom;
|
|
3224
|
-
const messageId =
|
|
3225
|
-
const response =
|
|
3302
|
+
const messageId = readStringField(eventRecord, "id");
|
|
3303
|
+
const response = asNullableRecord(eventRecord.response);
|
|
3226
3304
|
if (!messageId || !response) return;
|
|
3227
|
-
const essay =
|
|
3305
|
+
const essay = asNullableRecord(asNullableRecord(response.add)?.essay);
|
|
3228
3306
|
if (!essay) return;
|
|
3229
|
-
const authorShip = normalizeShip(
|
|
3307
|
+
const authorShip = normalizeShip(readStringField(essay, "author") ?? "");
|
|
3230
3308
|
const partnerShip = extractDmPartnerShip(whom);
|
|
3231
3309
|
const senderShip = partnerShip || authorShip;
|
|
3232
3310
|
if (authorShip === botShipName) return;
|
|
@@ -3261,12 +3339,34 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3261
3339
|
messageText: resolvedMessageText,
|
|
3262
3340
|
messageContent: essay.content,
|
|
3263
3341
|
isGroup: false,
|
|
3264
|
-
timestamp:
|
|
3265
|
-
turnAdoptionLifecycle
|
|
3342
|
+
timestamp: asFiniteNumber(essay?.sent) ?? Date.now(),
|
|
3343
|
+
turnAdoptionLifecycle,
|
|
3344
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3345
|
+
senderShip,
|
|
3346
|
+
accountId: account.accountId,
|
|
3347
|
+
conversation: {
|
|
3348
|
+
kind: "direct",
|
|
3349
|
+
id: senderShip
|
|
3350
|
+
},
|
|
3351
|
+
allowFrom: [senderShip],
|
|
3352
|
+
dmPolicy: "allowlist",
|
|
3353
|
+
contextBinding
|
|
3354
|
+
})
|
|
3266
3355
|
});
|
|
3267
3356
|
return;
|
|
3268
3357
|
}
|
|
3269
|
-
|
|
3358
|
+
const resolveChannelIngress = async (contextBinding) => await resolveTlonMessageIngress({
|
|
3359
|
+
senderShip,
|
|
3360
|
+
accountId: account.accountId,
|
|
3361
|
+
conversation: {
|
|
3362
|
+
kind: "direct",
|
|
3363
|
+
id: senderShip
|
|
3364
|
+
},
|
|
3365
|
+
allowFrom: effectiveDmAllowlist ?? [],
|
|
3366
|
+
dmPolicy: "allowlist",
|
|
3367
|
+
contextBinding
|
|
3368
|
+
});
|
|
3369
|
+
if (!(await resolveChannelIngress()).senderAccess.allowed) {
|
|
3270
3370
|
if (effectiveOwnerShip) {
|
|
3271
3371
|
const approval = createPendingApproval({
|
|
3272
3372
|
type: "dm",
|
|
@@ -3276,7 +3376,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3276
3376
|
messageId: messageId ?? "",
|
|
3277
3377
|
messageText,
|
|
3278
3378
|
messageContent: essay.content,
|
|
3279
|
-
timestamp:
|
|
3379
|
+
timestamp: asFiniteNumber(essay?.sent) ?? Date.now()
|
|
3280
3380
|
}
|
|
3281
3381
|
});
|
|
3282
3382
|
await queueApprovalRequest(approval);
|
|
@@ -3294,11 +3394,12 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3294
3394
|
senderShip,
|
|
3295
3395
|
messageContent: essay.content,
|
|
3296
3396
|
isGroup: false,
|
|
3297
|
-
timestamp:
|
|
3298
|
-
turnAdoptionLifecycle
|
|
3397
|
+
timestamp: asFiniteNumber(essay?.sent) ?? Date.now(),
|
|
3398
|
+
turnAdoptionLifecycle,
|
|
3399
|
+
resolveChannelIngress
|
|
3299
3400
|
});
|
|
3300
3401
|
} catch (error) {
|
|
3301
|
-
runtime.error?.(`[tlon] Error handling chat firehose event: ${formatErrorMessage
|
|
3402
|
+
runtime.error?.(`[tlon] Error handling chat firehose event: ${formatErrorMessage(error)}`);
|
|
3302
3403
|
throw error;
|
|
3303
3404
|
}
|
|
3304
3405
|
};
|
|
@@ -3355,11 +3456,11 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3355
3456
|
path: "/v1/news",
|
|
3356
3457
|
event: (event) => {
|
|
3357
3458
|
try {
|
|
3358
|
-
const eventRecord =
|
|
3459
|
+
const eventRecord = asNullableRecord(event);
|
|
3359
3460
|
if (eventRecord?.self) {
|
|
3360
|
-
const nickname =
|
|
3461
|
+
const nickname = asNullableRecord(asNullableRecord(asNullableRecord(eventRecord.self)?.contact)?.nickname);
|
|
3361
3462
|
if (nickname && "value" in nickname) {
|
|
3362
|
-
const newNickname =
|
|
3463
|
+
const newNickname = readStringField(nickname, "value") ?? null;
|
|
3363
3464
|
if (newNickname !== botNickname) {
|
|
3364
3465
|
botNickname = newNickname;
|
|
3365
3466
|
runtime.log?.(`[tlon] Nickname updated: ${botNickname}`);
|
|
@@ -3367,7 +3468,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3367
3468
|
}
|
|
3368
3469
|
}
|
|
3369
3470
|
} catch (error) {
|
|
3370
|
-
runtime.error?.(`[tlon] Error handling contacts event: ${formatErrorMessage
|
|
3471
|
+
runtime.error?.(`[tlon] Error handling contacts event: ${formatErrorMessage(error)}`);
|
|
3371
3472
|
}
|
|
3372
3473
|
},
|
|
3373
3474
|
err: (error) => {
|
|
@@ -3405,9 +3506,9 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3405
3506
|
event: (event) => {
|
|
3406
3507
|
(async () => {
|
|
3407
3508
|
try {
|
|
3408
|
-
const eventRecord =
|
|
3509
|
+
const eventRecord = asNullableRecord(event);
|
|
3409
3510
|
if (eventRecord) {
|
|
3410
|
-
const channels =
|
|
3511
|
+
const channels = asNullableRecord(eventRecord.channels);
|
|
3411
3512
|
if (channels) for (const [channelNest, _channelData] of Object.entries(channels)) {
|
|
3412
3513
|
if (!channelNest.startsWith("chat/")) continue;
|
|
3413
3514
|
if (!watchedChannels.has(channelNest)) {
|
|
@@ -3434,7 +3535,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3434
3535
|
}
|
|
3435
3536
|
}
|
|
3436
3537
|
}
|
|
3437
|
-
const join =
|
|
3538
|
+
const join = asNullableRecord(eventRecord.join);
|
|
3438
3539
|
if (join) {
|
|
3439
3540
|
const joinChannels = Array.isArray(join.channels) ? join.channels : [];
|
|
3440
3541
|
if (joinChannels.length > 0) for (const channelNest of joinChannels) {
|
|
@@ -3467,7 +3568,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3467
3568
|
}
|
|
3468
3569
|
}
|
|
3469
3570
|
} catch (error) {
|
|
3470
|
-
runtime.error?.(`[tlon] Error handling groups-ui event: ${formatErrorMessage
|
|
3571
|
+
runtime.error?.(`[tlon] Error handling groups-ui event: ${formatErrorMessage(error)}`);
|
|
3471
3572
|
}
|
|
3472
3573
|
})();
|
|
3473
3574
|
},
|
|
@@ -3562,7 +3663,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3562
3663
|
try {
|
|
3563
3664
|
await processPendingInvites(data);
|
|
3564
3665
|
} catch (error) {
|
|
3565
|
-
runtime.error?.(`[tlon] Error handling foreigns event: ${formatErrorMessage
|
|
3666
|
+
runtime.error?.(`[tlon] Error handling foreigns event: ${formatErrorMessage(error)}`);
|
|
3566
3667
|
}
|
|
3567
3668
|
})();
|
|
3568
3669
|
},
|
|
@@ -3599,7 +3700,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3599
3700
|
}
|
|
3600
3701
|
}
|
|
3601
3702
|
} catch (error) {
|
|
3602
|
-
runtime.error?.(`[tlon] Channel refresh error: ${formatErrorMessage
|
|
3703
|
+
runtime.error?.(`[tlon] Channel refresh error: ${formatErrorMessage(error)}`);
|
|
3603
3704
|
}
|
|
3604
3705
|
})();
|
|
3605
3706
|
}, 120 * 1e3);
|
|
@@ -3612,7 +3713,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3612
3713
|
try {
|
|
3613
3714
|
await api?.close();
|
|
3614
3715
|
} catch (error) {
|
|
3615
|
-
runtime.error?.(`[tlon] Cleanup error: ${formatErrorMessage
|
|
3716
|
+
runtime.error?.(`[tlon] Cleanup error: ${formatErrorMessage(error)}`);
|
|
3616
3717
|
}
|
|
3617
3718
|
}
|
|
3618
3719
|
}
|
|
@@ -3959,6 +4060,8 @@ async function withHttpPokeAccountApi(account, run) {
|
|
|
3959
4060
|
}
|
|
3960
4061
|
const tlonRuntimeOutbound = {
|
|
3961
4062
|
deliveryMode: "direct",
|
|
4063
|
+
chunker: chunkTextForOutbound,
|
|
4064
|
+
chunkerMode: "markdown",
|
|
3962
4065
|
textChunkLimit: 1e4,
|
|
3963
4066
|
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
3964
4067
|
deliveryCapabilities: { durableFinal: {
|
|
@@ -4050,7 +4153,6 @@ async function probeTlonAccount(account, timeoutMs) {
|
|
|
4050
4153
|
};
|
|
4051
4154
|
return { ok: true };
|
|
4052
4155
|
} finally {
|
|
4053
|
-
if (!response.bodyUsed) await response.body?.cancel().catch(() => void 0);
|
|
4054
4156
|
await release();
|
|
4055
4157
|
}
|
|
4056
4158
|
}, (error) => ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLegacyPrivateNetworkDoctorContract } from "openclaw/plugin-sdk/
|
|
1
|
+
import { createLegacyPrivateNetworkDoctorContract } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
2
2
|
//#region extensions/tlon/src/doctor-contract.ts
|
|
3
3
|
const contract = createLegacyPrivateNetworkDoctorContract({ channelKey: "tlon" });
|
|
4
4
|
const legacyConfigRules = contract.legacyConfigRules;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-
|
|
1
|
+
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-CZ8OWBXt.js";
|
|
2
2
|
export { legacyConfigRules, normalizeCompatibilityConfig };
|
package/dist/setup-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as tlonSetupAdapter } from "./setup-core-
|
|
2
|
-
import { t as tlonSetupWizard } from "./setup-surface-
|
|
1
|
+
import { a as tlonSetupAdapter } from "./setup-core-QCmS9Gmh.js";
|
|
2
|
+
import { t as tlonSetupWizard } from "./setup-surface-UgXzT7Tg.js";
|
|
3
3
|
export { tlonSetupAdapter, tlonSetupWizard };
|
|
@@ -297,6 +297,8 @@ function createTlonSetupWizardBase(params) {
|
|
|
297
297
|
inputKey: "code",
|
|
298
298
|
message: t("wizard.tlon.loginCodePrompt"),
|
|
299
299
|
placeholder: "lidlut-tabwed-pillex-ridrup",
|
|
300
|
+
sensitive: true,
|
|
301
|
+
keepPrompt: t("wizard.tlon.loginCodeKeep"),
|
|
300
302
|
currentValue: ({ cfg, accountId }) => resolveTlonAccount(cfg, accountId).code ?? void 0,
|
|
301
303
|
validate: ({ value }) => normalizeStringifiedOptionalString(value) ? void 0 : "Required",
|
|
302
304
|
normalizeValue: ({ value }) => normalizeStringifiedOptionalString(value) ?? "",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as resolveTlonAccount, i as resolveTlonSetupStatusLines, l as validateUrbitBaseUrl, n as createTlonSetupWizardBase, p as normalizeShip, r as resolveTlonSetupConfigured, s as isBlockedUrbitHostname, t as applyTlonSetupConfig } from "./setup-core-
|
|
1
|
+
import { d as resolveTlonAccount, i as resolveTlonSetupStatusLines, l as validateUrbitBaseUrl, n as createTlonSetupWizardBase, p as normalizeShip, r as resolveTlonSetupConfigured, s as isBlockedUrbitHostname, t as applyTlonSetupConfig } from "./setup-core-QCmS9Gmh.js";
|
|
2
2
|
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { createSetupTranslator } from "openclaw/plugin-sdk/setup-runtime";
|
|
4
4
|
//#region extensions/tlon/src/setup-surface.ts
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "tlon",
|
|
3
|
+
"doctorContract": {
|
|
4
|
+
"configRepair": true
|
|
5
|
+
},
|
|
3
6
|
"name": "Tlon/Urbit",
|
|
4
7
|
"description": "OpenClaw Tlon/Urbit channel plugin for chat workflows.",
|
|
5
8
|
"activation": {
|
|
@@ -28,6 +31,9 @@
|
|
|
28
31
|
"enabled": {
|
|
29
32
|
"type": "boolean"
|
|
30
33
|
},
|
|
34
|
+
"configWrites": {
|
|
35
|
+
"type": "boolean"
|
|
36
|
+
},
|
|
31
37
|
"ship": {
|
|
32
38
|
"type": "string",
|
|
33
39
|
"minLength": 1
|
|
@@ -155,6 +161,9 @@
|
|
|
155
161
|
"enabled": {
|
|
156
162
|
"type": "boolean"
|
|
157
163
|
},
|
|
164
|
+
"configWrites": {
|
|
165
|
+
"type": "boolean"
|
|
166
|
+
},
|
|
158
167
|
"ship": {
|
|
159
168
|
"type": "string",
|
|
160
169
|
"minLength": 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/tlon",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.8.1-beta.3",
|
|
4
4
|
"description": "OpenClaw Tlon/Urbit channel plugin for chat workflows.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@aws-sdk/client-s3": "3.1095.0",
|
|
12
12
|
"@aws-sdk/s3-request-presigner": "3.1095.0",
|
|
13
|
-
"@tloncorp/tlon-skill": "0.4.
|
|
13
|
+
"@tloncorp/tlon-skill": "0.4.5",
|
|
14
14
|
"@urbit/aura": "3.0.0",
|
|
15
15
|
"zod": "4.4.3"
|
|
16
16
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"openclaw": "workspace:*"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"openclaw": ">=2026.
|
|
22
|
+
"openclaw": ">=2026.8.1-beta.3"
|
|
23
23
|
},
|
|
24
24
|
"peerDependenciesMeta": {
|
|
25
25
|
"openclaw": {
|
|
@@ -120,10 +120,10 @@
|
|
|
120
120
|
"minHostVersion": ">=2026.4.10"
|
|
121
121
|
},
|
|
122
122
|
"compat": {
|
|
123
|
-
"pluginApi": ">=2026.
|
|
123
|
+
"pluginApi": ">=2026.8.1-beta.3"
|
|
124
124
|
},
|
|
125
125
|
"build": {
|
|
126
|
-
"openclawVersion": "2026.
|
|
126
|
+
"openclawVersion": "2026.8.1-beta.3"
|
|
127
127
|
},
|
|
128
128
|
"release": {
|
|
129
129
|
"bundleRuntimeDependencies": false,
|