depa-actor 0.1.2 → 0.2.1

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 (96) hide show
  1. package/dist/addressing.d.ts +100 -0
  2. package/dist/addressing.d.ts.map +1 -0
  3. package/dist/addressing.js +409 -0
  4. package/dist/addressing.js.map +1 -0
  5. package/dist/core/ActorSystem.d.ts +1 -1
  6. package/dist/core/ActorSystem.d.ts.map +1 -1
  7. package/dist/dispatch/ActorDispatchAdapter.d.ts +75 -18
  8. package/dist/dispatch/ActorDispatchAdapter.d.ts.map +1 -1
  9. package/dist/dispatch/ActorDispatchAdapter.js +109 -24
  10. package/dist/dispatch/ActorDispatchAdapter.js.map +1 -1
  11. package/dist/execution/commandDeque.d.ts +121 -0
  12. package/dist/execution/commandDeque.d.ts.map +1 -0
  13. package/dist/execution/commandDeque.js +415 -0
  14. package/dist/execution/commandDeque.js.map +1 -0
  15. package/dist/execution/dispatcher.d.ts +72 -0
  16. package/dist/execution/dispatcher.d.ts.map +1 -0
  17. package/dist/execution/dispatcher.js +77 -0
  18. package/dist/execution/dispatcher.js.map +1 -0
  19. package/dist/execution/index.d.ts +7 -0
  20. package/dist/execution/index.d.ts.map +1 -0
  21. package/dist/execution/index.js +4 -0
  22. package/dist/execution/index.js.map +1 -0
  23. package/dist/execution/stack.d.ts +24 -0
  24. package/dist/execution/stack.d.ts.map +1 -0
  25. package/dist/execution/stack.js +84 -0
  26. package/dist/execution/stack.js.map +1 -0
  27. package/dist/index.d.ts +21 -15
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +15 -8
  30. package/dist/index.js.map +1 -1
  31. package/dist/orchestration/index.d.ts +8 -8
  32. package/dist/orchestration/index.d.ts.map +1 -1
  33. package/dist/orchestration/index.js +6 -6
  34. package/dist/orchestration/index.js.map +1 -1
  35. package/dist/orchestration/presets/aiAgent.d.ts +2 -2
  36. package/dist/orchestration/presets/aiAgent.d.ts.map +1 -1
  37. package/dist/orchestration/recovery.d.ts +2 -2
  38. package/dist/orchestration/recovery.d.ts.map +1 -1
  39. package/dist/orchestration/reducer.d.ts +2 -2
  40. package/dist/orchestration/reducer.d.ts.map +1 -1
  41. package/dist/orchestration/reducer.js +2 -2
  42. package/dist/orchestration/reducer.js.map +1 -1
  43. package/dist/orchestration/runtimeAdapter.d.ts +3 -3
  44. package/dist/orchestration/runtimeAdapter.d.ts.map +1 -1
  45. package/dist/orchestration/scheduler.d.ts +2 -2
  46. package/dist/orchestration/scheduler.d.ts.map +1 -1
  47. package/dist/orchestration/types.d.ts +1 -1
  48. package/dist/orchestration/types.d.ts.map +1 -1
  49. package/dist/pipeline/ActorPipeline.d.ts +36 -9
  50. package/dist/pipeline/ActorPipeline.d.ts.map +1 -1
  51. package/dist/pipeline/ActorPipeline.js +26 -16
  52. package/dist/pipeline/ActorPipeline.js.map +1 -1
  53. package/dist/runtime/ActorRuntime.d.ts +2 -2
  54. package/dist/runtime/ActorRuntime.d.ts.map +1 -1
  55. package/dist/runtime/ActorRuntime.js +1 -1
  56. package/dist/runtime/ActorRuntime.js.map +1 -1
  57. package/dist-cjs/addressing.cjs +424 -0
  58. package/dist-cjs/core/ActorSystem.cjs +172 -0
  59. package/dist-cjs/core/types.cjs +10 -0
  60. package/dist-cjs/dispatch/ActorDispatchAdapter.cjs +125 -0
  61. package/dist-cjs/execution/commandDeque.cjs +430 -0
  62. package/dist-cjs/execution/dispatcher.cjs +79 -0
  63. package/dist-cjs/execution/index.cjs +24 -0
  64. package/dist-cjs/execution/stack.cjs +88 -0
  65. package/dist-cjs/index.cjs +77 -0
  66. package/dist-cjs/orchestration/index.cjs +19 -0
  67. package/dist-cjs/orchestration/presets/aiAgent.cjs +40 -0
  68. package/dist-cjs/orchestration/recovery.cjs +112 -0
  69. package/dist-cjs/orchestration/reducer.cjs +276 -0
  70. package/dist-cjs/orchestration/runtimeAdapter.cjs +14 -0
  71. package/dist-cjs/orchestration/scheduler.cjs +86 -0
  72. package/dist-cjs/orchestration/types.cjs +14 -0
  73. package/dist-cjs/package.json +3 -0
  74. package/dist-cjs/pipeline/ActorPipeline.cjs +44 -0
  75. package/dist-cjs/runtime/ActorRuntime.cjs +77 -0
  76. package/dist-cjs/runtime/completion.cjs +75 -0
  77. package/dist-cjs/runtime/indexing.cjs +34 -0
  78. package/dist-cjs/runtime/snapshot.cjs +14 -0
  79. package/package.json +9 -4
  80. package/src/addressing.ts +756 -0
  81. package/src/core/ActorSystem.ts +1 -1
  82. package/src/dispatch/ActorDispatchAdapter.ts +219 -48
  83. package/src/execution/commandDeque.ts +656 -0
  84. package/src/execution/dispatcher.ts +188 -0
  85. package/src/execution/index.ts +58 -0
  86. package/src/execution/stack.ts +130 -0
  87. package/src/index.ts +121 -16
  88. package/src/orchestration/index.ts +8 -8
  89. package/src/orchestration/presets/aiAgent.ts +2 -2
  90. package/src/orchestration/recovery.ts +2 -2
  91. package/src/orchestration/reducer.ts +3 -3
  92. package/src/orchestration/runtimeAdapter.ts +3 -3
  93. package/src/orchestration/scheduler.ts +2 -2
  94. package/src/orchestration/types.ts +1 -1
  95. package/src/pipeline/ActorPipeline.ts +104 -58
  96. package/src/runtime/ActorRuntime.ts +2 -2
