@livx.cc/agentx 0.99.155 → 0.99.156

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/index.d.ts CHANGED
@@ -1699,9 +1699,12 @@ interface QuickContext {
1699
1699
  /** The unsaid rest of an answer the user just cut ('' = none). */
1700
1700
  rest?: string;
1701
1701
  }
1702
- type QuickMove = {
1702
+ type QuickMove =
1703
+ /** `end`: a farewell to someone ending the call — the host hangs up once it has played. */
1704
+ {
1703
1705
  kind: 'say';
1704
1706
  line: string;
1707
+ end?: true;
1705
1708
  } | {
1706
1709
  kind: 'deep';
1707
1710
  ack: string;
@@ -1810,7 +1813,7 @@ interface TurnTimeline {
1810
1813
  end?: 'answered' | 'cut' | 'replaced' | 'silent';
1811
1814
  }
1812
1815
  interface CallMetric {
1813
- name: 'first_sound' | 'first_word' | 'turn' | 'drop' | 'hold' | 'fill' | 'lang' | 'timeline' | 'lane';
1816
+ name: 'first_sound' | 'first_word' | 'turn' | 'drop' | 'hold' | 'fill' | 'lang' | 'timeline' | 'lane' | 'hangup';
1814
1817
  id?: string;
1815
1818
  /** ms from the user's last word (see TurnTimeline) */
1816
1819
  ms?: number;
@@ -1843,6 +1846,9 @@ declare class VoiceCallOptions {
1843
1846
  /** Live: the quick lane (fastQuickLane) owns the conversation — each turn it answers, acks + hands to MAIN, resumes a
1844
1847
  * cut answer, or stays quiet. Absent (or another mode): every turn goes to MAIN as before. */
1845
1848
  quick?: QuickDecider;
1849
+ /** The quick lane said a farewell to someone ending the call (QuickMove `end`): the host hangs up once that line has
1850
+ * played (as Para's [[hangup]] marker does for MAIN). The call takes no more turns after it. */
1851
+ hangUp?: () => void;
1846
1852
  /** Past this the turn goes to MAIN as before (the bridge covers it). */
1847
1853
  quickBudgetMs: number;
1848
1854
  /** The unsaid rest of MAIN's reply a barge just cut (a peek, like heardCut), else null — what a resume says. */
@@ -1979,7 +1985,7 @@ declare class VoiceCall {
1979
1985
  private quickTurn;
1980
1986
  /** The quick lane's answer became audible at `at`: the turn's first word, and it is answered. */
1981
1987
  private quickWorded;
1982
- /** say(), retried while the host's player is busy (up to 2s). */
1988
+ /** say(), retried while the host's player is busy (`tries` × 250ms: 2s). */
1983
1989
  private sayRetry;
1984
1990
  private onDrop;
1985
1991
  /** Every fill/progress line passes here: only in the turn's known language, never after the call ended. */
package/dist/index.js CHANGED
@@ -14046,9 +14046,17 @@ var ProgressOptions = class {
14046
14046
  now = () => performance.now();
14047
14047
  };
14048
14048
  function argsHint(args) {
14049
- if (!args || typeof args !== "object") return typeof args === "string" ? args.slice(0, 40) : "";
14050
- const s = Object.values(args).find((v) => typeof v === "string" && v.trim());
14051
- return typeof s === "string" ? s.trim().replace(/\s+/g, " ").slice(0, 40) : "";
14049
+ const s = !args || typeof args !== "object" ? args : Object.values(args).find((v) => typeof v === "string" && v.trim());
14050
+ return typeof s === "string" ? urlWords(s.trim()).replace(/\s+/g, " ").slice(0, 40).trim() : "";
14051
+ }
14052
+ function urlWords(s) {
14053
+ if (!/^https?:\/\/\S+$/i.test(s)) return s;
14054
+ try {
14055
+ const u = new URL(s), host = u.hostname.replace(/^www\./, "").split(".").slice(0, -1).filter((p) => p.length > 2);
14056
+ return [...host, ...decodeURIComponent(u.pathname).split(/[/._-]+/)].filter((w) => new RegExp("\\p{L}{2}", "u").test(w) && !/^(?:html?|php|aspx?|index)$/i.test(w)).join(" ");
14057
+ } catch {
14058
+ return s;
14059
+ }
14052
14060
  }
14053
14061
  var Progress = class {
14054
14062
  constructor(options) {
@@ -14131,13 +14139,17 @@ var Progress = class {
14131
14139
  return null;
14132
14140
  }), late]).finally(() => clearTimeout(t));
14133
14141
  const l = cleanLine(raw ?? "", lang, 5);
14134
- if (!l || about && !echoesHeard(l, hint) || RESULT_CLAIM_RE.test(l) || HE_RESULT_CLAIM.test(l) || this.said.has(norm3(l)) || this.streamed) return "";
14142
+ const why = raw === null ? "late or failed" : !l ? `unusable "${raw}"` : about && !echoesHeard(l, `${hint} ${about}`) ? `names nothing of "${hint}": "${l}"` : RESULT_CLAIM_RE.test(l) || HE_RESULT_CLAIM.test(l) ? `claims a result: "${l}"` : this.said.has(norm3(l)) ? `repeat: "${l}"` : this.streamed ? "reply streamed" : "";
14143
+ if (why) {
14144
+ log30.debug(`no line for ${tool || "(no tool)"}: ${why}`);
14145
+ return "";
14146
+ }
14135
14147
  return l;
14136
14148
  }
14137
14149
  };
14138
14150
  function fastProgressGenerator(ai, model, gender) {
14139
14151
  return async (tool, hint, lang, signal, avoid = []) => {
14140
- const prompt = `An assistant on a live voice call is running the tool "${tool}"${hint ? ` (about: "${hint}")` : ""}. Write ONE spoken line of 2-5 words, in ${languageName(lang)}, saying what it is doing right now (like "checking the board\u2026"). ${hint ? 'Name what it works on the way a person would say it ("looking up that Astra post\u2026"), never a string of its keywords ("scanning Astra weights\u2026"). ' : ""}${avoid.length ? `It already said ${avoid.map((a) => `"${a}"`).join(", ")}: say something new, a different angle on the same work. ` : ""}Never state a result or a finding. ${personaHint(gender)} Output only the line.`;
14152
+ const prompt = `An assistant on a live voice call is ${tool ? `running the tool "${tool}"` : "working on a request"}${hint ? ` (about: "${hint}")` : ""}. Write ONE spoken line of 2-5 words, in ${languageName(lang)}, saying what it is doing right now (like "checking the board\u2026"). ${hint ? 'Name what it works on the way a person would say it ("looking up that Astra post\u2026"), never a string of its keywords ("scanning Astra weights\u2026"). ' : ""}${avoid.length ? `It already said ${avoid.map((a) => `"${a}"`).join(", ")}: say something new, a different angle on the same work. ` : ""}Never state a result or a finding. ${personaHint(gender)} Output only the line.`;
14141
14153
  return fastText(ai, { model, prompt, signal });
14142
14154
  };
14143
14155
  }
@@ -15074,6 +15086,9 @@ var VoiceCallOptions = class {
15074
15086
  /** Live: the quick lane (fastQuickLane) owns the conversation — each turn it answers, acks + hands to MAIN, resumes a
15075
15087
  * cut answer, or stays quiet. Absent (or another mode): every turn goes to MAIN as before. */
15076
15088
  quick;
15089
+ /** The quick lane said a farewell to someone ending the call (QuickMove `end`): the host hangs up once that line has
15090
+ * played (as Para's [[hangup]] marker does for MAIN). The call takes no more turns after it. */
15091
+ hangUp;
15077
15092
  /** Past this the turn goes to MAIN as before (the bridge covers it). */
15078
15093
  quickBudgetMs = 1800;
15079
15094
  /** The unsaid rest of MAIN's reply a barge just cut (a peek, like heardCut), else null — what a resume says. */
@@ -15159,7 +15174,9 @@ var VoiceCall = class {
15159
15174
  cancel: () => o.cancel(),
15160
15175
  now: o.now
15161
15176
  });
15162
- this.progress = new Progress({ ...o.mode === "live" ? { templates: {}, generateBudgetMs: 1500, gapMs: 5e3 } : {}, ...ai ? { generate: fastProgressGenerator(ai, o.fastModel, o.gender) } : {}, gender: o.gender, now: o.now, ...o.progress });
15177
+ const po = { ...o.mode === "live" ? { templates: {}, generateBudgetMs: 1500, gapMs: 5e3 } : {}, ...ai ? { generate: fastProgressGenerator(ai, o.fastModel, o.gender) } : {}, gender: o.gender, now: o.now, ...o.progress };
15178
+ if (o.mode === "live") po.stageRepeatMs ??= po.gapMs;
15179
+ this.progress = new Progress(po);
15163
15180
  this.judge = new OverlapJudge({ ...ai ? { model: overlapModelFor(ai) } : {}, now: o.now });
15164
15181
  this.gate = new TurnGate({
15165
15182
  now: o.now,
@@ -15550,8 +15567,10 @@ var VoiceCall = class {
15550
15567
  }
15551
15568
  const said = mv.kind === "resume" ? `${mv.line} ${cutSentence([...this.history].reverse().find((h) => h.who === "you" && h.cut)?.text ?? "")} ${rest}`.replace(/\s+/g, " ").trim() : mv.line;
15552
15569
  this.gate.replyStarted(c.id);
15553
- if (!await this.sayRetry(said, "reply", c.id)) return this.close(c, "silent");
15554
- this.o.show(said, "reply");
15570
+ const end = mv.kind === "say" && !!mv.end;
15571
+ const played = await this.sayRetry(said, "reply", c.id, end ? 240 : 8);
15572
+ if (!played && !end) return this.close(c, "silent");
15573
+ if (played) this.o.show(said, "reply");
15555
15574
  if (mv.kind === "resume") {
15556
15575
  this.cutRest = "";
15557
15576
  this.o.dropCut?.();
@@ -15561,6 +15580,17 @@ var VoiceCall = class {
15561
15580
  this.history.push({ who: "you", text: said });
15562
15581
  note(`On the call they said "${t.text}" and you (the call's quick voice) answered aloud: "${said}". Already said \u2014 do not repeat it.`);
15563
15582
  }
15583
+ if (end) {
15584
+ this.o.onMetric({ name: "hangup", id: c.id, text: said });
15585
+ if (played && (!this.o.hostAudio || c.worded)) this.quickWorded(c, this.lastAudibleAt);
15586
+ this.end();
15587
+ try {
15588
+ this.o.hangUp?.();
15589
+ } catch (e) {
15590
+ log32.warn(`hangUp threw: ${e.message}`);
15591
+ }
15592
+ return;
15593
+ }
15564
15594
  if (this.o.hostAudio && !c.worded) {
15565
15595
  c.quickWord = true;
15566
15596
  return;
@@ -15577,9 +15607,9 @@ var VoiceCall = class {
15577
15607
  }
15578
15608
  this.close(c, "answered");
15579
15609
  }
15580
- /** say(), retried while the host's player is busy (up to 2s). */
15581
- async sayRetry(line, kind, id) {
15582
- for (let i = 0; i < 8; i++) {
15610
+ /** say(), retried while the host's player is busy (`tries` × 250ms: 2s). */
15611
+ async sayRetry(line, kind, id, tries = 8) {
15612
+ for (let i = 0; i < tries; i++) {
15583
15613
  if (this.ended) return false;
15584
15614
  if (this.say(line, kind) !== false) return true;
15585
15615
  await new Promise((r) => setTimeout(r, 250));