openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
65 lines (64 loc) • 3.16 kB
JavaScript
import { r as createLazyRuntimeModule } from "./lazy-runtime-zGjszCtt.mjs";
import { t as warnPluginSdkDeprecation } from "./sdk-deprecation-D5N9acnu.mjs";
//#region src/infra/approval-handler-adapter-runtime.ts
/** Runtime-context capability key used by channels to register native approval resources. */
const CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY = "approval.native";
/** @deprecated Use createLazyChannelApprovalNativeRuntimeAdapterAsync with awaited availability callbacks. Final compatibility day: 2026-12-31. Removal in the first January 2027 stable release. */
function createLazyChannelApprovalNativeRuntimeAdapter(e) {
warnPluginSdkDeprecation({
family: "approval-session-routing",
method: "createLazyChannelApprovalNativeRuntimeAdapter",
replacement: "createLazyChannelApprovalNativeRuntimeAdapterAsync"
});
return {
...createLazyChannelApprovalNativeRuntimeAdapterAsync(e),
availability: {
isConfigured: e.isConfigured,
shouldHandle: e.shouldHandle
}
};
}
/** Creates an approval runtime adapter that loads heavy channel code only when delivery hooks run. */
function createLazyChannelApprovalNativeRuntimeAdapterAsync(e) {
const t = createLazyRuntimeModule(e.load);
let n = null;
const loadResolvedRuntime = async () => {
const e = await t();
n = e;
return e;
};
const loadHook = async (e) => e(await loadResolvedRuntime());
return {
...e.eventKinds ? { eventKinds: e.eventKinds } : {},
...e.resolveApprovalKind ? { resolveApprovalKind: e.resolveApprovalKind } : {},
availability: {
isConfigured: e.isConfigured,
shouldHandle: e.shouldHandle
},
presentation: {
buildPendingPayload: async (e) => (await loadHook((e) => e.presentation.buildPendingPayload))(e),
buildResolvedResult: async (e) => (await loadHook((e) => e.presentation.buildResolvedResult))(e),
buildExpiredResult: async (e) => (await loadHook((e) => e.presentation.buildExpiredResult))(e)
},
transport: {
prepareTarget: async (e) => (await loadHook((e) => e.transport.prepareTarget))(e),
deliverPending: async (e) => (await loadHook((e) => e.transport.deliverPending))(e),
updateEntry: async (e) => (await loadHook((e) => e.transport.updateEntry))?.(e),
deleteEntry: async (e) => (await loadHook((e) => e.transport.deleteEntry))?.(e)
},
interactions: {
bindPending: async (e) => (await loadHook((e) => e.interactions?.bindPending))?.(e) ?? null,
unbindPending: async (e) => (await loadHook((e) => e.interactions?.unbindPending))?.(e),
clearPendingActions: async (e) => (await loadHook((e) => e.interactions?.clearPendingActions))?.(e),
cancelDelivered: async (e) => (await loadHook((e) => e.interactions?.cancelDelivered))?.(e)
},
observe: {
onDeliveryError: (e) => n?.observe?.onDeliveryError?.(e),
onDuplicateSkipped: (e) => n?.observe?.onDuplicateSkipped?.(e),
onDelivered: (e) => n?.observe?.onDelivered?.(e),
onFinalized: (e) => n?.observe?.onFinalized?.(e)
}
};
}
//#endregion
export { createLazyChannelApprovalNativeRuntimeAdapter as n, createLazyChannelApprovalNativeRuntimeAdapterAsync as r, CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY as t };