Skip to content

Commit 07b916e

Browse files
committed
refactor: replace actor tags with key-based identification
1 parent 1f5d184 commit 07b916e

File tree

52 files changed

+1345
-736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1345
-736
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ This ensures imports resolve correctly across different build environments and p
103103
- Ensure proper error handling with descriptive messages
104104
- Run `yarn check-types` regularly during development to catch type errors early. Prefer `yarn check-types` instead of `yarn build`.
105105
- Use `tsx` CLI to execute TypeScript scripts directly (e.g., `tsx script.ts` instead of `node script.js`).
106-
106+
- Do not auto-commit changes

examples/chat-room/scripts/cli.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ async function main() {
1010

1111
// connect to chat room - now accessed via property
1212
// can still pass parameters like room
13-
const chatRoom = await client.chatRoom.get({
14-
tags: { room },
13+
const chatRoom = await client.chatRoom.connect(room, {
1514
params: { room },
1615
});
1716

examples/chat-room/scripts/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function main() {
77
const client = createClient<App>(process.env.ENDPOINT ?? "http://localhost:6420");
88

99
// connect to chat room - now accessed via property
10-
const chatRoom = await client.chatRoom.get();
10+
const chatRoom = await client.chatRoom.connect();
1111

1212
// call action to get existing messages
1313
const messages = await chatRoom.getHistory();

examples/chat-room/tests/chat-room.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test("chat room should handle messages", async (test) => {
66
const { client } = await setupTest(test, app);
77

88
// Connect to chat room
9-
const chatRoom = await client.chatRoom.get();
9+
const chatRoom = await client.chatRoom.connect();
1010

1111
// Initial history should be empty
1212
const initialMessages = await chatRoom.getHistory();

examples/counter/scripts/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { App } from "../actors/app";
55
async function main() {
66
const client = createClient<App>(process.env.ENDPOINT ?? "http://localhost:6420");
77

8-
const counter = await client.counter.get()
8+
const counter = await client.counter.connect()
99

1010
counter.on("newCount", (count: number) => console.log("Event:", count));
1111

examples/counter/tests/counter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { app } from "../actors/app";
44

55
test("it should count", async (test) => {
66
const { client } = await setupTest(test, app);
7-
const counter = await client.counter.get();
7+
const counter = await client.counter.connect();
88

99
// Test initial count
1010
expect(await counter.getCount()).toBe(0);

examples/linear-coding-agent/src/actors/coding-agent/mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ export const codingAgent = actor({
406406

407407
// Handle actor instantiation
408408
onCreate: (c) => {
409-
console.log(`[ACTOR] Created actor instance with tags: ${JSON.stringify(c.tags)}`);
410-
updateDebugState(c, "Actor created", `with tags: ${JSON.stringify(c.tags)}`);
409+
console.log(`[ACTOR] Created actor instance with key: ${JSON.stringify(c.key)}`);
410+
updateDebugState(c, "Actor created", `with key: ${JSON.stringify(c.key)}`);
411411
},
412412

413413
// Handle actor start

examples/linear-coding-agent/src/server/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ server.post('/api/webhook/linear', async (c) => {
7272
return c.json({ status: 'error', statusEmoji: '❌', message: 'No issue ID found in webhook event' }, 400);
7373
}
7474

75-
// Create or get a coding agent instance with the issue ID as a tag
75+
// Create or get a coding agent instance with the issue ID as a key
7676
// This ensures each issue gets its own actor instance
7777
console.log(`[SERVER] Getting actor for issue: ${issueId}`);
78-
const actorClient = await client.codingAgent.get({
79-
tags: { issueId },
80-
});
78+
const actorClient = await client.codingAgent.connect(issueId);
8179

8280
// Initialize the agent if needed
8381
console.log(`[SERVER] Initializing actor for issue: ${issueId}`);

examples/resend-streaks/tests/user.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ beforeEach(() => {
2626

2727
test("streak tracking with time zone signups", async (t) => {
2828
const { client } = await setupTest(t, app);
29-
const actor = await client.user.get();
29+
const actor = await client.user.connect();
3030

3131
// Sign up with specific time zone
3232
const signupResult = await actor.completeSignUp(

packages/actor-core/src/actor/action.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AnyActorInstance } from "./instance";
22
import type { Conn } from "./connection";
33
import type { Logger } from "@/common/log";
4-
import type { ActorTags } from "@/common/utils";
4+
import type { ActorKey } from "@/common/utils";
55
import type { Schedule } from "./schedule";
66
import type { ConnId } from "./connection";
77
import type { SaveStateOptions } from "./instance";
@@ -65,10 +65,10 @@ export class ActionContext<S, CP, CS, V> {
6565
}
6666

6767
/**
68-
* Gets the actor tags.
68+
* Gets the actor key.
6969
*/
70-
get tags(): ActorTags {
71-
return this.#actorContext.tags;
70+
get key(): ActorKey {
71+
return this.#actorContext.key;
7272
}
7373

7474
/**

0 commit comments

Comments
 (0)