@barnum/barnum 0.3.0 → 0.4.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 (109) hide show
  1. package/artifacts/linux-arm64/barnum +0 -0
  2. package/artifacts/linux-x64/barnum +0 -0
  3. package/artifacts/macos-arm64/barnum +0 -0
  4. package/artifacts/macos-x64/barnum +0 -0
  5. package/artifacts/win-x64/barnum.exe +0 -0
  6. package/dist/all.d.ts +41 -10
  7. package/dist/all.d.ts.map +1 -0
  8. package/dist/all.js +1 -1
  9. package/dist/ast.d.ts +199 -98
  10. package/dist/ast.d.ts.map +1 -0
  11. package/dist/ast.js +271 -233
  12. package/dist/bind.d.ts +9 -12
  13. package/dist/bind.d.ts.map +1 -0
  14. package/dist/bind.js +14 -51
  15. package/dist/builtins/array.d.ts +36 -0
  16. package/dist/builtins/array.d.ts.map +1 -0
  17. package/dist/builtins/array.js +93 -0
  18. package/dist/builtins/index.d.ts +6 -0
  19. package/dist/builtins/index.d.ts.map +1 -0
  20. package/dist/builtins/index.js +5 -0
  21. package/dist/builtins/scalar.d.ts +12 -0
  22. package/dist/builtins/scalar.d.ts.map +1 -0
  23. package/dist/builtins/scalar.js +41 -0
  24. package/dist/builtins/struct.d.ts +25 -0
  25. package/dist/builtins/struct.d.ts.map +1 -0
  26. package/dist/builtins/struct.js +67 -0
  27. package/dist/builtins/tagged-union.d.ts +54 -0
  28. package/dist/builtins/tagged-union.d.ts.map +1 -0
  29. package/dist/builtins/tagged-union.js +81 -0
  30. package/dist/builtins/with-resource.d.ts +23 -0
  31. package/dist/builtins/with-resource.d.ts.map +1 -0
  32. package/dist/builtins/with-resource.js +35 -0
  33. package/dist/chain.d.ts +1 -0
  34. package/dist/chain.d.ts.map +1 -0
  35. package/dist/chain.js +3 -3
  36. package/dist/effect-id.d.ts +1 -0
  37. package/dist/effect-id.d.ts.map +1 -0
  38. package/dist/handler.d.ts +7 -6
  39. package/dist/handler.d.ts.map +1 -0
  40. package/dist/handler.js +5 -21
  41. package/dist/index.d.ts +10 -6
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +4 -2
  44. package/dist/iterator.d.ts +32 -0
  45. package/dist/iterator.d.ts.map +1 -0
  46. package/dist/iterator.js +123 -0
  47. package/dist/option.d.ts +74 -0
  48. package/dist/option.d.ts.map +1 -0
  49. package/dist/option.js +141 -0
  50. package/dist/pipe.d.ts +11 -10
  51. package/dist/pipe.d.ts.map +1 -0
  52. package/dist/pipe.js +5 -4
  53. package/dist/race.d.ts +5 -4
  54. package/dist/race.d.ts.map +1 -0
  55. package/dist/race.js +17 -42
  56. package/dist/recursive.d.ts +9 -3
  57. package/dist/recursive.d.ts.map +1 -0
  58. package/dist/recursive.js +18 -13
  59. package/dist/result.d.ts +50 -0
  60. package/dist/result.d.ts.map +1 -0
  61. package/dist/result.js +117 -0
  62. package/dist/run.d.ts +9 -2
  63. package/dist/run.d.ts.map +1 -0
  64. package/dist/run.js +37 -20
  65. package/dist/runtime.d.ts +6 -0
  66. package/dist/runtime.d.ts.map +1 -0
  67. package/dist/runtime.js +7 -0
  68. package/dist/schema.d.ts +1 -0
  69. package/dist/schema.d.ts.map +1 -0
  70. package/dist/schemas.d.ts +5 -0
  71. package/dist/schemas.d.ts.map +1 -0
  72. package/dist/schemas.js +13 -0
  73. package/dist/try-catch.d.ts +2 -1
  74. package/dist/try-catch.d.ts.map +1 -0
  75. package/dist/try-catch.js +10 -9
  76. package/dist/values.d.ts +6 -0
  77. package/dist/values.d.ts.map +1 -0
  78. package/dist/values.js +12 -0
  79. package/dist/worker.d.ts +5 -1
  80. package/dist/worker.d.ts.map +1 -0
  81. package/dist/worker.js +15 -3
  82. package/package.json +8 -6
  83. package/src/all.ts +118 -74
  84. package/src/ast.ts +773 -350
  85. package/src/bind.ts +32 -62
  86. package/src/builtins/array.ts +121 -0
  87. package/src/builtins/index.ts +17 -0
  88. package/src/builtins/scalar.ts +49 -0
  89. package/src/builtins/struct.ts +111 -0
  90. package/src/builtins/tagged-union.ts +142 -0
  91. package/src/builtins/with-resource.ts +69 -0
  92. package/src/chain.ts +4 -4
  93. package/src/handler.ts +12 -28
  94. package/src/index.ts +24 -17
  95. package/src/iterator.ts +243 -0
  96. package/src/option.ts +199 -0
  97. package/src/pipe.ts +123 -78
  98. package/src/race.ts +41 -51
  99. package/src/recursive.ts +44 -27
  100. package/src/result.ts +168 -0
  101. package/src/run.ts +53 -25
  102. package/src/runtime.ts +16 -0
  103. package/src/schemas.ts +21 -0
  104. package/src/try-catch.ts +14 -10
  105. package/src/values.ts +21 -0
  106. package/src/worker.ts +17 -2
  107. package/dist/builtins.d.ts +0 -257
  108. package/dist/builtins.js +0 -600
  109. package/src/builtins.ts +0 -804
