@openclaw/tlon 2026.10.2 → 2026.10.5-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/.setup/{api-B1JbxRVg.mjs → api-CD82bZzj.mjs} +1 -1
- package/dist/.setup/{channel-1Iz9bkFT.mjs → channel-C4naQdox.mjs} +2 -2
- package/dist/.setup/{channel.runtime-BespHUPW.mjs → channel.runtime-Bbp6_R2T.mjs} +226 -255
- package/dist/.setup/{setup-core-CDShPwjB.mjs → setup-core-kO8u8noA.mjs} +5 -9
- package/dist/.setup/{setup-surface-o-30U28J.mjs → setup-surface-Byac6RoF.mjs} +1 -1
- package/dist/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/setup-api.js +2 -2
- package/dist/setup-entry.js +1 -1
- package/package.json +7 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "../runtime-api.js";
|
|
2
|
-
import { t as tlonPlugin } from "./channel-
|
|
2
|
+
import { t as tlonPlugin } from "./channel-C4naQdox.mjs";
|
|
3
3
|
import { n as setTlonRuntime } from "./runtime-Ck3lNvST.mjs";
|
|
4
4
|
import "../api.js";
|
|
5
5
|
export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-bInPRAQZ.mjs";
|
|
2
|
-
import { c as resolveTlonAccount, f as parseTlonTarget, i as tlonSetupContract, l as formatTargetHint, n as createTlonSetupWizardBase, p as resolveTlonOutboundTarget, s as listTlonAccountIds, u as normalizeShip } from "./setup-core-
|
|
2
|
+
import { c as resolveTlonAccount, f as parseTlonTarget, i as tlonSetupContract, l as formatTargetHint, n as createTlonSetupWizardBase, p as resolveTlonOutboundTarget, s as listTlonAccountIds, u as normalizeShip } from "./setup-core-kO8u8noA.mjs";
|
|
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";
|
|
@@ -94,7 +94,7 @@ function resolveTlonOutboundSessionRoute(params) {
|
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region extensions/tlon/src/channel.ts
|
|
96
96
|
const TLON_CHANNEL_ID = "tlon";
|
|
97
|
-
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-
|
|
97
|
+
const loadTlonChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime-Bbp6_R2T.mjs"));
|
|
98
98
|
const tlonSetupWizardProxy = createTlonSetupWizardBase(async (params) => await (await loadTlonChannelRuntime()).tlonSetupWizard.finalize(params));
|
|
99
99
|
const tlonConfigAdapter = createHybridChannelConfigAdapter({
|
|
100
100
|
sectionKey: TLON_CHANNEL_ID,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as __reExport, r as __exportAll } from "./doctor-contract-bInPRAQZ.mjs";
|
|
2
2
|
import { createDedupeCache, createLoggerBackedRuntime } from "../runtime-api.js";
|
|
3
|
-
import { c as resolveTlonAccount, d as parseChannelNest, f as parseTlonTarget, l as formatTargetHint, o as validateUrbitBaseUrl, u as normalizeShip } from "./setup-core-
|
|
3
|
+
import { c as resolveTlonAccount, d as parseChannelNest, f as parseTlonTarget, l as formatTargetHint, o as validateUrbitBaseUrl, u as normalizeShip } from "./setup-core-kO8u8noA.mjs";
|
|
4
4
|
import { t as getTlonRuntime } from "./runtime-Ck3lNvST.mjs";
|
|
5
|
-
import { t as tlonSetupWizard } from "./setup-surface-
|
|
5
|
+
import { t as tlonSetupWizard } from "./setup-surface-Byac6RoF.mjs";
|
|
6
6
|
import { fetchWithSsrFGuard, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
7
7
|
import { bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createMessageReceiptFromOutboundResults, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
|
|
8
8
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
@@ -11,13 +11,13 @@ import crypto, { randomBytes, randomUUID } from "node:crypto";
|
|
|
11
11
|
import { readProviderJsonResponse, readResponseTextLimited } from "openclaw/plugin-sdk/provider-http";
|
|
12
12
|
import { escapeRegExp, runChannelProbe, sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
13
13
|
import { resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import { createChannelInboundEnvelopeBuilderAsync, formatAgentEnvelope, formatInboundMediaUnavailableText, resolveEnvelopeFormatOptions } from "openclaw/plugin-sdk/channel-inbound";
|
|
15
15
|
import { collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
16
16
|
import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
|
|
17
17
|
import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
18
|
+
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
18
19
|
import { da, scot } from "@urbit/aura";
|
|
19
20
|
import { Readable } from "node:stream";
|
|
20
|
-
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
21
21
|
import { resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
|
|
22
22
|
import { MAX_IMAGE_BYTES, readRemoteMediaBuffer, saveRemoteMedia } from "openclaw/plugin-sdk/media-runtime";
|
|
23
23
|
import { resolveChannelImplicitMentions } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
@@ -65,8 +65,7 @@ function parseSettingsResponse(raw) {
|
|
|
65
65
|
}
|
|
66
66
|
function isChannelRulesObject(val) {
|
|
67
67
|
if (!val || typeof val !== "object" || Array.isArray(val)) return false;
|
|
68
|
-
|
|
69
|
-
return true;
|
|
68
|
+
return Object.values(val).every((rule) => rule && typeof rule === "object");
|
|
70
69
|
}
|
|
71
70
|
function parsePendingApprovals(value) {
|
|
72
71
|
const parsed = parseJsonSetting(value);
|
|
@@ -149,6 +148,12 @@ function createSettingsManager(api, logger) {
|
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
//#endregion
|
|
151
|
+
//#region extensions/tlon/src/urbit/redact.ts
|
|
152
|
+
const URBIT_COOKIE_REFLECTION_RE = /\burbauth-[a-z0-9~-]+=[^\s"'(),;]+/gi;
|
|
153
|
+
function redactUrbitErrorText(text) {
|
|
154
|
+
return redactToolPayloadText(text).replace(URBIT_COOKIE_REFLECTION_RE, "***");
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
152
157
|
//#region extensions/tlon/src/urbit/errors.ts
|
|
153
158
|
var UrbitError = class extends Error {
|
|
154
159
|
constructor(code, message, options) {
|
|
@@ -165,12 +170,13 @@ var UrbitUrlError = class extends UrbitError {
|
|
|
165
170
|
};
|
|
166
171
|
var UrbitHttpError = class extends UrbitError {
|
|
167
172
|
constructor(params) {
|
|
168
|
-
const
|
|
173
|
+
const bodyText = params.bodyText ? redactUrbitErrorText(params.bodyText) : void 0;
|
|
174
|
+
const suffix = bodyText ? ` - ${bodyText}` : "";
|
|
169
175
|
super("http_error", `${params.operation} failed: ${params.status}${suffix}`, { cause: params.cause });
|
|
170
176
|
this.name = "UrbitHttpError";
|
|
171
177
|
this.status = params.status;
|
|
172
178
|
this.operation = params.operation;
|
|
173
|
-
this.bodyText =
|
|
179
|
+
this.bodyText = bodyText;
|
|
174
180
|
}
|
|
175
181
|
};
|
|
176
182
|
var UrbitAuthError = class extends UrbitError {
|
|
@@ -251,6 +257,33 @@ function getUrbitContext(url, ship) {
|
|
|
251
257
|
}
|
|
252
258
|
//#endregion
|
|
253
259
|
//#region extensions/tlon/src/urbit/story.ts
|
|
260
|
+
function matchMarkdownDestination(text, image) {
|
|
261
|
+
const prefix = (image ? /^!\[([^\]]*)\]\(/ : /^\[([^\]]+)\]\(/).exec(text);
|
|
262
|
+
if (!prefix) return null;
|
|
263
|
+
const start = prefix[0].length;
|
|
264
|
+
let depth = 0;
|
|
265
|
+
for (let end = start; end < text.length; end++) if (text[end] === "\\") end++;
|
|
266
|
+
else if (text[end] === "(") depth++;
|
|
267
|
+
else if (text[end] === ")") {
|
|
268
|
+
if (depth === 0) return end > start ? [
|
|
269
|
+
text.slice(0, end + 1),
|
|
270
|
+
prefix[1],
|
|
271
|
+
text.slice(start, end)
|
|
272
|
+
] : null;
|
|
273
|
+
depth--;
|
|
274
|
+
}
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
function matchBareUrl(text) {
|
|
278
|
+
let url = /^https?:\/\/[^\s<>"\]]+/.exec(text)?.[0];
|
|
279
|
+
if (!url) return null;
|
|
280
|
+
let unbalanced = url.split(")").length - url.split("(").length;
|
|
281
|
+
while (/[.,;:!?(]$/.test(url) || url.endsWith(")") && unbalanced > 0) {
|
|
282
|
+
unbalanced += url.endsWith(")") ? -1 : url.endsWith("(") ? 1 : 0;
|
|
283
|
+
url = url.slice(0, -1);
|
|
284
|
+
}
|
|
285
|
+
return /^https?:\/\/./.test(url) ? [url, url] : null;
|
|
286
|
+
}
|
|
254
287
|
const INLINE_MARKDOWN_RULES = [
|
|
255
288
|
{
|
|
256
289
|
pattern: /^(~[a-z][-a-z0-9]*)/,
|
|
@@ -273,21 +306,21 @@ const INLINE_MARKDOWN_RULES = [
|
|
|
273
306
|
render: (match) => ({ "inline-code": expectDefined(match[1], "inline code capture") })
|
|
274
307
|
},
|
|
275
308
|
{
|
|
276
|
-
pattern:
|
|
309
|
+
pattern: (text) => matchMarkdownDestination(text, false),
|
|
277
310
|
render: (match) => ({ link: {
|
|
278
311
|
href: expectDefined(match[2], "link URL capture"),
|
|
279
312
|
content: expectDefined(match[1], "link text capture")
|
|
280
313
|
} })
|
|
281
314
|
},
|
|
282
315
|
{
|
|
283
|
-
pattern:
|
|
316
|
+
pattern: (text) => matchMarkdownDestination(text, true),
|
|
284
317
|
render: (match) => ({ imageBlock: {
|
|
285
318
|
src: expectDefined(match[2], "image URL capture"),
|
|
286
319
|
alt: expectDefined(match[1], "image alt capture")
|
|
287
320
|
} })
|
|
288
321
|
},
|
|
289
322
|
{
|
|
290
|
-
pattern:
|
|
323
|
+
pattern: matchBareUrl,
|
|
291
324
|
render: (match) => {
|
|
292
325
|
const url = expectDefined(match[1], "plain URL capture");
|
|
293
326
|
return { link: {
|
|
@@ -297,7 +330,7 @@ const INLINE_MARKDOWN_RULES = [
|
|
|
297
330
|
}
|
|
298
331
|
},
|
|
299
332
|
{
|
|
300
|
-
pattern: /^[^*_`~[#\n
|
|
333
|
+
pattern: /^(?:(?!https?:\/\/)[^*_`~[#\n!])+/,
|
|
301
334
|
render: (match) => expectDefined(match[0], "plain text match")
|
|
302
335
|
}
|
|
303
336
|
];
|
|
@@ -308,7 +341,7 @@ function parseInlineMarkdown(text) {
|
|
|
308
341
|
let consumed = 1;
|
|
309
342
|
let inline = remaining.charAt(0);
|
|
310
343
|
for (const rule of INLINE_MARKDOWN_RULES) {
|
|
311
|
-
const match = remaining.match(rule.pattern);
|
|
344
|
+
const match = typeof rule.pattern === "function" ? rule.pattern(remaining) : remaining.match(rule.pattern);
|
|
312
345
|
if (match) {
|
|
313
346
|
inline = rule.render(match);
|
|
314
347
|
consumed = match[0].length;
|
|
@@ -353,14 +386,25 @@ function isImageUrl(url) {
|
|
|
353
386
|
} catch {}
|
|
354
387
|
return imageExtensions.test(path);
|
|
355
388
|
}
|
|
389
|
+
function hoistImageBlocks(inlines, imageBlocks) {
|
|
390
|
+
const wrap = (content, make) => content.length > 0 ? [make(content)] : [];
|
|
391
|
+
return mergeAdjacentStrings(inlines.flatMap((inline) => {
|
|
392
|
+
if (typeof inline !== "object") return [inline];
|
|
393
|
+
if ("imageBlock" in inline) {
|
|
394
|
+
imageBlocks.push(createImageBlock(inline.imageBlock.src, inline.imageBlock.alt));
|
|
395
|
+
return [];
|
|
396
|
+
}
|
|
397
|
+
if ("bold" in inline) return wrap(hoistImageBlocks(inline.bold, imageBlocks), (bold) => ({ bold }));
|
|
398
|
+
if ("italics" in inline) return wrap(hoistImageBlocks(inline.italics, imageBlocks), (italics) => ({ italics }));
|
|
399
|
+
if ("strike" in inline) return wrap(hoistImageBlocks(inline.strike, imageBlocks), (strike) => ({ strike }));
|
|
400
|
+
if ("blockquote" in inline) return wrap(hoistImageBlocks(inline.blockquote, imageBlocks), (blockquote) => ({ blockquote }));
|
|
401
|
+
return [inline];
|
|
402
|
+
}));
|
|
403
|
+
}
|
|
356
404
|
function parseInlinesWithBreaks(text) {
|
|
357
405
|
const withBreaks = [];
|
|
358
406
|
const imageBlocks = [];
|
|
359
|
-
for (const inline of parseInlineMarkdown(text)) {
|
|
360
|
-
if (typeof inline === "object" && "imageBlock" in inline) {
|
|
361
|
-
imageBlocks.push(createImageBlock(inline.imageBlock.src, inline.imageBlock.alt));
|
|
362
|
-
continue;
|
|
363
|
-
}
|
|
407
|
+
for (const inline of hoistImageBlocks(parseInlineMarkdown(text), imageBlocks)) {
|
|
364
408
|
if (typeof inline !== "string" || !inline.includes("\n")) {
|
|
365
409
|
withBreaks.push(inline);
|
|
366
410
|
continue;
|
|
@@ -542,10 +586,13 @@ function markdownToStory(markdown) {
|
|
|
542
586
|
const headerMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
|
543
587
|
if (headerMatch) {
|
|
544
588
|
const tag = HEADING_TAGS[expectDefined(headerMatch[1], "header marker capture").length - 1] ?? "h6";
|
|
545
|
-
|
|
589
|
+
const imageBlocks = [];
|
|
590
|
+
const content = hoistImageBlocks(parseInlineMarkdown(expectDefined(headerMatch[2], "header body capture")), imageBlocks);
|
|
591
|
+
if (content.length > 0) story.push({ block: { header: {
|
|
546
592
|
tag,
|
|
547
|
-
content
|
|
593
|
+
content
|
|
548
594
|
} } });
|
|
595
|
+
story.push(...imageBlocks);
|
|
549
596
|
i++;
|
|
550
597
|
continue;
|
|
551
598
|
}
|
|
@@ -563,7 +610,10 @@ function markdownToStory(markdown) {
|
|
|
563
610
|
i++;
|
|
564
611
|
}
|
|
565
612
|
const quoteText = quoteLines.join("\n");
|
|
566
|
-
|
|
613
|
+
const imageBlocks = [];
|
|
614
|
+
const inline = hoistImageBlocks([{ blockquote: parseInlineMarkdown(quoteText) }], imageBlocks);
|
|
615
|
+
if (inline.length > 0) story.push({ inline });
|
|
616
|
+
story.push(...imageBlocks);
|
|
567
617
|
continue;
|
|
568
618
|
}
|
|
569
619
|
if (line.trim() === "") {
|
|
@@ -826,6 +876,7 @@ async function ensureUrbitChannelOpen(deps, params) {
|
|
|
826
876
|
//#endregion
|
|
827
877
|
//#region extensions/tlon/src/urbit/sse-client.ts
|
|
828
878
|
const MAX_SSE_PAYLOAD_BYTES = 16777216;
|
|
879
|
+
const MAX_RECONNECT_ATTEMPTS = 10;
|
|
829
880
|
function parseUrbitSsePayload(data) {
|
|
830
881
|
if (Buffer.byteLength(data, "utf8") > MAX_SSE_PAYLOAD_BYTES) throw new Error("Tlon Urbit SSE payload exceeds 16 MiB limit");
|
|
831
882
|
try {
|
|
@@ -859,10 +910,6 @@ var UrbitSSEClient = class {
|
|
|
859
910
|
this.ship = ctx.ship;
|
|
860
911
|
this.channelId = `${Math.floor(Date.now() / 1e3)}-${randomUUID()}`;
|
|
861
912
|
this.onReconnect = options.onReconnect ?? null;
|
|
862
|
-
this.autoReconnect = options.autoReconnect !== false;
|
|
863
|
-
this.maxReconnectAttempts = options.maxReconnectAttempts ?? 10;
|
|
864
|
-
this.reconnectDelay = resolveTimerTimeoutMs(options.reconnectDelay, 1e3);
|
|
865
|
-
this.maxReconnectDelay = resolveTimerTimeoutMs(options.maxReconnectDelay, 3e4);
|
|
866
913
|
this.logger = options.logger ?? {};
|
|
867
914
|
this.ssrfPolicy = options.ssrfPolicy;
|
|
868
915
|
this.lookupFn = options.lookupFn;
|
|
@@ -921,7 +968,8 @@ var UrbitSSEClient = class {
|
|
|
921
968
|
try {
|
|
922
969
|
if (!response.ok && response.status !== 204) {
|
|
923
970
|
const errorText = await readResponseTextLimited(response, 16384).catch(() => "");
|
|
924
|
-
|
|
971
|
+
const detail = errorText ? redactUrbitErrorText(errorText) : "";
|
|
972
|
+
throw new Error(`Subscribe failed: ${response.status}${detail ? ` - ${detail}` : ""}`);
|
|
925
973
|
}
|
|
926
974
|
} finally {
|
|
927
975
|
await release();
|
|
@@ -1035,7 +1083,7 @@ var UrbitSSEClient = class {
|
|
|
1035
1083
|
await release();
|
|
1036
1084
|
}
|
|
1037
1085
|
this.streamController = null;
|
|
1038
|
-
if (!this.aborted
|
|
1086
|
+
if (!this.aborted) {
|
|
1039
1087
|
this.isConnected = false;
|
|
1040
1088
|
this.logger.log?.("[SSE] Stream ended, attempting reconnection...");
|
|
1041
1089
|
await this.attemptReconnect();
|
|
@@ -1086,13 +1134,7 @@ var UrbitSSEClient = class {
|
|
|
1086
1134
|
});
|
|
1087
1135
|
}
|
|
1088
1136
|
async scry(path) {
|
|
1089
|
-
return await scryUrbitPath({
|
|
1090
|
-
baseUrl: this.url,
|
|
1091
|
-
cookie: this.cookie,
|
|
1092
|
-
ssrfPolicy: this.ssrfPolicy,
|
|
1093
|
-
lookupFn: this.lookupFn,
|
|
1094
|
-
fetchImpl: this.fetchImpl
|
|
1095
|
-
}, {
|
|
1137
|
+
return await scryUrbitPath(this.channelRequestContext(), {
|
|
1096
1138
|
path,
|
|
1097
1139
|
auditContext: "tlon-urbit-scry"
|
|
1098
1140
|
});
|
|
@@ -1119,20 +1161,20 @@ var UrbitSSEClient = class {
|
|
|
1119
1161
|
}
|
|
1120
1162
|
}
|
|
1121
1163
|
async attemptReconnect() {
|
|
1122
|
-
if (this.aborted
|
|
1164
|
+
if (this.aborted) {
|
|
1123
1165
|
this.logger.log?.("[SSE] Reconnection aborted or disabled");
|
|
1124
1166
|
return;
|
|
1125
1167
|
}
|
|
1126
|
-
if (this.reconnectAttempts >=
|
|
1127
|
-
this.logger.log?.(`[SSE] Max reconnection attempts (${
|
|
1168
|
+
if (this.reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
|
|
1169
|
+
this.logger.log?.(`[SSE] Max reconnection attempts (${MAX_RECONNECT_ATTEMPTS}) reached. Waiting 10s before resetting...`);
|
|
1128
1170
|
if (!await this.waitForReconnectDelay(1e4) || this.aborted) return;
|
|
1129
1171
|
this.reconnectAttempts = 0;
|
|
1130
1172
|
this.logger.log?.("[SSE] Reconnection attempts reset, resuming reconnection...");
|
|
1131
1173
|
}
|
|
1132
1174
|
this.reconnectAttempts += 1;
|
|
1133
|
-
const delay = Math.min(
|
|
1134
|
-
this.logger.log?.(`[SSE] Reconnection attempt ${this.reconnectAttempts}/${
|
|
1135
|
-
if (!await this.waitForReconnectDelay(delay) || this.aborted
|
|
1175
|
+
const delay = Math.min(1e3 * 2 ** (this.reconnectAttempts - 1), 3e4);
|
|
1176
|
+
this.logger.log?.(`[SSE] Reconnection attempt ${this.reconnectAttempts}/${MAX_RECONNECT_ATTEMPTS} in ${delay}ms...`);
|
|
1177
|
+
if (!await this.waitForReconnectDelay(delay) || this.aborted) return;
|
|
1136
1178
|
try {
|
|
1137
1179
|
if (this.onReconnect) await this.onReconnect(this);
|
|
1138
1180
|
try {
|
|
@@ -1291,12 +1333,12 @@ function formatPendingList(approvals) {
|
|
|
1291
1333
|
//#endregion
|
|
1292
1334
|
//#region extensions/tlon/src/monitor/approval-runtime.ts
|
|
1293
1335
|
function createTlonApprovalRuntime(params) {
|
|
1294
|
-
const { api, runtime, botShipName,
|
|
1336
|
+
const { api, runtime, botShipName, state, processApprovedMessage, refreshWatchedChannels } = params;
|
|
1295
1337
|
let approvalOverflowNoticeSent = false;
|
|
1296
1338
|
let approvalOverflowNoticeAttempts = 0;
|
|
1297
1339
|
const savePendingApprovals = async (required = false) => {
|
|
1298
1340
|
try {
|
|
1299
|
-
await putTlonSetting(api, "pendingApprovals", JSON.stringify(
|
|
1341
|
+
await putTlonSetting(api, "pendingApprovals", JSON.stringify(state.pendingApprovals));
|
|
1300
1342
|
} catch (err) {
|
|
1301
1343
|
runtime.error?.(`[tlon] Failed to save pending approvals: ${String(err)}`);
|
|
1302
1344
|
if (required) throw err;
|
|
@@ -1304,8 +1346,8 @@ function createTlonApprovalRuntime(params) {
|
|
|
1304
1346
|
};
|
|
1305
1347
|
const addToDmAllowlist = async (ship) => {
|
|
1306
1348
|
const normalizedShip = normalizeShip(ship);
|
|
1307
|
-
const nextAllowlist =
|
|
1308
|
-
|
|
1349
|
+
const nextAllowlist = state.effectiveDmAllowlist.includes(normalizedShip) ? state.effectiveDmAllowlist : [...state.effectiveDmAllowlist, normalizedShip];
|
|
1350
|
+
state.effectiveDmAllowlist = nextAllowlist;
|
|
1309
1351
|
try {
|
|
1310
1352
|
await putTlonSetting(api, "dmAllowlist", nextAllowlist);
|
|
1311
1353
|
runtime.log?.(`[tlon] Added ${normalizedShip} to dmAllowlist`);
|
|
@@ -1315,7 +1357,7 @@ function createTlonApprovalRuntime(params) {
|
|
|
1315
1357
|
};
|
|
1316
1358
|
const addToChannelAllowlist = async (ship, channelNest) => {
|
|
1317
1359
|
const normalizedShip = normalizeShip(ship);
|
|
1318
|
-
const currentSettings =
|
|
1360
|
+
const currentSettings = state.currentSettings;
|
|
1319
1361
|
const channelRules = currentSettings.channelRules ?? {};
|
|
1320
1362
|
const rule = channelRules[channelNest] ?? {
|
|
1321
1363
|
mode: "restricted",
|
|
@@ -1330,10 +1372,10 @@ function createTlonApprovalRuntime(params) {
|
|
|
1330
1372
|
allowedShips
|
|
1331
1373
|
}
|
|
1332
1374
|
};
|
|
1333
|
-
|
|
1375
|
+
state.currentSettings = {
|
|
1334
1376
|
...currentSettings,
|
|
1335
1377
|
channelRules: updatedRules
|
|
1336
|
-
}
|
|
1378
|
+
};
|
|
1337
1379
|
try {
|
|
1338
1380
|
await putTlonSetting(api, "channelRules", JSON.stringify(updatedRules));
|
|
1339
1381
|
runtime.log?.(`[tlon] Added ${normalizedShip} to ${channelNest} allowlist`);
|
|
@@ -1341,17 +1383,20 @@ function createTlonApprovalRuntime(params) {
|
|
|
1341
1383
|
runtime.error?.(`[tlon] Failed to update channelRules: ${String(err)}`);
|
|
1342
1384
|
}
|
|
1343
1385
|
};
|
|
1344
|
-
const
|
|
1386
|
+
const setShipBlocked = async (ship, blocked) => {
|
|
1345
1387
|
const normalizedShip = normalizeShip(ship);
|
|
1388
|
+
const action = blocked ? "block" : "unblock";
|
|
1346
1389
|
try {
|
|
1347
1390
|
await api.poke({
|
|
1348
1391
|
app: "chat",
|
|
1349
|
-
mark:
|
|
1392
|
+
mark: `chat-${action}-ship`,
|
|
1350
1393
|
json: { ship: normalizedShip }
|
|
1351
1394
|
});
|
|
1352
|
-
runtime.log?.(`[tlon] Blocked ship ${normalizedShip}`);
|
|
1395
|
+
runtime.log?.(`[tlon] ${blocked ? "Blocked" : "Unblocked"} ship ${normalizedShip}`);
|
|
1396
|
+
return true;
|
|
1353
1397
|
} catch (err) {
|
|
1354
|
-
runtime.error?.(`[tlon] Failed to
|
|
1398
|
+
runtime.error?.(`[tlon] Failed to ${action} ship ${normalizedShip}: ${String(err)}`);
|
|
1399
|
+
return false;
|
|
1355
1400
|
}
|
|
1356
1401
|
};
|
|
1357
1402
|
const isShipBlocked = async (ship) => {
|
|
@@ -1373,23 +1418,8 @@ function createTlonApprovalRuntime(params) {
|
|
|
1373
1418
|
return [];
|
|
1374
1419
|
}
|
|
1375
1420
|
};
|
|
1376
|
-
const unblockShip = async (ship) => {
|
|
1377
|
-
const normalizedShip = normalizeShip(ship);
|
|
1378
|
-
try {
|
|
1379
|
-
await api.poke({
|
|
1380
|
-
app: "chat",
|
|
1381
|
-
mark: "chat-unblock-ship",
|
|
1382
|
-
json: { ship: normalizedShip }
|
|
1383
|
-
});
|
|
1384
|
-
runtime.log?.(`[tlon] Unblocked ship ${normalizedShip}`);
|
|
1385
|
-
return true;
|
|
1386
|
-
} catch (err) {
|
|
1387
|
-
runtime.error?.(`[tlon] Failed to unblock ship ${normalizedShip}: ${String(err)}`);
|
|
1388
|
-
return false;
|
|
1389
|
-
}
|
|
1390
|
-
};
|
|
1391
1421
|
const sendOwnerNotification = async (message) => {
|
|
1392
|
-
const ownerShip =
|
|
1422
|
+
const ownerShip = state.effectiveOwnerShip;
|
|
1393
1423
|
if (!ownerShip) {
|
|
1394
1424
|
runtime.log?.("[tlon] No ownerShip configured, cannot send notification");
|
|
1395
1425
|
return false;
|
|
@@ -1413,7 +1443,7 @@ function createTlonApprovalRuntime(params) {
|
|
|
1413
1443
|
runtime.log?.(`[tlon] Ignoring request from blocked ship ${approval.requestingShip}`);
|
|
1414
1444
|
return false;
|
|
1415
1445
|
}
|
|
1416
|
-
const approvals =
|
|
1446
|
+
const approvals = state.pendingApprovals;
|
|
1417
1447
|
const existing = approvals.find((item) => item.type === approval.type && item.requestingShip === approval.requestingShip && (approval.type !== "channel" || item.channelNest === approval.channelNest) && (approval.type !== "group" || item.groupFlag === approval.groupFlag));
|
|
1418
1448
|
if (existing) {
|
|
1419
1449
|
if (approval.originalMessage) {
|
|
@@ -1435,7 +1465,7 @@ function createTlonApprovalRuntime(params) {
|
|
|
1435
1465
|
}
|
|
1436
1466
|
approvalOverflowNoticeSent = false;
|
|
1437
1467
|
approvalOverflowNoticeAttempts = 0;
|
|
1438
|
-
|
|
1468
|
+
state.pendingApprovals = [...approvals, approval];
|
|
1439
1469
|
await savePendingApprovals(true);
|
|
1440
1470
|
await sendOwnerNotification(formatApprovalRequest(approval));
|
|
1441
1471
|
runtime.log?.(`[tlon] Queued approval request: ${approval.id} (${approval.type} from ${approval.requestingShip})`);
|
|
@@ -1444,59 +1474,55 @@ function createTlonApprovalRuntime(params) {
|
|
|
1444
1474
|
const handleApprovalResponse = async (text) => {
|
|
1445
1475
|
const parsed = parseApprovalResponse(text);
|
|
1446
1476
|
if (!parsed) return false;
|
|
1447
|
-
const approval = findPendingApproval(
|
|
1477
|
+
const approval = findPendingApproval(state.pendingApprovals, parsed.id);
|
|
1448
1478
|
if (!approval) {
|
|
1449
1479
|
await sendOwnerNotification(`No pending approval found${parsed.id ? ` for ID: ${parsed.id}` : ""}`);
|
|
1450
1480
|
return true;
|
|
1451
1481
|
}
|
|
1452
|
-
if (parsed.action === "approve") {
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1482
|
+
if (parsed.action === "approve") switch (approval.type) {
|
|
1483
|
+
case "dm":
|
|
1484
|
+
await addToDmAllowlist(approval.requestingShip);
|
|
1485
|
+
if (approval.originalMessage) {
|
|
1486
|
+
runtime.log?.(`[tlon] Processing original message from ${approval.requestingShip} after approval`);
|
|
1487
|
+
await processApprovedMessage(approval);
|
|
1488
|
+
}
|
|
1489
|
+
break;
|
|
1490
|
+
case "channel":
|
|
1491
|
+
if (approval.channelNest) {
|
|
1492
|
+
await addToChannelAllowlist(approval.requestingShip, approval.channelNest);
|
|
1456
1493
|
if (approval.originalMessage) {
|
|
1457
|
-
runtime.log?.(`[tlon] Processing original message from ${approval.requestingShip} after approval`);
|
|
1494
|
+
runtime.log?.(`[tlon] Processing original message from ${approval.requestingShip} in ${approval.channelNest} after approval`);
|
|
1458
1495
|
await processApprovedMessage(approval);
|
|
1459
1496
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1497
|
+
}
|
|
1498
|
+
break;
|
|
1499
|
+
case "group": if (approval.groupFlag) try {
|
|
1500
|
+
await api.poke({
|
|
1501
|
+
app: "groups",
|
|
1502
|
+
mark: "group-join",
|
|
1503
|
+
json: {
|
|
1504
|
+
flag: approval.groupFlag,
|
|
1505
|
+
"join-all": true
|
|
1468
1506
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1507
|
+
});
|
|
1508
|
+
runtime.log?.(`[tlon] Joined group ${approval.groupFlag} after approval`);
|
|
1509
|
+
setTimeout(() => {
|
|
1510
|
+
(async () => {
|
|
1511
|
+
try {
|
|
1512
|
+
const newCount = await refreshWatchedChannels();
|
|
1513
|
+
if (newCount > 0) runtime.log?.(`[tlon] Discovered ${newCount} new channel(s) after joining group`);
|
|
1514
|
+
} catch (err) {
|
|
1515
|
+
runtime.log?.(`[tlon] Channel discovery after group join failed: ${String(err)}`);
|
|
1477
1516
|
}
|
|
1478
|
-
});
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
try {
|
|
1483
|
-
const newCount = await refreshWatchedChannels();
|
|
1484
|
-
if (newCount > 0) runtime.log?.(`[tlon] Discovered ${newCount} new channel(s) after joining group`);
|
|
1485
|
-
} catch (err) {
|
|
1486
|
-
runtime.log?.(`[tlon] Channel discovery after group join failed: ${String(err)}`);
|
|
1487
|
-
}
|
|
1488
|
-
})();
|
|
1489
|
-
}, 2e3);
|
|
1490
|
-
} catch (err) {
|
|
1491
|
-
runtime.error?.(`[tlon] Failed to join group ${approval.groupFlag}: ${String(err)}`);
|
|
1492
|
-
}
|
|
1517
|
+
})();
|
|
1518
|
+
}, 2e3);
|
|
1519
|
+
} catch (err) {
|
|
1520
|
+
runtime.error?.(`[tlon] Failed to join group ${approval.groupFlag}: ${String(err)}`);
|
|
1493
1521
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
} else await sendOwnerNotification(formatApprovalConfirmation(approval, "deny"));
|
|
1499
|
-
setPendingApprovals(removePendingApproval(getPendingApprovals(), approval.id));
|
|
1522
|
+
}
|
|
1523
|
+
else if (parsed.action === "block") await setShipBlocked(approval.requestingShip, true);
|
|
1524
|
+
await sendOwnerNotification(formatApprovalConfirmation(approval, parsed.action));
|
|
1525
|
+
state.pendingApprovals = removePendingApproval(state.pendingApprovals, approval.id);
|
|
1500
1526
|
await savePendingApprovals();
|
|
1501
1527
|
return true;
|
|
1502
1528
|
};
|
|
@@ -1511,8 +1537,8 @@ function createTlonApprovalRuntime(params) {
|
|
|
1511
1537
|
return true;
|
|
1512
1538
|
}
|
|
1513
1539
|
case "pending":
|
|
1514
|
-
await sendOwnerNotification(formatPendingList(
|
|
1515
|
-
runtime.log?.(`[tlon] Owner requested pending approvals list (${
|
|
1540
|
+
await sendOwnerNotification(formatPendingList(state.pendingApprovals));
|
|
1541
|
+
runtime.log?.(`[tlon] Owner requested pending approvals list (${state.pendingApprovals.length} pending)`);
|
|
1516
1542
|
return true;
|
|
1517
1543
|
case "unblock": {
|
|
1518
1544
|
const shipToUnblock = command.ship;
|
|
@@ -1520,7 +1546,7 @@ function createTlonApprovalRuntime(params) {
|
|
|
1520
1546
|
await sendOwnerNotification(`${shipToUnblock} is not blocked.`);
|
|
1521
1547
|
return true;
|
|
1522
1548
|
}
|
|
1523
|
-
const success = await
|
|
1549
|
+
const success = await setShipBlocked(shipToUnblock, false);
|
|
1524
1550
|
await sendOwnerNotification(success ? `Unblocked ${shipToUnblock}.` : `Failed to unblock ${shipToUnblock}.`);
|
|
1525
1551
|
return true;
|
|
1526
1552
|
}
|
|
@@ -1683,7 +1709,7 @@ function extractInlineText(items) {
|
|
|
1683
1709
|
return items.map((item) => renderInlineItem(item)).join("");
|
|
1684
1710
|
}
|
|
1685
1711
|
function extractMessageText(content) {
|
|
1686
|
-
if (!
|
|
1712
|
+
if (!Array.isArray(content)) return "";
|
|
1687
1713
|
return content.map((verse) => {
|
|
1688
1714
|
const verseRecord = asNullableRecord(verse);
|
|
1689
1715
|
if (!verseRecord) return "";
|
|
@@ -1701,7 +1727,7 @@ function extractMessageText(content) {
|
|
|
1701
1727
|
const codeBlock = asNullableRecord(block.code);
|
|
1702
1728
|
if (codeBlock) return `\n\`\`\`${readStringField(codeBlock, "lang") ?? ""}\n${readStringField(codeBlock, "code") ?? ""}\n\`\`\`\n`;
|
|
1703
1729
|
const header = asNullableRecord(block.header);
|
|
1704
|
-
if (header) return `\n## ${(Array.isArray(header.content) ? header.content : []).map((item) => typeof item === "string" ? item : "").join("")
|
|
1730
|
+
if (header) return `\n## ${(Array.isArray(header.content) ? header.content : []).map((item) => typeof item === "string" ? item : "").join("")}\n`;
|
|
1705
1731
|
const cite = asNullableRecord(block.cite);
|
|
1706
1732
|
if (cite) {
|
|
1707
1733
|
const chanCite = asNullableRecord(cite.chan);
|
|
@@ -1780,41 +1806,32 @@ function buildCitedPostScryPath(nest, postId) {
|
|
|
1780
1806
|
if (new URL(scryPath, CITE_PATH_NORMALIZATION_BASE).pathname !== scryPath) return null;
|
|
1781
1807
|
return scryPath;
|
|
1782
1808
|
}
|
|
1783
|
-
function
|
|
1784
|
-
|
|
1785
|
-
const
|
|
1809
|
+
async function resolveTlonCitations(content, api, runtime) {
|
|
1810
|
+
if (!Array.isArray(content)) return "";
|
|
1811
|
+
const resolved = [];
|
|
1812
|
+
for (const verse of content) {
|
|
1813
|
+
const block = asNullableRecord(asNullableRecord(verse)?.block);
|
|
1814
|
+
const chan = asNullableRecord(asNullableRecord(block?.cite)?.chan);
|
|
1815
|
+
const nest = readStringField(chan, "nest");
|
|
1816
|
+
const whereMatch = readStringField(chan, "where")?.match(/\/msg\/(~[a-z-]+)\/(.+)/);
|
|
1817
|
+
const postId = whereMatch?.[2];
|
|
1818
|
+
if (!nest || !postId) continue;
|
|
1786
1819
|
const scryPath = buildCitedPostScryPath(nest, postId);
|
|
1787
1820
|
if (!scryPath) {
|
|
1788
1821
|
runtime.log?.("[tlon] Skipping cited post: citation does not name a channel post");
|
|
1789
|
-
|
|
1822
|
+
continue;
|
|
1790
1823
|
}
|
|
1791
1824
|
try {
|
|
1792
1825
|
runtime.log?.(`[tlon] Fetching cited post: ${scryPath}`);
|
|
1793
1826
|
const data = asNullableRecord(await api.scry(scryPath));
|
|
1794
1827
|
const essay = asNullableRecord(data?.essay);
|
|
1795
|
-
|
|
1796
|
-
|
|
1828
|
+
const text = essay?.content ? extractMessageText(essay.content) : "";
|
|
1829
|
+
if (text) resolved.push(`> ${whereMatch?.[1] || "unknown"} wrote: ${text}`);
|
|
1797
1830
|
} catch (err) {
|
|
1798
1831
|
runtime.log?.(`[tlon] Failed to fetch cited post: ${String(err)}`);
|
|
1799
|
-
return null;
|
|
1800
1832
|
}
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
if (!Array.isArray(content)) return "";
|
|
1804
|
-
const resolved = [];
|
|
1805
|
-
for (const verse of content) {
|
|
1806
|
-
const block = asNullableRecord(asNullableRecord(verse)?.block);
|
|
1807
|
-
const chan = asNullableRecord(asNullableRecord(block?.cite)?.chan);
|
|
1808
|
-
const nest = readStringField(chan, "nest");
|
|
1809
|
-
const whereMatch = readStringField(chan, "where")?.match(/\/msg\/(~[a-z-]+)\/(.+)/);
|
|
1810
|
-
const postId = whereMatch?.[2];
|
|
1811
|
-
if (!nest || !postId) continue;
|
|
1812
|
-
const text = await resolveCiteContent(nest, postId);
|
|
1813
|
-
if (text) resolved.push(`> ${whereMatch?.[1] || "unknown"} wrote: ${text}`);
|
|
1814
|
-
}
|
|
1815
|
-
return resolved.length > 0 ? `${resolved.join("\n")}\n\n` : "";
|
|
1816
|
-
};
|
|
1817
|
-
return { resolveAllCites };
|
|
1833
|
+
}
|
|
1834
|
+
return resolved.length > 0 ? `${resolved.join("\n")}\n\n` : "";
|
|
1818
1835
|
}
|
|
1819
1836
|
//#endregion
|
|
1820
1837
|
//#region extensions/tlon/src/monitor/discovery.ts
|
|
@@ -1923,10 +1940,6 @@ async function fetchThreadRootAuthor(api, channelNest, parentId, runtime) {
|
|
|
1923
1940
|
return null;
|
|
1924
1941
|
}
|
|
1925
1942
|
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Fetch thread/reply history for a specific parent post.
|
|
1928
|
-
* Used to get context when entering a thread conversation.
|
|
1929
|
-
*/
|
|
1930
1943
|
async function fetchThreadHistory(api, channelNest, parentId, count = 50, runtime) {
|
|
1931
1944
|
try {
|
|
1932
1945
|
const formattedParentId = formatUd(parentId);
|
|
@@ -2127,12 +2140,8 @@ function buildTlonInboundMediaPrompt(messageText, attachments) {
|
|
|
2127
2140
|
media
|
|
2128
2141
|
};
|
|
2129
2142
|
}
|
|
2130
|
-
/**
|
|
2131
|
-
* Extract image blocks from Tlon message content.
|
|
2132
|
-
* Returns up to the download cap plus the number omitted by that cap.
|
|
2133
|
-
*/
|
|
2134
2143
|
function extractImageBlocks(content) {
|
|
2135
|
-
if (!
|
|
2144
|
+
if (!Array.isArray(content)) return {
|
|
2136
2145
|
images: [],
|
|
2137
2146
|
unavailableCount: 0
|
|
2138
2147
|
};
|
|
@@ -2143,7 +2152,7 @@ function extractImageBlocks(content) {
|
|
|
2143
2152
|
unavailableCount++;
|
|
2144
2153
|
continue;
|
|
2145
2154
|
}
|
|
2146
|
-
images.push(
|
|
2155
|
+
images.push(verse.block.image.src);
|
|
2147
2156
|
}
|
|
2148
2157
|
return {
|
|
2149
2158
|
images,
|
|
@@ -2173,16 +2182,12 @@ async function downloadMedia(url, maxBytes) {
|
|
|
2173
2182
|
return null;
|
|
2174
2183
|
}
|
|
2175
2184
|
}
|
|
2176
|
-
/**
|
|
2177
|
-
* Download all images from a message and return attachment metadata.
|
|
2178
|
-
* Format matches OpenClaw's expected attachment structure.
|
|
2179
|
-
*/
|
|
2180
2185
|
async function downloadMessageImages(content, maxBytes) {
|
|
2181
2186
|
const { images, unavailableCount: overCapCount } = extractImageBlocks(content);
|
|
2182
2187
|
const attachments = [];
|
|
2183
2188
|
let unavailableCount = overCapCount;
|
|
2184
|
-
for (const
|
|
2185
|
-
const downloaded = await downloadMedia(
|
|
2189
|
+
for (const url of images) {
|
|
2190
|
+
const downloaded = await downloadMedia(url, maxBytes);
|
|
2186
2191
|
if (downloaded) attachments.push(downloaded);
|
|
2187
2192
|
else unavailableCount++;
|
|
2188
2193
|
}
|
|
@@ -2421,15 +2426,10 @@ async function monitorTlonProvider(opts) {
|
|
|
2421
2426
|
log: (msg) => runtime.log?.(msg),
|
|
2422
2427
|
error: (msg) => runtime.error?.(msg)
|
|
2423
2428
|
});
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
let effectiveGroupInviteAllowlist = account.groupInviteAllowlist;
|
|
2429
|
-
let effectiveAutoDiscoverChannels = account.autoDiscoverChannels ?? false;
|
|
2430
|
-
let effectiveOwnerShip = account.ownerShip ? normalizeShip(account.ownerShip) : null;
|
|
2431
|
-
let pendingApprovals = [];
|
|
2432
|
-
let currentSettings = {};
|
|
2429
|
+
const settingsState = applyTlonSettingsOverrides({
|
|
2430
|
+
account,
|
|
2431
|
+
currentSettings: {}
|
|
2432
|
+
});
|
|
2433
2433
|
const participatedThreads = createParticipatedThreadTracker();
|
|
2434
2434
|
const channelHistory = createChannelHistoryCache();
|
|
2435
2435
|
const dmSendersBySession = /* @__PURE__ */ new Map();
|
|
@@ -2444,27 +2444,24 @@ async function monitorTlonProvider(opts) {
|
|
|
2444
2444
|
runtime.log?.(`[tlon] Could not fetch nickname: ${formatErrorMessage(error)}`);
|
|
2445
2445
|
}
|
|
2446
2446
|
let initForeigns = null;
|
|
2447
|
-
|
|
2448
|
-
|
|
2447
|
+
try {
|
|
2448
|
+
settingsState.currentSettings = await settingsManager.load();
|
|
2449
|
+
const migrations = buildTlonSettingsMigrations(account, settingsState.currentSettings);
|
|
2449
2450
|
for (const { key, fileValue, settingsValue } of migrations) if (shouldMigrateTlonSetting(fileValue, settingsValue)) try {
|
|
2450
2451
|
await putTlonSetting(api, key, fileValue);
|
|
2451
2452
|
runtime.log?.(`[tlon] Migrated ${key} from config to settings store`);
|
|
2452
2453
|
} catch (err) {
|
|
2453
2454
|
runtime.log?.(`[tlon] Failed to migrate ${key}: ${String(err)}`);
|
|
2454
2455
|
}
|
|
2455
|
-
|
|
2456
|
-
try {
|
|
2457
|
-
currentSettings = await settingsManager.load();
|
|
2458
|
-
await migrateConfigToSettings();
|
|
2459
|
-
({effectiveDmAllowlist, effectiveShowModelSig, effectiveAutoAcceptDmInvites, effectiveAutoAcceptGroupInvites, effectiveGroupInviteAllowlist, effectiveAutoDiscoverChannels, effectiveOwnerShip, pendingApprovals, currentSettings} = applyTlonSettingsOverrides({
|
|
2456
|
+
Object.assign(settingsState, applyTlonSettingsOverrides({
|
|
2460
2457
|
account,
|
|
2461
|
-
currentSettings,
|
|
2458
|
+
currentSettings: settingsState.currentSettings,
|
|
2462
2459
|
log: (message) => runtime.log?.(message)
|
|
2463
2460
|
}));
|
|
2464
2461
|
} catch (err) {
|
|
2465
2462
|
runtime.log?.(`[tlon] Settings store not available, using file config: ${String(err)}`);
|
|
2466
2463
|
}
|
|
2467
|
-
if (effectiveAutoDiscoverChannels) try {
|
|
2464
|
+
if (settingsState.effectiveAutoDiscoverChannels) try {
|
|
2468
2465
|
const initData = await fetchInitData(api, runtime);
|
|
2469
2466
|
if (initData.channels.length > 0) groupChannels = initData.channels;
|
|
2470
2467
|
initForeigns = initData.foreigns;
|
|
@@ -2475,12 +2472,12 @@ async function monitorTlonProvider(opts) {
|
|
|
2475
2472
|
groupChannels = mergeUniqueStrings(groupChannels, account.groupChannels);
|
|
2476
2473
|
runtime.log?.(`[tlon] Added ${account.groupChannels.length} manual groupChannels to monitoring`);
|
|
2477
2474
|
}
|
|
2478
|
-
groupChannels = mergeUniqueStrings(groupChannels, currentSettings.groupChannels);
|
|
2475
|
+
groupChannels = mergeUniqueStrings(groupChannels, settingsState.currentSettings.groupChannels);
|
|
2479
2476
|
if (groupChannels.length > 0) runtime.log?.(`[tlon] Monitoring ${groupChannels.length} group channel(s): ${groupChannels.join(", ")}`);
|
|
2480
2477
|
else runtime.log?.("[tlon] No group channels to monitor (DMs only)");
|
|
2481
2478
|
function isOwner(ship) {
|
|
2482
|
-
if (!effectiveOwnerShip) return false;
|
|
2483
|
-
return normalizeShip(ship) === effectiveOwnerShip;
|
|
2479
|
+
if (!settingsState.effectiveOwnerShip) return false;
|
|
2480
|
+
return normalizeShip(ship) === settingsState.effectiveOwnerShip;
|
|
2484
2481
|
}
|
|
2485
2482
|
const processMessage = async (params) => {
|
|
2486
2483
|
const { messageId, senderShip, isGroup, channelNest, timestamp, parentId, isThreadReply, isAdmissionAllowed, messageContent, turnAdoptionLifecycle, resolveChannelIngress } = params;
|
|
@@ -2503,16 +2500,18 @@ async function monitorTlonProvider(opts) {
|
|
|
2503
2500
|
} catch (error) {
|
|
2504
2501
|
runtime?.log?.(`[tlon] Could not fetch thread context: ${formatErrorMessage(error)}`);
|
|
2505
2502
|
}
|
|
2503
|
+
const groupTarget = isGroup && channelNest ? parseChannelNest(channelNest) : null;
|
|
2504
|
+
const groupSendContext = groupTarget && {
|
|
2505
|
+
api,
|
|
2506
|
+
fromShip: botShipName,
|
|
2507
|
+
...groupTarget
|
|
2508
|
+
};
|
|
2506
2509
|
if (isGroup && channelNest && isSummarizationRequest(messageText)) try {
|
|
2507
2510
|
const history = await channelHistory.getChannelHistory(api, channelNest, 50, runtime);
|
|
2508
2511
|
if (history.length === 0) {
|
|
2509
2512
|
const noHistoryMsg = "I couldn't fetch any messages for this channel. It might be empty or there might be a permissions issue.";
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
api,
|
|
2513
|
-
fromShip: botShipName,
|
|
2514
|
-
hostShip: parsed.hostShip,
|
|
2515
|
-
channelName: parsed.channelName,
|
|
2513
|
+
if (groupSendContext && isAdmissionAllowed?.() !== false) await sendGroupMessage({
|
|
2514
|
+
...groupSendContext,
|
|
2516
2515
|
text: noHistoryMsg
|
|
2517
2516
|
});
|
|
2518
2517
|
return;
|
|
@@ -2525,12 +2524,8 @@ async function monitorTlonProvider(opts) {
|
|
|
2525
2524
|
4. Notable participants`;
|
|
2526
2525
|
} catch (error) {
|
|
2527
2526
|
const errorMsg = `Sorry, I encountered an error while fetching the channel history: ${formatErrorMessage(error)}`;
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
api,
|
|
2531
|
-
fromShip: botShipName,
|
|
2532
|
-
hostShip: parsed.hostShip,
|
|
2533
|
-
channelName: parsed.channelName,
|
|
2527
|
+
if (groupSendContext && isAdmissionAllowed?.() !== false) await sendGroupMessage({
|
|
2528
|
+
...groupSendContext,
|
|
2534
2529
|
text: errorMsg
|
|
2535
2530
|
});
|
|
2536
2531
|
return;
|
|
@@ -2560,12 +2555,12 @@ async function monitorTlonProvider(opts) {
|
|
|
2560
2555
|
const senders = dmSendersBySession.get(sessionKey);
|
|
2561
2556
|
if (senders.size > 0 && !senders.has(senderShip)) {
|
|
2562
2557
|
runtime.log?.("[tlon] ⚠️ SECURITY: Multiple users sharing DM session. Configure \"session.dmScope: per-channel-peer\" in OpenClaw config.");
|
|
2563
|
-
if (!sharedSessionWarningSent && effectiveOwnerShip) {
|
|
2558
|
+
if (!sharedSessionWarningSent && settingsState.effectiveOwnerShip) {
|
|
2564
2559
|
sharedSessionWarningSent = true;
|
|
2565
2560
|
sendDm({
|
|
2566
2561
|
api,
|
|
2567
2562
|
fromShip: botShipName,
|
|
2568
|
-
toShip: effectiveOwnerShip,
|
|
2563
|
+
toShip: settingsState.effectiveOwnerShip,
|
|
2569
2564
|
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#dm-isolation"
|
|
2570
2565
|
}).catch((err) => runtime.error?.(`[tlon] Failed to send security warning to owner: ${formatErrorMessage(err)}`));
|
|
2571
2566
|
}
|
|
@@ -2579,15 +2574,15 @@ async function monitorTlonProvider(opts) {
|
|
|
2579
2574
|
if (shouldComputeAuth) {
|
|
2580
2575
|
commandAuthorized = (await resolveTlonCommandAuthorizationWithIngress({
|
|
2581
2576
|
senderShip,
|
|
2582
|
-
ownerShip: effectiveOwnerShip
|
|
2577
|
+
ownerShip: settingsState.effectiveOwnerShip
|
|
2583
2578
|
})).commandAccess.authorized;
|
|
2584
|
-
if (!commandAuthorized) console.log(`[tlon] Command attempt denied: ${senderShip} is not owner (owner=${effectiveOwnerShip ?? "not configured"})`);
|
|
2579
|
+
if (!commandAuthorized) console.log(`[tlon] Command attempt denied: ${senderShip} is not owner (owner=${settingsState.effectiveOwnerShip ?? "not configured"})`);
|
|
2585
2580
|
}
|
|
2586
2581
|
const promptMedia = buildTlonInboundMediaPrompt(messageText, attachments);
|
|
2587
|
-
const body =
|
|
2582
|
+
const body = (await createChannelInboundEnvelopeBuilderAsync({
|
|
2588
2583
|
cfg,
|
|
2589
2584
|
route
|
|
2590
|
-
})({
|
|
2585
|
+
}))({
|
|
2591
2586
|
channel: "Tlon",
|
|
2592
2587
|
from: fromLabel,
|
|
2593
2588
|
timestamp,
|
|
@@ -2647,7 +2642,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2647
2642
|
const deliveryTarget = isGroup ? channelNest : senderShip;
|
|
2648
2643
|
const prepareReplyPayload = (payload) => {
|
|
2649
2644
|
const replyText = payload.text;
|
|
2650
|
-
if (!replyText || !effectiveShowModelSig) return payload;
|
|
2645
|
+
if (!replyText || !settingsState.effectiveShowModelSig) return payload;
|
|
2651
2646
|
const extPayload = payload;
|
|
2652
2647
|
const defaultModel = cfg.agents?.defaults?.model;
|
|
2653
2648
|
const modelInfo = extPayload.metadata?.model || extPayload.model || (typeof defaultModel === "string" ? defaultModel : defaultModel?.primary);
|
|
@@ -2656,11 +2651,6 @@ async function monitorTlonProvider(opts) {
|
|
|
2656
2651
|
text: `${replyText}\n\n_[Generated by ${formatModelName(modelInfo)}]_`
|
|
2657
2652
|
};
|
|
2658
2653
|
};
|
|
2659
|
-
const rememberThreadParticipation = (result) => {
|
|
2660
|
-
if (!isGroup || !channelNest || !parentId || result?.visibleReplySent === false) return;
|
|
2661
|
-
participatedThreads.add(parentId);
|
|
2662
|
-
runtime.log?.(`[tlon] Now tracking thread for future replies: ${parentId}`);
|
|
2663
|
-
};
|
|
2664
2654
|
const replyOptions = {
|
|
2665
2655
|
...turnAdoptionLifecycle ? bindIngressLifecycleToReplyOptions(turnAdoptionLifecycle) : {},
|
|
2666
2656
|
...promptMedia.media.length > 0 ? { media: promptMedia.media } : {}
|
|
@@ -2688,13 +2678,9 @@ async function monitorTlonProvider(opts) {
|
|
|
2688
2678
|
const replyText = payload.text;
|
|
2689
2679
|
if (!replyText) return { visibleReplySent: false };
|
|
2690
2680
|
if (isGroup && channelNest) {
|
|
2691
|
-
|
|
2692
|
-
if (!parsed) return { visibleReplySent: false };
|
|
2681
|
+
if (!groupSendContext) return { visibleReplySent: false };
|
|
2693
2682
|
await sendGroupMessage({
|
|
2694
|
-
|
|
2695
|
-
fromShip: botShipName,
|
|
2696
|
-
hostShip: parsed.hostShip,
|
|
2697
|
-
channelName: parsed.channelName,
|
|
2683
|
+
...groupSendContext,
|
|
2698
2684
|
text: replyText,
|
|
2699
2685
|
replyToId: parentId ?? void 0
|
|
2700
2686
|
});
|
|
@@ -2712,7 +2698,10 @@ async function monitorTlonProvider(opts) {
|
|
|
2712
2698
|
return { visibleReplySent: true };
|
|
2713
2699
|
},
|
|
2714
2700
|
onDelivered: (_payload, _info, result) => {
|
|
2715
|
-
|
|
2701
|
+
if (isGroup && channelNest && parentId && result?.visibleReplySent !== false) {
|
|
2702
|
+
participatedThreads.add(parentId);
|
|
2703
|
+
runtime.log?.(`[tlon] Now tracking thread for future replies: ${parentId}`);
|
|
2704
|
+
}
|
|
2716
2705
|
},
|
|
2717
2706
|
onError: (err, info) => {
|
|
2718
2707
|
const dispatchDuration = Date.now() - dispatchStartTime;
|
|
@@ -2735,31 +2724,11 @@ async function monitorTlonProvider(opts) {
|
|
|
2735
2724
|
}
|
|
2736
2725
|
return watchedChannels.size - previousCount;
|
|
2737
2726
|
};
|
|
2738
|
-
const refreshWatchedChannels = async () => {
|
|
2739
|
-
const { channels: discoveredChannels } = await fetchInitData(api, runtime);
|
|
2740
|
-
return addWatchedChannels(discoveredChannels);
|
|
2741
|
-
};
|
|
2742
|
-
const { resolveAllCites } = createTlonCitationResolver({
|
|
2743
|
-
api,
|
|
2744
|
-
runtime
|
|
2745
|
-
});
|
|
2746
2727
|
const { queueApprovalRequest, handleApprovalResponse, handleAdminCommand } = createTlonApprovalRuntime({
|
|
2747
2728
|
api,
|
|
2748
2729
|
runtime,
|
|
2749
2730
|
botShipName,
|
|
2750
|
-
|
|
2751
|
-
setPendingApprovals: (approvals) => {
|
|
2752
|
-
pendingApprovals = approvals;
|
|
2753
|
-
},
|
|
2754
|
-
getCurrentSettings: () => currentSettings,
|
|
2755
|
-
setCurrentSettings: (settings) => {
|
|
2756
|
-
currentSettings = settings;
|
|
2757
|
-
},
|
|
2758
|
-
getEffectiveDmAllowlist: () => effectiveDmAllowlist,
|
|
2759
|
-
setEffectiveDmAllowlist: (ships) => {
|
|
2760
|
-
effectiveDmAllowlist = ships;
|
|
2761
|
-
},
|
|
2762
|
-
getEffectiveOwnerShip: () => effectiveOwnerShip,
|
|
2731
|
+
state: settingsState,
|
|
2763
2732
|
processApprovedMessage: async (approval) => {
|
|
2764
2733
|
if (!approval.originalMessage || approval.type === "group") return;
|
|
2765
2734
|
const isGroup = approval.type === "channel";
|
|
@@ -2790,7 +2759,10 @@ async function monitorTlonProvider(opts) {
|
|
|
2790
2759
|
})
|
|
2791
2760
|
});
|
|
2792
2761
|
},
|
|
2793
|
-
refreshWatchedChannels
|
|
2762
|
+
refreshWatchedChannels: async () => {
|
|
2763
|
+
const { channels: discoveredChannels } = await fetchInitData(api, runtime);
|
|
2764
|
+
return addWatchedChannels(discoveredChannels);
|
|
2765
|
+
}
|
|
2794
2766
|
});
|
|
2795
2767
|
const handleChannelsFirehose = async (event, turnAdoptionLifecycle) => {
|
|
2796
2768
|
try {
|
|
@@ -2838,12 +2810,12 @@ async function monitorTlonProvider(opts) {
|
|
|
2838
2810
|
messageSeal: isThreadReply ? asNullableRecord(replySet?.seal) : asNullableRecord(set?.seal),
|
|
2839
2811
|
isThreadReply,
|
|
2840
2812
|
hasParticipatedInThread: participatedThreads.has,
|
|
2841
|
-
getSettings: () => currentSettings,
|
|
2813
|
+
getSettings: () => settingsState.currentSettings,
|
|
2842
2814
|
runtime
|
|
2843
2815
|
});
|
|
2844
2816
|
if (mentionDecision.shouldSkip) return;
|
|
2845
2817
|
if (!senderAllowed) {
|
|
2846
|
-
if (effectiveOwnerShip) {
|
|
2818
|
+
if (settingsState.effectiveOwnerShip) {
|
|
2847
2819
|
const approval = createPendingApproval({
|
|
2848
2820
|
type: "channel",
|
|
2849
2821
|
requestingShip: senderShip,
|
|
@@ -2862,7 +2834,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2862
2834
|
} else runtime.log?.(`[tlon] Access denied: ${senderShip} in ${nest} (allowed: ${allowedShips.join(", ")})`);
|
|
2863
2835
|
return;
|
|
2864
2836
|
}
|
|
2865
|
-
const messageText = await
|
|
2837
|
+
const messageText = await resolveTlonCitations(contentBody, api, runtime) + rawText;
|
|
2866
2838
|
await processMessage({
|
|
2867
2839
|
messageId,
|
|
2868
2840
|
senderShip,
|
|
@@ -2876,7 +2848,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2876
2848
|
turnAdoptionLifecycle,
|
|
2877
2849
|
isAdmissionAllowed,
|
|
2878
2850
|
resolveChannelIngress: async (contextBinding) => {
|
|
2879
|
-
const { mode, allowedShips: currentAllowedShips } = resolveChannelAuthorization(cfg, nest, currentSettings);
|
|
2851
|
+
const { mode, allowedShips: currentAllowedShips } = resolveChannelAuthorization(cfg, nest, settingsState.currentSettings);
|
|
2880
2852
|
return await resolveTlonMessageIngress({
|
|
2881
2853
|
senderShip,
|
|
2882
2854
|
accountId: account.accountId,
|
|
@@ -2884,7 +2856,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2884
2856
|
kind: "group",
|
|
2885
2857
|
id: nest
|
|
2886
2858
|
},
|
|
2887
|
-
allowFrom: [...currentAllowedShips.map(normalizeShip), ...effectiveOwnerShip ? [normalizeShip(effectiveOwnerShip)] : []],
|
|
2859
|
+
allowFrom: [...currentAllowedShips.map(normalizeShip), ...settingsState.effectiveOwnerShip ? [normalizeShip(settingsState.effectiveOwnerShip)] : []],
|
|
2888
2860
|
groupPolicy: mode === "restricted" ? "allowlist" : "open",
|
|
2889
2861
|
contextBinding
|
|
2890
2862
|
});
|
|
@@ -2903,8 +2875,8 @@ async function monitorTlonProvider(opts) {
|
|
|
2903
2875
|
for (const ship of ships) {
|
|
2904
2876
|
if (processedDmInvites.has(ship)) continue;
|
|
2905
2877
|
const ownerInvite = isOwner(ship);
|
|
2906
|
-
const allowed = ownerInvite || await isDmAllowedWithIngress(ship, effectiveDmAllowlist);
|
|
2907
|
-
if (ownerInvite || effectiveAutoAcceptDmInvites && allowed) {
|
|
2878
|
+
const allowed = ownerInvite || await isDmAllowedWithIngress(ship, settingsState.effectiveDmAllowlist);
|
|
2879
|
+
if (ownerInvite || settingsState.effectiveAutoAcceptDmInvites && allowed) {
|
|
2908
2880
|
try {
|
|
2909
2881
|
await api.poke({
|
|
2910
2882
|
app: "chat",
|
|
@@ -2922,7 +2894,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2922
2894
|
}
|
|
2923
2895
|
continue;
|
|
2924
2896
|
}
|
|
2925
|
-
if (effectiveOwnerShip && !allowed) {
|
|
2897
|
+
if (settingsState.effectiveOwnerShip && !allowed) {
|
|
2926
2898
|
const approval = createPendingApproval({
|
|
2927
2899
|
type: "dm",
|
|
2928
2900
|
requestingShip: ship,
|
|
@@ -2966,11 +2938,11 @@ async function monitorTlonProvider(opts) {
|
|
|
2966
2938
|
kind: "direct",
|
|
2967
2939
|
id: senderShip
|
|
2968
2940
|
},
|
|
2969
|
-
allowFrom: ownerDm ? [senderShip] : effectiveDmAllowlist,
|
|
2941
|
+
allowFrom: ownerDm ? [senderShip] : settingsState.effectiveDmAllowlist,
|
|
2970
2942
|
contextBinding
|
|
2971
2943
|
});
|
|
2972
2944
|
if (!ownerDm && !(await resolveChannelIngress()).senderAccess.allowed) {
|
|
2973
|
-
if (effectiveOwnerShip) {
|
|
2945
|
+
if (settingsState.effectiveOwnerShip) {
|
|
2974
2946
|
const approval = createPendingApproval({
|
|
2975
2947
|
type: "dm",
|
|
2976
2948
|
requestingShip: senderShip,
|
|
@@ -2986,7 +2958,7 @@ async function monitorTlonProvider(opts) {
|
|
|
2986
2958
|
} else runtime.log?.(`[tlon] Blocked DM from ${senderShip}: not in allowlist`);
|
|
2987
2959
|
return;
|
|
2988
2960
|
}
|
|
2989
|
-
const resolvedMessageText = await
|
|
2961
|
+
const resolvedMessageText = await resolveTlonCitations(essay.content, api, runtime) + rawText;
|
|
2990
2962
|
if (ownerDm) runtime.log?.(`[tlon] Processing DM from owner ${senderShip}`);
|
|
2991
2963
|
await processMessage({
|
|
2992
2964
|
messageText: resolvedMessageText,
|
|
@@ -3078,9 +3050,9 @@ async function monitorTlonProvider(opts) {
|
|
|
3078
3050
|
runtime.log?.("[tlon] Subscribed to contacts updates (/v1/news)");
|
|
3079
3051
|
try {
|
|
3080
3052
|
await settingsManager.startSubscription((newSettings) => {
|
|
3081
|
-
currentSettings = newSettings;
|
|
3053
|
+
settingsState.currentSettings = newSettings;
|
|
3082
3054
|
addWatchedChannels(newSettings.groupChannels ?? [], "[tlon] Settings: now watching channel ");
|
|
3083
|
-
(
|
|
3055
|
+
Object.assign(settingsState, applyTlonSettingsOverrides({
|
|
3084
3056
|
account,
|
|
3085
3057
|
currentSettings: newSettings,
|
|
3086
3058
|
log: (message) => runtime.log?.(message)
|
|
@@ -3101,14 +3073,14 @@ async function monitorTlonProvider(opts) {
|
|
|
3101
3073
|
const joinedChannels = Array.isArray(join?.channels) ? join.channels : [];
|
|
3102
3074
|
const discoveredChannels = mergeUniqueStrings(Object.keys(asNullableRecord(eventRecord.channels) ?? {}), joinedChannels.filter((channel) => typeof channel === "string")).filter((channel) => channel.startsWith("chat/"));
|
|
3103
3075
|
addWatchedChannels(discoveredChannels, "[tlon] Auto-detected new channel: ");
|
|
3104
|
-
if (!effectiveAutoAcceptGroupInvites) return;
|
|
3105
|
-
const currentChannels = currentSettings.groupChannels ?? [];
|
|
3076
|
+
if (!settingsState.effectiveAutoAcceptGroupInvites) return;
|
|
3077
|
+
const currentChannels = settingsState.currentSettings.groupChannels ?? [];
|
|
3106
3078
|
const unpersistedChannels = discoveredChannels.filter((channel) => !currentChannels.includes(channel));
|
|
3107
3079
|
if (unpersistedChannels.length === 0) return;
|
|
3108
3080
|
const updatedChannels = mergeUniqueStrings(currentChannels, unpersistedChannels);
|
|
3109
3081
|
await putTlonSetting(api, "groupChannels", updatedChannels);
|
|
3110
|
-
currentSettings = {
|
|
3111
|
-
...currentSettings,
|
|
3082
|
+
settingsState.currentSettings = {
|
|
3083
|
+
...settingsState.currentSettings,
|
|
3112
3084
|
groupChannels: updatedChannels
|
|
3113
3085
|
};
|
|
3114
3086
|
runtime.log?.(`[tlon] Persisted ${unpersistedChannels.join(", ")} to settings store`);
|
|
@@ -3142,7 +3114,7 @@ async function monitorTlonProvider(opts) {
|
|
|
3142
3114
|
if (processedGroupInvites.has(groupFlag)) continue;
|
|
3143
3115
|
const inviterShip = validInvite.from;
|
|
3144
3116
|
const ownerInvite = isOwner(inviterShip);
|
|
3145
|
-
if (ownerInvite || effectiveAutoAcceptGroupInvites && isGroupInviteAllowed(inviterShip, effectiveGroupInviteAllowlist)) {
|
|
3117
|
+
if (ownerInvite || settingsState.effectiveAutoAcceptGroupInvites && isGroupInviteAllowed(inviterShip, settingsState.effectiveGroupInviteAllowlist)) {
|
|
3146
3118
|
try {
|
|
3147
3119
|
await api.poke({
|
|
3148
3120
|
app: "groups",
|
|
@@ -3160,7 +3132,7 @@ async function monitorTlonProvider(opts) {
|
|
|
3160
3132
|
}
|
|
3161
3133
|
continue;
|
|
3162
3134
|
}
|
|
3163
|
-
if (effectiveOwnerShip) {
|
|
3135
|
+
if (settingsState.effectiveOwnerShip) {
|
|
3164
3136
|
const approval = createPendingApproval({
|
|
3165
3137
|
type: "group",
|
|
3166
3138
|
requestingShip: inviterShip,
|
|
@@ -3169,7 +3141,7 @@ async function monitorTlonProvider(opts) {
|
|
|
3169
3141
|
if (await queueApprovalRequest(approval)) processedGroupInvites.add(groupFlag);
|
|
3170
3142
|
continue;
|
|
3171
3143
|
}
|
|
3172
|
-
if (effectiveAutoAcceptGroupInvites) {
|
|
3144
|
+
if (settingsState.effectiveAutoAcceptGroupInvites) {
|
|
3173
3145
|
runtime.log?.(`[tlon] Rejected group invite from ${inviterShip} (not in groupInviteAllowlist): ${groupFlag}`);
|
|
3174
3146
|
processedGroupInvites.add(groupFlag);
|
|
3175
3147
|
}
|
|
@@ -3205,7 +3177,7 @@ async function monitorTlonProvider(opts) {
|
|
|
3205
3177
|
runtime.log?.(`[tlon] Foreigns subscription failed: ${String(err)}`);
|
|
3206
3178
|
}
|
|
3207
3179
|
}
|
|
3208
|
-
if (effectiveAutoDiscoverChannels) {
|
|
3180
|
+
if (settingsState.effectiveAutoDiscoverChannels) {
|
|
3209
3181
|
const { channels: discoveredChannels } = await fetchInitData(api, runtime);
|
|
3210
3182
|
addWatchedChannels(discoveredChannels);
|
|
3211
3183
|
runtime.log?.(`[tlon] Watching ${watchedChannels.size} channel(s)`);
|
|
@@ -3221,7 +3193,7 @@ async function monitorTlonProvider(opts) {
|
|
|
3221
3193
|
delayMs: 12e4,
|
|
3222
3194
|
everyMs: 12e4,
|
|
3223
3195
|
run: async () => {
|
|
3224
|
-
if (!effectiveAutoDiscoverChannels) return;
|
|
3196
|
+
if (!settingsState.effectiveAutoDiscoverChannels) return;
|
|
3225
3197
|
try {
|
|
3226
3198
|
const { channels: discoveredChannels } = await fetchInitData(api, runtime);
|
|
3227
3199
|
if (discoveryScheduler.signal.aborted) return;
|
|
@@ -3534,7 +3506,7 @@ async function createHttpPokeApi(params) {
|
|
|
3534
3506
|
try {
|
|
3535
3507
|
if (!response.ok && response.status !== 204) {
|
|
3536
3508
|
const errorText = await readResponseTextLimited(response, 16384);
|
|
3537
|
-
throw new Error(`Poke failed: ${response.status} - ${errorText}`);
|
|
3509
|
+
throw new Error(`Poke failed: ${response.status} - ${redactUrbitErrorText(errorText)}`);
|
|
3538
3510
|
}
|
|
3539
3511
|
return pokeId;
|
|
3540
3512
|
} finally {
|
|
@@ -3575,7 +3547,6 @@ async function sendTlonOutbound(params, kind) {
|
|
|
3575
3547
|
uploadedUrl = mediaUrl ? await uploadImageFromUrl(mediaUrl, {
|
|
3576
3548
|
shipUrl: account.url,
|
|
3577
3549
|
shipName: account.ship,
|
|
3578
|
-
verbose: false,
|
|
3579
3550
|
getCode: async () => account.code,
|
|
3580
3551
|
dangerouslyAllowPrivateNetwork: account.dangerouslyAllowPrivateNetwork ?? void 0,
|
|
3581
3552
|
assertDirectAdapterHandoff
|
|
@@ -158,15 +158,11 @@ function validateUrbitBaseUrl(raw) {
|
|
|
158
158
|
error: "Required"
|
|
159
159
|
};
|
|
160
160
|
const candidate = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
ok: false,
|
|
167
|
-
error: "Invalid URL"
|
|
168
|
-
};
|
|
169
|
-
}
|
|
161
|
+
const parsed = URL.parse(candidate);
|
|
162
|
+
if (!parsed) return {
|
|
163
|
+
ok: false,
|
|
164
|
+
error: "Invalid URL"
|
|
165
|
+
};
|
|
170
166
|
if (!["http:", "https:"].includes(parsed.protocol)) return {
|
|
171
167
|
ok: false,
|
|
172
168
|
error: "URL must use http:// or https://"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isBlockedUrbitHostname, c as resolveTlonAccount, n as createTlonSetupWizardBase, o as validateUrbitBaseUrl, t as applyTlonSetupConfig, u as normalizeShip } from "./setup-core-
|
|
1
|
+
import { a as isBlockedUrbitHostname, c as resolveTlonAccount, n as createTlonSetupWizardBase, o as validateUrbitBaseUrl, t as applyTlonSetupConfig, u as normalizeShip } from "./setup-core-kO8u8noA.mjs";
|
|
2
2
|
import { createSetupTranslator, splitSetupEntries } from "openclaw/plugin-sdk/setup-runtime";
|
|
3
3
|
//#region extensions/tlon/src/setup-surface.ts
|
|
4
4
|
const t = createSetupTranslator();
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "./runtime-api.js";
|
|
2
|
-
import { t as tlonPlugin } from "./.setup/channel-
|
|
2
|
+
import { t as tlonPlugin } from "./.setup/channel-C4naQdox.mjs";
|
|
3
3
|
import { n as setTlonRuntime } from "./.setup/runtime-Ck3lNvST.mjs";
|
|
4
4
|
export { SsrFBlockedError, createDedupeCache, createLoggerBackedRuntime, fetchWithSsrFGuard, isBlockedHostnameOrIp, setTlonRuntime, ssrfPolicyFromDangerouslyAllowPrivateNetwork, tlonPlugin };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as tlonPlugin } from "./.setup/channel-
|
|
1
|
+
import { t as tlonPlugin } from "./.setup/channel-C4naQdox.mjs";
|
|
2
2
|
export { tlonPlugin };
|
package/dist/setup-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as tlonSetupAdapter } from "./.setup/setup-core-
|
|
2
|
-
import { t as tlonSetupWizard } from "./.setup/setup-surface-
|
|
1
|
+
import { r as tlonSetupAdapter } from "./.setup/setup-core-kO8u8noA.mjs";
|
|
2
|
+
import { t as tlonSetupWizard } from "./.setup/setup-surface-Byac6RoF.mjs";
|
|
3
3
|
export { tlonSetupAdapter, tlonSetupWizard };
|
package/dist/setup-entry.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
plugin: {
|
|
7
|
-
specifier: fileURLToPath(new URL(".setup/api-
|
|
7
|
+
specifier: fileURLToPath(new URL(".setup/api-CD82bZzj.mjs", import.meta.url).href),
|
|
8
8
|
exportName: "tlonPlugin"
|
|
9
9
|
}
|
|
10
10
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/tlon",
|
|
3
|
-
"version": "2026.10.2",
|
|
3
|
+
"version": "2026.10.5-beta.2",
|
|
4
4
|
"description": "OpenClaw Tlon/Urbit channel plugin for chat workflows.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@aws-sdk/client-s3": "3.
|
|
12
|
-
"@aws-sdk/s3-request-presigner": "3.
|
|
13
|
-
"@tloncorp/tlon-skill": "0.
|
|
11
|
+
"@aws-sdk/client-s3": "3.1146.0",
|
|
12
|
+
"@aws-sdk/s3-request-presigner": "3.1146.0",
|
|
13
|
+
"@tloncorp/tlon-skill": "0.7.0",
|
|
14
14
|
"@urbit/aura": "3.0.0",
|
|
15
15
|
"zod": "4.6.5"
|
|
16
16
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"openclaw": "workspace:*"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"openclaw": ">=2026.10.2"
|
|
22
|
+
"openclaw": ">=2026.10.5-beta.2"
|
|
23
23
|
},
|
|
24
24
|
"peerDependenciesMeta": {
|
|
25
25
|
"openclaw": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
"minHostVersion": ">=2026.4.10"
|
|
122
122
|
},
|
|
123
123
|
"compat": {
|
|
124
|
-
"pluginApi": ">=2026.10.2"
|
|
124
|
+
"pluginApi": ">=2026.10.5-beta.2"
|
|
125
125
|
},
|
|
126
126
|
"build": {
|
|
127
|
-
"openclawVersion": "2026.10.2"
|
|
127
|
+
"openclawVersion": "2026.10.5-beta.2"
|
|
128
128
|
},
|
|
129
129
|
"release": {
|
|
130
130
|
"bundleRuntimeDependencies": false,
|