add-activity
Add a new duroxide activity to the runtime. Activities are the durable boundary between the orchestration and session management — they dispatch to ManagedSession or SessionManager methods.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 16
- Forks
- 10
01 前言 Front Matter
- name
- add-activity
- description
- Add a new duroxide activity to the runtime. Activities are the durable boundary between the orchestration and session management — they dispatch to ManagedSession or SessionManager methods.
03 SKILL.md 正文
Add a New Activity
Activities are the durable boundary between the orchestration generator and the session layer. They must only accept and return serializable data.
Steps
-
Define the activity function in
src/session-proxy.tsinsideregisterActivities():runtime.registerActivity("myActivity", async (ctx: any, input: any) => { const { sessionId, ...args } = input; const session = await sessionManager.getOrCreate(sessionId, args.config); const result = await session.myMethod(args); return result; }); -
Create a proxy function in
createSessionProxy()(session-scoped) orcreateSessionManagerProxy()(manager-scoped):myActivity: (args: any) => { return ctx.scheduleActivityOnSession( "myActivity", { sessionId, ...args }, affinityKey, ); } -
Call it from the orchestration in
src/orchestration.ts:const result = yield session.myActivity(args); -
Add tests in
test/sdk.test.js.
Key constraints
- Activities must only accept and return serializable data (no functions, no class instances).
- Activity functions should be thin — delegate business logic to
ManagedSessionorSessionManager. - Use
ctx.scheduleActivityOnSession()(notctx.scheduleActivity()) to maintain session affinity. - The
affinityKeyensures the activity runs on the same worker that holds the in-memory session.
Key files
- src/session-proxy.ts — activity definitions and proxy factories
- src/orchestration.ts — orchestration generator function
- src/types.ts — type definitions for activity inputs/outputs
04 同仓库更多 Skills
workflow-testing
Load before you test a Workflow with mocked effects — the test, test_respond and test_advance operations, fixtures, interception ids, valid answers, the virtual clock, test evidence and what a test run does not prove.
workflow-tools
Every argument of the Workflow tools, testing a revision, package definitions and the refusals you can fix. Load when a Workflow tool's short description is not enough.
workflow-reference
Field reference for Workflow YAML (root keys, every state type, bindings, outputs, runtime error codes), what the engine guarantees, and a review fan-out example. For design, call load_skill with name workflow-authoring.
workflow-patterns
Load when one Workflow must run different nodes in its branches at the same time (a different prompt or model for each branch), or loops back to a state (a polling loop). Named branches, the router pattern, examples that compile.
workflow-authoring
Load before you create, edit, publish or run a Workflow (pilotswarm.dev/v1) — choosing states, bounded graphs, bindings, typed contracts, agent and parallel states, the lifecycle and failure diagnosis.
tla-formal-validation
Required for any change to the core orchestrations (the durable session orchestration, session hydration and dehydration, and the Workflow controller and store). Teaches how to model the change in TLA+, update the existing models, run TLC with the repo runner, read the results, turn a counterexample into a fix and a regression test, and record the binding to the code.