brass-runtime 1.15.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 (93) hide show
  1. package/README.md +409 -137
  2. package/dist/agent/cli/main.cjs +40 -35
  3. package/dist/agent/cli/main.js +9 -4
  4. package/dist/agent/cli/main.mjs +9 -4
  5. package/dist/agent/index.cjs +8 -4
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +7 -3
  8. package/dist/agent/index.mjs +7 -3
  9. package/dist/{chunk-PPUXIH5R.js → chunk-2WC63LJK.mjs} +11 -7
  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-STVLQ3XD.cjs → chunk-7HUOJA4W.cjs} +78 -74
  14. package/dist/{chunk-BMH5AV44.js → chunk-7LVI2GIN.js} +251 -370
  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-AR22SXML.js → chunk-CY33PGEX.mjs} +488 -421
  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-TO7IKXYT.js → chunk-G3XGCZDQ.js} +1 -1
  24. package/dist/{chunk-BDF4AMWX.mjs → chunk-G6IQOE4P.mjs} +251 -370
  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-ELOOF35R.mjs → chunk-J3H54ZRV.mjs} +1 -1
  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-VEZNF5GZ.cjs → chunk-N6VHMOWB.cjs} +130 -126
  36. package/dist/{chunk-3QMOKAS5.js → chunk-NC5SDRYE.js} +9 -5
  37. package/dist/chunk-NOYZIMUJ.mjs +144 -0
  38. package/dist/{chunk-R3R2FVLG.cjs → chunk-NYL4D7SK.cjs} +5 -5
  39. package/dist/chunk-OBGZSXTJ.cjs +10 -0
  40. package/dist/{chunk-4NHES7VK.mjs → chunk-OOGJ73B6.js} +11 -7
  41. package/dist/chunk-PNVFW245.js +144 -0
  42. package/dist/chunk-PRWCB3QL.mjs +2491 -0
  43. package/dist/{chunk-JFPU5GQI.mjs → chunk-QY5FKYEQ.js} +488 -421
  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-TGIFUAK4.cjs → chunk-WQ5QNU5R.cjs} +459 -578
  51. package/dist/chunk-XDZOO4L5.js +354 -0
  52. package/dist/chunk-Y6FXYEAI.mjs +10 -0
  53. package/dist/{chunk-K6M7MDZ4.mjs → chunk-ZGLD4TVZ.mjs} +9 -5
  54. package/dist/client-CtFmoDvM.d.ts +645 -0
  55. package/dist/core/index.cjs +72 -4
  56. package/dist/core/index.d.ts +92 -198
  57. package/dist/core/index.js +106 -38
  58. package/dist/core/index.mjs +106 -38
  59. package/dist/{effect-CMOQKX8y.d.ts → effect-CGNl5Rqp.d.ts} +107 -1
  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 +2189 -1271
  64. package/dist/http/index.d.ts +830 -270
  65. package/dist/http/index.js +2008 -1090
  66. package/dist/http/index.mjs +2008 -1090
  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 +246 -178
  72. package/dist/index.d.ts +9 -35
  73. package/dist/index.js +120 -52
  74. package/dist/index.mjs +120 -52
  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-FQm9h4Mg.d.ts → stream-dvSs0QS5.d.ts} +1 -1
  86. package/dist/tracer-B5tRH9H7.d.ts +230 -0
  87. package/dist/tracing-Dt9S_6V8.d.ts +148 -0
  88. package/package.json +27 -1
  89. package/dist/chunk-BDYEENHT.js +0 -224
  90. package/dist/chunk-MS34J5LY.cjs +0 -224
  91. package/dist/chunk-UMAZLXAB.mjs +0 -224
  92. package/dist/chunk-XPZNXSVN.cjs +0 -1043
  93. package/dist/tracing-DNT9jEbr.d.ts +0 -106
