@livx.cc/agentx 0.95.6 → 0.96.1
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.js +184 -41
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +66 -3
- package/dist/index.js +145 -21
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Claude Code is the floor; running isolated, on the edge, or hybrid is the ceilin
|
|
|
30
30
|
| Tokens | **69k** | 171k — **2.5× fewer** |
|
|
31
31
|
| Wall-time | **~100s** | 133s — **~25% faster** |
|
|
32
32
|
|
|
33
|
-
**Cost** (9-task hard suite, USD-metered,
|
|
33
|
+
**Cost at parity** (9-task hard suite, USD-metered, REPEATS=2): all reach 9/9 — **$0.59** single-tier Sonnet (**~8× cheaper**) · **$0.93** three-tier voice/duplex (**~5× cheaper**, 8/9: one miss on a deliberately probabilistic task) vs CC-on-Opus **$4.82**. The win is the same correctness for a fraction of the spend.
|
|
34
34
|
|
|
35
35
|
Plus things Claude Code simply doesn't do:
|
|
36
36
|
|
package/dist/cli.js
CHANGED
|
@@ -1616,10 +1616,10 @@ function sandboxArgv(command, cwd, opts = {}, platform2 = process.platform, tmpD
|
|
|
1616
1616
|
return null;
|
|
1617
1617
|
}
|
|
1618
1618
|
async function findSandboxWrapper(platform2 = process.platform) {
|
|
1619
|
-
const { existsSync:
|
|
1620
|
-
if (platform2 === "darwin") return
|
|
1619
|
+
const { existsSync: existsSync10 } = await import("fs");
|
|
1620
|
+
if (platform2 === "darwin") return existsSync10("/usr/bin/sandbox-exec") ? "/usr/bin/sandbox-exec" : null;
|
|
1621
1621
|
if (platform2 === "linux") {
|
|
1622
|
-
for (const dir of (process.env.PATH ?? "/usr/bin:/bin").split(":")) if (dir &&
|
|
1622
|
+
for (const dir of (process.env.PATH ?? "/usr/bin:/bin").split(":")) if (dir && existsSync10(`${dir}/bwrap`)) return `${dir}/bwrap`;
|
|
1623
1623
|
return null;
|
|
1624
1624
|
}
|
|
1625
1625
|
return null;
|
|
@@ -1907,7 +1907,7 @@ var init_tools_shell = __esm({
|
|
|
1907
1907
|
|
|
1908
1908
|
// cli/cli.ts
|
|
1909
1909
|
import { createInterface } from "readline/promises";
|
|
1910
|
-
import { existsSync as
|
|
1910
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8, appendFileSync, mkdirSync as mkdirSync11, writeFileSync as writeFileSync9, readdirSync as readdirSync4, statSync as statSync4, unlinkSync as unlinkSync5 } from "fs";
|
|
1911
1911
|
import { homedir as homedir9, tmpdir as tmpdir3 } from "os";
|
|
1912
1912
|
|
|
1913
1913
|
// cli/clipboard.ts
|
|
@@ -4623,17 +4623,26 @@ var DuplexAgentOptions = class {
|
|
|
4623
4623
|
memoryUserDir;
|
|
4624
4624
|
};
|
|
4625
4625
|
var RESERVED_EVENT_MARKER = /\[task\b[^\]\n]*\b(?:completed|failed|progress|asks)\b/i;
|
|
4626
|
+
var RESERVED_EVENT_OPENER = /\[\s*task\b/i;
|
|
4626
4627
|
var VOICE_SYSTEM_PROMPT = 'You are a spoken voice assistant \u2014 the user HEARS everything you say. Use short sentences. One idea per sentence. No markdown, no bullet lists, no code blocks, no headings, no emoji.\nThis holds even when asked to "print", "list", "show", or "make a table" \u2014 there is no screen for the spoken channel. Speak it as flowing prose ("Tuesday is half a meter, Wednesday a bit less\u2026"), or if they truly need it on screen, route it to Act to render. Never emit dashes or pipes into speech.\nKeep turns SHORT \u2014 one to three sentences, then stop. Never lecture, enumerate cases, or add caveats unprompted. Conversation is a fast exchange: give the one thing asked, and let the user pull more if they want it.\nYou have three cognitive tiers \u2014 like a human brain:\n\u2022 YOU (reflex) \u2014 instant, lightweight. Handle greetings, simple questions, status checks, QuickLook.\n\u2022 `Act` \u2014 your hands. A background worker with its own configured tools and access to the user\'s environment (files and shell{{WORKER_WEB}}). Use for reading, editing, searching, running tasks, building \u2014 any real work.\n{{THINK_SLOT}}\nWhen you are unsure whether you can do or access something, do NOT assume and do NOT claim a capability you have not confirmed. To check what you can do, QuickLook `capabilities` (instant \u2014 it lists your worker\'s real tools) and answer from that. Never promise an ability that is not in your capabilities; if it is not there, tell the user plainly you can\'t. To actually DO real work, call `Act`. When the user mentions their project, folder, files, or environment ("this project", "the current folder", "my code"), call `Act` IMMEDIATELY \u2014 do not ask for paths or details the worker can discover itself. Never pretend to have done the work or invent results \u2014 the worker\'s report is your only source.\nYou cannot mute the microphone or stop voice capture yourself \u2014 no tool does it. If the user asks you to stop listening or turn the voice off, never claim you did: tell them to say exactly "voice off" (handled by the app directly), or type /voice.\nYou are NOT a knowledge base. For any question whose answer needs SPECIFIC verifiable facts you do not already have in hand \u2014 how to build/configure/implement something, exact API, library, entitlement, command or option names, current events, or particular numbers, dates, or names \u2014 do NOT answer from your own memory: you will confidently make things up (a fake API, a wrong entitlement, an event that did not happen). Route it to `Act`, which can search and verify, and speak only what its report says. Answer inline ONLY for general conversation, chit-chat, and trivia you are sure of, or facts you can see via QuickLook. When elaborating on a completed task ("tell me more", "the gist"), stay strictly within what that result actually said \u2014 if the user asks for something the result did not cover, that is NEW information: dispatch `Act`, do not improvise.\nALWAYS react before you work: the FIRST thing in your turn is a brief spoken acknowledgement of what you heard and what you are about to do ("got it \u2014 opening that now", "sure, let me pull it up", "okay, checking"). NEVER call a tool (Act, Think, QuickLook) silently \u2014 the user must hear you react before you go quiet to work. After dispatching Act or Think, that same one short sentence IS your turn \u2014 end it and do not wait for the result.\nResults arrive later as events like "[task t1 completed] \u2026" or "[task t1 failed] \u2026". When one arrives, speak the USEFUL gist in one or two short sentences \u2014 the actual answer the user wanted (the headline finding, the key numbers), not the thinnest possible "it\'s done". A forecast \u2192 say it\'s calm AND that it\'s good for swimming but not surf; a count \u2192 say the number. Be brief, but do not drop the substance. DISTILL vs DELIVER \u2014 know which the request wants. When the result is a FACT to extract (a forecast, a count, a status), distill the headline. But when the user wanted specific CONTENT \u2014 a joke, a quote, a name, a definition, the actual lines \u2014 that content IS the deliverable: LEAD WITH IT. Your first words ARE the joke / the quote / the answer itself, before any "got it" or offer. SPEAK the content, never a comment ABOUT it: "why was six afraid of seven? because seven ate nine" \u2014 NOT "those are funny" or "I found a couple". If you did not actually say the joke/quote/answer aloud this turn, you FAILED the request, no matter how friendly the wrapper. A short joke is short \u2014 just say it. NEVER speak as if you already delivered something you did not actually say aloud THIS turn: do not say "those are\u2026", "there you go", or offer "a few MORE" when you never voiced the first one. The on-screen text is invisible to a voice user \u2014 if you did not speak it, they did not get it, so deliver it before you comment on it or offer more. If the result is a LIST (search results, multiple files/matches), the user CANNOT see it \u2014 there is no screen and no numbered menu to point at. Speak the gist: say what you found and name the top one or two by NAME (the source, not "the first one" or a number), then ask plainly if they want more. Never ask them to "pick which one" or reference items by position. The completed result stays in YOUR context \u2014 it is yours to draw on. When the user follows up ("tell me more", "what else", "and?"), answer FROM that result first: you already have the detail, so elaborate on what you have. Do NOT spawn a fresh worker to re-search or re-gather what you were just handed. Re-dispatch ONLY when genuinely new information is needed \u2014 e.g. the user wants the full contents of a SPECIFIC source, which is one WebFetch of that URL, not a brand-new search. "[task t1 progress] \u2026" events are interim status, NOT results \u2014 give at most a half-sentence aside ("still on it \u2014 running tests now") and end your turn. Never present progress as a finished result.\nCRITICAL: while a task is still running you have NO answer yet \u2014 never state a specific result of any kind (a number, size, count, name, path, or value). The real answer arrives ONLY in the "[task \u2026 completed]" event; inventing one meanwhile (a made-up disk size, commit count, etc.) is a serious error. Until then, only acknowledge and wait.\nNever read raw file paths, diffs, or code aloud verbatim.\nDo NOT end every turn with the same canned offer ("want a rundown?", "want the steps?"). Offer once at most; if the user pushes back, repeats themselves, or sounds unsatisfied ("you know what I mean?", "think deeper", "are you sure?"), do NOT re-offer the same thing \u2014 change approach: dispatch `Act`/`Think` to actually dig in, or ask one concrete clarifying question. Repeating a non-answer is worse than silence.\n"[task t1 asks] \u2026" events are QUESTIONS from a background task \u2014 relay to the user in your own words, short, then end your turn. When the user answers, call `AnswerTask` with that id and their answer. NEVER answer on the user\'s behalf for permissions or risky operations; if their reply is ambiguous, confirm first.\nIf the user\'s message sounds INCOMPLETE \u2014 trailing off mid-sentence, a fragment that needs more context ("and then we", "but the problem is"), hesitation fillers ("uh", "um") \u2014 call `Hold` instead of answering. This keeps listening for the rest of their thought. Only respond with substance when you have a complete question or request.\nDispatch discipline: send ONE self-contained task per request \u2014 a single worker with the full brief beats several workers with fragments (each worker starts fresh and re-discovers context). NEVER dispatch a worker just to read files or gather information \u2014 workers explore and discover context themselves; pass on what you already know and let one worker do the whole job. Split into parallel tasks only when the user asks for genuinely independent things. When a task completes, report its result and stop \u2014 do NOT dispatch follow-up work (verification, polish, extras) the user did not ask for, unless the report itself signals failure or doubt.\nDo not fire a second Act/Think for work already in flight, and NEVER spawn a second task to re-count, cross-check, or verify a result a worker already gave you \u2014 trust its answer; a single question gets ONE task. Call `TaskStatus` at most ONCE per turn; if a task is still running, just say "still on it" and end the turn \u2014 never poll it again and again in a loop. Use `CancelTask` when the user asks to stop something.\nPRIORITY: when the user says goodbye or wants to end/finish/wrap up the session ("ok bye", "that\'s all", "let\'s finish", "let\'s end", "goodnight", "exit", "wrap up"), call `ExitSession` IMMEDIATELY \u2014 do not act, do not check status, just exit.\nFor TRIVIAL instant lookups only \u2014 current time, git branch, listing a folder, peeking at a small file, or checking your own `capabilities`/tools \u2014 use `QuickLook` (instant, no task). Whenever the user asks what you can do or whether you have some ability, QuickLook `capabilities` and answer from that \u2014 never guess. Anything requiring searching, reasoning, running commands, or editing goes through `Act`.\n{{MEMORY_SLOT}}\nUser messages may arrive via speech-to-text and can carry transcription artifacts \u2014 odd words, cut-offs, homophones ("for you" vs "folder"). Read for INTENT, not surface text. If a message seems garbled or surprising, briefly confirm what they meant ("did you mean\u2026?") instead of answering the literal words.';
|
|
4627
4628
|
var THINK_GUIDANCE = "\u2022 `Think` \u2014 your brain. A premium reasoning model, FAR more expensive than Act. Reserve it for open-ended architecture/design questions, or a problem Act already FAILED at. ALL implementation work \u2014 coding, refactoring, debugging, edge cases, tests \u2014 goes to Act; Act is highly capable. Never send the same work to both.";
|
|
4628
4629
|
var THINK_DISABLED_GUIDANCE = "(Think tier is not available \u2014 use Act for all escalations.)";
|
|
4629
4630
|
var VOICE_STYLE_CONVERSATIONAL = `Speak like a person in a live conversation, not an assistant reading a script. React first, then deliver: a quick impulsive beat ("oh nice", "hmm, hold on", "ah, got it") before the substance. Use contractions always. Vary sentence length \u2014 some very short. Light fillers and backchannels are fine ("mm-hm", "right", "let's see") but at most one per reply \u2014 never stack them. When you escalate to Act or Think, say it like a human would ("hang on, let me actually dig into that \u2014 gimme a minute") instead of announcing a task. When a result comes back, react to it like you just found out ("okay so \u2014 turns out\u2026"). Match the user's energy: a quick question gets a quick answer \u2014 a few words is a perfectly good turn. Prefer a short answer plus an offer ("want the details?") over covering everything. Never narrate your own mechanics (no "I will now act", no task ids out loud).`;
|
|
4630
|
-
var DuplexAgent = class {
|
|
4631
|
+
var DuplexAgent = class _DuplexAgent {
|
|
4631
4632
|
options;
|
|
4632
4633
|
voice;
|
|
4633
4634
|
tasks = /* @__PURE__ */ new Map();
|
|
4634
4635
|
queue = Promise.resolve();
|
|
4635
4636
|
seq = 0;
|
|
4636
4637
|
pendingEvents = [];
|
|
4638
|
+
/** Out-of-band follow-up attribution for the events coalescing into the next flush turn: TRUE iff ≥1 of
|
|
4639
|
+
* the tasks being integrated was NON-CLEAN (early-stop/failure). Carried out-of-band on the enqueue call
|
|
4640
|
+
* by the caller that KNOWS the outcome — a plain boolean the MODEL CANNOT PERTURB. It is NOT scanned from
|
|
4641
|
+
* worker-authored event text (v1: an "Outcome:" substring over-stamped siblings) and NOT keyed on a brief
|
|
4642
|
+
* string the reflex re-authors (v2: a paraphrased escalation brief missed the Set → followUp:false →
|
|
4643
|
+
* RE-ENABLED unbounded auto-escalation, the dangerous runaway direction). See [[wrong-discriminator]] /
|
|
4644
|
+
* [[drive-real-reflex]] / [[fakeaiclient-blind-to-wire-format]]. */
|
|
4645
|
+
pendingNonClean = false;
|
|
4637
4646
|
flushQueued = false;
|
|
4638
4647
|
/** Per-voice-turn guards (reset by resetTurn at each turn's start). The reflex is a weak model:
|
|
4639
4648
|
* left unguarded it polls TaskStatus after a dispatch and/or dispatches silently (dead air).
|
|
@@ -4652,6 +4661,21 @@ var DuplexAgent = class {
|
|
|
4652
4661
|
// chars of reflexBuf already forwarded to the host/TTS
|
|
4653
4662
|
fabricationCut = false;
|
|
4654
4663
|
// reflex emitted a reserved [task …] marker → suppress its tail
|
|
4664
|
+
/** TRUE for the duration of a re-voice turn that is integrating ≥1 NON-CLEAN task (turn-eligibility,
|
|
4665
|
+
* carried out-of-band — NOT derived from any worker/brief string). ANY Act/Think dispatched in such a
|
|
4666
|
+
* turn is stamped followUp:true. This GUARANTEES the dangerous direction is impossible: a genuine
|
|
4667
|
+
* escalation (even one with a paraphrased brief) ALWAYS lands in a non-clean integration turn, so it is
|
|
4668
|
+
* ALWAYS recognized as a follow-up and CANNOT re-escalate (one hop). The single-dispatch-per-turn guard
|
|
4669
|
+
* means at most one dispatch happens per flush, so realistically "the one dispatch IS the escalation".
|
|
4670
|
+
* ACCEPTED SAFE-DIRECTION ERROR: if the reflex instead dispatches FRESH unrelated work during a non-clean
|
|
4671
|
+
* flush (rare — and only possible when it batches multiple calls in one step, bypassing the guard), that
|
|
4672
|
+
* fresh task is over-stamped followUp:true and forgoes ONE future auto-escalation. That is SAFE (it only
|
|
4673
|
+
* ever REMOVES a future escalation, never adds one — no runaway) and is the correct side to err on. */
|
|
4674
|
+
turnFollowUp = false;
|
|
4675
|
+
/** Hard absolute backstop against runaway regardless of attribution: total automatic escalations across
|
|
4676
|
+
* the whole conversation. Once it hits MAX_AUTO_ESCALATIONS, no integration turn offers escalate/re-delegate. */
|
|
4677
|
+
autoEscalations = 0;
|
|
4678
|
+
static MAX_AUTO_ESCALATIONS = 8;
|
|
4655
4679
|
/** Parked worker questions awaiting a (voice-relayed) user answer, keyed by ask id. */
|
|
4656
4680
|
pendingAsks = /* @__PURE__ */ new Map();
|
|
4657
4681
|
/** Lazily resolved memory tools (async loadMemory runs in initMemory). */
|
|
@@ -4694,7 +4718,7 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4694
4718
|
if (this.fabricationCut) return;
|
|
4695
4719
|
const msg = ev.message;
|
|
4696
4720
|
this.reflexBuf += msg;
|
|
4697
|
-
const m = this.reflexBuf.match(RESERVED_EVENT_MARKER);
|
|
4721
|
+
const m = this.reflexBuf.match(RESERVED_EVENT_MARKER) ?? this.reflexBuf.match(RESERVED_EVENT_OPENER);
|
|
4698
4722
|
if (m) {
|
|
4699
4723
|
this.fabricationCut = true;
|
|
4700
4724
|
log8.warn(`reflex fabricated a [task \u2026] event in its spoken stream \u2014 cutting it (kept ${m.index} chars)`);
|
|
@@ -4704,8 +4728,15 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4704
4728
|
host.notify?.({ ...ev, message: safe });
|
|
4705
4729
|
return;
|
|
4706
4730
|
}
|
|
4707
|
-
|
|
4708
|
-
|
|
4731
|
+
const held = this.reflexBuf.length - this.reflexForwarded;
|
|
4732
|
+
const partial = held > 0 && /\[\s*t?a?s?k?$/i.test(this.reflexBuf.slice(-Math.min(held, 6)));
|
|
4733
|
+
const upto = partial ? this.reflexBuf.length - this.reflexBuf.slice(-6).match(/\[\s*t?a?s?k?$/i)[0].length : this.reflexBuf.length;
|
|
4734
|
+
const out = this.reflexBuf.slice(this.reflexForwarded, upto);
|
|
4735
|
+
this.reflexForwarded = upto;
|
|
4736
|
+
if (!out) return;
|
|
4737
|
+
if (out.trim()) this.spokeThisTurn = true;
|
|
4738
|
+
host.notify?.({ ...ev, message: out });
|
|
4739
|
+
return;
|
|
4709
4740
|
}
|
|
4710
4741
|
host.notify?.(ev);
|
|
4711
4742
|
}
|
|
@@ -4738,6 +4769,16 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4738
4769
|
this.voice.options.tools.push(...mem.tools);
|
|
4739
4770
|
if (mem.index) this.voice.options.systemPrompt += "\n\n" + mem.index;
|
|
4740
4771
|
}
|
|
4772
|
+
/** Flush any held-back trailing fragment (a possible `[task` opener that never completed) once the
|
|
4773
|
+
* turn's stream is done — so a legit message ending in "[t" isn't silently dropped. */
|
|
4774
|
+
flushHeldReflexTail() {
|
|
4775
|
+
if (this.fabricationCut) return;
|
|
4776
|
+
const tail = this.reflexBuf.slice(this.reflexForwarded);
|
|
4777
|
+
this.reflexForwarded = this.reflexBuf.length;
|
|
4778
|
+
if (!tail) return;
|
|
4779
|
+
if (tail.trim()) this.spokeThisTurn = true;
|
|
4780
|
+
this.options.host?.notify?.({ kind: "text_delta", message: tail });
|
|
4781
|
+
}
|
|
4741
4782
|
/** Clear the per-turn guards. Called at the head of every voice turn (user send + re-voice flush). */
|
|
4742
4783
|
resetTurn() {
|
|
4743
4784
|
this.turnDispatched = false;
|
|
@@ -4746,6 +4787,7 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4746
4787
|
this.reflexBuf = "";
|
|
4747
4788
|
this.reflexForwarded = 0;
|
|
4748
4789
|
this.fabricationCut = false;
|
|
4790
|
+
this.turnFollowUp = false;
|
|
4749
4791
|
this.voice.options.toolChoice = void 0;
|
|
4750
4792
|
}
|
|
4751
4793
|
/** preToolUse guard on the reflex: once it has dispatched this turn, a dispatch is "said my piece,
|
|
@@ -4775,17 +4817,18 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4775
4817
|
/** A turn that voiced nothing is dead air. Re-prompt the reflex ONCE so the LLM itself voices a short
|
|
4776
4818
|
* line (no template). If it STILL says nothing, fall back to a minimal line so silence never ships.
|
|
4777
4819
|
* Wording adapts to whether work was dispatched (an ack) or the inline reply was simply lost. */
|
|
4778
|
-
async ackIfSilent() {
|
|
4820
|
+
async ackIfSilent(fallback) {
|
|
4779
4821
|
const dispatched = this.turnDispatched;
|
|
4780
4822
|
this.nudging = true;
|
|
4781
4823
|
try {
|
|
4782
|
-
await this.voice.send(dispatched ? "[reminder] You dispatched a task but said nothing to the user. Say ONE short spoken acknowledgement now \u2014 no tools." : "[reminder] You said nothing to the user this turn. Give your ONE short spoken reply now \u2014 no tools.");
|
|
4824
|
+
await this.voice.send(fallback ? "[reminder] You said nothing to the user this turn. Tell them, in ONE short spoken sentence, what just happened \u2014 no tools." : dispatched ? "[reminder] You dispatched a task but said nothing to the user. Say ONE short spoken acknowledgement now \u2014 no tools." : "[reminder] You said nothing to the user this turn. Give your ONE short spoken reply now \u2014 no tools.");
|
|
4783
4825
|
} catch (e) {
|
|
4784
4826
|
log8.warn(`ack nudge failed: ${e instanceof Error ? e.message : e}`);
|
|
4785
4827
|
} finally {
|
|
4786
4828
|
this.nudging = false;
|
|
4787
4829
|
}
|
|
4788
|
-
if (!this.spokeThisTurn)
|
|
4830
|
+
if (!this.spokeThisTurn)
|
|
4831
|
+
this.options.host?.notify?.({ kind: "text_delta", message: fallback ?? (dispatched ? "Okay, on it." : "Sorry, could you say that again?") });
|
|
4789
4832
|
}
|
|
4790
4833
|
/** One user turn: the voice agent streams the reply (and may Act/Think). Serialized with re-voice turns. */
|
|
4791
4834
|
send(content) {
|
|
@@ -4793,6 +4836,7 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4793
4836
|
await this.initMemory();
|
|
4794
4837
|
this.resetTurn();
|
|
4795
4838
|
const res = await this.voice.send(content);
|
|
4839
|
+
this.flushHeldReflexTail();
|
|
4796
4840
|
if (this.silentTurn) await this.ackIfSilent();
|
|
4797
4841
|
return res;
|
|
4798
4842
|
});
|
|
@@ -4827,18 +4871,27 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4827
4871
|
notify(kind, message, data) {
|
|
4828
4872
|
this.options.host?.notify?.({ kind, message, data });
|
|
4829
4873
|
}
|
|
4830
|
-
/** Queue a `[task …]` event for re-voicing. Events arriving while the voice is busy coalesce into ONE turn.
|
|
4831
|
-
|
|
4874
|
+
/** Queue a `[task …]` event for re-voicing. Events arriving while the voice is busy coalesce into ONE turn.
|
|
4875
|
+
* `nonClean` (out-of-band boolean, set by the caller that KNOWS this event integrates a NON-CLEAN outcome)
|
|
4876
|
+
* marks the coalesced flush as a non-clean integration turn — turn-eligibility, never inferred from event
|
|
4877
|
+
* text and never keyed on a (re-authored) brief string. Any dispatch in such a turn is a follow-up. */
|
|
4878
|
+
queueRevoice(event, nonClean = false) {
|
|
4832
4879
|
this.pendingEvents.push(event);
|
|
4880
|
+
if (nonClean) this.pendingNonClean = true;
|
|
4833
4881
|
if (this.flushQueued) return;
|
|
4834
4882
|
this.flushQueued = true;
|
|
4835
4883
|
void this.enqueue(async () => {
|
|
4836
4884
|
this.flushQueued = false;
|
|
4837
4885
|
const events = this.pendingEvents.splice(0);
|
|
4886
|
+
const nonCleanTurn = this.pendingNonClean;
|
|
4887
|
+
this.pendingNonClean = false;
|
|
4838
4888
|
if (!events.length) return;
|
|
4889
|
+
const failed = events.find((e) => /^\[task\b[^\]\n]*\bfailed\b/i.test(e));
|
|
4839
4890
|
this.resetTurn();
|
|
4891
|
+
this.turnFollowUp = nonCleanTurn;
|
|
4840
4892
|
await this.voice.send(events.join("\n"));
|
|
4841
|
-
|
|
4893
|
+
this.flushHeldReflexTail();
|
|
4894
|
+
if (this.silentTurn) await this.ackIfSilent(failed ? "Sorry, that didn't work \u2014 the task failed." : void 0);
|
|
4842
4895
|
this.notify("revoice_done", "");
|
|
4843
4896
|
});
|
|
4844
4897
|
}
|
|
@@ -4855,7 +4908,7 @@ Today's date: ${(/* @__PURE__ */ new Date()).toDateString()}.`;
|
|
|
4855
4908
|
${recent}` : brief) + verify;
|
|
4856
4909
|
}
|
|
4857
4910
|
/** Spawn a detached worker for task `id`; its settlement notifies + enqueues the re-voice turn. */
|
|
4858
|
-
spawnWorker(id, label, briefText, tier
|
|
4911
|
+
spawnWorker(id, label, briefText, tier, brief, followUp) {
|
|
4859
4912
|
const o = this.options;
|
|
4860
4913
|
const tierOpts = tier === "think" ? o.thinkOptions : o.actOptions;
|
|
4861
4914
|
const tierModel = tier === "think" ? o.thinkModel : o.actModel;
|
|
@@ -4907,7 +4960,7 @@ ${recent}` : brief) + verify;
|
|
|
4907
4960
|
// shared with the checker so a cancel tears down both
|
|
4908
4961
|
};
|
|
4909
4962
|
const promise = new Agent(agentOpts).run(briefText).then((res) => this.maybeVerify(id, briefText, res, tier, agentOpts)).then((res) => this.onWorkerSettled(id, res)).catch((err2) => this.onWorkerFailed(id, err2));
|
|
4910
|
-
this.tasks.set(id, { id, label, status: "running", controller, promise, tail });
|
|
4963
|
+
this.tasks.set(id, { id, label, status: "running", controller, promise, tail, brief, followUp });
|
|
4911
4964
|
if (this.tasks.size > this.options.maxTaskRecords)
|
|
4912
4965
|
for (const [tid, rec] of this.tasks) {
|
|
4913
4966
|
if (this.tasks.size <= this.options.maxTaskRecords) break;
|
|
@@ -5018,6 +5071,38 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
5018
5071
|
dropAsk(id) {
|
|
5019
5072
|
this.pendingAsks.get(id)?.resolve("");
|
|
5020
5073
|
}
|
|
5074
|
+
/** Build the INTEGRATION TURN prompt for a settled worker. Instead of trust-and-forwarding the raw
|
|
5075
|
+
* result, the result re-enters the reflex as a decision (like a tool_result flowing back into a normal
|
|
5076
|
+
* agent loop): the reflex evaluates the outcome against the original intent and chooses what to do next.
|
|
5077
|
+
*
|
|
5078
|
+
* Decision branches (the reflex acts on them with EXISTING tools — no new surface):
|
|
5079
|
+
* • accept → just SPEAK the result to the user (happy path; the only move on a clean success).
|
|
5080
|
+
* • escalate → call `Think` with the SAME brief — only when Act failed/stalled AND a Think tier
|
|
5081
|
+
* exists AND this task wasn't already a follow-up (one hop max). Wires the dead
|
|
5082
|
+
* "Reserve Think for a problem Act already FAILED at" promise.
|
|
5083
|
+
* • re-delegate→ call `Act` with a CORRECTED brief — for a recoverable error / partial result.
|
|
5084
|
+
* • ask → ask the user ONE concrete question if genuinely blocked.
|
|
5085
|
+
*
|
|
5086
|
+
* Keeps the `[task <id> completed]` / `[task <id> failed]` opener so existing coalescing + the
|
|
5087
|
+
* failed-revoice fallback still fire, and the per-event transcript markers stay intact. */
|
|
5088
|
+
integrationPrompt(rec, outcome, body, finishReason) {
|
|
5089
|
+
const opener = outcome === "error" ? `[task ${rec.id} failed]` : `[task ${rec.id} completed]`;
|
|
5090
|
+
if (outcome === "ok")
|
|
5091
|
+
return `${opener} ${body}`;
|
|
5092
|
+
const underCap = this.autoEscalations < _DuplexAgent.MAX_AUTO_ESCALATIONS;
|
|
5093
|
+
const canEscalate = (outcome === "error" || outcome === "incomplete") && underCap;
|
|
5094
|
+
const hasThink = this.options.thinkModel !== false;
|
|
5095
|
+
const options = [];
|
|
5096
|
+
if (!rec.followUp && canEscalate && hasThink)
|
|
5097
|
+
options.push("ESCALATE to the Think tier (call Think with the same brief) if this is a hard/architectural problem the Act worker stalled or failed on");
|
|
5098
|
+
if (!rec.followUp && canEscalate)
|
|
5099
|
+
options.push("RE-DELEGATE to Act with a corrected brief if the failure looks recoverable (a wrong path, a fixable mistake)");
|
|
5100
|
+
options.push("ASK the user one short, concrete question if you genuinely cannot proceed without their input");
|
|
5101
|
+
options.push("ACCEPT and tell the user plainly what happened (don't dress a failure up as success)");
|
|
5102
|
+
const decision = options.length > 1 ? ` You must decide what to do next \u2014 choose ONE: ${options.map((o, i) => `(${i + 1}) ${o}`).join("; ")}. Pick exactly one and act on it; do not voice this as a finished success.` : ` Tell the user plainly what happened \u2014 do not present this as a finished success.`;
|
|
5103
|
+
const state = outcome === "error" ? `the worker FAILED with: ${body}` : `the worker STOPPED EARLY (${finishReason}) \u2014 its result is PARTIAL, not a finished success: ${body}`;
|
|
5104
|
+
return `${opener} Original request: "${rec.brief}". Outcome: ${state}.${decision}`;
|
|
5105
|
+
}
|
|
5021
5106
|
onWorkerSettled(id, res) {
|
|
5022
5107
|
this.dropAsk(id);
|
|
5023
5108
|
const rec = this.tasks.get(id);
|
|
@@ -5032,16 +5117,18 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
5032
5117
|
}
|
|
5033
5118
|
rec.status = "done";
|
|
5034
5119
|
rec.result = res.text;
|
|
5035
|
-
|
|
5120
|
+
const incomplete = res.finishReason !== "stop";
|
|
5121
|
+
log8.verbose(`task ${id} done (${res.steps} steps${incomplete ? `, INCOMPLETE: ${res.finishReason}` : ""})`);
|
|
5036
5122
|
this.notify("task_done", `task ${id} (${rec.label}) completed`, {
|
|
5037
5123
|
id,
|
|
5038
5124
|
text: res.text,
|
|
5039
5125
|
usage: res.usage,
|
|
5040
5126
|
usageEstimated: res.usageEstimated,
|
|
5127
|
+
finishReason: res.finishReason,
|
|
5041
5128
|
steps: res.steps,
|
|
5042
5129
|
toolCalls: res.messages.filter((m) => m.role === "tool").length
|
|
5043
5130
|
});
|
|
5044
|
-
this.queueRevoice(
|
|
5131
|
+
this.queueRevoice(this.integrationPrompt(rec, incomplete ? "incomplete" : "ok", res.text, res.finishReason), incomplete);
|
|
5045
5132
|
}
|
|
5046
5133
|
onWorkerFailed(id, err2) {
|
|
5047
5134
|
this.failTask(this.tasks.get(id), err2 instanceof Error ? err2.message : String(err2));
|
|
@@ -5052,7 +5139,7 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
5052
5139
|
rec.result = msg;
|
|
5053
5140
|
log8.warn(`task ${rec.id} failed: ${msg}`);
|
|
5054
5141
|
this.notify("task_error", `task ${rec.id} (${rec.label}) failed: ${msg}`);
|
|
5055
|
-
this.queueRevoice(
|
|
5142
|
+
this.queueRevoice(this.integrationPrompt(rec, "error", msg, "error"), true);
|
|
5056
5143
|
}
|
|
5057
5144
|
// --- voice tools (closures over this instance) ---
|
|
5058
5145
|
/** Live-switch the think tier: `false` disables (removes the Think tool from the voice agent),
|
|
@@ -5066,13 +5153,16 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
5066
5153
|
if (model === false && i >= 0) tools.splice(i, 1);
|
|
5067
5154
|
else if (model !== false && i < 0) tools.push(this.thinkTool());
|
|
5068
5155
|
}
|
|
5069
|
-
/** User/programmatic spawn: the CLI's /act and /think commands. Returns the task id.
|
|
5070
|
-
|
|
5156
|
+
/** User/programmatic spawn: the CLI's /act and /think commands. Returns the task id.
|
|
5157
|
+
* `followUp` marks an automatic escalation/re-delegation (set by the integration turn) so the new
|
|
5158
|
+
* task's own integration turn won't escalate again — capping auto-follow-ups to one hop. */
|
|
5159
|
+
async dispatch(brief, tier = "act", label, followUp = false) {
|
|
5071
5160
|
if (tier === "think" && this.options.thinkModel === false) tier = "act";
|
|
5161
|
+
if (followUp) this.autoEscalations++;
|
|
5072
5162
|
const id = `t${++this.seq}`;
|
|
5073
5163
|
const lbl = label ?? tier;
|
|
5074
5164
|
await this.options.onTaskStart?.(id, lbl);
|
|
5075
|
-
this.spawnWorker(id, lbl, this.buildBrief(brief, tier), tier);
|
|
5165
|
+
this.spawnWorker(id, lbl, this.buildBrief(brief, tier), tier, brief, followUp);
|
|
5076
5166
|
this.notify("task_started", `task ${id} (${lbl}) started`, { id, brief, tier });
|
|
5077
5167
|
return id;
|
|
5078
5168
|
}
|
|
@@ -5092,7 +5182,7 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
5092
5182
|
this.turnDispatched = true;
|
|
5093
5183
|
this.turnBriefs.add(String(brief ?? ""));
|
|
5094
5184
|
this.voice.options.toolChoice = "none";
|
|
5095
|
-
const id = await this.dispatch(String(brief ?? ""), "act", label ? String(label) : void 0);
|
|
5185
|
+
const id = await this.dispatch(String(brief ?? ""), "act", label ? String(label) : void 0, this.turnFollowUp);
|
|
5096
5186
|
return `Acting on task ${id}. Acknowledge briefly; the result will arrive as a [task ${id} completed] event.`;
|
|
5097
5187
|
}
|
|
5098
5188
|
};
|
|
@@ -5113,7 +5203,7 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
5113
5203
|
this.turnDispatched = true;
|
|
5114
5204
|
this.turnBriefs.add(String(brief ?? ""));
|
|
5115
5205
|
this.voice.options.toolChoice = "none";
|
|
5116
|
-
const id = await this.dispatch(String(brief ?? ""), "think", label ? String(label) : void 0);
|
|
5206
|
+
const id = await this.dispatch(String(brief ?? ""), "think", label ? String(label) : void 0, this.turnFollowUp);
|
|
5117
5207
|
return `Thinking on task ${id}. Acknowledge briefly; the result will arrive as a [task ${id} completed] event.`;
|
|
5118
5208
|
}
|
|
5119
5209
|
};
|
|
@@ -5381,6 +5471,11 @@ var VoiceEngineOptions = class {
|
|
|
5381
5471
|
/** Extended merge window (ms) for utterances that look incomplete (trailing conjunction/filler).
|
|
5382
5472
|
* Gives the user time to finish their thought without triggering a model call. */
|
|
5383
5473
|
incompleteMergeMs = 1500;
|
|
5474
|
+
/** Grace window (ms) after an utterance dispatches, during which the user's own trailing audio cannot
|
|
5475
|
+
* barge the reply it requested. Soniox keeps finalizing partials past <end>; without this they read
|
|
5476
|
+
* as a barge and abort the fresh turn (live: mid-sentence self-interruption + steps=1→steps=0 double
|
|
5477
|
+
* abort). Short enough that a genuine immediate barge ("no wait—") still lands right after. */
|
|
5478
|
+
bargeGraceMs = 600;
|
|
5384
5479
|
/** Filler phrase spoken when holding for an incomplete utterance ('' disables). */
|
|
5385
5480
|
holdFiller = "";
|
|
5386
5481
|
/** Called when the engine holds an incomplete utterance (host can render a visual cue). */
|
|
@@ -5436,6 +5531,9 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
5436
5531
|
suspectUntil = 0;
|
|
5437
5532
|
ackAt = 0;
|
|
5438
5533
|
// when the micro-ack was spoken — its echo can leak before the AEC filter converges
|
|
5534
|
+
bargeGraceUntil = 0;
|
|
5535
|
+
// no barge-in until this time — the user's OWN trailing audio (after the
|
|
5536
|
+
// utterance that JUST dispatched this turn) must not immediately re-interrupt the reply it requested.
|
|
5439
5537
|
pendingUtt = "";
|
|
5440
5538
|
// endpointed text held for the merge window
|
|
5441
5539
|
pendingTimer = null;
|
|
@@ -5622,6 +5720,10 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
5622
5720
|
}
|
|
5623
5721
|
handlePartial(text) {
|
|
5624
5722
|
if (this.speaking) {
|
|
5723
|
+
if (now() < this.bargeGraceUntil) {
|
|
5724
|
+
if (!this.echoActive() || (this.usingAec ? this.genuine(text) : this.novelWords(text).length >= 1)) this.options.onPartial(text);
|
|
5725
|
+
return;
|
|
5726
|
+
}
|
|
5625
5727
|
if (this.overlapCapable) {
|
|
5626
5728
|
const txt = text.trim();
|
|
5627
5729
|
if (!txt || txt === this.lastOverlapPartial) return;
|
|
@@ -5662,6 +5764,27 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
5662
5764
|
}
|
|
5663
5765
|
if (!this.echoActive() || (this.usingAec ? this.genuine(text) : this.novelWords(text).length >= 1)) this.options.onPartial(text);
|
|
5664
5766
|
}
|
|
5767
|
+
/** Merge a resumed utterance into the pending one, deduping any word-overlap. Soniox re-finalizes
|
|
5768
|
+
* overlapping audio when the silence-timer and the semantic `<end>` both endpoint a growing
|
|
5769
|
+
* utterance (or after a reconnect): the next "utterance" repeats the tail of the previous one, and
|
|
5770
|
+
* a naive `${prev} ${next}` produced the live duplication ("Um, I want to check if Um, I want to
|
|
5771
|
+
* check if…"). Find the longest suffix of `prev`'s words that prefixes `next` and drop it. */
|
|
5772
|
+
mergeUtterance(prev, next) {
|
|
5773
|
+
if (!prev) return next;
|
|
5774
|
+
if (!next) return prev;
|
|
5775
|
+
const pw = prev.split(/\s+/), nw = next.split(/\s+/);
|
|
5776
|
+
const norm2 = (w) => w.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
5777
|
+
const max = Math.min(pw.length, nw.length);
|
|
5778
|
+
for (let k = max; k > 0; k--) {
|
|
5779
|
+
let match = true;
|
|
5780
|
+
for (let i = 0; i < k; i++) if (norm2(pw[pw.length - k + i]) !== norm2(nw[i])) {
|
|
5781
|
+
match = false;
|
|
5782
|
+
break;
|
|
5783
|
+
}
|
|
5784
|
+
if (match) return [...pw, ...nw.slice(k)].join(" ");
|
|
5785
|
+
}
|
|
5786
|
+
return `${prev} ${next}`;
|
|
5787
|
+
}
|
|
5665
5788
|
static TRAIL_RE = /(?:^|\s)(?:and|but|or|so|to|the|a|an|of|in|for|with|that|if|uh|um|like|about|from|into|on|is|are|was|were|,)$/i;
|
|
5666
5789
|
/** The utterance sounds like the user paused mid-thought (trailing conjunction/filler/comma). */
|
|
5667
5790
|
looksIncomplete(text) {
|
|
@@ -5681,7 +5804,7 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
5681
5804
|
this.ackAt = 0;
|
|
5682
5805
|
return;
|
|
5683
5806
|
}
|
|
5684
|
-
this.pendingUtt = this.
|
|
5807
|
+
this.pendingUtt = this.mergeUtterance(this.pendingUtt, text);
|
|
5685
5808
|
if (this.pendingTimer) clearTimeout(this.pendingTimer);
|
|
5686
5809
|
if (this.options.incompleteMergeMs && this.looksIncomplete(this.pendingUtt)) {
|
|
5687
5810
|
log9.verbose(`hold: incomplete utterance "${this.pendingUtt.slice(-40)}"`);
|
|
@@ -5706,6 +5829,7 @@ var VoiceEngine = class _VoiceEngine {
|
|
|
5706
5829
|
this.pendingUtt = "";
|
|
5707
5830
|
if (text) {
|
|
5708
5831
|
this.turnStartAt = now();
|
|
5832
|
+
this.bargeGraceUntil = now() + this.options.bargeGraceMs;
|
|
5709
5833
|
this.options.onUtterance(text);
|
|
5710
5834
|
}
|
|
5711
5835
|
}
|
|
@@ -7667,7 +7791,7 @@ ${formatDiff(ops)}`);
|
|
|
7667
7791
|
// cli/gitCheckpoints.ts
|
|
7668
7792
|
import { execFile as execFile3 } from "child_process";
|
|
7669
7793
|
import { promisify } from "util";
|
|
7670
|
-
import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync7
|
|
7794
|
+
import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync7 } from "fs";
|
|
7671
7795
|
import { join as join9, resolve as resolve2, sep as sep2 } from "path";
|
|
7672
7796
|
var log19 = forComponent("checkpoints");
|
|
7673
7797
|
var exec = promisify(execFile3);
|
|
@@ -7700,10 +7824,10 @@ var ShadowRepo = class {
|
|
|
7700
7824
|
if (this.ready !== void 0) return this.ready;
|
|
7701
7825
|
try {
|
|
7702
7826
|
await exec(this.git, ["--version"]);
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
}
|
|
7827
|
+
mkdirSync7(this.gitDir, { recursive: true });
|
|
7828
|
+
const valid = await this.run("rev-parse", "--git-dir").then(() => true, () => false);
|
|
7829
|
+
if (!valid) await this.run("init", "-q");
|
|
7830
|
+
mkdirSync7(join9(this.gitDir, "info"), { recursive: true });
|
|
7707
7831
|
writeFileSync5(join9(this.gitDir, "info", "exclude"), this.exclude.join("\n") + "\n");
|
|
7708
7832
|
this.ready = true;
|
|
7709
7833
|
} catch (e) {
|
|
@@ -9591,7 +9715,7 @@ function readPlainLine() {
|
|
|
9591
9715
|
|
|
9592
9716
|
// cli/osScheduler.ts
|
|
9593
9717
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
9594
|
-
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync9, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as
|
|
9718
|
+
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync9, readdirSync as readdirSync2, unlinkSync as unlinkSync3, chmodSync, existsSync as existsSync7 } from "fs";
|
|
9595
9719
|
import { homedir as homedir7 } from "os";
|
|
9596
9720
|
import { join as join12 } from "path";
|
|
9597
9721
|
var log20 = forComponent("os-sched");
|
|
@@ -9667,7 +9791,7 @@ var OsScheduler = class {
|
|
|
9667
9791
|
return true;
|
|
9668
9792
|
}
|
|
9669
9793
|
list() {
|
|
9670
|
-
if (!
|
|
9794
|
+
if (!existsSync7(this.dir)) return [];
|
|
9671
9795
|
return readdirSync2(this.dir).filter((f) => f.endsWith(".json")).map((f) => readJsonFile(join12(this.dir, f), null)).filter(Boolean);
|
|
9672
9796
|
}
|
|
9673
9797
|
/** The per-job runner script: cd to the project, headless-resume the session, log, notify. */
|
|
@@ -9770,7 +9894,7 @@ function routeTrigger(trigger, backendHint, now5 = Date.now()) {
|
|
|
9770
9894
|
// cli/remoteTrigger.ts
|
|
9771
9895
|
import { createServer as createServer2, createConnection } from "net";
|
|
9772
9896
|
import { spawn as spawn3 } from "child_process";
|
|
9773
|
-
import { existsSync as
|
|
9897
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync10, unlinkSync as unlinkSync4, readdirSync as readdirSync3 } from "fs";
|
|
9774
9898
|
import { homedir as homedir8 } from "os";
|
|
9775
9899
|
import { join as join13 } from "path";
|
|
9776
9900
|
var log21 = forComponent("remote-trigger");
|
|
@@ -9838,7 +9962,7 @@ var TriggerServer = class {
|
|
|
9838
9962
|
};
|
|
9839
9963
|
function triggerLive(sessionId, req, dir = TRIGGER_DIR(), timeoutMs = 3e3) {
|
|
9840
9964
|
const p = sockPath(sessionId, dir);
|
|
9841
|
-
if (!
|
|
9965
|
+
if (!existsSync8(p)) return Promise.resolve(null);
|
|
9842
9966
|
return new Promise((res) => {
|
|
9843
9967
|
const conn = createConnection(p);
|
|
9844
9968
|
const done = (v) => {
|
|
@@ -9892,7 +10016,7 @@ function makeRemoteTriggerTool(opts) {
|
|
|
9892
10016
|
if (opts.selfId && full === opts.selfId()) return "Error: that is THIS session \u2014 use Task/TaskBatch for self-delegation.";
|
|
9893
10017
|
const live = await triggerLive(full, { prompt: text, from: opts.selfId?.() }, dir);
|
|
9894
10018
|
if (live?.ok) return `Delivered to live session ${full} \u2014 it runs there; the user sees it in that terminal.`;
|
|
9895
|
-
if (!target.meta.cwd || !
|
|
10019
|
+
if (!target.meta.cwd || !existsSync8(target.meta.cwd)) return `Error: session ${full} has no reachable cwd (${target.meta.cwd ?? "unknown"}).`;
|
|
9896
10020
|
return new Promise((res) => {
|
|
9897
10021
|
const child = doSpawn("/bin/sh", ["-c", `${opts.agentx} -p "$1" --resume "$2" --yes`, "sh", text, full], {
|
|
9898
10022
|
cwd: target.meta.cwd,
|
|
@@ -9946,6 +10070,19 @@ var VERSION = (() => {
|
|
|
9946
10070
|
return "?";
|
|
9947
10071
|
}
|
|
9948
10072
|
})();
|
|
10073
|
+
async function checkForUpdate(current) {
|
|
10074
|
+
if (current === "?") return null;
|
|
10075
|
+
const res = await fetch("https://registry.npmjs.org/@livx.cc/agentx/latest", {
|
|
10076
|
+
signal: AbortSignal.timeout(3e3)
|
|
10077
|
+
});
|
|
10078
|
+
if (!res.ok) return null;
|
|
10079
|
+
const { version: latest } = await res.json();
|
|
10080
|
+
if (!latest || latest === current) return null;
|
|
10081
|
+
const [cM, cm, cp] = current.split(".").map(Number);
|
|
10082
|
+
const [lM, lm, lp] = latest.split(".").map(Number);
|
|
10083
|
+
if (cM > lM || cM === lM && cm > lm || cM === lM && cm === lm && cp >= lp) return null;
|
|
10084
|
+
return `Update available: ${current} \u2192 ${latest}. Run \`bun add -g @livx.cc/agentx\` to update.`;
|
|
10085
|
+
}
|
|
9949
10086
|
var spinner = /* @__PURE__ */ (() => {
|
|
9950
10087
|
const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
9951
10088
|
let timer;
|
|
@@ -10166,10 +10303,10 @@ function resolveModelOrNewest(model) {
|
|
|
10166
10303
|
var ENV_KEY_ALIASES = { google: ["GEMINI_API_KEY"] };
|
|
10167
10304
|
function loadInstallEnv() {
|
|
10168
10305
|
let dir = dirname4(import.meta.path);
|
|
10169
|
-
for (let i = 0; i < 5 && !
|
|
10306
|
+
for (let i = 0; i < 5 && !existsSync9(join14(dir, "package.json")); i++) dir = dirname4(dir);
|
|
10170
10307
|
for (const name of [".env", ".env.local"]) {
|
|
10171
10308
|
const file = join14(dir, name);
|
|
10172
|
-
if (!
|
|
10309
|
+
if (!existsSync9(file)) continue;
|
|
10173
10310
|
for (const line of readFileSync8(file, "utf8").split("\n")) {
|
|
10174
10311
|
const m = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
10175
10312
|
if (!m || m[1] in process.env) continue;
|
|
@@ -11002,7 +11139,7 @@ var AGENTS_MD_TEMPLATE = `# ${"${name}"}
|
|
|
11002
11139
|
`;
|
|
11003
11140
|
function initInstructions(cwd) {
|
|
11004
11141
|
for (const f of ["AGENTS.md", "CLAUDE.md"]) {
|
|
11005
|
-
if (
|
|
11142
|
+
if (existsSync9(join14(cwd, f))) {
|
|
11006
11143
|
err(yellow(` ${f} already exists \u2014 leaving it as-is
|
|
11007
11144
|
`));
|
|
11008
11145
|
return;
|
|
@@ -11016,7 +11153,7 @@ function initInstructions(cwd) {
|
|
|
11016
11153
|
function persistSetting(cwd, key, value) {
|
|
11017
11154
|
const path = join14(cwd, ".agent", "settings.json");
|
|
11018
11155
|
try {
|
|
11019
|
-
const obj =
|
|
11156
|
+
const obj = existsSync9(path) ? JSON.parse(readFileSync8(path, "utf8")) : {};
|
|
11020
11157
|
if (obj[key] === value) return;
|
|
11021
11158
|
obj[key] = value;
|
|
11022
11159
|
mkdirSync11(dirname4(path), { recursive: true });
|
|
@@ -11216,6 +11353,7 @@ async function repl(args, ai, cfg, cwd) {
|
|
|
11216
11353
|
if (typeof e.kind === "string" && e.kind.startsWith("task_")) {
|
|
11217
11354
|
spinner.stop();
|
|
11218
11355
|
err("\r\x1B[0J" + (e.kind === "task_ask" ? yellow(` ? ${e.message} \u2014 answer by voice or type yes/no
|
|
11356
|
+
`) : e.kind === "task_error" ? yellow(` \u2717 ${e.message}
|
|
11219
11357
|
`) : dim(` \xB7 ${e.message}
|
|
11220
11358
|
`)));
|
|
11221
11359
|
editorRef?.redrawNow();
|
|
@@ -11496,7 +11634,7 @@ Added entries are loadable now via the Skill/SlashCommand tools; removed ones ar
|
|
|
11496
11634
|
</system-reminder>`;
|
|
11497
11635
|
};
|
|
11498
11636
|
const histPath = join14(cwd, ".agent", "history");
|
|
11499
|
-
const history =
|
|
11637
|
+
const history = existsSync9(histPath) ? readFileSync8(histPath, "utf8").split("\n").filter(Boolean).reverse().slice(0, 500) : [];
|
|
11500
11638
|
const remember = (line) => {
|
|
11501
11639
|
try {
|
|
11502
11640
|
mkdirSync11(join14(cwd, ".agent"), { recursive: true });
|
|
@@ -11820,7 +11958,7 @@ ${task}`;
|
|
|
11820
11958
|
keys.length ? ok(`provider keys: ${keys.join(", ")}`) : bad("no provider keys set (ANTHROPIC_API_KEY / OPENAI_API_KEY / GOOGLE_API_KEY / GROQ_API_KEY)");
|
|
11821
11959
|
const info = getModelInfo(work.model);
|
|
11822
11960
|
info?.pricing ? ok(`model ${work.model} \u2014 priced (${info.pricing.inputCostPer1K}/${info.pricing.outputCostPer1K} per 1k in/out)`) : warn(`model ${work.model} \u2014 no pricing in the catalog (costs will show ~$0; verify the id)`);
|
|
11823
|
-
const cfgFiles = ["ts", "js", "json"].flatMap((e) => [`${cwd}/.agent/config.${e}`, `${homedir9()}/.agent/config.${e}`]).filter((p) =>
|
|
11961
|
+
const cfgFiles = ["ts", "js", "json"].flatMap((e) => [`${cwd}/.agent/config.${e}`, `${homedir9()}/.agent/config.${e}`]).filter((p) => existsSync9(p));
|
|
11824
11962
|
cfgFiles.length ? ok(`config: ${cfgFiles.join(", ")}`) : warn("no .agent/config.* found (project or ~) \u2014 running on defaults");
|
|
11825
11963
|
try {
|
|
11826
11964
|
const probe = `${cwd}/.agent/sessions/.doctor-probe`;
|
|
@@ -12622,6 +12760,11 @@ ${task}`;
|
|
|
12622
12760
|
banner(bold("agentx") + cyan(" v" + VERSION) + dim(` \u2014 ${work.model} \xB7 ${cwd}`));
|
|
12623
12761
|
banner(dim("Type a task, or /help. Type / or @ for live suggestions (\u2191/\u2193 \u23CE). Esc cancels/clears; double-Esc jumps back; Ctrl-D exits."));
|
|
12624
12762
|
if (dx) banner(dim(`\u25D1 duplex \u2014 reflex: ${dx.options.reflexModel} \xB7 act: ${work.model}${dx.options.thinkModel !== false ? ` \xB7 think: ${dx.options.thinkModel}` : ""} (real work runs in background tasks, re-voiced when done)`));
|
|
12763
|
+
checkForUpdate(VERSION).then((msg) => {
|
|
12764
|
+
if (msg) err(yellow(` ${msg}
|
|
12765
|
+
`));
|
|
12766
|
+
}).catch(() => {
|
|
12767
|
+
});
|
|
12625
12768
|
const listDir = (absDir) => {
|
|
12626
12769
|
try {
|
|
12627
12770
|
return readdirSync4(join14(cwd, absDir.replace(/^\/+/, "")), { withFileTypes: true }).map((d) => ({ name: d.name, dir: d.isDirectory() }));
|