@eduardorenani/atlasjs 0.1.0-alpha.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 (67) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +113 -0
  3. package/dist/actorName.d.ts +2 -0
  4. package/dist/actorName.d.ts.map +1 -0
  5. package/dist/actorName.js +24 -0
  6. package/dist/actorName.js.map +1 -0
  7. package/dist/buildActions.d.ts +11 -0
  8. package/dist/buildActions.d.ts.map +1 -0
  9. package/dist/buildActions.js +23 -0
  10. package/dist/buildActions.js.map +1 -0
  11. package/dist/buildActiveState.d.ts +43 -0
  12. package/dist/buildActiveState.d.ts.map +1 -0
  13. package/dist/buildActiveState.js +194 -0
  14. package/dist/buildActiveState.js.map +1 -0
  15. package/dist/buildActors.d.ts +4 -0
  16. package/dist/buildActors.d.ts.map +1 -0
  17. package/dist/buildActors.js +40 -0
  18. package/dist/buildActors.js.map +1 -0
  19. package/dist/buildPassiveState.d.ts +19 -0
  20. package/dist/buildPassiveState.d.ts.map +1 -0
  21. package/dist/buildPassiveState.js +59 -0
  22. package/dist/buildPassiveState.js.map +1 -0
  23. package/dist/compile.d.ts +6 -0
  24. package/dist/compile.d.ts.map +1 -0
  25. package/dist/compile.js +164 -0
  26. package/dist/compile.js.map +1 -0
  27. package/dist/contextLift.d.ts +35 -0
  28. package/dist/contextLift.d.ts.map +1 -0
  29. package/dist/contextLift.js +172 -0
  30. package/dist/contextLift.js.map +1 -0
  31. package/dist/defineAgent.d.ts +60 -0
  32. package/dist/defineAgent.d.ts.map +1 -0
  33. package/dist/defineAgent.js +79 -0
  34. package/dist/defineAgent.js.map +1 -0
  35. package/dist/defineCompoundMode.d.ts +77 -0
  36. package/dist/defineCompoundMode.d.ts.map +1 -0
  37. package/dist/defineCompoundMode.js +79 -0
  38. package/dist/defineCompoundMode.js.map +1 -0
  39. package/dist/defineMode.d.ts +89 -0
  40. package/dist/defineMode.d.ts.map +1 -0
  41. package/dist/defineMode.js +95 -0
  42. package/dist/defineMode.js.map +1 -0
  43. package/dist/index.d.ts +6 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +10 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/injectEnd.d.ts +10 -0
  48. package/dist/injectEnd.d.ts.map +1 -0
  49. package/dist/injectEnd.js +106 -0
  50. package/dist/injectEnd.js.map +1 -0
  51. package/dist/types.d.ts +539 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +51 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/validateRoutes.d.ts +2 -0
  56. package/dist/validateRoutes.d.ts.map +1 -0
  57. package/dist/validateRoutes.js +107 -0
  58. package/dist/validateRoutes.js.map +1 -0
  59. package/dist/validateTargets.d.ts +2 -0
  60. package/dist/validateTargets.d.ts.map +1 -0
  61. package/dist/validateTargets.js +132 -0
  62. package/dist/validateTargets.js.map +1 -0
  63. package/dist/walk.d.ts +20 -0
  64. package/dist/walk.d.ts.map +1 -0
  65. package/dist/walk.js +35 -0
  66. package/dist/walk.js.map +1 -0
  67. package/package.json +63 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Eduardo Renani
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # @eduardorenani/atlasjs
2
+
3
+ Mode-based agent orchestration on top of [XState v5](https://stately.ai/docs/xstate).
4
+
5
+ > **Alpha.** The API is stable enough to build with, but minor 0.x bumps may still break shape. Pin exact versions.
6
+
7
+ ## Why
8
+
9
+ Building an AI agent on a raw state machine forces every mode (greeting, answering, teaching, etc.) into ad-hoc actor/onDone/guard plumbing. `@eduardorenani/atlasjs` collapses that into three constructors and a four-outcome contract so the agent's structure stays in the modes — not in the wiring.
10
+
11
+ - A **mode** is a unit of agentic work with one well-defined **goal**.
12
+ - Every mode terminates with one of four **outcomes**: `achieved` / `retry` / `abandoned` / `error`.
13
+ - **Exits are bound to outcomes** — routing is over the outcome plus its typed payload, never over arbitrary conditions.
14
+
15
+ The type system rejects anything that does not fit: active+passive mixing in the same leaf mode, modes missing outcomes, cross-compound targets, `retry` with an arbitrary target.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install @eduardorenani/atlasjs@alpha xstate
21
+ ```
22
+
23
+ `xstate@^5` is a peer dependency — install it explicitly. Node 20+ required, ESM only.
24
+
25
+ ## 30-second tour
26
+
27
+ A trivial agent with two modes: `listening` waits for a user message, `answering` calls an LLM and routes back to `listening`.
28
+
29
+ ```ts
30
+ import { createActor } from "xstate";
31
+ import { defineMode, defineAgent } from "@eduardorenani/atlasjs";
32
+
33
+ type Ctx = { question: string; answer: string };
34
+ type Ev = { type: "ASK"; question: string };
35
+
36
+ // Passive mode — waits for an event. Inline callbacks aren't allowed in `on`;
37
+ // transitions reference reusable actions declared on `defineAgent` below.
38
+ const listening = defineMode<Ctx, Ev>({
39
+ on: {
40
+ ASK: {
41
+ target: "answering",
42
+ actions: "captureQuestion",
43
+ },
44
+ },
45
+ });
46
+
47
+ // Active mode — runs an async `behavior` and dispatches on its outcome.
48
+ // All three outcome buckets (achieved / retry / abandoned) are required;
49
+ // pass `[]` for retry when there's no retry policy.
50
+ const answering = defineMode<Ctx, Ev, { answer: string }>({
51
+ input: ({ context }) => ({ question: context.question }),
52
+ behavior: async ({ input }) => {
53
+ const { question } = input as { question: string };
54
+ const answer = await callYourLLM(question);
55
+ return { outcome: "achieved", payload: { answer } };
56
+ },
57
+ routes: {
58
+ achieved: {
59
+ target: "listening",
60
+ assign: ({ payload }) => ({ answer: payload.answer }),
61
+ },
62
+ retry: [],
63
+ abandoned: { target: "listening" },
64
+ },
65
+ });
66
+
67
+ const machine = defineAgent<
68
+ Ctx,
69
+ Ev,
70
+ { listening: typeof listening; answering: typeof answering }
71
+ >({
72
+ id: "qa",
73
+ initial: "listening",
74
+ context: { question: "", answer: "" },
75
+ events: {} as Ev,
76
+ actions: {
77
+ captureQuestion: ({ event }) => ({ question: event.question }),
78
+ },
79
+ modes: { listening, answering },
80
+ });
81
+
82
+ const actor = createActor(machine).start();
83
+ actor.send({ type: "ASK", question: "What is a mode?" });
84
+ ```
85
+
86
+ `behavior` returns `{ outcome, payload }`. The route on `achieved` is the **only** way out of a successful run — there is no untyped escape hatch.
87
+
88
+ ## The three constructors
89
+
90
+ | Constructor | Purpose |
91
+ | -------------------- | ------------------------------------------------------------------------- |
92
+ | `defineMode` | A leaf mode. Pass `{ input, behavior, routes }` for active, `{ on }` for passive. Mixing is a compile error. |
93
+ | `defineCompoundMode` | A composite of nested modes. Routes to `END` to exit; the enclosing scope's `onDone` picks the destination. |
94
+ | `defineAgent` | The top-level entry. Compiles to an XState machine ready for `createActor`. |
95
+
96
+ ## Concepts in 60 seconds
97
+
98
+ - **Active mode** — runs an async `behavior` that returns `ModeOutput<TPayload>`. Routing is declared upfront under `routes.{achieved,retry,abandoned}`. Optional `routes.error` catches rejections; if absent, errors re-throw above the actor (no silent swallow).
99
+ - **Passive mode** — waits for events declared in `on`. Transitions reference named `actions` on `defineAgent`, never inline closures (keeps DD-004 churn out of state files).
100
+ - **Compound mode** — groups child modes under an `initial` slot. Children exit the compound by routing to `END`; the parent's `onDone` decides where to go next. Compounds can declare lexically-scoped `context` (inherited keys + local resets on re-entry).
101
+ - **Deps** — `defineAgent({ deps: { ... } })` exposes a frozen container of external resources (DB, logger, LLM client) to every `input` / `behavior` / `assign`. Defaults to `{}` when omitted.
102
+ - **JSON-safe context** — `context` (root and compound-local) is checked against `JsonCompatible<T>` so snapshots round-trip through any storage layer.
103
+
104
+ ## Where to go next
105
+
106
+ - **API reference** — the type signatures and JSDoc in [`packages/atlas/src/types.ts`](https://github.com/EduardoRenani/atlas/blob/main/packages/atlas/src/types.ts) are the source of truth.
107
+ - **Worked example** — [`examples/zoe/`](https://github.com/EduardoRenani/atlas/tree/main/examples/zoe) is a CLI agent that classifies user intent and dispatches across greetings / improvising / socratic modes.
108
+ - **Specs** — the API contract lives in [`docs/specs/004-xstate-agent-wrapper.md`](https://github.com/EduardoRenani/atlas/blob/main/docs/specs/004-xstate-agent-wrapper.md), [`005-agent-deps-and-stringifiable-context.md`](https://github.com/EduardoRenani/atlas/blob/main/docs/specs/005-agent-deps-and-stringifiable-context.md), and [`006-modes-not-states.md`](https://github.com/EduardoRenani/atlas/blob/main/docs/specs/006-modes-not-states.md).
109
+ - **Design decisions** — [`docs/design-decisions.md`](https://github.com/EduardoRenani/atlas/blob/main/docs/design-decisions.md) records the "why" behind the four-outcome contract, goal-bound exits, and the modes-not-states vocabulary.
110
+
111
+ ## License
112
+
113
+ Apache-2.0. See [`LICENSE`](https://github.com/EduardoRenani/atlas/blob/main/LICENSE).
@@ -0,0 +1,2 @@
1
+ export declare function actorName(path: string): string;
2
+ //# sourceMappingURL=actorName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actorName.d.ts","sourceRoot":"","sources":["../src/actorName.ts"],"names":[],"mappings":"AAWA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY9C"}
@@ -0,0 +1,24 @@
1
+ // Derive the XState actor name for an active `Mode` (leaf) from its
2
+ // root-relative path. Spec: docs/design-decisions.md DD-008 — actor names
3
+ // are `<camelCase(path)>Node`. Encoding the convention as code (here) makes
4
+ // DD-008 an invariant enforced by the compiler, not a hand-maintained rule.
5
+ //
6
+ // Examples:
7
+ // "listening" → "listeningNode"
8
+ // "classifying" → "classifyingNode"
9
+ // "socratic.evaluating" → "socraticEvaluatingNode"
10
+ // "greetings.thinking" → "greetingsThinkingNode"
11
+ export function actorName(path) {
12
+ if (path === "") {
13
+ throw new Error("atlas/actorName: empty path");
14
+ }
15
+ const segments = path.split(".");
16
+ if (segments.some((s) => s === "")) {
17
+ throw new Error(`atlas/actorName: malformed path "${path}" (empty segment)`);
18
+ }
19
+ const camel = segments
20
+ .map((seg, i) => (i === 0 ? seg : seg.charAt(0).toUpperCase() + seg.slice(1)))
21
+ .join("");
22
+ return `${camel}Node`;
23
+ }
24
+ //# sourceMappingURL=actorName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actorName.js","sourceRoot":"","sources":["../src/actorName.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,EAAE;AACF,YAAY;AACZ,8CAA8C;AAC9C,gDAAgD;AAChD,uDAAuD;AACvD,sDAAsD;AAEtD,MAAM,UAAU,SAAS,CAAC,IAAY;IAClC,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,mBAAmB,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ;SACjB,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC7E,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,OAAO,GAAG,KAAK,MAAM,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { assign } from "xstate";
2
+ type UserActionCallback = (args: {
3
+ context: unknown;
4
+ event: {
5
+ type: string;
6
+ };
7
+ deps: Readonly<Record<string, unknown>>;
8
+ }) => object;
9
+ export declare function buildActions(actions: Readonly<Record<string, UserActionCallback>> | undefined, deps: Readonly<Record<string, unknown>>): Record<string, ReturnType<typeof assign>>;
10
+ export {};
11
+ //# sourceMappingURL=buildActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildActions.d.ts","sourceRoot":"","sources":["../src/buildActions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3C,KAAK,MAAM,CAAC;AAEb,wBAAgB,YAAY,CACxB,OAAO,EACD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,GAC5C,SAAS,EACf,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAO3C"}
@@ -0,0 +1,23 @@
1
+ // Wrap `defineAgent.actions` callbacks so each lives in
2
+ // `setup({ actions: { name: assign(...) } })`. Spec:
3
+ // docs/specs/004-tasks.md Phase 5.5 + docs/specs/004-xstate-agent-wrapper.md
4
+ // §"Actions: named in passive, inline in routes" + §Mapping.
5
+ // Spec 005: the wrapper closes over the agent's frozen `deps` reference
6
+ // and threads it into every named action's argument envelope.
7
+ //
8
+ // The user wrote a plain callback returning `Partial<TContext>`. The wrapper
9
+ // is the only place that calls `xstate.assign(...)` for these — user code
10
+ // never imports from `xstate`. The callback's return type is forwarded to
11
+ // XState untouched (a runtime identity — the wrapper just adds the assign
12
+ // envelope so XState applies the patch to the context store).
13
+ import { assign } from "xstate";
14
+ export function buildActions(actions, deps) {
15
+ if (actions === undefined)
16
+ return {};
17
+ const out = {};
18
+ for (const [name, callback] of Object.entries(actions)) {
19
+ out[name] = assign(({ context, event }) => callback({ context, event, deps }));
20
+ }
21
+ return out;
22
+ }
23
+ //# sourceMappingURL=buildActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildActions.js","sourceRoot":"","sources":["../src/buildActions.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,qDAAqD;AACrD,6EAA6E;AAC7E,6DAA6D;AAC7D,wEAAwE;AACxE,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,8DAA8D;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,MAAM,UAAU,YAAY,CACxB,OAEe,EACf,IAAuC;IAEvC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,GAAG,GAA8C,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { assign } from "xstate";
2
+ import { type LiftContext } from "./contextLift.js";
3
+ import type { ErrorRouteTarget, ModeOutput, RouteTarget } from "./types.js";
4
+ import type { LeafSlot } from "./walk.js";
5
+ export type LoweredGuard = (args: {
6
+ event: {
7
+ output: ModeOutput<unknown>;
8
+ };
9
+ }) => boolean;
10
+ export type LoweredOnDoneTransition = {
11
+ guard?: LoweredGuard;
12
+ target?: RouteTarget;
13
+ reenter?: boolean;
14
+ actions?: ReturnType<typeof assign>;
15
+ };
16
+ export type LoweredErrorGuard = (args: {
17
+ event: {
18
+ error: unknown;
19
+ };
20
+ }) => boolean;
21
+ export type LoweredReThrowAction = (args: {
22
+ event: {
23
+ error: unknown;
24
+ };
25
+ }) => never;
26
+ export type LoweredErrorAction = ReturnType<typeof assign> | LoweredReThrowAction;
27
+ export type LoweredOnErrorTransition = {
28
+ guard?: LoweredErrorGuard;
29
+ target?: ErrorRouteTarget;
30
+ actions?: LoweredErrorAction;
31
+ };
32
+ export type LoweredInvokeState = {
33
+ invoke: {
34
+ src: string;
35
+ input: (args: {
36
+ context: unknown;
37
+ }) => unknown;
38
+ onDone: readonly LoweredOnDoneTransition[];
39
+ onError?: readonly LoweredOnErrorTransition[];
40
+ };
41
+ };
42
+ export declare function buildActiveState(slot: LeafSlot, lift: LiftContext | undefined, deps: Readonly<Record<string, unknown>>): LoweredInvokeState;
43
+ //# sourceMappingURL=buildActiveState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildActiveState.d.ts","sourceRoot":"","sources":["../src/buildActiveState.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAIH,KAAK,WAAW,EACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAER,gBAAgB,EAGhB,UAAU,EAGV,WAAW,EAEd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAe1C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE;IAC9B,KAAK,EAAE;QAAE,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;CAC1C,KAAK,OAAO,CAAC;AAEd,MAAM,MAAM,uBAAuB,GAAG;IAClC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE;IACnC,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7B,KAAK,OAAO,CAAC;AAKd,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE;IACtC,KAAK,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7B,KAAK,KAAK,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,GAAG,oBAAoB,CAAC;AAElF,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,MAAM,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,CAAC,IAAI,EAAE;YAAE,OAAO,EAAE,OAAO,CAAA;SAAE,KAAK,OAAO,CAAC;QAC/C,MAAM,EAAE,SAAS,uBAAuB,EAAE,CAAC;QAC3C,OAAO,CAAC,EAAE,SAAS,wBAAwB,EAAE,CAAC;KACjD,CAAC;CACL,CAAC;AA0KF,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,kBAAkB,CAmDpB"}
@@ -0,0 +1,194 @@
1
+ // Lower an active `Mode` (leaf) slot to an XState `{ invoke: { src, input, onDone, onError? } }`
2
+ // state. Spec: docs/specs/004-tasks.md Phase 5.6 + 5.7 + 5.9 +
3
+ // docs/specs/004-xstate-agent-wrapper.md §Mapping.
4
+ // Spec 005: every user callback envelope (input, behavior, routes.*.assign)
5
+ // is extended with the agent's frozen `deps` reference, captured here in
6
+ // each generated closure.
7
+ //
8
+ // Cardinality and order of `onDone[i]`:
9
+ // - one entry per `routes.achieved` route entry, in order
10
+ // - then one entry per `routes.retry` route entry, in order
11
+ // (zero if `retry: readonly []`)
12
+ // - then one entry per `routes.abandoned` route entry, in order
13
+ //
14
+ // Each `onDone[i]` carries:
15
+ // - `target`:
16
+ // achieved / abandoned → the entry's own `target` (END symbol stays;
17
+ // slice 5.11 rewrites it to `$end`)
18
+ // retry → the leaf's last-segment sibling name, with `reenter: true`
19
+ // so XState re-fires the invoke
20
+ // - `guard`: combines `event.output.outcome === "<key>"` with the user's
21
+ // optional `when(payload)` — the entry only fires for the matching
22
+ // outcome AND only when the user's payload-typed predicate agrees
23
+ // - `actions`: the user's optional `assign` callback wrapped in XState's
24
+ // `assign(...)`, with `event.output.payload` bridged into the `payload`
25
+ // argument the user typed against, and `deps` threaded from the
26
+ // closure that `buildActiveState` was called with
27
+ //
28
+ // `routes.error` → `invoke.onError[i]` with the same shape as onDone, except:
29
+ // - guard sees `event.error` instead of `event.output.{outcome,payload}`
30
+ // - target may be `RE_THROW` (a symbol); the actual re-throw action is
31
+ // emitted in slice 5.10 — slice 5.9 leaves RE_THROW as-is in `target`.
32
+ // When `routes.error` is omitted, no `onError` field is emitted — XState's
33
+ // default (rejection halts the actor) matches the spec's "wrapper re-throws"
34
+ // guarantee.
35
+ import { assign } from "xstate";
36
+ import { actorName } from "./actorName.js";
37
+ import { liftErrorAssign, liftExitAssign, liftInput, } from "./contextLift.js";
38
+ import { RE_THROW } from "./types.js";
39
+ // `Array.isArray` widens `readonly T[]` to `any[]` and does not subtract it
40
+ // from a `T | readonly T[]` union. A typed predicate fixes the narrowing
41
+ // without leaking `any`.
42
+ function isReadonlyArray(value) {
43
+ return Array.isArray(value);
44
+ }
45
+ function normalizeExitEntries(entry) {
46
+ return isReadonlyArray(entry) ? entry : [entry];
47
+ }
48
+ function normalizeRetryEntries(entry) {
49
+ return isReadonlyArray(entry) ? entry : [entry];
50
+ }
51
+ function normalizeErrorEntries(entry) {
52
+ return isReadonlyArray(entry) ? entry : [entry];
53
+ }
54
+ function makeGuard(outcomeKey, userWhen) {
55
+ return ({ event }) => {
56
+ if (event.output.outcome !== outcomeKey)
57
+ return false;
58
+ if (userWhen === undefined)
59
+ return true;
60
+ return userWhen(event.output.payload);
61
+ };
62
+ }
63
+ // Bridge `entry.assign({ context, payload, deps })` to XState's
64
+ // `assign(({ context, event }) => ...)`. The payload narrowing the user
65
+ // typed against is preserved through `event.output.payload`. The `deps`
66
+ // reference is captured from the closure that `buildActiveState` was
67
+ // called with — every emitted callback sees the same frozen object by
68
+ // identity.
69
+ //
70
+ // When a `lift` is in effect (the enclosing compound declared
71
+ // `context: { inherit, local }`), delegate to `liftExitAssign` instead:
72
+ // it presents the virtual `Pick<TParent, inherit[number]> & local` view to
73
+ // the user's callback and splits the returned partial back to the right
74
+ // destination (agent root vs. ancestor slot vs. own slot). `deps` is
75
+ // forwarded verbatim through the lift wrapper.
76
+ function wrapAssign(userAssign, lift, deps) {
77
+ if (lift !== undefined) {
78
+ return liftExitAssign(userAssign, lift, deps);
79
+ }
80
+ return assign(({ context, event }) => {
81
+ const output = event.output;
82
+ return userAssign({ context, payload: output.payload, deps });
83
+ });
84
+ }
85
+ function buildExitTransition(outcomeKey, entry, lift, deps) {
86
+ const transition = {
87
+ guard: makeGuard(outcomeKey, entry.when),
88
+ target: entry.target,
89
+ };
90
+ if (entry.assign !== undefined) {
91
+ transition.actions = wrapAssign(entry.assign, lift, deps);
92
+ }
93
+ return transition;
94
+ }
95
+ function buildRetryTransition(selfSegment, entry, lift, deps) {
96
+ const transition = {
97
+ guard: makeGuard("retry", entry.when),
98
+ target: selfSegment,
99
+ reenter: true,
100
+ };
101
+ if (entry.assign !== undefined) {
102
+ transition.actions = wrapAssign(entry.assign, lift, deps);
103
+ }
104
+ return transition;
105
+ }
106
+ function makeErrorGuard(userWhen) {
107
+ return ({ event }) => {
108
+ if (userWhen === undefined)
109
+ return true;
110
+ return userWhen(event.error);
111
+ };
112
+ }
113
+ function wrapErrorAssign(userAssign, lift, deps) {
114
+ if (lift !== undefined) {
115
+ return liftErrorAssign(userAssign, lift, deps);
116
+ }
117
+ return assign(({ context, event }) => {
118
+ const error = event.error;
119
+ return userAssign({ context, error, deps });
120
+ });
121
+ }
122
+ // Re-throw action emitted for `target: RE_THROW` entries. Throwing inside an
123
+ // XState v5 action causes the invoking actor to surface the error, which
124
+ // propagates above the leaf — matching the spec's RE_THROW semantics. The
125
+ // transition itself carries no `target`; the re-throw IS the side effect.
126
+ function makeReThrowAction() {
127
+ return ({ event }) => {
128
+ throw event.error;
129
+ };
130
+ }
131
+ function buildErrorTransition(entry, lift, deps) {
132
+ const guard = makeErrorGuard(entry.when);
133
+ if (entry.target === RE_THROW) {
134
+ // Spec line 833: `assign` on a RE_THROW entry is dropped at compile
135
+ // time. The dispatch walk treats RE_THROW as terminal — XState's
136
+ // first-match-wins ordering plus the thrown rejection naturally
137
+ // prevent any later entry from running.
138
+ return {
139
+ guard,
140
+ actions: makeReThrowAction(),
141
+ };
142
+ }
143
+ const transition = {
144
+ guard,
145
+ target: entry.target,
146
+ };
147
+ if (entry.assign !== undefined) {
148
+ transition.actions = wrapErrorAssign(entry.assign, lift, deps);
149
+ }
150
+ return transition;
151
+ }
152
+ export function buildActiveState(slot, lift, deps) {
153
+ const config = slot.config;
154
+ if (!("behavior" in config)) {
155
+ throw new Error(`atlas/buildActiveState: leaf at "${slot.path}" is passive — use buildPassiveState`);
156
+ }
157
+ const routes = config.routes;
158
+ const segments = slot.path.split(".");
159
+ const selfSegment = segments[segments.length - 1];
160
+ if (selfSegment === undefined || selfSegment === "") {
161
+ throw new Error(`atlas/buildActiveState: malformed leaf path "${slot.path}"`);
162
+ }
163
+ const onDone = [];
164
+ for (const entry of normalizeExitEntries(routes.achieved)) {
165
+ onDone.push(buildExitTransition("achieved", entry, lift, deps));
166
+ }
167
+ for (const entry of normalizeRetryEntries(routes.retry)) {
168
+ onDone.push(buildRetryTransition(selfSegment, entry, lift, deps));
169
+ }
170
+ for (const entry of normalizeExitEntries(routes.abandoned)) {
171
+ onDone.push(buildExitTransition("abandoned", entry, lift, deps));
172
+ }
173
+ // The user's `input` callback gains a `deps` parameter; wrap it so the
174
+ // XState-facing input fn matches the existing `({ context }) => unknown`
175
+ // shape while injecting `deps` from the closure.
176
+ const userInput = config.input;
177
+ const wrappedInput = lift !== undefined
178
+ ? liftInput(userInput, lift, deps)
179
+ : ({ context }) => userInput({ context, deps });
180
+ const invoke = {
181
+ src: actorName(slot.path),
182
+ input: wrappedInput,
183
+ onDone,
184
+ };
185
+ if (routes.error !== undefined) {
186
+ const onError = [];
187
+ for (const entry of normalizeErrorEntries(routes.error)) {
188
+ onError.push(buildErrorTransition(entry, lift, deps));
189
+ }
190
+ invoke.onError = onError;
191
+ }
192
+ return { invoke };
193
+ }
194
+ //# sourceMappingURL=buildActiveState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildActiveState.js","sourceRoot":"","sources":["../src/buildActiveState.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,+DAA+D;AAC/D,mDAAmD;AACnD,4EAA4E;AAC5E,yEAAyE;AACzE,0BAA0B;AAC1B,EAAE;AACF,wCAAwC;AACxC,4DAA4D;AAC5D,8DAA8D;AAC9D,qCAAqC;AACrC,kEAAkE;AAClE,EAAE;AACF,4BAA4B;AAC5B,gBAAgB;AAChB,2EAA2E;AAC3E,0CAA0C;AAC1C,2EAA2E;AAC3E,sCAAsC;AACtC,2EAA2E;AAC3E,uEAAuE;AACvE,sEAAsE;AACtE,2EAA2E;AAC3E,4EAA4E;AAC5E,oEAAoE;AACpE,sDAAsD;AACtD,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,aAAa;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CA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