mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 09:50:48 +01:00
Send compatible GitHub review updates to active native turns after normal admission. Preserve durable receipt fallback and recover acknowledgements without consuming unsent edits. Keep legacy conversation batching and existing identity, source-trust, and attachment boundaries. Add PostgreSQL regressions for concurrency, restart recovery, and edited inputs.
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import type { Db } from "@paperclipai/db";
|
|
import { reconcileSteeredIdentity, storedSteeringAcknowledgement, type RunIdentityContext } from "./run-identity.js";
|
|
import { NativeSessionSteeringError, steerNativeSession } from "./native-runtime/native-session-executor.js";
|
|
|
|
export function steeringDeliveryIsUncertain(error: unknown, attempted: boolean): boolean {
|
|
return attempted && (!(error instanceof NativeSessionSteeringError) || error.code === "steering_timeout");
|
|
}
|
|
|
|
export async function deliverSteeredMessage(db: Db, input: {
|
|
executor?: Pick<Db, "select">;
|
|
companyId: string;
|
|
runId: string;
|
|
messageId: string;
|
|
message: string;
|
|
identity: RunIdentityContext | null;
|
|
onAcknowledged?: () => Promise<void>;
|
|
}) {
|
|
return await storedSteeringAcknowledgement(input.executor ?? db, input.identity ?? {
|
|
companyId: input.companyId, runId: input.runId, messageId: input.messageId,
|
|
}) ?? await steerNativeSession({
|
|
runId: input.runId, correlationId: input.messageId, message: input.message,
|
|
onAcknowledged: input.onAcknowledged ?? (input.identity ? () => reconcileSteeredIdentity(db, input.identity!) : undefined),
|
|
});
|
|
}
|