@m4trix/core 0.15.1 → 0.15.2
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.
- package/dist/index.cjs +351 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +351 -349
- package/dist/index.js.map +1 -1
- package/dist/matrix/index.cjs +351 -349
- package/dist/matrix/index.cjs.map +1 -1
- package/dist/matrix/index.d.ts +100 -100
- package/dist/matrix/index.js +351 -349
- package/dist/matrix/index.js.map +1 -1
- package/package.json +1 -1
package/dist/matrix/index.d.ts
CHANGED
|
@@ -452,6 +452,106 @@ declare class EventAggregatorInstance<TTriggerEvent, TEmitEvent> {
|
|
|
452
452
|
}): Promise<void>;
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
/**
|
|
456
|
+
* A Tracer that logs spans to console when they end. No optional dependencies
|
|
457
|
+
* required. Use `consoleTracerLayer` when running your program to enable.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* import { Effect } from 'effect';
|
|
462
|
+
* import { AgentNetwork, consoleTracerLayer } from '@m4trix/core/matrix';
|
|
463
|
+
*
|
|
464
|
+
* const network = AgentNetwork.setup(({ ... }) => { ... });
|
|
465
|
+
* const program = network.run().pipe(
|
|
466
|
+
* Effect.provide(consoleTracerLayer),
|
|
467
|
+
* Effect.scoped
|
|
468
|
+
* );
|
|
469
|
+
* Effect.runPromise(program);
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
declare const consoleTracer: Tracer.Tracer;
|
|
473
|
+
/**
|
|
474
|
+
* Layer that provides the console tracer. Pipe your program with
|
|
475
|
+
* `Effect.provide(consoleTracerLayer)` before running to see spans in stdout.
|
|
476
|
+
*/
|
|
477
|
+
declare const consoleTracerLayer: Layer.Layer<never>;
|
|
478
|
+
|
|
479
|
+
/** Thrown when auth denies the request */
|
|
480
|
+
declare class ExposeAuthError extends Error {
|
|
481
|
+
readonly status: number;
|
|
482
|
+
constructor(message: string, status?: number);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** Format a single SSE message (event + data) */
|
|
486
|
+
declare function formatSSE(envelope: Envelope): string;
|
|
487
|
+
/** Create a ReadableStream that encodes envelopes as SSE */
|
|
488
|
+
declare function toSSEStream(source: AsyncIterable<Envelope>, signal?: AbortSignal | null): ReadableStream<Uint8Array>;
|
|
489
|
+
|
|
490
|
+
/** Next.js App Router GET/POST handler signature */
|
|
491
|
+
type NextGetHandler = (request: Request) => Promise<Response>;
|
|
492
|
+
/** Options for NextEndpoint.from() - required to define how request maps to contextId and runId */
|
|
493
|
+
type NextEndpointOptions = {
|
|
494
|
+
requestToContextId: (request: Request) => string;
|
|
495
|
+
requestToRunId: (request: Request) => string;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Adapter for Next.js App Router. Maps an ExposedAPI to a route handler
|
|
499
|
+
* that streams events as SSE. Use for both GET and POST; POST with JSON body
|
|
500
|
+
* is recommended for passing the start event payload.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* const api = agentNetwork.expose({ protocol: "sse", auth, select });
|
|
504
|
+
* const handler = NextEndpoint.from(api, {
|
|
505
|
+
* requestToContextId: (req) => req.headers.get('x-correlation-id') ?? crypto.randomUUID(),
|
|
506
|
+
* requestToRunId: () => crypto.randomUUID(),
|
|
507
|
+
* }).handler();
|
|
508
|
+
* export const GET = handler;
|
|
509
|
+
* export const POST = handler;
|
|
510
|
+
*/
|
|
511
|
+
declare const NextEndpoint: {
|
|
512
|
+
from(api: ExposedAPI, options: NextEndpointOptions): {
|
|
513
|
+
handler(): NextGetHandler;
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/** Minimal Express-like request (compatible with express.Request) */
|
|
518
|
+
type ExpressRequest = {
|
|
519
|
+
on(event: 'close', fn: () => void): void;
|
|
520
|
+
};
|
|
521
|
+
/** Options for ExpressEndpoint.from() - required to define how request maps to contextId and runId */
|
|
522
|
+
type ExpressEndpointOptions = {
|
|
523
|
+
requestToContextId: (req: ExpressRequest) => string;
|
|
524
|
+
requestToRunId: (req: ExpressRequest) => string;
|
|
525
|
+
};
|
|
526
|
+
/** Minimal Express-like response (compatible with express.Response) */
|
|
527
|
+
type ExpressResponse = {
|
|
528
|
+
setHeader(name: string, value: string | number): void;
|
|
529
|
+
flushHeaders?(): void;
|
|
530
|
+
write(chunk: Uint8Array): void;
|
|
531
|
+
flush?(): void;
|
|
532
|
+
end(): void;
|
|
533
|
+
status(code: number): ExpressResponse;
|
|
534
|
+
send(body: string): void;
|
|
535
|
+
};
|
|
536
|
+
/** Express route handler signature */
|
|
537
|
+
type ExpressHandler = (req: ExpressRequest, res: ExpressResponse) => void | Promise<void>;
|
|
538
|
+
/**
|
|
539
|
+
* Adapter for Express. Maps an ExposedAPI to an Express route handler
|
|
540
|
+
* that streams events as SSE.
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* const api = agentNetwork.expose({ protocol: "sse", auth, select });
|
|
544
|
+
* app.get("/events", ExpressEndpoint.from(api, {
|
|
545
|
+
* requestToContextId: (req) => req.headers?.['x-correlation-id'] ?? crypto.randomUUID(),
|
|
546
|
+
* requestToRunId: () => crypto.randomUUID(),
|
|
547
|
+
* }).handler());
|
|
548
|
+
*/
|
|
549
|
+
declare const ExpressEndpoint: {
|
|
550
|
+
from(api: ExposedAPI, options: ExpressEndpointOptions): {
|
|
551
|
+
handler(): ExpressHandler;
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
|
|
455
555
|
/**
|
|
456
556
|
* Branded type for layer/dependency names. Enforces camelCase at runtime via refinement.
|
|
457
557
|
* Used internally for parsing, validation, and uniqueness enforcement across layers.
|
|
@@ -543,104 +643,4 @@ declare class Skill<TInput = unknown, TChunk = unknown, TDone = unknown, TDeps e
|
|
|
543
643
|
define(fn: DefineFn<TInput, TChunk, TDone, LayersFromDeps<TDeps>>): SkillInstance<TInput, TChunk, TDone, LayersFromDeps<TDeps>>;
|
|
544
644
|
}
|
|
545
645
|
|
|
546
|
-
/** Thrown when auth denies the request */
|
|
547
|
-
declare class ExposeAuthError extends Error {
|
|
548
|
-
readonly status: number;
|
|
549
|
-
constructor(message: string, status?: number);
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/** Format a single SSE message (event + data) */
|
|
553
|
-
declare function formatSSE(envelope: Envelope): string;
|
|
554
|
-
/** Create a ReadableStream that encodes envelopes as SSE */
|
|
555
|
-
declare function toSSEStream(source: AsyncIterable<Envelope>, signal?: AbortSignal | null): ReadableStream<Uint8Array>;
|
|
556
|
-
|
|
557
|
-
/** Next.js App Router GET/POST handler signature */
|
|
558
|
-
type NextGetHandler = (request: Request) => Promise<Response>;
|
|
559
|
-
/** Options for NextEndpoint.from() - required to define how request maps to contextId and runId */
|
|
560
|
-
type NextEndpointOptions = {
|
|
561
|
-
requestToContextId: (request: Request) => string;
|
|
562
|
-
requestToRunId: (request: Request) => string;
|
|
563
|
-
};
|
|
564
|
-
/**
|
|
565
|
-
* Adapter for Next.js App Router. Maps an ExposedAPI to a route handler
|
|
566
|
-
* that streams events as SSE. Use for both GET and POST; POST with JSON body
|
|
567
|
-
* is recommended for passing the start event payload.
|
|
568
|
-
*
|
|
569
|
-
* @example
|
|
570
|
-
* const api = agentNetwork.expose({ protocol: "sse", auth, select });
|
|
571
|
-
* const handler = NextEndpoint.from(api, {
|
|
572
|
-
* requestToContextId: (req) => req.headers.get('x-correlation-id') ?? crypto.randomUUID(),
|
|
573
|
-
* requestToRunId: () => crypto.randomUUID(),
|
|
574
|
-
* }).handler();
|
|
575
|
-
* export const GET = handler;
|
|
576
|
-
* export const POST = handler;
|
|
577
|
-
*/
|
|
578
|
-
declare const NextEndpoint: {
|
|
579
|
-
from(api: ExposedAPI, options: NextEndpointOptions): {
|
|
580
|
-
handler(): NextGetHandler;
|
|
581
|
-
};
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
/** Minimal Express-like request (compatible with express.Request) */
|
|
585
|
-
type ExpressRequest = {
|
|
586
|
-
on(event: 'close', fn: () => void): void;
|
|
587
|
-
};
|
|
588
|
-
/** Options for ExpressEndpoint.from() - required to define how request maps to contextId and runId */
|
|
589
|
-
type ExpressEndpointOptions = {
|
|
590
|
-
requestToContextId: (req: ExpressRequest) => string;
|
|
591
|
-
requestToRunId: (req: ExpressRequest) => string;
|
|
592
|
-
};
|
|
593
|
-
/** Minimal Express-like response (compatible with express.Response) */
|
|
594
|
-
type ExpressResponse = {
|
|
595
|
-
setHeader(name: string, value: string | number): void;
|
|
596
|
-
flushHeaders?(): void;
|
|
597
|
-
write(chunk: Uint8Array): void;
|
|
598
|
-
flush?(): void;
|
|
599
|
-
end(): void;
|
|
600
|
-
status(code: number): ExpressResponse;
|
|
601
|
-
send(body: string): void;
|
|
602
|
-
};
|
|
603
|
-
/** Express route handler signature */
|
|
604
|
-
type ExpressHandler = (req: ExpressRequest, res: ExpressResponse) => void | Promise<void>;
|
|
605
|
-
/**
|
|
606
|
-
* Adapter for Express. Maps an ExposedAPI to an Express route handler
|
|
607
|
-
* that streams events as SSE.
|
|
608
|
-
*
|
|
609
|
-
* @example
|
|
610
|
-
* const api = agentNetwork.expose({ protocol: "sse", auth, select });
|
|
611
|
-
* app.get("/events", ExpressEndpoint.from(api, {
|
|
612
|
-
* requestToContextId: (req) => req.headers?.['x-correlation-id'] ?? crypto.randomUUID(),
|
|
613
|
-
* requestToRunId: () => crypto.randomUUID(),
|
|
614
|
-
* }).handler());
|
|
615
|
-
*/
|
|
616
|
-
declare const ExpressEndpoint: {
|
|
617
|
-
from(api: ExposedAPI, options: ExpressEndpointOptions): {
|
|
618
|
-
handler(): ExpressHandler;
|
|
619
|
-
};
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* A Tracer that logs spans to console when they end. No optional dependencies
|
|
624
|
-
* required. Use `consoleTracerLayer` when running your program to enable.
|
|
625
|
-
*
|
|
626
|
-
* @example
|
|
627
|
-
* ```ts
|
|
628
|
-
* import { Effect } from 'effect';
|
|
629
|
-
* import { AgentNetwork, consoleTracerLayer } from '@m4trix/core/matrix';
|
|
630
|
-
*
|
|
631
|
-
* const network = AgentNetwork.setup(({ ... }) => { ... });
|
|
632
|
-
* const program = network.run().pipe(
|
|
633
|
-
* Effect.provide(consoleTracerLayer),
|
|
634
|
-
* Effect.scoped
|
|
635
|
-
* );
|
|
636
|
-
* Effect.runPromise(program);
|
|
637
|
-
* ```
|
|
638
|
-
*/
|
|
639
|
-
declare const consoleTracer: Tracer.Tracer;
|
|
640
|
-
/**
|
|
641
|
-
* Layer that provides the console tracer. Pipe your program with
|
|
642
|
-
* `Effect.provide(consoleTracerLayer)` before running to see spans in stdout.
|
|
643
|
-
*/
|
|
644
|
-
declare const consoleTracerLayer: Layer.Layer<never>;
|
|
645
|
-
|
|
646
646
|
export { Agent, AgentBinding, AgentFactory, AgentNetwork, AgentNetworkEvent, AgentNetworkEventDef, AnyAgent, AuthResult, Channel, ChannelDef, ChannelName, ConfiguredChannel, ContextEvents, DepedencyLayer, DepedencyLayerDef, Done, EmitPayload$1 as EmitPayload, EnvelopeLike, EventAggregator, EventAggregatorInstance, EventEnvelope$1 as EventEnvelope, EventMeta, EventMetaSchema, EventPlane, ExposeAuthError, ExposeOptions, ExposeRequest, ExposeSelect, ExposedAPI, ExposedStream, ExpressEndpoint, ExpressEndpointOptions, ExpressHandler, ExpressRequest, ExpressResponse, LayerName, LayersFromDeps, NextEndpoint, NextEndpointOptions, NextGetHandler, OnRequestContext, RunEvents, SetupContext, Sink, SinkDef, Skill, SkillDefineContext, SkillInstance, SkillRuntimeOptions, SpawnCallbackContext, SpawnFn, SpawnerBuilder, StreamFactory, UnboundEvent, consoleTracer, consoleTracerLayer, formatSSE, isHttpStreamSink, toSSEStream };
|