@livx.cc/agentx 0.99.159 → 0.99.161
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/README.md +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +369 -80
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +56 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4214,7 +4214,7 @@ var PermissionPolicy = class {
|
|
|
4214
4214
|
if (this.options.default !== "deny") return void 0;
|
|
4215
4215
|
const gate = async (input) => {
|
|
4216
4216
|
const t = input?.tool_input ?? {}, path = t.file_path ?? t.notebook_path ?? t.path;
|
|
4217
|
-
const d = this.decide({ name: String(input?.tool_name ?? ""), args: { ...t, ...typeof path === "string" ? { path } : {} } });
|
|
4217
|
+
const d = this.decide({ name: String(input?.tool_name ?? "").replace(/^mcp__agentx__/, ""), args: { ...t, ...typeof path === "string" ? { path } : {} } });
|
|
4218
4218
|
return d === "allow" ? {} : { hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: `not on this run's tool allow-list (${input?.tool_name})` } };
|
|
4219
4219
|
};
|
|
4220
4220
|
return { PreToolUse: [{ hooks: [gate] }] };
|
|
@@ -10668,6 +10668,9 @@ var ASIDES = {
|
|
|
10668
10668
|
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?"] }
|
|
10669
10669
|
};
|
|
10670
10670
|
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;
|
|
10671
|
+
var WH_LEAD = "^(?:(?:oh|and|so|wait|but|ok|okay|um|uh|sorry)\\s+)*";
|
|
10672
|
+
var WH_QUESTION = new RegExp(WH_LEAD + "(?:who|whom|whose|where|which|why|how|when|what|\u05DE\u05D9|\u05D0\u05D9\u05E4\u05D4|\u05DC\u05DE\u05D4|\u05D0\u05D9\u05DA|\u05DE\u05EA\u05D9|\u05DE\u05D4)\\s+\\S", "u");
|
|
10673
|
+
var WH_EXCLAIM = new RegExp(WH_LEAD + "(?:what an? |how (?:cool|nice|fun|sweet|sad|funny|weird|crazy|strange|interesting|beautiful|lovely|cute|amazing|awesome)\\b)", "u");
|
|
10671
10674
|
var isReaction = (text) => {
|
|
10672
10675
|
const t = norm2(text);
|
|
10673
10676
|
return REACT.test(t) || new RegExp("\\s\\p{L}{1,3}$", "u").test(t) && REACT.test(t.replace(new RegExp("\\s\\p{L}{1,3}$", "u"), ""));
|
|
@@ -10686,6 +10689,7 @@ function overlapRule(text) {
|
|
|
10686
10689
|
if (!t) return void 0;
|
|
10687
10690
|
if (isClosing(text)) return "cut";
|
|
10688
10691
|
if (HARD.test(t + " ")) return t.includes(" ") ? "cut" : "hold";
|
|
10692
|
+
if (WH_QUESTION.test(t) && !REACT.test(t) && !WH_EXCLAIM.test(t)) return "cut";
|
|
10689
10693
|
for (const p of PHRASES) t = t.split(p).join(" ");
|
|
10690
10694
|
const words5 = t.split(/[\s-]+/).filter(Boolean);
|
|
10691
10695
|
const ack = (w) => ACK.has(w) || HE_ACK.has(w) || /^(?:ha)+h?$|^(?:he)+h?$|^m+(?:hm+)?$|^h?m+$/.test(w);
|
|
@@ -10697,7 +10701,7 @@ function overlapRule(text) {
|
|
|
10697
10701
|
function fastOverlapModel(ai, model = "groq/qwen/qwen3.8-27b") {
|
|
10698
10702
|
return async (heard, signal) => {
|
|
10699
10703
|
const prompt = 'Live voice call. The assistant is mid-sentence and the user just said this over it: "' + heard + `"
|
|
10700
|
-
Are they STEERING \u2014 asking for something new, asking a real question about it, correcting it, telling it to stop, or saying goodbye? A reaction is not steering: surprise, disbelief, "what?", "really?", "you're serious?", "that's serious", agreement, a laugh \u2014 the assistant just carries on.
|
|
10704
|
+
Are they STEERING \u2014 asking for something new, asking a real question about it, correcting it, telling it to stop, or saying goodbye? A question about what it said ("who did that?", "where?", "which one?") IS steering. A reaction is not steering: surprise, disbelief, a lone "what?", "really?", "you're serious?", "that's serious", agreement, a laugh \u2014 the assistant just carries on.
|
|
10701
10705
|
Answer yes (steering) or no (a reaction).`;
|
|
10702
10706
|
const reasoning = /qwen/.test(model) ? { providerOptions: { reasoning_effort: "none" } } : /gpt-oss/.test(model) ? { providerOptions: { reasoning_effort: "low" } } : {};
|
|
10703
10707
|
const r = await ai.chat({ model, messages: [{ role: "user", content: prompt }], stream: false, signal, temperature: 0, maxTokens: /gpt-oss/.test(model) ? 200 : 3, ...reasoning });
|
|
@@ -10787,6 +10791,19 @@ function voiceDecider(env = process.env, timeoutMs = 1500) {
|
|
|
10787
10791
|
const llm = new LlmDecideAdapter({ client: { chat: (c) => ai.chat({ reasoningEffort: "low", ...c }) } });
|
|
10788
10792
|
return new DecideClient({ ...o, timeoutMs, adapters: { typesafe: new JevAdapter(), llm } });
|
|
10789
10793
|
}
|
|
10794
|
+
var TURN_ACTIONS = {
|
|
10795
|
+
answer: "Their line is complete and calls for your reply now (a question, a request, a greeting, an answer to what you asked).",
|
|
10796
|
+
ack_then_answer: "Complete, and a real answer needs a moment: a short acknowledgement now, then the answer.",
|
|
10797
|
+
backchannel: 'They are telling something longer and only paused: a tiny listener sound ("mm", "right") at most, keep listening.',
|
|
10798
|
+
wait: 'They are mid-thought (cut off, a list, "and...", a number being said): say nothing, they will go on.',
|
|
10799
|
+
silence: "Not for you to answer (a recording, a menu, talk to someone else, or an ending that needs nothing)."
|
|
10800
|
+
};
|
|
10801
|
+
function turnJudgeFor(env = process.env, timeoutMs = 900) {
|
|
10802
|
+
const decider = voiceDecider(env, timeoutMs);
|
|
10803
|
+
if (!decider) return void 0;
|
|
10804
|
+
const instinct = new Instinct({ decider });
|
|
10805
|
+
return (heard, state) => instinct.turnEnd(heard, state);
|
|
10806
|
+
}
|
|
10790
10807
|
var InstinctOptions = class {
|
|
10791
10808
|
decider;
|
|
10792
10809
|
/** Partial unchanged this long (a micro-pause) → consult. */
|
|
@@ -11112,6 +11129,18 @@ var Instinct = class {
|
|
|
11112
11129
|
CHANNEL_ACTIONS
|
|
11113
11130
|
);
|
|
11114
11131
|
}
|
|
11132
|
+
/** A held final (the STT ended a line; the gate waits to see if more comes): is it our turn, and how to react.
|
|
11133
|
+
* answer / ack_then_answer → the turn goes out now; wait / backchannel → it waits the long hold; silence → it goes
|
|
11134
|
+
* out and the quick lane may stay quiet. The choice also reaches the quick lane as a hint. */
|
|
11135
|
+
turnEnd(heard, state = {}) {
|
|
11136
|
+
return this.ask(
|
|
11137
|
+
"turn_end",
|
|
11138
|
+
heard,
|
|
11139
|
+
{ their_line: heard, ...state },
|
|
11140
|
+
FRAME + "The other person just paused after this line. Decide, as a person on a phone call would, whether it is your turn now and how you would react.",
|
|
11141
|
+
TURN_ACTIONS
|
|
11142
|
+
);
|
|
11143
|
+
}
|
|
11115
11144
|
/** A random phrase from `pool`, never the one said last (no back-to-back repeat across keys). */
|
|
11116
11145
|
rotate(pool) {
|
|
11117
11146
|
const fresh = pool.filter((x) => x !== this.lastAckSaid);
|
|
@@ -11449,18 +11478,18 @@ function fitsLanguage(line, lang) {
|
|
|
11449
11478
|
return !ws.some((w) => !mine?.has(w) && Object.entries(STOP3).some(([l, s]) => l !== lang && s.has(w)));
|
|
11450
11479
|
}
|
|
11451
11480
|
var norm3 = (s) => s.toLowerCase().replace(/[^\p{L}\p{N}' ]/gu, "").replace(/\s+/g, " ").trim();
|
|
11452
|
-
function cleanLine(s, lang, maxWords = 6) {
|
|
11481
|
+
function cleanLine(s, lang, maxWords = 6, maxChars = 60) {
|
|
11453
11482
|
if (/^(?:gasp|quiet|laughter)[.!?…]*$/i.test(s.trim())) return "";
|
|
11454
11483
|
const first = s.trim().split("\n")[0];
|
|
11455
11484
|
const tags = [...first.matchAll(LINE_TAG)].map((m) => `[${m[1].toLowerCase()}]`).filter((t, i, a) => a.indexOf(t) === i).join(" ");
|
|
11456
11485
|
const raw = first.replace(LINE_TAG, " ").trim();
|
|
11457
11486
|
if (tags && !/[\p{L}\p{N}]/u.test(raw)) return /laughter|gasp/.test(tags) ? tags : "";
|
|
11458
|
-
const words5 = cleanWords(raw, lang, maxWords);
|
|
11487
|
+
const words5 = cleanWords(raw, lang, maxWords, maxChars);
|
|
11459
11488
|
return words5 && tags ? `${tags} ${words5}` : words5;
|
|
11460
11489
|
}
|
|
11461
11490
|
var LINE_TAG = /\[(laughter|gasp|quiet)\]/gi;
|
|
11462
11491
|
var lineWords = (line) => line.replace(LINE_TAG, " ").trim();
|
|
11463
|
-
function cleanWords(raw, lang, maxWords) {
|
|
11492
|
+
function cleanWords(raw, lang, maxWords, maxChars = 60) {
|
|
11464
11493
|
const l = raw.replace(/^[-*•\d.)\s]+/, "").replace(/^["'“”«»]+|["'“”«»]+$/g, "").replace(new RegExp("^\\p{L}+:\\s*", "u"), "").trim();
|
|
11465
11494
|
if (!l || isLeakSuspect(raw) || isLeakSuspect(l)) {
|
|
11466
11495
|
if (l) log23.debug(`line "${raw}" reads as meta \u2014 rejected`);
|
|
@@ -11470,7 +11499,7 @@ function cleanWords(raw, lang, maxWords) {
|
|
|
11470
11499
|
log23.debug(`line "${l}" is not ${lang} \u2014 rejected`);
|
|
11471
11500
|
return "";
|
|
11472
11501
|
}
|
|
11473
|
-
return l.split(/\s+/).length > maxWords || l.length >
|
|
11502
|
+
return l.split(/\s+/).length > maxWords || l.length > maxChars ? "" : l;
|
|
11474
11503
|
}
|
|
11475
11504
|
var SPEAKER_FILLER = /^(?:so|well|actually|basically|anyway|anyways|like|you know|i mean|kind of|sort of|literally|honestly|and|but|because|then|the thing is)\b/i;
|
|
11476
11505
|
function validateBank(raw, lang, minPerKind = 3) {
|
|
@@ -11762,6 +11791,21 @@ var TurnGate = class {
|
|
|
11762
11791
|
clearTimeout(h.timer);
|
|
11763
11792
|
h.timer = setTimeout(() => this.settle(), h.ms);
|
|
11764
11793
|
}
|
|
11794
|
+
/** A turn judge says the held `text` is a whole turn: send it now (not while they are mid-line). */
|
|
11795
|
+
release(text) {
|
|
11796
|
+
const h = this.held;
|
|
11797
|
+
if (!h || h.talking || norm3(h.text) !== norm3(text)) return false;
|
|
11798
|
+
this.flush();
|
|
11799
|
+
return true;
|
|
11800
|
+
}
|
|
11801
|
+
/** A turn judge says they are not done: the held `text` waits the long hold (more speech still merges in). */
|
|
11802
|
+
extend(text) {
|
|
11803
|
+
const h = this.held;
|
|
11804
|
+
if (!h || norm3(h.text) !== norm3(text) || h.ms >= this.o.holdMs) return;
|
|
11805
|
+
h.ms = this.o.holdMs;
|
|
11806
|
+
clearTimeout(h.timer);
|
|
11807
|
+
h.timer = setTimeout(() => this.settle(), h.ms);
|
|
11808
|
+
}
|
|
11765
11809
|
/** The hold's quiet ran out: send it — unless the user is mid-line (a partial with no final yet). */
|
|
11766
11810
|
settle() {
|
|
11767
11811
|
const h = this.held;
|
|
@@ -14930,6 +14974,7 @@ var SecondChannel = class {
|
|
|
14930
14974
|
const preset = CHANNEL_MODES[options?.mode ?? "normal"] ?? {};
|
|
14931
14975
|
const base = new SecondChannelOptions();
|
|
14932
14976
|
this.options = { ...base, ...preset, ...options };
|
|
14977
|
+
if (process.env.AGENTX_CALL_ROLE === "caller") this.options.kinds = (this.options.kinds ?? []).filter((k) => k === "backchannel");
|
|
14933
14978
|
for (const k of Object.keys(preset)) if (!options || !(k in options)) this.normalTiming[k] = base[k];
|
|
14934
14979
|
this.startedAt = this.o.now();
|
|
14935
14980
|
if (this.o.lang) this.setLanguage(this.o.lang, true);
|
|
@@ -15696,6 +15741,9 @@ var VoiceCallOptions = class {
|
|
|
15696
15741
|
};
|
|
15697
15742
|
/** The fast model (lines, banks, progress) — used only with `ai`. */
|
|
15698
15743
|
fastModel = latestClaude("haiku");
|
|
15744
|
+
/** The turn-end judge (Instinct.turnEnd over Jev): a held final goes out at once or waits, and its read of how to
|
|
15745
|
+
* react reaches the quick lane. Absent → the gate's timers alone. */
|
|
15746
|
+
turnJudge;
|
|
15699
15747
|
/** Model client for the fast model + the channel decider / overlap judge. Absent → canned lines and rules only. */
|
|
15700
15748
|
ai;
|
|
15701
15749
|
/** Cache dir for per-language banks (ChannelBanks). */
|
|
@@ -15771,7 +15819,10 @@ var VoiceCall = class {
|
|
|
15771
15819
|
...o.gate,
|
|
15772
15820
|
onTurn: (t) => this.onTurn(t),
|
|
15773
15821
|
onDrop: (text, why) => this.onDrop(text, why),
|
|
15774
|
-
onHold: (text) =>
|
|
15822
|
+
onHold: (text) => {
|
|
15823
|
+
o.onMetric({ name: "hold", text });
|
|
15824
|
+
this.judgeHold(text);
|
|
15825
|
+
}
|
|
15775
15826
|
});
|
|
15776
15827
|
}
|
|
15777
15828
|
options;
|
|
@@ -15800,6 +15851,20 @@ var VoiceCall = class {
|
|
|
15800
15851
|
get o() {
|
|
15801
15852
|
return this.options;
|
|
15802
15853
|
}
|
|
15854
|
+
/** The turn judge's last read (choice for `text`): the quick lane's hint for that turn. */
|
|
15855
|
+
hint;
|
|
15856
|
+
judgeHold(text) {
|
|
15857
|
+
const j = this.o.turnJudge;
|
|
15858
|
+
if (!j || this.ended) return;
|
|
15859
|
+
const said = [...this.history].reverse().find((h) => h.who === "you")?.text;
|
|
15860
|
+
j(text, { agent_last_said: said ?? null, agent_speaking: !!this.cur?.running }).then((d) => {
|
|
15861
|
+
if (!d) return;
|
|
15862
|
+
this.hint = { text, choice: d.choice };
|
|
15863
|
+
const go = d.choice === "answer" || d.choice === "ack_then_answer" || d.choice === "silence";
|
|
15864
|
+
const acted2 = go ? this.gate.release(text) ? "released" : "late" : (this.gate.extend(text), "extended");
|
|
15865
|
+
this.o.onMetric({ name: "judge", ms: d.ms, kind: `${d.choice} ${acted2}`, text });
|
|
15866
|
+
}).catch((e) => log31.warn(`turn judge failed \u2014 the gate's timers decide: ${e?.message ?? e}`));
|
|
15867
|
+
}
|
|
15803
15868
|
/** The language the fill channel speaks right now (null = unknown → silent). */
|
|
15804
15869
|
get language() {
|
|
15805
15870
|
return this.lang;
|
|
@@ -16120,7 +16185,7 @@ var VoiceCall = class {
|
|
|
16120
16185
|
const ac = new AbortController(), t0 = this.o.now(), lang = this.lang, rest = this.cutRest;
|
|
16121
16186
|
c.ask = ac;
|
|
16122
16187
|
const late = setTimeout(() => ac.abort(), this.o.quickBudgetMs);
|
|
16123
|
-
const mv = lang ? await this.o.quick({ history: this.history.slice(0, -1), heard: t.text, lang, rest }, ac.signal).catch((e) => {
|
|
16188
|
+
const mv = lang ? await this.o.quick({ history: this.history.slice(0, -1), heard: t.text, lang, rest, ...this.hint && t.text.includes(this.hint.text) ? { hint: this.hint.choice } : {} }, ac.signal).catch((e) => {
|
|
16124
16189
|
if (this.cur === c) log31.warn(`quick lane ${ac.signal.aborted ? `late (${this.o.quickBudgetMs}ms)` : `failed: ${e?.message ?? e}`} \u2014 deep lane`);
|
|
16125
16190
|
return null;
|
|
16126
16191
|
}).finally(() => clearTimeout(late)) : null;
|
|
@@ -16152,7 +16217,8 @@ var VoiceCall = class {
|
|
|
16152
16217
|
c.due = false;
|
|
16153
16218
|
return this.close(c, "silent");
|
|
16154
16219
|
}
|
|
16155
|
-
const
|
|
16220
|
+
const cutAt = () => cutSentence([...this.history].reverse().find((h) => h.who === "you" && h.cut)?.text ?? "");
|
|
16221
|
+
const said = mv.kind === "resume" ? `${mv.line} ${cutAt()} ${rest}`.replace(/\s+/g, " ").trim() : mv.kind === "clarify" ? `${mv.line} ${lang && BACK_TO[lang] || ""} ${cutAt()} ${rest}`.replace(/\s+/g, " ").trim() : mv.line;
|
|
16156
16222
|
this.gate.replyStarted(c.id);
|
|
16157
16223
|
const end = mv.kind === "say" && !!mv.end;
|
|
16158
16224
|
if (end) try {
|
|
@@ -16168,6 +16234,11 @@ var VoiceCall = class {
|
|
|
16168
16234
|
this.o.dropCut?.();
|
|
16169
16235
|
this.history.push({ who: "you", text: rest });
|
|
16170
16236
|
note(`They asked you to go on, and you continued your cut answer aloud: "${rest}". All of it has now been said.`);
|
|
16237
|
+
} else if (mv.kind === "clarify") {
|
|
16238
|
+
this.cutRest = "";
|
|
16239
|
+
this.o.dropCut?.();
|
|
16240
|
+
this.history.push({ who: "you", text: mv.line }, { who: "you", text: rest });
|
|
16241
|
+
note(`They cut your answer to ask "${t.text}". You (the call's quick voice) answered aloud "${mv.line}" and then continued your cut answer: "${rest}". All of it has now been said.`);
|
|
16171
16242
|
} else {
|
|
16172
16243
|
this.history.push({ who: "you", text: said });
|
|
16173
16244
|
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.`);
|
|
@@ -16356,6 +16427,7 @@ var VoiceCall = class {
|
|
|
16356
16427
|
}
|
|
16357
16428
|
}
|
|
16358
16429
|
};
|
|
16430
|
+
var BACK_TO = { en: "Anyway,", he: "\u05D1\u05DB\u05DC \u05DE\u05E7\u05E8\u05D4," };
|
|
16359
16431
|
function cutSentence(heard) {
|
|
16360
16432
|
const tail = heard.trim().split(/(?<=[.!?…])\s+/).at(-1) ?? "";
|
|
16361
16433
|
if (!tail || /[.!?…]["'”’)]*$/.test(tail)) return "";
|
|
@@ -17003,7 +17075,7 @@ function defaultOpenBrowser(url) {
|
|
|
17003
17075
|
import { randomUUID } from "crypto";
|
|
17004
17076
|
import { execFile as execFile3 } from "child_process";
|
|
17005
17077
|
import { resolve as resolve3, basename as basename3, join as join7 } from "path";
|
|
17006
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync4 } from "fs";
|
|
17078
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync4, realpathSync as realpathSync3 } from "fs";
|
|
17007
17079
|
import { platform, arch, release, userInfo, homedir as homedir2, tmpdir } from "os";
|
|
17008
17080
|
init_tools_shell();
|
|
17009
17081
|
|
|
@@ -17177,6 +17249,7 @@ function claudeCodeProviderOptions(model, cwd, mcpServers) {
|
|
|
17177
17249
|
function providerOptionsFor(model, cwd, mcpServers, hostMcpServers) {
|
|
17178
17250
|
return cursorProviderOptions(model, cwd, mcpServers, hostMcpServers) ?? claudeCodeProviderOptions(model, cwd, mcpServers);
|
|
17179
17251
|
}
|
|
17252
|
+
var CONFINE_DENY = ["**/.agent", "**/.agent/**", "**/.claude", "**/.claude/**", "**/.mcp.json", "**/AGENTS.md", "**/CLAUDE.md", "**/CLAUDE.local.md"];
|
|
17180
17253
|
async function buildAgent(o) {
|
|
17181
17254
|
if (typeof o.sandbox !== "boolean")
|
|
17182
17255
|
throw new Error(
|
|
@@ -17215,7 +17288,23 @@ async function buildAgent(o) {
|
|
|
17215
17288
|
fs = bod;
|
|
17216
17289
|
}
|
|
17217
17290
|
let mountNote = "";
|
|
17218
|
-
if (o.
|
|
17291
|
+
if (o.confine) {
|
|
17292
|
+
if (virtual) throw new Error("--confine is a disk-mode jail; --sandbox/--boddb already contain the agent.");
|
|
17293
|
+
if (isClaudeCode && o.permissions?.options.default !== "deny") throw new Error("claude-code/* can be confined only with an allow-list (--onlyTools): its own tools bypass the jail.");
|
|
17294
|
+
const roots = [...new Set([cwd, ...o.addDirs ?? []].map((d) => realpathSync3(resolve3(d))))];
|
|
17295
|
+
const mem = new MemFilesystem3();
|
|
17296
|
+
for (const r of roots) await mkdirp(mem, r);
|
|
17297
|
+
mem.setCwd(roots[0]);
|
|
17298
|
+
const mounts = [];
|
|
17299
|
+
for (const r of roots) {
|
|
17300
|
+
const d = new NodeDiskFilesystem(r);
|
|
17301
|
+
await d.init();
|
|
17302
|
+
mounts.push({ prefix: r, fs: new JailedFilesystem(d, { deny: [...DEFAULT_DENY, ...CONFINE_DENY] }) });
|
|
17303
|
+
}
|
|
17304
|
+
fs = new MountFilesystem(new JailedFilesystem(mem, { confineTo: [] }), mounts);
|
|
17305
|
+
if (roots.length > 1) mountNote = `You can reach ONLY these directories (read/write), by their full path:
|
|
17306
|
+
${roots.join("\n")}`;
|
|
17307
|
+
} else if (o.addDirs?.length && !virtual) {
|
|
17219
17308
|
const used = /* @__PURE__ */ new Set();
|
|
17220
17309
|
const mounts = [];
|
|
17221
17310
|
const notes = [];
|
|
@@ -17289,8 +17378,13 @@ Reference files in them by their mount path (the left side).`;
|
|
|
17289
17378
|
// Warm cursor session (default on; CURSOR_WARM=0 to disable): one long-lived agent reused across
|
|
17290
17379
|
// turns, amortising the ~2s Agent.create + h2 handshake. Keyed per agentx launch.
|
|
17291
17380
|
...(() => {
|
|
17292
|
-
|
|
17293
|
-
|
|
17381
|
+
let po = providerOptionsFor(o.model, cwd, o.mcpServers, o.hostMcpServers);
|
|
17382
|
+
if (po && o.lean && isClaudeCode) po = { ...po, settingSources: [] };
|
|
17383
|
+
if (po && o.confine && isClaudeCode) {
|
|
17384
|
+
if (!po.claudeCodeSession) throw new Error("claude-code/* cannot be confined without the warm session (AGENTX_CC_WARM=0): its own tools would bypass the jail.");
|
|
17385
|
+
return { providerOptions: { ...po, tools: [] }, ccBridge: "all" };
|
|
17386
|
+
}
|
|
17387
|
+
return po ? { providerOptions: po } : {};
|
|
17294
17388
|
})(),
|
|
17295
17389
|
// A child on ANOTHER provider (delegate mode's anthropic planner → claude-code/* worker, or back) gets that
|
|
17296
17390
|
// runtime's own options (cwd, env, MCP) — the Agent default inherits only same-provider options, so a claude-code
|
|
@@ -17331,7 +17425,7 @@ Windows paths: file tools accept ${cwd} style paths and the same path written ${
|
|
|
17331
17425
|
return { systemPrompt: basePrompt + "\n\n" + extra };
|
|
17332
17426
|
})(),
|
|
17333
17427
|
tools: (() => {
|
|
17334
|
-
if (isClaudeCode) return [];
|
|
17428
|
+
if (isClaudeCode) return o.confine ? toolsByName(o.tools ?? DEFAULT_TOOLS).filter((t) => o.permissions?.decide({ name: t.name, args: {} }) !== "deny") : [];
|
|
17335
17429
|
const requested = o.tools ?? DEFAULT_TOOLS;
|
|
17336
17430
|
const base = toolsByName([...requested, ...autoWebTools()]);
|
|
17337
17431
|
const tail = [...o.extraTools ?? []];
|
|
@@ -17579,6 +17673,7 @@ var NodeMicSource = class {
|
|
|
17579
17673
|
}, 500).unref?.();
|
|
17580
17674
|
}
|
|
17581
17675
|
};
|
|
17676
|
+
var vpioProbeMs = () => Number(process.env.MIC_VPIO_PROBE_MS) || 5e3;
|
|
17582
17677
|
var AecDuplexAudio = class {
|
|
17583
17678
|
constructor(bin) {
|
|
17584
17679
|
this.bin = bin;
|
|
@@ -17607,6 +17702,9 @@ var AecDuplexAudio = class {
|
|
|
17607
17702
|
fallbackTimer = null;
|
|
17608
17703
|
bytesWritten = 0;
|
|
17609
17704
|
startedAt = 0;
|
|
17705
|
+
/** This turn's TTS while VPIO is unproven (no mic chunk yet). A dead VPIO engine plays nothing either, so the
|
|
17706
|
+
* fallback helper replays it — else the greeting, spoken inside the VPIO probe window, is never heard. */
|
|
17707
|
+
unproven = [];
|
|
17610
17708
|
// --- AudioSource ---
|
|
17611
17709
|
start(onChunk) {
|
|
17612
17710
|
this.onChunk = onChunk;
|
|
@@ -17619,7 +17717,7 @@ var AecDuplexAudio = class {
|
|
|
17619
17717
|
this.spawnHelper();
|
|
17620
17718
|
}
|
|
17621
17719
|
/** (Re)spawn the helper. On the first spawn, arm a fast watchdog: if VPIO delivers NO audio within
|
|
17622
|
-
*
|
|
17720
|
+
* vpioProbeMs(), the VP input tap is dead on this machine (seen on macOS 26.5.x) — respawn once with
|
|
17623
17721
|
* MIC_NO_VPIO=1 (plain capture, heuristic echo) so the mic actually works instead of starving STT. */
|
|
17624
17722
|
spawnHelper() {
|
|
17625
17723
|
const env = this.noVpio ? { ...process.env, MIC_NO_VPIO: "1" } : process.env;
|
|
@@ -17630,7 +17728,10 @@ var AecDuplexAudio = class {
|
|
|
17630
17728
|
if (c && !this.stopped) log36.error(`aec duplex audio exited (${c}) \u2014 check mic permission / MIC_AEC=0`);
|
|
17631
17729
|
});
|
|
17632
17730
|
this.proc.stdout.on("data", (chunk) => {
|
|
17633
|
-
this.gotChunk
|
|
17731
|
+
if (!this.gotChunk) {
|
|
17732
|
+
this.gotChunk = true;
|
|
17733
|
+
this.unproven = [];
|
|
17734
|
+
}
|
|
17634
17735
|
this.onChunk(chunk);
|
|
17635
17736
|
});
|
|
17636
17737
|
this.proc.stderr.on("data", (d) => {
|
|
@@ -17652,11 +17753,19 @@ var AecDuplexAudio = class {
|
|
|
17652
17753
|
this.triedFallback = true;
|
|
17653
17754
|
this.noVpio = true;
|
|
17654
17755
|
this._aec = false;
|
|
17655
|
-
log36.warn(
|
|
17756
|
+
log36.warn(`mic-aec: VPIO delivered no audio in ${vpioProbeMs() / 1e3}s \u2014 falling back to non-VPIO capture (no AEC \u2192 half-duplex, no barge-in)`);
|
|
17656
17757
|
this.onDegrade?.();
|
|
17657
17758
|
this.killProc();
|
|
17658
17759
|
this.spawnHelper();
|
|
17659
|
-
|
|
17760
|
+
const replay = this.unproven;
|
|
17761
|
+
this.unproven = [];
|
|
17762
|
+
if (replay.length) {
|
|
17763
|
+
this.startedAt = now3();
|
|
17764
|
+
this.pausedSince = 0;
|
|
17765
|
+
this.pausedAccum = 0;
|
|
17766
|
+
for (const c of replay) this.frame(c);
|
|
17767
|
+
}
|
|
17768
|
+
}, vpioProbeMs());
|
|
17660
17769
|
this.fallbackTimer.unref?.();
|
|
17661
17770
|
}
|
|
17662
17771
|
}
|
|
@@ -17691,12 +17800,14 @@ var AecDuplexAudio = class {
|
|
|
17691
17800
|
this.frame(null);
|
|
17692
17801
|
this.bytesWritten = 0;
|
|
17693
17802
|
this.startedAt = 0;
|
|
17803
|
+
this.unproven = [];
|
|
17694
17804
|
this.pausedSince = 0;
|
|
17695
17805
|
this.pausedAccum = 0;
|
|
17696
17806
|
}
|
|
17697
17807
|
write(chunk) {
|
|
17698
17808
|
if (!this.startedAt) this.startedAt = now3();
|
|
17699
17809
|
this.bytesWritten += chunk.length;
|
|
17810
|
+
if (!this.gotChunk && !this.noVpio) this.unproven.push(chunk);
|
|
17700
17811
|
this.frame(chunk);
|
|
17701
17812
|
}
|
|
17702
17813
|
playedMs() {
|
|
@@ -17712,6 +17823,7 @@ var AecDuplexAudio = class {
|
|
|
17712
17823
|
this.frame(null);
|
|
17713
17824
|
this.bytesWritten = 0;
|
|
17714
17825
|
this.startedAt = 0;
|
|
17826
|
+
this.unproven = [];
|
|
17715
17827
|
this.pausedSince = 0;
|
|
17716
17828
|
this.pausedAccum = 0;
|
|
17717
17829
|
}
|
|
@@ -18040,7 +18152,7 @@ var VoiceIO = class extends VoiceEngine {
|
|
|
18040
18152
|
const duplex = bin ? new AecDuplexAudio(bin) : null;
|
|
18041
18153
|
super({
|
|
18042
18154
|
...o,
|
|
18043
|
-
stt: o.stt ?? new SonioxSTT({ auth: o.sonioxApiKey, source: duplex ?? new NodeMicSource(), terms: o.sttTerms }),
|
|
18155
|
+
stt: o.stt ?? new SonioxSTT({ auth: o.sonioxApiKey, source: duplex ?? new NodeMicSource(), terms: o.sttTerms, agentTextInput: true }),
|
|
18044
18156
|
tts: o.tts ?? new CartesiaTTS({ auth: o.cartesiaApiKey, voiceId: o.cartesiaVoiceId }),
|
|
18045
18157
|
asideTts: o.tts ? o.asideTts : new CartesiaTTS({ auth: o.cartesiaApiKey, voiceId: o.cartesiaVoiceId }),
|
|
18046
18158
|
// asides (VoiceCall.aside): a 2nd client — the reply's context may still stream
|
|
@@ -18384,9 +18496,68 @@ ${o.persona}
|
|
|
18384
18496
|
return line || o.fallback;
|
|
18385
18497
|
}
|
|
18386
18498
|
|
|
18499
|
+
// src/voice/menuKeys.ts
|
|
18500
|
+
init_logging();
|
|
18501
|
+
var log39 = forComponent("MenuKeys");
|
|
18502
|
+
var MenuKeysOptions = class {
|
|
18503
|
+
ai;
|
|
18504
|
+
model = "groq/openai/gpt-oss-120b";
|
|
18505
|
+
/** Who we are and what the call is for (the call persona / task). */
|
|
18506
|
+
persona = "";
|
|
18507
|
+
timeoutMs = 4e3;
|
|
18508
|
+
};
|
|
18509
|
+
var MenuKeys = class _MenuKeys {
|
|
18510
|
+
options;
|
|
18511
|
+
/** The menu so far: each line heard, and what we pressed after it. */
|
|
18512
|
+
steps = [];
|
|
18513
|
+
constructor(options) {
|
|
18514
|
+
this.options = { ...new MenuKeysOptions(), ...options };
|
|
18515
|
+
}
|
|
18516
|
+
/** The prompt for the menu so far (exported for tests). */
|
|
18517
|
+
static prompt(persona, steps) {
|
|
18518
|
+
const menu = steps.map((s) => `MENU: ${s.line}${s.pressed ? `
|
|
18519
|
+
YOU PRESSED: ${s.pressed}` : ""}`).join("\n");
|
|
18520
|
+
return `${persona.slice(0, 800)}
|
|
18521
|
+
|
|
18522
|
+
You placed this call and an automated phone menu is playing. What it said so far, oldest first:
|
|
18523
|
+
${menu}
|
|
18524
|
+
|
|
18525
|
+
Which key(s) do you press NOW for your task? Answer with only the keys (digits, * or #, e.g. "1" or "2#"), or WAIT when: the option for your task was not said yet, it is a greeting/recording/hold message, you already pressed for this same menu, or it asks for something the task does not give (an ID, a number). After "wrong key"/"invalid choice", press the right key for the menu again.`;
|
|
18526
|
+
}
|
|
18527
|
+
/** "1", "2#", "WAIT", "Press 1." … → the keys, or '' (wait). */
|
|
18528
|
+
static parse(raw) {
|
|
18529
|
+
const t = raw.trim().replace(/^["'`]+|["'`.]+$/g, "");
|
|
18530
|
+
if (/^wait\b/i.test(t)) return "";
|
|
18531
|
+
const m = t.match(/^(?:press\s*)?([0-9*#]{1,12})$/i);
|
|
18532
|
+
return m ? m[1] : "";
|
|
18533
|
+
}
|
|
18534
|
+
/** A menu line was heard: the keys to press now, or '' (wait). */
|
|
18535
|
+
async hear(line) {
|
|
18536
|
+
const t0 = performance.now();
|
|
18537
|
+
this.steps.push({ line });
|
|
18538
|
+
const ac = new AbortController(), timer = setTimeout(() => ac.abort(), this.options.timeoutMs);
|
|
18539
|
+
try {
|
|
18540
|
+
const raw = await fastText(this.options.ai, { model: this.options.model, prompt: _MenuKeys.prompt(this.options.persona, this.steps.slice(-8)), signal: ac.signal, maxTokens: 20, temperature: 0 });
|
|
18541
|
+
const digits = _MenuKeys.parse(raw);
|
|
18542
|
+
if (digits) this.steps[this.steps.length - 1].pressed = digits;
|
|
18543
|
+
return { digits, ms: Math.round(performance.now() - t0) };
|
|
18544
|
+
} catch (e) {
|
|
18545
|
+
log39.debug(`menu keys failed \u2014 the main agent decides: ${e?.message ?? e}`);
|
|
18546
|
+
return { digits: "", ms: Math.round(performance.now() - t0) };
|
|
18547
|
+
} finally {
|
|
18548
|
+
clearTimeout(timer);
|
|
18549
|
+
}
|
|
18550
|
+
}
|
|
18551
|
+
/** The host pressed keys itself (the main agent's press_keys): later reads know it. */
|
|
18552
|
+
pressed(digits) {
|
|
18553
|
+
const s = this.steps.at(-1);
|
|
18554
|
+
if (s) s.pressed = digits;
|
|
18555
|
+
}
|
|
18556
|
+
};
|
|
18557
|
+
|
|
18387
18558
|
// src/voice/quickLane.ts
|
|
18388
18559
|
init_logging();
|
|
18389
|
-
var
|
|
18560
|
+
var log40 = forComponent("QuickLane");
|
|
18390
18561
|
var SAY_WORDS = 30;
|
|
18391
18562
|
var ACK_WORDS = 10;
|
|
18392
18563
|
var ACKS = { en: ["On it.", "Sure, one sec.", "Okay.", "Alright."], he: ["\u05E8\u05D2\u05E2 \u05D0\u05D7\u05D3.", "\u05D0\u05D5\u05E7\u05D9\u05D9, \u05E9\u05E0\u05D9\u05D9\u05D4.", "\u05E9\u05E0\u05D9\u05D9\u05D4."] };
|
|
@@ -18408,9 +18579,20 @@ var ownLine = (pool, c) => {
|
|
|
18408
18579
|
return (pool ?? []).find((x) => !said.has(norm3(x))) ?? "";
|
|
18409
18580
|
};
|
|
18410
18581
|
function rawMove(raw, c) {
|
|
18411
|
-
const m = /^\s*(SAY|BYE|DEEP|RESUME|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
|
|
18582
|
+
const m = /^\s*(SAY|BYE|DEEP|RESUME|CLARIFY|QUIET)\b\s*:?\s*(.*)$/im.exec(raw.trim());
|
|
18412
18583
|
if (!m) return null;
|
|
18413
18584
|
const bye = m[1].toUpperCase() === "BYE", kind = bye ? "SAY" : m[1].toUpperCase(), body = m[2].trim();
|
|
18585
|
+
if (kind === "CLARIFY") {
|
|
18586
|
+
const deep = { kind: "deep", ack: stockAck(c), brief: "" };
|
|
18587
|
+
if (!c.rest) return deep;
|
|
18588
|
+
const [ans = "", quote = ""] = body.split("|").map((s) => s.trim());
|
|
18589
|
+
const line2 = sayLine(ans, c.lang);
|
|
18590
|
+
if (!line2) return null;
|
|
18591
|
+
if (unknownFacts(line2, c).length || novelWords(line2, c).length >= 2) return deep;
|
|
18592
|
+
const answer = norm3([...c.history.filter((h) => h.who === "you" && h.cut).slice(-1).map((h) => h.text), c.rest].join(" ")), q2 = norm3(quote);
|
|
18593
|
+
if (!q2 || !answer.includes(q2) || !asksAbout(c.heard, q2) || novelWords(line2, c, quote).length < novelWords(line2, c, answer).length) return deep;
|
|
18594
|
+
return { kind: "clarify", line: line2 };
|
|
18595
|
+
}
|
|
18414
18596
|
const owns = quickOwns(c.heard);
|
|
18415
18597
|
if (!owns && kind !== "DEEP") return { kind: "deep", ack: stockAck(c), brief: "" };
|
|
18416
18598
|
if (kind === "QUIET") return { kind: "quiet" };
|
|
@@ -18420,7 +18602,7 @@ function rawMove(raw, c) {
|
|
|
18420
18602
|
}
|
|
18421
18603
|
if (kind === "DEEP") {
|
|
18422
18604
|
const [ack = "", brief = ""] = body.split(body.includes("|") ? "|" : /\s+[—–-]\s+/).map((s) => s.trim());
|
|
18423
|
-
const a = cleanLine(ack, c.lang, ACK_WORDS).replace(/[\s,;:—–-]+$/u, "");
|
|
18605
|
+
const a = cleanLine(ack, c.lang, c.plan ? 18 : ACK_WORDS, c.plan ? 140 : 60).replace(/[\s,;:—–-]+$/u, "");
|
|
18424
18606
|
const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
|
|
18425
18607
|
const ok = a && !said.has(norm3(a)) && !RESULT_CLAIM_RE.test(a) && !new RegExp("\\p{N}", "u").test(a);
|
|
18426
18608
|
return { kind: "deep", ack: ok ? a : stockAck(c), brief };
|
|
@@ -18432,12 +18614,18 @@ function rawMove(raw, c) {
|
|
|
18432
18614
|
const facts = unknownFacts(line, c), novel = novelWords(line, c);
|
|
18433
18615
|
const unknown = facts.length || novel.length >= 2 ? [...facts, ...novel] : [];
|
|
18434
18616
|
if (unknown.length) {
|
|
18435
|
-
|
|
18617
|
+
log40.debug(`quick line "${line}" names ${unknown.join(", ")} \u2014 not in the call: deep lane`);
|
|
18436
18618
|
return { kind: "deep", ack: "", brief: "" };
|
|
18437
18619
|
}
|
|
18438
18620
|
return bye && isClosing(c.heard) ? { kind: "say", line, end: true } : { kind: "say", line };
|
|
18439
18621
|
}
|
|
18440
|
-
var
|
|
18622
|
+
var Q_STOP = new Set("who whom whose where which why how when what do does did is are was were the a an they she he it you your that this of in on at to and or one ones there their them about mean meant wait sorry so okay \u05DE\u05D9 \u05D0\u05D9\u05E4\u05D4 \u05DC\u05DE\u05D4 \u05D0\u05D9\u05DA \u05DE\u05EA\u05D9 \u05DE\u05D4 \u05D0\u05EA \u05D6\u05D4 \u05D6\u05D0\u05EA \u05D4\u05DD \u05D4\u05DF \u05D4\u05D5\u05D0 \u05D4\u05D9\u05D0".split(" "));
|
|
18623
|
+
function asksAbout(heard, normQuote) {
|
|
18624
|
+
const st = (w) => w.replace(/['’]s$/, "").replace(new RegExp("(?<=\\p{L}{3})(?:es|s)$", "u"), "");
|
|
18625
|
+
const qs = new Set(normQuote.split(" ").map(st));
|
|
18626
|
+
return norm3(heard).split(" ").some((w) => w && !Q_STOP.has(w) && qs.has(st(w)));
|
|
18627
|
+
}
|
|
18628
|
+
var stockAck = (c) => c.caller ? "" : ownLine(ACKS[c.lang], c);
|
|
18441
18629
|
function quickOwns(heard) {
|
|
18442
18630
|
const t = heard.replace(/\s*[—–]\s*/g, " ").trim(), n = norm3(t);
|
|
18443
18631
|
if (!n) return null;
|
|
@@ -18493,15 +18681,17 @@ function holdLine(c) {
|
|
|
18493
18681
|
const said = new Set(c.history.filter((h) => h.who === "you").map((h) => norm3(h.text)));
|
|
18494
18682
|
return (HOLDS[c.lang] ?? []).find((x) => !said.has(norm3(x))) ?? "";
|
|
18495
18683
|
}
|
|
18496
|
-
function fastQuickLane(ai, model, gender, persona = "", hedgeMs = 900, tools = true) {
|
|
18497
|
-
return async (
|
|
18684
|
+
function fastQuickLane(ai, model, gender, persona = "", hedgeMs = 900, tools = true, caller = false, plan) {
|
|
18685
|
+
return async (c0, signal) => {
|
|
18686
|
+
const c = caller ? { ...c0, caller: true, ...plan?.text ? { plan: plan.text } : {} } : c0;
|
|
18687
|
+
if (caller && plan?.opener && !c.history.some((h) => h.who === "you")) return { kind: "deep", ack: plan.opener, brief: "" };
|
|
18498
18688
|
if (c.rest && GO_ON.test(c.heard)) return { kind: "resume", line: "" };
|
|
18499
18689
|
const hold = holdLine(c);
|
|
18500
18690
|
if (hold) return { kind: "say", line: hold };
|
|
18501
18691
|
const ask = async () => {
|
|
18502
18692
|
const raw = await fastText(ai, { model, prompt: quickPrompt(c, gender, persona, tools), signal, temperature: 0.4 });
|
|
18503
18693
|
const mv = quickMove(raw, c);
|
|
18504
|
-
if (!mv)
|
|
18694
|
+
if (!mv) log40.debug(`quick lane: unusable "${raw.slice(0, 80)}"`);
|
|
18505
18695
|
return mv;
|
|
18506
18696
|
};
|
|
18507
18697
|
let timer;
|
|
@@ -18531,13 +18721,83 @@ They just said: "${c.heard}"
|
|
|
18531
18721
|
` : "") + `
|
|
18532
18722
|
Reply with exactly ONE line, one of:
|
|
18533
18723
|
BYE: <a short farewell> \u2014 they mean to end the call ("no, thank you, bye", "okay, talk later"): the call hangs up after it. Judge the intent: "say bye to Dan" or "before I go, one more thing" is not an end.
|
|
18534
|
-
SAY: <your words> \u2014 ONLY a greeting or how-are-you, a short reaction ("wow", "really?"), or when they ask exactly to repeat something ALREADY said ("say that again", "which one was that?"). Any request ("tell me a story\u2026"), any question about content ("what is\u2026?", "wait, what?", "how long is it?") is DEEP, even if you could guess. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
|
|
18724
|
+
SAY: <your words> \u2014 ONLY a greeting or how-are-you, a short reaction ("wow", "really?"), or when they ask exactly to repeat something ALREADY said ("say that again", "which one was that?"). Any request ("tell me a story\u2026"), any question about content ("what is\u2026?", "wait, what?", "how long is it?") is DEEP, even if you could guess${c.rest ? " (or CLARIFY, below)" : ""}. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
|
|
18535
18725
|
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 is your natural first reaction to THIS kind of ask, in your own voice: ${tools ? `a lookup says you're on it and names what you'll look at ("Sure, let me pull up the kitty changelog."); ` : `never say you will check, look up, pull up, find or fetch anything \u2014 nothing can be; a question gets a short thinking reaction ("Hmm, okay\u2026", "Right, so\u2026"); `}a story, joke or idea gets a reaction to the idea itself (a story about a dragon: "Ooh, a dragon story, okay\u2026"); a question about what was said gets a short "ah"-type reaction ("Ah, good question."). Say "checking" or "looking" only when something is actually looked up. Never a result. The speech-to-text misspells names: fix them from context ("Haka News" \u2192 Hacker News).
|
|
18536
|
-
|
|
18726
|
+
` + (c.rest ? `CLARIFY: <one short answer> | <the exact words of your cut answer or its rest that answer it, copied verbatim> \u2014 they cut your answer to ask a quick question ABOUT it ("who?", "where do they sit?", "which one?") that your words above or the unsaid rest already answer. Find the exact span first, then answer from it only; your cut answer then goes on by itself. A new request, a change of topic, or a question those words do not answer is DEEP.
|
|
18727
|
+
` : "") + `QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
|
|
18537
18728
|
"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.
|
|
18538
|
-
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.
|
|
18729
|
+
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. ` + (c.hint ? `
|
|
18730
|
+
A listener judge read this moment as: ${c.hint} (a hint; your own reading of their words wins).
|
|
18731
|
+
` : "") + (c.plan ? `
|
|
18732
|
+
YOUR PLAN for this call (made before dialing; follow it, adapt to what they say):
|
|
18733
|
+
${c.plan}
|
|
18734
|
+
When their words match a case in your plan, answer DEEP with that planned line as the acknowledgement (said at once; the colleague goes on from it).
|
|
18735
|
+
` : "") + (c.caller ? `
|
|
18736
|
+
YOU PLACED THIS CALL: you ask, they answer; they are not your user. Never say you will check, wait or look anything up ("one moment", "checking", "\u05E8\u05D2\u05E2", "\u05D1\u05D5\u05D3\u05E7"). "Hello?" / "are you there?" from them = they lost you: SAY a short presence line in their language ("Yes, hi, I'm here" / "\u05DB\u05DF, \u05E9\u05DC\u05D5\u05DD, \u05D0\u05E0\u05D9 \u05E4\u05D4"). A DEEP acknowledgement may be empty ("DEEP: | \u2026"): prefer empty to a filler.
|
|
18737
|
+
` : "") + `Speak ${languageName(c.lang)}. ${personaHint(gender)} Output only the line.`;
|
|
18539
18738
|
}
|
|
18540
18739
|
|
|
18740
|
+
// src/voice/callPlan.ts
|
|
18741
|
+
init_logging();
|
|
18742
|
+
var log41 = forComponent("CallPlan");
|
|
18743
|
+
var CallPlanOptions = class {
|
|
18744
|
+
ai;
|
|
18745
|
+
model = "";
|
|
18746
|
+
/** Who calls whom and why (the call's task): the plan's only input. */
|
|
18747
|
+
persona = "";
|
|
18748
|
+
/** The call's language ('' = the persona's). */
|
|
18749
|
+
lang = "";
|
|
18750
|
+
gender;
|
|
18751
|
+
/** Give up after this long (the call goes on without a plan). */
|
|
18752
|
+
timeoutMs = 1e4;
|
|
18753
|
+
};
|
|
18754
|
+
var CallPlan = class _CallPlan {
|
|
18755
|
+
options;
|
|
18756
|
+
/** The whole plan as text ('' until ready / when it failed). */
|
|
18757
|
+
text = "";
|
|
18758
|
+
/** The first thing to say when a person answers: a hello + one short question. */
|
|
18759
|
+
opener = "";
|
|
18760
|
+
ready;
|
|
18761
|
+
/** How long the plan took (ms; 0 = not made). */
|
|
18762
|
+
ms = 0;
|
|
18763
|
+
/** The model's raw answer (diagnostics: a plan with no opener). */
|
|
18764
|
+
raw = "";
|
|
18765
|
+
constructor(options) {
|
|
18766
|
+
this.options = { ...new CallPlanOptions(), ...options };
|
|
18767
|
+
this.ready = this.options.persona ? this.make() : Promise.resolve();
|
|
18768
|
+
}
|
|
18769
|
+
/** The plan's prompt (exported for tests). */
|
|
18770
|
+
static prompt(persona, lang, gender) {
|
|
18771
|
+
return `${persona.slice(0, 800)}
|
|
18772
|
+
|
|
18773
|
+
You are about to dial this call. Plan it in your head first, like a person does: what you say first, what you ask and in what order, and how you answer what they will most likely say. One line each:
|
|
18774
|
+
OPENER: <only a casual greeting, the way people really open a call \u2014 may start with a small filler ("hmm", "uh") \u2014 1-3 words, no question yet>
|
|
18775
|
+
ASK: <your first short question, said after they answer the greeting; then the follow-ups in order> (2-4 lines)
|
|
18776
|
+
IF <a likely reply \u2014 yes, no, not in stock, don't know, hold on, transfer, who is this, a question back\u2026>: <what you say then> (4-7 lines)
|
|
18777
|
+
CLOSE: <a short thanks + bye>
|
|
18778
|
+
Every line is what you would say aloud: ${lang ? languageName(lang) : "the persona's language"}, casual and spoken like a real person (fillers, short turns, never formal), max 14 words, never a list in one breath, never "I am an AI", never a name for yourself or anyone that the task does not give, numbers as words ("five", not "5"). ${personaHint(gender)} Output only these lines.`;
|
|
18779
|
+
}
|
|
18780
|
+
/** "OPENER: …" → the opener (cleaned for speech). */
|
|
18781
|
+
static parse(raw, lang) {
|
|
18782
|
+
const lines = raw.split("\n").map((l) => l.replace(/^[\s>*_`#\-\d.)]+/, "").replace(/\*\*|__/g, "").trim()).filter((l) => /^(OPENER|ASK|IF|CLOSE)\b/i.test(l));
|
|
18783
|
+
const op = lines.find((l) => /^OPENER\b/i.test(l))?.replace(/^OPENER\s*:\s*/i, "").replace(/^["'\s]+|["'\s]+$/g, "") ?? "";
|
|
18784
|
+
return { text: lines.join("\n").slice(0, 1200), opener: op ? cleanLine(op, lang || "en", 18, 140) : "" };
|
|
18785
|
+
}
|
|
18786
|
+
async make() {
|
|
18787
|
+
const o = this.options, t0 = Date.now(), ac = new AbortController(), timer = setTimeout(() => ac.abort(), o.timeoutMs);
|
|
18788
|
+
try {
|
|
18789
|
+
const raw = this.raw = await fastText(o.ai, { model: o.model, prompt: _CallPlan.prompt(o.persona, o.lang, o.gender), signal: ac.signal, temperature: 0.4, maxTokens: 1500 });
|
|
18790
|
+
Object.assign(this, _CallPlan.parse(raw, o.lang));
|
|
18791
|
+
this.ms = Date.now() - t0;
|
|
18792
|
+
log41.debug(`plan ready in ${Date.now() - t0}ms: ${this.opener ? `opener "${this.opener}"` : "no opener"}`);
|
|
18793
|
+
} catch (e) {
|
|
18794
|
+
log41.debug(`no plan (${e?.message || e}) \u2014 the call goes on without one`);
|
|
18795
|
+
} finally {
|
|
18796
|
+
clearTimeout(timer);
|
|
18797
|
+
}
|
|
18798
|
+
}
|
|
18799
|
+
};
|
|
18800
|
+
|
|
18541
18801
|
// cli/config.ts
|
|
18542
18802
|
import { homedir as homedir5 } from "os";
|
|
18543
18803
|
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
|
|
@@ -18685,7 +18945,7 @@ function applyOverlay(cfg, file) {
|
|
|
18685
18945
|
// cli/hooks-config.ts
|
|
18686
18946
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
18687
18947
|
init_platform();
|
|
18688
|
-
var
|
|
18948
|
+
var log42 = forComponent("hooks");
|
|
18689
18949
|
var escapeRegex = (s) => s.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
18690
18950
|
function ruleMatches(rule, toolName) {
|
|
18691
18951
|
if (!rule.tool || rule.tool === "*") return true;
|
|
@@ -18704,7 +18964,7 @@ function runCmd(rule, env) {
|
|
|
18704
18964
|
});
|
|
18705
18965
|
return { code: r.status ?? 1, out: ((r.stdout ?? "") + (r.stderr ?? "")).trim() };
|
|
18706
18966
|
} catch (e) {
|
|
18707
|
-
|
|
18967
|
+
log42.debug(`hook command failed: ${rule.command}`, e);
|
|
18708
18968
|
return { code: 1, out: String(e?.message ?? e) };
|
|
18709
18969
|
}
|
|
18710
18970
|
}
|
|
@@ -18812,7 +19072,7 @@ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as rea
|
|
|
18812
19072
|
import { homedir as homedir6 } from "os";
|
|
18813
19073
|
import { join as join11 } from "path";
|
|
18814
19074
|
init_platform();
|
|
18815
|
-
var
|
|
19075
|
+
var log43 = forComponent("session");
|
|
18816
19076
|
var globalDir = () => join11(homedir6(), ".agent", "sessions");
|
|
18817
19077
|
function indexLink(target, link2) {
|
|
18818
19078
|
try {
|
|
@@ -18875,7 +19135,7 @@ var SessionStore = class {
|
|
|
18875
19135
|
}
|
|
18876
19136
|
load(id) {
|
|
18877
19137
|
if (!this.safeId(id)) {
|
|
18878
|
-
|
|
19138
|
+
log43.debug(`rejecting unsafe session id: ${id}`);
|
|
18879
19139
|
return void 0;
|
|
18880
19140
|
}
|
|
18881
19141
|
const path = join11(this.dir, `${id}.json`);
|
|
@@ -18883,7 +19143,7 @@ var SessionStore = class {
|
|
|
18883
19143
|
try {
|
|
18884
19144
|
return JSON.parse(readFileSync8(path, "utf8"));
|
|
18885
19145
|
} catch (e) {
|
|
18886
|
-
|
|
19146
|
+
log43.debug(`unreadable session ${id} \u2014 ignoring`, e);
|
|
18887
19147
|
return void 0;
|
|
18888
19148
|
}
|
|
18889
19149
|
}
|
|
@@ -18896,7 +19156,7 @@ var SessionStore = class {
|
|
|
18896
19156
|
try {
|
|
18897
19157
|
metas.push(JSON.parse(readFileSync8(join11(this.dir, f), "utf8")).meta);
|
|
18898
19158
|
} catch (e) {
|
|
18899
|
-
|
|
19159
|
+
log43.debug(`skipping unreadable session file ${f}`, e);
|
|
18900
19160
|
}
|
|
18901
19161
|
}
|
|
18902
19162
|
return metas.sort((a, b) => b.updated - a.updated);
|
|
@@ -19328,7 +19588,7 @@ import { promisify } from "util";
|
|
|
19328
19588
|
import { writeFileSync as writeFileSync6, mkdirSync as mkdirSync9 } from "fs";
|
|
19329
19589
|
import { homedir as homedir7 } from "os";
|
|
19330
19590
|
import { join as join12, resolve as resolve4, sep as sep3, parse as parsePath } from "path";
|
|
19331
|
-
var
|
|
19591
|
+
var log44 = forComponent("checkpoints");
|
|
19332
19592
|
var exec = promisify(execFile4);
|
|
19333
19593
|
var DEFAULT_EXCLUDE = [".agent/", ".git/", "node_modules/", "dist/", "build/", ".next/", "target/", ".venv/", "__pycache__/", "*.log"];
|
|
19334
19594
|
function isBroadRoot(p) {
|
|
@@ -19376,7 +19636,7 @@ var ShadowRepo = class {
|
|
|
19376
19636
|
writeFileSync6(join12(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
|
|
19377
19637
|
this.ready = true;
|
|
19378
19638
|
} catch (e) {
|
|
19379
|
-
|
|
19639
|
+
log44.debug(`git checkpoints unavailable for ${this.workTree}`, e);
|
|
19380
19640
|
this.ready = false;
|
|
19381
19641
|
}
|
|
19382
19642
|
return this.ready;
|
|
@@ -19387,7 +19647,7 @@ var ShadowRepo = class {
|
|
|
19387
19647
|
}
|
|
19388
19648
|
async commit(label, forced = []) {
|
|
19389
19649
|
await this.run("add", "-A");
|
|
19390
|
-
for (const p of forced) await this.run("add", "-f", "--", p).catch((e) =>
|
|
19650
|
+
for (const p of forced) await this.run("add", "-f", "--", p).catch((e) => log44.debug(`force-add failed: ${p}`, e));
|
|
19391
19651
|
await this.run("commit", "--allow-empty", "-q", "-m", label);
|
|
19392
19652
|
}
|
|
19393
19653
|
/** Inject the CURRENT (pre-edit) content of `paths` into the turn-open restore point by amending it.
|
|
@@ -19395,8 +19655,8 @@ var ShadowRepo = class {
|
|
|
19395
19655
|
* turn-boundary `add -A` would never have captured it. Amend (vs a new commit) keeps one restore
|
|
19396
19656
|
* point per turn, so the REPL's turn↔frame mapping stays intact. */
|
|
19397
19657
|
async amendForced(paths) {
|
|
19398
|
-
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) =>
|
|
19399
|
-
await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) =>
|
|
19658
|
+
for (const p of paths) await this.run("add", "-f", "--", p).catch((e) => log44.debug(`force-capture failed: ${p}`, e));
|
|
19659
|
+
await this.run("commit", "--amend", "--no-edit", "-q", "--allow-empty").catch((e) => log44.debug("amend failed", e));
|
|
19400
19660
|
}
|
|
19401
19661
|
/** Commits on `ref`, oldest-first (canonical index space). */
|
|
19402
19662
|
async log(ref) {
|
|
@@ -19456,7 +19716,7 @@ var ShadowRepo = class {
|
|
|
19456
19716
|
await this.run("gc", "--auto", "-q").catch(() => {
|
|
19457
19717
|
});
|
|
19458
19718
|
} catch (e) {
|
|
19459
|
-
|
|
19719
|
+
log44.debug("checkpoint prune failed", e);
|
|
19460
19720
|
}
|
|
19461
19721
|
}
|
|
19462
19722
|
};
|
|
@@ -19524,7 +19784,7 @@ var GitCheckpoints = class {
|
|
|
19524
19784
|
use(sessionId) {
|
|
19525
19785
|
if (sessionId === this.session) return;
|
|
19526
19786
|
this.session = sessionId;
|
|
19527
|
-
if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) =>
|
|
19787
|
+
if (this.started) for (const r of this.repos) void r.point(this.ref()).catch((e) => log44.debug("re-point failed", e));
|
|
19528
19788
|
}
|
|
19529
19789
|
async begin(label) {
|
|
19530
19790
|
if (!await this.start()) return;
|
|
@@ -19544,7 +19804,7 @@ var GitCheckpoints = class {
|
|
|
19544
19804
|
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
|
|
19545
19805
|
`);
|
|
19546
19806
|
} else {
|
|
19547
|
-
|
|
19807
|
+
log44.debug("checkpoint commit failed", e);
|
|
19548
19808
|
survivors.push(this.repos[i]);
|
|
19549
19809
|
survivorCaches.push(this.caches[i] ?? []);
|
|
19550
19810
|
}
|
|
@@ -19579,7 +19839,7 @@ var GitCheckpoints = class {
|
|
|
19579
19839
|
if (this.forced.has(abs)) continue;
|
|
19580
19840
|
this.forced.add(abs);
|
|
19581
19841
|
const i = this.repoIndexFor(abs);
|
|
19582
|
-
if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) =>
|
|
19842
|
+
if (i >= 0) await this.repos[i].amendForced([abs]).catch((e) => log44.debug("amendForced failed", e));
|
|
19583
19843
|
}
|
|
19584
19844
|
}
|
|
19585
19845
|
};
|
|
@@ -21369,7 +21629,7 @@ import { spawnSync as spawnSync6 } from "child_process";
|
|
|
21369
21629
|
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync10, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
|
|
21370
21630
|
import { homedir as homedir8 } from "os";
|
|
21371
21631
|
import { join as join14 } from "path";
|
|
21372
|
-
var
|
|
21632
|
+
var log45 = forComponent("os-sched");
|
|
21373
21633
|
var OsScheduler = class {
|
|
21374
21634
|
options;
|
|
21375
21635
|
constructor(options) {
|
|
@@ -21431,7 +21691,7 @@ var OsScheduler = class {
|
|
|
21431
21691
|
}
|
|
21432
21692
|
}
|
|
21433
21693
|
} catch (e) {
|
|
21434
|
-
|
|
21694
|
+
log45.debug(`cancel ${id}`, e);
|
|
21435
21695
|
}
|
|
21436
21696
|
for (const f of [`${id}.json`, `${id}.sh`]) {
|
|
21437
21697
|
try {
|
|
@@ -21549,7 +21809,7 @@ import { existsSync as existsSync8, mkdirSync as mkdirSync11, unlinkSync as unli
|
|
|
21549
21809
|
import { homedir as homedir9 } from "os";
|
|
21550
21810
|
import { join as join15 } from "path";
|
|
21551
21811
|
init_platform();
|
|
21552
|
-
var
|
|
21812
|
+
var log46 = forComponent("remote-trigger");
|
|
21553
21813
|
var TRIGGER_DIR = () => join15(homedir9(), ".agent", "triggers");
|
|
21554
21814
|
var sockPath = (sessionId, dir = TRIGGER_DIR()) => join15(dir, `${sessionId}.sock`);
|
|
21555
21815
|
var TriggerServer = class {
|
|
@@ -21587,13 +21847,13 @@ var TriggerServer = class {
|
|
|
21587
21847
|
conn.end(JSON.stringify({ ok: false, error: String(e) }) + "\n");
|
|
21588
21848
|
}
|
|
21589
21849
|
});
|
|
21590
|
-
conn.on("error", (e) =>
|
|
21850
|
+
conn.on("error", (e) => log46.debug("trigger conn error", e));
|
|
21591
21851
|
});
|
|
21592
|
-
this.server.on("error", (e) =>
|
|
21852
|
+
this.server.on("error", (e) => log46.debug("trigger server error", e));
|
|
21593
21853
|
this.server.listen(p);
|
|
21594
21854
|
this.path = p;
|
|
21595
21855
|
} catch (e) {
|
|
21596
|
-
|
|
21856
|
+
log46.debug("trigger server unavailable", e);
|
|
21597
21857
|
}
|
|
21598
21858
|
}
|
|
21599
21859
|
/** Re-bind on /resume (the session id changed). */
|
|
@@ -21725,7 +21985,7 @@ var strike = C("9");
|
|
|
21725
21985
|
var link = (text, url) => useColor ? `\x1B]8;;${url}\x1B\\${cyan(text)}\x1B]8;;\x1B\\` : `${text} (${url})`;
|
|
21726
21986
|
var mdPalette = { bold, dim, cyan, italic, strike, green, link };
|
|
21727
21987
|
var err = (s) => process.stderr.write(s);
|
|
21728
|
-
var
|
|
21988
|
+
var log47 = forComponent("cli");
|
|
21729
21989
|
var VERSION = (() => {
|
|
21730
21990
|
try {
|
|
21731
21991
|
return JSON.parse(readFileSync10(new URL("../package.json", import.meta.url), "utf8")).version ?? "?";
|
|
@@ -21887,6 +22147,12 @@ function parseArgs(argv) {
|
|
|
21887
22147
|
else if (x === "--conversational" || x === "--convo" || x === "--voice") {
|
|
21888
22148
|
a.voice = true;
|
|
21889
22149
|
a.duplex = true;
|
|
22150
|
+
} else if (x === "--live") {
|
|
22151
|
+
a.voice = true;
|
|
22152
|
+
a.call = true;
|
|
22153
|
+
a.duplex = true;
|
|
22154
|
+
a.lean = true;
|
|
22155
|
+
a.channelMode ??= "live";
|
|
21890
22156
|
} else if (x === "--voice-model") a.voiceModel = val(++i, x);
|
|
21891
22157
|
else if (x === "--voice-gender") {
|
|
21892
22158
|
const g = val(++i, x);
|
|
@@ -21901,6 +22167,7 @@ function parseArgs(argv) {
|
|
|
21901
22167
|
else if (x === "--voice-system-prompt") a.voiceSystemPrompt = val(++i, x);
|
|
21902
22168
|
else if (x === "--voice-persona") a.voicePersona = readPersona(val(++i, x));
|
|
21903
22169
|
else if (x === "--add-dir") (a.addDirs ??= []).push(val(++i, x));
|
|
22170
|
+
else if (x === "--confine") a.confine = true;
|
|
21904
22171
|
else if (x === "--mcp-config") a.mcpConfig = val(++i, x);
|
|
21905
22172
|
else if (x === "--reasoning") a.reasoning = parseReasoning(val(++i, x));
|
|
21906
22173
|
else if (x === "--session-id") a.sessionId = val(++i, x);
|
|
@@ -21993,6 +22260,8 @@ Flags:
|
|
|
21993
22260
|
--call voice call (duplex v3): the main agent (-m, full tools) answers every turn; a fast model
|
|
21994
22261
|
(--voice-model, default Claude Haiku) only fills the wait \u2014 backchannels, fillers, bridges,
|
|
21995
22262
|
progress lines \u2014 and never enters the history. --duplex/--duplex-v2/--voice alias it
|
|
22263
|
+
--live live voice call: --call + mic on at start + --channel-mode live (Jev turn judge, quick lane,
|
|
22264
|
+
live prediction tree); TYPESAFE_AI_KEY enables Jev, else Groq decides
|
|
21996
22265
|
interactively (AGENTX_DUPLEX_V1=1 keeps the v1 reflex below for one release)
|
|
21997
22266
|
--duplex duplex mode: a fast voice model replies instantly and delegates real work
|
|
21998
22267
|
to a background worker agent (-m model); results are re-voiced when ready
|
|
@@ -22019,6 +22288,8 @@ Flags:
|
|
|
22019
22288
|
--no-think with --duplex: disable the Think tier (Act handles everything)
|
|
22020
22289
|
--voice-system-prompt <text> with --duplex: appended to the voice (reflex) prompt only (--append-system-prompt \u2192 workers)
|
|
22021
22290
|
--add-dir <path> mount another directory into the workspace (repeatable; disk mode only)
|
|
22291
|
+
--confine file tools reach ONLY cwd + --add-dir dirs (no absolute paths/../symlinks out; secrets still hidden);
|
|
22292
|
+
claude-code/* needs --onlyTools with it (its own tools are then switched off)
|
|
22022
22293
|
--mcp-config <file> JSON { mcpServers?, permissions?, skillDirs? } merged over .agent config for this run only
|
|
22023
22294
|
--subagents allow the Task tool (spawn child agents)
|
|
22024
22295
|
--delegate <worker> delegate mode: the main model plans (its writes are refused), <worker> writes via Task
|
|
@@ -22634,7 +22905,7 @@ function turnCost(model, usage) {
|
|
|
22634
22905
|
const priced = model.startsWith("claude-code/") ? `anthropic/${resolveModelAlias(model.slice("claude-code/".length))}` : model;
|
|
22635
22906
|
return costOf(getModelInfo(priced)?.pricing, usage?.promptTokens ?? 0, usage?.completionTokens ?? 0, usage?.cacheCreationTokens ?? 0, usage?.cacheReadTokens ?? 0, priced);
|
|
22636
22907
|
}
|
|
22637
|
-
async function evaluateGoal(ai, condition, transcript,
|
|
22908
|
+
async function evaluateGoal(ai, condition, transcript, log48) {
|
|
22638
22909
|
const recent = transcript.filter((m) => m.role === "assistant").slice(-8).map((m) => {
|
|
22639
22910
|
const text = typeof m.content === "string" ? m.content : m.content.filter((p) => p.type === "text").map((p) => p.text).join(" ");
|
|
22640
22911
|
return text.slice(0, 600);
|
|
@@ -22654,7 +22925,7 @@ ${recent}` }
|
|
|
22654
22925
|
const match = r.content.match(/\{[\s\S]*\}/);
|
|
22655
22926
|
if (match) return JSON.parse(match[0]);
|
|
22656
22927
|
} catch (e) {
|
|
22657
|
-
|
|
22928
|
+
log48(dim(` (goal evaluator error: ${e?.message ?? e})
|
|
22658
22929
|
`));
|
|
22659
22930
|
}
|
|
22660
22931
|
return { met: false, reason: "evaluation unclear" };
|
|
@@ -22801,6 +23072,7 @@ function optsFor(args, ai, cfg = {}, extraTools = []) {
|
|
|
22801
23072
|
scratch: args.scratch,
|
|
22802
23073
|
appendSystemPrompt: args.appendSystemPrompt,
|
|
22803
23074
|
addDirs: args.addDirs,
|
|
23075
|
+
confine: args.confine,
|
|
22804
23076
|
stream: args.stream,
|
|
22805
23077
|
host: makeHost(args.outputFormat, { stream: true }),
|
|
22806
23078
|
planMode: args.plan || cfg.planMode || false,
|
|
@@ -22882,7 +23154,7 @@ function mcpAgentTools(mounted, opts) {
|
|
|
22882
23154
|
return tools;
|
|
22883
23155
|
}
|
|
22884
23156
|
async function closeMcp(mounted) {
|
|
22885
|
-
await Promise.all(mounted.map((m) => m.client.close().catch((e) =>
|
|
23157
|
+
await Promise.all(mounted.map((m) => m.client.close().catch((e) => log47.debug("mcp close failed", e))));
|
|
22886
23158
|
}
|
|
22887
23159
|
var IMG_EXT = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp" };
|
|
22888
23160
|
function mentionRefs(line) {
|
|
@@ -22941,7 +23213,7 @@ async function expandMentions(fs, line) {
|
|
|
22941
23213
|
if (loaded.includes(ref) || missing.includes(ref)) continue;
|
|
22942
23214
|
if (ref.includes(":") && mcpMentionResolver) {
|
|
22943
23215
|
const body = await mcpMentionResolver(ref).catch((e) => {
|
|
22944
|
-
|
|
23216
|
+
log47.debug("mcp mention resolve failed", e);
|
|
22945
23217
|
return null;
|
|
22946
23218
|
});
|
|
22947
23219
|
if (body != null) {
|
|
@@ -22967,7 +23239,7 @@ ${await fs.readFile(path)}`);
|
|
|
22967
23239
|
${blocks.join("\n\n")}` : line, loaded, missing };
|
|
22968
23240
|
}
|
|
22969
23241
|
function applyTurnMode(agent, session, task, flags = {}, onModel) {
|
|
22970
|
-
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) =>
|
|
23242
|
+
const p = parseDirectives(task, { strict: true, keys: ["model", "turns", "delegate", "advisor", "mode"], warn: (m) => log47.debug(m) });
|
|
22971
23243
|
const d = p.directives, isMode = !!(d.delegate || d.advisor || d.modeOff);
|
|
22972
23244
|
if (p.unresolvedModel && /->|<-|delegate:|advisor:/.test(task.slice(0, task.length - p.prompt.length))) {
|
|
22973
23245
|
err(red(` \u2717 unknown model "${p.unresolvedModel}"${p.ambiguous ? ` (could be: ${p.ambiguous.join(", ")})` : ""} \u2014 turn not sent
|
|
@@ -23060,7 +23332,7 @@ async function runTurn(agent, store, session, task, cp, cwd = process.cwd(), sen
|
|
|
23060
23332
|
try {
|
|
23061
23333
|
store.save(session);
|
|
23062
23334
|
} catch (ex) {
|
|
23063
|
-
|
|
23335
|
+
log47.debug("mid-turn session flush failed", ex);
|
|
23064
23336
|
}
|
|
23065
23337
|
}
|
|
23066
23338
|
return origNotify(e);
|
|
@@ -23224,14 +23496,14 @@ var isCancelTeardown = (e) => {
|
|
|
23224
23496
|
function installCancelGuards(mounted) {
|
|
23225
23497
|
process.on("unhandledRejection", (e) => {
|
|
23226
23498
|
if (isCancelTeardown(e)) {
|
|
23227
|
-
|
|
23499
|
+
log47.debug("suppressed unhandledRejection (cursor stream cancel)", e);
|
|
23228
23500
|
return;
|
|
23229
23501
|
}
|
|
23230
|
-
|
|
23502
|
+
log47.error("unhandledRejection", e);
|
|
23231
23503
|
});
|
|
23232
23504
|
process.on("uncaughtException", (e) => {
|
|
23233
23505
|
if (isCancelTeardown(e)) {
|
|
23234
|
-
|
|
23506
|
+
log47.debug("suppressed uncaughtException (cursor stream cancel)", e);
|
|
23235
23507
|
return;
|
|
23236
23508
|
}
|
|
23237
23509
|
console.error(e);
|
|
@@ -23586,6 +23858,10 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
23586
23858
|
call = new VoiceCall({
|
|
23587
23859
|
ai,
|
|
23588
23860
|
...fast.options,
|
|
23861
|
+
...args.channelMode === "live" ? (() => {
|
|
23862
|
+
const turnJudge = turnJudgeFor();
|
|
23863
|
+
return turnJudge ? { turnJudge } : {};
|
|
23864
|
+
})() : {},
|
|
23589
23865
|
// live: the quick lane owns the conversation, MAIN is its deep lane (#1331). Only here: its lines reach MAIN through
|
|
23590
23866
|
// noteTurn, which a --channel-only host (Para) does not take yet.
|
|
23591
23867
|
...args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0" ? { quick: fastQuickLane(ai, fast.options.fastModel, args.voiceGender, args.voicePersona) } : {},
|
|
@@ -23647,7 +23923,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
23647
23923
|
editorRef?.abort();
|
|
23648
23924
|
}
|
|
23649
23925
|
} catch (e) {
|
|
23650
|
-
|
|
23926
|
+
log47.error("call turn failed", e);
|
|
23651
23927
|
} finally {
|
|
23652
23928
|
rec.running = false;
|
|
23653
23929
|
call?.main({ type: "done", id });
|
|
@@ -23801,7 +24077,7 @@ ${SPOKEN_TURN}`, { id });
|
|
|
23801
24077
|
try {
|
|
23802
24078
|
mkdirSync12(dir, { recursive: true });
|
|
23803
24079
|
} catch (e) {
|
|
23804
|
-
|
|
24080
|
+
log47.debug("paste image dir create failed", e);
|
|
23805
24081
|
}
|
|
23806
24082
|
const img = grabClipboardImage(dir, String(Date.now()));
|
|
23807
24083
|
return img ? { display: "Image", ref: "@" + img.path, path: img.path } : null;
|
|
@@ -23914,7 +24190,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23914
24190
|
mkdirSync12(join16(cwd, ".agent"), { recursive: true });
|
|
23915
24191
|
appendFileSync2(histPath, line + "\n");
|
|
23916
24192
|
} catch (e) {
|
|
23917
|
-
|
|
24193
|
+
log47.debug("history write failed", e);
|
|
23918
24194
|
}
|
|
23919
24195
|
};
|
|
23920
24196
|
const ago = (t) => {
|
|
@@ -23986,7 +24262,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
23986
24262
|
try {
|
|
23987
24263
|
store.save(session);
|
|
23988
24264
|
} catch (e) {
|
|
23989
|
-
|
|
24265
|
+
log47.debug("session save after rewind failed", e);
|
|
23990
24266
|
}
|
|
23991
24267
|
err(green(" \u27F2 jumped back") + dim(` \u2014 ${face.transcript.length} message(s) kept; edit + resend
|
|
23992
24268
|
`));
|
|
@@ -24021,7 +24297,7 @@ ${task}`;
|
|
|
24021
24297
|
bangContext.length = 0;
|
|
24022
24298
|
}
|
|
24023
24299
|
const delta = await refreshCatalogs().catch((e) => {
|
|
24024
|
-
|
|
24300
|
+
log47.debug("catalog refresh failed", e);
|
|
24025
24301
|
return "";
|
|
24026
24302
|
});
|
|
24027
24303
|
if (delta) {
|
|
@@ -24295,7 +24571,7 @@ ${task}`;
|
|
|
24295
24571
|
desc: "rescan skills/commands dirs and rebuild the system prompt (one cache miss) \u2014 picks up entries created mid-session",
|
|
24296
24572
|
run: async () => {
|
|
24297
24573
|
await refreshCatalogs().catch((e) => {
|
|
24298
|
-
|
|
24574
|
+
log47.debug("catalog refresh failed", e);
|
|
24299
24575
|
});
|
|
24300
24576
|
face.reprepare();
|
|
24301
24577
|
err(green(` \u2713 reloaded \u2014 ${skills.length} skill(s), ${cmds.length} command(s); system prompt rebuilds on next message
|
|
@@ -24798,7 +25074,7 @@ ${task}`;
|
|
|
24798
25074
|
try {
|
|
24799
25075
|
for (const def of (await loadAgents(fs2, d)).agents) if (!seen.has(def.name)) seen.set(def.name, { def, from: d });
|
|
24800
25076
|
} catch (e) {
|
|
24801
|
-
|
|
25077
|
+
log47.debug(`loadAgents(${d}) failed`, e);
|
|
24802
25078
|
}
|
|
24803
25079
|
}
|
|
24804
25080
|
if (!seen.size) {
|
|
@@ -24886,7 +25162,7 @@ ${task}`;
|
|
|
24886
25162
|
}
|
|
24887
25163
|
if (idx >= 0) {
|
|
24888
25164
|
const old = mounted.splice(idx, 1)[0];
|
|
24889
|
-
await old.client.close().catch((e) =>
|
|
25165
|
+
await old.client.close().catch((e) => log47.debug("mcp close failed", e));
|
|
24890
25166
|
}
|
|
24891
25167
|
try {
|
|
24892
25168
|
const m = await mountMcpServer(name, conf);
|
|
@@ -24914,7 +25190,7 @@ ${task}`;
|
|
|
24914
25190
|
}
|
|
24915
25191
|
const m = mounted.splice(idx, 1)[0];
|
|
24916
25192
|
remountMcpTools();
|
|
24917
|
-
await m.client.close().catch((e) =>
|
|
25193
|
+
await m.client.close().catch((e) => log47.debug("mcp close failed", e));
|
|
24918
25194
|
err(dim(` removed "${name}"
|
|
24919
25195
|
`));
|
|
24920
25196
|
return;
|
|
@@ -25117,7 +25393,7 @@ ${task}`;
|
|
|
25117
25393
|
try {
|
|
25118
25394
|
return readdirSync4(join16(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
|
|
25119
25395
|
} catch (e) {
|
|
25120
|
-
|
|
25396
|
+
log47.debug("completion readdir failed", absDir, e);
|
|
25121
25397
|
return null;
|
|
25122
25398
|
}
|
|
25123
25399
|
};
|
|
@@ -25256,7 +25532,7 @@ ${out}
|
|
|
25256
25532
|
return;
|
|
25257
25533
|
}
|
|
25258
25534
|
await refreshCatalogs().catch((e) => {
|
|
25259
|
-
|
|
25535
|
+
log47.debug("catalog refresh failed", e);
|
|
25260
25536
|
});
|
|
25261
25537
|
const sk = skills.find((x) => x.name === name);
|
|
25262
25538
|
if (sk) {
|
|
@@ -25386,7 +25662,7 @@ ${out}
|
|
|
25386
25662
|
if (delivery || cut) dx?.parkCutDelivery(delivery, !!cut, heard);
|
|
25387
25663
|
const cutReply = cut && cut.full.length - cut.heard.length > 40 ? cut : null;
|
|
25388
25664
|
const noteP = replaces ? replaces.note : !cutReply ? Promise.resolve("") : (instinct ? instinct.bargeIntent(text).catch((e) => {
|
|
25389
|
-
|
|
25665
|
+
log47.warn(`barge intent failed \u2014 model decides: ${e.message}`);
|
|
25390
25666
|
return void 0;
|
|
25391
25667
|
}) : Promise.resolve(void 0)).then(async (intent) => interruptionNote(cutReply, intent) + ackedNote(await instinct?.ackFor(text)));
|
|
25392
25668
|
const cutIn = replaces ? replaces.cutIn : interjectNote;
|
|
@@ -25787,10 +26063,10 @@ function channelOptions(ai, model, gender) {
|
|
|
25787
26063
|
// 0: the reactive live path
|
|
25788
26064
|
pickLeaf: fastLeafPicker(ai, process.env.AGENTX_LEAF_MODEL || "groq/openai/gpt-oss-120b"),
|
|
25789
26065
|
persona: process.env.AGENTX_CALL_PERSONA ?? "",
|
|
25790
|
-
onTree: (e) =>
|
|
26066
|
+
onTree: (e) => log47.debug(`voice tree: ${e.branches} branches in ${e.ms}ms${e.tokens ? ` tokens ${e.tokens.input}/${e.tokens.output}` : ""}${e.error ? ` error ${e.error}` : ""}`),
|
|
25791
26067
|
onEvent: (e) => {
|
|
25792
|
-
if (e.moment)
|
|
25793
|
-
else
|
|
26068
|
+
if (e.moment) log47.debug(`voice leaf: ${e.moment} ${e.conf} "${e.text}" ${e.acted}`);
|
|
26069
|
+
else log47.debug(`channel ${e.trigger}: rule=${e.rule} choice=${e.choice ?? "-"} \u2192 ${e.acted}${e.text ? ` "${e.text}"` : ""}${e.cue ? " (planned cue)" : ""} ${e.ms}ms`);
|
|
25794
26070
|
},
|
|
25795
26071
|
// Banks in the user's language: generated once per language, cached + topped up across sessions (~/.agent/cache).
|
|
25796
26072
|
banks: new ChannelBanks({ generate: fastBankGenerator(ai, model), cacheDir: join16(homedir10(), ".agent", "cache", "channel-banks") }),
|
|
@@ -25884,7 +26160,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25884
26160
|
try {
|
|
25885
26161
|
store.save(session);
|
|
25886
26162
|
} catch (e) {
|
|
25887
|
-
|
|
26163
|
+
log47.warn("duplex session save failed", e);
|
|
25888
26164
|
}
|
|
25889
26165
|
};
|
|
25890
26166
|
const overlap2 = overlapResponder(ai, args.duplexV2 ? args.channelMode : void 0, out);
|
|
@@ -25924,7 +26200,7 @@ async function duplexServe(args, ai, cfg, cwd) {
|
|
|
25924
26200
|
done2();
|
|
25925
26201
|
out({ type: "turn_done", id, finishReason: res?.finishReason ?? "error", ...why ? { error: why } : {} });
|
|
25926
26202
|
}).catch((e) => {
|
|
25927
|
-
|
|
26203
|
+
log47.error("duplex turn failed", e);
|
|
25928
26204
|
done2();
|
|
25929
26205
|
out({ type: "turn_done", id, finishReason: "error", error: String(e?.message ?? e) });
|
|
25930
26206
|
});
|
|
@@ -25943,12 +26219,22 @@ async function channelServe(args, ai, cfg) {
|
|
|
25943
26219
|
const { model, notes, options: fast } = callFast(args, ai, cfg);
|
|
25944
26220
|
const quick = args.quickLane && args.channelMode === "live" && process.env.AGENTX_QUICK_LANE !== "0";
|
|
25945
26221
|
let cut = null;
|
|
26222
|
+
const caller = process.env.AGENTX_CALL_ROLE === "caller", persona = process.env.AGENTX_CALL_PERSONA ?? "";
|
|
26223
|
+
const plan = quick && caller && persona ? new CallPlan({ ai, model: fast.fastModel, persona, lang: process.env.AGENTX_CALL_LANG ?? "", gender: args.voiceGender }) : void 0;
|
|
26224
|
+
void plan?.ready.then(() => {
|
|
26225
|
+
out({ type: "metric", name: "plan", ms: plan.ms, ...plan.opener ? { text: plan.opener } : {}, kind: plan.opener ? `opener "${plan.opener}"` : `no opener: ${JSON.stringify(plan.raw.slice(0, 300))}` });
|
|
26226
|
+
if (plan.text) out({ type: "note", text: `Your plan for this call (made before dialing \u2014 follow it, adapt to what they say; your quick voice may already have said its lines):
|
|
26227
|
+
${plan.text}` });
|
|
26228
|
+
});
|
|
26229
|
+
const menu = caller ? new MenuKeys({ ai, model: process.env.AGENTX_MENU_MODEL || "groq/openai/gpt-oss-120b", persona }) : void 0;
|
|
26230
|
+
const turnJudge = args.channelMode === "live" ? turnJudgeFor() : void 0;
|
|
25946
26231
|
const call = new VoiceCall({
|
|
25947
26232
|
...fast,
|
|
25948
26233
|
// no `ai` here: the channel's model wiring is explicit
|
|
26234
|
+
...turnJudge ? { turnJudge } : {},
|
|
25949
26235
|
...quick ? {
|
|
25950
|
-
quick: fastQuickLane(ai, fast.fastModel, args.voiceGender,
|
|
25951
|
-
// (1: MAIN has no tools — a sandboxed phone call)
|
|
26236
|
+
quick: fastQuickLane(ai, fast.fastModel, args.voiceGender, persona, void 0, process.env.AGENTX_CALL_NO_TOOLS !== "1", caller, plan),
|
|
26237
|
+
// (NO_TOOLS 1: MAIN has no tools — a sandboxed phone call; ROLE caller: we placed it)
|
|
25952
26238
|
noteTurn: (text) => out({ type: "note", text }),
|
|
25953
26239
|
heardCut: () => cut?.heard ?? null,
|
|
25954
26240
|
cutRest: () => cut && cut.full.slice(cut.heard.length).trim() || null,
|
|
@@ -25984,6 +26270,7 @@ async function channelServe(args, ai, cfg) {
|
|
|
25984
26270
|
return call.aside(t);
|
|
25985
26271
|
});
|
|
25986
26272
|
out({ type: "ready", model, channelMode: args.channelMode, softBarge: softBarge(args.channelMode), call: true, ...quick ? { quickLane: true } : {}, ...notes.length ? { notes } : {} });
|
|
26273
|
+
if (args.channelMode === "live") out({ type: "metric", name: "judge", kind: turnJudge ? `on (${process.env.TYPESAFE_AI_KEY ? "jev" : "groq"})` : "off (no decider key)" });
|
|
25987
26274
|
const rl = createInterface({ input: process.stdin });
|
|
25988
26275
|
rl.on("line", (line) => {
|
|
25989
26276
|
let m;
|
|
@@ -26006,6 +26293,8 @@ async function channelServe(args, ai, cfg) {
|
|
|
26006
26293
|
else if (m.type === "user" && typeof m.text === "string") call.hostTurn(m.text);
|
|
26007
26294
|
else if (m.type === "text" && typeof m.text === "string") call.fill.onMainTokens(m.text);
|
|
26008
26295
|
else if (m.type === "overlap") overlap2(m);
|
|
26296
|
+
else if (m.type === "menu" && menu && typeof m.text === "string") void menu.hear(m.text).then((r) => out({ type: "keys", digits: r.digits, ms: r.ms, text: m.text }));
|
|
26297
|
+
else if (m.type === "pressed" && menu && typeof m.digits === "string") menu.pressed(m.digits);
|
|
26009
26298
|
else if (m.type === "exit") rl.close();
|
|
26010
26299
|
});
|
|
26011
26300
|
await new Promise((r) => rl.on("close", () => r()));
|