agent.libx.js 0.89.9 → 0.92.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/cli/cli.ts +1981 -0
- package/dist/{Agent-B0l9qT_j.d.ts → Agent-BzwprwHr.d.ts} +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +1145 -191
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +200 -6
- package/dist/index.js +584 -14
- package/dist/index.js.map +1 -1
- package/dist/{mcp-Dg3vA1Uj.d.ts → mcp-Bn5TlRbV.d.ts} +10 -2
- package/dist/mcp.client.d.ts +2 -2
- package/dist/mcp.client.js +19 -7
- package/dist/mcp.client.js.map +1 -1
- package/dist/{tools-Ch-OzOU8.d.ts → tools-CeK5AquG.d.ts} +11 -2
- package/dist/tools.shell.d.ts +1 -1
- package/dist/tools.shell.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-
|
|
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-
|
|
1
|
+
import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-BzwprwHr.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-BzwprwHr.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';
|
|
6
|
-
import { A as AgentTool, C as ChatLike, a as ChatOptions, b as ChatResponse, h as ToolCall, H as HostBridge, U as UserQuestion, e as MessageContent } from './tools-
|
|
7
|
-
export { c as ContentPart, d as HostEvent, M as Message, R as Role, S as SandboxJobRegistry, f as StreamChunk, T as TodoItem, g as Tool, i as ToolContext, j as bashTool, k as contentText, l as defaultTools, m as editTool, n as
|
|
8
|
-
export { M as McpCall, a as
|
|
6
|
+
import { A as AgentTool, C as ChatLike, a as ChatOptions, b as ChatResponse, h as ToolCall, H as HostBridge, U as UserQuestion, e as MessageContent } from './tools-CeK5AquG.js';
|
|
7
|
+
export { c as ContentPart, d as HostEvent, M as Message, R as Role, S as SandboxJobRegistry, f as StreamChunk, T as TodoItem, g as Tool, i as ToolContext, j as bashTool, k as contentText, l as defaultTools, m as editTool, n as exitSessionTool, o as imagePart, p as makeContext, q as makeJobTools, r as readTool, t as toWireTools, s as todoWriteTool, u as toolRegistry, v as toolsByName } from './tools-CeK5AquG.js';
|
|
8
|
+
export { M as McpCall, a as McpImage, b as McpToolResult, c as McpToolSearchOptions, d as McpToolSpec, m as makeMcpToolSearch, e as mcpToolToAgentTool, f as mcpToolsToAgentTools } from './mcp-Bn5TlRbV.js';
|
|
9
9
|
import * as libx_js_src_modules_log from 'libx.js/src/modules/log';
|
|
10
10
|
export { log } from 'libx.js/src/modules/log';
|
|
11
11
|
|
|
@@ -597,6 +597,9 @@ declare class DuplexAgentOptions {
|
|
|
597
597
|
/** Awaited BEFORE a delegated worker spawns — open a per-task checkpoint frame, audit, etc.
|
|
598
598
|
* (post-spawn would race the worker's first edits). */
|
|
599
599
|
onTaskStart?: (id: string, label: string) => void | Promise<void>;
|
|
600
|
+
/** Host overrides for QuickLook lookups (keyed by `what`). The engine's defaults go through the
|
|
601
|
+
* (possibly jailed) fs — e.g. `.git/**` is deny-listed, so the CLI supplies 'branch' itself. */
|
|
602
|
+
quickLook?: Record<string, (path?: string) => string | Promise<string>>;
|
|
600
603
|
}
|
|
601
604
|
declare const VOICE_SYSTEM_PROMPT: string;
|
|
602
605
|
/**
|
|
@@ -632,6 +635,10 @@ declare class DuplexAgent {
|
|
|
632
635
|
private failTask;
|
|
633
636
|
private delegateTool;
|
|
634
637
|
private taskStatusTool;
|
|
638
|
+
/** Sub-100ms read-only lookups the voice may do itself — everything else stays Delegate-only.
|
|
639
|
+
* fs-only (no shell; the engine is VFS-abstracted): time, git branch (.git/HEAD read), ls, file
|
|
640
|
+
* head. Output is hard-capped so a lookup can never bloat the skinny voice context. */
|
|
641
|
+
private quickLookTool;
|
|
635
642
|
private cancelTaskTool;
|
|
636
643
|
}
|
|
637
644
|
|
|
@@ -697,4 +704,191 @@ declare function makeTaskBatchTool(opts: TaskToolOptions): AgentTool;
|
|
|
697
704
|
/** Component-scoped logger (libx.js). debug/verbose gated via DEBUG env/localStorage. */
|
|
698
705
|
declare const forComponent: (name: string) => libx_js_src_modules_log.ComponentLogger;
|
|
699
706
|
|
|
700
|
-
|
|
707
|
+
/**
|
|
708
|
+
* Portable voice I/O contracts — zero platform imports. The engine, STT and TTS clients in this
|
|
709
|
+
* directory run anywhere with a `WebSocket` global (Bun, Node, browser); platform backends
|
|
710
|
+
* (mic capture, audio playback) plug in through these seams.
|
|
711
|
+
*/
|
|
712
|
+
type VoiceState = 'idle' | 'listening' | 'thinking' | 'speaking';
|
|
713
|
+
/** STT input sample format — sources MUST deliver this (downsample/convert in the adapter). */
|
|
714
|
+
declare const STT_SAMPLE_RATE = 16000;
|
|
715
|
+
/** Playback format the TTS requests and sinks must play. */
|
|
716
|
+
declare const TTS_SAMPLE_RATE = 44100;
|
|
717
|
+
/** A microphone (or any PCM) source. Emits s16le mono 16kHz chunks.
|
|
718
|
+
* Node: mic-aec/ffmpeg child process. Web: getUserMedia({ echoCancellation: true }) + worklet. */
|
|
719
|
+
interface AudioSource {
|
|
720
|
+
/** `aec` = the source is echo-cancelled (assistant's own TTS never reaches the chunks) —
|
|
721
|
+
* selects the engine's trivial barge-in path vs the heuristic echo tier. */
|
|
722
|
+
readonly aec: boolean;
|
|
723
|
+
start(onChunk: (pcm: Uint8Array) => void): void | Promise<void>;
|
|
724
|
+
stop(): void;
|
|
725
|
+
}
|
|
726
|
+
/** An audio playback sink for s16le mono 44.1kHz PCM.
|
|
727
|
+
* Node: per-turn ffplay. Web: AudioContext/worklet ring buffer. */
|
|
728
|
+
interface AudioSink {
|
|
729
|
+
/** start a new spoken turn (may recycle or recreate the underlying player) */
|
|
730
|
+
markTurn(): void;
|
|
731
|
+
write(pcm: Uint8Array): void;
|
|
732
|
+
/** estimated ms until queued audio finishes playing */
|
|
733
|
+
drainMs(): number;
|
|
734
|
+
/** ms of audio actually played this turn */
|
|
735
|
+
playedMs(): number;
|
|
736
|
+
/** stop playback NOW (barge-in primitive) */
|
|
737
|
+
kill(): void;
|
|
738
|
+
}
|
|
739
|
+
/** Static key (server/CLI) or an async getter (browser: fetch a short-lived token from YOUR
|
|
740
|
+
* backend). Getters are invoked on EVERY (re)connect — temp tokens expire, so a reconnect
|
|
741
|
+
* must re-mint, never reuse the boot-time token. */
|
|
742
|
+
type AuthProvider = string | (() => string | Promise<string>);
|
|
743
|
+
declare function resolveAuth(auth: AuthProvider): Promise<string>;
|
|
744
|
+
|
|
745
|
+
/** Structural contracts (satisfied by SonioxSTT/CartesiaTTS or test fakes). */
|
|
746
|
+
interface SttLike {
|
|
747
|
+
usingAec: boolean;
|
|
748
|
+
onPartial: (text: string) => void;
|
|
749
|
+
onUtterance: (text: string, endpointAt: number) => void;
|
|
750
|
+
onLevel: (rms: number) => void;
|
|
751
|
+
start(): Promise<void> | void;
|
|
752
|
+
reset(): void;
|
|
753
|
+
stop(): void;
|
|
754
|
+
}
|
|
755
|
+
interface TtsLike {
|
|
756
|
+
onAudio: (chunk: Uint8Array) => void;
|
|
757
|
+
onDone: () => void;
|
|
758
|
+
connect(): Promise<void> | void;
|
|
759
|
+
newContext(): string;
|
|
760
|
+
speak(text: string, cont: boolean): void;
|
|
761
|
+
end(): void;
|
|
762
|
+
cancel(): void;
|
|
763
|
+
close(): void;
|
|
764
|
+
}
|
|
765
|
+
declare class VoiceEngineOptions {
|
|
766
|
+
stt: SttLike;
|
|
767
|
+
tts: TtsLike;
|
|
768
|
+
player: AudioSink;
|
|
769
|
+
/** a final utterance arrived (endpoint) — host dispatches it as a turn */
|
|
770
|
+
onUtterance: (text: string) => void;
|
|
771
|
+
/** live partial transcript while listening (host renders the 🎤 line) */
|
|
772
|
+
onPartial: (text: string) => void;
|
|
773
|
+
onState: (s: VoiceState) => void;
|
|
774
|
+
/** user spoke/acted over playback — host aborts the in-flight turn (called AFTER audio is killed).
|
|
775
|
+
* phase: 'speaking' = cut mid-speech (real interruption); 'drain' = in the final audio tail
|
|
776
|
+
* (normal turn-taking — hosts shouldn't alarm). */
|
|
777
|
+
onBargeIn: (phase: 'speaking' | 'drain') => void;
|
|
778
|
+
/** spoken micro-ack on utterance endpoint (masks LLM TTFT); '' disables */
|
|
779
|
+
ackPhrase: string;
|
|
780
|
+
/** Endpoint merge window (ms): hold an endpointed utterance briefly — if speech resumes (spelled
|
|
781
|
+
* letters, mid-thought pauses), the next utterance MERGES instead of dispatching a truncated one
|
|
782
|
+
* ("E-L-Y." / "A."). Costs this much latency per turn; 0 disables. */
|
|
783
|
+
utteranceMergeMs: number;
|
|
784
|
+
/** heuristic (non-AEC) energy barge-in tuning */
|
|
785
|
+
bargeRmsMult: number;
|
|
786
|
+
bargeRmsFloor: number;
|
|
787
|
+
}
|
|
788
|
+
declare class VoiceEngine {
|
|
789
|
+
options: VoiceEngineOptions;
|
|
790
|
+
state: VoiceState;
|
|
791
|
+
protected stt: SttLike;
|
|
792
|
+
protected tts: TtsLike;
|
|
793
|
+
protected player: AudioSink;
|
|
794
|
+
private speaking;
|
|
795
|
+
private ctxOpen;
|
|
796
|
+
private interrupted;
|
|
797
|
+
private spokeDeltas;
|
|
798
|
+
private drainTimer;
|
|
799
|
+
private echoWords;
|
|
800
|
+
private prevReply;
|
|
801
|
+
private reply;
|
|
802
|
+
private echoUntil;
|
|
803
|
+
private baseline;
|
|
804
|
+
private hot;
|
|
805
|
+
private suspectUntil;
|
|
806
|
+
private ackAt;
|
|
807
|
+
private pendingUtt;
|
|
808
|
+
private pendingTimer;
|
|
809
|
+
private lastInterrupted;
|
|
810
|
+
constructor(options?: Partial<VoiceEngineOptions>);
|
|
811
|
+
start(): Promise<void>;
|
|
812
|
+
get usingAec(): boolean;
|
|
813
|
+
private idleWaiters;
|
|
814
|
+
private setState;
|
|
815
|
+
/** Resolve when the engine is no longer speaking (immediate if already idle). */
|
|
816
|
+
awaitIdle(): Promise<void>;
|
|
817
|
+
/** open a spoken turn (idempotent — safe from both onUtterance and first-delta paths).
|
|
818
|
+
* `ack` speaks the configured micro-ack as the context opener (utterance path only —
|
|
819
|
+
* masks LLM TTFT; re-voice turns begun by their first delta skip it). */
|
|
820
|
+
beginSpeech(ack?: boolean): void;
|
|
821
|
+
speakDelta(text: string): void;
|
|
822
|
+
/** close the spoken turn (idempotent); stays audible until ALL audio arrived AND playback drains */
|
|
823
|
+
endSpeech(): void;
|
|
824
|
+
/** text of the reply cut by the last barge-in — consumed by the host to tell the model what
|
|
825
|
+
* the user did NOT hear. Cleared on read. */
|
|
826
|
+
takeInterruptedReply(): {
|
|
827
|
+
full: string;
|
|
828
|
+
heard: string;
|
|
829
|
+
} | null;
|
|
830
|
+
/** barge-in: stop audio NOW, cancel generation, reset for the user's utterance */
|
|
831
|
+
interrupt(): void;
|
|
832
|
+
stop(): void;
|
|
833
|
+
private words;
|
|
834
|
+
private novelWords;
|
|
835
|
+
private echoActive;
|
|
836
|
+
private handlePartial;
|
|
837
|
+
private handleUtterance;
|
|
838
|
+
private flushUtterance;
|
|
839
|
+
/** energy two-stage barge-in (heuristic tier only): spike over echo baseline → pause + confirm via STT */
|
|
840
|
+
private handleLevel;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
declare class SonioxSTTOptions {
|
|
844
|
+
auth: AuthProvider;
|
|
845
|
+
source: AudioSource;
|
|
846
|
+
model: string;
|
|
847
|
+
languageHints: string[];
|
|
848
|
+
}
|
|
849
|
+
declare class SonioxSTT {
|
|
850
|
+
options: SonioxSTTOptions;
|
|
851
|
+
private ws;
|
|
852
|
+
private stopped;
|
|
853
|
+
private sourceStarted;
|
|
854
|
+
onPartial: (text: string) => void;
|
|
855
|
+
onUtterance: (text: string, endpointAt: number) => void;
|
|
856
|
+
/** mic energy (RMS) per chunk — drives the energy-based heuristic barge-in tier */
|
|
857
|
+
onLevel: (rms: number) => void;
|
|
858
|
+
private finalText;
|
|
859
|
+
private partialText;
|
|
860
|
+
constructor(options?: Partial<SonioxSTTOptions>);
|
|
861
|
+
get usingAec(): boolean;
|
|
862
|
+
private connectWs;
|
|
863
|
+
start(): Promise<void>;
|
|
864
|
+
private handle;
|
|
865
|
+
reset(): void;
|
|
866
|
+
stop(): void;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
declare class CartesiaTTSOptions {
|
|
870
|
+
auth: AuthProvider;
|
|
871
|
+
voiceId: string;
|
|
872
|
+
model: string;
|
|
873
|
+
/** 'apiKey' (server/CLI) → `api_key=` URL param; 'token' (browser, BE-minted) → `access_token=`. */
|
|
874
|
+
authMode: 'apiKey' | 'token';
|
|
875
|
+
}
|
|
876
|
+
declare class CartesiaTTS {
|
|
877
|
+
options: CartesiaTTSOptions;
|
|
878
|
+
private ws;
|
|
879
|
+
private ctxSeq;
|
|
880
|
+
ctxId: string;
|
|
881
|
+
onAudio: (chunk: Uint8Array) => void;
|
|
882
|
+
onDone: () => void;
|
|
883
|
+
firstAudioAt: number;
|
|
884
|
+
constructor(options?: Partial<CartesiaTTSOptions>);
|
|
885
|
+
connect(): Promise<void>;
|
|
886
|
+
newContext(): string;
|
|
887
|
+
private frame;
|
|
888
|
+
speak(text: string, cont: boolean): void;
|
|
889
|
+
end(): void;
|
|
890
|
+
cancel(): void;
|
|
891
|
+
close(): void;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
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 };
|