posipaki 0.10.4 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +164 -10
  2. package/dist/hooks.d.ts +48 -0
  3. package/dist/hooks.d.ts.map +1 -0
  4. package/dist/hooks.js +20 -0
  5. package/dist/hooks.js.map +1 -0
  6. package/dist/index.d.ts +30 -6
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +178 -38
  9. package/dist/index.js.map +1 -1
  10. package/dist/pipe.d.ts +1 -1
  11. package/dist/pipe.js +3 -2
  12. package/dist/pipe.js.map +1 -1
  13. package/dist/plugins/debug-logger.d.ts +11 -0
  14. package/dist/plugins/debug-logger.d.ts.map +1 -0
  15. package/dist/plugins/debug-logger.js +34 -0
  16. package/dist/plugins/debug-logger.js.map +1 -0
  17. package/dist/plugins/rbac.d.ts +10 -0
  18. package/dist/plugins/rbac.d.ts.map +1 -0
  19. package/dist/plugins/rbac.js +21 -0
  20. package/dist/plugins/rbac.js.map +1 -0
  21. package/dist/plugins/timeout-guard.d.ts +10 -0
  22. package/dist/plugins/timeout-guard.d.ts.map +1 -0
  23. package/dist/plugins/timeout-guard.js +24 -0
  24. package/dist/plugins/timeout-guard.js.map +1 -0
  25. package/dist/process-B1vevrTc.d.ts +33 -0
  26. package/dist/process-B1vevrTc.d.ts.map +1 -0
  27. package/dist/supervisor.d.ts +3 -2
  28. package/dist/supervisor.d.ts.map +1 -1
  29. package/dist/supervisor.js +6 -2
  30. package/dist/supervisor.js.map +1 -1
  31. package/dist/{process-C-ERBQY5.d.ts → types-Bau9O_vk.d.ts} +75 -80
  32. package/dist/types-Bau9O_vk.d.ts.map +1 -0
  33. package/dist/util-Cw64MseZ.js.map +1 -1
  34. package/dist/xfetch.d.ts +4 -3
  35. package/dist/xfetch.d.ts.map +1 -1
  36. package/dist/xfetch.js +4 -3
  37. package/dist/xfetch.js.map +1 -1
  38. package/package.json +17 -1
  39. package/dist/process-C-ERBQY5.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,19 +1,173 @@
1
- # Wat
1
+ # Posipaki
2
2
 
3
- When you want to do some Erlang, but you can only have reactive composable stores instead
3
+ The missing primitive: actor processes for JavaScript, built on generator functions
4
+ and the `[msg, sender]` tuple.
4
5
 
5
- # Wat?
6
+ ## Why
6
7
 
7
- It's like a promise but worse -- you can abort it and have more undebuggable things to figure out.
8
+ JavaScript has three ways to model async work:
8
9
 
9
- # Do I need vue3 to use it?
10
+ - **Promises** model a single eventual value. Great for request/response, useless
11
+ for something with more than one outcome.
12
+ - **Observables / Streams** — model a sequence of values over time. Great for
13
+ events, but every subscriber sees the same events and there's no back-and-forth.
14
+ - **Stores / Reactive state** — model a value that changes over time. Great for UI
15
+ state, but they're passive — you read them, they don't talk back.
10
16
 
11
- No.
17
+ What's missing is a primitive for something that **receives messages, updates its
18
+ own state, and sends messages back** — a thing with its own lifecycle, can be started
19
+ and aborted before it resolves.
12
20
 
13
- # Is this about Public Key Infrastructure?
21
+ A **process**.
14
22
 
15
- No.
23
+ ```ts
24
+ const counter = defineActor({
25
+ initialState: { count: 0 },
26
+ handlers: {
27
+ POKE(msg, sender) {
28
+ this.state.count++;
29
+ if (this.state.count >= 10) {
30
+ this.emit({ type: "FULL" });
31
+ this.exit("limit reached");
32
+ }
33
+ },
34
+ RESET(msg, sender) {
35
+ this.state.count = 0;
36
+ },
37
+ },
38
+ });
16
39
 
17
- # Are you sure it's not another halfbroken X509 parser?
40
+ const proc = counter.spawn(null);
41
+ await proc.ready();
42
+ proc.send({ type: "POKE" });
43
+ ```
18
44
 
