Skip to content
DhivyeshpPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Destina with Tina

Destina is a responsive player companion for Tina with an arcane tabletop aesthetic. The web app handles room onboarding, profile ingestion, interest review, AI processing, and relic prompt reveals. The Vision Pro app owns all Game Master interaction. There are no browser Game Master controls, scoring, timers, relic claims, or simulated delivery.

The two physical entry points

  1. Tina’s QR → /join/ROOMCODE: a custom QR identifies the correct room. A player enters their name, connects/shares their profile, approves extracted interests, and adds any extras. Joining stores room membership in an HTTP-only cookie on that phone.
  2. Every relic chip → /c: write the identical absolute URL to every tap-readable chip. No tag ID, player ID, question ID, or room code is encoded in relic URLs. The server uses the phone's joined room and returns that room's active, Game Master-approved question.

If no question is approved, /c shows a waiting state. After an assignment, it shows the new question. Clearing a question returns it to waiting. Private Bounty instructions are included only for the assigned target's session. All other room members receive the public prompt only.

A phone that has not joined a room must onboard through the bot QR (or enter its room code). It cannot infer a room from the universal relic URL. The same browser used for onboarding must open the chip URL, since membership belongs to that browser's cookie. Identical chips cannot prove delivery or identify individual relics, and merely opening /c never claims/consumes a relic or changes game state. Physical tags and any NFT association are outside this web implementation; no wallet verification or minting is assumed.

Run locally

Requires Node.js 20.19+ and npm, plus a TigerDB (TimescaleDB) service. Set TIGER_DATABASE_URL and run npm run tigerdb:migrate once; the server creates any missing tables on start.

npm install
cp .env.example .env
npm run room -- "The midnight gathering"
npm run dev

The room command prints the bot QR destination and universal relic URL. Open the printed /join/ROOMCODE link to test onboarding. The root / also accepts a room code; players cannot create their own rooms from the browser. Existing joined phones return to their profile/ready screen.

npm test
npm run build
npm start

npm run dev serves the frontend and backend at http://localhost:3000, with Vite and server hot reload. npm start serves the production build. Set PORT to change the port. Format with npm run format.

All state lives in TigerDB, configured by TIGER_DATABASE_URL; there is no local database file. See TigerDB store. Existing JSON session records are preserved; obsolete score/GM fields are no longer exposed. The new player UI does not expose old game dashboards or sample-player controls.

Player profile flow

  • Connect Instagram, paste selected bio/caption text, or load a .txt file into the text editor.
  • Shared text is submitted to Meta AI only when the player chooses Find my interests or explicitly authorizes Instagram import.
  • Show extracted suggestions and source excerpts privately to their owner.
  • Let the player deselect suggestions and add comma-separated manual interests (up to 12 approved interests).
  • Save & join the circle confirms what may be used for recommendations.
  • Show a simple ready screen explaining the physical relic tap. Players can edit interests at any time or delete their profile data.

There is no fabricated extraction fallback. If a profile is sparse, unsupported, or the model fails, manual interests remain available. .txt import accepts selected text up to 16,000 characters; it is not a parser for full Instagram export archives or screenshots.

Meta AI

Configure the ignored .env file and restart:

MODEL_API_KEY=your-meta-model-api-key
MODEL_API_URL=https://api.meta.ai/v1
MODEL_NAME=muse-spark-1.1

The server calls Muse Spark through Meta's OpenAI-compatible Chat Completions endpoint, using the configurable model supported by your account. No OpenAI key is used. See the Meta Model API guide.

The pipeline extracts source-backed interest suggestions, then combines approved interests, relic rules, previous questions, participation, optional GM context, and an optional selected target into three candidate challenges. Candidates include participant IDs, a public prompt, a separate private mission where applicable, duration, evidence IDs, and a short grounding reason. The server checks structure, evidence references, participant counts, target selection, and repeated titles. Ranking favors shared interests, variety, and participants with fewer prior turns.

Each request has an 18-second timeout and bounded output. Invalid structured output gets one repair attempt, with invalid output kept in untrusted user data. Profile content never becomes developer instructions. Failed recommendation generation returns explicitly attributed deterministic fallback candidates to the control interface; only a Game Master assignment makes any candidate visible to players.

Supported relic templates: Duel, Bounty, Hot Seat, Jinx, Forge, and a Golden bonus. Prompts are played and moderated at the table; no audio monitoring, result verification, scoring, crypto payout, or art generation runs here. Interest inference remains provisional until the player approves it; the GM reviews generated questions before assigning one.

Live provider calls have not been verified with project credentials. Automated tests mock Meta and Instagram.

Instagram setup

