@cognipeer/agent-sdk 0.7.3 → 0.8.1

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
@@ -38,8 +38,10 @@ Highlights:
38
38
  - **Structured output** – provide a Zod schema and the agent injects a finalize tool to capture JSON deterministically.
39
39
  - **Skills / progressive disclosure** – expose cheap capability headers first, then bind skill tools on demand with `open_skill` and `bind_skill_tools`.
40
40
  - **Multi-agent and handoffs** – wrap agents as tools or transfer control mid-run with `asTool` / `asHandoff`.
41
+ - **Sub-agents / dynamic delegation** – let the orchestrator decompose problems with `delegate_to` (registry), `spawn_subagent` (ad-hoc), and `spawn_subagents_parallel` (fan-out); children are model-agnostic and inherit event/streaming/cancellation wiring. **Opt-in:** the spawn tools + `<available_subagents>` catalog appear only when you pass `subagents` and/or `subagentPolicy`.
42
+ - **Prompt overrides** – intercept otherwise-static prompts with `promptHooks` (`transformSystemPrompt`, `toolDescriptions`, `subagentCatalog`).
41
43
  - **Human-in-the-loop** – `needsApproval` tools pause for review; `humanInTheLoop.askUser` enables a built-in `ask_user_question` tool that pauses with a structured multi-choice prompt and resumes from the user's answer.
42
- - **Usage + events** – normalize provider usage, surface `tool_call`, `tool_approval`, `user_question`, `plan`, `summarization`, `reflection`, `metadata`, and `handoff` events.
44
+ - **Usage + events** – normalize provider usage, surface `tool_call`, `tool_approval`, `user_question`, `plan`, `summarization`, `reflection`, `metadata`, `handoff`, and `subagent` events.
43
45
  - **Structured tracing** – optional per-invoke JSON traces with metadata, payload capture, and pluggable sinks (file, HTTP, Cognipeer, custom).
44
46
 
45
47
  ## What’s inside
@@ -295,6 +297,7 @@ console.log(res.content);
295
297
  - **Planning discipline** – when planning is enabled the system prompt distinguishes full plan writes from incremental plan updates and emits `plan` events as todos change.
296
298
  - **Structured output** – supply `outputSchema` and the framework adds a hidden `response` finalize tool; parsed JSON is returned as `result.output`.
297
299
  - **Multi-agent orchestration** – reuse agents via `agent.asTool({ toolName })` or perform handoffs that swap runtimes mid-execution.
300
+ - **Sub-agents** – pass `subagents` / `subagentPolicy` to give the orchestrator `delegate_to`, `spawn_subagent`, and `spawn_subagents_parallel`; children inherit the parent model + observability and surface human-in-the-loop pauses for transparent resume. See [Sub-Agents guide](docs/guide/sub-agents.md).
298
301
  - **Ask the user** – opt in with `humanInTheLoop: { askUser: true }` to give the model an `ask_user_question` tool that pauses the run; resume by calling `agent.resolveUserQuestion(state, { id, answers })`. The global `allowFreeText` flag controls whether "Other" / typed answers are allowed.
299
302
  - **MCP + LangChain tools** – any object satisfying the minimal tool interface works; LangChain’s `Tool` implementations plug in directly.
300
303
  - **Vision input** – message parts accept base64 or URL images for multimodal requests.
@@ -316,6 +319,7 @@ Examples live under `examples/` with per-folder READMEs. Build the package first
316
319
  | `rewrite-summary/` | Continue conversations after summaries are injected. |
317
320
  | `ask-user/` | Built-in `ask_user_question` tool, structured multi-choice prompt, resume with user's answer. |
318
321
  | `multi-agent/` | Delegating between agents via `asTool`. |
322
+ | `sub-agents/` | Dynamic decomposition: `delegate_to`, `spawn_subagent`, `spawn_subagents_parallel`. |
319
323
  | `handoff/` | Explicit runtime handoffs. |
320
324
  | `mcp-tavily/` | MCP remote tool discovery. |
321
325
  | `vision/` | Text + image input using LangChain’s OpenAI bindings. |
@@ -425,6 +429,18 @@ npm run build
425
429
 
426
430
  From the repo root you can run `npm run build` (delegates to the package) or use `npm run example:<name>` scripts defined in `package.json`.
427
431
 
432
+ ### Testing
433
+
434
+ ```sh
435
+ npm test # all mock-based tests (no API key)
436
+ npm run test:coverage # v8 coverage + enforced thresholds
437
+ npm run test:critical # critical-feature integration suite
438
+ npm run test:real # real OpenAI (OPENAI_API_KEY)
439
+ npm run test:matrix # real-provider matrix (per-provider keys; skips without)
440
+ ```
441
+
442
+ The mock suite is deterministic and key-free. The opt-in **provider matrix** (`tests/integration/providerMatrix.integration.test.ts`) runs the same contract — tool-calling, structured output, streaming — against any provider whose credentials are present (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, Azure/Bedrock/Vertex vars) and skips the rest. The public **eval harness** (`runSmartAgentEvalHarness`) scores behavioural quality across runtime profiles. See the [Testing & Evaluation guide](docs/guide/testing.md) and [`tests/README.md`](tests/README.md).
443
+
428
444
  ### Publishing
429
445
 
430
446
  Only publish `agent-sdk/`: