agent.libx.js 0.93.8 → 0.93.11
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/README.md +1 -1
- package/cli/cli.ts +117 -31
- package/dist/{Agent-B_xvSHlG.d.ts → Agent-Di1u5nH0.d.ts} +8 -1
- package/dist/cli.d.ts +8 -3
- package/dist/cli.js +344 -76
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +61 -21
- package/dist/index.js +227 -52
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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-
|
|
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-Di1u5nH0.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-Di1u5nH0.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';
|
|
@@ -572,12 +572,16 @@ declare function reflectOnRun(o: ReflectOptions): Promise<string | null>;
|
|
|
572
572
|
declare function loadInstructions(fs: IFilesystem, names?: string[]): Promise<string>;
|
|
573
573
|
|
|
574
574
|
/**
|
|
575
|
-
* DuplexAgent — voice-optimized
|
|
575
|
+
* DuplexAgent — voice-optimized three-tier conversational engine, composed on top of `Agent`.
|
|
576
576
|
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
577
|
+
* Three cognitive tiers (like a human brain):
|
|
578
|
+
* REFLEX — fast voice agent (streams instant replies, owns THE transcript, the only voice the
|
|
579
|
+
* user hears). Handles simple questions, routes complex work to Act or Think.
|
|
580
|
+
* ACT — standard worker (Sonnet-class). Full tools, file access, shell. The hands.
|
|
581
|
+
* THINK — premium reasoning (Opus-class). Deep analysis, architecture, hard problems. The brain.
|
|
582
|
+
*
|
|
583
|
+
* Workers are spawned per escalation via `Act`/`Think` tools. Results are pushed back as
|
|
584
|
+
* `[task <id> completed] …` events and re-voiced by the reflex — push, not poll.
|
|
581
585
|
*
|
|
582
586
|
* Host events (via the open HostEvent union): the voice agent's standard `text_delta` stream,
|
|
583
587
|
* plus `task_started` / `task_progress` / `task_done` / `task_error` / `task_cancelled`.
|
|
@@ -592,16 +596,20 @@ interface TaskRecord {
|
|
|
592
596
|
/** Settles when the worker finished AND its completion was processed. Never rejects. */
|
|
593
597
|
promise: Promise<void>;
|
|
594
598
|
}
|
|
599
|
+
type WorkerTier = 'act' | 'think';
|
|
595
600
|
declare class DuplexAgentOptions {
|
|
596
|
-
/** Any ai.libx.js AIClient — shared by
|
|
601
|
+
/** Any ai.libx.js AIClient — shared by all tiers (routed by model). */
|
|
597
602
|
ai: ChatLike;
|
|
598
|
-
/** The WORKER's filesystem. If omitted the worker keeps Agent's jailed-disk-at-cwd default. */
|
|
603
|
+
/** The WORKER's filesystem (act + think). If omitted the worker keeps Agent's jailed-disk-at-cwd default. */
|
|
599
604
|
fs?: IFilesystem;
|
|
600
|
-
|
|
601
|
-
|
|
605
|
+
reflexModel: string;
|
|
606
|
+
actModel: string;
|
|
607
|
+
/** Premium reasoning model. Set to `false` to disable the Think tier entirely. */
|
|
608
|
+
thinkModel: string | false;
|
|
602
609
|
/** Escape hatches merged over the derived per-agent options. */
|
|
603
|
-
|
|
604
|
-
|
|
610
|
+
reflexOptions?: Partial<AgentOptions>;
|
|
611
|
+
actOptions?: Partial<AgentOptions>;
|
|
612
|
+
thinkOptions?: Partial<AgentOptions>;
|
|
605
613
|
/** Receives the voice text_delta stream + task lifecycle events. */
|
|
606
614
|
host?: HostBridge;
|
|
607
615
|
/** How many recent transcript messages are rendered into a worker's brief. */
|
|
@@ -609,7 +617,7 @@ declare class DuplexAgentOptions {
|
|
|
609
617
|
/** Voice register: 'neutral' = clean spoken style; 'conversational' = human-like — fillers,
|
|
610
618
|
* backchannels, impulsive first reactions before content (mimics real duplex conversation). */
|
|
611
619
|
voiceStyle: 'neutral' | 'conversational';
|
|
612
|
-
/** Awaited BEFORE a
|
|
620
|
+
/** Awaited BEFORE a worker spawns — open a per-task checkpoint frame, audit, etc.
|
|
613
621
|
* (post-spawn would race the worker's first edits). */
|
|
614
622
|
onTaskStart?: (id: string, label: string) => void | Promise<void>;
|
|
615
623
|
/** Re-voice throttled worker progress asides ('[task t1 progress] …') so long tasks aren't dead
|
|
@@ -634,8 +642,8 @@ declare class DuplexAgentOptions {
|
|
|
634
642
|
}
|
|
635
643
|
declare const VOICE_SYSTEM_PROMPT: string;
|
|
636
644
|
/**
|
|
637
|
-
* The duplex orchestrator. `send()` enqueues a user turn on the
|
|
638
|
-
*
|
|
645
|
+
* The duplex orchestrator. `send()` enqueues a user turn on the reflex agent; `Act`/`Think`
|
|
646
|
+
* spawn detached workers whose completions enqueue re-voice turns. A promise-chain
|
|
639
647
|
* mutex serializes all voice turns so streams never interleave, and completions that
|
|
640
648
|
* pile up while the voice is busy are coalesced into a single re-voice turn.
|
|
641
649
|
*/
|
|
@@ -657,7 +665,7 @@ declare class DuplexAgent {
|
|
|
657
665
|
constructor(options?: Partial<DuplexAgentOptions>);
|
|
658
666
|
/** Resolve memory tools + inject index into voice system prompt (once). */
|
|
659
667
|
private initMemory;
|
|
660
|
-
/** One user turn: the voice agent streams the reply (and may
|
|
668
|
+
/** One user turn: the voice agent streams the reply (and may Act/Think). Serialized with re-voice turns. */
|
|
661
669
|
send(content: MessageContent): Promise<RunResult>;
|
|
662
670
|
/** Resolve when all queued voice turns AND all in-flight worker tasks have settled (tests, graceful shutdown). */
|
|
663
671
|
idle(): Promise<void>;
|
|
@@ -666,7 +674,10 @@ declare class DuplexAgent {
|
|
|
666
674
|
private notify;
|
|
667
675
|
/** Queue a `[task …]` event for re-voicing. Events arriving while the voice is busy coalesce into ONE turn. */
|
|
668
676
|
private queueRevoice;
|
|
669
|
-
/** The worker's brief: the
|
|
677
|
+
/** The worker's brief: the Act/Think args + a STATIC text snapshot of the recent conversation.
|
|
678
|
+
* Act briefs get a self-verify footer — the worker's report is trusted without review, so it
|
|
679
|
+
* must check its own work before reporting (nearly free under prompt caching; measured honest:
|
|
680
|
+
* it does NOT fix one-shot logic bugs — see mind/10). Think tasks are pure reasoning — no footer. */
|
|
670
681
|
private buildBrief;
|
|
671
682
|
/** Spawn a detached worker for task `id`; its settlement notifies + enqueues the re-voice turn. */
|
|
672
683
|
private spawnWorker;
|
|
@@ -684,13 +695,22 @@ declare class DuplexAgent {
|
|
|
684
695
|
private onWorkerSettled;
|
|
685
696
|
private onWorkerFailed;
|
|
686
697
|
private failTask;
|
|
687
|
-
|
|
698
|
+
/** Live-switch the think tier: `false` disables (removes the Think tool from the voice agent),
|
|
699
|
+
* a model id enables (adds the tool if missing). The system-prompt THINK_SLOT text is frozen at
|
|
700
|
+
* construction — the tool's own description carries the routing guidance, so a live enable works;
|
|
701
|
+
* dispatch()'s think→act fallback covers any straggler calls after a live disable. */
|
|
702
|
+
setThinkModel(model: string | false): void;
|
|
703
|
+
/** User/programmatic spawn: the CLI's /act and /think commands. Returns the task id. */
|
|
704
|
+
dispatch(brief: string, tier?: WorkerTier, label?: string): Promise<string>;
|
|
705
|
+
private actTool;
|
|
706
|
+
private thinkTool;
|
|
688
707
|
private taskStatusTool;
|
|
689
|
-
/** Sub-100ms read-only lookups the voice may do itself — everything else stays
|
|
708
|
+
/** Sub-100ms read-only lookups the voice may do itself — everything else stays Act-only.
|
|
690
709
|
* fs-only (no shell; the engine is VFS-abstracted): time, git branch (.git/HEAD read), ls, file
|
|
691
710
|
* head. Output is hard-capped so a lookup can never bloat the skinny voice context. */
|
|
692
711
|
private quickLookTool;
|
|
693
712
|
private answerTaskTool;
|
|
713
|
+
private holdTool;
|
|
694
714
|
private cancelTaskTool;
|
|
695
715
|
}
|
|
696
716
|
|
|
@@ -838,6 +858,13 @@ declare class VoiceEngineOptions {
|
|
|
838
858
|
* letters, mid-thought pauses), the next utterance MERGES instead of dispatching a truncated one
|
|
839
859
|
* ("E-L-Y." / "A."). Costs this much latency per turn; 0 disables. */
|
|
840
860
|
utteranceMergeMs: number;
|
|
861
|
+
/** Extended merge window (ms) for utterances that look incomplete (trailing conjunction/filler).
|
|
862
|
+
* Gives the user time to finish their thought without triggering a model call. */
|
|
863
|
+
incompleteMergeMs: number;
|
|
864
|
+
/** Filler phrase spoken when holding for an incomplete utterance ('' disables). */
|
|
865
|
+
holdFiller: string;
|
|
866
|
+
/** Called when the engine holds an incomplete utterance (host can render a visual cue). */
|
|
867
|
+
onHold: () => void;
|
|
841
868
|
/** heuristic (non-AEC) energy barge-in tuning */
|
|
842
869
|
bargeRmsMult: number;
|
|
843
870
|
bargeRmsFloor: number;
|
|
@@ -897,6 +924,8 @@ declare class VoiceEngine {
|
|
|
897
924
|
full: string;
|
|
898
925
|
heard: string;
|
|
899
926
|
} | null;
|
|
927
|
+
/** Speak a short filler phrase without starting a model turn (stays in listening mode after). */
|
|
928
|
+
speakFiller(text: string): void;
|
|
900
929
|
/** barge-in: stop audio NOW, cancel generation, reset for the user's utterance */
|
|
901
930
|
interrupt(): void;
|
|
902
931
|
stop(): void;
|
|
@@ -910,6 +939,9 @@ declare class VoiceEngine {
|
|
|
910
939
|
* longer ones on count. */
|
|
911
940
|
private genuine;
|
|
912
941
|
private handlePartial;
|
|
942
|
+
private static readonly TRAIL_RE;
|
|
943
|
+
/** The utterance sounds like the user paused mid-thought (trailing conjunction/filler/comma). */
|
|
944
|
+
private looksIncomplete;
|
|
913
945
|
private handleUtterance;
|
|
914
946
|
private flushUtterance;
|
|
915
947
|
private get overlapCapable();
|
|
@@ -968,6 +1000,12 @@ declare class CartesiaTTS {
|
|
|
968
1000
|
onAudio: (chunk: Uint8Array) => void;
|
|
969
1001
|
onDone: () => void;
|
|
970
1002
|
firstAudioAt: number;
|
|
1003
|
+
/** Circuit breaker: consecutive error count + down flag. */
|
|
1004
|
+
private consecutiveErrors;
|
|
1005
|
+
private down;
|
|
1006
|
+
private probeTimer;
|
|
1007
|
+
private static readonly CB_THRESHOLD;
|
|
1008
|
+
private static readonly CB_PROBE_MS;
|
|
971
1009
|
constructor(options?: Partial<CartesiaTTSOptions>);
|
|
972
1010
|
private closed;
|
|
973
1011
|
private connecting;
|
|
@@ -980,7 +1018,9 @@ declare class CartesiaTTS {
|
|
|
980
1018
|
speak(text: string, cont: boolean): void;
|
|
981
1019
|
end(): void;
|
|
982
1020
|
cancel(): void;
|
|
1021
|
+
private startProbe;
|
|
1022
|
+
private stopProbe;
|
|
983
1023
|
close(): void;
|
|
984
1024
|
}
|
|
985
1025
|
|
|
986
|
-
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 };
|
|
1026
|
+
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, type WorkerTier, 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 };
|