@openclaw/imessage 2026.10.10-beta.5 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{accounts-DacCvDBt.mjs → accounts-C1Ypv3Wn.mjs} +9 -13
- package/dist/.setup/{actions-762Azi-J.mjs → actions-qOuKy8To.mjs} +364 -116
- package/dist/.setup/{actions.runtime-DHiRiPHe.mjs → actions.runtime-Ccg9CARL.mjs} +12 -61
- package/dist/.setup/{api-Deyo8NDs.mjs → api-BXXuQQCS.mjs} +8 -9
- package/dist/.setup/{api-BFGXDHiC.mjs → api-DTbxSOPc.mjs} +9 -9
- package/dist/.setup/{approval-handler.runtime-fsSBf2jf.mjs → approval-handler.runtime-B6vrFfZx.mjs} +113 -133
- package/dist/.setup/{approval-reactions-CoAkCiwf.mjs → approval-reactions-DBBsqbRC.mjs} +156 -79
- package/dist/.setup/{channel-C61YdcZR.mjs → channel-CLaN4mQn.mjs} +151 -137
- package/dist/.setup/{channel.runtime-B5jle0g3.mjs → channel.runtime-XJGx1MIH.mjs} +236 -425
- package/dist/.setup/chat-context-fTfJVqAi.mjs +77 -0
- package/dist/.setup/chat-lookup-xtPsOBkl.mjs +50 -0
- package/dist/.setup/client-D_BaG8sC.mjs +367 -0
- package/dist/.setup/{config-schema-DXwa_3V5.mjs → config-schema-BjkQV5P5.mjs} +1 -4
- package/dist/.setup/{conversation-bindings-DR-dbHjs.mjs → conversation-bindings-8DjxoIYU.mjs} +10 -8
- package/dist/.setup/{media-contract-BwWs5PM7.mjs → media-contract-BErFBKV9.mjs} +2 -3
- package/dist/.setup/{message-tool-api-B5NfPnFL.mjs → message-tool-api-DtZ1wKbT.mjs} +6 -12
- package/dist/.setup/{outbound-send-deps-B-QEsLSM.mjs → outbound-send-deps-_da8jqeo.mjs} +1 -2
- package/dist/.setup/{remote-file-B94a787O.mjs → remote-file-DpK3GQFD.mjs} +12 -30
- package/dist/.setup/{rolldown-runtime-BBjsoOtd.mjs → rolldown-runtime-782esTHO.mjs} +1 -2
- package/dist/.setup/{sanitize-outbound-BtEY324R.mjs → sanitize-outbound-Dhjhz0a-.mjs} +25 -31
- package/dist/.setup/{send-BvxKNWzF.mjs → send-DhEW0gfe.mjs} +155 -236
- package/dist/.setup/{setup-core-BHyLkAEJ.mjs → setup-core-B1_P_t4T.mjs} +3 -4
- package/dist/.setup/{setup-surface-DPqiLGy0.mjs → setup-surface-CD28mXWK.mjs} +13 -29
- package/dist/.setup/{targets-B4oU7n-v.mjs → targets-C7CIWJ0k.mjs} +15 -9
- package/dist/.source-module-urls/929c518fa2986b0f85f66bceefead22868db0ab452dee914dc6a2bb86b2e60ad.json +1 -1
- package/dist/api.js +9 -9
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/doctor-contract-api.js +7 -13
- package/dist/index.js +1 -2
- package/dist/media-contract-api.js +1 -1
- package/dist/message-tool-api.js +1 -1
- package/dist/runtime-api.js +1 -3
- package/dist/secret-contract-api.js +1 -2
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/setup-entry.js +2 -3
- package/dist/src/chat-db.worker.js +2 -3
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/openclaw.plugin.json +0 -30
- package/package.json +6 -6
- package/dist/.setup/client-CcROCvRq.mjs +0 -746
- package/dist/.setup/question-reactions-BD06B1Lx.mjs +0 -68
- package/dist/.setup/reaction-context-Q26DYzQH.mjs +0 -106
- package/dist/.setup/runtime-Cza4CY5T.mjs +0 -8
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { d as resolveIMessageChatDbLookupPath, l as resolveIMessageRemoteHost, n as hasExclusiveIMessageLocalDatabase, o as resolveIMessageAccount } from "./accounts-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { d as getIMessageApprovalApprovers, f as imessageApprovalAuth } from "./channel-
|
|
7
|
-
import { n as sanitizeIMessageFinalOutboundText, t as protectIMessageFencedRoleMarkers } from "./sanitize-outbound-
|
|
8
|
-
import { a as withIMessageReceiptGuidReader, r as resolveAuthorizedIMessageReplyReference, t as withIMessageRemoteFile } from "./remote-file-
|
|
9
|
-
import { d as resolveIMessageApprovalControlActor,
|
|
1
|
+
import { l as parseIMessageTarget, n as iMessageTargetRpcParams, s as normalizeIMessageHandle, t as formatIMessageChatTarget } from "./targets-C7CIWJ0k.mjs";
|
|
2
|
+
import { d as resolveIMessageChatDbLookupPath, l as resolveIMessageRemoteHost, n as hasExclusiveIMessageLocalDatabase, o as resolveIMessageAccount } from "./accounts-C1Ypv3Wn.mjs";
|
|
3
|
+
import { a as resolveIMessageDirectChatService, t as chatContextFromIMessageTarget } from "./chat-context-fTfJVqAi.mjs";
|
|
4
|
+
import { i as runIMessageCliJsonCommand, n as createIMessageRpcClient, t as IMessageRpcRequestError } from "./client-D_BaG8sC.mjs";
|
|
5
|
+
import { a as rememberIMessageReplyCache, b as normalizeIMessageMessageId, g as getOptionalIMessageRuntime, h as getIMessageRuntime, l as IMESSAGE_SENT_ECHOES_NAMESPACE, m as resolveIMessageSentEchoEntryKey, p as resolveIMessageEchoMediaKey, u as IMESSAGE_SENT_ECHOES_TTL_MS, v as createPersistenceFailureReporter, y as normalizeIMessageGuid } from "./actions-qOuKy8To.mjs";
|
|
6
|
+
import { d as getIMessageApprovalApprovers, f as imessageApprovalAuth } from "./channel-CLaN4mQn.mjs";
|
|
7
|
+
import { n as sanitizeIMessageFinalOutboundText, t as protectIMessageFencedRoleMarkers } from "./sanitize-outbound-Dhjhz0a-.mjs";
|
|
8
|
+
import { a as withIMessageReceiptGuidReader, r as resolveAuthorizedIMessageReplyReference, t as withIMessageRemoteFile } from "./remote-file-DpK3GQFD.mjs";
|
|
9
|
+
import { d as resolveIMessageApprovalControlActor, l as enumerateApprovalTargetKeys, r as registerIMessageApprovalReactionTarget, s as buildIMessageApprovalConversationKeyForInbound, u as normalizeConversationKey } from "./approval-reactions-DBBsqbRC.mjs";
|
|
10
10
|
import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
11
|
import { createMessageReceiptFromOutboundResults } from "openclaw/plugin-sdk/channel-outbound";
|
|
12
12
|
import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
|
13
13
|
import { accessSync, constants } from "node:fs";
|
|
14
14
|
import { basename } from "node:path";
|
|
15
15
|
import { extractOriginalFilename, kindFromMime, resolveOutboundAttachmentFromUrl } from "openclaw/plugin-sdk/media-runtime";
|
|
16
|
-
import {
|
|
17
|
-
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
16
|
+
import { sleep } from "openclaw/plugin-sdk/runtime-env";
|
|
18
17
|
import { PlatformMessageNotDispatchedError, isApprovalNotFoundError } from "openclaw/plugin-sdk/error-runtime";
|
|
19
18
|
import { captureChannelReadAuthority, captureEffectAuthority } from "openclaw/plugin-sdk/fetch-runtime";
|
|
20
19
|
import { addApprovalReactionHintToText, createApprovalReactionTargetStore, listApprovalReactionBindings } from "openclaw/plugin-sdk/approval-reaction-runtime";
|
|
21
20
|
import { convertMarkdownTables, stripInlineDirectiveTagsForDelivery } from "openclaw/plugin-sdk/text-chunking";
|
|
22
21
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
23
22
|
import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
23
|
+
import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
24
24
|
import { createPluginStateErrorReporter } from "openclaw/plugin-sdk/plugin-state-runtime";
|
|
25
25
|
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
26
26
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
27
|
-
|
|
27
|
+
// extensions/imessage/src/approval-polls.ts
|
|
28
28
|
const TARGET_NAMESPACE = "imessage.approval-polls";
|
|
29
29
|
const TOMBSTONE_NAMESPACE = "imessage.approval-poll-tombstones";
|
|
30
30
|
const MAX_ENTRIES = 1e3;
|
|
@@ -313,7 +313,6 @@ async function maybeResolveIMessageApprovalPollVote(params) {
|
|
|
313
313
|
channel: "imessage",
|
|
314
314
|
accountId: params.accountId,
|
|
315
315
|
senderId: event.actorHandle,
|
|
316
|
-
gatewayUrl: params.gatewayUrl,
|
|
317
316
|
...params.gatewayRuntime ? { gatewayRuntime: params.gatewayRuntime } : {}
|
|
318
317
|
});
|
|
319
318
|
await unregisterIMessageApprovalPollTarget({
|
|
@@ -345,19 +344,12 @@ async function maybeResolveIMessageApprovalPollVote(params) {
|
|
|
345
344
|
throw error;
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
|
-
function clearIMessageApprovalPollTargetsForTest() {
|
|
349
|
-
pollTargets.clearForTest();
|
|
350
|
-
pollTombstones.clearForTest();
|
|
351
|
-
loadResolveApprovalOverGateway.clear();
|
|
352
|
-
}
|
|
353
347
|
const iMessageApprovalPollTargets = {
|
|
354
348
|
register: registerIMessageApprovalPollTarget,
|
|
355
349
|
unregister: unregisterIMessageApprovalPollTarget,
|
|
356
|
-
registerTombstone: registerIMessageApprovalPollTombstone
|
|
357
|
-
clearForTest: clearIMessageApprovalPollTargetsForTest
|
|
350
|
+
registerTombstone: registerIMessageApprovalPollTombstone
|
|
358
351
|
};
|
|
359
|
-
|
|
360
|
-
//#region extensions/imessage/src/monitor/echo-text-corruption.ts
|
|
352
|
+
// extensions/imessage/src/monitor/echo-text-corruption.ts
|
|
361
353
|
function isLeadingEchoTextCorruptionMarker(code) {
|
|
362
354
|
return code === 0 || code === 65279 || code === 65533 || code === 65534 || code === 65535;
|
|
363
355
|
}
|
|
@@ -368,14 +360,8 @@ function normalizeIMessageEchoText(text) {
|
|
|
368
360
|
while (offset < normalized.length && isLeadingEchoTextCorruptionMarker(normalized.charCodeAt(offset))) offset += 1;
|
|
369
361
|
return normalized.slice(offset).trim() || void 0;
|
|
370
362
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
let persistenceFailureLogged = false;
|
|
374
|
-
function reportFailure(scope, err) {
|
|
375
|
-
if (persistenceFailureLogged) return;
|
|
376
|
-
persistenceFailureLogged = true;
|
|
377
|
-
logVerbose(`imessage echo-cache: ${scope} disabled after first failure: ${String(err)}`);
|
|
378
|
-
}
|
|
363
|
+
// extensions/imessage/src/monitor/persisted-echo-cache.ts
|
|
364
|
+
const reportFailure = createPersistenceFailureReporter("echo-cache");
|
|
379
365
|
function normalizeMedia(media) {
|
|
380
366
|
if (!resolveIMessageEchoMediaKey(media)) return;
|
|
381
367
|
const contentType = media?.contentType?.trim().toLowerCase() || void 0;
|
|
@@ -395,28 +381,23 @@ function remainingTtlMs(timestamp) {
|
|
|
395
381
|
const remaining = IMESSAGE_SENT_ECHOES_TTL_MS - Math.max(0, Date.now() - timestamp);
|
|
396
382
|
return remaining > 0 ? remaining : void 0;
|
|
397
383
|
}
|
|
398
|
-
function resolveEntryTtlMs(entry, ttlMs) {
|
|
399
|
-
if (typeof ttlMs === "number" && Number.isFinite(ttlMs) && ttlMs > 0) return ttlMs;
|
|
400
|
-
return remainingTtlMs(entry.timestamp);
|
|
401
|
-
}
|
|
402
384
|
function isLiveEntry(entry, now = Date.now()) {
|
|
403
385
|
const cutoff = now - IMESSAGE_SENT_ECHOES_TTL_MS;
|
|
404
386
|
return entry.timestamp >= cutoff && (entry.expiresAt == null || entry.expiresAt > now);
|
|
405
387
|
}
|
|
406
388
|
async function readRecentEntries() {
|
|
407
389
|
try {
|
|
408
|
-
return (await openPersistedEchoStore().entries()).map(({ value }) => value).filter((entry) => isLiveEntry(entry))
|
|
390
|
+
return (await openPersistedEchoStore().entries()).map(({ value }) => value).filter((entry) => isLiveEntry(entry));
|
|
409
391
|
} catch (err) {
|
|
410
392
|
reportFailure("read", err);
|
|
411
393
|
return [];
|
|
412
394
|
}
|
|
413
395
|
}
|
|
414
396
|
async function persistEntry(entry, ttlMs) {
|
|
415
|
-
|
|
416
|
-
if (!effectiveTtlMs) return;
|
|
397
|
+
if (!ttlMs) return;
|
|
417
398
|
const key = resolveIMessageSentEchoEntryKey(entry);
|
|
418
399
|
try {
|
|
419
|
-
await openPersistedEchoStore().register(key, entry, { ttlMs
|
|
400
|
+
await openPersistedEchoStore().register(key, entry, { ttlMs });
|
|
420
401
|
} catch (err) {
|
|
421
402
|
reportFailure("write", err);
|
|
422
403
|
return;
|
|
@@ -435,9 +416,10 @@ async function rememberPersistedIMessageEcho(params) {
|
|
|
435
416
|
...messageId ? { messageId } : {},
|
|
436
417
|
...params.pending ? { pending: true } : {}
|
|
437
418
|
};
|
|
438
|
-
|
|
419
|
+
const ttlMs = typeof params.ttlMs === "number" && Number.isFinite(params.ttlMs) && params.ttlMs > 0 ? params.ttlMs : void 0;
|
|
420
|
+
if (ttlMs !== void 0) entry.expiresAt = entry.timestamp + ttlMs;
|
|
439
421
|
if (!entry.text && !entry.media && !entry.messageId) return;
|
|
440
|
-
return await persistEntry(entry,
|
|
422
|
+
return await persistEntry(entry, ttlMs ?? remainingTtlMs(entry.timestamp));
|
|
441
423
|
}
|
|
442
424
|
async function forgetPersistedIMessageEchoKey(key) {
|
|
443
425
|
if (!key) return;
|
|
@@ -461,19 +443,17 @@ async function hasPersistedIMessageEcho(params) {
|
|
|
461
443
|
}
|
|
462
444
|
return false;
|
|
463
445
|
}
|
|
464
|
-
|
|
465
|
-
//#region extensions/imessage/src/send-transport.ts
|
|
446
|
+
// extensions/imessage/src/send-transport.ts
|
|
466
447
|
function bindIMessageCliSend(handoff, options) {
|
|
467
448
|
const effect = captureEffectAuthority();
|
|
468
449
|
const assertReadAuthority = captureChannelReadAuthority();
|
|
469
|
-
const runCli = handoff.runCliJson ?? ((args) => runIMessageCliJsonCommand({
|
|
470
|
-
...options,
|
|
471
|
-
args
|
|
472
|
-
}));
|
|
473
450
|
return (args) => effect.initiate(() => {
|
|
474
451
|
assertReadAuthority?.();
|
|
475
452
|
handoff.assertDirectAdapterHandoff?.();
|
|
476
|
-
return
|
|
453
|
+
return runIMessageCliJsonCommand({
|
|
454
|
+
...options,
|
|
455
|
+
args
|
|
456
|
+
});
|
|
477
457
|
});
|
|
478
458
|
}
|
|
479
459
|
function normalizeIMessageRpcSendError(error) {
|
|
@@ -494,8 +474,7 @@ async function requestIMessageRpcSend(client, method, params, timeoutMs, handoff
|
|
|
494
474
|
throw normalizeIMessageRpcSendError(error);
|
|
495
475
|
}
|
|
496
476
|
}
|
|
497
|
-
|
|
498
|
-
//#region extensions/imessage/src/send.ts
|
|
477
|
+
// extensions/imessage/src/send.ts
|
|
499
478
|
const MIN_PENDING_PERSISTED_ECHO_TTL_MS = 6e4;
|
|
500
479
|
const PENDING_PERSISTED_ECHO_GRACE_MS = 5e3;
|
|
501
480
|
function resolveMessageId(result) {
|
|
@@ -521,74 +500,25 @@ function canResolveLatestSentMessageGuidFromChatDb(dbPath) {
|
|
|
521
500
|
return false;
|
|
522
501
|
}
|
|
523
502
|
}
|
|
524
|
-
async function resolveApprovalBindingMessageGuid(params) {
|
|
525
|
-
for (const key of [
|
|
526
|
-
"messageGuid",
|
|
527
|
-
"guid",
|
|
528
|
-
"messageId",
|
|
529
|
-
"message_id",
|
|
530
|
-
"id"
|
|
531
|
-
]) {
|
|
532
|
-
const guid = normalizeResolvedMessageGuid(params.result?.[key]);
|
|
533
|
-
if (guid) return guid;
|
|
534
|
-
}
|
|
535
|
-
const messageId = params.messageId?.trim();
|
|
536
|
-
if (!messageId || !isNumericMessageRowId(messageId)) return null;
|
|
537
|
-
if (params.resolveMessageGuidImpl) return normalizeResolvedMessageGuid(await params.resolveMessageGuidImpl({
|
|
538
|
-
dbPath: params.dbPath,
|
|
539
|
-
messageId
|
|
540
|
-
}));
|
|
541
|
-
const dbPath = params.dbPath?.trim();
|
|
542
|
-
return dbPath ? normalizeResolvedMessageGuid(await withIMessageReceiptGuidReader(dbPath, (read) => read({
|
|
543
|
-
type: "messageGuid",
|
|
544
|
-
input: { messageId }
|
|
545
|
-
}))) : null;
|
|
546
|
-
}
|
|
547
503
|
async function resolveFallbackSentMessageGuid(params) {
|
|
548
504
|
const dbPath = params.dbPath?.trim();
|
|
549
|
-
if (!
|
|
505
|
+
if (!dbPath || !canResolveLatestSentMessageGuidFromChatDb(dbPath)) return null;
|
|
550
506
|
const deadlineMs = Date.now() + 5e3;
|
|
551
|
-
|
|
507
|
+
return await withIMessageReceiptGuidReader(dbPath, async (read) => {
|
|
552
508
|
while (Date.now() <= deadlineMs) {
|
|
553
|
-
const resolved = normalizeResolvedMessageGuid(await
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
509
|
+
const resolved = normalizeResolvedMessageGuid(await read({
|
|
510
|
+
type: "latestSentGuid",
|
|
511
|
+
input: {
|
|
512
|
+
target: params.target,
|
|
513
|
+
text: params.text,
|
|
514
|
+
sentAfterMs: params.sentAfterMs
|
|
515
|
+
}
|
|
558
516
|
}));
|
|
559
517
|
if (resolved) return resolved;
|
|
560
518
|
if (Date.now() >= deadlineMs) return null;
|
|
561
519
|
await sleep(250);
|
|
562
520
|
}
|
|
563
521
|
return null;
|
|
564
|
-
};
|
|
565
|
-
if (params.resolveSentMessageGuidImpl) return await poll(params.resolveSentMessageGuidImpl);
|
|
566
|
-
if (!dbPath) return null;
|
|
567
|
-
return await withIMessageReceiptGuidReader(dbPath, (read) => poll(({ target, text, sentAfterMs }) => read({
|
|
568
|
-
type: "latestSentGuid",
|
|
569
|
-
input: {
|
|
570
|
-
target,
|
|
571
|
-
text,
|
|
572
|
-
sentAfterMs
|
|
573
|
-
}
|
|
574
|
-
})));
|
|
575
|
-
}
|
|
576
|
-
function createIMessageSendReceipt(params) {
|
|
577
|
-
const messageId = params.messageId.trim();
|
|
578
|
-
const results = normalizeIMessageMessageId(messageId) ? [{
|
|
579
|
-
channel: "imessage",
|
|
580
|
-
messageId,
|
|
581
|
-
meta: { targetKind: params.target.kind }
|
|
582
|
-
}] : [];
|
|
583
|
-
if (results[0]) {
|
|
584
|
-
if (params.target.kind === "chat_id") results[0].chatId = String(params.target.chatId);
|
|
585
|
-
else if (params.target.kind === "chat_guid") results[0].conversationId = params.target.chatGuid;
|
|
586
|
-
else if (params.target.kind === "chat_identifier") results[0].conversationId = params.target.chatIdentifier;
|
|
587
|
-
}
|
|
588
|
-
return createMessageReceiptFromOutboundResults({
|
|
589
|
-
results,
|
|
590
|
-
kind: params.kind,
|
|
591
|
-
...params.replyToId ? { replyToId: params.replyToId } : {}
|
|
592
522
|
});
|
|
593
523
|
}
|
|
594
524
|
async function withOriginalIMessageAttachmentPath(filePath, send) {
|
|
@@ -599,12 +529,6 @@ async function withOriginalIMessageAttachmentPath(filePath, send) {
|
|
|
599
529
|
prefix: "openclaw-imessage-outbound-"
|
|
600
530
|
}, async (workspace) => await send(await workspace.copyIn(filename, filePath)));
|
|
601
531
|
}
|
|
602
|
-
function resolveOutboundEchoScope(params) {
|
|
603
|
-
if (params.target.kind === "chat_id") return `${params.accountId}:${formatIMessageChatTarget(params.target.chatId)}`;
|
|
604
|
-
if (params.target.kind === "chat_guid") return `${params.accountId}:chat_guid:${params.target.chatGuid}`;
|
|
605
|
-
if (params.target.kind === "chat_identifier") return `${params.accountId}:chat_identifier:${params.target.chatIdentifier}`;
|
|
606
|
-
return `${params.accountId}:imessage:${params.target.to}`;
|
|
607
|
-
}
|
|
608
532
|
function resolveIMessageSendFailure(result) {
|
|
609
533
|
if (result.success !== false) return null;
|
|
610
534
|
return typeof result.error === "string" && result.error.trim() ? result.error.trim() : "iMessage action failed";
|
|
@@ -668,7 +592,7 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
668
592
|
const timeoutMs = opts.timeoutMs ?? Math.max(account.config.probeTimeoutMs ?? 0, 18e4);
|
|
669
593
|
const pendingEchoTtlMs = Math.max(MIN_PENDING_PERSISTED_ECHO_TTL_MS, Math.max(0, timeoutMs) + PENDING_PERSISTED_ECHO_GRACE_MS);
|
|
670
594
|
const region = opts.region?.trim() || account.config.region?.trim() || "US";
|
|
671
|
-
const maxBytes =
|
|
595
|
+
const maxBytes = opts.maxBytes ?? (account.config.mediaMaxMb ?? 16) * 1024 * 1024;
|
|
672
596
|
let message = opts.approvalPrompt ? addApprovalReactionHintToText({
|
|
673
597
|
text,
|
|
674
598
|
allowedDecisions: opts.approvalPrompt.allowedDecisions
|
|
@@ -678,7 +602,7 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
678
602
|
let filePath;
|
|
679
603
|
let mediaContentType;
|
|
680
604
|
if (opts.mediaUrl?.trim()) {
|
|
681
|
-
const resolved = await
|
|
605
|
+
const resolved = await resolveOutboundAttachmentFromUrl(opts.mediaUrl.trim(), maxBytes, {
|
|
682
606
|
mediaAccess: opts.mediaAccess,
|
|
683
607
|
localRoots: opts.mediaLocalRoots,
|
|
684
608
|
readFile: opts.mediaReadFile
|
|
@@ -721,7 +645,7 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
721
645
|
});
|
|
722
646
|
const requestOwnedRpc = async (method, rpcParams) => {
|
|
723
647
|
opts.assertDirectAdapterHandoff?.();
|
|
724
|
-
const rpcClient = await
|
|
648
|
+
const rpcClient = await createIMessageRpcClient({
|
|
725
649
|
cliPath,
|
|
726
650
|
dbPath,
|
|
727
651
|
remoteHost
|
|
@@ -732,10 +656,109 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
732
656
|
await rpcClient.stop();
|
|
733
657
|
}
|
|
734
658
|
};
|
|
735
|
-
const
|
|
659
|
+
const echoScope = target.kind === "chat_id" ? `${account.accountId}:${formatIMessageChatTarget(target.chatId)}` : target.kind === "chat_guid" ? `${account.accountId}:chat_guid:${target.chatGuid}` : target.kind === "chat_identifier" ? `${account.accountId}:chat_identifier:${target.chatIdentifier}` : `${account.accountId}:imessage:${target.to}`;
|
|
660
|
+
async function recordAcceptedSend(result, delivery) {
|
|
661
|
+
const isMessage = delivery.kind === "message";
|
|
662
|
+
const resolvedId = resolveMessageId(result);
|
|
663
|
+
const messageId = resolvedId ?? (result.ok || result.success || isMessage && result.status === "sent" ? "ok" : "unknown");
|
|
664
|
+
let guid = null;
|
|
665
|
+
for (const key of [
|
|
666
|
+
"messageGuid",
|
|
667
|
+
"guid",
|
|
668
|
+
"messageId",
|
|
669
|
+
"message_id",
|
|
670
|
+
"id"
|
|
671
|
+
]) {
|
|
672
|
+
guid = normalizeResolvedMessageGuid(result[key]);
|
|
673
|
+
if (guid) break;
|
|
674
|
+
}
|
|
675
|
+
if (!guid) {
|
|
676
|
+
const rowId = resolvedId?.trim();
|
|
677
|
+
if (rowId && isNumericMessageRowId(rowId)) {
|
|
678
|
+
const lookupPath = chatDbLookupPath?.trim();
|
|
679
|
+
if (lookupPath) guid = normalizeResolvedMessageGuid(await withIMessageReceiptGuidReader(lookupPath, (read) => read({
|
|
680
|
+
type: "messageGuid",
|
|
681
|
+
input: { messageId: rowId }
|
|
682
|
+
})));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (!guid && isMessage && opts.approvalPrompt && !filePath && !effectiveReplyToId) guid = await resolveFallbackSentMessageGuid({
|
|
686
|
+
dbPath: chatDbLookupPath,
|
|
687
|
+
target,
|
|
688
|
+
text: message,
|
|
689
|
+
sentAfterMs: delivery.startedAtMs
|
|
690
|
+
});
|
|
691
|
+
await rememberPersistedIMessageEcho({
|
|
692
|
+
scope: echoScope,
|
|
693
|
+
text: isMessage ? echoText : void 0,
|
|
694
|
+
media: echoMedia,
|
|
695
|
+
messageId: resolvedId ?? void 0
|
|
696
|
+
});
|
|
697
|
+
const providerChatGuid = isMessage ? normalizeOptionalString(result.chat_guid) ?? normalizeOptionalString(result.chatGuid) : void 0;
|
|
698
|
+
const confirmedService = isMessage ? resolveIMessageDirectChatService(resultService(result.service) ?? service, providerChatGuid) : void 0;
|
|
699
|
+
if (resolvedId && normalizeIMessageMessageId(resolvedId)) {
|
|
700
|
+
const chatContext = isMessage ? {
|
|
701
|
+
...chatContextFromIMessageTarget(target, confirmedService ?? service),
|
|
702
|
+
...providerChatGuid ? { chatGuid: providerChatGuid } : {}
|
|
703
|
+
} : {
|
|
704
|
+
chatGuid: target.kind === "chat_guid" ? target.chatGuid : target.kind === "chat_id" ? delivery.chatTarget : void 0,
|
|
705
|
+
chatIdentifier: target.kind === "chat_identifier" || target.kind === "handle" ? delivery.chatTarget : void 0,
|
|
706
|
+
chatId: target.kind === "chat_id" ? target.chatId : void 0
|
|
707
|
+
};
|
|
708
|
+
await rememberIMessageReplyCache({
|
|
709
|
+
accountId: account.accountId,
|
|
710
|
+
messageId: resolvedId,
|
|
711
|
+
...chatContext,
|
|
712
|
+
timestamp: Date.now(),
|
|
713
|
+
isFromMe: true
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
if (isMessage && message && guid && opts.approvalPrompt) {
|
|
717
|
+
const handle = target.kind === "handle" ? normalizeIMessageHandle(target.to) : void 0;
|
|
718
|
+
const conversation = {
|
|
719
|
+
...target.kind === "chat_guid" ? { chatGuid: target.chatGuid } : {},
|
|
720
|
+
...target.kind === "chat_identifier" ? { chatIdentifier: target.chatIdentifier } : {},
|
|
721
|
+
...target.kind === "chat_id" ? { chatId: target.chatId } : {},
|
|
722
|
+
...handle ? { handle } : {}
|
|
723
|
+
};
|
|
724
|
+
await registerIMessageApprovalReactionTarget({
|
|
725
|
+
accountId: account.accountId,
|
|
726
|
+
conversation,
|
|
727
|
+
messageId: guid,
|
|
728
|
+
approvalId: opts.approvalPrompt.approvalId,
|
|
729
|
+
approvalKind: opts.approvalPrompt.approvalKind,
|
|
730
|
+
allowedDecisions: opts.approvalPrompt.allowedDecisions
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
const replyToId = isMessage ? effectiveReplyToId : resolvedReplyToId;
|
|
734
|
+
const receiptMessageId = messageId.trim();
|
|
735
|
+
const results = normalizeIMessageMessageId(receiptMessageId) ? [{
|
|
736
|
+
channel: "imessage",
|
|
737
|
+
messageId: receiptMessageId,
|
|
738
|
+
meta: { targetKind: target.kind }
|
|
739
|
+
}] : [];
|
|
740
|
+
if (results[0]) {
|
|
741
|
+
if (target.kind === "chat_id") results[0].chatId = String(target.chatId);
|
|
742
|
+
else if (target.kind === "chat_guid") results[0].conversationId = target.chatGuid;
|
|
743
|
+
else if (target.kind === "chat_identifier") results[0].conversationId = target.chatIdentifier;
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
messageId,
|
|
747
|
+
...guid ? { guid } : {},
|
|
748
|
+
...confirmedService ? { service: confirmedService } : {},
|
|
749
|
+
...providerChatGuid ? { chatGuid: providerChatGuid } : {},
|
|
750
|
+
sentText: isMessage ? message : "",
|
|
751
|
+
...isMessage && echoText ? { echoText } : {},
|
|
752
|
+
...echoMedia ? { echoMedia } : {},
|
|
753
|
+
receipt: createMessageReceiptFromOutboundResults({
|
|
754
|
+
results,
|
|
755
|
+
kind: isMessage ? filePath ? "media" : "text" : delivery.audioAsVoice ? "voice" : "media",
|
|
756
|
+
...replyToId ? { replyToId } : {}
|
|
757
|
+
})
|
|
758
|
+
};
|
|
759
|
+
}
|
|
736
760
|
async function trySendAttachment(attachmentFilePath) {
|
|
737
|
-
const { audioAsVoice,
|
|
738
|
-
const accountId = account.accountId;
|
|
761
|
+
const { audioAsVoice, assertDirectAdapterHandoff, onPlatformSendDispatch } = opts;
|
|
739
762
|
if (audioAsVoice && sendTransport === "applescript") throw new Error("iMessage voice messages require bridge transport; AppleScript cannot send native voice notes. Set sendTransport to bridge or auto.");
|
|
740
763
|
if (target.kind === "handle" && !audioAsVoice && sendTransport !== "bridge" && (service === "sms" || service === "imessage")) return null;
|
|
741
764
|
if (remoteHost && sendTransport === "applescript") return null;
|
|
@@ -767,10 +790,6 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
767
790
|
return null;
|
|
768
791
|
}
|
|
769
792
|
assertDirectAdapterHandoff?.();
|
|
770
|
-
const echoScope = resolveOutboundEchoScope({
|
|
771
|
-
accountId,
|
|
772
|
-
target
|
|
773
|
-
});
|
|
774
793
|
let result;
|
|
775
794
|
let pendingEchoKey;
|
|
776
795
|
try {
|
|
@@ -781,7 +800,7 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
781
800
|
pending: true
|
|
782
801
|
});
|
|
783
802
|
result = await withOriginalIMessageAttachmentPath(attachmentFilePath, async (attachmentPath) => {
|
|
784
|
-
if (remoteHost) return await
|
|
803
|
+
if (remoteHost) return await withIMessageRemoteFile({
|
|
785
804
|
remoteHost,
|
|
786
805
|
localPath: attachmentPath,
|
|
787
806
|
timeoutMs,
|
|
@@ -820,40 +839,11 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
820
839
|
if (!audioAsVoice && isAttachmentCommandFallbackError(error)) return null;
|
|
821
840
|
throw error;
|
|
822
841
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
result,
|
|
828
|
-
resolveMessageGuidImpl
|
|
842
|
+
return await recordAcceptedSend(result, {
|
|
843
|
+
kind: "attachment",
|
|
844
|
+
chatTarget: attachmentChatTarget,
|
|
845
|
+
audioAsVoice
|
|
829
846
|
});
|
|
830
|
-
const messageId = resolvedId ?? (result.ok || result.success ? "ok" : "unknown");
|
|
831
|
-
await rememberPersistedIMessageEcho({
|
|
832
|
-
scope: echoScope,
|
|
833
|
-
media: echoMedia,
|
|
834
|
-
messageId: resolvedId ?? void 0
|
|
835
|
-
});
|
|
836
|
-
if (resolvedId && normalizeIMessageMessageId(resolvedId)) await rememberIMessageReplyCache({
|
|
837
|
-
accountId,
|
|
838
|
-
messageId: resolvedId,
|
|
839
|
-
chatGuid: target.kind === "chat_guid" ? target.chatGuid : target.kind === "chat_id" ? attachmentChatTarget : void 0,
|
|
840
|
-
chatIdentifier: target.kind === "chat_identifier" || target.kind === "handle" ? attachmentChatTarget : void 0,
|
|
841
|
-
chatId: target.kind === "chat_id" ? target.chatId : void 0,
|
|
842
|
-
timestamp: Date.now(),
|
|
843
|
-
isFromMe: true
|
|
844
|
-
});
|
|
845
|
-
return {
|
|
846
|
-
messageId,
|
|
847
|
-
...approvalBindingMessageId ? { guid: approvalBindingMessageId } : {},
|
|
848
|
-
sentText: "",
|
|
849
|
-
...echoMedia ? { echoMedia } : {},
|
|
850
|
-
receipt: createIMessageSendReceipt({
|
|
851
|
-
messageId,
|
|
852
|
-
target,
|
|
853
|
-
kind: audioAsVoice ? "voice" : "media",
|
|
854
|
-
...resolvedReplyToId ? { replyToId: resolvedReplyToId } : {}
|
|
855
|
-
})
|
|
856
|
-
};
|
|
857
847
|
}
|
|
858
848
|
if (filePath && (!resolvedReplyToId || opts.audioAsVoice)) {
|
|
859
849
|
const attachmentResult = await trySendAttachment(filePath);
|
|
@@ -895,6 +885,7 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
895
885
|
}
|
|
896
886
|
}
|
|
897
887
|
const params = {
|
|
888
|
+
...iMessageTargetRpcParams(target),
|
|
898
889
|
text: message,
|
|
899
890
|
service: service || "auto",
|
|
900
891
|
region,
|
|
@@ -903,16 +894,8 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
903
894
|
if (resolvedReplyToId) params.reply_to = resolvedReplyToId;
|
|
904
895
|
if (formatted.ranges.length > 0) params.formatting = formatted.ranges;
|
|
905
896
|
if (filePath) params.file = filePath;
|
|
906
|
-
if (target.kind === "chat_id") params.chat_id = target.chatId;
|
|
907
|
-
else if (target.kind === "chat_guid") params.chat_guid = target.chatGuid;
|
|
908
|
-
else if (target.kind === "chat_identifier") params.chat_identifier = target.chatIdentifier;
|
|
909
|
-
else params.to = target.to;
|
|
910
|
-
const echoScope = resolveOutboundEchoScope({
|
|
911
|
-
accountId: account.accountId,
|
|
912
|
-
target
|
|
913
|
-
});
|
|
914
897
|
opts.assertDirectAdapterHandoff?.();
|
|
915
|
-
const client = opts.client ?? await
|
|
898
|
+
const client = opts.client ?? await createIMessageRpcClient({
|
|
916
899
|
cliPath,
|
|
917
900
|
dbPath,
|
|
918
901
|
remoteHost
|
|
@@ -921,7 +904,7 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
921
904
|
const requestSuccessfulSend = async (sendParams) => {
|
|
922
905
|
const request = async (nativeParams) => await requestIMessageRpcSend(client, "send", nativeParams, timeoutMs, opts);
|
|
923
906
|
const response = filePath ? await withOriginalIMessageAttachmentPath(filePath, async (attachmentPath) => {
|
|
924
|
-
if (remoteHost) return await
|
|
907
|
+
if (remoteHost) return await withIMessageRemoteFile({
|
|
925
908
|
remoteHost,
|
|
926
909
|
localPath: attachmentPath,
|
|
927
910
|
timeoutMs,
|
|
@@ -960,14 +943,13 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
960
943
|
result = await requestSuccessfulSend(plainParams);
|
|
961
944
|
effectiveReplyToId = void 0;
|
|
962
945
|
} else if (filePath || !isIMessageRpcSendTimeout(error)) throw error;
|
|
963
|
-
else if (!opts.approvalPrompt || resolvedReplyToId || !
|
|
946
|
+
else if (!opts.approvalPrompt || resolvedReplyToId || !canResolveLatestSentMessageGuidFromChatDb(chatDbLookupPath)) throw error;
|
|
964
947
|
else {
|
|
965
948
|
const recoveredGuid = await resolveFallbackSentMessageGuid({
|
|
966
949
|
dbPath: chatDbLookupPath,
|
|
967
950
|
target,
|
|
968
951
|
text: message,
|
|
969
|
-
sentAfterMs: sendStartedAtMs
|
|
970
|
-
resolveSentMessageGuidImpl: opts.resolveSentMessageGuidImpl
|
|
952
|
+
sentAfterMs: sendStartedAtMs
|
|
971
953
|
});
|
|
972
954
|
if (recoveredGuid) result = {
|
|
973
955
|
guid: recoveredGuid,
|
|
@@ -976,72 +958,10 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
976
958
|
else throw error;
|
|
977
959
|
}
|
|
978
960
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
dbPath: chatDbLookupPath,
|
|
983
|
-
messageId: resolvedId,
|
|
984
|
-
result,
|
|
985
|
-
resolveMessageGuidImpl: opts.resolveMessageGuidImpl
|
|
986
|
-
});
|
|
987
|
-
if (!approvalBindingMessageId && opts.approvalPrompt && !filePath && !effectiveReplyToId) approvalBindingMessageId = await resolveFallbackSentMessageGuid({
|
|
988
|
-
dbPath: chatDbLookupPath,
|
|
989
|
-
target,
|
|
990
|
-
text: message,
|
|
991
|
-
sentAfterMs: sendStartedAtMs,
|
|
992
|
-
resolveSentMessageGuidImpl: opts.resolveSentMessageGuidImpl
|
|
993
|
-
});
|
|
994
|
-
await rememberPersistedIMessageEcho({
|
|
995
|
-
scope: echoScope,
|
|
996
|
-
text: echoText,
|
|
997
|
-
media: echoMedia,
|
|
998
|
-
messageId: resolvedId ?? void 0
|
|
961
|
+
return await recordAcceptedSend(result, {
|
|
962
|
+
kind: "message",
|
|
963
|
+
startedAtMs: sendStartedAtMs
|
|
999
964
|
});
|
|
1000
|
-
const providerChatGuid = normalizeOptionalString(result.chat_guid) ?? normalizeOptionalString(result.chatGuid);
|
|
1001
|
-
const confirmedService = resolveIMessageDirectChatService(resultService(result.service) ?? service, providerChatGuid);
|
|
1002
|
-
if (resolvedId && normalizeIMessageMessageId(resolvedId)) {
|
|
1003
|
-
const chatContext = chatContextFromIMessageTarget(target, confirmedService ?? service);
|
|
1004
|
-
await rememberIMessageReplyCache({
|
|
1005
|
-
accountId: account.accountId,
|
|
1006
|
-
messageId: resolvedId,
|
|
1007
|
-
...chatContext,
|
|
1008
|
-
...providerChatGuid ? { chatGuid: providerChatGuid } : {},
|
|
1009
|
-
timestamp: Date.now(),
|
|
1010
|
-
isFromMe: true
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
if (message && approvalBindingMessageId && opts.approvalPrompt) {
|
|
1014
|
-
const handleForKey = target.kind === "handle" ? normalizeIMessageHandle(target.to) : void 0;
|
|
1015
|
-
const conversation = {
|
|
1016
|
-
...target.kind === "chat_guid" ? { chatGuid: target.chatGuid } : {},
|
|
1017
|
-
...target.kind === "chat_identifier" ? { chatIdentifier: target.chatIdentifier } : {},
|
|
1018
|
-
...target.kind === "chat_id" ? { chatId: target.chatId } : {},
|
|
1019
|
-
...handleForKey ? { handle: handleForKey } : {}
|
|
1020
|
-
};
|
|
1021
|
-
await registerIMessageApprovalReactionTarget({
|
|
1022
|
-
accountId: account.accountId,
|
|
1023
|
-
conversation,
|
|
1024
|
-
messageId: approvalBindingMessageId,
|
|
1025
|
-
approvalId: opts.approvalPrompt.approvalId,
|
|
1026
|
-
approvalKind: opts.approvalPrompt.approvalKind,
|
|
1027
|
-
allowedDecisions: opts.approvalPrompt.allowedDecisions
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
return {
|
|
1031
|
-
messageId,
|
|
1032
|
-
...approvalBindingMessageId ? { guid: approvalBindingMessageId } : {},
|
|
1033
|
-
...confirmedService ? { service: confirmedService } : {},
|
|
1034
|
-
...providerChatGuid ? { chatGuid: providerChatGuid } : {},
|
|
1035
|
-
sentText: message,
|
|
1036
|
-
...echoText ? { echoText } : {},
|
|
1037
|
-
...echoMedia ? { echoMedia } : {},
|
|
1038
|
-
receipt: createIMessageSendReceipt({
|
|
1039
|
-
messageId,
|
|
1040
|
-
target,
|
|
1041
|
-
kind: filePath ? "media" : "text",
|
|
1042
|
-
...effectiveReplyToId ? { replyToId: effectiveReplyToId } : {}
|
|
1043
|
-
})
|
|
1044
|
-
};
|
|
1045
965
|
} catch (error) {
|
|
1046
966
|
await forgetPersistedIMessageEchoKey(pendingEchoKey);
|
|
1047
967
|
throw error;
|
|
@@ -1049,5 +969,4 @@ async function sendMessageIMessage(to, text, opts) {
|
|
|
1049
969
|
if (shouldClose) await client.stop();
|
|
1050
970
|
}
|
|
1051
971
|
}
|
|
1052
|
-
//#endregion
|
|
1053
972
|
export { iMessageApprovalPollTargets as a, buildApprovalPollOptions as i, hasPersistedIMessageEcho as n, mapSentPollOptionsToDecisions as o, normalizeIMessageEchoText as r, maybeResolveIMessageApprovalPollVote as s, sendMessageIMessage as t };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as resolveDefaultIMessageAccountId, o as resolveIMessageAccount } from "./accounts-
|
|
1
|
+
import { s as normalizeIMessageHandle, u as IMESSAGE_CHAT_TARGET_PREFIX_RE } from "./targets-C7CIWJ0k.mjs";
|
|
2
|
+
import { a as resolveDefaultIMessageAccountId, o as resolveIMessageAccount } from "./accounts-C1Ypv3Wn.mjs";
|
|
3
3
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { parseAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
|
|
5
5
|
import { createChannelDmPolicy } from "openclaw/plugin-sdk/channel-dm-policy";
|
|
6
6
|
import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
7
7
|
import { createCliPathTextInput, createDelegatedSetupWizardProxy, createDelegatedTextInputShouldPrompt, createPatchedAccountSetupAdapter, createSetupTranslator, promptParsedAllowFromForAccount, setAccountAllowFromForChannel, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup-runtime";
|
|
8
8
|
import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
|
9
|
-
|
|
9
|
+
// extensions/imessage/src/setup-core.ts
|
|
10
10
|
const t = createSetupTranslator();
|
|
11
11
|
const channel = "imessage";
|
|
12
12
|
const IMESSAGE_INSTALL_COMMAND = "brew install steipete/tap/imsg";
|
|
@@ -191,5 +191,4 @@ function createIMessageSetupWizardProxy(loadWizard) {
|
|
|
191
191
|
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
//#endregion
|
|
195
194
|
export { imessageCompletionNote as a, imessageSetupStatusBase as c, parseIMessageAllowFromEntries as d, createIMessageSetupWizardProxy as i, isAutoManagedIMessageCliPath as l, IMESSAGE_UPDATE_COMMAND as n, imessageDmPolicy as o, createIMessageCliPathTextInput as r, imessageSetupContract as s, IMESSAGE_INSTALL_COMMAND as t, normalizeIMessageCliPathForSetup as u };
|