@@ -1,74 +1,106 @@
1
1
  /**
2
2
  * depa-actor — ActorPipeline
3
3
  *
4
- * Adapts the DOP 6-step pipeline (from depa-processor) to actor context.
4
+ * Adapts the DOP 6-step pipeline to actor context by REUSING the depa-processor
5
+ * `component` primitives (DEPA dimension chain Processor → Actor): the 6-step
6
+ * orchestration is delegated to `runByFuncStyleAdapter`, identity/null seams come
7
+ * from `stdMake*`, and the core-logic seam is `StdInnerLogic` verbatim — this module
8
+ * no longer re-implements a parallel copy of `component/types.ts`.
5
9
  *
6
- * Mapping:
10
+ * Mapping (outer dimension):
7
11
  * OuterRuntime = ActorSelf
8
12
  * OuterInput = envelope payload
9
13
  * OuterConfig = actor state
10
14
  *
15
+ * Step 6 (output) is adapted with `TOuterOutput = void`: actor output is a side
16
+ * effect (write `self.state` / `self.send`), not a returned value. This thinly
17
+ * adapts depa-processor's pure-function `StdOuterOutputAdapter` without leaking
18
+ * actor semantics back into the generic primitive.
19
+ *
11
20
  * createPipelineHandler() wraps a pipeline definition into an ActorHandler.
12
21
  */
13
22
 
23
+ import { runByFuncStyleAdapter } from 'depa-processor';
24
+ import type {
25
+ StdOuterComputedAdapter,
26
+ StdInnerRuntimeAdapter,
27
+ StdInnerInputAdapter,
28
+ StdInnerConfigAdapter,
29
+ StdInnerLogic,
30
+ StdOuterOutputAdapter,
31
+ } from 'depa-processor';
14
32
  import type {
15
33
  MailboxSchema,
16
34
  ActorSelf,
17
35
  ActorHandler,
18
- } from '../core/types';
36
+ } from '../core/types.js';
19
37
 
