@symerian/symi 3.5.5 → 3.5.6

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 (104) hide show
  1. package/dist/{agent-8EuVoCbs.js → agent-BCszhl_7.js} +1 -1
  2. package/dist/{agent-B87OYNFx.js → agent-Cmx-1Tfs.js} +1 -1
  3. package/dist/{agents-CNbjbSD0.js → agents-BkTzJJ83.js} +2 -2
  4. package/dist/{auth-choice-BL4lqaJL.js → auth-choice-CucG4Wor.js} +1 -1
  5. package/dist/{auth-choice-CB0rQByJ.js → auth-choice-D-iIJjJY.js} +1 -1
  6. package/dist/{banner-D-ssxnQN.js → banner-CApT91CY.js} +1 -1
  7. package/dist/build-info.json +3 -3
  8. package/dist/bundled/boot-md/handler.js +2 -2
  9. package/dist/bundled/session-memory/handler.js +2 -2
  10. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  11. package/dist/{channel-options-_DJXj921.js → channel-options-CdIEyHya.js} +1 -1
  12. package/dist/{channel-options-DLV6zIpW.js → channel-options-DYh8mLMN.js} +1 -1
  13. package/dist/{channels-cli-2OTAQPvZ.js → channels-cli-Bb18aE2b.js} +7 -7
  14. package/dist/{channels-cli-CUsX2v-1.js → channels-cli-sG9Wf2LH.js} +7 -7
  15. package/dist/{cli-Qq7pr2SX.js → cli-DEGt0Tp0.js} +4 -4
  16. package/dist/{cli-D4cMWhob.js → cli-DtdTf-ZQ.js} +4 -4
  17. package/dist/{command-registry-Br9vlIL_.js → command-registry-O155hUhR.js} +10 -10
  18. package/dist/{completion-cli-CKLoZFMQ.js → completion-cli-BaOjuoPX.js} +2 -2
  19. package/dist/{completion-cli-P5zBWNnc.js → completion-cli-DLUKoSIx.js} +1 -1
  20. package/dist/{config-cli-NvqRZAqr.js → config-cli-BuZ-L1Iw.js} +1 -1
  21. package/dist/{config-cli-CcJOubCt.js → config-cli-BxWavRxN.js} +1 -1
  22. package/dist/{configure-C7BfUqKR.js → configure-BSKWgEhS.js} +2 -2
  23. package/dist/{configure-B1RJ6bi3.js → configure-gxAEhC9E.js} +2 -2
  24. package/dist/{doctor-completion-Be3Of_A2.js → doctor-completion-BzfgfpBH.js} +1 -1
  25. package/dist/{doctor-completion-Dco2Lmvy.js → doctor-completion-wlBp8bv7.js} +1 -1
  26. package/dist/entry.js +1 -1
  27. package/dist/extensionAPI.js +2 -2
  28. package/dist/{gateway-cli-XV8T-ix8.js → gateway-cli-Bz5fqsnE.js} +10 -10
  29. package/dist/{gateway-cli-BQAh5DqM.js → gateway-cli-_xNZ2L_e.js} +10 -10
  30. package/dist/{glass-ui-ws-1FOCi0nn.js → glass-ui-ws-CbKVlQRh.js} +8 -8
  31. package/dist/{glass-ui-ws-CqGzDNV7.js → glass-ui-ws-DO8WKPIK.js} +8 -8
  32. package/dist/{hooks-cli-D7iTDry_.js → hooks-cli-CrgD2ZqP.js} +5 -5
  33. package/dist/{hooks-cli-BPa-ssdB.js → hooks-cli-mwiHuRfO.js} +5 -5
  34. package/dist/index.js +8 -8
  35. package/dist/llm-slug-generator.js +2 -2
  36. package/dist/{manager-DghM7T-b.js → manager-BVPXSK-I.js} +1 -1
  37. package/dist/{manager-Bt-1HGg9.js → manager-CnBU0aOR.js} +1 -1
  38. package/dist/{manager-Ck1YSfr6.js → manager-CpBJ1BE6.js} +1 -1
  39. package/dist/{manager-CC13EPO9.js → manager-CvqH_tah.js} +1 -1
  40. package/dist/{memory-CgWOtF4K.js → memory-BsGfHO_F.js} +2 -2
  41. package/dist/{memory-d0YI5Lr0.js → memory-CbwmxmxW.js} +2 -2
  42. package/dist/{memory-cli-DGheAg5i.js → memory-cli-B1dFPZw-.js} +2 -2
  43. package/dist/{memory-cli-vN3fGs79.js → memory-cli-BwQsPEFk.js} +2 -2
  44. package/dist/{models-CBw1pGIq.js → models-Dm6dSSSx.js} +2 -2
  45. package/dist/{models-cli-Bmh1S3iG.js → models-cli-BA6ufqLd.js} +5 -5
  46. package/dist/{models-cli-BBReZHNq.js → models-cli-BPSrz6tf.js} +6 -6
  47. package/dist/{onboard-Csj4sOF5.js → onboard-CjnPughY.js} +1 -1
  48. package/dist/{onboard-LVUmCZhX.js → onboard-Cmz6Rtm-.js} +1 -1
  49. package/dist/{onboard-channels-vDtX0e0w.js → onboard-channels-Cozz3CQv.js} +1 -1
  50. package/dist/{onboard-channels-mrSIlZDB.js → onboard-channels-D00NAtQt.js} +1 -1
  51. package/dist/{onboarding-DojADc8N.js → onboarding-BPZb40BJ.js} +3 -3
  52. package/dist/{onboarding-D2VmoKU1.js → onboarding-BrTMOcPF.js} +3 -3
  53. package/dist/{onboarding.finalize-C4BwVw6u.js → onboarding.finalize-Bd2rGMjo.js} +3 -3
  54. package/dist/{onboarding.finalize-Bi1wSEtw.js → onboarding.finalize-BiL_LXrR.js} +4 -4
  55. package/dist/{pi-embedded-zSv7VKNQ.js → pi-embedded-C9wLrFjj.js} +177 -69
  56. package/dist/{plugin-registry-L1h7mxjX.js → plugin-registry-BLoSesyj.js} +1 -1
  57. package/dist/{plugin-registry-Dq6OJ45H.js → plugin-registry-CZDG8fjK.js} +1 -1
  58. package/dist/plugin-sdk/auto-reply/reply/middleware-context-warning.d.ts +22 -0
  59. package/dist/plugin-sdk/auto-reply/session-boundary-messages.d.ts +16 -3
  60. package/dist/plugin-sdk/index.js +6 -6
  61. package/dist/{plugins-cli-C9ehLXaT.js → plugins-cli-2yraoR6V.js} +5 -5
  62. package/dist/{plugins-cli-BEIKMoVH.js → plugins-cli-CGs9-UtO.js} +5 -5
  63. package/dist/{program-iTd2Dei7.js → program-BnKEJpZF.js} +10 -10
  64. package/dist/{program-context-Bh5wzWdC.js → program-context-BvP9L_1W.js} +18 -18
  65. package/dist/{prompt-select-styled-CNFytCD3.js → prompt-select-styled-BTF5vvv8.js} +4 -4
  66. package/dist/{prompt-select-styled-fXotfbCt.js → prompt-select-styled-Brx330O3.js} +4 -4
  67. package/dist/{provider-auth-helpers-Dho1n21x.js → provider-auth-helpers-CppzYZM9.js} +1 -1
  68. package/dist/{provider-auth-helpers-DBrH-cce.js → provider-auth-helpers-hjy3e-oS.js} +1 -1
  69. package/dist/{push-apns-DpyCFRTu.js → push-apns-BD2iO09c.js} +1 -1
  70. package/dist/{push-apns-DYYY9NOE.js → push-apns-DJ55TFPT.js} +1 -1
  71. package/dist/{register.agent-BYpBNbHe.js → register.agent-DTGvQGla.js} +9 -9
  72. package/dist/{register.agent-DceNHGi_.js → register.agent-Dz_P7PxO.js} +8 -8
  73. package/dist/{register.configure-09lIIUvq.js → register.configure-CrgU3FzU.js} +8 -8
  74. package/dist/{register.configure-UUZqL0Ck.js → register.configure-D9w7Tm9e.js} +8 -8
  75. package/dist/{register.maintenance-DdX8GZpv.js → register.maintenance-CqvrXPF7.js} +9 -9
  76. package/dist/{register.maintenance-CsoEyVyl.js → register.maintenance-d5xHdDgu.js} +8 -8
  77. package/dist/{register.message-RYn7LD6-.js → register.message-C0tqgEor.js} +5 -5
  78. package/dist/{register.message-CAM62MaW.js → register.message-DNMCxaAD.js} +5 -5
  79. package/dist/{register.onboard-CoRtNlNa.js → register.onboard--eJVfJGa.js} +2 -2
  80. package/dist/{register.onboard-DhR5o8KO.js → register.onboard-dkAvGraV.js} +2 -2
  81. package/dist/{register.setup-CI_RT1Wa.js → register.setup-CgufX-6c.js} +2 -2
  82. package/dist/{register.setup-CEjhFwYz.js → register.setup-Dwh0ylCS.js} +2 -2
  83. package/dist/{register.status-health-sessions-DNlsQ-xt.js → register.status-health-sessions-BeAm7HAq.js} +3 -3
  84. package/dist/{register.status-health-sessions-8N1xEKl7.js → register.status-health-sessions-D6BRCFg_.js} +3 -3
  85. package/dist/{register.subclis-D1qkm3UK.js → register.subclis-Hb2xSHBy.js} +9 -9
  86. package/dist/{run-main-hKg6FDt6.js → run-main-B_NTFmz1.js} +17 -17
  87. package/dist/{server-methods-bIWvtXlT.js → server-methods-CFWjtx32.js} +7 -7
  88. package/dist/{server-methods-CXoipzKe.js → server-methods-Cz_-FX5B.js} +7 -7
  89. package/dist/{server-node-events-BD8wnswX.js → server-node-events-BiMD-Sik.js} +6 -6
  90. package/dist/{server-node-events-nQkNuQOx.js → server-node-events-UJ4Hwcsf.js} +6 -6
  91. package/dist/{status-CIZltjd7.js → status-BGUaaSHe.js} +1 -1
  92. package/dist/{status-Dgg3SlRY.js → status-Bp48-ySL.js} +1 -1
  93. package/dist/{status-CWzbgPAZ.js → status-CObdh7-H.js} +1 -1
  94. package/dist/{status-CTDVhXdb.js → status-FX0BMcCb.js} +1 -1
  95. package/dist/{subagent-registry-DQ_BPb-T.js → subagent-registry-ChDWDl_p.js} +177 -69
  96. package/dist/{synthesis-CSsmBmJc.js → synthesis-CmQvOHg6.js} +2 -2
  97. package/dist/{synthesis-XbEFEFK1.js → synthesis-DIkOQnhF.js} +2 -2
  98. package/dist/{synthesis-CDd1xqI3.js → synthesis-DdP6tbyk.js} +4 -4
  99. package/dist/{synthesis-DIqhHKjV.js → synthesis-m6WCyI41.js} +4 -4
  100. package/dist/{unified-runner-DN0asRIR.js → unified-runner-Cu3lGa3A.js} +177 -69
  101. package/dist/{unified-runner-Bm3r8UOg.js → unified-runner-DL-sfvGT.js} +178 -70
  102. package/dist/{update-cli-kysdsvn3.js → update-cli-DAKoU0Wn.js} +8 -8
  103. package/dist/{update-cli-CK7nw0t0.js → update-cli-gEBRNrm2.js} +9 -9
  104. package/package.json +1 -1