19
- Yes, it's not another halfbroken X509 parser
45
+
46
+ A process can do everything a promise, a stream, or a store can do —
47
+ but it can also fork children, pause/resume, and exit on its own terms.
48
+ And every handler receives the sender's identity in the `[msg, sender]` tuple,
49
+ so you always know *who* sent what.
50
+ Of course processes are composable into trees.
51
+
52
+ ## Quick start
53
+
54
+ ```ts
55
+ import { spawnAsync, defineActor } from "posipaki";
56
+
57
+ const counter = defineActor({
58
+ initialState: { count: 0 },
59
+ handlers: {
60
+ POKE(msg, sender) {
61
+ this.state.count++;
62
+ },
63
+ },
64
+ });
65
+
66
+ const proc = counter.spawn(null);
67
+ await proc.ready(); // state is available
68
+ proc.send({ type: "POKE" }); // delivers [msg, sender] to the generator
69
+ // proc.state.count === 1
70
+ ```
71
+
72
+ For full control, drop to generators:
73
+
74
+ ```ts
75
+ import { spawnAsync, runDispatchAsync } from "posipaki";
76
+
77
+ async function* counter(ctx, { max }) {
78
+ const state = { count: 0 };
79
+ yield state;
80
+
81
+ yield* runDispatchAsync(ctx.pname, async ([msg, sender]) => {
82
+ if (msg.type === "POKE" && state.count < max) state.count++;
83
+ });
84
+ // ... or wait for the signal to replace it with another generator
85
+ }
86
+
87
+ const proc = spawnAsync(counter, "counter")({ max: 3 });
88
+ await proc.ready();
89
+ proc.send({ type: "POKE" });
90
+ await proc.wait();
91
+ ```
92
+
93
+
94
+ ## Okay, but what do I use it for?
95
+
96
+ To call the `/chat_complete` endpoint and emit effects (tool calls)
97
+ that the pure function (LLM) produces.
98
+
99
+ Use it on the frontend for things like file upload progress or anything
100
+ that has to be more interactive than a promise but not static enough
101
+ to afford to be a store with the lifetime tied to the app.
102
+
103
+ You can also use it to define components on the server side that have life
104
+ time bounded by incoming request or some kind of a transient state.
105
+
106
+ ## How are the messages processed?
107
+
108
+ Actors are loops iterating over the messages you send to their queue (inbox).
109
+ Get the new message, process it, maybe emit something, wait for the next message.
110
+
111
+ This means when you send three messages to a process -- they will be processed serially
112
+ and their results will not produce a race. You can also ask the process to exit
113
+ and it will not produce any messages once it does. This also cascades to their children.
114
+
115
+
116
+ ## Features
117
+
118
+ - **Processes** — sync or async, same API
119
+ - **Child processes** — `ctx.fork(fn, name)(args)` spawns supervised children
120
+ - **Supervisor** — run and monitor named workers
121
+ - **Reactive state** — `proc.subscribe(cb)` notifies on every state change
122
+ - **Pause/resume** — buffer messages while idle
123
+ - **Pipe** — chain processes so each runs after the previous exits
124
+ - **xfetch** — HTTP requests as processes, with abort support
125
+ - **defineActor** — declarative config for structured actors
126
+
127
+ ## Sender provenance
128
+
129
+ Every message the generator receives is a `[msg, sender]` tuple:
130
+
131
+ ```ts
132
+ const [msg, sender] = yield state;
133
+ // msg: your discriminated message
134
+ // sender: { fromName: string, fromId: symbol }
135
+ ```
136
+
137
+ Messages you send via `ctx.sendSelf()` or `ctx.toParent()` are stamped automatically.
138
+
139
+ ## Install
140
+
141
+ ```sh
142
+ npm install posipaki
143
+ ```
144
+
145
+ ## API
146
+
147
+ ### Processes
148
+
149
+ - `spawnAsync(fn, name)(args)` — create an async process
150
+ - `proc.ready()` — wait for initial state
151
+ - `proc.state` — current reactive state
152
+ - `proc.send(msg, sender)` — inject a message from a named sender
153
+ - `proc.subscribe(cb)` — react to state changes
154
+ - `proc.pause()` / `proc.resume()` — buffer or process messages
155
+ - `proc.wait()` — resolve when the generator completes
156
+
157
+ ### Generator context
158
+
159
+ - `ctx.pname` — process name
160
+ - `ctx.id` — unique symbol
161
+ - `ctx.sendSelf(msg)` — enqueue a message to yourself
162
+ - `ctx.toParent(msg)` — send a message to the parent process
163
+ - `ctx.fork(fn, name)(args)` — spawn a child process
164
+
165
+ ### Sender types
166
+
167
+ - `SenderInfo` — `{ fromName: string, fromId: symbol }`
168
+ - `WithSender<M>` — `[M, SenderInfo]`
169
+ - `WithoutSender<T>` — extracts `M` from `WithSender<M>`
170
+
171
+ ## License
172
+
173
+ MIT
@@ -0,0 +1,48 @@
1
+ import { a as ProcessCtx, r as Message, s as SenderInfo } from "./types-Bau9O_vk.js";
2
+
3
+ //#region src/hooks.d.ts
4
+ /** Returned by onMessage hooks to prevent further dispatch. */
5
+ declare const STOP_SENTINEL: unique symbol;
6
+ /** Type-safe sentinel for short-circuiting onMessage hooks. */
7
+ declare const stopPropagation: () => typeof STOP_SENTINEL;
8
+ /** Return type of onMessage hooks: void (continue) or sentinel (stop). */
9
+ type HookResult = void | typeof STOP_SENTINEL;
10
+ type OnStartHook<State> = (state: State) => void | Promise<void>;
11
+ type OnMessageHook<InMsg extends Message> = (msg: InMsg, sender: SenderInfo) => HookResult | Promise<HookResult>;
12
+ type OnEmitHook<OutMsg extends Message> = (msg: OutMsg) => void;
13
+ type OnChildExitHook = (name: string) => void | Promise<void>;
14
+ type OnStopRequestedHook = () => void | Promise<void>;
15
+ type OnEndHook = (reason: unknown) => void | Promise<void>;
16
+ type OnErrorHook = (err: unknown) => void;
17
+ declare class HookRegistry<State, InMsg extends Message, OutMsg extends Message> {
18
+ onStart: Array<OnStartHook<State>>;
19
+ onMessage: Array<OnMessageHook<InMsg>>;
20
+ onEmit: Array<OnEmitHook<OutMsg>>;
21
+ onChildExit: Array<OnChildExitHook>;
22
+ onStopRequested: Array<OnStopRequestedHook>;
23
+ onEnd: Array<OnEndHook>;
24
+ onError: Array<OnErrorHook>;
25
+ }
26
+ /** A reusable unit of actor behaviour, installed at fork time. */
27
+ interface ActorPlugin<InMsg extends Message = Message, OutMsg extends Message = Message, State = unknown> {
28
+ name: string;
29
+ install(ctx: ProcessCtx<unknown, State, InMsg, OutMsg>): void | Promise<void>;
30
+ }
31
+ /** Transform parent plugins into child plugins. */
32
+ type PluginTransform = (parentPlugins: ActorPlugin[]) => ActorPlugin[];
33
+ /**
34
+ * Interface that plugins can augment via declaration merging.
35
+ * Plugins ship a .d.ts that adds properties to this interface,
36
+ * making them available on `this` in handlers and methods.
37
+ *
38
+ * Example (in a plugin's .d.ts):
39
+ * declare module 'posipaki' {
40
+ * interface ActorDecorated {
41
+ * log: Logger;
42
+ * }
43
+ * }
44
+ */
45
+ interface ActorDecorated {}
46
+ //#endregion
47
+ export { ActorDecorated, ActorPlugin, HookRegistry, HookResult, OnChildExitHook, OnEmitHook, OnEndHook, OnErrorHook, OnMessageHook, OnStartHook, OnStopRequestedHook, PluginTransform, STOP_SENTINEL, stopPropagation };
48
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","names":[],"sources":["../src/hooks.ts"],"mappings":";;;;cAWa,aAAA;AAAb;AAAA,cAGa,eAAA,eAA6B,aAA8B;;KAG5D,UAAA,iBAA2B,aAAa;AAAA,KAIxC,WAAA,WAAsB,KAAA,EAAO,KAAA,YAAiB,OAAO;AAAA,KACrD,aAAA,eAA4B,OAAA,KAAY,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,UAAA,KAAe,UAAA,GAAa,OAAA,CAAQ,UAAA;AAAA,KAChG,UAAA,gBAA0B,OAAA,KAAY,GAAA,EAAK,MAAM;AAAA,KACjD,eAAA,IAAmB,IAAA,oBAAwB,OAAO;AAAA,KAClD,mBAAA,gBAAmC,OAAO;AAAA,KAC1C,SAAA,IAAa,MAAA,qBAA2B,OAAO;AAAA,KAC/C,WAAA,IAAe,GAAY;AAAA,cAI1B,YAAA,sBAAkC,OAAA,iBAAwB,OAAA;EACrE,OAAA,EAAS,KAAA,CAAM,WAAA,CAAY,KAAA;EAC3B,SAAA,EAAW,KAAA,CAAM,aAAA,CAAc,KAAA;EAC/B,MAAA,EAAQ,KAAA,CAAM,UAAA,CAAW,MAAA;EACzB,WAAA,EAAa,KAAA,CAAM,eAAA;EACnB,eAAA,EAAiB,KAAA,CAAM,mBAAA;EACvB,KAAA,EAAO,KAAA,CAAM,SAAA;EACb,OAAA,EAAS,KAAA,CAAM,WAAA;AAAA;;UAOA,WAAA,eACD,OAAA,GAAU,OAAA,iBACT,OAAA,GAAU,OAAA;EAGzB,IAAA;EACA,OAAA,CAAQ,GAAA,EAAK,UAAA,UAAoB,KAAA,EAAO,KAAA,EAAO,MAAA,WAAiB,OAAA;AAAA;AA7BlE;AAAA,KAiCY,eAAA,IAAmB,aAAA,EAAe,WAAA,OAAkB,WAAW;;;;;;;;;;;;;UAgB1D,cAAA"}
package/dist/hooks.js ADDED
@@ -0,0 +1,20 @@
1
+ //#region src/hooks.ts
2
+ /** Returned by onMessage hooks to prevent further dispatch. */
3
+ const STOP_SENTINEL = Symbol("posipaki.stopPropagation");
4
+ /** Type-safe sentinel for short-circuiting onMessage hooks. */
5
+ const stopPropagation = () => STOP_SENTINEL;
6
+ var HookRegistry = class {
7
+ constructor() {
8
+ this.onStart = [];
9
+ this.onMessage = [];
10
+ this.onEmit = [];
11
+ this.onChildExit = [];
12
+ this.onStopRequested = [];
13
+ this.onEnd = [];
14
+ this.onError = [];
15
+ }
16
+ };
17
+ //#endregion
18
+ export { HookRegistry, STOP_SENTINEL, stopPropagation };
19
+
20
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","names":[],"sources":["../src/hooks.ts"],"sourcesContent":["// ── Lifecycle Hooks ──────────────────────────────────────────────────────\n//\n// Extends ProcessCtx and defineActor with observable lifecycle hooks.\n// Hooks are additive — multiple callbacks can register for the same hook\n// point, and they fire in registration order.\n\nimport type { Message, SenderInfo, ProcessCtx } from './types.js';\n\n// ── stop propagation sentinel ────────────────────────────────────────────\n\n/** Returned by onMessage hooks to prevent further dispatch. */\nexport const STOP_SENTINEL = Symbol('posipaki.stopPropagation');\n\n/** Type-safe sentinel for short-circuiting onMessage hooks. */\nexport const stopPropagation = (): typeof STOP_SENTINEL => STOP_SENTINEL;\n\n/** Return type of onMessage hooks: void (continue) or sentinel (stop). */\nexport type HookResult = void | typeof STOP_SENTINEL;\n\n// ── hook function types ──────────────────────────────────────────────────\n\nexport type OnStartHook<State> = (state: State) => void | Promise<void>;\nexport type OnMessageHook<InMsg extends Message> = (msg: InMsg, sender: SenderInfo) => HookResult | Promise<HookResult>;\nexport type OnEmitHook<OutMsg extends Message> = (msg: OutMsg) => void;\nexport type OnChildExitHook = (name: string) => void | Promise<void>;\nexport type OnStopRequestedHook = () => void | Promise<void>;\nexport type OnEndHook = (reason: unknown) => void | Promise<void>;\nexport type OnErrorHook = (err: unknown) => void;\n\n// ── hook registry ────────────────────────────────────────────────────────\n\nexport class HookRegistry<State, InMsg extends Message, OutMsg extends Message> {\n onStart: Array<OnStartHook<State>> = [];\n onMessage: Array<OnMessageHook<InMsg>> = [];\n onEmit: Array<OnEmitHook<OutMsg>> = [];\n onChildExit: Array<OnChildExitHook> = [];\n onStopRequested: Array<OnStopRequestedHook> = [];\n onEnd: Array<OnEndHook> = [];\n onError: Array<OnErrorHook> = [];\n}\n\n// ── plugin types ─────────────────────────────────────────────────────────\n\n\n/** A reusable unit of actor behaviour, installed at fork time. */\nexport interface ActorPlugin<\n InMsg extends Message = Message,\n OutMsg extends Message = Message,\n State = unknown,\n> {\n name: string;\n install(ctx: ProcessCtx<unknown, State, InMsg, OutMsg>): void | Promise<void>;\n}\n\n/** Transform parent plugins into child plugins. */\nexport type PluginTransform = (parentPlugins: ActorPlugin[]) => ActorPlugin[];\n\n// ── type augmentation (Fastify-style) ────────────────────────────────────\n\n/**\n * Interface that plugins can augment via declaration merging.\n * Plugins ship a .d.ts that adds properties to this interface,\n * making them available on `this` in handlers and methods.\n *\n * Example (in a plugin's .d.ts):\n * declare module 'posipaki' {\n * interface ActorDecorated {\n * log: Logger;\n * }\n * }\n */\nexport interface ActorDecorated {}\n"],"mappings":";;AAWA,MAAa,gBAAgB,OAAO,0BAA0B;;AAG9D,MAAa,wBAA8C;AAiB3D,IAAa,eAAb,MAAgF;;iBACzC,CAAC;mBACG,CAAC;gBACN,CAAC;qBACC,CAAC;yBACO,CAAC;eACrB,CAAC;iBACG,CAAC;;AACjC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { a as runDispatchAsync, c as ExitMessage, d as ProcessCtx, f as ProcessFn, i as AsyncProcess, l as Message, m as SupervisorState, n as spawn, o as spawnAsync, p as StopMessage, r as runDispatch, s as AsyncProcessFn, t as Process, u as PipeState } from "./process-C-ERBQY5.js";
1
+ import { a as ProcessCtx, c as SenderOrigin, d as WithSender, f as WithoutSender, h as spawnAsync, i as PipeState, l as StopMessage, m as runDispatchAsync, n as ExitMessage, o as ProcessFn, p as AsyncProcess, r as Message, s as SenderInfo, t as AsyncProcessFn, u as SupervisorState } from "./types-Bau9O_vk.js";
2
+ import { ActorDecorated as ActorDecorated$1, ActorPlugin as ActorPlugin$1, HookRegistry, HookResult as HookResult$1, OnChildExitHook, OnEmitHook, OnEndHook, OnErrorHook, OnMessageHook, OnStartHook as OnStartHook$1, OnStopRequestedHook, PluginTransform as PluginTransform$1, stopPropagation } from "./hooks.js";
3
+ import { n as spawn, r as runDispatch, t as Process } from "./process-B1vevrTc.js";
2
4
 
