Commit Graph

45 Commits

Author SHA1 Message Date
JackChen fea9df3f7a chore: add coverage/ to .gitignore 2026-04-03 17:38:41 +08:00
JackChen 2253122515 docs: reposition README around TypeScript-native, goal-to-result, lightweight differentiators 2026-04-03 17:35:12 +08:00
JackChen 0111876264
feat: add onTrace observability callback (#18)
Add lightweight onTrace callback to OrchestratorConfig that emits
structured span events (llm_call, tool_call, task, agent) with timing,
token usage, and runId correlation. Zero overhead when not subscribed.

Closes #18
2026-04-03 15:28:59 +08:00
JackChen 17546fd93e docs: merge Gemma 4 examples, reorder README sections
- Merge examples 08 (runTasks) and 09 (runTeam) into a single Gemma 4 example
- Renumber: structured output → 09, task retry → 10
- Move Author and Contributors sections to bottom in both READMEs
- Add Author section to English README
2026-04-03 14:32:48 +08:00
JackChen 27c0103736 docs: add examples for structured output and task retry 2026-04-03 14:23:22 +08:00
JackChen 043deaf562 docs: update CLAUDE.md with structured output and task retry 2026-04-03 14:16:44 +08:00
JackChen d9b20c0cf6 fix: guard retry fields against Infinity/NaN
Use Number.isFinite() to sanitize maxRetries, retryDelayMs, and
retryBackoff before entering the retry loop. Prevents unbounded
retries from Infinity or broken loop bounds from NaN.
2026-04-03 14:14:34 +08:00
JackChen 42f3717115 chore: bump version to 0.2.0 2026-04-03 14:13:33 +08:00
JackChen 2187f3b310
docs: add Structured Output and Task Retry to feature list (#39) 2026-04-03 14:11:54 +08:00
JackChen 4d7564b71a
feat: task-level retry with exponential backoff (#37)
* feat: add task-level retry with exponential backoff

Add `maxRetries`, `retryDelayMs`, and `retryBackoff` to task config.
When a task fails and retries remain, the orchestrator waits with
exponential backoff and re-runs the task with a fresh agent conversation.
A `task_retry` event is emitted via `onProgress` for observability.
Cascade failure only occurs after all retries are exhausted.

Closes #30

* fix: address review — extract executeWithRetry, add delay cap, fix tests

- Extract `executeWithRetry()` as a testable exported function
- Add `computeRetryDelay()` with 30s max cap (prevents runaway backoff)
- Remove retry fields from `ParsedTaskSpec` (dead code for runTeam path)
- Deduplicate retry event emission (single code path for both error types)
- Injectable delay function for test determinism
- Rewrite tests to call the real `executeWithRetry`, not a copy
- 15 tests covering: success, retry+success, retry+failure, backoff
  calculation, delay cap, delay function injection, no-retry default

* fix: clamp negative maxRetries/retryBackoff to safe values

- maxRetries clamped to >= 0 (negative values treated as no retry)
- retryBackoff clamped to >= 1 (prevents zero/negative delay oscillation)
- retryDelayMs clamped to >= 0
- Add tests for negative maxRetries and negative backoff

Addresses Codex review P1 on #37

* fix: accumulate token usage across retry attempts

Previously only the final attempt's tokenUsage was returned, causing
under-reporting of actual model consumption when retries occurred.
Now all attempts' token counts are summed in the returned result.

Addresses Codex review P2 (token usage) on #37
2026-04-03 14:08:36 +08:00
JackChen 99b028dc1d
fix: address Codex review for structured output (#36) (#38)
- Include error feedback user turn in mergedMessages to maintain
  alternating user/assistant roles required by Anthropic API
- Use explicit undefined check instead of ?? for structured merge
  to preserve null as a valid structured output value
2026-04-03 14:08:27 +08:00
JackChen fbc5546fa1
feat: add optional outputSchema (Zod) for structured agent output (#36)
When `outputSchema` is set on AgentConfig, the agent's final text output
is parsed as JSON, validated against the Zod schema, and exposed via
`result.structured`. On validation failure a single retry with error
feedback is attempted automatically.

Closes #29
2026-04-03 13:45:47 +08:00
JackChen e0438e3764 docs: add security policy 2026-04-03 12:10:47 +08:00
JackChen 277dac2fe4 docs: add Code of Conduct and issue templates
Add Contributor Covenant Code of Conduct and GitHub issue templates
(bug report + feature request) to reach 100% community health score.
2026-04-03 12:09:41 +08:00
JackChen 0db0a4d869 docs: adapt Star History chart for dark mode 2026-04-03 09:57:18 +08:00
JackChen 37bd56b193 docs: refresh Star History chart cache 2026-04-03 09:56:17 +08:00
JackChen 4fc7bb3f85 docs: add Gemma 4 to Model Agnostic feature description 2026-04-03 09:38:22 +08:00
JackChen d86ea766d3 feat: add Gemma 4 auto-orchestration example (runTeam)
Add examples/09-gemma4-auto-orchestration.ts demonstrating runTeam()
with Gemma 4 as the coordinator — the framework's key feature running
fully local. The coordinator successfully decomposes goals into JSON
task arrays, schedules dependencies, and synthesises results.

Verified on gemma4:e2b (5.1B params) with Ollama 0.20.0-rc1.
2026-04-03 09:28:45 +08:00
JackChen f9fcac0c38 feat: add Gemma 4 local model example with tool-calling
Add examples/08-gemma4-local.ts demonstrating a pure-local multi-agent
team using Gemma 4 via Ollama — zero API cost. Two agents (researcher +
summarizer) collaborate through a task pipeline with bash, file_write,
and file_read tools. Verified on gemma4:e2b with Ollama 0.20.0-rc1.

Update both READMEs: add example 08 to the examples table and note
Gemma 4 as a verified local model with tool-calling support.
2026-04-03 09:12:44 +08:00
JackChen d8a217106f docs: add DECISIONS.md recording deliberate "won't do" choices
Document 5 features we evaluated and chose not to implement
(handoffs, checkpointing, A2A, MCP, dashboard) to maintain
our "simplest multi-agent framework" positioning.

Closes #17, #20.
2026-04-03 03:02:56 +08:00
JackChen 8d27c6a1fe docs: add supported providers section and clarify contributing guidelines
- Add Supported Providers table with 4 verified providers (Anthropic, OpenAI,
  Copilot, Ollama) and note that other OpenAI-compatible providers are unverified
- Update Contributing to distinguish baseURL verification (#25) from new adapters
- Note that local models via Ollama require no API key in Quick Start
2026-04-03 02:47:02 +08:00
JackChen 24a2c4fe1a chore: add tsx to devDependencies for running examples 2026-04-03 02:20:47 +08:00
JackChen 94cccf24d7 docs: replace inline code examples with examples/ index table
Remove ~160 lines of duplicated code snippets from both READMEs.
Link to the runnable scripts in examples/ instead — single source of truth,
type-checked by npm run lint.
2026-04-03 02:18:58 +08:00
JackChen 31a0fa4951 docs: add examples for local models (Ollama) and fan-out/aggregate pattern
- 06-local-model.ts: mix Ollama (local) + Claude (cloud) in a runTasks pipeline,
  demonstrating baseURL and apiKey placeholder for OpenAI-compatible servers
- 07-fan-out-aggregate.ts: MapReduce pattern using AgentPool.runParallel() to
  fan out analysis to 3 perspective agents, then aggregate via a synthesizer
2026-04-03 02:12:05 +08:00
JackChen 6e6a85178b docs: sync Chinese README source file count (20 → 27) 2026-04-03 00:07:11 +08:00
JackChen 54400580a2 docs: fix source file count in README (20 → 27) 2026-04-03 00:05:31 +08:00
JackChen 3a46669a69 fix: use explicit crypto import for Node 18 compatibility
crypto.randomUUID() is not globally available in Node 18. Import
randomUUID from node:crypto explicitly so the framework works on
all supported Node versions (>=18).
2026-04-02 23:46:43 +08:00
JackChen a772312a68 chore: add tests, CI, contributing guide, and PR template
- 5 test files, 61 test cases covering TaskQueue, SharedMemory,
  ToolExecutor, ToolRegistry, and Semaphore
- GitHub Actions CI running lint + test on Node 18/20/22
- CONTRIBUTING.md with setup, commands, and PR workflow
- Pull request template with checklist
2026-04-02 23:43:54 +08:00
JackChen 80a8c1dcff fix: blocked tasks never unblocked when dependencies complete
isTaskReady() rejects non-pending tasks on its first line, but
unblockDependents() passed blocked tasks directly to it. This meant
dependent tasks stayed blocked forever after their dependencies
completed, breaking any workflow with task dependencies.

Fix: pass a pending-status copy so isTaskReady only checks the
dependency condition.
2026-04-02 23:43:49 +08:00
JackChen 01b93d9897 docs: lead Quick Start with runTeam, add output example and Node version 2026-04-02 22:35:45 +08:00
JackChen 736121fe10 docs: add lightweight positioning tagline to README headers 2026-04-02 22:24:08 +08:00
JackChen 9f9f4e95d4 docs: highlight auto task decomposition, add run modes table, move contributors up
- Rewrite headline to emphasize automatic goal-to-task decomposition
- Add "Auto Task Decomposition" as first item in Why section
- Add "Three Ways to Run" table (runAgent / runTeam / runTasks)
- Move Contributors section higher for visibility
- Bust star-history cache to refresh chart
2026-04-02 21:55:04 +08:00
JackChen a32440728f docs: update READMEs for baseURL support and local model examples
- Add Ollama/local model agent example in multi-model teams section
- Update "Model Agnostic" description to mention local models and baseURL
- Update contributing section to reflect built-in OpenAI-compatible support
- Add author block with Xiaohongshu link in Chinese README
2026-04-02 19:42:59 +08:00
JackChen 62d6fa9e26 feat: add baseURL and apiKey support for OpenAI-compatible APIs
Enable connecting to any OpenAI-compatible API (Ollama, vLLM, LM Studio,
etc.) by adding baseURL and apiKey fields to AgentConfig and
OrchestratorConfig, threaded through to adapter constructors.

- OpenAIAdapter and AnthropicAdapter accept optional baseURL
- createAdapter() forwards baseURL to both adapters, warns if used with copilot
- All execution paths (runAgent, runTeam coordinator, buildPool) merge defaults
- Fully backward compatible — omitting new fields preserves existing behavior
2026-04-02 19:33:10 +08:00
JackChen 7acd450707 Update READMEs: add Copilot adapter, contributors section 2026-04-02 12:20:21 +08:00
JackChen 3ae8011673
Merge pull request #9 from Deathwing/main
feat: add GitHub Copilot as LLM provider
2026-04-02 11:54:17 +08:00
Deathwing 8371cdb7c0 refactor: address all 7 PR review comments
1. Fix header comment — document correct env var precedence
   (apiKey → GITHUB_COPILOT_TOKEN → GITHUB_TOKEN → device flow)
2. Use application/x-www-form-urlencoded for device code endpoint
3. Use application/x-www-form-urlencoded for poll endpoint
4. Add mutex (promise-based) on #getSessionToken to prevent
   concurrent token refreshes and duplicate device flow prompts
5. Add DeviceCodeCallback + CopilotAdapterOptions so callers can
   control device flow output instead of hardcoded console.log
6. Extract shared OpenAI wire-format helpers into openai-common.ts,
   imported by both openai.ts and copilot.ts (-142 lines net)
7. Update createAdapter JSDoc to mention copilot env vars
2026-04-02 02:19:06 +02:00
Deathwing eedfeb17a2 feat: add GitHub Copilot as LLM provider
- Add CopilotAdapter with OAuth2 device flow authentication
- Token exchange via /copilot_internal/v2/token with caching
- Premium request multiplier system (getCopilotMultiplier)
- Full model metadata catalog (COPILOT_MODELS)
- Add 'copilot' to SupportedProvider and provider union types
- Add example: examples/05-copilot-test.ts
2026-04-02 01:45:43 +02:00
JackChen ad317610ff Bust GitHub cache for star history chart, ignore non-tech dirs 2026-04-02 00:56:15 +08:00
JackChen 376785c3fa Add Chinese README and GitHub topic tags for discoverability 2026-04-01 16:24:43 +08:00
JackChen ae6968a52c Publish to npm as @jackchen_me/open-multi-agent 2026-04-01 13:44:23 +08:00
JackChen 0c02327a56 Switch install method to GitHub, remove npm badges 2026-04-01 13:14:29 +08:00
JackChen 3b24b99056 Improve README: clearer intro, fewer code walls, contributing section 2026-04-01 13:04:40 +08:00
JackChen 6cbc5582fe Add star history chart to README and update .gitignore 2026-04-01 12:12:28 +08:00
JackChen a6244cfe64 Initial release: open-multi-agent v0.1.0
Production-grade multi-agent orchestration framework.
Model-agnostic, supports team collaboration, task scheduling
with dependency resolution, and inter-agent communication.
2026-04-01 04:33:15 +08:00