Open History to see the last commit
1import { defineInterrupt } from '@tanstack/ai'
2import { z } from 'zod'
3
4/** One OpenAI pending safety check on a computer call. */
5export const safetyCheckSchema = z.object({
6 id: z.string(),
7 code: z.string().nullish(),
8 message: z.string().nullish(),
9})
10
11/**
12 * The interrupt that asks a person to approve a computer action with OpenAI
13 * safety checks. The interrupt key is the tool call id.
14 *
15 * - Payload: `{ checks, action }`. `checks` are the pending safety checks.
16 * `action` is the action (or the list of actions) that waits.
17 * - Response: `{ approved: boolean }`.
18 *
19 * Register it on the client with `useChat({ interrupts: [computerSafetyCheck] })`.
20 * It is the same object as the `interrupt` from `createComputerUse`.
21 */
22export const computerSafetyCheck = defineInterrupt({
23 id: 'computer-safety-check',
24 payloadSchema: z.object({
25 checks: z.array(safetyCheckSchema),
26 action: z.unknown(),
27 }),
28 responseSchema: z.object({ approved: z.boolean() }),
29})