### Run Flight Booking Example Dev Server Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Start the development server for the flight booking example using Bun. ```bash bun --filter='flight-booking-example' run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Run `bun install` from the repository root to install all dependencies for the main package and examples. ```bash bun install ``` -------------------------------- ### Other Flight Booking Example Scripts Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Provides alternative scripts for building, starting, and cleaning the flight booking example. ```bash bun --filter='flight-booking-example' run build ``` ```bash bun --filter='flight-booking-example' run start ``` ```bash bun --filter='flight-booking-example' run clean ``` -------------------------------- ### Start Development Server Source: https://github.com/worldcoin/human-in-the-loop/blob/main/examples/flight-booking/README.md Start the local development server to run the flight booking app. ```bash pnpm dev ``` -------------------------------- ### Configure Flight Booking Example Environment Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Set up environment variables for the flight booking example, including API tokens for OpenAI and World ID. ```bash # OpenAI (used by @workflow/ai/openai in the chat workflow) OPENAI_API_TOKEN=sk-... # World ID — server-side (used by @worldcoin/human-in-the-loop) WORLD_RP_ID=your_rp_id WORLD_SIGNING_KEY=your_signing_key # World ID — client-side (used by the IDKitRequestWidget) NEXT_PUBLIC_WORLD_APP_ID=app_... ``` -------------------------------- ### Install Project Dependencies with Bun Source: https://github.com/worldcoin/human-in-the-loop/blob/main/README.md Install all project dependencies, including those for workspaces and examples, using Bun. This command ensures all necessary packages are downloaded and linked. ```bash bun install ``` -------------------------------- ### Install Server and React Packages Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Install the server-side and client-side React packages for the human-in-the-loop library using npm or bun. ```bash # Server package bun add @worldcoin/human-in-the-loop # or npm install @worldcoin/human-in-the-loop # React client bindings bun add @worldcoin/human-in-the-loop-react # or npm install @worldcoin/human-in-the-loop-react ``` -------------------------------- ### Clone and Install Dependencies Source: https://github.com/worldcoin/human-in-the-loop/blob/main/examples/flight-booking/README.md Clone the repository and install project dependencies using pnpm. ```bash git clone https://github.com/vercel/workflow-examples cd workflow-examples/flight-booking-app pnpm install ``` -------------------------------- ### Install @worldcoin/human-in-the-loop-react Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop-react/README.md Install the package using bun or npm. Ensure you have the required peer dependencies: react, ai, and @worldcoin/idkit. ```bash bun add @worldcoin/human-in-the-loop-react # or npm install @worldcoin/human-in-the-loop-react ``` -------------------------------- ### Install React Bindings for Human Approval Component Source: https://github.com/worldcoin/human-in-the-loop/blob/main/README.md Install the React bindings for the human-in-the-loop package to use the `` component. This component handles rendering the IDKit widget and posting proofs back to the webhook. ```bash bun add @worldcoin/human-in-the-loop-react ``` -------------------------------- ### Install Human-in-the-Loop React Package Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Add the `@worldcoin/human-in-the-loop-react` package to your project using Bun to enable client-side human approval components. ```bash bun add @worldcoin/human-in-the-loop-react ``` -------------------------------- ### Next.js API Route to Start Workflow Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Initiates a durable workflow run from a Next.js API route. It parses incoming messages, starts the workflow using `workflow/api.start`, and streams UI messages back to the client. ```typescript // src/app/api/chat/route.ts import type { UIMessage } from 'ai' import { start } from 'workflow/api' import { chatWorkflow } from '@/workflows/chat' import { convertToModelMessages, createUIMessageStreamResponse } from 'ai' export async function POST(req: Request) { const { messages }: { messages: UIMessage[] } = await req.json() const modelMessages = await convertToModelMessages(messages) // Start a durable workflow run; returns { readable, ... } const run = await start(chatWorkflow, [modelMessages]) // Stream UI message chunks (including data-approval-context) back to the client return createUIMessageStreamResponse({ stream: run.readable }) } ``` -------------------------------- ### Monorepo Structure Overview Source: https://github.com/worldcoin/human-in-the-loop/blob/main/CLAUDE.md This snippet displays the directory structure of the Bun workspaces monorepo. It shows the location of the main '@worldcoin/human-in-the-loop' package and the 'flight-booking' example. ```tree . ├── packages/ │ └── human-in-the-loop/ # The @worldcoin/human-in-the-loop package └── examples/ └── flight-booking/ # Next.js demo: AI flight booking agent that asks # for World ID approval before confirming a booking ``` -------------------------------- ### Custom Approval UI with useHumanApproval Hook Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Implement a custom UI for World ID approval using the `useHumanApproval` hook. This example shows how to manage the verification state and integrate with `IDKitRequestWidget`. Ensure `NEXT_PUBLIC_WORLD_APP_ID` is set in your environment variables. ```tsx 'use client' import { useState } from 'react' import { useHumanApproval } from '@worldcoin/human-in-the-loop-react' import { IDKitRequestWidget, orbLegacy } from '@worldcoin/idkit' import type { UIMessage, UIMessagePart } from 'ai' interface Props { message: UIMessage part: UIMessagePart } export function MyCustomApproval({ message, part }: Props) { const [open, setOpen] = useState(false) const { ready, action, rpContext, webhookUrl, state, verify } = useHumanApproval(message, part) // state is a discriminated union: // { status: 'idle' } // { status: 'verifying' } // { status: 'verified' } // { status: 'error'; error: Error } if (state.status === 'verified') { return (