3
5
  //#region src/adapters.d.ts
4
6
  declare function asyncify<A, S, IM extends Message, OM extends Message>(fn: ProcessFn<A, S, IM, OM>): AsyncProcessFn<A, S, IM, OM>;
@@ -10,17 +12,39 @@ type ActorMessages<M extends Message> = {
10
12
  interface MethodOptions {
11
13
  [key: string]: Function;
12
14
  }
13
- type HandlerFn<InMsg extends Message> = (msg: InMsg) => void | Promise<void>;
15
+ type HandlerFn<InMsg extends Message> = (msg: InMsg, sender: SenderInfo) => void | Promise<void>;
14
16
  type HandlerOptions<InMsg extends Message> = Omit<{ [K in InMsg["type"]]: HandlerFn<Extract<InMsg, {
15
17
  type: K;
16
18
  }>> }, "STOP">;
17
19
  interface ActorDefinition<Args, ExposedState, InMsg extends Message, OutMsg extends Message, Handlers extends HandlerOptions<InMsg>> {
18
20
  fn: AsyncProcessFn<Args, ExposedState, InMsg, OutMsg>;
19
21
  config: ActorConfig<Args, any, ExposedState, InMsg, OutMsg, {}, Handlers>;
22
+ /** Preferred process name (from config.name). */
23
+ name?: string;
24
+ /** Raw plugin config (array or transform). Resolved at fork time. @internal */
25
+ _pluginsRaw?: ActorPlugin[] | PluginTransform;
26
+ /** Spawn this actor as a standalone process. */
27
+ spawn(args: Args): AsyncProcess<Args, ExposedState, InMsg, OutMsg>;
28
+ /** Spawn this actor as a child of the calling process. */
29
+ spawnAsChild(ctx: ProcessCtx<any, any, any, any>, args: Args, name?: string): AsyncProcess<Args, ExposedState, InMsg, OutMsg>;
30
+ }
31
+ interface ActorHooksConfig<Args, InternalState, ExposedState, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions, Handlers extends HandlerOptions<InMsg>> {
32
+ onStart?: OnStartHook<ExposedState>;
33
+ onMessage?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, msg: InMsg, sender: SenderInfo) => HookResult | Promise<HookResult>;
34
+ onEmit?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, msg: OutMsg) => void;
35
+ onChildExit?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, name: string) => void | Promise<void>;
36
+ onStopRequested?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>) => void | Promise<void>;
37
+ onEnd?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, reason: unknown) => void | Promise<void>;
38
+ onError?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, err: unknown) => void;
20
39
  }
