Skip to content

feat(examples): add headless smart-home agent - #70

Merged
0xjcf merged 5 commits into
betafrom
fas/smart-home-agent-example
Jun 29, 2026
Merged

feat(examples): add headless smart-home agent#70
0xjcf merged 5 commits into
betafrom
fas/smart-home-agent-example

Conversation

@0xjcf

@0xjcf 0xjcf commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add the headless smart-home agent example under examples/agents/smart-home.
  • Surface the derived view in ToolObservation so tool results carry snapshot, view, and events.
  • Address CodeRabbit smart-home review issues: runtime method binding, turn exhaustion, scripted fixture exhaustion, light events, scene clearing, and SDK missing-package handling.

Verification

  • FAS_PROCESS_PRESSURE_PREFLIGHT=0 .fas/scripts/verify.sh --full
  • npm run test in examples/agents/smart-home
  • npm run test -- src/tests/tools.test.ts in packages/ignite-element
  • git push pre-push package suite: 45 files, 454 tests
  • coderabbit review --agent --base beta --type committed -c AGENTS.md

CodeRabbit disposition

  • Rerun left one minor model-ID finding. Current Anthropic docs list claude-sonnet-4-6 as a supported model ID, so this was treated as stale reviewer data.
  • The PR feat(runtime): make the headless agent runtime DOM-free #69 host-type split finding is already tracked as a follow-up and was not expanded into this Phase B PR.

Summary by CodeRabbit

  • New Features
    • Tool results now include a derived view alongside the snapshot and events, improving post-command observations.
    • Added a headless smart-home agent example, including scripted and live runs plus terminal rendering of the home state.
  • Documentation
    • Updated the ignite tools guide to reflect the new observation contract and when the view is captured.
  • Bug Fixes
    • Improved consistency of tool-result observation data across supported flows.
  • Tests / CI
    • Expanded CI typechecking to cover additional example projects.

0xjcf added 4 commits June 28, 2026 23:00
A virtual smart home (lights/thermostat/blinds/locks/scenes) built as an
ordinary ignite-element component and driven by Claude through igniteTools +
the ignite-element/tools/anthropic adapter — running fully headless in Node
with no DOM and no jsdom. This is the end-to-end proof of the DOM-free agent
runtime (Phase A) and a stress test of the agent API surface.

- Varied command schemas: object (toggleLight/setThermostat/setBlinds), scalar
  enum (lockDoor/unlockDoor/runScene → Option D scalar wrap), no-arg (status).
- Pluggable model seam: a scripted key-free model (npm run mock / the test) and
  the real @anthropic-ai/sdk (npm run anthropic).
- A pure-Node (environment: node, zero jsdom) test asserts the schema breadth,
  the scalar round-trip, event observation, and errors-as-values.
- A terminal renderer for a watchable demo.
- GAPS.md records what dogfooding surfaced (view-vs-snapshot grounding,
  canExecute gating, an observe() channel, async/settle, scalar legibility).
