agent.libx.js 0.89.9 → 0.92.2
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 +1208 -192
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +211 -7
- package/dist/index.js +645 -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
|
|
|
@@ -565,7 +565,7 @@ declare function loadInstructions(fs: IFilesystem, names?: string[]): Promise<st
|
|
|
565
565
|
* re-voiced by the fast persona — push, not poll (unlike subagent.ts's background `Task`).
|
|
566
566
|
*
|
|
567
567
|
* Host events (via the open HostEvent union): the voice agent's standard `text_delta` stream,
|
|
568
|
-
* plus `task_started` / `task_done` / `task_error` / `task_cancelled`.
|
|
568
|
+
* plus `task_started` / `task_progress` / `task_done` / `task_error` / `task_cancelled`.
|
|
569
569
|
*/
|
|
570
570
|
|
|
571
571
|
type DuplexTaskStatus = 'running' | 'done' | 'error' | 'cancelled';
|
|
@@ -597,6 +597,14 @@ 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
|
+
/** Re-voice throttled worker progress asides ('[task t1 progress] …') so long tasks aren't dead
|
|
601
|
+
* air. Off by default — each update costs a voice turn (LLM call + speech). */
|
|
602
|
+
progressUpdates: boolean;
|
|
603
|
+
/** Min ms between progress re-voices per task. */
|
|
604
|
+
progressIntervalMs: number;
|
|
605
|
+
/** Host overrides for QuickLook lookups (keyed by `what`). The engine's defaults go through the
|
|
606
|
+
* (possibly jailed) fs — e.g. `.git/**` is deny-listed, so the CLI supplies 'branch' itself. */
|
|
607
|
+
quickLook?: Record<string, (path?: string) => string | Promise<string>>;
|
|
600
608
|
}
|
|
601
609
|
declare const VOICE_SYSTEM_PROMPT: string;
|
|
602
610
|
/**
|
|
@@ -627,11 +635,20 @@ declare class DuplexAgent {
|
|
|
627
635
|
private buildBrief;
|
|
628
636
|
/** Spawn a detached worker for task `id`; its settlement notifies + enqueues the re-voice turn. */
|
|
629
637
|
private spawnWorker;
|
|
638
|
+
/** Throttled per-task progress: worker tool calls → at most one progress re-voice per interval.
|
|
639
|
+
* Two sources, one throttle: completed steps (post) and a heartbeat for a SINGLE long tool call
|
|
640
|
+
* (pre records the in-flight call; a self-cleaning timer narrates "still inside Bash — 70s").
|
|
641
|
+
* Completion supersedes: nothing is emitted once the task has settled. */
|
|
642
|
+
private progressReporter;
|
|
630
643
|
private onWorkerSettled;
|
|
631
644
|
private onWorkerFailed;
|
|
632
645
|
private failTask;
|
|
633
646
|
private delegateTool;
|
|
634
647
|
private taskStatusTool;
|
|
648
|
+
/** Sub-100ms read-only lookups the voice may do itself — everything else stays Delegate-only.
|
|
649
|
+
* fs-only (no shell; the engine is VFS-abstracted): time, git branch (.git/HEAD read), ls, file
|
|
650
|
+
* head. Output is hard-capped so a lookup can never bloat the skinny voice context. */
|
|
651
|
+
private quickLookTool;
|
|
635
652
|
private cancelTaskTool;
|
|
636
653
|
}
|
|
637
654
|
|
|
@@ -697,4 +714,191 @@ declare function makeTaskBatchTool(opts: TaskToolOptions): AgentTool;
|
|
|
697
714
|
/** Component-scoped logger (libx.js). debug/verbose gated via DEBUG env/localStorage. */
|
|
698
715
|
declare const forComponent: (name: string) => libx_js_src_modules_log.ComponentLogger;
|
|
699
716
|
|
|
700
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Portable voice I/O contracts — zero platform imports. The engine, STT and TTS clients in this
|
|
719
|
+
* directory run anywhere with a `WebSocket` global (Bun, Node, browser); platform backends
|
|
720
|
+
* (mic capture, audio playback) plug in through these seams.
|
|
721
|
+
*/
|
|
722
|
+
type VoiceState = 'idle' | 'listening' | 'thinking' | 'speaking';
|
|
723
|
+
/** STT input sample format — sources MUST deliver this (downsample/convert in the adapter). */
|
|
724
|
+
declare const STT_SAMPLE_RATE = 16000;
|
|
725
|
+
/** Playback format the TTS requests and sinks must play. */
|
|
726
|
+
declare const TTS_SAMPLE_RATE = 44100;
|
|
727
|
+
/** A microphone (or any PCM) source. Emits s16le mono 16kHz chunks.
|
|
728
|
+
* Node: mic-aec/ffmpeg child process. Web: getUserMedia({ echoCancellation: true }) + worklet. */
|
|
729
|
+
interface AudioSource {
|
|
730
|
+
/** `aec` = the source is echo-cancelled (assistant's own TTS never reaches the chunks) —
|
|
731
|
+
* selects the engine's trivial barge-in path vs the heuristic echo tier. */
|
|
732
|
+
readonly aec: boolean;
|
|
733
|
+
start(onChunk: (pcm: Uint8Array) => void): void | Promise<void>;
|
|
734
|
+
stop(): void;
|
|
735
|
+
}
|
|
736
|
+
/** An audio playback sink for s16le mono 44.1kHz PCM.
|
|
737
|
+
* Node: per-turn ffplay. Web: AudioContext/worklet ring buffer. */
|
|
738
|
+
interface AudioSink {
|
|
739
|
+
/** start a new spoken turn (may recycle or recreate the underlying player) */
|
|
740
|
+
markTurn(): void;
|
|
741
|
+
write(pcm: Uint8Array): void;
|
|
742
|
+
/** estimated ms until queued audio finishes playing */
|
|
743
|
+
drainMs(): number;
|
|
744
|
+
/** ms of audio actually played this turn */
|
|
745
|
+
playedMs(): number;
|
|
746
|
+
/** stop playback NOW (barge-in primitive) */
|
|
747
|
+
kill(): void;
|
|
748
|
+
}
|
|
749
|
+
/** Static key (server/CLI) or an async getter (browser: fetch a short-lived token from YOUR
|
|
750
|
+
* backend). Getters are invoked on EVERY (re)connect — temp tokens expire, so a reconnect
|
|
751
|
+
* must re-mint, never reuse the boot-time token. */
|
|
752
|
+
type AuthProvider = string | (() => string | Promise<string>);
|
|
753
|
+
declare function resolveAuth(auth: AuthProvider): Promise<string>;
|
|
754
|
+
|
|
755
|
+
/** Structural contracts (satisfied by SonioxSTT/CartesiaTTS or test fakes). */
|
|
756
|
+
interface SttLike {
|
|
757
|
+
usingAec: boolean;
|
|
758
|
+
onPartial: (text: string) => void;
|
|
759
|
+
onUtterance: (text: string, endpointAt: number) => void;
|
|
760
|
+
onLevel: (rms: number) => void;
|
|
761
|
+
start(): Promise<void> | void;
|
|
762
|
+
reset(): void;
|
|
763
|
+
stop(): void;
|
|
764
|
+
}
|
|
765
|
+
interface TtsLike {
|
|
766
|
+
onAudio: (chunk: Uint8Array) => void;
|
|
767
|
+
onDone: () => void;
|
|
768
|
+
connect(): Promise<void> | void;
|
|
769
|
+
newContext(): string;
|
|
770
|
+
speak(text: string, cont: boolean): void;
|
|
771
|
+
end(): void;
|
|
772
|
+
cancel(): void;
|
|
773
|
+
close(): void;
|
|
774
|
+
}
|
|
775
|
+
declare class VoiceEngineOptions {
|
|
776
|
+
stt: SttLike;
|
|
777
|
+
tts: TtsLike;
|
|
778
|
+
player: AudioSink;
|
|
779
|
+
/** a final utterance arrived (endpoint) — host dispatches it as a turn */
|
|
780
|
+
onUtterance: (text: string) => void;
|
|
781
|
+
/** live partial transcript while listening (host renders the 🎤 line) */
|
|
782
|
+
onPartial: (text: string) => void;
|
|
783
|
+
onState: (s: VoiceState) => void;
|
|
784
|
+
/** user spoke/acted over playback — host aborts the in-flight turn (called AFTER audio is killed).
|
|
785
|
+
* phase: 'speaking' = cut mid-speech (real interruption); 'drain' = in the final audio tail
|
|
786
|
+
* (normal turn-taking — hosts shouldn't alarm). */
|
|
787
|
+
onBargeIn: (phase: 'speaking' | 'drain') => void;
|
|
788
|
+
/** spoken micro-ack on utterance endpoint (masks LLM TTFT); '' disables */
|
|
789
|
+
ackPhrase: string;
|
|
790
|
+
/** Endpoint merge window (ms): hold an endpointed utterance briefly — if speech resumes (spelled
|
|
791
|
+
* letters, mid-thought pauses), the next utterance MERGES instead of dispatching a truncated one
|
|
792
|
+
* ("E-L-Y." / "A."). Costs this much latency per turn; 0 disables. */
|
|
793
|
+
utteranceMergeMs: number;
|
|
794
|
+
/** heuristic (non-AEC) energy barge-in tuning */
|
|
795
|
+
bargeRmsMult: number;
|
|
796
|
+
bargeRmsFloor: number;
|
|
797
|
+
}
|
|
798
|
+
declare class VoiceEngine {
|
|
799
|
+
options: VoiceEngineOptions;
|
|
800
|
+
state: VoiceState;
|
|
801
|
+
protected stt: SttLike;
|
|
802
|
+
protected tts: TtsLike;
|
|
803
|
+
protected player: AudioSink;
|
|
804
|
+
private speaking;
|
|
805
|
+
private ctxOpen;
|
|
806
|
+
private interrupted;
|
|
807
|
+
private spokeDeltas;
|
|
808
|
+
private drainTimer;
|
|
809
|
+
private echoWords;
|
|
810
|
+
private prevReply;
|
|
811
|
+
private reply;
|
|
812
|
+
private echoUntil;
|
|
813
|
+
private baseline;
|
|
814
|
+
private hot;
|
|
815
|
+
private suspectUntil;
|
|
816
|
+
private ackAt;
|
|
817
|
+
private pendingUtt;
|
|
818
|
+
private pendingTimer;
|
|
819
|
+
private lastInterrupted;
|
|
820
|
+
constructor(options?: Partial<VoiceEngineOptions>);
|
|
821
|
+
start(): Promise<void>;
|
|
822
|
+
get usingAec(): boolean;
|
|
823
|
+
private idleWaiters;
|
|
824
|
+
private setState;
|
|
825
|
+
/** Resolve when the engine is no longer speaking (immediate if already idle). */
|
|
826
|
+
awaitIdle(): Promise<void>;
|
|
827
|
+
/** open a spoken turn (idempotent — safe from both onUtterance and first-delta paths).
|
|
828
|
+
* `ack` speaks the configured micro-ack as the context opener (utterance path only —
|
|
829
|
+
* masks LLM TTFT; re-voice turns begun by their first delta skip it). */
|
|
830
|
+
beginSpeech(ack?: boolean): void;
|
|
831
|
+
speakDelta(text: string): void;
|
|
832
|
+
/** close the spoken turn (idempotent); stays audible until ALL audio arrived AND playback drains */
|
|
833
|
+
endSpeech(): void;
|
|
834
|
+
/** text of the reply cut by the last barge-in — consumed by the host to tell the model what
|
|
835
|
+
* the user did NOT hear. Cleared on read. */
|
|
836
|
+
takeInterruptedReply(): {
|
|
837
|
+
full: string;
|
|
838
|
+
heard: string;
|
|
839
|
+
} | null;
|
|
840
|
+
/** barge-in: stop audio NOW, cancel generation, reset for the user's utterance */
|
|
841
|
+
interrupt(): void;
|
|
842
|
+
stop(): void;
|
|
843
|
+
private words;
|
|
844
|
+
private novelWords;
|
|
845
|
+
private echoActive;
|
|
846
|
+
private handlePartial;
|
|
847
|
+
private handleUtterance;
|
|
848
|
+
private flushUtterance;
|
|
849
|
+
/** energy two-stage barge-in (heuristic tier only): spike over echo baseline → pause + confirm via STT */
|
|
850
|
+
private handleLevel;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
declare class SonioxSTTOptions {
|
|
854
|
+
auth: AuthProvider;
|
|
855
|
+
source: AudioSource;
|
|
856
|
+
model: string;
|
|
857
|
+
languageHints: string[];
|
|
858
|
+
}
|
|
859
|
+
declare class SonioxSTT {
|
|
860
|
+
options: SonioxSTTOptions;
|
|
861
|
+
private ws;
|
|
862
|
+
private stopped;
|
|
863
|
+
private sourceStarted;
|
|
864
|
+
onPartial: (text: string) => void;
|
|
865
|
+
onUtterance: (text: string, endpointAt: number) => void;
|
|
866
|
+
/** mic energy (RMS) per chunk — drives the energy-based heuristic barge-in tier */
|
|
867
|
+
onLevel: (rms: number) => void;
|
|
868
|
+
private finalText;
|
|
869
|
+
private partialText;
|
|
870
|
+
constructor(options?: Partial<SonioxSTTOptions>);
|
|
871
|
+
get usingAec(): boolean;
|
|
872
|
+
private connectWs;
|
|
873
|
+
start(): Promise<void>;
|
|
874
|
+
private handle;
|
|
875
|
+
reset(): void;
|
|
876
|
+
stop(): void;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
declare class CartesiaTTSOptions {
|
|
880
|
+
auth: AuthProvider;
|
|
881
|
+
voiceId: string;
|
|
882
|
+
model: string;
|
|
883
|
+
/** 'apiKey' (server/CLI) → `api_key=` URL param; 'token' (browser, BE-minted) → `access_token=`. */
|
|
884
|
+
authMode: 'apiKey' | 'token';
|
|
885
|
+
}
|
|
886
|
+
declare class CartesiaTTS {
|
|
887
|
+
options: CartesiaTTSOptions;
|
|
888
|
+
private ws;
|
|
889
|
+
private ctxSeq;
|
|
890
|
+
ctxId: string;
|
|
891
|
+
onAudio: (chunk: Uint8Array) => void;
|
|
892
|
+
onDone: () => void;
|
|
893
|
+
firstAudioAt: number;
|
|
894
|
+
constructor(options?: Partial<CartesiaTTSOptions>);
|
|
895
|
+
connect(): Promise<void>;
|
|
896
|
+
newContext(): string;
|
|
897
|
+
private frame;
|
|
898
|
+
speak(text: string, cont: boolean): void;
|
|
899
|
+
end(): void;
|
|
900
|
+
cancel(): void;
|
|
901
|
+
close(): void;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
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 };
|