agent.libx.js 0.92.8 → 0.93.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,5 +1,5 @@
1
- import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-QwBA0wu6.js';
2
- export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-QwBA0wu6.js';
1
+ import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-B_xvSHlG.js';
2
+ export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-B_xvSHlG.js';
3
3
  import { IFilesystem, FileMetadata } from '@livx.cc/wcli/core';
4
4
  export { CommandExecutor, FileMetadata, IFilesystem, IndexedDbFilesystem, MemFilesystem, registerHeadlessCommands } from '@livx.cc/wcli/core';
5
5
  import { BodDB } from '@bod.ee/db';
@@ -473,6 +473,10 @@ declare function loadCommands(fs: IFilesystem, dir: string | string[], opts?: {
473
473
  tool?: AgentTool;
474
474
  }>;
475
475
 
476
+ /** Behavioral guidance injected alongside the memory index — adapted from CC's battle-tuned prose, for our tool-based workflow. */
477
+ declare const MEMORY_PROMPT: string;
478
+ /** Voice-specific memory guidance — shorter, spoken-interaction tuned. */
479
+ declare const VOICE_MEMORY_PROMPT: string;
476
480
  /**
477
481
  * Load memory for injection at run start (the recall step), with progressive disclosure:
478
482
  * - `index`: the compact `<dir>/MEMORY.md` index, injected into the system prompt — cheap,
@@ -485,10 +489,18 @@ declare function loadCommands(fs: IFilesystem, dir: string | string[], opts?: {
485
489
  * IndexedDbFilesystem → browser, (planned) BodDbFilesystem → database. The same
486
490
  * memory mechanism therefore works in node, a browser tab, or on edge.
487
491
  */
488
- declare function loadMemory(fs: IFilesystem, dir: string, opts?: {
492
+ interface LoadMemoryOpts {
489
493
  relevanceHint?: string;
490
494
  max?: number;
491
- }): Promise<{
495
+ /** Max Remember calls per session (default 25). Prevents runaway memory writes. */
496
+ maxWritesPerSession?: number;
497
+ /** Called after each successful memory write (auditing, UI indicators). */
498
+ onMemorySaved?: (slug: string, type?: string) => void;
499
+ /** User-scope dir for global memories (type=user/feedback). If set, Remember routes by type:
500
+ * user/feedback → userDir (global, survives across projects), project/reference → writeDir. */
501
+ userDir?: string;
502
+ }
503
+ declare function loadMemory(fs: IFilesystem, dir: string | string[], opts?: LoadMemoryOpts): Promise<{
492
504
  index: string;
493
505
  tools: AgentTool[];
494
506
  }>;
@@ -499,7 +511,10 @@ declare function slugify(s: string, fallback?: string): string;
499
511
  * `<dir>/MEMORY.md` (created if missing). Idempotent on the index (won't duplicate a pointer).
500
512
  * This is the shared write path behind the `Remember` tool and automatic lesson capture.
501
513
  */
502
- declare function writeFact(fs: IFilesystem, dir: string, slug: string, body: string): Promise<void>;
514
+ declare function writeFact(fs: IFilesystem, dir: string, slug: string, body: string, opts?: {
515
+ type?: string;
516
+ description?: string;
517
+ }): Promise<void>;
503
518
 
504
519
  /**
505
520
  * Automatic mistake → lesson → steer loop. Closes the within-run learning gap: the agent
@@ -611,6 +626,11 @@ declare class DuplexAgentOptions {
611
626
  /** Host overrides for QuickLook lookups (keyed by `what`). The engine's defaults go through the
612
627
  * (possibly jailed) fs — e.g. `.git/**` is deny-listed, so the CLI supplies 'branch' itself. */
613
628
  quickLook?: Record<string, (path?: string) => string | Promise<string>>;
629
+ /** Memory directory/directories on the WORKER fs. If set, the voice agent gets Remember + Recall
630
+ * tools directly (no delegation needed) and implicit capture guidance. */
631
+ memoryDir?: string | string[];
632
+ /** User-scope memory dir for global facts (type=user/feedback). Forwarded to Remember's routing. */
633
+ memoryUserDir?: string;
614
634
  }
615
635
  declare const VOICE_SYSTEM_PROMPT: string;
616
636
  /**
@@ -632,7 +652,11 @@ declare class DuplexAgent {
632
652
  question: string;
633
653
  resolve: (answer: string) => void;
634
654
  }>;
655
+ /** Lazily resolved memory tools (async loadMemory runs in initMemory). */
656
+ private memoryReady;
635
657
  constructor(options?: Partial<DuplexAgentOptions>);
658
+ /** Resolve memory tools + inject index into voice system prompt (once). */
659
+ private initMemory;
636
660
  /** One user turn: the voice agent streams the reply (and may Delegate). Serialized with re-voice turns. */
637
661
  send(content: MessageContent): Promise<RunResult>;
638
662
  /** Resolve when all queued voice turns AND all in-flight worker tasks have settled (tests, graceful shutdown). */
@@ -817,18 +841,15 @@ declare class VoiceEngineOptions {
817
841
  /** heuristic (non-AEC) energy barge-in tuning */
818
842
  bargeRmsMult: number;
819
843
  bargeRmsFloor: number;
820
- /** Overlap turn-taking (AEC tier, needs player.pause/resume) — human phone-call model:
821
- * onset PAUSE (exact-sample hold, nothing lost); sustained overlap cede (interrupt; the LLM
822
- * re-enters). Brief overlaps that die out (backchannels"mm-hm", decided by DURATION, not
823
- * vocabulary) resume from the precise sample and are dropped. false disables. */
844
+ /** Overlap turn-taking (AEC tier, needs player.pause/resume) — human phone-call model, driven by
845
+ * the STT ITSELF (a trained speech classifier) instead of energy thresholds (energy could not
846
+ * separate residue bursts from speech in every room hiccup whack-a-mole): partial text while
847
+ * speaking PAUSE (exact-sample hold); partial grows into dominant-novel ≥2 words → cede
848
+ * (interrupt; the LLM re-enters); partial stalls/endpoints without ceding (backchannel by
849
+ * DURATION, not vocabulary) → resume + drop. false disables. */
824
850
  overlapPause: boolean;
825
- /** sustained overlap this → cede the turn */
826
- overlapSustainMs: number;
827
- /** quiet for this long while paused → resume, drop the interjection */
851
+ /** no new partial activity for this long while paused resume, drop the interjection */
828
852
  overlapResumeMs: number;
829
- /** energy floor for "overlap candidate" — must sit ABOVE typical room ambient (~110 rms measured;
830
- * ungated ambient re-arming the resume timer forever was a live wedge). User speech ≫ 300. */
831
- overlapRms: number;
832
853
  }
833
854
  declare class VoiceEngine {
834
855
  options: VoiceEngineOptions;
@@ -853,8 +874,7 @@ declare class VoiceEngine {
853
874
  private pendingTimer;
854
875
  private lastInterrupted;
855
876
  private pausedAt;
856
- private overlapLoud;
857
- private overlapLastLoudAt;
877
+ private lastOverlapPartial;
858
878
  private resumeTimer;
859
879
  constructor(options?: Partial<VoiceEngineOptions>);
860
880
  start(): Promise<void>;
@@ -892,13 +912,10 @@ declare class VoiceEngine {
892
912
  private handleUtterance;
893
913
  private flushUtterance;
894
914
  private get overlapCapable();
895
- /** Overlap turn-taking (AEC tier): onset → pause (exact-sample hold); sustained → cede; died out
896
- * → resume. No vocabulary anywhere — duration and persistence decide (backchannels are short
897
- * and stop). Nothing is lost across a pause, so a false positive costs only a brief hold. */
898
- private handleOverlap;
899
915
  private armResume;
900
916
  private resetOverlap;
901
917
  /** energy two-stage barge-in (heuristic tier only): spike over echo baseline → pause + confirm via STT */
918
+ private gatePassTimes;
902
919
  private handleLevel;
903
920
  }
904
921
 
@@ -907,6 +924,9 @@ declare class SonioxSTTOptions {
907
924
  source: AudioSource;
908
925
  model: string;
909
926
  languageHints: string[];
927
+ /** Client-side endpoint: finalized text + no new tokens for this long = utterance (don't wait for
928
+ * Soniox's semantic <end>, which adds 0.5-1.5s — the difference between ping-pong and lag). */
929
+ silenceEndpointMs: number;
910
930
  }
911
931
  declare class SonioxSTT {
912
932
  options: SonioxSTTOptions;
@@ -919,6 +939,9 @@ declare class SonioxSTT {
919
939
  onLevel: (rms: number) => void;
920
940
  private finalText;
921
941
  private partialText;
942
+ private lastChangeAt;
943
+ private lastCombined;
944
+ private endpointTimer;
922
945
  constructor(options?: Partial<SonioxSTTOptions>);
923
946
  get usingAec(): boolean;
924
947
  private connectWs;
@@ -953,4 +976,4 @@ declare class CartesiaTTS {
953
976
  close(): void;
954
977
  }
955
978
 
956
- export { Agent, type AgentDef, AgentOptions, AgentTool, type Attempt, type AudioSink, type AudioSource, type AuthProvider, BodDbFilesystem, CartesiaTTS, CartesiaTTSOptions, ChatLike, ChatOptions, ChatResponse, type CommandInfo, ConsoleHostBridge, DEFAULT_DENY, DuplexAgent, DuplexAgentOptions, type DuplexTaskStatus, FakeAIClient, Hooks, HostBridge, JailOptions, JailedFilesystem, type LessonOptions, LessonOptionsDefaults, MessageContent, type Mount, MountFilesystem, NodeDiskFilesystem, OverlayFilesystem, type ReflectOptions, RunResult, STT_SAMPLE_RATE, ScriptedHostBridge, type SkillInfo, SonioxSTT, SonioxSTTOptions, type SttLike, TTS_SAMPLE_RATE, type TaskRecord, type TaskToolOptions, ToolCall, type ToolSpec, type TtsLike, UserQuestion, VOICE_SYSTEM_PROMPT, VoiceEngine, VoiceEngineOptions, type VoiceState, type WebFetchOptions, type WebSearchOptions, applyEditsTool, askUserQuestionTool, checkpointTool, checkpointTools, compileSynthesizedTool, diskAgentOptions, expandCommand, expandTemplate, forComponent, fullAgentOptions, globTool, grepTool, htmlToText, idfWeights, lessonCapture, loadAgents, loadCommands, loadInstructions, loadMemory, loadSkills, makeTaskBatchTool, makeTaskTool, makeWebFetchTool, makeWebSearchTool, mkdirp, multiEditTool, raceAttempts, reflectOnRun, relevanceScore, repoIndex, repoMapTool, resolveAuth, rollbackTool, sandboxAgentOptions, slugify, tokenize, toolCall, topByRelevance, validateToolCode, webFetchTool, webSearchTool, writeFact, writeTool };
979
+ export { Agent, type AgentDef, AgentOptions, AgentTool, type Attempt, type AudioSink, type AudioSource, type AuthProvider, BodDbFilesystem, CartesiaTTS, CartesiaTTSOptions, ChatLike, ChatOptions, ChatResponse, type CommandInfo, ConsoleHostBridge, DEFAULT_DENY, DuplexAgent, DuplexAgentOptions, type DuplexTaskStatus, FakeAIClient, Hooks, HostBridge, JailOptions, JailedFilesystem, type LessonOptions, LessonOptionsDefaults, type LoadMemoryOpts, MEMORY_PROMPT, MessageContent, type Mount, MountFilesystem, NodeDiskFilesystem, OverlayFilesystem, type ReflectOptions, RunResult, STT_SAMPLE_RATE, ScriptedHostBridge, type SkillInfo, SonioxSTT, SonioxSTTOptions, type SttLike, TTS_SAMPLE_RATE, type TaskRecord, type TaskToolOptions, ToolCall, type ToolSpec, type TtsLike, UserQuestion, VOICE_MEMORY_PROMPT, VOICE_SYSTEM_PROMPT, VoiceEngine, VoiceEngineOptions, type VoiceState, type WebFetchOptions, type WebSearchOptions, applyEditsTool, askUserQuestionTool, checkpointTool, checkpointTools, compileSynthesizedTool, diskAgentOptions, expandCommand, expandTemplate, forComponent, fullAgentOptions, globTool, grepTool, htmlToText, idfWeights, lessonCapture, loadAgents, loadCommands, loadInstructions, loadMemory, loadSkills, makeTaskBatchTool, makeTaskTool, makeWebFetchTool, makeWebSearchTool, mkdirp, multiEditTool, raceAttempts, reflectOnRun, relevanceScore, repoIndex, repoMapTool, resolveAuth, rollbackTool, sandboxAgentOptions, slugify, tokenize, toolCall, topByRelevance, validateToolCode, webFetchTool, webSearchTool, writeFact, writeTool };