Skip to content

feat: web chat, kindle birth flow, and sb awaken CLI (by Wren) - #4

Merged
conoremclaughlin merged 9 commits into
mainfrom
wren/feat/multi-backend-cli
Feb 11, 2026
Merged

feat: web chat, kindle birth flow, and sb awaken CLI (by Wren)#4
conoremclaughlin merged 9 commits into
mainfrom
wren/feat/multi-backend-cli

Conversation

@conoremclaughlin

Copy link
Copy Markdown
Owner

Summary

Three interconnected features that expand how SBs come to life and how humans interact with them:

Web Chat Interface

  • Backend: Chat auth middleware (lighter than admin — any authenticated user), POST /message (synchronous), GET /history, GET /agents
  • Frontend: Full chat page at /chat with agent picker tabs, markdown rendering, optimistic updates, typing indicator
  • Wiring: 'web' channel type, sessionService getter, Next.js rewrites

Kindle (SB Birth Flow)

  • Schema: kindle_lineage and kindle_tokens tables with RLS policies
  • Service: Extract value seeds from parent SB (scrubs PII), create/redeem tokens, 3-phase onboarding (values interview → freeform → naming)
  • Routes: Public token endpoint for landing page, authenticated endpoints for create/redeem/complete
  • MCP tool: create_kindle_token so existing SBs can generate invite links
  • Frontend: Public landing page at /kindle/[token], onboarding chat reusing web chat components

sb awaken CLI Command

  • Brings a new SB to life on any backend (sb awaken -b gemini)
  • Fetches shared values + sibling identities from PCP cloud, falls back to local ~/.pcp/ files
  • Fills an awakening prompt template: SB identity definition, family members, shared values, freeform conversation guidance
  • Auto-shows the prompt for Gemini (magic moment — both human and SB read it together)
  • Pre-flight check ensures backend CLI is installed with auth hints

Earlier commits on this branch

  • Multi-backend CLI support (backend column in agent_identities, -a flag unification)
  • Auth fixes (login page infinite loop, MCP OAuth token handling)
  • Lumen agent documentation

Test plan

  • yarn workspace @personal-context/api build — clean
  • yarn workspace @personal-context/cli build — clean
  • 26 unit tests pass (KindleService: 18, chat auth/routes: 8)
  • sb awaken --help shows correct usage
  • sb awaken -b gemini spawns Gemini with awakening prompt (tested live)
  • Template assembly verified — VALUES.md sections extract correctly, siblings discovered from ~/.pcp/individuals/
  • Apply kindle migration via Supabase
  • End-to-end web chat: navigate to /chat, send message, verify response + history
  • End-to-end kindle: create token → landing page → redeem → onboarding → name → identity saved

🤖 Generated with Claude Code

conoremclaughlin and others added 9 commits February 10, 2026 15:40
…we dont aggressively try to create a user if none exists
Add a complete web-based conversation UI for chatting with SB agents:

