@livx.cc/agentx 0.99.151 → 0.99.152
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 +180 -136
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +82 -33
- package/dist/index.js.map +1 -1
- package/dist/{secondChannel--iqPHPO_.d.ts → secondChannel-BVmp2lze.d.ts} +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as AgentOptions, H as Hooks, x as RunResult, k as Decider, b as Agent, q as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, y as SecondChannelOptions, S as SecondChannel } from './secondChannel
|
|
2
|
-
export { A as ADVISE_LIMIT, a as AdvisorSetup, C as CC_WRITE_TOOLS, e as ChatFragment, f as ChatUsage, g as Classification, h as Classifier, i as CompactResult, j as ContextFileSpec, D as DEFAULT_MUTATING, l as Decision, M as ModelRouter, m as ModelRouterOptions, P as PLANNER_BLOCKED, n as PLANNER_REFUSAL, o as PLAN_FIRST, p as PermissionOptions, r as PermissionRule, s as PreToolUseDecision, R as ReasoningEffort, t as RecordingHooks, u as RecordingLifecycle, v as RouteDecision, w as RouterState, T as Tier, z as ToolUse, B as ToolUseMeta, W as WRITE_TOOLS, E as advisorFor, F as advisorPrompt, I as ccModeOptions, J as claudeCodeDisallowedTools, K as composeHooks, N as delegatePrompt, O as delegateTools, Q as delegateWorkerFor, U as estimateTokens, V as jevAvailable, X as jevClassifier, Y as loadContextFiles, Z as loadInstructions, _ as makeAdvisor, $ as meterWorkers, a0 as pickTier, a1 as planMode, a2 as plannerBlocks, a3 as reasoningToChatFragment } from './secondChannel
|
|
1
|
+
import { c as AgentOptions, H as Hooks, x as RunResult, k as Decider, b as Agent, q as PermissionPolicy, G as Gender, L as LineKind, d as ChannelMode, y as SecondChannelOptions, S as SecondChannel } from './secondChannel-BVmp2lze.js';
|
|
2
|
+
export { A as ADVISE_LIMIT, a as AdvisorSetup, C as CC_WRITE_TOOLS, e as ChatFragment, f as ChatUsage, g as Classification, h as Classifier, i as CompactResult, j as ContextFileSpec, D as DEFAULT_MUTATING, l as Decision, M as ModelRouter, m as ModelRouterOptions, P as PLANNER_BLOCKED, n as PLANNER_REFUSAL, o as PLAN_FIRST, p as PermissionOptions, r as PermissionRule, s as PreToolUseDecision, R as ReasoningEffort, t as RecordingHooks, u as RecordingLifecycle, v as RouteDecision, w as RouterState, T as Tier, z as ToolUse, B as ToolUseMeta, W as WRITE_TOOLS, E as advisorFor, F as advisorPrompt, I as ccModeOptions, J as claudeCodeDisallowedTools, K as composeHooks, N as delegatePrompt, O as delegateTools, Q as delegateWorkerFor, U as estimateTokens, V as jevAvailable, X as jevClassifier, Y as loadContextFiles, Z as loadInstructions, _ as makeAdvisor, $ as meterWorkers, a0 as pickTier, a1 as planMode, a2 as plannerBlocks, a3 as reasoningToChatFragment } from './secondChannel-BVmp2lze.js';
|
|
3
3
|
export { MODEL_ALIASES, ModelSwitch, ResolveModelSwitchOpts, latestClaude, modelShortLabel, resolveModelAlias, resolveModelSwitch } from './models.js';
|
|
4
4
|
import { IFilesystem, FileMetadata } from '@livx.cc/wcli/core';
|
|
5
5
|
export { CommandExecutor, FileMetadata, IFilesystem, IndexedDbFilesystem, MemFilesystem, registerHeadlessCommands } from '@livx.cc/wcli/core';
|
|
@@ -972,6 +972,10 @@ declare class TurnGateOptions {
|
|
|
972
972
|
* 20261103-114604, "Okay." settled 700ms into "What will the…" and MAIN started, was aborted twice and merged. The
|
|
973
973
|
* rest's final merges in; capped at this long from the hold (an STT that never finalizes a partial). */
|
|
974
974
|
talkingMaxMs: number;
|
|
975
|
+
/** With settleMs: a final of acknowledgement words only ("Ok Okay.") waits this long. No answer is due, and it is
|
|
976
|
+
* mostly the start of the turn: live 20261103-210433, "Ok Okay." settled at 700ms, the rest began 1s after it, and
|
|
977
|
+
* MAIN was started and aborted. Quiet past this sends it as it was. */
|
|
978
|
+
openerMs: number;
|
|
975
979
|
onTurn: (t: GateTurn) => void;
|
|
976
980
|
onDrop: (text: string, why: GateDrop) => void;
|
|
977
981
|
/** A final is being held (ends mid-phrase) — the fill channel may cover it with a filler, never a bridge. */
|
|
@@ -1010,6 +1014,9 @@ declare class TurnGate {
|
|
|
1010
1014
|
replyStarted(id: string): void;
|
|
1011
1015
|
/** Send a held fragment now (e.g. the call ends). */
|
|
1012
1016
|
flush(): void;
|
|
1017
|
+
/** Only acknowledgement words ("Ok Okay.", "Alright.") and no goodbye: no answer is due, and it usually opens what
|
|
1018
|
+
* comes next. */
|
|
1019
|
+
private opener;
|
|
1013
1020
|
end(): void;
|
|
1014
1021
|
private refinal;
|
|
1015
1022
|
private send;
|
|
@@ -1869,6 +1876,7 @@ declare class VoiceCall {
|
|
|
1869
1876
|
lang?: string;
|
|
1870
1877
|
}): void;
|
|
1871
1878
|
private finalAt;
|
|
1879
|
+
private floor;
|
|
1872
1880
|
private sttLang;
|
|
1873
1881
|
/** The host's player started a line's audio now (or in `inMs`): `fill`/`progress` = the fill channel's, `main` = MAIN's
|
|
1874
1882
|
* reply (as main({type:'audio'})). With hostAudio this is what first_sound counts. */
|
package/dist/index.js
CHANGED
|
@@ -10442,12 +10442,14 @@ var LEADER = /* @__PURE__ */ new Set(["yeah", "yea", "yes", "yep", "yup", "ok",
|
|
|
10442
10442
|
var PHRASES = ["got it", "i see", "makes sense", "of course", "for sure", "all right", "that's right", "that's true", "thats right", "thats true", "love it", "i know", "me too", "uh huh"];
|
|
10443
10443
|
var CONTINUE = /^(?:(?:and|so|oh) )?(?:and|so|really|seriously|then what|and then|go on|keep going|ואז|באמת|נו)$/;
|
|
10444
10444
|
var AGREE = new Set("yeah yea yes yep yup right sure true totally exactly definitely absolutely agreed correct indeed \u05DB\u05DF \u05E0\u05DB\u05D5\u05DF \u05D1\u05D3\u05D9\u05D5\u05E7 \u05D1\u05E8\u05D5\u05E8 \u05D1\u05D8\u05D7 \u05D0\u05DB\u05DF \u05DC\u05D2\u05DE\u05E8\u05D9 \u05DE\u05E1\u05DB\u05D9\u05DD \u05DE\u05E1\u05DB\u05D9\u05DE\u05D4 \u05DE\u05DE\u05E9".split(" "));
|
|
10445
|
+
var DOUBT = /^(?:(?:and|so|oh|wait|but) )*(?:really|seriously|are|is|was|were|do|does|did|you|no way|באמת|בטוח|בטוחה|רצינית?)(?=\s|$)/u;
|
|
10445
10446
|
var AGREE_PHRASES = ["of course", "for sure", "that's right", "that's true", "thats right", "thats true", "makes sense", "i agree"];
|
|
10446
10447
|
var HE_ACK = new Set("\u05DB\u05DF \u05E0\u05DB\u05D5\u05DF \u05D1\u05D3\u05D9\u05D5\u05E7 \u05D1\u05E8\u05D5\u05E8 \u05D1\u05D8\u05D7 \u05D0\u05DB\u05DF \u05DC\u05D2\u05DE\u05E8\u05D9 \u05DE\u05DE\u05E9 \u05D0\u05D5\u05E7\u05D9\u05D9 \u05D0\u05D5\u05E7\u05D9 \u05E1\u05D1\u05D1\u05D4 \u05D9\u05E4\u05D4 \u05DE\u05E2\u05D5\u05DC\u05D4 \u05D5\u05D5\u05D0\u05D5 \u05D0\u05D4\u05D4 \u05D0\u05D4 \u05D4\u05DE\u05DE \u05DE\u05DE\u05DE".split(" "));
|
|
10447
10448
|
function cueKind(text) {
|
|
10448
10449
|
const t = norm2(text);
|
|
10449
10450
|
if (!t) return null;
|
|
10450
10451
|
if (CONTINUE.test(t)) return "continue";
|
|
10452
|
+
if (/\?/.test(text) || DOUBT.test(t)) return null;
|
|
10451
10453
|
let r = t;
|
|
10452
10454
|
for (const p of AGREE_PHRASES) if (r.includes(p)) return "agree";
|
|
10453
10455
|
r = r.split(/[\s-]+/).filter((w) => !LEAD.has(w)).join(" ");
|
|
@@ -11150,6 +11152,10 @@ var TurnGateOptions = class {
|
|
|
11150
11152
|
* 20261103-114604, "Okay." settled 700ms into "What will the…" and MAIN started, was aborted twice and merged. The
|
|
11151
11153
|
* rest's final merges in; capped at this long from the hold (an STT that never finalizes a partial). */
|
|
11152
11154
|
talkingMaxMs = 6e3;
|
|
11155
|
+
/** With settleMs: a final of acknowledgement words only ("Ok Okay.") waits this long. No answer is due, and it is
|
|
11156
|
+
* mostly the start of the turn: live 20261103-210433, "Ok Okay." settled at 700ms, the rest began 1s after it, and
|
|
11157
|
+
* MAIN was started and aborted. Quiet past this sends it as it was. */
|
|
11158
|
+
openerMs = 2e3;
|
|
11153
11159
|
onTurn = () => {
|
|
11154
11160
|
};
|
|
11155
11161
|
onDrop = () => {
|
|
@@ -11207,7 +11213,7 @@ var TurnGate = class {
|
|
|
11207
11213
|
if (this.closed && isClosing(t)) return this.o.onDrop(t, "goodbye");
|
|
11208
11214
|
const mid = endsMidPhrase(t);
|
|
11209
11215
|
if (mid || this.o.settleMs && !/\?["')\]]*$/.test(t)) {
|
|
11210
|
-
const ms = mid ? this.o.holdMs : this.o.settleMs;
|
|
11216
|
+
const ms = mid ? this.o.holdMs : this.o.settleMs && this.opener(t) ? Math.max(this.o.settleMs, this.o.openerMs) : this.o.settleMs;
|
|
11211
11217
|
this.held = { text: t, sttId, ms, replaces, since: now3, timer: setTimeout(() => this.settle(), ms) };
|
|
11212
11218
|
return this.o.onHold(t);
|
|
11213
11219
|
}
|
|
@@ -11252,6 +11258,11 @@ var TurnGate = class {
|
|
|
11252
11258
|
if (this.closed && isClosing(h.text)) return this.o.onDrop(h.text, "goodbye");
|
|
11253
11259
|
this.send(h.text, norm3(h.text), h.sttId, "new", h.replaces);
|
|
11254
11260
|
}
|
|
11261
|
+
/** Only acknowledgement words ("Ok Okay.", "Alright.") and no goodbye: no answer is due, and it usually opens what
|
|
11262
|
+
* comes next. */
|
|
11263
|
+
opener(t) {
|
|
11264
|
+
return turnIntent(t) === "closer" && !isClosing(t);
|
|
11265
|
+
}
|
|
11255
11266
|
end() {
|
|
11256
11267
|
if (this.held) {
|
|
11257
11268
|
clearTimeout(this.held.timer);
|
|
@@ -13777,8 +13788,30 @@ function matchCue(plan, heard, from = 0) {
|
|
|
13777
13788
|
return null;
|
|
13778
13789
|
}
|
|
13779
13790
|
|
|
13791
|
+
// src/voice/fastText.ts
|
|
13792
|
+
init_logging();
|
|
13793
|
+
var log28 = forComponent("FastText");
|
|
13794
|
+
var isReasoningFast = (model) => /gpt-oss/.test(model);
|
|
13795
|
+
async function fastText(ai, o) {
|
|
13796
|
+
const reasons = isReasoningFast(o.model);
|
|
13797
|
+
const r = await ai.chat({
|
|
13798
|
+
model: o.model,
|
|
13799
|
+
messages: [{ role: "user", content: o.prompt }],
|
|
13800
|
+
stream: false,
|
|
13801
|
+
...o.signal ? { signal: o.signal } : {},
|
|
13802
|
+
maxTokens: reasons ? Math.max(o.maxTokens ?? 0, 400) : o.maxTokens ?? 150,
|
|
13803
|
+
...o.temperature !== void 0 ? { temperature: o.temperature } : {},
|
|
13804
|
+
...reasons ? { providerOptions: { reasoning_effort: "low" } } : {}
|
|
13805
|
+
});
|
|
13806
|
+
if (reasons && r.finishReason === "length") {
|
|
13807
|
+
log28.debug(`${o.model} hit its token cap \u2014 no answer: ${(r.content ?? "").slice(0, 80)}`);
|
|
13808
|
+
return "";
|
|
13809
|
+
}
|
|
13810
|
+
return r.content ?? "";
|
|
13811
|
+
}
|
|
13812
|
+
|
|
13780
13813
|
// src/voice/convoTree.ts
|
|
13781
|
-
var
|
|
13814
|
+
var log29 = forComponent("ConvoTree");
|
|
13782
13815
|
var SOFT_CUE = "~";
|
|
13783
13816
|
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(" "));
|
|
13784
13817
|
var isContent = (w) => w.length >= 4 && !STOP4.has(w);
|
|
@@ -13885,7 +13918,7 @@ var ConvoTree = class {
|
|
|
13885
13918
|
|
|
13886
13919
|
// src/voice/progress.ts
|
|
13887
13920
|
init_logging();
|
|
13888
|
-
var
|
|
13921
|
+
var log30 = forComponent("Progress");
|
|
13889
13922
|
var HE_RESULT_CLAIM = /(?:^|\s)(?:מצאתי|סיימתי|בוצע|הנה|אין)(?=\s|$|[.,!…])/u;
|
|
13890
13923
|
var PLUMBING = /toolsearch|^mcp__.*__(list_commands|call_info)$/;
|
|
13891
13924
|
var isPlumbing = (tool) => PLUMBING.test(tool.toLowerCase());
|
|
@@ -14060,7 +14093,7 @@ var Progress = class {
|
|
|
14060
14093
|
});
|
|
14061
14094
|
const hint = argsHint(args) || about.slice(-80);
|
|
14062
14095
|
const raw = await Promise.race([this.o.generate(tool, hint, lang, ac.signal, this.lines).catch((e) => {
|
|
14063
|
-
|
|
14096
|
+
log30.warn(`progress line failed: ${e?.message ?? e}`);
|
|
14064
14097
|
return null;
|
|
14065
14098
|
}), late]).finally(() => clearTimeout(t));
|
|
14066
14099
|
const l = cleanLine(raw ?? "", lang, 5);
|
|
@@ -14071,9 +14104,7 @@ var Progress = class {
|
|
|
14071
14104
|
function fastProgressGenerator(ai, model, gender) {
|
|
14072
14105
|
return async (tool, hint, lang, signal, avoid = []) => {
|
|
14073
14106
|
const prompt = `An assistant on a live voice call is running the tool "${tool}"${hint ? ` (about: "${hint}")` : ""}. Write ONE spoken line of 2-5 words, in ${languageName(lang)}, saying what it is doing right now (like "checking the board\u2026"). ${hint ? 'Name what it works on the way a person would say it ("looking up that Astra post\u2026"), never a string of its keywords ("scanning Astra weights\u2026"). ' : ""}${avoid.length ? `It already said ${avoid.map((a) => `"${a}"`).join(", ")}: say something new, a different angle on the same work. ` : ""}Never state a result or a finding. ${personaHint(gender)} Output only the line.`;
|
|
14074
|
-
|
|
14075
|
-
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
|
|
14076
|
-
return r.content ?? "";
|
|
14107
|
+
return fastText(ai, { model, prompt, signal });
|
|
14077
14108
|
};
|
|
14078
14109
|
}
|
|
14079
14110
|
var WORK_CLAIM = /\b(?:none|nothing|nobody|zero|\d+|one|two|three|four|five|many|several|some|looks like|seems|turns out|apparently|it'?s|they'?re|there'?s)\b|(?:^|\s)(?:כלום|אף|נראה)(?=\s|$|[.,!…])/iu;
|
|
@@ -14090,7 +14121,7 @@ function workAck(raw, lang, gender = "") {
|
|
|
14090
14121
|
|
|
14091
14122
|
// src/voice/secondChannel.ts
|
|
14092
14123
|
init_logging();
|
|
14093
|
-
var
|
|
14124
|
+
var log31 = forComponent("SecondChannel");
|
|
14094
14125
|
var CHANNEL_MODES = {
|
|
14095
14126
|
turn: { kinds: ["bridge"], bridgeDelayMs: 1500 },
|
|
14096
14127
|
normal: {},
|
|
@@ -14255,15 +14286,15 @@ function withBudget(p, ms, what, ac) {
|
|
|
14255
14286
|
let t;
|
|
14256
14287
|
const late = new Promise((r) => {
|
|
14257
14288
|
t = setTimeout(() => {
|
|
14258
|
-
|
|
14289
|
+
log31.debug(`${what}: over the ${ms}ms budget \u2014 dropped`);
|
|
14259
14290
|
ac?.abort();
|
|
14260
14291
|
r(null);
|
|
14261
14292
|
}, ms);
|
|
14262
14293
|
});
|
|
14263
14294
|
return Promise.race([p.catch((e) => {
|
|
14264
14295
|
const msg = String(e?.message ?? e);
|
|
14265
|
-
if (e?.name === "AbortError" || /aborted/i.test(msg))
|
|
14266
|
-
else
|
|
14296
|
+
if (e?.name === "AbortError" || /aborted/i.test(msg)) log31.debug(`${what}: aborted after its budget`);
|
|
14297
|
+
else log31.warn(`${what} failed \u2014 falling back: ${msg}`);
|
|
14267
14298
|
return null;
|
|
14268
14299
|
}), late]).finally(() => clearTimeout(t));
|
|
14269
14300
|
}
|
|
@@ -14307,6 +14338,8 @@ var SecondChannel = class {
|
|
|
14307
14338
|
// a bridge generated ahead, used only if ready in time
|
|
14308
14339
|
bridgeReady = Promise.resolve();
|
|
14309
14340
|
// live: that draft settled
|
|
14341
|
+
noLine = "";
|
|
14342
|
+
// live: why that draft gave no line
|
|
14310
14343
|
askLeaf = null;
|
|
14311
14344
|
// live: this turn's ask leaf
|
|
14312
14345
|
barged = false;
|
|
@@ -14366,7 +14399,7 @@ var SecondChannel = class {
|
|
|
14366
14399
|
if (host) this.pinned = true;
|
|
14367
14400
|
const lang = primaryLang(tag);
|
|
14368
14401
|
if (!lang || lang === this.lang) return;
|
|
14369
|
-
|
|
14402
|
+
log31.debug(`language ${this.lang} \u2192 ${lang}`);
|
|
14370
14403
|
this.lang = lang;
|
|
14371
14404
|
this.recent = [];
|
|
14372
14405
|
this.picks.clear();
|
|
@@ -14516,6 +14549,16 @@ var SecondChannel = class {
|
|
|
14516
14549
|
}, Math.max(late, wait + 1));
|
|
14517
14550
|
}
|
|
14518
14551
|
}
|
|
14552
|
+
/** The STT closed the user's line (a final that ends a sentence), before it is a turn (the host may still hold it): a
|
|
14553
|
+
* listener cue armed on its last words is late now. Replay of 20261103-210433: "oh wow" played 330ms after "…and
|
|
14554
|
+
* hacker news." while the gate held the turn, and spaced the request's own line to 1.5s. */
|
|
14555
|
+
onLineEnd() {
|
|
14556
|
+
this.userSpeaking = false;
|
|
14557
|
+
for (const k of ["bcTimer", "leafTimer", "breathTimer"]) {
|
|
14558
|
+
if (this[k]) clearTimeout(this[k]);
|
|
14559
|
+
this[k] = null;
|
|
14560
|
+
}
|
|
14561
|
+
}
|
|
14519
14562
|
/** The user's final line was dispatched to the main agent (its words are the bridge's micro-context). */
|
|
14520
14563
|
onUserTurn(text, lastWordAgoMs = 0) {
|
|
14521
14564
|
this.heard = text.trim();
|
|
@@ -14551,7 +14594,7 @@ var SecondChannel = class {
|
|
|
14551
14594
|
try {
|
|
14552
14595
|
this.o.cancel();
|
|
14553
14596
|
} catch (e) {
|
|
14554
|
-
|
|
14597
|
+
log31.warn(`cancel threw: ${e.message}`);
|
|
14555
14598
|
}
|
|
14556
14599
|
}
|
|
14557
14600
|
}
|
|
@@ -14661,7 +14704,7 @@ var SecondChannel = class {
|
|
|
14661
14704
|
if (r.nodes.length) tree.grow(r.nodes, this.userSpeaking ? words2(this.heard).length : 0);
|
|
14662
14705
|
this.o.onTree({ ms: Math.round(this.o.now() - t0), branches: r.nodes.length, lines: r.nodes.flatMap((n) => [n.line, ...n.next.map((k) => k.line)]), ...r.tokens ? { tokens: r.tokens } : {} });
|
|
14663
14706
|
}, (e) => {
|
|
14664
|
-
|
|
14707
|
+
log31.warn(`tree failed: ${e?.message ?? e}`);
|
|
14665
14708
|
this.o.onTree({ ms: Math.round(this.o.now() - t0), branches: 0, error: String(e?.message ?? e) });
|
|
14666
14709
|
}).finally(() => {
|
|
14667
14710
|
clearTimeout(late);
|
|
@@ -14715,7 +14758,7 @@ var SecondChannel = class {
|
|
|
14715
14758
|
if (gen === this.gen && echoesHeard(hit.node.line, heard)) this.askLeaf = { gen, text: hit.node.line };
|
|
14716
14759
|
return;
|
|
14717
14760
|
}
|
|
14718
|
-
if (hit && steer) return;
|
|
14761
|
+
if (hit && (steer || turnIntent(heard) === "ask")) return;
|
|
14719
14762
|
if (hit && gen === this.gen && (this.main === "queued" || this.main === "thinking")) {
|
|
14720
14763
|
this.playLeaf(hit, "working", "bridge");
|
|
14721
14764
|
if (this.lastKind === "bridge" && this.bridged) {
|
|
@@ -14770,7 +14813,7 @@ var SecondChannel = class {
|
|
|
14770
14813
|
const opts = this.options;
|
|
14771
14814
|
if (opts.mode === "chatty" && !opts.aec && !this.degradedLogged) {
|
|
14772
14815
|
this.degradedLogged = true;
|
|
14773
|
-
|
|
14816
|
+
log31.info("chatty mode without echo cancellation \u2014 normal timing (our lines would re-trigger the mic)");
|
|
14774
14817
|
}
|
|
14775
14818
|
const rule = this.rule(trigger, pauseMs, breath, cue);
|
|
14776
14819
|
if (rule === "silence") {
|
|
@@ -14789,14 +14832,14 @@ var SecondChannel = class {
|
|
|
14789
14832
|
const d = await withBudget(this.o.decide(this.tail(), { ...this.state(pauseMs), rule }, ac.signal), this.o.decisionBudgetMs, "channel decision", ac);
|
|
14790
14833
|
choice = d?.choice;
|
|
14791
14834
|
if (choice && choice in CHANNEL_ACTIONS && (choice === "silence" || this.allowed(choice))) kind = choice;
|
|
14792
|
-
else if (choice && choice in CHANNEL_ACTIONS)
|
|
14835
|
+
else if (choice && choice in CHANNEL_ACTIONS) log31.debug(`decider chose ${choice} for a ${rule} moment \u2014 the rule stands`);
|
|
14793
14836
|
}
|
|
14794
14837
|
if (kind === "silence") return ev({ choice, acted: "silence" });
|
|
14795
14838
|
if (stale()) return ev({ choice, kind, acted: "stale" });
|
|
14796
14839
|
if (!this.allowed(kind)) return ev({ choice, kind, acted: "gated" });
|
|
14797
14840
|
const react = kind === "backchannel" && !this.answeringUs && this.o.now() - this.lastReactAt >= this.o.reactionGapMs;
|
|
14798
14841
|
const text = cue && react && !this.recent.some((r) => norm3(r) === norm3(cue.line)) ? cue.line : await this.line(kind, react);
|
|
14799
|
-
if (!text) return ev({ choice, kind, acted: "no_bank" });
|
|
14842
|
+
if (!text) return ev({ choice, kind, acted: "no_bank", ...kind === "bridge" && this.ownWords ? { reason: this.noLine || (gen !== this.gen ? "turn moved on" : "no line") } : {} });
|
|
14800
14843
|
if (stale()) return ev({ choice, kind, text, acted: "stale" });
|
|
14801
14844
|
if (!this.allowed(kind)) return ev({ choice, kind, text, acted: "gated" });
|
|
14802
14845
|
const said = this.say(kind, text);
|
|
@@ -14823,13 +14866,15 @@ var SecondChannel = class {
|
|
|
14823
14866
|
this.bridgeDraft = null;
|
|
14824
14867
|
this.askLeaf = null;
|
|
14825
14868
|
this.bridgeReady = Promise.resolve();
|
|
14869
|
+
this.noLine = "";
|
|
14826
14870
|
if (!this.o.generate || !(this.ownWords || this.o.generateFor.includes("bridge")) || !this.lang || !this.heard) return;
|
|
14827
14871
|
const gen = this.gen, ac = new AbortController(), own = this.ownWords, heard = this.heard;
|
|
14828
14872
|
const ctx = { kind: "bridge", heard: this.tail(), state: this.main, avoid: [...this.recent], lang: this.lang, ...own ? { ask: true } : {} };
|
|
14829
14873
|
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) => {
|
|
14830
|
-
const
|
|
14831
|
-
if (text && gen === this.gen &&
|
|
14832
|
-
|
|
14874
|
+
const none = own && /^\s*none\b/i.test(raw ?? ""), text = none ? "" : cleanLine(raw ?? "", ctx.lang), echoes = !own || echoesHeard(text, heard);
|
|
14875
|
+
if (text && gen === this.gen && echoes) this.bridgeDraft = { gen, text };
|
|
14876
|
+
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";
|
|
14877
|
+
}).catch((e) => log31.debug(`bridge prefetch failed: ${e?.message ?? e}`));
|
|
14833
14878
|
}
|
|
14834
14879
|
async line(kind, react = true) {
|
|
14835
14880
|
if (kind === "bridge" && this.ownWords) {
|
|
@@ -14856,7 +14901,7 @@ var SecondChannel = class {
|
|
|
14856
14901
|
if (raw === null) ac.abort();
|
|
14857
14902
|
const text = cleanLine(raw ?? "", this.lang);
|
|
14858
14903
|
if (text && !this.recent.some((r) => norm3(r) === norm3(text))) return text;
|
|
14859
|
-
if (text)
|
|
14904
|
+
if (text) log31.debug(`generated "${text}" repeats a recent line \u2014 canned`);
|
|
14860
14905
|
}
|
|
14861
14906
|
return this.pick(kind);
|
|
14862
14907
|
}
|
|
@@ -14880,7 +14925,7 @@ var SecondChannel = class {
|
|
|
14880
14925
|
try {
|
|
14881
14926
|
r = this.o.speak(text, kind);
|
|
14882
14927
|
} catch (e) {
|
|
14883
|
-
|
|
14928
|
+
log31.warn(`speak threw \u2014 line dropped: ${e.message}`);
|
|
14884
14929
|
return false;
|
|
14885
14930
|
}
|
|
14886
14931
|
if (r === false) return false;
|
|
@@ -14894,7 +14939,7 @@ var SecondChannel = class {
|
|
|
14894
14939
|
if (words3) this.o.show(words3, kind);
|
|
14895
14940
|
const p = Promise.resolve(r).then(() => {
|
|
14896
14941
|
}, (e) => {
|
|
14897
|
-
|
|
14942
|
+
log31.warn(`channel line playback failed: ${e?.message ?? e}`);
|
|
14898
14943
|
}).finally(() => {
|
|
14899
14944
|
if (this.inflight === p) this.inflight = null;
|
|
14900
14945
|
});
|
|
@@ -14943,9 +14988,7 @@ ${personaHint(gender)} Output only the line.` : `You voice the tiny side-sounds
|
|
|
14943
14988
|
The assistant is: ${c.state}.
|
|
14944
14989
|
` + (c.avoid.length ? `Do not reuse any of: ${c.avoid.map((a) => `"${a}"`).join(", ")}.
|
|
14945
14990
|
` : "") + `React to their actual words, casually, in ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
|
|
14946
|
-
|
|
14947
|
-
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, maxTokens: 150, ...reasoning });
|
|
14948
|
-
return r.content ?? "";
|
|
14991
|
+
return fastText(ai, { model, prompt, signal });
|
|
14949
14992
|
};
|
|
14950
14993
|
}
|
|
14951
14994
|
function closedQuestion(reply) {
|
|
@@ -14956,7 +14999,7 @@ function closedQuestion(reply) {
|
|
|
14956
14999
|
}
|
|
14957
15000
|
|
|
14958
15001
|
// src/voice/call.ts
|
|
14959
|
-
var
|
|
15002
|
+
var log32 = forComponent("VoiceCall");
|
|
14960
15003
|
function newWords(text, turn) {
|
|
14961
15004
|
const said = new Set(norm3(turn).split(" "));
|
|
14962
15005
|
return norm3(text).split(" ").filter((w) => w && !said.has(w)).length;
|
|
@@ -15111,7 +15154,7 @@ var VoiceCall = class {
|
|
|
15111
15154
|
const c = this.cur, steers = !!this.o.noteTurn && this.working;
|
|
15112
15155
|
const resumed = !steers || c.marks.mainFirst === void 0 && this.o.now() - c.at < this.o.resumeMs;
|
|
15113
15156
|
if (this.o.mode === "live" && c?.running && !c.worded && resumed && newWords(text, c.text) >= 2) {
|
|
15114
|
-
|
|
15157
|
+
log32.debug("user resumed before the reply \u2014 yielded");
|
|
15115
15158
|
this.giveWay(c);
|
|
15116
15159
|
this.gate.reopen(c.id);
|
|
15117
15160
|
}
|
|
@@ -15130,9 +15173,13 @@ var VoiceCall = class {
|
|
|
15130
15173
|
this.sttLang = o.lang ? primaryLang(o.lang) : null;
|
|
15131
15174
|
this.lastWordAt = typeof lastWordAgoMs === "number" && lastWordAgoMs >= 0 ? now3 - lastWordAgoMs : null;
|
|
15132
15175
|
this.finalAt = now3;
|
|
15176
|
+
this.floor = `${this.floor} ${text}`.trim();
|
|
15177
|
+
if (!endsMidPhrase(text) && turnIntent(this.floor) !== "say") this.fill.onLineEnd();
|
|
15133
15178
|
this.gate.final(text, sttId);
|
|
15134
15179
|
}
|
|
15135
15180
|
finalAt = 0;
|
|
15181
|
+
floor = "";
|
|
15182
|
+
// the finals said since the last turn went out
|
|
15136
15183
|
sttLang = null;
|
|
15137
15184
|
// the STT's language for the final being followed
|
|
15138
15185
|
/** The host's player started a line's audio now (or in `inMs`): `fill`/`progress` = the fill channel's, `main` = MAIN's
|
|
@@ -15232,7 +15279,7 @@ var VoiceCall = class {
|
|
|
15232
15279
|
try {
|
|
15233
15280
|
this.o.cancel();
|
|
15234
15281
|
} catch (e) {
|
|
15235
|
-
|
|
15282
|
+
log32.warn(`cancel threw: ${e.message}`);
|
|
15236
15283
|
}
|
|
15237
15284
|
return;
|
|
15238
15285
|
}
|
|
@@ -15244,7 +15291,7 @@ var VoiceCall = class {
|
|
|
15244
15291
|
try {
|
|
15245
15292
|
this.o.cancel();
|
|
15246
15293
|
} catch (e) {
|
|
15247
|
-
|
|
15294
|
+
log32.warn(`cancel threw: ${e.message}`);
|
|
15248
15295
|
}
|
|
15249
15296
|
if (c?.running) {
|
|
15250
15297
|
c.running = false;
|
|
@@ -15296,6 +15343,7 @@ var VoiceCall = class {
|
|
|
15296
15343
|
if (l) this.fill.setLanguage(l, true);
|
|
15297
15344
|
}
|
|
15298
15345
|
onTurn(t) {
|
|
15346
|
+
this.floor = "";
|
|
15299
15347
|
if (this.o.noteTurn && this.o.workReply && t.kind !== "replace" && this.working && !isClosing(t.text)) return void this.overWork(this.cur, t);
|
|
15300
15348
|
const now3 = this.o.now(), lastWord = this.lastWordAt !== null;
|
|
15301
15349
|
const at = this.lastWordAt ?? this.firstFinalAt ?? now3;
|
|
@@ -15322,6 +15370,7 @@ var VoiceCall = class {
|
|
|
15322
15370
|
this.firstFinalAt = null;
|
|
15323
15371
|
this.lastWordAt = null;
|
|
15324
15372
|
this.earlyHeard = null;
|
|
15373
|
+
this.floor = "";
|
|
15325
15374
|
}
|
|
15326
15375
|
this.o.onMetric({ name: "drop", kind: why, text });
|
|
15327
15376
|
}
|
|
@@ -15332,7 +15381,7 @@ var VoiceCall = class {
|
|
|
15332
15381
|
try {
|
|
15333
15382
|
r = this.o.speak(text, kind);
|
|
15334
15383
|
} catch (e) {
|
|
15335
|
-
|
|
15384
|
+
log32.warn(`speak threw: ${e.message}`);
|
|
15336
15385
|
return false;
|
|
15337
15386
|
}
|
|
15338
15387
|
if (r === false) return false;
|
|
@@ -15392,7 +15441,7 @@ var VoiceCall = class {
|
|
|
15392
15441
|
this.o.onMetric({ name: "turn", id: t.id, kind: "aside", text: t.text });
|
|
15393
15442
|
const ac = new AbortController(), late = setTimeout(() => ac.abort(), this.o.workReplyBudgetMs), lang = this.lang;
|
|
15394
15443
|
const raw = lang ? await this.o.workReply({ request: c.text, heard: t.text, tool: c.tool, hint: argsHint(c.args), lang, avoid: this.progress.recent }, ac.signal).catch((e) => {
|
|
15395
|
-
|
|
15444
|
+
log32.warn(`work reply failed \u2014 MAIN only: ${e?.message ?? e}`);
|
|
15396
15445
|
return "";
|
|
15397
15446
|
}).finally(() => clearTimeout(late)) : "";
|
|
15398
15447
|
const own = cleanWorkReply(raw, lang ?? ""), answer = own || workAck(raw, lang ?? "", this.o.gender);
|