@@ -92,6 +92,7 @@ declare function makeBoundedRingBuffer<T>(initialCapacity: number, maxCapacity?:
92
92
 
93
93
  type Task = () => void;
94
94
  type ScheduleResult = "accepted" | "dropped";
95
+ type SchedulerLaneMode = "fair" | "single";
95
96
  type SchedulerEngine = "ts" | "wasm";
96
97
  type LaneStatsData = {
97
98
  key: string;
@@ -116,6 +117,8 @@ type SchedulerStatsData = {
116
117
  type SchedulerStats = EngineStats<SchedulerStatsData>;
117
118
  type SchedulerOptions = RingBufferOptions & {
118
119
  engine?: SchedulerEngine;
120
+ /** fair keeps per-lane round-robin scheduling; single uses one direct TS queue for maximum throughput. */
121
+ laneMode?: SchedulerLaneMode;
119
122
  initialCapacity?: number;
120
123
  maxCapacity?: number;
121
124
  flushBudget?: number;
@@ -138,6 +141,7 @@ declare function inferCallerLaneFromStack(stack?: string | undefined, fallback?:
138
141
  declare class Scheduler {
139
142
  private readonly engine;
140
143
  private readonly js?;
144
+ private readonly jsSingle?;
141
145
  private readonly wasm?;
142
146
  private readonly flushBudget;
143
147
  private readonly microThreshold;
@@ -146,6 +150,7 @@ declare class Scheduler {
146
150
  private readonly maxLanes;
147
151
  private readonly fallbackUsed;
148
152
  private readonly boundFlush;
153
+ private shiftedTag;
149
154
  constructor(options?: SchedulerOptions);
150
155
  schedule(task: Task, tag?: string): ScheduleResult;
151
156
  scheduleBatch(tasks: Array<{
@@ -157,10 +162,13 @@ declare class Scheduler {
157
162
  private scheduleBatchWasm;
158
163
  private getOrCreateLane;
159
164
  private createLane;
165
+ private scheduleJsSingle;
166
+ private scheduleBatchJsSingle;
160
167
  private scheduleJs;
161
168
  private requestFlush;
162
169
  private flush;
163
170
  private flushWasm;
171
+ private flushJsSingle;
164
172
  private shiftFromNextLane;
165
173
  private flushJs;
166
174
  }
@@ -193,17 +201,73 @@ type RuntimeEvent = {
193
201
  scopeId: number;
194
202
  status: "success" | "failure" | "interrupted";
195
203
  error?: unknown;
204
+ } | {
205
+ type: "supervisor.child.start";
206
+ supervisorId: number;
207
+ childId: number;
208
+ name?: string;
209
+ restartCount: number;
210
+ } | {
211
+ type: "supervisor.child.end";
212
+ supervisorId: number;
213
+ childId: number;
214
+ name?: string;
215
+ status: "success" | "failure" | "interrupted";
216
+ error?: unknown;
217
+ } | {
218
+ type: "supervisor.child.restart";
219
+ supervisorId: number;
220
+ childId: number;
221
+ name?: string;
222
+ restartCount: number;
223
+ delayMs: number;
224
+ reason?: string;
225
+ } | {
226
+ type: "supervisor.child.escalate";
227
+ supervisorId: number;
228
+ childId: number;
229
+ name?: string;
230
+ reason?: string;
231
+ error?: unknown;
232
+ } | {
233
+ type: "supervisor.shutdown";
234
+ supervisorId: number;
196
235
  } | {
197
236
  type: "log";
198
237
  level: "debug" | "info" | "warn" | "error";
199
238
  message: string;
200
239
  fields?: Record<string, unknown>;
240
+ } | {
241
+ type: "span.start";
242
+ name: string;
243
+ attributes?: Record<string, unknown>;
244
+ links?: RuntimeSpanLink[];
245
+ } | {
246
+ type: "span.event";
247
+ name: string;
248
+ attributes?: Record<string, unknown>;
249
+ } | {
250
+ type: "span.end";
251
+ name?: string;
252
+ status: "success" | "failure" | "interrupted";
253
+ error?: unknown;
254
+ attributes?: Record<string, unknown>;
201
255
  };
202
256
  type RuntimeEmitContext = {
203
257
  fiberId?: number;
204
258
  scopeId?: number;
205
259
  traceId?: string;
206
260
  spanId?: string;
261
+ parentSpanId?: string;
262
+ traceState?: string;
263
+ baggage?: Record<string, string>;
264
+ sampled?: boolean;
265
+ };
266
+ type RuntimeSpanLink = {
267
+ traceId: string;
268
+ spanId: string;
269
+ traceState?: string;
270
+ attributes?: Record<string, string | number | boolean>;
207
271
  };
208
272
  interface RuntimeHooks {
209
273
  emit(ev: RuntimeEvent, ctx: RuntimeEmitContext): void;
@@ -212,6 +276,13 @@ type RuntimeEventRecord = RuntimeEvent & RuntimeEmitContext & {
212
276
  seq: number;
213
277
  wallTs: number;
214
278
  ts: number;
279
+ /**
280
+ * The ambient fiber/scope from RuntimeEmitContext. Event payload fields
281
+ * keep priority in the merged record, so these preserve the context when
282
+ * an event also has a fiberId/scopeId of its own.
283
+ */
284
+ contextFiberId?: number;
285
+ contextScopeId?: number;
215
286
  /**
216
287
  * Convenience fields for generic event consumers. They are present for
217
288
  * log events and absent for fiber/scope events, but keeping them optional
@@ -222,6 +293,8 @@ type RuntimeEventRecord = RuntimeEvent & RuntimeEmitContext & {
222
293
  message?: string;
223
294
  fields?: Record<string, unknown>;
224
295
  };
296
+ declare function makeRuntimeEventRecord(ev: RuntimeEvent, ctx: RuntimeEmitContext, seq: number): RuntimeEventRecord;
297
+ declare function runtimeEventRecordContext(record: RuntimeEventRecord): RuntimeEmitContext;
225
298
 
226
299
  type FiberRunState = "Queued" | "Running" | "Suspended" | "Done";
227
300
  type FiberInfo = {
@@ -528,9 +601,36 @@ interface WasmBridge {
528
601
  }
529
602
  type Joiner<E, A> = (exit: Exit<E, A>) => void;
530
603
 
604
+ type ReadyQueueScheduleKind = "micro" | "macro" | "none" | "dropped";
605
+ type FiberReadyQueueStats = {
606
+ readonly engine: "ts" | "wasm";
607
+ readonly fallbackUsed: boolean;
608
+ readonly data: unknown;
609
+ };
610
+ interface FiberReadyQueue {
611
+ readonly engine: "ts" | "wasm";
612
+ enqueue(fiberId: FiberId$1, tag: string): ReadyQueueScheduleKind;
613
+ beginFlush(): number;
614
+ shift(): FiberId$1 | undefined;
615
+ endFlush(ran: number): ReadyQueueScheduleKind;
616
+ len(): number;
617
+ clear(): void;
618
+ stats(): FiberReadyQueueStats;
619
+ }
620
+ type FiberReadyQueueOptions = {
621
+ readonly engine?: "ts" | "wasm";
622
+ readonly flushBudget?: number;
623
+ readonly microThreshold?: number;
624
+ readonly laneCapacity?: number;
625
+ readonly laneBudget?: number;
626
+ readonly maxLanes?: number;
627
+ };
628
+ declare function makeFiberReadyQueue(options?: FiberReadyQueueOptions): FiberReadyQueue;
629
+
531
630
  type WasmFiberEngineOptions = {
532
631
  readonly bridge?: WasmBridge;
533
632
  readonly modulePath?: string;
633
+ readonly readyQueue?: Omit<FiberReadyQueueOptions, "engine">;
534
634
  };
535
635
  declare class WasmFiberEngine<R> implements FiberEngine<R> {
536
636
  private readonly runtime;
@@ -726,11 +826,17 @@ type ContextNode = {
726
826
  parent: ContextNode | null;
727
827
  patch: Record<string, JSONValue>;
728
828
  };
829
+ declare const emptyContext: ContextNode;
830
+ declare function ctxExtend(parent: ContextNode, patch: Record<string, JSONValue>): ContextNode;
831
+ declare function ctxToObject(ctx: ContextNode): Record<string, JSONValue>;
832
+ type Baggage = Record<string, string>;
729
833
  type TraceContext = {
730
834
  traceId: string;
731
835
  spanId: string;
732
836
  parentSpanId?: string;
733
837
  sampled?: boolean;
838
+ traceState?: string;
839
+ baggage?: Baggage;
734
840
  };
735
841
  type FiberContext = {
736
842
  log: ContextNode;
@@ -965,4 +1071,4 @@ declare const catchAll: <R, E, A, R2, E2, B>(fa: ZIO<R, E, A>, handler: (e: E) =
965
1071
  declare function orElseOptional<R, E, A, R2, A2>(fa: ZIO<R, Option<E>, A>, that: () => ZIO<R2, Option<E>, A2>): ZIO<R & R2, Option<E>, A | A2>;
966
1072
  declare const end: <E>() => ZIO<unknown, Option<E>, never>;
967
1073
 
968
- export { type Joiner as $, Async as A, type EngineKind as B, type CancelToken as C, type DbHostAction as D, Exit as E, type FiberEngine as F, type EngineSelection as G, type EngineSelectionMode as H, type FiberEngineKind as I, type FlatMapRef as J, type FoldFailureRef as K, type FoldSuccessRef as L, type HostAction as M, type NodeId as N, type Option as O, type HostActionKind as P, type HostActionResult as Q, RuntimeFiber as R, Scope as S, type HostExecutionContext as T, type HostExecutor as U, HostRegistry as V, type WasmEngineRuntime as W, type HostRegistryStats as X, type HttpHostAction as Y, type ZIO as Z, type Interrupted as _, type FiberEngineStats as a, sanitizeLaneKey as a$, type LaneStatsData as a0, type None as a1, NoopHooks as a2, ProgramBuilder as a3, type ProgramPatch as a4, PushStatus as a5, type QueueHostAction as a6, RingBuffer as a7, type RingBufferEngine as a8, type RingBufferStatsData as a9, asyncSucceed as aA, asyncSync as aB, asyncTotal as aC, catchAll as aD, end as aE, engineStats as aF, fail as aG, flatMap as aH, fork as aI, fromPromiseAbortable as aJ, getBenchmarkBudget as aK, getCurrentFiber as aL, globalScheduler as aM, inferCallerLaneFromStack as aN, laneTag as aO, linkAbortController as aP, makeBoundedRingBuffer as aQ, makeCancelToken as aR, map as aS, mapAsync as aT, mapError as aU, mapTryAsync as aV, none as aW, orElseOptional as aX, resetAbortablePromiseStats as aY, runtimeCapabilities as aZ, runtimeForCaller as a_, Runtime as aa, type RuntimeCapabilities as ab, type RuntimeEngineMode as ac, type RuntimeOptions as ad, type ScheduleResult as ae, Scheduler as af, type SchedulerEngine as ag, type SchedulerOptions as ah, type SchedulerStats as ai, type SchedulerStatsData as aj, type ScopeId as ak, type Some as al, type SyncRef as am, type Task as an, WasmFiberEngine as ao, type WasmFiberEngineOptions as ap, abortablePromiseStats as aq, acquireRelease as ar, asyncEffect as as, asyncCatchAll as at, asyncFail as au, asyncFlatMap as av, asyncFold as aw, asyncInterruptible as ax, asyncMap as ay, asyncMapError as az, type Fiber as b, selectedEngineStats as b0, setBenchmarkBudget as b1, some as b2, succeed as b3, sync as b4, toPromise as b5, toPromiseByCaller as b6, unit as b7, unsafeGetCurrentRuntime as b8, unsafeRunAsync as b9, unsafeRunFoldWithEnv as ba, withAsyncPromise as bb, withCurrentFiber as bc, withScope as bd, withScopeAsync as be, type FiberId as c, type FiberStatus as d, type RuntimeEvent as e, type WasmBridge as f, type OpcodeProgram as g, type FiberId$1 as h, type EngineEvent as i, type RefId as j, type OpcodeNode as k, type RingBufferOptions as l, type EngineStats as m, type AbortablePromiseFinish as n, type AbortablePromiseLabelStats as o, type AbortablePromiseOptions as p, type AbortablePromiseOutcome as q, type AbortablePromiseStats as r, type AsyncRegisterRef as s, type AsyncWithPromise as t, type RingLike as u, type Canceler as v, Cause as w, type CustomHostAction as x, type DecodeRef as y, DefaultHostExecutor as z };
1074
+ export { type FiberInfo as $, Async as A, type Baggage as B, type AsyncWithPromise as C, type RingLike as D, Exit as E, type FiberEngine as F, type CancelToken as G, type Canceler as H, Cause as I, type JSONValue as J, type ContextNode as K, type CustomHostAction as L, type DbHostAction as M, type NodeId as N, type Option as O, type DecodeRef as P, DefaultHostExecutor as Q, type RuntimeHooks as R, Scope as S, type TraceContext as T, type EngineKind as U, type EngineSelection as V, type WasmEngineRuntime as W, type EngineSelectionMode as X, type FiberContext as Y, type ZIO as Z, type FiberEngineKind as _, type RingBufferOptions as a, fail as a$, type FiberReadyQueue as a0, type FiberReadyQueueOptions as a1, type FiberReadyQueueStats as a2, type FiberRunState as a3, type FlatMapRef as a4, type FoldFailureRef as a5, type FoldSuccessRef as a6, type HostAction as a7, type HostActionKind as a8, type HostActionResult as a9, type SchedulerStatsData as aA, type ScopeId as aB, type ScopeInfo as aC, type Some as aD, type SyncRef as aE, type Task as aF, WasmFiberEngine as aG, type WasmFiberEngineOptions as aH, abortablePromiseStats as aI, acquireRelease as aJ, asyncEffect as aK, asyncCatchAll as aL, asyncFail as aM, asyncFlatMap as aN, asyncFold as aO, asyncInterruptible as aP, asyncMap as aQ, asyncMapError as aR, asyncSucceed as aS, asyncSync as aT, asyncTotal as aU, catchAll as aV, ctxExtend as aW, ctxToObject as aX, emptyContext as aY, end as aZ, engineStats as a_, type HostExecutionContext as aa, type HostExecutor as ab, HostRegistry as ac, type HostRegistryStats as ad, type HttpHostAction as ae, type Interrupted as af, type Joiner as ag, type LaneStatsData as ah, type None as ai, NoopHooks as aj, ProgramBuilder as ak, type ProgramPatch as al, PushStatus as am, type QueueHostAction as an, type ReadyQueueScheduleKind as ao, RingBuffer as ap, type RingBufferEngine as aq, type RingBufferStatsData as ar, type RuntimeCapabilities as as, type RuntimeEngineMode as at, type ScheduleResult as au, Scheduler as av, type SchedulerEngine as aw, type SchedulerLaneMode as ax, type SchedulerOptions as ay, type SchedulerStats as az, type RuntimeEvent as b, flatMap as b0, fork as b1, fromPromiseAbortable as b2, getBenchmarkBudget as b3, getCurrentFiber as b4, globalScheduler as b5, inferCallerLaneFromStack as b6, laneTag as b7, linkAbortController as b8, makeBoundedRingBuffer as b9, withCurrentFiber as bA, withScope as bB, withScopeAsync as bC, makeCancelToken as ba, makeFiberReadyQueue as bb, makeRuntimeEventRecord as bc, map as bd, mapAsync as be, mapError as bf, mapTryAsync as bg, none as bh, orElseOptional as bi, resetAbortablePromiseStats as bj, runtimeCapabilities as bk, runtimeEventRecordContext as bl, runtimeForCaller as bm, sanitizeLaneKey as bn, selectedEngineStats as bo, setBenchmarkBudget as bp, some as bq, succeed as br, sync as bs, toPromise as bt, toPromiseByCaller as bu, unit as bv, unsafeGetCurrentRuntime as bw, unsafeRunAsync as bx, unsafeRunFoldWithEnv as by, withAsyncPromise as bz, type RuntimeEmitContext as c, type RuntimeEventRecord as d, type RuntimeSpanLink as e, Runtime as f, RuntimeRegistry as g, type RuntimeOptions as h, RuntimeFiber as i, type FiberEngineStats as j, type Fiber as k, type FiberId as l, type FiberStatus as m, type WasmBridge as n, type OpcodeProgram as o, type FiberId$1 as p, type EngineEvent as q, type RefId as r, type OpcodeNode as s, type EngineStats as t, type AbortablePromiseFinish as u, type AbortablePromiseLabelStats as v, type AbortablePromiseOptions as w, type AbortablePromiseOutcome as x, type AbortablePromiseStats as y, type AsyncRegisterRef as z };
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkIJT6RRQ5cjs = require('./chunk-IJT6RRQ5.cjs');
4
+ require('./chunk-DJQ7OMMB.cjs');
5
+ require('./chunk-OBGZSXTJ.cjs');
6
+
7
+
8
+ exports.registerHttpEffect = _chunkIJT6RRQ5cjs.registerHttpEffect;
@@ -0,0 +1,8 @@
1
+ import {
2
+ registerHttpEffect
3
+ } from "./chunk-H55LI6WY.js";
4
+ import "./chunk-PNVFW245.js";
5
+ import "./chunk-3RG5ZIWI.js";
6
+ export {
7
+ registerHttpEffect
8
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ registerHttpEffect
3
+ } from "./chunk-K2T3DV26.mjs";
4
+ import "./chunk-NOYZIMUJ.mjs";
5
+ import "./chunk-Y6FXYEAI.mjs";
6
+ export {
7
+ registerHttpEffect
8
+ };