Wisent App

Developer documentation

Build on the Wisent App platform.

Canonical contracts for iOS, Android, the web application, backend services, private media, data migrations, and signed messaging integrations.

Client surfaces

iOS

  • Native Swift application with local-first chat and character workflows.
  • App Store release metadata and TestFlight automation are release inputs, not runtime configuration.
  • Room and persona state is owned by the authenticated account and synchronized through the application API.

Android

  • Native Android client using the same authenticated application contracts.
  • The package is com.wisent.android and is distributed through Google Play.
  • Platform UI may differ; conversation, persona, document, and media ownership rules do not.

Service APIs

Application API

The web and mobile clients authenticate before calling the stateless application API. That service owns business logic and database access, while generation is delegated to a separately deployed authenticated inference service.

MethodPathContract
POST/api/chatRun an authenticated conversation turn.
GET · POST/api/conversationsList or create conversations.
GET/api/conversations/searchSearch the caller’s conversations.
GET · DELETE/api/conversations/{id}Read or remove one owned conversation.
GET · POST · DELETE/api/personasManage caller-owned personas.
POST · GET/api/documentsUpload or list caller-owned documents.
GET · POST/api/data-transfer/{export|import}Download or atomically import the caller’s canonical Wisent account-data JSON.
POST/webhooks/user-inactivityReceive the authenticated inactivity event.
GET/health · /api/healthReport that the application process is accepting connections, deliberately without probing a dependency.
GET/readyz · /api/readyzMeasure the database, the model router and the object store, and answer 200 or 503 naming each dependency's operation, result and duration.
GET/api/versionReport the immutable content-addressed release the host is running, and the instance role it resolved.

Inference and platform bridges

Inference, training, and App Store automation deploy independently from the application API. The inference service owns tokenization and generation; training consumes queued offline work; the App Store bridge verifies webhooks and emits normalized GitHub dispatches.

MethodPathContract
POST/v1/generateGenerate text as a blocking response or server-sent event stream.
GET/healthReport inference readiness as ready, warming, or unhealthy.
POST/webhooks/app-store-connectVerify an App Store Connect webhook and dispatch its stable identifiers.
GET/healthReport App Store webhook bridge process health.

Off-platform messaging

Authenticated users can link an existing character and conversation to WhatsApp, Telegram, or iMessage. Linking returns a platform deep link; callers must treat delivery status separately from link creation.

MethodPathContract
POST/api/messaging/whatsapp/connectLink a phone number and character to WhatsApp.
POST/api/messaging/telegram/connectIssue a single-use Telegram deep-link token.
POST/api/messaging/imessage/connectLink a phone number and character to iMessage.
GET/api/messaging/statusRead the caller’s per-platform link state.

Private image service

Generated image objects remain private under stado://wisent-images. The application returns only short-lived HMAC-signed proxy URLs; clients never receive object-store credentials.

MethodPathContract
POST/image-generate/Create an image-generation job.
GET/image-generate/images/{uuid}.{ext}Read an authorized image through the signed proxy.
GET/image-generate/healthReport image pipeline readiness.
GET/healthReport process health.

Character text and lifecycle

The web application's manual Create wizard keeps the complete name, description and appearance entered by the user. Character Settings → Edit Character also keeps the complete name and description. These fields are not silently shortened. The manual wizard still requires a nonblank name and a processed profile image before completion.

Names and descriptions are saved in the character record. Appearance is an input to image generation, not a saved description: the image step removes surrounding whitespace and adds the selected avatar style's prompt modifier. Generation, crop, moderation and private image upload remain separate operations whose results must succeed; a preview alone is not proof of a stored image.

Character and room image POST operations reserve unique private locators without replacing the current image. Their authenticated PUT operations write the actual bytes before publishing the locator on the owned record. Reserve and upload responses alone are not display proof; read the record and load its signed image URL. The shared uploader preserves the actual media type, HTTP status and public failure response.

iOS uploads and local character portraits use PNG at the selected image's pixel dimensions, with its orientation applied. They do not silently resize the image or apply a guessed compression quality. PNG can use more storage and network data than a lossy image. A server refusal remains visible. Native upload clients resolve relative upload URLs against the configured API origin. They require the reserving route and refuse redirects rather than sending bytes or account credentials to another destination.