The connector uses Instagram API with Instagram Login, requesting only instagram_business_basic. It supports eligible Business and Creator accounts, not ordinary consumer accounts. It cannot read personalized feeds, saved posts, private messages, or a complete interest history.

  1. Create a Meta developer app with the Instagram API product and Instagram Login configuration.

  2. Add an eligible professional test account and complete its required test authorization.

  3. Start an HTTPS tunnel to local port 3000 using your preferred tool. For example, with an installed Cloudflare Tunnel:

    cloudflared tunnel --url http://localhost:3000
  4. Register the exact redirect URL and configure:

    PUBLIC_URL=https://your-tunnel-domain.example
    INSTAGRAM_APP_ID=your-instagram-app-id
    INSTAGRAM_APP_SECRET=your-instagram-app-secret
    INSTAGRAM_REDIRECT_URI=https://your-tunnel-domain.example/api/instagram/callback
    INSTAGRAM_GRAPH_VERSION=v25.0
    TOKEN_ENCRYPTION_KEY=64-hexadecimal-characters

    Generate the encryption key with openssl rand -hex 32. Never commit secrets.

  5. Restart, generate the bot QR using that HTTPS origin, and join via that origin before connecting Instagram. Encode ${PUBLIC_URL}/c on every NFC chip. Localhost links do not work on other phones.

  6. Validate one test account's actual fields. The import notice reports available and unavailable fields. Broader access depends on Meta's current review and access requirements.

The connector imports supported profile text and up to 12 recent captions, probing optional biography/type/caption fields separately. Unsupported fields do not fabricate data or fail the entire import. OAuth state is session-bound, one-time, and expires after ten minutes. Tokens are encrypted with AES-256-GCM and purged after expiry; this immediate-import release uses short-lived tokens and requires reconnecting for another import rather than running a refresh/sync service.

ngrok alternative for HTTPS testing

If Cloudflare Tunnel cannot connect on the current network, install the official ngrok client with brew install ngrok. Create an ngrok account and paste its agent authtoken into the ignored .env file as NGROK_AUTHTOKEN. This is separate from the Muse key and the ngrok management API key.

For a reserved ngrok domain, set NGROK_URL=https://your-name.ngrok.app in .env alongside the matching PUBLIC_URL and INSTAGRAM_REDIRECT_URI. The launcher passes this URL to ngrok on every start.

With the app running on port 3000, run npm run tunnel. The launcher reads .env and redacts the token from any agent output. Retrieve the HTTPS forwarding address from ngrok, set PUBLIC_URL to that origin and INSTAGRAM_REDIRECT_URI to its /api/instagram/callback URL, then restart the app. Register the exact same callback in Meta's Instagram Business Login settings. Use the HTTPS origin for both onboarding and the Instagram connection. Keep the app and tunnel running while testing.

Game Master / bot integration boundary

The actual Vision Pro UI and application WebSocket are deferred. The current processing operations are available through a small authenticated HTTP control API, and shared transport-neutral types/event envelopes are ready for a future adapter. Player browsers currently poll: room/profile metadata every 10 seconds; the open relic view every 4 seconds and on returning to the tab. A fresh chip navigation always fetches the current question with caching disabled.

Set GM_API_KEY to a securely generated server-side control credential (openssl rand -hex 32). Keep it out of browser code, chip URLs, and room QR codes. Calls from the trusted bot/Vision Pro adapter use Authorization: Bearer <GM_API_KEY>. Without configuration the control API fails closed with 503; player cookies cannot authorize it. Use HTTPS outside local development.