21
40
  interface ActorConfig<Args, InternalState, ExposedState, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions, Handlers extends HandlerOptions<InMsg>> {
22
41
  initialState: InternalState | ((this: void, args: Args, ctx: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>["ctx"]) => InternalState);
23
42
  expose?: (internalState: InternalState) => ExposedState;
43
+ /** Preferred process name. Used by ctx.fork() when no explicit name is given. */
44
+ name?: string;
45
+ hooks?: ActorHooksConfig<Args, InternalState, InMsg, OutMsg, Methods, Handlers>;
46
+ /** Plugins installed at fork time. Array = replace, function = transform parent chain. */
47
+ plugins?: ActorPlugin[] | PluginTransform;
24
48
  outMessages?: ActorMessages<OutMsg>;
25
49
  inMessages?: ActorMessages<InMsg>;
26
50
  onStart?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, args: Args) => void | Promise<void>;
@@ -28,10 +52,10 @@ interface ActorConfig<Args, InternalState, ExposedState, InMsg extends Message,
28
52
  onEnd?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, reason?: unknown) => void | Promise<void>;
29
53
  handlers: Handlers & ThisType<ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>>;
30
54
  methods?: Methods & ThisType<ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>>;
31
- onUnhandled?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, msg: InMsg) => void | Promise<void>;
55
+ onUnhandled?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, msg: InMsg, sender: SenderInfo) => void | Promise<void>;
32
56
  onChildExit?: (this: ActorContext<Args, InternalState, InMsg, OutMsg, Methods, Handlers>, name: string, reason: ExitMessage) => void | Promise<void>;