Native image readers authorize a fresh private-object read before loading the bytes. They verify the returned object and delivery address, do not send account credentials to the signed delivery URL, and do not reuse private images from a shared cache. Local portraits remain local. An unavailable image opens details for the failed operation and observed HTTP status instead of remaining a loading placeholder. The saved image field being present is not proof that its bytes can be read.

If a required image fails after record creation is acknowledged, the wizard keeps that record on the current page, shows the saved name and upload error, and offers Upload for the same record. It does not announce completion or open the chat or room. Back and character-mode switching stay disabled after saving; leaving the page does not delete the saved record.

Character Settings → Edit Character, Room Settings → Edit room, and the standalone /edit/ID character page also use the completed image publication. Their image errors remain visible with the actual operation, HTTP status and service response. A refused storage write keeps the saved image unchanged; a selected-file preview is not evidence of publication. Standalone saves update only the fields that page edits and preserve existing traits. Its image qualification attaches a declared real control vector to the isolated character and checks that the stored relation and strength survive. Loading and saving show the actual failed operation and retain failed drafts. Visibility follows the authenticated owner API, not a separate legacy plan lookup. The page does not offer the unsupported Training Mode switch.

Authenticated clients create with POST /api/characters, read with GET /api/characters/ID, edit with PUT /api/characters/ID, and delete with DELETE /api/characters/ID. JSON creation and update bodies carry the complete name and description. Read the detail operation after an update to observe the saved values, rather than treating a success response as persistence evidence.

Missing authentication is refused. Another account cannot edit or delete an owned character; an inaccessible record can be reported as not found rather than forbidden. Database failures remain failures. Deletion reports deleted or unassigned: a public character with other people's conversations can lose its author association without being erased. New private qualification characters must be deleted, not merely unassigned.

Quick Mode keeps the complete description and requires only nonblank input in the application. Select Generate, review the saved private character or room, then select Create to open it. The final button navigates to records already saved by generation. Authenticated clients use POST /api/autogenerate/createwith description and type: character, room or auto. Character success returns the character; room success returns the room and its generated characters.

Wisent Backend still owns the accepted character-description range through AUTOGENERATE_DESCRIPTION_MIN_CHARS and AUTOGENERATE_DESCRIPTION_MAX_CHARS. The application sends a complete trimmed character description. For rooms it saves the complete trimmed scene and sends complete participant segments without a word or participant-count cut. A character-service refusal keeps its actual status and response body; the wizard displays the service detail without clearing the input. Blank requests are refused. Any failed room participant fails the room request and reports its cause. Generated characters from that attempt are discarded only while owned, private and unused; cleanup refusals retain the character ID and actual cause.

Both room creation forms and Room Settings → Edit room keep complete names and descriptions and do not impose the former participant cap. Authenticated POST /api/rooms requires name, an explicit characterIds array and optional description and entryMessages array. An empty participant array creates an empty room through the API; manual screens require a selected character. Missing arrays, blank names, duplicate IDs and another account's private characters are refused. The room wizard requires a nonblank name, not a local minimum name length. Its qualification checks whitespace refusal, short-name progression and a short name saved unchanged through the shorter room form. The full room wizard also keeps the complete image prompt, without a length cap or remaining-character counter. It trims surrounding whitespace, adds the existing wide-angle interior instruction and sends the chosen room style separately to generation; image-service failures remain failures. Cropping preserves the selected source rectangle's native pixel dimensions instead of rescaling every selection to a fixed canvas. JPEG encoding and image-upload checks are unchanged.

Manual and quick creation save the private room and all participants in one create_private_room transaction. Read GET /api/rooms/ID and GET /api/rooms/ID/participantsto observe saved state, edit with PUT /api/rooms/ID, and delete with DELETE /api/rooms/ID. Deletion removes participants and retains existing conversations with their room association cleared. Room Settings → Edit room → Delete Room confirms the room operation without claiming that these retained conversations will be deleted. A refused deletion keeps its confirmation open with the actual operation, HTTP status and response, rather than announcing success or navigating away. Deploy the canonical migrations providing create_private_room, discard_generated_character and change_room_participantsbefore the application cutover. The schema deployment branch runs migrations; verify the selected database, not merely the application source revision.

Room Settings → Edit room saves text and visibility when the owner selects Save Changes, not after a timer. Blank names disable saving. Failed writes retain the draft and show the actual operation, status and response. Participant and image changes save separately without submitting or replacing the text draft. Closing the editor discards unsaved text.

