durable-actors 0.4.0 → 0.4.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/README.md CHANGED
@@ -22,7 +22,9 @@ Install Node.js 22.19+, pnpm, and Bun 1.3.9+.
22
22
  npx durable-actors init my-actors
23
23
  cd my-actors
24
24
  pnpm install
25
- pnpm exec durable-actors dev # Run the server locally on your machine
25
+ # Or with npm:
26
+ npm install
27
+ npx durable-actors dev # Run the server locally on your machine
26
28
  ```
27
29
 
28
30
  Running dev will also start a watch, every-time you make a change to an actor and save, metadata changes will be stored automatically.
@@ -32,15 +34,19 @@ Running dev will also start a watch, every-time you make a change to an actor an
32
34
  In your separate application project's directory (ex: node server), install the generator as a development dependency:
33
35
 
34
36
  ```sh
35
- pnpm add -D durable-actors
37
+ pnpm install --save-dev durable-actors
38
+ # Or with npm:
39
+ npm install --save-dev durable-actors
36
40
  ```
37
41
 
38
42
  Local CLI commands and backend clients default to project `local` at `http://127.0.0.1:7100`. No project ID or secret is required, and local authentication is disabled unless you set `DURABLE_ACTORS_SECRET` on the actor server and backend.
39
43
 
44
+ `durable-actors observe` never requires a secret when connecting to `durable-actors dev`, even when application routes use one. The dev runtime binds only to localhost; hosted observability still uses the server's configured authentication.
45
+
40
46
  Then generate your client from the same application directory:
41
47
 
42
48
  ```sh
43
- pnpm exec durable-actors generate
49
+ npx durable-actors generate
44
50
  ```
45
51
 
46
52
  Now you may call your actor and access the state.
@@ -56,7 +62,15 @@ For complete sample applications, see [AI Chat](https://github.com/TerseAI/durab
56
62
 
57
63
  ## Define an Actor
58
64
 
59
- Define and export actors in your actor project’s `src/durable-objects.ts`. For example, a chat history actor:
65
+ Install `ai` in your actor project:
66
+
67
+ ```sh
68
+ pnpm install ai
69
+ # Or with npm:
70
+ npm install ai
71
+ ```
72
+
73
+ Define and export actors in your actor project’s `src/actors.ts`, the default entrypoint loaded by `durable-actors dev`. For example, a chat history actor:
60
74
 
61
75
  ```ts
62
76
  import type { UIMessage } from "ai"
@@ -78,7 +92,7 @@ export class ChatHistory extends Actor {
78
92
 
79
93
  ## Stream from the backend (Express)
80
94
 
81
- After adding `ChatHistory`, rerun `pnpm exec durable-actors generate` in your application and use its generated client:
95
+ After adding `ChatHistory`, rerun `npx durable-actors generate` in your application and use its generated client:
82
96
 
83
97
  ```ts
84
98
  import { openai } from "@ai-sdk/openai"
@@ -1 +1 @@
1
- {"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../../src/cli/control-plane.ts"],"names":[],"mappings":"AAKA,UAAU,sBAAsB;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC;AAED,cAAM,kBAAkB;IAEhB,QAAQ,CAAC,UAAU,EAAE,sBAAsB;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADf,UAAU,EAAE,sBAAsB,EAC1B,OAAO,EAAE,OAAO,KAAK;IAGpC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,kBAAkB,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIvD,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAK/E,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5E,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1E,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,M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AO,CAAC;IAU5E,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAU1E,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAU9E,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;YAUhE,UAAU;IAaxB,OAAO,CAAC,WAAW;YAIL,WAAW;CAwB5B;AAED,iBAAS,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,KAAK,GAAG,kBAAkB,CAEnG;AA0BD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAA;AACvD,YAAY,EAAE,sBAAsB,EAAE,CAAA"}
@@ -9,7 +9,7 @@ class ControlPlaneClient {
9
9
  this.request = request;
10
10
  }
11
11
  async checkConnection() {
12
- await this.requestJson("GET", "/v1/observe/actors", undefined, 10_000);
12
+ await this.requestJson("GET", `${this.projectPath()}/observe/actors`, undefined, 10_000);
13
13
  }
