
























@@ -1,5 +1,6 @@
11import type { ReplyPayload } from "../../auto-reply/reply-payload.js";
22import { clearHistoryEntriesIfEnabled } from "../../auto-reply/reply/history.js";
3+import { EMPTY_CHANNEL_TURN_DISPATCH_COUNTS } from "./dispatch-result.js";
34export { buildChannelTurnContext, filterChannelTurnSupplementalContext } from "./context.js";
45export type { BuildChannelTurnContextParams } from "./context.js";
56import type {
@@ -15,6 +16,7 @@ import type {
1516PreparedChannelTurn,
1617PreflightFacts,
1718RunChannelTurnParams,
19+RunResolvedChannelTurnParams,
1820} from "./types.js";
1921export {
2022EMPTY_CHANNEL_TURN_DISPATCH_COUNTS,
@@ -49,6 +51,7 @@ export type {
4951ReplyPlanFacts,
5052RouteFacts,
5153RunChannelTurnParams,
54+RunResolvedChannelTurnParams,
5255SenderFacts,
5356SupplementalContextFacts,
5457} from "./types.js";
@@ -110,6 +113,15 @@ function clearPendingHistoryAfterTurn(params?: ChannelTurnHistoryFinalizeOptions
110113});
111114}
112115116+function resolveObserveOnlyDispatchResult<TDispatchResult>(
117+params: PreparedChannelTurn<TDispatchResult>,
118+): TDispatchResult {
119+return (params.observeOnlyDispatchResult ?? {
120+queuedFinal: false,
121+counts: EMPTY_CHANNEL_TURN_DISPATCH_COUNTS,
122+}) as TDispatchResult;
123+}
124+113125export async function dispatchAssembledChannelTurn(
114126params: AssembledChannelTurn,
115127): Promise<DispatchedChannelTurnResult> {
@@ -158,7 +170,14 @@ async function dispatchResolvedChannelTurn<TDispatchResult>(
158170},
159171): Promise<DispatchedChannelTurnResult<TDispatchResult>> {
160172if (isPreparedChannelTurn(params)) {
161-return await runPreparedChannelTurn(params);
173+return await runPreparedChannelTurn(
174+params.admission.kind === "observeOnly"
175+ ? {
176+ ...params,
177+runDispatch: async () => resolveObserveOnlyDispatchResult(params),
178+}
179+ : params,
180+);
162181}
163182return (await dispatchAssembledChannelTurn(
164183params,
@@ -431,3 +450,21 @@ export async function runChannelTurn<
431450432451return result;
433452}
453+454+export async function runResolvedChannelTurn<
455+TRaw,
456+TDispatchResult = DispatchedChannelTurnResult["dispatchResult"],
457+>(
458+params: RunResolvedChannelTurnParams<TRaw, TDispatchResult>,
459+): Promise<ChannelTurnResult<TDispatchResult>> {
460+return await runChannelTurn({
461+channel: params.channel,
462+accountId: params.accountId,
463+raw: params.raw,
464+log: params.log,
465+adapter: {
466+ingest: (raw) => (typeof params.input === "function" ? params.input(raw) : params.input),
467+resolveTurn: params.resolveTurn,
468+},
469+});
470+}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。