@fatagnus/codebuff 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -347,6 +347,49 @@ export async function multiTurnConversation(
347
347
  }
348
348
  ```
349
349
 
350
+ ### Subagent Spawning in Convex
351
+
352
+ The Convex runtime supports spawning subagents using the `spawn_agents` tool. To use this feature:
353
+
354
+ 1. Define your agents with `spawnableAgents` arrays
355
+ 2. Include all agent definitions in `agentDefinitions`
356
+
357
+ ```typescript
358
+ import { ConvexCodebuffClient } from '@fatagnus/codebuff/convex'
359
+ import type { AgentDefinition } from '@fatagnus/codebuff/convex'
360
+
361
+ const helperAgent: AgentDefinition = {
362
+ id: 'helper',
363
+ displayName: 'Helper Agent',
364
+ systemPrompt: 'You are a helpful assistant that answers questions.',
365
+ toolNames: ['read_files', 'end_turn'],
366
+ }
367
+
368
+ const orchestratorAgent: AgentDefinition = {
369
+ id: 'orchestrator',
370
+ displayName: 'Orchestrator',
371
+ systemPrompt: 'You coordinate tasks by spawning helper agents.',
372
+ toolNames: ['spawn_agents', 'read_files', 'end_turn'],
373
+ spawnableAgents: ['helper'], // Can spawn the helper agent
374
+ }
375
+
376
+ const client = new ConvexCodebuffClient({
377
+ apiKey,
378
+ projectFiles: myFiles,
379
+ agentDefinitions: [helperAgent, orchestratorAgent],
380
+ })
381
+
382
+ const result = await client.run({
383
+ agent: orchestratorAgent,
384
+ prompt: 'Analyze this codebase by spawning helpers for each file.',
385
+ })
386
+ ```
387
+
388
+ **Subagent limitations in Convex:**
389
+ - Maximum nesting depth of 5 levels
390
+ - Subagents can only be spawned from `agentDefinitions` (no database lookups)
391
+ - Subagents run in parallel using `Promise.allSettled`
392
+
350
393
  ### Convex Limitations
351
394
 
352
395
  When running in Convex, the following tools are **not available** (they will throw `ConvexUnsupportedToolError`):
@@ -385,7 +428,7 @@ const client = new ConvexCodebuffClient({
385
428
  - **`agentDefinitions`** (array, optional): Custom agent definitions
386
429
  - **`maxAgentSteps`** (number, optional): Max steps before stopping (recommended: 10-20 for Convex timeout limits)
387
430
  - **`handleEvent`** (function, optional): Event callback for streaming
388
- - **`handleStreamChunk`** (function, optional): Chunk callback for real-time updates
431
+ - **`handleStreamChunk`** (function, optional): Chunk callback for real-time updates. Receives text chunks and subagent events (`subagent_start`, `subagent_chunk`, `subagent_finish`)
389
432
  - **`overrideTools`** (object, optional): Custom tool implementations
390
433
  - **`customToolDefinitions`** (array, optional): Custom tool definitions
391
434