@mcp-b/do-runtime 0.1.2 → 0.2.2
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/CHANGELOG.md +25 -0
- package/README.md +9 -0
- package/dist/index.js +96 -4
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/io/io-context.d.ts +39 -0
- package/dist/src/io/worker.d.ts +2 -3
- package/dist/src/server/actor-container.d.ts +4 -4
- package/dist/src/server/actor-namespace.d.ts +3 -0
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export type { Module as SourceModule, ModuleContent, ModulesSource, WorkerSource
|
|
|
52
52
|
*/
|
|
53
53
|
export type { ActorContainer, ActorContainerOptions, ActorEntry, ActorPorts, FacetHandle, FacetHost, FacetId, FacetStartRequest, FacetTree, } from "./server/actor-container.js";
|
|
54
54
|
export { createActorContainer, FACET_ALARM_UNIMPLEMENTED_MESSAGE, noFacets, } from "./server/actor-container.js";
|
|
55
|
+
export type { ActorChannelFactory, GlobalActorRequest } from "./api/actor.js";
|
|
56
|
+
export { createDurableObjectNamespace } from "./server/actor-namespace.js";
|
|
55
57
|
export { ACTOR_CLASS_SERIALIZATION_UNIMPLEMENTED_MESSAGE } from "./api/actor.js";
|
|
56
58
|
/**
|
|
57
59
|
* The `ctx.exports` entries, exported where the rest of `api/` is not — for the
|
|
@@ -169,6 +169,21 @@ export declare const BLOCK_CONCURRENCY_WHILE_TIMEOUT_MESSAGE: string;
|
|
|
169
169
|
* lost transaction boundary is not.
|
|
170
170
|
*/
|
|
171
171
|
export declare function requireInputLock(ctx: IoContext, op: string): void;
|
|
172
|
+
/**
|
|
173
|
+
* A stack for `noteGateUse`, captured where user frames are still on the stack.
|
|
174
|
+
*
|
|
175
|
+
* The invocation stack's own push and pop are scheduler moments — `#runImpl`
|
|
176
|
+
* runs from a gate resumption and `#exit` from a `MessageChannel` callback — so
|
|
177
|
+
* a trace taken there names only runtime internals. The moments that still see
|
|
178
|
+
* the caller are the synchronous entries into the gate machinery: an `awaitIo`
|
|
179
|
+
* call, an `entry` dispatch, a callback's registration. V8's zero-cost async
|
|
180
|
+
* traces extend those with the awaiting chain, which is usually the frame the
|
|
181
|
+
* reader actually wants.
|
|
182
|
+
*
|
|
183
|
+
* The first slice drops the `Error` header (absent on SpiderMonkey) and the two
|
|
184
|
+
* runtime frames: this helper and the gate entry point that called it.
|
|
185
|
+
*/
|
|
186
|
+
export declare function captureGateStack(): string | undefined;
|
|
172
187
|
/**
|
|
173
188
|
* The end of the microtask checkpoint — the moment `runImpl`'s `KJ_DEFER` fires.
|
|
174
189
|
*
|
|
@@ -305,6 +320,30 @@ export declare class IoContext {
|
|
|
305
320
|
* actor's?
|
|
306
321
|
*/
|
|
307
322
|
isCurrentSlice(): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Record that user code just engaged this context's gate — an `awaitIo`, an
|
|
325
|
+
* `entry` dispatch, a re-entry callback firing. No upstream analogue, because
|
|
326
|
+
* upstream cannot lose the lock; here a continuation that awaits a promise
|
|
327
|
+
* the runtime does not own comes back lockless, the throw lands at the next
|
|
328
|
+
* storage call three layers later, and the gap between "where the code last
|
|
329
|
+
* verifiably ran gated" and the throw site is exactly where the foreign await
|
|
330
|
+
* hides. This is that first coordinate. Always on: the capture rides calls
|
|
331
|
+
* that already allocate promise machinery, and a stack costs microseconds
|
|
332
|
+
* against the diagnosis it replaces.
|
|
333
|
+
*/
|
|
334
|
+
noteGateUse(what: string, stack: string | undefined): void;
|
|
335
|
+
/**
|
|
336
|
+
* The suffix `requireInputLock` appends when the invocation stack is empty:
|
|
337
|
+
* where this context's gate was last engaged, and how long before the throw.
|
|
338
|
+
*
|
|
339
|
+
* "Last engaged" is the honest claim, not "this continuation's ancestor" —
|
|
340
|
+
* once the offending chain went lockless the gate reopened, so another slice
|
|
341
|
+
* may have run in between and be the note this reports. In practice the loss
|
|
342
|
+
* is discovered within the same event storm and the note is the parent; when
|
|
343
|
+
* it is not, an engagement of this actor moments earlier is still the right
|
|
344
|
+
* neighbourhood to search.
|
|
345
|
+
*/
|
|
346
|
+
describeLostLock(): string;
|
|
308
347
|
/**
|
|
309
348
|
* ← `IoContext::getActorOrThrow()`. Upstream's throws when the request is not
|
|
310
349
|
* an actor request; there is no such request here, so it is a plain accessor.
|
package/dist/src/io/worker.d.ts
CHANGED
|
@@ -44,9 +44,8 @@ import type { ActorClassChannel } from "./io-channels.js";
|
|
|
44
44
|
* reentry callback (`actor-state.c++:1044`) — so `api/actor-state.ts` now does
|
|
45
45
|
* the same and this field carries the resolved channel.
|
|
46
46
|
*
|
|
47
|
-
* `id` is upstream's `Worker::Actor::Id` as
|
|
48
|
-
*
|
|
49
|
-
* package, since ids never cross the host boundary.
|
|
47
|
+
* `id` is upstream's `Worker::Actor::Id` as its stable name when present, or
|
|
48
|
+
* the string form of an unnamed `DurableObjectId`.
|
|
50
49
|
*/
|
|
51
50
|
export type FacetStartInfo = {
|
|
52
51
|
readonly actorClass: ActorClassChannel;
|
|
@@ -66,10 +66,10 @@ export type FacetStartRequest = {
|
|
|
66
66
|
*
|
|
67
67
|
* The scaffolding called this "the DurableObjectId name". It is not
|
|
68
68
|
* necessarily a name: `FacetStartupOptions.id` is `DurableObjectId | string`
|
|
69
|
-
* (`actor-state.h:453`), so this carries a
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
* (`actor-state.h:453`), so this carries a named id's stable name, an unnamed
|
|
70
|
+
* id's 64-hex string, or the string the app supplied. The host decides what to
|
|
71
|
+
* do with it, exactly as upstream's `Worker::Actor::Id` leaves that to the
|
|
72
|
+
* supervisor.
|
|
73
73
|
*/
|
|
74
74
|
routedId?: string;
|
|
75
75
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DurableObjectNamespace, type ActorChannelFactory } from "../api/actor.js";
|
|
2
|
+
/** Assemble the configured namespace binding a host places in `env`. */
|
|
3
|
+
export declare function createDurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined>(uniqueKey: string, channel: ActorChannelFactory): DurableObjectNamespace<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-b/do-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Cloudflare's Durable Object runtime (workerd), ported to TypeScript: actors with input/output gates, SQLite storage, facets and alarms, running in the browser and in Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actors",
|