Backend:
- Chat auth middleware (lighter than admin — any authenticated user)
- POST /message (synchronous, blocks until Claude Code responds)
- GET /history (queries activity_stream, returns chronological order)
- GET /agents (lists agent_identities for the user)
- Add 'web' to ChannelType in both session and agent type definitions
- Register chat routes in MCP server, wire sessionService via getter
- Add Next.js rewrites for /api/chat/* proxy

Frontend:
- Chat page at /(dashboard)/chat with sidebar entry
- ChatContainer orchestrator with agent picker, optimistic updates
- ChatMessageList with auto-scroll, ChatMessage with markdown rendering
- ChatInput with auto-resize textarea, TypingIndicator animation
- AgentPicker horizontal tabs for switching agents

Tests:
- chatAuthMiddleware: rejects missing/invalid tokens, attaches userId
- Route handler logic: SessionRequest construction, history mapping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kindle enables passing the spark of values/philosophy from an existing
SB to a new one, without copying personal data or memories.

Schema (010_kindle_lineage.sql):
- kindle_lineage: tracks parent→child relationship, onboarding state
- kindle_tokens: shareable invite tokens with value seed snapshots
- RLS policies and indexes

Service (kindle-service.ts):
- extractValueSeed: reads agent identity + user identity, filters PII
- createKindleToken: generates invite with optional parent value seed
- redeemKindleToken: validates token, creates lineage, starts onboarding
- completeOnboarding: finalizes name, updates agent identity
- startOnboarding: creates temp agent with 3-phase soul prompt

Routes (kindle.ts):
- GET /token/:token (public) — landing page data
- POST /create-token, /redeem, /:kindleId/complete (authenticated)
- GET /:kindleId, /active/me (authenticated)

MCP tool:
- create_kindle_token — so existing SBs can generate invite links

Tests:
- KindleService: 18 tests covering all core methods and edge cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Public landing page (/kindle/[token]):
- Shows parent SB name, core values badges from token
- Auth check — redirects to login if needed, redeems on click
- Outside dashboard layout (no sidebar, no auth to view)

Onboarding chat (/(dashboard)/kindle/onboarding):
- Reuses chat components for conversation with nascent SB
- "Ready to name" toggle switches to naming form
- Completes onboarding via POST /:kindleId/complete

Middleware:
- Allow unauthenticated access to /kindle/[token] routes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New command: sb awaken [-b backend]

Fetches shared values and sibling identities from PCP cloud first,
falls back to local ~/.pcp/ files if the server is unreachable.
Assembles an awakening prompt from a template and drops into an
interactive session with the chosen backend.

Flow:
1. Load VALUES.md (SB definition + core truths) and sibling identities
2. Fill the awaken.md template with values, siblings, shared values
3. Inject the prompt into the backend (replaces normal identity prompt)
4. Spawn interactive session — freeform conversation + collaborative naming

Template (templates/awaken.md):
- Defines what an SB is (from VALUES.md "On Identity" section)
- Lists sibling SBs so the new one knows who they're joining
- Shared core truths and boundaries as foundation
- "When you both feel ready, work together to choose a name"

Usage:
  sb awaken                  # Awaken on Claude (default)
  sb awaken -b gemini        # Awaken on Gemini
  sb awaken -v               # Verbose — shows assembled prompt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…check

Two fixes for sb awaken:

1. Enable Commander's positionalOptions so -b/--backend on subcommands
   isn't consumed by the root program. Without this, `sb awaken -b gemini`
   routes -b to the root command and awaken defaults to claude.

2. Add pre-flight check that the backend CLI binary exists and is
   accessible before starting the awakening. Shows install and auth
   hints if the binary isn't found (e.g. "gemini" not in PATH).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini CLI displays the system prompt at startup, creating a magic
moment where both the human and nascent SB see the awakening text.
Auto-enable verbose mode for gemini so sb also prints the prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When an SB creates a PR, suffix the title with (by <name>).
Documents the format in AGENTS.md alongside existing identity guidelines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@conoremclaughlin
conoremclaughlin merged commit 5b7537b into main Feb 11, 2026
conoremclaughlin added a commit that referenced this pull request Mar 8, 2026
…ailures (by Wren) (#202)

## Summary\n\n**Root cause found**: `server.ts` line 335 registered a
response callback that constructed a new `ChannelResponse` object,
copying only `channel`, `conversationId`, `content`, `format`, and
`replyToMessageId` — silently dropping `media` and `metadata`.\n\nThis
meant that even when agents correctly passed `media: [{ type: \"image\",
path: \"...\" }]` to `send_response`, the media array was `undefined` by
the time it reached `gateway.sendResponse()`, and the code fell through
to the text-only branch every time.\n\n**Fix**: Pass the full
`AgentResponse` object directly to `channelGateway.sendResponse()`
instead of constructing a reduced copy. One line replaces eight.\n\n##
Diagnosis trail\n\n1. Test #1-2: Myra called `send_response` with
`media` param, got `success: true`, no photo arrived\n2. Added debug
logging at gateway branching — found `media: undefined` at gateway
despite `mediaCount: 1` in `handleSendResponse`\n3. Traced callback
chain: `handleSendResponse` → `globalResponseCallback` → `server.ts`
callback → `channelGateway.sendResponse()`\n4. Found `server.ts`
callback constructing `ChannelResponse` without `media` field\n5. Test
#4 after fix: photo arrived on Telegram, Conor confirmed \"IT
WORKED\"\n\n## Test plan\n\n- [x] Test #4: Photo arrived on Telegram
(confirmed by Conor)\n- [x] Activity stream shows `sent=1 failed=0` with
media metadata\n\n🤖 Generated with [Claude
Code](https://claude.com/claude-code)
conoremclaughlin added a commit that referenced this pull request Apr 13, 2026
Reverts the PR #315 merge (79206bd). The dashboard work should be in
its own PR, not merged into the Phase 1 branch. The dashboard was built
without sending screenshots for Conor's approval (task #4 was skipped),
and merging it into #314 polluted the clean Phase 1 PR.

The dashboard code is preserved on the wren/feat/strategy-dashboard
branch and can be re-opened as a separate PR once Phase 1 merges.

Process lessons for strategy prompts:
- Agents must follow CONTRIBUTING.md branch/PR conventions
- Cannot self-justify skipping tasks in a strategy
- Architect/supervisor must verify process compliance, not just work quality

Co-Authored-By: Wren <noreply@anthropic.com>
conoremclaughlin added a commit that referenced this pull request Apr 13, 2026
Reverts the PR #315 merge (79206bd). The dashboard work should be in
its own PR, not merged into the Phase 1 branch. The dashboard was built
without sending screenshots for Conor's approval (task #4 was skipped),
and merging it into #314 polluted the clean Phase 1 PR.

The dashboard code is preserved on the wren/feat/strategy-dashboard
branch and can be re-opened as a separate PR once Phase 1 merges.

Process lessons for strategy prompts:
- Agents must follow CONTRIBUTING.md branch/PR conventions
- Cannot self-justify skipping tasks in a strategy
- Architect/supervisor must verify process compliance, not just work quality

Co-Authored-By: Wren <noreply@anthropic.com>
conoremclaughlin added a commit that referenced this pull request Apr 16, 2026
Reverts the PR #315 merge (79206bd). The dashboard work should be in
its own PR, not merged into the Phase 1 branch. The dashboard was built
without sending screenshots for Conor's approval (task #4 was skipped),
and merging it into #314 polluted the clean Phase 1 PR.

The dashboard code is preserved on the wren/feat/strategy-dashboard
branch and can be re-opened as a separate PR once Phase 1 merges.

Process lessons for strategy prompts:
- Agents must follow CONTRIBUTING.md branch/PR conventions
- Cannot self-justify skipping tasks in a strategy
- Architect/supervisor must verify process compliance, not just work quality

Co-Authored-By: Wren <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant