






















11import {
2+buildChannelApprovalExpiredText,
3+buildChannelApprovalResolvedText,
24createChannelApprovalNativeRuntimeAdapter,
3-type ExpiredApprovalView,
45type PendingApprovalView,
5-type ResolvedApprovalView,
6+resolvePreparedApprovalAccountId,
67} from "openclaw/plugin-sdk/approval-handler-runtime";
78import { buildChannelApprovalNativeTargetKey } from "openclaw/plugin-sdk/approval-native-runtime";
89import { buildApprovalReactionPendingContent } from "openclaw/plugin-sdk/approval-reaction-runtime";
910import type { ExecApprovalReplyDecision } from "openclaw/plugin-sdk/approval-reply-runtime";
1011import {
11-buildApprovalResolvedReplyPayload,
12-buildPluginApprovalExpiredMessage,
13-buildPluginApprovalResolvedMessage,
1412type ExecApprovalRequest,
15-type ExecApprovalResolved,
1613type PluginApprovalRequest,
17-type PluginApprovalResolved,
1814} from "openclaw/plugin-sdk/approval-runtime";
1915import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
20-import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
2116import {
2217registerIMessageApprovalReactionTarget,
2318unregisterIMessageApprovalReactionTarget,
@@ -30,7 +25,6 @@ import { normalizeIMessageHandle, parseIMessageTarget } from "./targets.js";
3025const log = createSubsystemLogger("imessage/approvals");
31263227type ApprovalRequest = ExecApprovalRequest | PluginApprovalRequest;
33-type ApprovalResolved = ExecApprovalResolved | PluginApprovalResolved;
3428type IMessagePendingDelivery = {
3529text: string;
3630allowedDecisions: readonly ExecApprovalReplyDecision[];
@@ -66,42 +60,6 @@ function buildPendingPayload(params: {
6660};
6761}
686269-function buildResolvedText(params: {
70-request: ApprovalRequest;
71-resolved: ApprovalResolved;
72-view: ResolvedApprovalView;
73-}): string {
74-if (params.view.approvalKind === "plugin") {
75-return buildPluginApprovalResolvedMessage(params.resolved as PluginApprovalResolved);
76-}
77-const resolvedByText = params.resolved.resolvedBy
78- ? ` Resolved by ${params.resolved.resolvedBy}.`
79- : "";
80-const payload = buildApprovalResolvedReplyPayload({
81-approvalId: params.request.id,
82-approvalSlug: params.request.id.slice(0, 8),
83-text: `✅ Exec approval ${params.resolved.decision}.${resolvedByText} ID: ${params.request.id}`,
84-});
85-return payload.text ?? "";
86-}
87-88-function buildExpiredText(params: { request: ApprovalRequest; view: ExpiredApprovalView }): string {
89-if (params.view.approvalKind === "plugin") {
90-return buildPluginApprovalExpiredMessage(params.request as PluginApprovalRequest);
91-}
92-return `⏱️ Exec approval expired. ID: ${params.request.id}`;
93-}
94-95-function resolvePreparedAccountId(params: {
96-plannedAccountId?: string | null;
97-contextAccountId?: string | null;
98-}): string | undefined {
99-return (
100-normalizeOptionalString(params.plannedAccountId) ??
101-normalizeOptionalString(params.contextAccountId)
102-);
103-}
104-10563function buildConversationKeyForTarget(to: string): IMessageApprovalConversationKey | null {
10664try {
10765const parsed = parseIMessageTarget(to);
@@ -138,11 +96,11 @@ export const imessageApprovalNativeRuntime = createChannelApprovalNativeRuntimeA
13896buildPendingPayload({ request, approvalKind, nowMs, view }),
13997buildResolvedResult: ({ request, resolved, view }) => ({
14098kind: "update",
141-payload: { text: buildResolvedText({ request, resolved, view }) },
99+payload: { text: buildChannelApprovalResolvedText({ request, resolved, view }) },
142100}),
143101buildExpiredResult: ({ request, view }) => ({
144102kind: "update",
145-payload: { text: buildExpiredText({ request, view }) },
103+payload: { text: buildChannelApprovalExpiredText({ request, view }) },
146104}),
147105},
148106transport: {
@@ -153,7 +111,7 @@ export const imessageApprovalNativeRuntime = createChannelApprovalNativeRuntimeA
153111}
154112const prepared: PreparedIMessageApprovalTarget = {
155113 to,
156-accountId: resolvePreparedAccountId({
114+accountId: resolvePreparedApprovalAccountId({
157115plannedAccountId: (plannedTarget.target as { accountId?: string | null }).accountId,
158116contextAccountId: accountId,
159117}),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。