mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 08:41:38 +00:00
* clawdbot-d08: route transcript writers through accessor seam * fix: refresh transcript writer seam proofs * refactor: add transcript turn writer operation * fix: preserve transcript writer store targeting * fix: preserve transcript append lock ordering * refactor: guard transcript turn session rebound * clawdbot-d02.1.9.1.35: route transcript rewrites through runtime scope * fix: preserve transcript event append return type * fix: publish transcript turn owned entries
94 lines
2.9 KiB
TypeScript
94 lines
2.9 KiB
TypeScript
// User-turn transcript type contracts shared by runtime and queue option types.
|
|
import type { AgentMessage } from "../../packages/agent-core/src/types.js";
|
|
import type { InputProvenance } from "./input-provenance.js";
|
|
|
|
export type UserTurnSessionEntry = {
|
|
sessionId: string;
|
|
updatedAt: number;
|
|
sessionFile?: string;
|
|
threadId?: string | number;
|
|
} & Record<string, unknown>;
|
|
|
|
export type PersistedUserTurnMediaInput = {
|
|
path?: string | null;
|
|
url?: string | null;
|
|
contentType?: string | null;
|
|
kind?: string | null;
|
|
};
|
|
|
|
export type PersistedUserTurnMessage = Extract<AgentMessage, { role: "user" }>;
|
|
|
|
export type UserTurnInput = {
|
|
text?: string | null;
|
|
media?: readonly PersistedUserTurnMediaInput[] | null;
|
|
timestamp?: number;
|
|
idempotencyKey?: string;
|
|
provenance?: InputProvenance;
|
|
mediaOnlyText?: string;
|
|
};
|
|
|
|
export type UserTurnTranscriptUpdateMode = "inline" | "none";
|
|
|
|
export type UserTurnBeforeMessageWrite = (params: {
|
|
message: PersistedUserTurnMessage;
|
|
agentId?: string;
|
|
sessionKey?: string;
|
|
}) => AgentMessage | null;
|
|
|
|
export type UserTurnTranscriptPersistenceTarget = {
|
|
sessionId: string;
|
|
sessionKey: string;
|
|
sessionEntry: UserTurnSessionEntry | undefined;
|
|
sessionStore?: Record<string, UserTurnSessionEntry>;
|
|
storePath?: string;
|
|
agentId: string;
|
|
threadId?: string | number;
|
|
cwd?: string;
|
|
config?: unknown;
|
|
beforeMessageWrite?: UserTurnBeforeMessageWrite;
|
|
};
|
|
|
|
export type UserTurnTranscriptFileTarget = {
|
|
transcriptPath: string;
|
|
sessionId?: string;
|
|
agentId?: string;
|
|
sessionKey?: string;
|
|
cwd?: string;
|
|
config?: unknown;
|
|
};
|
|
|
|
export type UserTurnTranscriptTarget =
|
|
| UserTurnTranscriptPersistenceTarget
|
|
| UserTurnTranscriptFileTarget;
|
|
|
|
export type UserTurnTranscriptPersistResult = {
|
|
sessionFile: string;
|
|
sessionEntry: UserTurnSessionEntry | undefined;
|
|
messageId: string;
|
|
message: PersistedUserTurnMessage;
|
|
};
|
|
|
|
export type UserTurnTranscriptTargetResolver =
|
|
| UserTurnTranscriptTarget
|
|
| (() => UserTurnTranscriptTarget | undefined | Promise<UserTurnTranscriptTarget | undefined>);
|
|
|
|
export type UserTurnTranscriptRecorder = {
|
|
readonly message: PersistedUserTurnMessage | undefined;
|
|
resolveMessage: () => Promise<PersistedUserTurnMessage | undefined>;
|
|
markRuntimePersistencePending: (pending: Promise<void>) => void;
|
|
markRuntimePersisted: (message?: PersistedUserTurnMessage) => void;
|
|
markBlocked: () => void;
|
|
hasPersisted: () => boolean;
|
|
isBlocked: () => boolean;
|
|
hasRuntimePersistencePending: () => boolean;
|
|
waitForRuntimePersistence: () => Promise<void>;
|
|
persistApproved: (params?: {
|
|
target?: UserTurnTranscriptTargetResolver;
|
|
updateMode?: UserTurnTranscriptUpdateMode;
|
|
}) => Promise<UserTurnTranscriptPersistResult | undefined>;
|
|
persistFallback: (params?: {
|
|
target?: UserTurnTranscriptTargetResolver;
|
|
updateMode?: UserTurnTranscriptUpdateMode;
|
|
}) => Promise<UserTurnTranscriptPersistResult | undefined>;
|
|
};
|