14
14
  registerDeployment(deployment) {
15
15
  return this.requestJson("PUT", `${this.projectPath()}/deployment`, deployment, 150_000);
@@ -18,26 +18,26 @@ class ControlPlaneClient {
18
18
  return this.requestJson("GET", `${this.projectPath()}/deployment/contract`);
19
19
  }
20
20
  listActors() {
21
- return this.requestJson("GET", "/v1/observe/actors");
21
+ return this.requestJson("GET", `${this.projectPath()}/observe/actors`);
22
22
  }
23
23
  async openActorStream(signal) {
24
- return this.openStream("/v1/observe/events", signal);
24
+ return this.openStream(`${this.projectPath()}/observe/events`, signal);
25
25
  }
26
26
  async openRequestStream(signal, after) {
27
27
  const query = after ? `?${new URLSearchParams({ after })}` : "";
28
- return this.openStream(`/v1/observe/requests/events${query}`, signal);
28
+ return this.openStream(`${this.projectPath()}/observe/requests/events${query}`, signal);
29
29
  }
30
30
  listRequests(query, signal) {
31
- return this.requestJson("GET", `/v1/observe/requests${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
31
+ return this.requestJson("GET", `${this.projectPath()}/observe/requests${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
32
32
  }
33
33
  getMetrics(query, signal) {
34
- return this.requestJson("GET", `/v1/observe/metrics${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
34
+ return this.requestJson("GET", `${this.projectPath()}/observe/metrics${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
35
35
  }
36
36
  listQueueWaits(query, signal) {
37
- return this.requestJson("GET", `/v1/observe/queue-waits${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
37
+ return this.requestJson("GET", `${this.projectPath()}/observe/queue-waits${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
38
38
  }
39
39
  listWebSockets(query, signal) {
40
- return this.requestJson("GET", `/v1/observe/websockets${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
40
+ return this.requestJson("GET", `${this.projectPath()}/observe/websockets${query.size ? `?${query}` : ""}`, undefined, 30_000, signal);
41
41
  }
42
42
  async openStream(path, signal) {
43
43
  const response = await this.request(`${this.connection.controlPlaneUrl}${path}`, {
@@ -1 +1 @@
1
- {"version":3,"file":"control-plane.js","sourceRoot":"","sources":["../../src/cli/control-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAQ5C,MAAM,kBAAkB;IAEP;IACQ;IAFrB,YACa,UAAkC,EAC1B,OAAqB;QAD7B,eAAU,GAAV,UAAU,CAAwB;QAC1B,YAAO,GAAP,OAAO,CAAc;IACvC,CAAC;IAEJ,KAAK,CAAC,eAAe;QACjB,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE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,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,GACN,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,sBAAsB,CAAC;YAC3D,CAAC,CAAC,qJAAqJ;YACvJ,CAAC,CAAC,EAAE,CAAA;QACZ,MAAM,IAAI,KAAK,CACX,sCAAsC,QAAQ,CAAC,MAAM,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,IAAI,GAAG,GAAG,IAAI,EAAE,CACpI,CAAA;IACL,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC;AAED,SAAS,YAAY,CAAC,MAAe;IACjC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACnF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;IAC1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAClF,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AACxE,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAA"}
@@ -13,10 +13,11 @@ export declare class HttpActorClient {
13
13
  protected readonly now: () => number;
14
14
  protected readonly monotonicNow: () => number;
15
15
  protected readonly telemetry: TelemetrySink;
16
- protected readonly targets: Map<string, Promise<ActorHostTarget>>;
16
+ protected readonly targets: Map<string, TargetResolution>;
17
17
  constructor(options?: DurableActorsClientOptions, dependencies?: HttpActorClientDependencies);
18
18
  invoke(actorName: string, actorId: string, method: string, args: readonly unknown[]): Promise<unknown>;
19
19
  private direct;
20
+ private invalidateTarget;
20
21
  protected target(invocation: ActorAddress, timeline: LatencyTimeline): Promise<ActorHostTarget>;
21
22
  private resolveTarget;
22
23
  private throwResponseFailure;
@@ -25,6 +26,10 @@ export declare class HttpActorClient {
25
26
  private jsonArguments;
26
27
  }
27
28
  type ActorAddress = Pick<DirectActorInvocation, "requestId" | "projectId" | "actorName" | "actorId">;
29
+ interface TargetResolution {
30
+ readonly promise: Promise<ActorHostTarget>;
31
+ target?: ActorHostTarget;
32
+ }
28
33
  type RemoteActorSettings = ReturnType<typeof configuredSettings>;
29
34
  export interface HttpActorClientDependencies {
30
35
  readonly environment?: Environment;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client-runtime/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAG3F,OAAO,EAEH,kBAAkB,EAMrB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAInD,qBAAa,eAAe;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAC1D,OAAO,CAAC,aAAa,CAAiC;IACtD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IAC3C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IACxD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,MAAM,CAAA;IAC1C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAA;IAChD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAA;IACpC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,MAAM,CAAA;IA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IA4CpB,OAAO,CAAC,gBAAgB;cAMR,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;YAyBvF,aAAa;IA0C3B,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,UAAU;IAiBlB,SAAS,KAAK,QAAQ,IAAI,mBAAmB,CAI5C;IAED,OAAO,CAAC,aAAa;CAKxB;AAcD,KAAK,YAAY,GAAG,IAAI,CAAC,qBAAqB,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC,CAAA;AACpG,UAAU,gBAAgB;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAC1C,MAAM,CAAC,EAAE,eAAe,CAAA;CAC3B;AACD,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAChE,MAAM,WAAW,2BAA2B;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAA;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,MAAM,CAAA;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAA;IACvC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAA;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAA;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;CACtD;AACD,YAAY,EAAE,0BAA0B,EAAE,CAAA"}
@@ -53,7 +53,7 @@ export class HttpActorClient {
53
53
  });
54
54
  }
55
55
  }
56
- async direct(target, invocation, retryReroute, timeline) {
56
+ async direct(target, invocation, retryAvailable, timeline) {
57
57
  try {
58
58
  const reply = await this.actorHost.invoke(target, invocation);
59
59
  timeline.mark("host_rpc_completed");
@@ -63,40 +63,57 @@ export class HttpActorClient {
63
63
  }
64
64
  if (reply.type === "failed")
65
65
  throw new ActorInvocationError(reply.code, invocation.requestId, reply.message);
66
- if (reply.type === "unauthenticated" && !retryReroute) {
67
- this.targets.delete(actorKey(invocation.actorName, invocation.actorId));
66
+ this.invalidateTarget(invocation, target);
67
+ if (reply.type === "unauthenticated" && !retryAvailable) {
68
68
  throw new ActorInvocationError("unauthenticated", invocation.requestId, "actor host rejected the refreshed invocation ticket");
69
69
  }
70
- if (!retryReroute)
71
- throw new ActorInvocationError("unavailable", invocation.requestId, "actor ownership changed repeatedly before execution");
72
- this.targets.delete(actorKey(invocation.actorName, invocation.actorId));
70
+ if (!retryAvailable)
71
+ throw new ActorInvocationError("unavailable", invocation.requestId, reply.type === "not_dispatched"
72
+ ? "actor host could not be reached before execution"
73
+ : "actor ownership changed repeatedly before execution");
73
74
  const rerouted = await this.target(invocation, timeline);
74
75
  return this.direct(rerouted, invocation, false, timeline);
75
76
  }
76
77
  catch (error) {
77
78
  if (error instanceof ActorInvocationError || error instanceof ActorProtocolError)
78
79
  throw error;
79
- this.targets.delete(actorKey(invocation.actorName, invocation.actorId));
80
+ this.invalidateTarget(invocation, target);
80
81
  const message = error instanceof Error ? error.message : String(error);
81
82
  throw new ActorInvocationError("outcome_unknown", invocation.requestId, `actor-host HTTP request failed after dispatch: ${message}`);
82
83
  }
83
84
  }
85
+ invalidateTarget(invocation, target) {
86
+ const key = actorKey(invocation.actorName, invocation.actorId);
87
+ const current = this.targets.get(key);
88
+ if (current?.target === target)
89
+ this.targets.delete(key);
90
+ }
84
91
  async target(invocation, timeline) {
85
92
  const key = actorKey(invocation.actorName, invocation.actorId);
86
93
  const current = this.targets.get(key);
87
94
  timeline.mark("target_cache_checked");
88
95
  if (current) {
89
- const target = await current;
96
+ const target = await current.promise;
97
+ if (this.targets.get(key) !== current)
98
+ return this.target(invocation, timeline);
90
99
  if (target.expiresAtMs > this.now() + TARGET_EXPIRATION_SAFETY_MS)
91
100
  return target;
92
101
  this.targets.delete(key);
93
102
  }
94
- const resolving = this.resolveTarget(invocation).catch(error => {
95
- this.targets.delete(key);
96
- throw error;
97
- });
103
+ const resolving = {
104
+ promise: this.resolveTarget(invocation)
105
+ .then(target => {
106
+ resolving.target = target;
107
+ return target;
108
+ })
109
+ .catch(error => {
110
+ if (this.targets.get(key) === resolving)
111
+ this.targets.delete(key);
112
+ throw error;
113
+ })
114
+ };
98
115
  this.targets.set(key, resolving);
99
- return resolving;
116
+ return resolving.promise;
100
117
  }
101
118
  async resolveTarget(invocation) {
102
119
  let response;
@@ -115,7 +132,7 @@ export class HttpActorClient {
115
132
  }
116
133
  catch (error) {
117
134
  const message = error instanceof Error ? error.message : String(error);
118
- throw new ActorInvocationError("outcome_unknown", invocation.requestId, `control-plane HTTP request failed before dispatch: ${message}`);
135
+ throw new ActorInvocationError("unavailable", invocation.requestId, `control-plane HTTP request failed before dispatch: ${message}`);
119
136
  }
120
137
  const document = await responseDocument(response);
121
138
  if (!response.ok)
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client-runtime/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACjB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGhD,MAAM,2BAA2B,GAAG,KAAK,CAAA;AAEzC,MAAM,OAAO,eAAe;IACP,YAAY,CAA6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AK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAA;AAChF,CAAC"}
@@ -35,6 +35,8 @@ export type ActorHostReply = {
35
35
  readonly type: "reroute";
36
36
  } | {
37
37
  readonly type: "unauthenticated";
38
+ } | {
39
+ readonly type: "not_dispatched";
38
40
  };
39
41
  export interface ActorHostTransport {
40
42
  invoke(target: ActorHostTarget, invocation: DirectActorInvocation): Promise<ActorHostReply>;
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/client-runtime/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAG1C,qBAAa,sBAAuB,YAAW,kBAAkB;IACjD,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,GAAE,OAAO,UAAU,CAAC,KAAwB;IAE/E,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IA0B3F,OAAO,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvG,OAAO,CAAC,IAAI;CAef;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAM3E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAC3B;AACD,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,C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IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAA;AACzC,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAC3F,OAAO,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpG"}
@@ -6,12 +6,20 @@ export class HttpActorHostTransport {
6
6
  this.fetchRequest = fetchRequest;
7
7
  }
8
8
  async invoke(target, invocation) {
9
- const response = await this.post(target, invocation, "invoke", {
10
- requestId: invocation.requestId,
11
- ownerEpoch: target.ownerEpoch,
12
- method: invocation.method,
13
- args: invocation.args
14
- });
9
+ let response;
10
+ try {
11
+ response = await this.post(target, invocation, "invoke", {
12
+ requestId: invocation.requestId,
13
+ ownerEpoch: target.ownerEpoch,
14
+ method: invocation.method,
15
+ args: invocation.args
16
+ });
17
+ }
18
+ catch (error) {
19
+ if (connectionRefused(error))
20
+ return { type: "not_dispatched" };
21
+ throw error;
22
+ }
15
23
  // A 401 is issued before dispatch, so refreshing this ticket cannot repeat actor code.
16
24
  if (response.status === 401)
17
25
  return { type: "unauthenticated" };
@@ -49,6 +57,20 @@ export class HttpActorHostTransport {
49
57
  });
50
58
  }
51
59
  }
60
+ function connectionRefused(error, ancestors = new Set()) {
61
+ if (!isRecord(error) || ancestors.has(error))
62
+ return false;
63
+ const visited = new Set(ancestors).add(error);
64
+ if (error.code !== undefined && error.code !== "ECONNREFUSED")
65
+ return false;
66
+ if (error.errors !== undefined)
67
+ return (Array.isArray(error.errors) &&
68
+ error.errors.length > 0 &&
69
+ error.errors.every(cause => connectionRefused(cause, visited)));
70
+ if (error.code === "ECONNREFUSED")
71
+ return error.syscall === "connect";
72
+ return connectionRefused(error.cause, visited);
73
+ }
52
74
  export async function responseDocument(response) {
53
75
  try {
54
76
  return await response.json();
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/client-runtime/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEhE,MAAM,OAAO,sBAAsB;IACF;IAA7B,YAA6B,eAAwC,UAAU,CAAC,KAAK;QAAxD,iBAAY,GAAZ,YAAY,CAA4C;IAAG,CAAC;IAEzF,KAAK,CAAC,MAAM,CAAC,MAAuB,EAAE,UAAiC;QACnE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE;YAC3D,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,IAAI,EAAE,UAAU,CAAC,IAAI;SACxB,CAAC,CAAA;QACF,uFAAuF;QACvF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAA;QAC/D,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAChF,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAA;QAC9C,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC;gBAC5D,OAAO,EAAE,IAAI,EAAE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AI,KAAK,CAAC,MAAM,KAAK,SAAS;QAC1B,OAAO,CACH,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;YAC3B,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YACvB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CACjE,CAAA;IACL,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc;QAAE,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS,CAAA;IACrE,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAkB;IACrD,IAAI,CAAC;QACD,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAAC,QAAQ,QAAQ,CAAC,MAAM,8BAA8B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACzG,CAAC;AACL,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"client-runtime.d.ts","sourceRoot":"","sources":["../../src/generated/client-runtime.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAA6gkC,CAAA"}
1
+ {"version":3,"file":"client-runtime.d.ts","sourceRoot":"","sources":["../../src/generated/client-runtime.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAA0onC,CAAA"}
@@ -1,2 +1,2 @@
1
- export const runtimeFiles = { "runtime/client.ts": "import { ActorInvocationError, ActorProtocolError } from \"./errors.js\"\nimport { HttpActorHostTransport, isRecord, responseDocument } from \"./http.js\"\nimport type { ActorHostTarget, ActorHostTransport, DirectActorInvocation } from \"./http.js\"\nimport { cloneJson } from \"./json.js\"\nimport type { JsonValue } from \"./json.js\"\nimport {\n authorizationHeaders,\n configuredSettings,\n environmentSettings,\n projectActorPath,\n runtimeEnvironment,\n validateActorComponent,\n validateOrigin\n} from \"./settings.js\"\nimport type { DurableActorsClientOptions, Environment } from \"./settings.js\"\nimport { LatencyTimeline } from \"./telemetry.js\"\nimport type { TelemetrySink } from \"./telemetry.js\"\n\nconst TARGET_EXPIRATION_SAFETY_MS = 5_000\n\nexport class HttpActorClient {\n private readonly beforeInvoke: (requestId: string) => void\n private settingsValue: RemoteActorSettings | undefined\n protected readonly environment: Environment\n protected readonly fetchRequest: typeof globalThis.fetch\n protected readonly requestId: () => string\n protected readonly actorHost: ActorHostTransport\n protected readonly now: () => number\n protected readonly monotonicNow: () => number\n protected readonly telemetry: TelemetrySink\n protected readonly targets = new Map<string, Promise<ActorHostTarget>>()\n\n constructor(options?: DurableActorsClientOptions, dependencies: HttpActorClientDependencies = {}) {\n this.beforeInvoke = dependencies.beforeInvoke ?? (() => {})\n this.environment = dependencies.environment ?? runtimeEnvironment()\n this.fetchRequest = dependencies.fetch ?? globalThis.fetch\n this.requestId = dependencies.requestId ?? (() => globalThis.crypto.randomUUID())\n this.actorHost = dependencies.actorHost ?? new HttpActorHostTransport(this.fetchRequest)\n // Workflow runtimes can replace Date.now with replayable logical time.\n this.now = dependencies.now ?? (() => performance.timeOrigin + performance.now())\n this.monotonicNow = dependencies.monotonicNow ?? (() => performance.now())\n this.telemetry = dependencies.telemetry ?? (() => {})\n this.settingsValue = options === undefined ? undefined : configuredSettings(options)\n }\n\n async invoke(actorName: string, actorId: string, method: string, args: readonly unknown[]): Promise<unknown> {\n const requestId = validateActorComponent(\"request ID\", this.requestId())\n const timeline = new LatencyTimeline(this.monotonicNow)\n let outcome = \"failed\"\n try {\n this.beforeInvoke(requestId)\n const invocation = this.invocation(requestId, actorName, actorId, method, args)\n timeline.mark(\"invocation_built\")\n const target = await this.target(invocation, timeline)\n timeline.mark(\"target_resolved\")\n const result = await this.direct(target, invocation, true, timeline)\n outcome = \"completed\"\n return result\n } finally {\n this.telemetry({\n event: \"actor_client_invocation\",\n request_id: requestId,\n actor_name: actorName,\n actor_id: actorId,\n method,\n ...timeline.finish(),\n outcome\n })\n }\n }\n\n private async direct(\n target: ActorHostTarget,\n invocation: DirectActorInvocation,\n retryReroute: boolean,\n timeline: LatencyTimeline\n ): Promise<unknown> {\n try {\n const reply = await this.actorHost.invoke(target, invocation)\n timeline.mark(\"host_rpc_completed\")\n if (reply.type === \"completed\") {\n timeline.mark(\"socket_effects_completed\")\n return reply.result\n }\n if (reply.type === \"failed\") throw new ActorInvocationError(reply.code, invocation.requestId, reply.message)\n if (reply.type === \"unauthenticated\" && !retryReroute) {\n this.targets.delete(actorKey(invocation.actorName, invocation.actorId))\n throw new ActorInvocationError(\n \"unauthenticated\",\n invocation.requestId,\n \"actor host rejected the refreshed invocation ticket\"\n )\n }\n if (!retryReroute)\n throw new ActorInvocationError(\n \"unavailable\",\n invocation.requestId,\n \"actor ownership changed repeatedly before execution\"\n )\n this.targets.delete(actorKey(invocation.actorName, invocation.actorId))\n const rerouted = await this.target(invocation, timeline)\n return this.direct(rerouted, invocation, false, timeline)\n } catch (error) {\n if (error instanceof ActorInvocationError || error instanceof ActorProtocolError) throw error\n this.targets.delete(actorKey(invocation.actorName, invocation.actorId))\n const message = error instanceof Error ? error.message : String(error)\n throw new ActorInvocationError(\n \"outcome_unknown\",\n invocation.requestId,\n `actor-host HTTP request failed after dispatch: ${message}`\n )\n }\n }\n\n protected async target(invocation: ActorAddress, timeline: LatencyTimeline): Promise<ActorHostTarget> {\n const key = actorKey(invocation.actorName, invocation.actorId)\n const current = this.targets.get(key)\n timeline.mark(\"target_cache_checked\")\n if (current) {\n const target = await current\n if (target.expiresAtMs > this.now() + TARGET_EXPIRATION_SAFETY_MS) return target\n this.targets.delete(key)\n }\n const resolving = this.resolveTarget(invocation).catch(error => {\n this.targets.delete(key)\n throw error\n })\n this.targets.set(key, resolving)\n return resolving\n }\n\n private async resolveTarget(invocation: ActorAddress): Promise<ActorHostTarget> {\n let response: Response\n try {\n response = await this.fetchRequest(targetUrl(this.settings, invocation.actorName, invocation.actorId), {\n method: \"POST\",\n redirect: \"error\",\n headers: {\n accept: \"application/json\",\n ...authorizationHeaders(this.settings.credential),\n \"x-request-id\": invocation.requestId,\n \"content-type\": \"application/json\"\n },\n body: JSON.stringify({ homeRegion: this.settings.homeRegion })\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new ActorInvocationError(\n \"outcome_unknown\",\n invocation.requestId,\n `control-plane HTTP request failed before dispatch: ${message}`\n )\n }\n const document = await responseDocument(response)\n if (!response.ok) this.throwResponseFailure(response, document, invocation.requestId)\n if (\n !isRecord(document) ||\n typeof document.route !== \"string\" ||\n typeof document.token !== \"string\" ||\n !document.token.trim() ||\n !positiveInteger(document.ownerEpoch) ||\n !positiveInteger(document.expiresAtMs)\n )\n throw new ActorProtocolError(\"control-plane response did not contain a valid actor host target\")\n validateOrigin(document.route)\n return {\n route: document.route,\n token: document.token,\n ownerEpoch: document.ownerEpoch,\n expiresAtMs: document.expiresAtMs\n }\n }\n\n private throwResponseFailure(response: Response, document: unknown, requestId: string): never {\n if (response.status === 401 || response.status === 403)\n throw new ActorInvocationError(\n \"unauthenticated\",\n requestId,\n \"the durable-actors application credential was rejected\"\n )\n const failure = isRecord(document) ? document.error : undefined\n if (\n !isRecord(failure) ||\n typeof failure.code !== \"string\" ||\n !failure.code ||\n typeof failure.message !== \"string\"\n )\n throw new ActorProtocolError(`control-plane HTTP ${response.status} response did not contain a valid error`)\n throw new ActorInvocationError(\n failure.code,\n typeof failure.requestId === \"string\" ? failure.requestId : requestId,\n failure.message\n )\n }\n\n private invocation(\n requestId: string,\n actorName: string,\n actorId: string,\n method: string,\n args: readonly unknown[]\n ): DirectActorInvocation {\n return {\n requestId,\n projectId: this.settings.projectId,\n actorName: validateActorComponent(\"actor name\", actorName),\n actorId: validateActorComponent(\"actor ID\", actorId),\n method: validateActorComponent(\"actor method\", method),\n args: this.jsonArguments(args)\n }\n }\n\n protected get settings(): RemoteActorSettings {\n if (this.settingsValue !== undefined) return this.settingsValue\n this.settingsValue = configuredSettings(environmentSettings(this.environment))\n return this.settingsValue\n }\n\n private jsonArguments(args: readonly unknown[]): readonly JsonValue[] {\n const value = cloneJson(args, \"actor arguments\")\n if (!Array.isArray(value)) throw new ActorProtocolError(\"actor arguments must be a JSON array\")\n return value\n }\n}\n\nfunction targetUrl(settings: RemoteActorSettings, actorName: string, actorId: string): string {\n const actor = validateActorComponent(\"actor name\", actorName)\n const id = validateActorComponent(\"actor ID\", actorId)\n return `${settings.controlPlaneUrl}${projectActorPath(settings.projectId, actor, id)}/find-actor`\n}\n\nfunction actorKey(actorName: string, actorId: string): string {\n return `${actorName}\\u001f${actorId}`\n}\nfunction positiveInteger(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0\n}\ntype ActorAddress = Pick<DirectActorInvocation, \"requestId\" | \"projectId\" | \"actorName\" | \"actorId\">\ntype RemoteActorSettings = ReturnType<typeof configuredSettings>\nexport interface HttpActorClientDependencies {\n readonly environment?: Environment\n readonly fetch?: typeof globalThis.fetch\n readonly requestId?: () => string\n readonly actorHost?: ActorHostTransport\n readonly now?: () => number\n readonly monotonicNow?: () => number\n readonly telemetry?: TelemetrySink\n readonly beforeInvoke?: (requestId: string) => void\n}\nexport type { DurableActorsClientOptions }\n", "runtime/errors.ts": "class ActorConfigurationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorConfigurationError\"\n }\n}\n\nclass ActorDefinitionError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"ActorDefinitionError\"\n }\n}\n\n/** Remote failure. Retrying an `outcome_unknown` operation may run it twice. */\nclass ActorInvocationError extends Error {\n /** Error category, such as `actor_error` or `outcome_unknown`. New codes may be added. */\n readonly code: string\n /** Identifies this caller attempt; it is not an application idempotency key. */\n readonly requestId: string\n\n constructor(code: string, requestId: string, message: string) {\n super(message)\n this.name = \"ActorInvocationError\"\n this.code = code\n this.requestId = requestId\n }\n}\n\nclass ActorSessionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorSessionError\"\n }\n}\n\nclass ActorProtocolError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorProtocolError\"\n }\n}\n\nclass ActorSerializationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorSerializationError\"\n }\n}\n\nclass ActorValidationError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"ActorValidationError\"\n }\n}\n\nexport {\n ActorConfigurationError,\n ActorDefinitionError,\n ActorInvocationError,\n ActorProtocolError,\n ActorSerializationError,\n ActorSessionError,\n ActorValidationError\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\nexport { errorMessage }\n", "runtime/http.ts": "import { ActorProtocolError } from \"./errors.js\"\nimport type { JsonValue } from \"./json.js\"\nimport { projectActorPath, validateOrigin } from \"./settings.js\"\n\nexport class HttpActorHostTransport implements ActorHostTransport {\n constructor(private readonly fetchRequest: typeof globalThis.fetch = globalThis.fetch) {}\n\n async invoke(target: ActorHostTarget, invocation: DirectActorInvocation): Promise<ActorHostReply> {\n const response = await this.post(target, invocation, \"invoke\", {\n requestId: invocation.requestId,\n ownerEpoch: target.ownerEpoch,\n method: invocation.method,\n args: invocation.args\n })\n // A 401 is issued before dispatch, so refreshing this ticket cannot repeat actor code.\n if (response.status === 401) return { type: \"unauthenticated\" }\n if (!response.ok) throw new Error(`actor host returned HTTP ${response.status}`)\n const reply = await responseDocument(response)\n if (isRecord(reply)) {\n if (reply.type === \"completed\" && Object.hasOwn(reply, \"result\"))\n return { type: \"completed\", result: reply.result }\n if (\n reply.type === \"failed\" &&\n typeof reply.code === \"string\" &&\n reply.code.length > 0 &&\n typeof reply.message === \"string\"\n )\n return { type: \"failed\", code: reply.code, message: reply.message }\n if (reply.type === \"reroute\") return { type: \"reroute\" }\n }\n throw new ActorProtocolError(\"actor host response did not contain a valid outcome\")\n }\n\n async publish(target: ActorHostTarget, actor: ActorAddress, effects: readonly unknown[]): Promise<void> {\n const response = await this.post(target, actor, \"socket-effects\", { ownerEpoch: target.ownerEpoch, effects })\n if (!response.ok) throw new Error(`socket effects returned HTTP ${response.status}`)\n }\n\n private post(target: ActorHostTarget, actor: ActorAddress, endpoint: string, body: unknown): Promise<Response> {\n return this.fetchRequest(\n `${validateOrigin(target.route)}${projectActorPath(actor.projectId, actor.actorName, actor.actorId)}/${endpoint}`,\n {\n method: \"POST\",\n redirect: \"error\",\n headers: {\n authorization: `Bearer ${target.token}`,\n \"content-type\": \"application/json\",\n accept: \"application/json\"\n },\n body: JSON.stringify(body)\n }\n )\n }\n}\n\nexport async function responseDocument(response: Response): Promise<unknown> {\n try {\n return await response.json()\n } catch (error) {\n throw new ActorProtocolError(`HTTP ${response.status} response was not valid JSON`, { cause: error })\n }\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nexport interface ActorAddress {\n readonly projectId: string\n readonly actorName: string\n readonly actorId: string\n}\nexport interface ActorHostTarget {\n readonly route: string\n readonly token: string\n readonly ownerEpoch: number\n readonly expiresAtMs: number\n}\nexport interface DirectActorInvocation extends ActorAddress {\n readonly requestId: string\n readonly method: string\n readonly args: readonly JsonValue[]\n}\nexport type ActorHostReply =\n | { readonly type: \"completed\"; readonly result: unknown }\n | { readonly type: \"failed\"; readonly code: string; readonly message: string }\n | { readonly type: \"reroute\" }\n | { readonly type: \"unauthenticated\" }\nexport interface ActorHostTransport {\n invoke(target: ActorHostTarget, invocation: DirectActorInvocation): Promise<ActorHostReply>\n publish(target: ActorHostTarget, actor: ActorAddress, effects: readonly unknown[]): Promise<void>\n}\n", "runtime/index.browser.ts": "import type { SocketProxy as ServerProxy } from \"./proxy.js\"\nimport type { createActorStub as ServerStub, createActorTransport as ServerTransport } from \"./stub.js\"\n\nconst createActorStub: typeof ServerStub = () => {\n throw new Error(\"actors must be used on the server\")\n}\n\nconst createActorTransport: typeof ServerTransport = () => {\n throw new Error(\"actors must be used on the server\")\n}\n\nconst SocketProxy = class {\n constructor() {\n throw new Error(\"ActorProxy must be used on the server\")\n }\n} as unknown as typeof ServerProxy\n\nexport { createActorStub, createActorTransport, SocketProxy }\nexport { ActorInvocationError } from \"./errors.js\"\n", "runtime/index.ts": "export { createActorStub, createActorTransport } from \"./stub.js\"\nexport type { ActorRpcTransport, DurableActorsClientOptions } from \"./stub.js\"\nexport { ActorInvocationError } from \"./errors.js\"\nexport { SocketProxy } from \"./proxy.js\"\nexport type { ProxyActor, SocketGrant, SocketProxyDependencies, SocketProxyOptions } from \"./proxy.js\"\n", "runtime/json.ts": "import { ActorSerializationError } from \"./errors.js\"\n\ntype JsonPrimitive = string | number | boolean | null\ntype JsonObject = { readonly [key: string]: JsonValue }\ntype JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[]\n\nfunction cloneJson(value: unknown, label: string): JsonValue {\n try {\n const encoded = JSON.stringify(value)\n if (encoded === undefined) throw new ActorSerializationError(`${label} must be JSON serializable`)\n return JSON.parse(encoded) as JsonValue\n } catch (error) {\n if (error instanceof ActorSerializationError) throw error\n throw new ActorSerializationError(`${label} must be JSON serializable`, { cause: error })\n }\n}\n\nexport { cloneJson }\nexport type { JsonValue }\n", "runtime/proxy.ts": "import { ActorProtocolError, ActorSerializationError, ActorValidationError } from \"./errors.js\"\nimport { isRecord } from \"./http.js\"\nimport {\n authorizationHeaders,\n configuredSettings,\n environmentSettings,\n projectActorPath,\n validateActorComponent\n} from \"./settings.js\"\n\n/** Overrides for the backend's DURABLE_ACTORS environment settings. */\ninterface SocketProxyOptions {\n readonly projectId?: string\n readonly controlPlaneUrl?: string\n readonly apiKey?: string\n /** Defaults to 180000 ms; accepts 1000–600000 ms. */\n readonly setupTimeoutMs?: number\n}\n\ninterface SocketProxyDependencies {\n readonly fetch?: typeof globalThis.fetch\n}\n\ninterface ProxyActor<Metadata = unknown> {\n readonly types?: Metadata\n}\n\n/** Actor access your backend has already authorized. */\ntype SocketAuthorization<Actors extends Record<string, ProxyActor>> = {\n [Name in keyof Actors & string]: {\n readonly actorName: Name\n readonly actorId: string\n readonly metadata: Actors[Name] extends ProxyActor<infer Metadata> ? Metadata : never\n readonly homeRegion?: string\n readonly authorizationLifetimeMs?: number\n }\n}[keyof Actors & string]\n\n/** Browser connection URL and deadlines in Unix milliseconds. Treat the URL as a credential. */\ninterface SocketGrant {\n websocketUrl: string\n homeRegion: string\n connectByMs: number\n authorizedUntilMs: number\n}\n\n/** Issues browser connection URLs from your backend. */\nclass SocketProxy<Actors extends Record<string, ProxyActor>> {\n private readonly projectId: string\n private readonly origin: string\n private readonly apiKey: string | undefined\n private readonly setupTimeoutMs: number\n private readonly fetchRequest: typeof globalThis.fetch\n\n constructor(\n private readonly actors: Actors,\n options: SocketProxyOptions = {},\n dependencies: SocketProxyDependencies = {}\n ) {\n this.setupTimeoutMs = options.setupTimeoutMs ?? 180000\n if (!Number.isSafeInteger(this.setupTimeoutMs) || this.setupTimeoutMs < 1000 || this.setupTimeoutMs > 600000)\n throw new Error(\"Socket setup timeout must be between one second and ten minutes\")\n const settings = configuredSettings(proxySettings(options))\n this.origin = settings.controlPlaneUrl\n this.apiKey = settings.credential\n this.projectId = settings.projectId\n this.fetchRequest = dependencies.fetch ?? globalThis.fetch\n }\n\n /**\n * Call after authenticating the user and checking actor access.\n * Pass `websocketUrl` to the browser's `new WebSocket()`.\n */\n async handle(authorization: SocketAuthorization<Actors>): Promise<SocketGrant> {\n const actorName = validateActorComponent(\"actor name\", authorization.actorName)\n const actorId = validateActorComponent(\"actor ID\", authorization.actorId)\n if (!Object.hasOwn(this.actors, actorName)) throw new Error(`Unknown actor name: ${actorName}`)\n const metadata = socketMetadata(authorization.metadata)\n const authorizationLifetimeMs = authorization.authorizationLifetimeMs ?? 900000\n if (\n !Number.isSafeInteger(authorizationLifetimeMs) ||\n authorizationLifetimeMs < 1000 ||\n authorizationLifetimeMs > 86400000\n )\n throw new Error(\"Socket authorization lifetime must be between one second and one day\")\n const homeRegion =\n authorization.homeRegion === undefined\n ? undefined\n : validateActorComponent(\"home region\", authorization.homeRegion)\n const response = await this.fetchRequest(\n `${this.origin}${projectActorPath(this.projectId, actorName, actorId)}/find-websocket`,\n {\n method: \"POST\",\n redirect: \"error\",\n headers: { ...authorizationHeaders(this.apiKey), \"content-type\": \"application/json\" },\n body: JSON.stringify({ metadata, authorizationLifetimeMs, homeRegion }),\n signal: AbortSignal.timeout(this.setupTimeoutMs)\n }\n )\n if (!response.ok) throw new Error(`WebSocket authorization could not be issued (HTTP ${response.status})`)\n return socketGrant(await response.json())\n }\n}\n\nfunction proxySettings(options: SocketProxyOptions) {\n const environment = environmentSettings()\n const controlPlaneUrl = options.controlPlaneUrl ?? environment.controlPlaneUrl\n const apiKey = options.apiKey ?? environment.apiKey\n return {\n projectId: options.projectId ?? environment.projectId,\n controlPlaneUrl: controlPlaneUrl ?? \"http://127.0.0.1:7100\",\n apiKey\n }\n}\n\nexport { SocketProxy }\nexport type { ProxyActor, SocketAuthorization, SocketGrant, SocketProxyDependencies, SocketProxyOptions }\n\nfunction socketGrant(value: unknown): SocketGrant {\n if (\n !isRecord(value) ||\n typeof value.websocketUrl !== \"string\" ||\n !URL.canParse(value.websocketUrl) ||\n !/^wss?:$/u.test(new URL(value.websocketUrl).protocol) ||\n typeof value.homeRegion !== \"string\" ||\n !value.homeRegion ||\n !Number.isSafeInteger(value.connectByMs) ||\n !Number.isSafeInteger(value.authorizedUntilMs)\n )\n throw new ActorProtocolError(\"invalid WebSocket authorization response\")\n return {\n websocketUrl: value.websocketUrl,\n homeRegion: value.homeRegion,\n connectByMs: value.connectByMs as number,\n authorizedUntilMs: value.authorizedUntilMs as number\n }\n}\n\nfunction socketMetadata(value: unknown): unknown {\n let encoded: string\n try {\n encoded = JSON.stringify(value)\n if (!isJsonValue(value)) throw new Error(\"invalid JSON value\")\n } catch (error) {\n throw new ActorSerializationError(\"socket metadata must be a JSON value\", { cause: error })\n }\n if (new TextEncoder().encode(encoded).length > 64 * 1024)\n throw new ActorValidationError(\"socket metadata exceeds 65536 bytes\")\n return value\n}\n\nfunction isJsonValue(value: unknown): boolean {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true\n if (typeof value === \"number\") return Number.isFinite(value)\n if (Array.isArray(value)) return Array.from(value).every(isJsonValue)\n return (\n isRecord(value) &&\n [Object.prototype, null].includes(Object.getPrototypeOf(value)) &&\n Object.values(value).every(isJsonValue)\n )\n}\n", "runtime/settings.ts": "import { ActorConfigurationError, ActorValidationError } from \"./errors.js\"\n\nexport interface DurableActorsClientOptions {\n readonly projectId?: string\n readonly apiKey?: string\n readonly homeRegion?: string\n readonly controlPlaneUrl: string\n}\n\nexport type Environment = Record<string, string | undefined>\n\nexport function configuredSettings(value: unknown) {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n Object.keys(value).some(key => ![\"projectId\", \"apiKey\", \"homeRegion\", \"controlPlaneUrl\"].includes(key))\n )\n throw new ActorConfigurationError(\"durable-actors client settings are invalid\")\n const options = value as DurableActorsClientOptions\n const controlPlaneUrl = validateOrigin(options.controlPlaneUrl)\n const local = [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(new URL(controlPlaneUrl).hostname)\n const projectId = options.projectId ?? (local ? \"local\" : undefined)\n if (typeof projectId !== \"string\" || !/^[A-Za-z0-9._-]{1,64}$/u.test(projectId) || [\".\", \"..\"].includes(projectId))\n throw new ActorConfigurationError(\n \"durable-actors client settings are invalid: a valid projectId is required for remote connections\"\n )\n if (options.apiKey !== undefined && (typeof options.apiKey !== \"string\" || !options.apiKey.trim()))\n throw new ActorConfigurationError(\"durable-actors client settings are invalid: apiKey must not be empty\")\n if (options.homeRegion !== undefined) validateActorComponent(\"home region\", options.homeRegion)\n return { projectId, credential: options.apiKey?.trim(), homeRegion: options.homeRegion, controlPlaneUrl }\n}\n\nexport function environmentSettings(environment: Environment = runtimeEnvironment()): DurableActorsClientOptions {\n return {\n projectId: environment.DURABLE_ACTORS_PROJECT_ID,\n apiKey: environment.DURABLE_ACTORS_SECRET ?? environment.DURABLE_ACTORS_API_KEY,\n homeRegion: environment.DURABLE_ACTORS_HOME_REGION,\n controlPlaneUrl: environment.DURABLE_ACTORS_CONTROL_PLANE_URL ?? \"http://127.0.0.1:7100\"\n }\n}\n\nexport function runtimeEnvironment(): Environment {\n return (globalThis as typeof globalThis & { process?: { env?: Environment } }).process?.env ?? {}\n}\n\nexport function validateOrigin(origin: string): string {\n let url: URL\n try {\n url = new URL(origin)\n } catch (error) {\n throw new ActorConfigurationError(`actor HTTP origin is invalid: ${origin}`, { cause: error })\n }\n if (\n !/^https?:$/u.test(url.protocol) ||\n !url.hostname ||\n url.username ||\n url.password ||\n url.pathname !== \"/\" ||\n url.search ||\n url.hash\n )\n throw new ActorConfigurationError(`actor URL must be an HTTP or HTTPS origin: ${origin}`)\n return url.origin\n}\n\nexport function validateActorComponent(name: string, value: string): string {\n if (typeof value !== \"string\" || !/^[A-Za-z0-9._-]+$/u.test(value) || value === \".\" || value === \"..\")\n throw new ActorValidationError(\n `${name} may contain only ASCII letters, digits, '.', '-', and '_' and must not be a path segment`\n )\n return value\n}\n\nexport function projectActorPath(projectId: string, actorName: string, actorId: string): string {\n return `/v1/projects/${encodeURIComponent(validateActorComponent(\"project ID\", projectId))}/actors/${encodeURIComponent(validateActorComponent(\"actor name\", actorName))}/${encodeURIComponent(validateActorComponent(\"actor ID\", actorId))}`\n}\n\nexport function authorizationHeaders(credential: string | undefined): Record<string, string> {\n return credential === undefined ? {} : { authorization: `Bearer ${credential}` }\n}\n", "runtime/stub.ts": "import { HttpActorClient } from \"./client.js\"\nimport { ActorDefinitionError, ActorSerializationError } from \"./errors.js\"\nimport { validateActorComponent } from \"./settings.js\"\nimport type { DurableActorsClientOptions } from \"./settings.js\"\n\ninterface ActorRpcTransport {\n invoke(actorName: string, actorId: string, method: string, args: readonly unknown[]): Promise<unknown>\n}\n\ninterface ActorRpcMethod {\n readonly name: string\n readonly result: \"void\" | \"value\"\n}\n\n/** Creates a backend client from generated method definitions. */\nfunction createActorStub<Stub extends object>(\n actorName: string,\n actorId: string,\n methods: readonly ActorRpcMethod[],\n transport?: ActorRpcTransport\n): Stub {\n validateActorComponent(\"actor name\", actorName)\n validateActorComponent(\"actor ID\", actorId)\n const stub = Object.create(null)\n for (const method of methods) {\n validateActorComponent(\"actor method\", method.name)\n if ([\"then\", \"connect\", \"broadcast\", \"onConnect\", \"onMessage\", \"onDisconnect\"].includes(method.name))\n throw new ActorDefinitionError(`actor method ${actorName}.${method.name} is reserved`)\n if (Object.hasOwn(stub, method.name))\n throw new ActorDefinitionError(`duplicate actor method ${actorName}.${method.name}`)\n Object.defineProperty(stub, method.name, {\n enumerable: true,\n value: async (...args: unknown[]) => {\n const parameters = invocationArguments(args)\n const client = transport ?? defaultTransport()\n const result = await client.invoke(actorName, actorId, method.name, parameters)\n return method.result === \"void\" ? undefined : result\n }\n })\n }\n return stub as Stub\n}\n\nexport { createActorStub }\nexport type { ActorRpcMethod, ActorRpcTransport }\n\nlet shared: ActorRpcTransport | undefined\nexport function createActorTransport(options: DurableActorsClientOptions): ActorRpcTransport {\n return new HttpActorClient(options)\n}\n\nfunction defaultTransport(): ActorRpcTransport {\n return (shared ??= new HttpActorClient())\n}\nexport type { DurableActorsClientOptions }\n\nfunction invocationArguments(args: readonly unknown[]): readonly unknown[] {\n let end = args.length\n while (end > 0 && args[end - 1] === undefined) end--\n const parameters = args.slice(0, end)\n if (parameters.includes(undefined))\n throw new ActorSerializationError(\"undefined cannot precede a supplied RPC argument in JSON transport\")\n return parameters\n}\n", "runtime/telemetry.ts": "type TelemetryEvent = Record<string, boolean | number | string | undefined>\ntype TelemetrySink = (event: TelemetryEvent) => void\n\nclass LatencyTimeline {\n private readonly origin: number\n private readonly milestones: Record<string, number> = { started_at_ms: 0 }\n\n constructor(private readonly now: () => number = () => performance.now()) {\n this.origin = this.now()\n }\n\n mark(name: string): void {\n this.milestones[`${name}_at_ms`] = Math.max(0, Math.round(this.now() - this.origin))\n }\n\n finish(): Record<string, number> {\n this.mark(\"completed\")\n return { ...this.milestones }\n }\n}\n\nexport { LatencyTimeline }\nexport type { TelemetryEvent, TelemetrySink }\n", "runtime/package.json": "{\n \"private\": true,\n \"type\": \"module\",\n \"sideEffects\": false,\n \"browser\": {\n \"./index.ts\": \"./index.browser.ts\",\n \"./index.js\": \"./index.browser.js\"\n }\n}\n", "runtime/LICENSE.md": "MIT License\n\nCopyright (c) 2026 Terse\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" };
1
+ export const runtimeFiles = { "runtime/client.ts": "import { ActorInvocationError, ActorProtocolError } from \"./errors.js\"\nimport { HttpActorHostTransport, isRecord, responseDocument } from \"./http.js\"\nimport type { ActorHostTarget, ActorHostTransport, DirectActorInvocation } from \"./http.js\"\nimport { cloneJson } from \"./json.js\"\nimport type { JsonValue } from \"./json.js\"\nimport {\n authorizationHeaders,\n configuredSettings,\n environmentSettings,\n projectActorPath,\n runtimeEnvironment,\n validateActorComponent,\n validateOrigin\n} from \"./settings.js\"\nimport type { DurableActorsClientOptions, Environment } from \"./settings.js\"\nimport { LatencyTimeline } from \"./telemetry.js\"\nimport type { TelemetrySink } from \"./telemetry.js\"\n\nconst TARGET_EXPIRATION_SAFETY_MS = 5_000\n\nexport class HttpActorClient {\n private readonly beforeInvoke: (requestId: string) => void\n private settingsValue: RemoteActorSettings | undefined\n protected readonly environment: Environment\n protected readonly fetchRequest: typeof globalThis.fetch\n protected readonly requestId: () => string\n protected readonly actorHost: ActorHostTransport\n protected readonly now: () => number\n protected readonly monotonicNow: () => number\n protected readonly telemetry: TelemetrySink\n protected readonly targets = new Map<string, TargetResolution>()\n\n constructor(options?: DurableActorsClientOptions, dependencies: HttpActorClientDependencies = {}) {\n this.beforeInvoke = dependencies.beforeInvoke ?? (() => {})\n this.environment = dependencies.environment ?? runtimeEnvironment()\n this.fetchRequest = dependencies.fetch ?? globalThis.fetch\n this.requestId = dependencies.requestId ?? (() => globalThis.crypto.randomUUID())\n this.actorHost = dependencies.actorHost ?? new HttpActorHostTransport(this.fetchRequest)\n // Workflow runtimes can replace Date.now with replayable logical time.\n this.now = dependencies.now ?? (() => performance.timeOrigin + performance.now())\n this.monotonicNow = dependencies.monotonicNow ?? (() => performance.now())\n this.telemetry = dependencies.telemetry ?? (() => {})\n this.settingsValue = options === undefined ? undefined : configuredSettings(options)\n }\n\n async invoke(actorName: string, actorId: string, method: string, args: readonly unknown[]): Promise<unknown> {\n const requestId = validateActorComponent(\"request ID\", this.requestId())\n const timeline = new LatencyTimeline(this.monotonicNow)\n let outcome = \"failed\"\n try {\n this.beforeInvoke(requestId)\n const invocation = this.invocation(requestId, actorName, actorId, method, args)\n timeline.mark(\"invocation_built\")\n const target = await this.target(invocation, timeline)\n timeline.mark(\"target_resolved\")\n const result = await this.direct(target, invocation, true, timeline)\n outcome = \"completed\"\n return result\n } finally {\n this.telemetry({\n event: \"actor_client_invocation\",\n request_id: requestId,\n actor_name: actorName,\n actor_id: actorId,\n method,\n ...timeline.finish(),\n outcome\n })\n }\n }\n\n private async direct(\n target: ActorHostTarget,\n invocation: DirectActorInvocation,\n retryAvailable: boolean,\n timeline: LatencyTimeline\n ): Promise<unknown> {\n try {\n const reply = await this.actorHost.invoke(target, invocation)\n timeline.mark(\"host_rpc_completed\")\n if (reply.type === \"completed\") {\n timeline.mark(\"socket_effects_completed\")\n return reply.result\n }\n if (reply.type === \"failed\") throw new ActorInvocationError(reply.code, invocation.requestId, reply.message)\n this.invalidateTarget(invocation, target)\n if (reply.type === \"unauthenticated\" && !retryAvailable) {\n throw new ActorInvocationError(\n \"unauthenticated\",\n invocation.requestId,\n \"actor host rejected the refreshed invocation ticket\"\n )\n }\n if (!retryAvailable)\n throw new ActorInvocationError(\n \"unavailable\",\n invocation.requestId,\n reply.type === \"not_dispatched\"\n ? \"actor host could not be reached before execution\"\n : \"actor ownership changed repeatedly before execution\"\n )\n const rerouted = await this.target(invocation, timeline)\n return this.direct(rerouted, invocation, false, timeline)\n } catch (error) {\n if (error instanceof ActorInvocationError || error instanceof ActorProtocolError) throw error\n this.invalidateTarget(invocation, target)\n const message = error instanceof Error ? error.message : String(error)\n throw new ActorInvocationError(\n \"outcome_unknown\",\n invocation.requestId,\n `actor-host HTTP request failed after dispatch: ${message}`\n )\n }\n }\n\n private invalidateTarget(invocation: ActorAddress, target: ActorHostTarget): void {\n const key = actorKey(invocation.actorName, invocation.actorId)\n const current = this.targets.get(key)\n if (current?.target === target) this.targets.delete(key)\n }\n\n protected async target(invocation: ActorAddress, timeline: LatencyTimeline): Promise<ActorHostTarget> {\n const key = actorKey(invocation.actorName, invocation.actorId)\n const current = this.targets.get(key)\n timeline.mark(\"target_cache_checked\")\n if (current) {\n const target = await current.promise\n if (this.targets.get(key) !== current) return this.target(invocation, timeline)\n if (target.expiresAtMs > this.now() + TARGET_EXPIRATION_SAFETY_MS) return target\n this.targets.delete(key)\n }\n const resolving: TargetResolution = {\n promise: this.resolveTarget(invocation)\n .then(target => {\n resolving.target = target\n return target\n })\n .catch(error => {\n if (this.targets.get(key) === resolving) this.targets.delete(key)\n throw error\n })\n }\n this.targets.set(key, resolving)\n return resolving.promise\n }\n\n private async resolveTarget(invocation: ActorAddress): Promise<ActorHostTarget> {\n let response: Response\n try {\n response = await this.fetchRequest(targetUrl(this.settings, invocation.actorName, invocation.actorId), {\n method: \"POST\",\n redirect: \"error\",\n headers: {\n accept: \"application/json\",\n ...authorizationHeaders(this.settings.credential),\n \"x-request-id\": invocation.requestId,\n \"content-type\": \"application/json\"\n },\n body: JSON.stringify({ homeRegion: this.settings.homeRegion })\n })\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n throw new ActorInvocationError(\n \"unavailable\",\n invocation.requestId,\n `control-plane HTTP request failed before dispatch: ${message}`\n )\n }\n const document = await responseDocument(response)\n if (!response.ok) this.throwResponseFailure(response, document, invocation.requestId)\n if (\n !isRecord(document) ||\n typeof document.route !== \"string\" ||\n typeof document.token !== \"string\" ||\n !document.token.trim() ||\n !positiveInteger(document.ownerEpoch) ||\n !positiveInteger(document.expiresAtMs)\n )\n throw new ActorProtocolError(\"control-plane response did not contain a valid actor host target\")\n validateOrigin(document.route)\n return {\n route: document.route,\n token: document.token,\n ownerEpoch: document.ownerEpoch,\n expiresAtMs: document.expiresAtMs\n }\n }\n\n private throwResponseFailure(response: Response, document: unknown, requestId: string): never {\n if (response.status === 401 || response.status === 403)\n throw new ActorInvocationError(\n \"unauthenticated\",\n requestId,\n \"the durable-actors application credential was rejected\"\n )\n const failure = isRecord(document) ? document.error : undefined\n if (\n !isRecord(failure) ||\n typeof failure.code !== \"string\" ||\n !failure.code ||\n typeof failure.message !== \"string\"\n )\n throw new ActorProtocolError(`control-plane HTTP ${response.status} response did not contain a valid error`)\n throw new ActorInvocationError(\n failure.code,\n typeof failure.requestId === \"string\" ? failure.requestId : requestId,\n failure.message\n )\n }\n\n private invocation(\n requestId: string,\n actorName: string,\n actorId: string,\n method: string,\n args: readonly unknown[]\n ): DirectActorInvocation {\n return {\n requestId,\n projectId: this.settings.projectId,\n actorName: validateActorComponent(\"actor name\", actorName),\n actorId: validateActorComponent(\"actor ID\", actorId),\n method: validateActorComponent(\"actor method\", method),\n args: this.jsonArguments(args)\n }\n }\n\n protected get settings(): RemoteActorSettings {\n if (this.settingsValue !== undefined) return this.settingsValue\n this.settingsValue = configuredSettings(environmentSettings(this.environment))\n return this.settingsValue\n }\n\n private jsonArguments(args: readonly unknown[]): readonly JsonValue[] {\n const value = cloneJson(args, \"actor arguments\")\n if (!Array.isArray(value)) throw new ActorProtocolError(\"actor arguments must be a JSON array\")\n return value\n }\n}\n\nfunction targetUrl(settings: RemoteActorSettings, actorName: string, actorId: string): string {\n const actor = validateActorComponent(\"actor name\", actorName)\n const id = validateActorComponent(\"actor ID\", actorId)\n return `${settings.controlPlaneUrl}${projectActorPath(settings.projectId, actor, id)}/find-actor`\n}\n\nfunction actorKey(actorName: string, actorId: string): string {\n return `${actorName}\\u001f${actorId}`\n}\nfunction positiveInteger(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value > 0\n}\ntype ActorAddress = Pick<DirectActorInvocation, \"requestId\" | \"projectId\" | \"actorName\" | \"actorId\">\ninterface TargetResolution {\n readonly promise: Promise<ActorHostTarget>\n target?: ActorHostTarget\n}\ntype RemoteActorSettings = ReturnType<typeof configuredSettings>\nexport interface HttpActorClientDependencies {\n readonly environment?: Environment\n readonly fetch?: typeof globalThis.fetch\n readonly requestId?: () => string\n readonly actorHost?: ActorHostTransport\n readonly now?: () => number\n readonly monotonicNow?: () => number\n readonly telemetry?: TelemetrySink\n readonly beforeInvoke?: (requestId: string) => void\n}\nexport type { DurableActorsClientOptions }\n", "runtime/errors.ts": "class ActorConfigurationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorConfigurationError\"\n }\n}\n\nclass ActorDefinitionError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"ActorDefinitionError\"\n }\n}\n\n/** Remote failure. Retrying an `outcome_unknown` operation may run it twice. */\nclass ActorInvocationError extends Error {\n /** Error category, such as `actor_error` or `outcome_unknown`. New codes may be added. */\n readonly code: string\n /** Identifies this caller attempt; it is not an application idempotency key. */\n readonly requestId: string\n\n constructor(code: string, requestId: string, message: string) {\n super(message)\n this.name = \"ActorInvocationError\"\n this.code = code\n this.requestId = requestId\n }\n}\n\nclass ActorSessionError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorSessionError\"\n }\n}\n\nclass ActorProtocolError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorProtocolError\"\n }\n}\n\nclass ActorSerializationError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = \"ActorSerializationError\"\n }\n}\n\nclass ActorValidationError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"ActorValidationError\"\n }\n}\n\nexport {\n ActorConfigurationError,\n ActorDefinitionError,\n ActorInvocationError,\n ActorProtocolError,\n ActorSerializationError,\n ActorSessionError,\n ActorValidationError\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\nexport { errorMessage }\n", "runtime/http.ts": "import { ActorProtocolError } from \"./errors.js\"\nimport type { JsonValue } from \"./json.js\"\nimport { projectActorPath, validateOrigin } from \"./settings.js\"\n\nexport class HttpActorHostTransport implements ActorHostTransport {\n constructor(private readonly fetchRequest: typeof globalThis.fetch = globalThis.fetch) {}\n\n async invoke(target: ActorHostTarget, invocation: DirectActorInvocation): Promise<ActorHostReply> {\n let response: Response\n try {\n response = await this.post(target, invocation, \"invoke\", {\n requestId: invocation.requestId,\n ownerEpoch: target.ownerEpoch,\n method: invocation.method,\n args: invocation.args\n })\n } catch (error) {\n if (connectionRefused(error)) return { type: \"not_dispatched\" }\n throw error\n }\n // A 401 is issued before dispatch, so refreshing this ticket cannot repeat actor code.\n if (response.status === 401) return { type: \"unauthenticated\" }\n if (!response.ok) throw new Error(`actor host returned HTTP ${response.status}`)\n const reply = await responseDocument(response)\n if (isRecord(reply)) {\n if (reply.type === \"completed\" && Object.hasOwn(reply, \"result\"))\n return { type: \"completed\", result: reply.result }\n if (\n reply.type === \"failed\" &&\n typeof reply.code === \"string\" &&\n reply.code.length > 0 &&\n typeof reply.message === \"string\"\n )\n return { type: \"failed\", code: reply.code, message: reply.message }\n if (reply.type === \"reroute\") return { type: \"reroute\" }\n }\n throw new ActorProtocolError(\"actor host response did not contain a valid outcome\")\n }\n\n async publish(target: ActorHostTarget, actor: ActorAddress, effects: readonly unknown[]): Promise<void> {\n const response = await this.post(target, actor, \"socket-effects\", { ownerEpoch: target.ownerEpoch, effects })\n if (!response.ok) throw new Error(`socket effects returned HTTP ${response.status}`)\n }\n\n private post(target: ActorHostTarget, actor: ActorAddress, endpoint: string, body: unknown): Promise<Response> {\n return this.fetchRequest(\n `${validateOrigin(target.route)}${projectActorPath(actor.projectId, actor.actorName, actor.actorId)}/${endpoint}`,\n {\n method: \"POST\",\n redirect: \"error\",\n headers: {\n authorization: `Bearer ${target.token}`,\n \"content-type\": \"application/json\",\n accept: \"application/json\"\n },\n body: JSON.stringify(body)\n }\n )\n }\n}\n\nfunction connectionRefused(error: unknown, ancestors = new Set<unknown>()): boolean {\n if (!isRecord(error) || ancestors.has(error)) return false\n const visited = new Set(ancestors).add(error)\n if (error.code !== undefined && error.code !== \"ECONNREFUSED\") return false\n if (error.errors !== undefined)\n return (\n Array.isArray(error.errors) &&\n error.errors.length > 0 &&\n error.errors.every(cause => connectionRefused(cause, visited))\n )\n if (error.code === \"ECONNREFUSED\") return error.syscall === \"connect\"\n return connectionRefused(error.cause, visited)\n}\n\nexport async function responseDocument(response: Response): Promise<unknown> {\n try {\n return await response.json()\n } catch (error) {\n throw new ActorProtocolError(`HTTP ${response.status} response was not valid JSON`, { cause: error })\n }\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\n\nexport interface ActorAddress {\n readonly projectId: string\n readonly actorName: string\n readonly actorId: string\n}\nexport interface ActorHostTarget {\n readonly route: string\n readonly token: string\n readonly ownerEpoch: number\n readonly expiresAtMs: number\n}\nexport interface DirectActorInvocation extends ActorAddress {\n readonly requestId: string\n readonly method: string\n readonly args: readonly JsonValue[]\n}\nexport type ActorHostReply =\n | { readonly type: \"completed\"; readonly result: unknown }\n | { readonly type: \"failed\"; readonly code: string; readonly message: string }\n | { readonly type: \"reroute\" }\n | { readonly type: \"unauthenticated\" }\n | { readonly type: \"not_dispatched\" }\nexport interface ActorHostTransport {\n invoke(target: ActorHostTarget, invocation: DirectActorInvocation): Promise<ActorHostReply>\n publish(target: ActorHostTarget, actor: ActorAddress, effects: readonly unknown[]): Promise<void>\n}\n", "runtime/index.browser.ts": "import type { SocketProxy as ServerProxy } from \"./proxy.js\"\nimport type { createActorStub as ServerStub, createActorTransport as ServerTransport } from \"./stub.js\"\n\nconst createActorStub: typeof ServerStub = () => {\n throw new Error(\"actors must be used on the server\")\n}\n\nconst createActorTransport: typeof ServerTransport = () => {\n throw new Error(\"actors must be used on the server\")\n}\n\nconst SocketProxy = class {\n constructor() {\n throw new Error(\"ActorProxy must be used on the server\")\n }\n} as unknown as typeof ServerProxy\n\nexport { createActorStub, createActorTransport, SocketProxy }\nexport { ActorInvocationError } from \"./errors.js\"\n", "runtime/index.ts": "export { createActorStub, createActorTransport } from \"./stub.js\"\nexport type { ActorRpcTransport, DurableActorsClientOptions } from \"./stub.js\"\nexport { ActorInvocationError } from \"./errors.js\"\nexport { SocketProxy } from \"./proxy.js\"\nexport type { ProxyActor, SocketGrant, SocketProxyDependencies, SocketProxyOptions } from \"./proxy.js\"\n", "runtime/json.ts": "import { ActorSerializationError } from \"./errors.js\"\n\ntype JsonPrimitive = string | number | boolean | null\ntype JsonObject = { readonly [key: string]: JsonValue }\ntype JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[]\n\nfunction cloneJson(value: unknown, label: string): JsonValue {\n try {\n const encoded = JSON.stringify(value)\n if (encoded === undefined) throw new ActorSerializationError(`${label} must be JSON serializable`)\n return JSON.parse(encoded) as JsonValue\n } catch (error) {\n if (error instanceof ActorSerializationError) throw error\n throw new ActorSerializationError(`${label} must be JSON serializable`, { cause: error })\n }\n}\n\nexport { cloneJson }\nexport type { JsonValue }\n", "runtime/proxy.ts": "import { ActorProtocolError, ActorSerializationError, ActorValidationError } from \"./errors.js\"\nimport { isRecord } from \"./http.js\"\nimport {\n authorizationHeaders,\n configuredSettings,\n environmentSettings,\n projectActorPath,\n validateActorComponent\n} from \"./settings.js\"\n\n/** Overrides for the backend's DURABLE_ACTORS environment settings. */\ninterface SocketProxyOptions {\n readonly projectId?: string\n readonly controlPlaneUrl?: string\n readonly apiKey?: string\n /** Defaults to 180000 ms; accepts 1000–600000 ms. */\n readonly setupTimeoutMs?: number\n}\n\ninterface SocketProxyDependencies {\n readonly fetch?: typeof globalThis.fetch\n}\n\ninterface ProxyActor<Metadata = unknown> {\n readonly types?: Metadata\n}\n\n/** Actor access your backend has already authorized. */\ntype SocketAuthorization<Actors extends Record<string, ProxyActor>> = {\n [Name in keyof Actors & string]: {\n readonly actorName: Name\n readonly actorId: string\n readonly metadata: Actors[Name] extends ProxyActor<infer Metadata> ? Metadata : never\n readonly homeRegion?: string\n readonly authorizationLifetimeMs?: number\n }\n}[keyof Actors & string]\n\n/** Browser connection URL and deadlines in Unix milliseconds. Treat the URL as a credential. */\ninterface SocketGrant {\n websocketUrl: string\n homeRegion: string\n connectByMs: number\n authorizedUntilMs: number\n}\n\n/** Issues browser connection URLs from your backend. */\nclass SocketProxy<Actors extends Record<string, ProxyActor>> {\n private readonly projectId: string\n private readonly origin: string\n private readonly apiKey: string | undefined\n private readonly setupTimeoutMs: number\n private readonly fetchRequest: typeof globalThis.fetch\n\n constructor(\n private readonly actors: Actors,\n options: SocketProxyOptions = {},\n dependencies: SocketProxyDependencies = {}\n ) {\n this.setupTimeoutMs = options.setupTimeoutMs ?? 180000\n if (!Number.isSafeInteger(this.setupTimeoutMs) || this.setupTimeoutMs < 1000 || this.setupTimeoutMs > 600000)\n throw new Error(\"Socket setup timeout must be between one second and ten minutes\")\n const settings = configuredSettings(proxySettings(options))\n this.origin = settings.controlPlaneUrl\n this.apiKey = settings.credential\n this.projectId = settings.projectId\n this.fetchRequest = dependencies.fetch ?? globalThis.fetch\n }\n\n /**\n * Call after authenticating the user and checking actor access.\n * Pass `websocketUrl` to the browser's `new WebSocket()`.\n */\n async handle(authorization: SocketAuthorization<Actors>): Promise<SocketGrant> {\n const actorName = validateActorComponent(\"actor name\", authorization.actorName)\n const actorId = validateActorComponent(\"actor ID\", authorization.actorId)\n if (!Object.hasOwn(this.actors, actorName)) throw new Error(`Unknown actor name: ${actorName}`)\n const metadata = socketMetadata(authorization.metadata)\n const authorizationLifetimeMs = authorization.authorizationLifetimeMs ?? 900000\n if (\n !Number.isSafeInteger(authorizationLifetimeMs) ||\n authorizationLifetimeMs < 1000 ||\n authorizationLifetimeMs > 86400000\n )\n throw new Error(\"Socket authorization lifetime must be between one second and one day\")\n const homeRegion =\n authorization.homeRegion === undefined\n ? undefined\n : validateActorComponent(\"home region\", authorization.homeRegion)\n const response = await this.fetchRequest(\n `${this.origin}${projectActorPath(this.projectId, actorName, actorId)}/find-websocket`,\n {\n method: \"POST\",\n redirect: \"error\",\n headers: { ...authorizationHeaders(this.apiKey), \"content-type\": \"application/json\" },\n body: JSON.stringify({ metadata, authorizationLifetimeMs, homeRegion }),\n signal: AbortSignal.timeout(this.setupTimeoutMs)\n }\n )\n if (!response.ok) throw new Error(`WebSocket authorization could not be issued (HTTP ${response.status})`)\n return socketGrant(await response.json())\n }\n}\n\nfunction proxySettings(options: SocketProxyOptions) {\n const environment = environmentSettings()\n const controlPlaneUrl = options.controlPlaneUrl ?? environment.controlPlaneUrl\n const apiKey = options.apiKey ?? environment.apiKey\n return {\n projectId: options.projectId ?? environment.projectId,\n controlPlaneUrl: controlPlaneUrl ?? \"http://127.0.0.1:7100\",\n apiKey\n }\n}\n\nexport { SocketProxy }\nexport type { ProxyActor, SocketAuthorization, SocketGrant, SocketProxyDependencies, SocketProxyOptions }\n\nfunction socketGrant(value: unknown): SocketGrant {\n if (\n !isRecord(value) ||\n typeof value.websocketUrl !== \"string\" ||\n !URL.canParse(value.websocketUrl) ||\n !/^wss?:$/u.test(new URL(value.websocketUrl).protocol) ||\n typeof value.homeRegion !== \"string\" ||\n !value.homeRegion ||\n !Number.isSafeInteger(value.connectByMs) ||\n !Number.isSafeInteger(value.authorizedUntilMs)\n )\n throw new ActorProtocolError(\"invalid WebSocket authorization response\")\n return {\n websocketUrl: value.websocketUrl,\n homeRegion: value.homeRegion,\n connectByMs: value.connectByMs as number,\n authorizedUntilMs: value.authorizedUntilMs as number\n }\n}\n\nfunction socketMetadata(value: unknown): unknown {\n let encoded: string\n try {\n encoded = JSON.stringify(value)\n if (!isJsonValue(value)) throw new Error(\"invalid JSON value\")\n } catch (error) {\n throw new ActorSerializationError(\"socket metadata must be a JSON value\", { cause: error })\n }\n if (new TextEncoder().encode(encoded).length > 64 * 1024)\n throw new ActorValidationError(\"socket metadata exceeds 65536 bytes\")\n return value\n}\n\nfunction isJsonValue(value: unknown): boolean {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true\n if (typeof value === \"number\") return Number.isFinite(value)\n if (Array.isArray(value)) return Array.from(value).every(isJsonValue)\n return (\n isRecord(value) &&\n [Object.prototype, null].includes(Object.getPrototypeOf(value)) &&\n Object.values(value).every(isJsonValue)\n )\n}\n", "runtime/settings.ts": "import { ActorConfigurationError, ActorValidationError } from \"./errors.js\"\n\nexport interface DurableActorsClientOptions {\n readonly projectId?: string\n readonly apiKey?: string\n readonly homeRegion?: string\n readonly controlPlaneUrl: string\n}\n\nexport type Environment = Record<string, string | undefined>\n\nexport function configuredSettings(value: unknown) {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n Object.keys(value).some(key => ![\"projectId\", \"apiKey\", \"homeRegion\", \"controlPlaneUrl\"].includes(key))\n )\n throw new ActorConfigurationError(\"durable-actors client settings are invalid\")\n const options = value as DurableActorsClientOptions\n const controlPlaneUrl = validateOrigin(options.controlPlaneUrl)\n const local = [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(new URL(controlPlaneUrl).hostname)\n const projectId = options.projectId ?? (local ? \"local\" : undefined)\n if (typeof projectId !== \"string\" || !/^[A-Za-z0-9._-]{1,64}$/u.test(projectId) || [\".\", \"..\"].includes(projectId))\n throw new ActorConfigurationError(\n \"durable-actors client settings are invalid: a valid projectId is required for remote connections\"\n )\n if (options.apiKey !== undefined && (typeof options.apiKey !== \"string\" || !options.apiKey.trim()))\n throw new ActorConfigurationError(\"durable-actors client settings are invalid: apiKey must not be empty\")\n if (options.homeRegion !== undefined) validateActorComponent(\"home region\", options.homeRegion)\n return { projectId, credential: options.apiKey?.trim(), homeRegion: options.homeRegion, controlPlaneUrl }\n}\n\nexport function environmentSettings(environment: Environment = runtimeEnvironment()): DurableActorsClientOptions {\n return {\n projectId: environment.DURABLE_ACTORS_PROJECT_ID,\n apiKey: environment.DURABLE_ACTORS_SECRET ?? environment.DURABLE_ACTORS_API_KEY,\n homeRegion: environment.DURABLE_ACTORS_HOME_REGION,\n controlPlaneUrl: environment.DURABLE_ACTORS_CONTROL_PLANE_URL ?? \"http://127.0.0.1:7100\"\n }\n}\n\nexport function runtimeEnvironment(): Environment {\n return (globalThis as typeof globalThis & { process?: { env?: Environment } }).process?.env ?? {}\n}\n\nexport function validateOrigin(origin: string): string {\n let url: URL\n try {\n url = new URL(origin)\n } catch (error) {\n throw new ActorConfigurationError(`actor HTTP origin is invalid: ${origin}`, { cause: error })\n }\n if (\n !/^https?:$/u.test(url.protocol) ||\n !url.hostname ||\n url.username ||\n url.password ||\n url.pathname !== \"/\" ||\n url.search ||\n url.hash\n )\n throw new ActorConfigurationError(`actor URL must be an HTTP or HTTPS origin: ${origin}`)\n return url.origin\n}\n\nexport function validateActorComponent(name: string, value: string): string {\n if (typeof value !== \"string\" || !/^[A-Za-z0-9._-]+$/u.test(value) || value === \".\" || value === \"..\")\n throw new ActorValidationError(\n `${name} may contain only ASCII letters, digits, '.', '-', and '_' and must not be a path segment`\n )\n return value\n}\n\nexport function projectActorPath(projectId: string, actorName: string, actorId: string): string {\n return `/v1/projects/${encodeURIComponent(validateActorComponent(\"project ID\", projectId))}/actors/${encodeURIComponent(validateActorComponent(\"actor name\", actorName))}/${encodeURIComponent(validateActorComponent(\"actor ID\", actorId))}`\n}\n\nexport function authorizationHeaders(credential: string | undefined): Record<string, string> {\n return credential === undefined ? {} : { authorization: `Bearer ${credential}` }\n}\n", "runtime/stub.ts": "import { HttpActorClient } from \"./client.js\"\nimport { ActorDefinitionError, ActorSerializationError } from \"./errors.js\"\nimport { validateActorComponent } from \"./settings.js\"\nimport type { DurableActorsClientOptions } from \"./settings.js\"\n\ninterface ActorRpcTransport {\n invoke(actorName: string, actorId: string, method: string, args: readonly unknown[]): Promise<unknown>\n}\n\ninterface ActorRpcMethod {\n readonly name: string\n readonly result: \"void\" | \"value\"\n}\n\n/** Creates a backend client from generated method definitions. */\nfunction createActorStub<Stub extends object>(\n actorName: string,\n actorId: string,\n methods: readonly ActorRpcMethod[],\n transport?: ActorRpcTransport\n): Stub {\n validateActorComponent(\"actor name\", actorName)\n validateActorComponent(\"actor ID\", actorId)\n const stub = Object.create(null)\n for (const method of methods) {\n validateActorComponent(\"actor method\", method.name)\n if ([\"then\", \"connect\", \"broadcast\", \"onConnect\", \"onMessage\", \"onDisconnect\"].includes(method.name))\n throw new ActorDefinitionError(`actor method ${actorName}.${method.name} is reserved`)\n if (Object.hasOwn(stub, method.name))\n throw new ActorDefinitionError(`duplicate actor method ${actorName}.${method.name}`)\n Object.defineProperty(stub, method.name, {\n enumerable: true,\n value: async (...args: unknown[]) => {\n const parameters = invocationArguments(args)\n const client = transport ?? defaultTransport()\n const result = await client.invoke(actorName, actorId, method.name, parameters)\n return method.result === \"void\" ? undefined : result\n }\n })\n }\n return stub as Stub\n}\n\nexport { createActorStub }\nexport type { ActorRpcMethod, ActorRpcTransport }\n\nlet shared: ActorRpcTransport | undefined\nexport function createActorTransport(options: DurableActorsClientOptions): ActorRpcTransport {\n return new HttpActorClient(options)\n}\n\nfunction defaultTransport(): ActorRpcTransport {\n return (shared ??= new HttpActorClient())\n}\nexport type { DurableActorsClientOptions }\n\nfunction invocationArguments(args: readonly unknown[]): readonly unknown[] {\n let end = args.length\n while (end > 0 && args[end - 1] === undefined) end--\n const parameters = args.slice(0, end)\n if (parameters.includes(undefined))\n throw new ActorSerializationError(\"undefined cannot precede a supplied RPC argument in JSON transport\")\n return parameters\n}\n", "runtime/telemetry.ts": "type TelemetryEvent = Record<string, boolean | number | string | undefined>\ntype TelemetrySink = (event: TelemetryEvent) => void\n\nclass LatencyTimeline {\n private readonly origin: number\n private readonly milestones: Record<string, number> = { started_at_ms: 0 }\n\n constructor(private readonly now: () => number = () => performance.now()) {\n this.origin = this.now()\n }\n\n mark(name: string): void {\n this.milestones[`${name}_at_ms`] = Math.max(0, Math.round(this.now() - this.origin))\n }\n\n finish(): Record<string, number> {\n this.mark(\"completed\")\n return { ...this.milestones }\n }\n}\n\nexport { LatencyTimeline }\nexport type { TelemetryEvent, TelemetrySink }\n", "runtime/package.json": "{\n \"private\": true,\n \"type\": \"module\",\n \"sideEffects\": false,\n \"browser\": {\n \"./index.ts\": \"./index.browser.ts\",\n \"./index.js\": \"./index.browser.js\"\n }\n}\n", "runtime/LICENSE.md": "MIT License\n\nCopyright (c) 2026 Terse\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" };
2
2
  //# sourceMappingURL=client-runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-runtime.js","sourceRoot":"","sources":["../../src/generated/client-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAA2B,EAAC,mBAAmB,EAAC,0jWAA0jW,EAAC,mBAAmB,EAAC,w/DAAw/D,EAAC,iBAAiB,EAAC,ohIAAohI,EAAC,0BAA0B,EAAC,2rBAA2rB,EAAC,kBAAkB,EAAC,qWAAqW,EAAC,iBAAiB,EAAC,owBAAowB,EAAC,kBAAkB,EAAC,mjNAAmjN,EAAC,qBAAqB,EAAC,+yHAA+yH,EAAC,iBAAiB,EAAC,mmFAAmmF,EAAC,sBAAsB,EAAC,kuBAAkuB,EAAC,sBAAsB,EAAC,kMAAkM,EAAC,oBAAoB,EAAC,ijCAAijC,EAAC,CAAA"}
1
+ {"version":3,"file":"client-runtime.js","sourceRoot":"","sources":["../../src/generated/client-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAA2B,EAAC,mBAAmB,EAAC,ozXAAozX,EAAC,mBAAmB,EAAC,w/DAAw/D,EAAC,iBAAiB,EAAC,u5JAAu5J,EAAC,0BAA0B,EAAC,2rBAA2rB,EAAC,kBAAkB,EAAC,qWAAqW,EAAC,iBAAiB,EAAC,owBAAowB,EAAC,kBAAkB,EAAC,mjNAAmjN,EAAC,qBAAqB,EAAC,+yHAA+yH,EAAC,iBAAiB,EAAC,mmFAAmmF,EAAC,sBAAsB,EAAC,kuBAAkuB,EAAC,sBAAsB,EAAC,kMAAkM,EAAC,oBAAoB,EAAC,ijCAAijC,EAAC,CAAA"}
@@ -4,20 +4,22 @@ Requires Node.js 22.19.0+, pnpm, and Bun 1.3.9+ on your PATH.
4
4
 
5
5
  ```sh
6
6
  pnpm install
7
- pnpm exec durable-actors dev
7
+ # Or with npm:
8
+ npm install
9
+ npx durable-actors dev
8
10
  ```
9
11
 
10
12
  Define your actors in `src/actors.ts`. The starter contains a counter with persisted state and `read()` and `increment()` methods. Each counter ID has its own saved value.
11
13
 
12
- `pnpm exec durable-actors dev` watches your actor source and stores local state in `.durable-actors/`. It defaults to project ID `local`; choose another with `DURABLE_ACTORS_PROJECT_ID=my-project pnpm exec durable-actors dev`.
14
+ `npx durable-actors dev` watches your actor source and stores local state in `.durable-actors/`. It defaults to project ID `local`; choose another with `DURABLE_ACTORS_PROJECT_ID=my-project npx durable-actors dev`.
13
15
 
14
16
  ## Connect your application
15
17
 
16
18
  In your separate application project's directory:
17
19
 
18
- 1. Run `pnpm add -D durable-actors`.
20
+ 1. Run `pnpm install --save-dev durable-actors` or `npm install --save-dev durable-actors`.
19
21
  2. Use the local defaults: project `local`, URL `http://127.0.0.1:7100`, and no secret. If you configure a different project, port, or optional secret on the actor server, put matching settings in your application’s `.env` or `.env.local` file.
20
- 3. Run `pnpm exec durable-actors generate`; the CLI loads both automatically. Exported environment variables take precedence over `.env.local`, which takes precedence over `.env`.
22
+ 3. Run `npx durable-actors generate`; the CLI loads both environment files automatically. Exported environment variables take precedence over `.env.local`, which takes precedence over `.env`.
21
23
 
22
24
  Your application backend can then use the generated client:
23
25
 
@@ -28,6 +30,4 @@ const counter = actors.Counter.get("example")
28
30
  console.log(await counter.increment())
29
31
  ```
30
32
 
31
- Start your backend with that environment file loaded. Update its secret after restarting the actor server. If you change the actor server's URL or port, also set `DURABLE_ACTORS_CONTROL_PLANE_URL` in the backend environment. After changing actor method signatures, rerun the printed generate command in your application.
32
-
33
33
  Use `pnpm check` to check types. Production deployment integrations register actor images through `PUT /v1/projects/{project_id}/deployment`; see the [HTTP API](https://github.com/TerseAI/durable-actors/blob/main/docs/reference/openapi.yaml).
@@ -10,7 +10,7 @@
10
10
  "check": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "durable-actors": "0.4.0"
13
+ "durable-actors": "0.4.2"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/node": "^22.0.0",
@@ -15,7 +15,7 @@
15
15
  "@ai-sdk/react": "^4.0.100",
16
16
  "ai": "^7.0.97",
17
17
  "express": "^5.2.1",
18
- "durable-actors": "0.4.0",
18
+ "durable-actors": "0.4.2",
19
19
  "react": "^19.3.0",
20
20
  "react-dom": "^19.3.0"
21
21
  },
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "express": "^5.2.1",
15
- "durable-actors": "0.4.0",
15
+ "durable-actors": "0.4.2",
16
16
  "react": "^19.3.0",
17
17
  "react-dom": "^19.3.0"
18
18
  },
@@ -19,7 +19,7 @@
19
19
  "@tiptap/y-tiptap": "^3.0.7",
20
20
  "express": "^5.2.1",
21
21
  "lib0": "^0.2.117",
22
- "durable-actors": "0.4.0",
22
+ "durable-actors": "0.4.2",
23
23
  "react": "^19.3.0",
24
24
  "react-dom": "^19.3.0",
25
25
  "yjs": "^13.6.32"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "durable-actors",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Provider-neutral actors for sandbox compute",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -81,7 +81,6 @@
81
81
  "chokidar": "^4.0.3",
82
82
  "commander": "^14.0.3",
83
83
  "dotenv": "^18.0.0",
84
- "durable-actors-observer": "0.1.0",
85
84
  "esbuild": "^0.28.2",
86
85
  "import-meta-resolve": "^4.2.0",
87
86
  "json-schema-to-typescript": "^16.0.0",
@@ -93,7 +92,8 @@
93
92
  "validate-npm-package-name": "^6.0.2",
94
93
  "vite": "^8.3.0",
95
94
  "ws": "^8.18.3",
96
- "zod": "^4.3.6"
95
+ "zod": "^4.3.6",
96
+ "durable-actors-observer": "0.4.2"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@types/node": "^22.0.0",