@livx.cc/agentx 0.99.91 → 0.99.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +421 -74
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +33 -4
- package/dist/index.js +274 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3545,6 +3545,13 @@ async function loadMemory(fs, dir, opts = {}) {
|
|
|
3545
3545
|
- (${restSlugs.length} more learnings, slugs only \u2014 call \`Recall\` if relevant): ${restSlugs.join(", ")}` : "");
|
|
3546
3546
|
return { index, tools };
|
|
3547
3547
|
}
|
|
3548
|
+
var TERM_STOPWORDS = new Set(`the and for but not you your yours our ours his her hers its their they them this that these those
|
|
3549
|
+
there here what when where which who whom whose why how all any each every some many much more most few other such only own same
|
|
3550
|
+
also just very can will would should could may might must shall have has had does did done was were are been being use used using
|
|
3551
|
+
always never often sometimes usually once then than now today tomorrow yesterday before after later soon first last next new old
|
|
3552
|
+
read write see make take give get set keep run add note notes user users company name names project projects team work works
|
|
3553
|
+
working home inbox label labels file files code prefer prefers please don't doesn't via per with without from into about over
|
|
3554
|
+
under yes okay important example one two three monday tuesday wednesday thursday friday saturday sunday`.split(/\s+/));
|
|
3548
3555
|
function slugify(s, fallback = "note") {
|
|
3549
3556
|
const base = String(s ?? "").trim().toLowerCase().replace(/\.md$/i, "").replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 48);
|
|
3550
3557
|
return base || fallback;
|
|
@@ -9372,6 +9379,19 @@ async function judgeLeak(decider, sentence, userSaid) {
|
|
|
9372
9379
|
if (!Number.isFinite(p)) throw new Error("leak judge: no noul in the answer");
|
|
9373
9380
|
return p;
|
|
9374
9381
|
}
|
|
9382
|
+
function scrubSpokenJunk(text, final = false) {
|
|
9383
|
+
let s = text.replace(/[-]/g, "").replace(/\[\s*emotion\b([^[\]]*)\]/gi, (_m, inner) => {
|
|
9384
|
+
const e = normalizeEmotion(inner.trim());
|
|
9385
|
+
return e ? `[${e}]` : "";
|
|
9386
|
+
}).replace(/\[[^\p{L}\p{N}[\]]*\]/gu, "").replace(/(?:[\s ]*(?:…|\.{2,}|[—–]|-{2,})){3,}/g, (m) => /^[\s ]/.test(m) ? " \u2026" : "\u2026");
|
|
9387
|
+
if (final) s = s.replace(/\[\s*emotion\b[^\]]*$/i, "");
|
|
9388
|
+
return s;
|
|
9389
|
+
}
|
|
9390
|
+
function isRepeatOf(sentence, spoken) {
|
|
9391
|
+
const norm2 = (x) => x.replace(/\[[a-z_ ]+\]/gi, "").replace(/[^\p{L}\p{N}]+/gu, " ").trim().toLowerCase();
|
|
9392
|
+
const s = norm2(sentence);
|
|
9393
|
+
return s.replace(/ /g, "").length >= 16 && spoken.split(SENTENCE_SPLIT).some((x) => norm2(x) === s);
|
|
9394
|
+
}
|
|
9375
9395
|
|
|
9376
9396
|
// src/duplex.ts
|
|
9377
9397
|
var log22 = forComponent("DuplexAgent");
|
|
@@ -9414,6 +9434,10 @@ var DuplexAgentOptions = class {
|
|
|
9414
9434
|
host;
|
|
9415
9435
|
/** How many recent transcript messages are rendered into a worker's brief. */
|
|
9416
9436
|
excerptTurns = 6;
|
|
9437
|
+
/** A Hold turn whose user says nothing more for this long is answered after all (a re-voice turn told they stopped):
|
|
9438
|
+
* without it a wrong Hold left the turn as a lone "mm-hm" forever. 0 = off. Only for a host that reports the user's
|
|
9439
|
+
* live speech via userActive() — else a slow talker's next words would be spoken over. */
|
|
9440
|
+
holdResumeMs = 0;
|
|
9417
9441
|
/** Voice register: 'neutral' = clean spoken style; 'conversational' = human-like — fillers,
|
|
9418
9442
|
* backchannels, impulsive first reactions before content (mimics real duplex conversation). */
|
|
9419
9443
|
voiceStyle = "neutral";
|
|
@@ -9454,6 +9478,9 @@ var DuplexAgentOptions = class {
|
|
|
9454
9478
|
/** Host overrides for QuickLook lookups (keyed by `what`). The engine's defaults go through the
|
|
9455
9479
|
* (possibly jailed) fs — e.g. `.git/**` is deny-listed, so the CLI supplies 'branch' itself. */
|
|
9456
9480
|
quickLook;
|
|
9481
|
+
/** Extra roots QuickLook ls/file try for a relative path not found under the cwd (the CLI passes ~ and ~/Documents:
|
|
9482
|
+
* a spoken "Projects/X" means ~/Documents/Projects/X far more often than <cwd>/Projects/X). */
|
|
9483
|
+
lookRoots = [];
|
|
9457
9484
|
/** Memory directory/directories on the WORKER fs. If set, the voice agent gets Remember + Recall
|
|
9458
9485
|
* tools directly (no delegation needed) and implicit capture guidance. */
|
|
9459
9486
|
memoryDir;
|
|
@@ -9461,6 +9488,60 @@ var DuplexAgentOptions = class {
|
|
|
9461
9488
|
memoryUserDir;
|
|
9462
9489
|
};
|
|
9463
9490
|
var SESSION_ID_RE = /^\d{8}-\d{6}(?:-[\w-]+)?$/;
|
|
9491
|
+
var MID_PHRASE_WORDS = /* @__PURE__ */ new Set([
|
|
9492
|
+
"slash",
|
|
9493
|
+
"backslash",
|
|
9494
|
+
"dash",
|
|
9495
|
+
"hyphen",
|
|
9496
|
+
"dot",
|
|
9497
|
+
"underscore",
|
|
9498
|
+
"colon",
|
|
9499
|
+
"comma",
|
|
9500
|
+
"and",
|
|
9501
|
+
"or",
|
|
9502
|
+
"but",
|
|
9503
|
+
"so",
|
|
9504
|
+
"because",
|
|
9505
|
+
"if",
|
|
9506
|
+
"then",
|
|
9507
|
+
"called",
|
|
9508
|
+
"named",
|
|
9509
|
+
"the",
|
|
9510
|
+
"a",
|
|
9511
|
+
"an",
|
|
9512
|
+
"my",
|
|
9513
|
+
"your",
|
|
9514
|
+
"our",
|
|
9515
|
+
"their",
|
|
9516
|
+
"is",
|
|
9517
|
+
"are",
|
|
9518
|
+
"um",
|
|
9519
|
+
"uh"
|
|
9520
|
+
]);
|
|
9521
|
+
var TRAILING_PREPS = /* @__PURE__ */ new Set(["to", "for", "with", "about", "of", "at", "in", "on", "from", "by", "into", "under", "inside"]);
|
|
9522
|
+
var QUESTION_START = /^(?:what|who|whom|whose|where|when|why|how|which|is|are|was|were|do|does|did|can|could|will|would|should|have|has)\b/i;
|
|
9523
|
+
var PHRASAL_HOST = /* @__PURE__ */ new Set(["it", "this", "that", "them", "him", "her", "me", "us", "you", "up", "out", "off", "down", "back", "over", "away"]);
|
|
9524
|
+
function endsMidPhrase(text) {
|
|
9525
|
+
const t = text.split("\n[")[0].trim();
|
|
9526
|
+
if (!t || /[.?!…]["')\]]*$/.test(t)) return false;
|
|
9527
|
+
if (/\b[a-z][\w+.-]*:\/\/\S+$/i.test(t)) return false;
|
|
9528
|
+
if (/[,/\\:\-–—]$/.test(t)) return true;
|
|
9529
|
+
const [last, prev] = (t.toLowerCase().match(/[\p{L}']+/gu) ?? []).reverse();
|
|
9530
|
+
if (!last) return false;
|
|
9531
|
+
if (TRAILING_PREPS.has(last)) return !QUESTION_START.test(t) && !PHRASAL_HOST.has(prev);
|
|
9532
|
+
return MID_PHRASE_WORDS.has(last);
|
|
9533
|
+
}
|
|
9534
|
+
function nameScore(want, have) {
|
|
9535
|
+
const a = want.toLowerCase().replace(/[^\p{L}\p{N}]/gu, ""), b = have.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "");
|
|
9536
|
+
if (!a || !b) return 0;
|
|
9537
|
+
let pre = 0;
|
|
9538
|
+
while (pre < a.length && a[pre] === b[pre]) pre++;
|
|
9539
|
+
const grams = (x) => new Set(Array.from({ length: Math.max(0, x.length - 1) }, (_, i) => x.slice(i, i + 2)));
|
|
9540
|
+
const ga = grams(a), gb = grams(b);
|
|
9541
|
+
let common = 0;
|
|
9542
|
+
for (const g of ga) if (gb.has(g)) common++;
|
|
9543
|
+
return pre * 2 + 2 * common / (ga.size + gb.size || 1);
|
|
9544
|
+
}
|
|
9464
9545
|
var RESERVED_EVENT_MARKER = /\[task\b[^\]\n]*\b(?:completed|failed|progress|asks)\b/i;
|
|
9465
9546
|
var RESERVED_EVENT_OPENER = /\[\s*task\b/i;
|
|
9466
9547
|
var STAGE_DIRECTION_RE = /^\(\s*(?:(?:waiting|checking|searching|thinking|processing|loading|working|fetching|looking)\b[^)]*|[^)]*(?:\.\.\.|…)\s*)\)$/i;
|
|
@@ -9483,11 +9564,11 @@ function isOfferAcceptance(text) {
|
|
|
9483
9564
|
}
|
|
9484
9565
|
var isQuestion = (s) => /\?["'”’)\]]*$/.test(s.trim());
|
|
9485
9566
|
var OFFER_OVERRUN = 150;
|
|
9486
|
-
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. Never emit stage directions or parenthetical asides about your own process \u2014 nothing like "(waiting for the result...)" or "(checking)"; while work runs, either say it as plain speech or end your turn.\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. DELEGATION RULE \u2014 decide for yourself, the user never has to push: if you cannot answer confidently from the conversation plus trivial well-known knowledge, do NOT refuse and do NOT guess \u2014 dispatch `Act` immediately with a clear brief and say you are checking. Anything needing CURRENT data (weather, news, prices, dates, sky/astronomy, "right now"), real computation, or verification is an automatic dispatch \u2014 never a refusal. The user should never need to say "search the web" or "think harder" to make you act; needing fresh or verified information IS the trigger. Refuse only what your worker genuinely cannot do (check `capabilities`), and say why. 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. Exactly ONE short line: never stack a second acknowledgement, and never narrate your own presence or status while waiting ("I\'m here", "let me see", "still checking" right after you already acked). One clean ack then silence reads as competent; repeated check-ins read as nervous.\nA completed task speaks its OWN result to the user (the worker voices what matters as it finishes) \u2014 you do NOT re-voice clean task results. A FAILED or INCOMPLETE task still arrives as a "[task t1 failed] \u2026" event for you to handle. 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 on a genuinely LONG wait you MAY give one brief half-sentence aside, but only occasionally; silence while working is normal and fine (the user knows you are on it). Do NOT narrate every step or re-announce yourself. 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 exists ONLY once the task finishes (the worker speaks it, and `TaskStatus` then returns it); 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, give one brief status aside and end the turn \u2014 never poll it again and again in a loop. "Still on it" is ONLY for a repeat check on a task you already acknowledged earlier \u2014 NEVER as the ack when you first dispatch work ("still" is wrong when nothing was running yet; use a fresh "on it"/"got it, checking" instead). 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, surprising, or only half-parses, do NOT guess an action or improvise content from it \u2014 briefly confirm what they meant ("did you mean\u2026?") and wait. A one-line confirm beats a confident wrong answer or an invented response to a request you did not actually understand.';
|
|
9567
|
+
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. Never emit stage directions or parenthetical asides about your own process \u2014 nothing like "(waiting for the result...)" or "(checking)"; while work runs, either say it as plain speech or end your turn.\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. DELEGATION RULE \u2014 decide for yourself, the user never has to push: if you cannot answer confidently from the conversation plus trivial well-known knowledge, do NOT refuse and do NOT guess \u2014 dispatch `Act` immediately with a clear brief and say you are checking. Anything needing CURRENT data (weather, news, prices, dates, sky/astronomy, "right now"), real computation, or verification is an automatic dispatch \u2014 never a refusal. The user should never need to say "search the web" or "think harder" to make you act; needing fresh or verified information IS the trigger. Refuse only what your worker genuinely cannot do (check `capabilities`), and say why. 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. Exactly ONE short line: never stack a second acknowledgement, and never narrate your own presence or status while waiting ("I\'m here", "let me see", "still checking" right after you already acked). One clean ack then silence reads as competent; repeated check-ins read as nervous.\nA completed task speaks its OWN result to the user (the worker voices what matters as it finishes) \u2014 you do NOT re-voice clean task results. A FAILED or INCOMPLETE task still arrives as a "[task t1 failed] \u2026" event for you to handle. 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 on a genuinely LONG wait you MAY give one brief half-sentence aside, but only occasionally; silence while working is normal and fine (the user knows you are on it). Do NOT narrate every step or re-announce yourself. 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 exists ONLY once the task finishes (the worker speaks it, and `TaskStatus` then returns it); 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 it ENDS mid-sentence or on a hesitation ("and then we", "but the problem is", "so I was, um") \u2014 call `Hold` instead of answering. A hesitation INSIDE a finished message ("can you, um, open it?") does not make it incomplete, and an unclear or odd but finished message is not a fragment: answer it, or ask one short question \u2014 never Hold on it. 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, give one brief status aside and end the turn \u2014 never poll it again and again in a loop. "Still on it" is ONLY for a repeat check on a task you already acknowledged earlier \u2014 NEVER as the ack when you first dispatch work ("still" is wrong when nothing was running yet; use a fresh "on it"/"got it, checking" instead). Use `CancelTask` when the user asks to stop something \u2014 to stop everything ("stop all", "cancel everything") pass id "all". When the user only ADDS to or CORRECTS a request whose task is still running (a detail, a path, a name, a spelling), call `Act` with `refines` set to that task id \u2014 it updates the running worker in place; never cancel and re-dispatch for a refinement.\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 (audio transcribed to text) and can carry transcription errors \u2014 odd words, cut-offs, homophones ("for you" vs "folder"), and especially MISHEARD NAMES: a surname, company, or project name often comes out as ordinary sound-alike words. Read for INTENT, not surface text, and do not silently rewrite what they said. If a message seems garbled, surprising, or only half-parses, or a word sounds like a name you already know (from memory or this conversation) but is spelled differently, treat it with suspicion \u2014 do NOT act on the odd word blindly or improvise content from it; briefly confirm what they meant ("did you mean\u2026?") and wait. A one-line confirm beats a confident wrong answer. NEVER save to memory a name, spelling, or term you only HEARD (it may be a transcription error) \u2014 when the user spells something aloud, read the spelling back and get a yes before storing it.';
|
|
9487
9568
|
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.";
|
|
9488
9569
|
var THINK_DISABLED_GUIDANCE = "(Think tier is not available \u2014 use Act for all escalations.)";
|
|
9489
9570
|
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).`;
|
|
9490
|
-
var EMOTION_TAGS_GUIDANCE = `EMOTION: your voice is synthesized with emotion control. Prefix a sentence with an inline
|
|
9571
|
+
var EMOTION_TAGS_GUIDANCE = `EMOTION: your voice is synthesized with emotion control. Prefix a sentence with an inline emotion tag \u2014 ONE emotion word from the list below in square brackets, the word alone (never the word "emotion" itself, never a guess or a question mark), placed directly before the sentence it colors, to shape how it is spoken. Use it ONLY when the emotion genuinely fits the words (it amplifies real feeling, it cannot fake it) \u2014 do not tag every sentence; reserve it for moments that carry feeling, and vary which one you use. You may also drop [laughter] for a natural laugh. Available emotions: ${EMOTIONS.join(", ")}.`;
|
|
9491
9572
|
var DuplexAgent = class _DuplexAgent {
|
|
9492
9573
|
options;
|
|
9493
9574
|
voice;
|
|
@@ -9538,6 +9619,10 @@ var DuplexAgent = class _DuplexAgent {
|
|
|
9538
9619
|
// host spoke on our behalf (adaptive micro-ack) — not reflex output
|
|
9539
9620
|
heldThisTurn = false;
|
|
9540
9621
|
// Hold called this turn → turn is INTENTIONALLY silent (suppress reflex text + no dead-air ack)
|
|
9622
|
+
holdTimer = null;
|
|
9623
|
+
// armed by a Hold turn's end (holdResumeMs)
|
|
9624
|
+
holdResumed = false;
|
|
9625
|
+
// the hold expired: the resume turn must answer (Hold refused) — until the user speaks
|
|
9541
9626
|
nudging = false;
|
|
9542
9627
|
// re-ack pass in flight: block ALL tools, prevent recursion
|
|
9543
9628
|
reflexBuf = "";
|
|
@@ -9548,6 +9633,10 @@ var DuplexAgent = class _DuplexAgent {
|
|
|
9548
9633
|
// reflex emitted a reserved [task …] marker → suppress its tail
|
|
9549
9634
|
leakCuts = [];
|
|
9550
9635
|
// heads of analysis-register leaks cut this turn — scrubbed from the transcript at turn end
|
|
9636
|
+
midPhraseBounced = false;
|
|
9637
|
+
// this turn's dispatch on a mid-phrase fragment was already bounced to Hold
|
|
9638
|
+
repeatCuts = [];
|
|
9639
|
+
// same-turn repeated sentences skipped this turn — their LATER copy is scrubbed from the transcript
|
|
9551
9640
|
leakStep = false;
|
|
9552
9641
|
// the CURRENT step's tail is muted by a leak cut (the next step speaks again, unlike a fabricated marker)
|
|
9553
9642
|
leakHit = false;
|
|
@@ -9711,7 +9800,7 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9711
9800
|
pumpReflex(final) {
|
|
9712
9801
|
for (; ; ) {
|
|
9713
9802
|
if (this.leakStep) return;
|
|
9714
|
-
this.
|
|
9803
|
+
this.scrubUnforwarded(final);
|
|
9715
9804
|
const from = this.reflexForwarded;
|
|
9716
9805
|
const buf = this.reflexBuf;
|
|
9717
9806
|
const lastMark = Math.max(from, ...this.stepMarks);
|
|
@@ -9721,6 +9810,8 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9721
9810
|
if (tail) upto -= tail[0].length;
|
|
9722
9811
|
const paren = buf.lastIndexOf("(");
|
|
9723
9812
|
if (paren >= lastMark && !buf.includes(")", paren) && buf.length - paren <= 80) upto = Math.min(upto, paren);
|
|
9813
|
+
const brk = buf.lastIndexOf("[");
|
|
9814
|
+
if (brk >= lastMark && !buf.includes("]", brk) && buf.length - brk <= 60) upto = Math.min(upto, brk);
|
|
9724
9815
|
}
|
|
9725
9816
|
if (upto <= from) return;
|
|
9726
9817
|
const region = buf.slice(from, upto);
|
|
@@ -9728,9 +9819,14 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9728
9819
|
for (const k of this.stepMarks) if (k > from && k <= upto) ends.push(k - from);
|
|
9729
9820
|
if (final || !ends.length && region.length >= 160) ends.push(region.length);
|
|
9730
9821
|
ends.sort((a, b) => a - b);
|
|
9731
|
-
let ok = 0, leak;
|
|
9822
|
+
let ok = 0, leak, repeat;
|
|
9732
9823
|
for (const e of ends) {
|
|
9733
9824
|
if (e <= ok) continue;
|
|
9825
|
+
const sent = region.slice(ok, e);
|
|
9826
|
+
if (sent.trim() && !/[\p{L}\p{N}]/u.test(sent) || isRepeatOf(sent, this.turnSpoken + region.slice(0, ok))) {
|
|
9827
|
+
repeat = e;
|
|
9828
|
+
break;
|
|
9829
|
+
}
|
|
9734
9830
|
const v = this.leakVerdict(region.slice(ok, e));
|
|
9735
9831
|
if (v === void 0) break;
|
|
9736
9832
|
if (v) {
|
|
@@ -9740,6 +9836,15 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9740
9836
|
ok = e;
|
|
9741
9837
|
}
|
|
9742
9838
|
this.forwardReflex(from + ok);
|
|
9839
|
+
if (repeat !== void 0) {
|
|
9840
|
+
const cut = region.slice(ok, repeat).trim();
|
|
9841
|
+
if (/[\p{L}\p{N}]/u.test(cut)) {
|
|
9842
|
+
this.repeatCuts.push(cut);
|
|
9843
|
+
this.notify("diag", "reflex_repeat", { text: cut.slice(0, 80) });
|
|
9844
|
+
}
|
|
9845
|
+
this.reflexForwarded = from + repeat;
|
|
9846
|
+
continue;
|
|
9847
|
+
}
|
|
9743
9848
|
if (leak === void 0) return;
|
|
9744
9849
|
const at = from + ok;
|
|
9745
9850
|
this.leakHit = true;
|
|
@@ -9814,6 +9919,22 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9814
9919
|
scrubLeakFromTranscript() {
|
|
9815
9920
|
const keys = this.leakCuts.splice(0);
|
|
9816
9921
|
const t = this.voice.transcript;
|
|
9922
|
+
for (let i = this.turnBase; i < t.length; i++) {
|
|
9923
|
+
const m = t[i];
|
|
9924
|
+
if (m.role === "assistant" && typeof m.content === "string") m.content = scrubSpokenJunk(m.content, true).trim();
|
|
9925
|
+
}
|
|
9926
|
+
for (const cut of this.repeatCuts.splice(0)) {
|
|
9927
|
+
const rep = cut.replace(/^(?:\[[^\]]*\]\s*)+/, "");
|
|
9928
|
+
if (!rep) continue;
|
|
9929
|
+
for (let i = t.length - 1; i >= this.turnBase; i--) {
|
|
9930
|
+
const m = t[i];
|
|
9931
|
+
if (m.role !== "assistant" || typeof m.content !== "string") continue;
|
|
9932
|
+
const at = m.content.lastIndexOf(rep);
|
|
9933
|
+
if (at <= 0 && !(at === 0 && t.slice(this.turnBase, i).some((x) => x.role === "assistant" && contentText(x.content).includes(rep)))) continue;
|
|
9934
|
+
m.content = (m.content.slice(0, at).replace(/\[[^\]]*\]\s*$/, "") + m.content.slice(at + rep.length)).trim();
|
|
9935
|
+
break;
|
|
9936
|
+
}
|
|
9937
|
+
}
|
|
9817
9938
|
for (const key of keys) {
|
|
9818
9939
|
let i = t.length - 1;
|
|
9819
9940
|
while (i >= this.turnBase && !(t[i].role === "assistant" && typeof t[i].content === "string" && t[i].content.includes(key))) i--;
|
|
@@ -9857,17 +9978,32 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9857
9978
|
await this.drainReflex();
|
|
9858
9979
|
this.scrubLeakFromTranscript();
|
|
9859
9980
|
this.scrubHeldText();
|
|
9981
|
+
if (this.heldThisTurn) {
|
|
9982
|
+
this.armHoldResume();
|
|
9983
|
+
return;
|
|
9984
|
+
}
|
|
9860
9985
|
if (this.silentTurn && res?.finishReason === "error" && refusedCall(res.error)) this.emitHost({ kind: "text_delta", message: fallback ?? _DuplexAgent.FALLBACK_ERROR });
|
|
9861
9986
|
else if (this.silentTurn) await this.ackIfSilent(fallback);
|
|
9862
9987
|
}
|
|
9863
|
-
/**
|
|
9864
|
-
* Only the unforwarded region is touched — already-spoken audio can't be unsent, and
|
|
9865
|
-
* reflexForwarded would corrupt the forward offset.
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
const
|
|
9869
|
-
|
|
9870
|
-
|
|
9988
|
+
/** Rewrite the UNFORWARDED reflex text: drop complete stage-direction parentheticals (STAGE_DIRECTION_RE) and spoken
|
|
9989
|
+
* junk (scrubSpokenJunk). Only the unforwarded region is touched — already-spoken audio can't be unsent, and
|
|
9990
|
+
* splicing before reflexForwarded would corrupt the forward offset. Rewritten per step segment so the stepMarks
|
|
9991
|
+
* after it move with the text (a mark is a reflexBuf offset); a segment that ends at a step mark is complete. */
|
|
9992
|
+
scrubUnforwarded(final) {
|
|
9993
|
+
const from = this.reflexForwarded, buf = this.reflexBuf;
|
|
9994
|
+
if (from >= buf.length) return;
|
|
9995
|
+
const scrub = (seg, complete) => scrubSpokenJunk(seg.replace(/\([^()]*\)/g, (x) => STAGE_DIRECTION_RE.test(x) ? "" : x), complete);
|
|
9996
|
+
const marks = new Set(this.stepMarks.filter((k) => k > from && k <= buf.length));
|
|
9997
|
+
let out = buf.slice(0, from), at = from;
|
|
9998
|
+
const moved = /* @__PURE__ */ new Map();
|
|
9999
|
+
for (const k of [.../* @__PURE__ */ new Set([...marks, buf.length])].sort((x, y) => x - y)) {
|
|
10000
|
+
out += scrub(buf.slice(at, k), final || marks.has(k));
|
|
10001
|
+
moved.set(k, out.length);
|
|
10002
|
+
at = k;
|
|
10003
|
+
}
|
|
10004
|
+
if (out === buf) return;
|
|
10005
|
+
this.reflexBuf = out;
|
|
10006
|
+
this.stepMarks = this.stepMarks.map((k) => moved.get(k) ?? k);
|
|
9871
10007
|
}
|
|
9872
10008
|
/** Clear the per-turn guards. Called at the head of every voice turn (user send + re-voice flush). */
|
|
9873
10009
|
resetTurn() {
|
|
@@ -9881,6 +10017,8 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9881
10017
|
this.reflexForwarded = 0;
|
|
9882
10018
|
this.fabricationCut = false;
|
|
9883
10019
|
this.leakCuts = [];
|
|
10020
|
+
this.repeatCuts = [];
|
|
10021
|
+
this.midPhraseBounced = false;
|
|
9884
10022
|
this.leakStep = this.leakHit = false;
|
|
9885
10023
|
this.stepMarks = [];
|
|
9886
10024
|
this.leakVerdicts.clear();
|
|
@@ -9904,6 +10042,13 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9904
10042
|
return { block: true, reason: "Speculative turn aborted." };
|
|
9905
10043
|
}
|
|
9906
10044
|
if (this.nudging) return { block: true, reason: "Just say one short spoken acknowledgement \u2014 no tools this turn." };
|
|
10045
|
+
if ((call.name === "Act" || call.name === "Think") && !this.turnDispatched && !this.midPhraseBounced) {
|
|
10046
|
+
const said = [...this.voice.transcript].reverse().find((m) => m.role === "user");
|
|
10047
|
+
if (said && endsMidPhrase(contentText(said.content))) {
|
|
10048
|
+
this.midPhraseBounced = true;
|
|
10049
|
+
return { block: true, reason: "The user stopped mid-phrase \u2014 the rest of their request is still coming. Call Hold now (no filler) and wait for it; do not dispatch on a fragment." };
|
|
10050
|
+
}
|
|
10051
|
+
}
|
|
9907
10052
|
if (!this.turnDispatched) return;
|
|
9908
10053
|
if (call.name === "TaskStatus")
|
|
9909
10054
|
return { block: true, reason: "You just dispatched a task this turn \u2014 do NOT poll. Give one short spoken acknowledgement and end your turn; the result arrives later as a [task \u2026] event." };
|
|
@@ -9919,6 +10064,27 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9919
10064
|
noteExternalSpeech() {
|
|
9920
10065
|
this.externalSpeech = true;
|
|
9921
10066
|
}
|
|
10067
|
+
/** The user is speaking (a live partial, a barge): a pending Hold expiry waits for them again. */
|
|
10068
|
+
userActive() {
|
|
10069
|
+
if (this.holdTimer) this.armHoldResume();
|
|
10070
|
+
}
|
|
10071
|
+
clearHoldResume() {
|
|
10072
|
+
if (this.holdTimer) clearTimeout(this.holdTimer);
|
|
10073
|
+
this.holdTimer = null;
|
|
10074
|
+
}
|
|
10075
|
+
armHoldResume() {
|
|
10076
|
+
this.clearHoldResume();
|
|
10077
|
+
const ms = this.options.holdResumeMs;
|
|
10078
|
+
if (!ms) return;
|
|
10079
|
+
this.holdTimer = setTimeout(() => {
|
|
10080
|
+
this.holdTimer = null;
|
|
10081
|
+
this.holdResumed = true;
|
|
10082
|
+
this.notify("diag", "hold_expired", { ms });
|
|
10083
|
+
this.queueRevoice(_DuplexAgent.HOLD_EXPIRED);
|
|
10084
|
+
}, ms);
|
|
10085
|
+
this.holdTimer.unref?.();
|
|
10086
|
+
}
|
|
10087
|
+
static HOLD_EXPIRED = "[the user stopped there and did not go on \u2014 respond to what they said now; if it is unclear, ask one short question. Do not Hold.]";
|
|
9922
10088
|
/** True when the just-finished turn voiced NOTHING — dead air to repair. Two ways this happens:
|
|
9923
10089
|
* (a) a dispatch with no spoken ack, and (b) an INLINE turn whose `final` channel came back empty —
|
|
9924
10090
|
* gpt-oss harmony sometimes puts the whole reply in `analysis` (→ thinking_delta, suppressed in
|
|
@@ -9981,6 +10147,8 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
9981
10147
|
* second Act). The host gets `turn_replace` {id, replaces, rolledBack, followed?}: only a rollback drops the replaced
|
|
9982
10148
|
* line; `followed` = the kept turn whose follow-up ran (absent: the merged text ran). */
|
|
9983
10149
|
send(content, opts) {
|
|
10150
|
+
this.clearHoldResume();
|
|
10151
|
+
this.holdResumed = false;
|
|
9984
10152
|
if (opts?.replaces) this.replaceTurn(opts.replaces);
|
|
9985
10153
|
const cur = this.voice.options.signal;
|
|
9986
10154
|
const ext = cur && cur === this.turnSignal?.own ? this.turnSignal.ext : cur;
|
|
@@ -10237,6 +10405,20 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
10237
10405
|
spec.decide("abort");
|
|
10238
10406
|
this.notify("diag", "speculation_aborted", { text: spec.text.slice(0, 80) });
|
|
10239
10407
|
}
|
|
10408
|
+
/** Fold a refinement into a RUNNING task's worker (Agent.inject — picked up at its next step) instead of cancel +
|
|
10409
|
+
* respawn: live 20261013-085238 one request spoken over three fragments became t5 → cancel → t6 → cancel → t7, each
|
|
10410
|
+
* worker restarting from zero. Returns the id when amended, undefined when the task is not running (→ dispatch new). */
|
|
10411
|
+
amendTask(id, brief) {
|
|
10412
|
+
const rec = this.tasks.get(id);
|
|
10413
|
+
if (!rec || rec.status !== "running" || !rec.worker || !brief.trim()) return void 0;
|
|
10414
|
+
rec.worker.inject(`[update from the user while you work \u2014 fold it into the SAME task, do not start over]
|
|
10415
|
+
${brief}`);
|
|
10416
|
+
rec.brief += `
|
|
10417
|
+
|
|
10418
|
+
Update: ${brief}`;
|
|
10419
|
+
this.notify("diag", "task_amended", { id, brief: brief.slice(0, 80) });
|
|
10420
|
+
return rec.id;
|
|
10421
|
+
}
|
|
10240
10422
|
/** Cancel a running background task — shared by the CancelTask tool and the CLI /tasks picker. */
|
|
10241
10423
|
cancelTask(id) {
|
|
10242
10424
|
const rec = this.tasks.get(id);
|
|
@@ -10523,14 +10705,15 @@ ${recent}` : brief) + verify + deliverContract;
|
|
|
10523
10705
|
signal: controller.signal
|
|
10524
10706
|
// shared with the checker so a cancel tears down both
|
|
10525
10707
|
};
|
|
10526
|
-
const
|
|
10708
|
+
const worker = new Agent(agentOpts);
|
|
10709
|
+
const promise = worker.run(briefText).then((res) => {
|
|
10527
10710
|
const { spoken, detail } = splitter.flush();
|
|
10528
10711
|
feedSpoken(spoken);
|
|
10529
10712
|
if (detail.trim()) pushTail(detail.trim());
|
|
10530
10713
|
flushSpoken();
|
|
10531
10714
|
return res;
|
|
10532
10715
|
}).then((res) => this.maybeVerify(id, brief, res, tier, agentOpts, askBridge)).then((res) => this.onWorkerSettled(id, res)).catch((err) => this.onWorkerFailed(id, err));
|
|
10533
|
-
this.tasks.set(id, { id, label, status: "running", controller, promise, tail, brief, followUp, splitter, createdTurn: this.turn });
|
|
10716
|
+
this.tasks.set(id, { id, label, status: "running", controller, promise, tail, brief, followUp, splitter, createdTurn: this.turn, worker });
|
|
10534
10717
|
if (this.tasks.size > this.options.maxTaskRecords)
|
|
10535
10718
|
for (const [tid, rec] of this.tasks) {
|
|
10536
10719
|
if (this.tasks.size <= this.options.maxTaskRecords) break;
|
|
@@ -10783,14 +10966,17 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
10783
10966
|
required: ["brief"],
|
|
10784
10967
|
properties: {
|
|
10785
10968
|
brief: { type: "string", description: "full, self-contained instructions for the worker" },
|
|
10786
|
-
label: { type: "string", description: "a short (2-4 word) label for the task" }
|
|
10969
|
+
label: { type: "string", description: "a short (2-4 word) label for the task" },
|
|
10970
|
+
refines: { type: "string", description: "id of a STILL-RUNNING task this message only adds detail to or corrects (a path, a name, a spelling) \u2014 the running worker is updated in place instead of starting a new task" }
|
|
10787
10971
|
}
|
|
10788
10972
|
},
|
|
10789
|
-
run: async ({ brief, label }) => {
|
|
10973
|
+
run: async ({ brief, label, refines }) => {
|
|
10790
10974
|
this.spokeBeforeDispatch = this.spokeThisTurn;
|
|
10791
10975
|
this.turnDispatched = true;
|
|
10792
10976
|
this.turnBriefs.add(String(brief ?? ""));
|
|
10793
10977
|
this.voice.options.toolChoice = "none";
|
|
10978
|
+
const amended = refines ? this.amendTask(String(refines), String(brief ?? "")) : void 0;
|
|
10979
|
+
if (amended) return this.dispatchResult(amended, "Updated the running");
|
|
10794
10980
|
const id = await this.dispatch(String(brief ?? ""), "act", label ? String(label) : void 0, this.turnFollowUp);
|
|
10795
10981
|
return this.dispatchResult(id, "Acting on");
|
|
10796
10982
|
}
|
|
@@ -10888,29 +11074,36 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
10888
11074
|
case "ls": {
|
|
10889
11075
|
if (!fs) return "unavailable (no filesystem)";
|
|
10890
11076
|
const p = String(path ?? ".");
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
return names.slice(0, 50).join("\n") + (names.length > 50 ? `
|
|
10894
|
-
\u2026 (+${names.length - 50} more)` : "");
|
|
10895
|
-
} catch {
|
|
10896
|
-
const names = await fs.readDir(".").catch(() => []);
|
|
10897
|
-
return `'${p}' not found here \u2014 you are likely already inside it. Current directory listing:
|
|
10898
|
-
` + names.slice(0, 50).join("\n") + (names.length > 50 ? `
|
|
11077
|
+
const list = (at, names) => (at === p ? "" : `(${at})
|
|
11078
|
+
`) + names.slice(0, 50).join("\n") + (names.length > 50 ? `
|
|
10899
11079
|
\u2026 (+${names.length - 50} more)` : "");
|
|
11080
|
+
for (const at of this.lookCandidates(p)) {
|
|
11081
|
+
try {
|
|
11082
|
+
return list(at, await fs.readDir(at));
|
|
11083
|
+
} catch {
|
|
11084
|
+
}
|
|
10900
11085
|
}
|
|
11086
|
+
const cwd = (fs.getCwd?.() ?? "").replace(/\/+$/, "");
|
|
11087
|
+
if (cwd && p.replace(/^\.\/|\/+$/g, "") === cwd.split("/").pop()) return `'${p}' is the current directory:
|
|
11088
|
+
` + list(".", await fs.readDir(".").catch(() => []));
|
|
11089
|
+
return await this.lookMiss(p);
|
|
10901
11090
|
}
|
|
10902
11091
|
case "file": {
|
|
10903
11092
|
if (!fs) return "unavailable (no filesystem)";
|
|
10904
11093
|
if (!path) return "file lookup needs a path";
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
11094
|
+
for (const at of this.lookCandidates(String(path))) {
|
|
11095
|
+
let text;
|
|
11096
|
+
try {
|
|
11097
|
+
text = await fs.readFile(at);
|
|
11098
|
+
} catch {
|
|
11099
|
+
continue;
|
|
11100
|
+
}
|
|
11101
|
+
const head = at === String(path) ? "" : `(${at})
|
|
11102
|
+
`;
|
|
11103
|
+
return head + (text.length > CAP ? text.slice(0, CAP) + `
|
|
11104
|
+
\u2026 (truncated \u2014 ${text.length} chars total; Act for the full file)` : text);
|
|
10913
11105
|
}
|
|
11106
|
+
return await this.lookMiss(String(path));
|
|
10914
11107
|
}
|
|
10915
11108
|
default:
|
|
10916
11109
|
return `unknown lookup '${what}'`;
|
|
@@ -10921,6 +11114,41 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
10921
11114
|
}
|
|
10922
11115
|
};
|
|
10923
11116
|
}
|
|
11117
|
+
/** Where QuickLook tries a path: as given (cwd-relative or absolute), then — relative only — under each lookRoot. */
|
|
11118
|
+
lookCandidates(p) {
|
|
11119
|
+
const rel = p.replace(/^~\/?/, "");
|
|
11120
|
+
const roots = this.options.lookRoots;
|
|
11121
|
+
if (p.startsWith("~")) return roots.length ? [`${roots[0].replace(/\/+$/, "")}/${rel}`.replace(/\/$/, "")] : [p];
|
|
11122
|
+
if (p.startsWith("/")) return [p];
|
|
11123
|
+
return [p, ...roots.map((r) => `${r.replace(/\/+$/, "")}/${rel}`)];
|
|
11124
|
+
}
|
|
11125
|
+
/** A QuickLook path not found anywhere: say where it looked and, at the deepest folder that DID exist, the few closest
|
|
11126
|
+
* names (a mis-heard segment — "Lead Sheets" for "Livshitz" — is usually one of them). Never the whole cwd listing:
|
|
11127
|
+
* live 20261013-085238 dumped it three times for three spellings of the same path. */
|
|
11128
|
+
async lookMiss(p) {
|
|
11129
|
+
const fs = this.options.fs;
|
|
11130
|
+
const segs = p.replace(/^~\/?/, "").split("/").filter((x) => x && x !== ".");
|
|
11131
|
+
const bases = p.startsWith("/") ? ["/"] : p.startsWith("~") ? this.options.lookRoots.slice(0, 1) : [".", ...this.options.lookRoots];
|
|
11132
|
+
let best;
|
|
11133
|
+
for (const base of bases) {
|
|
11134
|
+
let dir = base;
|
|
11135
|
+
for (let i = 0; i < segs.length; i++) {
|
|
11136
|
+
const names = await fs.readDir(dir).catch(() => void 0);
|
|
11137
|
+
if (!names) break;
|
|
11138
|
+
const hit = names.find((n) => n.toLowerCase() === segs[i].toLowerCase());
|
|
11139
|
+
if (!hit) {
|
|
11140
|
+
if (i > (best?.depth ?? -1)) best = { dir, depth: i, names };
|
|
11141
|
+
break;
|
|
11142
|
+
}
|
|
11143
|
+
dir = dir === "." ? hit : `${dir.replace(/\/+$/, "")}/${hit}`;
|
|
11144
|
+
}
|
|
11145
|
+
}
|
|
11146
|
+
const where = ["the current folder", ...this.options.lookRoots].join(", ");
|
|
11147
|
+
if (!best || !best.names.length) return `'${p}' not found (looked under ${where}). Ask the user for the exact path, or Act to search for it.`;
|
|
11148
|
+
const missing = segs[best.depth];
|
|
11149
|
+
const close = [...best.names].sort((x, y) => nameScore(missing, y) - nameScore(missing, x)).slice(0, 6);
|
|
11150
|
+
return `'${p}' not found (looked under ${where}). '${missing}' is not in ${best.dir} \u2014 closest names there: ${close.join(", ")}. If one of these is what they meant (speech-to-text often mishears names), use it; otherwise ask the user or Act to search.`;
|
|
11151
|
+
}
|
|
10924
11152
|
answerTaskTool() {
|
|
10925
11153
|
return {
|
|
10926
11154
|
name: "AnswerTask",
|
|
@@ -10949,6 +11177,8 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
10949
11177
|
}
|
|
10950
11178
|
},
|
|
10951
11179
|
run: async ({ filler }) => {
|
|
11180
|
+
if (this.heldThisTurn) return "Already holding \u2014 stay silent.";
|
|
11181
|
+
if (this.holdResumed) return "Not now \u2014 the user already stopped after those words. Answer them now in one or two short sentences, or ask one short question.";
|
|
10952
11182
|
this.heldThisTurn = true;
|
|
10953
11183
|
this.notify("hold_filler", filler ? String(filler) : "");
|
|
10954
11184
|
return "Holding \u2014 listening for the rest of the user's thought. Do not respond further this turn.";
|
|
@@ -10958,13 +11188,21 @@ Another agent just implemented the above. Independently check the CURRENT state
|
|
|
10958
11188
|
cancelTaskTool() {
|
|
10959
11189
|
return {
|
|
10960
11190
|
name: "CancelTask",
|
|
10961
|
-
description:
|
|
10962
|
-
parameters: { type: "object", required: ["id"], properties: { id: { type: "string" } } },
|
|
11191
|
+
description: 'Cancel a running background task by id \u2014 or id "all" to cancel EVERY running task (the user said "stop everything", "stop all the searches").',
|
|
11192
|
+
parameters: { type: "object", required: ["id"], properties: { id: { type: "string", description: 'a task id, or "all"' } } },
|
|
10963
11193
|
// Cancel-and-redirect ("stop — do Y instead") is ONE user line: live, the reflex cancelled, said "fetching Y now" and
|
|
10964
11194
|
// never dispatched (2/5 Bare voice runs). The tool result is where it looks next — tell it the redirect needs Act.
|
|
11195
|
+
// "Stop all the searches" cancelled one task (and hit a done one) and left t4 running (live 20261013-085238): the
|
|
11196
|
+
// result always names what is STILL running, and "all" stops every one in a single call.
|
|
10965
11197
|
run: async ({ id }) => {
|
|
10966
|
-
const
|
|
10967
|
-
|
|
11198
|
+
const want = String(id ?? "").trim();
|
|
11199
|
+
const running = () => [...this.tasks.values()].filter((t) => t.status === "running");
|
|
11200
|
+
const ids = /^(?:all|\*|everything)$/i.test(want) ? running().map((t) => t.id) : [want];
|
|
11201
|
+
const lines = ids.length ? ids.map((x) => this.cancelTask(x)) : ["No running tasks."];
|
|
11202
|
+
const left = running();
|
|
11203
|
+
const tail = left.length ? ` Still running: ${left.map((t) => `${t.id} (${t.label})`).join(", ")} \u2014 if the user asked to stop ALL, cancel these too (or call CancelTask with id "all").` : " No tasks are running now.";
|
|
11204
|
+
const cancelled = ids.some((x) => this.tasks.get(x)?.status === "cancelled");
|
|
11205
|
+
return lines.join(" ") + tail + (cancelled ? ` If the user's message ALSO asked for different work (a redirect \u2014 "instead\u2026", "actually\u2026", "do Y"), call Act NOW with that new brief: saying you are on it without calling Act does nothing. If they only asked to stop, just acknowledge in a few words.` : "");
|
|
10968
11206
|
}
|
|
10969
11207
|
};
|
|
10970
11208
|
}
|