Endpoint Purpose
POST /api/control/rooms {name} → create room; return joinPath and common capsulePath
GET /api/control/rooms/:code Read approved roster, candidate options, and active question
POST /api/control/rooms/:code/recommendations {context?, targetPlayerId?} → generate 3 candidates
POST /api/control/rooms/:code/assign {recommendationId, instructions?} → approve a candidate and set the active question
POST /api/control/rooms/:code/clear `{status:"completed"
POST /api/control/rooms/:code/finish Close room and remove raw source excerpts

Choose the target through targetPlayerId when requesting recommendations; every returned candidate puts that player first. To change targets, request fresh grounded candidates for the new player rather than blindly substituting names into an old question. Assignment accepts an optional edited public instruction. Candidates are invalidated by interest changes; in-flight generation is rejected if room state changes. Clear the active question before generating/assigning the next one. Repeated reads are safe; duplicate assignments are rejected. Only one question is active per room.

shared/types.ts defines Snapshot (private player profile), CapsuleSnapshot (role-filtered active prompt), ControlSnapshot (trusted GM state), and RoomEvent. createApp().setEventSink() accepts an internal event consumer. Its envelope is {schemaVersion:1,type,roomId,roomVersion,at}; it contains no secret text. A later WebSocket adapter can subscribe to these events and obtain the appropriate snapshot after authenticating the recipient. Nothing currently opens a game WebSocket port or sends GM state to players.

Player HTTP interfaces

Endpoint Purpose
GET /api/rooms/:code Minimal public onboarding metadata
POST /api/join {code,name} → join and issue a room-bound cookie
GET /api/session Current player's profile and room metadata only
GET /api/capsule Current approved prompt for that player's room; prompt:null while waiting
GET /api/instagram/connect Begin Instagram linking
GET /api/instagram/callback Consume OAuth state and import supported text
POST /api/profile/text {text} → extract interest suggestions
POST /api/interests {approvedIds,labels} → approve suggestions and add manual interests
DELETE /api/profile Delete own sources/interests and disconnect

Player cookies are HTTP-only, SameSite=Lax, and Secure for an HTTPS PUBLIC_URL; their credentials are stored hashed. Browser mutations reject foreign origins. Private sources and pending interests are visible only to their owner; public prompt responses omit the recommendation queue, evidence IDs, model reasoning, and private missions for other players. Finished rooms show no active prompt. Rejoining the same room with the same browser does not add a duplicate player. Joining another room explicitly changes that browser's active room.

Source layout and verification

  • src/: player onboarding, profile review, ready state, and universal relic view; mobile controls and reduced-motion styles.
  • server/: HTTP operations, TigerDB storage, Instagram, encryption, Meta generation, room state, and future transport event boundary.
  • shared/types.ts: player/control contracts.
  • scripts/room.ts: local room provisioning; the bot can later use the control API instead.
  • tests/: shared URL behavior, target privacy, room isolation, control authorization, source review, persistence, provider failures, target selection, OAuth states, encryption, stale candidates, and room closure.

Raw profile text is removed when its owner deletes it or the room closes. Approved interests and prior assigned prompts remain in the room's internal history to support generation; deleting a profile does not rewrite questions already assigned. TigerDB holds versioned JSON room aggregates plus credential, connection, OAuth, and event tables, and the transcript hypertable. npm run tigerdb:migrate is idempotent and safe to re-run. Keep the database and encryption key together if backing up data.

Private question review and Muse credit limits

Run npm run questions -- ROOMCODE --sample --serve for a free local template preview at http://localhost:3001. --sample adds preview-only players when fewer than three ready players exist; it does not create accounts or alter the room. Use --live to explicitly request one batch of three Muse candidates (at most one repair). Subsequent runs without --live reuse the saved result for the same inputs. Browser refresh never invokes AI. Files live in ignored data/question-previews/ and include private Bounty text: keep them private. This developer preview does not assign questions or replace Vision Pro controls.

All model calls now reserve a persistent request slot before sending. The default MODEL_MAX_REQUESTS=100 counts extraction, generation, repairs, and failed sends from this point forward. The ledger is the model_usage table in TigerDB. Reaching the cap uses the existing manual-interest/template fallback. The cap cannot guarantee a dollar amount; provider billing is authoritative, and it does not include earlier usage or other applications. Do not delete the ledger to reset usage accidentally. Review quality using the rubric on the preview before spending more on regeneration. Real testing needs only one Instagram connection; other players can join separate browser sessions and approve manual interests.

Visual direction

The supplied design spec is implemented with shared color and typography tokens in src/design-tokens.css. The existing layout stays in place. Cormorant Unicase handles the lowercase destina wordmark and prompt titles, Cormorant Garamond handles italic headlines, and Space Grotesk handles body text and controls. All three fonts and their SIL licenses are bundled in public/fonts so players do not need Google Fonts access.

The profile uses a dark Instagram panel and a cream interests panel. Removable interest rows expose 44px controls and kept counts; removing a saved item opens an unsaved edit. The imported-profile summary uses a cream inset box and reports only the bio/captions actually stored. The original source excerpts stay verbatim. The provided ring-and-star logo, light variant, app icon, and website favicon are in public. The lowercase wordmark and omitted tagline follow the explicit branding preferences from the app design session.

Destina calls its questions prompts. Tina carries the NFC tags. Existing public URLs and API field names remain compatible with the tap tags and control adapter. The private preview uses the same design tokens and a numbered question reading layout.

Appearance and phone layouts

The header switches between light and dark appearance. public/theme.js applies the saved destina-theme preference before the app renders, otherwise following the device setting. Changes sync across tabs on the same origin; storage-blocked browsers still allow switching for the current page. The preview uses the same controller and palette. On phones, profiles with interests place that list first, connection/privacy details are collapsed, and save actions remain at the bottom with safe-area spacing. Imported text and question explanations stay available through disclosures.

Single-game demo

With DEMO_MODE=true and DEMO_ROOM_CODE set to an existing room, /gm opens Game Master controls without a key, /join onboards into the shared demo without a room code, and /prompt shows the selected prompt. Anyone with /gm can view transcripts and control this demo, including paid generation. Existing caps and recording consent still apply. Disable demo mode and restart to restore private GM access. Room identifiers remain internal; existing profiles are preserved.

Shared NFC link and private questions

Write https://your-domain/prompt onto every NFC tag. Existing /relic and /c tags redirect to /prompt. The link uses the phone’s joined room and always reads that room’s current GM selection. It updates every four seconds and when returning to the page. Tapping does not claim or consume a relic. The assigned player alone sees private Bounty instructions. Players should onboard and tap using the same browser on the same domain; an in-app browser or a different browser may need to join again. A single shared tag URL cannot identify a physical relic or infer the player’s room without their saved player session.

/gm (also /questions?room=ROOMCODE) is the private Game Master view. It retains suggestions, the current selection, player readiness and earlier turns. Opening or refreshing it never requests Muse generation.

Run npm run questions:link -- ROOMCODE --control --file to create a private link with browser testing controls. Open data/questions-access-link.txt once within ten minutes. Omit --control for read-only access. Never put these links on Tina's public QR code or NFC tags. Access lasts twelve hours in an HttpOnly, room-scoped cookie; “Close private view” revokes it. Signing in with the configured GM_API_KEY also grants control. The browser cookie does not grant bearer API access.

Use Open on another device in an authorized GM view to create a one-use private link for the deployed app. Bookmark /gm there to reopen the room while its 12-hour access cookie is valid.

The combined control view can choose or edit prompts, record completed/passed turns and transcribe consenting participants through Deepgram. Assigned solo prompts offer a suggested speaker name that the GM must confirm. Muse can prepare a bounded batch from recent conversation between turns. See live conversation setup and the feed interface.

The profile screen has no Prompt tab. NFC tags open /prompt directly to show the GM selection. The profile footer offers Reset profile, which clears the Instagram connection, OAuth attempts, imported text and interests while keeping the player name and room. Previously shared questions stay in room history. Imported text is explained alongside the Instagram connection and can be expanded to review the original bio and captions.

See remaining work for the integration and deployment checklist.

Voice and text introductions

The profile’s “In your own words” section accepts a short typed or dictated introduction. On supported secure browsers, “Use my voice” starts one browser speech-recognition session, limited to 30 seconds. Other browsers show guidance for phone keyboard dictation. Users can review and edit up to 1,200 characters before explicitly requesting suggested interests. Destina receives text only; browser recognition may use the browser vendor’s online service.

POST /api/profile/intro uses the joined player cookie, preserves Instagram sources and saved interests, and creates unapproved suggestions grounded in an intro source. It uses the existing bounded Muse pipeline and request allowance. Repeating an identical saved intro does not send another model request. A profile reset during extraction prevents that request from restoring deleted data. Intro text stays out of the GM/player roster and is removed by profile reset or session closure. Device microphone permission and speech quality still need verification on actual iOS and Android phones. See voice intro details.

Automatic interest saving

Profile onboarding is ordered Your interests, In your own words, Your Instagram on every screen. Add an interest with Enter, a comma, the Add button or by leaving the field. Changes save immediately with a saving/saved state and retry on failure; there is no sticky Save footer. Extracted suggestions populate the top list and save automatically; players can remove anything that does not fit. The voice intro still requires reviewing its text and explicitly requesting extraction.

GM readiness updates from persisted interests. Every joined player needs at least one interest, with at least two players in demo mode (three in private mode), before generation or assignment. Removing a player's last interest blocks the next generation and start again.

Tina Tokens and Game Master stats

/gm#gm-tokens contains round award review, player statistics, shared-goal settings and explicit Solana devnet settlement. The five scored actions total at most 10 Tina Tokens per person per round. Bonuses need a GM observation or real speech evidence with a confirmed player name. Passing carries no deduction. Players see their own confirmed/pending balance and the shared goal below their profile cards. Muse can suggest awards during existing conversation generation; only GM approval creates pending awards, and settlement is a separate action.

Set CHAIN_SERVICE_URL and CHAIN_API_TOKEN on the game server, alongside the existing TOKEN_ENCRYPTION_KEY. Wallets are encrypted locally before registration. Mainnet is rejected. Each reset starts a new reward game so round IDs cannot accidentally replay an old payout. See Tina Tokens setup and operation.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages