@moxxy/cli 0.35.3 → 0.36.0

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/bin.js +596 -196
  3. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -8,7 +8,7 @@ import path3__default, { join, dirname, resolve, relative, isAbsolute, posix } f
8
8
  import { ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, resolveChannelToken, rotateChannelToken, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, MOXXY_WS_SUBPROTOCOL, bearerTokenMatches, PRIVATE_FILE_MODE, bearerGuard, tokenFromWsProtocolHeader, resolveOsPrincipal, redactProxyUrl, listLiveChannelStatuses, CrossProcessFireLock, writeChannelStatus, writeFileAtomicSync, readRequestBody } from '@moxxy/sdk/server';
9
9
  import { spawn, execFile, spawnSync } from 'child_process';
10
10
  import { fileURLToPath, pathToFileURL } from 'url';
11
- import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, defineTool, defineCommand, defineEmbedder, asPluginId, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, defineCompactor, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, isSelectableMode, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, toolResultBytes, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computeElisionState, toolResultStubbed, toolResultStub, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, moxxyPackageSchema, auditActionOf, verifyEd25519, defineSecretProvider, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, asToolCallId, parseFrontmatterFile, createJsonFileStore, evaluateToolRule, asEventId } from '@moxxy/sdk';
11
+ import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, defineTool, defineCommand, defineEmbedder, asPluginId, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, isSelectableMode, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computeElisionState, toolResultStubbed, toolResultStub, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, moxxyPackageSchema, auditActionOf, verifyEd25519, defineSecretProvider, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, asToolCallId, parseFrontmatterFile, createJsonFileStore, evaluateToolRule, asEventId } from '@moxxy/sdk';
12
12
  import * as os from 'os';
13
13
  import os__default, { homedir, tmpdir, userInfo } from 'os';
14
14
  import { createRequire as createRequire$1 } from 'module';
