@m4trix/core 0.11.0 → 0.11.1

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
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';
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 };