20
38
  // ─── Pipeline Adapter Types ──────────────────────────────────────────
39
+ // Thin actor-flavoured aliases over the depa-processor component adapters.
40
+ // Outer dimension = (ActorSelf, payload, state); the seam contracts are reused
41
+ // 1:1 from `depa-processor` rather than re-declared.
21
42
 
22
43
  export type PipelineDerivedAdapter<
23
44
  TRuntime, TSchema extends MailboxSchema, TState, TDerived,
24
- > = (
25
- self: ActorSelf<TRuntime, TSchema, TState>,
26
- payload: TSchema[keyof TSchema & string],
27
- state: TState,
28
- ) => TDerived;
45
+ > = StdOuterComputedAdapter<
46
+ ActorSelf<TRuntime, TSchema, TState>,
47
+ TSchema[keyof TSchema & string],
48
+ TState,
49
+ TDerived
50
+ >;
29
51
 
30
52
  export type PipelineInnerRuntimeAdapter<
31
53
  TRuntime, TSchema extends MailboxSchema, TState, TDerived, TInnerRuntime,
32
- > = (
33
- self: ActorSelf<TRuntime, TSchema, TState>,
34
- payload: TSchema[keyof TSchema & string],
35
- state: TState,
36
- derived: TDerived,
37
- ) => TInnerRuntime;
54
+ > = StdInnerRuntimeAdapter<
55
+ ActorSelf<TRuntime, TSchema, TState>,
56
+ TSchema[keyof TSchema & string],
57
+ TState,
58
+ TDerived,
59
+ TInnerRuntime
60
+ >;
38
61
 
39
62
  export type PipelineInnerInputAdapter<
40
63
  TRuntime, TSchema extends MailboxSchema, TState, TDerived, TInnerInput,
41
- > = (
42
- self: ActorSelf<TRuntime, TSchema, TState>,
43
- payload: TSchema[keyof TSchema & string],
44
- state: TState,
45
- derived: TDerived,
46
- ) => TInnerInput;
64
+ > = StdInnerInputAdapter<
65
+ ActorSelf<TRuntime, TSchema, TState>,
66
+ TSchema[keyof TSchema & string],
67
+ TState,
68
+ TDerived,
69
+ TInnerInput
70
+ >;
47
71
 
48
72
  export type PipelineInnerConfigAdapter<
49
73
  TRuntime, TSchema extends MailboxSchema, TState, TDerived, TInnerConfig,
50
- > = (
51
- self: ActorSelf<TRuntime, TSchema, TState>,
52
- payload: TSchema[keyof TSchema & string],
53
- state: TState,
54
- derived: TDerived,
55
- ) => TInnerConfig;
74
+ > = StdInnerConfigAdapter<
75
+ ActorSelf<TRuntime, TSchema, TState>,
76
+ TSchema[keyof TSchema & string],
77
+ TState,
78
+ TDerived,
79
+ TInnerConfig
80
+ >;
56
81
 
57
- export type PipelineCoreLogic<TInnerRuntime, TInnerInput, TInnerConfig, TInnerOutput> = (
58
- runtime: TInnerRuntime,
59
- input: TInnerInput,
60
- config: TInnerConfig,
61
- ) => TInnerOutput | Promise<TInnerOutput>;
82
+ /**
83
+ * Core business logic seam — reuses depa-processor `StdInnerLogic` verbatim:
84
+ * (runtime, input, config) => output | Promise<output>.
85
+ */
86
+ export type PipelineCoreLogic<TInnerRuntime, TInnerInput, TInnerConfig, TInnerOutput> =
87
+ StdInnerLogic<TInnerRuntime, TInnerInput, TInnerConfig, TInnerOutput>;
62
88
 
89
+ /**
90
+ * Step 6 output adapter — actor variant with `TOuterOutput = void`.
91
+ * The adapter performs side effects (write state / send messages) and returns
92
+ * nothing. This is the depa-processor `StdOuterOutputAdapter` specialised to void.
93
+ */
63
94
  export type PipelineOutputAdapter<