@@ -8445,7 +8445,7 @@ var require_jiti = __commonJS({
8445
8445
  function V3() {
8446
8446
  return 10 !== n2.getToken() ? (k2(3, [], [2, 5]), false) : (P3(false), 6 === n2.getToken() ? (I3(":"), T(), U3() || k2(4, [], [2, 5])) : k2(5, [], [2, 5]), a2.pop(), true);
8447
8447
  }
8448
- function z62() {
8448
+ function z63() {
8449
8449
  l2(), T();
8450
8450
  let e5 = false;
8451
8451
  for (; 2 !== n2.getToken() && 17 !== n2.getToken(); ) {
@@ -8472,14 +8472,14 @@ var require_jiti = __commonJS({
8472
8472
  case 3:
8473
8473
  return G2();
8474
8474
  case 1:
8475
- return z62();
8475
+ return z63();
8476
8476
  case 10:
8477
8477
  return P3(true);
8478
8478
  default:
8479
8479
  return J2();
8480
8480
  }
8481
8481
  }
8482
- return r(T, "scanNext"), r(k2, "handleError"), r(P3, "parseString"), r(J2, "parseLiteral"), r(V3, "parseProperty"), r(z62, "parseObject"), r(G2, "parseArray"), r(U3, "parseValue"), T(), 17 === n2.getToken() ? !!i3.allowEmptyContent || (k2(4, [], []), false) : U3() ? (17 !== n2.getToken() && k2(9, [], []), true) : (k2(4, [], []), false);
8482
+ return r(T, "scanNext"), r(k2, "handleError"), r(P3, "parseString"), r(J2, "parseLiteral"), r(V3, "parseProperty"), r(z63, "parseObject"), r(G2, "parseArray"), r(U3, "parseValue"), T(), 17 === n2.getToken() ? !!i3.allowEmptyContent || (k2(4, [], []), false) : U3() ? (17 !== n2.getToken() && k2(9, [], []), true) : (k2(4, [], []), false);
8483
8483
  }
8484
8484
  new Array(W2).fill(0).map((e4, t3) => "\n" + " ".repeat(t3)), new Array(W2).fill(0).map((e4, t3) => "\r" + " ".repeat(t3)), new Array(W2).fill(0).map((e4, t3) => "\r\n" + " ".repeat(t3)), new Array(W2).fill(0).map((e4, t3) => "\n" + " ".repeat(t3)), new Array(W2).fill(0).map((e4, t3) => "\r" + " ".repeat(t3)), new Array(W2).fill(0).map((e4, t3) => "\r\n" + " ".repeat(t3)), (function(e4) {
8485
8485
  e4.DEFAULT = { allowTrailingComma: false };
@@ -22299,7 +22299,7 @@ var init_provider_catalog_generated = __esm({
22299
22299
  ],
22300
22300
  "provider": {
22301
22301
  "auth": "oauth",
22302
- "defaultModel": "claude-sonnet-4-6"
22302
+ "defaultModel": "claude-sonnet-5"
22303
22303
  }
22304
22304
  },
22305
22305
  {
@@ -36344,7 +36344,7 @@ function createWasmIsolator(opts = {}) {
36344
36344
  if (!verdict.ok)
36345
36345
  throw new Error(`[security:wasm] ${verdict.reason}`);
36346
36346
  const timeMs = caps.timeMs ?? defaultTimeMs;
36347
- const abortError2 = () => new Error(`[security:wasm] tool '${call.toolName}' aborted`);
36347
+ const abortError3 = () => new Error(`[security:wasm] tool '${call.toolName}' aborted`);
36348
36348
  let timer;
36349
36349
  let onAbort;
36350
36350
  try {
@@ -36352,14 +36352,14 @@ function createWasmIsolator(opts = {}) {
36352
36352
  invoke(call, caps, signal, timeMs),
36353
36353
  new Promise((_resolve, reject) => {
36354
36354
  if (signal.aborted) {
36355
- reject(abortError2());
36355
+ reject(abortError3());
36356
36356
  return;
36357
36357
  }
36358
36358
  timer = setTimeout(() => {
36359
36359
  reject(new Error(`[security:wasm] tool '${call.toolName}' exceeded ${timeMs}ms budget`));
36360
36360
  }, timeMs);
36361
36361
  timer.unref?.();
36362
- onAbort = () => reject(abortError2());
36362
+ onAbort = () => reject(abortError3());
36363
36363
  signal.addEventListener("abort", onAbort, { once: true });
36364
36364
  })
36365
36365
  ]);
@@ -43267,7 +43267,7 @@ function createSummarizeCompactor(opts = {}) {
43267
43267
  const text = slice.map((e2) => describeEvent(e2)).filter(Boolean).join("\n");
43268
43268
  const summary = opts.summary ? await opts.summary(text) : await providerSummary(text, ctx) ?? fallbackDigest(text);
43269
43269
  if (ctx?.signal?.aborted)
43270
- throwAbort();
43270
+ throw abortError("summarize-old-turns: compaction aborted");
43271
43271
  const originalChars = slice.reduce((n, e2) => n + contextChars(e2), 0);
43272
43272
  const tokensSaved = Math.max(0, Math.ceil((originalChars - summary.length) / 4));
43273
43273
  return {
@@ -43283,62 +43283,18 @@ function createSummarizeCompactor(opts = {}) {
43283
43283
  }
43284
43284
  });
43285
43285
  }
43286
- async function providerSummary(text, ctx) {
43287
- if (!ctx?.provider)
43288
- return null;
43289
- if (ctx.signal?.aborted)
43290
- throwAbort();
43291
- const provider = ctx.provider;
43292
- const model = ctx.model ?? provider.models[0]?.id;
43293
- if (!model)
43294
- return null;
43295
- const input = text.length > MAX_SUMMARIZE_INPUT_CHARS2 ? `${text.slice(0, MAX_SUMMARIZE_INPUT_CHARS2 / 2)}
43296
- [... digest truncated ...]
43297
- ${text.slice(-MAX_SUMMARIZE_INPUT_CHARS2 / 2)}` : text;
43298
- try {
43299
- let out = "";
43300
- for await (const event of provider.stream({
43301
- model,
43302
- system: SUMMARY_SYSTEM_PROMPT,
43303
- messages: [
43304
- {
43305
- role: "user",
43306
- content: [{ type: "text", text: `Digest of the turns to compress:
43307
-
43308
- ${input}` }]
43309
- }
43310
- ],
43311
- maxTokens: SUMMARY_MAX_TOKENS2,
43312
- ...ctx.signal ? { signal: ctx.signal } : {}
43313
- })) {
43314
- if (ctx.signal?.aborted)
43315
- throwAbort();
43316
- if (event.type === "text_delta")
43317
- out += event.delta;
43318
- if (event.type === "error") {
43319
- if (ctx.signal?.aborted)
43320
- throwAbort();
43321
- return null;
43322
- }
43323
- }
43324
- const trimmed = out.trim();
43325
- return trimmed.length > 0 ? trimmed : null;
43326
- } catch (err) {
43327
- if (isAbort(err) || ctx.signal?.aborted)
43328
- throw err instanceof Error ? err : abortError();
43329
- return null;
43330
- }
43331
- }
43332
- function isAbort(err) {
43333
- return err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
43334
- }
43335
- function abortError() {
43336
- const e2 = new Error("summarize-old-turns: compaction aborted");
43337
- e2.name = "AbortError";
43338
- return e2;
43339
- }
43340
- function throwAbort() {
43341
- throw abortError();
43286
+ function providerSummary(text, ctx) {
43287
+ return summarizeWithProvider(text, {
43288
+ system: SUMMARY_SYSTEM_PROMPT,
43289
+ prompt: (digest) => `Digest of the turns to compress:
43290
+
43291
+ ${digest}`,
43292
+ maxInputChars: MAX_SUMMARIZE_INPUT_CHARS2,
43293
+ maxTokens: SUMMARY_MAX_TOKENS2,
43294
+ ...ctx?.provider ? { provider: ctx.provider } : {},
43295
+ ...ctx?.model ? { model: ctx.model } : {},
43296
+ ...ctx?.signal ? { signal: ctx.signal } : {}
43297
+ });
43342
43298
  }
43343
43299
  function describeEvent(e2) {
43344
43300
  switch (e2.type) {
@@ -43433,6 +43389,438 @@ var init_dist20 = __esm({
43433
43389
  });
43434
43390
  }
43435
43391
  });
43392
+ function resolveOptions(opts = {}) {
43393
+ const num = (v2, fallback2, min) => Number.isFinite(v2) ? Math.max(min, Math.floor(v2)) : fallback2;
43394
+ const maxSegments = num(opts.maxSegments, DEFAULTS.maxSegments, 2);
43395
+ return {
43396
+ keepRecentTurns: num(opts.keepRecentTurns, DEFAULTS.keepRecentTurns, 1),
43397
+ minSegmentChars: num(opts.minSegmentChars, DEFAULTS.minSegmentChars, 200),
43398
+ maxSegments,
43399
+ // Folding must consume at least two summaries (folding one is a rename) and
43400
+ // can never exceed the cap it is trying to get back under.
43401
+ foldSegments: Math.min(maxSegments, num(opts.foldSegments, DEFAULTS.foldSegments, 2))
43402
+ };
43403
+ }
43404
+ function isProjected(e2) {
43405
+ return PROJECTED_TYPES.has(e2.type);
43406
+ }
43407
+ function contextChars2(e2) {
43408
+ switch (e2.type) {
43409
+ case "user_prompt": {
43410
+ let n = e2.text.length;
43411
+ for (const att of e2.attachments ?? []) {
43412
+ if (att.kind === "file" || att.kind === "stdin")
43413
+ n += att.content.length;
43414
+ }
43415
+ return n;
43416
+ }
43417
+ case "assistant_message":
43418
+ return e2.content.length;
43419
+ case "tool_call_requested":
43420
+ return e2.name.length + safeJsonLen2(e2.input);
43421
+ case "tool_result":
43422
+ if (e2.error)
43423
+ return (e2.error.message?.length ?? 0) + 12;
43424
+ return toolResultBytes(e2.output);
43425
+ default:
43426
+ return 0;
43427
+ }
43428
+ }
43429
+ function safeJsonLen2(v2) {
43430
+ try {
43431
+ return JSON.stringify(v2 ?? "").length;
43432
+ } catch {
43433
+ return 0;
43434
+ }
43435
+ }
43436
+ function planCompaction(events, opts) {
43437
+ if (events.length === 0)
43438
+ return null;
43439
+ const live = activeCompactionRanges(events);
43440
+ if (live.length > opts.maxSegments) {
43441
+ const chapter = planChapter(events, live, opts);
43442
+ if (chapter)
43443
+ return chapter;
43444
+ }
43445
+ return planSegment(events, live, opts);
43446
+ }
43447
+ function planChapter(events, live, opts) {
43448
+ const ordered = [...live].sort((a, b2) => a.from - b2.from);
43449
+ const candidates = ordered.slice(0, opts.foldSegments);
43450
+ if (candidates.length < 2)
43451
+ return null;
43452
+ const covered = (seq) => ordered.some((r) => seq >= r.from && seq <= r.to);
43453
+ let taken = 0;
43454
+ let to = -1;
43455
+ for (let i = 0; i < candidates.length; i++) {
43456
+ const next = candidates[i];
43457
+ const clean3 = events.every((e2) => !isProjected(e2) || e2.seq < candidates[0].from || e2.seq > next.to || covered(e2.seq));
43458
+ if (!clean3)
43459
+ break;
43460
+ taken = i + 1;
43461
+ to = next.to;
43462
+ }
43463
+ if (taken < 2)
43464
+ return null;
43465
+ const folded = candidates.slice(0, taken);
43466
+ return {
43467
+ kind: "chapter",
43468
+ from: folded[0].from,
43469
+ to,
43470
+ ordinal: countSummaries(events, "[chapter ") + 1,
43471
+ summaries: folded.map((r) => r.summary),
43472
+ originalChars: folded.reduce((n, r) => n + r.summary.length, 0)
43473
+ };
43474
+ }
43475
+ function planSegment(events, live, opts) {
43476
+ const covered = (seq) => live.some((r) => seq >= r.from && seq <= r.to);
43477
+ const turnOrder = [];
43478
+ const seen = /* @__PURE__ */ new Set();
43479
+ for (const e2 of events) {
43480
+ if (!seen.has(e2.turnId)) {
43481
+ seen.add(e2.turnId);
43482
+ turnOrder.push(e2.turnId);
43483
+ }
43484
+ }
43485
+ const eligible = turnOrder.slice(0, Math.max(0, turnOrder.length - opts.keepRecentTurns));
43486
+ if (eligible.length === 0)
43487
+ return null;
43488
+ const uncoveredOf = (turnId) => events.filter((e2) => e2.turnId === turnId && !covered(e2.seq));
43489
+ let start = 0;
43490
+ while (start < eligible.length && uncoveredOf(eligible[start]).every((e2) => !isProjected(e2))) {
43491
+ start += 1;
43492
+ }
43493
+ if (start >= eligible.length)
43494
+ return null;
43495
+ const turnIds = [];
43496
+ let originalChars = 0;
43497
+ let from = Number.MAX_SAFE_INTEGER;
43498
+ let to = -1;
43499
+ for (let i = start; i < eligible.length; i++) {
43500
+ const turnId = eligible[i];
43501
+ const turnEvents = events.filter((e2) => e2.turnId === turnId);
43502
+ if (turnEvents.length === 0)
43503
+ continue;
43504
+ turnIds.push(turnId);
43505
+ for (const e2 of turnEvents) {
43506
+ from = Math.min(from, e2.seq);
43507
+ to = Math.max(to, e2.seq);
43508
+ if (!covered(e2.seq))
43509
+ originalChars += contextChars2(e2);
43510
+ }
43511
+ if (originalChars >= opts.minSegmentChars)
43512
+ break;
43513
+ }
43514
+ if (turnIds.length === 0 || to < 0)
43515
+ return null;
43516
+ if (originalChars < opts.minSegmentChars)
43517
+ return null;
43518
+ const inSegment = new Set(turnIds);
43519
+ const trespass = events.find((e2) => isProjected(e2) && e2.seq >= from && e2.seq <= to && !inSegment.has(e2.turnId) && !covered(e2.seq));
43520
+ if (trespass) {
43521
+ to = trespass.seq - 1;
43522
+ if (to < from)
43523
+ return null;
43524
+ }
43525
+ const windowEvents = events.filter((e2) => e2.seq >= from && e2.seq <= to && !covered(e2.seq));
43526
+ if (!windowEvents.some(isProjected))
43527
+ return null;
43528
+ return {
43529
+ kind: "segment",
43530
+ from,
43531
+ to,
43532
+ turnIds,
43533
+ ordinal: countSummaries(events, "[segment ") + 1,
43534
+ originalChars: windowEvents.reduce((n, e2) => n + contextChars2(e2), 0),
43535
+ events: windowEvents
43536
+ };
43537
+ }
43538
+ function countSummaries(events, prefix) {
43539
+ let n = 0;
43540
+ for (const e2 of events) {
43541
+ if (e2.type === "compaction" && e2.summary.startsWith(prefix))
43542
+ n += 1;
43543
+ }
43544
+ return n;
43545
+ }
43546
+ function segmentHeader(plan) {
43547
+ const turns = plan.turnIds.join(", ");
43548
+ return `[segment ${plan.ordinal} \xB7 turn ${turns} \xB7 seq ${plan.from}-${plan.to}]`;
43549
+ }
43550
+ function chapterHeader(plan, coveredSegments) {
43551
+ return `[chapter ${plan.ordinal} \xB7 folds ${coveredSegments} earlier summaries \xB7 seq ${plan.from}-${plan.to}]`;
43552
+ }
43553
+ function buildDigest(events) {
43554
+ return events.map(describeEvent2).filter(Boolean).join("\n");
43555
+ }
43556
+ function describeEvent2(e2) {
43557
+ switch (e2.type) {
43558
+ case "user_prompt":
43559
+ return `[user] ${e2.text.slice(0, 2e3)}`;
43560
+ case "assistant_message":
43561
+ return `[assistant] ${e2.content.slice(0, 800)}`;
43562
+ case "tool_call_requested":
43563
+ return `[tool_use] ${e2.name}(${safeJsonStr2(e2.input).slice(0, 160)})`;
43564
+ case "tool_result":
43565
+ return `[tool_result ${e2.ok ? "ok" : "err"}] ${typeof e2.output === "string" ? e2.output.slice(0, 200) : ""}${e2.error?.message?.slice(0, 200) ?? ""}`;
43566
+ default:
43567
+ return null;
43568
+ }
43569
+ }
43570
+ function safeJsonStr2(v2) {
43571
+ try {
43572
+ return JSON.stringify(v2 ?? {}) ?? "{}";
43573
+ } catch {
43574
+ return "[unserializable]";
43575
+ }
43576
+ }
43577
+ var DEFAULTS, PROJECTED_TYPES;
43578
+ var init_segments = __esm({
43579
+ "../compactor-segments/dist/segments.js"() {
43580
+ DEFAULTS = {
43581
+ keepRecentTurns: 3,
43582
+ minSegmentChars: 2e3,
43583
+ maxSegments: 12,
43584
+ foldSegments: 6
43585
+ };
43586
+ PROJECTED_TYPES = /* @__PURE__ */ new Set([
43587
+ "user_prompt",
43588
+ "assistant_message",
43589
+ "reasoning_message",
43590
+ "tool_call_requested",
43591
+ "tool_result"
43592
+ ]);
43593
+ }
43594
+ });
43595
+
43596
+ // ../compactor-segments/dist/search.js
43597
+ function tokenize3(text) {
43598
+ return text.toLowerCase().match(/[\p{L}\p{N}]{2,}/gu) ?? [];
43599
+ }
43600
+ function rank(docs, query, limit) {
43601
+ const terms = new Set(tokenize3(query));
43602
+ if (terms.size === 0 || docs.length === 0)
43603
+ return [];
43604
+ const tokenized = docs.map((doc) => {
43605
+ const counts = /* @__PURE__ */ new Map();
43606
+ for (const t of tokenize3(doc.searchText))
43607
+ counts.set(t, (counts.get(t) ?? 0) + 1);
43608
+ return { doc, counts, length: Math.max(1, counts.size) };
43609
+ });
43610
+ const df = /* @__PURE__ */ new Map();
43611
+ for (const term of terms) {
43612
+ let n = 0;
43613
+ for (const entry of tokenized)
43614
+ if (entry.counts.has(term))
43615
+ n += 1;
43616
+ df.set(term, n);
43617
+ }
43618
+ const scored = [];
43619
+ for (const entry of tokenized) {
43620
+ let score = 0;
43621
+ for (const term of terms) {
43622
+ const tf = entry.counts.get(term);
43623
+ if (!tf)
43624
+ continue;
43625
+ const idf = Math.log(1 + docs.length / (1 + (df.get(term) ?? 0)));
43626
+ score += idf * (1 + Math.log(tf));
43627
+ }
43628
+ if (score <= 0)
43629
+ continue;
43630
+ scored.push({ doc: entry.doc, score: score / Math.sqrt(entry.length) });
43631
+ }
43632
+ scored.sort((a, b2) => b2.score - a.score || b2.doc.ordinal - a.doc.ordinal);
43633
+ return scored.slice(0, limit);
43634
+ }
43635
+ var init_search2 = __esm({
43636
+ "../compactor-segments/dist/search.js"() {
43637
+ }
43638
+ });
43639
+ function createSegmentsCompactor(opts = {}) {
43640
+ const base = resolveOptions(opts);
43641
+ const effectiveOptions = (budget) => {
43642
+ if (!budget || budget.contextWindow <= 0)
43643
+ return base;
43644
+ if (budget.estimatedTokens <= PRESSURE_RATIO * budget.contextWindow)
43645
+ return base;
43646
+ return { ...base, keepRecentTurns: 1 };
43647
+ };
43648
+ return defineCompactor({
43649
+ name: "segments",
43650
+ shouldCompact(log, budget) {
43651
+ return planCompaction(log.slice(), effectiveOptions(budget)) !== null;
43652
+ },
43653
+ async compact(events, ctx) {
43654
+ if (events.length === 0) {
43655
+ throw new Error("segments: compact() called with no events");
43656
+ }
43657
+ const plan = planCompaction(events, effectiveOptions(ctx?.budget));
43658
+ if (!plan)
43659
+ return noOp(events);
43660
+ const summary = plan.kind === "segment" ? await summarizeSegment(plan, ctx, opts.summary) : await summarizeChapter(plan, ctx, opts.summary);
43661
+ if (ctx?.signal?.aborted)
43662
+ throw abortError("segments: compaction aborted");
43663
+ const first = events[0];
43664
+ const last = events[events.length - 1];
43665
+ return {
43666
+ type: "compaction",
43667
+ sessionId: first.sessionId,
43668
+ turnId: last.turnId,
43669
+ source: "compactor",
43670
+ compactor: "segments",
43671
+ replacedRange: [plan.from, plan.to],
43672
+ summary,
43673
+ tokensSaved: Math.max(0, Math.ceil((plan.originalChars - summary.length) / 4))
43674
+ };
43675
+ }
43676
+ });
43677
+ }
43678
+ async function summarizeSegment(plan, ctx, custom) {
43679
+ const digest = buildDigest(plan.events);
43680
+ const header = segmentHeader(plan);
43681
+ const body = custom ? await custom(digest, "segment") : await summarizeWithProvider(digest, {
43682
+ system: SEGMENT_SYSTEM_PROMPT,
43683
+ prompt: (d) => `Sub-session transcript to record:
43684
+
43685
+ ${d}`,
43686
+ maxInputChars: MAX_SUMMARIZE_INPUT_CHARS3,
43687
+ maxTokens: SEGMENT_MAX_TOKENS,
43688
+ ...providerOpts(ctx)
43689
+ }) ?? fallbackDigest2(digest);
43690
+ return `${header}
43691
+ ${clampSummary(body, budgetFor(plan.originalChars, 0.6, header.length))}`;
43692
+ }
43693
+ async function summarizeChapter(plan, ctx, custom) {
43694
+ const digest = plan.summaries.join("\n\n");
43695
+ const header = chapterHeader(plan, plan.summaries.length);
43696
+ const body = custom ? await custom(digest, "chapter") : await summarizeWithProvider(digest, {
43697
+ system: CHAPTER_SYSTEM_PROMPT,
43698
+ prompt: (d) => `Sub-session records to merge, oldest first:
43699
+
43700
+ ${d}`,
43701
+ maxInputChars: MAX_SUMMARIZE_INPUT_CHARS3,
43702
+ maxTokens: CHAPTER_MAX_TOKENS,
43703
+ ...providerOpts(ctx)
43704
+ }) ?? fallbackDigest2(digest);
43705
+ return `${header}
43706
+ ${clampSummary(body, budgetFor(plan.originalChars, 0.5, header.length))}`;
43707
+ }
43708
+ function providerOpts(ctx) {
43709
+ return {
43710
+ ...ctx?.provider ? { provider: ctx.provider } : {},
43711
+ ...ctx?.model ? { model: ctx.model } : {},
43712
+ ...ctx?.signal ? { signal: ctx.signal } : {}
43713
+ };
43714
+ }
43715
+ function budgetFor(originalChars, ratio, headerChars) {
43716
+ return Math.max(200, Math.floor(originalChars * ratio) - headerChars - 1);
43717
+ }
43718
+ function clampSummary(text, maxChars) {
43719
+ const trimmed = text.trim();
43720
+ if (trimmed.length <= maxChars)
43721
+ return trimmed;
43722
+ return `${trimmed.slice(0, maxChars - 24).trimEnd()}
43723
+ [\u2026 record truncated \u2026]`;
43724
+ }
43725
+ function fallbackDigest2(text) {
43726
+ if (!warnedFallback2) {
43727
+ warnedFallback2 = true;
43728
+ console.warn("[compactor-segments] no provider available for summarization; recording a labeled digest truncation instead");
43729
+ }
43730
+ return `[no summarizer available: truncated digest of this sub-session, not a summary]
43731
+ ${text}`;
43732
+ }
43733
+ function noOp(events) {
43734
+ const first = events[0];
43735
+ const last = events[events.length - 1];
43736
+ return {
43737
+ type: "compaction",
43738
+ sessionId: first.sessionId,
43739
+ turnId: last.turnId,
43740
+ source: "compactor",
43741
+ compactor: "segments",
43742
+ replacedRange: [Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
43743
+ summary: "",
43744
+ tokensSaved: 0
43745
+ };
43746
+ }
43747
+ function buildSessionDocs(events) {
43748
+ const live = activeCompactionRanges(events);
43749
+ return live.map((range, index) => {
43750
+ const covered = events.filter((e2) => e2.seq >= range.from && e2.seq <= range.to);
43751
+ const turnIds = [...new Set(covered.map((e2) => e2.turnId))];
43752
+ const prompts = covered.filter((e2) => e2.type === "user_prompt").map((e2) => e2.text).join("\n");
43753
+ const head2 = /^\[(segment|chapter) (\d+)/.exec(range.summary);
43754
+ return {
43755
+ kind: head2?.[1] === "chapter" ? "chapter" : "segment",
43756
+ ordinal: head2 ? Number(head2[2]) : index + 1,
43757
+ turnIds,
43758
+ from: range.from,
43759
+ to: range.to,
43760
+ summary: range.summary,
43761
+ searchText: `${range.summary}
43762
+ ${prompts}`
43763
+ };
43764
+ });
43765
+ }
43766
+ var MAX_SUMMARIZE_INPUT_CHARS3, SEGMENT_MAX_TOKENS, CHAPTER_MAX_TOKENS, PRESSURE_RATIO, SEGMENT_SYSTEM_PROMPT, CHAPTER_SYSTEM_PROMPT, warnedFallback2, sessionRecallTool, segmentsCompactorPlugin;
43767
+ var init_dist21 = __esm({
43768
+ "../compactor-segments/dist/index.js"() {
43769
+ init_segments();
43770
+ init_search2();
43771
+ init_segments();
43772
+ init_search2();
43773
+ MAX_SUMMARIZE_INPUT_CHARS3 = 48e3;
43774
+ SEGMENT_MAX_TOKENS = 700;
43775
+ CHAPTER_MAX_TOKENS = 900;
43776
+ PRESSURE_RATIO = 0.85;
43777
+ SEGMENT_SYSTEM_PROMPT = 'You compress ONE completed sub-session of an AI agent (a user request and everything the agent did to answer it) into a durable record the agent can rely on months later, without the transcript. Write exactly these lines, each on one line, no preamble and no markdown headers:\nAsked: what the user actually wanted.\nDid: the concrete actions taken: files created/edited, commands run, decisions made.\nOutcome: what resulted, INCLUDING failures and what was abandoned.\nFacts: exact paths, identifiers, versions, numbers and names worth keeping. Omit the line if there are none.\nOpen: anything unresolved or promised for later. Write "none" if nothing is open.\nBe dense and factual. Never invent detail that is not in the digest.';
43778
+ CHAPTER_SYSTEM_PROMPT = "You merge several sub-session records of an AI agent into ONE coarser record covering the same period. Keep the same line structure (Asked / Did / Outcome / Facts / Open), but describe the PERIOD rather than a single request: what the work was about, what got done, what the standing results are. Preserve exact identifiers (paths, names, versions) that later work may still need, and preserve every still-open thread. Drop step-by-step detail that has been superseded. Never invent anything.";
43779
+ warnedFallback2 = false;
43780
+ sessionRecallTool = defineTool({
43781
+ name: "session_recall",
43782
+ icon: "search",
43783
+ description: 'Search the record of THIS session\'s earlier sub-sessions. Older parts of the conversation are kept as one dense record per sub-session (a user request and everything you did for it) rather than verbatim, so use this whenever the user refers to something from earlier that you cannot see in the visible context ("what did we decide about X", "the file you changed yesterday", "go back to the thing before this"). Returns the matching records; call `recall({ turnId })` afterwards to pull one sub-session back verbatim when you need the exact detail.',
43784
+ inputSchema: z$1.object({
43785
+ query: z$1.string().min(1).describe("What you are looking for, in the user's own words if possible."),
43786
+ limit: z$1.number().int().min(1).max(10).optional().default(4)
43787
+ }),
43788
+ permission: { action: "allow" },
43789
+ isolation: {
43790
+ // Reads ctx.log, which an out-of-process isolator would not carry.
43791
+ required: "inproc",
43792
+ capabilities: { net: { mode: "none" }, timeMs: 5e3 }
43793
+ },
43794
+ handler: ({ query, limit }, ctx) => {
43795
+ const docs = buildSessionDocs(ctx.log.slice());
43796
+ if (docs.length === 0) {
43797
+ return "No earlier sub-sessions have been recorded yet; the whole conversation so far is still visible in your context.";
43798
+ }
43799
+ const matches = rank(docs, query, limit);
43800
+ if (matches.length === 0) {
43801
+ return `No recorded sub-session matches "${query}". ${docs.length} record(s) exist, covering seq 0-${docs[docs.length - 1].to}.`;
43802
+ }
43803
+ return {
43804
+ matches: matches.map(({ doc, score }) => ({
43805
+ kind: doc.kind,
43806
+ ordinal: doc.ordinal,
43807
+ turnIds: doc.turnIds,
43808
+ seqRange: [doc.from, doc.to],
43809
+ record: doc.summary,
43810
+ score: Math.round(score * 1e3) / 1e3
43811
+ })),
43812
+ hint: 'Call recall({ turnId: "<one of turnIds>" }) to bring that sub-session back verbatim, or recall({ seq: N }) for a single message.'
43813
+ };
43814
+ }
43815
+ });
43816
+ segmentsCompactorPlugin = definePlugin({
43817
+ name: "@moxxy/compactor-segments",
43818
+ version: "0.0.0",
43819
+ compactors: [createSegmentsCompactor()],
43820
+ tools: [sessionRecallTool]
43821
+ });
43822
+ }
43823
+ });
43436
43824
  function createStablePrefixCacheStrategy() {
43437
43825
  return defineCacheStrategy({
43438
43826
  name: "stable-prefix",
@@ -43462,7 +43850,7 @@ function createNoCacheStrategy() {
43462
43850
  return defineCacheStrategy({ name: "none", plan: () => [] });
43463
43851
  }
43464
43852
  var stablePrefixCacheStrategyPlugin;
43465
- var init_dist21 = __esm({
43853
+ var init_dist22 = __esm({
43466
43854
  "../cache-strategy-stable-prefix/dist/index.js"() {
43467
43855
  stablePrefixCacheStrategyPlugin = definePlugin({
43468
43856
  name: "@moxxy/cache-strategy-stable-prefix",
@@ -43487,10 +43875,10 @@ var require_react_production_min = __commonJS({
43487
43875
  var w3 = /* @__PURE__ */ Symbol.for("react.suspense");
43488
43876
  var x3 = /* @__PURE__ */ Symbol.for("react.memo");
43489
43877
  var y = /* @__PURE__ */ Symbol.for("react.lazy");
43490
- var z62 = Symbol.iterator;
43878
+ var z63 = Symbol.iterator;
43491
43879
  function A2(a) {
43492
43880
  if (null === a || "object" !== typeof a) return null;
43493
- a = z62 && a[z62] || a["@@iterator"];
43881
+ a = z63 && a[z63] || a["@@iterator"];
43494
43882
  return "function" === typeof a ? a : null;
43495
43883
  }
43496
43884
  var B2 = { isMounted: function() {
@@ -46222,7 +46610,7 @@ var require_signal_exit = __commonJS({
46222
46610
  }
46223
46611
  });
46224
46612
  var consoleMethods, originalMethods, patchConsole, dist_default;
46225
- var init_dist22 = __esm({
46613
+ var init_dist23 = __esm({
46226
46614
  "../../node_modules/.pnpm/patch-console@2.0.0/node_modules/patch-console/dist/index.js"() {
46227
46615
  consoleMethods = [
46228
46616
  "assert",
@@ -46297,7 +46685,7 @@ var init_yoga_wasm_base64_esm = __esm({
46297
46685
  h2.noExitRuntime || true;
46298
46686
  "object" != typeof WebAssembly && x3("no native wasm support detected");
46299
46687
  var fa, ha = false;
46300
- function z62(a, b2, c) {
46688
+ function z63(a, b2, c) {
46301
46689
  c = b2 + c;
46302
46690
  for (var d = ""; !(b2 >= c); ) {
46303
46691
  var e2 = a[b2++];
@@ -46947,7 +47335,7 @@ var init_yoga_wasm_base64_esm = __esm({
46947
47335
  return b2;
46948
47336
  }, Jb = {
46949
47337
  l: function(a, b2, c, d) {
46950
- x3("Assertion failed: " + (a ? z62(A2, a) : "") + ", at: " + [b2 ? b2 ? z62(A2, b2) : "" : "unknown filename", c, d ? d ? z62(A2, d) : "" : "unknown function"]);
47338
+ x3("Assertion failed: " + (a ? z63(A2, a) : "") + ", at: " + [b2 ? b2 ? z63(A2, b2) : "" : "unknown filename", c, d ? d ? z63(A2, d) : "" : "unknown function"]);
46951
47339
  },
46952
47340
  q: function(a, b2, c) {
46953
47341
  a = N2(a);
@@ -47200,7 +47588,7 @@ var init_yoga_wasm_base64_esm = __esm({
47200
47588
  if (c) for (var g = f2, k2 = 0; k2 <= e2; ++k2) {
47201
47589
  var m2 = f2 + k2;
47202
47590
  if (k2 == e2 || 0 == A2[m2]) {
47203
- g = g ? z62(A2, g, m2 - g) : "";
47591
+ g = g ? z63(A2, g, m2 - g) : "";
47204
47592
  if (void 0 === l) var l = g;
47205
47593
  else l += String.fromCharCode(0), l += g;
47206
47594
  g = m2 + 1;
@@ -47397,7 +47785,7 @@ var init_yoga_wasm_base64_esm = __esm({
47397
47785
  b2 += 8;
47398
47786
  for (var m2 = 0; m2 < k2; m2++) {
47399
47787
  var l = A2[g + m2], n = Fb[a];
47400
- 0 === l || 10 === l ? ((1 === a ? ea : v2)(z62(n, 0)), n.length = 0) : n.push(l);
47788
+ 0 === l || 10 === l ? ((1 === a ? ea : v2)(z63(n, 0)), n.length = 0) : n.push(l);
47401
47789
  }
47402
47790
  e2 += k2;
47403
47791
  }
@@ -47885,7 +48273,7 @@ var require_scheduler_production_min = __commonJS({
47885
48273
  var u = 1;
47886
48274
  var v2 = null;
47887
48275
  var y = 3;
47888
- var z62 = false;
48276
+ var z63 = false;
47889
48277
  var A2 = false;
47890
48278
  var B2 = false;
47891
48279
  var D2 = "function" === typeof setTimeout ? setTimeout : null;
@@ -47912,7 +48300,7 @@ var require_scheduler_production_min = __commonJS({
47912
48300
  function J2(a, b2) {
47913
48301
  A2 = false;
47914
48302
  B2 && (B2 = false, E2(L2), L2 = -1);
47915
- z62 = true;
48303
+ z63 = true;
47916
48304
  var c = y;
47917
48305
  try {
47918
48306
  G2(b2);
@@ -47936,7 +48324,7 @@ var require_scheduler_production_min = __commonJS({
47936
48324
  }
47937
48325
  return w3;
47938
48326
  } finally {
47939
- v2 = null, y = c, z62 = false;
48327
+ v2 = null, y = c, z63 = false;
47940
48328
  }
47941
48329
  }
47942
48330
  var N2 = false;
@@ -47993,7 +48381,7 @@ var require_scheduler_production_min = __commonJS({
47993
48381
  a.callback = null;
47994
48382
  };
47995
48383
  exports.unstable_continueExecution = function() {
47996
- A2 || z62 || (A2 = true, I2(J2));
48384
+ A2 || z63 || (A2 = true, I2(J2));
47997
48385
  };
47998
48386
  exports.unstable_forceFrameRate = function(a) {
47999
48387
  0 > a || 125 < a ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : P3 = 0 < a ? Math.floor(1e3 / a) : 5;
@@ -48066,7 +48454,7 @@ var require_scheduler_production_min = __commonJS({
48066
48454
  }
48067
48455
  e2 = c + e2;
48068
48456
  a = { id: u++, callback: b2, priorityLevel: a, startTime: c, expirationTime: e2, sortIndex: -1 };
48069
- c > d ? (a.sortIndex = c, f2(t, a), null === h2(r) && a === h2(t) && (B2 ? (E2(L2), L2 = -1) : B2 = true, K3(H3, c - d))) : (a.sortIndex = e2, f2(r, a), A2 || z62 || (A2 = true, I2(J2)));
48457
+ c > d ? (a.sortIndex = c, f2(t, a), null === h2(r) && a === h2(t) && (B2 ? (E2(L2), L2 = -1) : B2 = true, K3(H3, c - d))) : (a.sortIndex = e2, f2(r, a), A2 || z63 || (A2 = true, I2(J2)));
48070
48458
  return a;
48071
48459
  };
48072
48460
  exports.unstable_shouldYield = M;
@@ -48823,7 +49211,7 @@ var require_react_reconciler_production_min = __commonJS({
48823
49211
  gc[hc] = a.current;
48824
49212
  a.current = b2;
48825
49213
  }
48826
- var jc = {}, x3 = ic(jc), z62 = ic(false), kc = jc;
49214
+ var jc = {}, x3 = ic(jc), z63 = ic(false), kc = jc;
48827
49215
  function mc(a, b2) {
48828
49216
  var c = a.type.contextTypes;
48829
49217
  if (!c) return jc;
@@ -48839,13 +49227,13 @@ var require_react_reconciler_production_min = __commonJS({
48839
49227
  return null !== a && void 0 !== a;
48840
49228
  }
48841
49229
  function nc() {
48842
- q3(z62);
49230
+ q3(z63);
48843
49231
  q3(x3);
48844
49232
  }
48845
49233
  function oc(a, b2, c) {
48846
49234
  if (x3.current !== jc) throw Error(n(168));
48847
49235
  v2(x3, b2);
48848
- v2(z62, c);
49236
+ v2(z63, c);
48849
49237
  }
48850
49238
  function pc(a, b2, c) {
48851
49239
  var d = a.stateNode;
@@ -48859,14 +49247,14 @@ var require_react_reconciler_production_min = __commonJS({
48859
49247
  a = (a = a.stateNode) && a.__reactInternalMemoizedMergedChildContext || jc;
48860
49248
  kc = x3.current;
48861
49249
  v2(x3, a);
48862
- v2(z62, z62.current);
49250
+ v2(z63, z63.current);
48863
49251
  return true;
48864
49252
  }
48865
49253
  function rc(a, b2, c) {
48866
49254
  var d = a.stateNode;
48867
49255
  if (!d) throw Error(n(169));
48868
- c ? (a = pc(a, b2, kc), d.__reactInternalMemoizedMergedChildContext = a, q3(z62), q3(x3), v2(x3, a)) : q3(z62);
48869
- v2(z62, c);
49256
+ c ? (a = pc(a, b2, kc), d.__reactInternalMemoizedMergedChildContext = a, q3(z63), q3(x3), v2(x3, a)) : q3(z63);
49257
+ v2(z63, c);
48870
49258
  }
48871
49259
  var tc = Math.clz32 ? Math.clz32 : sc, uc = Math.log, vc = Math.LN2;
48872
49260
  function sc(a) {
@@ -50464,7 +50852,7 @@ var require_react_reconciler_production_min = __commonJS({
50464
50852
  g.state = p2;
50465
50853
  ke(b2, d, g, e2);
50466
50854
  k2 = b2.memoizedState;
50467
- h2 !== d || p2 !== k2 || z62.current || de2 ? ("function" === typeof m2 && (yf(b2, c, m2, d), k2 = b2.memoizedState), (h2 = de2 || Af(b2, c, h2, d, p2, k2, l)) ? (r || "function" !== typeof g.UNSAFE_componentWillMount && "function" !== typeof g.componentWillMount || ("function" === typeof g.componentWillMount && g.componentWillMount(), "function" === typeof g.UNSAFE_componentWillMount && g.UNSAFE_componentWillMount()), "function" === typeof g.componentDidMount && (b2.flags |= 4194308)) : ("function" === typeof g.componentDidMount && (b2.flags |= 4194308), b2.memoizedProps = d, b2.memoizedState = k2), g.props = d, g.state = k2, g.context = l, d = h2) : ("function" === typeof g.componentDidMount && (b2.flags |= 4194308), d = false);
50855
+ h2 !== d || p2 !== k2 || z63.current || de2 ? ("function" === typeof m2 && (yf(b2, c, m2, d), k2 = b2.memoizedState), (h2 = de2 || Af(b2, c, h2, d, p2, k2, l)) ? (r || "function" !== typeof g.UNSAFE_componentWillMount && "function" !== typeof g.componentWillMount || ("function" === typeof g.componentWillMount && g.componentWillMount(), "function" === typeof g.UNSAFE_componentWillMount && g.UNSAFE_componentWillMount()), "function" === typeof g.componentDidMount && (b2.flags |= 4194308)) : ("function" === typeof g.componentDidMount && (b2.flags |= 4194308), b2.memoizedProps = d, b2.memoizedState = k2), g.props = d, g.state = k2, g.context = l, d = h2) : ("function" === typeof g.componentDidMount && (b2.flags |= 4194308), d = false);
50468
50856
  } else {
50469
50857
  g = b2.stateNode;
50470
50858
  fe2(a, b2);
@@ -50482,7 +50870,7 @@ var require_react_reconciler_production_min = __commonJS({
50482
50870
  g.state = p2;
50483
50871
  ke(b2, d, g, e2);
50484
50872
  var w3 = b2.memoizedState;
50485
- h2 !== r || p2 !== w3 || z62.current || de2 ? ("function" === typeof B2 && (yf(b2, c, B2, d), w3 = b2.memoizedState), (l = de2 || Af(b2, c, l, d, p2, w3, k2) || false) ? (m2 || "function" !== typeof g.UNSAFE_componentWillUpdate && "function" !== typeof g.componentWillUpdate || ("function" === typeof g.componentWillUpdate && g.componentWillUpdate(d, w3, k2), "function" === typeof g.UNSAFE_componentWillUpdate && g.UNSAFE_componentWillUpdate(d, w3, k2)), "function" === typeof g.componentDidUpdate && (b2.flags |= 4), "function" === typeof g.getSnapshotBeforeUpdate && (b2.flags |= 1024)) : ("function" !== typeof g.componentDidUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 4), "function" !== typeof g.getSnapshotBeforeUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 1024), b2.memoizedProps = d, b2.memoizedState = w3), g.props = d, g.state = w3, g.context = k2, d = l) : ("function" !== typeof g.componentDidUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 4), "function" !== typeof g.getSnapshotBeforeUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 1024), d = false);
50873
+ h2 !== r || p2 !== w3 || z63.current || de2 ? ("function" === typeof B2 && (yf(b2, c, B2, d), w3 = b2.memoizedState), (l = de2 || Af(b2, c, l, d, p2, w3, k2) || false) ? (m2 || "function" !== typeof g.UNSAFE_componentWillUpdate && "function" !== typeof g.componentWillUpdate || ("function" === typeof g.componentWillUpdate && g.componentWillUpdate(d, w3, k2), "function" === typeof g.UNSAFE_componentWillUpdate && g.UNSAFE_componentWillUpdate(d, w3, k2)), "function" === typeof g.componentDidUpdate && (b2.flags |= 4), "function" === typeof g.getSnapshotBeforeUpdate && (b2.flags |= 1024)) : ("function" !== typeof g.componentDidUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 4), "function" !== typeof g.getSnapshotBeforeUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 1024), b2.memoizedProps = d, b2.memoizedState = w3), g.props = d, g.state = w3, g.context = k2, d = l) : ("function" !== typeof g.componentDidUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 4), "function" !== typeof g.getSnapshotBeforeUpdate || h2 === a.memoizedProps && p2 === a.memoizedState || (b2.flags |= 1024), d = false);
50486
50874
  }
50487
50875
  return dg(a, b2, c, d, f2, e2);
50488
50876
  }
@@ -50951,7 +51339,7 @@ var require_react_reconciler_production_min = __commonJS({
50951
51339
  case 3:
50952
51340
  c = b2.stateNode;
50953
51341
  te2();
50954
- q3(z62);
51342
+ q3(z63);
50955
51343
  q3(x3);
50956
51344
  ye2();
50957
51345
  c.pendingContext && (c.context = c.pendingContext, c.pendingContext = null);
@@ -51094,7 +51482,7 @@ var require_react_reconciler_production_min = __commonJS({
51094
51482
  case 1:
51095
51483
  return A2(b2.type) && nc(), a = b2.flags, a & 65536 ? (b2.flags = a & -65537 | 128, b2) : null;
51096
51484
  case 3:
51097
- return te2(), q3(z62), q3(x3), ye2(), a = b2.flags, 0 !== (a & 65536) && 0 === (a & 128) ? (b2.flags = a & -65537 | 128, b2) : null;
51485
+ return te2(), q3(z63), q3(x3), ye2(), a = b2.flags, 0 !== (a & 65536) && 0 === (a & 128) ? (b2.flags = a & -65537 | 128, b2) : null;
51098
51486
  case 5:
51099
51487
  return ve2(b2), null;
51100
51488
  case 13:
@@ -52149,7 +52537,7 @@ var require_react_reconciler_production_min = __commonJS({
52149
52537
  break;
52150
52538
  case 3:
52151
52539
  te2();
52152
- q3(z62);
52540
+ q3(z63);
52153
52541
  q3(x3);
52154
52542
  ye2();
52155
52543
  break;
@@ -52626,7 +53014,7 @@ var require_react_reconciler_production_min = __commonJS({
52626
53014
  }
52627
53015
  var ai;
52628
53016
  ai = function(a, b2, c) {
52629
- if (null !== a) if (a.memoizedProps !== b2.pendingProps || z62.current) G2 = true;
53017
+ if (null !== a) if (a.memoizedProps !== b2.pendingProps || z63.current) G2 = true;
52630
53018
  else {
52631
53019
  if (0 === (a.lanes & c) && 0 === (b2.flags & 128)) return G2 = false, sg(a, b2, c);
52632
53020
  G2 = 0 !== (a.flags & 131072) ? true : false;
@@ -52735,7 +53123,7 @@ var require_react_reconciler_production_min = __commonJS({
52735
53123
  g = e2.value;
52736
53124
  Vd(b2, d, g);
52737
53125
  if (null !== f2) if (Vc(f2.value, g)) {
52738
- if (f2.children === e2.children && !z62.current) {
53126
+ if (f2.children === e2.children && !z63.current) {
52739
53127
  b2 = Tf(a, b2, c);
52740
53128
  break a;
52741
53129
  }
@@ -70872,7 +71260,7 @@ function parseAnsiCode(string, offset) {
70872
71260
  return string.slice(0, endIndex + 1);
70873
71261
  }
70874
71262
  }
70875
- function tokenize3(string, endCharacter = Number.POSITIVE_INFINITY) {
71263
+ function tokenize4(string, endCharacter = Number.POSITIVE_INFINITY) {
70876
71264
  const returnValue = [];
70877
71265
  let index = 0;
70878
71266
  let visibleCount = 0;
@@ -70925,7 +71313,7 @@ function undoAnsiCodes(codes) {
70925
71313
  return endCodes.reverse().join("");
70926
71314
  }
70927
71315
  function sliceAnsi2(string, start, end) {
70928
- const tokens = tokenize3(string, end);
71316
+ const tokens = tokenize4(string, end);
70929
71317
  let activeCodes = [];
70930
71318
  let position = 0;
70931
71319
  let returnValue = "";
@@ -71142,7 +71530,7 @@ function parseAnsiCode2(string, offset) {
71142
71530
  return string.slice(0, endIndex + 1);
71143
71531
  }
71144
71532
  }
71145
- function tokenize4(str, endChar = Number.POSITIVE_INFINITY) {
71533
+ function tokenize5(str, endChar = Number.POSITIVE_INFINITY) {
71146
71534
  const ret = [];
71147
71535
  let index = 0;
71148
71536
  let visible = 0;
@@ -71307,7 +71695,7 @@ var init_output = __esm({
71307
71695
  for (const transformer of transformers) {
71308
71696
  line = transformer(line, index);
71309
71697
  }
71310
- const characters = styledCharsFromTokens(tokenize4(line));
71698
+ const characters = styledCharsFromTokens(tokenize5(line));
71311
71699
  let offsetX = x3;
71312
71700
  for (const character of characters) {
71313
71701
  currentLine[offsetX] = character;
@@ -71888,7 +72276,7 @@ var require_stack_utils = __commonJS({
71888
72276
 
71889
72277
  // ../../node_modules/.pnpm/convert-to-spaces@2.0.1/node_modules/convert-to-spaces/dist/index.js
71890
72278
  var convertToSpaces, dist_default2;
71891
- var init_dist23 = __esm({
72279
+ var init_dist24 = __esm({
71892
72280
  "../../node_modules/.pnpm/convert-to-spaces@2.0.1/node_modules/convert-to-spaces/dist/index.js"() {
71893
72281
  convertToSpaces = (input, spaces = 2) => {
71894
72282
  return input.replace(/^\t+/gm, ($1) => " ".repeat($1.length * spaces));
@@ -71899,9 +72287,9 @@ var init_dist23 = __esm({
71899
72287
 
71900
72288
  // ../../node_modules/.pnpm/code-excerpt@4.0.0/node_modules/code-excerpt/dist/index.js
71901
72289
  var generateLineNumbers, codeExcerpt, dist_default3;
71902
- var init_dist24 = __esm({
72290
+ var init_dist25 = __esm({
71903
72291
  "../../node_modules/.pnpm/code-excerpt@4.0.0/node_modules/code-excerpt/dist/index.js"() {
71904
- init_dist23();
72292
+ init_dist24();
71905
72293
  generateLineNumbers = (line, around) => {
71906
72294
  const lineNumbers = [];
71907
72295
  const min = line - around;
@@ -72093,7 +72481,7 @@ var init_ErrorOverview = __esm({
72093
72481
  "../../node_modules/.pnpm/ink@5.2.1_@types+react@18.3.28_react@18.3.1/node_modules/ink/build/components/ErrorOverview.js"() {
72094
72482
  import_react8 = __toESM(require_react());
72095
72483
  import_stack_utils = __toESM(require_stack_utils());
72096
- init_dist24();
72484
+ init_dist25();
72097
72485
  init_Box();
72098
72486
  init_Text();
72099
72487
  cleanupPath = (path68) => {
@@ -72398,7 +72786,7 @@ var init_ink = __esm({
72398
72786
  init_is_in_ci();
72399
72787
  init_auto_bind();
72400
72788
  import_signal_exit2 = __toESM(require_signal_exit());
72401
- init_dist22();
72789
+ init_dist23();
72402
72790
  await init_src();
72403
72791
  await init_reconciler();
72404
72792
  await init_renderer();
@@ -75920,7 +76308,7 @@ var init_id = __esm({
75920
76308
  });
75921
76309
 
75922
76310
  // ../chat-model/dist/index.js
75923
- var init_dist25 = __esm({
76311
+ var init_dist26 = __esm({
75924
76312
  "../chat-model/dist/index.js"() {
75925
76313
  init_types();
75926
76314
  init_pair_events();
@@ -76318,7 +76706,7 @@ var init_EventLine = __esm({
76318
76706
  await init_build2();
76319
76707
  init_theme();
76320
76708
  init_density();
76321
- init_dist25();
76709
+ init_dist26();
76322
76710
  await init_AssistantBlock();
76323
76711
  EventLine = ({ event, expandToolOutputs }) => {
76324
76712
  switch (event.type) {
@@ -76474,7 +76862,7 @@ var init_ToolCallBlock = __esm({
76474
76862
  __toESM(require_react());
76475
76863
  await init_build2();
76476
76864
  init_theme();
76477
- init_dist25();
76865
+ init_dist26();
76478
76866
  await init_FileDiffView();
76479
76867
  await init_ShimmerText();
76480
76868
  NAME_DISPLAY_MAX = 48;
@@ -76512,7 +76900,7 @@ var init_LiveToolBlock = __esm({
76512
76900
  init_theme();
76513
76901
  await init_ToolCallBlock();
76514
76902
  await init_ShimmerText();
76515
- init_dist25();
76903
+ init_dist26();
76516
76904
  LiveToolBlock = ({ block, expanded, nested = false }) => {
76517
76905
  const inFlight = block.calls.some((call) => call.outcome === null);
76518
76906
  const showDetails = expanded || inFlight;
@@ -76540,7 +76928,7 @@ var init_SubagentScopeView = __esm({
76540
76928
  await init_build2();
76541
76929
  init_theme();
76542
76930
  init_density();
76543
- init_dist25();
76931
+ init_dist26();
76544
76932
  init_motion();
76545
76933
  SubagentScopeView = ({ scope }) => {
76546
76934
  const [now, setNow] = (0, import_react38.useState)(() => Date.now());
@@ -76570,7 +76958,7 @@ var init_SubagentGroupView = __esm({
76570
76958
  await init_build2();
76571
76959
  init_theme();
76572
76960
  init_density();
76573
- init_dist25();
76961
+ init_dist26();
76574
76962
  LABEL_MAX = 60;
76575
76963
  ERROR_MAX = 80;
76576
76964
  SubagentGroupView = ({ group, expandToolOutputs }) => {
@@ -76610,7 +76998,7 @@ var init_CollabScopeView = __esm({
76610
76998
  await init_build2();
76611
76999
  init_theme();
76612
77000
  init_density();
76613
- init_dist25();
77001
+ init_dist26();
76614
77002
  init_motion();
76615
77003
  MAX_AGENTS = 8;
76616
77004
  MAX_TASKS = 6;
@@ -76672,7 +77060,7 @@ var init_BlockLine = __esm({
76672
77060
  await init_SubagentGroupView();
76673
77061
  await init_CollabScopeView();
76674
77062
  await init_ShimmerText();
76675
- init_dist25();
77063
+ init_dist26();
76676
77064
  NAME_DISPLAY_MAX2 = 48;
76677
77065
  BlockLine = (0, import_react41.memo)(
76678
77066
  function BlockLine2({ block, expandToolOutputs, renderVersion, nested = false }) {
@@ -76773,7 +77161,7 @@ var init_ChatView = __esm({
76773
77161
  import_react43 = __toESM(require_react());
76774
77162
  await init_build2();
76775
77163
  await init_BlockLine();
76776
- init_dist25();
77164
+ init_dist26();
76777
77165
  await init_StreamingPreview();
76778
77166
  ChatView = ({ events, streamingDelta, reasoningDelta, expandToolOutputs, compactTools, hideLive }) => {
76779
77167
  const foldRef = (0, import_react43.useRef)(null);
@@ -76872,7 +77260,7 @@ var init_StatusLine = __esm({
76872
77260
  import_jsx_runtime25 = __toESM(require_jsx_runtime());
76873
77261
  import_react46 = __toESM(require_react());
76874
77262
  await init_build2();
76875
- init_dist25();
77263
+ init_dist26();
76876
77264
  init_theme();
76877
77265
  await init_Spinner();
76878
77266
  await init_ModeFooter();
@@ -76929,18 +77317,18 @@ function eventChars(e2) {
76929
77317
  case "assistant_message":
76930
77318
  return e2.content.length;
76931
77319
  case "tool_call_requested":
76932
- return e2.name.length + safeJsonLen2(e2.input);
77320
+ return e2.name.length + safeJsonLen3(e2.input);
76933
77321
  case "tool_result":
76934
77322
  if (e2.error)
76935
77323
  return (e2.error.message?.length ?? 0) + 12;
76936
77324
  if (typeof e2.output === "string")
76937
77325
  return e2.output.length;
76938
- return safeJsonLen2(e2.output);
77326
+ return safeJsonLen3(e2.output);
76939
77327
  default:
76940
77328
  return 0;
76941
77329
  }
76942
77330
  }
76943
- function safeJsonLen2(v2) {
77331
+ function safeJsonLen3(v2) {
76944
77332
  try {
76945
77333
  return JSON.stringify(v2 ?? "").length;
76946
77334
  } catch {
@@ -78192,7 +78580,7 @@ var init_voice_reply = __esm({
78192
78580
  });
78193
78581
 
78194
78582
  // ../channel-kit/dist/index.js
78195
- var init_dist26 = __esm({
78583
+ var init_dist27 = __esm({
78196
78584
  "../channel-kit/dist/index.js"() {
78197
78585
  init_frame_pump();
78198
78586
  init_turn();
@@ -78625,7 +79013,7 @@ function noPlayerNotice(platform2) {
78625
79013
  var READ_ALOUD_NO_SYNTH_HINT, NO_SYNTH_NOTICE;
78626
79014
  var init_read_aloud = __esm({
78627
79015
  "../plugin-cli/dist/session/read-aloud.js"() {
78628
- init_dist26();
79016
+ init_dist27();
78629
79017
  init_audio_play();
78630
79018
  READ_ALOUD_NO_SYNTH_HINT = "Install a text-to-speech backend:\n moxxy plugins install tts-local (offline)\n moxxy plugins install tts-openai";
78631
79019
  NO_SYNTH_NOTICE = `read-aloud: no active text-to-speech backend.
@@ -80063,7 +80451,7 @@ var init_SkillsPanel = __esm({
80063
80451
  import_jsx_runtime27 = __toESM(require_jsx_runtime());
80064
80452
  import_react56 = __toESM(require_react());
80065
80453
  await init_build2();
80066
- init_dist25();
80454
+ init_dist26();
80067
80455
  await init_Modal();
80068
80456
  await init_useScrollableList();
80069
80457
  NAME_COL = 28;
@@ -80125,7 +80513,7 @@ var init_ToolsPanel = __esm({
80125
80513
  import_jsx_runtime28 = __toESM(require_jsx_runtime());
80126
80514
  import_react57 = __toESM(require_react());
80127
80515
  await init_build2();
80128
- init_dist25();
80516
+ init_dist26();
80129
80517
  init_theme();
80130
80518
  await init_Modal();
80131
80519
  await init_useScrollableList();
@@ -80296,7 +80684,7 @@ var init_AgentsPanel = __esm({
80296
80684
  import_jsx_runtime29 = __toESM(require_jsx_runtime());
80297
80685
  import_react58 = __toESM(require_react());
80298
80686
  await init_build2();
80299
- init_dist25();
80687
+ init_dist26();
80300
80688
  init_theme();
80301
80689
  await init_Modal();
80302
80690
  await init_useScrollableList();
@@ -80493,7 +80881,7 @@ var init_WorkflowsPanel = __esm({
80493
80881
  import_jsx_runtime31 = __toESM(require_jsx_runtime());
80494
80882
  import_react60 = __toESM(require_react());
80495
80883
  await init_build2();
80496
- init_dist25();
80884
+ init_dist26();
80497
80885
  init_theme();
80498
80886
  await init_Modal();
80499
80887
  await init_useScrollableList();
@@ -82526,7 +82914,7 @@ __export(dist_exports3, {
82526
82914
  unavailableVoiceCaptureCheck: () => unavailableVoiceCaptureCheck
82527
82915
  });
82528
82916
  var tuiChannelDef, cliPlugin, dist_default4;
82529
- var init_dist27 = __esm({
82917
+ var init_dist28 = __esm({
82530
82918
  async "../plugin-cli/dist/index.js"() {
82531
82919
  await init_TuiChannel();
82532
82920
  await init_InteractiveSession();
@@ -82887,8 +83275,8 @@ var init_remote = __esm({
82887
83275
  // Multi-session conversations: list/create/switch/rename are conversation-
82888
83276
  // scoped — the same trust class as `session.newSession` (already allowed),
82889
83277
  // and what a paired phone needs to mirror the desktop's session list.
82890
- // `sessions.remove` is deliberately NOT here: it deletes on-disk state
82891
- // (the runner's session JSONL + the chat NDJSON transcript), a destructive
83278
+ // `sessions.remove` is deliberately NOT here: it deletes the authoritative
83279
+ // on-disk session JSONL, a destructive
82892
83280
  // host mutation in the same class as `desks.remove`, which is also
82893
83281
  // host-only.
82894
83282
  "sessions.list",
@@ -82898,8 +83286,8 @@ var init_remote = __esm({
82898
83286
  // Voice input (capability-probed; transcribe fails coded without a transcriber).
82899
83287
  "session.hasTranscriber",
82900
83288
  "session.transcribe",
82901
- // Read a workspace's transcript history from the runner's authoritative log
82902
- // (a paired phone may read history, scoped to a workspace, not host config).
83289
+ // Read a workspace's transcript history from its authoritative session log
83290
+ // (a paired phone may read history, scoped to a known workspace, not host config).
82903
83291
  "chat.loadHistory",
82904
83292
  // Scheduler: mobile may inspect, pause/resume, and delete existing schedules
82905
83293
  // from the shared scheduler store. Creating/editing prompts remains an
@@ -82925,7 +83313,7 @@ var init_remote = __esm({
82925
83313
  });
82926
83314
 
82927
83315
  // ../desktop-ipc-contract/dist/index.js
82928
- var init_dist28 = __esm({
83316
+ var init_dist29 = __esm({
82929
83317
  "../desktop-ipc-contract/dist/index.js"() {
82930
83318
  init_ask();
82931
83319
  init_error_envelope();
@@ -83267,9 +83655,9 @@ var init_validation = __esm({
83267
83655
  "mobileGateway.status": z.undefined(),
83268
83656
  "mobileGateway.rotateToken": z.undefined(),
83269
83657
  "mobileGateway.setEnabled": z.object({ enabled: z.boolean() }).strict(),
83270
- // `before` is a runner `seq` cursor; the page is RAW events. The runner itself
83271
- // re-validates and caps at its own MAX_HISTORY_PAGE_LIMIT (2000), so bound the
83272
- // renderer's raw-window request to that ceiling.
83658
+ // `before` is a session-log `seq` cursor; the page is RAW events. Both the
83659
+ // connected runner and host-side startup reader cap at the runner's
83660
+ // MAX_HISTORY_PAGE_LIMIT (2000), so bind the renderer to that ceiling.
83273
83661
  "chat.loadHistory": z.object({
83274
83662
  workspaceId: z.string().min(1).max(256),
83275
83663
  before: z.number().int().nonnegative().nullable(),
@@ -83354,7 +83742,7 @@ var WebSocketCommandBus;
83354
83742
  var init_ws_command_bus = __esm({
83355
83743
  "../ipc-server-ws/dist/ws-command-bus.js"() {
83356
83744
  init_dist17();
83357
- init_dist28();
83745
+ init_dist29();
83358
83746
  init_dispatch();
83359
83747
  WebSocketCommandBus = class {
83360
83748
  methods = /* @__PURE__ */ new Map();
@@ -83443,7 +83831,7 @@ async function startWsBridge(bus, opts) {
83443
83831
  }
83444
83832
  };
83445
83833
  }
83446
- var init_dist29 = __esm({
83834
+ var init_dist30 = __esm({
83447
83835
  "../ipc-server-ws/dist/index.js"() {
83448
83836
  init_ws_transport();
83449
83837
  init_ws_transport();
@@ -83597,7 +83985,7 @@ function timestampFromIso(value2) {
83597
83985
  return Number.isFinite(parsed) ? parsed : Date.now();
83598
83986
  }
83599
83987
  var MOXXY_WORKSPACE_ID, MOXXY_WORKSPACE_NAME, MOXXY_WORKSPACE_COLOR, NEW_SESSION_NAME, DOC_VERSION, MAX_TITLE, DEFAULT_COLORS, WorkspaceRegistry;
83600
- var init_dist30 = __esm({
83988
+ var init_dist31 = __esm({
83601
83989
  "../workspace-registry/dist/index.js"() {
83602
83990
  init_dist2();
83603
83991
  MOXXY_WORKSPACE_ID = "moxxy";
@@ -83881,7 +84269,7 @@ var init_single_session_host = __esm({
83881
84269
  "../plugin-channel-mobile/dist/single-session-host.js"() {
83882
84270
  init_dist2();
83883
84271
  init_dispatch();
83884
- init_dist30();
84272
+ init_dist31();
83885
84273
  DEFAULT_ASK_TIMEOUT_MS = 5 * 6e4;
83886
84274
  MAX_PENDING_ASKS = 256;
83887
84275
  MobileSessionHost = class {
@@ -84329,17 +84717,17 @@ function lanHost(fallback2) {
84329
84717
  if (ni.family !== "IPv4" || ni.internal)
84330
84718
  continue;
84331
84719
  const virtual = VIRTUAL_IFACE.test(name);
84332
- let rank;
84720
+ let rank2;
84333
84721
  if (isLinkLocalV4(ni.address))
84334
- rank = 5;
84722
+ rank2 = 5;
84335
84723
  else if (isRfc1918(ni.address))
84336
- rank = virtual ? 3 : 1;
84724
+ rank2 = virtual ? 3 : 1;
84337
84725
  else if (isCgnat(ni.address))
84338
- rank = 4;
84726
+ rank2 = 4;
84339
84727
  else
84340
- rank = virtual ? 4 : 2;
84341
- if (!best || rank < best.rank)
84342
- best = { address: ni.address, rank };
84728
+ rank2 = virtual ? 4 : 2;
84729
+ if (!best || rank2 < best.rank)
84730
+ best = { address: ni.address, rank: rank2 };
84343
84731
  }
84344
84732
  }
84345
84733
  return best?.address ?? fallback2;
@@ -89216,7 +89604,7 @@ function resolveAllowQueryToken(opt) {
89216
89604
  var DEFAULT_PORT, MobileChannel;
89217
89605
  var init_channel2 = __esm({
89218
89606
  "../plugin-channel-mobile/dist/channel.js"() {
89219
- init_dist29();
89607
+ init_dist30();
89220
89608
  init_dist8();
89221
89609
  init_node();
89222
89610
  init_single_session_host();
@@ -89470,7 +89858,7 @@ function pickExpoOptions(opts) {
89470
89858
  };
89471
89859
  }
89472
89860
  var mobileChannelDef, mobileChannelPlugin;
89473
- var init_dist31 = __esm({
89861
+ var init_dist32 = __esm({
89474
89862
  "../plugin-channel-mobile/dist/index.js"() {
89475
89863
  init_channel2();
89476
89864
  init_channel2();
@@ -89565,7 +89953,7 @@ function plural2(count, noun) {
89565
89953
  return count === 1 ? noun : `${noun}s`;
89566
89954
  }
89567
89955
  var infoCmd, clearCmd, newCmd, compactCmd, exitCmd, helpCmd, commandsPlugin;
89568
- var init_dist32 = __esm({
89956
+ var init_dist33 = __esm({
89569
89957
  "../plugin-commands/dist/index.js"() {
89570
89958
  infoCmd = {
89571
89959
  name: "info",
@@ -89697,6 +90085,11 @@ function buildBuiltinEntries(args) {
89697
90085
  { name: "@moxxy/mode-collaborative", plugin: collaborativeModePlugin },
89698
90086
  { name: "@moxxy/plugin-collab", plugin: collabPlugin },
89699
90087
  { name: "@moxxy/compactor-summarize", plugin: summarizeCompactorPlugin },
90088
+ // Sub-session compaction, the default. Records each finished turn as one
90089
+ // outcome summary and folds old records into chapters, so a session's
90090
+ // context is bounded by policy instead of by how long you've been talking.
90091
+ // `summarize-old-turns` stays registered as the protected floor.
90092
+ { name: "@moxxy/compactor-segments", plugin: segmentsCompactorPlugin },
89700
90093
  { name: "@moxxy/cache-strategy-stable-prefix", plugin: stablePrefixCacheStrategyPlugin },
89701
90094
  { name: "@moxxy/plugin-vault", plugin: vaultPlugin },
89702
90095
  // plugin-stt-whisper(+codex) are NOT bundled — install on demand / seeded
@@ -89769,10 +90162,11 @@ var init_builtin_entries = __esm({
89769
90162
  init_dist18();
89770
90163
  init_dist20();
89771
90164
  init_dist21();
89772
- await init_dist27();
89773
- init_dist31();
89774
- init_dist6();
90165
+ init_dist22();
90166
+ await init_dist28();
89775
90167
  init_dist32();
90168
+ init_dist6();
90169
+ init_dist33();
89776
90170
  init_builtin_skills_dir();
89777
90171
  init_plugin_snapshot();
89778
90172
  init_version();
@@ -92567,7 +92961,7 @@ var init_paths = __esm({
92567
92961
  });
92568
92962
 
92569
92963
  // ../plugin-workflows/dist/index.js
92570
- var init_dist33 = __esm({
92964
+ var init_dist34 = __esm({
92571
92965
  "../plugin-workflows/dist/index.js"() {
92572
92966
  init_schema2();
92573
92967
  init_loader4();
@@ -92760,7 +93154,7 @@ var PLUGIN_ID3;
92760
93154
  var init_build_workflow_runner = __esm({
92761
93155
  "src/setup/build-workflow-runner.ts"() {
92762
93156
  init_dist2();
92763
- init_dist33();
93157
+ init_dist34();
92764
93158
  PLUGIN_ID3 = asPluginId(WORKFLOWS_PLUGIN_NAME);
92765
93159
  }
92766
93160
  });
@@ -92843,7 +93237,7 @@ function buildWorkflowsView(args) {
92843
93237
  }
92844
93238
  var init_build_workflow_tools = __esm({
92845
93239
  "src/setup/build-workflow-tools.ts"() {
92846
- init_dist33();
93240
+ init_dist34();
92847
93241
  }
92848
93242
  });
92849
93243
  function detectAfterWorkflowCycles(workflows) {
@@ -93208,7 +93602,7 @@ function buildWorkflowsIntegration(args) {
93208
93602
  var init_workflows2 = __esm({
93209
93603
  "src/setup/workflows.ts"() {
93210
93604
  init_dist2();
93211
- init_dist33();
93605
+ init_dist34();
93212
93606
  init_build_workflow_runner();
93213
93607
  init_build_workflow_tools();
93214
93608
  init_wire_run_store();
@@ -93929,7 +94323,10 @@ var init_resolve_plugins_tree = __esm({
93929
94323
  "src/setup/resolve-plugins-tree.ts"() {
93930
94324
  BUILTIN_DEFAULTS = {
93931
94325
  mode: "default",
93932
- compactor: "summarize",
94326
+ // Sub-session compaction: bounds context by policy rather than by session
94327
+ // length. `summarize-old-turns` remains registered as the protected floor and
94328
+ // is selectable via `plugins.compactor.default`.
94329
+ compactor: "segments",
93933
94330
  cacheStrategy: "stable-prefix",
93934
94331
  workflowExecutor: "dag",
93935
94332
  embedder: "tfidf",
@@ -94125,7 +94522,7 @@ var init_utils4 = __esm({
94125
94522
 
94126
94523
  // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
94127
94524
  var ANSI_RE, CONTROL_RE, CJKT_WIDE_RE, TAB_RE, EMOJI_RE, LATIN_RE, MODIFIER_RE, NO_TRUNCATION, getStringTruncatedWidth, dist_default5;
94128
- var init_dist34 = __esm({
94525
+ var init_dist35 = __esm({
94129
94526
  "../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js"() {
94130
94527
  init_utils4();
94131
94528
  ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
@@ -94229,9 +94626,9 @@ var init_dist34 = __esm({
94229
94626
 
94230
94627
  // ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
94231
94628
  var NO_TRUNCATION2, fastStringWidth, dist_default6;
94232
- var init_dist35 = __esm({
94629
+ var init_dist36 = __esm({
94233
94630
  "../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js"() {
94234
- init_dist34();
94631
+ init_dist35();
94235
94632
  NO_TRUNCATION2 = {
94236
94633
  limit: Infinity,
94237
94634
  ellipsis: "",
@@ -94251,7 +94648,7 @@ function wrapAnsi3(string, columns, options) {
94251
94648
  var ESC2, CSI, END_CODE2, ANSI_ESCAPE_BELL2, ANSI_CSI2, ANSI_OSC2, ANSI_SGR_TERMINATOR2, ANSI_ESCAPE_LINK2, GROUP_REGEX, getClosingCode, wrapAnsiCode2, wrapAnsiHyperlink2, wrapWord2, stringVisibleTrimSpacesRight2, exec2, CRLF_OR_LF;
94252
94649
  var init_main = __esm({
94253
94650
  "../../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js"() {
94254
- init_dist35();
94651
+ init_dist36();
94255
94652
  ESC2 = "\x1B";
94256
94653
  CSI = "\x9B";
94257
94654
  END_CODE2 = 39;
@@ -94555,7 +94952,7 @@ function C(r, t) {
94555
94952
  for (const s of r) if (s !== void 0 && C(s, t)) return true;
94556
94953
  return false;
94557
94954
  }
94558
- function z56(r, t) {
94955
+ function z57(r, t) {
94559
94956
  if (r === t) return;
94560
94957
  const s = r.split(`
94561
94958
  `), e2 = t.split(`
@@ -94644,7 +95041,7 @@ function st(r, t, s, e2) {
94644
95041
  return r === "year" ? { min: i?.year ?? 1, max: n?.year ?? 9999 } : r === "month" ? { min: i && t.year === i.year ? i.month : 1, max: n && t.year === n.year ? n.month : 12 } : { min: i && t.year === i.year && t.month === i.month ? i.day : 1, max: n && t.year === n.year && t.month === n.month ? n.day : U(t.year, t.month) };
94645
95042
  }
94646
95043
  var import_sisteransi, G, K, h, Y, k, A, L, m, Q, X, Z, et, it, rt, nt, ot, ut, at, ht;
94647
- var init_dist36 = __esm({
95044
+ var init_dist37 = __esm({
94648
95045
  "../../node_modules/.pnpm/@clack+core@1.3.1/node_modules/@clack/core/dist/index.mjs"() {
94649
95046
  init_main();
94650
95047
  import_sisteransi = __toESM(require_src());
@@ -94746,7 +95143,7 @@ var init_dist36 = __esm({
94746
95143
  if (t !== this._prevFrame) {
94747
95144
  if (this.state === "initial") this.output.write(import_sisteransi.cursor.hide);
94748
95145
  else {
94749
- const s = z56(this._prevFrame, t), e2 = L(this.output);
95146
+ const s = z57(this._prevFrame, t), e2 = L(this.output);
94750
95147
  if (this.restoreCursor(), s) {
94751
95148
  const i = Math.max(0, s.numLinesAfter - e2), n = Math.max(0, s.numLinesBefore - e2);
94752
95149
  let o = s.lines.find((u) => u >= i);
@@ -95274,7 +95671,7 @@ __export(dist_exports4, {
95274
95671
  S_ERROR: () => gt,
95275
95672
  S_INFO: () => ht2,
95276
95673
  S_PASSWORD_MASK: () => Et,
95277
- S_RADIO_ACTIVE: () => z57,
95674
+ S_RADIO_ACTIVE: () => z58,
95278
95675
  S_RADIO_INACTIVE: () => U2,
95279
95676
  S_STEP_ACTIVE: () => Tt,
95280
95677
  S_STEP_CANCEL: () => at2,
@@ -95376,13 +95773,13 @@ function _e({ style: t = "heavy", max: i = 100, size: s = 40, ...r } = {}) {
95376
95773
  };
95377
95774
  return { start: g, stop: u.stop, cancel: u.cancel, error: u.error, clear: u.clear, advance: p2, isCancelled: u.isCancelled, message: (f2) => p2(0, f2) };
95378
95775
  }
95379
- var import_sisteransi2, tt2, ot2, It, w2, Tt, at2, ut2, H2, lt, $2, x2, _t, xt, z57, U2, et2, K2, Y2, Et, st2, ct, Gt, $t, dt, Mt, ht2, pt, mt, gt, P2, yt, Ot, F2, At, ie, re, ne, oe, ae, ue, le, de, he, pe, R2, me, ge, ye, fe, Q2, ve, we, be, Se, Ce, Ie, Te, ft, jt, it2, xe, Ee, Nt, q2, Ge, Me, Oe, Pe;
95380
- var init_dist37 = __esm({
95776
+ var import_sisteransi2, tt2, ot2, It, w2, Tt, at2, ut2, H2, lt, $2, x2, _t, xt, z58, U2, et2, K2, Y2, Et, st2, ct, Gt, $t, dt, Mt, ht2, pt, mt, gt, P2, yt, Ot, F2, At, ie, re, ne, oe, ae, ue, le, de, he, pe, R2, me, ge, ye, fe, Q2, ve, we, be, Se, Ce, Ie, Te, ft, jt, it2, xe, Ee, Nt, q2, Ge, Me, Oe, Pe;
95777
+ var init_dist38 = __esm({
95381
95778
  "../../node_modules/.pnpm/@clack+prompts@1.4.0/node_modules/@clack/prompts/dist/index.mjs"() {
95382
- init_dist36();
95383
- init_dist36();
95779
+ init_dist37();
95780
+ init_dist37();
95384
95781
  init_main();
95385
- init_dist35();
95782
+ init_dist36();
95386
95783
  import_sisteransi2 = __toESM(require_src());
95387
95784
  tt2 = ee();
95388
95785
  ot2 = () => process.env.CI === "true";
@@ -95397,7 +95794,7 @@ var init_dist37 = __esm({
95397
95794
  x2 = w2("\u2514", "\u2014");
95398
95795
  _t = w2("\u2510", "T");
95399
95796
  xt = w2("\u2518", "\u2014");
95400
- z57 = w2("\u25CF", ">");
95797
+ z58 = w2("\u25CF", ">");
95401
95798
  U2 = w2("\u25CB", " ");
95402
95799
  et2 = w2("\u25FB", "[\u2022]");
95403
95800
  K2 = w2("\u25FC", "[+]");
@@ -95476,7 +95873,7 @@ var init_dist37 = __esm({
95476
95873
  const d = Pt(o), g = o.hint && o.value === this.focusedValue ? styleText("dim", ` (${o.hint})`) : "";
95477
95874
  switch (l) {
95478
95875
  case "active":
95479
- return `${styleText("green", z57)} ${d}${g}`;
95876
+ return `${styleText("green", z58)} ${d}${g}`;
95480
95877
  case "inactive":
95481
95878
  return `${styleText("dim", U2)} ${styleText("dim", d)}`;
95482
95879
  case "disabled":
@@ -95585,9 +95982,9 @@ ${styleText("gray", $2)}` : ""}`;
95585
95982
  }
95586
95983
  default: {
95587
95984
  const l = r ? `${styleText("cyan", $2)} ` : "", d = r ? styleText("cyan", x2) : "";
95588
- return `${c}${l}${this.value ? `${styleText("green", z57)} ${i}` : `${styleText("dim", U2)} ${styleText("dim", i)}`}${t.vertical ? r ? `
95985
+ return `${c}${l}${this.value ? `${styleText("green", z58)} ${i}` : `${styleText("dim", U2)} ${styleText("dim", i)}`}${t.vertical ? r ? `
95589
95986
  ${styleText("cyan", $2)} ` : `
95590
- ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", U2)} ${styleText("dim", s)}` : `${styleText("green", z57)} ${s}`}
95987
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", U2)} ${styleText("dim", s)}` : `${styleText("green", z58)} ${s}`}
95591
95988
  ${d}
95592
95989
  `;
95593
95990
  }
@@ -95973,7 +96370,7 @@ ${a}
95973
96370
  case "selected":
95974
96371
  return `${it2(u, (n) => styleText("dim", n))}`;
95975
96372
  case "active":
95976
- return `${styleText("green", z57)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
96373
+ return `${styleText("green", z58)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
95977
96374
  case "cancelled":
95978
96375
  return `${it2(u, (n) => styleText(["strikethrough", "dim"], n))}`;
95979
96376
  default:
@@ -96221,7 +96618,7 @@ async function clackPrompt(question, opts) {
96221
96618
  var activeReaders;
96222
96619
  var init_auth_context = __esm({
96223
96620
  "src/wizard/auth-context.ts"() {
96224
- init_dist37();
96621
+ init_dist38();
96225
96622
  activeReaders = /* @__PURE__ */ new WeakMap();
96226
96623
  }
96227
96624
  });
@@ -96370,7 +96767,10 @@ var init_apply_plugins_tree = __esm({
96370
96767
  "src/setup/apply-plugins-tree.ts"() {
96371
96768
  init_resolve_plugins_tree();
96372
96769
  BUILTIN_FLOORS = [
96373
- { registry: (s) => s.compactors, name: "summarize" },
96770
+ // The def's own name. `summarize`, the old value here, matched nothing, so
96771
+ // the floor was never actually marked. Harmless while one compactor
96772
+ // existed; with a second one it decides where an unregister reverts to.
96773
+ { registry: (s) => s.compactors, name: "summarize-old-turns" },
96374
96774
  { registry: (s) => s.cacheStrategies, name: "stable-prefix" },
96375
96775
  { registry: (s) => s.workflowExecutors, name: "dag" }
96376
96776
  ];
@@ -97055,8 +97455,8 @@ async function collectKey(providerId, controller) {
97055
97455
  }
97056
97456
  var init_run_setup_wizard = __esm({
97057
97457
  async "src/wizard/run-setup-wizard.ts"() {
97058
- init_dist37();
97059
- await init_dist27();
97458
+ init_dist38();
97459
+ await init_dist28();
97060
97460
  init_colors();
97061
97461
  }
97062
97462
  });
@@ -97127,7 +97527,7 @@ async function collectField(packageName, field, opts) {
97127
97527
  }
97128
97528
  var init_plugin_setup_steps = __esm({
97129
97529
  "src/wizard/plugin-setup-steps.ts"() {
97130
- init_dist37();
97530
+ init_dist38();
97131
97531
  init_dist3();
97132
97532
  init_dist6();
97133
97533
  init_colors();
@@ -97336,7 +97736,7 @@ var init_init = __esm({
97336
97736
  init_dist6();
97337
97737
  init_dist3();
97338
97738
  init_logo();
97339
- init_dist37();
97739
+ init_dist38();
97340
97740
  init_colors();
97341
97741
  }
97342
97742
  });
@@ -98038,7 +98438,7 @@ function toInteractiveStep(step) {
98038
98438
  var import_react75;
98039
98439
  var init_run_tui = __esm({
98040
98440
  async "src/commands/run-tui.ts"() {
98041
- await init_dist27();
98441
+ await init_dist28();
98042
98442
  init_dist3();
98043
98443
  await init_build2();
98044
98444
  import_react75 = __toESM(require_react());
@@ -99343,7 +99743,7 @@ ${colors.dim("`moxxy plugins set-default <category> <name>` changes one.")}`,
99343
99743
  var ONBOARD_CHANNELS, HELP3;
99344
99744
  var init_onboard = __esm({
99345
99745
  async "src/commands/onboard.ts"() {
99346
- init_dist37();
99746
+ init_dist38();
99347
99747
  init_dist3();
99348
99748
  init_dist6();
99349
99749
  await init_argv_helpers();
@@ -99834,7 +100234,7 @@ async function runPermsCommand(argv) {
99834
100234
  const [{ render: render4 }, React58, { PermissionEditor: PermissionEditor2 }] = await Promise.all([
99835
100235
  init_build2().then(() => build_exports),
99836
100236
  Promise.resolve().then(() => __toESM(require_react())),
99837
- init_dist27().then(() => dist_exports3)
100237
+ init_dist28().then(() => dist_exports3)
99838
100238
  ]);
99839
100239
  const { waitUntilExit } = render4(
99840
100240
  React58.createElement(PermissionEditor2, { policyPath: policyPath() })
@@ -100151,7 +100551,7 @@ function l2Normalize(v2) {
100151
100551
  const norm = Math.sqrt(sum);
100152
100552
  return v2.map((x3) => x3 / norm);
100153
100553
  }
100154
- function tokenize5(text) {
100554
+ function tokenize6(text) {
100155
100555
  return text.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").split(/[^a-z0-9_-]+/).filter((t) => t.length >= 2 && !STOPWORDS.has(t));
100156
100556
  }
100157
100557
  var TfIdfEmbedder, STOPWORDS;
@@ -100170,7 +100570,7 @@ var init_tfidf = __esm({
100170
100570
  * source corpus changes; embed() must be called only after fit().
100171
100571
  */
100172
100572
  fit(corpus) {
100173
- const docs = corpus.map(tokenize5);
100573
+ const docs = corpus.map(tokenize6);
100174
100574
  const df = /* @__PURE__ */ new Map();
100175
100575
  for (const doc of docs) {
100176
100576
  const seen = /* @__PURE__ */ new Set();
@@ -100196,7 +100596,7 @@ var init_tfidf = __esm({
100196
100596
  embedSync(text) {
100197
100597
  if (this.vocab.length === 0)
100198
100598
  return [];
100199
- const tokens = tokenize5(text);
100599
+ const tokens = tokenize6(text);
100200
100600
  const tf = /* @__PURE__ */ new Map();
100201
100601
  for (const t of tokens) {
100202
100602
  const idx = this.vocabIndex.get(t);
@@ -100581,7 +100981,7 @@ async function rankAllFresh(all, corpus, query, limit, embedder) {
100581
100981
  return rankCosine(all, vectors.slice(0, all.length), queryVec, limit);
100582
100982
  }
100583
100983
  function rankByKeywords(all, query, limit) {
100584
- const tokens = tokenize5(query);
100984
+ const tokens = tokenize6(query);
100585
100985
  return all.map((entry) => ({ entry, score: scoreEntry(entry, tokens) })).filter((r) => r.score > 0).sort((a, b2) => b2.score - a.score).slice(0, limit);
100586
100986
  }
100587
100987
  function rankCosine(entries, vectors, query, limit) {
@@ -100641,7 +101041,7 @@ function scoreEntry(entry, tokens) {
100641
101041
  }
100642
101042
  return score;
100643
101043
  }
100644
- var init_search2 = __esm({
101044
+ var init_search3 = __esm({
100645
101045
  "../plugin-memory/dist/store/search.js"() {
100646
101046
  init_tfidf();
100647
101047
  }
@@ -100657,7 +101057,7 @@ var init_store6 = __esm({
100657
101057
  init_embedding_cache();
100658
101058
  init_types3();
100659
101059
  init_io();
100660
- init_search2();
101060
+ init_search3();
100661
101061
  init_types3();
100662
101062
  DEFAULT_MAX_MEMORIES = 500;
100663
101063
  MemoryStore = class {
@@ -101079,10 +101479,10 @@ function planConsolidation(entries, opts = {}) {
101079
101479
  }
101080
101480
  const descClusters = [];
101081
101481
  for (const entry of tagless) {
101082
- const tokens = new Set(tokenize6(entry.frontmatter.description).concat(tokenize6(entry.frontmatter.name)));
101482
+ const tokens = new Set(tokenize7(entry.frontmatter.description).concat(tokenize7(entry.frontmatter.name)));
101083
101483
  let placed = false;
101084
101484
  for (const cluster of descClusters) {
101085
- const clusterTokens = new Set(cluster.members.flatMap((m2) => tokenize6(m2.frontmatter.description)));
101485
+ const clusterTokens = new Set(cluster.members.flatMap((m2) => tokenize7(m2.frontmatter.description)));
101086
101486
  const overlap = [...tokens].filter((t) => clusterTokens.has(t)).length;
101087
101487
  if (overlap >= 2) {
101088
101488
  cluster.members.push(entry);
@@ -101116,7 +101516,7 @@ function planConsolidation(entries, opts = {}) {
101116
101516
  }
101117
101517
  return { clusters, stable };
101118
101518
  }
101119
- function tokenize6(text) {
101519
+ function tokenize7(text) {
101120
101520
  return text.toLowerCase().split(/[^a-z0-9_-]+/).filter((t) => t.length >= 3);
101121
101521
  }
101122
101522
  async function consolidateMemory(store, provider, opts = {}) {
@@ -101565,7 +101965,7 @@ function buildMemoryPlugin(opts = {}) {
101565
101965
  });
101566
101966
  return { plugin: plugin5, store };
101567
101967
  }
101568
- var init_dist38 = __esm({
101968
+ var init_dist39 = __esm({
101569
101969
  "../plugin-memory/dist/index.js"() {
101570
101970
  init_store6();
101571
101971
  init_tfidf();
@@ -101832,7 +102232,7 @@ function formatRelative(d) {
101832
102232
  var HELP6;
101833
102233
  var init_memory = __esm({
101834
102234
  async "src/commands/memory.ts"() {
101835
- init_dist38();
102235
+ init_dist39();
101836
102236
  await init_argv_helpers();
101837
102237
  init_errors();
101838
102238
  init_colors();
@@ -102813,7 +103213,7 @@ var HELP8;
102813
103213
  var init_doctor = __esm({
102814
103214
  async "src/commands/doctor.ts"() {
102815
103215
  init_dist2();
102816
- await init_dist27();
103216
+ await init_dist28();
102817
103217
  init_dist();
102818
103218
  await init_setup();
102819
103219
  init_close_session();
@@ -102934,7 +103334,7 @@ async function defaultConfirm(message) {
102934
103334
  var HELP9;
102935
103335
  var init_update2 = __esm({
102936
103336
  async "src/commands/update.ts"() {
102937
- init_dist37();
103337
+ init_dist38();
102938
103338
  await init_argv_helpers();
102939
103339
  init_errors();
102940
103340
  init_colors();
@@ -103193,9 +103593,9 @@ function formatAgo2(iso) {
103193
103593
  var HELP10, RESUME_HELP;
103194
103594
  var init_sessions = __esm({
103195
103595
  async "src/commands/sessions.ts"() {
103196
- init_dist37();
103596
+ init_dist38();
103197
103597
  init_dist2();
103198
- init_dist30();
103598
+ init_dist31();
103199
103599
  await init_argv_helpers();
103200
103600
  init_colors();
103201
103601
  init_help_format();
@@ -104070,7 +104470,7 @@ var skills_exports = {};
104070
104470
  __export(skills_exports, {
104071
104471
  groupSimilarPrompts: () => groupSimilarPrompts,
104072
104472
  runSkillsCommand: () => runSkillsCommand,
104073
- tokenize: () => tokenize7,
104473
+ tokenize: () => tokenize8,
104074
104474
  usedLabel: () => usedLabel
104075
104475
  });
104076
104476
  async function runSkillsCommand(argv) {
@@ -104250,7 +104650,7 @@ function groupSimilarPrompts(entries) {
104250
104650
  const groups = [];
104251
104651
  const groupTokenSets = [];
104252
104652
  for (const entry of entries) {
104253
- const tokens = tokenize7(entry.originatingPrompt);
104653
+ const tokens = tokenize8(entry.originatingPrompt);
104254
104654
  let placed = false;
104255
104655
  for (let i = 0; i < groups.length; i += 1) {
104256
104656
  const groupTokens = groupTokenSets[i];
@@ -104273,7 +104673,7 @@ function groupSimilarPrompts(entries) {
104273
104673
  function usedLabel(count) {
104274
104674
  return count && count > 0 ? String(count) : "-";
104275
104675
  }
104276
- function tokenize7(s) {
104676
+ function tokenize8(s) {
104277
104677
  return s.toLowerCase().split(/[^a-z0-9_-]+/).filter((t) => t.length >= 3);
104278
104678
  }
104279
104679
  function truncate8(s, n) {
@@ -104635,7 +105035,7 @@ Re-run with --yes to accept its capability surface, or enable it later with \`mo
104635
105035
  );
104636
105036
  return 0;
104637
105037
  }
104638
- const { confirm, isCancel } = await Promise.resolve().then(() => (init_dist37(), dist_exports4));
105038
+ const { confirm, isCancel } = await Promise.resolve().then(() => (init_dist38(), dist_exports4));
104639
105039
  const keep = await confirm({
104640
105040
  message: `${packageName} is third-party code. Keep it enabled with this capability surface?`,
104641
105041
  initialValue: false