@m4trix/core 0.11.0 → 0.12.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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,80 @@
1
1
  export { HttpStreamOptions, MessageStream, Pump, Source, StreamChunk, StreamTransformer, ensureFullWords, httpStreamResponse } from './stream/index.js';
2
- export { BaseMessage, Message, Role, SocketEventName, SocketIoFactory, TextMessage, VoiceMessage } from './api/index.js';
2
+ import { Socket } from 'socket.io';
3
3
  export { FormatType, MessageFilterType, TransformMessages } from './helper/index.js';
4
- export { Agent, AgentBinding, AgentFactory, AgentNetwork, AgentNetworkEvent, AgentNetworkEventDef, AnyAgent, AuthResult, Channel, ChannelDef, ChannelName, ConfiguredChannel, ContextEvents, EmitPayload, EnvelopeLike, 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, SkillDependency, SkillDependencyDef, SkillInstance, SkillRuntimeOptions, SpawnCallbackContext, SpawnFn, SpawnerBuilder, StreamFactory, UnboundEvent, consoleTracer, consoleTracerLayer, formatSSE, isHttpStreamSink, toSSEStream } from './matrix/index.js';
4
+ export { Agent, AgentBinding, AgentFactory, AgentNetwork, AgentNetworkEvent, AgentNetworkEventDef, AnyAgent, AuthResult, Channel, ChannelDef, ChannelName, ConfiguredChannel, ContextEvents, DepedencyLayer, DepedencyLayerDef, EmitPayload, EnvelopeLike, 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 } from './matrix/index.js';
5
5
  export { Schema as S } from 'effect';
6
- import 'socket.io';
7
6
  import '@langchain/core/messages';
8
7
  import 'effect/ParseResult';
8
+
9
+ type Role = 'system' | 'user' | 'assistant' | string;
10
+ interface BaseMessage {
11
+ /** Unique across the conversation */
12
+ id: string;
13
+ role: Role;
14
+ /** ISO string or Date; normalized when you receive it */
15
+ timestamp: string;
16
+ }
17
+ interface TextMessage extends BaseMessage {
18
+ kind: 'text';
19
+ /** two modes: plain vs. structured */
20
+ content: string | {
21
+ format: 'markdown' | 'html';
22
+ body: string;
23
+ };
24
+ }
25
+ interface VoiceMessage extends BaseMessage {
26
+ kind: 'voice';
27
+ /** raw bytes or reference */
28
+ data: ArrayBuffer | Blob;
29
+ format: 'mp3' | 'wav' | string;
30
+ durationMs: number;
31
+ /** optional transcript if you run speech-to-text */
32
+ transcript?: string;
33
+ }
34
+ type Message = TextMessage | VoiceMessage;
35
+
36
+ type SocketEventName = 'conversation:create' | 'voice:input_file' | 'voice:input_chunk' | 'voice:input_commit' | 'voice:output_delta' | 'voice:output_commit' | 'voice:output_file' | 'voice:output_transcript_delta' | 'voice:output_transcript_full';
37
+
38
+ type HookContext<T> = {
39
+ socket: T;
40
+ hooks: Hooks<T>;
41
+ };
42
+ type Hooks<SocketType> = {
43
+ onConversationCreated?: (conversationId: string, context: HookContext<SocketType>) => void;
44
+ onVoiceInputFile?: (file: Blob | Uint8Array, context: HookContext<SocketType>) => void;
45
+ onVoiceInputChunk?: (chunk: Uint8Array, context: HookContext<SocketType>) => void;
46
+ onVoiceInputCommit?: (context: HookContext<SocketType>) => void;
47
+ onVoiceOutputDelta?: (chunk: Uint8Array, context: HookContext<SocketType>) => void;
48
+ onVoiceOutputCommit?: (context: HookContext<SocketType>) => void;
49
+ onVoiceOutputFile?: (file: Blob | Uint8Array, context: HookContext<SocketType>) => void;
50
+ onVoiceOutputTranscriptDelta?: (transcriptChunk: string, context: HookContext<SocketType>) => void;
51
+ onVoiceOutputTranscriptFull?: (transcript: string, context: HookContext<SocketType>) => void;
52
+ };
53
+ type BaseSetupSocketHandlersParams<SocketType> = {
54
+ enableVoiceEvents: boolean;
55
+ enableChatEvents: boolean;
56
+ enableTranscriptEvents: boolean;
57
+ prefix?: string;
58
+ hooks?: Hooks<SocketType>;
59
+ };
60
+ /**
61
+ * Extra keys supplied by the caller are kept,
62
+ * but if they collide with a base key the base type wins.
63
+ */
64
+ type SetupSocketHandlersParams<SocketType, Extra = Record<string, never>> = Omit<Extra, keyof BaseSetupSocketHandlersParams<SocketType>> & BaseSetupSocketHandlersParams<SocketType>;
65
+
66
+ declare class SocketIoFactory {
67
+ private socket;
68
+ private prefix;
69
+ private hooks;
70
+ private constructor();
71
+ static setupSocketHandlers({ enableVoiceEvents, enableChatEvents, enableTranscriptEvents, prefix, socket, hooks, }: SetupSocketHandlersParams<Socket, {
72
+ socket: Socket;
73
+ }>): void;
74
+ private setupVoiceEvents;
75
+ private setupChatEvents;
76
+ private setupTranscriptEvents;
77
+ private prefixEvent;
78
+ }
79
+
80
+ export { BaseMessage, Message, Role, SocketEventName, SocketIoFactory, TextMessage, VoiceMessage };
package/dist/index.js CHANGED
@@ -1828,7 +1828,7 @@ var LayerName = Brand.refined(
1828
1828
  (s) => typeof s === "string" && CAMEL_CASE_REGEX.test(s),
1829
1829
  (s) => Brand.error(`Expected camelCase (e.g. myLayerFoo), got: ${s}`)
1830
1830
  );