Owners add with POST /api/rooms/ID/participants, remove with DELETE, or replace the complete selection with PUT. Each body carries a characterIds array of integers. Replacement is atomic and accepts an empty selection; adding a removed character reactivates the existing membership. Duplicate IDs, inaccessible characters and another account's room are refused without partial changes. The editor sends one replacement, keeps a refused selection open and shows the operation, status and response. Membership reads retain inactive rows; clients use isActive for the current selection. Delete responses contain active rows only. A character made private by another account is no longer disclosed through a room's participant read.

The supported account-data CLI imports and exports canonical account records; it does not provide separate character-management commands. The web and authenticated server operations above are the character lifecycle interfaces.

From the application checkout, run node tests/characters/retention.mjs --fixture .build/character-fixture.jsonon a Stado-selected dedicated Weles host. The private fixture selects dedicated accounts, an exclusive authenticated English-language browser profile, real application and database URLs, meaningful long text, the model and avatar style, and independently retained evidence for the exact deployed source revision.

The journey creates, reads, edits, reloads and deletes a real private character; exercises actual image generation, moderation and display; checks authentication and ownership refusals; and reads the database after changes and cleanup. It keeps source revision, commands, exit statuses, complete responses, screenshots and supported Weles recordings under the checkout's ignored build directory. Missing prerequisites are blocked, not passed. Failed cleanup remains a failure, and media and analytics service records are not claimed to have been erased with the character.

Quick creation has a separate real journey: node tests/characters/quick/quick-retention.mjs --fixture .build/quick-character-fixture.json. It requires an exclusive initially empty account, the real backend's declared bounds, independent application/backend/schema release evidence, and long character and room descriptions. It compares real backend refusals with application and wizard results, checks retained participant facts and actual saved rows, and checks partial room failure cleanup. Both manual room forms select beyond the former cap; the full wizard generates and displays a real room image. Its fixture independently declares the generation and selected native crop dimensions; the journey checks those sizes in the preview and stored image. The editor saves and reloads long text, adds another participant and deletes through its confirmation dialog. Cleanup deletes rooms before characters through normal APIs and confirms the account's character and room state is empty. Existing data prevents the run; missing prerequisites are blocked, not passed. Retained conversations, media and analytics remain service records. These commands describe qualification, not a claim that an unrun journey passed.

A text-only character update sends PUT /api/characters/ID with the account's bearer token and a body such as {"name":"Ada, keeper of the northern observatory","description":"She records each observation in its original language."}. The update answers its success and ID; GET /api/characters/ID then shows the saved text. Quick creation sends POST /api/autogenerate/createwith a body such as {"description":"Ada remembers every observation in its original language.","type":"character"}and answers HTTP 201. A blank description is refused with HTTP 400 and {"error":"Description is required"}, a missing or unknown type with HTTP 400 naming the accepted values, and a scene reading that names no room or participant with HTTP 502 and the model's text.

An image is attached in three steps. POST /api/characters/ID/image or POST /api/rooms/ID/image with {"file_type":"image/jpeg"}(JPEG, PNG or WebP) reserves a private locator and answers upload_url and image_url; the record's current image is unchanged. A PUT of the actual bytes to upload_url, with their actual Content-Type, stores the object and publishes it on the owned record, answering uri and a freshly signed url. Signed URLs expire and change; compare uri. A stored image is read again with GET /api/get-signed-url?operation=read&uri=…, which answers { uri, url } for the current account; a missing locator, a missing operation or any operation other than read is refused with HTTP 400, and the endpoint never authorizes a write. Missing authentication, another account's record, an unsupported type and an upload outside the owner's prefix are refused, and a refused upload leaves the existing image in place.

API deployment

A Stado release, built and delivered by Stado

  • wisent-backend is a Stado release product (.wisent-release.json). A Stado builder compiles wisent-backend-api, wisent-backend-imessage and asc-webhook-bridge from the handed-off commit with deploy/release/build.sh, then runs the post-build tests the release declares: the API's start journeys and the App Store Connect bridge's launcher journey. A build that fails them is not delivered.
  • Each required delivery runs stado release local install on a declared host, the binary first and then its launcher, into the host's Stado bin directory. The unit's next start runs a launcher and binary of one release; nothing is downloaded or compiled at start.
  • The API launcher reads its settings from the release's settings declaration delivered beside it and from the wisent-backend-api-runtime role's lines, through the Stado executable STADO_BIN names. Credential errors name the requested role or field; missing, empty or still-encrypted values are refusals, not usable credentials.

