@livx.cc/agentx 0.99.152 → 0.99.153

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/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-BVmp2lze.js';
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-CR3xWWB_.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
@@ -10666,13 +10666,20 @@ var INTENT_ACK_OVER = {
10666
10666
  resume: ["agreement", "silent"],
10667
10667
  aside: []
10668
10668
  };
10669
- function interruptionNote(cut, intent) {
10669
+ function heardAt(cut) {
10670
+ const at = Math.min(cut.heard.length, cut.full.length);
10671
+ return /\S/.test(cut.full[at] ?? "") && /\S/.test(cut.full[at - 1] ?? "") ? cut.full.lastIndexOf(" ", at) + 1 : at;
10672
+ }
10673
+ function cutHeard(cut) {
10674
+ return cut.full.slice(0, heardAt(cut)).trim();
10675
+ }
10676
+ function interruptionNote(cut, intent, hold = true) {
10670
10677
  const full = cut.full.trim();
10671
- let at = Math.min(cut.heard.length, cut.full.length);
10672
- if (/\S/.test(cut.full[at] ?? "") && /\S/.test(cut.full[at - 1] ?? "")) at = cut.full.lastIndexOf(" ", at) + 1;
10678
+ const at = heardAt(cut);
10673
10679
  const heardWords = cut.full.slice(0, at).trim().split(/\s+/).filter(Boolean).length;
10674
10680
  const unheard = cut.full.slice(at).trim();
10675
- const landed = heardWords < 4 ? "They cut in almost at once \u2014 treat all of it as unsaid." : `They heard everything before this part. They missed the rest of it: "${unheard}".`;
10681
+ const lastWords = cut.full.slice(0, at).trim().split(/\s+/).slice(-8).join(" ");
10682
+ const landed = heardWords < 4 ? "They cut in almost at once \u2014 treat all of it as unsaid." : `They heard everything before this part. They missed the rest of it: "${unheard}". The last words they heard were "\u2026${lastWords}" \u2014 a "that"/"it"/"this" in their words means the thing those words were naming, never anything in the missed part.`;
10676
10683
  const how = {
10677
10684
  resume: "They did not ask anything new. Carry on with the part they missed \u2014 no restart, no apology.",
10678
10685
  aside: "It was an aside. Answer it briefly FIRST, then finish the part they missed, adjusted to anything they just said. Say each point once: skip whatever they already heard and whatever your answer just covered.",
@@ -10681,7 +10688,7 @@ function interruptionNote(cut, intent) {
10681
10688
  unknown: "Decide like a person would: if it was an aside, answer it and then finish your point; if they steered away, follow them and drop or adapt the rest."
10682
10689
  };
10683
10690
  return `
10684
- [the user interrupted you mid-speech. You were saying: "${full}" ${landed} ${how[intent ?? "unknown"]} Just talk, like a person picking the thread back up: never tell them what they heard or missed, never say where you were cut off, and never quote your earlier words back. If their words are still an unfinished fragment, call Hold instead of answering.]`;
10691
+ [the user interrupted you mid-speech. You were saying: "${full}" ${landed} ${how[intent ?? "unknown"]} Just talk, like a person picking the thread back up: never tell them what they heard or missed, never say where you were cut off, and never quote your earlier words back.` + (hold ? " If their words are still an unfinished fragment, call Hold instead of answering." : "") + "]";
10685
10692
  }
10686
10693
  var FRAME = "You are the instinct of a warm, attentive human in a live spoken conversation. Decide what a natural human would do THIS instant \u2014 the way people do without thinking. ";
10687
10694
  var acted = (what, r) => r === false ? `${what}_skipped` : what;
@@ -14125,9 +14132,12 @@ var SOFT_CUE = "~";
14125
14132
  var STOP4 = new Set("about after again also always been before being could does doing down even every from going have here into just know like look make many more most much must never only other over really right same should some still such sure take than that their them then there these they thing think this those through very want well were what when where which while will with would your yeah okay".split(" "));
14126
14133
  var isContent = (w) => w.length >= 4 && !STOP4.has(w);
14127
14134
  function echoesHeard(line, heard) {
14128
- const said = new Set(cueWords(heard));
14129
- return cueWords(lineWords(line)).some((w) => isContent(w) && said.has(w));
14135
+ const said = cueWords(heard).map(stem).filter(echoable);
14136
+ return cueWords(lineWords(line)).map(stem).filter(echoable).some((w) => said.some((h) => h === w || Math.min(h.length, w.length) >= 4 && (h.startsWith(w) || w.startsWith(h))));
14130
14137
  }
14138
+ var stem = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})s$", "u"), "");
14139
+ var SHORT_STOP = new Set("the and you are was for not but has had his her its our who why how can did get got let may one out see she two use way yes all any new now off old own say too him hey huh ooh wow yep".split(" "));
14140
+ var echoable = (w) => isContent(w) || w.length === 3 && !SHORT_STOP.has(w) && !new RegExp("^\\p{N}+$", "u").test(w);
14131
14141
  var leafKey = (line) => cueWords(lineWords(line)).join(" ");
14132
14142
  function parseNodes(list, lang, depth, maxBranches) {
14133
14143
  const out = [];
@@ -14741,6 +14751,8 @@ var SecondChannel = class {
14741
14751
  // live: this turn's ask leaf
14742
14752
  barged = false;
14743
14753
  // the user cut in since their last turn: that turn is a steer, not a story to react to
14754
+ said = "";
14755
+ // live: what the user heard the assistant say last (the cut's heard part, else the last reply)
14744
14756
  leafReady = Promise.resolve();
14745
14757
  // live: the turn-end leaf pick settled
14746
14758
  recent = [];
@@ -14957,8 +14969,9 @@ var SecondChannel = class {
14957
14969
  }
14958
14970
  }
14959
14971
  /** The user's final line was dispatched to the main agent (its words are the bridge's micro-context). */
14960
- onUserTurn(text, lastWordAgoMs = 0) {
14972
+ onUserTurn(text, lastWordAgoMs = 0, heardCut) {
14961
14973
  this.heard = text.trim();
14974
+ this.said = (heardCut ?? this.reply).trim();
14962
14975
  this.lastWordAgo = Math.max(0, lastWordAgoMs);
14963
14976
  this.floorWords = this.carried + words3(this.heard).length;
14964
14977
  this.lastUser = this.heard;
@@ -15265,12 +15278,14 @@ var SecondChannel = class {
15265
15278
  this.bridgeReady = Promise.resolve();
15266
15279
  this.noLine = "";
15267
15280
  if (!this.o.generate || !(this.ownWords || this.o.generateFor.includes("bridge")) || !this.lang || !this.heard) return;
15268
- const gen = this.gen, ac = new AbortController(), own = this.ownWords, heard = this.heard;
15269
- const ctx = { kind: "bridge", heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...own ? { ask: true } : {} };
15281
+ const gen = this.gen, ac = new AbortController(), own = this.ownWords;
15282
+ const said = own ? words3(this.said.replace(/\[[^\]]*\]/g, " ")).slice(-this.o.microWords).join(" ") : "", heard = `${this.heard} ${said}`;
15283
+ const ctx = { kind: "bridge", heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...own ? { ask: true } : {}, ...said ? { said, cut: this.barged } : {} };
15284
+ log30.debug(`bridge ctx: said=${JSON.stringify(ctx.said ?? "")} cut=${!!ctx.cut}`);
15270
15285
  this.bridgeReady = withBudget(this.o.generate(ctx, ac.signal), own ? this.o.bridgeBudgetMs : Math.max(this.o.generateBudgetMs, this.o.bridgeDelayMs), "bridge generate", ac).then((raw) => {
15271
15286
  const none = own && /^\s*none\b/i.test(raw ?? ""), text = none ? "" : cleanLine(raw ?? "", ctx.lang), echoes = !own || echoesHeard(text, heard);
15272
15287
  if (text && gen === this.gen && echoes) this.bridgeDraft = { gen, text };
15273
- else if (gen === this.gen) this.noLine = raw === null ? "fast model late or failed" : none ? "fast model: none" : !text ? "fast model line unusable" : "line names nothing heard";
15288
+ else if (gen === this.gen) this.noLine = raw === null ? "fast model late or failed" : none ? "fast model: none" : !text ? "fast model line unusable" : `line names nothing heard: "${text}"`;
15274
15289
  }).catch((e) => log30.debug(`bridge prefetch failed: ${e?.message ?? e}`));
15275
15290
  }
15276
15291
  async line(kind, react = true) {
@@ -15378,11 +15393,21 @@ function channelLine(line, kind) {
15378
15393
  const text = lineWords(line);
15379
15394
  return { type: "channel", kind, text, ...text === line ? {} : { speech: line } };
15380
15395
  }
15396
+ function askPrompt(c, gender) {
15397
+ const last = c.said ? c.said.split(/(?<=[.!?])\s+/).filter((x) => /\w/.test(x)).pop() : "";
15398
+ const said = !c.said ? "" : c.cut ? `You (the assistant) were saying: "\u2026${c.said}" \u2014 they cut you off there, so the last thing they heard was "${last}". Their "that"/"it" means THAT last thing.
15399
+ ` : `You (the assistant) last said: "\u2026${c.said}"
15400
+ `;
15401
+ return `A live voice call. ${said}The user just said: "${c.heard}"
15402
+ Your full answer takes a few seconds. Write ONE spoken line of 2-5 words in ${languageName(c.lang)} to say at once, in their or your own words:
15403
+ - they ask you to look up, check, find or do something \u2192 name the thing and say you are on it ("Hacker News, one sec.")
15404
+ - they ask about something you said ("that", "it", "who", "why") \u2192 echo the thing they mean as a short question ("the OpenAI one?", "the Postman thing?") or a quick reaction to it
15405
+ Never state a fact, a name or an answer that was not already said. If it is a closer, thanks, an ok/yes, small talk or a remark that needs no answer, write: none
15406
+ ${personaHint(gender)} Output only the line.`;
15407
+ }
15381
15408
  function fastLineGenerator(ai, model, gender) {
15382
15409
  return async (c, signal) => {
15383
- const prompt = c.ask ? `A live voice call. The user just said: "${c.heard}"
15384
- If this asks you to look up, check, find or do something that takes a while, write ONE spoken line of 2-5 words in ${languageName(c.lang)} that names the thing in their own words and says you are on it ("Hacker News, one sec."). If it is small talk, a statement, or something you can answer at once, write: none
15385
- ${personaHint(gender)} Output only the line.` : `You voice the tiny side-sounds of a live spoken conversation. Write ONE line of 1-5 words: ${KIND_HINT2[c.kind]}.
15410
+ const prompt = c.ask ? askPrompt(c, gender) : `You voice the tiny side-sounds of a live spoken conversation. Write ONE line of 1-5 words: ${KIND_HINT2[c.kind]}.
15386
15411
  ` + (c.react ? `Here the line may be ${REACT_HINT}.
15387
15412
  ` : "") + (c.tags ? `${TAG_HINT}
15388
15413
  ` : "") + `The user just said: "${c.heard}"
@@ -15417,6 +15442,9 @@ var VoiceCallOptions = class {
15417
15442
  * runs as MAIN's next turn. Not injected mid-run: that makes MAIN run again just to hear a remark. Absent: such a line
15418
15443
  * barges in as before. */
15419
15444
  noteTurn;
15445
+ /** What the user HEARD of MAIN's reply a barge just cut (a peek — the host still takes the cut for MAIN), else null:
15446
+ * a live bridge echoes what their "that" points at. */
15447
+ heardCut;
15420
15448
  /** Writes that immediate answer (fastWorkReply). */
15421
15449
  workReply;
15422
15450
  workReplyBudgetMs = 1500;
@@ -15764,7 +15792,7 @@ var VoiceCall = class {
15764
15792
  this.progress.turn();
15765
15793
  this.o.onMetric({ name: "turn", id: t.id, kind: t.kind, text: t.text });
15766
15794
  this.o.sendTurn(t.text, { id: t.id, ...t.replaces ? { replaces: t.replaces } : {} });
15767
- if (t.kind === "new") this.fill.onUserTurn(t.text, now4 - at);
15795
+ if (t.kind === "new") this.fill.onUserTurn(t.text, now4 - at, this.o.heardCut?.() ?? void 0);
15768
15796
  }
15769
15797
  onDrop(text, why) {
15770
15798
  if (!this.gate.holding) {
@@ -17433,10 +17461,19 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
17433
17461
  const { onPartial, onState, onBargeIn, onDiag } = o;
17434
17462
  let own = false;
17435
17463
  const take = v.takeInterruptedReply.bind(v);
17436
- v.takeInterruptedReply = () => {
17464
+ let held2;
17465
+ const ownCut = () => {
17437
17466
  const r = take();
17438
- if (!r || !call.spoke(r.full)) return r;
17439
- return r.queued.length ? { ...r, full: "", heard: "" } : null;
17467
+ return !r || !call.spoke(r.full) ? r : r.queued.length ? { ...r, full: "", heard: "" } : null;
17468
+ };
17469
+ v.takeInterruptedReply = () => {
17470
+ const r = held2 !== void 0 ? held2 : ownCut();
17471
+ held2 = void 0;
17472
+ return r;
17473
+ };
17474
+ call.options.heardCut = () => {
17475
+ held2 ??= ownCut();
17476
+ return held2?.full ? cutHeard(held2) : null;
17440
17477
  };
17441
17478
  o.onPartial = (t) => {
17442
17479
  if (live() && (own || !v.audible)) call.interim(t, performance.now(), v.usingAec);
@@ -17446,7 +17483,17 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
17446
17483
  if (live() && !own && s === "speaking") call.main({ type: "audio" });
17447
17484
  onState(s);
17448
17485
  };
17486
+ let filling = false;
17487
+ const beginSpeech = v.beginSpeech.bind(v);
17488
+ v.beginSpeech = ((...a) => {
17489
+ if (own && !filling && live()) {
17490
+ own = false;
17491
+ call.main({ type: "audio" }, v.player?.drainMs() ?? 0);
17492
+ }
17493
+ return beginSpeech(...a);
17494
+ });
17449
17495
  o.onBargeIn = (phase) => {
17496
+ held2 = void 0;
17450
17497
  if (live()) call.barge();
17451
17498
  onBargeIn(phase);
17452
17499
  };
@@ -17467,7 +17514,12 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
17467
17514
  if (!live() || v.audible) return false;
17468
17515
  if (kind === "backchannel") return speakBlip(v, text);
17469
17516
  own = true;
17470
- v.speakFiller(text);
17517
+ filling = true;
17518
+ try {
17519
+ v.speakFiller(text);
17520
+ } finally {
17521
+ filling = false;
17522
+ }
17471
17523
  return v.awaitIdle().finally(() => {
17472
17524
  own = false;
17473
17525
  });
@@ -17642,7 +17694,7 @@ function fakeVoiceParts(uttFile) {
17642
17694
  return { stt, tts, player };
17643
17695
  }
17644
17696
  function fakeTape(heardFile, saidFile) {
17645
- const CHAR = TTS_SAMPLE_RATE * 2 * 60 / 1e3;
17697
+ const CHAR = TTS_SAMPLE_RATE * 2 / 15;
17646
17698
  const makeTts = () => {
17647
17699
  const t = {
17648
17700
  connect() {
@@ -22926,10 +22978,11 @@ ${note}`;
22926
22978
  if (old?.before !== void 0) face.transcript.splice(old.before);
22927
22979
  if (rec.skip) return;
22928
22980
  const { reply: cut } = takeCut(voiceIO, true);
22929
- if (cut && keepHeard(face.transcript, cut)) voiceDiag?.push({ t: performance.now(), kind: "call_kept_heard", heard: cut.heard.length, full: cut.full.length });
22981
+ const cutNote = cut && keepHeard(face.transcript, cut) ? interruptionNote(cut, void 0, false) : "";
22982
+ if (cutNote) voiceDiag?.push({ t: performance.now(), kind: "call_kept_heard", heard: cut.heard.length, full: cut.full.length });
22930
22983
  rec.running = true;
22931
22984
  rec.before = face.transcript.length;
22932
- const note = greetNote;
22985
+ const note = cutNote + greetNote;
22933
22986
  greetNote = "";
22934
22987
  callReplyOpen = false;
22935
22988
  spoken = new SpokenFilter();