@livx.cc/agentx 0.99.144 → 0.99.145
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/dist/cli.d.ts +1 -1
- package/dist/cli.js +29 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel--Iv3ZQ69.d.ts → secondChannel-BFPgXN2z.d.ts} +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@ agentx --resume <id> "…" # resume a specific session
|
|
|
121
121
|
- **Raise, don't guess** (`AskUserQuestion` + `finishReason: 'needs_input'`) — when a decision is genuinely the user's, the agent asks. Interactively that's an arrow-select prompt. **Headless** (`-p`, piped, no TTY) there's nobody to prompt, so instead of blocking on a prompt no one can see — or, worse, "proceeding with best judgment" — the run **stops and hands the question to its caller**: exit code `2`, a yellow `? needs input` footer, and `{finishReason:'needs_input', question:{…}, sessionId}` in `--output-format json`. The transcript is preserved, so the caller answers and continues (`--resume <id> -p "<answer>"`) instead of re-running. A delegated agent silently deciding something that was never its to decide is the failure this closes.
|
|
122
122
|
- **Tab-completion** — `Tab` completes `/<command>` names and `@<path>` file/dir references (descends subdirs, dotfiles hidden unless typed) straight from the working tree.
|
|
123
123
|
- **Voice call (duplex v3)** — `agentx --call --voice` (also what interactive `--duplex`/`--duplex-v2`/`--voice` run now; `AGENTX_DUPLEX_V1=1` keeps the reflex engine below for one release): the main agent (`-m`, full tools, real history) hears the user's exact words and answers every turn; a fast model (`--voice-model`, default Claude Haiku) only covers the wait — backchannels, fillers, bridges and tool-progress lines — and has no path into the history. `VoiceCall` (`src/voice/call.ts`, exported) is the host-agnostic core: `TurnGate` holds mid-phrase finals, merges re-finals, drops duplicates and a second goodbye; `Progress` speaks "checking the board…" during long tool runs.
|
|
124
|
-
- **Fill channel for host apps** — `agentx --channel-only --input-format stream-json --output-format stream-json` hosts a `VoiceCall` behind NDJSON for an app whose MAIN is its own agent: stdin `{type:'final', text, sttId?}`, `{type:'main', ev}` (MAIN's start/text/tool/tool_done/audio/done/error), `{type:'interim'|'pause'|'barge'|'overlap'}`; stdout `{type:'turn', id, text, replaces?}` (run MAIN on it), `{type:'abort', id}`, `{type:'channel', kind, text}
|
|
124
|
+
- **Fill channel for host apps** — `agentx --channel-only --input-format stream-json --output-format stream-json` hosts a `VoiceCall` behind NDJSON for an app whose MAIN is its own agent: stdin `{type:'final', text, sttId?}`, `{type:'main', ev}` (MAIN's start/text/tool/tool_done/audio/done/error), `{type:'interim'|'pause'|'barge'|'overlap'}`; stdout `{type:'turn', id, text, replaces?}` (run MAIN on it), `{type:'abort', id}`, `{type:'channel', kind, text, speech?}` (`speech`: what to play when it differs: tagged; `text` is '' for a sound alone). The v2 inputs (`user`/`text`/`agent_state`) still work.
|
|
125
125
|
- **Duplex mode** — `agentx --duplex` runs the full standard REPL (slash commands, sessions, postures, rewind, MCP) with the three-tier engine driving turns: a fast voice model (`--voice-model`, default `groq/openai/gpt-oss-120b`) answers every line instantly and delegates real work to background workers built with the same wiring as a normal run (fs mode, permissions, MCP); worker activity shows as dim chrome and results are re-voiced when ready. Switch any tier live with `/model` (opens a reflex/act/think picker), or the `/voice-model` · `/think-model` shortcuts. `/tasks` lists background tasks, inspects a task's live output tail, and cancels a running one from a picker (Esc mid-turn cancels the foreground turn; Esc again at the idle prompt cancels running workers).
|
|
126
126
|
- **Headless duplex for host apps** — `agentx --voice --input-format stream-json --output-format stream-json` runs the same duplex engine behind an NDJSON pipe, for an app that owns its own mic/TTS (the Bare browser uses it). stdin: `{type:'user', text, id?, replaces?, cut?}` (`cut` = the host voice engine's `takeInterruptedReply()`, so "heard up to" / parked deliveries work exactly as in the CLI), `{type:'barge'}`, `{type:'cancel', task}`, `{type:'exit'}`. stdout: reflex `text`/`thinking` deltas, worker `speak` utterances, `filler`, `task` lifecycle events, `turn_done`, `revoice_done`, `exit`. `--append-system-prompt` goes to the workers, `--voice-system-prompt` to the voice model.
|
|
127
127
|
- **MCP servers** — declare `mcpServers: { name: { command, args } | { url } }` in config and they're auto-mounted at startup (in parallel, with an optional `mountTimeoutMs` deadline so one slow/dead server never blocks the rest): the client does the JSON-RPC handshake (stdio or HTTP) + `tools/list`, and the discovered tools appear as `mcp__<name>__<tool>` in `/tools` (inspect with `/mcp`). A bad server is logged and skipped, never blocking the agent. For large tool sets, **deferred mode** (`makeMcpToolSearch` / `mountMcpDeferred`) exposes just two bounded tools (`ToolSearch` + `McpCall`) instead of N defs — dodging the provider tool-cap and improving selection accuracy; the CLI applies this automatically past 12 mounted tools (a 42-tool server was costing ~80k tok/turn in schema alone), and permission rules written against the real `mcp__<name>__<tool>` names still match through `McpCall`. **`mountMcpCatalog`** goes further: a cached, hash-keyed catalog + lazy connect means a turn that uses no MCP tool opens **zero** connections, and one that uses a tool connects exactly that server — latency scales with tools-used, not servers-configured. A down server is **negative-cached** (`failureCooldownMs`) so it never re-floors a later turn at the deadline. For zero turn-path latency even on a cold process, call **`warmMcpCatalog`** at boot + on a timer (off-turn discovery) and mount with **`{ discover: 'cache-only' }`** — the turn then never synchronously connects: it serves the warmed catalog and discovers any miss in the background. **Slow tools are jobs, not timeouts**: `timeoutMs` (default 30s) bounds protocol requests (`initialize`, `tools/list`) only; a `tools/call` still running after the soft foreground timeout (`foregroundMs.mcp`, 30s) returns `[still running] … background job job-N` while the request keeps going, and its result is delivered when it lands. The client sends a `progressToken` and reads progress over stdio and incrementally over HTTP/SSE; a call is cancelled (`notifications/cancelled`) only by `JobKill`, the stuck-job reaper, or its hard cap `callTimeoutMs` (per server, default 30 min).
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { w as RouterState, H as Hooks, c as AgentOptions, x as RunResult, f as ChatUsage, R as ReasoningEffort, d as ChannelMode, b as Agent } from './secondChannel
|
|
2
|
+
import { w as RouterState, H as Hooks, c as AgentOptions, x as RunResult, f as ChatUsage, R as ReasoningEffort, d as ChannelMode, b as Agent } from './secondChannel-BFPgXN2z.js';
|
|
3
3
|
import { IFilesystem } from '@livx.cc/wcli/core';
|
|
4
4
|
import { M as Message, U as UserQuestion, H as HostBridge, c as ContentPart, o as MessageContent } from './tools-DwfeF8VQ.js';
|
|
5
5
|
|
package/dist/cli.js
CHANGED
|
@@ -10459,7 +10459,16 @@ function fitsLanguage(line, lang) {
|
|
|
10459
10459
|
}
|
|
10460
10460
|
var norm3 = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}' ]/gu, "").replace(/\s+/g, " ").trim();
|
|
10461
10461
|
function cleanLine(s, lang, maxWords = 6) {
|
|
10462
|
-
const
|
|
10462
|
+
const first = s.trim().split("\n")[0];
|
|
10463
|
+
const tags = [...first.matchAll(LINE_TAG)].map((m) => `[${m[1].toLowerCase()}]`).filter((t, i, a) => a.indexOf(t) === i).join(" ");
|
|
10464
|
+
const raw = first.replace(LINE_TAG, " ").trim();
|
|
10465
|
+
if (tags && !/[\p{L}\p{N}]/u.test(raw)) return /laughter|gasp/.test(tags) ? tags : "";
|
|
10466
|
+
const words4 = cleanWords(raw, lang, maxWords);
|
|
10467
|
+
return words4 && tags ? `${tags} ${words4}` : words4;
|
|
10468
|
+
}
|
|
10469
|
+
var LINE_TAG = /\[(laughter|gasp|quiet)\]/gi;
|
|
10470
|
+
var lineWords = (line) => line.replace(LINE_TAG, " ").trim();
|
|
10471
|
+
function cleanWords(raw, lang, maxWords) {
|
|
10463
10472
|
const l = raw.replace(/^[-*•\d.)\s]+/, "").replace(/^["'“”«»]+|["'“”«»]+$/g, "").replace(new RegExp("^\\p{L}+:\\s*", "u"), "").trim();
|
|
10464
10473
|
if (!l || isLeakSuspect(raw) || isLeakSuspect(l)) {
|
|
10465
10474
|
if (l) log23.debug(`line "${raw}" reads as meta \u2014 rejected`);
|
|
@@ -13992,7 +14001,7 @@ var SecondChannel = class {
|
|
|
13992
14001
|
}
|
|
13993
14002
|
if (this.o.generate && this.o.generateFor.includes(kind) && (kind !== "backchannel" || react)) {
|
|
13994
14003
|
const ac = new AbortController();
|
|
13995
|
-
const ctx = { kind, heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...kind === "backchannel" && this.o.reactionGapMs ? { react: true } : {} };
|
|
14004
|
+
const ctx = { kind, heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...kind === "backchannel" && this.o.reactionGapMs ? { react: true } : {}, ...kind === "backchannel" && this.o.mode === "live" ? { tags: true } : {} };
|
|
13996
14005
|
const raw = await withBudget(this.o.generate(ctx, ac.signal), this.o.generateBudgetMs, `${kind} generate`);
|
|
13997
14006
|
if (raw === null) ac.abort();
|
|
13998
14007
|
const text = cleanLine(raw ?? "", this.lang);
|
|
@@ -14028,8 +14037,9 @@ var SecondChannel = class {
|
|
|
14028
14037
|
if (kind === "backchannel") this.bcTimes.push(this.lastAt);
|
|
14029
14038
|
if (kind === "bridge") this.bridged = true;
|
|
14030
14039
|
this.recent = [...this.recent, text].slice(-this.o.avoidLines);
|
|
14031
|
-
this.live = text
|
|
14032
|
-
this.
|
|
14040
|
+
this.live = lineWords(text);
|
|
14041
|
+
const words4 = this.live;
|
|
14042
|
+
if (words4) this.o.show(words4, kind);
|
|
14033
14043
|
const p = Promise.resolve(r).then(() => {
|
|
14034
14044
|
}, (e) => {
|
|
14035
14045
|
log28.warn(`channel line playback failed: ${e?.message ?? e}`);
|
|
@@ -14069,10 +14079,16 @@ var KIND_HINT2 = {
|
|
|
14069
14079
|
bridge: 'a neutral one-moment cue while the answer is prepared ("let me see\u2026", "one sec\u2026") \u2014 never the start of a statement or opinion ("the thing is", "well actually")'
|
|
14070
14080
|
};
|
|
14071
14081
|
var REACT_HINT = 'a short reaction to their LAST words instead: feeling ("oh no", "ha, nice", "ugh"), surprise ("wait, really?", "huh"), a light laugh if they joke or laugh ("ha!"), or an echo of their key word ("the deploy?") \u2014 still never asks for an answer or takes the turn; if nothing there deserves a reaction, a plain "mm-hm"';
|
|
14082
|
+
var TAG_HINT = 'Real listeners often react without words: the line may be, or begin with, [laughter] or [gasp], and [quiet] before words breathes them under the voice ("[gasp]", "[laughter]", "[gasp] [quiet] no way"). Use a sound when it fits what they said.';
|
|
14083
|
+
function channelLine(line, kind) {
|
|
14084
|
+
const text = lineWords(line);
|
|
14085
|
+
return { type: "channel", kind, text, ...text === line ? {} : { speech: line } };
|
|
14086
|
+
}
|
|
14072
14087
|
function fastLineGenerator(ai, model, gender) {
|
|
14073
14088
|
return async (c, signal) => {
|
|
14074
14089
|
const prompt = `You voice the tiny side-sounds of a live spoken conversation. Write ONE line of 1-5 words: ${KIND_HINT2[c.kind]}.
|
|
14075
14090
|
` + (c.react ? `Here the line may be ${REACT_HINT}.
|
|
14091
|
+
` : "") + (c.tags ? `${TAG_HINT}
|
|
14076
14092
|
` : "") + `The user just said: "${c.heard}"
|
|
14077
14093
|
The assistant is: ${c.state}.
|
|
14078
14094
|
` + (c.avoid.length ? `Do not reuse any of: ${c.avoid.map((a) => `"${a}"`).join(", ")}.
|
|
@@ -23467,7 +23483,10 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
23467
23483
|
});
|
|
23468
23484
|
if (args.voiceSystemPrompt) dx.voice.options.systemPrompt += "\n\n" + args.voiceSystemPrompt;
|
|
23469
23485
|
let scTurn = 0;
|
|
23470
|
-
const sc = args.duplexV2 ? makeSecondChannel(ai, dx.options.reflexModel, args.channelMode, {
|
|
23486
|
+
const sc = args.duplexV2 ? makeSecondChannel(ai, dx.options.reflexModel, args.channelMode, { speak: (line, kind) => {
|
|
23487
|
+
out(channelLine(line, kind));
|
|
23488
|
+
return true;
|
|
23489
|
+
} }) : void 0;
|
|
23471
23490
|
const store = new SessionStore(cwd);
|
|
23472
23491
|
const session = startSession(args, store, dx.voice, cwd);
|
|
23473
23492
|
persist = () => {
|
|
@@ -23539,11 +23558,13 @@ async function channelServe(args, ai, cfg) {
|
|
|
23539
23558
|
mode: args.channelMode,
|
|
23540
23559
|
gender: args.voiceGender ?? "",
|
|
23541
23560
|
channel: channelOptions(ai, process.env.AGENTX_CHANNEL_MODEL || model, args.voiceGender),
|
|
23542
|
-
speak: () =>
|
|
23543
|
-
|
|
23561
|
+
speak: (line, kind) => {
|
|
23562
|
+
out(channelLine(line, kind));
|
|
23563
|
+
return true;
|
|
23564
|
+
},
|
|
23565
|
+
// the host plays {type:'channel'} lines: `speech` keeps the tags, `text` shows
|
|
23544
23566
|
hostAudio: true,
|
|
23545
23567
|
// …and says when one really plays ({type:'heard'}) — a line its player drops never counts as sound
|
|
23546
|
-
show: (text, kind) => out({ type: "channel", kind, text }),
|
|
23547
23568
|
sendTurn: (text, o) => out({ type: "turn", id: o.id, text, ...o.replaces ? { replaces: o.replaces } : {} }),
|
|
23548
23569
|
abortTurn: (id) => out({ type: "abort", id }),
|
|
23549
23570
|
onMetric: (m) => {
|