brass-runtime 1.14.0 → 1.16.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 (90) hide show
  1. package/README.md +410 -135
  2. package/dist/agent/cli/main.cjs +49 -43
  3. package/dist/agent/cli/main.js +11 -5
  4. package/dist/agent/cli/main.mjs +11 -5
  5. package/dist/agent/index.cjs +8 -3
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +7 -2
  8. package/dist/agent/index.mjs +7 -2
  9. package/dist/{chunk-BMRF4FN6.js → chunk-2WC63LJK.mjs} +68 -242
  10. package/dist/chunk-3RG5ZIWI.js +10 -0
  11. package/dist/chunk-45F7OKGT.cjs +104 -0
  12. package/dist/chunk-5YOQOXEQ.cjs +2491 -0
  13. package/dist/chunk-7HUOJA4W.cjs +493 -0
  14. package/dist/{chunk-4N2JEK4H.mjs → chunk-7LVI2GIN.js} +252 -495
  15. package/dist/chunk-7TL2LHQJ.js +2491 -0
  16. package/dist/chunk-7V4KY4RL.mjs +104 -0
  17. package/dist/chunk-7XOPAB5Q.js +2143 -0
  18. package/dist/chunk-CCKHV5BT.mjs +193 -0
  19. package/dist/chunk-CY33PGEX.mjs +1110 -0
  20. package/dist/chunk-DJQ7OMMB.cjs +144 -0
  21. package/dist/chunk-F5EUMJL7.mjs +2143 -0
  22. package/dist/chunk-FM4W4QPL.js +193 -0
  23. package/dist/chunk-G3XGCZDQ.js +131 -0
  24. package/dist/{chunk-JT7D6M5H.js → chunk-G6IQOE4P.mjs} +252 -495
  25. package/dist/chunk-GOV47PPB.mjs +552 -0
  26. package/dist/chunk-H55LI6WY.js +93 -0
  27. package/dist/chunk-IJT6RRQ5.cjs +93 -0
  28. package/dist/chunk-J3H54ZRV.mjs +131 -0
  29. package/dist/chunk-JF4XXPZ5.cjs +552 -0
  30. package/dist/chunk-JNFRRJYH.cjs +2143 -0
  31. package/dist/chunk-JX3LZQJH.cjs +354 -0
  32. package/dist/chunk-K2T3DV26.mjs +93 -0
  33. package/dist/chunk-KCPT2D6G.js +552 -0
  34. package/dist/chunk-MWXMNYJS.cjs +1110 -0
  35. package/dist/{chunk-XTMZTVIT.cjs → chunk-N6VHMOWB.cjs} +140 -134
  36. package/dist/{chunk-WJESVBWN.js → chunk-NC5SDRYE.js} +16 -10
  37. package/dist/chunk-NOYZIMUJ.mjs +144 -0
  38. package/dist/chunk-NYL4D7SK.cjs +131 -0
  39. package/dist/chunk-OBGZSXTJ.cjs +10 -0
  40. package/dist/{chunk-UWMMYKVK.mjs → chunk-OOGJ73B6.js} +68 -242
  41. package/dist/chunk-PNVFW245.js +144 -0
  42. package/dist/chunk-PRWCB3QL.mjs +2491 -0
  43. package/dist/chunk-QY5FKYEQ.js +1110 -0
  44. package/dist/chunk-ROJC3NBJ.js +104 -0
  45. package/dist/chunk-SPUEME2B.cjs +343 -0
  46. package/dist/chunk-TDVMADDN.js +343 -0
  47. package/dist/chunk-TVN5I4U6.cjs +193 -0
  48. package/dist/chunk-U5KWK3PX.mjs +343 -0
  49. package/dist/chunk-VFIUZG7J.mjs +354 -0
  50. package/dist/{chunk-BKBFSOGT.cjs → chunk-WQ5QNU5R.cjs} +460 -703
  51. package/dist/chunk-XDZOO4L5.js +354 -0
  52. package/dist/chunk-Y6FXYEAI.mjs +10 -0
  53. package/dist/{chunk-MQF7HZ7Y.mjs → chunk-ZGLD4TVZ.mjs} +16 -10
  54. package/dist/client-CtFmoDvM.d.ts +645 -0
  55. package/dist/core/index.cjs +284 -0
  56. package/dist/core/index.d.ts +567 -0
  57. package/dist/core/index.js +284 -0
  58. package/dist/core/index.mjs +284 -0
  59. package/dist/{effect-DM56H743.d.ts → effect-CGNl5Rqp.d.ts} +118 -11
  60. package/dist/effectRunner-3ZHAD3LE.cjs +8 -0
  61. package/dist/effectRunner-A4CHJXJI.js +8 -0
  62. package/dist/effectRunner-OPUF6QRN.mjs +8 -0
  63. package/dist/http/index.cjs +4130 -890
  64. package/dist/http/index.d.ts +2289 -219
  65. package/dist/http/index.js +4116 -876
  66. package/dist/http/index.mjs +4116 -876
  67. package/dist/http/testing.cjs +159 -0
  68. package/dist/http/testing.d.ts +42 -0
  69. package/dist/http/testing.js +159 -0
  70. package/dist/http/testing.mjs +159 -0
  71. package/dist/index.cjs +305 -1168
  72. package/dist/index.d.ts +9 -701
  73. package/dist/index.js +176 -1039
  74. package/dist/index.mjs +176 -1039
  75. package/dist/observability/index.cjs +677 -0
  76. package/dist/observability/index.d.ts +79 -0
  77. package/dist/observability/index.js +677 -0
  78. package/dist/observability/index.mjs +677 -0
  79. package/dist/schedule-Fque9Abz.d.ts +70 -0
  80. package/dist/schema/index.cjs +25 -0
  81. package/dist/schema/index.d.ts +177 -0
  82. package/dist/schema/index.js +25 -0
  83. package/dist/schema/index.mjs +25 -0
  84. package/dist/server-C8hDXA74.d.ts +674 -0
  85. package/dist/stream-dvSs0QS5.d.ts +74 -0
  86. package/dist/tracer-B5tRH9H7.d.ts +230 -0
  87. package/dist/tracing-Dt9S_6V8.d.ts +148 -0
  88. package/package.json +37 -3
  89. package/dist/chunk-SKVY72E5.cjs +0 -667
  90. package/dist/stream-Oqe6WeLE.d.ts +0 -173
