brass-runtime 1.13.7 β 1.13.8
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 +231 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,58 +1,234 @@
|
|
|
1
|
-
#
|
|
1
|
+
# π οΈ brass-runtime β Mini ZIO-like runtime in TypeScript
|
|
2
|
+
|
|
3
|
+
A small experimental runtime inspired by **ZIO 2**, implemented in vanilla TypeScript and intentionally built without using `Promise` / `async`/`await` as the **primary semantic primitive**.
|
|
4
|
+
|
|
5
|
+
`brass-runtime` is the foundation: it provides an effect system, fibers, scheduler, scopes, and streams.
|
|
6
|
+
Higher-level modules (HTTP, streaming utilities, integrations) are built **on top of the runtime**, not baked into it.
|
|
7
|
+
|
|
8
|
+
> You can still interop with the outside world (timers, fetch, Node APIs) via explicit, cancellable bridges such as `fromPromiseAbortable`.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Philosophy
|
|
13
|
+
|
|
14
|
+
- **Effects are values** β lazy, composable, referentially transparent
|
|
15
|
+
- **Async is explicit** β no hidden Promise semantics
|
|
16
|
+
- **Concurrency is structured** β fibers, scopes, finalizers
|
|
17
|
+
- **Side effects are interpreted** β not executed eagerly
|
|
18
|
+
- **Higher-level APIs are libraries, not magic**
|
|
19
|
+
|
|
20
|
+
If you like ZIOβs separation between `zio-core`, `zio-streams`, and `zio-http`, this project follows the same spirit.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Core concepts
|
|
25
|
+
|
|
26
|
+
- Sync core effect: `Effect<R, E, A>` and `Exit<E, A>`
|
|
27
|
+
- Algebraic async representation: `Async<R, E, A>`
|
|
28
|
+
- Cooperative `Scheduler` (observable / testable)
|
|
29
|
+
- Lightweight `Fiber`s with interruption & finalizers
|
|
30
|
+
- Structured `Scope`s for resource safety
|
|
31
|
+
- ZStream-style streams with backpressure
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm i brass-runtime
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
### Run an effect
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { Runtime, succeed, toPromise } from "brass-runtime";
|
|
49
|
+
|
|
50
|
+
const runtime = new Runtime({ env: {} });
|
|
51
|
+
|
|
52
|
+
const value = await toPromise(succeed(123), runtime.env);
|
|
53
|
+
console.log(value); // 123
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Structured concurrency with Scope
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { Runtime, withScope } from "brass-runtime";
|
|
60
|
+
|
|
61
|
+
const runtime = new Runtime({ env: {} });
|
|
62
|
+
|
|
63
|
+
withScope(runtime, (scope) => {
|
|
64
|
+
const f = scope.fork(/* Async effect */);
|
|
65
|
+
// later...
|
|
66
|
+
scope.close(); // interrupts child fibers + runs finalizers
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> `toPromise` is just a convenience bridge for examples/DX. The runtime semantics remain explicit.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Modules built on top of brass-runtime
|
|
75
|
+
|
|
76
|
+
These are optional layers, implemented using the runtime primitives.
|
|
77
|
+
|
|
78
|
+
### π HTTP client (brass-http layer)
|
|
79
|
+
|
|
80
|
+
A ZIO-style HTTP client built on top of fibers and `Async`.
|
|
81
|
+
|
|
82
|
+
- Lazy & cancelable HTTP requests
|
|
83
|
+
- Explicit wire/content separation
|
|
84
|
+
- Middleware-friendly (logging, retry, timeout, etc.)
|
|
85
|
+
- Integrated with fiber interruption via `AbortController`
|
|
86
|
+
|
|
87
|
+
π **Docs:** [HTTP module](./docs/http.md)
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { Runtime, toPromise } from "brass-runtime";
|
|
93
|
+
import { httpClientStream } from "brass-runtime/http";
|
|
94
|
+
|
|
95
|
+
type Post = { id: number; title: string; body: string };
|
|
96
|
+
|
|
97
|
+
const runtime = new Runtime({ env: {} });
|
|
98
|
+
|
|
99
|
+
const client = httpClientStream({ baseUrl: "https://jsonplaceholder.typicode.com" });
|
|
100
|
+
|
|
101
|
+
const res = await toPromise(client.getJson<Post>("/posts/1"), runtime.env);
|
|
102
|
+
console.log(res.status, res.value.title);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### π€ Brass Agent (experimental)
|
|
108
|
+
|
|
109
|
+
A CLI-first coding agent built on top of the runtime. Brass Agent is currently experimental: it can inspect a workspace, discover validation commands, gather bounded context, ask an LLM for a patch, apply/rollback patches through explicit policies, and expose a thin VS Code extension over the CLI protocol.
|
|
2
110
|
|
|
3
111
|
Start here:
|
|
4
112
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- [
|
|
48
|
-
- [
|
|
49
|
-
- [
|
|
50
|
-
|
|
51
|
-
- [
|
|
52
|
-
- [
|
|
53
|
-
- [
|
|
54
|
-
- [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
113
|
+
- [Install and configure Brass Agent](./docs/agent-install-and-configure.md)
|
|
114
|
+
- [Declarative optimized planning roadmap](./docs/agent-declarative-optimized-planning.md)
|
|
115
|
+
- [Brass Agent CLI](./docs/agent-cli.md)
|
|
116
|
+
- [Project intelligence](./docs/agent-project-intelligence.md)
|
|
117
|
+
- [Global usage and workspace discovery](./docs/agent-global-usage.md)
|
|
118
|
+
- [VS Code local install](./docs/agent-vscode-install.md)
|
|
119
|
+
- [VS Code auto-discovery](./docs/agent-vscode-auto-discovery.md)
|
|
120
|
+
- [VS Code model setup](./docs/agent-vscode-model-setup.md)
|
|
121
|
+
- [VS Code chat layout / focus mode](./docs/agent-vscode-chat-layout.md)
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm run agent:vscode:install
|
|
125
|
+
# then open any repo in VS Code and use Brass Agent -> Chat
|
|
126
|
+
|
|
127
|
+
npm run build
|
|
128
|
+
npm run agent:link
|
|
129
|
+
brass-agent --where
|
|
130
|
+
brass-agent --doctor
|
|
131
|
+
brass-agent --init
|
|
132
|
+
brass-agent --preset inspect
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### π Streams (ZStream-like)
|
|
138
|
+
|
|
139
|
+
Pull-based, resource-aware streams with backpressure.
|
|
140
|
+
|
|
141
|
+
- `ZStream<R, E, A>`
|
|
142
|
+
- `Pull` semantics
|
|
143
|
+
- Bounded buffers
|
|
144
|
+
- Deterministic resource cleanup
|
|
145
|
+
|
|
146
|
+
Examples:
|
|
147
|
+
|
|
148
|
+
- `src/examples/fromPromise.ts`
|
|
149
|
+
- `src/examples/mergeStreamSync.ts`
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Docs
|
|
154
|
+
|
|
155
|
+
- [Getting Started](./docs/getting-started.md)
|
|
156
|
+
- [Architecture](./docs/ARCHITECTURE.md)
|
|
157
|
+
- [Cancellation & Interruption](./docs/cancellation.md)
|
|
158
|
+
- [Observability: Hooks & Tracing](./docs/observability.md)
|
|
159
|
+
- [HTTP module](./docs/http.md)
|
|
160
|
+
- [Modules overview](./docs/modules.md)
|
|
161
|
+
- [Install and configure Brass Agent](./docs/agent-install-and-configure.md)
|
|
162
|
+
- [Declarative optimized planning roadmap](./docs/agent-declarative-optimized-planning.md)
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Whatβs new (recent changes)
|
|
167
|
+
|
|
168
|
+
- Stream buffering with backpressure (`buffer`)
|
|
169
|
+
- Abortable async integration (`fromPromiseAbortable`)
|
|
170
|
+
- Fiber-safe `toPromise` for examples & DX
|
|
171
|
+
- HTTP client module built on top of the runtime
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Features (status)
|
|
176
|
+
|
|
177
|
+
### Runtime (core)
|
|
178
|
+
|
|
179
|
+
- [x] Sync core: `Effect`
|
|
180
|
+
- [x] Async algebra: `Async`
|
|
181
|
+
- [x] Cooperative `Scheduler`
|
|
182
|
+
- [x] Fibers with interruption & finalizers
|
|
183
|
+
- [x] Structured `Scope`
|
|
184
|
+
- [x] Resource safety (`acquireRelease`)
|
|
185
|
+
|
|
186
|
+
### Concurrency & Streams
|
|
187
|
+
|
|
188
|
+
- [x] `race`, `zipPar`, `collectAllPar`
|
|
189
|
+
- [x] ZStream-like core
|
|
190
|
+
- [x] Bounded buffers & backpressure
|
|
191
|
+
- [x] Stream merge / zip
|
|
192
|
+
- [x] Hubs / Broadcast
|
|
193
|
+
- [x] Pipelines (`ZPipeline`-style)
|
|
194
|
+
|
|
195
|
+
### Libraries
|
|
196
|
+
|
|
197
|
+
- [x] HTTP client
|
|
198
|
+
- [ ] Retry / timeout middleware
|
|
199
|
+
- [ ] Logging / metrics layers
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Design notes
|
|
204
|
+
|
|
205
|
+
- **No hidden Promises**: async is always modeled explicitly
|
|
206
|
+
- **Deterministic execution**: scheduler is observable & testable
|
|
207
|
+
- **Resource safety is structural**: scopes guarantee cleanup
|
|
208
|
+
- **Libraries compose via functions**: middleware, not inheritance
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
- Runtime invariants matter β avoid sneaking Promises into semantics
|
|
215
|
+
- Prefer libraries on top of the runtime over changes in the core
|
|
216
|
+
- Small, focused PRs are welcome (your repo may enforce PR-only changes)
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT License Β© 2025
|
|
223
|
+
|
|
224
|
+
## Brass Agent local smoke tests
|
|
225
|
+
|
|
226
|
+
Run local smoke tests without CI or a real LLM provider:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npm run agent:test:local
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
This builds the project and runs a fake-LLM smoke test against the `brass-agent` CLI.
|
|
233
|
+
|
|
234
|
+
See also: [Agent language and workspace setup UX](docs/agent-language-workspace-ux.md).
|