33
57
  }
34
- type ActorContext<Args, InternalState, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions, Handlers extends HandlerOptions<InMsg>> = Methods & {
58
+ type ActorContext<Args, InternalState, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions, Handlers extends HandlerOptions<InMsg>> = Methods & ActorDecorated & {
35
59
  state: InternalState;
36
60
  name: string;
37
61
  id: symbol;
@@ -39,7 +63,7 @@ type ActorContext<Args, InternalState, InMsg extends Message, OutMsg extends Mes
39
63
  agreeToStop: () => void;
40
64
  exit: (reason?: unknown) => void;
41
65
  $child: Record<string, AsyncProcess<unknown, unknown, Message, Message>>;
42
- fork<A, S, IM extends Message, OM extends Message, H extends HandlerOptions<IM>>(fn: AsyncProcessFn<A, S, IM, OM> | ActorDefinition<A, S, IM, OM, H>, name: string, args?: A): AsyncProcess<A, S, IM, OM>;
66
+ fork<A, S, IM extends Message, OM extends Message, H extends HandlerOptions<IM>>(fn: AsyncProcessFn<A, S, IM, OM> | ActorDefinition<A, S, IM, OM, H>, name?: string, args?: A): AsyncProcess<A, S, IM, OM>;
43
67
  ctx: ProcessCtx<Args, InternalState, InMsg, OutMsg>;
44
68
  };
45
69
  //#endregion
@@ -47,5 +71,5 @@ type ActorContext<Args, InternalState, InMsg extends Message, OutMsg extends Mes
47
71
  declare function defineMessages<OutMsg extends Message = Message>(): ActorMessages<OutMsg>;
48
72
  declare function defineActor<Args, InternalState, ExposedState, InMsg extends Message, OutMsg extends Message, Methods extends MethodOptions, Handlers extends HandlerOptions<InMsg>>(config: ActorConfig<Args, InternalState, ExposedState, InMsg, OutMsg, Methods, Handlers>): ActorDefinition<Args, ExposedState, InMsg, OutMsg, Handlers>;
49
73
  //#endregion
50
- export { type ActorConfig, type ActorContext, type ActorDefinition, AsyncProcess, type AsyncProcessFn, type ExitMessage, type HandlerFn, type HandlerOptions, type Message, type MethodOptions, type PipeState, Process, type ProcessCtx, type ProcessFn, type StopMessage, type SupervisorState, asyncify, defineActor, defineMessages, runDispatch, runDispatchAsync, spawn, spawnAsync };
74
+ export { type ActorConfig, type ActorContext, type ActorDecorated$1 as ActorDecorated, type ActorDefinition, type ActorPlugin$1 as ActorPlugin, AsyncProcess, type AsyncProcessFn, type ExitMessage, type HandlerFn, type HandlerOptions, HookRegistry, type HookResult$1 as HookResult, type Message, type MethodOptions, type OnChildExitHook, type OnEmitHook, type OnEndHook, type OnErrorHook, type OnMessageHook, type OnStartHook$1 as OnStartHook, type OnStopRequestedHook, type PipeState, type PluginTransform$1 as PluginTransform, Process, type ProcessCtx, type ProcessFn, type SenderInfo, type SenderOrigin, type StopMessage, type SupervisorState, type WithSender, type WithoutSender, asyncify, defineActor, defineMessages, runDispatch, runDispatchAsync, spawn, spawnAsync, stopPropagation };
51
75
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/adapters.ts","../src/actor-types.ts","../src/define-actor.ts"],"mappings":";;;iBAEgB,QAAA,kBAA0B,OAAA,aAAoB,OAAA,EAC5D,EAAA,EAAI,SAAA,CAAU,CAAA,EAAG,CAAA,EAAG,EAAA,EAAI,EAAA,IACvB,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,EAAA,EAAI,EAAA;;;KCY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