package/dist/race.js CHANGED
@@ -1,27 +1,18 @@
1
- import { typedAction, buildRestartBranchAction, TAG_BREAK, IDENTITY, } from "./ast.js";
1
+ import { toAction, typedAction, buildRestartBranchAction, } from "./ast.js";
2
+ import { chain } from "./chain.js";
3
+ import { identity, tag } from "./builtins/index.js";
4
+ import { Result } from "./result.js";
2
5
  import { allocateRestartHandlerId, } from "./effect-id.js";
3
- // ---------------------------------------------------------------------------
4
- // Shared AST fragments
5
- // ---------------------------------------------------------------------------
6
- const TAG_OK = {
7
- kind: "Invoke",
8
- handler: { kind: "Builtin", builtin: { kind: "Tag", value: "Ok" } },
9
- };
10
- const TAG_ERR = {
11
- kind: "Invoke",
12
- handler: { kind: "Builtin", builtin: { kind: "Tag", value: "Err" } },
13
- };
14
6
  /**
15
7
  * `Chain(Tag("Break"), RestartPerform(id))` — shared by race branches.
16
8
  * The winning branch tags its result as Break, then performs. The handler
17
9
  * restarts the body; Branch takes the Break arm (identity), `RestartHandle` exits.
18
10
  */
19
11
  function breakPerform(restartHandlerId) {
20
- return {
21
- kind: "Chain",
22
- first: TAG_BREAK,
23
- rest: { kind: "RestartPerform", restart_handler_id: restartHandlerId },
24
- };
12
+ return toAction(chain(toAction(tag("Break", "LoopResult")), {
13
+ kind: "RestartPerform",
14
+ restart_handler_id: restartHandlerId,
15
+ }));
25
16
  }
26
17
  // ---------------------------------------------------------------------------
27
18
  // race — first branch to complete wins, losers cancelled