- CI examples-typecheck now covers examples/agents/*.
Dogfooding the smart-home agent (Phase B) showed the agent only ever saw the raw
snapshot, never the derived view the design says it should ground on. Fix:

- ToolObservation is now { snapshot, view, events } (gains a View type param).
- igniteTools binds getView (added to the IgniteToolsRuntime surface alongside
  getSchema/execute) and captures it at command-acknowledgement, so every run()
  observation — and every provider tool_result a dialect serializes — carries
  the view (the read-model: lightsOn/allDoorsLocked/...), distinct from the
  raw snapshot.
- NeutralToolResult threads View; the Anthropic dialect needs no change (it
  serializes the whole observation).

Breaking to the pre-stable beta igniteTools surface (observation shape +
IgniteToolsRuntime pick). Resolves GAPS.md #1.
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34e61c8f-05f0-447e-8081-539b4c3372e7

📥 Commits

Reviewing files that changed from the base of the PR and between 12191c6 and cd15f76.

📒 Files selected for processing (3)
  • examples/agents/smart-home/package.json
  • examples/agents/smart-home/src/agentLoop.test.ts
  • examples/agents/smart-home/src/home.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/agents/smart-home/package.json
  • examples/agents/smart-home/src/home.ts

Walkthrough

ToolObservation now carries a derived view, and igniteTools threads getView through runtime bindings and returned observations. A new headless smart-home example adds a model loop, entrypoints, tests, docs, and CI wiring around the updated API.

Changes

View-aware tool observations

Layer / File(s) Summary
ToolObservation and runtime types
packages/ignite-element/src/tools/types.ts, .changeset/ignitetools-view-in-observation.md
Adds the View generic and view field to ToolObservation, updates NeutralToolResult, requires getView on IgniteToolsRuntime, and records the change in the changeset.
igniteTools view capture
packages/ignite-element/src/tools/igniteTools.ts
Reparameterizes the neutral and dialect tool APIs with View, binds getView from runtime, and returns { snapshot, view, events }.
Core tests and docs
packages/ignite-element/src/tests/tools.test.ts, packages/ignite-element/src/tests/tools.anthropic.test.ts, packages/ignite-element/src/tests/types/tools.types.test.ts, docs/ignite-tools.md
Updates runtime, dialect, and type tests to expect view, and revises the public docs to describe the new observation shape.

Smart-home agent example

Layer / File(s) Summary
Smart-home domain model and loop
examples/agents/smart-home/src/home.ts, examples/agents/smart-home/src/render.ts, examples/agents/smart-home/src/model.ts, examples/agents/smart-home/src/agentLoop.ts
Defines the smart-home state model and renderer, the model abstraction, and the agent loop that records tool outcomes and feeds tool results back into the model.
Smart-home entrypoints and tests
examples/agents/smart-home/src/mock.ts, examples/agents/smart-home/src/anthropic.ts, examples/agents/smart-home/src/agentLoop.test.ts, examples/agents/smart-home/package.json, examples/agents/smart-home/tsconfig.json, examples/agents/smart-home/vite.config.ts
Adds the mock and Anthropic entrypoints, the headless Vitest suite, and the example package plus local TypeScript/Vite wiring.
Smart-home docs, gaps, and CI
examples/agents/smart-home/README.md, examples/agents/smart-home/GAPS.md, .github/workflows/ci.yml
Documents the example usage and gap notes, and expands CI typechecking to include the new example directories.

Sequence Diagram(s)

sequenceDiagram
  participant runHomeAgent
  participant igniteTools
  participant createHome runtime
  participant Model

  runHomeAgent->>Model: messages + tools
  Model-->>runHomeAgent: tool_use blocks
  runHomeAgent->>igniteTools: run(toolCall)
  igniteTools->>createHome runtime: execute(command, input)
  createHome runtime-->>igniteTools: snapshot
  igniteTools->>createHome runtime: getView()
  createHome runtime-->>igniteTools: view
  igniteTools-->>runHomeAgent: { snapshot, view, events }
  runHomeAgent->>Model: tool_result with view
  Model-->>runHomeAgent: final text
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 I hopped through snapshots, then found the view,
A clearer little read-model shining through.
The smart-home doors now lock in tidy rows,
And every tool result tells the tale it knows.
With views and scenes and moonlit code aglow,
This rabbit grins: “Run, loop, run!” — and off we go.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a headless smart-home agent example.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fas/smart-home-agent-example

Comment @coderabbitai help to get the list of available commands.

@0xjcf

0xjcf commented Jun 29, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (beta@787b6c8). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             beta      #70   +/-   ##
=======================================
  Coverage        ?   89.96%           
=======================================
  Files           ?       32           
  Lines           ?     1515           
  Branches        ?      433           
=======================================
  Hits            ?     1363           
  Misses          ?      142           
  Partials        ?       10           
Flag Coverage Δ
unittests 89.96% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/ignite-element/src/tools/igniteTools.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/agents/smart-home/package.json`:
- Around line 6-10: The smart-home package’s local typecheck setup is broken
because package.json defines a typecheck script that calls tsc without ensuring
typescript is installed. Fix this by either adding typescript to the package’s
dependencies/devDependencies or removing the typecheck script from
examples/agents/smart-home/package.json; keep the test/mock/anthropic scripts
unchanged and make sure npm run typecheck works in a standalone install.

In `@examples/agents/smart-home/src/home.ts`:
- Around line 91-125: The SET_THERMOSTAT, SET_BLINDS, and SET_LOCK handlers in
the smart-home state machine are clearing activeScene even when the command is a
no-op. Update the assign logic in home.ts so activeScene is only reset when the
incoming event actually changes the stored value in context. Use the existing
TOGGLE_LIGHT-style state update pattern as a reference, and apply the same
idempotency guard across these handlers so runScene presets remain active after
repeated commands that do not change state.
- Around line 149-159: The view() function is returning live references from
snapshot.context, which exposes the machine’s internal state to downstream
mutation. Update the view in home.ts so it returns defensive copies for the
lights, thermostat, blinds, and locks fields while keeping derived values like
lightsOn and allDoorsLocked computed from snapshot.context. Use the existing
view()/getView() path as the place to clone those objects before exposing them
through tool observations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13786e57-14a9-495a-ac3e-f99a4997604a

📥 Commits

Reviewing files that changed from the base of the PR and between 787b6c8 and 12191c6.

📒 Files selected for processing (20)
  • .changeset/ignitetools-view-in-observation.md
  • .github/workflows/ci.yml
  • docs/ignite-tools.md
  • examples/agents/smart-home/GAPS.md
  • examples/agents/smart-home/README.md
  • examples/agents/smart-home/package.json
  • examples/agents/smart-home/src/agentLoop.test.ts
  • examples/agents/smart-home/src/agentLoop.ts
  • examples/agents/smart-home/src/anthropic.ts
  • examples/agents/smart-home/src/home.ts
  • examples/agents/smart-home/src/mock.ts
  • examples/agents/smart-home/src/model.ts
  • examples/agents/smart-home/src/render.ts
  • examples/agents/smart-home/tsconfig.json
  • examples/agents/smart-home/vite.config.ts
  • packages/ignite-element/src/tests/tools.anthropic.test.ts
  • packages/ignite-element/src/tests/tools.test.ts
  • packages/ignite-element/src/tests/types/tools.types.test.ts
  • packages/ignite-element/src/tools/igniteTools.ts
  • packages/ignite-element/src/tools/types.ts

Comment thread examples/agents/smart-home/package.json
Comment thread examples/agents/smart-home/src/home.ts
Comment thread examples/agents/smart-home/src/home.ts
@0xjcf

0xjcf commented Jun 29, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@0xjcf
0xjcf merged commit eabc37d into beta Jun 29, 2026
6 checks passed
@0xjcf
0xjcf deleted the fas/smart-home-agent-example branch June 29, 2026 14:11
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