Start refusals and delivery evidence

  • The launcher refuses, naming it, a missing binary or settings declaration beside it, a missing service environment, WISENT_API_BIND_HOST, WISENT_API_BIND_PORT or STADO_BIN, a line that is not KEY=VALUE, a key both sources set, and an object API that does not answer an authenticated listing.
  • At start the binary reads every setting and vault role it needs before acting on any, and refuses once naming all that are missing or invalid, so a deployment fixes the whole list in one pass.
  • A successful start is not delivery evidence. Read /api/version on the deployment: it reports the compiled package version and the commit the builder built. /readyz separately measures downstream dependencies.

Local steering on Apple Silicon

Wisent App's chat, conversations, personas, characters, their images and character autogeneration are served by the Application API above. The earlier local MLX backend that ran steered models on a Mac is removed; nothing in Wisent App starts it.

Steered generation on Apple Silicon is Ster, on Metal. Install it with the ster release installer at stado://releases/ster/<version>/<platform>/install.sh; its documentation gives the commands that train a steering vector from a contrastive pair set and generate with it, and what each refuses.

Data and migrations

Canonical schema

  • wisent-supabase-wisent-app migrations are the schema source for the configured application database.
  • Pull-request CI checks migrations; the default branch is the deployment boundary.
  • Application code must not treat dashboard edits or local snapshots as canonical schema.

Optimization service

  • Supported steering comparisons include CAA, DAC, BiPO, REFT, and RepEng.
  • Requests identify steering type and layer configuration explicitly.
  • Optimization results are versioned artifacts; clients do not infer compatibility from filenames.

Bring existing account data

Wisent accepts its own canonical JSON export, identified by wisent.app.account-data.v1. The raw document is sent to authenticated POST /api/data-transfer/import; it is not wrapped in another object. Product-specific Byk clients usePOST /api/data-transfer/import?scope=byk, which rejects the whole file if any character, conversation, or project record is present. The 10 MiB request is completely validated before one atomic database call, so invalid input leaves no partial rows.

Where to import

  • Web: choose Import in the first onboarding screen or Settings → Support → Account data.
  • Android: use the account-import onboarding step or the account-data card in Settings.
  • iOS: use the first onboarding step or the account-data card in Settings; the legacy iOS Settings screen exposes the same action.
  • Each client uploads the selected JSON unchanged to the same authenticated operation and displays every imported, unchanged, conflicting, or rejected record result.
  • Byk clients use the server-owned scope=byk boundary, so they never parse or filter the selected file locally and cannot mutate non-Byk collections.

Accepted records

  • Every record has sourceOwnerId and sourceId. Characters accept name, description, greetings, suggestedFirstMessages, language, country, gender, isNsfw, visualPrompt, createdAt, and updatedAt; imported characters are private.
  • Conversations accept title, an optional imported-character source reference, characterName, modelName, systemPrompt, timestamps, metadata, and messages with sourceId, role, content, tokenCount, createdAt, metadata, and usesConversationCharacter.
  • Coding projects accept repository, issueNumber, instruction, COMPLETED or FAILED status, messages, proposedEdits, test and pull-request history, errors, and timestamps. Import never executes a project or its tests.
  • Byk data accepts paper-only portfolios, ad-hoc watchlist entries, and CLOSED or CANCELLED position history. Portfolio source references are portable; signal, strategy, published-signal, order, execution, and broker-credential references are not.

Duplicates and retained state

  • A repeated sourceOwnerId, sourceId, and record kind with the same content is unchanged.
  • If that source later has different content, the destination is reported conflicting and the existing row is retained.
  • An existing watchlist symbol and side is a conflict. Existing account data is not overwritten, and a destination default portfolio is not displaced.
  • Imported data remains in the normal account tables and is available after onboarding. Skipping import leaves an empty, usable account.

