@nones/agentflow-core 0.1.0 → 0.6.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AgentFlow contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # `@nones/agentflow-core`
2
+
3
+ ![AgentFlow Core by Nones Tools](https://raw.githubusercontent.com/nones-tools/agentflow/main/assets/brand/banner-agentflow-core.png)
4
+
5
+ AgentFlow's runtime contracts, durable store, scheduler, quota manager and local
6
+ JSON-lines RPC server/client. Use it to embed the engine in a trusted Bun
7
+ process or to run the owner-only Unix socket daemon that the `agentflow` CLI
8
+ talks to.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ bun add @nones/agentflow-core
14
+ ```
15
+
16
+ Core is a standalone SDK. It provides the engine, persistence, lifecycle,
17
+ optional IPC, and the `ProviderAdapter`, `Strategy`, and `AgentFlowModule`
18
+ contracts. It has no dependency on the AgentFlow CLI or extension packages.
19
+ See the [core-only example](https://github.com/nones-tools/agentflow/blob/main/examples/core.ts)
20
+ for an application that registers its own provider and strategy.
21
+
22
+ For the daemon example below, install the chosen provider and strategy:
23
+
24
+ ```sh
25
+ bun add @nones/agentflow-opencode @nones/agentflow-strategy-agent
26
+ ```
27
+
28
+ Bun 1.4.5 or newer is required. The package ships TypeScript source and Bun
29
+ loads it directly.
30
+
31
+ ## Start a daemon and client
32
+
33
+ ```ts
34
+ import { createClient, serve } from "@nones/agentflow-core";
35
+ import { createOpenCodeAdapter } from "@nones/agentflow-opencode";
36
+ import { agentStrategy } from "@nones/agentflow-strategy-agent";
37
+
38
+ const adapter = createOpenCodeAdapter();
39
+
40
+ const server = await serve({
41
+ stateDir: "/tmp/agentflow-state",
42
+ defaultProfile: "local",
43
+ profiles: [
44
+ {
45
+ id: "local",
46
+ adapter: "opencode",
47
+ model: "provider/model",
48
+ settings: { endpoint: "http://127.0.0.1:4096" },
49
+ },
50
+ ],
51
+ adapters: [adapter],
52
+ strategies: [agentStrategy],
53
+ });
54
+
55
+ const client = createClient({ socketPath: server.socketPath });
56
+
57
+ try {
58
+ const run = await client.start({
59
+ strategy: agentStrategy.id,
60
+ input: {
61
+ agent: {
62
+ id: "reader",
63
+ prompt: "Summarize README.md without editing files.",
64
+ cwd: process.cwd(),
65
+ },
66
+ },
67
+ });
68
+
69
+ // RunStatus: idle | running | paused | completed | failed | cancelled
70
+ let snapshot = await client.status(run.id);
71
+ while (snapshot.status === "idle" || snapshot.status === "running") {
72
+ await Bun.sleep(250);
73
+ snapshot = await client.status(run.id);
74
+ }
75
+ console.log(snapshot.status);
76
+ } finally {
77
+ await client.close();
78
+ await server.close();
79
+ }
80
+ ```
81
+
82
+ `serve()` composes and owns one engine, resolves after the socket is
83
+ listening, and returns `{ socketPath, close() }`. The state directory is created
84
+ with mode `0700` when missing; an existing directory must already be private and
85
+ owned by the current user. A lock prevents two daemons from owning the same
86
+ state directory.
87
+
88
+ When `socketPath` is omitted, the socket is `<stateDir>/s.sock`. Use
89
+ `server.socketPath` for `createClient` rather than constructing a separate path:
90
+ a custom socket parent must already be a private `0700` directory owned by the
91
+ current user. AgentFlow accepts socket paths up to 100 bytes. The socket and its RPC request
92
+ size are bounded, and the server speaks one JSON request/response object per
93
+ line.
94
+
95
+ ## Embed the engine
96
+
97
+ When your process already owns the lifecycle and does not need RPC, use
98
+ `createEngine()` with the same `profiles`, `adapters`, `strategies` and optional
99
+ `modules` arguments:
100
+
101
+ ```ts
102
+ import { createEngine, type EngineOptions } from "@nones/agentflow-core";
103
+
104
+ async function listRuns(options: EngineOptions) {
105
+ const engine = createEngine(options);
106
+ try {
107
+ await engine.ready();
108
+ return engine.runs();
109
+ } finally {
110
+ await engine.close();
111
+ }
112
+ }
113
+ ```
114
+
115
+ Do not run an embedded engine and a `serve()` daemon against the same state
116
+ directory. One engine owns one state directory.
117
+
118
+ ## Engine and client methods
119
+
120
+ `Engine` and `Client` mirror each other:
121
+
122
+ - `start(request)` — compile a strategy input and admit a run.
123
+ - `runs()`, `status(id)`, `events(id, { after?, agentId? })`.
124
+ - `append(id, { waves })`, `send(id, agentId, options)`, `resume(...)`.
125
+ - `seal(id)`, `cancel(id)`.
126
+ - `limits()`, `output(id, artifactId)`, `close()`.
127
+
128
+ On the client, `events()` also accepts `waitMs`, `pollIntervalMs` and an
129
+ `AbortSignal`. Event waits are cursor polls, so closing a client never changes
130
+ daemon state. A client request defaults to a 30-second timeout.
131
+
132
+ Snapshots and contracts are exported from the package root. Common types include
133
+ `Profile`, `AgentSpec`, `WaveSpec`, `RunPlan`, `RunRequest`, `RunSnapshot`,
134
+ `WaveSnapshot`, `AgentSnapshot`, `EngineEvent`, `TurnResult`,
135
+ `ProviderAdapter`, `Strategy`, `AgentFlowModule` and `SessionPermission`. The
136
+ `./types` subpath exports the same contract types.
137
+
138
+ ## Modules
139
+
140
+ Modules are off by default. Pass `modules` to `serve()` or `createEngine()` to
141
+ add session-only instructions, permission intents and exact operation names:
142
+
143
+ ```ts
144
+ import { createBeadsModule } from "@nones/agentflow-beads";
145
+ import type { ServeOptions } from "@nones/agentflow-core";
146
+
147
+ const moduleOptions = {
148
+ modules: [createBeadsModule({ cwd: "/path/to/beads-repository" })],
149
+ moduleCallLimit: 12,
150
+ } satisfies Pick<ServeOptions, "modules" | "moduleCallLimit">;
151
+ ```
152
+
153
+ Core imports no concrete module. See
154
+ [Opt-in modules](https://github.com/nones-tools/agentflow/blob/main/docs/modules.md)
155
+ for the interface, action protocol and Beads module.
156
+
157
+ ## Other exports
158
+
159
+ - `Store`, `QuotaManager`, `quotaGroupName` — durable state and admission
160
+ controls.
161
+ - `validateRunPlan`, `assertJsonSchema`, `validateJsonSchema`, `SchemaError` —
162
+ plan, artifact and JSON-schema validation.
163
+ - `prepareArtifact`, `readArtifactOutput`, `requiredArtifactFailure` — declared
164
+ artifact handling.
165
+ - `createModuleBroker`, `parseModuleToolReply`, `moduleResultPrompt` — module
166
+ registry and action protocol.
167
+ - `AgentFlowError`, `asAgentFlowError`, `newId` — shared error and ID helpers.
168
+
169
+ ## Documentation
170
+
171
+ - [Core contracts](https://github.com/nones-tools/agentflow/blob/main/docs/contracts.md)
172
+ - [Server bootstrap example](https://github.com/nones-tools/agentflow/blob/main/examples/server.ts)
173
+ - [Workflow example](https://github.com/nones-tools/agentflow/blob/main/examples/workflow.ts)
174
+ - [Repository README](https://github.com/nones-tools/agentflow/blob/main/README.md)
175
+ - [Issues](https://github.com/nones-tools/agentflow/issues)
176
+
177
+ ## License
178
+
179
+ MIT. See [LICENSE](https://github.com/nones-tools/agentflow/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nones/agentflow-core",
3
- "version": "0.1.0",
3
+ "version": "0.6.0",
4
4
  "description": "AgentFlow contracts, durable store, scheduler, quotas and local JSON RPC",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -16,6 +16,16 @@
16
16
  "types": "./src/types.ts",
17
17
  "import": "./src/types.ts",
18
18
  "default": "./src/types.ts"
19
+ },
20
+ "./inspection": {
21
+ "types": "./src/inspection.ts",
22
+ "import": "./src/inspection.ts",
23
+ "default": "./src/inspection.ts"
24
+ },
25
+ "./artifact-history": {
26
+ "types": "./src/artifact-history.ts",
27
+ "import": "./src/artifact-history.ts",
28
+ "default": "./src/artifact-history.ts"
19
29
  }
20
30
  },
21
31
  "files": [
@@ -36,5 +46,9 @@
36
46
  "scripts": {
37
47
  "build": "bun build ./src/index.ts --target=bun --outdir=.tmp/build --packages external",
38
48
  "test": "bun test"
39
- }
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/nones-tools/agentflow/issues"
52
+ },
53
+ "license": "MIT"
40
54
  }