@@ -1,17 +1,23 @@
1
+ import {
2
+ race
3
+ } from "./chunk-G3XGCZDQ.js";
4
+ import {
5
+ withScopeAsync
6
+ } from "./chunk-FM4W4QPL.js";
7
+ import {
8
+ fromPromiseAbortable
9
+ } from "./chunk-7LVI2GIN.js";
1
10
  import {
2
11
  Cause,
3
12
  Exit,
4
- async,
13
+ asyncEffect,
5
14
  asyncFail,
6
15
  asyncFlatMap,
7
16
  asyncFold,
8
17
  asyncMap,
9
18
  asyncSucceed,
10
- asyncSync,
11
- fromPromiseAbortable,
12
- race,
13
- withScopeAsync
14
- } from "./chunk-JT7D6M5H.js";
19
+ asyncSync
20
+ } from "./chunk-PNVFW245.js";
15
21
 
16
22
  // src/agent/core/state.ts
17
23
  var initialAgentState = (goal) => ({
@@ -1425,10 +1431,10 @@ var decideNextAction = (state) => {
1425
1431
  };
1426
1432
 
1427
1433
  // src/agent/core/events.ts
1428
- var nowMillis = () => async((_env, cb) => {
1434
+ var nowMillis = () => asyncEffect((_env, cb) => {
1429
1435
  cb({ _tag: "Success", value: Date.now() });
1430
1436
  });
1431
- var emitAgentEvent = (event) => async((env, cb) => {
1437
+ var emitAgentEvent = (event) => asyncEffect((env, cb) => {
1432
1438
  try {
1433
1439
  env.events?.emit(event);
1434
1440
  } catch {
@@ -1684,7 +1690,7 @@ var retry = (make, options) => {
1684
1690
  };
1685
1691
 
1686
1692
  // src/agent/tools/timeout.ts
1687
- var sleep = (ms) => async((_env, cb) => {
1693
+ var sleep = (ms) => asyncEffect((_env, cb) => {
1688
1694
  const id = setTimeout(() => cb({ _tag: "Success", value: void 0 }), ms);
1689
1695
  return () => clearTimeout(id);
1690
1696
  });
@@ -2124,7 +2130,7 @@ var chunkToString = (chunk) => {
2124
2130
  return typeof maybeToString === "function" ? maybeToString.call(chunk, "utf8") : String(chunk);
2125
2131
  };
2126
2132
  var NodeShell = {
2127
- exec: (command, options) => async((_env, cb) => {
2133
+ exec: (command, options) => asyncEffect((_env, cb) => {
2128
2134
  const [bin, ...args] = command;
2129
2135
  if (!bin) {
2130
2136
  cb(
@@ -0,0 +1,144 @@
1
+ // src/core/types/asyncEffect.ts
2
+ var Async = {
3
+ succeed: (value) => ({ _tag: "Succeed", value }),
4
+ fail: (error) => ({ _tag: "Fail", error }),
5
+ sync: (thunk) => ({ _tag: "Sync", thunk }),
6
+ async: (register) => ({ _tag: "Async", register })
7
+ };
8
+ function asyncFold(fa, onFailure, onSuccess) {
9
+ return {
10
+ _tag: "Fold",
11
+ first: fa,
12
+ onFailure,
13
+ onSuccess
14
+ };
15
+ }
16
+ function asyncCatchAll(fa, handler) {
17
+ return asyncFold(fa, handler, asyncSucceed);
18
+ }
19
+ function asyncMapError(fa, f) {
20
+ return asyncFold(fa, (e) => asyncFail(f(e)), asyncSucceed);
21
+ }
22
+ var SUCCEED_UNDEFINED = { _tag: "Succeed", value: void 0 };
23
+ var SUCCEED_TRUE = { _tag: "Succeed", value: true };
24
+ var SUCCEED_FALSE = { _tag: "Succeed", value: false };
25
+ var SUCCEED_NULL = { _tag: "Succeed", value: null };
26
+ var unit = () => SUCCEED_UNDEFINED;
27
+ var asyncSucceed = (value) => {
28
+ if (value === void 0) return SUCCEED_UNDEFINED;
29
+ if (value === true) return SUCCEED_TRUE;
30
+ if (value === false) return SUCCEED_FALSE;
31
+ if (value === null) return SUCCEED_NULL;
32
+ return { _tag: "Succeed", value };
33
+ };
34
+ var asyncFail = (error) => ({
35
+ _tag: "Fail",
36
+ error
37
+ });
38
+ var asyncSync = (thunk) => ({
39
+ _tag: "Sync",
40
+ thunk
41
+ });
42
+ var asyncTotal = (thunk) => asyncSync(() => thunk());
43
+ var asyncEffect = (register) => ({
44
+ _tag: "Async",
45
+ register
46
+ });
47
+ function asyncMap(fa, f) {
48
+ return asyncFlatMap(fa, (a) => asyncSucceed(f(a)));
49
+ }
50
+ function asyncFlatMap(fa, f) {
51
+ return {
52
+ _tag: "FlatMap",
53
+ first: fa,
54
+ andThen: f
55
+ };
56
+ }
57
+ function acquireRelease(acquire, release, scope) {
58
+ return asyncFlatMap(acquire, (resource) => {
59
+ scope.addFinalizer((exit) => release(resource, exit));
60
+ return asyncSucceed(resource);
61
+ });
62
+ }
63
+ function asyncInterruptible(register) {
64
+ return asyncEffect(register);
65
+ }
66
+ var withAsyncPromise = (run) => (eff) => {
67
+ const anyEff = eff;
68
+ if (!anyEff.toPromise) {
69
+ anyEff.toPromise = (env) => run(eff, env);
70
+ anyEff.unsafeRunPromise = () => run(eff, {});
71
+ }
72
+ return anyEff;
73
+ };
74
+ var mapAsync = (fa, f) => asyncFlatMap(fa, (a) => asyncSucceed(f(a)));
75
+ var mapTryAsync = (fa, f) => asyncFlatMap(fa, (a) => asyncSync(() => f(a)));
76
+
77
+ // src/core/types/option.ts
78
+ var none = { _tag: "None" };
79
+ var some = (value) => ({ _tag: "Some", value });
80
+
81
+ // src/core/types/effect.ts
82
+ var Cause = {
83
+ fail: (error) => ({ _tag: "Fail", error }),
84
+ interrupt: () => ({ _tag: "Interrupt" }),
85
+ die: (defect) => ({ _tag: "Die", defect })
86
+ };
87
+ var Exit = {
88
+ succeed: (value) => ({
89
+ _tag: "Success",
90
+ value
91
+ }),
92
+ failCause: (cause) => ({
93
+ _tag: "Failure",
94
+ cause
95
+ })
96
+ };
97
+ var succeed = (value) => asyncSucceed(value);
98
+ var fail = (error) => asyncFail(error);
99
+ var sync = (thunk) => asyncSync((env) => thunk(env));
100
+ var map = (fa, f) => asyncMap(fa, f);
101
+ var flatMap = (fa, f) => asyncFlatMap(fa, f);
102
+ var mapError = (fa, f) => asyncMapError(fa, f);
103
+ var catchAll = (fa, handler) => asyncFold(fa, handler, asyncSucceed);
104
+ function orElseOptional(fa, that) {
105
+ return asyncFold(
106
+ fa,
107
+ (opt) => opt._tag === "Some" ? asyncFail(opt) : that(),
108
+ asyncSucceed
109
+ );
110
+ }
111
+ var end = () => fail(none);
112
+
113
+ export {
114
+ Async,
115
+ asyncFold,
116
+ asyncCatchAll,
117
+ asyncMapError,
118
+ unit,
119
+ asyncSucceed,
120
+ asyncFail,
121
+ asyncSync,
122
+ asyncTotal,
123
+ asyncEffect,
124
+ asyncMap,
125
+ asyncFlatMap,
126
+ acquireRelease,
127
+ asyncInterruptible,
128
+ withAsyncPromise,
129
+ mapAsync,
130
+ mapTryAsync,
131
+ none,
132
+ some,
133
+ Cause,
134
+ Exit,
135
+ succeed,
136
+ fail,
137
+ sync,
138
+ map,
139
+ flatMap,
140
+ mapError,
141
+ catchAll,
142
+ orElseOptional,
143
+ end
144
+ };
@@ -0,0 +1,131 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkDJQ7OMMBcjs = require('./chunk-DJQ7OMMB.cjs');
4
+
5
+ // src/core/stream/structuredConcurrency.ts
6
+ function race(left, right, parentScope) {
7
+ return _chunkDJQ7OMMBcjs.asyncEffect.call(void 0, (env, cb) => {
8
+ const scope = parentScope.subScope();
9
+ let done = false;
10
+ const onResult = (exit) => {
11
+ if (done) return;
12
+ done = true;
13
+ scope.close(exit);
14
+ cb(exit);
15
+ };
16
+ const fiberLeft = scope.fork(left);
17
+ const fiberRight = scope.fork(right);
18
+ fiberLeft.join(onResult);
19
+ fiberRight.join(onResult);
20
+ });
21
+ }
22
+ function zipPar(left, right, parentScope) {
23
+ return _chunkDJQ7OMMBcjs.asyncEffect.call(void 0, (env, cb) => {
24
+ const scope = parentScope.subScope();
25
+ let leftExit = null;
26
+ let rightExit = null;
27
+ let done = false;
28
+ const checkDone = () => {
29
+ if (!leftExit || !rightExit || done) return;
30
+ done = true;
31
+ if (leftExit._tag === "Success" && rightExit._tag === "Success") {
32
+ scope.close({ _tag: "Success", value: void 0 });
33
+ cb({
34
+ _tag: "Success",
35
+ value: [leftExit.value, rightExit.value]
36
+ });
37
+ return;
38
+ }
39
+ let cause;
40
+ if (leftExit._tag === "Failure") {
41
+ cause = leftExit.cause;
42
+ } else if (rightExit._tag === "Failure") {
43
+ cause = rightExit.cause;
44
+ } else {
45
+ throw new Error("zipPar: unreachable state (no Failure exit)");
46
+ }
47
+ const errExit = {
48
+ _tag: "Failure",
49
+ cause
50
+ };
51
+ scope.close(errExit);
52
+ cb(errExit);
53
+ };
54
+ const f1 = scope.fork(left);
55
+ const f2 = scope.fork(right);
56
+ f1.join((exit) => {
57
+ leftExit = exit;
58
+ checkDone();
59
+ });
60
+ f2.join((exit) => {
61
+ rightExit = exit;
62
+ checkDone();
63
+ });
64
+ });
65
+ }
66
+ function collectAllPar(effects, parentScope) {
67
+ return _chunkDJQ7OMMBcjs.asyncEffect.call(void 0, (env, cb) => {
68
+ const scope = parentScope.subScope();
69
+ const results = new Array(effects.length);
70
+ let completed = 0;
71
+ let done = false;
72
+ effects.forEach((eff, i) => {
73
+ const f = scope.fork(eff);
74
+ f.join((exit) => {
75
+ if (done) return;
76
+ if (exit._tag === "Failure") {
77
+ done = true;
78
+ const errExit = {
79
+ _tag: "Failure",
80
+ cause: exit.cause
81
+ };
82
+ scope.close(errExit);
83
+ cb(errExit);
84
+ return;
85
+ }
86
+ results[i] = exit.value;
87
+ completed++;
88
+ if (completed === effects.length) {
89
+ done = true;
90
+ const successExit = {
91
+ _tag: "Success",
92
+ value: results
93
+ };
94
+ scope.close({ _tag: "Success", value: void 0 });
95
+ cb(successExit);
96
+ }
97
+ });
98
+ });
99
+ });
100
+ }
101
+ function raceWith(left, right, parentScope, onLeft, onRight) {
102
+ return _chunkDJQ7OMMBcjs.asyncEffect.call(void 0, (env, cb) => {
103
+ const scope = parentScope.subScope();
104
+ let done = false;
105
+ const fiberLeft = scope.fork(left);
106
+ const fiberRight = scope.fork(right);
107
+ const finish = (next) => {
108
+ scope.fork(next).join((exitNext) => {
109
+ scope.close(exitNext);
110
+ cb(exitNext);
111
+ });
112
+ };
113
+ fiberLeft.join((exitL) => {
114
+ if (done) return;
115
+ done = true;
116
+ finish(onLeft(exitL, fiberRight, scope));
117
+ });
118
+ fiberRight.join((exitR) => {
119
+ if (done) return;
120
+ done = true;
121
+ finish(onRight(exitR, fiberLeft, scope));
122
+ });
123
+ });
124
+ }
125
+
126
+
127
+
128
+
129
+
130
+
131
+ exports.race = race; exports.zipPar = zipPar; exports.collectAllPar = collectAllPar; exports.raceWith = raceWith;
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+
9
+
10
+ exports.__require = __require;