Explicit refusals

  • Unknown fields, malformed identifiers or timestamps, missing character or portfolio references, duplicate source identities, oversized collections, and more than 50,000 messages return HTTP 422 with the normal summary and records report; every count except rejected is zero.
  • Room or test conversations, live or auto-live portfolios, running projects, active positions, protective-order state, published signals, strategy references, orders, executions, broker credentials, generation configuration, and media URLs are not imported.
  • Authentication failure is HTTP 401 and a database refusal is HTTP 503, each with { detail: string }. Both leave the destination unchanged; clients never display or log credential contents.

Exact document contract

The required top-level keys are format and exportedAt. Supported optional arrays arecharacters, conversations, projects, portfolios, watchlist, andpositions; omitted arrays are empty and unknown keys are rejected. The canonical full export emits every array. Collection limits are 500 characters, 1,000 conversations, 1,000 projects, 100 portfolios, 1,000 watchlist entries, and 10,000 positions.

Portfolio fields are exactly sourceOwnerId, sourceId, name, accountSize, riskPct, heatCapPct, mode, currency, isDefault, riskTier, volatilityRiskPct, dailyLossLimitPct, weeklyLossLimitPct, maxPositions, grossExposureCapPct, netExposureCapPct, maxLongExposurePct, maxShortExposurePct, maxSectorExposurePct, maxAverageCorrelation, maxDrawdownPct, dailyPnl, weeklyPnl, buyingPower, cashBalance, maxPositionAdvPct, maxSingleNamePct, maxGroupExposurePct, globalKillSwitch, reconciliationBlocked, reduceOnly, allowAutoLive, equityPeak, scaleOutPlan, trailingStopR, timeStopDays, policyVersion, createdAt, updatedAt.mode must be paper, allowAutoLive must be false, and live risk tiers are refused.

Watchlist fields are exactly sourceOwnerId, sourceId, symbol, side, notes, createdAt, updatedAt. Position fields are exactly sourceOwnerId, sourceId, portfolioSourceOwnerId, portfolioSourceId, symbol, side, status, entryPrice, stop, target, shares, notional, riskDollars, multiplier, underlyingGroup, openedAt, closedAt, realizedR, normalizedR, fees, notes, initialStop, finalStop, averageEntry, filledQuantity, remainingQuantity, grossPnl, netPnl, feesPaid, commissionsPaid, plannedR, realizedGrossR, realizedNetR, entrySlippageR, exitSlippageR, costsR, managementDeltaR, signalAlphaR, executionAlphaR, sizingContribution, maeR, mfeR, exitEfficiency, exitReason, protectionStatus, protectedQuantity, protectiveOrderIds, protectiveOcaGroup, protectionVersion, timeStopAt, favorablePrice, adversePrice, managementState, managementVersion, version, createdAt, updatedAt.status must be CLOSED or CANCELLED; protectiveOrderIds must be empty and no active protective quantity or OCA group is accepted.

CLI

Install the wisent-app executable with Stado, from the recipe the product catalog declares. It uses the same Supabase bearer session and API operation as the graphical clients, and never accepts a token as an argument. Point --session-file at a mode-0600 standard Supabase session JSON containing access_token, or pipe an access token from an existing credential manager with --token-stdin.

# run the wisent-app release installer at stado://releases/wisent-app/<version>/<platform>/install.sh
wisent-app export ./wisent-account.json --session-file ~/.config/wisent/session.json
wisent-app import ./wisent-account.json --session-file ~/.config/wisent/session.json
security find-generic-password -s wisent-access-token -w | wisent-app import ./wisent-account.json --token-stdin

Export creates a new owner-only file and refuses to overwrite an existing path. Import prints the summary and one line per record without printing content or credentials; conflicts or rejections produce exit status 2. See the complete CLI reference.

Tour messaging bridge

The FastAPI bridge exposes GET /health and signed POST /webhook. A webhook is admitted only for x-webhook-event: message.received, a timestamp no more than five minutes old, and an HMAC-SHA256 signature over <timestamp>.<raw body>.

  1. Resolve the sender through Supabase imessage_users; unlinked senders receive account-link guidance.
  2. Detect explicit travel or location intent.
  3. Call POST /api/messaging/tour-chat with { messages, user_id, location? } and x-agent-secret.
  4. Reply through Ultrareach POST /v3/chats/{chat_id}/messages with the service bearer.

Required secrets: SERVICE_API_TOKEN, AGENT_TOOL_SECRET, SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, and TOUR_BRIDGE_SIGNING_SECRET(S). Optional bases default to local Ultrareach on port 8080 and https://app.wisent.ai.