@livx.cc/agentx 0.99.153 → 0.99.154
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.js +310 -67
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +64 -3
- package/dist/index.js +133 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10460,11 +10460,13 @@ function cueKind(text) {
|
|
|
10460
10460
|
return r.split(" ").some((w) => AGREE.has(w)) ? "agree" : null;
|
|
10461
10461
|
}
|
|
10462
10462
|
var ASIDES = {
|
|
10463
|
-
en: { agree: ["Oh yeah, definitely.", "Yeah, exactly.", "Right, yeah."], continue: [] },
|
|
10464
|
-
he: { agree: ["\u05DB\u05DF, \u05D1\u05D3\u05D9\u05D5\u05E7.", "\u05DB\u05DF, \u05DE\u05DE\u05E9.", "\u05E0\u05DB\u05D5\u05DF, \u05DB\u05DF."], continue: [] }
|
|
10463
|
+
en: { agree: ["Oh yeah, definitely.", "Yeah, exactly.", "Right, yeah."], continue: [], react: ["I know, right?", "Right? Wild.", "Yeah, crazy, right?"] },
|
|
10464
|
+
he: { agree: ["\u05DB\u05DF, \u05D1\u05D3\u05D9\u05D5\u05E7.", "\u05DB\u05DF, \u05DE\u05DE\u05E9.", "\u05E0\u05DB\u05D5\u05DF, \u05DB\u05DF."], continue: [], react: ["\u05E0\u05DB\u05D5\u05DF? \u05DE\u05D8\u05D5\u05E8\u05E3.", "\u05DB\u05DF, \u05DE\u05D8\u05D5\u05E8\u05E3.", "\u05DE\u05D8\u05D5\u05E8\u05E3, \u05E0\u05DB\u05D5\u05DF?"] }
|
|
10465
10465
|
};
|
|
10466
|
-
|
|
10467
|
-
|
|
10466
|
+
var REACT = /^(?:(?:oh|and|so|wait|but|ok|okay|yeah)\s+)*(?:wow|whoa|woah|really|seriously|no way|oh my god|omg|crazy|insane|amazing|unbelievable|what|are you serious|you're kidding|וואו|באמת|מה|מטורף|רצינית?|לא נכון)(?:\s+(?:wow|really|seriously|that's crazy|that's wild|no way|באמת|וואו))*$/u;
|
|
10467
|
+
var isReaction = (text) => REACT.test(norm2(text));
|
|
10468
|
+
function overlapAside(text, lang, avoid = "", pick = (n) => Math.floor(Math.random() * n), react = false) {
|
|
10469
|
+
const kind = react && REACT.test(norm2(text)) ? "react" : cueKind(text);
|
|
10468
10470
|
const l = new RegExp("\\p{Script=Hebrew}", "u").test(text) ? "he" : /[a-z]/i.test(text) ? "en" : lang;
|
|
10469
10471
|
const pool = kind && l ? ASIDES[l]?.[kind] : void 0;
|
|
10470
10472
|
if (!pool?.length) return null;
|
|
@@ -14132,8 +14134,8 @@ var SOFT_CUE = "~";
|
|
|
14132
14134
|
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(" "));
|
|
14133
14135
|
var isContent = (w) => w.length >= 4 && !STOP4.has(w);
|
|
14134
14136
|
function echoesHeard(line, heard) {
|
|
14135
|
-
const said = cueWords(heard).
|
|
14136
|
-
return cueWords(lineWords(line)).
|
|
14137
|
+
const said = cueWords(heard).filter(echoable).map(stem);
|
|
14138
|
+
return cueWords(lineWords(line)).filter(echoable).map(stem).some((w) => said.some((h) => h === w || Math.min(h.length, w.length) >= 4 && (h.startsWith(w) || w.startsWith(h))));
|
|
14137
14139
|
}
|
|
14138
14140
|
var stem = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})s$", "u"), "");
|
|
14139
14141
|
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(" "));
|
|
@@ -15448,6 +15450,15 @@ var VoiceCallOptions = class {
|
|
|
15448
15450
|
/** Writes that immediate answer (fastWorkReply). */
|
|
15449
15451
|
workReply;
|
|
15450
15452
|
workReplyBudgetMs = 1500;
|
|
15453
|
+
/** Live: the quick lane (fastQuickLane) owns the conversation — each turn it answers, acks + hands to MAIN, resumes a
|
|
15454
|
+
* cut answer, or stays quiet. Absent (or another mode): every turn goes to MAIN as before. */
|
|
15455
|
+
quick;
|
|
15456
|
+
/** Past this the turn goes to MAIN as before (the bridge covers it). */
|
|
15457
|
+
quickBudgetMs = 1800;
|
|
15458
|
+
/** The unsaid rest of MAIN's reply a barge just cut (a peek, like heardCut), else null — what a resume says. */
|
|
15459
|
+
cutRest;
|
|
15460
|
+
/** A resume said that rest: the host drops the cut (MAIN's history keeps the whole reply). */
|
|
15461
|
+
dropCut;
|
|
15451
15462
|
/** Host TTS (fill lane): resolves when played; `false` = could not play. */
|
|
15452
15463
|
speak = () => false;
|
|
15453
15464
|
/** Stop the in-flight fill line now (barge-in only). */
|
|
@@ -15489,6 +15500,7 @@ var VoiceCallOptions = class {
|
|
|
15489
15500
|
progressLeadMs = 1e3;
|
|
15490
15501
|
};
|
|
15491
15502
|
var VoiceCall = class {
|
|
15503
|
+
// a MAIN reply cut while audible: its heard part goes to the history at the next turn
|
|
15492
15504
|
constructor(options) {
|
|
15493
15505
|
this.options = options;
|
|
15494
15506
|
this.options = { ...new VoiceCallOptions(), ...options };
|
|
@@ -15551,6 +15563,11 @@ var VoiceCall = class {
|
|
|
15551
15563
|
progressTimer = null;
|
|
15552
15564
|
lastUserAt = -Infinity;
|
|
15553
15565
|
ended = false;
|
|
15566
|
+
/** The call as both lanes know it: the user's turns and what was said aloud (quick lines, MAIN's heard replies). */
|
|
15567
|
+
history = [];
|
|
15568
|
+
cutRest = "";
|
|
15569
|
+
// the unsaid rest of the last cut MAIN reply, until the next turn decides it
|
|
15570
|
+
cutTurn;
|
|
15554
15571
|
get o() {
|
|
15555
15572
|
return this.options;
|
|
15556
15573
|
}
|
|
@@ -15646,6 +15663,7 @@ var VoiceCall = class {
|
|
|
15646
15663
|
return;
|
|
15647
15664
|
case "text":
|
|
15648
15665
|
if (!ev.text) return;
|
|
15666
|
+
c.reply += ev.text;
|
|
15649
15667
|
c.marks.mainFirst ??= this.o.now();
|
|
15650
15668
|
c.marks.mainText ??= this.o.now();
|
|
15651
15669
|
if (!c.streamed) {
|
|
@@ -15722,6 +15740,7 @@ var VoiceCall = class {
|
|
|
15722
15740
|
} catch (e) {
|
|
15723
15741
|
log31.warn(`cancel threw: ${e.message}`);
|
|
15724
15742
|
}
|
|
15743
|
+
if (c?.worded && c.lane === "deep" && !c.cutRead) this.cutTurn = c;
|
|
15725
15744
|
if (c?.running) {
|
|
15726
15745
|
c.running = false;
|
|
15727
15746
|
this.o.abortTurn(c.id);
|
|
@@ -15730,6 +15749,7 @@ var VoiceCall = class {
|
|
|
15730
15749
|
}
|
|
15731
15750
|
/** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
|
|
15732
15751
|
async overlap(text) {
|
|
15752
|
+
if (this.o.mode === "live" && isReaction(text)) return "keep";
|
|
15733
15753
|
const d = await this.judge.judge(text);
|
|
15734
15754
|
if (d.verdict === "cut") this.barge();
|
|
15735
15755
|
return d.verdict;
|
|
@@ -15741,9 +15761,10 @@ var VoiceCall = class {
|
|
|
15741
15761
|
aside(text) {
|
|
15742
15762
|
const now4 = this.o.now();
|
|
15743
15763
|
if (now4 - this.lastAside.at < this.o.asideGapMs) return null;
|
|
15744
|
-
const line = overlapAside(text, this.lang, this.lastAside.text);
|
|
15764
|
+
const line = overlapAside(text, this.lang, this.lastAside.text, void 0, this.o.mode === "live");
|
|
15745
15765
|
if (!line) return null;
|
|
15746
15766
|
this.lastAside = { text: line, at: now4 };
|
|
15767
|
+
if (this.quickOn) this.history.push({ who: "user", text }, { who: "you", text: line });
|
|
15747
15768
|
this.o.onMetric({ name: "fill", kind: "aside", text: line, lang: this.lang });
|
|
15748
15769
|
return line;
|
|
15749
15770
|
}
|
|
@@ -15771,18 +15792,23 @@ var VoiceCall = class {
|
|
|
15771
15792
|
this.lang = l;
|
|
15772
15793
|
if (l) this.fill.setLanguage(l, true);
|
|
15773
15794
|
}
|
|
15795
|
+
get quickOn() {
|
|
15796
|
+
return this.o.mode === "live" && !!this.o.quick;
|
|
15797
|
+
}
|
|
15774
15798
|
onTurn(t) {
|
|
15775
15799
|
this.floor = "";
|
|
15776
15800
|
if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
|
|
15801
|
+
const prev = this.cur, quick = this.quickOn && !this.working && (t.kind === "new" || prev?.lane !== "deep");
|
|
15777
15802
|
const now4 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
15778
15803
|
const at = this.lastWordAt ?? this.firstFinalAt ?? now4;
|
|
15779
15804
|
const finalAt = this.finalAt || now4;
|
|
15780
15805
|
this.firstFinalAt = null;
|
|
15781
15806
|
this.lastWordAt = null;
|
|
15782
|
-
if (this.
|
|
15807
|
+
if (this.quickOn) this.logCut();
|
|
15808
|
+
if (prev) this.close(prev, t.replaces === prev.id ? "replaced" : void 0);
|
|
15783
15809
|
this.follow(t.text);
|
|
15784
15810
|
this.clearProgress();
|
|
15785
|
-
this.cur = { id: t.id, text: t.text, at, finalAt, lastWord, running:
|
|
15811
|
+
this.cur = { id: t.id, text: t.text, at, finalAt, lastWord, running: !quick, streamed: false, sounded: false, worded: false, done: false, marks: { sent: now4 }, closed: false, due: turnIntent(t.text) !== "closer", open: 0, tool: "", draft: "", drafting: false, draftAt: -Infinity, reply: "", ...this.quickOn ? { lane: quick ? "pending" : "deep" } : {} };
|
|
15786
15812
|
const early = this.earlyHeard;
|
|
15787
15813
|
this.earlyHeard = null;
|
|
15788
15814
|
if (early && early.at >= at) {
|
|
@@ -15791,9 +15817,99 @@ var VoiceCall = class {
|
|
|
15791
15817
|
}
|
|
15792
15818
|
this.progress.turn();
|
|
15793
15819
|
this.o.onMetric({ name: "turn", id: t.id, kind: t.kind, text: t.text });
|
|
15794
|
-
this.
|
|
15820
|
+
if (this.quickOn) {
|
|
15821
|
+
const last = this.history.at(-1);
|
|
15822
|
+
if (t.kind !== "new" && last?.who === "user") last.text = t.text;
|
|
15823
|
+
else this.history.push({ who: "user", text: t.text });
|
|
15824
|
+
}
|
|
15825
|
+
if (quick) return void this.quickTurn(this.cur, t);
|
|
15826
|
+
this.o.sendTurn(t.text, { id: t.id, ...t.replaces && (!this.quickOn || prev?.lane === "deep") ? { replaces: t.replaces } : {} });
|
|
15795
15827
|
if (t.kind === "new") this.fill.onUserTurn(t.text, now4 - at, this.o.heardCut?.() ?? void 0);
|
|
15796
15828
|
}
|
|
15829
|
+
/** A MAIN reply cut while it played: the history keeps the part heard; a resume may say the rest. */
|
|
15830
|
+
logCut() {
|
|
15831
|
+
const c = this.cutTurn;
|
|
15832
|
+
this.cutTurn = void 0;
|
|
15833
|
+
if (!c || c.cutRead) return;
|
|
15834
|
+
c.cutRead = true;
|
|
15835
|
+
this.cutRest = "";
|
|
15836
|
+
const heard = this.o.heardCut?.() ?? null;
|
|
15837
|
+
if (heard === null) return void this.logReply(c);
|
|
15838
|
+
if (c.logged) Object.assign(c.logged, { text: heard, cut: true });
|
|
15839
|
+
else this.history.push(c.logged = { who: "you", text: heard, cut: true });
|
|
15840
|
+
this.cutRest = this.o.cutRest?.() ?? "";
|
|
15841
|
+
}
|
|
15842
|
+
logReply(c) {
|
|
15843
|
+
if (c.lane !== "deep" || c.logged || !c.reply.trim()) return;
|
|
15844
|
+
this.history.push(c.logged = { who: "you", text: c.reply.replace(/\[[a-z ]+\]\s*/gi, "").trim() });
|
|
15845
|
+
}
|
|
15846
|
+
/** The quick lane owns this turn: it answers, acks and hands it to MAIN, resumes a cut answer, or stays quiet. A late
|
|
15847
|
+
* or unusable decision hands the turn to MAIN as before (the fill channel's bridge covers it). */
|
|
15848
|
+
async quickTurn(c, t) {
|
|
15849
|
+
const ac = new AbortController(), t0 = this.o.now(), lang = this.lang, rest = this.cutRest;
|
|
15850
|
+
c.ask = ac;
|
|
15851
|
+
const late = setTimeout(() => ac.abort(), this.o.quickBudgetMs);
|
|
15852
|
+
const mv = lang ? await this.o.quick({ history: this.history.slice(0, -1), heard: t.text, lang, rest }, ac.signal).catch((e) => {
|
|
15853
|
+
if (this.cur === c) log31.warn(`quick lane ${ac.signal.aborted ? `late (${this.o.quickBudgetMs}ms)` : `failed: ${e?.message ?? e}`} \u2014 deep lane`);
|
|
15854
|
+
return null;
|
|
15855
|
+
}).finally(() => clearTimeout(late)) : null;
|
|
15856
|
+
if (this.ended || this.cur !== c || c.closed) return;
|
|
15857
|
+
c.ask = void 0;
|
|
15858
|
+
this.o.onMetric({ name: "lane", id: c.id, kind: mv?.kind ?? "fallback", ms: Math.round(this.o.now() - t0), ...mv && "line" in mv && mv.line ? { text: mv.line } : mv?.kind === "deep" && mv.ack ? { text: mv.ack } : {} });
|
|
15859
|
+
const note = (n) => this.o.noteTurn?.(`[${n}]`);
|
|
15860
|
+
if (!mv || mv.kind === "deep") {
|
|
15861
|
+
c.lane = "deep";
|
|
15862
|
+
c.running = true;
|
|
15863
|
+
this.cutRest = "";
|
|
15864
|
+
const ack = mv?.kind === "deep" ? mv.ack : "", brief = mv?.kind === "deep" ? mv.brief : "";
|
|
15865
|
+
if (ack) {
|
|
15866
|
+
note(`You (the call's quick voice) already told them aloud: "${ack}". Do not acknowledge again \u2014 start with the answer itself.${brief && brief !== t.text ? ` It took their words to mean: ${brief}.` : ""}`);
|
|
15867
|
+
this.history.push({ who: "you", text: ack });
|
|
15868
|
+
}
|
|
15869
|
+
this.o.sendTurn(t.text, { id: t.id });
|
|
15870
|
+
if (!ack) return void this.fill.onUserTurn(t.text, this.o.now() - c.at, this.o.heardCut?.() ?? void 0);
|
|
15871
|
+
this.gate.replyStarted(c.id);
|
|
15872
|
+
if (await this.sayRetry(ack, "ack", c.id)) {
|
|
15873
|
+
this.o.show(ack, "ack");
|
|
15874
|
+
if (this.cur === c && c.running) this.beat(c);
|
|
15875
|
+
}
|
|
15876
|
+
return;
|
|
15877
|
+
}
|
|
15878
|
+
c.lane = "quick";
|
|
15879
|
+
if (mv.kind === "quiet") {
|
|
15880
|
+
c.due = false;
|
|
15881
|
+
return this.close(c, "silent");
|
|
15882
|
+
}
|
|
15883
|
+
const said = mv.kind === "resume" ? `${mv.line} ${rest}`.trim() : mv.line;
|
|
15884
|
+
this.gate.replyStarted(c.id);
|
|
15885
|
+
if (!await this.sayRetry(said, "reply", c.id)) return this.close(c, "silent");
|
|
15886
|
+
this.o.show(said, "reply");
|
|
15887
|
+
if (!c.worded) {
|
|
15888
|
+
c.worded = true;
|
|
15889
|
+
c.marks.mainAudio = this.lastAudibleAt;
|
|
15890
|
+
this.o.onMetric({ name: "first_word", id: c.id, ms: Math.round(this.lastAudibleAt - c.at), by: "quick" });
|
|
15891
|
+
}
|
|
15892
|
+
if (mv.kind === "resume") {
|
|
15893
|
+
this.cutRest = "";
|
|
15894
|
+
this.o.dropCut?.();
|
|
15895
|
+
this.history.push({ who: "you", text: rest });
|
|
15896
|
+
note(`They asked you to go on, and you continued your cut answer aloud: "${rest}". All of it has now been said.`);
|
|
15897
|
+
} else {
|
|
15898
|
+
this.history.push({ who: "you", text: said });
|
|
15899
|
+
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.`);
|
|
15900
|
+
}
|
|
15901
|
+
this.close(c, "answered");
|
|
15902
|
+
}
|
|
15903
|
+
/** say(), retried while the host's player is busy (up to 2s). */
|
|
15904
|
+
async sayRetry(line, kind, id) {
|
|
15905
|
+
for (let i = 0; i < 8; i++) {
|
|
15906
|
+
if (this.ended) return false;
|
|
15907
|
+
if (this.say(line, kind) !== false) return true;
|
|
15908
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
15909
|
+
}
|
|
15910
|
+
this.o.onMetric({ name: "drop", id, kind: `${kind} unplayed`, text: line });
|
|
15911
|
+
return false;
|
|
15912
|
+
}
|
|
15797
15913
|
onDrop(text, why) {
|
|
15798
15914
|
if (!this.gate.holding) {
|
|
15799
15915
|
this.firstFinalAt = null;
|
|
@@ -15817,7 +15933,7 @@ var VoiceCall = class {
|
|
|
15817
15933
|
this.o.onMetric({ name: "fill", kind, text, lang: this.lang });
|
|
15818
15934
|
if (kind !== "backchannel") this.progress.heard();
|
|
15819
15935
|
const c = this.cur && !this.cur.closed ? this.cur : void 0;
|
|
15820
|
-
const forTurn = !!c && (kind === "bridge" || kind === "progress" || kind === "filler" && c.running && !c.sounded);
|
|
15936
|
+
const forTurn = !!c && (kind === "bridge" || kind === "progress" || kind === "ack" || kind === "reply" || kind === "filler" && c.running && !c.sounded);
|
|
15821
15937
|
if (c && forTurn && c.marks.fill === void 0) {
|
|
15822
15938
|
c.marks.fill = this.o.now();
|
|
15823
15939
|
c.fillKind = kind;
|
|
@@ -15827,7 +15943,7 @@ var VoiceCall = class {
|
|
|
15827
15943
|
this.lastAudibleAt = this.o.now();
|
|
15828
15944
|
if (c && forTurn) {
|
|
15829
15945
|
c.marks.fillAudio ??= this.o.now();
|
|
15830
|
-
this.sounded(c, kind === "progress" ? "progress" : "fill");
|
|
15946
|
+
this.sounded(c, kind === "progress" ? "progress" : kind === "ack" || kind === "reply" ? "quick" : "fill");
|
|
15831
15947
|
}
|
|
15832
15948
|
return r;
|
|
15833
15949
|
}
|
|
@@ -15841,6 +15957,8 @@ var VoiceCall = class {
|
|
|
15841
15957
|
close(c, end) {
|
|
15842
15958
|
if (c.closed) return;
|
|
15843
15959
|
c.closed = true;
|
|
15960
|
+
c.ask?.abort();
|
|
15961
|
+
this.logReply(c);
|
|
15844
15962
|
c.end = c.worded ? "answered" : end ?? c.end ?? "silent";
|
|
15845
15963
|
if (!c.worded) this.o.onMetric({ name: "first_word", id: c.id, by: "main", kind: c.end });
|
|
15846
15964
|
const rel = (t) => t === void 0 ? void 0 : Math.round(t - c.at);
|
|
@@ -15877,17 +15995,13 @@ var VoiceCall = class {
|
|
|
15877
15995
|
const line = own || (this.o.mode === "live" ? "" : answer);
|
|
15878
15996
|
const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
|
|
15879
15997
|
const noted = `[The user said this on the call while you worked: "${t.text}".${line ? ` You answered aloud: "${line}".` : ""}${stop ? " That stopped the work." : ""} Take it into account; do not answer it again.]`;
|
|
15998
|
+
this.history.push({ who: "user", text: t.text });
|
|
15880
15999
|
if (line && !this.ended) {
|
|
15881
|
-
|
|
15882
|
-
if (i === 7) {
|
|
15883
|
-
this.o.onMetric({ name: "drop", id: t.id, kind: "aside unplayed", text: line });
|
|
15884
|
-
break;
|
|
15885
|
-
}
|
|
15886
|
-
await new Promise((r) => setTimeout(r, 250));
|
|
15887
|
-
}
|
|
16000
|
+
await this.sayRetry(line, "aside", t.id);
|
|
15888
16001
|
if (this.lastAudibleAt >= at) {
|
|
15889
16002
|
this.progress.note(line);
|
|
15890
16003
|
this.o.show(line, "aside");
|
|
16004
|
+
this.history.push({ who: "you", text: line });
|
|
15891
16005
|
}
|
|
15892
16006
|
} else if (!line) this.o.onMetric({ name: "drop", id: t.id, kind: "no aside line" });
|
|
15893
16007
|
if (stop) {
|
|
@@ -17475,6 +17589,13 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
17475
17589
|
held2 ??= ownCut();
|
|
17476
17590
|
return held2?.full ? cutHeard(held2) : null;
|
|
17477
17591
|
};
|
|
17592
|
+
call.options.cutRest = () => {
|
|
17593
|
+
held2 ??= ownCut();
|
|
17594
|
+
return held2?.full ? held2.full.slice(cutHeard(held2).length).trim() || null : null;
|
|
17595
|
+
};
|
|
17596
|
+
call.options.dropCut = () => {
|
|
17597
|
+
v.takeInterruptedReply();
|
|
17598
|
+
};
|
|
17478
17599
|
o.onPartial = (t) => {
|
|
17479
17600
|
if (live() && (own || !v.audible)) call.interim(t, performance.now(), v.usingAec);
|
|
17480
17601
|
onPartial(t);
|
|
@@ -17916,6 +18037,125 @@ ${o.persona}
|
|
|
17916
18037
|
return line || o.fallback;
|
|
17917
18038
|
}
|
|
17918
18039
|
|
|
18040
|
+
// src/voice/quickLane.ts
|
|
18041
|
+
init_logging();
|
|
18042
|
+
var log39 = forComponent("QuickLane");
|
|
18043
|
+
var SAY_WORDS = 30;
|
|
18044
|
+
var ACK_WORDS = 10;
|
|
18045
|
+
var ACKS = { en: ["On it.", "Sure, one sec.", "Okay, looking.", "Got it, checking."], he: ["\u05E8\u05D2\u05E2 \u05D0\u05D7\u05D3.", "\u05D0\u05D5\u05E7\u05D9\u05D9, \u05E9\u05E0\u05D9\u05D9\u05D4.", "\u05E9\u05E0\u05D9\u05D9\u05D4."] };
|
|
18046
|
+
function quickMove(raw, c) {
|
|
18047
|
+
const m = /^\s*(SAY|DEEP|RESUME|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
|
|
18048
|
+
if (!m) return null;
|
|
18049
|
+
const kind = m[1].toUpperCase(), body = m[2].trim();
|
|
18050
|
+
if (kind === "QUIET") return { kind: "quiet" };
|
|
18051
|
+
if (kind === "RESUME") {
|
|
18052
|
+
const l = sayLine(body, c.lang);
|
|
18053
|
+
return !c.rest ? null : GO_ON.test(c.heard) ? { kind: "resume", line: l.split(/\s+/).length <= 5 ? l : "" } : { kind: "quiet" };
|
|
18054
|
+
}
|
|
18055
|
+
if (kind === "DEEP") {
|
|
18056
|
+
const [ack = "", brief = ""] = body.split("|").map((s) => s.trim());
|
|
18057
|
+
const a = cleanLine(ack, c.lang, ACK_WORDS);
|
|
18058
|
+
const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
|
|
18059
|
+
const ok = a && !said.has(norm3(a)) && !RESULT_CLAIM_RE.test(a) && !new RegExp("\\p{N}", "u").test(a);
|
|
18060
|
+
return { kind: "deep", ack: ok ? a : (ACKS[c.lang] ?? []).find((x) => !said.has(norm3(x))) ?? "", brief };
|
|
18061
|
+
}
|
|
18062
|
+
const line = sayLine(body, c.lang);
|
|
18063
|
+
if (!line) return null;
|
|
18064
|
+
if (parrots(line, c.heard)) return { kind: "quiet" };
|
|
18065
|
+
if (c.history.some((h) => h.who === "you" && norm3(h.text) === norm3(line))) return { kind: "quiet" };
|
|
18066
|
+
const facts = unknownFacts(line, c), novel = novelWords(line, c);
|
|
18067
|
+
const unknown = facts.length || novel.length >= 2 ? [...facts, ...novel] : [];
|
|
18068
|
+
if (unknown.length) {
|
|
18069
|
+
log39.debug(`quick line "${line}" names ${unknown.join(", ")} \u2014 not in the call: deep lane`);
|
|
18070
|
+
return { kind: "deep", ack: "", brief: "" };
|
|
18071
|
+
}
|
|
18072
|
+
return { kind: "say", line };
|
|
18073
|
+
}
|
|
18074
|
+
function sayLine(s, lang) {
|
|
18075
|
+
const l = s.split("\n")[0].replace(/^["'“”«»]+|["'“”«»]+$/g, "").trim();
|
|
18076
|
+
const d = detectLanguage(l);
|
|
18077
|
+
const latinOnly = !new RegExp("\\p{L}", "u").test(l.replace(new RegExp("\\p{Script=Latin}", "gu"), "")), latinLang = fitsLanguage("ok", lang);
|
|
18078
|
+
return l && (d ? d === lang : fitsLanguage(l, lang) || latinOnly && latinLang) && l.split(/\s+/).length <= SAY_WORDS ? l : "";
|
|
18079
|
+
}
|
|
18080
|
+
function parrots(line, heard) {
|
|
18081
|
+
const h = new Set(norm3(heard).split(" ").filter(Boolean));
|
|
18082
|
+
const l = norm3(line).split(" ").filter((w) => w && !FILLER.has(w));
|
|
18083
|
+
return h.size <= 3 && l.length > 0 && l.every((w) => h.has(w));
|
|
18084
|
+
}
|
|
18085
|
+
var FILLER = new Set("oh ah uh um yeah yes so well".split(" "));
|
|
18086
|
+
function unknownFacts(line, c) {
|
|
18087
|
+
const known = norm3([c.heard, c.rest ?? "", ...c.history.map((h) => h.text)].join(" "));
|
|
18088
|
+
const knownSet = new Set(known.split(" "));
|
|
18089
|
+
const out = [];
|
|
18090
|
+
for (const s of line.split(/(?<=[.!?])\s+/)) {
|
|
18091
|
+
const ws = s.split(/\s+/);
|
|
18092
|
+
ws.forEach((w, i) => {
|
|
18093
|
+
const k = norm3(w);
|
|
18094
|
+
if (!k) return;
|
|
18095
|
+
const fact = new RegExp("\\p{N}", "u").test(k) || i > 0 && new RegExp("^\\p{Lu}", "u").test(w) && k !== "i" && !/^i'/.test(k);
|
|
18096
|
+
if (fact && !knownSet.has(k) && !knownSet.has(k.replace(/'s$/, ""))) out.push(w);
|
|
18097
|
+
});
|
|
18098
|
+
}
|
|
18099
|
+
return out;
|
|
18100
|
+
}
|
|
18101
|
+
function novelWords(line, c, within) {
|
|
18102
|
+
const st = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})(?:es|s)$", "u"), "");
|
|
18103
|
+
const known = new Set(norm3(within ?? [c.heard, c.rest ?? "", ...c.history.map((h) => h.text)].join(" ")).split(" ").map(st));
|
|
18104
|
+
return norm3(line).split(" ").filter((w) => isContent(w) && !SOCIAL.has(w)).filter((w) => within ? known.has(st(w)) : !known.has(st(w)));
|
|
18105
|
+
}
|
|
18106
|
+
var SOCIAL = new Set("thanks thank doing well good great fine help assist today glad sure right crazy wild sorry problem welcome talk later hear nice awesome pretty happy know okay cool stuff night morning evening love care chat again anything else there think sounds absolutely course totally really amazing exactly definitely listening ahead want need would could like going about what that this these those something someone tell more much maybe just wanna gonna kidding believe insane unreal huh yeah sounds fun hope busy pleasure great".split(" "));
|
|
18107
|
+
var GO_ON = new RegExp("(?<!\\p{L})(?:go on|go ahead|continue|keep going|carry on|you were saying|as you were|finish (?:that|it)|\u05D4\u05DE\u05E9\u05D9\u05DB\u05D9|\u05D4\u05DE\u05E9\u05DA|\u05EA\u05DE\u05E9\u05D9\u05DB\u05D9|\u05EA\u05DE\u05E9\u05D9\u05DA|\u05DB\u05DF,? \u05EA\u05DE\u05E9\u05D9\u05DB\u05D9)(?!\\p{L})", "iu");
|
|
18108
|
+
var HOLD = /^(?:(?:okay|ok|oh|um|uh|so|sorry|no)[,.]?\s+)*(?:wait|hold on|hang on|one sec(?:ond)?|just a sec(?:ond)?|give me a sec(?:ond)?|רגע|שנייה|חכי|חכה)(?:[,.!]?\s*(?:wait|hold on|hang on|a sec(?:ond)?|please|רגע))*[.!?…]*$/iu;
|
|
18109
|
+
var HOLDS = { en: ["Sure.", "Sure, take your time.", "No problem."], he: ["\u05D1\u05D8\u05D7.", "\u05D0\u05D9\u05DF \u05D1\u05E2\u05D9\u05D4."] };
|
|
18110
|
+
function holdLine(c) {
|
|
18111
|
+
if (!HOLD.test(c.heard.trim())) return "";
|
|
18112
|
+
const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
|
|
18113
|
+
return (HOLDS[c.lang] ?? []).find((x) => !said.has(norm3(x))) ?? "";
|
|
18114
|
+
}
|
|
18115
|
+
function fastQuickLane(ai, model, gender, persona = "", hedgeMs = 900) {
|
|
18116
|
+
return async (c, signal) => {
|
|
18117
|
+
if (c.rest && GO_ON.test(c.heard)) return { kind: "resume", line: "" };
|
|
18118
|
+
const hold = holdLine(c);
|
|
18119
|
+
if (hold) return { kind: "say", line: hold };
|
|
18120
|
+
const ask = async () => {
|
|
18121
|
+
const raw = await fastText(ai, { model, prompt: quickPrompt(c, gender, persona), signal, temperature: 0.4 });
|
|
18122
|
+
const mv = quickMove(raw, c);
|
|
18123
|
+
if (!mv) log39.debug(`quick lane: unusable "${raw.slice(0, 80)}"`);
|
|
18124
|
+
return mv;
|
|
18125
|
+
};
|
|
18126
|
+
let timer;
|
|
18127
|
+
const first = ask();
|
|
18128
|
+
const second = new Promise((res, rej) => {
|
|
18129
|
+
timer = setTimeout(() => ask().then(res, rej), hedgeMs);
|
|
18130
|
+
});
|
|
18131
|
+
try {
|
|
18132
|
+
return await Promise.any([first, second]);
|
|
18133
|
+
} finally {
|
|
18134
|
+
clearTimeout(timer);
|
|
18135
|
+
}
|
|
18136
|
+
};
|
|
18137
|
+
}
|
|
18138
|
+
function quickPrompt(c, gender, persona = "") {
|
|
18139
|
+
const hist = c.history.slice(-12).map((h) => `${h.who === "user" ? "Them" : "You"}: ${h.text.slice(0, 400)}${h.cut ? " \u2014(they cut you here)" : ""}`).join("\n");
|
|
18140
|
+
return `${persona ? `Who you are on this call:
|
|
18141
|
+
${persona.slice(0, 500)}
|
|
18142
|
+
|
|
18143
|
+
` : ""}You are the quick voice of a live phone call. A slower expert colleague works behind you: they use tools, the web and files and think things through. You answer at once.
|
|
18144
|
+
|
|
18145
|
+
The call so far:
|
|
18146
|
+
${hist || "(just started)"}
|
|
18147
|
+
|
|
18148
|
+
They just said: "${c.heard}"
|
|
18149
|
+
` + (c.rest ? `Your last answer was cut. Its unsaid rest: "${c.rest.slice(0, 300)}"
|
|
18150
|
+
` : "") + `
|
|
18151
|
+
Reply with exactly ONE line, one of:
|
|
18152
|
+
SAY: <your words> \u2014 greetings, chit-chat, a short reaction, a clarification, or restating/explaining something ALREADY said in this call. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
|
|
18153
|
+
DEEP: <a 2-8 word acknowledgement> | <what the colleague must do, names spelled right> \u2014 anything needing a lookup, current information, tools, files, or real thinking. The acknowledgement says you're on it ("Sure, checking Hacker News.") and never a result. The speech-to-text misspells names: fix them from context ("Haka News" \u2192 Hacker News).
|
|
18154
|
+
QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
|
|
18155
|
+
"Wait" / "hold on" with nothing new: a brief SAY ("Sure.") \u2014 no work for the colleague. Vary your words: never reuse an acknowledgement or reaction already said in this call.
|
|
18156
|
+
A reaction ("wow", "really?") gets a short fitting reply in your own words ("I know, right?"), never their word back. Never repeat what was already said. Speak ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
|
|
18157
|
+
}
|
|
18158
|
+
|
|
17919
18159
|
// cli/config.ts
|
|
17920
18160
|
import { homedir as homedir5 } from "os";
|
|
17921
18161
|
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
|
|
@@ -18063,7 +18303,7 @@ function applyOverlay(cfg, file) {
|
|
|
18063
18303
|
// cli/hooks-config.ts
|
|
18064
18304
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
18065
18305
|
init_platform();
|
|
18066
|
-
var
|
|
18306
|
+
var log40 = forComponent("hooks");
|
|
18067
18307
|
var escapeRegex = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
18068
18308
|
function ruleMatches(rule, toolName) {
|
|
18069
18309
|
if (!rule.tool || rule.tool === "*") return true;
|
|
@@ -18082,7 +18322,7 @@ function runCmd(rule, env) {
|
|
|
18082
18322
|
});
|
|
18083
18323
|
return { code: r.status ?? 1, out: ((r.stdout ?? "") + (r.stderr ?? "")).trim() };
|
|
18084
18324
|
} catch (e) {
|
|
18085
|
-
|
|
18325
|
+
log40.debug(`hook command failed: ${rule.command}`, e);
|
|
18086
18326
|
return { code: 1, out: String(e?.message ?? e) };
|
|
18087
18327
|
}
|
|
18088
18328
|
}
|
|
@@ -18190,7 +18430,7 @@ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as rea
|
|
|
18190
18430
|
import { homedir as homedir6 } from "os";
|
|
18191
18431
|
import { join as join11 } from "path";
|
|
18192
18432
|
init_platform();
|
|
18193
|
-
var
|
|
18433
|
+
var log41 = forComponent("session");
|
|
18194
18434
|
var globalDir = () => join11(homedir6(), ".agent", "sessions");
|
|
18195
18435
|
function indexLink(target, link2) {
|
|
18196
18436
|
try {
|
|
@@ -18253,7 +18493,7 @@ var SessionStore = class {
|
|
|
18253
18493
|
}
|
|
18254
18494
|
load(id) {
|
|
18255
18495
|
if (!this.safeId(id)) {
|
|
18256
|
-
|
|
18496
|
+
log41.debug(`rejecting unsafe session id: ${id}`);
|
|
18257
18497
|
return void 0;
|
|
18258
18498
|
}
|
|
18259
18499
|
const path = join11(this.dir, `${id}.json`);
|
|
@@ -18261,7 +18501,7 @@ var SessionStore = class {
|
|
|
18261
18501
|
try {
|
|
18262
18502
|
return JSON.parse(readFileSync8(path, "utf8"));
|
|
18263
18503
|
} catch (e) {
|
|
18264
|
-
|
|
18504
|
+
log41.debug(`unreadable session ${id} \u2014 ignoring`, e);
|
|
18265
18505
|
return void 0;
|
|
18266
18506
|
}
|
|
18267
18507
|
}
|
|
@@ -18274,7 +18514,7 @@ var SessionStore = class {
|
|
|
18274
18514
|
try {
|
|
18275
18515
|
metas.push(JSON.parse(readFileSync8(join11(this.dir, f), "utf8")).meta);
|
|
18276
18516
|
} catch (e) {
|
|
18277
|
-
|
|
18517
|
+
log41.debug(`skipping unreadable session file ${f}`, e);
|
|
18278
18518
|
}
|
|
18279
18519
|
}
|
|
18280
18520
|
return metas.sort((a, b) => b.updated - a.updated);
|
|
@@ -18706,7 +18946,7 @@ import { promisify } from "util";
|
|
|
18706
18946
|
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9 } from "fs";
|
|
18707
18947
|
import { homedir as homedir7 } from "os";
|
|
18708
18948
|
import { join as join12, resolve as resolve4, sep as sep3, parse as parsePath } from "path";
|
|
18709
|
-
var
|
|
18949
|
+
var log42 = forComponent("checkpoints");
|
|
18710
18950
|
var exec = promisify(execFile4);
|
|
18711
18951
|
var DEFAULT_EXCLUDE = [".agent/", ".git/", "node_modules/", "dist/", "build/", ".next/", "target/", ".venv/", "__pycache__/", "*.log"];
|
|
18712
18952
|
function isBroadRoot(p) {
|
|
@@ -18754,7 +18994,7 @@ var ShadowRepo = class {
|
|
|
18754
18994
|
writeFileSync6(join12(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
|
|
18755
18995
|
this.ready = true;
|
|
18756
18996
|
} catch (e) {
|
|
18757
|
-
|
|
18997
|
+
log42.debug(`git checkpoints unavailable for ${this.workTree}`, e);
|
|
18758
18998
|
this.ready = false;
|
|
18759
18999
|
}
|
|
18760
19000
|
return this.ready;
|
|
@@ -18765,7 +19005,7 @@ var ShadowRepo = class {
|
|
|
18765
19005
|
}
|
|
18766
19006
|
async commit(label, forced = []) {
|
|
18767
19007
|
await this.run("add", "-A");
|
|
18768
|
-
for (const p of forced) await this.run("add", "-f", "--", p).catch((e) =>
|
|
19008
|
+
for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log42.debug(`force-add failed: ${p}`, e));
|
|
18769
19009
|
await this.run("commit", "--allow-empty", "-q", "-m", label);
|
|
18770
19010
|
}
|
|
18771
19011
|
/** Inject the CURRENT (pre-edit) content of `paths` into the turn-open restore point by amending it.
|
|
@@ -18773,8 +19013,8 @@ var ShadowRepo = class {
|
|
|
18773
19013
|
* turn-boundary `add -A` would never have captured it. Amend (vs a new commit) keeps one restore
|
|
18774
19014
|
* point per turn, so the REPL's turn↔frame mapping stays intact. */
|
|
18775
19015
|
async amendForced(paths) {
|
|
18776
|
-
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) =>
|
|
18777
|
-
await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) =>
|
|
19016
|
+
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) => log42.debug(`force-capture failed: ${p}`, e));
|
|
19017
|
+
await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) => log42.debug("amend failed", e));
|
|
18778
19018
|
}
|
|
18779
19019
|
/** Commits on `ref`, oldest-first (canonical index space). */
|
|
18780
19020
|
async log(ref) {
|
|
@@ -18834,7 +19074,7 @@ var ShadowRepo = class {
|
|
|
18834
19074
|
await this.run("gc", "--auto", "-q").catch(() => {
|
|
18835
19075
|
});
|
|
18836
19076
|
} catch (e) {
|
|
18837
|
-
|
|
19077
|
+
log42.debug("checkpoint prune failed", e);
|
|
18838
19078
|
}
|
|
18839
19079
|
}
|
|
18840
19080
|
};
|
|
@@ -18902,7 +19142,7 @@ var GitCheckpoints = class {
|
|
|
18902
19142
|
use(sessionId) {
|
|
18903
19143
|
if (sessionId === this.session) return;
|
|
18904
19144
|
this.session = sessionId;
|
|
18905
|
-
if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) =>
|
|
19145
|
+
if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log42.debug("re-point failed", e));
|
|
18906
19146
|
}
|
|
18907
19147
|
async begin(label) {
|
|
18908
19148
|
if (!await this.start()) return;
|
|
@@ -18922,7 +19162,7 @@ var GitCheckpoints = class {
|
|
|
18922
19162
|
process.stderr.write(`\x1B[2m checkpoints: '${this.repos[i].root}' too large to snapshot in ${Math.round(this.options.opTimeoutMs / 1e3)}s \u2014 file rewind disabled here\x1B[0m
|
|
18923
19163
|
`);
|
|
18924
19164
|
} else {
|
|
18925
|
-
|
|
19165
|
+
log42.debug("checkpoint commit failed", e);
|
|
18926
19166
|
survivors.push(this.repos[i]);
|
|
18927
19167
|
survivorCaches.push(this.caches[i] ?? []);
|
|
18928
19168
|
}
|
|
@@ -18957,7 +19197,7 @@ var GitCheckpoints = class {
|
|
|
18957
19197
|
if (this.forced.has(abs)) continue;
|
|
18958
19198
|
this.forced.add(abs);
|
|
18959
19199
|
const i = this.repoIndexFor(abs);
|
|
18960
|
-
if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) =>
|
|
19200
|
+
if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log42.debug("amendForced failed", e));
|
|
18961
19201
|
}
|
|
18962
19202
|
}
|
|
18963
19203
|
};
|
|
@@ -20747,7 +20987,7 @@ import { spawnSync as spawnSync6 } from "child_process";
|
|
|
20747
20987
|
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
|
|
20748
20988
|
import { homedir as homedir8 } from "os";
|
|
20749
20989
|
import { join as join14 } from "path";
|
|
20750
|
-
var
|
|
20990
|
+
var log43 = forComponent("os-sched");
|
|
20751
20991
|
var OsScheduler = class {
|
|
20752
20992
|
options;
|
|
20753
20993
|
constructor(options) {
|
|
@@ -20809,7 +21049,7 @@ var OsScheduler = class {
|
|
|
20809
21049
|
}
|
|
20810
21050
|
}
|
|
20811
21051
|
} catch (e) {
|
|
20812
|
-
|
|
21052
|
+
log43.debug(`cancel ${id}`, e);
|
|
20813
21053
|
}
|
|
20814
21054
|
for (const f of [`${id}.json`, `${id}.sh`]) {
|
|
20815
21055
|
try {
|
|
@@ -20927,7 +21167,7 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync11, unlinkSync as unli
|
|
|
20927
21167
|
import { homedir as homedir9 } from "os";
|
|
20928
21168
|
import { join as join15 } from "path";
|
|
20929
21169
|
init_platform();
|
|
20930
|
-
var
|
|
21170
|
+
var log44 = forComponent("remote-trigger");
|
|
20931
21171
|
var TRIGGER_DIR = () => join15(homedir9(), ".agent", "triggers");
|
|
20932
21172
|
var sockPath = (sessionId, dir = TRIGGER_DIR()) => join15(dir, `${sessionId}.sock`);
|
|
20933
21173
|
var TriggerServer = class {
|
|
@@ -20965,13 +21205,13 @@ var TriggerServer = class {
|
|
|
20965
21205
|
conn.end(JSON.stringify({ ok: false, error: String(e) }) + "\n");
|
|
20966
21206
|
}
|
|
20967
21207
|
});
|
|
20968
|
-
conn.on("error", (e) =>
|
|
21208
|
+
conn.on("error", (e) => log44.debug("trigger conn error", e));
|
|
20969
21209
|
});
|
|
20970
|
-
this.server.on("error", (e) =>
|
|
21210
|
+
this.server.on("error", (e) => log44.debug("trigger server error", e));
|
|
20971
21211
|
this.server.listen(p);
|
|
20972
21212
|
this.path = p;
|
|
20973
21213
|
} catch (e) {
|
|
20974
|
-
|
|
21214
|
+
log44.debug("trigger server unavailable", e);
|
|
20975
21215
|
}
|
|
20976
21216
|
}
|
|
20977
21217
|
/** Re-bind on /resume (the session id changed). */
|
|
@@ -21103,7 +21343,7 @@ var strike = C("9");
|
|
|
21103
21343
|
var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
|
|
21104
21344
|
var mdPalette = { bold, dim, cyan, italic, strike, green, link };
|
|
21105
21345
|
var err = (s) => process.stderr.write(s);
|
|
21106
|
-
var
|
|
21346
|
+
var log45 = forComponent("cli");
|
|
21107
21347
|
var VERSION = (() => {
|
|
21108
21348
|
try {
|
|
21109
21349
|
return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
|
|
@@ -22007,7 +22247,7 @@ function turnCost(model, usage) {
|
|
|
22007
22247
|
const priced = model.startsWith("claude-code/") ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
|
|
22008
22248
|
return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
|
|
22009
22249
|
}
|
|
22010
|
-
async function evaluateGoal(ai, condition, transcript,
|
|
22250
|
+
async function evaluateGoal(ai, condition, transcript, log46) {
|
|
22011
22251
|
const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
|
|
22012
22252
|
const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
|
|
22013
22253
|
return text.slice(0, 600);
|
|
@@ -22027,7 +22267,7 @@ ${recent}` }
|
|
|
22027
22267
|
const match = r.content.match(/\{[\s\S]*\}/);
|
|
22028
22268
|
if (match) return JSON.parse(match[0]);
|
|
22029
22269
|
} catch (e) {
|
|
22030
|
-
|
|
22270
|
+
log46(dim(` (goal evaluator error: ${e?.message ?? e})
|
|
22031
22271
|
`));
|
|
22032
22272
|
}
|
|
22033
22273
|
return { met: false, reason: "evaluation unclear" };
|
|
@@ -22255,7 +22495,7 @@ function mcpAgentTools(mounted, opts) {
|
|
|
22255
22495
|
return tools;
|
|
22256
22496
|
}
|
|
22257
22497
|
async function closeMcp(mounted) {
|
|
22258
|
-
await Promise.all(mounted.map((m) => m.client.close().catch((e) =>
|
|
22498
|
+
await Promise.all(mounted.map((m) => m.client.close().catch((e) => log45.debug("mcp close failed", e))));
|
|
22259
22499
|
}
|
|
22260
22500
|
var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
|
|
22261
22501
|
function mentionRefs(line) {
|
|
@@ -22314,7 +22554,7 @@ async function expandMentions(fs, line) {
|
|
|
22314
22554
|
if (loaded.includes(ref) || missing.includes(ref)) continue;
|
|
22315
22555
|
if (ref.includes(":") && mcpMentionResolver) {
|
|
22316
22556
|
const body = await mcpMentionResolver(ref).catch((e) => {
|
|
22317
|
-
|
|
22557
|
+
log45.debug("mcp mention resolve failed", e);
|
|
22318
22558
|
return null;
|
|
22319
22559
|
});
|
|
22320
22560
|
if (body != null) {
|
|
@@ -22340,7 +22580,7 @@ ${await fs.readFile(path)}`);
|
|
|
22340
22580
|
${blocks.join("\n\n")}` : line, loaded, missing };
|
|
22341
22581
|
}
|
|
22342
22582
|
function applyTurnMode(agent, session, task, flags = {}, onModel) {
|
|
22343
|
-
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) =>
|
|
22583
|
+
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log45.debug(m) });
|
|
22344
22584
|
const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
|
|
22345
22585
|
if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
|
|
22346
22586
|
err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
|
|
@@ -22433,7 +22673,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
|
|
|
22433
22673
|
try {
|
|
22434
22674
|
store.save(session);
|
|
22435
22675
|
} catch (ex) {
|
|
22436
|
-
|
|
22676
|
+
log45.debug("mid-turn session flush failed", ex);
|
|
22437
22677
|
}
|
|
22438
22678
|
}
|
|
22439
22679
|
return origNotify(e);
|
|
@@ -22597,14 +22837,14 @@ var isCancelTeardown = (e) => {
|
|
|
22597
22837
|
function installCancelGuards(mounted) {
|
|
22598
22838
|
process.on("unhandledRejection", (e) => {
|
|
22599
22839
|
if (isCancelTeardown(e)) {
|
|
22600
|
-
|
|
22840
|
+
log45.debug("suppressed unhandledRejection (cursor stream cancel)", e);
|
|
22601
22841
|
return;
|
|
22602
22842
|
}
|
|
22603
|
-
|
|
22843
|
+
log45.error("unhandledRejection", e);
|
|
22604
22844
|
});
|
|
22605
22845
|
process.on("uncaughtException", (e) => {
|
|
22606
22846
|
if (isCancelTeardown(e)) {
|
|
22607
|
-
|
|
22847
|
+
log45.debug("suppressed uncaughtException (cursor stream cancel)", e);
|
|
22608
22848
|
return;
|
|
22609
22849
|
}
|
|
22610
22850
|
console.error(e);
|
|
@@ -22946,6 +23186,9 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
22946
23186
|
call = new VoiceCall({
|
|
22947
23187
|
ai,
|
|
22948
23188
|
...fast.options,
|
|
23189
|
+
// live: the quick lane owns the conversation, MAIN is its deep lane (#1331). Only here: its lines reach MAIN through
|
|
23190
|
+
// noteTurn, which a --channel-only host (Para) does not take yet.
|
|
23191
|
+
...args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0" ? { quick: fastQuickLane(ai, fast.options.fastModel, args.voiceGender, args.voicePersona) } : {},
|
|
22949
23192
|
show: (t, kind) => {
|
|
22950
23193
|
err("\r\x1B[0J" + dim(` \u21B3 ${kind === "progress" ? "\u22EF " : ""}${t}
|
|
22951
23194
|
`));
|
|
@@ -22995,7 +23238,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
22995
23238
|
editorRef?.abort();
|
|
22996
23239
|
}
|
|
22997
23240
|
} catch (e) {
|
|
22998
|
-
|
|
23241
|
+
log45.error("call turn failed", e);
|
|
22999
23242
|
} finally {
|
|
23000
23243
|
rec.running = false;
|
|
23001
23244
|
call?.main({ type: "done", id });
|
|
@@ -23145,7 +23388,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
23145
23388
|
try {
|
|
23146
23389
|
mkdirSync12(dir, { recursive: true });
|
|
23147
23390
|
} catch (e) {
|
|
23148
|
-
|
|
23391
|
+
log45.debug("paste image dir create failed", e);
|
|
23149
23392
|
}
|
|
23150
23393
|
const img = grabClipboardImage(dir, String(Date.now()));
|
|
23151
23394
|
return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
|
|
@@ -23258,7 +23501,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23258
23501
|
mkdirSync12(join16(cwd, ".agent"), { recursive: true });
|
|
23259
23502
|
appendFileSync2(histPath, line + "\n");
|
|
23260
23503
|
} catch (e) {
|
|
23261
|
-
|
|
23504
|
+
log45.debug("history write failed", e);
|
|
23262
23505
|
}
|
|
23263
23506
|
};
|
|
23264
23507
|
const ago = (t) => {
|
|
@@ -23330,7 +23573,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23330
23573
|
try {
|
|
23331
23574
|
store.save(session);
|
|
23332
23575
|
} catch (e) {
|
|
23333
|
-
|
|
23576
|
+
log45.debug("session save after rewind failed", e);
|
|
23334
23577
|
}
|
|
23335
23578
|
err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
|
|
23336
23579
|
`));
|
|
@@ -23365,7 +23608,7 @@ ${task}`;
|
|
|
23365
23608
|
bangContext.length = 0;
|
|
23366
23609
|
}
|
|
23367
23610
|
const delta = await refreshCatalogs().catch((e) => {
|
|
23368
|
-
|
|
23611
|
+
log45.debug("catalog refresh failed", e);
|
|
23369
23612
|
return "";
|
|
23370
23613
|
});
|
|
23371
23614
|
if (delta) {
|
|
@@ -23639,7 +23882,7 @@ ${task}`;
|
|
|
23639
23882
|
desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
|
|
23640
23883
|
run: async () => {
|
|
23641
23884
|
await refreshCatalogs().catch((e) => {
|
|
23642
|
-
|
|
23885
|
+
log45.debug("catalog refresh failed", e);
|
|
23643
23886
|
});
|
|
23644
23887
|
face.reprepare();
|
|
23645
23888
|
err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
|
|
@@ -24142,7 +24385,7 @@ ${task}`;
|
|
|
24142
24385
|
try {
|
|
24143
24386
|
for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
|
|
24144
24387
|
} catch (e) {
|
|
24145
|
-
|
|
24388
|
+
log45.debug(`loadAgents(${d}) failed`, e);
|
|
24146
24389
|
}
|
|
24147
24390
|
}
|
|
24148
24391
|
if (!seen.size) {
|
|
@@ -24230,7 +24473,7 @@ ${task}`;
|
|
|
24230
24473
|
}
|
|
24231
24474
|
if (idx >= 0) {
|
|
24232
24475
|
const old = mounted.splice(idx, 1)[0];
|
|
24233
|
-
await old.client.close().catch((e) =>
|
|
24476
|
+
await old.client.close().catch((e) => log45.debug("mcp close failed", e));
|
|
24234
24477
|
}
|
|
24235
24478
|
try {
|
|
24236
24479
|
const m = await mountMcpServer(name, conf);
|
|
@@ -24258,7 +24501,7 @@ ${task}`;
|
|
|
24258
24501
|
}
|
|
24259
24502
|
const m = mounted.splice(idx, 1)[0];
|
|
24260
24503
|
remountMcpTools();
|
|
24261
|
-
await m.client.close().catch((e) =>
|
|
24504
|
+
await m.client.close().catch((e) => log45.debug("mcp close failed", e));
|
|
24262
24505
|
err(dim(` removed "${name}"
|
|
24263
24506
|
`));
|
|
24264
24507
|
return;
|
|
@@ -24461,7 +24704,7 @@ ${task}`;
|
|
|
24461
24704
|
try {
|
|
24462
24705
|
return readdirSync4(join16(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
|
|
24463
24706
|
} catch (e) {
|
|
24464
|
-
|
|
24707
|
+
log45.debug("completion readdir failed", absDir, e);
|
|
24465
24708
|
return null;
|
|
24466
24709
|
}
|
|
24467
24710
|
};
|
|
@@ -24600,7 +24843,7 @@ ${out}
|
|
|
24600
24843
|
return;
|
|
24601
24844
|
}
|
|
24602
24845
|
await refreshCatalogs().catch((e) => {
|
|
24603
|
-
|
|
24846
|
+
log45.debug("catalog refresh failed", e);
|
|
24604
24847
|
});
|
|
24605
24848
|
const sk = skills.find((x) => x.name === name);
|
|
24606
24849
|
if (sk) {
|
|
@@ -24730,7 +24973,7 @@ ${out}
|
|
|
24730
24973
|
if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
|
|
24731
24974
|
const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
|
|
24732
24975
|
const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
|
|
24733
|
-
|
|
24976
|
+
log45.warn(`barge intent failed \u2014 model decides: ${e.message}`);
|
|
24734
24977
|
return void 0;
|
|
24735
24978
|
}) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
|
|
24736
24979
|
const cutIn = replaces ? replaces.cutIn : interjectNote;
|
|
@@ -25131,10 +25374,10 @@ function channelOptions(ai, model, gender) {
|
|
|
25131
25374
|
// 0: the reactive live path
|
|
25132
25375
|
pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
|
|
25133
25376
|
persona: process.env.AGENTX_CALL_PERSONA ?? "",
|
|
25134
|
-
onTree: (e) =>
|
|
25377
|
+
onTree: (e) => log45.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
|
|
25135
25378
|
onEvent: (e) => {
|
|
25136
|
-
if (e.moment)
|
|
25137
|
-
else
|
|
25379
|
+
if (e.moment) log45.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
|
|
25380
|
+
else log45.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
|
|
25138
25381
|
},
|
|
25139
25382
|
// Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
|
|
25140
25383
|
banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join16(homedir10(), ".agent", "cache", "channel-banks") }),
|
|
@@ -25228,7 +25471,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25228
25471
|
try {
|
|
25229
25472
|
store.save(session);
|
|
25230
25473
|
} catch (e) {
|
|
25231
|
-
|
|
25474
|
+
log45.warn("duplex session save failed", e);
|
|
25232
25475
|
}
|
|
25233
25476
|
};
|
|
25234
25477
|
const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
|
|
@@ -25268,7 +25511,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25268
25511
|
done2();
|
|
25269
25512
|
out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
|
|
25270
25513
|
}).catch((e) => {
|
|
25271
|
-
|
|
25514
|
+
log45.error("duplex turn failed", e);
|
|
25272
25515
|
done2();
|
|
25273
25516
|
out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
|
|
25274
25517
|
});
|