@ouispec/agent-react
v0.10.0
Published
React bindings — view annotations, execution engine, agent UI components
Readme
@ouispec/agent-react
The agent in a React app: the provider that runs turns against the product's API and realtime server, the hooks a chat UI is built from, and the card where a person approves an irreversible action.
npm install @ouispec/agent-reactAgentProvideranduseAgent: the conversation, its messages and tool calls, sending a turn, and the turn's stream. The socket is a seam (realtime.createSocket), so a product supplies its own connection and credentials.stopTurn,isStoppingandacceptedTurnIdonuseAgent: the person's Stop for the turn in progress, and the turn whose UI requests the tab runs now (give it to the tab's OUI runtime:accept: acceptCurrentTurn(agent.acceptedTurnId)). A message sent while a turn runs supersedes it; a stopped turn's message keeps what it had said, markedstopped.sendMessage(content, options?)onuseAgent: sends the person's message.options.attachmentsgives the message's files by reference (an array alone as the second argument does the same); without them it carries the composer's ready files.options.inputsays how a message was entered when it was not typed:{ mode: 'voice', language }for one the person spoke, with the language the recogniser detected (ADR-0259 §2.6). It reachesconfig.sendMessageascontext.input, for the platform to pass to the worker and store on the message; the message keeps it asAgentMessage.input, and a restored one fromAgentStoredMessage.input. A spoken message sent while a turn runs supersedes it, as a typed one does. An inputreadMessageInputdoes not recognise is not sent.historyonuseAgent: the person's earlier conversations, fromconfig.listConversations. A listed conversation keepspreviewInput, how the message its preview is taken from was entered, and each search match itsinput, when the person spoke it (ADR-0259 §2.6), so a list can mark it; whatreadMessageInputdoes not recognise is dropped (readConversationSummary).attachmentsonuseAgent: the files on the message being written.attach(files)checks each against the platform's limits and uploads it at once throughconfig.attachments.upload(into the conversation, made then if there is none yet); each item shows its progress, or why it was refused;remove(key)cancels an upload or removes the file.sendMessagewaits for uploads still running and sends the ready files' references;waitingToSendis true meanwhile. It sends nothing, and resolvesnotSent: { reason, content }so the composer keeps the draft, when a file on the message is refused, when a send already waits, or when the conversation changes orstopTurngives the waiting send up. A file uploaded for a message that is not sent is removed throughconfig.attachments.remove. A message's files are onAgentMessage.attachments.ApprovalCard: shows what an irreversible call will do and takes the person's decision. It can't be bound to the agent: only a person's click approves.useFeedback,storedToAgentMessages, and the view annotations.
React 18 or 19 is a peer dependency. It releases with the rest of the agent SDK, under one version: see VERSIONING.md.