✅ Approved via World ID

) } return (

Human approval required

{state.status === 'error' && (

{state.error.message}

)} {ready && rpContext && action && ( {}} handleVerify={verify} // POSTs proof to webhookUrl; updates state app_id={process.env.NEXT_PUBLIC_WORLD_APP_ID as `app_${string}`} action={action} // Server-signed action slug rp_context={rpContext} // Server-signed RP context preset={orbLegacy()} allow_legacy_proofs={false} /> )}
) } ``` -------------------------------- ### Create and Configure .env.local Source: https://github.com/worldcoin/human-in-the-loop/blob/main/examples/flight-booking/README.md Create a .env.local file and add your Vercel AI Gateway API key. ```bash touch .env.local AI_GATEWAY_API_KEY=your_api_key_here ``` -------------------------------- ### Build Human-in-the-Loop Package Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Build the package using Bun. Use watch mode during development for continuous builds. ```bash bun --filter='@worldcoin/human-in-the-loop' run build ``` ```bash bun --filter='@worldcoin/human-in-the-loop' run dev ``` -------------------------------- ### Configure PostgreSQL Environment Variables Source: https://github.com/worldcoin/human-in-the-loop/blob/main/examples/flight-booking/README.md Set up environment variables for PostgreSQL World persistence on non-Vercel platforms. ```bash WORKFLOW_TARGET_WORLD="@workflow/world-postgres" WORKFLOW_POSTGRES_URL="postgres://postgres:password@db.yourdb.co:5432/postgres" WORKFLOW_POSTGRES_JOB_PREFIX="workflow_" WORKFLOW_POSTGRES_WORKER_CONCURRENCY=10 ``` -------------------------------- ### Configure Environment Variables Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Set up required environment variables for both server-side and client-side operations, including signing keys and app IDs. ```bash # Server-side WORLD_SIGNING_KEY=your_hex_encoded_signing_key WORLD_RP_ID=your_relying_party_id # Client-side (Next.js / Vite) NEXT_PUBLIC_WORLD_APP_ID=app_... ``` -------------------------------- ### Create Database Schema Source: https://github.com/worldcoin/human-in-the-loop/blob/main/examples/flight-booking/README.md Execute the command to create the necessary database schema for the PostgreSQL World. ```bash pnpm exec workflow-postgres-setup ``` -------------------------------- ### Server-side Workflow with DurableAgent Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Sets up a durable chat workflow using DurableAgent. It retrieves a writable stream for approval context chunks and initializes an agent with a model, tools, and system prompt. ```typescript // src/workflows/chat/index.ts import { getWritable } from 'workflow' import { DurableAgent } from '@workflow/ai/agent' import type { ModelMessage, UIMessageChunk } from 'ai' import { openai } from '@workflow/ai/openai' import { flightBookingTools, FLIGHT_ASSISTANT_PROMPT } from './steps/tools' export async function chatWorkflow(messages: ModelMessage[]) { 'use workflow' const writable = getWritable() const agent = new DurableAgent({ model: openai('gpt-5.4'), tools: flightBookingTools, system: FLIGHT_ASSISTANT_PROMPT, providerOptions: { openai: { reasoningEffort: 'low' } }, }) await agent.stream({ messages, writable }) } ``` -------------------------------- ### Register Content-Bound Action Tool Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Create a tool where the action string is derived from specific input data, preventing replay attacks across different actions. ```typescript // --- Option 2: content-bound action derived from input fields --- // Binding the action to specific booking details makes it impossible to // "approve booking A then execute booking B". const bookingSchema = z.object({ flightNumber: z.string(), passengerName: z.string(), seatPreference: z.string().optional(), summary: z.string(), }) export const bookingTools = { bookingApproval: { description: 'Request World ID approval for a specific flight booking.', inputSchema: bookingSchema, execute: requestHumanAuthorization>({ // Function form — derives action from the per-call input: action: ({ input }) => `book-flight:${JSON.stringify([ input.flightNumber, input.passengerName.trim().toLowerCase(), (input.seatPreference ?? 'any').trim().toLowerCase(), ])}`, }), }, } ``` -------------------------------- ### Configure Environment Variable Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop-react/README.md Set the NEXT_PUBLIC_WORLD_APP_ID environment variable to your World developer portal app ID. This is used by default by the HumanApproval component. ```bash NEXT_PUBLIC_WORLD_APP_ID=app_... ``` -------------------------------- ### Register Simple Human Approval Tool Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Register a basic human approval tool with a default action derived from the tool call ID. This is the simplest way to integrate human authorization. ```typescript // src/workflows/chat/steps/tools.ts import { z } from 'zod' import { requestHumanAuthorization } from '@worldcoin/human-in-the-loop/workflows' // --- Option 1: simplest — action defaults to toolCallId (unique per call) --- export const tools = { approveAction: { description: 'Request human approval via World ID before a sensitive action.', inputSchema: z.object({ summary: z.string() }), execute: requestHumanAuthorization(), }, } ``` -------------------------------- ### Typecheck Human-in-the-Loop Package Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Perform a type check on the package using Bun and TypeScript. ```bash bun --filter='@worldcoin/human-in-the-loop' run typecheck ``` -------------------------------- ### Register Tool with Explicit Signing Key and RP ID Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Configure the human authorization tool with explicit signing key and relying party ID, useful in environments like Cloudflare Workers. ```typescript // --- Option 3: explicit signingKey / rpId (e.g. Cloudflare Workers bindings) --- export const cfTools = { approveAction: { description: 'Request human approval.', inputSchema: z.object({ summary: z.string() }), // Evaluated at request time inside the workflow step: execute: requestHumanAuthorization({ signingKey: process.env.WORLD_SIGNING_KEY, rpId: process.env.WORLD_RP_ID, }), }, } ``` -------------------------------- ### Add Human Authorization Tool to Workflow Steps Source: https://github.com/worldcoin/human-in-the-loop/blob/main/README.md In your tool definitions, import `requestHumanAuthorization` and configure its `execute` function. The `action` parameter must be unique per verification; it can be a plain string or a function deriving a unique ID. ```typescript // src/workflows/chat/steps/tools.ts import { requestHumanAuthorization } from '@worldcoin/human-in-the-loop/workflows' export const tools = { approveAction: { description: 'Request human approval via World ID before a sensitive action.', inputSchema: z.object({ summary: z.string() }), execute: requestHumanAuthorization(), }, // your other tools (each with 'use step' in their execute function) } ``` ```typescript execute: requestHumanAuthorization({ action: myUniqueOperationId }) ``` ```typescript execute: requestHumanAuthorization({ action: ({ toolCallId, input }) => `booking:${toolCallId}`, }) ``` ```typescript execute: requestHumanAuthorization({ signingKey: c.env.WORLD_SIGNING_KEY, rpId: c.env.WORLD_RP_ID, }) ``` -------------------------------- ### Render HumanApproval Component in Message Renderer Source: https://github.com/worldcoin/human-in-the-loop/blob/main/README.md Integrate the `` component into your message rendering logic. It checks for `tool-approveAction` parts and renders the approval UI, facilitating the World ID verification process. ```tsx import { HumanApproval } from '@worldcoin/human-in-the-loop-react' {message.parts.map(part => { if (part.type === 'tool-approveAction' && 'toolCallId' in part) { return } // ...your other part renderers })} ``` -------------------------------- ### Configure Signing Key and RP ID for Human Authorization Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Explicitly pass `signingKey` and `rpId` to `requestHumanAuthorization` if they are not available via environment variables (`WORLD_SIGNING_KEY`, `WORLD_RP_ID`). ```typescript execute: requestHumanAuthorization({ signingKey: c.env.WORLD_SIGNING_KEY, rpId: c.env.WORLD_RP_ID, }) ``` -------------------------------- ### Add Human Authorization Tool to Workflow Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md In your tool definitions, import `requestHumanAuthorization` and configure its `execute` function. The `action` parameter must be unique per verification. ```typescript import { requestHumanAuthorization } from '@worldcoin/human-in-the-loop/workflows' export const tools = { approveAction: { description: 'Request human approval via World ID before a sensitive action.', inputSchema: z.object({ summary: z.string() }), execute: requestHumanAuthorization(), }, // your other tools (each with 'use step' in their execute function) } ``` -------------------------------- ### Use useHumanApproval Hook for Custom UI Source: https://github.com/worldcoin/human-in-the-loop/blob/main/README.md For custom UI implementations, utilize the `useHumanApproval` hook. This hook provides the necessary state and functions (`ready`, `action`, `rpContext`, `verify`, `status`) to build your own approval interface with `IDKitRequestWidget`. ```tsx import { useHumanApproval } from '@worldcoin/human-in-the-loop-react' const { ready, action, rpContext, verify, status } = useHumanApproval(message, part) ``` -------------------------------- ### Initialize Workflow Workers in Next.js Source: https://github.com/worldcoin/human-in-the-loop/blob/main/examples/flight-booking/README.md Register Workflow workers in your Next.js instrumentation.ts file to handle workflow state persistence with PostgreSQL. ```typescript export async function register() { if (process.env.NEXT_RUNTIME !== "edge") { console.log("Starting workflow workers..."); import("workflow/runtime").then(async ({ getWorld }) => { console.log("Starting Postgres World..."); await getWorld().start?.(); }); console.log("Workflow workers started!"); } } ``` -------------------------------- ### Define Chat Workflow with Human Authorization Tool Source: https://github.com/worldcoin/human-in-the-loop/blob/main/README.md Register `requestHumanAuthorization` as a tool on your `DurableAgent` to enable human approval steps within AI workflows. Ensure the agent is configured with the appropriate model and tools. ```typescript // src/workflows/chat/index.ts import { DurableAgent } from 'workflow/ai' import { getWritable } from 'workflow' import { openai } from '@workflow/ai/openai' import { tools } from './steps/tools' export async function chatWorkflow(messages: ModelMessage[]) { 'use workflow' const writable = getWritable() const agent = new DurableAgent({ model: openai('gpt-5.4'), tools, system: 'You are a helpful assistant. Before performing any sensitive action, use the approveAction tool.', }) await agent.stream({ messages, writable }) } ``` -------------------------------- ### Use useHumanApproval Hook for Custom UI Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md For custom UI, utilize the `useHumanApproval` hook directly to manage the approval state and render your own button and `IDKitRequestWidget`. ```tsx import { useHumanApproval } from '@worldcoin/human-in-the-loop-react' const { ready, action, rpContext, verify, status } = useHumanApproval(message, part) ``` -------------------------------- ### Use Headless useHumanApproval Hook Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop-react/README.md Utilize the useHumanApproval hook for custom UI implementations. It provides the necessary state and callbacks to manage the approval process. ```tsx import { useHumanApproval } from '@worldcoin/human-in-the-loop-react' import { IDKitRequestWidget, orbLegacy } from '@worldcoin/idkit' import { useState } from 'react' function MyApproval({ message, part }) { const [open, setOpen] = useState(false) const { ready, action, rpContext, state, verify } = useHumanApproval(message, part) if (state.status === 'verified') return

