@livx.cc/agentx 0.99.164 → 0.99.166

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.js CHANGED
@@ -3359,7 +3359,7 @@ var init_tools_shell = __esm({
3359
3359
 
3360
3360
  // cli/cli.ts
3361
3361
  import { createInterface } from "readline/promises";
3362
- import { existsSync as existsSync9, readFileSync as readFileSync10, appendFileSync as appendFileSync2, mkdirSync as mkdirSync12, writeFileSync as writeFileSync9, readdirSync as readdirSync4, statSync as statSync8, unlinkSync as unlinkSync5 } from "fs";
3362
+ import { existsSync as existsSync9, readFileSync as readFileSync10, appendFileSync as appendFileSync2, mkdirSync as mkdirSync12, writeFileSync as writeFileSync9, readdirSync as readdirSync4, statSync as statSync7, unlinkSync as unlinkSync5 } from "fs";
3363
3363
  import { homedir as homedir10 } from "os";
3364
3364
  import { spawnSync as spawnSync7 } from "child_process";
3365
3365
 
@@ -5340,12 +5340,17 @@ var Agent = class _Agent {
5340
5340
  * No model call; the transcript gains only that system message. Other models: nothing to warm. */
5341
5341
  async prewarm() {
5342
5342
  const o = this.options;
5343
- if (!o.model.startsWith("claude-code/") || !o.providerOptions?.claudeCodeSession) return;
5343
+ const api = o.model.startsWith("anthropic/") && o.promptCache;
5344
+ if (!api && (!o.model.startsWith("claude-code/") || !o.providerOptions?.claudeCodeSession)) return;
5344
5345
  await this.ensureFs();
5345
5346
  const systemPrompt = await this.prepare(), startCtx = await this.fireSessionStart();
5346
5347
  const sys = { role: "system", content: systemPrompt + (startCtx ? "\n\n" + startCtx : "") };
5347
5348
  if (this.transcript[0]?.role === "system") this.transcript[0] = sys;
5348
5349
  else this.transcript.unshift(sys);
5350
+ if (api) {
5351
+ await o.ai.chat({ model: o.model, messages: [sys, { role: "user", content: "." }], tools: toWireTools(this.activeTools), stream: false, maxTokens: 1, promptCache: true, ...o.providerOptions ? { providerOptions: o.providerOptions } : {} });
5352
+ return;
5353
+ }
5349
5354
  const po = this.claudeCodePo(), frag = reasoningToChatFragment(o.model, o.reasoning);
5350
5355
  const r = await o.ai.chat({ model: o.model, messages: this.trimContext(), tools: [], stream: true, ...frag, ...o.promptCache ? { promptCache: true } : {}, providerOptions: { ...frag.providerOptions, ...o.providerOptions, ...po, prewarm: true } });
5351
5356
  for await (const _ of r) {
@@ -8148,6 +8153,9 @@ var VoiceEngine = class _VoiceEngine {
8148
8153
  // bumps on every aside start/cancel — a late aside of a dead hold never plays
8149
8154
  speaking = false;
8150
8155
  // audible (deltas flowing OR audio draining)
8156
+ speechStartAt = 0;
8157
+ // clock time `speaking` last turned on / off
8158
+ speechEndAt = 0;
8151
8159
  ctxOpen = false;
8152
8160
  // the current TTS context still accepts deltas (false once end-frame sent)
8153
8161
  interrupted = false;
@@ -8345,11 +8353,13 @@ var VoiceEngine = class _VoiceEngine {
8345
8353
  this.handleUtterance(k.text, language ? { [language]: k.text.length } : void 0, k.turns);
8346
8354
  };
8347
8355
  this.stt.onLevel = (rms) => this.handleLevel(rms);
8356
+ this.stt.isAudible = (agoMs = 0) => this.speakingAt(this.clock.now() - agoMs);
8348
8357
  const stt = this.stt;
8349
8358
  this.agentText = stt.agentTextInput && stt.sendAgentText ? new AgentTextFeed({
8350
8359
  clock: this.clock,
8351
8360
  playedMs: () => Math.max(0, this.player.playedMs()),
8352
8361
  send: (text, end) => {
8362
+ this.diag("agent_text", { text: text.slice(0, 80), ...end ? { end: true } : {} });
8353
8363
  try {
8354
8364
  stt.sendAgentText(text, end);
8355
8365
  } catch (e) {
@@ -8441,7 +8451,10 @@ var VoiceEngine = class _VoiceEngine {
8441
8451
  }
8442
8452
  this.diag("tts_turn_begin", { ack, gapless: this.speaking });
8443
8453
  const gapless = this.speaking;
8444
- if (!this.speaking) this.player.markTurn();
8454
+ if (!this.speaking) {
8455
+ this.player.markTurn();
8456
+ this.speechStartAt = this.clock.now();
8457
+ }
8445
8458
  this.speaking = true;
8446
8459
  this.ctxOpen = true;
8447
8460
  this.spokeDeltas = false;
@@ -8666,6 +8679,7 @@ var VoiceEngine = class _VoiceEngine {
8666
8679
  }
8667
8680
  this.drainTimer = null;
8668
8681
  this.speaking = false;
8682
+ this.speechEndAt = this.clock.now();
8669
8683
  this.agentText?.end();
8670
8684
  this.stopWordReveal(true);
8671
8685
  if (this.turnStartAt) log14.debug(`turn: ${Math.round(this.clock.now() - this.turnStartAt)}ms (incl. playback)`);
@@ -8864,6 +8878,7 @@ var VoiceEngine = class _VoiceEngine {
8864
8878
  if (this.reply || droppedQueued) this.lastInterrupted = { full: this.reply, heard, exact, queued, queuedTurn: this.queuedTurn };
8865
8879
  if (heard.length < this.reply.length || droppedQueued) this.bargedSinceDispatch = true;
8866
8880
  this.speaking = false;
8881
+ this.speechEndAt = this.clock.now();
8867
8882
  this.ctxOpen = false;
8868
8883
  this.interrupted = true;
8869
8884
  this.suspectUntil = 0;
@@ -8973,6 +8988,14 @@ var VoiceEngine = class _VoiceEngine {
8973
8988
  novelWords(text) {
8974
8989
  return this.words(text).filter((w) => !this.echoWords.has(w));
8975
8990
  }
8991
+ /** Was the assistant speaking at clock time `t` (+ PHANTOM_TAIL_MS)? Narrower than echoActive's multi-second echo
8992
+ * tail on purpose: the STT phantom guard drops low-confidence short finals here, and a real "Yes." said right after
8993
+ * a question must not land inside it. speechEndAt already trails the audio by the settle margin (~300ms). */
8994
+ speakingAt(t) {
8995
+ if (t < this.speechStartAt) return false;
8996
+ return this.speaking || t < this.speechEndAt + _VoiceEngine.PHANTOM_TAIL_MS;
8997
+ }
8998
+ static PHANTOM_TAIL_MS = 300;
8976
8999
  echoActive() {
8977
9000
  return this.speaking || this.clock.now() < this.echoUntil;
8978
9001
  }
@@ -10042,7 +10065,18 @@ var SonioxSTTOptions = class {
10042
10065
  * same socket (`sendAgentText`, which VoiceEngine drives paced to playback), so Soniox filters the leftover echo
10043
10066
  * of our own voice out of the transcript. Complements AEC — keep echo cancellation on. */
10044
10067
  agentTextInput = false;
10068
+ /** Phantom guard: when its last word fell while the assistant was speaking (`isAudible`, wired by VoiceEngine), drop a
10069
+ * final of at most `phantomMaxWords` words, all listener tokens (`phantomTokens`), whose least-sure token is below
10070
+ * `phantomMinConfidence`. stt-rt-v6 makes up backchannels ("Okay.", "Yeah.", "Mm-hmm.") from echo residue under our
10071
+ * own voice: all at confMin 0.33-0.78 (agentx session 20261111-124649). Confidence alone can't separate them from a
10072
+ * real word said over our voice — `say` clips into live Soniox under a reply's residue: 12/19 soft interjections fell
10073
+ * below 0.8 — so words that act ("Stop.", "No.", "Yes.", "Wait.") always pass; a listener token over our own speech
10074
+ * is a no-op anyway. 0 = off. */
10075
+ phantomMinConfidence = 0.8;
10076
+ phantomMaxWords = 2;
10077
+ phantomTokens = /^(?:okay|ok|yeah|yep|yup|mm-?hmm|mhm|hmm+|mm+|uh-?huh|oh|ah|right)$/i;
10045
10078
  };
10079
+ var STD_TOKEN_KEYS = /* @__PURE__ */ new Set(["text", "start_ms", "end_ms", "confidence", "is_final", "language", "speaker"]);
10046
10080
  var SonioxSTT = class {
10047
10081
  options;
10048
10082
  ws;
@@ -10067,6 +10101,9 @@ var SonioxSTT = class {
10067
10101
  * loop). The host tears voice down instead of spinning forever. */
10068
10102
  onFatal = () => {
10069
10103
  };
10104
+ /** Was the assistant speaking `agoMs` ago (+ a short tail)? Set by VoiceEngine; gates the phantom guard, asked for the
10105
+ * moment the utterance's last word was said (not when its final landed, ~1s later). */
10106
+ isAudible = () => false;
10070
10107
  /** Diagnostic tap (provider errors, ws reconnects, no-audio watchdog). Fire-and-forget: a throwing
10071
10108
  * handler disables itself — never affects transcription. Wired by VoiceIO / the lab bridge. */
10072
10109
  onDiag = () => {
@@ -10101,6 +10138,12 @@ var SonioxSTT = class {
10101
10138
  finalToks = [];
10102
10139
  // diarization only: finalized tokens of the current utterance
10103
10140
  partialToks = [];
10141
+ uttToks = [];
10142
+ // stt_final diag: finalized tokens of the current utterance
10143
+ uttPartials = [];
10144
+ // stt_final diag: its current partial tokens
10145
+ levels = [];
10146
+ // stt_final diag: recent mic RMS per chunk (~12s)
10104
10147
  constructor(options) {
10105
10148
  this.options = { ...new SonioxSTTOptions(), ...options };
10106
10149
  }
@@ -10164,10 +10207,7 @@ var SonioxSTT = class {
10164
10207
  const combined = (this.finalText + this.partialText).trim();
10165
10208
  if (!combined || now() - this.lastChangeAt < this.options.silenceEndpointMs) return;
10166
10209
  if (this.firstTokenAt) log15.debug(`stt: ${Math.round(now() - this.firstTokenAt)}ms first-token\u2192silence-endpoint, "${combined.slice(0, 60)}"`);
10167
- const language = this.language(true);
10168
- const turns = this.turns(true), ago = this.lastWordAgoMs();
10169
- this.reset();
10170
- this.onUtterance(this.stray(combined), now(), language, turns, ago);
10210
+ this.emit(combined, "silence");
10171
10211
  }, 120);
10172
10212
  this.endpointTimer.unref?.();
10173
10213
  this.startedChunksAt = now();
@@ -10193,7 +10233,10 @@ var SonioxSTT = class {
10193
10233
  const v = view.getInt16(i, true);
10194
10234
  sum += v * v;
10195
10235
  }
10196
- this.onLevel(Math.sqrt(sum / (chunk.byteLength / 2)));
10236
+ const rms = Math.sqrt(sum / (chunk.byteLength / 2));
10237
+ this.levels.push({ at: this.lastChunkAt, rms });
10238
+ if (this.levels.length > 120) this.levels.shift();
10239
+ this.onLevel(rms);
10197
10240
  if (this.ws.readyState === WebSocket.OPEN) {
10198
10241
  this.ws.send(chunk);
10199
10242
  const at = this.sentBytes / 2 / STT_SAMPLE_RATE * 1e3;
@@ -10224,6 +10267,7 @@ var SonioxSTT = class {
10224
10267
  if (t.text !== "<end>" && typeof t.end_ms === "number" && String(t.text).trim() && t.end_ms > this.lastWordEndMs) this.lastWordEndMs = t.end_ms;
10225
10268
  if (t.text === "<end>") endpoint = true;
10226
10269
  else if (t.is_final) {
10270
+ this.uttToks.push(t);
10227
10271
  this.finalText += t.text;
10228
10272
  this.countLang(this.finalLangChars, t);
10229
10273
  if (this.options.diarization) this.finalToks.push(t);
@@ -10234,6 +10278,7 @@ var SonioxSTT = class {
10234
10278
  this.partialLangChars = {};
10235
10279
  for (const t of partials) this.countLang(this.partialLangChars, t);
10236
10280
  if (this.options.diarization) this.partialToks = partials;
10281
+ this.uttPartials = partials;
10237
10282
  const combined = this.finalText + this.partialText;
10238
10283
  if (combined !== this.lastCombined) {
10239
10284
  this.lastCombined = combined;
@@ -10244,10 +10289,32 @@ var SonioxSTT = class {
10244
10289
  if (endpoint && this.finalText.trim()) {
10245
10290
  const utterance = this.finalText.trim();
10246
10291
  if (this.firstTokenAt) log15.debug(`stt: ${Math.round(now() - this.firstTokenAt)}ms first-token\u2192endpoint, "${utterance.slice(0, 60)}"`);
10247
- const language = this.language(false);
10248
- const turns = this.turns(false), ago = this.lastWordAgoMs();
10249
- this.reset();
10250
- this.onUtterance(this.stray(utterance), now(), language, turns, ago);
10292
+ this.emit(utterance, "end");
10293
+ }
10294
+ }
10295
+ /** Close the current utterance: diag, reset, then hand it to onUtterance — unless the phantom guard drops it. */
10296
+ emit(text, endpoint) {
10297
+ const withPartials = endpoint === "silence";
10298
+ const language = this.language(withPartials);
10299
+ const turns = this.turns(withPartials), ago = this.lastWordAgoMs();
10300
+ const confMin = this.finalDiag(text, endpoint, ago);
10301
+ this.reset();
10302
+ if (this.phantom(text, confMin, ago)) {
10303
+ this.diag("stt_phantom_dropped", { text: text.slice(0, 80), confMin, lastWordAgoMs: ago });
10304
+ return;
10305
+ }
10306
+ this.onUtterance(this.stray(text), now(), language, turns, ago);
10307
+ }
10308
+ phantom(text, confMin, agoMs) {
10309
+ const { phantomMinConfidence: min, phantomMaxWords: max, phantomTokens: listener } = this.options;
10310
+ if (!min || confMin === void 0 || confMin >= min) return false;
10311
+ const words5 = text.split(/[\s,.!?…]+/).filter(Boolean);
10312
+ if (!words5.length || words5.length > max || !words5.every((w) => listener.test(w))) return false;
10313
+ try {
10314
+ return this.isAudible(agoMs ?? 0);
10315
+ } catch (e) {
10316
+ log15.warn(`isAudible threw: ${e instanceof Error ? e.message : e}`);
10317
+ return false;
10251
10318
  }
10252
10319
  }
10253
10320
  /** How long ago (ms, now) the utterance's last spoken word ended: the audio sent so far minus that token's end_ms on
@@ -10280,7 +10347,29 @@ var SonioxSTT = class {
10280
10347
  const words5 = sonioxWords(withPartials ? [...this.finalToks, ...this.partialToks] : this.finalToks);
10281
10348
  return words5.some((w) => w.spk != null) ? speakerRuns(words5) : void 0;
10282
10349
  }
10350
+ /** One `stt_final` diag per utterance: how sure Soniox was, the mic level over it, and any token fields beyond the
10351
+ * usual ones — to tell words the user said from ones the STT made up (a phantom "Okay." heard 186× over our own
10352
+ * speech, agentx session 20261111-105859). */
10353
+ finalDiag(text, endpoint, lastWordAgoMs) {
10354
+ const toks = [...this.uttToks, ...endpoint === "silence" ? this.uttPartials : []].filter((t) => String(t.text).trim());
10355
+ const conf = toks.map((t) => t.confidence).filter((c) => typeof c === "number");
10356
+ const since = (this.firstTokenAt || now()) - 1500;
10357
+ const rms = this.levels.filter((l) => l.at >= since).map((l) => l.rms).sort((a, b) => a - b);
10358
+ const extra = [...new Set(toks.flatMap((t) => Object.keys(t).filter((k) => !STD_TOKEN_KEYS.has(k))))];
10359
+ this.diag("stt_final", {
10360
+ text: text.slice(0, 80),
10361
+ endpoint,
10362
+ lastWordAgoMs,
10363
+ ...conf.length ? { confMin: +Math.min(...conf).toFixed(3), confAvg: +(conf.reduce((a, b) => a + b, 0) / conf.length).toFixed(3) } : {},
10364
+ ...rms.length ? { rmsPeak: Math.round(rms[rms.length - 1]), rmsMed: Math.round(rms[rms.length >> 1]) } : {},
10365
+ ...toks.length ? { startMs: toks[0].start_ms, endMs: toks[toks.length - 1].end_ms } : {},
10366
+ ...extra.length ? { tokenKeys: extra } : {}
10367
+ });
10368
+ return conf.length ? Math.min(...conf) : void 0;
10369
+ }
10283
10370
  reset() {
10371
+ this.uttToks = [];
10372
+ this.uttPartials = [];
10284
10373
  this.finalToks = [];
10285
10374
  this.partialToks = [];
10286
10375
  this.finalLangChars = {};
@@ -10383,7 +10472,7 @@ var now2 = () => performance.now();
10383
10472
  var CartesiaTTSOptions = class {
10384
10473
  auth = "";
10385
10474
  voiceId = "";
10386
- model = "sonic-3.5";
10475
+ model = "sonic-3.6";
10387
10476
  /** 'apiKey' (server/CLI) → `api_key=` URL param; 'token' (browser, BE-minted) → `access_token=`. */
10388
10477
  authMode = "apiKey";
10389
10478
  /** Cartesia `language` code ('en', 'he', …). Unset → field omitted (provider default). Mutable:
@@ -10485,6 +10574,16 @@ var CartesiaTTS = class _CartesiaTTS {
10485
10574
  };
10486
10575
  this.ws.onmessage = (ev) => {
10487
10576
  const m = JSON.parse(String(ev.data));
10577
+ const pr = m.context_id && this.priming.get(m.context_id);
10578
+ if (pr) {
10579
+ if (m.type === "chunk" && m.data) pr.chunks.push(base64ToBytes(m.data));
10580
+ else if (m.type === "done" || m.type === "error") {
10581
+ this.priming.delete(m.context_id);
10582
+ if (m.type === "done") this.primed.set(pr.key, pr.chunks);
10583
+ else this.primed.delete(pr.key);
10584
+ }
10585
+ return;
10586
+ }
10488
10587
  if (m.context_id && m.context_id !== this.ctxId) return;
10489
10588
  if (m.type === "chunk" && m.data) {
10490
10589
  this.consecutiveErrors = 0;
@@ -10542,7 +10641,40 @@ var CartesiaTTS = class _CartesiaTTS {
10542
10641
  this.newContext();
10543
10642
  if (this.ws?.readyState === WebSocket.OPEN) this.ws.send(this.frame("Ok.", false));
10544
10643
  }
10644
+ /** Phrases synthesized ahead (prime): key → audio (null = still generating). */
10645
+ primed = /* @__PURE__ */ new Map();
10646
+ priming = /* @__PURE__ */ new Map();
10647
+ /** This context began with a primed phrase: its audio played from the cache; more text is synthesized after it. */
10648
+ ctxCached = false;
10649
+ ctxRest = "";
10650
+ ctxSent = false;
10651
+ static key(t) {
10652
+ return t.trim().replace(/[\s.,!?…]+$/u, "").replace(/\s+/g, " ");
10653
+ }
10654
+ /** Synthesize `text` now, in this voice and language, and keep its audio: a later utterance that is exactly this text
10655
+ * plays at once, with no TTS round trip (a call's planned opener — live: ~470ms to its first audio). */
10656
+ prime(text) {
10657
+ const key = _CartesiaTTS.key(text);
10658
+ if (!key || this.primed.has(key) || this.down) return;
10659
+ this.primed.set(key, null);
10660
+ const id = `prime-${++this.ctxSeq}`;
10661
+ const send = () => {
10662
+ const cur = this.ctxId, lang = this.ctxLanguage;
10663
+ this.ctxId = id;
10664
+ this.ctxLanguage = this.options.language;
10665
+ const f = this.frame(text, false);
10666
+ this.ctxId = cur;
10667
+ this.ctxLanguage = lang;
10668
+ this.priming.set(id, { key, chunks: [] });
10669
+ this.ws.send(f);
10670
+ };
10671
+ if (this.ws?.readyState === WebSocket.OPEN) send();
10672
+ else void this.ensureConnected().then(() => this.ws?.readyState === WebSocket.OPEN && send());
10673
+ }
10545
10674
  newContext() {
10675
+ this.ctxCached = false;
10676
+ this.ctxRest = "";
10677
+ this.ctxSent = false;
10546
10678
  this.ctxId = `ctx-${++this.ctxSeq}`;
10547
10679
  this.firstAudioAt = 0;
10548
10680
  this.ctxLanguage = this.options.language;
@@ -10568,6 +10700,19 @@ var CartesiaTTS = class _CartesiaTTS {
10568
10700
  if (this.down) return;
10569
10701
  text = cont ? this.say.feed(text) : this.say.feed(text) + this.say.flush();
10570
10702
  if (cont && !text) return;
10703
+ const hit = !this.firstAudioAt && !this.ctxCached && this.primed.get(_CartesiaTTS.key(text));
10704
+ if (hit) {
10705
+ this.ctxCached = true;
10706
+ this.firstAudioAt = now2();
10707
+ this.diag("tts_primed", { chars: text.length });
10708
+ for (const c of hit) this.onAudio(c);
10709
+ return;
10710
+ }
10711
+ if (this.ctxCached) {
10712
+ this.ctxRest += text;
10713
+ return;
10714
+ }
10715
+ this.ctxSent = true;
10571
10716
  if (this.ws?.readyState === WebSocket.OPEN) this.ws.send(this.frame(text, cont));
10572
10717
  else void this.ensureConnected().then(() => this.ws?.readyState === WebSocket.OPEN && this.ws.send(this.frame(text, cont)));
10573
10718
  }
@@ -10581,11 +10726,27 @@ var CartesiaTTS = class _CartesiaTTS {
10581
10726
  this.ws.send(JSON.stringify({ ...JSON.parse(this.frame("", true)), flush: true }));
10582
10727
  }
10583
10728
  end() {
10584
- const held2 = this.say.flush();
10729
+ let held2 = this.say.flush();
10585
10730
  if (this.down) {
10586
10731
  this.onDone();
10587
10732
  return;
10588
10733
  }
10734
+ const hit = !this.ctxSent && !this.ctxCached && !this.firstAudioAt && this.primed.get(_CartesiaTTS.key(held2));
10735
+ if (hit) {
10736
+ this.diag("tts_primed", { chars: held2.length });
10737
+ this.firstAudioAt = now2();
10738
+ for (const c of hit) this.onAudio(c);
10739
+ queueMicrotask(() => this.onDone());
10740
+ return;
10741
+ }
10742
+ if (this.ctxCached) {
10743
+ held2 = (this.ctxRest + held2).trim();
10744
+ this.ctxRest = "";
10745
+ if (!held2) {
10746
+ queueMicrotask(() => this.onDone());
10747
+ return;
10748
+ }
10749
+ }
10589
10750
  if (this.ws?.readyState === WebSocket.OPEN) this.ws.send(this.frame(held2, false));
10590
10751
  }
10591
10752
  cancel() {
@@ -17518,7 +17679,8 @@ init_logging();
17518
17679
  init_llm();
17519
17680
  init_platform();
17520
17681
  import { spawn as spawn2, spawnSync as spawnSync3 } from "child_process";
17521
- import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync6, statSync as statSync6 } from "fs";
17682
+ import { createHash as createHash3 } from "crypto";
17683
+ import { appendFileSync, existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync, rmSync as rmSync2 } from "fs";
17522
17684
  import { homedir as homedir3 } from "os";
17523
17685
  import { dirname as dirname4, join as join8 } from "path";
17524
17686
  import { fileURLToPath } from "url";
@@ -17617,20 +17779,26 @@ function resolveAecBinary() {
17617
17779
  const plist = join8(nativeDir(), "Info.plist");
17618
17780
  if (!existsSync4(src)) return null;
17619
17781
  const cacheDir = join8(homedir3(), ".agent", "cache");
17620
- const bin = join8(cacheDir, "mic-aec");
17621
- if (existsSync4(bin) && statSync6(bin).mtimeMs >= statSync6(src).mtimeMs) return bin;
17782
+ const hash = createHash3("sha1").update(readFileSync6(src)).update(readFileSync6(plist)).digest("hex").slice(0, 10);
17783
+ const bin = join8(cacheDir, `mic-aec-${hash}`);
17784
+ if (existsSync4(bin)) return bin;
17622
17785
  if (spawnSync3("which", ["swiftc"]).status !== 0) return null;
17623
17786
  mkdirSync5(cacheDir, { recursive: true });
17624
17787
  log36.info("compiling AEC mic helper (first run)\u2026");
17625
- const build = spawnSync3("swiftc", ["-O", "-o", bin, src, "-Xlinker", "-sectcreate", "-Xlinker", "__TEXT", "-Xlinker", "__info_plist", "-Xlinker", plist], { encoding: "utf8" });
17626
- if (build.status !== 0) {
17627
- log36.warn(`AEC build failed: ${build.stderr?.slice(0, 400)}`);
17628
- return null;
17629
- }
17630
- const sign = spawnSync3("codesign", ["-fs", "-", bin], { encoding: "utf8" });
17631
- if (sign.status !== 0) {
17632
- log36.warn(`codesign failed: ${sign.stderr?.slice(0, 200)}`);
17788
+ const tmp = `${bin}.${process.pid}.tmp`;
17789
+ const fail = (msg) => {
17790
+ log36.warn(msg);
17791
+ rmSync2(tmp, { force: true });
17633
17792
  return null;
17793
+ };
17794
+ const build = spawnSync3("swiftc", ["-O", "-o", tmp, src, "-Xlinker", "-sectcreate", "-Xlinker", "__TEXT", "-Xlinker", "__info_plist", "-Xlinker", plist], { encoding: "utf8" });
17795
+ if (build.status !== 0) return fail(`AEC build failed: ${build.stderr?.slice(0, 400)}`);
17796
+ const sign = spawnSync3("codesign", ["-fs", "-", tmp], { encoding: "utf8" });
17797
+ if (sign.status !== 0) return fail(`codesign failed: ${sign.stderr?.slice(0, 200)}`);
17798
+ try {
17799
+ renameSync(tmp, bin);
17800
+ } catch (e) {
17801
+ return fail(`AEC helper install failed: ${e instanceof Error ? e.message : e}`);
17634
17802
  }
17635
17803
  return bin;
17636
17804
  }
@@ -18748,7 +18916,7 @@ They just said: "${c.heard}"
18748
18916
  Reply with exactly ONE line, one of:
18749
18917
  BYE: <a short farewell> \u2014 they mean to end the call ("no, thank you, bye", "okay, talk later"): the call hangs up after it. Judge the intent: "say bye to Dan" or "before I go, one more thing" is not an end.
18750
18918
  SAY: <your words> \u2014 ONLY a greeting or how-are-you, a short reaction ("wow", "really?"), or when they ask exactly to repeat something ALREADY said ("say that again", "which one was that?"). Any request ("tell me a story\u2026"), any question about content ("what is\u2026?", "wait, what?", "how long is it?") is DEEP, even if you could guess${c.rest ? " (or CLARIFY, below)" : ""}. Max two short sentences. Use only facts from the call above; never invent a name, number, news item or result.
18751
- DEEP: <a 2-8 word acknowledgement> | <what the colleague must do, names spelled right> \u2014 anything needing a lookup, current information, tools, files, or real thinking. The acknowledgement is your natural first reaction to THIS kind of ask, in your own voice: ${tools ? `a lookup says you're on it and names what you'll look at ("Sure, let me pull up the kitty changelog."); ` : `never say you will check, look up, pull up, find or fetch anything \u2014 nothing can be; a question gets a short thinking reaction ("Hmm, okay\u2026", "Right, so\u2026"); `}a story, joke or idea gets a reaction to the idea itself (a story about a dragon: "Ooh, a dragon story, okay\u2026"); a question about what was said gets a short "ah"-type reaction ("Ah, good question."). Say "checking" or "looking" only when something is actually looked up. Never a result. The speech-to-text misspells names: fix them from context ("Haka News" \u2192 Hacker News).
18919
+ DEEP: <a 2-8 word acknowledgement> | <what the colleague must do, names spelled right> \u2014 anything needing a lookup, current information, tools, files, or real thinking. The acknowledgement is your natural first reaction to THIS kind of ask, in your own voice: ${tools ? `an ask that needs current or outside information (news, weather, prices, a site, a file) says you're on it and names what you'll look at ("Sure, let me pull up the kitty changelog."); a question the colleague simply knows (a fact, a tip, a recommendation, a sum) is NOT a lookup: a short thinking reaction ("Hmm, good one\u2026", "Ooh, let me think\u2026"), never "let me check / look up" for it; ` : `never say you will check, look up, pull up, find or fetch anything \u2014 nothing can be; a question gets a short thinking reaction ("Hmm, okay\u2026", "Right, so\u2026"); `}a story, joke or idea gets a reaction to the idea itself (a story about a dragon: "Ooh, a dragon story, okay\u2026"); a question about what was said gets a short "ah"-type reaction ("Ah, good question."). Say "checking" or "looking" only when something is actually looked up. Never a result. The speech-to-text misspells names: fix them from context ("Haka News" \u2192 Hacker News).
18752
18920
  ` + (c.rest ? `CLARIFY: <one short answer> | <the exact words of your cut answer or its rest that answer it, copied verbatim> \u2014 they cut your answer to ask a quick question ABOUT it ("who?", "where do they sit?", "which one?") that your words above or the unsaid rest already answer. Find the exact span first, then answer from it only; your cut answer then goes on by itself. A new request, a change of topic, or a question those words do not answer is DEEP.
18753
18921
  ` : "") + `QUIET \u2014 nothing is owed: a bare "okay", "mm-hm", or a reaction you already answered.
18754
18922
  "Wait" / "hold on" with nothing new: a brief SAY ("Sure.") \u2014 no work for the colleague. Vary your words: never reuse an acknowledgement or reaction already said in this call.
@@ -19094,7 +19262,7 @@ function formatDiff(ops, opts = {}) {
19094
19262
  }
19095
19263
 
19096
19264
  // cli/session.ts
19097
- import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync5, readdirSync, renameSync, symlinkSync as symlinkSync2, unlinkSync, readlinkSync, statSync as statSync7 } from "fs";
19265
+ import { existsSync as existsSync6, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync5, readdirSync, renameSync as renameSync2, symlinkSync as symlinkSync2, unlinkSync, readlinkSync, statSync as statSync6 } from "fs";
19098
19266
  import { homedir as homedir6 } from "os";
19099
19267
  import { join as join11 } from "path";
19100
19268
  init_platform();
@@ -19150,7 +19318,7 @@ var SessionStore = class {
19150
19318
  const path = join11(this.dir, `${data.meta.id}.json`);
19151
19319
  const tmp = `${path}.${process.pid}.tmp`;
19152
19320
  writeFileSync5(tmp, JSON.stringify(data));
19153
- renameSync(tmp, path);
19321
+ renameSync2(tmp, path);
19154
19322
  try {
19155
19323
  const gd = globalDir();
19156
19324
  if (!existsSync6(gd)) mkdirSync8(gd, { recursive: true });
@@ -19195,7 +19363,7 @@ var SessionStore = class {
19195
19363
  for (const f of readdirSync(this.dir)) {
19196
19364
  if (!f.endsWith(".json")) continue;
19197
19365
  try {
19198
- const st = statSync7(join11(this.dir, f));
19366
+ const st = statSync6(join11(this.dir, f));
19199
19367
  out.push({ id: f.slice(0, -5), mtime: st.mtimeMs, size: st.size });
19200
19368
  } catch {
19201
19369
  }
@@ -23202,7 +23370,7 @@ function readImageParts(cwd, line) {
23202
23370
  if (!mime) continue;
23203
23371
  const abs = userPath(cwd, ref);
23204
23372
  try {
23205
- statSync8(abs);
23373
+ statSync7(abs);
23206
23374
  } catch {
23207
23375
  continue;
23208
23376
  }
@@ -23218,7 +23386,7 @@ function pastePathClassifier(cwd) {
23218
23386
  if (!PATH_LIKE.test(t)) return null;
23219
23387
  const abs = userPath(cwd, t);
23220
23388
  try {
23221
- if (!statSync8(abs).isFile()) return null;
23389
+ if (!statSync7(abs).isFile()) return null;
23222
23390
  } catch {
23223
23391
  return null;
23224
23392
  }