@@ -35,7 +26,7 @@ function breakPerform(restartHandlerId) {
35
26
  *
36
27
  * Compiled form (restart+Branch, same substrate as loop/earlyReturn):
37
28
  * `Chain(Tag("Continue"),`
38
- * `RestartHandle(id, ExtractIndex(0),`
29
+ * `RestartHandle(id, GetIndex(0),`
39
30
  * `Branch({`
40
31
  * `Continue: All(Chain(a, breakPerform), Chain(b, breakPerform), ...),`
41
32
  * `Break: identity,`
@@ -47,13 +38,9 @@ function breakPerform(restartHandlerId) {
47
38
  export function race(...actions) {
48
39
  const restartHandlerId = allocateRestartHandlerId();
49
40
  const perform = breakPerform(restartHandlerId);
50
- const branches = actions.map((action) => ({
51
- kind: "Chain",
52
- first: action,
53
- rest: perform,
54
- }));
41
+ const branches = actions.map((action) => toAction(chain(toAction(action), toAction(perform))));
55
42
  const allAction = { kind: "All", actions: branches };
56
- return typedAction(buildRestartBranchAction(restartHandlerId, allAction, IDENTITY));
43
+ return typedAction(buildRestartBranchAction(restartHandlerId, allAction, toAction(identity())));
57
44
  }
58
45
  // ---------------------------------------------------------------------------
59
46
  // sleep — Rust builtin that delays for a fixed duration (passthrough)
@@ -69,7 +56,7 @@ export function race(...actions) {
69
56
  export function sleep(ms) {
70
57
  return typedAction({
71
58
  kind: "Invoke",
72
- handler: { kind: "Builtin", builtin: { kind: "Sleep", value: ms } },
59
+ handler: { kind: "Builtin", builtin: { kind: "Sleep", ms } },
73
60
  });
74
61
  }
75
62
  // ---------------------------------------------------------------------------
@@ -120,22 +107,10 @@ Object.defineProperty(dynamicSleep, "__definition", {
120
107
  export function withTimeout(ms, body) {
121
108
  const restartHandlerId = allocateRestartHandlerId();
122
109
  const perform = breakPerform(restartHandlerId);
123
- // Branch 1: body → Tag("Ok") → Tag("Break") → RestartPerform
124
- const bodyBranch = {
125
- kind: "Chain",
126
- first: { kind: "Chain", first: body, rest: TAG_OK },
127
- rest: perform,
128
- };
129
- // Branch 2: ms → sleep() → Tag("Err") → Tag("Break") → RestartPerform
130
- const sleepBranch = {
131
- kind: "Chain",
132
- first: {
133
- kind: "Chain",
134
- first: { kind: "Chain", first: ms, rest: DYNAMIC_SLEEP_INVOKE },
135
- rest: TAG_ERR,
136
- },
137
- rest: perform,
138
- };
110
+ // Branch 1: body → Tag("Ok") → Break → RestartPerform
111
+ const bodyBranch = toAction(chain(toAction(chain(toAction(body), toAction(Result.ok()))), toAction(perform)));
112
+ // Branch 2: ms → sleep() → Tag("Err") → Break → RestartPerform
113
+ const sleepBranch = toAction(chain(toAction(chain(toAction(chain(toAction(ms), toAction(DYNAMIC_SLEEP_INVOKE))), toAction(Result.err()))), toAction(perform)));
139
114
  const allAction = { kind: "All", actions: [bodyBranch, sleepBranch] };
140
- return typedAction(buildRestartBranchAction(restartHandlerId, allAction, IDENTITY));
115
+ return typedAction(buildRestartBranchAction(restartHandlerId, allAction, toAction(identity())));
141
116
  }
@@ -5,12 +5,11 @@ type FunctionRefs<TDefs extends FunctionDef[]> = {
5
5
  };
6
6
  /**
7
7
  * Constraint for the entry-point callback return type. Only requires the
8
- * output phantom fields — omits __in and __in_co so that actions with
9
- * In = never (e.g. pipelines starting from a call token) are assignable.
8
+ * output phantom field — omits __in and __in_co so that actions with
9
+ * any input type (e.g. pipelines starting from a call token) are assignable.
10
10
  */
11
11
  type BodyResult<TOut> = Action & {
12
12
  __out?: () => TOut;
13
- __out_contra?: (output: TOut) => void;
14
13
  };
15
14
  /**
16
15
  * Define mutually recursive functions that can call each other.
@@ -27,8 +26,15 @@ type BodyResult<TOut> = Action & {
27
26
  * is Chain(Tag("CallN"), ResumePerform(id)). The handler dispatches to the
28
27
  * correct function body by tag. The caller's pipeline is preserved as a
29
28
  * ResumePerformFrame across each call.
29
+ *
30
+ * **Known limitation:** concurrent calls to the same function do not work
31
+ * as expected. `all(f(x), f(x))` will NOT call `f` twice — both branches
32
+ * perform on the same ResumeHandle, and the second perform will not
33
+ * execute independently. Use sequential calls (chain/then) instead of
34
+ * concurrent calls (all) when calling recursive functions multiple times.
30
35
  */
31
36
  export declare function defineRecursiveFunctions<TDefs extends FunctionDef[]>(bodiesFn: (...fns: FunctionRefs<TDefs>) => {
32
37
  [K in keyof TDefs]: Pipeable<TDefs[K][0], TDefs[K][1]>;
33
38
  }): <TOut>(entryFn: (...fns: FunctionRefs<TDefs>) => BodyResult<TOut>) => TypedAction<any, TOut>;
34
39
  export {};
40
+ //# sourceMappingURL=recursive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recursive.d.ts","sourceRoot":"","sources":["../src/recursive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,WAAW,EAIjB,MAAM,UAAU,CAAC;AAgBlB,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,KAAK,YAAY,CAAC,KAAK,SAAS,WAAW,EAAE,IAAI;KAC9C,CAAC,IAAI,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,KAAK,UAAU,CAAC,IAAI,IAAI,MAAM,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAQF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,WAAW,EAAE,EAClE,QAAQ,EAAE,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK;KACxC,CAAC,IAAI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACvD,GACA,CAAC,IAAI,EACN,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,KACvD,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAwD1B"}
package/dist/recursive.js CHANGED
@@ -1,10 +1,9 @@
1
- import { typedAction, branch, } from "./ast.js";
1
+ import { toAction, typedAction, branch, } from "./ast.js";
2
2
  import { all } from "./all.js";
3
3
  import { chain } from "./chain.js";
4
- import { constant, identity, extractField, extractIndex, tag, } from "./builtins.js";
4
+ import { constant, identity, getField, getIndex, tag, } from "./builtins/index.js";
5
5
  import { allocateResumeHandlerId } from "./effect-id.js";
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- const UNUSED_STATE = undefined;
6
+ const UNUSED_STATE = null;
8
7
  // ---------------------------------------------------------------------------
9
8
  // defineRecursiveFunctions
10
9
  // ---------------------------------------------------------------------------
@@ -23,6 +22,12 @@ const UNUSED_STATE = undefined;
23
22
  * is Chain(Tag("CallN"), ResumePerform(id)). The handler dispatches to the
24
23
  * correct function body by tag. The caller's pipeline is preserved as a
25
24
  * ResumePerformFrame across each call.
25
+ *
26
+ * **Known limitation:** concurrent calls to the same function do not work
27
+ * as expected. `all(f(x), f(x))` will NOT call `f` twice — both branches
28
+ * perform on the same ResumeHandle, and the second perform will not
29
+ * execute independently. Use sequential calls (chain/then) instead of
30
+ * concurrent calls (all) when calling recursive functions multiple times.
26
31
  */
27
32
  export function defineRecursiveFunctions(bodiesFn) {
28
33
  const resumeHandlerId = allocateResumeHandlerId();
@@ -32,22 +37,22 @@ export function defineRecursiveFunctions(bodiesFn) {
32
37
  };
33
38
  // Call tokens: Chain(Tag("CallN"), ResumePerform(resumeHandlerId))
34
39
  const fnCount = bodiesFn.length;
35
- const callTokens = Array.from({ length: fnCount }, (_, i) => typedAction(chain(tag(`Call${i}`), resumePerform)));
40
+ const callTokens = Array.from({ length: fnCount }, (_, i) => typedAction(toAction(chain(toAction(tag(`Call${i}`, "RecursiveDispatch")), toAction(resumePerform)))));
36
41
  // Get function body ASTs
37
- const bodyActions = bodiesFn(...callTokens);
38
- // Branch cases: CallN → ExtractField("value") → bodyN
42
+ const bodyActions = bodiesFn(...callTokens).map(toAction);
43
+ // Branch cases: CallN → GetField("value") → bodyN
39
44
  const cases = {};
40
45
  for (let i = 0; i < bodyActions.length; i++) {
41
- cases[`Call${i}`] = chain(extractField("value"), bodyActions[i]);
46
+ cases[`Call${i}`] = toAction(chain(toAction(getField("value")), toAction(bodyActions[i])));
42
47
  }
43
48
  // Return curried entry-point combinator
44
49
  return (entryFn) => {
45
- const userBody = entryFn(...callTokens);
46
- return typedAction(chain(all(identity, constant(UNUSED_STATE)), {
50
+ const userBody = toAction(entryFn(...callTokens));
51
+ return typedAction(toAction(chain(toAction(all(identity(), constant(UNUSED_STATE))), {
47
52
  kind: "ResumeHandle",
48
53
  resume_handler_id: resumeHandlerId,
49
- body: chain(extractIndex(0), userBody),
50
- handler: all(chain(extractIndex(0), branch(cases)), constant(UNUSED_STATE)),
51
- }));
54
+ body: toAction(chain(toAction(getIndex(0).unwrap()), toAction(userBody))),
55
+ handler: toAction(all(chain(toAction(getIndex(0).unwrap()), toAction(branch(cases))), constant(UNUSED_STATE))),
56
+ })));
52
57
  };
53
58
  }
@@ -0,0 +1,50 @@
1
+ import { type Option as OptionT, type Pipeable, type Result as ResultT, type TypedAction } from "./ast.js";
2
+ export declare const Result: {
3
+ /** Tag combinator: wrap value as `Result.Ok`. `TValue → Result<TValue, TError>` */
4
+ readonly ok: <TValue, TError = never>() => TypedAction<TValue, ResultT<TValue, TError>>;
5
+ /** Tag combinator: wrap value as `Result.Err`. `TError → Result<TValue, TError>` */
6
+ readonly err: <TValue = never, TError = unknown>() => TypedAction<TError, ResultT<TValue, TError>>;
7
+ /** Transform the Ok value. `Result<TValue, TError> → Result<TOut, TError>` */
8
+ readonly map: <TValue, TOut, TError>(action: Pipeable<TValue, TOut>) => TypedAction<ResultT<TValue, TError>, ResultT<TOut, TError>>;
9
+ /** Transform the Err value. `Result<TValue, TError> → Result<TValue, TErrorOut>` */
10
+ readonly mapErr: <TValue, TError, TErrorOut>(action: Pipeable<TError, TErrorOut>) => TypedAction<ResultT<TValue, TError>, ResultT<TValue, TErrorOut>>;
11
+ /**
12
+ * Monadic bind (flatMap) for Ok. If Ok, pass value to action which
13
+ * returns Result<TOut, TError>. If Err, propagate.
14
+ */
15
+ readonly andThen: <TValue, TOut, TError>(action: Pipeable<TValue, ResultT<TOut, TError>>) => TypedAction<ResultT<TValue, TError>, ResultT<TOut, TError>>;
16
+ /** Fallback on Err. If Ok, keep it. If Err, pass error to fallback. */
17
+ readonly or: <TValue, TError, TErrorOut>(fallback: Pipeable<TError, ResultT<TValue, TErrorOut>>) => TypedAction<ResultT<TValue, TError>, ResultT<TValue, TErrorOut>>;
18
+ /**
19
+ * Extract the Ok value or panic. `Result<TValue, TError> → TValue`
20
+ *
21
+ * Panics (fatal, not caught by tryCatch) if the value is Err.
22
+ */
23
+ readonly unwrap: <TValue, TError>() => TypedAction<ResultT<TValue, TError>, TValue>;
24
+ /**
25
+ * Extract Ok or compute default from Err. `Result<TValue, TError> → TValue`
26
+ */
27
+ readonly unwrapOr: <TValue, TError>(defaultAction: Pipeable<TError, TValue>) => TypedAction<ResultT<TValue, TError>, TValue>;
28
+ /**
29
+ * Convert Ok to Some, Err to None. `Result<TValue, TError> → Option<TValue>`
30
+ */
31
+ readonly asOkOption: <TValue, TError>() => TypedAction<ResultT<TValue, TError>, OptionT<TValue>>;
32
+ /**
33
+ * Convert Err to Some, Ok to None. `Result<TValue, TError> → Option<TError>`
34
+ */
35
+ readonly asErrOption: <TValue, TError>() => TypedAction<ResultT<TValue, TError>, OptionT<TError>>;
36
+ /**
37
+ * Swap Result/Option nesting.
38
+ * `Result<Option<TValue>, TError> → Option<Result<TValue, TError>>`
39
+ */
40
+ readonly transpose: <TValue, TError>() => TypedAction<ResultT<OptionT<TValue>, TError>, OptionT<ResultT<TValue, TError>>>;
41
+ /**
42
+ * Test if the value is Ok. `Result<TValue, TError> → boolean`
43
+ */
44
+ readonly isOk: <TValue, TError>() => TypedAction<ResultT<TValue, TError>, boolean>;
45
+ /**
46
+ * Test if the value is Err. `Result<TValue, TError> → boolean`
47
+ */
48
+ readonly isErr: <TValue, TError>() => TypedAction<ResultT<TValue, TError>, boolean>;
49
+ };
50
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,QAAQ,EACb,KAAK,MAAM,IAAI,OAAO,EAEtB,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;AASlB,eAAO,MAAM,MAAM;IACjB,mFAAmF;kBAChF,MAAM,EAAE,MAAM,eAAa,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAG1E,oFAAoF;mBAChF,MAAM,UAAU,MAAM,iBAAe,WAAW,CAClD,MAAM,EACN,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CACxB;IAID,8EAA8E;mBAC1E,MAAM,EAAE,IAAI,EAAE,MAAM,UACd,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,KAC7B,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAO9D,oFAAoF;sBAC7E,MAAM,EAAE,MAAM,EAAE,SAAS,UACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,KAClC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAOnE;;;OAGG;uBACK,MAAM,EAAE,IAAI,EAAE,MAAM,UAClB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAC9C,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAO9D,uEAAuE;kBACpE,MAAM,EAAE,MAAM,EAAE,SAAS,YAChB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,KACrD,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAOnE;;;;OAIG;sBACI,MAAM,EAAE,MAAM,OAAK,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAOtE;;OAEG;wBACM,MAAM,EAAE,MAAM,iBACN,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAO/C;;OAEG;0BACQ,MAAM,EAAE,MAAM,OAAK,WAAW,CACvC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EACvB,OAAO,CAAC,MAAM,CAAC,CAChB;IAOD;;OAEG;2BACS,MAAM,EAAE,MAAM,OAAK,WAAW,CACxC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EACvB,OAAO,CAAC,MAAM,CAAC,CAChB;IAOD;;;OAGG;yBACO,MAAM,EAAE,MAAM,OAAK,WAAW,CACtC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAChC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CACjC;IAmBD;;OAEG;oBACE,MAAM,EAAE,MAAM,OAAK,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAOrE;;OAEG;qBACG,MAAM,EAAE,MAAM,OAAK,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC;CAM9D,CAAC"}
package/dist/result.js ADDED
@@ -0,0 +1,117 @@
1
+ import { branch, } from "./ast.js";
2
+ import { chain } from "./chain.js";
3
+ import { constant, drop, identity, panic, tag } from "./builtins/index.js";
4
+ import { Option } from "./option.js";
5
+ // ---------------------------------------------------------------------------
6
+ // Result namespace — combinators for Result<TValue, TError> tagged unions
7
+ // ---------------------------------------------------------------------------
8
+ export const Result = {
9
+ /** Tag combinator: wrap value as `Result.Ok`. `TValue → Result<TValue, TError>` */
10
+ ok() {
11
+ return tag("Ok", "Result");
12
+ },
13
+ /** Tag combinator: wrap value as `Result.Err`. `TError → Result<TValue, TError>` */
14
+ err() {
15
+ return tag("Err", "Result");
16
+ },
17
+ /** Transform the Ok value. `Result<TValue, TError> → Result<TOut, TError>` */
18
+ map(action) {
19
+ return branch({
20
+ Ok: chain(action, Result.ok()),
21
+ Err: Result.err(),
22
+ });
23
+ },
24
+ /** Transform the Err value. `Result<TValue, TError> → Result<TValue, TErrorOut>` */
25
+ mapErr(action) {
26
+ return branch({
27
+ Ok: Result.ok(),
28
+ Err: chain(action, Result.err()),
29
+ });
30
+ },
31
+ /**
32
+ * Monadic bind (flatMap) for Ok. If Ok, pass value to action which
33
+ * returns Result<TOut, TError>. If Err, propagate.
34
+ */
35
+ andThen(action) {
36
+ return branch({
37
+ Ok: action,
38
+ Err: Result.err(),
39
+ });
40
+ },
41
+ /** Fallback on Err. If Ok, keep it. If Err, pass error to fallback. */
42
+ or(fallback) {
43
+ return branch({
44
+ Ok: Result.ok(),
45
+ Err: fallback,
46
+ });
47
+ },
48
+ /**
49
+ * Extract the Ok value or panic. `Result<TValue, TError> → TValue`
50
+ *
51
+ * Panics (fatal, not caught by tryCatch) if the value is Err.
52
+ */
53
+ unwrap() {
54
+ return branch({
55
+ Ok: identity(),
56
+ Err: panic("called unwrap on Err"),
57
+ });
58
+ },
59
+ /**
60
+ * Extract Ok or compute default from Err. `Result<TValue, TError> → TValue`
61
+ */
62
+ unwrapOr(defaultAction) {
63
+ return branch({
64
+ Ok: identity(),
65
+ Err: defaultAction,
66
+ });
67
+ },
68
+ /**
69
+ * Convert Ok to Some, Err to None. `Result<TValue, TError> → Option<TValue>`
70
+ */
71
+ asOkOption() {
72
+ return branch({
73
+ Ok: Option.some(),
74
+ Err: chain(drop, Option.none()),
75
+ });
76
+ },
77
+ /**
78
+ * Convert Err to Some, Ok to None. `Result<TValue, TError> → Option<TError>`
79
+ */
80
+ asErrOption() {
81
+ return branch({
82
+ Ok: chain(drop, Option.none()),
83
+ Err: Option.some(),
84
+ });
85
+ },
86
+ /**
87
+ * Swap Result/Option nesting.
88
+ * `Result<Option<TValue>, TError> → Option<Result<TValue, TError>>`
89
+ */
90
+ transpose() {
91
+ return branch({
92
+ Ok: branch({
93
+ Some: chain(Result.ok(), Option.some()),
94
+ None: chain(drop, Option.none()),
95
+ }),
96
+ Err: chain(Result.err(), Option.some()),
97
+ });
98
+ },
99
+ /**
100
+ * Test if the value is Ok. `Result<TValue, TError> → boolean`
101
+ */
102
+ isOk() {
103
+ return branch({
104
+ Ok: constant(true),
105
+ Err: constant(false),
106
+ });
107
+ },
108
+ /**
109
+ * Test if the value is Err. `Result<TValue, TError> → boolean`
110
+ */
111
+ isErr() {
112
+ return branch({
113
+ Ok: constant(false),
114
+ Err: constant(true),
115
+ });
116
+ },
117
+ };
package/dist/run.d.ts CHANGED
@@ -2,6 +2,13 @@
2
2
  * Workflow execution: resolves the barnum binary, tsx executor, and worker
3
3
  * script, then spawns the workflow as a subprocess.
4
4
  */
5
- import type { Action, ExtractOutput } from "./ast.js";
5
+ import { type Action, type ExtractOutput } from "./ast.js";
6
+ /** Log verbosity for the barnum engine runtime. Passed to the CLI's `--log-level`. */
7
+ export type LogLevel = "off" | "error" | "warn" | "info" | "debug" | "trace";
8
+ export interface RunPipelineOptions {
9
+ /** Engine log verbosity. Default: "off" (only handler stderr is visible). */
10
+ logLevel?: LogLevel;
11
+ }
6
12
  /** Run a pipeline to completion. Returns the workflow's final output value. */
7
- export declare function runPipeline<TPipeline extends Action>(pipeline: TPipeline, input?: unknown): Promise<ExtractOutput<TPipeline>>;
13
+ export declare function runPipeline<TPipeline extends Action>(pipeline: TPipeline, input?: unknown, options?: RunPipelineOptions): Promise<ExtractOutput<TPipeline>>;
14
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,aAAa,EAEnB,MAAM,UAAU,CAAC;AAIlB,sFAAsF;AACtF,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE7E,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAyGD,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAClD,QAAQ,EAAE,SAAS,EACnB,KAAK,CAAC,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAMnC"}
package/dist/run.js CHANGED
@@ -7,8 +7,9 @@ import { createRequire } from "node:module";
7
7
  import { existsSync } from "node:fs";
8
8
  import os from "node:os";
9
9
  import path from "node:path";
10
+ import { toAction, } from "./ast.js";
10
11
  import { chain } from "./chain.js";
11
- import { constant } from "./builtins.js";
12
+ import { constant } from "./builtins/index.js";
12
13
  const __dirname = import.meta.dirname;
13
14
  /** Resolve the TypeScript executor. Uses bun if the workflow was launched with bun, otherwise tsx. */
14
15
  function resolveExecutor() {
@@ -79,52 +80,68 @@ function resolveBinary() {
79
80
  function resolveWorker() {
80
81
  return path.resolve(__dirname, "../src/worker.ts");
81
82
  }
82
- /** Build the barnum binary if using the local dev path. */
83
- function buildBinary() {
83
+ /** Build the barnum binary if using the local dev path. Skips if binary already exists. */
84
+ function buildBinaryIfNeeded(binaryPath) {
85
+ if (existsSync(binaryPath)) {
86
+ return;
87
+ }
84
88
  const repoRoot = path.resolve(__dirname, "../../..");
89
+ // eslint-disable-next-line no-console
90
+ console.error("[barnum] building CLI binary (cargo build -p barnum_cli)...");
85
91
  execFileSync("cargo", ["build", "-p", "barnum_cli"], {
86
92
  cwd: repoRoot,
87
- stdio: "ignore",
93
+ stdio: "inherit",
88
94
  });
89
95
  }
90
96
  /** Run a pipeline to completion. Returns the workflow's final output value. */
91
- export function runPipeline(pipeline, input) {
97
+ export function runPipeline(pipeline, input, options) {
92
98
  const workflow = input === undefined
93
99
  ? pipeline
94
- : chain(constant(input), pipeline);
95
- return spawnBarnum({ workflow });
100
+ : toAction(chain(toAction(constant(input)), toAction(pipeline)));
101
+ return spawnBarnum({ workflow }, options?.logLevel);
96
102
  }
97
103
  /** Spawn the barnum CLI with the given config. Returns the parsed final value from stdout. */
98
- function spawnBarnum(config) {
104
+ function spawnBarnum(config, logLevel) {
99
105
  const binaryResolution = resolveBinary();
100
106
  if (binaryResolution.kind === "Local") {
101
- buildBinary();
107
+ buildBinaryIfNeeded(binaryResolution.path);
102
108
  }
103
109
  const executor = resolveExecutor();
104
110
  const worker = resolveWorker();
105
111
  const configJson = JSON.stringify(config);
112
+ const cliArgs = [
113
+ "run",
114
+ "--config",
115
+ configJson,
116
+ "--executor",
117
+ executor,
118
+ "--worker",
119
+ worker,
120
+ ];
121
+ if (logLevel) {
122
+ cliArgs.push("--log-level", logLevel);
123
+ }
106
124
  return new Promise((resolve, reject) => {
107
- const child = nodeSpawn(binaryResolution.path, [
108
- "run",
109
- "--config",
110
- configJson,
111
- "--executor",
112
- executor,
113
- "--worker",
114
- worker,
115
- ], {
116
- stdio: ["inherit", "pipe", "inherit"],
125
+ const child = nodeSpawn(binaryResolution.path, cliArgs, {
126
+ stdio: ["inherit", "pipe", "pipe"],
117
127
  });
118
128
  const stdoutChunks = [];
129
+ const stderrChunks = [];
119
130
  child.stdout?.on("data", (chunk) => {
120
131
  stdoutChunks.push(chunk);
121
132
  });
133
+ child.stderr?.on("data", (chunk) => {
134
+ stderrChunks.push(chunk);
135
+ process.stderr.write(chunk);
136
+ });
122
137
  child.on("error", (error) => {
123
138
  reject(new Error(`Failed to spawn barnum: ${error.message}`));
124
139
  });
125
140
  child.on("close", (code) => {
126
141
  if (code !== 0) {
127
- reject(new Error(`barnum exited with code ${code}`));
142
+ const stderr = Buffer.concat(stderrChunks).toString("utf8").trim();
143
+ const detail = stderr ? `\n${stderr}` : "";
144
+ reject(new Error(`barnum exited with code ${code}${detail}`));
128
145
  return;
129
146
  }
130
147
  const stdout = Buffer.concat(stdoutChunks).toString("utf8").trim();
@@ -0,0 +1,6 @@
1
+ export { ok, err, some, none } from "./values.js";
2
+ export { createHandler, createHandlerWithConfig, type Handler, } from "./handler.js";
3
+ export { resultSchema, optionSchema } from "./schemas.js";
4
+ export { taggedUnionSchema } from "./builtins/index.js";
5
+ export type { Result, Option, TaggedUnion } from "./ast.js";
6
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,KAAK,OAAO,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ // Runtime value constructors
2
+ export { ok, err, some, none } from "./values.js";
3
+ // Handler creation
4
+ export { createHandler, createHandlerWithConfig, } from "./handler.js";
5
+ // Schema builders
6
+ export { resultSchema, optionSchema } from "./schemas.js";
7
+ export { taggedUnionSchema } from "./builtins/index.js";
package/dist/schema.d.ts CHANGED
@@ -6,3 +6,4 @@ import { type z } from "zod";
6
6
  * survive the TS → JSON → Rust boundary.
7
7
  */
8
8
  export declare function zodToCheckedJsonSchema(schema: z.ZodType, label: string): JSONSchema7;
9
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,CAAC,EAAgB,MAAM,KAAK,CAAC;AAoF3C;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,CAAC,CAAC,OAAO,EACjB,KAAK,EAAE,MAAM,GACZ,WAAW,CAwBb"}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ import type { Result, Option } from "./ast.js";
3
+ export declare function resultSchema<TValue, TError>(okSchema: z.ZodType<TValue>, errSchema: z.ZodType<TError>): z.ZodType<Result<TValue, TError>>;
4
+ export declare function optionSchema<TValue>(valueSchema: z.ZodType<TValue>): z.ZodType<Option<TValue>>;
5
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE/C,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EACzC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAC3B,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAC3B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAKnC;AAED,wBAAgB,YAAY,CAAC,MAAM,EACjC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAK3B"}
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export function resultSchema(okSchema, errSchema) {
3
+ return z.discriminatedUnion("kind", [
4
+ z.object({ kind: z.literal("Result.Ok"), value: okSchema }),
5
+ z.object({ kind: z.literal("Result.Err"), value: errSchema }),
6
+ ]);
7
+ }
8
+ export function optionSchema(valueSchema) {
9
+ return z.discriminatedUnion("kind", [
10
+ z.object({ kind: z.literal("Option.Some"), value: valueSchema }),
11
+ z.object({ kind: z.literal("Option.None"), value: z.null() }),
12
+ ]);
13
+ }
@@ -12,7 +12,7 @@ import { type Pipeable, type TypedAction } from "./ast.js";
12
12
  *
13
13
  * Compiled form (restart+Branch, same substrate as loop/earlyReturn):
14
14
  * `Chain(Tag("Continue"),`
15
- * `RestartHandle(id, ExtractIndex(0),`
15
+ * `RestartHandle(id, GetIndex(0),`
16
16
  * `Branch({ Continue: body, Break: recovery })))`
17
17
  *
18
18
  * throwError = `Chain(Tag("Break"), RestartPerform(id))`
@@ -21,3 +21,4 @@ import { type Pipeable, type TypedAction } from "./ast.js";
21
21
  * payload → body restarts → Branch takes Break arm → recovery receives error.
22
22
  */
23
23
  export declare function tryCatch<TIn, TOut, TError>(body: (throwError: TypedAction<TError, never>) => Pipeable<TIn, TOut>, recovery: Pipeable<TError, TOut>): TypedAction<TIn, TOut>;
24
+ //# sourceMappingURL=try-catch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try-catch.d.ts","sourceRoot":"","sources":["../src/try-catch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EAIjB,MAAM,UAAU,CAAC;AASlB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EACxC,IAAI,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EACrE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,GAC/B,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAiBxB"}
package/dist/try-catch.js CHANGED
@@ -1,4 +1,6 @@
1
- import { typedAction, buildRestartBranchAction, TAG_BREAK, } from "./ast.js";
1
+ import { toAction, typedAction, buildRestartBranchAction, } from "./ast.js";
2
+ import { chain } from "./chain.js";
3
+ import { tag } from "./builtins/index.js";
2
4
  import { allocateRestartHandlerId } from "./effect-id.js";
3
5
  // ---------------------------------------------------------------------------
4
6
  // tryCatch — type-level error handling via restart+Branch
@@ -16,7 +18,7 @@ import { allocateRestartHandlerId } from "./effect-id.js";
16
18
  *
17
19
  * Compiled form (restart+Branch, same substrate as loop/earlyReturn):
18
20
  * `Chain(Tag("Continue"),`
19
- * `RestartHandle(id, ExtractIndex(0),`
21
+ * `RestartHandle(id, GetIndex(0),`
20
22
  * `Branch({ Continue: body, Break: recovery })))`
21
23
  *
22
24
  * throwError = `Chain(Tag("Break"), RestartPerform(id))`
@@ -26,11 +28,10 @@ import { allocateRestartHandlerId } from "./effect-id.js";
26
28
  */
27
29
  export function tryCatch(body, recovery) {
28
30
  const restartHandlerId = allocateRestartHandlerId();
29
- const throwError = typedAction({
30
- kind: "Chain",
31
- first: TAG_BREAK,
32
- rest: { kind: "RestartPerform", restart_handler_id: restartHandlerId },
33
- });
34
- const bodyAction = body(throwError);
35
- return typedAction(buildRestartBranchAction(restartHandlerId, bodyAction, recovery));
31
+ const throwError = typedAction(toAction(chain(toAction(tag("Break", "LoopResult")), {
32
+ kind: "RestartPerform",
33
+ restart_handler_id: restartHandlerId,
34
+ })));
35
+ const bodyAction = toAction(body(throwError));
36
+ return typedAction(buildRestartBranchAction(restartHandlerId, bodyAction, toAction(recovery)));
36
37
  }
@@ -0,0 +1,6 @@
1
+ import type { Result, Option } from "./ast.js";
2
+ export declare function ok<TValue, TError = unknown>(value: TValue): Result<TValue, TError>;
3
+ export declare function err<TValue = unknown, TError = never>(error: TError): Result<TValue, TError>;
4
+ export declare function some<T>(value: T): Option<T>;
5
+ export declare function none<T = unknown>(): Option<T>;
6
+ //# sourceMappingURL=values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE/C,wBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EACzC,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB;AAED,wBAAgB,GAAG,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,EAClD,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAE3C;AAED,wBAAgB,IAAI,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,CAE7C"}
package/dist/values.js ADDED
@@ -0,0 +1,12 @@
1
+ export function ok(value) {
2
+ return { kind: "Result.Ok", value };
3
+ }
4
+ export function err(error) {
5
+ return { kind: "Result.Err", value: error };
6
+ }
7
+ export function some(value) {
8
+ return { kind: "Option.Some", value };
9
+ }
10
+ export function none() {
11
+ return { kind: "Option.None", value: null };
12
+ }
package/dist/worker.d.ts CHANGED
@@ -5,7 +5,11 @@
5
5
  * Rust → stdin: JSON `{ "value": <any> }`
6
6
  * stdout → Rust: JSON result (handler return value)
7
7
  *
8
+ * stdout is reserved for the protocol. All console output is redirected to
9
+ * stderr so that handler code can freely use console.log for debugging.
10
+ *
8
11
  * If the handler throws or the module/export can't be resolved, the
9
12
  * process exits non-zero. Rust interprets that as a fatal workflow error.
10
13
  */
11
- declare function main(): Promise<void>;
14
+ export {};
15
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}