@openclaw/tlon 2026.7.2-beta.7 → 2026.8.1-beta.2
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-CcNtsFWE.js} +11 -5
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-D9SOTGdH.js → channel.runtime-BrjZMX8z.js} +296 -202
- 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-CcNtsFWE.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-BrjZMX8z.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-CcNtsFWE.js";
|
|
2
2
|
export { tlonPlugin };
|
|
@@ -1,23 +1,24 @@
|
|
|
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";
|
|
14
16
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
15
17
|
import { da, scot } from "@urbit/aura";
|
|
16
18
|
import { Readable } from "node:stream";
|
|
17
19
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
18
20
|
import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
|
|
19
21
|
import { resolveChannelImplicitMentions, resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
20
|
-
import { collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
21
22
|
import { isRecord } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
22
23
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
23
24
|
import * as path from "node:path";
|
|
@@ -26,6 +27,16 @@ import { MAX_IMAGE_BYTES, readRemoteMediaBuffer, saveRemoteMedia } from "opencla
|
|
|
26
27
|
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
27
28
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
28
29
|
//#region extensions/tlon/src/settings.ts
|
|
30
|
+
/**
|
|
31
|
+
* Settings Store integration for hot-reloading Tlon plugin config.
|
|
32
|
+
*
|
|
33
|
+
* Settings are stored in Urbit's %settings agent under:
|
|
34
|
+
* desk: "moltbot"
|
|
35
|
+
* bucket: "tlon"
|
|
36
|
+
*
|
|
37
|
+
* This allows config changes via poke from any Landscape client
|
|
38
|
+
* without requiring a gateway restart.
|
|
39
|
+
*/
|
|
29
40
|
const SETTINGS_DESK = "moltbot";
|
|
30
41
|
const SETTINGS_BUCKET = "tlon";
|
|
31
42
|
/**
|
|
@@ -52,15 +63,15 @@ function parseSettingsResponse(raw) {
|
|
|
52
63
|
if (!bucket || typeof bucket !== "object") return {};
|
|
53
64
|
const settings = bucket;
|
|
54
65
|
return {
|
|
55
|
-
groupChannels: Array.isArray(settings.groupChannels) ? settings.groupChannels
|
|
56
|
-
dmAllowlist: Array.isArray(settings.dmAllowlist) ? settings.dmAllowlist
|
|
57
|
-
|
|
66
|
+
groupChannels: Array.isArray(settings.groupChannels) ? filterStringEntries(settings.groupChannels) : void 0,
|
|
67
|
+
dmAllowlist: Array.isArray(settings.dmAllowlist) ? filterStringEntries(settings.dmAllowlist) : void 0,
|
|
68
|
+
autoDiscoverChannels: typeof settings.autoDiscoverChannels === "boolean" ? settings.autoDiscoverChannels : void 0,
|
|
58
69
|
showModelSig: typeof settings.showModelSig === "boolean" ? settings.showModelSig : void 0,
|
|
59
70
|
autoAcceptDmInvites: typeof settings.autoAcceptDmInvites === "boolean" ? settings.autoAcceptDmInvites : void 0,
|
|
60
71
|
autoAcceptGroupInvites: typeof settings.autoAcceptGroupInvites === "boolean" ? settings.autoAcceptGroupInvites : void 0,
|
|
61
|
-
groupInviteAllowlist: Array.isArray(settings.groupInviteAllowlist) ? settings.groupInviteAllowlist
|
|
72
|
+
groupInviteAllowlist: Array.isArray(settings.groupInviteAllowlist) ? filterStringEntries(settings.groupInviteAllowlist) : void 0,
|
|
62
73
|
channelRules: parseChannelRules(settings.channelRules),
|
|
63
|
-
defaultAuthorizedShips: Array.isArray(settings.defaultAuthorizedShips) ? settings.defaultAuthorizedShips
|
|
74
|
+
defaultAuthorizedShips: Array.isArray(settings.defaultAuthorizedShips) ? filterStringEntries(settings.defaultAuthorizedShips) : void 0,
|
|
64
75
|
ownerShip: typeof settings.ownerShip === "string" ? settings.ownerShip : void 0,
|
|
65
76
|
pendingApprovals: parsePendingApprovals(settings.pendingApprovals)
|
|
66
77
|
};
|
|
@@ -120,13 +131,13 @@ function applySettingsUpdate(current, key, value) {
|
|
|
120
131
|
const next = { ...current };
|
|
121
132
|
switch (key) {
|
|
122
133
|
case "groupChannels":
|
|
123
|
-
next.groupChannels = Array.isArray(value) ? value
|
|
134
|
+
next.groupChannels = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
124
135
|
break;
|
|
125
136
|
case "dmAllowlist":
|
|
126
|
-
next.dmAllowlist = Array.isArray(value) ? value
|
|
137
|
+
next.dmAllowlist = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
127
138
|
break;
|
|
128
|
-
case "
|
|
129
|
-
next.
|
|
139
|
+
case "autoDiscoverChannels":
|
|
140
|
+
next.autoDiscoverChannels = typeof value === "boolean" ? value : void 0;
|
|
130
141
|
break;
|
|
131
142
|
case "showModelSig":
|
|
132
143
|
next.showModelSig = typeof value === "boolean" ? value : void 0;
|
|
@@ -138,13 +149,13 @@ function applySettingsUpdate(current, key, value) {
|
|
|
138
149
|
next.autoAcceptGroupInvites = typeof value === "boolean" ? value : void 0;
|
|
139
150
|
break;
|
|
140
151
|
case "groupInviteAllowlist":
|
|
141
|
-
next.groupInviteAllowlist = Array.isArray(value) ? value
|
|
152
|
+
next.groupInviteAllowlist = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
142
153
|
break;
|
|
143
154
|
case "channelRules":
|
|
144
155
|
next.channelRules = parseChannelRules(value);
|
|
145
156
|
break;
|
|
146
157
|
case "defaultAuthorizedShips":
|
|
147
|
-
next.defaultAuthorizedShips = Array.isArray(value) ? value
|
|
158
|
+
next.defaultAuthorizedShips = Array.isArray(value) ? filterStringEntries(value) : void 0;
|
|
148
159
|
break;
|
|
149
160
|
case "ownerShip":
|
|
150
161
|
next.ownerShip = typeof value === "string" ? value : void 0;
|
|
@@ -274,7 +285,7 @@ var UrbitAuthError = class extends UrbitError {
|
|
|
274
285
|
async function urbitFetch(params) {
|
|
275
286
|
const validated = validateUrbitBaseUrl(params.baseUrl);
|
|
276
287
|
if (!validated.ok) throw new UrbitUrlError(validated.error);
|
|
277
|
-
|
|
288
|
+
const guarded = await fetchWithSsrFGuard({
|
|
278
289
|
url: new URL(params.path, validated.baseUrl).toString(),
|
|
279
290
|
fetchImpl: params.fetchImpl,
|
|
280
291
|
init: params.init,
|
|
@@ -286,6 +297,13 @@ async function urbitFetch(params) {
|
|
|
286
297
|
auditContext: params.auditContext,
|
|
287
298
|
pinDns: params.pinDns
|
|
288
299
|
});
|
|
300
|
+
return {
|
|
301
|
+
...guarded,
|
|
302
|
+
release: async () => {
|
|
303
|
+
if (!guarded.response.bodyUsed) guarded.response.body?.cancel().catch(() => void 0);
|
|
304
|
+
await guarded.release();
|
|
305
|
+
}
|
|
306
|
+
};
|
|
289
307
|
}
|
|
290
308
|
//#endregion
|
|
291
309
|
//#region extensions/tlon/src/urbit/auth.ts
|
|
@@ -307,10 +325,7 @@ async function authenticate(url, code, options = {}) {
|
|
|
307
325
|
auditContext: "tlon-urbit-login"
|
|
308
326
|
});
|
|
309
327
|
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
|
-
}
|
|
328
|
+
if (!response.ok) throw new UrbitAuthError("auth_failed", `Login failed with status ${response.status}`);
|
|
314
329
|
await readResponseTextLimited(response, MAX_AUTH_BODY_DRAIN_BYTES).catch(() => void 0);
|
|
315
330
|
const cookie = response.headers.get("set-cookie");
|
|
316
331
|
if (!cookie) throw new UrbitAuthError("missing_cookie", "No authentication cookie received");
|
|
@@ -1311,18 +1326,14 @@ var UrbitSSEClient = class {
|
|
|
1311
1326
|
subscription: sub.id
|
|
1312
1327
|
}));
|
|
1313
1328
|
{
|
|
1314
|
-
const {
|
|
1329
|
+
const { release } = await this.putChannelPayload(unsubscribes, {
|
|
1315
1330
|
timeoutMs: 3e4,
|
|
1316
1331
|
auditContext: "tlon-urbit-unsubscribe"
|
|
1317
1332
|
});
|
|
1318
|
-
|
|
1319
|
-
response.body?.cancel().catch(() => void 0);
|
|
1320
|
-
} finally {
|
|
1321
|
-
await release();
|
|
1322
|
-
}
|
|
1333
|
+
await release();
|
|
1323
1334
|
}
|
|
1324
1335
|
{
|
|
1325
|
-
const {
|
|
1336
|
+
const { release } = await urbitFetch({
|
|
1326
1337
|
baseUrl: this.url,
|
|
1327
1338
|
path: `/~/channel/${this.channelId}`,
|
|
1328
1339
|
init: {
|
|
@@ -1335,11 +1346,7 @@ var UrbitSSEClient = class {
|
|
|
1335
1346
|
timeoutMs: 3e4,
|
|
1336
1347
|
auditContext: "tlon-urbit-channel-close"
|
|
1337
1348
|
});
|
|
1338
|
-
|
|
1339
|
-
response.body?.cancel().catch(() => void 0);
|
|
1340
|
-
} finally {
|
|
1341
|
-
await release();
|
|
1342
|
-
}
|
|
1349
|
+
await release();
|
|
1343
1350
|
}
|
|
1344
1351
|
} catch (error) {
|
|
1345
1352
|
this.logger.error?.(`Error closing channel: ${String(error)}`);
|
|
@@ -1865,19 +1872,30 @@ const tlonIngressIdentity = {
|
|
|
1865
1872
|
entryIdPrefix: "tlon-entry"
|
|
1866
1873
|
};
|
|
1867
1874
|
async function isDmAllowedWithIngress(senderShip, allowlist) {
|
|
1868
|
-
return (await
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
identity: tlonIngressIdentity,
|
|
1872
|
-
subject: { stableId: senderShip },
|
|
1875
|
+
return (await resolveTlonMessageIngress({
|
|
1876
|
+
senderShip,
|
|
1877
|
+
allowFrom: allowlist ?? [],
|
|
1873
1878
|
conversation: {
|
|
1874
1879
|
kind: "direct",
|
|
1875
1880
|
id: "direct"
|
|
1876
1881
|
},
|
|
1877
|
-
dmPolicy: "allowlist"
|
|
1878
|
-
allowFrom: allowlist ?? []
|
|
1882
|
+
dmPolicy: "allowlist"
|
|
1879
1883
|
})).senderAccess.allowed;
|
|
1880
1884
|
}
|
|
1885
|
+
async function resolveTlonMessageIngress(params) {
|
|
1886
|
+
return await resolveStableChannelMessageIngress({
|
|
1887
|
+
channelId: "tlon",
|
|
1888
|
+
accountId: params.accountId ?? "default",
|
|
1889
|
+
identity: tlonIngressIdentity,
|
|
1890
|
+
subject: { stableId: params.senderShip },
|
|
1891
|
+
conversation: params.conversation,
|
|
1892
|
+
contextBinding: params.contextBinding,
|
|
1893
|
+
dmPolicy: params.dmPolicy ?? "allowlist",
|
|
1894
|
+
groupPolicy: params.groupPolicy ?? "open",
|
|
1895
|
+
allowFrom: params.allowFrom,
|
|
1896
|
+
groupAllowFrom: params.allowFrom
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1881
1899
|
async function resolveTlonCommandAuthorizationWithIngress(params) {
|
|
1882
1900
|
const normalizedOwner = params.ownerShip ? normalizeShip(params.ownerShip) : null;
|
|
1883
1901
|
return await resolveStableChannelMessageIngress({
|
|
@@ -1937,21 +1955,11 @@ async function resolveAuthorizedMessageText(params) {
|
|
|
1937
1955
|
if (!authorizedForCites) return rawText;
|
|
1938
1956
|
return await resolveAllCites(content) + rawText;
|
|
1939
1957
|
}
|
|
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
1958
|
function renderInlineItem(item, options) {
|
|
1951
1959
|
if (typeof item === "string") return item;
|
|
1952
|
-
const record =
|
|
1960
|
+
const record = asNullableRecord(item);
|
|
1953
1961
|
if (!record) return "";
|
|
1954
|
-
const ship =
|
|
1962
|
+
const ship = readStringField(record, "ship");
|
|
1955
1963
|
if (ship) return ship;
|
|
1956
1964
|
if ("sect" in record) {
|
|
1957
1965
|
const sect = record.sect;
|
|
@@ -1959,14 +1967,14 @@ function renderInlineItem(item, options) {
|
|
|
1959
1967
|
if (sect === null) return "@all";
|
|
1960
1968
|
}
|
|
1961
1969
|
if (options?.allowBreak && "break" in record) return "\n";
|
|
1962
|
-
const inlineCode =
|
|
1970
|
+
const inlineCode = readStringField(record, "inline-code");
|
|
1963
1971
|
if (inlineCode) return `\`${inlineCode}\``;
|
|
1964
|
-
const code =
|
|
1972
|
+
const code = readStringField(record, "code");
|
|
1965
1973
|
if (code) return `\`${code}\``;
|
|
1966
|
-
const link =
|
|
1967
|
-
const linkHref = link ?
|
|
1974
|
+
const link = asNullableRecord(record.link);
|
|
1975
|
+
const linkHref = link ? readStringField(link, "href") : void 0;
|
|
1968
1976
|
if (link && linkHref) {
|
|
1969
|
-
const linkContent =
|
|
1977
|
+
const linkContent = readStringField(link, "content");
|
|
1970
1978
|
return options?.linkMode === "href" ? linkHref : linkContent || linkHref;
|
|
1971
1979
|
}
|
|
1972
1980
|
if (Array.isArray(record.bold)) return `**${extractInlineText(record.bold)}**`;
|
|
@@ -1981,50 +1989,50 @@ function extractInlineText(items) {
|
|
|
1981
1989
|
function extractMessageText(content) {
|
|
1982
1990
|
if (!content || !Array.isArray(content)) return "";
|
|
1983
1991
|
return content.map((verse) => {
|
|
1984
|
-
const verseRecord =
|
|
1992
|
+
const verseRecord = asNullableRecord(verse);
|
|
1985
1993
|
if (!verseRecord) return "";
|
|
1986
1994
|
if (Array.isArray(verseRecord.inline)) return verseRecord.inline.map((item) => renderInlineItem(item, {
|
|
1987
1995
|
linkMode: "href",
|
|
1988
1996
|
allowBreak: true,
|
|
1989
1997
|
allowBlockquote: true
|
|
1990
1998
|
})).join("");
|
|
1991
|
-
const block =
|
|
1999
|
+
const block = asNullableRecord(verseRecord.block);
|
|
1992
2000
|
if (block) {
|
|
1993
|
-
const image =
|
|
2001
|
+
const image = asNullableRecord(block.image);
|
|
1994
2002
|
if (image) {
|
|
1995
|
-
const imageSrc =
|
|
2003
|
+
const imageSrc = readStringField(image, "src");
|
|
1996
2004
|
if (imageSrc) {
|
|
1997
|
-
const altText =
|
|
2005
|
+
const altText = readStringField(image, "alt");
|
|
1998
2006
|
return `\n${imageSrc}${altText ? ` (${altText})` : ""}\n`;
|
|
1999
2007
|
}
|
|
2000
2008
|
}
|
|
2001
|
-
const codeBlock =
|
|
2002
|
-
if (codeBlock) return `\n\`\`\`${
|
|
2003
|
-
const header =
|
|
2009
|
+
const codeBlock = asNullableRecord(block.code);
|
|
2010
|
+
if (codeBlock) return `\n\`\`\`${readStringField(codeBlock, "lang") ?? ""}\n${readStringField(codeBlock, "code") ?? ""}\n\`\`\`\n`;
|
|
2011
|
+
const header = asNullableRecord(block.header);
|
|
2004
2012
|
if (header) return `\n## ${(Array.isArray(header.content) ? header.content : []).map((item) => typeof item === "string" ? item : "").join("") || ""}\n`;
|
|
2005
|
-
const cite =
|
|
2013
|
+
const cite = asNullableRecord(block.cite);
|
|
2006
2014
|
if (cite) {
|
|
2007
|
-
const chanCite =
|
|
2015
|
+
const chanCite = asNullableRecord(cite.chan);
|
|
2008
2016
|
if (chanCite) {
|
|
2009
|
-
const nest =
|
|
2010
|
-
const whereMatch =
|
|
2017
|
+
const nest = readStringField(chanCite, "nest");
|
|
2018
|
+
const whereMatch = readStringField(chanCite, "where")?.match(/\/msg\/(~[a-z-]+)\/(.+)/);
|
|
2011
2019
|
if (whereMatch) {
|
|
2012
2020
|
const [, author, _postId] = whereMatch;
|
|
2013
2021
|
return `\n> [quoted: ${author} in ${nest}]\n`;
|
|
2014
2022
|
}
|
|
2015
2023
|
return `\n> [quoted from ${nest}]\n`;
|
|
2016
2024
|
}
|
|
2017
|
-
const group =
|
|
2025
|
+
const group = readStringField(cite, "group");
|
|
2018
2026
|
if (group) return `\n> [ref: group ${group}]\n`;
|
|
2019
|
-
const desk =
|
|
2027
|
+
const desk = asNullableRecord(cite.desk);
|
|
2020
2028
|
if (desk) {
|
|
2021
|
-
const flag =
|
|
2029
|
+
const flag = readStringField(desk, "flag");
|
|
2022
2030
|
if (flag) return `\n> [ref: ${flag}]\n`;
|
|
2023
2031
|
}
|
|
2024
|
-
const bait =
|
|
2032
|
+
const bait = asNullableRecord(cite.bait);
|
|
2025
2033
|
if (bait) {
|
|
2026
|
-
const graph =
|
|
2027
|
-
const groupName =
|
|
2034
|
+
const graph = readStringField(bait, "graph");
|
|
2035
|
+
const groupName = readStringField(bait, "group");
|
|
2028
2036
|
if (graph && groupName) return `\n> [ref: ${graph} in ${groupName}]\n`;
|
|
2029
2037
|
}
|
|
2030
2038
|
return `\n> [quoted message]\n`;
|
|
@@ -2042,6 +2050,21 @@ function isSummarizationRequest(messageText) {
|
|
|
2042
2050
|
/tldr/i
|
|
2043
2051
|
].some((pattern) => pattern.test(messageText));
|
|
2044
2052
|
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Formats channel history for a summarization request. Each entry is rendered
|
|
2055
|
+
* through the shared inbound envelope so timestamps honor the configured user
|
|
2056
|
+
* timezone instead of the host process zone (matches Mattermost/Feishu).
|
|
2057
|
+
*/
|
|
2058
|
+
function formatSummarizationHistoryText(history, cfg) {
|
|
2059
|
+
const envelopeOptions = resolveEnvelopeFormatOptions(cfg);
|
|
2060
|
+
return history.map((msg) => formatAgentEnvelope({
|
|
2061
|
+
channel: "Tlon",
|
|
2062
|
+
from: msg.author,
|
|
2063
|
+
timestamp: msg.timestamp,
|
|
2064
|
+
body: msg.content,
|
|
2065
|
+
envelope: envelopeOptions
|
|
2066
|
+
})).join("\n");
|
|
2067
|
+
}
|
|
2045
2068
|
//#endregion
|
|
2046
2069
|
//#region extensions/tlon/src/monitor/cites.ts
|
|
2047
2070
|
function createTlonCitationResolver(params) {
|
|
@@ -2051,7 +2074,7 @@ function createTlonCitationResolver(params) {
|
|
|
2051
2074
|
try {
|
|
2052
2075
|
const scryPath = `/channels/v4/${cite.nest}/posts/post/${cite.postId}.json`;
|
|
2053
2076
|
runtime.log?.(`[tlon] Fetching cited post: ${scryPath}`);
|
|
2054
|
-
const essay =
|
|
2077
|
+
const essay = asNullableRecord(asNullableRecord(await api.scry(scryPath))?.essay);
|
|
2055
2078
|
if (essay?.content) return extractMessageText(essay.content) || null;
|
|
2056
2079
|
return null;
|
|
2057
2080
|
} catch (err) {
|
|
@@ -2083,18 +2106,18 @@ function createTlonCitationResolver(params) {
|
|
|
2083
2106
|
async function fetchInitData(api, runtime) {
|
|
2084
2107
|
try {
|
|
2085
2108
|
runtime.log?.("[tlon] Fetching groups-ui init data...");
|
|
2086
|
-
const initData =
|
|
2109
|
+
const initData = asNullableRecord(await api.scry("/groups-ui/v6/init.json"));
|
|
2087
2110
|
const channels = [];
|
|
2088
|
-
const groups =
|
|
2111
|
+
const groups = asNullableRecord(initData?.groups);
|
|
2089
2112
|
if (groups) for (const groupData of Object.values(groups)) {
|
|
2090
|
-
const groupChannels =
|
|
2113
|
+
const groupChannels = asNullableRecord(asNullableRecord(groupData)?.channels);
|
|
2091
2114
|
if (groupChannels) {
|
|
2092
2115
|
for (const channelNest of Object.keys(groupChannels)) if (channelNest.startsWith("chat/")) channels.push(channelNest);
|
|
2093
2116
|
}
|
|
2094
2117
|
}
|
|
2095
2118
|
if (channels.length > 0) runtime.log?.(`[tlon] Auto-discovered ${channels.length} chat channel(s)`);
|
|
2096
2119
|
else runtime.log?.("[tlon] No chat channels found via auto-discovery");
|
|
2097
|
-
const foreignsValue =
|
|
2120
|
+
const foreignsValue = asNullableRecord(initData?.foreigns);
|
|
2098
2121
|
const foreigns = foreignsValue ? foreignsValue : null;
|
|
2099
2122
|
if (foreigns) {
|
|
2100
2123
|
const pendingCount = Object.values(foreigns).filter((f) => f.invites?.some((i) => i.valid)).length;
|
|
@@ -2105,7 +2128,7 @@ async function fetchInitData(api, runtime) {
|
|
|
2105
2128
|
foreigns
|
|
2106
2129
|
};
|
|
2107
2130
|
} catch (error) {
|
|
2108
|
-
runtime.log?.(`[tlon] Init data fetch failed: ${formatErrorMessage
|
|
2131
|
+
runtime.log?.(`[tlon] Init data fetch failed: ${formatErrorMessage(error)}`);
|
|
2109
2132
|
return {
|
|
2110
2133
|
channels: [],
|
|
2111
2134
|
foreigns: null
|
|
@@ -2155,16 +2178,16 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
|
|
|
2155
2178
|
let posts = [];
|
|
2156
2179
|
if (Array.isArray(data)) posts = data;
|
|
2157
2180
|
else {
|
|
2158
|
-
const dataRecord =
|
|
2159
|
-
const postMap =
|
|
2181
|
+
const dataRecord = asNullableRecord(data);
|
|
2182
|
+
const postMap = asNullableRecord(dataRecord?.posts);
|
|
2160
2183
|
if (postMap) posts = Object.values(postMap);
|
|
2161
2184
|
else if (dataRecord) posts = Object.values(dataRecord);
|
|
2162
2185
|
}
|
|
2163
2186
|
const messages = posts.map((item) => {
|
|
2164
|
-
const itemRecord =
|
|
2165
|
-
const replyPostSet =
|
|
2166
|
-
const essay =
|
|
2167
|
-
const seal =
|
|
2187
|
+
const itemRecord = asNullableRecord(item);
|
|
2188
|
+
const replyPostSet = asNullableRecord(asNullableRecord(itemRecord?.["r-post"])?.set);
|
|
2189
|
+
const essay = asNullableRecord(itemRecord?.essay) ?? asNullableRecord(replyPostSet?.essay);
|
|
2190
|
+
const seal = asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replyPostSet?.seal);
|
|
2168
2191
|
return {
|
|
2169
2192
|
author: typeof essay?.author === "string" ? essay.author : "unknown",
|
|
2170
2193
|
content: extractMessageText(essay?.content || []),
|
|
@@ -2175,7 +2198,7 @@ async function fetchChannelHistory(api, channelNest, count = 50, runtime) {
|
|
|
2175
2198
|
runtime?.log?.(`[tlon] Extracted ${messages.length} messages from history`);
|
|
2176
2199
|
return messages;
|
|
2177
2200
|
} catch (error) {
|
|
2178
|
-
runtime?.log?.(`[tlon] Error fetching channel history: ${formatErrorMessage
|
|
2201
|
+
runtime?.log?.(`[tlon] Error fetching channel history: ${formatErrorMessage(error)}`);
|
|
2179
2202
|
return [];
|
|
2180
2203
|
}
|
|
2181
2204
|
}
|
|
@@ -2206,44 +2229,44 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
|
|
|
2206
2229
|
let replies = [];
|
|
2207
2230
|
if (Array.isArray(data)) replies = data;
|
|
2208
2231
|
else {
|
|
2209
|
-
const dataRecord =
|
|
2232
|
+
const dataRecord = asNullableRecord(data);
|
|
2210
2233
|
const replyValue = dataRecord?.replies;
|
|
2211
2234
|
if (Array.isArray(replyValue)) replies = replyValue;
|
|
2212
2235
|
else if (typeof replyValue === "object" && replyValue) replies = Object.values(replyValue);
|
|
2213
2236
|
else if (dataRecord) replies = Object.values(dataRecord);
|
|
2214
2237
|
}
|
|
2215
2238
|
const messages = replies.map((item) => {
|
|
2216
|
-
const itemRecord =
|
|
2217
|
-
const replySet =
|
|
2239
|
+
const itemRecord = asNullableRecord(item);
|
|
2240
|
+
const replySet = asNullableRecord(asNullableRecord(itemRecord?.["r-reply"])?.set);
|
|
2218
2241
|
return createHistoryEntryFromMemo({
|
|
2219
|
-
memo:
|
|
2220
|
-
seal:
|
|
2242
|
+
memo: asNullableRecord(itemRecord?.memo) ?? asNullableRecord(replySet?.memo) ?? itemRecord,
|
|
2243
|
+
seal: asNullableRecord(itemRecord?.seal) ?? asNullableRecord(replySet?.seal),
|
|
2221
2244
|
fallbackId: itemRecord?.id
|
|
2222
2245
|
});
|
|
2223
2246
|
}).filter((msg) => msg.content);
|
|
2224
2247
|
runtime?.log?.(`[tlon] Extracted ${messages.length} thread replies from history`);
|
|
2225
2248
|
return messages;
|
|
2226
2249
|
} catch (error) {
|
|
2227
|
-
runtime?.log?.(`[tlon] Error fetching thread history: ${formatErrorMessage
|
|
2250
|
+
runtime?.log?.(`[tlon] Error fetching thread history: ${formatErrorMessage(error)}`);
|
|
2228
2251
|
try {
|
|
2229
2252
|
const altPath = `/channels/v4/${channelNest}/posts/post/id/${formatUd(parentId)}.json`;
|
|
2230
2253
|
runtime?.log?.(`[tlon] Trying alternate path: ${altPath}`);
|
|
2231
|
-
const data =
|
|
2232
|
-
const dataMeta =
|
|
2254
|
+
const data = asNullableRecord(await api.scry(altPath));
|
|
2255
|
+
const dataMeta = asNullableRecord(asNullableRecord(data?.seal)?.meta);
|
|
2233
2256
|
const repliesValue = data?.replies;
|
|
2234
2257
|
if (typeof dataMeta?.replyCount === "number" && dataMeta.replyCount > 0 && repliesValue) {
|
|
2235
2258
|
const messages = (Array.isArray(repliesValue) ? repliesValue : Object.values(repliesValue)).map((reply) => {
|
|
2236
|
-
const replyRecord =
|
|
2259
|
+
const replyRecord = asNullableRecord(reply);
|
|
2237
2260
|
return createHistoryEntryFromMemo({
|
|
2238
|
-
memo:
|
|
2239
|
-
seal:
|
|
2261
|
+
memo: asNullableRecord(replyRecord?.memo),
|
|
2262
|
+
seal: asNullableRecord(replyRecord?.seal)
|
|
2240
2263
|
});
|
|
2241
2264
|
}).filter((msg) => msg.content);
|
|
2242
2265
|
runtime?.log?.(`[tlon] Extracted ${messages.length} replies from post data`);
|
|
2243
2266
|
return messages;
|
|
2244
2267
|
}
|
|
2245
2268
|
} catch (altError) {
|
|
2246
|
-
runtime?.log?.(`[tlon] Alternate path also failed: ${formatErrorMessage
|
|
2269
|
+
runtime?.log?.(`[tlon] Alternate path also failed: ${formatErrorMessage(altError)}`);
|
|
2247
2270
|
}
|
|
2248
2271
|
return [];
|
|
2249
2272
|
}
|
|
@@ -2253,12 +2276,6 @@ async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtim
|
|
|
2253
2276
|
const TLON_INGRESS_PAYLOAD_VERSION = 1;
|
|
2254
2277
|
const TLON_INGRESS_POLL_INTERVAL_MS = 1e3;
|
|
2255
2278
|
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
2279
|
function inspectChannelsEvent(event) {
|
|
2263
2280
|
const envelope = isRecord(event) ? event : null;
|
|
2264
2281
|
const nest = normalizeNullableString(envelope?.nest);
|
|
@@ -2360,7 +2377,7 @@ function createTlonIngressMonitor(options) {
|
|
|
2360
2377
|
onLog: (message) => options.runtime.log?.(`tlon ${message}`)
|
|
2361
2378
|
},
|
|
2362
2379
|
...options.abortSignal ? { abortSignal: options.abortSignal } : {},
|
|
2363
|
-
createStoppedError: () => new
|
|
2380
|
+
createStoppedError: () => /* @__PURE__ */ new Error("Tlon ingress stopped before dispatch adoption."),
|
|
2364
2381
|
onError: (error) => options.runtime.error?.(`tlon ingress drain failed: ${formatErrorMessage(error)}`)
|
|
2365
2382
|
});
|
|
2366
2383
|
return {
|
|
@@ -2398,19 +2415,26 @@ function buildTlonInboundMediaPrompt(messageText, attachments) {
|
|
|
2398
2415
|
}
|
|
2399
2416
|
/**
|
|
2400
2417
|
* Extract image blocks from Tlon message content.
|
|
2401
|
-
* Returns
|
|
2418
|
+
* Returns up to the download cap plus the number omitted by that cap.
|
|
2402
2419
|
*/
|
|
2403
2420
|
function extractImageBlocks(content) {
|
|
2404
|
-
if (!content || !Array.isArray(content)) return
|
|
2421
|
+
if (!content || !Array.isArray(content)) return {
|
|
2422
|
+
images: [],
|
|
2423
|
+
unavailableCount: 0
|
|
2424
|
+
};
|
|
2405
2425
|
const images = [];
|
|
2426
|
+
let unavailableCount = 0;
|
|
2406
2427
|
for (const verse of content) if (verse?.block?.image?.src) {
|
|
2407
|
-
images.
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2428
|
+
if (images.length >= MAX_IMAGES_PER_MESSAGE) {
|
|
2429
|
+
unavailableCount++;
|
|
2430
|
+
continue;
|
|
2431
|
+
}
|
|
2432
|
+
images.push({ url: verse.block.image.src });
|
|
2412
2433
|
}
|
|
2413
|
-
return
|
|
2434
|
+
return {
|
|
2435
|
+
images,
|
|
2436
|
+
unavailableCount
|
|
2437
|
+
};
|
|
2414
2438
|
}
|
|
2415
2439
|
/**
|
|
2416
2440
|
* Download a media file from URL to local storage.
|
|
@@ -2434,8 +2458,7 @@ async function downloadMedia(url, mediaDir) {
|
|
|
2434
2458
|
const saved = await saveRemoteMedia(fetchOptions);
|
|
2435
2459
|
return {
|
|
2436
2460
|
localPath: saved.path,
|
|
2437
|
-
contentType: saved.contentType ?? "application/octet-stream"
|
|
2438
|
-
originalUrl: url
|
|
2461
|
+
contentType: saved.contentType ?? "application/octet-stream"
|
|
2439
2462
|
};
|
|
2440
2463
|
}
|
|
2441
2464
|
const fetched = await readRemoteMediaBuffer(fetchOptions);
|
|
@@ -2445,8 +2468,7 @@ async function downloadMedia(url, mediaDir) {
|
|
|
2445
2468
|
await writeFile(localPath, fetched.buffer);
|
|
2446
2469
|
return {
|
|
2447
2470
|
localPath,
|
|
2448
|
-
contentType: fetched.contentType ?? "application/octet-stream"
|
|
2449
|
-
originalUrl: url
|
|
2471
|
+
contentType: fetched.contentType ?? "application/octet-stream"
|
|
2450
2472
|
};
|
|
2451
2473
|
} catch (error) {
|
|
2452
2474
|
console.error(`[tlon-media] Error downloading ${url}: ${formatErrorMessage(error)}`);
|
|
@@ -2473,17 +2495,21 @@ function getExtensionFromUrl(url) {
|
|
|
2473
2495
|
* Format matches OpenClaw's expected attachment structure.
|
|
2474
2496
|
*/
|
|
2475
2497
|
async function downloadMessageImages(content, mediaDir) {
|
|
2476
|
-
const images = extractImageBlocks(content);
|
|
2477
|
-
if (images.length === 0) return [];
|
|
2498
|
+
const { images, unavailableCount: overCapCount } = extractImageBlocks(content);
|
|
2478
2499
|
const attachments = [];
|
|
2500
|
+
let unavailableCount = overCapCount;
|
|
2479
2501
|
for (const image of images) {
|
|
2480
2502
|
const downloaded = await downloadMedia(image.url, mediaDir);
|
|
2481
2503
|
if (downloaded) attachments.push({
|
|
2482
2504
|
path: downloaded.localPath,
|
|
2483
2505
|
contentType: downloaded.contentType
|
|
2484
2506
|
});
|
|
2507
|
+
else unavailableCount++;
|
|
2485
2508
|
}
|
|
2486
|
-
return
|
|
2509
|
+
return {
|
|
2510
|
+
attachments,
|
|
2511
|
+
unavailableCount
|
|
2512
|
+
};
|
|
2487
2513
|
}
|
|
2488
2514
|
//#endregion
|
|
2489
2515
|
//#region extensions/tlon/src/monitor/settings-helpers.ts
|
|
@@ -2621,9 +2647,6 @@ function createActiveSnapshotTracker() {
|
|
|
2621
2647
|
}
|
|
2622
2648
|
//#endregion
|
|
2623
2649
|
//#region extensions/tlon/src/monitor/index.ts
|
|
2624
|
-
function readNumber(record, key) {
|
|
2625
|
-
return asFiniteNumber(record?.[key]);
|
|
2626
|
-
}
|
|
2627
2650
|
async function monitorTlonProvider(opts = {}) {
|
|
2628
2651
|
const core = getTlonRuntime();
|
|
2629
2652
|
const cfg = core.config.current();
|
|
@@ -2645,7 +2668,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2645
2668
|
runtime.log?.(`[tlon] Attempting authentication to ${accountUrl}...`);
|
|
2646
2669
|
return await authenticate(accountUrl, accountCode, { ssrfPolicy });
|
|
2647
2670
|
} catch (error) {
|
|
2648
|
-
runtime.error?.(`[tlon] Failed to authenticate (attempt ${attempt}): ${formatErrorMessage
|
|
2671
|
+
runtime.error?.(`[tlon] Failed to authenticate (attempt ${attempt}): ${formatErrorMessage(error)}`);
|
|
2649
2672
|
if (attempt >= maxAttempts) throw error;
|
|
2650
2673
|
const delay = Math.min(3e4, 1e3 * 2 ** (attempt - 1));
|
|
2651
2674
|
runtime.log?.(`[tlon] Retrying authentication in ${delay}ms...`);
|
|
@@ -2695,7 +2718,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2695
2718
|
if (botNickname) runtime.log?.(`[tlon] Bot nickname: ${botNickname}`);
|
|
2696
2719
|
}
|
|
2697
2720
|
} catch (error) {
|
|
2698
|
-
runtime.log?.(`[tlon] Could not fetch nickname: ${formatErrorMessage
|
|
2721
|
+
runtime.log?.(`[tlon] Could not fetch nickname: ${formatErrorMessage(error)}`);
|
|
2699
2722
|
}
|
|
2700
2723
|
let initForeigns = null;
|
|
2701
2724
|
async function migrateConfigToSettings() {
|
|
@@ -2732,7 +2755,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2732
2755
|
if (initData.channels.length > 0) groupChannels = initData.channels;
|
|
2733
2756
|
initForeigns = initData.foreigns;
|
|
2734
2757
|
} catch (error) {
|
|
2735
|
-
runtime.error?.(`[tlon] Auto-discovery failed: ${formatErrorMessage
|
|
2758
|
+
runtime.error?.(`[tlon] Auto-discovery failed: ${formatErrorMessage(error)}`);
|
|
2736
2759
|
}
|
|
2737
2760
|
if (account.groupChannels.length > 0) {
|
|
2738
2761
|
groupChannels = mergeUniqueStrings(groupChannels, account.groupChannels);
|
|
@@ -2755,15 +2778,16 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2755
2778
|
return /^~?[a-z-]+$/i.test(normalized) ? normalized : "";
|
|
2756
2779
|
}
|
|
2757
2780
|
const processMessage = async (params) => {
|
|
2758
|
-
const { messageId, senderShip, isGroup, channelNest, hostShip: _hostShip, channelName: _channelName, timestamp, parentId, isThreadReply, messageContent, turnAdoptionLifecycle } = params;
|
|
2781
|
+
const { messageId, senderShip, isGroup, channelNest, hostShip: _hostShip, channelName: _channelName, timestamp, parentId, isThreadReply, messageContent, turnAdoptionLifecycle, resolveChannelIngress } = params;
|
|
2759
2782
|
const groupChannel = channelNest;
|
|
2760
2783
|
let messageText = params.messageText;
|
|
2761
2784
|
let attachments = [];
|
|
2785
|
+
let unavailableMediaCount = 0;
|
|
2762
2786
|
if (messageContent) try {
|
|
2763
|
-
attachments = await downloadMessageImages(messageContent);
|
|
2787
|
+
({attachments, unavailableCount: unavailableMediaCount} = await downloadMessageImages(messageContent));
|
|
2764
2788
|
if (attachments.length > 0) runtime.log?.(`[tlon] Downloaded ${attachments.length} image(s) from message`);
|
|
2765
2789
|
} catch (error) {
|
|
2766
|
-
runtime.log?.(`[tlon] Failed to download images: ${formatErrorMessage
|
|
2790
|
+
runtime.log?.(`[tlon] Failed to download images: ${formatErrorMessage(error)}`);
|
|
2767
2791
|
}
|
|
2768
2792
|
if (isThreadReply && parentId && groupChannel) try {
|
|
2769
2793
|
const threadHistory = await fetchThreadHistory(api, groupChannel, parentId, 20, runtime);
|
|
@@ -2773,7 +2797,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2773
2797
|
runtime?.log?.(`[tlon] Added thread context (${threadHistory.length} replies) to message`);
|
|
2774
2798
|
}
|
|
2775
2799
|
} catch (error) {
|
|
2776
|
-
runtime?.log?.(`[tlon] Could not fetch thread context: ${formatErrorMessage
|
|
2800
|
+
runtime?.log?.(`[tlon] Could not fetch thread context: ${formatErrorMessage(error)}`);
|
|
2777
2801
|
}
|
|
2778
2802
|
if (isGroup && groupChannel && isSummarizationRequest(messageText)) try {
|
|
2779
2803
|
const history = await getChannelHistory(api, groupChannel, 50, runtime);
|
|
@@ -2796,14 +2820,14 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2796
2820
|
});
|
|
2797
2821
|
return;
|
|
2798
2822
|
}
|
|
2799
|
-
const historyText = history
|
|
2823
|
+
const historyText = formatSummarizationHistoryText(history, cfg);
|
|
2800
2824
|
messageText = `Please summarize this channel conversation (${history.length} recent messages):\n\n${historyText}\n\nProvide a concise summary highlighting:
|
|
2801
2825
|
1. Main topics discussed
|
|
2802
2826
|
2. Key decisions or conclusions
|
|
2803
2827
|
3. Action items if any
|
|
2804
2828
|
4. Notable participants`;
|
|
2805
2829
|
} catch (error) {
|
|
2806
|
-
const errorMsg = `Sorry, I encountered an error while fetching the channel history: ${formatErrorMessage
|
|
2830
|
+
const errorMsg = `Sorry, I encountered an error while fetching the channel history: ${formatErrorMessage(error)}`;
|
|
2807
2831
|
if (isGroup && groupChannel) {
|
|
2808
2832
|
const parsed = parseChannelNest(groupChannel);
|
|
2809
2833
|
if (parsed) await sendGroupMessage({
|
|
@@ -2830,6 +2854,16 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2830
2854
|
id: isGroup ? groupChannel ?? senderShip : senderShip
|
|
2831
2855
|
}
|
|
2832
2856
|
});
|
|
2857
|
+
const channelIngress = await resolveChannelIngress({
|
|
2858
|
+
agentId: route.agentId,
|
|
2859
|
+
sessionKey: route.sessionKey,
|
|
2860
|
+
messageId,
|
|
2861
|
+
inboundEventKind: "user_request"
|
|
2862
|
+
});
|
|
2863
|
+
if (!channelIngress.senderAccess.allowed) {
|
|
2864
|
+
runtime.log?.(`[tlon] Authorization changed before dispatch for ${senderShip}`);
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2833
2867
|
if (!isGroup) {
|
|
2834
2868
|
const sessionKey = route.sessionKey;
|
|
2835
2869
|
if (!dmSendersBySession.has(sessionKey)) dmSendersBySession.set(sessionKey, /* @__PURE__ */ new Set());
|
|
@@ -2843,7 +2877,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2843
2877
|
fromShip: botShipName,
|
|
2844
2878
|
toShip: effectiveOwnerShip,
|
|
2845
2879
|
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
|
|
2880
|
+
}).catch((err) => runtime.error?.(`[tlon] Failed to send security warning to owner: ${formatErrorMessage(err)}`));
|
|
2847
2881
|
}
|
|
2848
2882
|
}
|
|
2849
2883
|
senders.add(senderShip);
|
|
@@ -2871,6 +2905,10 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2871
2905
|
body: promptMedia.body
|
|
2872
2906
|
});
|
|
2873
2907
|
const commandBody = isGroup ? stripBotMention(messageText, botShipName) : messageText;
|
|
2908
|
+
const bodyForAgent = unavailableMediaCount > 0 ? formatInboundMediaUnavailableText({
|
|
2909
|
+
body: commandBody,
|
|
2910
|
+
notice: `[tlon ${unavailableMediaCount > 1 ? `${unavailableMediaCount} attachments` : "attachment"} unavailable]`
|
|
2911
|
+
}) : commandBody;
|
|
2874
2912
|
const tlonConversationId = isGroup ? groupChannel ?? channelNest ?? senderShip : senderShip;
|
|
2875
2913
|
const ctxPayload = core.channel.inbound.buildContext({
|
|
2876
2914
|
channel: "tlon",
|
|
@@ -2901,10 +2939,11 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
2901
2939
|
},
|
|
2902
2940
|
message: {
|
|
2903
2941
|
body,
|
|
2904
|
-
bodyForAgent
|
|
2942
|
+
bodyForAgent,
|
|
2905
2943
|
rawBody: messageText,
|
|
2906
2944
|
commandBody
|
|
2907
2945
|
},
|
|
2946
|
+
channelIngress,
|
|
2908
2947
|
extra: {
|
|
2909
2948
|
GroupSubject: void 0,
|
|
2910
2949
|
SenderRole: senderRole,
|
|
@@ -3044,7 +3083,18 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3044
3083
|
messageText: approval.originalMessage.messageText,
|
|
3045
3084
|
messageContent: approval.originalMessage.messageContent,
|
|
3046
3085
|
isGroup: false,
|
|
3047
|
-
timestamp: approval.originalMessage.timestamp
|
|
3086
|
+
timestamp: approval.originalMessage.timestamp,
|
|
3087
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3088
|
+
senderShip: approval.requestingShip,
|
|
3089
|
+
accountId: account.accountId,
|
|
3090
|
+
conversation: {
|
|
3091
|
+
kind: "direct",
|
|
3092
|
+
id: approval.requestingShip
|
|
3093
|
+
},
|
|
3094
|
+
allowFrom: [approval.requestingShip],
|
|
3095
|
+
dmPolicy: "allowlist",
|
|
3096
|
+
contextBinding
|
|
3097
|
+
})
|
|
3048
3098
|
});
|
|
3049
3099
|
return;
|
|
3050
3100
|
}
|
|
@@ -3061,7 +3111,18 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3061
3111
|
channelName: parsedChannel?.channelName,
|
|
3062
3112
|
timestamp: approval.originalMessage.timestamp,
|
|
3063
3113
|
parentId: approval.originalMessage.parentId,
|
|
3064
|
-
isThreadReply: approval.originalMessage.isThreadReply
|
|
3114
|
+
isThreadReply: approval.originalMessage.isThreadReply,
|
|
3115
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3116
|
+
senderShip: approval.requestingShip,
|
|
3117
|
+
accountId: account.accountId,
|
|
3118
|
+
conversation: {
|
|
3119
|
+
kind: "group",
|
|
3120
|
+
id: approval.channelNest
|
|
3121
|
+
},
|
|
3122
|
+
allowFrom: [approval.requestingShip],
|
|
3123
|
+
groupPolicy: "allowlist",
|
|
3124
|
+
contextBinding
|
|
3125
|
+
})
|
|
3065
3126
|
});
|
|
3066
3127
|
}
|
|
3067
3128
|
},
|
|
@@ -3069,39 +3130,39 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3069
3130
|
});
|
|
3070
3131
|
const handleChannelsFirehose = async (event, turnAdoptionLifecycle) => {
|
|
3071
3132
|
try {
|
|
3072
|
-
const eventRecord =
|
|
3073
|
-
const nest =
|
|
3133
|
+
const eventRecord = asNullableRecord(event);
|
|
3134
|
+
const nest = readStringField(eventRecord, "nest");
|
|
3074
3135
|
if (!nest) return;
|
|
3075
3136
|
if (!watchedChannels.has(nest)) return;
|
|
3076
|
-
const response =
|
|
3137
|
+
const response = asNullableRecord(eventRecord?.response);
|
|
3077
3138
|
if (!response) return;
|
|
3078
|
-
const post =
|
|
3079
|
-
const rPost =
|
|
3080
|
-
const set =
|
|
3081
|
-
const reply =
|
|
3082
|
-
const replySet =
|
|
3083
|
-
const essay =
|
|
3084
|
-
const memo =
|
|
3139
|
+
const post = asNullableRecord(response.post);
|
|
3140
|
+
const rPost = asNullableRecord(post?.["r-post"]);
|
|
3141
|
+
const set = asNullableRecord(rPost?.set);
|
|
3142
|
+
const reply = asNullableRecord(rPost?.reply);
|
|
3143
|
+
const replySet = asNullableRecord(asNullableRecord(reply?.["r-reply"])?.set);
|
|
3144
|
+
const essay = asNullableRecord(set?.essay);
|
|
3145
|
+
const memo = asNullableRecord(replySet?.memo);
|
|
3085
3146
|
if (!essay && !memo) return;
|
|
3086
3147
|
const content = memo ?? essay;
|
|
3087
3148
|
if (!content) return;
|
|
3088
3149
|
const isThreadReply = Boolean(memo);
|
|
3089
|
-
const messageId = isThreadReply ?
|
|
3150
|
+
const messageId = isThreadReply ? readStringField(reply, "id") : readStringField(post, "id");
|
|
3090
3151
|
if (!messageId) return;
|
|
3091
|
-
const senderShip = normalizeShip(
|
|
3152
|
+
const senderShip = normalizeShip(readStringField(content, "author") ?? "");
|
|
3092
3153
|
if (!senderShip || senderShip === botShipName) return;
|
|
3093
3154
|
const rawText = extractMessageText(content.content);
|
|
3094
3155
|
if (!rawText.trim()) return;
|
|
3095
3156
|
const contentBody = content.content;
|
|
3096
|
-
const sentAt =
|
|
3157
|
+
const sentAt = asFiniteNumber(content?.sent) ?? Date.now();
|
|
3097
3158
|
cacheMessage(nest, {
|
|
3098
3159
|
author: senderShip,
|
|
3099
3160
|
content: rawText,
|
|
3100
3161
|
timestamp: sentAt,
|
|
3101
3162
|
id: messageId
|
|
3102
3163
|
});
|
|
3103
|
-
const seal = isThreadReply ?
|
|
3104
|
-
const parentId =
|
|
3164
|
+
const seal = isThreadReply ? asNullableRecord(replySet?.seal) : asNullableRecord(set?.seal);
|
|
3165
|
+
const parentId = readStringField(seal, "parent-id") ?? readStringField(seal, "parent") ?? null;
|
|
3105
3166
|
const mentioned = isBotMentioned(rawText, botShipName, botNickname ?? void 0);
|
|
3106
3167
|
const inParticipatedThread = isThreadReply && parentId && participatedThreads.has(parentId);
|
|
3107
3168
|
const mentionDecision = resolveTlonGroupMentionDecision({
|
|
@@ -3112,30 +3173,28 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3112
3173
|
});
|
|
3113
3174
|
if (mentionDecision.shouldSkip) return;
|
|
3114
3175
|
if (mentionDecision.implicitMention && !mentioned) runtime.log?.(`[tlon] Responding to thread we participated in (no mention): ${parentId}`);
|
|
3176
|
+
const { mode, allowedShips } = resolveChannelAuthorization(cfg, nest, currentSettings);
|
|
3115
3177
|
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
|
-
}
|
|
3178
|
+
else if (mode === "restricted") {
|
|
3179
|
+
if (!allowedShips.map(normalizeShip).includes(senderShip)) {
|
|
3180
|
+
if (effectiveOwnerShip) {
|
|
3181
|
+
const approval = createPendingApproval({
|
|
3182
|
+
type: "channel",
|
|
3183
|
+
requestingShip: senderShip,
|
|
3184
|
+
channelNest: nest,
|
|
3185
|
+
messagePreview: sliceUtf16Safe(rawText, 0, 100),
|
|
3186
|
+
originalMessage: {
|
|
3187
|
+
messageId: messageId ?? "",
|
|
3188
|
+
messageText: rawText,
|
|
3189
|
+
messageContent: contentBody,
|
|
3190
|
+
timestamp: sentAt,
|
|
3191
|
+
parentId: parentId ?? void 0,
|
|
3192
|
+
isThreadReply
|
|
3193
|
+
}
|
|
3194
|
+
});
|
|
3195
|
+
await queueApprovalRequest(approval);
|
|
3196
|
+
} else runtime.log?.(`[tlon] Access denied: ${senderShip} in ${nest} (allowed: ${allowedShips.join(", ")})`);
|
|
3197
|
+
return;
|
|
3139
3198
|
}
|
|
3140
3199
|
}
|
|
3141
3200
|
const messageText = await resolveAuthorizedMessageText({
|
|
@@ -3157,10 +3216,21 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3157
3216
|
timestamp: sentAt,
|
|
3158
3217
|
parentId,
|
|
3159
3218
|
isThreadReply,
|
|
3160
|
-
turnAdoptionLifecycle
|
|
3219
|
+
turnAdoptionLifecycle,
|
|
3220
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3221
|
+
senderShip,
|
|
3222
|
+
accountId: account.accountId,
|
|
3223
|
+
conversation: {
|
|
3224
|
+
kind: "group",
|
|
3225
|
+
id: nest
|
|
3226
|
+
},
|
|
3227
|
+
allowFrom: [...allowedShips.map(normalizeShip), ...effectiveOwnerShip ? [normalizeShip(effectiveOwnerShip)] : []],
|
|
3228
|
+
groupPolicy: mode === "restricted" ? "allowlist" : "open",
|
|
3229
|
+
contextBinding
|
|
3230
|
+
})
|
|
3161
3231
|
});
|
|
3162
3232
|
} catch (error) {
|
|
3163
|
-
runtime.error?.(`[tlon] Error handling channel firehose event: ${formatErrorMessage
|
|
3233
|
+
runtime.error?.(`[tlon] Error handling channel firehose event: ${formatErrorMessage(error)}`);
|
|
3164
3234
|
throw error;
|
|
3165
3235
|
}
|
|
3166
3236
|
};
|
|
@@ -3218,15 +3288,15 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3218
3288
|
}
|
|
3219
3289
|
return;
|
|
3220
3290
|
}
|
|
3221
|
-
const eventRecord =
|
|
3291
|
+
const eventRecord = asNullableRecord(event);
|
|
3222
3292
|
if (!eventRecord) return;
|
|
3223
3293
|
const whom = eventRecord.whom;
|
|
3224
|
-
const messageId =
|
|
3225
|
-
const response =
|
|
3294
|
+
const messageId = readStringField(eventRecord, "id");
|
|
3295
|
+
const response = asNullableRecord(eventRecord.response);
|
|
3226
3296
|
if (!messageId || !response) return;
|
|
3227
|
-
const essay =
|
|
3297
|
+
const essay = asNullableRecord(asNullableRecord(response.add)?.essay);
|
|
3228
3298
|
if (!essay) return;
|
|
3229
|
-
const authorShip = normalizeShip(
|
|
3299
|
+
const authorShip = normalizeShip(readStringField(essay, "author") ?? "");
|
|
3230
3300
|
const partnerShip = extractDmPartnerShip(whom);
|
|
3231
3301
|
const senderShip = partnerShip || authorShip;
|
|
3232
3302
|
if (authorShip === botShipName) return;
|
|
@@ -3261,12 +3331,34 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3261
3331
|
messageText: resolvedMessageText,
|
|
3262
3332
|
messageContent: essay.content,
|
|
3263
3333
|
isGroup: false,
|
|
3264
|
-
timestamp:
|
|
3265
|
-
turnAdoptionLifecycle
|
|
3334
|
+
timestamp: asFiniteNumber(essay?.sent) ?? Date.now(),
|
|
3335
|
+
turnAdoptionLifecycle,
|
|
3336
|
+
resolveChannelIngress: async (contextBinding) => await resolveTlonMessageIngress({
|
|
3337
|
+
senderShip,
|
|
3338
|
+
accountId: account.accountId,
|
|
3339
|
+
conversation: {
|
|
3340
|
+
kind: "direct",
|
|
3341
|
+
id: senderShip
|
|
3342
|
+
},
|
|
3343
|
+
allowFrom: [senderShip],
|
|
3344
|
+
dmPolicy: "allowlist",
|
|
3345
|
+
contextBinding
|
|
3346
|
+
})
|
|
3266
3347
|
});
|
|
3267
3348
|
return;
|
|
3268
3349
|
}
|
|
3269
|
-
|
|
3350
|
+
const resolveChannelIngress = async (contextBinding) => await resolveTlonMessageIngress({
|
|
3351
|
+
senderShip,
|
|
3352
|
+
accountId: account.accountId,
|
|
3353
|
+
conversation: {
|
|
3354
|
+
kind: "direct",
|
|
3355
|
+
id: senderShip
|
|
3356
|
+
},
|
|
3357
|
+
allowFrom: effectiveDmAllowlist ?? [],
|
|
3358
|
+
dmPolicy: "allowlist",
|
|
3359
|
+
contextBinding
|
|
3360
|
+
});
|
|
3361
|
+
if (!(await resolveChannelIngress()).senderAccess.allowed) {
|
|
3270
3362
|
if (effectiveOwnerShip) {
|
|
3271
3363
|
const approval = createPendingApproval({
|
|
3272
3364
|
type: "dm",
|
|
@@ -3276,7 +3368,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3276
3368
|
messageId: messageId ?? "",
|
|
3277
3369
|
messageText,
|
|
3278
3370
|
messageContent: essay.content,
|
|
3279
|
-
timestamp:
|
|
3371
|
+
timestamp: asFiniteNumber(essay?.sent) ?? Date.now()
|
|
3280
3372
|
}
|
|
3281
3373
|
});
|
|
3282
3374
|
await queueApprovalRequest(approval);
|
|
@@ -3294,11 +3386,12 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3294
3386
|
senderShip,
|
|
3295
3387
|
messageContent: essay.content,
|
|
3296
3388
|
isGroup: false,
|
|
3297
|
-
timestamp:
|
|
3298
|
-
turnAdoptionLifecycle
|
|
3389
|
+
timestamp: asFiniteNumber(essay?.sent) ?? Date.now(),
|
|
3390
|
+
turnAdoptionLifecycle,
|
|
3391
|
+
resolveChannelIngress
|
|
3299
3392
|
});
|
|
3300
3393
|
} catch (error) {
|
|
3301
|
-
runtime.error?.(`[tlon] Error handling chat firehose event: ${formatErrorMessage
|
|
3394
|
+
runtime.error?.(`[tlon] Error handling chat firehose event: ${formatErrorMessage(error)}`);
|
|
3302
3395
|
throw error;
|
|
3303
3396
|
}
|
|
3304
3397
|
};
|
|
@@ -3355,11 +3448,11 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3355
3448
|
path: "/v1/news",
|
|
3356
3449
|
event: (event) => {
|
|
3357
3450
|
try {
|
|
3358
|
-
const eventRecord =
|
|
3451
|
+
const eventRecord = asNullableRecord(event);
|
|
3359
3452
|
if (eventRecord?.self) {
|
|
3360
|
-
const nickname =
|
|
3453
|
+
const nickname = asNullableRecord(asNullableRecord(asNullableRecord(eventRecord.self)?.contact)?.nickname);
|
|
3361
3454
|
if (nickname && "value" in nickname) {
|
|
3362
|
-
const newNickname =
|
|
3455
|
+
const newNickname = readStringField(nickname, "value") ?? null;
|
|
3363
3456
|
if (newNickname !== botNickname) {
|
|
3364
3457
|
botNickname = newNickname;
|
|
3365
3458
|
runtime.log?.(`[tlon] Nickname updated: ${botNickname}`);
|
|
@@ -3367,7 +3460,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3367
3460
|
}
|
|
3368
3461
|
}
|
|
3369
3462
|
} catch (error) {
|
|
3370
|
-
runtime.error?.(`[tlon] Error handling contacts event: ${formatErrorMessage
|
|
3463
|
+
runtime.error?.(`[tlon] Error handling contacts event: ${formatErrorMessage(error)}`);
|
|
3371
3464
|
}
|
|
3372
3465
|
},
|
|
3373
3466
|
err: (error) => {
|
|
@@ -3405,9 +3498,9 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3405
3498
|
event: (event) => {
|
|
3406
3499
|
(async () => {
|
|
3407
3500
|
try {
|
|
3408
|
-
const eventRecord =
|
|
3501
|
+
const eventRecord = asNullableRecord(event);
|
|
3409
3502
|
if (eventRecord) {
|
|
3410
|
-
const channels =
|
|
3503
|
+
const channels = asNullableRecord(eventRecord.channels);
|
|
3411
3504
|
if (channels) for (const [channelNest, _channelData] of Object.entries(channels)) {
|
|
3412
3505
|
if (!channelNest.startsWith("chat/")) continue;
|
|
3413
3506
|
if (!watchedChannels.has(channelNest)) {
|
|
@@ -3434,7 +3527,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3434
3527
|
}
|
|
3435
3528
|
}
|
|
3436
3529
|
}
|
|
3437
|
-
const join =
|
|
3530
|
+
const join = asNullableRecord(eventRecord.join);
|
|
3438
3531
|
if (join) {
|
|
3439
3532
|
const joinChannels = Array.isArray(join.channels) ? join.channels : [];
|
|
3440
3533
|
if (joinChannels.length > 0) for (const channelNest of joinChannels) {
|
|
@@ -3467,7 +3560,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3467
3560
|
}
|
|
3468
3561
|
}
|
|
3469
3562
|
} catch (error) {
|
|
3470
|
-
runtime.error?.(`[tlon] Error handling groups-ui event: ${formatErrorMessage
|
|
3563
|
+
runtime.error?.(`[tlon] Error handling groups-ui event: ${formatErrorMessage(error)}`);
|
|
3471
3564
|
}
|
|
3472
3565
|
})();
|
|
3473
3566
|
},
|
|
@@ -3562,7 +3655,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3562
3655
|
try {
|
|
3563
3656
|
await processPendingInvites(data);
|
|
3564
3657
|
} catch (error) {
|
|
3565
|
-
runtime.error?.(`[tlon] Error handling foreigns event: ${formatErrorMessage
|
|
3658
|
+
runtime.error?.(`[tlon] Error handling foreigns event: ${formatErrorMessage(error)}`);
|
|
3566
3659
|
}
|
|
3567
3660
|
})();
|
|
3568
3661
|
},
|
|
@@ -3599,7 +3692,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3599
3692
|
}
|
|
3600
3693
|
}
|
|
3601
3694
|
} catch (error) {
|
|
3602
|
-
runtime.error?.(`[tlon] Channel refresh error: ${formatErrorMessage
|
|
3695
|
+
runtime.error?.(`[tlon] Channel refresh error: ${formatErrorMessage(error)}`);
|
|
3603
3696
|
}
|
|
3604
3697
|
})();
|
|
3605
3698
|
}, 120 * 1e3);
|
|
@@ -3612,7 +3705,7 @@ async function monitorTlonProvider(opts = {}) {
|
|
|
3612
3705
|
try {
|
|
3613
3706
|
await api?.close();
|
|
3614
3707
|
} catch (error) {
|
|
3615
|
-
runtime.error?.(`[tlon] Cleanup error: ${formatErrorMessage
|
|
3708
|
+
runtime.error?.(`[tlon] Cleanup error: ${formatErrorMessage(error)}`);
|
|
3616
3709
|
}
|
|
3617
3710
|
}
|
|
3618
3711
|
}
|
|
@@ -3959,6 +4052,8 @@ async function withHttpPokeAccountApi(account, run) {
|
|
|
3959
4052
|
}
|
|
3960
4053
|
const tlonRuntimeOutbound = {
|
|
3961
4054
|
deliveryMode: "direct",
|
|
4055
|
+
chunker: chunkTextForOutbound,
|
|
4056
|
+
chunkerMode: "markdown",
|
|
3962
4057
|
textChunkLimit: 1e4,
|
|
3963
4058
|
resolveTarget: ({ to }) => resolveTlonOutboundTarget(to),
|
|
3964
4059
|
deliveryCapabilities: { durableFinal: {
|
|
@@ -4050,7 +4145,6 @@ async function probeTlonAccount(account, timeoutMs) {
|
|
|
4050
4145
|
};
|
|
4051
4146
|
return { ok: true };
|
|
4052
4147
|
} finally {
|
|
4053
|
-
if (!response.bodyUsed) await response.body?.cancel().catch(() => void 0);
|
|
4054
4148
|
await release();
|
|
4055
4149
|
}
|
|
4056
4150
|
}, (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.2",
|
|
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.2"
|
|
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.2"
|
|
124
124
|
},
|
|
125
125
|
"build": {
|
|
126
|
-
"openclawVersion": "2026.
|
|
126
|
+
"openclawVersion": "2026.8.1-beta.2"
|
|
127
127
|
},
|
|
128
128
|
"release": {
|
|
129
129
|
"bundleRuntimeDependencies": false,
|