feat(process): support explicit stdin closure
This commit is contained in:
@@ -34,12 +34,12 @@ export interface RenderedTerminalFrame {
|
||||
readonly serialized_state: string;
|
||||
}
|
||||
|
||||
/** Scheduled input, resize, or signal with its observed dispatch outcome. */
|
||||
/** Scheduled terminal interaction with its observed dispatch outcome. */
|
||||
export interface InteractionEvent {
|
||||
readonly sequence: number;
|
||||
readonly scheduled_at_ms: number;
|
||||
readonly dispatched_at_ms: number;
|
||||
readonly type: "input" | "resize" | "signal";
|
||||
readonly type: "input" | "resize" | "stdin_close" | "signal";
|
||||
readonly data: string;
|
||||
readonly outcome: "dispatched" | "target_exited" | "failed";
|
||||
}
|
||||
@@ -307,7 +307,7 @@ export const processCaptureSchema: z.ZodType<ProcessCapture> = z.object({
|
||||
sequence: z.number().int().nonnegative(),
|
||||
scheduled_at_ms: z.number().int().nonnegative(),
|
||||
dispatched_at_ms: z.number().int().nonnegative(),
|
||||
type: z.enum(["input", "resize", "signal"]),
|
||||
type: z.enum(["input", "resize", "stdin_close", "signal"]),
|
||||
data: z.string(),
|
||||
outcome: z.enum(["dispatched", "target_exited", "failed"]),
|
||||
}),
|
||||
@@ -447,7 +447,13 @@ export const processCaptureSchema: z.ZodType<ProcessCapture> = z.object({
|
||||
.max(PROCESS_REACTIVE_LIMITS.actionsPerTransition),
|
||||
action_types: z
|
||||
.array(
|
||||
z.enum(["send_input", "resize", "send_signal", "checkpoint"]),
|
||||
z.enum([
|
||||
"send_input",
|
||||
"resize",
|
||||
"close_stdin",
|
||||
"send_signal",
|
||||
"checkpoint",
|
||||
]),
|
||||
)
|
||||
.max(PROCESS_REACTIVE_LIMITS.actionsPerTransition),
|
||||
}),
|
||||
|
||||
@@ -190,6 +190,7 @@ const processReactiveActionSchema = z.discriminatedUnion("type", [
|
||||
columns: z.number().int().min(1).max(1_000),
|
||||
rows: z.number().int().min(1).max(1_000),
|
||||
}),
|
||||
z.strictObject({ type: z.literal("close_stdin") }),
|
||||
z.strictObject({
|
||||
type: z.literal("send_signal"),
|
||||
target: signalTargetSchema,
|
||||
|
||||
@@ -121,6 +121,23 @@ const applyProcessReactiveTransition = (input: {
|
||||
};
|
||||
};
|
||||
|
||||
const terminalControlObservationMatches = (
|
||||
action: Exclude<
|
||||
ProcessReactiveScenario["states"][number]["on"][number]["actions"][number],
|
||||
{ readonly type: "checkpoint" | "send_input" }
|
||||
>,
|
||||
payload: Readonly<Record<string, unknown>>,
|
||||
): boolean => {
|
||||
if (action.type === "resize")
|
||||
return (
|
||||
payload["type"] === "resize" &&
|
||||
payload["data"] === `${String(action.columns)}x${String(action.rows)}`
|
||||
);
|
||||
if (action.type === "close_stdin")
|
||||
return payload["type"] === "stdin_close" && payload["data"] === "";
|
||||
return payload["type"] === "signal" && payload["data"] === action.signal;
|
||||
};
|
||||
|
||||
const effectObservationMatchesAction = (
|
||||
action: ProcessReactiveScenario["states"][number]["on"][number]["actions"][number],
|
||||
observation: ProcessObservation,
|
||||
@@ -160,12 +177,7 @@ const effectObservationMatchesAction = (
|
||||
committedSensitiveInputs,
|
||||
)
|
||||
);
|
||||
if (action.type === "resize")
|
||||
return (
|
||||
payload["type"] === "resize" &&
|
||||
payload["data"] === `${String(action.columns)}x${String(action.rows)}`
|
||||
);
|
||||
return payload["type"] === "signal" && payload["data"] === action.signal;
|
||||
return terminalControlObservationMatches(action, payload);
|
||||
};
|
||||
|
||||
const expectedInputEvidence = (
|
||||
|
||||
Reference in New Issue
Block a user