@fenixforce/kernel 0.1.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 (213) hide show
  1. package/dist/agent/execution-result.d.ts +27 -0
  2. package/dist/agent-loop.d.ts +55 -0
  3. package/dist/api/dashboard.d.ts +260 -0
  4. package/dist/api/index.d.ts +9 -0
  5. package/dist/api/middleware.d.ts +46 -0
  6. package/dist/api/openai-compat.d.ts +163 -0
  7. package/dist/api/server.d.ts +44 -0
  8. package/dist/api/streaming.d.ts +15 -0
  9. package/dist/api/webhook-triggers.d.ts +139 -0
  10. package/dist/billing/cost-meter.d.ts +123 -0
  11. package/dist/billing/index.d.ts +2 -0
  12. package/dist/boot.d.ts +109 -0
  13. package/dist/channels/discord.d.ts +99 -0
  14. package/dist/channels/email.d.ts +88 -0
  15. package/dist/channels/http-api.d.ts +155 -0
  16. package/dist/channels/index.d.ts +20 -0
  17. package/dist/channels/mcp-channel.d.ts +75 -0
  18. package/dist/channels/mobile-hil.d.ts +88 -0
  19. package/dist/channels/openai-compat.d.ts +42 -0
  20. package/dist/channels/registry.d.ts +80 -0
  21. package/dist/channels/signal.d.ts +75 -0
  22. package/dist/channels/slack.d.ts +115 -0
  23. package/dist/channels/teams.d.ts +106 -0
  24. package/dist/channels/telegram.d.ts +164 -0
  25. package/dist/channels/types.d.ts +71 -0
  26. package/dist/channels/whatsapp.d.ts +83 -0
  27. package/dist/checkpoint.d.ts +77 -0
  28. package/dist/config/canary.d.ts +74 -0
  29. package/dist/config/constitution.d.ts +57 -0
  30. package/dist/config/defaults.d.ts +17 -0
  31. package/dist/config/index.d.ts +8 -0
  32. package/dist/config/loader.d.ts +11 -0
  33. package/dist/config/provider-config.d.ts +29 -0
  34. package/dist/config/schema.d.ts +118 -0
  35. package/dist/config/steering-rules.d.ts +28 -0
  36. package/dist/content/chunker.d.ts +42 -0
  37. package/dist/content/entity-extractor.d.ts +58 -0
  38. package/dist/content/index.d.ts +8 -0
  39. package/dist/content/ocr.d.ts +79 -0
  40. package/dist/content/pipeline.d.ts +153 -0
  41. package/dist/context-overflow.d.ts +19 -0
  42. package/dist/editions/mobile.d.ts +12 -0
  43. package/dist/editions/pro.d.ts +12 -0
  44. package/dist/editions/voices.d.ts +14 -0
  45. package/dist/events/block-manager.d.ts +37 -0
  46. package/dist/events/bus.d.ts +39 -0
  47. package/dist/events/index.d.ts +8 -0
  48. package/dist/events/session-manager.d.ts +59 -0
  49. package/dist/events/stream-adapter.d.ts +24 -0
  50. package/dist/events/types.d.ts +465 -0
  51. package/dist/events/websocket.d.ts +34 -0
  52. package/dist/extensions/defaults/05-session-repair.d.ts +6 -0
  53. package/dist/extensions/defaults/10-logging.d.ts +6 -0
  54. package/dist/extensions/defaults/15-loop-guard.d.ts +6 -0
  55. package/dist/extensions/defaults/20-cost-tracking.d.ts +7 -0
  56. package/dist/extensions/defaults/25-ssrf-protection.d.ts +6 -0
  57. package/dist/extensions/defaults/30-rate-limiting.d.ts +6 -0
  58. package/dist/extensions/defaults/35-shell-bleed.d.ts +6 -0
  59. package/dist/extensions/defaults/40-observation-capture.d.ts +7 -0
  60. package/dist/extensions/defaults/45-context-survival.d.ts +6 -0
  61. package/dist/extensions/defaults/50-context-budget.d.ts +6 -0
  62. package/dist/extensions/defaults/55-steering-rules.d.ts +7 -0
  63. package/dist/extensions/defaults/60-quality-gates.d.ts +7 -0
  64. package/dist/extensions/defaults/65-job-dispatch.d.ts +24 -0
  65. package/dist/extensions/defaults/70-skill-loader.d.ts +18 -0
  66. package/dist/extensions/hooks.d.ts +74 -0
  67. package/dist/extensions/index.d.ts +21 -0
  68. package/dist/extensions/intervention.d.ts +59 -0
  69. package/dist/extensions/manager.d.ts +63 -0
  70. package/dist/extensions/runner.d.ts +63 -0
  71. package/dist/hooks/hook-manager.d.ts +39 -0
  72. package/dist/hooks/hook-types.d.ts +60 -0
  73. package/dist/identity/assembler.d.ts +45 -0
  74. package/dist/identity/ccc-adapter.d.ts +33 -0
  75. package/dist/identity/index.d.ts +6 -0
  76. package/dist/identity/persona-parser.d.ts +24 -0
  77. package/dist/identity/soul-parser.d.ts +23 -0
  78. package/dist/identity/user-populator.d.ts +20 -0
  79. package/dist/index.d.ts +227 -0
  80. package/dist/index.js +579 -0
  81. package/dist/interrupt.d.ts +84 -0
  82. package/dist/job-queue.d.ts +69 -0
  83. package/dist/jobs/index.d.ts +12 -0
  84. package/dist/jobs/memory-queue.d.ts +23 -0
  85. package/dist/jobs/planned-tasks.d.ts +121 -0
  86. package/dist/jobs/queue.d.ts +79 -0
  87. package/dist/jobs/router.d.ts +23 -0
  88. package/dist/jobs/synthesize-memories.d.ts +26 -0
  89. package/dist/jobs/types.d.ts +47 -0
  90. package/dist/jobs/worker-pool.d.ts +25 -0
  91. package/dist/jobs/worker.d.ts +40 -0
  92. package/dist/loop/autonomous-controller.d.ts +91 -0
  93. package/dist/loop/backpressure.d.ts +64 -0
  94. package/dist/loop/fresh-context.d.ts +48 -0
  95. package/dist/loop/prd-importer.d.ts +134 -0
  96. package/dist/loop/stop-controller.d.ts +31 -0
  97. package/dist/loop-guard.d.ts +32 -0
  98. package/dist/mcp/tool-executor.d.ts +57 -0
  99. package/dist/memory/brain-artifacts.d.ts +25 -0
  100. package/dist/memory/dual-search.d.ts +67 -0
  101. package/dist/memory/episodic.d.ts +45 -0
  102. package/dist/memory/index.d.ts +27 -0
  103. package/dist/memory/knowledge-graph.d.ts +89 -0
  104. package/dist/memory/markdown-store.d.ts +64 -0
  105. package/dist/memory/metadata-filter.d.ts +29 -0
  106. package/dist/memory/mid-conversation-saves.d.ts +17 -0
  107. package/dist/memory/note-parser.d.ts +34 -0
  108. package/dist/memory/observation-store.d.ts +36 -0
  109. package/dist/memory/observation-thresholds.d.ts +26 -0
  110. package/dist/memory/progressive-search.d.ts +25 -0
  111. package/dist/memory/synthesis.d.ts +36 -0
  112. package/dist/memory/tree-index.d.ts +104 -0
  113. package/dist/memory/write-gate.d.ts +63 -0
  114. package/dist/mission-control.d.ts +34 -0
  115. package/dist/pre-classifier-widgets.d.ts +40 -0
  116. package/dist/pre-classifier.d.ts +19 -0
  117. package/dist/prompt/context-budget.d.ts +68 -0
  118. package/dist/prompt/index.d.ts +3 -0
  119. package/dist/prompt/system-prompt.d.ts +32 -0
  120. package/dist/prompt/templates.d.ts +11 -0
  121. package/dist/providers/anthropic.d.ts +24 -0
  122. package/dist/providers/auto-detect.d.ts +16 -0
  123. package/dist/providers/auto-discover.d.ts +28 -0
  124. package/dist/providers/bedrock.d.ts +38 -0
  125. package/dist/providers/cache-strategy.d.ts +58 -0
  126. package/dist/providers/circuit-breaker.d.ts +33 -0
  127. package/dist/providers/cost-meter.d.ts +74 -0
  128. package/dist/providers/cost-tracking.d.ts +36 -0
  129. package/dist/providers/google.d.ts +35 -0
  130. package/dist/providers/index.d.ts +32 -0
  131. package/dist/providers/interface.d.ts +98 -0
  132. package/dist/providers/json-repair.d.ts +10 -0
  133. package/dist/providers/key-rotation.d.ts +36 -0
  134. package/dist/providers/manager.d.ts +64 -0
  135. package/dist/providers/model-registry.d.ts +50 -0
  136. package/dist/providers/openai-compatible.d.ts +26 -0
  137. package/dist/providers/optimization-modes.d.ts +38 -0
  138. package/dist/providers/provider-manager.d.ts +71 -0
  139. package/dist/providers/runtime-crud.d.ts +68 -0
  140. package/dist/providers/sidecar-lifecycle.d.ts +40 -0
  141. package/dist/providers/stream-wrapper.d.ts +21 -0
  142. package/dist/providers/structured-verify.d.ts +31 -0
  143. package/dist/providers/versioning.d.ts +18 -0
  144. package/dist/quality-gates.d.ts +10 -0
  145. package/dist/scheduler/engine.d.ts +95 -0
  146. package/dist/scheduler/index.d.ts +4 -0
  147. package/dist/scheduler/webhook-handler.d.ts +37 -0
  148. package/dist/sdk/agent.d.ts +22 -0
  149. package/dist/sdk/cli.d.ts +2 -0
  150. package/dist/sdk/client.d.ts +19 -0
  151. package/dist/sdk/index.d.ts +24 -0
  152. package/dist/sdk/jobs.d.ts +25 -0
  153. package/dist/sdk/memory.d.ts +18 -0
  154. package/dist/sdk/types.d.ts +69 -0
  155. package/dist/security/approval-gates.d.ts +166 -0
  156. package/dist/security/content-wrapper.d.ts +38 -0
  157. package/dist/security/guard-rails.d.ts +6 -0
  158. package/dist/security/index.d.ts +21 -0
  159. package/dist/security/instruction-hierarchy.d.ts +109 -0
  160. package/dist/security/pii-tokenizer.d.ts +30 -0
  161. package/dist/security/reputation.d.ts +53 -0
  162. package/dist/security/secret-store.d.ts +41 -0
  163. package/dist/security/security-engine.d.ts +53 -0
  164. package/dist/security/shell-bleed.d.ts +15 -0
  165. package/dist/security/ssrf.d.ts +12 -0
  166. package/dist/security/taint-tracker.d.ts +63 -0
  167. package/dist/security/tool-access-control.d.ts +114 -0
  168. package/dist/session-compaction.d.ts +20 -0
  169. package/dist/session-orient.d.ts +22 -0
  170. package/dist/session-repair.d.ts +6 -0
  171. package/dist/storage/index.d.ts +24 -0
  172. package/dist/storage/interface.d.ts +245 -0
  173. package/dist/storage/postgres.d.ts +6 -0
  174. package/dist/storage/sqlite.d.ts +2 -0
  175. package/dist/streaming/reasoning.d.ts +67 -0
  176. package/dist/task-tracker.d.ts +26 -0
  177. package/dist/testing/action-cache.d.ts +39 -0
  178. package/dist/testing/incident-eval.d.ts +49 -0
  179. package/dist/testing/workflow-evals.d.ts +73 -0
  180. package/dist/tools/access-control.d.ts +60 -0
  181. package/dist/tools/browser-engine.d.ts +73 -0
  182. package/dist/tools/builtins/jobs-router.d.ts +7 -0
  183. package/dist/tools/builtins/tasks-router.d.ts +25 -0
  184. package/dist/tools/index.d.ts +20 -0
  185. package/dist/tools/map-reduce.d.ts +64 -0
  186. package/dist/tools/registry.d.ts +39 -0
  187. package/dist/tools/router.d.ts +30 -0
  188. package/dist/tools/routers/browser-router.d.ts +12 -0
  189. package/dist/tools/routers/code-router.d.ts +34 -0
  190. package/dist/tools/routers/file-router.d.ts +35 -0
  191. package/dist/tools/routers/memory-router.d.ts +21 -0
  192. package/dist/tools/routers/schedule-router.d.ts +31 -0
  193. package/dist/tools/routers/search-backends.d.ts +47 -0
  194. package/dist/tools/routers/task-router.d.ts +32 -0
  195. package/dist/tools/routers/web-router.d.ts +36 -0
  196. package/dist/tools/skill-discovery.d.ts +32 -0
  197. package/dist/tools/skill-loader.d.ts +76 -0
  198. package/dist/tools/skill-types.d.ts +21 -0
  199. package/dist/voice/audio-intelligence.d.ts +42 -0
  200. package/dist/voice/barge-in.d.ts +51 -0
  201. package/dist/voice/index.d.ts +22 -0
  202. package/dist/voice/marker-parser.d.ts +31 -0
  203. package/dist/voice/sidecar-manager.d.ts +68 -0
  204. package/dist/voice/speaker-focus.d.ts +41 -0
  205. package/dist/voice/speaker-voiceprint.d.ts +47 -0
  206. package/dist/voice/speech-intent.d.ts +51 -0
  207. package/dist/voice/speechmatics-stt.d.ts +77 -0
  208. package/dist/voice/speechmatics-tts.d.ts +39 -0
  209. package/dist/voice/stt-provider.d.ts +40 -0
  210. package/dist/voice/transcript.d.ts +19 -0
  211. package/dist/voice/turn-detection.d.ts +53 -0
  212. package/dist/wrapup.d.ts +15 -0
  213. package/package.json +39 -0
