@livx.cc/agentx 0.99.152 → 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.d.ts +1 -1
- package/dist/cli.js +383 -87
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +69 -5
- package/dist/index.js +171 -32
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel-BVmp2lze.d.ts → secondChannel-CR3xWWB_.d.ts} +7 -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;
|
|
@@ -10666,13 +10668,20 @@ var INTENT_ACK_OVER = {
|
|
|
10666
10668
|
resume: ["agreement", "silent"],
|
|
10667
10669
|
aside: []
|
|
10668
10670
|
};
|
|
10669
|
-
function
|
|
10671
|
+
function heardAt(cut) {
|
|
10672
|
+
const at = Math.min(cut.heard.length, cut.full.length);
|
|
10673
|
+
return /\S/.test(cut.full[at] ?? "") && /\S/.test(cut.full[at - 1] ?? "") ? cut.full.lastIndexOf(" ", at) + 1 : at;
|
|
10674
|
+
}
|
|
10675
|
+
function cutHeard(cut) {
|
|
10676
|
+
return cut.full.slice(0, heardAt(cut)).trim();
|
|
10677
|
+
}
|
|
10678
|
+
function interruptionNote(cut, intent, hold = true) {
|
|
10670
10679
|
const full = cut.full.trim();
|
|
10671
|
-
|
|
10672
|
-
if (/\S/.test(cut.full[at] ?? "") && /\S/.test(cut.full[at - 1] ?? "")) at = cut.full.lastIndexOf(" ", at) + 1;
|
|
10680
|
+
const at = heardAt(cut);
|
|
10673
10681
|
const heardWords = cut.full.slice(0, at).trim().split(/\s+/).filter(Boolean).length;
|
|
10674
10682
|
const unheard = cut.full.slice(at).trim();
|
|
10675
|
-
const
|
|
10683
|
+
const lastWords = cut.full.slice(0, at).trim().split(/\s+/).slice(-8).join(" ");
|
|
10684
|
+
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
10685
|
const how = {
|
|
10677
10686
|
resume: "They did not ask anything new. Carry on with the part they missed \u2014 no restart, no apology.",
|
|
10678
10687
|
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 +10690,7 @@ function interruptionNote(cut, intent) {
|
|
|
10681
10690
|
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
10691
|
};
|
|
10683
10692
|
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
|
|
10693
|
+
[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
10694
|
}
|
|
10686
10695
|
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
10696
|
var acted = (what, r) => r === false ? `${what}_skipped` : what;
|
|
@@ -14125,9 +14134,12 @@ var SOFT_CUE = "~";
|
|
|
14125
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(" "));
|
|
14126
14135
|
var isContent = (w) => w.length >= 4 && !STOP4.has(w);
|
|
14127
14136
|
function echoesHeard(line, heard) {
|
|
14128
|
-
const said =
|
|
14129
|
-
return cueWords(lineWords(line)).some((w) =>
|
|
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))));
|
|
14130
14139
|
}
|
|
14140
|
+
var stem = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})s$", "u"), "");
|
|
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(" "));
|
|
14142
|
+
var echoable = (w) => isContent(w) || w.length === 3 && !SHORT_STOP.has(w) && !new RegExp("^\\p{N}+$", "u").test(w);
|
|
14131
14143
|
var leafKey = (line) => cueWords(lineWords(line)).join(" ");
|
|
14132
14144
|
function parseNodes(list, lang, depth, maxBranches) {
|
|
14133
14145
|
const out = [];
|
|
@@ -14741,6 +14753,8 @@ var SecondChannel = class {
|
|
|
14741
14753
|
// live: this turn's ask leaf
|
|
14742
14754
|
barged = false;
|
|
14743
14755
|
// the user cut in since their last turn: that turn is a steer, not a story to react to
|
|
14756
|
+
said = "";
|
|
14757
|
+
// live: what the user heard the assistant say last (the cut's heard part, else the last reply)
|
|
14744
14758
|
leafReady = Promise.resolve();
|
|
14745
14759
|
// live: the turn-end leaf pick settled
|
|
14746
14760
|
recent = [];
|
|
@@ -14957,8 +14971,9 @@ var SecondChannel = class {
|
|
|
14957
14971
|
}
|
|
14958
14972
|
}
|
|
14959
14973
|
/** The user's final line was dispatched to the main agent (its words are the bridge's micro-context). */
|
|
14960
|
-
onUserTurn(text, lastWordAgoMs = 0) {
|
|
14974
|
+
onUserTurn(text, lastWordAgoMs = 0, heardCut) {
|
|
14961
14975
|
this.heard = text.trim();
|
|
14976
|
+
this.said = (heardCut ?? this.reply).trim();
|
|
14962
14977
|
this.lastWordAgo = Math.max(0, lastWordAgoMs);
|
|
14963
14978
|
this.floorWords = this.carried + words3(this.heard).length;
|
|
14964
14979
|
this.lastUser = this.heard;
|
|
@@ -15265,12 +15280,14 @@ var SecondChannel = class {
|
|
|
15265
15280
|
this.bridgeReady = Promise.resolve();
|
|
15266
15281
|
this.noLine = "";
|
|
15267
15282
|
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
|
|
15269
|
-
const
|
|
15283
|
+
const gen = this.gen, ac = new AbortController(), own = this.ownWords;
|
|
15284
|
+
const said = own ? words3(this.said.replace(/\[[^\]]*\]/g, " ")).slice(-this.o.microWords).join(" ") : "", heard = `${this.heard} ${said}`;
|
|
15285
|
+
const ctx = { kind: "bridge", heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...own ? { ask: true } : {}, ...said ? { said, cut: this.barged } : {} };
|
|
15286
|
+
log30.debug(`bridge ctx: said=${JSON.stringify(ctx.said ?? "")} cut=${!!ctx.cut}`);
|
|
15270
15287
|
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
15288
|
const none = own && /^\s*none\b/i.test(raw ?? ""), text = none ? "" : cleanLine(raw ?? "", ctx.lang), echoes = !own || echoesHeard(text, heard);
|
|
15272
15289
|
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" :
|
|
15290
|
+
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
15291
|
}).catch((e) => log30.debug(`bridge prefetch failed: ${e?.message ?? e}`));
|
|
15275
15292
|
}
|
|
15276
15293
|
async line(kind, react = true) {
|
|
@@ -15378,11 +15395,21 @@ function channelLine(line, kind) {
|
|
|
15378
15395
|
const text = lineWords(line);
|
|
15379
15396
|
return { type: "channel", kind, text, ...text === line ? {} : { speech: line } };
|
|
15380
15397
|
}
|
|
15398
|
+
function askPrompt(c, gender) {
|
|
15399
|
+
const last = c.said ? c.said.split(/(?<=[.!?])\s+/).filter((x) => /\w/.test(x)).pop() : "";
|
|
15400
|
+
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.
|
|
15401
|
+
` : `You (the assistant) last said: "\u2026${c.said}"
|
|
15402
|
+
`;
|
|
15403
|
+
return `A live voice call. ${said}The user just said: "${c.heard}"
|
|
15404
|
+
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:
|
|
15405
|
+
- 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.")
|
|
15406
|
+
- 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
|
|
15407
|
+
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
|
|
15408
|
+
${personaHint(gender)} Output only the line.`;
|
|
15409
|
+
}
|
|
15381
15410
|
function fastLineGenerator(ai, model, gender) {
|
|
15382
15411
|
return async (c, signal) => {
|
|
15383
|
-
const prompt = c.ask ? `
|
|
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]}.
|
|
15412
|
+
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
15413
|
` + (c.react ? `Here the line may be ${REACT_HINT}.
|
|
15387
15414
|
` : "") + (c.tags ? `${TAG_HINT}
|
|
15388
15415
|
` : "") + `The user just said: "${c.heard}"
|
|
@@ -15417,9 +15444,21 @@ var VoiceCallOptions = class {
|
|
|
15417
15444
|
* 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
15445
|
* barges in as before. */
|
|
15419
15446
|
noteTurn;
|
|
15447
|
+
/** What the user HEARD of MAIN's reply a barge just cut (a peek — the host still takes the cut for MAIN), else null:
|
|
15448
|
+
* a live bridge echoes what their "that" points at. */
|
|
15449
|
+
heardCut;
|
|
15420
15450
|
/** Writes that immediate answer (fastWorkReply). */
|
|
15421
15451
|
workReply;
|
|
15422
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;
|
|
15423
15462
|
/** Host TTS (fill lane): resolves when played; `false` = could not play. */
|
|
15424
15463
|
speak = () => false;
|
|
15425
15464
|
/** Stop the in-flight fill line now (barge-in only). */
|
|
@@ -15461,6 +15500,7 @@ var VoiceCallOptions = class {
|
|
|
15461
15500
|
progressLeadMs = 1e3;
|
|
15462
15501
|
};
|
|
15463
15502
|
var VoiceCall = class {
|
|
15503
|
+
// a MAIN reply cut while audible: its heard part goes to the history at the next turn
|
|
15464
15504
|
constructor(options) {
|
|
15465
15505
|
this.options = options;
|
|
15466
15506
|
this.options = { ...new VoiceCallOptions(), ...options };
|
|
@@ -15523,6 +15563,11 @@ var VoiceCall = class {
|
|
|
15523
15563
|
progressTimer = null;
|
|
15524
15564
|
lastUserAt = -Infinity;
|
|
15525
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;
|
|
15526
15571
|
get o() {
|
|
15527
15572
|
return this.options;
|
|
15528
15573
|
}
|
|
@@ -15618,6 +15663,7 @@ var VoiceCall = class {
|
|
|
15618
15663
|
return;
|
|
15619
15664
|
case "text":
|
|
15620
15665
|
if (!ev.text) return;
|
|
15666
|
+
c.reply += ev.text;
|
|
15621
15667
|
c.marks.mainFirst ??= this.o.now();
|
|
15622
15668
|
c.marks.mainText ??= this.o.now();
|
|
15623
15669
|
if (!c.streamed) {
|
|
@@ -15694,6 +15740,7 @@ var VoiceCall = class {
|
|
|
15694
15740
|
} catch (e) {
|
|
15695
15741
|
log31.warn(`cancel threw: ${e.message}`);
|
|
15696
15742
|
}
|
|
15743
|
+
if (c?.worded && c.lane === "deep" && !c.cutRead) this.cutTurn = c;
|
|
15697
15744
|
if (c?.running) {
|
|
15698
15745
|
c.running = false;
|
|
15699
15746
|
this.o.abortTurn(c.id);
|
|
@@ -15702,6 +15749,7 @@ var VoiceCall = class {
|
|
|
15702
15749
|
}
|
|
15703
15750
|
/** Soft barge-in: keep (a listener cue — no turn) or cut (→ barge()). */
|
|
15704
15751
|
async overlap(text) {
|
|
15752
|
+
if (this.o.mode === "live" && isReaction(text)) return "keep";
|
|
15705
15753
|
const d = await this.judge.judge(text);
|
|
15706
15754
|
if (d.verdict === "cut") this.barge();
|
|
15707
15755
|
return d.verdict;
|
|
@@ -15713,9 +15761,10 @@ var VoiceCall = class {
|
|
|
15713
15761
|
aside(text) {
|
|
15714
15762
|
const now4 = this.o.now();
|
|
15715
15763
|
if (now4 - this.lastAside.at < this.o.asideGapMs) return null;
|
|
15716
|
-
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");
|
|
15717
15765
|
if (!line) return null;
|
|
15718
15766
|
this.lastAside = { text: line, at: now4 };
|
|
15767
|
+
if (this.quickOn) this.history.push({ who: "user", text }, { who: "you", text: line });
|
|
15719
15768
|
this.o.onMetric({ name: "fill", kind: "aside", text: line, lang: this.lang });
|
|
15720
15769
|
return line;
|
|
15721
15770
|
}
|
|
@@ -15743,18 +15792,23 @@ var VoiceCall = class {
|
|
|
15743
15792
|
this.lang = l;
|
|
15744
15793
|
if (l) this.fill.setLanguage(l, true);
|
|
15745
15794
|
}
|
|
15795
|
+
get quickOn() {
|
|
15796
|
+
return this.o.mode === "live" && !!this.o.quick;
|
|
15797
|
+
}
|
|
15746
15798
|
onTurn(t) {
|
|
15747
15799
|
this.floor = "";
|
|
15748
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");
|
|
15749
15802
|
const now4 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
15750
15803
|
const at = this.lastWordAt ?? this.firstFinalAt ?? now4;
|
|
15751
15804
|
const finalAt = this.finalAt || now4;
|
|
15752
15805
|
this.firstFinalAt = null;
|
|
15753
15806
|
this.lastWordAt = null;
|
|
15754
|
-
if (this.
|
|
15807
|
+
if (this.quickOn) this.logCut();
|
|
15808
|
+
if (prev) this.close(prev, t.replaces === prev.id ? "replaced" : void 0);
|
|
15755
15809
|
this.follow(t.text);
|
|
15756
15810
|
this.clearProgress();
|
|
15757
|
-
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" } : {} };
|
|
15758
15812
|
const early = this.earlyHeard;
|
|
15759
15813
|
this.earlyHeard = null;
|
|
15760
15814
|
if (early && early.at >= at) {
|
|
@@ -15763,8 +15817,98 @@ var VoiceCall = class {
|
|
|
15763
15817
|
}
|
|
15764
15818
|
this.progress.turn();
|
|
15765
15819
|
this.o.onMetric({ name: "turn", id: t.id, kind: t.kind, text: t.text });
|
|
15766
|
-
this.
|
|
15767
|
-
|
|
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 } : {} });
|
|
15827
|
+
if (t.kind === "new") this.fill.onUserTurn(t.text, now4 - at, this.o.heardCut?.() ?? void 0);
|
|
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;
|
|
15768
15912
|
}
|
|
15769
15913
|
onDrop(text, why) {
|
|
15770
15914
|
if (!this.gate.holding) {
|
|
@@ -15789,7 +15933,7 @@ var VoiceCall = class {
|
|
|
15789
15933
|
this.o.onMetric({ name: "fill", kind, text, lang: this.lang });
|
|
15790
15934
|
if (kind !== "backchannel") this.progress.heard();
|
|
15791
15935
|
const c = this.cur && !this.cur.closed ? this.cur : void 0;
|
|
15792
|
-
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);
|
|
15793
15937
|
if (c && forTurn && c.marks.fill === void 0) {
|
|
15794
15938
|
c.marks.fill = this.o.now();
|
|
15795
15939
|
c.fillKind = kind;
|
|
@@ -15799,7 +15943,7 @@ var VoiceCall = class {
|
|
|
15799
15943
|
this.lastAudibleAt = this.o.now();
|
|
15800
15944
|
if (c && forTurn) {
|
|
15801
15945
|
c.marks.fillAudio ??= this.o.now();
|
|
15802
|
-
this.sounded(c, kind === "progress" ? "progress" : "fill");
|
|
15946
|
+
this.sounded(c, kind === "progress" ? "progress" : kind === "ack" || kind === "reply" ? "quick" : "fill");
|
|
15803
15947
|
}
|
|
15804
15948
|
return r;
|
|
15805
15949
|
}
|
|
@@ -15813,6 +15957,8 @@ var VoiceCall = class {
|
|
|
15813
15957
|
close(c, end) {
|
|
15814
15958
|
if (c.closed) return;
|
|
15815
15959
|
c.closed = true;
|
|
15960
|
+
c.ask?.abort();
|
|
15961
|
+
this.logReply(c);
|
|
15816
15962
|
c.end = c.worded ? "answered" : end ?? c.end ?? "silent";
|
|
15817
15963
|
if (!c.worded) this.o.onMetric({ name: "first_word", id: c.id, by: "main", kind: c.end });
|
|
15818
15964
|
const rel = (t) => t === void 0 ? void 0 : Math.round(t - c.at);
|
|
@@ -15849,17 +15995,13 @@ var VoiceCall = class {
|
|
|
15849
15995
|
const line = own || (this.o.mode === "live" ? "" : answer);
|
|
15850
15996
|
const stop = /^\s*stop\s*:/i.test(raw), change = !answer || /^\s*work\s*:/i.test(raw);
|
|
15851
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 });
|
|
15852
15999
|
if (line && !this.ended) {
|
|
15853
|
-
|
|
15854
|
-
if (i === 7) {
|
|
15855
|
-
this.o.onMetric({ name: "drop", id: t.id, kind: "aside unplayed", text: line });
|
|
15856
|
-
break;
|
|
15857
|
-
}
|
|
15858
|
-
await new Promise((r) => setTimeout(r, 250));
|
|
15859
|
-
}
|
|
16000
|
+
await this.sayRetry(line, "aside", t.id);
|
|
15860
16001
|
if (this.lastAudibleAt >= at) {
|
|
15861
16002
|
this.progress.note(line);
|
|
15862
16003
|
this.o.show(line, "aside");
|
|
16004
|
+
this.history.push({ who: "you", text: line });
|
|
15863
16005
|
}
|
|
15864
16006
|
} else if (!line) this.o.onMetric({ name: "drop", id: t.id, kind: "no aside line" });
|
|
15865
16007
|
if (stop) {
|
|
@@ -17433,10 +17575,26 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
17433
17575
|
const { onPartial, onState, onBargeIn, onDiag } = o;
|
|
17434
17576
|
let own = false;
|
|
17435
17577
|
const take = v.takeInterruptedReply.bind(v);
|
|
17436
|
-
|
|
17578
|
+
let held2;
|
|
17579
|
+
const ownCut = () => {
|
|
17437
17580
|
const r = take();
|
|
17438
|
-
|
|
17439
|
-
|
|
17581
|
+
return !r || !call.spoke(r.full) ? r : r.queued.length ? { ...r, full: "", heard: "" } : null;
|
|
17582
|
+
};
|
|
17583
|
+
v.takeInterruptedReply = () => {
|
|
17584
|
+
const r = held2 !== void 0 ? held2 : ownCut();
|
|
17585
|
+
held2 = void 0;
|
|
17586
|
+
return r;
|
|
17587
|
+
};
|
|
17588
|
+
call.options.heardCut = () => {
|
|
17589
|
+
held2 ??= ownCut();
|
|
17590
|
+
return held2?.full ? cutHeard(held2) : null;
|
|
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();
|
|
17440
17598
|
};
|
|
17441
17599
|
o.onPartial = (t) => {
|
|
17442
17600
|
if (live() && (own || !v.audible)) call.interim(t, performance.now(), v.usingAec);
|
|
@@ -17446,7 +17604,17 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
17446
17604
|
if (live() && !own && s === "speaking") call.main({ type: "audio" });
|
|
17447
17605
|
onState(s);
|
|
17448
17606
|
};
|
|
17607
|
+
let filling = false;
|
|
17608
|
+
const beginSpeech = v.beginSpeech.bind(v);
|
|
17609
|
+
v.beginSpeech = ((...a) => {
|
|
17610
|
+
if (own && !filling && live()) {
|
|
17611
|
+
own = false;
|
|
17612
|
+
call.main({ type: "audio" }, v.player?.drainMs() ?? 0);
|
|
17613
|
+
}
|
|
17614
|
+
return beginSpeech(...a);
|
|
17615
|
+
});
|
|
17449
17616
|
o.onBargeIn = (phase) => {
|
|
17617
|
+
held2 = void 0;
|
|
17450
17618
|
if (live()) call.barge();
|
|
17451
17619
|
onBargeIn(phase);
|
|
17452
17620
|
};
|
|
@@ -17467,7 +17635,12 @@ function bindVoiceCall(v, call, live, decideMs = 900) {
|
|
|
17467
17635
|
if (!live() || v.audible) return false;
|
|
17468
17636
|
if (kind === "backchannel") return speakBlip(v, text);
|
|
17469
17637
|
own = true;
|
|
17470
|
-
|
|
17638
|
+
filling = true;
|
|
17639
|
+
try {
|
|
17640
|
+
v.speakFiller(text);
|
|
17641
|
+
} finally {
|
|
17642
|
+
filling = false;
|
|
17643
|
+
}
|
|
17471
17644
|
return v.awaitIdle().finally(() => {
|
|
17472
17645
|
own = false;
|
|
17473
17646
|
});
|
|
@@ -17642,7 +17815,7 @@ function fakeVoiceParts(uttFile) {
|
|
|
17642
17815
|
return { stt, tts, player };
|
|
17643
17816
|
}
|
|
17644
17817
|
function fakeTape(heardFile, saidFile) {
|
|
17645
|
-
const CHAR = TTS_SAMPLE_RATE * 2
|
|
17818
|
+
const CHAR = TTS_SAMPLE_RATE * 2 / 15;
|
|
17646
17819
|
const makeTts = () => {
|
|
17647
17820
|
const t = {
|
|
17648
17821
|
connect() {
|
|
@@ -17864,6 +18037,125 @@ ${o.persona}
|
|
|
17864
18037
|
return line || o.fallback;
|
|
17865
18038
|
}
|
|
17866
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
|
+
|
|
17867
18159
|
// cli/config.ts
|
|
17868
18160
|
import { homedir as homedir5 } from "os";
|
|
17869
18161
|
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
|
|
@@ -18011,7 +18303,7 @@ function applyOverlay(cfg, file) {
|
|
|
18011
18303
|
// cli/hooks-config.ts
|
|
18012
18304
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
18013
18305
|
init_platform();
|
|
18014
|
-
var
|
|
18306
|
+
var log40 = forComponent("hooks");
|
|
18015
18307
|
var escapeRegex = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
18016
18308
|
function ruleMatches(rule, toolName) {
|
|
18017
18309
|
if (!rule.tool || rule.tool === "*") return true;
|
|
@@ -18030,7 +18322,7 @@ function runCmd(rule, env) {
|
|
|
18030
18322
|
});
|
|
18031
18323
|
return { code: r.status ?? 1, out: ((r.stdout ?? "") + (r.stderr ?? "")).trim() };
|
|
18032
18324
|
} catch (e) {
|
|
18033
|
-
|
|
18325
|
+
log40.debug(`hook command failed: ${rule.command}`, e);
|
|
18034
18326
|
return { code: 1, out: String(e?.message ?? e) };
|
|
18035
18327
|
}
|
|
18036
18328
|
}
|
|
@@ -18138,7 +18430,7 @@ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as rea
|
|
|
18138
18430
|
import { homedir as homedir6 } from "os";
|
|
18139
18431
|
import { join as join11 } from "path";
|
|
18140
18432
|
init_platform();
|
|
18141
|
-
var
|
|
18433
|
+
var log41 = forComponent("session");
|
|
18142
18434
|
var globalDir = () => join11(homedir6(), ".agent", "sessions");
|
|
18143
18435
|
function indexLink(target, link2) {
|
|
18144
18436
|
try {
|
|
@@ -18201,7 +18493,7 @@ var SessionStore = class {
|
|
|
18201
18493
|
}
|
|
18202
18494
|
load(id) {
|
|
18203
18495
|
if (!this.safeId(id)) {
|
|
18204
|
-
|
|
18496
|
+
log41.debug(`rejecting unsafe session id: ${id}`);
|
|
18205
18497
|
return void 0;
|
|
18206
18498
|
}
|
|
18207
18499
|
const path = join11(this.dir, `${id}.json`);
|
|
@@ -18209,7 +18501,7 @@ var SessionStore = class {
|
|
|
18209
18501
|
try {
|
|
18210
18502
|
return JSON.parse(readFileSync8(path, "utf8"));
|
|
18211
18503
|
} catch (e) {
|
|
18212
|
-
|
|
18504
|
+
log41.debug(`unreadable session ${id} \u2014 ignoring`, e);
|
|
18213
18505
|
return void 0;
|
|
18214
18506
|
}
|
|
18215
18507
|
}
|
|
@@ -18222,7 +18514,7 @@ var SessionStore = class {
|
|
|
18222
18514
|
try {
|
|
18223
18515
|
metas.push(JSON.parse(readFileSync8(join11(this.dir, f), "utf8")).meta);
|
|
18224
18516
|
} catch (e) {
|
|
18225
|
-
|
|
18517
|
+
log41.debug(`skipping unreadable session file ${f}`, e);
|
|
18226
18518
|
}
|
|
18227
18519
|
}
|
|
18228
18520
|
return metas.sort((a, b) => b.updated - a.updated);
|
|
@@ -18654,7 +18946,7 @@ import { promisify } from "util";
|
|
|
18654
18946
|
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9 } from "fs";
|
|
18655
18947
|
import { homedir as homedir7 } from "os";
|
|
18656
18948
|
import { join as join12, resolve as resolve4, sep as sep3, parse as parsePath } from "path";
|
|
18657
|
-
var
|
|
18949
|
+
var log42 = forComponent("checkpoints");
|
|
18658
18950
|
var exec = promisify(execFile4);
|
|
18659
18951
|
var DEFAULT_EXCLUDE = [".agent/", ".git/", "node_modules/", "dist/", "build/", ".next/", "target/", ".venv/", "__pycache__/", "*.log"];
|
|
18660
18952
|
function isBroadRoot(p) {
|
|
@@ -18702,7 +18994,7 @@ var ShadowRepo = class {
|
|
|
18702
18994
|
writeFileSync6(join12(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
|
|
18703
18995
|
this.ready = true;
|
|
18704
18996
|
} catch (e) {
|
|
18705
|
-
|
|
18997
|
+
log42.debug(`git checkpoints unavailable for ${this.workTree}`, e);
|
|
18706
18998
|
this.ready = false;
|
|
18707
18999
|
}
|
|
18708
19000
|
return this.ready;
|
|
@@ -18713,7 +19005,7 @@ var ShadowRepo = class {
|
|
|
18713
19005
|
}
|
|
18714
19006
|
async commit(label, forced = []) {
|
|
18715
19007
|
await this.run("add", "-A");
|
|
18716
|
-
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));
|
|
18717
19009
|
await this.run("commit", "--allow-empty", "-q", "-m", label);
|
|
18718
19010
|
}
|
|
18719
19011
|
/** Inject the CURRENT (pre-edit) content of `paths` into the turn-open restore point by amending it.
|
|
@@ -18721,8 +19013,8 @@ var ShadowRepo = class {
|
|
|
18721
19013
|
* turn-boundary `add -A` would never have captured it. Amend (vs a new commit) keeps one restore
|
|
18722
19014
|
* point per turn, so the REPL's turn↔frame mapping stays intact. */
|
|
18723
19015
|
async amendForced(paths) {
|
|
18724
|
-
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) =>
|
|
18725
|
-
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));
|
|
18726
19018
|
}
|
|
18727
19019
|
/** Commits on `ref`, oldest-first (canonical index space). */
|
|
18728
19020
|
async log(ref) {
|
|
@@ -18782,7 +19074,7 @@ var ShadowRepo = class {
|
|
|
18782
19074
|
await this.run("gc", "--auto", "-q").catch(() => {
|
|
18783
19075
|
});
|
|
18784
19076
|
} catch (e) {
|
|
18785
|
-
|
|
19077
|
+
log42.debug("checkpoint prune failed", e);
|
|
18786
19078
|
}
|
|
18787
19079
|
}
|
|
18788
19080
|
};
|
|
@@ -18850,7 +19142,7 @@ var GitCheckpoints = class {
|
|
|
18850
19142
|
use(sessionId) {
|
|
18851
19143
|
if (sessionId === this.session) return;
|
|
18852
19144
|
this.session = sessionId;
|
|
18853
|
-
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));
|
|
18854
19146
|
}
|
|
18855
19147
|
async begin(label) {
|
|
18856
19148
|
if (!await this.start()) return;
|
|
@@ -18870,7 +19162,7 @@ var GitCheckpoints = class {
|
|
|
18870
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
|
|
18871
19163
|
`);
|
|
18872
19164
|
} else {
|
|
18873
|
-
|
|
19165
|
+
log42.debug("checkpoint commit failed", e);
|
|
18874
19166
|
survivors.push(this.repos[i]);
|
|
18875
19167
|
survivorCaches.push(this.caches[i] ?? []);
|
|
18876
19168
|
}
|
|
@@ -18905,7 +19197,7 @@ var GitCheckpoints = class {
|
|
|
18905
19197
|
if (this.forced.has(abs)) continue;
|
|
18906
19198
|
this.forced.add(abs);
|
|
18907
19199
|
const i = this.repoIndexFor(abs);
|
|
18908
|
-
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));
|
|
18909
19201
|
}
|
|
18910
19202
|
}
|
|
18911
19203
|
};
|
|
@@ -20695,7 +20987,7 @@ import { spawnSync as spawnSync6 } from "child_process";
|
|
|
20695
20987
|
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
|
|
20696
20988
|
import { homedir as homedir8 } from "os";
|
|
20697
20989
|
import { join as join14 } from "path";
|
|
20698
|
-
var
|
|
20990
|
+
var log43 = forComponent("os-sched");
|
|
20699
20991
|
var OsScheduler = class {
|
|
20700
20992
|
options;
|
|
20701
20993
|
constructor(options) {
|
|
@@ -20757,7 +21049,7 @@ var OsScheduler = class {
|
|
|
20757
21049
|
}
|
|
20758
21050
|
}
|
|
20759
21051
|
} catch (e) {
|
|
20760
|
-
|
|
21052
|
+
log43.debug(`cancel ${id}`, e);
|
|
20761
21053
|
}
|
|
20762
21054
|
for (const f of [`${id}.json`, `${id}.sh`]) {
|
|
20763
21055
|
try {
|
|
@@ -20875,7 +21167,7 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync11, unlinkSync as unli
|
|
|
20875
21167
|
import { homedir as homedir9 } from "os";
|
|
20876
21168
|
import { join as join15 } from "path";
|
|
20877
21169
|
init_platform();
|
|
20878
|
-
var
|
|
21170
|
+
var log44 = forComponent("remote-trigger");
|
|
20879
21171
|
var TRIGGER_DIR = () => join15(homedir9(), ".agent", "triggers");
|
|
20880
21172
|
var sockPath = (sessionId, dir = TRIGGER_DIR()) => join15(dir, `${sessionId}.sock`);
|
|
20881
21173
|
var TriggerServer = class {
|
|
@@ -20913,13 +21205,13 @@ var TriggerServer = class {
|
|
|
20913
21205
|
conn.end(JSON.stringify({ ok: false, error: String(e) }) + "\n");
|
|
20914
21206
|
}
|
|
20915
21207
|
});
|
|
20916
|
-
conn.on("error", (e) =>
|
|
21208
|
+
conn.on("error", (e) => log44.debug("trigger conn error", e));
|
|
20917
21209
|
});
|
|
20918
|
-
this.server.on("error", (e) =>
|
|
21210
|
+
this.server.on("error", (e) => log44.debug("trigger server error", e));
|
|
20919
21211
|
this.server.listen(p);
|
|
20920
21212
|
this.path = p;
|
|
20921
21213
|
} catch (e) {
|
|
20922
|
-
|
|
21214
|
+
log44.debug("trigger server unavailable", e);
|
|
20923
21215
|
}
|
|
20924
21216
|
}
|
|
20925
21217
|
/** Re-bind on /resume (the session id changed). */
|
|
@@ -21051,7 +21343,7 @@ var strike = C("9");
|
|
|
21051
21343
|
var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
|
|
21052
21344
|
var mdPalette = { bold, dim, cyan, italic, strike, green, link };
|
|
21053
21345
|
var err = (s) => process.stderr.write(s);
|
|
21054
|
-
var
|
|
21346
|
+
var log45 = forComponent("cli");
|
|
21055
21347
|
var VERSION = (() => {
|
|
21056
21348
|
try {
|
|
21057
21349
|
return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
|
|
@@ -21955,7 +22247,7 @@ function turnCost(model, usage) {
|
|
|
21955
22247
|
const priced = model.startsWith("claude-code/") ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
|
|
21956
22248
|
return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
|
|
21957
22249
|
}
|
|
21958
|
-
async function evaluateGoal(ai, condition, transcript,
|
|
22250
|
+
async function evaluateGoal(ai, condition, transcript, log46) {
|
|
21959
22251
|
const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
|
|
21960
22252
|
const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
|
|
21961
22253
|
return text.slice(0, 600);
|
|
@@ -21975,7 +22267,7 @@ ${recent}` }
|
|
|
21975
22267
|
const match = r.content.match(/\{[\s\S]*\}/);
|
|
21976
22268
|
if (match) return JSON.parse(match[0]);
|
|
21977
22269
|
} catch (e) {
|
|
21978
|
-
|
|
22270
|
+
log46(dim(` (goal evaluator error: ${e?.message ?? e})
|
|
21979
22271
|
`));
|
|
21980
22272
|
}
|
|
21981
22273
|
return { met: false, reason: "evaluation unclear" };
|
|
@@ -22203,7 +22495,7 @@ function mcpAgentTools(mounted, opts) {
|
|
|
22203
22495
|
return tools;
|
|
22204
22496
|
}
|
|
22205
22497
|
async function closeMcp(mounted) {
|
|
22206
|
-
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))));
|
|
22207
22499
|
}
|
|
22208
22500
|
var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
|
|
22209
22501
|
function mentionRefs(line) {
|
|
@@ -22262,7 +22554,7 @@ async function expandMentions(fs, line) {
|
|
|
22262
22554
|
if (loaded.includes(ref) || missing.includes(ref)) continue;
|
|
22263
22555
|
if (ref.includes(":") && mcpMentionResolver) {
|
|
22264
22556
|
const body = await mcpMentionResolver(ref).catch((e) => {
|
|
22265
|
-
|
|
22557
|
+
log45.debug("mcp mention resolve failed", e);
|
|
22266
22558
|
return null;
|
|
22267
22559
|
});
|
|
22268
22560
|
if (body != null) {
|
|
@@ -22288,7 +22580,7 @@ ${await fs.readFile(path)}`);
|
|
|
22288
22580
|
${blocks.join("\n\n")}` : line, loaded, missing };
|
|
22289
22581
|
}
|
|
22290
22582
|
function applyTurnMode(agent, session, task, flags = {}, onModel) {
|
|
22291
|
-
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) });
|
|
22292
22584
|
const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
|
|
22293
22585
|
if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
|
|
22294
22586
|
err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
|
|
@@ -22381,7 +22673,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
|
|
|
22381
22673
|
try {
|
|
22382
22674
|
store.save(session);
|
|
22383
22675
|
} catch (ex) {
|
|
22384
|
-
|
|
22676
|
+
log45.debug("mid-turn session flush failed", ex);
|
|
22385
22677
|
}
|
|
22386
22678
|
}
|
|
22387
22679
|
return origNotify(e);
|
|
@@ -22545,14 +22837,14 @@ var isCancelTeardown = (e) => {
|
|
|
22545
22837
|
function installCancelGuards(mounted) {
|
|
22546
22838
|
process.on("unhandledRejection", (e) => {
|
|
22547
22839
|
if (isCancelTeardown(e)) {
|
|
22548
|
-
|
|
22840
|
+
log45.debug("suppressed unhandledRejection (cursor stream cancel)", e);
|
|
22549
22841
|
return;
|
|
22550
22842
|
}
|
|
22551
|
-
|
|
22843
|
+
log45.error("unhandledRejection", e);
|
|
22552
22844
|
});
|
|
22553
22845
|
process.on("uncaughtException", (e) => {
|
|
22554
22846
|
if (isCancelTeardown(e)) {
|
|
22555
|
-
|
|
22847
|
+
log45.debug("suppressed uncaughtException (cursor stream cancel)", e);
|
|
22556
22848
|
return;
|
|
22557
22849
|
}
|
|
22558
22850
|
console.error(e);
|
|
@@ -22894,6 +23186,9 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
22894
23186
|
call = new VoiceCall({
|
|
22895
23187
|
ai,
|
|
22896
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) } : {},
|
|
22897
23192
|
show: (t, kind) => {
|
|
22898
23193
|
err("\r\x1B[0J" + dim(` \u21B3 ${kind === "progress" ? "\u22EF " : ""}${t}
|
|
22899
23194
|
`));
|
|
@@ -22926,10 +23221,11 @@ ${note}`;
|
|
|
22926
23221
|
if (old?.before !== void 0) face.transcript.splice(old.before);
|
|
22927
23222
|
if (rec.skip) return;
|
|
22928
23223
|
const { reply: cut } = takeCut(voiceIO, true);
|
|
22929
|
-
|
|
23224
|
+
const cutNote = cut && keepHeard(face.transcript, cut) ? interruptionNote(cut, void 0, false) : "";
|
|
23225
|
+
if (cutNote) voiceDiag?.push({ t: performance.now(), kind: "call_kept_heard", heard: cut.heard.length, full: cut.full.length });
|
|
22930
23226
|
rec.running = true;
|
|
22931
23227
|
rec.before = face.transcript.length;
|
|
22932
|
-
const note = greetNote;
|
|
23228
|
+
const note = cutNote + greetNote;
|
|
22933
23229
|
greetNote = "";
|
|
22934
23230
|
callReplyOpen = false;
|
|
22935
23231
|
spoken = new SpokenFilter();
|
|
@@ -22942,7 +23238,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
22942
23238
|
editorRef?.abort();
|
|
22943
23239
|
}
|
|
22944
23240
|
} catch (e) {
|
|
22945
|
-
|
|
23241
|
+
log45.error("call turn failed", e);
|
|
22946
23242
|
} finally {
|
|
22947
23243
|
rec.running = false;
|
|
22948
23244
|
call?.main({ type: "done", id });
|
|
@@ -23092,7 +23388,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
23092
23388
|
try {
|
|
23093
23389
|
mkdirSync12(dir, { recursive: true });
|
|
23094
23390
|
} catch (e) {
|
|
23095
|
-
|
|
23391
|
+
log45.debug("paste image dir create failed", e);
|
|
23096
23392
|
}
|
|
23097
23393
|
const img = grabClipboardImage(dir, String(Date.now()));
|
|
23098
23394
|
return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
|
|
@@ -23205,7 +23501,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23205
23501
|
mkdirSync12(join16(cwd, ".agent"), { recursive: true });
|
|
23206
23502
|
appendFileSync2(histPath, line + "\n");
|
|
23207
23503
|
} catch (e) {
|
|
23208
|
-
|
|
23504
|
+
log45.debug("history write failed", e);
|
|
23209
23505
|
}
|
|
23210
23506
|
};
|
|
23211
23507
|
const ago = (t) => {
|
|
@@ -23277,7 +23573,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23277
23573
|
try {
|
|
23278
23574
|
store.save(session);
|
|
23279
23575
|
} catch (e) {
|
|
23280
|
-
|
|
23576
|
+
log45.debug("session save after rewind failed", e);
|
|
23281
23577
|
}
|
|
23282
23578
|
err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
|
|
23283
23579
|
`));
|
|
@@ -23312,7 +23608,7 @@ ${task}`;
|
|
|
23312
23608
|
bangContext.length = 0;
|
|
23313
23609
|
}
|
|
23314
23610
|
const delta = await refreshCatalogs().catch((e) => {
|
|
23315
|
-
|
|
23611
|
+
log45.debug("catalog refresh failed", e);
|
|
23316
23612
|
return "";
|
|
23317
23613
|
});
|
|
23318
23614
|
if (delta) {
|
|
@@ -23586,7 +23882,7 @@ ${task}`;
|
|
|
23586
23882
|
desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
|
|
23587
23883
|
run: async () => {
|
|
23588
23884
|
await refreshCatalogs().catch((e) => {
|
|
23589
|
-
|
|
23885
|
+
log45.debug("catalog refresh failed", e);
|
|
23590
23886
|
});
|
|
23591
23887
|
face.reprepare();
|
|
23592
23888
|
err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
|
|
@@ -24089,7 +24385,7 @@ ${task}`;
|
|
|
24089
24385
|
try {
|
|
24090
24386
|
for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
|
|
24091
24387
|
} catch (e) {
|
|
24092
|
-
|
|
24388
|
+
log45.debug(`loadAgents(${d}) failed`, e);
|
|
24093
24389
|
}
|
|
24094
24390
|
}
|
|
24095
24391
|
if (!seen.size) {
|
|
@@ -24177,7 +24473,7 @@ ${task}`;
|
|
|
24177
24473
|
}
|
|
24178
24474
|
if (idx >= 0) {
|
|
24179
24475
|
const old = mounted.splice(idx, 1)[0];
|
|
24180
|
-
await old.client.close().catch((e) =>
|
|
24476
|
+
await old.client.close().catch((e) => log45.debug("mcp close failed", e));
|
|
24181
24477
|
}
|
|
24182
24478
|
try {
|
|
24183
24479
|
const m = await mountMcpServer(name, conf);
|
|
@@ -24205,7 +24501,7 @@ ${task}`;
|
|
|
24205
24501
|
}
|
|
24206
24502
|
const m = mounted.splice(idx, 1)[0];
|
|
24207
24503
|
remountMcpTools();
|
|
24208
|
-
await m.client.close().catch((e) =>
|
|
24504
|
+
await m.client.close().catch((e) => log45.debug("mcp close failed", e));
|
|
24209
24505
|
err(dim(` removed "${name}"
|
|
24210
24506
|
`));
|
|
24211
24507
|
return;
|
|
@@ -24408,7 +24704,7 @@ ${task}`;
|
|
|
24408
24704
|
try {
|
|
24409
24705
|
return readdirSync4(join16(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
|
|
24410
24706
|
} catch (e) {
|
|
24411
|
-
|
|
24707
|
+
log45.debug("completion readdir failed", absDir, e);
|
|
24412
24708
|
return null;
|
|
24413
24709
|
}
|
|
24414
24710
|
};
|
|
@@ -24547,7 +24843,7 @@ ${out}
|
|
|
24547
24843
|
return;
|
|
24548
24844
|
}
|
|
24549
24845
|
await refreshCatalogs().catch((e) => {
|
|
24550
|
-
|
|
24846
|
+
log45.debug("catalog refresh failed", e);
|
|
24551
24847
|
});
|
|
24552
24848
|
const sk = skills.find((x) => x.name === name);
|
|
24553
24849
|
if (sk) {
|
|
@@ -24677,7 +24973,7 @@ ${out}
|
|
|
24677
24973
|
if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
|
|
24678
24974
|
const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
|
|
24679
24975
|
const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
|
|
24680
|
-
|
|
24976
|
+
log45.warn(`barge intent failed \u2014 model decides: ${e.message}`);
|
|
24681
24977
|
return void 0;
|
|
24682
24978
|
}) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
|
|
24683
24979
|
const cutIn = replaces ? replaces.cutIn : interjectNote;
|
|
@@ -25078,10 +25374,10 @@ function channelOptions(ai, model, gender) {
|
|
|
25078
25374
|
// 0: the reactive live path
|
|
25079
25375
|
pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
|
|
25080
25376
|
persona: process.env.AGENTX_CALL_PERSONA ?? "",
|
|
25081
|
-
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}` : ""}`),
|
|
25082
25378
|
onEvent: (e) => {
|
|
25083
|
-
if (e.moment)
|
|
25084
|
-
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`);
|
|
25085
25381
|
},
|
|
25086
25382
|
// Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
|
|
25087
25383
|
banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join16(homedir10(), ".agent", "cache", "channel-banks") }),
|
|
@@ -25175,7 +25471,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25175
25471
|
try {
|
|
25176
25472
|
store.save(session);
|
|
25177
25473
|
} catch (e) {
|
|
25178
|
-
|
|
25474
|
+
log45.warn("duplex session save failed", e);
|
|
25179
25475
|
}
|
|
25180
25476
|
};
|
|
25181
25477
|
const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
|
|
@@ -25215,7 +25511,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25215
25511
|
done2();
|
|
25216
25512
|
out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
|
|
25217
25513
|
}).catch((e) => {
|
|
25218
|
-
|
|
25514
|
+
log45.error("duplex turn failed", e);
|
|
25219
25515
|
done2();
|
|
25220
25516
|
out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
|
|
25221
25517
|
});
|