1831
- var SkillDependency = {
1831
+ var DepedencyLayer = {
1832
1832
  of(config) {
1833
1833
  const name = LayerName(config.name);
1834
1834
  const decode = Schema.decodeUnknown(config.shape);
@@ -1897,7 +1897,7 @@ var Skill = class _Skill {
1897
1897
  doneSchema: schema
1898
1898
  });
1899
1899
  }
1900
- use(...layers) {
1900
+ dependsOn(...layers) {
1901
1901
  const normalized = toLayerArray(layers);
1902
1902
  const allLayers = [...this._layers, ...normalized];
1903
1903
  assertUniqueLayerNames(allLayers);
@@ -2184,6 +2184,6 @@ var consoleTracerLayer = Layer.setTracer(
2184
2184
  consoleTracer
2185
2185
  );
2186
2186
 
2187
- export { Agent, AgentFactory, AgentNetwork, AgentNetworkEvent, Channel, ChannelName, ConfiguredChannel, EventMetaSchema, ExposeAuthError, ExpressEndpoint, LayerName, NextEndpoint, Pump, Sink, Skill, SkillDependency, SocketIoFactory, TransformMessages, consoleTracer, consoleTracerLayer, ensureFullWords, formatSSE, httpStreamResponse, isHttpStreamSink, toSSEStream };
2187
+ export { Agent, AgentFactory, AgentNetwork, AgentNetworkEvent, Channel, ChannelName, ConfiguredChannel, DepedencyLayer, EventMetaSchema, ExposeAuthError, ExpressEndpoint, LayerName, NextEndpoint, Pump, Sink, Skill, SocketIoFactory, TransformMessages, consoleTracer, consoleTracerLayer, ensureFullWords, formatSSE, httpStreamResponse, isHttpStreamSink, toSSEStream };
2188
2188
  //# sourceMappingURL=out.js.map
2189
2189
  //# sourceMappingURL=index.js.map