@@ -0,0 +1,32 @@
1
+ export interface Skill {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ edition: "all" | "pro";
6
+ triggers: string[];
7
+ version?: string;
8
+ author?: string;
9
+ body: string;
10
+ files: string[];
11
+ root: string;
12
+ }
13
+ export interface SkillValidationError {
14
+ path: string;
15
+ errors: string[];
16
+ }
17
+ export declare function discoverSkills(roots: string[]): Promise<{
18
+ skills: Skill[];
19
+ errors: SkillValidationError[];
20
+ }>;
21
+ export declare function extractFrontmatter(raw: string): {
22
+ frontmatter: Record<string, unknown>;
23
+ body: string;
24
+ };
25
+ export declare function formatSkillForAgent(skill: Skill): string;
26
+ /**
27
+ * Match skills by trigger substring against an inbound message.
28
+ * Returns skills whose triggers appear as substrings in the
29
+ * lowercased message, sorted by number of matching triggers.
30
+ */
31
+ export declare function matchSkillsByTrigger(skills: Skill[], message: string): Skill[];
32
+ export declare function searchSkills(skills: Skill[], query: string, limit?: number): string[];
@@ -0,0 +1,76 @@
1
+ import { type Skill } from "./skill-discovery.js";
2
+ import type { ToolRegistry, ToolDefinition } from "./registry.js";
3
+ export interface SkillLoaderConfig {
4
+ /** Root directory containing skills/{builtin,community,user}/ */
5
+ projectRoot: string;
6
+ /** Override search directories (default: builtin → community → user) */
7
+ searchDirs?: string[];
8
+ }
9
+ export interface SkillLoadResult {
10
+ loaded: string[];
11
+ failed: Array<{
12
+ name: string;
13
+ error: string;
14
+ }>;
15
+ skipped: string[];
16
+ }
17
+ /** Lightweight metadata registered at startup (no body, no tools). */
18
+ export interface SkillStub {
19
+ id: string;
20
+ name: string;
21
+ description: string;
22
+ edition: "all" | "pro";
23
+ triggers: string[];
24
+ root: string;
25
+ }
26
+ /**
27
+ * Lazy skill registry. At startup only metadata stubs are loaded.
28
+ * Full skill content (body, file list) and index.ts tools are
29
+ * loaded on first access via `resolve()`.
30
+ */
31
+ export declare class LazySkillRegistry {
32
+ private stubs;
33
+ private resolved;
34
+ private tools;
35
+ /** Register a lightweight stub (startup). */
36
+ registerStub(stub: SkillStub): void;
37
+ /** List all registered skill names and descriptions (cheap). */
38
+ listStubs(): SkillStub[];
39
+ /** Check if a skill name is registered. */
40
+ has(name: string): boolean;
41
+ /** Number of registered skills (stubs + resolved). */
42
+ get size(): number;
43
+ /**
44
+ * Resolve a skill on first trigger: read full SKILL.md body,
45
+ * import index.ts tools. Caches for subsequent calls.
46
+ */
47
+ resolve(name: string): Promise<{
48
+ skill: Skill;
49
+ tools: ToolDefinition[];
50
+ } | null>;
51
+ /** Get the formatted agent prompt for a resolved skill. */
52
+ format(name: string): string | null;
53
+ /** Check whether a skill has been fully resolved. */
54
+ isResolved(name: string): boolean;
55
+ }
56
+ /**
57
+ * Discover skills lazily: parse only frontmatter metadata at startup.
58
+ * Returns a LazySkillRegistry that resolves full content on demand.
59
+ */
60
+ export declare function loadSkillsLazy(config: SkillLoaderConfig): Promise<{
61
+ registry: LazySkillRegistry;
62
+ errors: Array<{
63
+ name: string;
64
+ error: string;
65
+ }>;
66
+ }>;
67
+ /**
68
+ * Discover skills from SKILL.md files and register their tools.
69
+ *
70
+ * Search order: skills/builtin/ → skills/community/ → skills/user/.
71
+ * Later roots override earlier ones by name (user overrides community).
72
+ *
73
+ * For each discovered skill directory, attempts to import index.ts
74
+ * and extract tool definitions from the `tools` or default export.
75
+ */
76
+ export declare function loadSkills(registry: ToolRegistry, config: SkillLoaderConfig): Promise<SkillLoadResult>;
@@ -0,0 +1,21 @@
1
+ export interface SkillDefinition {
2
+ id: string;
3
+ name: string;
4
+ edition: "all" | "pro";
5
+ category: SkillCategory;
6
+ description: string;
7
+ triggers: string[];
8
+ manifest: string;
9
+ dependencies?: string[];
10
+ mcpServers?: McpServerRef[];
11
+ }
12
+ export interface McpServerRef {
13
+ name: string;
14
+ url: string;
15
+ auth: "none" | {
16
+ type: "header";
17
+ key: string;
18
+ envVar: string;
19
+ };
20
+ }
21
+ export type SkillCategory = "build" | "deploy" | "documents" | "content" | "design" | "code-quality" | "workflow" | "integrations" | "data" | "security" | "offsec" | "research" | "decision" | "communication" | "support" | "governance" | "agentic" | "finance" | "voice" | "rag" | "teams" | "discipline" | "domain";
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Audio Intelligence — post-transcription analysis features.
3
+ *
4
+ * Available from providers that support them (e.g., Speechmatics batch mode).
5
+ *
6
+ * Features:
7
+ * Sentiment Analysis — per-utterance sentiment scoring
8
+ * Topic Detection — identify topics discussed in conversation
9
+ * Summarization — generate summary of conversation
10
+ * Channel Diarization — separate speakers by audio channel (stereo)
11
+ *
12
+ * Fenix applications:
13
+ * Call center analytics (customer-support skill)
14
+ * Student engagement tracking (Ejiogbe Voices)
15
+ * Lesson summaries and topic tracking
16
+ */
17
+ export interface AudioIntelligenceConfig {
18
+ sentimentAnalysis?: boolean;
19
+ topicDetection?: boolean;
20
+ summarization?: boolean;
21
+ channelDiarization?: {
22
+ enabled: boolean;
23
+ /** Channel labels (e.g., ["Teacher", "Student"] or ["Agent", "Customer"]) */
24
+ channelLabels?: string[];
25
+ };
26
+ }
27
+ export interface SentimentResult {
28
+ speakerId: string;
29
+ text: string;
30
+ sentiment: "positive" | "negative" | "neutral";
31
+ confidence: number;
32
+ }
33
+ export interface TopicResult {
34
+ topic: string;
35
+ confidence: number;
36
+ segments: string[];
37
+ }
38
+ export interface AudioIntelligenceResult {
39
+ sentiment?: SentimentResult[];
40
+ topics?: TopicResult[];
41
+ summary?: string;
42
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Barge-In Handler — manages user interruptions during agent speech.
3
+ *
4
+ * When the user starts speaking while the agent is generating or
5
+ * playing audio, the barge-in handler:
6
+ * 1. Stops current TTS playback
7
+ * 2. Aborts pending LLM generation
8
+ * 3. Checkpoints conversation state (what was said before interruption)
9
+ * 4. Resumes listening for new user input
10
+ *
11
+ * Validated against Pipecat pipeline architecture:
12
+ * Mic → VAD → STT → UserAggregator → LLM → TTS → Speakers → AssistantAggregator
13
+ *
14
+ * Pipeline patterns supported:
15
+ * - Pipecat: composable processors, interruption built in
16
+ * - LiveKit: WebRTC transport, Speechmatics STT + ElevenLabs TTS
17
+ * - Twilio SIP: phone → SIP trunk → room → STT → LLM → TTS → phone
18
+ */
19
+ import type { SpeechIntent } from "./speech-intent.js";
20
+ export interface BargeInState {
21
+ /** What the agent had said before being interrupted */
22
+ spokenText: string;
23
+ /** What the agent was about to say (remaining queued text) */
24
+ pendingText: string;
25
+ /** Turn number when interruption occurred */
26
+ turnNumber: number;
27
+ /** Timestamp of the interruption */
28
+ interruptedAt: number;
29
+ }
30
+ export interface BargeInHandler {
31
+ /** Handle user barge-in: stop TTS, abort LLM, checkpoint state */
32
+ onBargeIn(): Promise<BargeInState>;
33
+ }
34
+ export interface BargeInDeps {
35
+ /** Stop current TTS playback, return text spoken so far */
36
+ stopTTS(): Promise<{
37
+ spokenText: string;
38
+ }>;
39
+ /** Abort pending LLM generation, return buffered unsent text */
40
+ abortLLM(): Promise<{
41
+ pendingText: string;
42
+ }>;
43
+ /** Get current turn number */
44
+ getCurrentTurn(): number;
45
+ /** Get the speech queue for flushing */
46
+ getSpeechQueue(): {
47
+ flush(): void;
48
+ current(): SpeechIntent | null;
49
+ };
50
+ }
51
+ export declare function createBargeInHandler(deps: BargeInDeps): BargeInHandler;
@@ -0,0 +1,22 @@
1
+ export { SidecarManager } from "./sidecar-manager.js";
2
+ export type { SidecarConfig, SidecarState, StartFn, HealthCheckFn, } from "./sidecar-manager.js";
3
+ export { SpeechQueue } from "./speech-intent.js";
4
+ export type { SpeechIntent, SpeechEventType, SpeechEventHandler, } from "./speech-intent.js";
5
+ export { parseMarkers, stripMarkers, DEFAULT_VOCABULARY, } from "./marker-parser.js";
6
+ export type { MarkerSegment, MarkerVocabulary, } from "./marker-parser.js";
7
+ export type { TranscriptChunk } from "./transcript.js";
8
+ export { applySpeakerFocus, formatSpeakerTranscript, DEFAULT_SPEAKER_FORMAT, } from "./speaker-focus.js";
9
+ export type { SpeakerFocusConfig, SpeakerActiveFormat, } from "./speaker-focus.js";
10
+ export { loadSpeakerVoiceprints, saveSpeakerVoiceprints, serializeVoiceprint, deserializeVoiceprint, } from "./speaker-voiceprint.js";
11
+ export type { SpeakerVoiceprint, SerializedVoiceprint, } from "./speaker-voiceprint.js";
12
+ export { resolveTurnDetection, listTurnDetectionPresets, EDITION_TURN_DEFAULTS, } from "./turn-detection.js";
13
+ export type { TurnDetectionConfig, TurnDetectionPreset, TurnDetectionMode, VoiceSessionControl, } from "./turn-detection.js";
14
+ export { PROVIDER_CAPABILITIES, checkProviderCapability, } from "./stt-provider.js";
15
+ export type { CustomVocabularyEntry, STTProviderCapabilities, } from "./stt-provider.js";
16
+ export type { AudioIntelligenceConfig, AudioIntelligenceResult, SentimentResult, TopicResult, } from "./audio-intelligence.js";
17
+ export { createBargeInHandler } from "./barge-in.js";
18
+ export type { BargeInHandler, BargeInState, BargeInDeps, } from "./barge-in.js";
19
+ export { SpeechmaticsSTT } from "./speechmatics-stt.js";
20
+ export type { SpeechmaticsSTTConfig, SpeechmaticsRealtimeSession, SpeechmaticsBatchResult, } from "./speechmatics-stt.js";
21
+ export { SpeechmaticsTTS } from "./speechmatics-tts.js";
22
+ export type { SpeechmaticsTTSConfig, TTSSynthesisResult, TTSStreamChunk, } from "./speechmatics-tts.js";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * LLM Marker Parser — extract inline emotion/expression markers from LLM output.
3
+ *
4
+ * Input: "[happy]Hello there![/happy] [thoughtful]Let me think...[/thoughtful]"
5
+ * Output: structured MarkerSegment[] with emotion metadata + clean text.
6
+ *
7
+ * Handles nested markers, unclosed markers (treat as plain text),
8
+ * and unknown marker types (pass through as metadata).
9
+ */
10
+ export interface MarkerSegment {
11
+ text: string;
12
+ emotion?: string;
13
+ intensity?: number;
14
+ speed?: number;
15
+ }
16
+ export interface MarkerVocabulary {
17
+ [emotion: string]: {
18
+ intensity?: number;
19
+ speed?: number;
20
+ };
21
+ }
22
+ export declare const DEFAULT_VOCABULARY: MarkerVocabulary;
23
+ /**
24
+ * Parse inline markers into structured segments.
25
+ * Matched markers become annotated segments; unmatched text becomes plain segments.
26
+ */
27
+ export declare function parseMarkers(rawText: string, vocabulary?: MarkerVocabulary): MarkerSegment[];
28
+ /**
29
+ * Strip all markers from text, returning clean output for text channels.
30
+ */
31
+ export declare function stripMarkers(rawText: string): string;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * SidecarManager — voice-only sidecar lifecycle management.
3
+ *
4
+ * Manages voice providers (Parakeet STT, Qwen3-TTS, MOSS-TTS):
5
+ * - cooldownUntilMs per sidecar
6
+ * - inFailureCooldown(), markFailure(), clearFailure()
7
+ * - Exponential backoff: 5s → 15s → 45s → 135s (base 5s, multiplier 3x)
8
+ * - Health check loop (configurable interval)
9
+ * - Restart on crash, fallback to cloud API after max retries
10
+ * - Yields voice:sidecar:started, voice:sidecar:crashed, sidecar:cooldown events
11
+ */
12
+ import type { AgentEvent } from "../events/types.js";
13
+ export interface SidecarConfig {
14
+ /** Unique sidecar ID (e.g. "parakeet-stt", "qwen3-tts") */
15
+ id: string;
16
+ /** Shell command or endpoint to start/reach the sidecar */
17
+ command: string;
18
+ /** HTTP health check endpoint */
19
+ healthEndpoint: string;
20
+ /** Max restart attempts before entering cooldown. Default: 3 */
21
+ maxRestartAttempts?: number;
22
+ /** Base cooldown duration in ms. Default: 5_000 (5s) */
23
+ baseCooldownMs?: number;
24
+ /** Backoff multiplier. Default: 3 (5s→15s→45s→135s) */
25
+ backoffMultiplier?: number;
26
+ /** Maximum cooldown in ms. Default: 300_000 (5 min) */
27
+ maxCooldownMs?: number;
28
+ /** Health check poll interval in ms. Default: 30_000 (30s) */
29
+ healthCheckIntervalMs?: number;
30
+ /** Cloud API fallback provider ID during cooldown */
31
+ fallbackProvider?: string;
32
+ }
33
+ export type SidecarState = "stopped" | "starting" | "running" | "restarting" | "cooldown";
34
+ export type StartFn = (command: string) => Promise<boolean>;
35
+ export type HealthCheckFn = (endpoint: string) => Promise<boolean>;
36
+ export declare class SidecarManager {
37
+ private sidecars;
38
+ private startFn;
39
+ private healthCheckFn;
40
+ private pendingEvents;
41
+ constructor(startFn: StartFn, healthCheckFn: HealthCheckFn);
42
+ /** Register a voice sidecar. */
43
+ add(config: SidecarConfig): void;
44
+ /** Start a sidecar and its health check loop. */
45
+ start(sidecarId: string, sessionId?: string): AsyncGenerator<AgentEvent, boolean>;
46
+ /** Check if a sidecar is in failure cooldown. */
47
+ inFailureCooldown(sidecarId: string): boolean;
48
+ /** Get the cooldown expiry timestamp (0 if not in cooldown). */
49
+ cooldownUntil(sidecarId: string): number;
50
+ /** Manually mark a sidecar as failed. */
51
+ markFailure(sidecarId: string, sessionId?: string): AsyncGenerator<AgentEvent, void>;
52
+ /** Clear failure state and restart. */
53
+ clearFailure(sidecarId: string, sessionId?: string): AsyncGenerator<AgentEvent, boolean>;
54
+ /** Get the active fallback provider for a sidecar in cooldown. */
55
+ activeFallback(sidecarId: string): string | null;
56
+ /** Get current state of a sidecar. */
57
+ getState(sidecarId: string): SidecarState | null;
58
+ /** Stop a sidecar and clean up timers. */
59
+ stop(sidecarId: string): void;
60
+ /** Stop all sidecars. */
61
+ stopAll(): void;
62
+ /** Drain any pending events (for non-generator callers). */
63
+ drainEvents(): AgentEvent[];
64
+ private handleFailure;
65
+ private enterCooldown;
66
+ private probeAfterCooldown;
67
+ private startHealthLoop;
68
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Speaker Focus System — controls how the agent handles multi-speaker audio.
3
+ *
4
+ * Two modes:
5
+ * IGNORE — Non-focused speakers completely filtered from output.
6
+ * The agent never sees their speech.
7
+ * RETAIN — Non-focused speakers appear in transcript marked as "passive"
8
+ * but don't drive conversation (no turn detection, no agent response).
9
+ *
10
+ * Use cases:
11
+ * IGNORE: Agent ignoring its own TTS playback, classroom focus on one student,
12
+ * call center where only the customer drives the agent.
13
+ * RETAIN: Meeting transcription prioritizing one speaker but recording all,
14
+ * language lesson focusing on student but observing group.
15
+ */
16
+ import type { TranscriptChunk } from "./transcript.js";
17
+ export interface SpeakerFocusConfig {
18
+ /** Speaker labels to focus on (e.g., ["S1", "Monroe"]) */
19
+ focusSpeakers: string[];
20
+ /** How to handle non-focused speakers */
21
+ focusMode: "ignore" | "retain";
22
+ }
23
+ export interface SpeakerActiveFormat {
24
+ /** Template for focused speakers. e.g., "<{speaker_id}>{text}</{speaker_id}>" */
25
+ active: string;
26
+ /** Template for non-focused speakers. e.g., "<PASSIVE><{speaker_id}>{text}</{speaker_id}></PASSIVE>" */
27
+ passive: string;
28
+ }
29
+ export declare const DEFAULT_SPEAKER_FORMAT: SpeakerActiveFormat;
30
+ /**
31
+ * Filter a transcript chunk based on speaker focus configuration.
32
+ *
33
+ * Returns null if the chunk should be dropped (ignore mode, non-focused speaker).
34
+ * Returns the chunk (possibly with isActiveSpeaker set) otherwise.
35
+ */
36
+ export declare function applySpeakerFocus(chunk: TranscriptChunk, config: SpeakerFocusConfig | undefined): TranscriptChunk | null;
37
+ /**
38
+ * Format a transcript chunk with speaker attribution tags.
39
+ * Injects speaker identity into the text before it reaches the agent loop.
40
+ */
41
+ export declare function formatSpeakerTranscript(chunk: TranscriptChunk, format?: SpeakerActiveFormat): string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Speaker Voiceprint Persistence — recognize speakers across sessions.
3
+ *
4
+ * After a voice session, the STT provider extracts acoustic fingerprints
5
+ * for each detected speaker. On session start, known voiceprints are
6
+ * loaded and passed to the STT provider as knownSpeakers.
7
+ *
8
+ * Storage: workspace/speakers/{label}.json
9
+ *
10
+ * Ejiogbe Voices applications:
11
+ * - Recognizing returning students without re-enrollment
12
+ * - Tracking individual student progress
13
+ * - Personalizing pronunciation feedback per student voice
14
+ * - Teacher vs student voice separation in classroom recordings
15
+ */
16
+ export interface SpeakerVoiceprint {
17
+ /** Human-readable name (e.g., "Monroe") */
18
+ label: string;
19
+ /** Opaque acoustic fingerprints from STT provider */
20
+ speakerIdentifiers: string[];
21
+ /** Which STT provider generated these voiceprints */
22
+ providerId: string;
23
+ /** When this voiceprint was first created */
24
+ createdAt: Date;
25
+ /** When this speaker was last detected */
26
+ lastSeenAt: Date;
27
+ }
28
+ export interface SerializedVoiceprint {
29
+ label: string;
30
+ speakerIdentifiers: string[];
31
+ providerId: string;
32
+ createdAt: string;
33
+ lastSeenAt: string;
34
+ }
35
+ export declare function serializeVoiceprint(vp: SpeakerVoiceprint): SerializedVoiceprint;
36
+ export declare function deserializeVoiceprint(raw: SerializedVoiceprint): SpeakerVoiceprint;
37
+ /**
38
+ * Load all speaker voiceprints for a workspace.
39
+ * Reads from workspace/speakers/*.json
40
+ */
41
+ export declare function loadSpeakerVoiceprints(workspaceDir: string): Promise<SpeakerVoiceprint[]>;
42
+ /**
43
+ * Save speaker voiceprints for a workspace.
44
+ * Merges with existing voiceprints — updates lastSeenAt for known speakers,
45
+ * adds new speakers.
46
+ */
47
+ export declare function saveSpeakerVoiceprints(workspaceDir: string, newPrints: SpeakerVoiceprint[]): Promise<void>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Intent-Based Speech Queue — priority-aware speech output management.
3
+ *
4
+ * When multiple modules generate speech simultaneously (agent response,
5
+ * notification, reminder, alarm), the intent system manages what plays,
6
+ * what queues, and what gets interrupted.
7
+ *
8
+ * Interrupt modes:
9
+ * force — stop current speech immediately, play new intent
10
+ * soft — wait for current sentence boundary, then switch
11
+ * queue — append to end of queue
12
+ */
13
+ export interface SpeechIntent {
14
+ id: string;
15
+ source: string;
16
+ priority: number;
17
+ interruptMode: "force" | "soft" | "queue";
18
+ text: string;
19
+ voiceId?: string;
20
+ metadata?: {
21
+ emotion?: string;
22
+ speed?: number;
23
+ };
24
+ }
25
+ export type SpeechEventType = "speech:started" | "speech:interrupted" | "speech:completed" | "speech:queued";
26
+ export type SpeechEventHandler = (type: SpeechEventType, intent: SpeechIntent) => void;
27
+ export declare class SpeechQueue {
28
+ private queue;
29
+ private playing;
30
+ private listener?;
31
+ /** Subscribe to speech lifecycle events. */
32
+ onEvent(handler: SpeechEventHandler): void;
33
+ /** Enqueue a speech intent with priority-aware insertion. */
34
+ enqueue(intent: SpeechIntent): void;
35
+ /** Force-interrupt: stop current speech and play this intent immediately. */
36
+ private forceInterrupt;
37
+ /** Interrupt a specific intent by ID (remove from queue or stop if playing). */
38
+ interrupt(intentId: string): boolean;
39
+ /** Mark current speech as completed and advance to next in queue. */
40
+ completeCurrent(): void;
41
+ /** Get the currently playing intent. */
42
+ current(): SpeechIntent | null;
43
+ /** Get all pending intents in priority order. */
44
+ pending(): SpeechIntent[];
45
+ /** Total items (playing + queued). */
46
+ get size(): number;
47
+ /** Clear all queued intents (does not stop current). */
48
+ flush(): void;
49
+ private advance;
50
+ private emit;
51
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Speechmatics STT Provider — real-time and batch speech-to-text.
3
+ *
4
+ * Uses speechmatics-rt for real-time WebSocket streaming (live voice)
5
+ * and speechmatics-batch for async file transcription (content pipeline).
6
+ *
7
+ * Features: 50+ languages, speaker diarization, speaker identification,
8
+ * speaker focus, custom vocabulary with sounds-like, sentiment analysis,
9
+ * topic detection, summarization.
10
+ */
11
+ import type { CustomVocabularyEntry, STTProviderCapabilities } from "./stt-provider.js";
12
+ import type { SpeakerFocusConfig } from "./speaker-focus.js";
13
+ import type { SpeakerVoiceprint } from "./speaker-voiceprint.js";
14
+ import type { TurnDetectionConfig } from "./turn-detection.js";
15
+ import type { AudioIntelligenceConfig, AudioIntelligenceResult } from "./audio-intelligence.js";
16
+ import type { TranscriptChunk } from "./transcript.js";
17
+ export interface SpeechmaticsSTTConfig {
18
+ apiKey: string;
19
+ /** "cloud" (default) | "on-prem" | "air-gapped" */
20
+ deployment?: "cloud" | "on-prem" | "air-gapped";
21
+ /** On-prem/air-gapped endpoint URL */
22
+ endpoint?: string;
23
+ /** Language code (e.g., "en", "yo", "ig"). Default: "en" */
24
+ language?: string;
25
+ /** Enable speaker diarization */
26
+ diarization?: boolean;
27
+ /** Speaker focus configuration */
28
+ speakerFocus?: SpeakerFocusConfig;
29
+ /** Known speaker voiceprints for recognition */
30
+ knownSpeakers?: SpeakerVoiceprint[];
31
+ /** Custom vocabulary with sounds-like mappings */
32
+ customVocabulary?: CustomVocabularyEntry[];
33
+ /** Turn detection settings */
34
+ turnDetection?: TurnDetectionConfig;
35
+ /** Audio intelligence (batch mode only) */
36
+ audioIntelligence?: AudioIntelligenceConfig;
37
+ }
38
+ export interface SpeechmaticsRealtimeSession {
39
+ /** Send audio chunk to the WebSocket stream */
40
+ sendAudio(chunk: Uint8Array): void;
41
+ /** Force end of utterance (external turn control) */
42
+ forceEndOfUtterance(): Promise<void>;
43
+ /** Subscribe to transcript chunks */
44
+ onTranscript(handler: (chunk: TranscriptChunk) => void): void;
45
+ /** Close the session and extract speaker voiceprints */
46
+ close(): Promise<{
47
+ voiceprints: SpeakerVoiceprint[];
48
+ }>;
49
+ }
50
+ export interface SpeechmaticsBatchResult {
51
+ transcript: string;
52
+ confidence: number;
53
+ durationMs: number;
54
+ speakers?: Array<{
55
+ id: string;
56
+ segments: Array<{
57
+ start: number;
58
+ end: number;
59
+ text: string;
60
+ }>;
61
+ }>;
62
+ intelligence?: AudioIntelligenceResult;
63
+ }
64
+ export declare class SpeechmaticsSTT {
65
+ readonly id: "speechmatics";
66
+ private config;
67
+ constructor(config: SpeechmaticsSTTConfig);
68
+ capabilities(): STTProviderCapabilities;
69
+ /** Transcribe a file (batch mode). Supports audio intelligence features. */
70
+ transcribeBatch(audioUrl: string, overrides?: Partial<SpeechmaticsSTTConfig>): Promise<SpeechmaticsBatchResult>;
71
+ /** Start a real-time streaming session via WebSocket. */
72
+ startRealtimeSession(overrides?: Partial<SpeechmaticsSTTConfig>): Promise<SpeechmaticsRealtimeSession>;
73
+ private resolveEndpoint;
74
+ private resolveWsEndpoint;
75
+ private pollBatchJob;
76
+ private parseBatchResult;
77
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Speechmatics TTS Provider — text-to-speech synthesis.
3
+ *
4
+ * Supports streaming and batch modes, multiple voices.
5
+ * Uses the speechmatics-tts SDK under the hood.
6
+ */
7
+ export interface SpeechmaticsTTSConfig {
8
+ apiKey: string;
9
+ /** Deployment mode. Default: "cloud" */
10
+ deployment?: "cloud" | "on-prem" | "air-gapped";
11
+ /** On-prem/air-gapped endpoint URL */
12
+ endpoint?: string;
13
+ /** Voice ID to use */
14
+ voiceId?: string;
15
+ /** Output audio format. Default: "mp3" */
16
+ format?: "mp3" | "wav" | "pcm";
17
+ /** Speaking rate multiplier. Default: 1.0 */
18
+ speed?: number;
19
+ }
20
+ export interface TTSSynthesisResult {
21
+ audioData: Uint8Array;
22
+ durationMs: number;
23
+ format: string;
24
+ }
25
+ export interface TTSStreamChunk {
26
+ audioData: Uint8Array;
27
+ index: number;
28
+ isFinal: boolean;
29
+ }
30
+ export declare class SpeechmaticsTTS {
31
+ readonly id: "speechmatics-tts";
32
+ private config;
33
+ constructor(config: SpeechmaticsTTSConfig);
34
+ /** Synthesize text to audio (batch). */
35
+ synthesize(text: string, overrides?: Partial<SpeechmaticsTTSConfig>): Promise<TTSSynthesisResult>;
36
+ /** Stream TTS synthesis chunk by chunk. */
37
+ stream(text: string, overrides?: Partial<SpeechmaticsTTSConfig>): AsyncGenerator<TTSStreamChunk>;
38
+ private resolveEndpoint;
39
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * STT Provider Contract — shared interface for all speech-to-text providers.
3
+ *
4
+ * Defines capability flags, custom vocabulary, and the provider capabilities
5
+ * matrix. Not all providers support all features.
6
+ */
7
+ export interface CustomVocabularyEntry {
8
+ /** Correct transcription (e.g., "Ekaabo") */
9
+ content: string;
10
+ /** Phonetic alternatives the STT might hear (e.g., ["eh kah bo", "eka abo"]) */
11
+ soundsLike?: string[];
12
+ }
13
+ export interface STTProviderCapabilities {
14
+ supportsCustomVocabulary: boolean;
15
+ supportsDiarization: boolean;
16
+ supportsSpeakerFocus: boolean;
17
+ supportsSpeakerIdentification: boolean;
18
+ supportsSentimentAnalysis: boolean;
19
+ supportsTopicDetection: boolean;
20
+ supportsSummarization: boolean;
21
+ }
22
+ /**
23
+ * Known capabilities for each STT provider.
24
+ *
25
+ * Provider STT TTS Diarize SpeakerID Focus Vocab Sentiment Topics Summary OnPrem
26
+ * Speechmatics Y Y Y Y Y Y Y Y Y Y
27
+ * Parakeet Y N N N N N N N N Y
28
+ * Groq Whisper Y N N N N N N N N N
29
+ * Deepgram Y Y Y N N Y N N N N
30
+ * Google Y Y Y N N Y N N N N
31
+ * ElevenLabs N Y N N N N N N N N
32
+ * Qwen3-TTS N Y N N N N N N N Y
33
+ * MOSS-TTS N Y N N N N N N N Y
34
+ */
35
+ export declare const PROVIDER_CAPABILITIES: Record<string, STTProviderCapabilities>;
36
+ /**
37
+ * Check if a provider supports a specific capability.
38
+ * Logs a warning if the capability is configured but not supported.
39
+ */
40
+ export declare function checkProviderCapability(providerId: string, capability: keyof STTProviderCapabilities): boolean;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * TranscriptChunk — the unit of speech-to-text output flowing
3
+ * through the realtime voice pipeline.
4
+ *
5
+ * Extended with speaker attribution for diarization and
6
+ * speaker focus systems.
7
+ */
8
+ export interface TranscriptChunk {
9
+ /** Transcribed text content */
10
+ text: string;
11
+ /** Whether this is a final (not partial) transcript */
12
+ isFinal: boolean;
13
+ /** STT confidence score (0-1) */
14
+ confidence: number;
15
+ /** Speaker label from diarization (e.g., "S1", "Monroe") */
16
+ speakerId?: string;
17
+ /** Whether this speaker is the active/focused speaker */
18
+ isActiveSpeaker?: boolean;
19
+ }