{"id":44915451,"url":"https://github.com/jcanizalez/fourmis-agent-sdk","last_synced_at":"2026-02-18T01:42:11.255Z","repository":{"id":337871030,"uuid":"1154889486","full_name":"jcanizalez/fourmis-agent-sdk","owner":"jcanizalez","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-11T22:50:10.000Z","size":179,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-12T02:14:55.221Z","etag":null,"topics":["ai-agent","ai-agents","ai-tools","anthropic-claude","anthropic-sdk","bun","openai"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcanizalez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-10T22:16:52.000Z","updated_at":"2026-02-11T22:50:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jcanizalez/fourmis-agent-sdk","commit_stats":null,"previous_names":["jcanizalez/fourmis-agent-sdk"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jcanizalez/fourmis-agent-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcanizalez%2Ffourmis-agent-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcanizalez%2Ffourmis-agent-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcanizalez%2Ffourmis-agent-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcanizalez%2Ffourmis-agent-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcanizalez","download_url":"https://codeload.github.com/jcanizalez/fourmis-agent-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcanizalez%2Ffourmis-agent-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29566364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T00:47:08.760Z","status":"ssl_error","status_checked_at":"2026-02-18T00:45:26.718Z","response_time":100,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","ai-agents","ai-tools","anthropic-claude","anthropic-sdk","bun","openai"],"created_at":"2026-02-18T01:42:10.765Z","updated_at":"2026-02-18T01:42:11.232Z","avatar_url":"https://github.com/jcanizalez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fourmis-agents-sdk\n\nMulti-provider AI agent SDK with direct API access and in-process tool execution.\n\n\u003e Requires [Bun](https://bun.sh) v1.0+. This SDK uses Bun-native APIs (`Bun.spawn`, `Bun.Glob`, `Bun.build`) and is not Node runtime-compatible for host execution.\n\n## What It Is\n\n`fourmis-agents-sdk` provides a single `query()` API that works across providers while keeping the agent loop transparent and controllable.\n\n- Multi-provider: Anthropic, OpenAI, Gemini (plus custom providers via registry)\n- Claude-style message envelopes (`system`, `assistant`, `user`, `stream_event`, `result`)\n- In-process tool execution (file/system/web/notebook/config/todo)\n- Hooks, permissions, MCP servers, subagents, skills, and memory\n\n## Quick Start\n\n```ts\nimport { query } from \"fourmis-agents-sdk\";\n\nconst conversation = query({\n  prompt: \"Read package.json and tell me the project name.\",\n  options: {\n    provider: \"anthropic\",\n    model: \"claude-sonnet-4-5-20250929\",\n    cwd: process.cwd(),\n    tools: { type: \"preset\", preset: \"claude_code\" },\n    maxTurns: 5,\n  },\n});\n\nfor await (const msg of conversation) {\n  if (msg.type === \"assistant\") {\n    for (const block of msg.message.content) {\n      if (block.type === \"text\") process.stdout.write(block.text);\n    }\n  }\n\n  if (msg.type === \"result\") {\n    console.log(`\\nstop=${msg.subtype} cost=$${msg.total_cost_usd.toFixed(4)}`);\n  }\n}\n```\n\n## Providers\n\nBuilt-in providers:\n\n| Provider | Auth |\n| --- | --- |\n| `anthropic` | `ANTHROPIC_API_KEY` or Claude OAuth token |\n| `openai` | `OPENAI_API_KEY` or OpenAI/Codex OAuth |\n| `gemini` | `GEMINI_API_KEY` or Gemini CLI OAuth |\n\n```ts\nimport { query, registerProvider } from \"fourmis-agents-sdk\";\n\nquery({ prompt: \"...\", options: { provider: \"openai\", model: \"gpt-4.1-mini\" } });\nquery({ prompt: \"...\", options: { provider: \"gemini\", model: \"gemini-2.5-flash\" } });\n\nregisterProvider(\"my-provider\", myAdapter);\n```\n\n## Tools\n\nCurrent built-in tools:\n\n| Tool | Purpose |\n| --- | --- |\n| `Bash` | Shell command execution |\n| `Read` | Read files with line numbers |\n| `Write` | Write/overwrite files |\n| `Edit` | Exact string replacement |\n| `Glob` | File pattern matching |\n| `Grep` | Regex content search |\n| `NotebookEdit` | Edit Jupyter notebook cells |\n| `WebFetch` | Fetch URL content |\n| `WebSearch` | Lightweight web search |\n| `TodoWrite` | Persist todo state |\n| `Config` | Read/write `.claude/settings*.json` |\n| `AskUserQuestion` | Ask user (returns runtime-unavailable error in this host mode) |\n| `ExitPlanMode` | Request exit from plan mode |\n\nTool configuration:\n\n```ts\nquery({\n  prompt: \"...\",\n  options: {\n    // Exposed preset\n    tools: { type: \"preset\", preset: \"claude_code\" },\n\n    // Or explicit list\n    // tools: [\"Read\", \"Glob\", \"Grep\"],\n\n    allowedTools: [\"Read\", \"Glob\", \"Grep\"],\n    disallowedTools: [\"Bash\"],\n  },\n});\n```\n\n## Hooks\n\nLifecycle hooks can observe and influence execution:\n\n- `PreToolUse`, `PostToolUse`, `PostToolUseFailure`\n- `SessionStart`, `SessionEnd`, `Stop`, `Notification`\n- `SubagentStart`, `SubagentStop`, `PreCompact`, `PermissionRequest`\n- `UserPromptSubmit`, `Setup`, `TeammateIdle`, `TaskCompleted`\n\n```ts\nquery({\n  prompt: \"...\",\n  options: {\n    hooks: {\n      PreToolUse: [\n        {\n          matcher: \"^Bash$\",\n          hooks: [\n            async () =\u003e ({\n              decision: { behavior: \"deny\", message: \"Blocked by policy.\" },\n            }),\n          ],\n        },\n      ],\n    },\n  },\n});\n```\n\n## MCP (Model Context Protocol)\n\nSupports `stdio`, `sse`, `http`, and in-process `sdk` MCP servers.\n\n```ts\nquery({\n  prompt: \"...\",\n  options: {\n    mcpServers: {\n      stdioServer: { command: \"node\", args: [\"server.js\"] },\n      remoteSse: { type: \"sse\", url: \"http://localhost:3000/sse\" },\n      remoteHttp: { type: \"http\", url: \"http://localhost:3000\" },\n      inProc: { type: \"sdk\", name: \"my-tools\", instance: myMcpServer },\n    },\n  },\n});\n```\n\nCreate in-process MCP server configs:\n\n```ts\nimport { createMcpServer, mcpTool } from \"fourmis-agents-sdk\";\nimport { z } from \"zod\";\n\nconst mcpConfig = createMcpServer({\n  name: \"my-tools\",\n  tools: [\n    mcpTool(\"greet\", \"Say hello\", { name: z.string() }, async ({ name }) =\u003e {\n      return `Hello, ${name}!`;\n    }),\n  ],\n});\n```\n\n## Subagents\n\nDefine agent roles and let the parent invoke them with `Task`:\n\n```ts\nquery({\n  prompt: \"Delegate to researcher and report package name.\",\n  options: {\n    agents: {\n      researcher: {\n        description: \"Reads code and reports facts.\",\n        prompt: \"Be concise and factual.\",\n        tools: [\"Read\", \"Glob\", \"Grep\"],\n        maxTurns: 3,\n      },\n    },\n  },\n});\n```\n\n## Permissions and Settings\n\nPermission modes:\n- `default`\n- `acceptEdits`\n- `bypassPermissions` (requires `allowDangerouslySkipPermissions: true`)\n- `plan`\n- `delegate`\n- `dontAsk`\n\nYou can combine:\n- explicit `permissions` allow/deny rules\n- dynamic `canUseTool` callback\n- settings-file loading via `settingSources: [\"user\", \"project\", \"local\"]`\n\n## Compatibility Harness\n\nA strict side-by-side harness compares Fourmis vs `@anthropic-ai/claude-agent-sdk`.\n\nRun:\n\n```bash\nbun run test:compat\n```\n\nUseful env vars:\n\n- `COMPAT_REPEATS=3`\n- `COMPAT_SCENARIOS=01-simple-text,02-read-package`\n- `COMPAT_OUTPUT_DIR=/absolute/path`\n\nArtifacts per run:\n\n- `tests/compat/output/\u003ctimestamp\u003e/summary.json`\n- `tests/compat/output/\u003ctimestamp\u003e/report.md`\n- `tests/compat/output/\u003ctimestamp\u003e/traces/*.json`\n\nCurrent baseline (2026-02-17): 11/12 scenarios passing, with a known hook-deny mismatch in `08-hooks-deny-bash` on the Anthropic side.\n\n## Message Model\n\n`query()` yields `AgentMessage` envelopes, primarily:\n\n- `system` (`init`, `status`, hook/task events)\n- `assistant` (text and `tool_use` blocks)\n- `user` (tool results)\n- `stream_event` (partial deltas)\n- `tool_progress`, `tool_use_summary`\n- `result` (`success` or error subtype)\n\n## Install and Test\n\n```bash\nbun add fourmis-agents-sdk\nbun test\nbun run test:compat\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcanizalez%2Ffourmis-agent-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcanizalez%2Ffourmis-agent-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcanizalez%2Ffourmis-agent-sdk/lists"}