Files
t3code/packages/contracts/src/checkpointDiff.ts
T
Julius Marminge a2944d622a Integrate orchestration v2 with the application runtime
Retain the existing event-sourced application data plane for projects and shell state while making orchestration v2 the sole agent runtime. Adapt v2 events and receipts to the shared infrastructure and remove the v1 provider reactors.
2026-08-15 16:49:25 +02:00

67 lines
2.2 KiB
TypeScript

import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import * as SchemaIssue from "effect/SchemaIssue";
import * as Struct from "effect/Struct";
import { NonNegativeInt, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
export const TurnCountRange = Schema.Struct({
fromTurnCount: NonNegativeInt,
toTurnCount: NonNegativeInt,
}).check(
Schema.makeFilter(
(input) =>
input.fromTurnCount <= input.toTurnCount ||
new SchemaIssue.InvalidValue(Option.some(input.fromTurnCount), {
message: "fromTurnCount must be less than or equal to toTurnCount",
}),
{ identifier: "OrchestrationTurnDiffRange" },
),
);
export const ThreadTurnDiff = TurnCountRange.mapFields(
Struct.assign({
threadId: ThreadId,
diff: Schema.String,
}),
{ unsafePreserveChecks: true },
);
export const OrchestrationGetTurnDiffInput = TurnCountRange.mapFields(
Struct.assign({
threadId: ThreadId,
ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
}),
{ unsafePreserveChecks: true },
);
export type OrchestrationGetTurnDiffInput = typeof OrchestrationGetTurnDiffInput.Type;
export const OrchestrationGetTurnDiffResult = ThreadTurnDiff;
export type OrchestrationGetTurnDiffResult = typeof OrchestrationGetTurnDiffResult.Type;
export const OrchestrationGetFullThreadDiffInput = Schema.Struct({
threadId: ThreadId,
toTurnCount: NonNegativeInt,
ignoreWhitespace: Schema.optionalKey(Schema.Boolean),
});
export type OrchestrationGetFullThreadDiffInput = typeof OrchestrationGetFullThreadDiffInput.Type;
export const OrchestrationGetFullThreadDiffResult = ThreadTurnDiff;
export type OrchestrationGetFullThreadDiffResult = typeof OrchestrationGetFullThreadDiffResult.Type;
export class OrchestrationGetTurnDiffError extends Schema.TaggedErrorClass<OrchestrationGetTurnDiffError>()(
"OrchestrationGetTurnDiffError",
{
message: TrimmedNonEmptyString,
cause: Schema.optional(Schema.Defect()),
},
) {}
export class OrchestrationGetFullThreadDiffError extends Schema.TaggedErrorClass<OrchestrationGetFullThreadDiffError>()(
"OrchestrationGetFullThreadDiffError",
{
message: TrimmedNonEmptyString,
cause: Schema.optional(Schema.Defect()),
},
) {}