@openclaw/imessage 2026.8.1-beta.3 → 2026.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accounts-D00Njxg2.js → accounts-CCirBEIm.js} +4 -5
- package/dist/{actions.runtime-B_xJiBXF.js → actions.runtime-CAl3WcqD.js} +2 -3
- package/dist/api.js +6 -5
- package/dist/{approval-handler.runtime-BKku8aUf.js → approval-handler.runtime-UBd1j2Sg.js} +7 -7
- package/dist/{approval-reactions-BME5eA6T.js → approval-reactions-LL5yn1Rc.js} +5 -9
- package/dist/{channel-BFQTpvrG.js → channel-DNI9DKGN.js} +17 -16
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-BjkXwX9_.js → channel.runtime-HSkrmWfW.js} +58 -11
- package/dist/{config-schema-DV0KP5nC.js → config-schema-DuGbA8Kp.js} +8 -7
- package/dist/contract-api.js +1 -1
- package/dist/doctor-contract-api.js +8 -281
- package/dist/{group-policy-Ca3c5KES.js → group-policy-Dvc-BcWo.js} +12 -17
- package/dist/{media-contract-BEgdvYhW.js → media-contract-D-FhGE98.js} +1 -1
- package/dist/media-contract-api.js +1 -1
- package/dist/{message-tool-api-TZiNYA17.js → message-tool-api-CvIgJpOo.js} +3 -3
- package/dist/message-tool-api.js +1 -1
- package/dist/{monitor-Uv5RaRTk.js → monitor-BywJn1QW.js} +289 -28
- package/dist/{question-reactions-to0i8vxE.js → question-reactions-viP7ZcyG.js} +1 -1
- package/dist/{reaction-context-DaNrZqYo.js → reaction-context-BAYI7pz0.js} +2 -2
- package/dist/{remote-file-CDuk0joc.js → remote-file-6mCj2ZBy.js} +2 -2
- package/dist/runtime-Cza4CY5T.js +8 -0
- package/dist/runtime-api.js +10 -9
- package/dist/{sanitize-outbound-DaLmdkbf.js → sanitize-outbound-Du-r1lNQ.js} +344 -57
- package/dist/{send-Dake4Awx.js → send-mgWPKqSV.js} +132 -11
- package/dist/state-contract-4TK_cDDb.js +56 -0
- package/dist/state-migrations-SFdKp3GQ.js +277 -0
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/openclaw.plugin.json +0 -6
- package/package.json +5 -5
- package/dist/catchup-Dh-Rv4Ur.js +0 -294
- package/dist/monitor-reply-cache-BdeUQaHO.js +0 -353
- package/dist/persisted-echo-cache-DGxy-J4t.js +0 -143
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -1,284 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as resolveIMessageReplyCacheEntryKey, i as IMESSAGE_REPLY_CACHE_NAMESPACE, n as IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE, r as IMESSAGE_REPLY_CACHE_MAX_ENTRIES, t as IMESSAGE_REPLY_CACHE_COUNTER_KEY } from "./monitor-reply-cache-BdeUQaHO.js";
|
|
3
|
-
import { o as resolveIMessageCatchupCursorKey, r as capFailureRetriesMap, t as IMESSAGE_CATCHUP_CURSOR_NAMESPACE } from "./catchup-Dh-Rv4Ur.js";
|
|
4
|
-
import { n as IMESSAGE_SENT_ECHOES_TTL_MS, s as resolveIMessageSentEchoEntryKey, t as IMESSAGE_SENT_ECHOES_NAMESPACE } from "./persisted-echo-cache-DGxy-J4t.js";
|
|
5
|
-
import fs from "node:fs";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { asFiniteNumber, isRecord, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
2
|
import { defineChannelAliasMigration, definePluginDoctorMigrationFromPlans } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
10
|
-
|
|
11
|
-
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
12
|
-
//#region extensions/imessage/src/state-migrations.ts
|
|
13
|
-
const REPLY_CACHE_TTL_MS = 360 * 60 * 1e3;
|
|
14
|
-
function resolveMigrationStateDir(params) {
|
|
15
|
-
return params.stateDir ?? resolveStateDir(params.env);
|
|
16
|
-
}
|
|
17
|
-
function remainingTtlMs(timestamp, ttlMs) {
|
|
18
|
-
const remaining = ttlMs - Math.max(0, Date.now() - timestamp);
|
|
19
|
-
return remaining > 0 ? remaining : void 0;
|
|
20
|
-
}
|
|
21
|
-
function readJsonl(pathValue) {
|
|
22
|
-
try {
|
|
23
|
-
return fs.readFileSync(pathValue, "utf8").split(/\n+/).flatMap((line) => {
|
|
24
|
-
if (!line) return [];
|
|
25
|
-
try {
|
|
26
|
-
return [JSON.parse(line)];
|
|
27
|
-
} catch {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} catch (err) {
|
|
32
|
-
throw new Error(`Failed reading ${pathValue}: ${String(err)}`, { cause: err });
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function parseReplyCacheEntry(raw) {
|
|
36
|
-
if (!raw || typeof raw !== "object") return null;
|
|
37
|
-
const parsed = raw;
|
|
38
|
-
if (typeof parsed.accountId !== "string" || typeof parsed.messageId !== "string" || typeof parsed.shortId !== "string" || typeof parsed.timestamp !== "number") return null;
|
|
39
|
-
return {
|
|
40
|
-
accountId: parsed.accountId,
|
|
41
|
-
messageId: parsed.messageId,
|
|
42
|
-
shortId: parsed.shortId,
|
|
43
|
-
timestamp: parsed.timestamp,
|
|
44
|
-
...typeof parsed.chatGuid === "string" ? { chatGuid: parsed.chatGuid } : {},
|
|
45
|
-
...typeof parsed.chatIdentifier === "string" ? { chatIdentifier: parsed.chatIdentifier } : {},
|
|
46
|
-
...typeof parsed.chatId === "number" ? { chatId: parsed.chatId } : {},
|
|
47
|
-
...typeof parsed.isFromMe === "boolean" ? { isFromMe: parsed.isFromMe } : {}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function readReplyCacheMaxShortId(sourcePath) {
|
|
51
|
-
let max = 0;
|
|
52
|
-
for (const raw of readJsonl(sourcePath)) {
|
|
53
|
-
if (!raw || typeof raw !== "object") continue;
|
|
54
|
-
const shortId = raw.shortId;
|
|
55
|
-
if (typeof shortId !== "string") continue;
|
|
56
|
-
const numeric = Number.parseInt(shortId, 10);
|
|
57
|
-
if (Number.isFinite(numeric) && numeric > max) max = numeric;
|
|
58
|
-
}
|
|
59
|
-
return max;
|
|
60
|
-
}
|
|
61
|
-
function readReplyCounterValue(value) {
|
|
62
|
-
if (!value || typeof value !== "object") return null;
|
|
63
|
-
const counter = value.counter;
|
|
64
|
-
return asFiniteNumber(counter) ?? null;
|
|
65
|
-
}
|
|
66
|
-
function shouldReplaceReplyCounter(existingValue, incomingValue) {
|
|
67
|
-
const incomingCounter = readReplyCounterValue(incomingValue);
|
|
68
|
-
if (incomingCounter === null) return false;
|
|
69
|
-
const existingCounter = readReplyCounterValue(existingValue);
|
|
70
|
-
return existingCounter === null || incomingCounter > existingCounter;
|
|
71
|
-
}
|
|
72
|
-
function parseSentEchoEntry(raw) {
|
|
73
|
-
if (!raw || typeof raw !== "object") return null;
|
|
74
|
-
const parsed = raw;
|
|
75
|
-
if (typeof parsed.scope !== "string" || typeof parsed.timestamp !== "number") return null;
|
|
76
|
-
return {
|
|
77
|
-
scope: parsed.scope,
|
|
78
|
-
timestamp: parsed.timestamp,
|
|
79
|
-
...typeof parsed.text === "string" ? { text: parsed.text } : {},
|
|
80
|
-
...typeof parsed.messageId === "string" ? { messageId: parsed.messageId } : {}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function listReplyCacheEntries(sourcePath) {
|
|
84
|
-
const entriesByKey = /* @__PURE__ */ new Map();
|
|
85
|
-
for (const entry of readJsonl(sourcePath).map(parseReplyCacheEntry)) {
|
|
86
|
-
if (!entry) continue;
|
|
87
|
-
const ttlMs = remainingTtlMs(entry.timestamp, REPLY_CACHE_TTL_MS);
|
|
88
|
-
if (!ttlMs) continue;
|
|
89
|
-
const key = resolveIMessageReplyCacheEntryKey(entry.messageId);
|
|
90
|
-
entriesByKey.delete(key);
|
|
91
|
-
entriesByKey.set(key, {
|
|
92
|
-
value: entry,
|
|
93
|
-
ttlMs
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return [...entriesByKey.entries()].slice(-IMESSAGE_REPLY_CACHE_MAX_ENTRIES).map(([key, entry]) => ({
|
|
97
|
-
key,
|
|
98
|
-
value: entry.value,
|
|
99
|
-
ttlMs: entry.ttlMs
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
function listSentEchoEntries(sourcePath) {
|
|
103
|
-
return readJsonl(sourcePath).map(parseSentEchoEntry).filter((entry) => Boolean(entry)).slice(-256).flatMap((entry) => {
|
|
104
|
-
const ttlMs = remainingTtlMs(entry.timestamp, IMESSAGE_SENT_ECHOES_TTL_MS);
|
|
105
|
-
if (!ttlMs) return [];
|
|
106
|
-
return [{
|
|
107
|
-
key: resolveIMessageSentEchoEntryKey(entry),
|
|
108
|
-
value: entry,
|
|
109
|
-
ttlMs
|
|
110
|
-
}];
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function resolveLegacyCatchupCursorPath(stateDir, accountId) {
|
|
114
|
-
const safePrefix = accountId.replace(/[^a-zA-Z0-9_-]/g, "_") || "account";
|
|
115
|
-
const hash = createHash("sha256").update(accountId, "utf8").digest("hex").slice(0, 12);
|
|
116
|
-
return path.join(stateDir, "imessage", "catchup", `${safePrefix}__${hash}.json`);
|
|
117
|
-
}
|
|
118
|
-
function listLegacyCatchupCursorPaths(stateDir) {
|
|
119
|
-
const dir = path.join(stateDir, "imessage", "catchup");
|
|
120
|
-
try {
|
|
121
|
-
return fs.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path.join(dir, entry.name));
|
|
122
|
-
} catch {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function normalizeCatchupCursor(raw) {
|
|
127
|
-
if (!raw || typeof raw !== "object") return null;
|
|
128
|
-
const value = raw;
|
|
129
|
-
if (typeof value.lastSeenMs !== "number" || !Number.isFinite(value.lastSeenMs) || typeof value.lastSeenRowid !== "number" || !Number.isFinite(value.lastSeenRowid)) return null;
|
|
130
|
-
const failureRetries = sanitizeCatchupFailureRetries(value.failureRetries);
|
|
131
|
-
const hasRetries = Object.keys(failureRetries).length > 0;
|
|
132
|
-
return {
|
|
133
|
-
lastSeenMs: value.lastSeenMs,
|
|
134
|
-
lastSeenRowid: value.lastSeenRowid,
|
|
135
|
-
updatedAt: typeof value.updatedAt === "number" ? value.updatedAt : 0,
|
|
136
|
-
...hasRetries ? { failureRetries } : {}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function readCatchupCursor(sourcePath) {
|
|
140
|
-
let parsed;
|
|
141
|
-
try {
|
|
142
|
-
parsed = JSON.parse(fs.readFileSync(sourcePath, "utf8"));
|
|
143
|
-
} catch (err) {
|
|
144
|
-
throw new Error(`Failed reading ${sourcePath}: ${String(err)}`, { cause: err });
|
|
145
|
-
}
|
|
146
|
-
const cursor = normalizeCatchupCursor(parsed);
|
|
147
|
-
if (!cursor) throw new Error(`Invalid iMessage catchup cursor: ${sourcePath}`);
|
|
148
|
-
return cursor;
|
|
149
|
-
}
|
|
150
|
-
function sanitizeCatchupFailureRetries(raw) {
|
|
151
|
-
if (!raw || typeof raw !== "object") return {};
|
|
152
|
-
const out = {};
|
|
153
|
-
for (const [guid, count] of Object.entries(raw)) if (typeof count === "number" && Number.isFinite(count) && count > 0) out[guid] = Math.floor(count);
|
|
154
|
-
return capFailureRetriesMap(out);
|
|
155
|
-
}
|
|
156
|
-
function shouldReplaceCatchupCursor(existingValue, incomingValue) {
|
|
157
|
-
const incoming = normalizeCatchupCursor(incomingValue);
|
|
158
|
-
if (!incoming) return false;
|
|
159
|
-
const existing = normalizeCatchupCursor(existingValue);
|
|
160
|
-
return !existing || incoming.lastSeenRowid > existing.lastSeenRowid || incoming.lastSeenRowid === existing.lastSeenRowid && incoming.lastSeenMs > existing.lastSeenMs;
|
|
161
|
-
}
|
|
162
|
-
function detectReplyCacheMigration(params) {
|
|
163
|
-
const stateDir = resolveMigrationStateDir(params);
|
|
164
|
-
const sourcePath = path.join(stateDir, "imessage", "reply-cache.jsonl");
|
|
165
|
-
if (!fileExists(sourcePath)) return [];
|
|
166
|
-
const plans = [];
|
|
167
|
-
plans.push({
|
|
168
|
-
kind: "plugin-state-import",
|
|
169
|
-
label: "iMessage reply short-id counter",
|
|
170
|
-
sourcePath,
|
|
171
|
-
targetPath: `plugin state:${IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE}`,
|
|
172
|
-
pluginId: "imessage",
|
|
173
|
-
namespace: IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE,
|
|
174
|
-
maxEntries: 1,
|
|
175
|
-
scopeKey: "",
|
|
176
|
-
stateDir,
|
|
177
|
-
preview: `- iMessage reply short-id counter: ${sourcePath} → plugin state (${IMESSAGE_REPLY_CACHE_COUNTER_NAMESPACE})`,
|
|
178
|
-
readEntries: () => {
|
|
179
|
-
const maxShortId = readReplyCacheMaxShortId(sourcePath);
|
|
180
|
-
return maxShortId > 0 ? [{
|
|
181
|
-
key: IMESSAGE_REPLY_CACHE_COUNTER_KEY,
|
|
182
|
-
value: { counter: maxShortId }
|
|
183
|
-
}] : [];
|
|
184
|
-
},
|
|
185
|
-
shouldReplaceExistingEntry: ({ existingValue, incomingValue }) => shouldReplaceReplyCounter(existingValue, incomingValue)
|
|
186
|
-
});
|
|
187
|
-
plans.push({
|
|
188
|
-
kind: "plugin-state-import",
|
|
189
|
-
label: "iMessage reply short-id cache",
|
|
190
|
-
sourcePath,
|
|
191
|
-
targetPath: `plugin state:${IMESSAGE_REPLY_CACHE_NAMESPACE}`,
|
|
192
|
-
pluginId: "imessage",
|
|
193
|
-
namespace: IMESSAGE_REPLY_CACHE_NAMESPACE,
|
|
194
|
-
maxEntries: IMESSAGE_REPLY_CACHE_MAX_ENTRIES,
|
|
195
|
-
scopeKey: "",
|
|
196
|
-
stateDir,
|
|
197
|
-
cleanupSource: "rename",
|
|
198
|
-
cleanupWhenEmpty: true,
|
|
199
|
-
preview: `- iMessage reply short-id cache: ${sourcePath} → plugin state (${IMESSAGE_REPLY_CACHE_NAMESPACE})`,
|
|
200
|
-
readEntries: () => listReplyCacheEntries(sourcePath)
|
|
201
|
-
});
|
|
202
|
-
return plans;
|
|
203
|
-
}
|
|
204
|
-
function detectSentEchoMigration(params) {
|
|
205
|
-
const stateDir = resolveMigrationStateDir(params);
|
|
206
|
-
const sourcePath = path.join(stateDir, "imessage", "sent-echoes.jsonl");
|
|
207
|
-
if (!fileExists(sourcePath)) return [];
|
|
208
|
-
return [{
|
|
209
|
-
kind: "plugin-state-import",
|
|
210
|
-
label: "iMessage sent-echo dedupe cache",
|
|
211
|
-
sourcePath,
|
|
212
|
-
targetPath: `plugin state:${IMESSAGE_SENT_ECHOES_NAMESPACE}`,
|
|
213
|
-
pluginId: "imessage",
|
|
214
|
-
namespace: IMESSAGE_SENT_ECHOES_NAMESPACE,
|
|
215
|
-
maxEntries: 256,
|
|
216
|
-
scopeKey: "",
|
|
217
|
-
stateDir,
|
|
218
|
-
cleanupSource: "rename",
|
|
219
|
-
cleanupWhenEmpty: true,
|
|
220
|
-
preview: `- iMessage sent-echo dedupe cache: ${sourcePath} → plugin state (${IMESSAGE_SENT_ECHOES_NAMESPACE})`,
|
|
221
|
-
readEntries: () => listSentEchoEntries(sourcePath)
|
|
222
|
-
}];
|
|
223
|
-
}
|
|
224
|
-
function detectCatchupCursorMigrations(params) {
|
|
225
|
-
const stateDir = resolveMigrationStateDir(params);
|
|
226
|
-
const accountIds = uniqueStrings([resolveDefaultIMessageAccountId(params.cfg), ...listIMessageAccountIds(params.cfg)].map((accountId) => resolveIMessageAccount({
|
|
227
|
-
cfg: params.cfg,
|
|
228
|
-
accountId
|
|
229
|
-
}).accountId));
|
|
230
|
-
const configuredPaths = new Set(accountIds.map((accountId) => resolveLegacyCatchupCursorPath(stateDir, accountId)));
|
|
231
|
-
const configuredPlans = accountIds.flatMap((accountId) => {
|
|
232
|
-
const sourcePath = resolveLegacyCatchupCursorPath(stateDir, accountId);
|
|
233
|
-
if (!fileExists(sourcePath)) return [];
|
|
234
|
-
return {
|
|
235
|
-
kind: "plugin-state-import",
|
|
236
|
-
label: "iMessage catchup cursor",
|
|
237
|
-
sourcePath,
|
|
238
|
-
targetPath: `plugin state:${IMESSAGE_CATCHUP_CURSOR_NAMESPACE}`,
|
|
239
|
-
pluginId: "imessage",
|
|
240
|
-
namespace: IMESSAGE_CATCHUP_CURSOR_NAMESPACE,
|
|
241
|
-
maxEntries: 256,
|
|
242
|
-
scopeKey: "",
|
|
243
|
-
stateDir,
|
|
244
|
-
cleanupSource: "rename",
|
|
245
|
-
preview: `- iMessage catchup cursor: ${sourcePath} → plugin state (${IMESSAGE_CATCHUP_CURSOR_NAMESPACE})`,
|
|
246
|
-
readEntries: () => {
|
|
247
|
-
const cursor = readCatchupCursor(sourcePath);
|
|
248
|
-
return [{
|
|
249
|
-
key: resolveIMessageCatchupCursorKey(accountId),
|
|
250
|
-
value: cursor
|
|
251
|
-
}];
|
|
252
|
-
},
|
|
253
|
-
shouldReplaceExistingEntry: (replaceParams) => shouldReplaceCatchupCursor(replaceParams.existingValue, replaceParams.incomingValue)
|
|
254
|
-
};
|
|
255
|
-
});
|
|
256
|
-
const orphanPlans = listLegacyCatchupCursorPaths(stateDir).filter((sourcePath) => !configuredPaths.has(sourcePath)).map((sourcePath) => ({
|
|
257
|
-
kind: "plugin-state-import",
|
|
258
|
-
label: "iMessage orphan catchup cursor",
|
|
259
|
-
sourcePath,
|
|
260
|
-
targetPath: `plugin state:${IMESSAGE_CATCHUP_CURSOR_NAMESPACE}`,
|
|
261
|
-
pluginId: "imessage",
|
|
262
|
-
namespace: IMESSAGE_CATCHUP_CURSOR_NAMESPACE,
|
|
263
|
-
maxEntries: 256,
|
|
264
|
-
scopeKey: "",
|
|
265
|
-
stateDir,
|
|
266
|
-
cleanupSource: "rename",
|
|
267
|
-
cleanupWhenEmpty: true,
|
|
268
|
-
preview: `- iMessage orphan catchup cursor: ${sourcePath} → archived legacy state`,
|
|
269
|
-
readEntries: () => []
|
|
270
|
-
}));
|
|
271
|
-
return [...configuredPlans, ...orphanPlans];
|
|
272
|
-
}
|
|
273
|
-
async function detectIMessageLegacyStateMigrations(params) {
|
|
274
|
-
return [
|
|
275
|
-
...detectCatchupCursorMigrations(params),
|
|
276
|
-
...detectReplyCacheMigration(params),
|
|
277
|
-
...detectSentEchoMigration(params)
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region extensions/imessage/doctor-contract-api.ts
|
|
3
|
+
//#region extensions/imessage/config-doctor-api.ts
|
|
282
4
|
function isEnabledCatchup(value) {
|
|
283
5
|
return isRecord(value) && value.enabled === true;
|
|
284
6
|
}
|
|
@@ -348,10 +70,15 @@ function normalizeCompatibilityConfig({ cfg }) {
|
|
|
348
70
|
changes
|
|
349
71
|
};
|
|
350
72
|
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region extensions/imessage/doctor-contract-api.ts
|
|
351
75
|
const stateMigrations = [definePluginDoctorMigrationFromPlans({
|
|
352
76
|
id: "imessage-legacy-state",
|
|
353
77
|
label: "iMessage legacy state",
|
|
354
|
-
resolvePlans:
|
|
78
|
+
resolvePlans: async (params) => {
|
|
79
|
+
const { detectIMessageLegacyStateMigrations } = await import("./state-migrations-SFdKp3GQ.js");
|
|
80
|
+
return detectIMessageLegacyStateMigrations(params);
|
|
81
|
+
}
|
|
355
82
|
})];
|
|
356
83
|
//#endregion
|
|
357
84
|
export { legacyConfigRules, normalizeCompatibilityConfig, stateMigrations };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { a as resolveDefaultIMessageAccountId, l as resolveIMessageRemoteHost, n as hasExclusiveIMessageLocalDatabase, o as resolveIMessageAccount, u as expandIMessageUserPath } from "./accounts-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { o as createIMessageRpcClient } from "./sanitize-outbound-DaLmdkbf.js";
|
|
1
|
+
import { a as resolveDefaultIMessageAccountId, l as resolveIMessageRemoteHost, n as hasExclusiveIMessageLocalDatabase, o as resolveIMessageAccount, u as expandIMessageUserPath } from "./accounts-CCirBEIm.js";
|
|
2
|
+
import { d as normalizeBareIMessageChatIdentifier, f as getCachedIMessagePrivateApiStatus, g as IMESSAGE_ACTION_NAMES, h as IMESSAGE_ACTIONS, l as parseIMessageTarget, m as setCachedIMessagePrivateApiStatus, p as imessageRpcSupportsMethod, s as normalizeIMessageHandle$1, t as describeIMessageMessageTool, u as isIMessagePhoneLikeHandle } from "./message-tool-api-CvIgJpOo.js";
|
|
3
|
+
import { c as isIMessageCurrentMessageInChat, h as chatContextFromIMessageTarget, o as createIMessageRpcClient, s as findLatestIMessageEntryForChat, u as rememberIMessageReplyCache } from "./sanitize-outbound-Du-r1lNQ.js";
|
|
5
4
|
import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
|
6
|
-
import { collectStatusIssuesFromLastError } from "openclaw/plugin-sdk/status-helpers";
|
|
7
5
|
import path from "node:path";
|
|
8
6
|
import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
|
|
9
7
|
import { filterStringEntries, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
8
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
11
9
|
import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
|
|
12
10
|
import { createActionGate, jsonResult, readNonNegativeIntegerParam, readPositiveIntegerParam, readReactionParams, readStringArrayParam, readStringParam } from "openclaw/plugin-sdk/channel-actions";
|
|
11
|
+
import { canonicalizeBase64 } from "openclaw/plugin-sdk/media-runtime";
|
|
13
12
|
import { normalizePollInput } from "openclaw/plugin-sdk/poll-runtime";
|
|
14
13
|
import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
|
|
15
14
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
@@ -23,11 +22,6 @@ import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
|
23
22
|
import { createCliPathTextInput, createDelegatedSetupWizardProxy, createDelegatedTextInputShouldPrompt, createPatchedAccountSetupAdapter, createSetupTranslator, promptParsedAllowFromForAccount, setAccountAllowFromForChannel, setSetupChannelEnabled as setSetupChannelEnabled$1 } from "openclaw/plugin-sdk/setup-runtime";
|
|
24
23
|
import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
|
25
24
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
26
|
-
import { formatTrimmedAllowFromEntries as formatTrimmedAllowFromEntries$1 } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
27
|
-
import { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
|
|
28
|
-
import { DEFAULT_ACCOUNT_ID, getChatChannelMeta } from "openclaw/plugin-sdk/core";
|
|
29
|
-
import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";
|
|
30
|
-
import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
|
|
31
25
|
import { buildChannelGroupsScopeTree, resolveScopeRequireMention, resolveScopeToolsPolicy } from "openclaw/plugin-sdk/channel-policy";
|
|
32
26
|
//#region extensions/imessage/src/message-action-reference.ts
|
|
33
27
|
async function resolveAuthorizedIMessageActionReference(params) {
|
|
@@ -525,7 +519,7 @@ async function probeIMessage(timeoutMs, opts = {}) {
|
|
|
525
519
|
}
|
|
526
520
|
//#endregion
|
|
527
521
|
//#region extensions/imessage/src/actions.ts
|
|
528
|
-
const loadIMessageActionsRuntime = createLazyRuntimeNamedExport(() => import("./actions.runtime-
|
|
522
|
+
const loadIMessageActionsRuntime = createLazyRuntimeNamedExport(() => import("./actions.runtime-CAl3WcqD.js"), "imessageActionsRuntime");
|
|
529
523
|
const log = createSubsystemLogger("channels/imessage");
|
|
530
524
|
const providerId = "imessage";
|
|
531
525
|
const SUPPORTED_ACTIONS = /* @__PURE__ */ new Set([...IMESSAGE_ACTION_NAMES, "upload-file"]);
|
|
@@ -686,7 +680,9 @@ function mapTapbackReaction(emoji) {
|
|
|
686
680
|
function decodeBase64Buffer(params, action) {
|
|
687
681
|
const base64Buffer = readStringParam(params, "buffer");
|
|
688
682
|
if (!base64Buffer) throw new Error(`iMessage ${action} requires buffer (base64) parameter.`);
|
|
689
|
-
|
|
683
|
+
const canonical = canonicalizeBase64(base64Buffer.replaceAll("-", "+").replaceAll("_", "/"));
|
|
684
|
+
if (!canonical) throw new Error(`iMessage ${action} buffer must be valid base64.`);
|
|
685
|
+
return Uint8Array.from(Buffer.from(canonical, "base64"));
|
|
690
686
|
}
|
|
691
687
|
const REPLY_ATTACHMENT_PATH_PARAM_NAMES = [
|
|
692
688
|
"filePath",
|
|
@@ -696,13 +692,12 @@ const REPLY_ATTACHMENT_PATH_PARAM_NAMES = [
|
|
|
696
692
|
"fileUrl"
|
|
697
693
|
];
|
|
698
694
|
function extractReplyAttachment(params) {
|
|
699
|
-
|
|
700
|
-
if (buffer) {
|
|
695
|
+
if (readStringParam(params, "buffer")) {
|
|
701
696
|
const filename = readStringParam(params, "filename") ?? "attachment.bin";
|
|
702
697
|
return {
|
|
703
698
|
spec: {
|
|
704
699
|
kind: "buffer",
|
|
705
|
-
buffer:
|
|
700
|
+
buffer: decodeBase64Buffer(params, "reply attachment"),
|
|
706
701
|
filename
|
|
707
702
|
},
|
|
708
703
|
sourceParam: "buffer"
|
|
@@ -1078,7 +1073,7 @@ const imessageMessageActions = {
|
|
|
1078
1073
|
if (action === "sendAttachment" || action === "upload-file") {
|
|
1079
1074
|
await assertPrivateApiEnabled();
|
|
1080
1075
|
const filename = readStringParam(params, "filename", { required: true });
|
|
1081
|
-
const asVoice = readBooleanParam(params, "asVoice")
|
|
1076
|
+
const asVoice = readBooleanParam(params, "asVoice");
|
|
1082
1077
|
const resolvedChatGuid = await chatGuid();
|
|
1083
1078
|
const result = await runtime.sendAttachment({
|
|
1084
1079
|
chatGuid: resolvedChatGuid,
|
|
@@ -1302,4 +1297,4 @@ function resolveIMessageGroupToolPolicy(params) {
|
|
|
1302
1297
|
});
|
|
1303
1298
|
}
|
|
1304
1299
|
//#endregion
|
|
1305
|
-
export {
|
|
1300
|
+
export { imessageDmPolicy as _, normalizeIMessageAcpConversationId as a, isAutoManagedIMessageCliPath as b, normalizeIMessageMessagingTarget as c, imessageMessageActions as d, probeIMessage as f, imessageCompletionNote as g, createIMessageSetupWizardProxy as h, matchIMessageAcpConversation as i, getIMessageApprovalApprovers as l, createIMessageCliPathTextInput as m, resolveIMessageGroupToolPolicy as n, resolveIMessageConversationIdFromTarget as o, IMESSAGE_INSTALL_COMMAND as p, resolveIMessageInboundConversationId as r, looksLikeIMessageTargetId as s, resolveIMessageGroupRequireMention as t, imessageApprovalAuth as u, imessageSetupContract as v, normalizeIMessageCliPathForSetup as x, imessageSetupStatusBase as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as resolveIMessageAccount } from "./accounts-
|
|
1
|
+
import { o as resolveIMessageAccount } from "./accounts-CCirBEIm.js";
|
|
2
2
|
import { mergeInboundPathRoots } from "openclaw/plugin-sdk/channel-inbound";
|
|
3
3
|
//#region extensions/imessage/src/media-contract.ts
|
|
4
4
|
const DEFAULT_IMESSAGE_ATTACHMENT_ROOTS = ["/Users/*/Library/Messages/Attachments"];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resolveIMessageAttachmentRoots, r as resolveIMessageRemoteAttachmentRoots, t as DEFAULT_IMESSAGE_ATTACHMENT_ROOTS } from "./media-contract-
|
|
1
|
+
import { n as resolveIMessageAttachmentRoots, r as resolveIMessageRemoteAttachmentRoots, t as DEFAULT_IMESSAGE_ATTACHMENT_ROOTS } from "./media-contract-D-FhGE98.js";
|
|
2
2
|
export { DEFAULT_IMESSAGE_ATTACHMENT_ROOTS, resolveIMessageAttachmentRoots, resolveIMessageAttachmentRoots as resolveInboundAttachmentRoots, resolveIMessageRemoteAttachmentRoots, resolveIMessageRemoteAttachmentRoots as resolveRemoteInboundAttachmentRoots };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as getCachedIMessageRemoteHost, o as resolveIMessageAccount } from "./accounts-
|
|
1
|
+
import { c as getCachedIMessageRemoteHost, o as resolveIMessageAccount } from "./accounts-CCirBEIm.js";
|
|
2
2
|
import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
|
|
3
3
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { createActionGate } from "openclaw/plugin-sdk/channel-actions";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
6
|
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
7
|
-
import { createAllowedChatSenderMatcher,
|
|
7
|
+
import { createAllowedChatSenderMatcher, parseChatTargetPrefixesOrThrow, resolveServicePrefixedChatTarget, resolveServicePrefixedOrChatAllowTarget } from "openclaw/plugin-sdk/channel-targets";
|
|
8
8
|
//#region extensions/imessage/src/actions-contract.ts
|
|
9
9
|
const IMESSAGE_ACTIONS = {
|
|
10
10
|
react: { gate: "reactions" },
|
|
@@ -315,4 +315,4 @@ function describeIMessageMessageTool({ cfg, accountId, currentChannelId }) {
|
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
317
|
//#endregion
|
|
318
|
-
export {
|
|
318
|
+
export { isAllowedIMessageSender as a, parseIMessageAllowTarget as c, normalizeBareIMessageChatIdentifier as d, getCachedIMessagePrivateApiStatus as f, IMESSAGE_ACTION_NAMES as g, IMESSAGE_ACTIONS as h, isAllowedIMessageReplyContextSender as i, parseIMessageTarget as l, setCachedIMessagePrivateApiStatus as m, formatIMessageChatTarget as n, looksLikeIMessageExplicitTargetId as o, imessageRpcSupportsMethod as p, inferIMessageTargetChatType as r, normalizeIMessageHandle as s, describeIMessageMessageTool as t, isIMessagePhoneLikeHandle as u };
|
package/dist/message-tool-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as describeIMessageMessageTool } from "./message-tool-api-
|
|
1
|
+
import { t as describeIMessageMessageTool } from "./message-tool-api-CvIgJpOo.js";
|
|
2
2
|
export { describeIMessageMessageTool as describeMessageTool };
|