iterate 0.2.7 → 0.3.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/README.md +86 -76
- package/THIRD_PARTY_NOTICES.md +55 -0
- package/bin/iterate.js +11 -3
- package/dist/api-url-B6404M82.mjs +17 -0
- package/dist/api-url-B6404M82.mjs.map +1 -0
- package/dist/app-ref-BipL0feU.mjs +35 -0
- package/dist/app-ref-BipL0feU.mjs.map +1 -0
- package/dist/app-ref-C1CrgXqX.mjs +7 -0
- package/dist/app-ref-C1CrgXqX.mjs.map +1 -0
- package/dist/app-ref-DYai_om1.mjs +7 -0
- package/dist/app-ref-DYai_om1.mjs.map +1 -0
- package/dist/cli-D0c-pDL_.mjs +1010 -0
- package/dist/cli-D0c-pDL_.mjs.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.mjs +4 -0
- package/dist/cloudflare-BTm90gQ4.mjs +951 -0
- package/dist/cloudflare-BTm90gQ4.mjs.map +1 -0
- package/dist/contract-s4FW4eES.mjs +309 -0
- package/dist/contract-s4FW4eES.mjs.map +1 -0
- package/dist/document-review/index.d.ts +5 -0
- package/dist/document-review/types.d.ts +107 -0
- package/dist/document-review.mjs +7015 -0
- package/dist/document-review.mjs.map +1 -0
- package/dist/durable-object-processor-durability-CNsTjAJS.mjs +205 -0
- package/dist/durable-object-processor-durability-CNsTjAJS.mjs.map +1 -0
- package/dist/idempotency-DleloJNt.mjs +28 -0
- package/dist/idempotency-DleloJNt.mjs.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/itx/api-url.d.ts +6 -0
- package/dist/itx/itx-node-client.d.ts +65 -0
- package/dist/itx/itx-session.d.ts +215 -0
- package/dist/itx/owned-rpc-session.d.ts +14 -0
- package/dist/itx/query-client.d.ts +10 -0
- package/dist/itx-api.generated.d.ts +6195 -0
- package/dist/itx-session-sjud8GiT.mjs +534 -0
- package/dist/itx-session-sjud8GiT.mjs.map +1 -0
- package/dist/live-state-BJNqOwFw.mjs +299 -0
- package/dist/live-state-BJNqOwFw.mjs.map +1 -0
- package/dist/next/api.d.ts +479 -0
- package/dist/next/api.mjs +0 -0
- package/dist/next/app-server.d.ts +44 -0
- package/dist/next/app-server.mjs +479 -0
- package/dist/next/app-server.mjs.map +1 -0
- package/dist/next/app-session.d.ts +49 -0
- package/dist/next/app-session.mjs +238 -0
- package/dist/next/app-session.mjs.map +1 -0
- package/dist/next/app.d.ts +29 -0
- package/dist/next/app.mjs +141 -0
- package/dist/next/app.mjs.map +1 -0
- package/dist/next/client/live-state.d.ts +63 -0
- package/dist/next/client/oauth.d.ts +12 -0
- package/dist/next/client/react.d.ts +109 -0
- package/dist/next/client/socket.d.ts +6 -0
- package/dist/next/client.mjs +156 -0
- package/dist/next/client.mjs.map +1 -0
- package/dist/next/expression.d.ts +146 -0
- package/dist/next/expression.mjs +399 -0
- package/dist/next/expression.mjs.map +1 -0
- package/dist/next/lib.d.ts +56 -0
- package/dist/next/lib.mjs +199 -0
- package/dist/next/lib.mjs.map +1 -0
- package/dist/next/oauth-scopes.d.ts +32 -0
- package/dist/next/oauth-scopes.mjs +40 -0
- package/dist/next/oauth-scopes.mjs.map +1 -0
- package/dist/next/oauth.mjs +29 -0
- package/dist/next/oauth.mjs.map +1 -0
- package/dist/next/principal.d.ts +64 -0
- package/dist/next/principal.mjs +98 -0
- package/dist/next/principal.mjs.map +1 -0
- package/dist/next/project-ingress.d.ts +37 -0
- package/dist/next/project-ingress.mjs +75 -0
- package/dist/next/project-ingress.mjs.map +1 -0
- package/dist/next/react.mjs +285 -0
- package/dist/next/react.mjs.map +1 -0
- package/dist/next/sdk/auth.d.ts +5 -0
- package/dist/next/sdk/index.d.ts +112 -0
- package/dist/next/sdk.mjs +139 -0
- package/dist/next/sdk.mjs.map +1 -0
- package/dist/next/stream/processor.d.ts +378 -0
- package/dist/next/stream/processor.mjs +582 -0
- package/dist/next/stream/processor.mjs.map +1 -0
- package/dist/next/stream/run.d.ts +58 -0
- package/dist/next/stream/run.mjs +40 -0
- package/dist/next/stream/run.mjs.map +1 -0
- package/dist/next-node.d.ts +15 -0
- package/dist/next-node.mjs +51 -0
- package/dist/next-node.mjs.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.mjs +185 -0
- package/dist/node.mjs.map +1 -0
- package/dist/processor-host-capabilities-BMFH3KTM.mjs +56 -0
- package/dist/processor-host-capabilities-BMFH3KTM.mjs.map +1 -0
- package/dist/processors/cloudflare.d.ts +3 -0
- package/dist/processors/durable-object-processor-durability.d.ts +79 -0
- package/dist/processors/event-consumption-metrics.d.ts +82 -0
- package/dist/processors/idempotency.d.ts +13 -0
- package/dist/processors/index.d.ts +12 -0
- package/dist/processors/processor-contracts.d.ts +342 -0
- package/dist/processors/processor-facet.d.ts +186 -0
- package/dist/processors/processor-host-capabilities.d.ts +60 -0
- package/dist/processors/prompt-sections.d.ts +17 -0
- package/dist/processors/rpc-types.d.ts +515 -0
- package/dist/processors/schemas.d.ts +102 -0
- package/dist/processors/stream-handle.d.ts +45 -0
- package/dist/processors/stream-processor-keepalive.d.ts +95 -0
- package/dist/processors/stream-processor-registry.d.ts +233 -0
- package/dist/processors/stream-processor-runner.d.ts +289 -0
- package/dist/processors/stream-processor.d.ts +339 -0
- package/dist/processors/stream-runtime-metrics.d.ts +107 -0
- package/dist/processors/testing.d.ts +302 -0
- package/dist/processors-BoNyeBfQ.mjs +10 -0
- package/dist/processors-BoNyeBfQ.mjs.map +1 -0
- package/dist/processors-cloudflare.mjs +3 -0
- package/dist/processors-testing.mjs +435 -0
- package/dist/processors-testing.mjs.map +1 -0
- package/dist/processors.mjs +52 -0
- package/dist/processors.mjs.map +1 -0
- package/dist/protocol-DnK_f2m6.mjs +251 -0
- package/dist/protocol-DnK_f2m6.mjs.map +1 -0
- package/dist/sdk/capnweb/index.d.ts +2 -0
- package/dist/sdk/capnweb/live-state/compact.d.ts +5 -0
- package/dist/sdk/capnweb/live-state/diff.d.ts +41 -0
- package/dist/sdk/capnweb/live-state/engine.d.ts +44 -0
- package/dist/sdk/capnweb/live-state/index.d.ts +41 -0
- package/dist/sdk/capnweb/live-state/protocol.d.ts +87 -0
- package/dist/sdk/capnweb/live-state/retain.d.ts +23 -0
- package/dist/sdk/capnweb/live-state/store.d.ts +20 -0
- package/dist/sdk/capnweb/live-state/types.d.ts +11 -0
- package/dist/sdk/capnweb/react.d.ts +45 -0
- package/dist/sdk/capnweb/react.mjs +316 -0
- package/dist/sdk/capnweb/react.mjs.map +1 -0
- package/dist/sdk/capnweb.mjs +4 -0
- package/dist/sdk/itx/react.d.ts +191 -0
- package/dist/sdk/itx/react.mjs +383 -0
- package/dist/sdk/itx/react.mjs.map +1 -0
- package/dist/sdk-DMB-IM11.mjs +933 -0
- package/dist/sdk-DMB-IM11.mjs.map +1 -0
- package/dist/sdk.d.ts +339 -0
- package/dist/sdk.mjs +2 -0
- package/dist/serve-itx.d.ts +46 -0
- package/dist/starter-apps/flake-dashboard/app-ref.d.ts +31 -0
- package/dist/starter-apps/flake-dashboard/configured-worker.mjs +1055 -0
- package/dist/starter-apps/flake-dashboard/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/flake-dashboard/contract.d.ts +4839 -0
- package/dist/starter-apps/flake-dashboard/contract.mjs +2 -0
- package/dist/starter-apps/flake-dashboard/index.d.ts +17 -0
- package/dist/starter-apps/flake-dashboard/index.mjs +56 -0
- package/dist/starter-apps/flake-dashboard/index.mjs.map +1 -0
- package/dist/starter-apps/flake-dashboard/worker.d.ts +4607 -0
- package/dist/starter-apps/github-ai-linter/ai-linter.d.ts +8914 -0
- package/dist/starter-apps/github-ai-linter/configured-worker.mjs +17987 -0
- package/dist/starter-apps/github-ai-linter/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/github-ai-linter/contract.d.ts +9193 -0
- package/dist/starter-apps/github-ai-linter/index.d.ts +10 -0
- package/dist/starter-apps/github-ai-linter/index.mjs +36 -0
- package/dist/starter-apps/github-ai-linter/index.mjs.map +1 -0
- package/dist/starter-apps/github-ai-linter/prompt.d.ts +13 -0
- package/dist/starter-apps/github-ai-linter/review-bot.d.ts +808 -0
- package/dist/starter-apps/github-ai-linter/rules.d.ts +34 -0
- package/dist/starter-apps/github-ai-linter/worker-ref.d.ts +19 -0
- package/dist/starter-apps/github-ai-linter/worker.d.ts +19 -0
- package/dist/starter-apps/github-ai-linter/worker.mjs +947 -0
- package/dist/starter-apps/github-ai-linter/worker.mjs.map +1 -0
- package/dist/starter-apps/guestbook/app-ref.d.ts +27 -0
- package/dist/starter-apps/guestbook/client.d.ts +7 -0
- package/dist/starter-apps/guestbook/client.mjs +59 -0
- package/dist/starter-apps/guestbook/configured-worker.mjs +205 -0
- package/dist/starter-apps/guestbook/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/guestbook/index.d.ts +9 -0
- package/dist/starter-apps/guestbook/index.mjs +31 -0
- package/dist/starter-apps/guestbook/index.mjs.map +1 -0
- package/dist/starter-apps/guestbook/processor.d.ts +2267 -0
- package/dist/starter-apps/guestbook/worker.d.ts +26 -0
- package/dist/starter-apps/guestbook/worker.mjs +191 -0
- package/dist/starter-apps/guestbook/worker.mjs.map +1 -0
- package/dist/starter-apps/media/configured-worker.mjs +577 -0
- package/dist/starter-apps/media/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/media/index.mjs +36 -0
- package/dist/starter-apps/media/index.mjs.map +1 -0
- package/dist/starter-apps/media/ref.mjs +20 -0
- package/dist/starter-apps/media/ref.mjs.map +1 -0
- package/dist/starter-apps/media/worker.mjs +579 -0
- package/dist/starter-apps/media/worker.mjs.map +1 -0
- package/dist/starter-apps/notes/configured-worker.mjs +6134 -0
- package/dist/starter-apps/notes/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/notes/index.mjs +23 -0
- package/dist/starter-apps/notes/index.mjs.map +1 -0
- package/dist/starter-apps/notes/ref.mjs +21 -0
- package/dist/starter-apps/notes/ref.mjs.map +1 -0
- package/dist/starter-apps/notes/worker.mjs +427 -0
- package/dist/starter-apps/notes/worker.mjs.map +1 -0
- package/dist/starter-apps/todo/client.mjs +59 -0
- package/dist/starter-apps/todo/configured-worker.mjs +2864 -0
- package/dist/starter-apps/todo/configured-worker.mjs.map +1 -0
- package/dist/starter-apps/todo/index.d.ts +8 -0
- package/dist/starter-apps/todo/index.mjs +29 -0
- package/dist/starter-apps/todo/index.mjs.map +1 -0
- package/dist/stream-processor-keepalive-DAQTP6m3.mjs +2082 -0
- package/dist/stream-processor-keepalive-DAQTP6m3.mjs.map +1 -0
- package/dist/usingCtx-inzbY1Qz.mjs +57 -0
- package/dist/usingCtx-mZx5nsAW.mjs +11800 -0
- package/dist/usingCtx-mZx5nsAW.mjs.map +1 -0
- package/dist/worker-ref-DZxPDmb_.mjs +390 -0
- package/dist/worker-ref-DZxPDmb_.mjs.map +1 -0
- package/menubar/Iterate.entitlements +12 -0
- package/menubar/Iterate.swift +914 -0
- package/menubar/IterateIcon.swift +145 -0
- package/menubar/README.md +28 -0
- package/menubar/build-menubar-app.sh +59 -0
- package/package.json +235 -18
- package/dist/cli-DMS4kJph.mjs +0 -868
- package/dist/cli-DMS4kJph.mjs.map +0 -1
- package/dist/config-DtnR7Lv7.mjs +0 -170
- package/dist/config-DtnR7Lv7.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/stream-tui/agent-chat-terminal.d.mts +0 -1
- package/dist/stream-tui/agent-chat-terminal.mjs +0 -933
- package/dist/stream-tui/agent-chat-terminal.mjs.map +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { DurableObject } from "cloudflare:workers";
|
|
2
|
+
import type { LiveStateCursor } from "../sdk/capnweb/live-state/protocol.ts";
|
|
3
|
+
import type { LiveStateRpc } from "../sdk/capnweb/live-state/types.ts";
|
|
4
|
+
import type { ProcessorStream } from "./stream-handle.ts";
|
|
5
|
+
import type { MaybePromise } from "./stream-processor.ts";
|
|
6
|
+
import type { ProcessorRuntimeState, ProcessorSnapshot, StreamProcessorWakeRequest, StreamProcessorWakeResponse } from "./rpc-types.ts";
|
|
7
|
+
import { type StreamProcessorRegistry } from "./stream-processor-registry.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Where the configured identity lives in the facet's own kv. Exported so a
|
|
10
|
+
* subclass's own doors can self-heal a fresh incarnation (re-run the
|
|
11
|
+
* idempotent `configure` from the stash) before the base's boot microtask has
|
|
12
|
+
* run — see apps/os `ProcessorFacet.#requireRegistry`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FACET_IDENTITY_KEY = "iterate:processor-facet:identity";
|
|
15
|
+
/**
|
|
16
|
+
* The identity a {@link ProcessorFacet} is configured with on first contact —
|
|
17
|
+
* stashed durably in the facet's own kv, never passed again. `path` +
|
|
18
|
+
* `projectId` are the registry's wake coordinate fence; `parentName` is how
|
|
19
|
+
* the facet dials BACK to the Durable Object hosting it (the Stream DO) for
|
|
20
|
+
* the alarm proxy.
|
|
21
|
+
*/
|
|
22
|
+
export type ProcessorFacetIdentity = {
|
|
23
|
+
/** Durable Object name of the hosting parent (the Stream DO). */
|
|
24
|
+
parentName: string;
|
|
25
|
+
/** Owning project of the hosted stream, or null on a deployment-global stream. */
|
|
26
|
+
projectId: string | null;
|
|
27
|
+
/** Path of the hosted stream. */
|
|
28
|
+
path: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The three parent-side alarm doors a facet dials in place of its own
|
|
32
|
+
* (unimplemented) `ctx.storage` alarm verbs. The parent implements them over
|
|
33
|
+
* its REAL platform alarm and replays each fire into the facet's
|
|
34
|
+
* {@link ProcessorFacet.handleAlarm}. The parent's implementations MUST
|
|
35
|
+
* tolerate being called reentrantly while the parent itself is still awaiting
|
|
36
|
+
* `handleAlarm` — the keepalive re-arms from inside its own alarm turn.
|
|
37
|
+
*/
|
|
38
|
+
export type ProcessorFacetAlarmProxy = {
|
|
39
|
+
proxySetAlarm(scheduledTimeMs: number): MaybePromise<unknown>;
|
|
40
|
+
proxyDeleteAlarm(): MaybePromise<unknown>;
|
|
41
|
+
proxyGetAlarm(): MaybePromise<number | null>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Everything app-specific about one facet host, derived from the stashed
|
|
45
|
+
* identity by {@link ProcessorFacet.createHost}: the stream handle processors
|
|
46
|
+
* append through, the worker deploy version (keepalive crash-loop budget
|
|
47
|
+
* reset), and the per-host processor composition — the subclass constructs its
|
|
48
|
+
* processors here and registers each under its subscription name.
|
|
49
|
+
*/
|
|
50
|
+
export type ProcessorFacetHost = {
|
|
51
|
+
/** The hosted stream — how processors append/read (colocated: a dial back
|
|
52
|
+
* to the parent Stream DO's stream surface). */
|
|
53
|
+
stream: ProcessorStream;
|
|
54
|
+
/** Worker deploy version — pass this worker's build identity. A change
|
|
55
|
+
* resets each keepalive's crash-loop budget (the antidote deploy). */
|
|
56
|
+
version: string;
|
|
57
|
+
/** Injected clock for tests; production omits it (Date.now). */
|
|
58
|
+
now?: () => number;
|
|
59
|
+
/** Assemble this node's live state; omit for the primary runner's fold. */
|
|
60
|
+
getLiveState?: () => Record<string, unknown>;
|
|
61
|
+
/** Construct and register this host's processors (`registry.register(new
|
|
62
|
+
* XProcessor({...}), { recovery, name })`) — called once, right after the
|
|
63
|
+
* registry is built. Per-processor recovery stays the author's explicit
|
|
64
|
+
* choice, exactly as on a hosting DO. */
|
|
65
|
+
registerProcessors(registry: StreamProcessorRegistry): void;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A facet's `DurableObjectState` facade for `createStreamProcessorRegistry`:
|
|
69
|
+
* ONLY `storage.setAlarm` / `storage.deleteAlarm` / `storage.getAlarm` are
|
|
70
|
+
* overridden to dial the parent's {@link ProcessorFacetAlarmProxy}; kv,
|
|
71
|
+
* waitUntil, and everything else pass through untouched. `parentAlarms` is
|
|
72
|
+
* invoked PER CALL — the parent stub must be resolved lazily from the stashed
|
|
73
|
+
* identity, because the recovery adapter's boot reconcile issues alarm calls
|
|
74
|
+
* at construction and a stub captured once would outlive its RPC session.
|
|
75
|
+
*/
|
|
76
|
+
export declare function facetProcessorDurableObjectState(ctx: DurableObjectState, parentAlarms: () => ProcessorFacetAlarmProxy): DurableObjectState;
|
|
77
|
+
/**
|
|
78
|
+
* Plain-copy an `AlarmInvocationInfo` before a facet hop. The platform hands
|
|
79
|
+
* the parent's `alarm()` a host object that does not serialize across RPC;
|
|
80
|
+
* a parent replaying a fire into {@link ProcessorFacet.handleAlarm} must send
|
|
81
|
+
* this copy instead.
|
|
82
|
+
*/
|
|
83
|
+
export declare function plainAlarmInvocationInfo(info: AlarmInvocationInfo | undefined): AlarmInvocationInfo | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Generic base for hosting stream processors in a Durable Object facet.
|
|
86
|
+
* Subclasses are the per-host composition (the facets task's target shape) and
|
|
87
|
+
* supply exactly two things: how to dial the parent's alarm proxy and what
|
|
88
|
+
* this host runs —
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* export class AgentProcessors extends ProcessorFacet<Env> {
|
|
92
|
+
* protected parentAlarms({ parentName }: ProcessorFacetIdentity) {
|
|
93
|
+
* return this.env.STREAM.getByName(parentName);
|
|
94
|
+
* }
|
|
95
|
+
* protected createHost({ path, projectId }: ProcessorFacetIdentity): ProcessorFacetHost {
|
|
96
|
+
* const stream = ...; // dial the parent stream
|
|
97
|
+
* return {
|
|
98
|
+
* stream,
|
|
99
|
+
* version: workerVersion(this.env),
|
|
100
|
+
* registerProcessors: (registry) => {
|
|
101
|
+
* registry.register(
|
|
102
|
+
* new AgentProcessor({ stream, path, projectId, ... }),
|
|
103
|
+
* { recovery: true, name: "agent" },
|
|
104
|
+
* );
|
|
105
|
+
* },
|
|
106
|
+
* };
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* The parent creates it with `ctx.facets.get(name, () => ({ class:
|
|
112
|
+
* ctx.exports.AgentProcessors }))`, calls `configure()` once (idempotent), and
|
|
113
|
+
* routes wakes/alarms/doors to the RPC surface below.
|
|
114
|
+
*
|
|
115
|
+
* THIS CLASS MUST NEVER DEFINE `alarm()` — and neither may a subclass. The
|
|
116
|
+
* fire arrives as `handleAlarm` (an ordinary RPC verb) instead: workerd
|
|
117
|
+
* reserves `alarm` for its native handler, and with one present a failed
|
|
118
|
+
* native `setAlarm` poisons the facet's output gate (workerd#6810). The
|
|
119
|
+
* constructor enforces this.
|
|
120
|
+
*/
|
|
121
|
+
export declare abstract class ProcessorFacet<Env = unknown> extends DurableObject<Env> {
|
|
122
|
+
#private;
|
|
123
|
+
constructor(ctx: DurableObjectState, env: Env);
|
|
124
|
+
/**
|
|
125
|
+
* Resolve the parent's alarm-proxy stub for the stashed identity — e.g.
|
|
126
|
+
* `this.env.STREAM.getByName(identity.parentName)`. Called once per alarm
|
|
127
|
+
* verb invocation (stubs must not outlive their call turn).
|
|
128
|
+
*/
|
|
129
|
+
protected abstract parentAlarms(identity: ProcessorFacetIdentity): ProcessorFacetAlarmProxy;
|
|
130
|
+
/** Build this host's app-specific wiring from the stashed identity — called
|
|
131
|
+
* once per incarnation, lazily on first use. */
|
|
132
|
+
protected abstract createHost(identity: ProcessorFacetIdentity): ProcessorFacetHost;
|
|
133
|
+
/**
|
|
134
|
+
* First-contact identity stash, idempotent: re-configuring with the same
|
|
135
|
+
* identity is a no-op (and ensures the host is built); a DIFFERENT identity
|
|
136
|
+
* throws — a facet's coordinate never changes, so a mismatch is a miswire,
|
|
137
|
+
* not a migration.
|
|
138
|
+
*/
|
|
139
|
+
configure(identity: ProcessorFacetIdentity): void;
|
|
140
|
+
/** The wake door — the parent's colocated delivery dial. Routes to the
|
|
141
|
+
* registry: name-first resolution, coordinate fence, per-batch settlement
|
|
142
|
+
* through each batch's independent `reportDeliveryResult`. */
|
|
143
|
+
wakeStreamProcessor(request: StreamProcessorWakeRequest): Promise<StreamProcessorWakeResponse>;
|
|
144
|
+
/**
|
|
145
|
+
* The parent's alarm replay door — deliberately NOT named `alarm` (see the
|
|
146
|
+
* class doc). The parent plain-copies its `AlarmInvocationInfo`
|
|
147
|
+
* ({@link plainAlarmInvocationInfo}) and awaits this; a rejection propagates
|
|
148
|
+
* so the parent can rethrow and get the platform's alarm retry.
|
|
149
|
+
*/
|
|
150
|
+
handleAlarm(info?: AlarmInvocationInfo): Promise<void>;
|
|
151
|
+
/** One consistent read of a hosted processor's committed fold. `name` may be
|
|
152
|
+
* omitted on a single-processor host. */
|
|
153
|
+
snapshot(args?: {
|
|
154
|
+
name?: string;
|
|
155
|
+
}): Promise<ProcessorSnapshot<unknown>>;
|
|
156
|
+
/** The hosted processor's runtime state (runner snapshot + contributed
|
|
157
|
+
* runtime bag). `name` may be omitted on a single-processor host. */
|
|
158
|
+
getRuntimeState(args?: {
|
|
159
|
+
name?: string;
|
|
160
|
+
}): Promise<ProcessorRuntimeState>;
|
|
161
|
+
/** Resolve once the named processor's acknowledged cursor reaches `offset` —
|
|
162
|
+
* the read-your-writes barrier. The subscription catalog's uniform
|
|
163
|
+
* `waitUntilProcessed` delegates its facet-placed processor rows here. */
|
|
164
|
+
waitUntilProcessed(args: {
|
|
165
|
+
offset: number;
|
|
166
|
+
timeoutMs?: number;
|
|
167
|
+
name?: string;
|
|
168
|
+
}): Promise<void>;
|
|
169
|
+
/** Pull the named processor through the durable stream tail — the parent
|
|
170
|
+
* facade's catch-up-before-snapshot leg, dialed before every facet read.
|
|
171
|
+
* `name` may be omitted on a single-processor host. */
|
|
172
|
+
catchUp(args?: {
|
|
173
|
+
name?: string;
|
|
174
|
+
}): Promise<void>;
|
|
175
|
+
/** Read a transient snapshot or delta for the parent's current stream lifetime.
|
|
176
|
+
* Cold or replaced processors hydrate from durable progress. Warm reads use
|
|
177
|
+
* committed local state: polling must not call back into the parent stream
|
|
178
|
+
* for every processor while it is delivering events to this facet. */
|
|
179
|
+
readLiveState(args: {
|
|
180
|
+
streamId: string;
|
|
181
|
+
cursor?: LiveStateCursor;
|
|
182
|
+
patchVersion?: 2 | 3;
|
|
183
|
+
}): Promise<import("../sdk/capnweb/index.ts").LiveStateRead<Record<string, unknown>>>;
|
|
184
|
+
/** Direct subscriptions retain their callbacks across the Workers RPC hop. */
|
|
185
|
+
liveState(): LiveStateRpc<Record<string, unknown>>;
|
|
186
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { GetProcessorRuntimeState, ProcessorSnapshot, StreamConnectionPing } from "./rpc-types.ts";
|
|
3
|
+
import type { ProcessorContractAnnouncement } from "./processor-contracts.ts";
|
|
4
|
+
import type { EventConsumptionMetrics } from "./event-consumption-metrics.ts";
|
|
5
|
+
import type { ProcessorRuntimeContribution } from "./stream-processor.ts";
|
|
6
|
+
/**
|
|
7
|
+
* The processor surface shared by the Durable Object registry
|
|
8
|
+
* (stream-processor-registry.ts) and the browser host (stream-browser-store.ts):
|
|
9
|
+
* the contract description returned by `wakeStreamProcessor`, the
|
|
10
|
+
* processor-contributed runtime bag, and self-measured event-consumption metrics.
|
|
11
|
+
* Deliberately NOT the drive surface — cursors, snapshots, and delivery live
|
|
12
|
+
* in the StreamProcessorRunner, which reaches the protected hooks through
|
|
13
|
+
* `StreamProcessor.runnerHooks`.
|
|
14
|
+
*/
|
|
15
|
+
export type AnyHostedProcessor = {
|
|
16
|
+
contract: {
|
|
17
|
+
slug: string;
|
|
18
|
+
version: string;
|
|
19
|
+
description: string;
|
|
20
|
+
stateSchema: z.ZodType;
|
|
21
|
+
consumes: readonly string[];
|
|
22
|
+
emits: readonly string[];
|
|
23
|
+
events: Record<string, {
|
|
24
|
+
description?: string;
|
|
25
|
+
payloadSchema?: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
/** The processor-contributed runtime bag; the snapshot half comes from the runner. */
|
|
29
|
+
getRuntimeState(): Promise<ProcessorRuntimeContribution>;
|
|
30
|
+
readonly eventConsumptionMetrics: Pick<EventConsumptionMetrics, "report" | "notePingObserved" | "noteAppendCommitted" | "clearPendingAppends">;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The two live capabilities every processor host hands the stream alongside
|
|
34
|
+
* its event-batch callback, shared by the DO registry and browser runtime so they cannot
|
|
35
|
+
* drift. `getRuntimeState` assembles the published shape from its two honest
|
|
36
|
+
* sources: the SNAPSHOT from the runner (`opts.snapshot` — the cursor owner),
|
|
37
|
+
* the `runtime` bag from the processor, with the self-measured metrics merged
|
|
38
|
+
* in host-side so a subclass override cannot accidentally drop them.
|
|
39
|
+
*/
|
|
40
|
+
export declare function hostRuntimeCapabilities(processor: AnyHostedProcessor, opts: {
|
|
41
|
+
now: () => number;
|
|
42
|
+
/** The driving runner's committed snapshot (`() => runner.snapshot()`). */
|
|
43
|
+
snapshot: () => Promise<ProcessorSnapshot<unknown>>;
|
|
44
|
+
oneWayEstimateMs?: () => number | undefined;
|
|
45
|
+
}): {
|
|
46
|
+
getRuntimeState: GetProcessorRuntimeState;
|
|
47
|
+
ping: StreamConnectionPing;
|
|
48
|
+
};
|
|
49
|
+
/** Serializable processor contract carried by server and browser hosts. */
|
|
50
|
+
export declare function announceContract(contract: {
|
|
51
|
+
slug: string;
|
|
52
|
+
version: string;
|
|
53
|
+
description: string;
|
|
54
|
+
consumes: readonly string[];
|
|
55
|
+
emits: readonly string[];
|
|
56
|
+
events: Record<string, {
|
|
57
|
+
description?: string;
|
|
58
|
+
payloadSchema?: unknown;
|
|
59
|
+
}>;
|
|
60
|
+
}): ProcessorContractAnnouncement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PromptSection = {
|
|
2
|
+
key: string;
|
|
3
|
+
content: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Parse a prompt file's authoring syntax into sections, in file order.
|
|
7
|
+
* Content inside `<section key="x">...</section>` becomes a section with
|
|
8
|
+
* that key; content outside any tag (including a whole untagged file)
|
|
9
|
+
* becomes a section with `fallbackKey` — so an untagged prompt file parses
|
|
10
|
+
* to one section and keeps working unchanged. Throws on malformed authoring
|
|
11
|
+
* (unclosed or nested tags): this runs at append time, where a loud failure
|
|
12
|
+
* beats silently shipping tag soup to a model.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parsePromptSections(input: {
|
|
15
|
+
content: string;
|
|
16
|
+
fallbackKey: string;
|
|
17
|
+
}): PromptSection[];
|