@@ -49,8 +49,8 @@ import { a as normalizeElevatedLevel, c as normalizeUsageDisplay, d as supportsX
49
49
  import { i as resolveApiKeyForProvider, n as getCustomProviderApiKey, o as resolveEnvApiKey, r as requireApiKey, s as resolveModelAuthMode, t as getApiKeyForModel } from "./model-auth-Byr7Gic_.js";
50
50
  import { b as OLLAMA_NATIVE_BASE_URL, c as normalizeGoogleModelId, t as ensureSymiModelsJson, x as createOllamaStreamFn } from "./models-config-CiR_RUxw.js";
51
51
  import { i as resolveAckReaction, o as resolveEffectiveMessagesConfig, r as resolveResponsePrefixTemplate, s as resolveHumanDelayConfig, t as createReplyPrefixOptions } from "./reply-prefix-DV3KhOhL.js";
52
- import { n as resolveMemoryBackendConfig, t as getMemorySearchManager } from "./memory-d0YI5Lr0.js";
53
- import { a as parseGeminiAuth, c as resolveMemorySearchConfig, n as retryAsync, o as collectProviderApiKeysForExecution, s as executeWithApiKeyRotation } from "./manager-DghM7T-b.js";
52
+ import { n as resolveMemoryBackendConfig, t as getMemorySearchManager } from "./memory-CbwmxmxW.js";
53
+ import { a as parseGeminiAuth, c as resolveMemorySearchConfig, n as retryAsync, o as collectProviderApiKeysForExecution, s as executeWithApiKeyRotation } from "./manager-BVPXSK-I.js";
54
54
  import { f as runTasksWithConcurrency } from "./internal-D3mEiuyB.js";
55
55
  import { a as chunkText, c as resolveChunkMode, d as isSafeFenceBreak, f as parseFenceSpans, i as chunkMarkdownTextWithMode, l as resolveTextChunkLimit, o as chunkTextWithMode, r as chunkMarkdownText, t as chunkByNewline, u as findFenceSpanAt } from "./chunk-B2lBXhR0.js";
56
56
  import { n as resolveMarkdownTableMode } from "./markdown-tables-BEdkErjm.js";
@@ -82,7 +82,7 @@ import { i as parseAbsoluteTimeMs, r as resolveDefaultCronStaggerMs, t as normal
82
82
  import { n as resolveMessageChannelSelection, t as listConfiguredMessageChannels } from "./channel-selection-BrFl0vVK.js";
83
83
  import { n as resolveAgentRoute, t as buildAgentSessionKey } from "./resolve-route-D0NrCHnr.js";
84
84
  import { t as parseTimeoutMs } from "./parse-timeout-DUdeaMqF.js";
85
- import { n as registerMemoryCli } from "./memory-cli-DGheAg5i.js";
85
+ import { n as registerMemoryCli } from "./memory-cli-B1dFPZw-.js";
86
86
  import { i as resolveSlackThreadTs, n as deliverReplies, t as createSlackReplyDeliveryPlan } from "./replies-_DV8VSSj.js";
87
87
  import { a as resolveSubagentToolPolicy, i as resolveGroupToolPolicy, n as isToolAllowedByPolicies, r as resolveEffectiveToolPolicy, t as filterToolsByPolicy } from "./pi-tools.policy-CU8U7--z.js";
88
88
  import { createRequire } from "node:module";
@@ -7647,13 +7647,21 @@ async function applyMediaUnderstanding(params) {
7647
7647
  * Soft warning appended when context usage crosses the threshold.
7648
7648
  * Fires once per session (tracked via `SessionEntry.contextWarningSent`).
7649
7649
  */
7650
- const SESSION_CONTEXT_WARNING_MESSAGE = "📋 Heads up — this session is approaching the context limit. Start a new session for best results. Past sessions stay in history and can be revisited there.";
7650
+ const SESSION_CONTEXT_WARNING_MESSAGE = "📋 Heads up — this session is approaching the context limit. Symi will compact older context automatically when usage reaches 90%.";
7651
7651
  /**
7652
- * Hard limit message returned when the model API rejects the turn for
7653
- * context-too-long or role-ordering reasons, and on every subsequent
7654
- * turn until the user starts a new session.
7652
+ * Inline status emitted by Symi before running compaction proactively
7653
+ * at the 90% threshold. Followed by the agent's actual response in the
7654
+ * same turn.
7655
7655
  */
7656
- const SESSION_OVERFLOW_MESSAGE = "📋 This session has reached the context limit. Please start a new session — your full conversation is saved in history and can be revisited there.";
7656
+ const SESSION_COMPACTING_MESSAGE = "📋 Context limit reached for this session. Compacting older context and continuing…";
7657
+ /**
7658
+ * Returned when compaction can't recover enough budget to continue —
7659
+ * either because the proactive compaction at 90% failed, or because a
7660
+ * single user message overshot the window in one turn and the reactive
7661
+ * fallback compaction also failed. Same message also short-circuits
7662
+ * subsequent turns until /reset or /new.
7663
+ */
7664
+ const SESSION_COMPACTION_FAILED_MESSAGE = "📋 Couldn't compact this session further. Please /reset or /new to continue — your full conversation is saved in history.";
7657
7665
 
7658
7666
  //#endregion
7659
7667
  //#region src/sessions/level-overrides.ts
@@ -28801,6 +28809,86 @@ async function handleInlineActions(params) {
28801
28809
  };
28802
28810
  }
28803
28811
 
28812
+ //#endregion
28813
+ //#region src/auto-reply/reply/middleware-context-warning.ts
28814
+ /** Threshold (fraction of context window) that triggers the soft warning. */
28815
+ const CONTEXT_WARNING_THRESHOLD = .85;
28816
+ /**
28817
+ * Threshold that triggers proactive compaction in `prepareReplyTurn`.
28818
+ * Higher than the soft warning so the user sees the heads-up first;
28819
+ * compaction runs the next turn the threshold is observed.
28820
+ */
28821
+ const CONTEXT_PROACTIVE_COMPACT_THRESHOLD = .9;
28822
+ /**
28823
+ * Pure decision for "should `prepareReplyTurn` run proactive compaction
28824
+ * before the next turn?" — extracted so the trigger logic is unit-testable
28825
+ * without mocking the rest of the prep pipeline.
28826
+ *
28827
+ * Returns true ONLY when:
28828
+ * - we have a session id (otherwise compaction has no target),
28829
+ * - we have a positive context window,
28830
+ * - we have a positive cumulative usage from the previous turn,
28831
+ * - usage / window ≥ CONTEXT_PROACTIVE_COMPACT_THRESHOLD.
28832
+ */
28833
+ function shouldProactivelyCompact(args) {
28834
+ if (!args.sessionId) return false;
28835
+ if (!args.contextTokens || args.contextTokens <= 0) return false;
28836
+ const usage = args.totalTokens ?? 0;
28837
+ if (usage <= 0) return false;
28838
+ return usage / args.contextTokens >= CONTEXT_PROACTIVE_COMPACT_THRESHOLD;
28839
+ }
28840
+ /**
28841
+ * Read the model's context-window size, falling back to the global
28842
+ * default when the model isn't in the registry yet.
28843
+ */
28844
+ function resolveContextWindow(modelId) {
28845
+ const fromRegistry = lookupContextTokens(modelId);
28846
+ if (fromRegistry && fromRegistry > 0) return fromRegistry;
28847
+ return DEFAULT_CONTEXT_TOKENS;
28848
+ }
28849
+ /**
28850
+ * After-turn hook that surfaces a one-time soft warning when usage
28851
+ * crosses the context threshold. Mutates the result text to append
28852
+ * the warning when triggered, and persists `contextWarningSent: true`
28853
+ * on the session entry so the warning doesn't fire again.
28854
+ */
28855
+ function withContextUsageWarning() {
28856
+ return (next) => async (params) => {
28857
+ const result = await next(params);
28858
+ if (result.outbound.action === "drop") return result;
28859
+ if (!params.sessionKey) return result;
28860
+ const usage = result.rawResult.meta.agentMeta?.usage?.total ?? 0;
28861
+ if (usage <= 0) return result;
28862
+ if (usage / resolveContextWindow(params.modelId ?? result.modelId) < CONTEXT_WARNING_THRESHOLD) return result;
28863
+ const agentId = resolveAgentIdFromSessionKey(params.sessionKey);
28864
+ const storePath = resolveStorePath(params.config.session?.store, { agentId });
28865
+ let alreadyWarned = false;
28866
+ try {
28867
+ await updateSessionStoreEntry({
28868
+ storePath,
28869
+ sessionKey: params.sessionKey,
28870
+ update: async (entry) => {
28871
+ if (entry.contextWarningSent === true) {
28872
+ alreadyWarned = true;
28873
+ return null;
28874
+ }
28875
+ return { contextWarningSent: true };
28876
+ }
28877
+ });
28878
+ } catch (err) {
28879
+ logVerbose(`context-warning: failed to persist contextWarningSent flag for ${params.sessionKey}: ${String(err)}`);
28880
+ return result;
28881
+ }
28882
+ if (alreadyWarned) return result;
28883
+ const trimmedText = result.text.trimEnd();
28884
+ const separator = trimmedText ? "\n\n" : "";
28885
+ return {
28886
+ ...result,
28887
+ text: `${trimmedText}${separator}${SESSION_CONTEXT_WARNING_MESSAGE}`
28888
+ };
28889
+ };
28890
+ }
28891
+
28804
28892
  //#endregion
28805
28893
  //#region src/auto-reply/reply/session-reset-model.ts
28806
28894
  function splitBody(body) {
@@ -29697,7 +29785,7 @@ async function prepareReplyTurn(ctx, opts, configOverride) {
29697
29785
  typing.cleanup();
29698
29786
  return {
29699
29787
  kind: "early-reply",
29700
- reply: { text: SESSION_OVERFLOW_MESSAGE }
29788
+ reply: { text: SESSION_COMPACTION_FAILED_MESSAGE }
29701
29789
  };
29702
29790
  }
29703
29791
  await applyResetModelOverride({
@@ -29810,6 +29898,82 @@ async function prepareReplyTurn(ctx, opts, configOverride) {
29810
29898
  };
29811
29899
  directives = inlineActionResult.directives;
29812
29900
  abortedLastRun = inlineActionResult.abortedLastRun ?? abortedLastRun;
29901
+ if (shouldProactivelyCompact({
29902
+ totalTokens: sessionEntry.totalTokens,
29903
+ contextTokens,
29904
+ sessionId: sessionEntry.sessionId
29905
+ })) {
29906
+ if (resolvedOpts?.onBlockReply) try {
29907
+ await resolvedOpts.onBlockReply({ text: SESSION_COMPACTING_MESSAGE });
29908
+ } catch (err) {
29909
+ logVerbose(`proactive-compact: inline status delivery failed: ${String(err)}`);
29910
+ }
29911
+ if (isEmbeddedPiRunActive(sessionEntry.sessionId)) {
29912
+ abortEmbeddedPiRun(sessionEntry.sessionId);
29913
+ await waitForEmbeddedPiRunEnd(sessionEntry.sessionId, 15e3);
29914
+ }
29915
+ let compactResult;
29916
+ try {
29917
+ compactResult = await compactEmbeddedPiSession({
29918
+ sessionId: sessionEntry.sessionId,
29919
+ sessionKey,
29920
+ messageChannel: command.channel,
29921
+ groupId: sessionEntry.groupId,
29922
+ groupChannel: sessionEntry.groupChannel,
29923
+ groupSpace: sessionEntry.space,
29924
+ spawnedBy: sessionEntry.spawnedBy,
29925
+ sessionFile: resolveSessionFilePath(sessionEntry.sessionId, sessionEntry, resolveSessionFilePathOptions({
29926
+ agentId,
29927
+ storePath
29928
+ })),
29929
+ workspaceDir,
29930
+ agentDir,
29931
+ config: cfg,
29932
+ skillsSnapshot: sessionEntry.skillsSnapshot,
29933
+ provider,
29934
+ model,
29935
+ thinkLevel: resolvedThinkLevel,
29936
+ reasoningLevel: resolvedReasoningLevel,
29937
+ trigger: "overflow",
29938
+ senderIsOwner: command.senderIsOwner,
29939
+ ownerNumbers: command.ownerList.length > 0 ? command.ownerList : void 0
29940
+ });
29941
+ } catch (err) {
29942
+ logVerbose(`proactive-compact: compactor threw for ${sessionKey}: ${String(err)}`);
29943
+ compactResult = {
29944
+ ok: false,
29945
+ compacted: false,
29946
+ reason: String(err)
29947
+ };
29948
+ }
29949
+ if (compactResult.ok && compactResult.compacted) await incrementCompactionCount({
29950
+ sessionEntry,
29951
+ sessionStore,
29952
+ sessionKey,
29953
+ storePath,
29954
+ tokensAfter: compactResult.result?.tokensAfter
29955
+ });
29956
+ else {
29957
+ logVerbose(`proactive-compact: failed for ${sessionKey} (${compactResult.reason ?? "unknown"})`);
29958
+ if (storePath) try {
29959
+ await updateSessionStoreEntry({
29960
+ storePath,
29961
+ sessionKey,
29962
+ update: async (entry) => {
29963
+ if (entry.endedReason === "context_overflow") return null;
29964
+ return { endedReason: "context_overflow" };
29965
+ }
29966
+ });
29967
+ } catch (err) {
29968
+ logVerbose(`proactive-compact: failed to mark session sealed: ${String(err)}`);
29969
+ }
29970
+ typing.cleanup();
29971
+ return {
29972
+ kind: "early-reply",
29973
+ reply: { text: SESSION_COMPACTION_FAILED_MESSAGE }
29974
+ };
29975
+ }
29976
+ }
29813
29977
  await stageSandboxMedia({
29814
29978
  ctx,
29815
29979
  sessionCtx,
@@ -39123,7 +39287,7 @@ async function runEmbeddedPiAgent(params) {
39123
39287
  error: err
39124
39288
  });
39125
39289
  }
39126
- const MAX_OVERFLOW_COMPACTION_ATTEMPTS = 3;
39290
+ const MAX_OVERFLOW_COMPACTION_ATTEMPTS = 1;
39127
39291
  const MAX_RUN_LOOP_ITERATIONS = resolveMaxRunRetryIterations(profileCandidates.length);
39128
39292
  let overflowCompactionAttempts = 0;
39129
39293
  let toolResultTruncationAttempted = false;
@@ -40146,8 +40310,8 @@ function extractErrorMessage(err) {
40146
40310
  function buildBoundaryResult(params) {
40147
40311
  const profile = resolveModelProfile(params.provider && params.modelId ? `${params.provider}/${params.modelId}` : "", params.config.models?.profiles);
40148
40312
  return {
40149
- text: SESSION_OVERFLOW_MESSAGE,
40150
- rawText: SESSION_OVERFLOW_MESSAGE,
40313
+ text: SESSION_COMPACTION_FAILED_MESSAGE,
40314
+ rawText: SESSION_COMPACTION_FAILED_MESSAGE,
40151
40315
  outbound: {
40152
40316
  action: "deliver",
40153
40317
  reason: "deliver"
@@ -40158,7 +40322,7 @@ function buildBoundaryResult(params) {
40158
40322
  profile,
40159
40323
  didSendViaMessagingTool: false,
40160
40324
  rawResult: {
40161
- payloads: [{ text: SESSION_OVERFLOW_MESSAGE }],
40325
+ payloads: [{ text: SESSION_COMPACTION_FAILED_MESSAGE }],
40162
40326
  meta: {
40163
40327
  durationMs: Date.now() - params.startTime,
40164
40328
  agentMeta: {
@@ -40217,62 +40381,6 @@ function withContextOverflowRecovery() {
40217
40381
  };
40218
40382
  }
40219
40383
 
40220
- //#endregion
40221
- //#region src/auto-reply/reply/middleware-context-warning.ts
40222
- /** Threshold (fraction of context window) that triggers the soft warning. */
40223
- const CONTEXT_WARNING_THRESHOLD = .85;
40224
- /**
40225
- * Read the model's context-window size, falling back to the global
40226
- * default when the model isn't in the registry yet.
40227
- */
40228
- function resolveContextWindow(modelId) {
40229
- const fromRegistry = lookupContextTokens(modelId);
40230
- if (fromRegistry && fromRegistry > 0) return fromRegistry;
40231
- return DEFAULT_CONTEXT_TOKENS;
40232
- }
40233
- /**
40234
- * After-turn hook that surfaces a one-time soft warning when usage
40235
- * crosses the context threshold. Mutates the result text to append
40236
- * the warning when triggered, and persists `contextWarningSent: true`
40237
- * on the session entry so the warning doesn't fire again.
40238
- */
40239
- function withContextUsageWarning() {
40240
- return (next) => async (params) => {
40241
- const result = await next(params);
40242
- if (result.outbound.action === "drop") return result;
40243
- if (!params.sessionKey) return result;
40244
- const usage = result.rawResult.meta.agentMeta?.usage?.total ?? 0;
40245
- if (usage <= 0) return result;
40246
- if (usage / resolveContextWindow(params.modelId ?? result.modelId) < CONTEXT_WARNING_THRESHOLD) return result;
40247
- const agentId = resolveAgentIdFromSessionKey(params.sessionKey);
40248
- const storePath = resolveStorePath(params.config.session?.store, { agentId });
40249
- let alreadyWarned = false;
40250
- try {
40251
- await updateSessionStoreEntry({
40252
- storePath,
40253
- sessionKey: params.sessionKey,
40254
- update: async (entry) => {
40255
- if (entry.contextWarningSent === true) {
40256
- alreadyWarned = true;
40257
- return null;
40258
- }
40259
- return { contextWarningSent: true };
40260
- }
40261
- });
40262
- } catch (err) {
40263
- logVerbose(`context-warning: failed to persist contextWarningSent flag for ${params.sessionKey}: ${String(err)}`);
40264
- return result;
40265
- }
40266
- if (alreadyWarned) return result;
40267
- const trimmedText = result.text.trimEnd();
40268
- const separator = trimmedText ? "\n\n" : "";
40269
- return {
40270
- ...result,
40271
- text: `${trimmedText}${separator}${SESSION_CONTEXT_WARNING_MESSAGE}`
40272
- };
40273
- };
40274
- }
40275
-
40276
40384
  //#endregion
40277
40385
  //#region src/auto-reply/reply/middleware-diagnostic-logging.ts
40278
40386
  function deriveChannel(ctx) {
@@ -3,7 +3,7 @@ import "./registry-C-JddWwo.js";
3
3
  import "./agent-scope-B1Ina6jV.js";
4
4
  import { t as createSubsystemLogger } from "./subsystem-DzRUKS9f.js";
5
5
  import "./workspace-CsaDUuDn.js";
6
- import { t as runAgentTurn } from "./unified-runner-DN0asRIR.js";
6
+ import { t as runAgentTurn } from "./unified-runner-Cu3lGa3A.js";
7
7
  import "./auth-profiles-BSw0aQND.js";
8
8
  import "./model-selection-BqshlIZc.js";
9
9
  import "./deliver-BiWlR84Y.js";
@@ -25,7 +25,7 @@ import "./paths-BsT3BvfH.js";
25
25
  import "./tokens-D_vCJSzF.js";
26
26
  import "./diagnostic-BALvP9wI.js";
27
27
  import "./diagnostic-session-state-BDfanaOY.js";
28
- import "./manager-Ck1YSfr6.js";
28
+ import "./manager-CpBJ1BE6.js";
29
29
  import "./github-copilot-token-uhEBNQfj.js";
30
30
  import "./pi-auth-json-DCGR3yfh.js";
31
31
  import "./reply-prefix-D0NzzC4I.js";
@@ -6,7 +6,7 @@ import "./model-selection-BisYvTBb.js";
6
6
  import "./reply-prefix-i-FPYcoQ.js";
7
7
  import "./plugins-CZ_mYwXq.js";
8
8
  import "./replies-0nzkXt6o.js";
9
- import { n as runAgentTurn } from "./pi-embedded-zSv7VKNQ.js";
9
+ import { n as runAgentTurn } from "./pi-embedded-C9wLrFjj.js";
10
10
  import "./deliver-f3cIWxXT.js";
11
11
  import "./diagnostic-BdRnGknC.js";
12
12
  import "./diagnostic-session-state-DpxCUzoM.js";
@@ -23,7 +23,7 @@ import "./errors-BEU7IHU6.js";
23
23
  import "./tokens-yWO1wD7Z.js";
24
24
  import "./thinking-DgjGxdSP.js";
25
25
  import "./paths-BsT3BvfH.js";
26
- import "./manager-Bt-1HGg9.js";
26
+ import "./manager-CnBU0aOR.js";
27
27
  import "./github-copilot-token-dYUr1mDQ.js";
28
28
  import "./sqlite-D8iYC_CU.js";
29
29
  import "./markdown-tables-jQzXAsf3.js";
@@ -1,4 +1,4 @@
1
- import { t as runAgentTurn } from "./unified-runner-Bm3r8UOg.js";
1
+ import { t as runAgentTurn } from "./unified-runner-DL-sfvGT.js";
2
2
  import "./registry-Sbac4a4z.js";
3
3
  import "./paths-By0XjHBk.js";
4
4
  import "./utils-CTPsqyE_.js";
@@ -50,8 +50,8 @@ import "./session-cost-usage-D3mgssM_.js";
50
50
  import "./session-utils-Cs1jlD-q.js";
51
51
  import "./with-timeout-GbJ1Yzsh.js";
52
52
  import "./reply-prefix-BFNeXT65.js";
53
- import "./memory-CgWOtF4K.js";
54
- import "./manager-CC13EPO9.js";
53
+ import "./memory-BsGfHO_F.js";
54
+ import "./manager-CvqH_tah.js";
55
55
  import "./sqlite-Cod7C5ba.js";
56
56
  import "./chunk-BxfKjCUx.js";
57
57
  import "./markdown-tables-CS1Tvb3z.js";
@@ -82,7 +82,7 @@ import "./links-CQZxjjCO.js";
82
82
  import "./cli-utils-CbnnSB38.js";
83
83
  import "./help-format-8IYCRvx1.js";
84
84
  import "./progress-DQTvTiEg.js";
85
- import "./memory-cli-vN3fGs79.js";
85
+ import "./memory-cli-BwQsPEFk.js";
86
86
  import "./logging-CLWZ3KQI.js";
87
87
  import "./replies-C5CBlnFS.js";
88
88
  import "./pi-tools.policy-WaLKhqJQ.js";
@@ -17,7 +17,7 @@ import "./client-DhdWcgZP.js";
17
17
  import "./call-ogggp9QZ.js";
18
18
  import "./message-channel-DXToSaWK.js";
19
19
  import "./pairing-token-B-OTYROz.js";
20
- import { T as runAgentTurn } from "./subagent-registry-DQ_BPb-T.js";
20
+ import { T as runAgentTurn } from "./subagent-registry-ChDWDl_p.js";
21
21
  import "./sessions-Dn6VXn4p.js";
22
22
  import "./plugins-BsEhWvLn.js";
23
23
  import "./send-Dq252-bi.js";
@@ -47,8 +47,8 @@ import "./model-auth-Byr7Gic_.js";
47
47
  import "./github-copilot-token-B5y4__YM.js";
48
48
  import "./models-config-CiR_RUxw.js";
49
49
  import "./reply-prefix-DV3KhOhL.js";
50
- import "./memory-d0YI5Lr0.js";
51
- import "./manager-DghM7T-b.js";
50
+ import "./memory-CbwmxmxW.js";
51
+ import "./manager-BVPXSK-I.js";
52
52
  import "./sqlite-9jF_eajd.js";
53
53
  import "./chunk-B2lBXhR0.js";
54
54
  import "./markdown-tables-BEdkErjm.js";
@@ -79,7 +79,7 @@ import "./links-B9CbwY46.js";
79
79
  import "./cli-utils-Ca0KE-dW.js";
80
80
  import "./help-format-BTNd5kFC.js";
81
81
  import "./progress-BOQ0hkeM.js";
82
- import "./memory-cli-DGheAg5i.js";
82
+ import "./memory-cli-B1dFPZw-.js";
83
83
  import "./logging-uD67RPtO.js";
84
84
  import "./replies-_DV8VSSj.js";
85
85
  import "./pi-tools.policy-CU8U7--z.js";