One card contract, any host

Reply Desk never builds its own compose form. It mounts the Process card for a proposal and passes commands back to Process. The same contract drives a plain JavaScript review, the React control, and a future MCP Apps host.

card.id + card.revision

Identity and version. Pass both through untouched; a newer revision of the same id updates the mounted review in place.

card.actions

The commands Process offers right now, such as "Save draft to Outlook". Render only these.

card.action command

Carries the action id, the reviewed edits, expectedRevision and expectedUpdatedAt. Process derives the user from your server's call.

execution

Process's outcome after it checks policy at execution: succeeded with a provider acknowledgement, denied with a reason, or not yet confirmed.

JavaScript

Receive an updated card and submit an offered command. The server half forwards it with the Process JavaScript SDK.

Review a proposal without Reactexamples/javascript.ts
import { createInstalledWorkflow } from '@process.co/sdk/server'

import {
  createProcessCardController,
  parseCommandResultForExample,
  type CardActionCommand,
  type CardCommandResult,
  type ConversationCard,
  type ProcessCardSnapshot,
  type ProcessCardTransport,
} from './card-sdk.ts'

// Browser or any JS runtime: mount one review, feed it newer cards, submit an offered command.
export function reviewProposal(
  card: ConversationCard,
  transport: ProcessCardTransport,
  render: (snapshot: ProcessCardSnapshot) => void,
) {
  const review = createProcessCardController(card, transport)
  const stop = review.subscribe(() => render(review.getSnapshot()))
  render(review.getSnapshot())

  return {
    /** A newer revision of the same card (from a poll, webhook or stream) updates this review in place. */
    receive: (next: ConversationCard) => review.receive(next),
    edit: (fields: { to?: string[]; subject?: string; body?: string }) => review.edit(fields),
    /** Submits the approve command Process offered, carrying the reviewed edits and revision. */
    async approve() {
      const command = review.availableCommands().find(action => action.command.includes('approve'))
      if (!command) return null
      const result = await review.submit(command.id)
      return result?.receipt ?? null
    },
    close() {
      stop()
      review.dispose()
    },
  }
}

// Your server: forward the command to the installation as the signed-in website user.
export async function submitAsWebsiteUser(
  command: CardActionCommand,
  { invokeUrl, consentOrigin, websiteUserId, accessToken }: {
    invokeUrl: string
    consentOrigin: string
    websiteUserId: string
    accessToken: () => Promise<string>
  },
): Promise<CardCommandResult> {
  const cardActions = createInstalledWorkflow({ invokeUrl, consentOrigin, externalUserId: websiteUserId, getAccessToken: accessToken })
  const result = await cardActions.invoke(command, { idempotencyKey: command.commandId })
  if (result.state === 'connection-required') throw new Error(`Reconnect Outlook through Process first (${result.reason}).`)
  const body = result.state === 'accepted' ? await result.operation.status() : await result.response.json()
  return parseCommandResultForExample(body, command.commandId)
}

React

Mount the review. Recipients, subject, body, the save command, policy feedback and the receipt all render inside the shared control.

Mount the shared reviewexamples/react.tsx
'use client'

import { useMemo } from 'react'

import { refreshCard, submitCardCommand } from '@/app/desk/actions'
import type { ConversationCard, ProcessCardTransport } from '@/lib/process-card'
import { ProcessActionCard } from '@/lib/process-card/react'

/** Mounts the shared Process review for one proposal. Commands go through this site's server actions. */
export function ReplyReview({ card }: { card: ConversationCard }) {
  const transport = useMemo<ProcessCardTransport>(() => ({
    async submit(command) {
      const result = await submitCardCommand(command)
      if (!result.ok) throw new Error(result.message)
      return result.result
    },
    async refresh(current) {
      const result = await refreshCard(current)
      return result.ok ? result.card : null
    },
  }), [])

  return <ProcessActionCard key={card.id} card={card} transport={transport} />
}

MCP Apps hosts

The card is plain JSON, and commands are a single card.action shape. An MCP Apps host can present the same proposal from a tool result and send the same command back, without a host-specific form.

Where the card lives

The public @process.co/sdk/react entry point exposes the card host. This preview uses its own fixture compose control in lib/process-card.