durable-actors 0.5.2 → 0.5.4
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 +23 -26
- package/dist/actor/sandbox.d.ts +40 -0
- package/dist/actor/sandbox.d.ts.map +1 -0
- package/dist/actor/sandbox.js +32 -0
- package/dist/actor/sandbox.js.map +1 -0
- package/dist/actor/schema.d.ts +2 -0
- package/dist/actor/schema.d.ts.map +1 -1
- package/dist/actor/schema.js.map +1 -1
- package/dist/cli/actor-source-watcher.d.ts +18 -4
- package/dist/cli/actor-source-watcher.d.ts.map +1 -1
- package/dist/cli/actor-source-watcher.js +104 -34
- package/dist/cli/actor-source-watcher.js.map +1 -1
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +12 -1
- package/dist/cli/dev.js.map +1 -1
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +25 -6
- package/dist/cli/generate.js.map +1 -1
- package/dist/cli/python.d.ts +6 -0
- package/dist/cli/python.d.ts.map +1 -0
- package/dist/cli/python.js +50 -0
- package/dist/cli/python.js.map +1 -0
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/client/remoteClient.d.ts.map +1 -1
- package/dist/client/remoteClient.js +1 -10
- package/dist/client/remoteClient.js.map +1 -1
- package/dist/client-runtime/client.d.ts +0 -2
- package/dist/client-runtime/client.d.ts.map +1 -1
- package/dist/client-runtime/client.js +0 -3
- package/dist/client-runtime/client.js.map +1 -1
- package/dist/compiler/actor-compiler.d.ts +2 -0
- package/dist/compiler/actor-compiler.d.ts.map +1 -1
- package/dist/compiler/actor-compiler.js +9 -0
- package/dist/compiler/actor-compiler.js.map +1 -1
- package/dist/compiler/deployment-build.js +7 -0
- package/dist/compiler/deployment-build.js.map +1 -1
- package/dist/compiler/features/sandbox.d.ts +9 -0
- package/dist/compiler/features/sandbox.d.ts.map +1 -0
- package/dist/compiler/features/sandbox.js +50 -0
- package/dist/compiler/features/sandbox.js.map +1 -0
- package/dist/compiler/types.d.ts +8 -1
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/compiler/types.js +1 -0
- package/dist/compiler/types.js.map +1 -1
- package/dist/compiler/validate-public-contract.d.ts.map +1 -1
- package/dist/compiler/validate-public-contract.js +4 -0
- package/dist/compiler/validate-public-contract.js.map +1 -1
- package/dist/generated/client-runtime.d.ts.map +1 -1
- package/dist/generated/client-runtime.js +1 -1
- package/dist/generated/client-runtime.js.map +1 -1
- package/dist/host/actor-runtime.d.ts.map +1 -1
- package/dist/host/actor-runtime.js +2 -3
- package/dist/host/actor-runtime.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/templates/actor/package.json +1 -1
- package/dist/templates/ai-chat/README.md +3 -25
- package/dist/templates/ai-chat/package.json +1 -1
- package/dist/templates/ai-chat/src/Chat.tsx +9 -2
- package/dist/templates/ai-chat/src/actors.ts +2 -3
- package/dist/templates/ai-chat/src/backend.ts +7 -2
- package/dist/templates/chat/README.md +1 -1
- package/dist/templates/chat/package.json +1 -1
- package/dist/templates/documents/README.md +1 -1
- package/dist/templates/documents/package.json +1 -1
- package/dist/templates/python/.env.example +1 -0
- package/dist/templates/python/README.md +7 -0
- package/dist/templates/python/gitignore +6 -0
- package/dist/templates/python/package.json +11 -0
- package/dist/templates/python/pnpm-workspace.yaml +2 -0
- package/dist/templates/python/pyproject.toml +8 -0
- package/dist/templates/python/src/actors.py +9 -0
- package/dist/wire/public-contract.d.ts +4 -0
- package/dist/wire/public-contract.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/actor/invocationContext.d.ts +0 -4
- package/dist/actor/invocationContext.d.ts.map +0 -1
- package/dist/actor/invocationContext.js +0 -10
- package/dist/actor/invocationContext.js.map +0 -1
|
@@ -6,7 +6,7 @@ import type { UIMessage } from "ai"
|
|
|
6
6
|
const initialMessages: UIMessage[] = await fetch("/api/chat/lobby").then(response => response.json())
|
|
7
7
|
|
|
8
8
|
function Chat() {
|
|
9
|
-
const { messages, sendMessage, status, error } = useChat({ id: "lobby", messages: initialMessages })
|
|
9
|
+
const { messages, sendMessage, regenerate, status, error } = useChat({ id: "lobby", messages: initialMessages })
|
|
10
10
|
const busy = status === "submitted" || status === "streaming"
|
|
11
11
|
|
|
12
12
|
return (
|
|
@@ -29,7 +29,14 @@ function Chat() {
|
|
|
29
29
|
</label>
|
|
30
30
|
<button disabled={busy}>{busy ? "Thinking…" : "Send"}</button>
|
|
31
31
|
</form>
|
|
32
|
-
{error &&
|
|
32
|
+
{error && (
|
|
33
|
+
<p role="alert">
|
|
34
|
+
{error.message}{" "}
|
|
35
|
+
<button onClick={() => regenerate()} disabled={busy}>
|
|
36
|
+
Retry
|
|
37
|
+
</button>
|
|
38
|
+
</p>
|
|
39
|
+
)}
|
|
33
40
|
</main>
|
|
34
41
|
)
|
|
35
42
|
}
|
|
@@ -19,7 +19,8 @@ app.post("/api/chat", async (request, response) => {
|
|
|
19
19
|
const [message] = await validateUIMessages({ messages: [request.body.messages.at(-1)] })
|
|
20
20
|
if (message.role !== "user") return response.sendStatus(400)
|
|
21
21
|
const chat = ChatHistory.get(request.body.id)
|
|
22
|
-
const messages = await chat.
|
|
22
|
+
const messages = [...(await chat.load()), message]
|
|
23
|
+
let failed = false
|
|
23
24
|
const result = streamText({
|
|
24
25
|
model: openai("gpt-5-mini"),
|
|
25
26
|
messages: await convertToModelMessages(messages)
|
|
@@ -30,8 +31,12 @@ app.post("/api/chat", async (request, response) => {
|
|
|
30
31
|
stream: result.stream,
|
|
31
32
|
originalMessages: messages,
|
|
32
33
|
generateMessageId: generateId,
|
|
34
|
+
onError: () => {
|
|
35
|
+
failed = true
|
|
36
|
+
return "Reply failed. Check the API key and try again."
|
|
37
|
+
},
|
|
33
38
|
onEnd: async ({ responseMessage, outcome }) => {
|
|
34
|
-
if (outcome.status === "completed") await chat.append(responseMessage)
|
|
39
|
+
if (!failed && outcome.status === "completed") await chat.append(message, responseMessage)
|
|
35
40
|
}
|
|
36
41
|
})
|
|
37
42
|
})
|
|
@@ -69,6 +69,6 @@ Everyone joins as a guest. Add authentication and room access checks before issu
|
|
|
69
69
|
|
|
70
70
|
## Development
|
|
71
71
|
|
|
72
|
-
Both processes read `.env`; saved state lives in `.durable-actors/`. Actor code reloads automatically. After changing public actor types, restart `npm run dev` to regenerate the client. For multiple examples, set distinct `PORT`, `DURABLE_ACTORS_PORT`, and matching control-plane URLs; see [Run the examples together](
|
|
72
|
+
Both processes read `.env`; saved state lives in `.durable-actors/`. Actor code reloads automatically. After changing public actor types, restart `npm run dev` to regenerate the client. For multiple examples, set distinct `PORT`, `DURABLE_ACTORS_PORT`, and matching control-plane URLs; see [Run the examples together](https://github.com/TerseAI/durable-actors/tree/main/examples#run-the-examples-together).
|
|
73
73
|
|
|
74
74
|
`npm run build` generates clients, checks TypeScript, and builds the frontend.
|
|
@@ -48,6 +48,6 @@ Editing pauses while disconnected. Reload to reconnect; unsaved edits are not st
|
|
|
48
48
|
|
|
49
49
|
## Development
|
|
50
50
|
|
|
51
|
-
Both processes read `.env`; saved state lives in `.durable-actors/`. Actor code reloads automatically. After changing public actor types, restart `npm run dev` to regenerate the client. For multiple examples, set distinct `PORT`, `DURABLE_ACTORS_PORT`, and matching control-plane URLs; see [Run the examples together](
|
|
51
|
+
Both processes read `.env`; saved state lives in `.durable-actors/`. Actor code reloads automatically. After changing public actor types, restart `npm run dev` to regenerate the client. For multiple examples, set distinct `PORT`, `DURABLE_ACTORS_PORT`, and matching control-plane URLs; see [Run the examples together](https://github.com/TerseAI/durable-actors/tree/main/examples#run-the-examples-together).
|
|
52
52
|
|
|
53
53
|
`npm run build` generates clients, checks TypeScript, and builds the frontend.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DURABLE_ACTORS_ENTRYPOINT=src/actors.py
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Python actors
|
|
2
|
+
|
|
3
|
+
Install Node.js 22+, Python 3.11+, and uv. Run `pnpm install`, `uv sync`, then `pnpm exec durable-actors dev`. The shared TypeScript CLI selects `.venv` and checks actor types before starting and reloading.
|
|
4
|
+
|
|
5
|
+
Edit `src/actors.py`. Write synchronous actor methods with ordinary `def`. Annotated fields persist by default; use `emitted()` for state broadcasts and `ephemeral()` for temporary values such as caches and service clients. From your client application, install `little-actors[codegen]` and run `pnpm exec durable-actors generate` against the running server. Generated Python clients include synchronous typed methods and models. Import `actors` from the generated package and use `actors.Counter.get("one")`; the SDK manages the HTTP connection pool. Actors with emitted fields also expose `actor.subscribe(callback)` for typed live state; close the returned subscription when finished. The CLI runs strict mypy after generation.
|
|
6
|
+
|
|
7
|
+
Set `DURABLE_ACTORS_PYTHON` to select another interpreter. `DURABLE_ACTORS_BINARY` selects a locally built runtime.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
import type { SandboxOptions } from "../actor/sandbox.js";
|
|
2
3
|
import type { SocketContract } from "./contract.js";
|
|
3
4
|
interface PublicActorContract {
|
|
4
5
|
readonly version: 1;
|
|
@@ -11,6 +12,8 @@ interface TypeScriptContract {
|
|
|
11
12
|
}
|
|
12
13
|
interface ActorApi {
|
|
13
14
|
readonly actorName: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly sandbox?: SandboxOptions;
|
|
14
17
|
readonly socket: SocketContract;
|
|
15
18
|
readonly rpc: RpcContract;
|
|
16
19
|
}
|
|
@@ -20,6 +23,7 @@ interface RpcContract {
|
|
|
20
23
|
}
|
|
21
24
|
interface RpcMethod {
|
|
22
25
|
readonly name: string;
|
|
26
|
+
readonly description?: string;
|
|
23
27
|
readonly parameters: readonly RpcParameter[];
|
|
24
28
|
readonly result: {
|
|
25
29
|
readonly kind: "void";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-contract.d.ts","sourceRoot":"","sources":["../../src/wire/public-contract.ts"],"names":[],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AAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,CAAA;IAC5C,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;KAAE,CAAA;CACxG;AAED,UAAU,YAAY;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAC/B;AAED,UAAU,aAAa;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACxB;AAED,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "durable-actors",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Provider-neutral actors for sandbox compute",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"vite": "^8.3.0",
|
|
94
94
|
"ws": "^8.18.3",
|
|
95
95
|
"zod": "^4.3.6",
|
|
96
|
-
"durable-actors-observer": "0.5.
|
|
96
|
+
"durable-actors-observer": "0.5.4"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@types/node": "^22.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invocationContext.d.ts","sourceRoot":"","sources":["../../src/actor/invocationContext.ts"],"names":[],"mappings":"AAIA,iBAAS,oBAAoB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAEtD;AAED,iBAAS,sBAAsB,IAAI,IAAI,GAAG,SAAS,CAElD;AAED,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
const invocationStorage = new AsyncLocalStorage();
|
|
3
|
-
function runInActorInvocation(operation) {
|
|
4
|
-
return invocationStorage.run(true, operation);
|
|
5
|
-
}
|
|
6
|
-
function currentActorInvocation() {
|
|
7
|
-
return invocationStorage.getStore();
|
|
8
|
-
}
|
|
9
|
-
export { currentActorInvocation, runInActorInvocation };
|
|
10
|
-
//# sourceMappingURL=invocationContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invocationContext.js","sourceRoot":"","sources":["../../src/actor/invocationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAQ,CAAA;AAEvD,SAAS,oBAAoB,CAAI,SAAkB;IAC/C,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AACjD,CAAC;AAED,SAAS,sBAAsB;IAC3B,OAAO,iBAAiB,CAAC,QAAQ,EAAE,CAAA;AACvC,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAA"}
|