@nimbus-sh/loom 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 +153 -106
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +4 -2
- package/package.json +2 -2
- package/src/actor.ts +4 -2
package/README.md
CHANGED
|
@@ -4,21 +4,42 @@
|
|
|
4
4
|
> cloud OS. This README is edited and maintained with Claude (AI) and
|
|
5
5
|
> presented as-is.
|
|
6
6
|
|
|
7
|
-
An actor framework for Cloudflare Durable Objects.
|
|
7
|
+
An actor framework for Cloudflare Durable Objects.
|
|
8
|
+
|
|
9
|
+
`Actor extends Server`, so it keeps
|
|
8
10
|
[partyserver](https://github.com/cloudflare/partykit/tree/main/packages/partyserver)'s
|
|
9
|
-
surface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
surface unchanged. Routing, connections, tags, broadcast, and hibernation
|
|
12
|
+
work as partyserver documents them. The machinery under that surface is
|
|
13
|
+
[`@nimbus-sh/fabric`](https://www.npmjs.com/package/@nimbus-sh/fabric), the
|
|
14
|
+
Durable Object code Nimbus runs in production. It arrives pre-wired, so you
|
|
15
|
+
write one class instead of the wiring.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
Use it for anything that lives in a Durable Object and holds state between
|
|
18
|
+
requests. An agent, a room, a job runner, a session.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @nimbus-sh/loom
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
Set `compatibility_flags: ["nodejs_compat"]` in your Worker. Loom dispatches
|
|
29
|
+
timers through fabric, and fabric's dispatcher imports `AsyncLocalStorage`
|
|
30
|
+
from `node:async_hooks`. Without the flag the module fails to load at deploy
|
|
31
|
+
time.
|
|
32
|
+
|
|
33
|
+
Actor classes must be SQLite-backed Durable Objects. State and schedules
|
|
34
|
+
live in the actor's own SQLite.
|
|
35
|
+
|
|
36
|
+
The root export pulls `partyserver`, which imports `cloudflare:workers`, so
|
|
37
|
+
`import ... from '@nimbus-sh/loom'` resolves only inside a Worker. Outside
|
|
38
|
+
workerd (unit tests, browsers), import the subpaths.
|
|
39
|
+
`@nimbus-sh/loom/client.js` and `@nimbus-sh/loom/protocol.js` need no
|
|
40
|
+
workerd. `@nimbus-sh/loom/schedules.js` is structurally typed for
|
|
41
|
+
plain-process tests, like fabric's. partyserver is pinned to an exact
|
|
42
|
+
version (0.5.10), because loom extends its prototype surface.
|
|
22
43
|
|
|
23
44
|
## One class
|
|
24
45
|
|
|
@@ -57,107 +78,133 @@ export default {
|
|
|
57
78
|
} satisfies ExportedHandler<Env>;
|
|
58
79
|
```
|
|
59
80
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
Bind the class, and give it a SQLite migration:
|
|
82
|
+
|
|
83
|
+
```jsonc
|
|
84
|
+
// wrangler.jsonc
|
|
85
|
+
{
|
|
86
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
87
|
+
"durable_objects": {
|
|
88
|
+
"bindings": [{ "name": "Counter", "class_name": "Counter" }]
|
|
89
|
+
},
|
|
90
|
+
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["Counter"] }]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`POST /parties/counter/room-1` now reaches `onRequest` on the actor named
|
|
95
|
+
`room-1`. `routeActorRequest` and `getActorByName` are partyserver's router,
|
|
96
|
+
re-exported with its URL convention: the path segment is the binding name in
|
|
97
|
+
kebab case.
|
|
65
98
|
|
|
66
|
-
|
|
99
|
+
Define hooks (`onMessage`, `onConnect`, ...) as methods, not instance
|
|
100
|
+
fields. Loom wraps them at construction to do the floor work and consume
|
|
101
|
+
protocol frames. An instance field assigns over that wiring.
|
|
102
|
+
|
|
103
|
+
## Cold start and the init gate
|
|
104
|
+
|
|
105
|
+
Nothing async belongs on the init gate. The constructor is synchronous, and
|
|
106
|
+
partyserver's gate runs your `onStart`. A gate callback still pending at
|
|
107
|
+
~30 s is cancelled, and that resets the object, so keep `onStart` short.
|
|
67
108
|
|
|
68
|
-
|
|
69
|
-
partyserver's gate runs exactly your `onStart`, and a gate callback still
|
|
70
|
-
pending at ~30 s is cancelled and resets the object, so `onStart` must stay
|
|
71
|
-
short. Work that belongs to a fresh incarnation goes through
|
|
109
|
+
Work that belongs to a fresh incarnation goes through
|
|
72
110
|
`this.deferToColdStart(task)` and runs on the first turn the actor owns.
|
|
73
111
|
Generation adoption (`this.generation`, fabric's incarnation counter) and
|
|
74
|
-
fenced-work recovery
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
fenced-work recovery run on that same turn.
|
|
113
|
+
|
|
114
|
+
## Timers
|
|
115
|
+
|
|
116
|
+
A Durable Object has one alarm, and a second `setAlarm()` silently
|
|
117
|
+
overwrites the first. `alarm()` therefore dispatches fabric's reason map.
|
|
118
|
+
Register a reason with `registerTimerReason` in the constructor. Arm it with
|
|
119
|
+
`this.timers.schedule(reason, whenMs)`. Re-arm it by returning
|
|
120
|
+
`{ rearmAt }` from the handler. The schedule API and every outbox are
|
|
121
|
+
reasons in the same map, so they do not overwrite each other.
|
|
122
|
+
|
|
123
|
+
## Scheduling
|
|
124
|
+
|
|
125
|
+
`schedule(when, callback, payload?)` takes a delay in seconds, a `Date`, or
|
|
126
|
+
a cron expression. `scheduleEvery(intervalSeconds, ...)` is a fixed
|
|
127
|
+
interval. `getScheduleById`, `listSchedules`, `cancelSchedule` read and
|
|
128
|
+
cancel. The callback receives `(payload, invocation)`. The invocation
|
|
129
|
+
carries the schedule, the attempt number, and the platform's `alarmInfo`
|
|
130
|
+
(`isRetry`, `retryCount`), which the Agents SDK drops.
|
|
131
|
+
|
|
132
|
+
Retries are durable. A failed attempt writes its backed-off deadline into
|
|
133
|
+
the row, so the budget survives an instance reset. Nothing sleeps inside the
|
|
134
|
+
alarm turn. Times are epoch milliseconds.
|
|
135
|
+
|
|
136
|
+
## State sync
|
|
137
|
+
|
|
138
|
+
Declare `initialState`, read `this.state`, write `setState(next)`. State
|
|
139
|
+
persists to SQLite and broadcasts to every connection as a `cf_agent_state`
|
|
140
|
+
frame (the Agents wire protocol, so its clients work as-is).
|
|
141
|
+
|
|
142
|
+
A client can send the same frame back.
|
|
143
|
+
`validateStateChange(next, source)` vetoes it synchronously before anything
|
|
98
144
|
persists, and `onStateChanged(state, source)` runs after. A refused client
|
|
99
|
-
update
|
|
100
|
-
|
|
101
|
-
**Callable RPC.** Mark a method `@callable()` and any connection can invoke
|
|
102
|
-
it by name; everything unmarked is refused. `@callable({ streaming: true })`
|
|
103
|
-
prepends a `StreamingResponse` to the arguments for chunked replies. The
|
|
104
|
-
caller side is `actorClient(socket)` from `@nimbus-sh/loom/client.js` —
|
|
105
|
-
dependency-free and workerd-free, with `call(method, args)` and a typed
|
|
106
|
-
`stub<T>()` proxy.
|
|
107
|
-
|
|
108
|
-
**Per-connection state.** `this.connections(schema)` is fabric's typed,
|
|
109
|
-
validated, hibernation-durable attachment state over partyserver's
|
|
110
|
-
`Connection` surface: `read` validates instead of casting (an attachment
|
|
111
|
-
written by a previous deploy is untrusted input), `write` validates on the
|
|
112
|
-
way in, tags address connections. partyserver owns the accept; tag
|
|
113
|
-
connections in `getConnectionTags`. Hibernating actors only — the state
|
|
114
|
-
rides the hibernatable socket attachment, and a non-hibernating actor is
|
|
115
|
-
refused with an error rather than corrupted later.
|
|
116
|
-
|
|
117
|
-
**Durable messaging.** `this.outbox(name, policy)` is a write-ahead retry
|
|
118
|
-
outbox (dispositions, per-key ordering, dead letters), its drain registered
|
|
119
|
-
as a timer reason the moment you create it. Create outboxes in the
|
|
120
|
-
constructor: a queued row survives an instance reset, but the alarm
|
|
121
|
-
dispatcher drops a fired reason no handler answers, so an outbox first
|
|
122
|
-
created inside a request path is unregistered until that path runs again.
|
|
123
|
-
`this.journal(name)` is an append-only event log with dedupe and
|
|
124
|
-
self-expiring delivery leases.
|
|
125
|
-
|
|
126
|
-
**Processes and facets.** `this.facets` leases DO facets so reclaiming
|
|
127
|
-
storage is the default and leaking it takes an explicit `detach()`.
|
|
128
|
-
`this.processes` is fabric's process fabric over a substrate you declare by
|
|
129
|
-
overriding `processHost()`. `this.derived` / `this.derivedAsync` are the
|
|
130
|
-
watermark memos.
|
|
131
|
-
|
|
132
|
-
**Hibernation, configured.** `static options = { hibernate: true }` opts
|
|
133
|
-
into partyserver's hibernation and also applies fabric's config: `ping`/
|
|
134
|
-
`pong` auto-response (a matched frame no longer wakes the actor) and the 5 s
|
|
135
|
-
hibernatable-event timeout. `this.hibernation` reports what the runtime
|
|
136
|
-
supported. State your fabric composition once, on the class:
|
|
137
|
-
`static options = { fabric: { supervisorEntrypoint: '...' } }`.
|
|
145
|
+
update gets a `cf_agent_state_error` frame.
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
fields. Loom wraps them at construction to pay the floor work and consume
|
|
141
|
-
protocol frames; an instance field assigns over the wiring.
|
|
147
|
+
## Callable RPC
|
|
142
148
|
|
|
143
|
-
|
|
149
|
+
Mark a method `@callable()` and any connection can invoke it by name;
|
|
150
|
+
everything unmarked is refused. `@callable({ streaming: true })` prepends a
|
|
151
|
+
`StreamingResponse` to the arguments for chunked replies.
|
|
144
152
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
and loom's `Actor` are siblings on the same partyserver base, and they do
|
|
149
|
-
not share a Durable Object.
|
|
153
|
+
The caller side is `actorClient(socket)` from `@nimbus-sh/loom/client.js`.
|
|
154
|
+
It has no dependencies, needs no workerd, and gives you `call(method, args)`
|
|
155
|
+
and a typed `stub<T>()` proxy.
|
|
150
156
|
|
|
151
|
-
##
|
|
157
|
+
## Per-connection state
|
|
152
158
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
159
|
+
`this.connections(schema)` is fabric's attachment state over partyserver's
|
|
160
|
+
`Connection` surface: typed, validated, and durable across hibernation.
|
|
161
|
+
`read` validates rather than casts, because an attachment written by a
|
|
162
|
+
previous deploy is untrusted input. `write` validates on the way in, and
|
|
163
|
+
tags address connections. partyserver owns the accept; tag connections in
|
|
164
|
+
`getConnectionTags`.
|
|
157
165
|
|
|
158
|
-
The
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
The state rides the hibernatable socket attachment, so a non-hibernating
|
|
167
|
+
actor is refused with an error.
|
|
168
|
+
|
|
169
|
+
## Durable messaging
|
|
170
|
+
|
|
171
|
+
`this.outbox(name, policy)` is a write-ahead retry outbox with
|
|
172
|
+
dispositions, per-key ordering, and dead letters. `this.journal(name)` is an
|
|
173
|
+
append-only event log with dedupe and self-expiring delivery leases.
|
|
174
|
+
|
|
175
|
+
Create outboxes in the constructor. An outbox registers its drain as a timer
|
|
176
|
+
reason the moment you create it. The alarm dispatcher drops a fired reason
|
|
177
|
+
that no handler answers. An outbox first created inside a request path stays
|
|
178
|
+
unregistered until that path runs again. A queued row survives an instance
|
|
179
|
+
reset.
|
|
180
|
+
|
|
181
|
+
## Processes and facets
|
|
182
|
+
|
|
183
|
+
`this.facets` leases DO facets, so the lease reclaims their storage by
|
|
184
|
+
default. An explicit `detach()` leaves the storage behind. `this.processes`
|
|
185
|
+
is fabric's process fabric over a substrate you declare by overriding
|
|
186
|
+
`processHost()`. `this.derived` / `this.derivedAsync` are the watermark
|
|
187
|
+
memos.
|
|
188
|
+
|
|
189
|
+
Declare the fabric composition on the class:
|
|
190
|
+
`static options = { fabric: { supervisorEntrypoint: '...' } }`.
|
|
191
|
+
|
|
192
|
+
## Hibernation
|
|
193
|
+
|
|
194
|
+
`static options = { hibernate: true }` opts into partyserver's hibernation.
|
|
195
|
+
It also applies fabric's config: `ping`/`pong` auto-response (a matched
|
|
196
|
+
frame no longer wakes the actor) and the 5 s hibernatable-event timeout.
|
|
197
|
+
`this.hibernation` reports what the runtime supported.
|
|
198
|
+
|
|
199
|
+
## Compared to the Agents SDK
|
|
200
|
+
|
|
201
|
+
Cloudflare's own Agents SDK takes the same shape (`Agent extends Server`).
|
|
202
|
+
Where the two overlap, loom keeps the SDK's API and wire protocol, so its
|
|
203
|
+
clients keep working. Underneath it swaps the machinery for fabric's. The
|
|
204
|
+
comparison here holds against the shipped `agents` 0.20.1 dist.
|
|
205
|
+
|
|
206
|
+
Loom has no chat surface, no MCP, no email routing, no React hooks, and no
|
|
207
|
+
Workflows integration. Those belong to the Agents SDK's product surface, and
|
|
208
|
+
loom stops at the framework layer. If you need them today, use `agents`. Its
|
|
209
|
+
`Agent` and loom's `Actor` are siblings on the same partyserver base, and
|
|
210
|
+
they do not share a Durable Object.
|
package/dist/actor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAA0C,MAAM,aAAa,CAAC;AAQ9F,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EAEvB,KAAK,MAAM,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAA0B,KAAK,MAAM,EAAsB,KAAK,YAAY,EAAE,MAAM,6BAA6B,CA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EAC1C,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,CAAC,EAC9C,KAAK,CAAC,EAAE,YAAY,GACnB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAIhB,+EAA+E;IAC/E,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,EACtB,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,EACnD,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACvD,KAAK,CAAC,EAAE,iBAAiB,GACxB,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IAIrB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC;IA0BzD;;;;OAIG;IACH,SAAS,CAAC,SAAS,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAMvF;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI;CAO/D"}
|
package/dist/actor.js
CHANGED
|
@@ -396,7 +396,8 @@ export class Actor extends Server {
|
|
|
396
396
|
}
|
|
397
397
|
/** Leased facets: disposal retires (storage wiped), `detach()` keeps it. */
|
|
398
398
|
get facets() {
|
|
399
|
-
|
|
399
|
+
this.#facets ??= facetPool(this.ctx);
|
|
400
|
+
return this.#facets;
|
|
400
401
|
}
|
|
401
402
|
/**
|
|
402
403
|
* The process fabric over this actor's substrate. Declare the substrate
|
|
@@ -404,7 +405,8 @@ export class Actor extends Server {
|
|
|
404
405
|
* use.
|
|
405
406
|
*/
|
|
406
407
|
get processes() {
|
|
407
|
-
|
|
408
|
+
this.#processes ??= new ProcessFabric(this.processHost());
|
|
409
|
+
return this.#processes;
|
|
408
410
|
}
|
|
409
411
|
/** The substrate {@link processes} runs on. Override to declare one. */
|
|
410
412
|
processHost() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimbus-sh/loom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The actor framework of Nimbus: partyserver's surface on top, the @nimbus-sh/fabric Durable Object floor pre-wired underneath.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typecheck": "tsc --noEmit"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@nimbus-sh/fabric": "^0.
|
|
54
|
+
"@nimbus-sh/fabric": "^0.3.0",
|
|
55
55
|
"cron-schedule": "^6.0.0",
|
|
56
56
|
"partyserver": "0.5.10",
|
|
57
57
|
"zod": "^4.4.3"
|
package/src/actor.ts
CHANGED
|
@@ -538,7 +538,8 @@ export class Actor<
|
|
|
538
538
|
|
|
539
539
|
/** Leased facets: disposal retires (storage wiped), `detach()` keeps it. */
|
|
540
540
|
get facets(): FacetPool {
|
|
541
|
-
|
|
541
|
+
this.#facets ??= facetPool(this.ctx as unknown as FacetPoolContext);
|
|
542
|
+
return this.#facets;
|
|
542
543
|
}
|
|
543
544
|
|
|
544
545
|
/**
|
|
@@ -547,7 +548,8 @@ export class Actor<
|
|
|
547
548
|
* use.
|
|
548
549
|
*/
|
|
549
550
|
get processes(): ProcessFabric {
|
|
550
|
-
|
|
551
|
+
this.#processes ??= new ProcessFabric(this.processHost());
|
|
552
|
+
return this.#processes;
|
|
551
553
|
}
|
|
552
554
|
|
|
553
555
|
/** The substrate {@link processes} runs on. Override to declare one. */
|