feat: add deep survey example and worker shared state support#4159
Merged
feat: add deep survey example and worker shared state support#4159
Conversation
1b53a99 to
c7b7419
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4159 +/- ##
==========================================
- Coverage 68.08% 67.91% -0.18%
==========================================
Files 130 130
Lines 16211 16264 +53
Branches 3912 3920 +8
==========================================
+ Hits 11037 11045 +8
- Misses 5170 5215 +45
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2 tasks
cc7640a to
3f1ba5c
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port the deep survey (wiki-swarm) example from the durable-streams repo. Add shared state DB support to worker agents, enabling spawners to give workers per-collection CRUD tools via sharedDb spawn arg. - Worker agents accept optional sharedDb and sharedDbToolMode spawn args - Rename schema param to dbSchema in db() observation source - Add deep survey example with orchestrator + explorer swarm pattern Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3f1ba5c to
eea8c7b
Compare
…onflicts Transitive deps pulled @types/react@19 alongside the direct @types/react@18, causing dual csstype versions (3.1.3 vs 3.2.3) and widespread TS errors. - linearlite, linearlite-read-only, todo-app: upgrade @types/react and @types/react-dom to v19 - linearlite: upgrade react-markdown 8→9 (v8 ships .ts files incompatible with React 19 types) - Fix React 19 type changes: useRef args, RefObject<Element | null> - Remove stale @types/react-router-dom from linearlite-read-only Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
eea8c7b to
91b4d38
Compare
icehaunter
approved these changes
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port of electric-sql/durable-streams#134.
Adds a new Deep Survey example app (
examples/deep-survey/) — a demo where ~50 AI agents explore a corpus in parallel, each doing real web research and writing wiki entries with cross-references. Also adds shared state DB support to the built-in DARIX worker entity type.Root cause (bundler fix)
The
db()observation source ints-darix-runtimeused property shorthand (schema,) which thetsdownbundler mangled todbSchema: schemain the dist output. This causedclient.observe(db(...))to fail silently because theschemaproperty was missing from the returned object. Fixed by renaming the parameter todbSchemawith explicitschema: dbSchemaassignment.Approach
Backend — Two entity types:
orchestrator: Receives a target corpus, does initial web research (Brave Search API), then spawns Nworkerentities each assigned a topic. Uses shared state to accumulate wiki entries and cross-references.workertype (extended in this PR to support shared state DBs). Each worker getsbrave_search+fetch_urltools plus auto-generated CRUD tools for the shared wiki/xrefs collections.Built-in worker shared state support (
ts-darix-server):WorkerArgsnow accepts optionalsharedDb: { id, schema }andsharedDbToolMode: "full" | "write-only"buildSharedStateTools()generateswrite_,read_,update_,delete_tools per collectionparseWorkerArgsvalidatessharedDbstructure and throws on malformed inputtoolsorsharedDbmust be providedFrontend — Real-time reactive UI:
useSwarmhook observes entities by tag + manifest-gated shared state subscriptioncreateEffectfrom@tanstack/dbfor live collection updatesKey invariants
clone_repotool validates URLs against^https?://[a-zA-Z0-9._\-]+/[a-zA-Z0-9._\-/]+$and usesexecFile(no shell interpolation)ctx.darixTools, only the tool subset chosen by the spawnerz.string().min(1)to prevent empty-key insertionctx.mkdb())Non-goals
as anycasts inuseSwarm.tsremain — fixing requires upstream type improvements to the darix-runtime client APIRunning the example
Prerequisites
# From repo root — starts Docker infra (Postgres, Electric, agents-server) + built-in Horton server node packages/electric-ax/bin/electric-dev.mjs agent quickstartANTHROPIC_API_KEYset in.envat repo root (required for the agents)BRAVE_SEARCH_API_KEYenv var for web search (set in.envat repo root)Setup & run
This starts:
http://localhost:4700— registers the orchestrator entity type with DARIXhttp://localhost:5175— Vite dev server with proxy to the backendEnvironment variables
DARIX_URLhttp://localhost:4437PORT4700SERVE_URLhttp://localhost:$PORTBRAVE_SEARCH_API_KEYType-check
cd examples/deep-survey pnpm typecheckFiles changed
New example app (
examples/deep-survey/):src/server/— orchestrator entity, explorer prompt, schema, HTTP serversrc/ui/— React frontend with 7 components, useSwarm hook, dark theme CSSpackage.json,tsconfig.json,vite.config.ts🤖 Generated with Claude Code