framework-agents 0.1.0 → 0.1.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 +49 -75
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,93 +1,67 @@
|
|
|
1
|
-
# framework-agents
|
|
1
|
+
# framework-agents
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript agent framework: a ReAct loop with validated tools, streaming, token/cost budgets, a middleware stack with human-in-the-loop, multi-agent orchestration (sequential / parallel / router, DAG workflows, swarms), a typed semantic graph, A2A serving, MCP clients, and a React companion package.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- **Runtime**: Node >= 20. Two production dependencies only (TogetherAI/OpenAI-compatible, Anthropic, and Ollama providers are `fetch`-based — no SDK lock-in).
|
|
6
|
+
- **Docs**: full guides + API reference live in the repo (`docs/` is an MkDocs site; published via GitHub Pages).
|
|
7
|
+
- **Live-tested**: every feature has an offline + gated live test suite hitting the real provider APIs.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
src/
|
|
9
|
-
├── index.ts <- public API (only import from here)
|
|
10
|
-
├── types/ <- shared branded types, result/error envelopes
|
|
11
|
-
├── agent/ <- Agent loop, state, history, sessions, snapshots
|
|
12
|
-
├── state/ <- AgentState (KV) + ToolContext + InvocationState
|
|
13
|
-
├── conversation/ <- Null/SlidingWindow/Summarizing managers
|
|
14
|
-
├── sessions/ <- Storage backends + SessionManager + snapshots
|
|
15
|
-
├── swarm/ <- autonomous handoffs + shared context + safety
|
|
16
|
-
├── a2a/ <- A2A client/server interop
|
|
17
|
-
├── tools/ <- Tool interface + registry + zod validation
|
|
18
|
-
├── memory/ <- Memory interface + in-memory store + compaction.ts
|
|
19
|
-
├── models/ <- ModelProvider + OpenAI-compatible + Anthropic + Ollama + initChatModel
|
|
20
|
-
├── checkpoint/ <- FileCheckpointer + withFileLock (local-first durability)
|
|
21
|
-
├── skills/ <- SKILL.md parse/registry + discover + match
|
|
22
|
-
├── mcp/ <- MCP clients (HTTP/stdio) + tools bridge
|
|
23
|
-
├── prompts/ <- versioned prompt templates + render
|
|
24
|
-
├── structured/ <- responseFormat (tool/provider strategies)
|
|
25
|
-
├── streaming/ <- StreamEvent + collectStream
|
|
26
|
-
├── middleware/ <- hooks + 15 prebuilt (retry/fallback/limits/HITL/PII/summary/todos/fs/subagents…)
|
|
27
|
-
├── semantic/ <- GraphStore + InMemoryGraphStore (entailment in P0-sem/P1-sem)
|
|
28
|
-
├── orchestration/ <- sequential / parallel / router multi-agent
|
|
29
|
-
├── runtime/ <- run with timeout / cancellation / budgets
|
|
30
|
-
├── workflows/ <- DAG workflows (topo levels, retry)
|
|
31
|
-
├── observability/ <- event emitter + logger hooks
|
|
32
|
-
└── utils/ <- abort, retry, tokens helpers
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Scripts
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
pnpm build
|
|
39
|
-
pnpm test
|
|
40
|
-
pnpm lint
|
|
41
|
-
pnpm typecheck
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Serve (`framework.json` + CLI)
|
|
9
|
+
## Install
|
|
45
10
|
|
|
46
11
|
```bash
|
|
47
|
-
|
|
48
|
-
./dist/cli.js validate -c ../../framework.json
|
|
49
|
-
./dist/cli.js dev -c ../../framework.json --port 8484
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"server": { "host": "127.0.0.1", "basePort": 8484 },
|
|
55
|
-
"envFile": "./.env",
|
|
56
|
-
"env": { "FRAMEWORK_ENV": "production" },
|
|
57
|
-
"checkpointer": { "dir": "./checkpoints" },
|
|
58
|
-
"http": { "corsOrigins": ["http://localhost:3000"] },
|
|
59
|
-
"agents": [
|
|
60
|
-
{ "name": "helper", "model": "together:Qwen/Qwen3.5-9B", "skills": ["./skills"] },
|
|
61
|
-
{ "file": "./agents/local.json", "port": 8485 }
|
|
62
|
-
]
|
|
63
|
-
}
|
|
12
|
+
npm install framework-agents
|
|
64
13
|
```
|
|
65
14
|
|
|
66
|
-
|
|
67
|
-
Relative paths in agent files resolve against their own dir; overrides against
|
|
68
|
-
`framework.json`. Env precedence: process < framework `envFile` < `env{}` <
|
|
69
|
-
per-agent `envFile`. Served agents get durable HITL threads (`threadId` =
|
|
70
|
-
context id), health (`/ok`), CORS, and per-context isolation.
|
|
15
|
+
Needs an OpenAI-compatible endpoint, Anthropic, or a local Ollama — configured via env keys (`TOGETHER_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `OLLAMA_*`) or passed inline.
|
|
71
16
|
|
|
72
|
-
##
|
|
17
|
+
## Agent + tool in 15 lines
|
|
73
18
|
|
|
74
19
|
```ts
|
|
75
|
-
import { Agent,
|
|
20
|
+
import { Agent, defineTool, initChatModel } from "framework-agents";
|
|
76
21
|
import { z } from "zod";
|
|
77
22
|
|
|
78
|
-
const
|
|
79
|
-
name: "
|
|
80
|
-
description: "
|
|
81
|
-
schema: z.object({}),
|
|
82
|
-
execute: async () =>
|
|
23
|
+
const weather = defineTool({
|
|
24
|
+
name: "get_weather",
|
|
25
|
+
description: "Get the weather for a city.",
|
|
26
|
+
schema: z.object({ city: z.string() }), // reaches the provider wire: models see real arg shapes
|
|
27
|
+
execute: async ({ city }) => `18c in ${city}`,
|
|
83
28
|
});
|
|
84
29
|
|
|
85
30
|
const agent = new Agent({
|
|
86
|
-
model:
|
|
87
|
-
tools: [
|
|
88
|
-
|
|
31
|
+
model: initChatModel("together:Qwen/Qwen3.5-9B", { maxTokens: 1500 }),
|
|
32
|
+
tools: [weather],
|
|
33
|
+
budgets: { maxTokens: 5000, maxCostUsd: 0.05 }, // enforced after every model call
|
|
89
34
|
});
|
|
90
35
|
|
|
91
|
-
const
|
|
92
|
-
console.log(
|
|
36
|
+
const res = await agent.run("What's the weather in Tokyo?");
|
|
37
|
+
console.log(res.text, res.toolCalls, res.usage.costUsd);
|
|
93
38
|
```
|
|
39
|
+
|
|
40
|
+
## Streaming
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
for await (const e of agent.stream("Plan my trip to Berlin")) {
|
|
44
|
+
if (e.type === "token") process.stdout.write(e.delta);
|
|
45
|
+
if (e.type === "tool_call") console.log("\n[tool]", e.name);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Token deltas arrive per model call; tool events stream live the moment the model dispatches (and the moment the result lands). Completions carry real `usage` (with `reasoningTokens`) and `costUsd` computed from the built-in price table — never guessed.
|
|
50
|
+
|
|
51
|
+
## Surface
|
|
52
|
+
|
|
53
|
+
| Area | Highlights |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Event streaming | `run()` / `stream()` with typed events, abort + timeout, both `reasoning` field families (Together/OpenAI) parsed |
|
|
56
|
+
| Structured output | zod schemas as native `response_format` or a self-repairing tool loop |
|
|
57
|
+
| Budgets | token / USD / per-run deadline enforcement, per-model pricing table |
|
|
58
|
+
| Middleware | before/after model+tool hooks, retries with backoff honoring retryable verdicts, human-in-the-loop (checkpointed resume, wildcard approvals), fallback chains, PII redaction, filesystem + subagents + todos |
|
|
59
|
+
| State | persist history/state across restarts, snapshots, `pause()`/`resume()`, message edit + branching with timelines |
|
|
60
|
+
| Multi-agent | orchestration (3 strategies), DAG workflows per-node retries, autonomous handoff swarms with loop detection |
|
|
61
|
+
| Semantic | graph store with RDFS/OWL entailment + `why()` proofs, SHACL shapes, a validated write path, entity linking, ontology migration with conformance batteries |
|
|
62
|
+
| Serving | A2A server/client (JSON-RPC + SSE), per-context isolation, MCP stdio + HTTP clients |
|
|
63
|
+
| Python | same surface in `framework_agents` on PyPI — the A2A wire contract is conformance-tested across both stacks |
|
|
64
|
+
|
|
65
|
+
## Publishing docs
|
|
66
|
+
|
|
67
|
+
`docs/` builds with MkDocs (`mkdocs build --strict`) and deploys to GitHub Pages via `.github/workflows/docs.yml`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "framework-agents",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript agent framework: ReAct loop, tools, memory, streaming, budgets, middleware, multi-agent, semantic graph, A2A serving",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
],
|
|
61
61
|
"repository": {
|
|
62
62
|
"type": "git",
|
|
63
|
-
"url": "git+https://github.com/
|
|
63
|
+
"url": "git+https://github.com/fab679/framework.git"
|
|
64
64
|
},
|
|
65
65
|
"license": "MIT",
|
|
66
66
|
"engines": {
|