64
95
  TRuntime, TSchema extends MailboxSchema, TState, TDerived, TInnerOutput,
65
- > = (
66
- self: ActorSelf<TRuntime, TSchema, TState>,
67
- payload: TSchema[keyof TSchema & string],
68
- state: TState,
69
- derived: TDerived,
70
- innerOutput: TInnerOutput,
71
- ) => void | Promise<void>;
96
+ > = StdOuterOutputAdapter<
97
+ ActorSelf<TRuntime, TSchema, TState>,
98
+ TSchema[keyof TSchema & string],
99
+ TState,
100
+ TDerived,
101
+ TInnerOutput,
102
+ void | Promise<void>
103
+ >;
72
104
 
73
105
  // ─── Pipeline Definition ─────────────────────────────────────────────
74
106
 
@@ -92,6 +124,14 @@ export interface ActorPipelineDef<
92
124
 
93
125
  // ─── createPipelineHandler ───────────────────────────────────────────
94
126
 
127
+ /**
128
+ * Wrap a pipeline definition into an ActorHandler by delegating the 6-step
129
+ * orchestration to depa-processor `runByFuncStyleAdapter`.
130
+ *
131
+ * Outer dimension: runtime = self, input = payload, config = state.
132
+ * Step 6 produces `void` — `runByFuncStyleAdapter` runs the output adapter for its
133
+ * side effects and the (void) return value is discarded.
134
+ */
95
135
  export function createPipelineHandler<
96
136
  TRuntime,
97
137
  TSchema extends MailboxSchema,
@@ -108,25 +148,31 @@ export function createPipelineHandler<
108
148
  >,
109
149
  ): ActorHandler<TRuntime, TSchema, TState> {
110
150
  return async (self, envelope) => {
111
- const payload = envelope.payload;
112
- const state = self.state;
113
-
114
- // Step 1: Compute derived
115
- const derived = pipeline.computeDerived(self, payload, state);
116
-
117
- // Step 2: Transform runtime
118
- const innerRuntime = pipeline.innerRuntime(self, payload, state, derived);
119
-
120
- // Step 3: Transform input
121
- const innerInput = pipeline.innerInput(self, payload, state, derived);
122
-
123
- // Step 4: Transform config
124
- const innerConfig = pipeline.innerConfig(self, payload, state, derived);
125
-
126
- // Step 5: Core logic
127
- const innerOutput = await pipeline.coreLogic(innerRuntime, innerInput, innerConfig);
128
-
129
- // Step 6: Output (side effects on actor state / send messages)
130
- await pipeline.output(self, payload, state, derived, innerOutput);
151
+ // `runByFuncStyleAdapter` returns the output adapter's value verbatim (without
152
+ // awaiting it). Capture it and await so an async step-6 side effect (write
153
+ // state / send messages) is fully settled before the handler resolves —
154
+ // preserving the original `await pipeline.output(...)` semantics.
155
+ const outputResult = await runByFuncStyleAdapter<
156
+ ActorSelf<TRuntime, TSchema, TState>,
157
+ TSchema[keyof TSchema & string],
158
+ TState,
159
+ TDerived,
160
+ void | Promise<void>,
161
+ TInnerRuntime,
162
+ TInnerInput,
163
+ TInnerConfig,
164
+ TInnerOutput
165
+ >(
166
+ self,
167
+ envelope.payload,
168
+ self.state,
169
+ pipeline.computeDerived,
170
+ pipeline.innerRuntime,
171
+ pipeline.innerInput,
172
+ pipeline.innerConfig,
173
+ pipeline.coreLogic,
174
+ pipeline.output,
175
+ );
176
+ await outputResult;
131
177
  };
132
178
  }
@@ -12,8 +12,8 @@ import type {
12
12
  ActorDef,
13
13
  ActorRef,
14
14
  ActorLogEntry,
15
- } from '../core/types';
16
- import { ActorSystem } from '../core/ActorSystem';
15
+ } from '../core/types.js';
16
+ import { ActorSystem } from '../core/ActorSystem.js';
17
17
 
18
18
  // ─── Plugin ──────────────────────────────────────────────────────────
19
19