Approved.

return ( <> {state.status === 'error' &&

{state.error.message}

} {ready && ( {}} handleVerify={verify} app_id={process.env.NEXT_PUBLIC_WORLD_APP_ID as `app_${string}`} action={action!} rp_context={rpContext!} preset={orbLegacy()} allow_legacy_proofs={false} /> )} ) } ``` -------------------------------- ### Use HumanApproval Drop-in Component Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop-react/README.md Render the HumanApproval component within your message renderer wherever an approval tool part appears. It handles the UI and verification flow automatically. ```tsx import { HumanApproval } from '@worldcoin/human-in-the-loop-react' {message.parts.map(part => { if (part.type === 'tool-approveAction' && 'toolCallId' in part) { return } // ...your other part renderers })} ``` -------------------------------- ### requestHumanAuthorization Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Factory function that returns a Workflow SDK-compatible `execute` function. This function is used to register a tool on a `DurableAgent` that pauses execution, streams an approval request to the client, and waits for a World ID proof before resuming. ```APIDOC ## `requestHumanAuthorization` Factory Function ### Description This function creates a tool for Workflow SDK-compatible agents. When invoked, it pauses the agent's execution, initiates a human approval process via World ID, and resumes only after a valid proof is received and verified. ### Usage ```typescript import { requestHumanAuthorization } from '@worldcoin/human-in-the-loop/workflows' // Example usage within a Workflow SDK tool definition: const tools = { approveAction: { description: 'Request human approval via World ID before a sensitive action.', inputSchema: z.object({ summary: z.string() }), execute: requestHumanAuthorization(), }, } // Example with custom action derivation: const bookingTools = { bookingApproval: { description: 'Request World ID approval for a specific flight booking.', inputSchema: bookingSchema, execute: requestHumanAuthorization>({ action: ({ input }) => `book-flight:${JSON.stringify([ input.flightNumber, input.passengerName.trim().toLowerCase(), (input.seatPreference ?? 'any').trim().toLowerCase(), ])}`, }), }, } // Example with explicit signingKey and rpId: const cfTools = { approveAction: { description: 'Request human approval.', inputSchema: z.object({ summary: z.string() }), execute: requestHumanAuthorization({ signingKey: process.env.WORLD_SIGNING_KEY, rpId: process.env.WORLD_RP_ID, }), }, } ``` ### Parameters for `requestHumanAuthorization` Options #### `action` - **Type**: `string | ((ctx: ActionContext) => string)` - **Default**: `toolCallId` (unique per call) - **Description**: The action string that the World ID proof will be cryptographically bound to. It must be unique for each verification to prevent replay attacks. #### `signingKey` - **Type**: `string` - **Default**: `process.env.WORLD_SIGNING_KEY` - **Description**: The hex-encoded Relying Party (RP) signing key used for signing the request. This is typically set via environment variables. #### `rpId` - **Type**: `string` - **Default**: `process.env.WORLD_RP_ID` - **Description**: The Relying Party ID, which is passed to the World ID verification endpoint (`https://developer.world.org/api/v4/verify/{rpId}`). This is also typically set via environment variables. ``` -------------------------------- ### React HumanApproval Component Integration Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt Integrates the HumanApproval React component into a chat interface to handle World ID verification for tool-call approval parts. It renders a button that triggers the World ID verification flow. ```tsx // src/app/page.tsx 'use client' import { useChat } from '@ai-sdk/react' import { HumanApproval } from '@worldcoin/human-in-the-loop-react' export default function ChatPage() { const { messages, sendMessage, status } = useChat({ onError: (error) => console.error(error), }) return (
{messages.map((message) => (
{message.parts.map((part, i) => { // Text parts if (part.type === 'text') { return

{part.text}

} // Approval tool — render the World ID widget if (part.type === 'tool-bookingApproval' && 'toolCallId' in part) { return ( ✅ Booking approved!

} className="my-4 p-4 border rounded-lg" /> ) } return null })}
))}
) } ``` -------------------------------- ### Define Chat Workflow with Human Authorization Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Define a workflow function that registers `requestHumanAuthorization` as a tool on a `DurableAgent`. Ensure sensitive actions are gated by this tool. ```typescript import { DurableAgent } from 'workflow/ai' import { getWritable } from 'workflow' import { openai } from '@workflow/ai/openai' import { tools } from './steps/tools' export async function chatWorkflow(messages: ModelMessage[]) { 'use workflow' const writable = getWritable() const agent = new DurableAgent({ model: openai('gpt-5.4'), tools, system: 'You are a helpful assistant. Before performing any sensitive action, use the approveAction tool.', }) await agent.stream({ messages, writable }) ``` -------------------------------- ### Derive World ID Action for Flight Booking Source: https://context7.com/worldcoin/human-in-the-loop/llms.txt This TypeScript code defines a function to derive a unique World ID action string based on flight booking parameters. It ensures that the action is specific to the flight number, passenger name, and seat preference, making it impossible to reuse an approval for one booking on another. ```typescript import { z, } from 'zod' import { requestHumanAuthorization, } from '@worldcoin/human-in-the-loop/workflows' const bookingSchema = z.object({ flightNumber: z.string(), passengerName: z.string(), seatPreference: z.string().optional(), summary: z.string(), }) type BookingParams = z.infer function deriveBookingAction({ flightNumber, passengerName, seatPreference, }: BookingParams): string { return `book-flight:${JSON.stringify([ flightNumber, passengerName.trim().toLowerCase(), (seatPreference ?? 'any').trim().toLowerCase(), ])}` } export const flightBookingTools = { // Step 1: request approval — action is derived from booking details bookingApproval: { description: 'Request World ID approval for a specific flight booking. Returns an IDKitResult.', inputSchema: bookingSchema, execute: requestHumanAuthorization({ action: ({ input }) => deriveBookingAction(input), }), }, // Step 2: execute booking — re-verifies the proof AND checks the action matches bookFlight: { description: 'Book a flight. Requires the IDKitResult from bookingApproval as `approval`.', inputSchema: bookingSchema.extend({ approval: z.object({ action: z.string() }).passthrough(), }), execute: async ({ flightNumber, passengerName, seatPreference, approval, }) => { 'use step' const expectedAction = deriveBookingAction({ flightNumber, passengerName, seatPreference, }) // Guard 1: action must match exact booking details if (approval.action !== expectedAction) { throw new Error( `bookFlight requires an approval bound to these exact booking details. ` + `Expected action: ${expectedAction}, got: ${String(approval.action)}` ) } // Guard 2: re-verify proof against World ID API (prevents fabricated proofs) const verifyResponse = await fetch( `https://developer.world.org/api/v4/verify/${process.env.WORLD_RP_ID}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(approval), } ) if (!verifyResponse.ok) { const error = await verifyResponse.text() throw new Error(`Approval proof failed World ID verification (${verifyResponse.status}): ${error}`) } // Proceed with the actual booking... const confirmationNumber = `BK${Math.random().toString(36).substring(2, 8).toUpperCase()}` return { success: true, confirmationNumber, passengerName, flightNumber, message: 'Flight booked successfully!', } }, }, } ``` -------------------------------- ### Override Action ID for Human Authorization Source: https://github.com/worldcoin/human-in-the-loop/blob/main/packages/human-in-the-loop/README.md Customize the `action` parameter for `requestHumanAuthorization` to ensure uniqueness. It can be a plain string or a function deriving the ID from call context. ```typescript execute: requestHumanAuthorization({ action: myUniqueOperationId }) // Function — derive from the call context (workflow run ID, input hash, resource id, ...) execute: requestHumanAuthorization({ action: ({ toolCallId, input }) => `booking:${toolCallId}`, }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.