@code-yeongyu/senpi 2026.8.31 → 2026.9.2-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -2
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.js +6 -2
- package/dist/core/extensions/builtin/claude-sdk-oauth/options.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js +2 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/stream.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts +6 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-pipeline.js +11 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/extension-wiring.js +1 -1
- package/dist/core/extensions/builtin/compaction/extension-wiring.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +4 -4
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js +110 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5-1.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +7 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts +50 -0
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js +66 -0
- package/dist/core/extensions/builtin/prompt-preset/execution-tooling.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts +5 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +6 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +11 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +11 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js +18 -1
- package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
- package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.d.ts +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.js +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +17 -8
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js +1 -0
- package/dist/core/retry-fallback/settings.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -3
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/main.d.ts +4 -4
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +10 -6
- package/dist/main.js.map +1 -1
- package/dist/modes/app-server/daemon/process.d.ts +13 -2
- package/dist/modes/app-server/daemon/process.d.ts.map +1 -1
- package/dist/modes/app-server/daemon/process.js +58 -12
- package/dist/modes/app-server/daemon/process.js.map +1 -1
- package/dist/modes/app-server/daemon.js +62 -4
- package/dist/modes/app-server/daemon.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +35 -6
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.js +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +8 -3
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/custom-capability.d.ts +1 -0
- package/dist/modes/rpc/custom-capability.d.ts.map +1 -1
- package/dist/modes/rpc/custom-capability.js +1 -0
- package/dist/modes/rpc/custom-capability.js.map +1 -1
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
- package/dist/modes/rpc/host-ensure.js +93 -17
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts +15 -0
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +180 -55
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/host-watchdog.d.ts +2 -2
- package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
- package/dist/modes/rpc/host-watchdog.js +89 -21
- package/dist/modes/rpc/host-watchdog.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +94 -56
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +8 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +7 -2
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/socket-transport.d.ts +13 -0
- package/dist/modes/rpc/socket-transport.d.ts.map +1 -0
- package/dist/modes/rpc/socket-transport.js +92 -0
- package/dist/modes/rpc/socket-transport.js.map +1 -0
- package/docs/extensions.md +1 -1
- package/docs/rpc.md +5 -1
- package/docs/settings.md +8 -8
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +45 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +4 -2
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/skill-contribution.ts +43 -9
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +4 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +10 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/SKILL.md +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/skill/bun-1-4/references/runtime-apis.md +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +3 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +3 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +2 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opengateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry-profile/profiles.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAExG,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EACN,6BAA6B,EAC7B,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,yCAAyC,EACzC,gCAAgC,GAChC,MA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C,CAAC;gBACvE,CAAC;gBACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;aACtD,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5B,WAAW,CAAC,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,yDAAyD;IACzD,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC9B,wBAAwB,GAAG,KAAK,CAAC;QACjC,qBAAqB,EAAE,CAAC;QACxB,iBAAiB,GAAG,CAAC,CAAC;QACtB,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;QACnC,cAAc,GAAG,SAAS,CAAC;IAC5B,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Tool } from \"@earendil-works/pi-ai\";\nimport type { CompactionResult } from \"../../../compaction/index.ts\";\nimport { createWarmAnchorSnapshot, isWarmSummaryAnchorValid } from \"../../../compaction/warm-anchor.ts\";\nimport type { ExtensionAPI, ExtensionContext, SessionBeforeCompactEvent, SessionCompactEvent } from \"../../types.ts\";\nimport * as checkpointState from \"./checkpoint-state.ts\";\nimport * as breaker from \"./circuit-breaker.ts\";\nimport { buildCompactionContext } from \"./context-pipeline.ts\";\nimport {\n\tcreateDegradationMonitorState,\n\thandleMessageEnd,\n\thandleTurnEnd,\n\tRECOVERY_INSTRUCTIONS,\n\tresetOnSessionCompact,\n} from \"./degradation-monitor.ts\";\nimport {\n\tclassifyRequiredCompactionFallbackFailure,\n\tcreateRequiredCompactionFallback,\n} from \"./deterministic-fallback.ts\";\nimport * as idle from \"./idle.ts\";\nimport * as idleRetry from \"./idle-retry.ts\";\nimport {\n\tCLAUDE_SDK_OAUTH_COMPACT_ENTRY_TYPE,\n\tcollectCompactBoundaryEntries,\n\tcreateCompactionLanePolicy,\n\tSDK_NATIVE_LANE_REJECTION_REASON,\n} from \"./lane-policy.ts\";\nimport { type CompactionLogger, createCompactionLogger } from \"./log.ts\";\nimport { handleCompactionModelSelect } from \"./model-selection.ts\";\nimport {\n\ttype OpenAiRemoteCompactionDependencies,\n\trewriteOpenAiPayloadWithRemoteCompaction,\n\trunOpenAiRemoteCompaction,\n\tSENPI_COMPACTION_EVENT,\n} from \"./openai-remote.ts\";\nimport {\n\tcreateOpenAiRemoteCompactionHeaders,\n\tisOpenAiRemoteCompactionModel,\n\topenAiRemoteCompactionOrigin,\n} from \"./openai-remote-model.ts\";\nimport {\n\tresolveBeforeAgentStartMessage,\n\tresolveCompactionGeometry,\n\tresolveIdleWarmAction,\n\tresolveReminderSystemPrompt,\n\tshouldDeferGraceBand,\n} from \"./orchestration.ts\";\nimport * as cap from \"./per-turn-cap.ts\";\nimport * as policy from \"./policy.ts\";\nimport * as restoration from \"./restoration-tracker.ts\";\nimport {\n\tapplyGeneratedCompaction,\n\tcreateEmergencyPruneLatch,\n\tcreateSpeculativeCompactionSnapshot,\n\tgetPromptVariant,\n\trunExtensionCompaction,\n\ttype SpeculativeCompactionResult,\n\ttype SpeculativeCompactionSnapshot,\n\tSummaryGenerationError,\n} from \"./speculative.ts\";\nimport { type SpeculativeJob, trackSpeculativeJob } from \"./speculative-job.ts\";\nimport { type CompactionExtensionState, createInitialState, resetTurnCounter } from \"./state.ts\";\nimport { resolveInheritedTaskIntent } from \"./task-intent.ts\";\nimport * as todoBridge from \"./todo-bridge.ts\";\nimport {\n\tcomputeTokenBudgetReminder,\n\tcreateInitialReminderState,\n\ttype TokenBudgetReminderState,\n} from \"./token-budget-reminder.ts\";\nimport { isTransientSummarizationFailure } from \"./transient-failure.ts\";\n\nexport { getPromptContextWindow } from \"./extension-wiring.ts\";\n\nimport {\n\tcreateBlockingRemoteCompactionEvent,\n\tendCompactionFeedback,\n\testimatePendingPromptTokens,\n\tgetPromptContextWindow,\n\tisAbortedAssistantMessage,\n\tisMonitorableMessageEvent,\n\tisRequiredCompactionFallbackReason,\n\tlinkAbortSignal,\n\trecentCheckpoint,\n\twithAdditionalTokens,\n} from \"./extension-wiring.ts\";\nimport { isIneffectiveCompaction } from \"./yield.ts\";\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\nconst EMERGENCY_COMPACTION_INSTRUCTIONS =\n\t\"EMERGENCY: hard context limit reached. Produce an aggressive recovery summary that preserves current goal, constraints, files touched, tool outcomes, and exact next steps. Prefer concise factual state over transcript detail.\";\nconst PROACTIVE_COMPACTION_INSTRUCTIONS = \"Proactively compact before the next agent turn.\";\nconst MAX_PENDING_METADATA = 8;\n\ninterface PendingCompactionMetadata {\n\tcheckpoint: checkpointState.AgentCheckpoint;\n\ttodoSnapshot: todoBridge.TodoSnapshotPayload;\n}\n\nexport default function compactionExtension(\n\tpi: ExtensionAPI,\n\tremoteCompactionDependencies: OpenAiRemoteCompactionDependencies = {},\n): void {\n\tlet state: CompactionExtensionState = createInitialState();\n\tconst lanePolicy = createCompactionLanePolicy();\n\tconst restorationDirectiveState = checkpointState.createRestorationDirectiveState();\n\tconst emergencyPruneLatch = createEmergencyPruneLatch();\n\tconst degradationState = createDegradationMonitorState();\n\tconst restorationState = state.restoration ?? restoration.createRestorationTrackerState();\n\tstate = { ...state, restoration: restorationState };\n\tlet speculativeGeneration = 0;\n\tlet reminderState: TokenBudgetReminderState = createInitialReminderState();\n\tlet speculativeJob: SpeculativeJob | undefined;\n\tconst pendingMetadata = new Map<string, PendingCompactionMetadata>();\n\tlet logger: CompactionLogger | undefined;\n\tconst getLogger = (ctx: ExtensionContext): CompactionLogger => (logger ??= createCompactionLogger(ctx.agentDir));\n\n\tfunction getSummarizationTools(): Tool[] {\n\t\tif (typeof pi.getAllTools !== \"function\" || typeof pi.getActiveTools !== \"function\") return [];\n\t\ttry {\n\t\t\tconst definitionsByName = new Map(pi.getAllTools().map((tool) => [tool.name, tool]));\n\t\t\treturn pi.getActiveTools().flatMap((name) => {\n\t\t\t\tconst tool = definitionsByName.get(name);\n\t\t\t\treturn tool ? [{ name: tool.name, description: tool.description, parameters: tool.parameters }] : [];\n\t\t\t});\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tlet idleWarmupTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet idleWarmupAttempt = 0;\n\t// True from the `agent_end` idle trigger until the next turn starts (or the\n\t// session shuts down). The idle-apply watcher below is fenced on it so a\n\t// summary that lands after the user has already prompted is never applied\n\t// out from under the turn that is starting; the warm-consume path in\n\t// `before_agent_start` owns the job from that point on.\n\tlet sessionIdleSinceAgentEnd = false;\n\n\tfunction cancelIdleWarmupRetry(): void {\n\t\tif (idleWarmupTimer === undefined) return;\n\t\tclearTimeout(idleWarmupTimer);\n\t\tidleWarmupTimer = undefined;\n\t}\n\n\t// A session reload retires this extension generation while the warm-up\n\t// watcher below is still armed: `AgentSession.reload()` invalidates the old\n\t// runner, after which every `ExtensionContext` getter throws\n\t// \"stale extension generation after reload\". The watcher outlives that\n\t// invalidation in two places — the `job.failure` continuation and the armed\n\t// retry timer — and neither had a caller left to receive the throw: the\n\t// continuation is spawned with `void` (unhandled rejection) and the timer\n\t// callback throws straight into the timer queue, which terminates the\n\t// process. The context carries no liveness flag, so a retired generation is\n\t// only observable by reading a getter and catching the assertion.\n\tfunction isContextRetired(ctx: ExtensionContext): boolean {\n\t\ttry {\n\t\t\tctx.isIdle();\n\t\t\treturn false;\n\t\t} catch {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Fenced on the observed job: a prompt, invalidation, a reload, or a newer\n\t// warm-up stands this watcher down before it can start a duplicate\n\t// summarization.\n\tfunction armIdleWarmupRetry(ctx: ExtensionContext): void {\n\t\tconst job = speculativeJob;\n\t\tif (!job) return;\n\t\tvoid job.failure.then((failure) => {\n\t\t\tif (failure === undefined) {\n\t\t\t\tidleWarmupAttempt = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (speculativeJob !== job) return;\n\t\t\t// A reload between arming and this continuation retires the context.\n\t\t\tif (isContextRetired(ctx)) {\n\t\t\t\tcancelIdleWarmupRetry();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst usage = ctx.getContextUsage();\n\t\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\t\tconst settings = ctx.getCompactionSettings();\n\t\t\tconst breakerTripped = breaker.isTripped(state, Date.now());\n\t\t\tconst retryDecision: idleRetry.IdleWarmupRetryDecision = {\n\t\t\t\tattempt: idleWarmupAttempt,\n\t\t\t\ttransient: isTransientSummarizationFailure(failure, failure.message),\n\t\t\t\tisIdle: ctx.isIdle(),\n\t\t\t\tbreakerTripped,\n\t\t\t\tstillWarmEligible: idle.shouldWarmAtIdle({\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\taborted: false,\n\t\t\t\t\tsettings,\n\t\t\t\t\tusage,\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\tbreakerTripped,\n\t\t\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t\t\t\tmode: ctx.mode,\n\t\t\t\t}),\n\t\t\t};\n\t\t\tif (!idleRetry.shouldRetryIdleWarmup(retryDecision)) return;\n\t\t\tcancelIdleWarmupRetry();\n\t\t\tidleWarmupTimer = setTimeout(() => {\n\t\t\t\tidleWarmupTimer = undefined;\n\t\t\t\tif (speculativeJob !== job) return;\n\t\t\t\t// The reload may land after the timer was armed; a throw here would\n\t\t\t\t// escape into the timer queue as an uncaughtException.\n\t\t\t\tif (isContextRetired(ctx)) return;\n\t\t\t\tif (!ctx.isIdle()) return;\n\t\t\t\tidleWarmupAttempt += 1;\n\t\t\t\tgetLogger(ctx).debug(\"idle_trigger\", {\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\ttokens: usage?.tokens ?? 0,\n\t\t\t\t\tcount: idleWarmupAttempt,\n\t\t\t\t});\n\t\t\t\tinvalidateSpeculativeCompaction(ctx);\n\t\t\t\tstartSpeculativeCompaction(ctx, idle.IDLE_COMPACTION_INSTRUCTIONS);\n\t\t\t\tarmIdleWarmupRetry(ctx);\n\t\t\t\tarmIdleApply(ctx);\n\t\t\t}, idleRetry.IDLE_WARMUP_RETRY_DELAY_MS);\n\t\t});\n\t}\n\n\t/**\n\t * Apply the idle warm summary as soon as it finishes generating, while the\n\t * session is still idle. Holding it warm until the next `before_agent_start`\n\t * makes the user watch their own prompt wait behind a compaction they could\n\t * not see coming; applying during the idle gap renders the [compaction] block\n\t * first and lets the next message stack below it.\n\t *\n\t * Every guard is re-read at continuation time, because generation takes long\n\t * enough for all of them to change: the session may no longer be idle, the\n\t * job may have been invalidated or claimed, the context may have dropped\n\t * below the threshold, the lane may have been handed to the SDK, or the\n\t * breaker may have tripped. A refused apply (stale anchor/revision) silently\n\t * keeps the warm hold, so the next prompt consumes it exactly as before.\n\t */\n\tfunction armIdleApply(ctx: ExtensionContext): void {\n\t\tconst job = speculativeJob;\n\t\tif (!job) return;\n\t\t// Never throws out of the continuation: a retired context, a refused apply,\n\t\t// or a provider failure all resolve into a silent stand-down.\n\t\tvoid job.promise\n\t\t\t.then(async (compaction) => {\n\t\t\t\tif (!compaction) return;\n\t\t\t\tif (speculativeJob !== job) return;\n\t\t\t\tif (!sessionIdleSinceAgentEnd) return;\n\t\t\t\tif (isContextRetired(ctx)) return;\n\t\t\t\tif (!ctx.isIdle()) return;\n\t\t\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) return;\n\t\t\t\tif (breaker.isTripped(state, Date.now())) return;\n\t\t\t\tif (cap.shouldRejectByCap(state).cancel) return;\n\t\t\t\tconst usage = ctx.getContextUsage();\n\t\t\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\t\t\tif (\n\t\t\t\t\t!usage ||\n\t\t\t\t\t!policy.shouldTriggerCompaction(\n\t\t\t\t\t\tusage,\n\t\t\t\t\t\tcontextWindow,\n\t\t\t\t\t\tctx.getCompactionSettings(),\n\t\t\t\t\t\tstate.lastYield ?? undefined,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst result = await applyGeneratedCompaction(ctx, job.snapshot, () => speculativeGeneration, compaction);\n\t\t\t\tif (!result.applied) return;\n\t\t\t\t// The job is consumed: clearing it here is also what stands the idle\n\t\t\t\t// retry watcher down for this generation.\n\t\t\t\tif (speculativeJob === job) speculativeJob = undefined;\n\t\t\t\tcancelIdleWarmupRetry();\n\t\t\t\tgetLogger(ctx).debug(\"idle_applied\", { generation: job.generation, origin: \"speculative\" });\n\t\t\t})\n\t\t\t.catch(() => {});\n\t}\n\n\tfunction isSameModelIdentity(\n\t\tleft: SpeculativeCompactionSnapshot[\"model\"],\n\t\tright: ExtensionContext[\"model\"],\n\t): boolean {\n\t\treturn (\n\t\t\tright !== undefined &&\n\t\t\tleft.api === right.api &&\n\t\t\tleft.provider === right.provider &&\n\t\t\tleft.id === right.id &&\n\t\t\tleft.baseUrl === right.baseUrl &&\n\t\t\tleft.contextWindow === right.contextWindow\n\t\t);\n\t}\n\n\t/**\n\t * Detach the warm job for the core route before any `await`, so exactly one\n\t * claimant can own it. The controller is deliberately NOT aborted: the whole\n\t * point is to keep the already-paid summarization alive and hand its result to\n\t * core, and clearing the reference is what stands the idle-retry watcher down.\n\t */\n\tfunction claimWarmSummaryForCoreRoute(\n\t\tevent: SessionBeforeCompactEvent,\n\t\tctx: ExtensionContext,\n\t): typeof speculativeJob {\n\t\tconst job = speculativeJob;\n\t\tif (!job) return undefined;\n\t\tif (event.customInstructions !== undefined) return undefined;\n\t\tif (job.snapshot.origin !== \"speculative\") return undefined;\n\t\tif (job.snapshot.preparation.firstKeptEntryId !== event.preparation.firstKeptEntryId) return undefined;\n\t\tif (!isSameModelIdentity(job.snapshot.model, ctx.model)) return undefined;\n\t\tconst anchor = createWarmAnchorSnapshot(\n\t\t\tjob.snapshot.preparation.firstKeptEntryId,\n\t\t\tjob.snapshot.branchEntries ?? [],\n\t\t);\n\t\tif (!anchor || !isWarmSummaryAnchorValid(anchor, event.branchEntries ?? ctx.sessionManager.getBranch())) {\n\t\t\treturn undefined;\n\t\t}\n\t\tspeculativeJob = undefined;\n\t\treturn job;\n\t}\n\n\tfunction invalidateSpeculativeCompaction(ctx: ExtensionContext): void {\n\t\tconst previousGeneration = speculativeGeneration;\n\t\tspeculativeGeneration++;\n\t\tgetLogger(ctx).debug(\"speculative_invalidated\", { generation: previousGeneration });\n\t\tspeculativeJob?.controller.abort();\n\t\tspeculativeJob = undefined;\n\t}\n\n\tfunction startSpeculativeCompaction(ctx: ExtensionContext, customInstructions: string): void {\n\t\tif (speculativeJob) return;\n\t\tconst generation = ++speculativeGeneration;\n\t\tconst snapshot = createSpeculativeCompactionSnapshot(ctx, {\n\t\t\tgeneration,\n\t\t\tcustomInstructions,\n\t\t\torigin: \"speculative\",\n\t\t\ttools: getSummarizationTools(),\n\t\t});\n\t\tif (!snapshot) return;\n\t\tgetLogger(ctx).debug(\"speculative_started\", { generation, origin: \"speculative\" });\n\t\tconst controller = new AbortController();\n\t\tconst settled = runExtensionCompaction(ctx, snapshot, controller.signal).then(\n\t\t\t(result) => ({ result, error: undefined }),\n\t\t\t(error: unknown) => ({ result: undefined, error: error instanceof Error ? error : new Error(String(error)) }),\n\t\t);\n\t\tspeculativeJob = trackSpeculativeJob({\n\t\t\tgeneration,\n\t\t\tsnapshot,\n\t\t\tcontroller,\n\t\t\tsettled,\n\t\t\tarmedAtTokens: ctx.getContextUsage()?.tokens ?? 0,\n\t\t});\n\t\tvoid settled.then(() => remoteCompactionDependencies.onSpeculativeJobSettled?.());\n\t}\n\n\tfunction capturePendingMetadata(requestId: string, ctx: ExtensionContext): void {\n\t\tpendingMetadata.set(requestId, {\n\t\t\tcheckpoint: checkpointState.captureAgentCheckpoint(pi, ctx),\n\t\t\ttodoSnapshot: todoBridge.createTodoSnapshot(ctx),\n\t\t});\n\t\twhile (pendingMetadata.size > MAX_PENDING_METADATA) {\n\t\t\tconst oldestRequestId = pendingMetadata.keys().next().value;\n\t\t\tif (oldestRequestId === undefined) break;\n\t\t\tpendingMetadata.delete(oldestRequestId);\n\t\t}\n\t}\n\n\tfunction persistAcceptedMetadata(requestId: string): void {\n\t\tconst metadata = pendingMetadata.get(requestId);\n\t\tif (!metadata) return;\n\t\tpendingMetadata.delete(requestId);\n\t\tcheckpointState.persistCheckpoint(pi, metadata.checkpoint);\n\t\ttodoBridge.persistTodoSnapshot(pi, metadata.todoSnapshot);\n\t}\n\n\tasync function applyBlockingCompaction(\n\t\tctx: ExtensionContext,\n\t\tcustomInstructions: string,\n\t): Promise<SpeculativeCompactionResult> {\n\t\tconst provider = ctx.model?.provider;\n\t\tif ((provider === \"cursor\" || provider === \"cursor-cli-oauth\") && !ctx.isIdle()) {\n\t\t\tgetLogger(ctx).debug(\"skip_cursor_mid_turn\", { route: \"blocking\" });\n\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t}\n\t\tif (breaker.isTripped(state, Date.now())) {\n\t\t\tgetLogger(ctx).debug(\"skip_breaker\", { route: \"blocking\" });\n\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t}\n\t\tif (cap.shouldRejectByCap(state).cancel) {\n\t\t\tgetLogger(ctx).debug(\"skip_cap\", { route: \"blocking\" });\n\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t}\n\t\tlet feedbackSignal = ctx.beginCompaction?.({ reason: \"extension\" });\n\t\ttry {\n\t\t\tlet remoteFallbackReason: string | undefined;\n\t\t\tif (isOpenAiRemoteCompactionModel(ctx.model)) {\n\t\t\t\tconst remoteGeneration = speculativeGeneration + 1;\n\t\t\t\tconst remoteSnapshot = createSpeculativeCompactionSnapshot(ctx, {\n\t\t\t\t\tgeneration: remoteGeneration,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\torigin: \"blocking\",\n\t\t\t\t});\n\t\t\t\tgetLogger(ctx).debug(\"blocking_started\", { generation: remoteGeneration, origin: \"blocking\" });\n\t\t\t\tif (remoteSnapshot) {\n\t\t\t\t\tconst remoteSignal = feedbackSignal ?? new AbortController().signal;\n\t\t\t\t\tconst remoteCompaction = await runOpenAiRemoteCompaction(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tcreateBlockingRemoteCompactionEvent(ctx, remoteSnapshot, customInstructions, remoteSignal),\n\t\t\t\t\t\t(data) => {\n\t\t\t\t\t\t\tif (data?.action === \"remote_fallback\" && typeof data.reason === \"string\") {\n\t\t\t\t\t\t\t\tremoteFallbackReason = data.reason;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpi.events.emit(SENPI_COMPACTION_EVENT, data);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tremoteCompactionDependencies,\n\t\t\t\t\t);\n\t\t\t\t\tif (remoteCompaction) {\n\t\t\t\t\t\tif (speculativeGeneration !== remoteGeneration - 1) {\n\t\t\t\t\t\t\tconst result = { applied: false, reason: \"stale\" } as const;\n\t\t\t\t\t\t\tgetLogger(ctx).debug(\"speculative_stale\", { generation: remoteGeneration });\n\t\t\t\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result);\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tspeculativeGeneration = remoteGeneration;\n\t\t\t\t\t\tspeculativeJob?.controller.abort();\n\t\t\t\t\t\tspeculativeJob = undefined;\n\t\t\t\t\t\tconst result = await applyGeneratedCompaction(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tremoteSnapshot,\n\t\t\t\t\t\t\t() => speculativeGeneration,\n\t\t\t\t\t\t\tremoteCompaction,\n\t\t\t\t\t\t\tfeedbackSignal,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tgetLogger(ctx).debug(\"speculative_applied\", { generation: remoteGeneration, origin: \"blocking\" });\n\t\t\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result);\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pendingJob = speculativeJob;\n\t\t\tif (pendingJob) {\n\t\t\t\tconst unlinkAbort = linkAbortSignal(feedbackSignal, pendingJob.controller);\n\t\t\t\tlet compaction: CompactionResult | undefined;\n\t\t\t\tlet inheritedFailure: Error | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tcompaction = await pendingJob.promise;\n\t\t\t\t\tinheritedFailure = await pendingJob.failure;\n\t\t\t\t\tif (compaction)\n\t\t\t\t\t\tgetLogger(ctx).debug(\"warm_consumed\", { generation: pendingJob.generation, route: \"speculative\" });\n\t\t\t\t} finally {\n\t\t\t\t\tunlinkAbort();\n\t\t\t\t}\n\t\t\t\tif (inheritedFailure !== undefined) {\n\t\t\t\t\tspeculativeJob = undefined;\n\t\t\t\t\tif (isTransientSummarizationFailure(inheritedFailure, inheritedFailure.message)) {\n\t\t\t\t\t\tctx.endCompaction?.({\n\t\t\t\t\t\t\treason: \"extension\",\n\t\t\t\t\t\t\tsignal: feedbackSignal,\n\t\t\t\t\t\t\taborted: feedbackSignal?.aborted,\n\t\t\t\t\t\t\terrorMessage: `Compaction failed: ${inheritedFailure.message}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tstate = breaker.recordFailure(state, Date.now(), { route: \"extension\" });\n\t\t\t\t\t\treturn { applied: false, reason: \"failed\" };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst result = await applyGeneratedCompaction(\n\t\t\t\t\tctx,\n\t\t\t\t\tpendingJob.snapshot,\n\t\t\t\t\t() => speculativeGeneration,\n\t\t\t\t\tcompaction,\n\t\t\t\t\tfeedbackSignal,\n\t\t\t\t);\n\t\t\t\tif (result.applied) {\n\t\t\t\t\tspeculativeJob = undefined;\n\t\t\t\t\tgetLogger(ctx).debug(\"speculative_applied\", {\n\t\t\t\t\t\tgeneration: pendingJob.generation,\n\t\t\t\t\t\torigin: \"speculative\",\n\t\t\t\t\t});\n\t\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tif (result.reason === \"stale\") {\n\t\t\t\t\tgetLogger(ctx).debug(\"speculative_stale\", { generation: pendingJob.generation });\n\t\t\t\t} else if (result.reason === \"rejected\") {\n\t\t\t\t\tfeedbackSignal = ctx.beginCompaction?.({ reason: \"extension\" });\n\t\t\t\t}\n\t\t\t\tspeculativeJob = undefined;\n\t\t\t}\n\n\t\t\tconst generation = ++speculativeGeneration;\n\t\t\tconst snapshot = createSpeculativeCompactionSnapshot(ctx, {\n\t\t\t\tgeneration,\n\t\t\t\tcustomInstructions,\n\t\t\t\torigin: \"core-route\",\n\t\t\t\ttools: getSummarizationTools(),\n\t\t\t});\n\t\t\tif (!snapshot) {\n\t\t\t\tconst result = { applied: false, reason: \"unavailable\" } as const;\n\t\t\t\tgetLogger(ctx).debug(\"summary_failed\", { reason: \"unavailable\" });\n\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result, remoteFallbackReason);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tlet compaction: CompactionResult | undefined;\n\t\t\ttry {\n\t\t\t\tcompaction = await runExtensionCompaction(ctx, snapshot, feedbackSignal, (delta) =>\n\t\t\t\t\tctx.updateCompaction?.({\n\t\t\t\t\t\treason: \"extension\",\n\t\t\t\t\t\tsignal: feedbackSignal,\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof SummaryGenerationError)) throw error;\n\t\t\t\tgetLogger(ctx).debug(\"summary_failed\", { reason: error.kind });\n\t\t\t}\n\t\t\tconst result = await applyGeneratedCompaction(\n\t\t\t\tctx,\n\t\t\t\tsnapshot,\n\t\t\t\t() => speculativeGeneration,\n\t\t\t\tcompaction,\n\t\t\t\tfeedbackSignal,\n\t\t\t);\n\t\t\tendCompactionFeedback(ctx, feedbackSignal, result, remoteFallbackReason);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (feedbackSignal?.aborted) {\n\t\t\t\t// An aborted blocking compaction is a cancellation, not a failure: no\n\t\t\t\t// red \"Compaction failed\" line, no breaker debit, no rethrow through\n\t\t\t\t// the before_agent_start handler (issue #886). The faux-route flavor\n\t\t\t\t// of this contract is pinned by blocking-compaction-review-hardening.\n\t\t\t\tgetLogger(ctx).debug(\"blocking_aborted\", { route: \"blocking\" });\n\t\t\t\tctx.endCompaction?.({ reason: \"extension\", signal: feedbackSignal, aborted: true });\n\t\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t\t}\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tctx.endCompaction?.({\n\t\t\t\treason: \"extension\",\n\t\t\t\tsignal: feedbackSignal,\n\t\t\t\taborted: feedbackSignal?.aborted,\n\t\t\t\terrorMessage: `Compaction failed: ${message}`,\n\t\t\t});\n\t\t\tconst transient = isTransientSummarizationFailure(error, message);\n\t\t\tif (transient) {\n\t\t\t\tstate = breaker.recordFailure(state, Date.now(), { route: \"extension\" });\n\t\t\t\treturn { applied: false, reason: \"failed\" };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpi.on(\"session_before_compact\", async (event: SessionBeforeCompactEvent, ctx) => {\n\t\t// A pre-aborted request (superseded admission or user cancel) must stand\n\t\t// down before touching warm-job ownership: core's own post-emit abort\n\t\t// checks turn it into a clean cancellation (issue #886).\n\t\tif (event.signal.aborted) return undefined;\n\t\tconst claimedWarmJob = claimWarmSummaryForCoreRoute(event, ctx);\n\t\t// The claim detaches the job without aborting it, so ownership must survive every\n\t\t// exit from this handler - including a throw - or the request it already paid for\n\t\t// keeps streaming for a result nobody will read.\n\t\tlet warmJobConsumed = false;\n\t\tinvalidateSpeculativeCompaction(ctx);\n\t\ttry {\n\t\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) {\n\t\t\t\treturn {\n\t\t\t\t\tcancel: true,\n\t\t\t\t\trejectionCause: \"external-owner\",\n\t\t\t\t\treason: SDK_NATIVE_LANE_REJECTION_REASON,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (cap.shouldRejectByCap(state).cancel) {\n\t\t\t\tgetLogger(ctx).debug(\"skip_cap\", { reason: event.reason, count: state.acceptedAbsolute });\n\t\t\t\treturn {\n\t\t\t\t\tcancel: true,\n\t\t\t\t\trejectionCause: \"per-turn-cap\",\n\t\t\t\t\treason: \"absolute compaction cap reached for this session\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst now = Date.now();\n\t\t\tif (breaker.isTripped(state, now) && !breaker.shouldBypass(state, { reason: event.reason })) {\n\t\t\t\tconst remainingMs = state.trippedAt !== null ? Math.max(0, state.trippedAt + breaker.COOLDOWN_MS - now) : 0;\n\t\t\t\tgetLogger(ctx).debug(\"skip_breaker\", { reason: event.reason, remainingSec: Math.ceil(remainingMs / 1000) });\n\t\t\t\treturn {\n\t\t\t\t\tcancel: true,\n\t\t\t\t\trejectionCause: \"circuit-breaker\",\n\t\t\t\t\treason: `compaction circuit breaker cooling down (${Math.ceil(remainingMs / 1000)}s left)`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tcapturePendingMetadata(event.requestId, ctx);\n\n\t\t\tconst model = ctx.model;\n\t\t\tif (!model) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tlet remoteCompaction: Awaited<ReturnType<typeof runOpenAiRemoteCompaction>>;\n\t\t\ttry {\n\t\t\t\tremoteCompaction = await runOpenAiRemoteCompaction(\n\t\t\t\t\tctx,\n\t\t\t\t\tevent,\n\t\t\t\t\t(data) => pi.events.emit(SENPI_COMPACTION_EVENT, data),\n\t\t\t\t\tremoteCompactionDependencies,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\t// The remote route deliberately rethrows once its signal aborts; the\n\t\t\t\t// handler converts that into a silent stand-down so the abort is not\n\t\t\t\t// reported as an extension error with a stack (issue #886).\n\t\t\t\tif (!event.signal.aborted) throw error;\n\t\t\t\tgetLogger(ctx).debug(\"remote_aborted\", { route: \"core-route\", requestId: event.requestId });\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (remoteCompaction) {\n\t\t\t\tgetLogger(ctx).debug(\"core_route_generated\", { route: \"core-route\", requestId: event.requestId });\n\t\t\t\treturn { compaction: remoteCompaction };\n\t\t\t}\n\n\t\t\tif (claimedWarmJob) {\n\t\t\t\tconst unlinkAbort = linkAbortSignal(event.signal, claimedWarmJob.controller);\n\t\t\t\tlet warmCompaction: CompactionResult | undefined;\n\t\t\t\tlet warmFailure: Error | undefined;\n\t\t\t\ttry {\n\t\t\t\t\twarmCompaction = await claimedWarmJob.promise;\n\t\t\t\t\twarmFailure = await claimedWarmJob.failure;\n\t\t\t\t} finally {\n\t\t\t\t\tunlinkAbort();\n\t\t\t\t}\n\t\t\t\tif (warmFailure === undefined && warmCompaction && !event.signal.aborted) {\n\t\t\t\t\tgetLogger(ctx).debug(\"warm_consumed\", { generation: claimedWarmJob.generation, route: \"core-route\" });\n\t\t\t\t\twarmJobConsumed = true;\n\t\t\t\t\treturn { compaction: warmCompaction };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst snapshot = {\n\t\t\t\tgeneration: ++speculativeGeneration,\n\t\t\t\texpectedRevision: ctx.getMessageRevision(),\n\t\t\t\tmodel,\n\t\t\t\tcontextWindow: ctx.getContextUsage()?.contextWindow ?? model.contextWindow ?? DEFAULT_CONTEXT_WINDOW,\n\t\t\t\tpreparation: event.preparation,\n\t\t\t\tbranchEntries: event.branchEntries,\n\t\t\t\tpromptVariant: getPromptVariant(event),\n\t\t\t\torigin: \"core-route\" as const,\n\t\t\t\tcustomInstructions: event.customInstructions,\n\t\t\t\tsystemPrompt: ctx.getSystemPrompt(),\n\t\t\t\ttools: getSummarizationTools(),\n\t\t\t};\n\t\t\tlet compaction: CompactionResult | undefined;\n\t\t\ttry {\n\t\t\t\tcompaction = await runExtensionCompaction(ctx, snapshot, event.signal, (delta) =>\n\t\t\t\t\tctx.updateCompaction?.({ reason: event.reason, signal: event.signal, delta }),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconst failureKind = classifyRequiredCompactionFallbackFailure(error);\n\t\t\t\tif (\n\t\t\t\t\tisRequiredCompactionFallbackReason(event.reason) &&\n\t\t\t\t\tfailureKind !== undefined &&\n\t\t\t\t\t!event.signal.aborted\n\t\t\t\t) {\n\t\t\t\t\tconst fallback = createRequiredCompactionFallback(\n\t\t\t\t\t\tsnapshot.preparation,\n\t\t\t\t\t\tsnapshot.contextWindow,\n\t\t\t\t\t\tfailureKind,\n\t\t\t\t\t\t{ taskIntent: resolveInheritedTaskIntent(event.branchEntries) },\n\t\t\t\t\t\tevent.branchEntries,\n\t\t\t\t\t);\n\t\t\t\t\tif (fallback) return { compaction: fallback };\n\t\t\t\t\tpendingMetadata.delete(event.requestId);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcancel: true,\n\t\t\t\t\t\treason: \"deterministic compaction fallback cannot retain the prepared suffix\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tpendingMetadata.delete(event.requestId);\n\t\t\t\tif (error instanceof SummaryGenerationError) {\n\t\t\t\t\treturn { cancel: true, reason: error.message };\n\t\t\t\t}\n\t\t\t\treturn { cancel: true, reason: `compaction generator failed: ${message}` };\n\t\t\t}\n\t\t\tif (!compaction) {\n\t\t\t\tpendingMetadata.delete(event.requestId);\n\t\t\t\tif (event.signal.aborted) {\n\t\t\t\t\treturn { cancel: true };\n\t\t\t\t}\n\t\t\t\treturn { cancel: true, reason: \"compaction generator returned no summary\" };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcompaction,\n\t\t\t};\n\t\t} finally {\n\t\t\tif (!warmJobConsumed) claimedWarmJob?.controller.abort();\n\t\t}\n\t});\n\n\tpi.on(\"model_select\", (event, ctx) =>\n\t\thandleCompactionModelSelect({\n\t\t\tevent,\n\t\t\tctx,\n\t\t\tstate,\n\t\t\tspeculativeSnapshot: speculativeJob?.snapshot,\n\t\t\tlaneOwnsCompaction: lanePolicy.disablesSenpiCompaction(ctx),\n\t\t\tbreakerTripped: breaker.isTripped(state, Date.now()),\n\t\t\tinvalidate: () => invalidateSpeculativeCompaction(ctx),\n\t\t\tstart: () => startSpeculativeCompaction(ctx, PROACTIVE_COMPACTION_INSTRUCTIONS),\n\t\t}),\n\t);\n\n\tpi.on(\"session_compact\", async (event: SessionCompactEvent, ctx) => {\n\t\tconst compactEvent = event;\n\t\tinvalidateSpeculativeCompaction(ctx);\n\t\tif (compactEvent.accepted) {\n\t\t\tpersistAcceptedMetadata(compactEvent.requestId);\n\t\t\tconst branchEntries = ctx.sessionManager.getBranch();\n\t\t\tconst firstKeptIndex = branchEntries.findIndex(\n\t\t\t\t(entry) => entry.id === compactEvent.compactionEntry.firstKeptEntryId,\n\t\t\t);\n\t\t\tconst keptEntries = firstKeptIndex === -1 ? [] : branchEntries.slice(firstKeptIndex);\n\t\t\tstate = cap.incrementAccepted(state);\n\t\t\tstate = breaker.recordSuccess(state);\n\t\t\treminderState = createInitialReminderState();\n\t\t\tconst details = compactEvent.compactionEntry.details as\n\t\t\t\t| { structuralYield?: { savedTokens: number; savingsRatio: number } }\n\t\t\t\t| undefined;\n\t\t\tconst sy = details?.structuralYield;\n\t\t\tif (sy && typeof sy.savedTokens === \"number\" && typeof sy.savingsRatio === \"number\") {\n\t\t\t\tstate = {\n\t\t\t\t\t...state,\n\t\t\t\t\tlastYield: { savedTokens: sy.savedTokens, tokensBefore: compactEvent.compactionEntry.tokensBefore },\n\t\t\t\t};\n\t\t\t\tif (\n\t\t\t\t\tisIneffectiveCompaction({\n\t\t\t\t\t\ttokensBefore: compactEvent.compactionEntry.tokensBefore,\n\t\t\t\t\t\tsavedTokens: sy.savedTokens,\n\t\t\t\t\t\tsavingsRatio: sy.savingsRatio,\n\t\t\t\t\t})\n\t\t\t\t) {\n\t\t\t\t\tstate = cap.incrementIneffective(state);\n\t\t\t\t\tgetLogger(ctx).debug(\"ineffective_counted\", {\n\t\t\t\t\t\ttokensBefore: compactEvent.compactionEntry.tokensBefore,\n\t\t\t\t\t\tsavedTokens: sy.savedTokens,\n\t\t\t\t\t\tsavingsRatio: sy.savingsRatio,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tresetOnSessionCompact(degradationState);\n\t\t\ttodoBridge.restoreTodosIfMissing(pi, ctx);\n\t\t\tconst usage = ctx.getContextUsage();\n\t\t\tconst settings = ctx.getCompactionSettings();\n\t\t\tif (settings.restorationEnabled ?? true) {\n\t\t\t\trestoration.preparePendingPayload(restorationState, {\n\t\t\t\t\taccepted: true,\n\t\t\t\t\treason: compactEvent.reason,\n\t\t\t\t\tcompactionEntryId: compactEvent.compactionEntry.id,\n\t\t\t\t\tcontextWindow: usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW,\n\t\t\t\t\tusageTokens: usage?.tokens ?? null,\n\t\t\t\t\treserveTokens: policy.resolveEffectiveReserveTokens(\n\t\t\t\t\t\tusage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW,\n\t\t\t\t\t\tsettings,\n\t\t\t\t\t),\n\t\t\t\t\tsettings,\n\t\t\t\t\tkeptMessages: keptEntries.flatMap((entry) => {\n\t\t\t\t\t\tif (entry.type !== \"message\") return [];\n\t\t\t\t\t\treturn [entry.message];\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (compactEvent.rejectionCause === \"external-owner\") return;\n\t\tif (!lanePolicy.disablesSenpiCompaction(ctx)) {\n\t\t\tstate = breaker.recordFailure(state, Date.now(), { route: compactEvent.reason });\n\t\t}\n\t});\n\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\tsessionIdleSinceAgentEnd = false;\n\t\tcancelIdleWarmupRetry();\n\t\tconst message = checkpointState.attachRestorationDirective(\n\t\t\trestorationDirectiveState,\n\t\t\trecentCheckpoint(ctx),\n\t\t\trestoration.consumePendingPayload(restorationState),\n\t\t);\n\n\t\tconst usage = ctx.getContextUsage();\n\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\tconst settings = ctx.getCompactionSettings();\n\t\tconst pendingPromptTokens = estimatePendingPromptTokens(event);\n\t\tconst usageWithPendingPrompt = usage ? withAdditionalTokens(usage, pendingPromptTokens) : undefined;\n\t\t// The SDK owns this lane's context entirely, so even the hard-limit valve stands down;\n\t\t// the circuit breaker never blocks that valve for senpi-owned lanes.\n\t\tconst laneOwnsCompaction = lanePolicy.disablesSenpiCompaction(ctx);\n\t\tconst breakerCoolingDown = breaker.isTripped(state, Date.now()) || laneOwnsCompaction;\n\t\tconst { reserveTokens, thresholdTokens, leadTokens } = resolveCompactionGeometry({\n\t\t\tcontextWindow,\n\t\t\tsettings,\n\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t});\n\t\tif (\n\t\t\t!laneOwnsCompaction &&\n\t\t\tusage &&\n\t\t\tpolicy.isAtHardLimit(usage, contextWindow, reserveTokens, pendingPromptTokens)\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"hard_limit_trigger\", {\n\t\t\t\tcontextWindow,\n\t\t\t\ttokens: usage.tokens ?? 0,\n\t\t\t\tthreshold: settings.reserveTokens,\n\t\t\t});\n\t\t\tawait applyBlockingCompaction(ctx, EMERGENCY_COMPACTION_INSTRUCTIONS);\n\t\t} else if (\n\t\t\t!breakerCoolingDown &&\n\t\t\tusageWithPendingPrompt &&\n\t\t\tpolicy.shouldTriggerCompaction(usageWithPendingPrompt, contextWindow, settings, state.lastYield ?? undefined)\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"threshold_trigger\", {\n\t\t\t\tcontextWindow,\n\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t\tthreshold: settings.reserveTokens,\n\t\t\t});\n\t\t\tif (\n\t\t\t\t!shouldDeferGraceBand({\n\t\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t\t\tthresholdTokens,\n\t\t\t\t\tleadTokens,\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\treserveTokens,\n\t\t\t\t\tcompactionInFlight: speculativeJob !== undefined && !speculativeJob.completed,\n\t\t\t\t\tgraceBandEnabled: settings.graceBandEnabled,\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\tawait applyBlockingCompaction(ctx, PROACTIVE_COMPACTION_INSTRUCTIONS);\n\t\t\t} else {\n\t\t\t\tgetLogger(ctx).debug(\"grace_deferred\", {\n\t\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t\t\tthreshold: thresholdTokens,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (\n\t\t\t!breakerCoolingDown &&\n\t\t\t!isOpenAiRemoteCompactionModel(ctx.model) &&\n\t\t\tusageWithPendingPrompt &&\n\t\t\tpolicy.shouldStartSpeculativeCompaction(\n\t\t\t\tusageWithPendingPrompt,\n\t\t\t\tcontextWindow,\n\t\t\t\tsettings,\n\t\t\t\tstate.lastYield ?? undefined,\n\t\t\t\tleadTokens,\n\t\t\t)\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"emergency_prune\", {\n\t\t\t\troute: \"context-event\",\n\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t});\n\t\t\tstartSpeculativeCompaction(ctx, PROACTIVE_COMPACTION_INSTRUCTIONS);\n\t\t}\n\n\t\tconst reminder = computeTokenBudgetReminder({\n\t\t\tcontextTokens: usageWithPendingPrompt?.tokens ?? 0,\n\t\t\tcontextWindow,\n\t\t\tthresholdTokens,\n\t\t\tleadTokens,\n\t\t\tcompactionEpoch: speculativeGeneration,\n\t\t\tstate: reminderState,\n\t\t});\n\t\treminderState = reminder.nextState;\n\t\tconst deliveredMessage = resolveBeforeAgentStartMessage({\n\t\t\tmessage,\n\t\t\treminder: reminder.message,\n\t\t\treminderEnabled: settings.reminderEnabled,\n\t\t});\n\t\tconst reminderSystemPrompt = resolveReminderSystemPrompt({\n\t\t\tsystemPrompt: event.systemPrompt,\n\t\t\treminder: !message ? reminder.message : undefined,\n\t\t\treminderEnabled: settings.reminderEnabled,\n\t\t});\n\t\tif (!deliveredMessage && !reminderSystemPrompt) return undefined;\n\t\treturn {\n\t\t\t...(deliveredMessage ? { message: deliveredMessage } : {}),\n\t\t\t...(reminderSystemPrompt ? { systemPrompt: reminderSystemPrompt } : {}),\n\t\t};\n\t});\n\n\tpi.on(\"context\", (event, ctx) => {\n\t\tconst usage = ctx.getContextUsage();\n\t\tconst settings = ctx.getCompactionSettings();\n\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\tconst laneOwnsCompaction = lanePolicy.disablesSenpiCompaction(ctx);\n\t\tconst breakerFallback =\n\t\t\t!laneOwnsCompaction &&\n\t\t\tbreaker.isTripped(state, Date.now()) &&\n\t\t\tusage?.tokens !== null &&\n\t\t\tusage !== undefined &&\n\t\t\tusage.tokens >= contextWindow * policy.computeEffectiveThreshold(contextWindow, state.lastYield ?? undefined);\n\t\tif (breakerFallback)\n\t\t\tgetLogger(ctx).debug(\"breaker_deterministic_fallback\", { route: \"context-event\", tokens: usage.tokens ?? 0 });\n\t\treturn {\n\t\t\tmessages: buildCompactionContext({\n\t\t\t\tevent,\n\t\t\t\tctx,\n\t\t\t\tcontextWindow,\n\t\t\t\tpromptContextWindow: getPromptContextWindow(contextWindow, ctx.model?.maxTokens),\n\t\t\t\ttoolAdmissionEnabled: settings.toolAdmissionEnabled !== false,\n\t\t\t\tbreakerFallback,\n\t\t\t\tlaneOwnsCompaction,\n\t\t\t\temergencyPruneLatch,\n\t\t\t}),\n\t\t};\n\t});\n\n\tpi.on(\"before_provider_request\", async (event, ctx) => {\n\t\tconst model = event.model ?? ctx.model;\n\t\tif (!isOpenAiRemoteCompactionModel(model)) return undefined;\n\t\tconst auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);\n\t\tif (!auth.ok) return undefined;\n\t\tconst effectiveModel =\n\t\t\tauth.upstreamModelId || auth.baseUrl\n\t\t\t\t? {\n\t\t\t\t\t\t...model,\n\t\t\t\t\t\t...(auth.upstreamModelId ? { id: auth.upstreamModelId } : {}),\n\t\t\t\t\t\t...(auth.baseUrl ? { baseUrl: auth.baseUrl } : {}),\n\t\t\t\t\t}\n\t\t\t\t: model;\n\t\tconst headers = createOpenAiRemoteCompactionHeaders(\n\t\t\teffectiveModel,\n\t\t\t{ ...auth, headers: event.headers ?? auth.headers },\n\t\t\tctx.sessionManager.getSessionId(),\n\t\t);\n\t\tif (!headers) return undefined;\n\t\tconst origin = openAiRemoteCompactionOrigin(effectiveModel, headers);\n\t\treturn rewriteOpenAiPayloadWithRemoteCompaction(\n\t\t\tevent.payload,\n\t\t\t{ model: effectiveModel, branchEntries: ctx.sessionManager.getBranch(), origin },\n\t\t\t(data) => pi.events.emit(SENPI_COMPACTION_EVENT, data),\n\t\t);\n\t});\n\n\tpi.on(\"turn_end\", async (_event, ctx) => {\n\t\ttry {\n\t\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) return;\n\t\t\thandleTurnEnd(degradationState);\n\t\t\tif (degradationState.recoveryTriggeredThisCycle) return;\n\t\t\tif (state.lastYield && state.lastYield.savedTokens <= 0) {\n\t\t\t\tvoid applyBlockingCompaction(ctx, RECOVERY_INSTRUCTIONS).catch(() => {});\n\t\t\t}\n\t\t} finally {\n\t\t\tstate = resetTurnCounter(state, \"\");\n\t\t}\n\t});\n\n\tpi.on(\"agent_end\", async (event, ctx) => {\n\t\tstate = resetTurnCounter(state, \"\");\n\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) return;\n\t\tconst usage = ctx.getContextUsage();\n\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\tconst settings = ctx.getCompactionSettings();\n\t\tif (\n\t\t\tidle.shouldRunIdleCompaction({\n\t\t\t\twillRetry: event.willRetry ?? false,\n\t\t\t\taborted: event.aborted === true,\n\t\t\t\tsettings,\n\t\t\t\tusage,\n\t\t\t\tcontextWindow,\n\t\t\t\tbreakerTripped: breaker.isTripped(state, Date.now()),\n\t\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t\t\tmode: ctx.mode,\n\t\t\t})\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"idle_trigger\", { contextWindow, tokens: usage?.tokens ?? 0 });\n\t\t\tidleWarmupAttempt = 0;\n\t\t\tsessionIdleSinceAgentEnd = true;\n\t\t\tstartSpeculativeCompaction(ctx, idle.IDLE_COMPACTION_INSTRUCTIONS);\n\t\t\tarmIdleWarmupRetry(ctx);\n\t\t\tarmIdleApply(ctx);\n\t\t} else {\n\t\t\t// A sub-threshold OpenAI warm-up cannot be consumed by the remote\n\t\t\t// compaction route. Once threshold admission succeeds remotely, it would\n\t\t\t// only abort and discard this paid local summary. Above threshold we keep\n\t\t\t// the existing local idle apply, which can finish before the next prompt;\n\t\t\t// if remote compaction later falls back, blocking local generation remains\n\t\t\t// unchanged.\n\t\t\tif (isOpenAiRemoteCompactionModel(ctx.model)) return;\n\t\t\tconst warmAction = resolveIdleWarmAction(\n\t\t\t\t{\n\t\t\t\t\twillRetry: event.willRetry ?? false,\n\t\t\t\t\taborted: event.aborted === true,\n\t\t\t\t\tsettings,\n\t\t\t\t\tusage,\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\tbreakerTripped: breaker.isTripped(state, Date.now()),\n\t\t\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t\t\t\tmode: ctx.mode,\n\t\t\t\t},\n\t\t\t\tspeculativeJob,\n\t\t\t);\n\t\t\tif (warmAction === \"replace\") invalidateSpeculativeCompaction(ctx);\n\t\t\tif (warmAction !== \"none\") {\n\t\t\t\tidleWarmupAttempt = 0;\n\t\t\t\tsessionIdleSinceAgentEnd = true;\n\t\t\t\tstartSpeculativeCompaction(ctx, idle.IDLE_COMPACTION_INSTRUCTIONS);\n\t\t\t\tarmIdleWarmupRetry(ctx);\n\t\t\t\tarmIdleApply(ctx);\n\t\t\t}\n\t\t}\n\t});\n\n\tpi.on(\"message_end\", async (event, ctx) => {\n\t\tfor (const entry of collectCompactBoundaryEntries(event.message)) {\n\t\t\tpi.appendEntry(CLAUDE_SDK_OAUTH_COMPACT_ENTRY_TYPE, entry);\n\t\t}\n\t\tif (isAbortedAssistantMessage(event)) {\n\t\t\tinvalidateSpeculativeCompaction(ctx);\n\t\t}\n\t\tif (isMonitorableMessageEvent(event) && !lanePolicy.disablesSenpiCompaction(ctx)) {\n\t\t\tawait handleMessageEnd(degradationState, event, {\n\t\t\t\tapplyCompaction: async (options) => {\n\t\t\t\t\treturn await applyBlockingCompaction(ctx, options.customInstructions);\n\t\t\t\t},\n\t\t\t\tnotify: (message) => ctx.ui.notify(message, \"warning\"),\n\t\t\t});\n\t\t}\n\t});\n\n\tpi.on(\"tool_call\", (event) => {\n\t\trestoration.trackToolCall(restorationState, event);\n\t});\n\n\t// The reload path retires this extension generation right after this event\n\t// (`AgentSession.reload()` invalidates the old runner), so stand the idle\n\t// warm-up watcher down here rather than leaving a timer armed against a\n\t// context that is about to start throwing on every read.\n\tpi.on(\"session_shutdown\", () => {\n\t\tsessionIdleSinceAgentEnd = false;\n\t\tcancelIdleWarmupRetry();\n\t\tidleWarmupAttempt = 0;\n\t\tspeculativeJob?.controller.abort();\n\t\tspeculativeJob = undefined;\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAExG,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AACh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,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC;YAClF,MAAM,gBAAgB,CAAC,gBAAgB,EAAE,KAAK,EAAE;gBAC/C,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;oBAClC,OAAO,MAAM,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;gBACvE,CAAC;gBACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;aACtD,CAAC,CAAC;QACJ,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5B,WAAW,CAAC,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,yDAAyD;IACzD,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC9B,wBAAwB,GAAG,KAAK,CAAC;QACjC,qBAAqB,EAAE,CAAC;QACxB,iBAAiB,GAAG,CAAC,CAAC;QACtB,cAAc,EAAE,UAAU,CAAC,KAAK,EAAE,CAAC;QACnC,cAAc,GAAG,SAAS,CAAC;IAC5B,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Tool } from \"@earendil-works/pi-ai\";\nimport type { CompactionResult } from \"../../../compaction/index.ts\";\nimport { createWarmAnchorSnapshot, isWarmSummaryAnchorValid } from \"../../../compaction/warm-anchor.ts\";\nimport type { ExtensionAPI, ExtensionContext, SessionBeforeCompactEvent, SessionCompactEvent } from \"../../types.ts\";\nimport * as checkpointState from \"./checkpoint-state.ts\";\nimport * as breaker from \"./circuit-breaker.ts\";\nimport { buildCompactionContext } from \"./context-pipeline.ts\";\nimport {\n\tcreateDegradationMonitorState,\n\thandleMessageEnd,\n\thandleTurnEnd,\n\tRECOVERY_INSTRUCTIONS,\n\tresetOnSessionCompact,\n} from \"./degradation-monitor.ts\";\nimport {\n\tclassifyRequiredCompactionFallbackFailure,\n\tcreateRequiredCompactionFallback,\n} from \"./deterministic-fallback.ts\";\nimport * as idle from \"./idle.ts\";\nimport * as idleRetry from \"./idle-retry.ts\";\nimport {\n\tCLAUDE_SDK_OAUTH_COMPACT_ENTRY_TYPE,\n\tcollectCompactBoundaryEntries,\n\tcreateCompactionLanePolicy,\n\tSDK_NATIVE_LANE_REJECTION_REASON,\n} from \"./lane-policy.ts\";\nimport { type CompactionLogger, createCompactionLogger } from \"./log.ts\";\nimport { handleCompactionModelSelect } from \"./model-selection.ts\";\nimport {\n\ttype OpenAiRemoteCompactionDependencies,\n\trewriteOpenAiPayloadWithRemoteCompaction,\n\trunOpenAiRemoteCompaction,\n\tSENPI_COMPACTION_EVENT,\n} from \"./openai-remote.ts\";\nimport {\n\tcreateOpenAiRemoteCompactionHeaders,\n\tisOpenAiRemoteCompactionModel,\n\topenAiRemoteCompactionOrigin,\n} from \"./openai-remote-model.ts\";\nimport {\n\tresolveBeforeAgentStartMessage,\n\tresolveCompactionGeometry,\n\tresolveIdleWarmAction,\n\tresolveReminderSystemPrompt,\n\tshouldDeferGraceBand,\n} from \"./orchestration.ts\";\nimport * as cap from \"./per-turn-cap.ts\";\nimport * as policy from \"./policy.ts\";\nimport * as restoration from \"./restoration-tracker.ts\";\nimport {\n\tapplyGeneratedCompaction,\n\tcreateEmergencyPruneLatch,\n\tcreateSpeculativeCompactionSnapshot,\n\tgetPromptVariant,\n\trunExtensionCompaction,\n\ttype SpeculativeCompactionResult,\n\ttype SpeculativeCompactionSnapshot,\n\tSummaryGenerationError,\n} from \"./speculative.ts\";\nimport { type SpeculativeJob, trackSpeculativeJob } from \"./speculative-job.ts\";\nimport { type CompactionExtensionState, createInitialState, resetTurnCounter } from \"./state.ts\";\nimport { resolveInheritedTaskIntent } from \"./task-intent.ts\";\nimport * as todoBridge from \"./todo-bridge.ts\";\nimport {\n\tcomputeTokenBudgetReminder,\n\tcreateInitialReminderState,\n\ttype TokenBudgetReminderState,\n} from \"./token-budget-reminder.ts\";\nimport { isTransientSummarizationFailure } from \"./transient-failure.ts\";\n\nexport { getPromptContextWindow } from \"./extension-wiring.ts\";\n\nimport {\n\tcreateBlockingRemoteCompactionEvent,\n\tendCompactionFeedback,\n\testimatePendingPromptTokens,\n\tgetPromptContextWindow,\n\tisAbortedAssistantMessage,\n\tisMonitorableMessageEvent,\n\tisRequiredCompactionFallbackReason,\n\tlinkAbortSignal,\n\trecentCheckpoint,\n\twithAdditionalTokens,\n} from \"./extension-wiring.ts\";\nimport { isIneffectiveCompaction } from \"./yield.ts\";\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\nconst EMERGENCY_COMPACTION_INSTRUCTIONS =\n\t\"EMERGENCY: hard context limit reached. Produce an aggressive recovery summary that preserves current goal, constraints, files touched, tool outcomes, and exact next steps. Prefer concise factual state over transcript detail.\";\nconst PROACTIVE_COMPACTION_INSTRUCTIONS = \"Proactively compact before the next agent turn.\";\nconst MAX_PENDING_METADATA = 8;\n\ninterface PendingCompactionMetadata {\n\tcheckpoint: checkpointState.AgentCheckpoint;\n\ttodoSnapshot: todoBridge.TodoSnapshotPayload;\n}\n\nexport default function compactionExtension(\n\tpi: ExtensionAPI,\n\tremoteCompactionDependencies: OpenAiRemoteCompactionDependencies = {},\n): void {\n\tlet state: CompactionExtensionState = createInitialState();\n\tconst lanePolicy = createCompactionLanePolicy();\n\tconst restorationDirectiveState = checkpointState.createRestorationDirectiveState();\n\tconst emergencyPruneLatch = createEmergencyPruneLatch();\n\tconst degradationState = createDegradationMonitorState();\n\tconst restorationState = state.restoration ?? restoration.createRestorationTrackerState();\n\tstate = { ...state, restoration: restorationState };\n\tlet speculativeGeneration = 0;\n\tlet reminderState: TokenBudgetReminderState = createInitialReminderState();\n\tlet speculativeJob: SpeculativeJob | undefined;\n\tconst pendingMetadata = new Map<string, PendingCompactionMetadata>();\n\tlet logger: CompactionLogger | undefined;\n\tconst getLogger = (ctx: ExtensionContext): CompactionLogger => (logger ??= createCompactionLogger(ctx.agentDir));\n\n\tfunction getSummarizationTools(): Tool[] {\n\t\tif (typeof pi.getAllTools !== \"function\" || typeof pi.getActiveTools !== \"function\") return [];\n\t\ttry {\n\t\t\tconst definitionsByName = new Map(pi.getAllTools().map((tool) => [tool.name, tool]));\n\t\t\treturn pi.getActiveTools().flatMap((name) => {\n\t\t\t\tconst tool = definitionsByName.get(name);\n\t\t\t\treturn tool ? [{ name: tool.name, description: tool.description, parameters: tool.parameters }] : [];\n\t\t\t});\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tlet idleWarmupTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet idleWarmupAttempt = 0;\n\t// True from the `agent_end` idle trigger until the next turn starts (or the\n\t// session shuts down). The idle-apply watcher below is fenced on it so a\n\t// summary that lands after the user has already prompted is never applied\n\t// out from under the turn that is starting; the warm-consume path in\n\t// `before_agent_start` owns the job from that point on.\n\tlet sessionIdleSinceAgentEnd = false;\n\n\tfunction cancelIdleWarmupRetry(): void {\n\t\tif (idleWarmupTimer === undefined) return;\n\t\tclearTimeout(idleWarmupTimer);\n\t\tidleWarmupTimer = undefined;\n\t}\n\n\t// A session reload retires this extension generation while the warm-up\n\t// watcher below is still armed: `AgentSession.reload()` invalidates the old\n\t// runner, after which every `ExtensionContext` getter throws\n\t// \"stale extension generation after reload\". The watcher outlives that\n\t// invalidation in two places — the `job.failure` continuation and the armed\n\t// retry timer — and neither had a caller left to receive the throw: the\n\t// continuation is spawned with `void` (unhandled rejection) and the timer\n\t// callback throws straight into the timer queue, which terminates the\n\t// process. The context carries no liveness flag, so a retired generation is\n\t// only observable by reading a getter and catching the assertion.\n\tfunction isContextRetired(ctx: ExtensionContext): boolean {\n\t\ttry {\n\t\t\tctx.isIdle();\n\t\t\treturn false;\n\t\t} catch {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\t// Fenced on the observed job: a prompt, invalidation, a reload, or a newer\n\t// warm-up stands this watcher down before it can start a duplicate\n\t// summarization.\n\tfunction armIdleWarmupRetry(ctx: ExtensionContext): void {\n\t\tconst job = speculativeJob;\n\t\tif (!job) return;\n\t\tvoid job.failure.then((failure) => {\n\t\t\tif (failure === undefined) {\n\t\t\t\tidleWarmupAttempt = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (speculativeJob !== job) return;\n\t\t\t// A reload between arming and this continuation retires the context.\n\t\t\tif (isContextRetired(ctx)) {\n\t\t\t\tcancelIdleWarmupRetry();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst usage = ctx.getContextUsage();\n\t\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\t\tconst settings = ctx.getCompactionSettings();\n\t\t\tconst breakerTripped = breaker.isTripped(state, Date.now());\n\t\t\tconst retryDecision: idleRetry.IdleWarmupRetryDecision = {\n\t\t\t\tattempt: idleWarmupAttempt,\n\t\t\t\ttransient: isTransientSummarizationFailure(failure, failure.message),\n\t\t\t\tisIdle: ctx.isIdle(),\n\t\t\t\tbreakerTripped,\n\t\t\t\tstillWarmEligible: idle.shouldWarmAtIdle({\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\taborted: false,\n\t\t\t\t\tsettings,\n\t\t\t\t\tusage,\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\tbreakerTripped,\n\t\t\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t\t\t\tmode: ctx.mode,\n\t\t\t\t}),\n\t\t\t};\n\t\t\tif (!idleRetry.shouldRetryIdleWarmup(retryDecision)) return;\n\t\t\tcancelIdleWarmupRetry();\n\t\t\tidleWarmupTimer = setTimeout(() => {\n\t\t\t\tidleWarmupTimer = undefined;\n\t\t\t\tif (speculativeJob !== job) return;\n\t\t\t\t// The reload may land after the timer was armed; a throw here would\n\t\t\t\t// escape into the timer queue as an uncaughtException.\n\t\t\t\tif (isContextRetired(ctx)) return;\n\t\t\t\tif (!ctx.isIdle()) return;\n\t\t\t\tidleWarmupAttempt += 1;\n\t\t\t\tgetLogger(ctx).debug(\"idle_trigger\", {\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\ttokens: usage?.tokens ?? 0,\n\t\t\t\t\tcount: idleWarmupAttempt,\n\t\t\t\t});\n\t\t\t\tinvalidateSpeculativeCompaction(ctx);\n\t\t\t\tstartSpeculativeCompaction(ctx, idle.IDLE_COMPACTION_INSTRUCTIONS);\n\t\t\t\tarmIdleWarmupRetry(ctx);\n\t\t\t\tarmIdleApply(ctx);\n\t\t\t}, idleRetry.IDLE_WARMUP_RETRY_DELAY_MS);\n\t\t});\n\t}\n\n\t/**\n\t * Apply the idle warm summary as soon as it finishes generating, while the\n\t * session is still idle. Holding it warm until the next `before_agent_start`\n\t * makes the user watch their own prompt wait behind a compaction they could\n\t * not see coming; applying during the idle gap renders the [compaction] block\n\t * first and lets the next message stack below it.\n\t *\n\t * Every guard is re-read at continuation time, because generation takes long\n\t * enough for all of them to change: the session may no longer be idle, the\n\t * job may have been invalidated or claimed, the context may have dropped\n\t * below the threshold, the lane may have been handed to the SDK, or the\n\t * breaker may have tripped. A refused apply (stale anchor/revision) silently\n\t * keeps the warm hold, so the next prompt consumes it exactly as before.\n\t */\n\tfunction armIdleApply(ctx: ExtensionContext): void {\n\t\tconst job = speculativeJob;\n\t\tif (!job) return;\n\t\t// Never throws out of the continuation: a retired context, a refused apply,\n\t\t// or a provider failure all resolve into a silent stand-down.\n\t\tvoid job.promise\n\t\t\t.then(async (compaction) => {\n\t\t\t\tif (!compaction) return;\n\t\t\t\tif (speculativeJob !== job) return;\n\t\t\t\tif (!sessionIdleSinceAgentEnd) return;\n\t\t\t\tif (isContextRetired(ctx)) return;\n\t\t\t\tif (!ctx.isIdle()) return;\n\t\t\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) return;\n\t\t\t\tif (breaker.isTripped(state, Date.now())) return;\n\t\t\t\tif (cap.shouldRejectByCap(state).cancel) return;\n\t\t\t\tconst usage = ctx.getContextUsage();\n\t\t\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\t\t\tif (\n\t\t\t\t\t!usage ||\n\t\t\t\t\t!policy.shouldTriggerCompaction(\n\t\t\t\t\t\tusage,\n\t\t\t\t\t\tcontextWindow,\n\t\t\t\t\t\tctx.getCompactionSettings(),\n\t\t\t\t\t\tstate.lastYield ?? undefined,\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst result = await applyGeneratedCompaction(ctx, job.snapshot, () => speculativeGeneration, compaction);\n\t\t\t\tif (!result.applied) return;\n\t\t\t\t// The job is consumed: clearing it here is also what stands the idle\n\t\t\t\t// retry watcher down for this generation.\n\t\t\t\tif (speculativeJob === job) speculativeJob = undefined;\n\t\t\t\tcancelIdleWarmupRetry();\n\t\t\t\tgetLogger(ctx).debug(\"idle_applied\", { generation: job.generation, origin: \"speculative\" });\n\t\t\t})\n\t\t\t.catch(() => {});\n\t}\n\n\tfunction isSameModelIdentity(\n\t\tleft: SpeculativeCompactionSnapshot[\"model\"],\n\t\tright: ExtensionContext[\"model\"],\n\t): boolean {\n\t\treturn (\n\t\t\tright !== undefined &&\n\t\t\tleft.api === right.api &&\n\t\t\tleft.provider === right.provider &&\n\t\t\tleft.id === right.id &&\n\t\t\tleft.baseUrl === right.baseUrl &&\n\t\t\tleft.contextWindow === right.contextWindow\n\t\t);\n\t}\n\n\t/**\n\t * Detach the warm job for the core route before any `await`, so exactly one\n\t * claimant can own it. The controller is deliberately NOT aborted: the whole\n\t * point is to keep the already-paid summarization alive and hand its result to\n\t * core, and clearing the reference is what stands the idle-retry watcher down.\n\t */\n\tfunction claimWarmSummaryForCoreRoute(\n\t\tevent: SessionBeforeCompactEvent,\n\t\tctx: ExtensionContext,\n\t): typeof speculativeJob {\n\t\tconst job = speculativeJob;\n\t\tif (!job) return undefined;\n\t\tif (event.customInstructions !== undefined) return undefined;\n\t\tif (job.snapshot.origin !== \"speculative\") return undefined;\n\t\tif (job.snapshot.preparation.firstKeptEntryId !== event.preparation.firstKeptEntryId) return undefined;\n\t\tif (!isSameModelIdentity(job.snapshot.model, ctx.model)) return undefined;\n\t\tconst anchor = createWarmAnchorSnapshot(\n\t\t\tjob.snapshot.preparation.firstKeptEntryId,\n\t\t\tjob.snapshot.branchEntries ?? [],\n\t\t);\n\t\tif (!anchor || !isWarmSummaryAnchorValid(anchor, event.branchEntries ?? ctx.sessionManager.getBranch())) {\n\t\t\treturn undefined;\n\t\t}\n\t\tspeculativeJob = undefined;\n\t\treturn job;\n\t}\n\n\tfunction invalidateSpeculativeCompaction(ctx: ExtensionContext): void {\n\t\tconst previousGeneration = speculativeGeneration;\n\t\tspeculativeGeneration++;\n\t\tgetLogger(ctx).debug(\"speculative_invalidated\", { generation: previousGeneration });\n\t\tspeculativeJob?.controller.abort();\n\t\tspeculativeJob = undefined;\n\t}\n\n\tfunction startSpeculativeCompaction(ctx: ExtensionContext, customInstructions: string): void {\n\t\tif (speculativeJob) return;\n\t\tconst generation = ++speculativeGeneration;\n\t\tconst snapshot = createSpeculativeCompactionSnapshot(ctx, {\n\t\t\tgeneration,\n\t\t\tcustomInstructions,\n\t\t\torigin: \"speculative\",\n\t\t\ttools: getSummarizationTools(),\n\t\t});\n\t\tif (!snapshot) return;\n\t\tgetLogger(ctx).debug(\"speculative_started\", { generation, origin: \"speculative\" });\n\t\tconst controller = new AbortController();\n\t\tconst settled = runExtensionCompaction(ctx, snapshot, controller.signal).then(\n\t\t\t(result) => ({ result, error: undefined }),\n\t\t\t(error: unknown) => ({ result: undefined, error: error instanceof Error ? error : new Error(String(error)) }),\n\t\t);\n\t\tspeculativeJob = trackSpeculativeJob({\n\t\t\tgeneration,\n\t\t\tsnapshot,\n\t\t\tcontroller,\n\t\t\tsettled,\n\t\t\tarmedAtTokens: ctx.getContextUsage()?.tokens ?? 0,\n\t\t});\n\t\tvoid settled.then(() => remoteCompactionDependencies.onSpeculativeJobSettled?.());\n\t}\n\n\tfunction capturePendingMetadata(requestId: string, ctx: ExtensionContext): void {\n\t\tpendingMetadata.set(requestId, {\n\t\t\tcheckpoint: checkpointState.captureAgentCheckpoint(pi, ctx),\n\t\t\ttodoSnapshot: todoBridge.createTodoSnapshot(ctx),\n\t\t});\n\t\twhile (pendingMetadata.size > MAX_PENDING_METADATA) {\n\t\t\tconst oldestRequestId = pendingMetadata.keys().next().value;\n\t\t\tif (oldestRequestId === undefined) break;\n\t\t\tpendingMetadata.delete(oldestRequestId);\n\t\t}\n\t}\n\n\tfunction persistAcceptedMetadata(requestId: string): void {\n\t\tconst metadata = pendingMetadata.get(requestId);\n\t\tif (!metadata) return;\n\t\tpendingMetadata.delete(requestId);\n\t\tcheckpointState.persistCheckpoint(pi, metadata.checkpoint);\n\t\ttodoBridge.persistTodoSnapshot(pi, metadata.todoSnapshot);\n\t}\n\n\tasync function applyBlockingCompaction(\n\t\tctx: ExtensionContext,\n\t\tcustomInstructions: string,\n\t): Promise<SpeculativeCompactionResult> {\n\t\tconst provider = ctx.model?.provider;\n\t\tif ((provider === \"cursor\" || provider === \"cursor-cli-oauth\") && !ctx.isIdle()) {\n\t\t\tgetLogger(ctx).debug(\"skip_cursor_mid_turn\", { route: \"blocking\" });\n\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t}\n\t\tif (breaker.isTripped(state, Date.now())) {\n\t\t\tgetLogger(ctx).debug(\"skip_breaker\", { route: \"blocking\" });\n\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t}\n\t\tif (cap.shouldRejectByCap(state).cancel) {\n\t\t\tgetLogger(ctx).debug(\"skip_cap\", { route: \"blocking\" });\n\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t}\n\t\tlet feedbackSignal = ctx.beginCompaction?.({ reason: \"extension\" });\n\t\ttry {\n\t\t\tlet remoteFallbackReason: string | undefined;\n\t\t\tif (isOpenAiRemoteCompactionModel(ctx.model)) {\n\t\t\t\tconst remoteGeneration = speculativeGeneration + 1;\n\t\t\t\tconst remoteSnapshot = createSpeculativeCompactionSnapshot(ctx, {\n\t\t\t\t\tgeneration: remoteGeneration,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\torigin: \"blocking\",\n\t\t\t\t});\n\t\t\t\tgetLogger(ctx).debug(\"blocking_started\", { generation: remoteGeneration, origin: \"blocking\" });\n\t\t\t\tif (remoteSnapshot) {\n\t\t\t\t\tconst remoteSignal = feedbackSignal ?? new AbortController().signal;\n\t\t\t\t\tconst remoteCompaction = await runOpenAiRemoteCompaction(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tcreateBlockingRemoteCompactionEvent(ctx, remoteSnapshot, customInstructions, remoteSignal),\n\t\t\t\t\t\t(data) => {\n\t\t\t\t\t\t\tif (data?.action === \"remote_fallback\" && typeof data.reason === \"string\") {\n\t\t\t\t\t\t\t\tremoteFallbackReason = data.reason;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpi.events.emit(SENPI_COMPACTION_EVENT, data);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tremoteCompactionDependencies,\n\t\t\t\t\t);\n\t\t\t\t\tif (remoteCompaction) {\n\t\t\t\t\t\tif (speculativeGeneration !== remoteGeneration - 1) {\n\t\t\t\t\t\t\tconst result = { applied: false, reason: \"stale\" } as const;\n\t\t\t\t\t\t\tgetLogger(ctx).debug(\"speculative_stale\", { generation: remoteGeneration });\n\t\t\t\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result);\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tspeculativeGeneration = remoteGeneration;\n\t\t\t\t\t\tspeculativeJob?.controller.abort();\n\t\t\t\t\t\tspeculativeJob = undefined;\n\t\t\t\t\t\tconst result = await applyGeneratedCompaction(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tremoteSnapshot,\n\t\t\t\t\t\t\t() => speculativeGeneration,\n\t\t\t\t\t\t\tremoteCompaction,\n\t\t\t\t\t\t\tfeedbackSignal,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tgetLogger(ctx).debug(\"speculative_applied\", { generation: remoteGeneration, origin: \"blocking\" });\n\t\t\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result);\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pendingJob = speculativeJob;\n\t\t\tif (pendingJob) {\n\t\t\t\tconst unlinkAbort = linkAbortSignal(feedbackSignal, pendingJob.controller);\n\t\t\t\tlet compaction: CompactionResult | undefined;\n\t\t\t\tlet inheritedFailure: Error | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tcompaction = await pendingJob.promise;\n\t\t\t\t\tinheritedFailure = await pendingJob.failure;\n\t\t\t\t\tif (compaction)\n\t\t\t\t\t\tgetLogger(ctx).debug(\"warm_consumed\", { generation: pendingJob.generation, route: \"speculative\" });\n\t\t\t\t} finally {\n\t\t\t\t\tunlinkAbort();\n\t\t\t\t}\n\t\t\t\tif (inheritedFailure !== undefined) {\n\t\t\t\t\tspeculativeJob = undefined;\n\t\t\t\t\tif (isTransientSummarizationFailure(inheritedFailure, inheritedFailure.message)) {\n\t\t\t\t\t\tctx.endCompaction?.({\n\t\t\t\t\t\t\treason: \"extension\",\n\t\t\t\t\t\t\tsignal: feedbackSignal,\n\t\t\t\t\t\t\taborted: feedbackSignal?.aborted,\n\t\t\t\t\t\t\terrorMessage: `Compaction failed: ${inheritedFailure.message}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tstate = breaker.recordFailure(state, Date.now(), { route: \"extension\" });\n\t\t\t\t\t\treturn { applied: false, reason: \"failed\" };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst result = await applyGeneratedCompaction(\n\t\t\t\t\tctx,\n\t\t\t\t\tpendingJob.snapshot,\n\t\t\t\t\t() => speculativeGeneration,\n\t\t\t\t\tcompaction,\n\t\t\t\t\tfeedbackSignal,\n\t\t\t\t);\n\t\t\t\tif (result.applied) {\n\t\t\t\t\tspeculativeJob = undefined;\n\t\t\t\t\tgetLogger(ctx).debug(\"speculative_applied\", {\n\t\t\t\t\t\tgeneration: pendingJob.generation,\n\t\t\t\t\t\torigin: \"speculative\",\n\t\t\t\t\t});\n\t\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tif (result.reason === \"stale\") {\n\t\t\t\t\tgetLogger(ctx).debug(\"speculative_stale\", { generation: pendingJob.generation });\n\t\t\t\t} else if (result.reason === \"rejected\") {\n\t\t\t\t\tfeedbackSignal = ctx.beginCompaction?.({ reason: \"extension\" });\n\t\t\t\t}\n\t\t\t\tspeculativeJob = undefined;\n\t\t\t}\n\n\t\t\tconst generation = ++speculativeGeneration;\n\t\t\tconst snapshot = createSpeculativeCompactionSnapshot(ctx, {\n\t\t\t\tgeneration,\n\t\t\t\tcustomInstructions,\n\t\t\t\torigin: \"core-route\",\n\t\t\t\ttools: getSummarizationTools(),\n\t\t\t});\n\t\t\tif (!snapshot) {\n\t\t\t\tconst result = { applied: false, reason: \"unavailable\" } as const;\n\t\t\t\tgetLogger(ctx).debug(\"summary_failed\", { reason: \"unavailable\" });\n\t\t\t\tendCompactionFeedback(ctx, feedbackSignal, result, remoteFallbackReason);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tlet compaction: CompactionResult | undefined;\n\t\t\ttry {\n\t\t\t\tcompaction = await runExtensionCompaction(ctx, snapshot, feedbackSignal, (delta) =>\n\t\t\t\t\tctx.updateCompaction?.({\n\t\t\t\t\t\treason: \"extension\",\n\t\t\t\t\t\tsignal: feedbackSignal,\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof SummaryGenerationError)) throw error;\n\t\t\t\tgetLogger(ctx).debug(\"summary_failed\", { reason: error.kind });\n\t\t\t}\n\t\t\tconst result = await applyGeneratedCompaction(\n\t\t\t\tctx,\n\t\t\t\tsnapshot,\n\t\t\t\t() => speculativeGeneration,\n\t\t\t\tcompaction,\n\t\t\t\tfeedbackSignal,\n\t\t\t);\n\t\t\tendCompactionFeedback(ctx, feedbackSignal, result, remoteFallbackReason);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (feedbackSignal?.aborted) {\n\t\t\t\t// An aborted blocking compaction is a cancellation, not a failure: no\n\t\t\t\t// red \"Compaction failed\" line, no breaker debit, no rethrow through\n\t\t\t\t// the before_agent_start handler (issue #886). The faux-route flavor\n\t\t\t\t// of this contract is pinned by blocking-compaction-review-hardening.\n\t\t\t\tgetLogger(ctx).debug(\"blocking_aborted\", { route: \"blocking\" });\n\t\t\t\tctx.endCompaction?.({ reason: \"extension\", signal: feedbackSignal, aborted: true });\n\t\t\t\treturn { applied: false, reason: \"rejected\" };\n\t\t\t}\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tctx.endCompaction?.({\n\t\t\t\treason: \"extension\",\n\t\t\t\tsignal: feedbackSignal,\n\t\t\t\taborted: feedbackSignal?.aborted,\n\t\t\t\terrorMessage: `Compaction failed: ${message}`,\n\t\t\t});\n\t\t\tconst transient = isTransientSummarizationFailure(error, message);\n\t\t\tif (transient) {\n\t\t\t\tstate = breaker.recordFailure(state, Date.now(), { route: \"extension\" });\n\t\t\t\treturn { applied: false, reason: \"failed\" };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpi.on(\"session_before_compact\", async (event: SessionBeforeCompactEvent, ctx) => {\n\t\t// A pre-aborted request (superseded admission or user cancel) must stand\n\t\t// down before touching warm-job ownership: core's own post-emit abort\n\t\t// checks turn it into a clean cancellation (issue #886).\n\t\tif (event.signal.aborted) return undefined;\n\t\tconst claimedWarmJob = claimWarmSummaryForCoreRoute(event, ctx);\n\t\t// The claim detaches the job without aborting it, so ownership must survive every\n\t\t// exit from this handler - including a throw - or the request it already paid for\n\t\t// keeps streaming for a result nobody will read.\n\t\tlet warmJobConsumed = false;\n\t\tinvalidateSpeculativeCompaction(ctx);\n\t\ttry {\n\t\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) {\n\t\t\t\treturn {\n\t\t\t\t\tcancel: true,\n\t\t\t\t\trejectionCause: \"external-owner\",\n\t\t\t\t\treason: SDK_NATIVE_LANE_REJECTION_REASON,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (cap.shouldRejectByCap(state).cancel) {\n\t\t\t\tgetLogger(ctx).debug(\"skip_cap\", { reason: event.reason, count: state.acceptedAbsolute });\n\t\t\t\treturn {\n\t\t\t\t\tcancel: true,\n\t\t\t\t\trejectionCause: \"per-turn-cap\",\n\t\t\t\t\treason: \"absolute compaction cap reached for this session\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst now = Date.now();\n\t\t\tif (breaker.isTripped(state, now) && !breaker.shouldBypass(state, { reason: event.reason })) {\n\t\t\t\tconst remainingMs = state.trippedAt !== null ? Math.max(0, state.trippedAt + breaker.COOLDOWN_MS - now) : 0;\n\t\t\t\tgetLogger(ctx).debug(\"skip_breaker\", { reason: event.reason, remainingSec: Math.ceil(remainingMs / 1000) });\n\t\t\t\treturn {\n\t\t\t\t\tcancel: true,\n\t\t\t\t\trejectionCause: \"circuit-breaker\",\n\t\t\t\t\treason: `compaction circuit breaker cooling down (${Math.ceil(remainingMs / 1000)}s left)`,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tcapturePendingMetadata(event.requestId, ctx);\n\n\t\t\tconst model = ctx.model;\n\t\t\tif (!model) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tlet remoteCompaction: Awaited<ReturnType<typeof runOpenAiRemoteCompaction>>;\n\t\t\ttry {\n\t\t\t\tremoteCompaction = await runOpenAiRemoteCompaction(\n\t\t\t\t\tctx,\n\t\t\t\t\tevent,\n\t\t\t\t\t(data) => pi.events.emit(SENPI_COMPACTION_EVENT, data),\n\t\t\t\t\tremoteCompactionDependencies,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\t// The remote route deliberately rethrows once its signal aborts; the\n\t\t\t\t// handler converts that into a silent stand-down so the abort is not\n\t\t\t\t// reported as an extension error with a stack (issue #886).\n\t\t\t\tif (!event.signal.aborted) throw error;\n\t\t\t\tgetLogger(ctx).debug(\"remote_aborted\", { route: \"core-route\", requestId: event.requestId });\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (remoteCompaction) {\n\t\t\t\tgetLogger(ctx).debug(\"core_route_generated\", { route: \"core-route\", requestId: event.requestId });\n\t\t\t\treturn { compaction: remoteCompaction };\n\t\t\t}\n\n\t\t\tif (claimedWarmJob) {\n\t\t\t\tconst unlinkAbort = linkAbortSignal(event.signal, claimedWarmJob.controller);\n\t\t\t\tlet warmCompaction: CompactionResult | undefined;\n\t\t\t\tlet warmFailure: Error | undefined;\n\t\t\t\ttry {\n\t\t\t\t\twarmCompaction = await claimedWarmJob.promise;\n\t\t\t\t\twarmFailure = await claimedWarmJob.failure;\n\t\t\t\t} finally {\n\t\t\t\t\tunlinkAbort();\n\t\t\t\t}\n\t\t\t\tif (warmFailure === undefined && warmCompaction && !event.signal.aborted) {\n\t\t\t\t\tgetLogger(ctx).debug(\"warm_consumed\", { generation: claimedWarmJob.generation, route: \"core-route\" });\n\t\t\t\t\twarmJobConsumed = true;\n\t\t\t\t\treturn { compaction: warmCompaction };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst snapshot = {\n\t\t\t\tgeneration: ++speculativeGeneration,\n\t\t\t\texpectedRevision: ctx.getMessageRevision(),\n\t\t\t\tmodel,\n\t\t\t\tcontextWindow: ctx.getContextUsage()?.contextWindow ?? model.contextWindow ?? DEFAULT_CONTEXT_WINDOW,\n\t\t\t\tpreparation: event.preparation,\n\t\t\t\tbranchEntries: event.branchEntries,\n\t\t\t\tpromptVariant: getPromptVariant(event),\n\t\t\t\torigin: \"core-route\" as const,\n\t\t\t\tcustomInstructions: event.customInstructions,\n\t\t\t\tsystemPrompt: ctx.getSystemPrompt(),\n\t\t\t\ttools: getSummarizationTools(),\n\t\t\t};\n\t\t\tlet compaction: CompactionResult | undefined;\n\t\t\ttry {\n\t\t\t\tcompaction = await runExtensionCompaction(ctx, snapshot, event.signal, (delta) =>\n\t\t\t\t\tctx.updateCompaction?.({ reason: event.reason, signal: event.signal, delta }),\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconst failureKind = classifyRequiredCompactionFallbackFailure(error);\n\t\t\t\tif (\n\t\t\t\t\tisRequiredCompactionFallbackReason(event.reason) &&\n\t\t\t\t\tfailureKind !== undefined &&\n\t\t\t\t\t!event.signal.aborted\n\t\t\t\t) {\n\t\t\t\t\tconst fallback = createRequiredCompactionFallback(\n\t\t\t\t\t\tsnapshot.preparation,\n\t\t\t\t\t\tsnapshot.contextWindow,\n\t\t\t\t\t\tfailureKind,\n\t\t\t\t\t\t{ taskIntent: resolveInheritedTaskIntent(event.branchEntries) },\n\t\t\t\t\t\tevent.branchEntries,\n\t\t\t\t\t);\n\t\t\t\t\tif (fallback) return { compaction: fallback };\n\t\t\t\t\tpendingMetadata.delete(event.requestId);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcancel: true,\n\t\t\t\t\t\treason: \"deterministic compaction fallback cannot retain the prepared suffix\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tpendingMetadata.delete(event.requestId);\n\t\t\t\tif (error instanceof SummaryGenerationError) {\n\t\t\t\t\treturn { cancel: true, reason: error.message };\n\t\t\t\t}\n\t\t\t\treturn { cancel: true, reason: `compaction generator failed: ${message}` };\n\t\t\t}\n\t\t\tif (!compaction) {\n\t\t\t\tpendingMetadata.delete(event.requestId);\n\t\t\t\tif (event.signal.aborted) {\n\t\t\t\t\treturn { cancel: true };\n\t\t\t\t}\n\t\t\t\treturn { cancel: true, reason: \"compaction generator returned no summary\" };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcompaction,\n\t\t\t};\n\t\t} finally {\n\t\t\tif (!warmJobConsumed) claimedWarmJob?.controller.abort();\n\t\t}\n\t});\n\n\tpi.on(\"model_select\", (event, ctx) =>\n\t\thandleCompactionModelSelect({\n\t\t\tevent,\n\t\t\tctx,\n\t\t\tstate,\n\t\t\tspeculativeSnapshot: speculativeJob?.snapshot,\n\t\t\tlaneOwnsCompaction: lanePolicy.disablesSenpiCompaction(ctx),\n\t\t\tbreakerTripped: breaker.isTripped(state, Date.now()),\n\t\t\tinvalidate: () => invalidateSpeculativeCompaction(ctx),\n\t\t\tstart: () => startSpeculativeCompaction(ctx, PROACTIVE_COMPACTION_INSTRUCTIONS),\n\t\t}),\n\t);\n\n\tpi.on(\"session_compact\", async (event: SessionCompactEvent, ctx) => {\n\t\tconst compactEvent = event;\n\t\tinvalidateSpeculativeCompaction(ctx);\n\t\tif (compactEvent.accepted) {\n\t\t\tpersistAcceptedMetadata(compactEvent.requestId);\n\t\t\tconst branchEntries = ctx.sessionManager.getBranch();\n\t\t\tconst firstKeptIndex = branchEntries.findIndex(\n\t\t\t\t(entry) => entry.id === compactEvent.compactionEntry.firstKeptEntryId,\n\t\t\t);\n\t\t\tconst keptEntries = firstKeptIndex === -1 ? [] : branchEntries.slice(firstKeptIndex);\n\t\t\tstate = cap.incrementAccepted(state);\n\t\t\tstate = breaker.recordSuccess(state);\n\t\t\treminderState = createInitialReminderState();\n\t\t\tconst details = compactEvent.compactionEntry.details as\n\t\t\t\t| { structuralYield?: { savedTokens: number; savingsRatio: number } }\n\t\t\t\t| undefined;\n\t\t\tconst sy = details?.structuralYield;\n\t\t\tif (sy && typeof sy.savedTokens === \"number\" && typeof sy.savingsRatio === \"number\") {\n\t\t\t\tstate = {\n\t\t\t\t\t...state,\n\t\t\t\t\tlastYield: { savedTokens: sy.savedTokens, tokensBefore: compactEvent.compactionEntry.tokensBefore },\n\t\t\t\t};\n\t\t\t\tif (\n\t\t\t\t\tisIneffectiveCompaction({\n\t\t\t\t\t\ttokensBefore: compactEvent.compactionEntry.tokensBefore,\n\t\t\t\t\t\tsavedTokens: sy.savedTokens,\n\t\t\t\t\t\tsavingsRatio: sy.savingsRatio,\n\t\t\t\t\t})\n\t\t\t\t) {\n\t\t\t\t\tstate = cap.incrementIneffective(state);\n\t\t\t\t\tgetLogger(ctx).debug(\"ineffective_counted\", {\n\t\t\t\t\t\ttokensBefore: compactEvent.compactionEntry.tokensBefore,\n\t\t\t\t\t\tsavedTokens: sy.savedTokens,\n\t\t\t\t\t\tsavingsRatio: sy.savingsRatio,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tresetOnSessionCompact(degradationState);\n\t\t\ttodoBridge.restoreTodosIfMissing(pi, ctx);\n\t\t\tconst usage = ctx.getContextUsage();\n\t\t\tconst settings = ctx.getCompactionSettings();\n\t\t\tif (settings.restorationEnabled ?? true) {\n\t\t\t\trestoration.preparePendingPayload(restorationState, {\n\t\t\t\t\taccepted: true,\n\t\t\t\t\treason: compactEvent.reason,\n\t\t\t\t\tcompactionEntryId: compactEvent.compactionEntry.id,\n\t\t\t\t\tcontextWindow: usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW,\n\t\t\t\t\tusageTokens: usage?.tokens ?? null,\n\t\t\t\t\treserveTokens: policy.resolveEffectiveReserveTokens(\n\t\t\t\t\t\tusage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW,\n\t\t\t\t\t\tsettings,\n\t\t\t\t\t),\n\t\t\t\t\tsettings,\n\t\t\t\t\tkeptMessages: keptEntries.flatMap((entry) => {\n\t\t\t\t\t\tif (entry.type !== \"message\") return [];\n\t\t\t\t\t\treturn [entry.message];\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (compactEvent.rejectionCause === \"external-owner\") return;\n\t\tif (!lanePolicy.disablesSenpiCompaction(ctx)) {\n\t\t\tstate = breaker.recordFailure(state, Date.now(), { route: compactEvent.reason });\n\t\t}\n\t});\n\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\tsessionIdleSinceAgentEnd = false;\n\t\tcancelIdleWarmupRetry();\n\t\tconst message = checkpointState.attachRestorationDirective(\n\t\t\trestorationDirectiveState,\n\t\t\trecentCheckpoint(ctx),\n\t\t\trestoration.consumePendingPayload(restorationState),\n\t\t);\n\n\t\tconst usage = ctx.getContextUsage();\n\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\tconst settings = ctx.getCompactionSettings();\n\t\tconst pendingPromptTokens = estimatePendingPromptTokens(event);\n\t\tconst usageWithPendingPrompt = usage ? withAdditionalTokens(usage, pendingPromptTokens) : undefined;\n\t\t// The SDK owns this lane's context entirely, so even the hard-limit valve stands down;\n\t\t// the circuit breaker never blocks that valve for senpi-owned lanes.\n\t\tconst laneOwnsCompaction = lanePolicy.disablesSenpiCompaction(ctx);\n\t\tconst breakerCoolingDown = breaker.isTripped(state, Date.now()) || laneOwnsCompaction;\n\t\tconst { reserveTokens, thresholdTokens, leadTokens } = resolveCompactionGeometry({\n\t\t\tcontextWindow,\n\t\t\tsettings,\n\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t});\n\t\tif (\n\t\t\t!laneOwnsCompaction &&\n\t\t\tusage &&\n\t\t\tpolicy.isAtHardLimit(usage, contextWindow, reserveTokens, pendingPromptTokens)\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"hard_limit_trigger\", {\n\t\t\t\tcontextWindow,\n\t\t\t\ttokens: usage.tokens ?? 0,\n\t\t\t\tthreshold: settings.reserveTokens,\n\t\t\t});\n\t\t\tawait applyBlockingCompaction(ctx, EMERGENCY_COMPACTION_INSTRUCTIONS);\n\t\t} else if (\n\t\t\t!breakerCoolingDown &&\n\t\t\tusageWithPendingPrompt &&\n\t\t\tpolicy.shouldTriggerCompaction(usageWithPendingPrompt, contextWindow, settings, state.lastYield ?? undefined)\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"threshold_trigger\", {\n\t\t\t\tcontextWindow,\n\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t\tthreshold: settings.reserveTokens,\n\t\t\t});\n\t\t\tif (\n\t\t\t\t!shouldDeferGraceBand({\n\t\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t\t\tthresholdTokens,\n\t\t\t\t\tleadTokens,\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\treserveTokens,\n\t\t\t\t\tcompactionInFlight: speculativeJob !== undefined && !speculativeJob.completed,\n\t\t\t\t\tgraceBandEnabled: settings.graceBandEnabled,\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\tawait applyBlockingCompaction(ctx, PROACTIVE_COMPACTION_INSTRUCTIONS);\n\t\t\t} else {\n\t\t\t\tgetLogger(ctx).debug(\"grace_deferred\", {\n\t\t\t\t\ttokens: usageWithPendingPrompt.tokens ?? 0,\n\t\t\t\t\tthreshold: thresholdTokens,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (\n\t\t\t!breakerCoolingDown &&\n\t\t\t!isOpenAiRemoteCompactionModel(ctx.model) &&\n\t\t\tusageWithPendingPrompt &&\n\t\t\tpolicy.shouldStartSpeculativeCompaction(\n\t\t\t\tusageWithPendingPrompt,\n\t\t\t\tcontextWindow,\n\t\t\t\tsettings,\n\t\t\t\tstate.lastYield ?? undefined,\n\t\t\t\tleadTokens,\n\t\t\t)\n\t\t) {\n\t\t\t// The speculative start below logs \"speculative_started\" itself; logging\n\t\t\t// \"emergency_prune\" here mislabeled proactive speculation as pruning and\n\t\t\t// corrupted the counter the incident analysis relies on.\n\t\t\tstartSpeculativeCompaction(ctx, PROACTIVE_COMPACTION_INSTRUCTIONS);\n\t\t}\n\n\t\tconst reminder = computeTokenBudgetReminder({\n\t\t\tcontextTokens: usageWithPendingPrompt?.tokens ?? 0,\n\t\t\tcontextWindow,\n\t\t\tthresholdTokens,\n\t\t\tleadTokens,\n\t\t\tcompactionEpoch: speculativeGeneration,\n\t\t\tstate: reminderState,\n\t\t});\n\t\treminderState = reminder.nextState;\n\t\tconst deliveredMessage = resolveBeforeAgentStartMessage({\n\t\t\tmessage,\n\t\t\treminder: reminder.message,\n\t\t\treminderEnabled: settings.reminderEnabled,\n\t\t});\n\t\tconst reminderSystemPrompt = resolveReminderSystemPrompt({\n\t\t\tsystemPrompt: event.systemPrompt,\n\t\t\treminder: !message ? reminder.message : undefined,\n\t\t\treminderEnabled: settings.reminderEnabled,\n\t\t});\n\t\tif (!deliveredMessage && !reminderSystemPrompt) return undefined;\n\t\treturn {\n\t\t\t...(deliveredMessage ? { message: deliveredMessage } : {}),\n\t\t\t...(reminderSystemPrompt ? { systemPrompt: reminderSystemPrompt } : {}),\n\t\t};\n\t});\n\n\tpi.on(\"context\", (event, ctx) => {\n\t\tconst usage = ctx.getContextUsage();\n\t\tconst settings = ctx.getCompactionSettings();\n\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\tconst laneOwnsCompaction = lanePolicy.disablesSenpiCompaction(ctx);\n\t\tconst breakerFallback =\n\t\t\t!laneOwnsCompaction &&\n\t\t\tbreaker.isTripped(state, Date.now()) &&\n\t\t\tusage?.tokens !== null &&\n\t\t\tusage !== undefined &&\n\t\t\tusage.tokens >= contextWindow * policy.computeEffectiveThreshold(contextWindow, state.lastYield ?? undefined);\n\t\tif (breakerFallback)\n\t\t\tgetLogger(ctx).debug(\"breaker_deterministic_fallback\", { route: \"context-event\", tokens: usage.tokens ?? 0 });\n\t\treturn {\n\t\t\tmessages: buildCompactionContext({\n\t\t\t\tevent,\n\t\t\t\tctx,\n\t\t\t\tcontextWindow,\n\t\t\t\tpromptContextWindow: getPromptContextWindow(contextWindow, ctx.model?.maxTokens),\n\t\t\t\ttoolAdmissionEnabled: settings.toolAdmissionEnabled !== false,\n\t\t\t\tbreakerFallback,\n\t\t\t\tlaneOwnsCompaction,\n\t\t\t\temergencyPruneLatch,\n\t\t\t\tlogEmergencyPrune: (fields) => getLogger(ctx).debug(\"emergency_prune\", fields),\n\t\t\t}),\n\t\t};\n\t});\n\n\tpi.on(\"before_provider_request\", async (event, ctx) => {\n\t\tconst model = event.model ?? ctx.model;\n\t\tif (!isOpenAiRemoteCompactionModel(model)) return undefined;\n\t\tconst auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);\n\t\tif (!auth.ok) return undefined;\n\t\tconst effectiveModel =\n\t\t\tauth.upstreamModelId || auth.baseUrl\n\t\t\t\t? {\n\t\t\t\t\t\t...model,\n\t\t\t\t\t\t...(auth.upstreamModelId ? { id: auth.upstreamModelId } : {}),\n\t\t\t\t\t\t...(auth.baseUrl ? { baseUrl: auth.baseUrl } : {}),\n\t\t\t\t\t}\n\t\t\t\t: model;\n\t\tconst headers = createOpenAiRemoteCompactionHeaders(\n\t\t\teffectiveModel,\n\t\t\t{ ...auth, headers: event.headers ?? auth.headers },\n\t\t\tctx.sessionManager.getSessionId(),\n\t\t);\n\t\tif (!headers) return undefined;\n\t\tconst origin = openAiRemoteCompactionOrigin(effectiveModel, headers);\n\t\treturn rewriteOpenAiPayloadWithRemoteCompaction(\n\t\t\tevent.payload,\n\t\t\t{ model: effectiveModel, branchEntries: ctx.sessionManager.getBranch(), origin },\n\t\t\t(data) => pi.events.emit(SENPI_COMPACTION_EVENT, data),\n\t\t);\n\t});\n\n\tpi.on(\"turn_end\", async (_event, ctx) => {\n\t\ttry {\n\t\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) return;\n\t\t\thandleTurnEnd(degradationState);\n\t\t\tif (degradationState.recoveryTriggeredThisCycle) return;\n\t\t\tif (state.lastYield && state.lastYield.savedTokens <= 0) {\n\t\t\t\tvoid applyBlockingCompaction(ctx, RECOVERY_INSTRUCTIONS).catch(() => {});\n\t\t\t}\n\t\t} finally {\n\t\t\tstate = resetTurnCounter(state, \"\");\n\t\t}\n\t});\n\n\tpi.on(\"agent_end\", async (event, ctx) => {\n\t\tstate = resetTurnCounter(state, \"\");\n\t\tif (lanePolicy.disablesSenpiCompaction(ctx)) return;\n\t\tconst usage = ctx.getContextUsage();\n\t\tconst contextWindow = usage?.contextWindow ?? ctx.model?.contextWindow ?? DEFAULT_CONTEXT_WINDOW;\n\t\tconst settings = ctx.getCompactionSettings();\n\t\tif (\n\t\t\tidle.shouldRunIdleCompaction({\n\t\t\t\twillRetry: event.willRetry ?? false,\n\t\t\t\taborted: event.aborted === true,\n\t\t\t\tsettings,\n\t\t\t\tusage,\n\t\t\t\tcontextWindow,\n\t\t\t\tbreakerTripped: breaker.isTripped(state, Date.now()),\n\t\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t\t\tmode: ctx.mode,\n\t\t\t})\n\t\t) {\n\t\t\tgetLogger(ctx).debug(\"idle_trigger\", { contextWindow, tokens: usage?.tokens ?? 0 });\n\t\t\tidleWarmupAttempt = 0;\n\t\t\tsessionIdleSinceAgentEnd = true;\n\t\t\tstartSpeculativeCompaction(ctx, idle.IDLE_COMPACTION_INSTRUCTIONS);\n\t\t\tarmIdleWarmupRetry(ctx);\n\t\t\tarmIdleApply(ctx);\n\t\t} else {\n\t\t\t// A sub-threshold OpenAI warm-up cannot be consumed by the remote\n\t\t\t// compaction route. Once threshold admission succeeds remotely, it would\n\t\t\t// only abort and discard this paid local summary. Above threshold we keep\n\t\t\t// the existing local idle apply, which can finish before the next prompt;\n\t\t\t// if remote compaction later falls back, blocking local generation remains\n\t\t\t// unchanged.\n\t\t\tif (isOpenAiRemoteCompactionModel(ctx.model)) return;\n\t\t\tconst warmAction = resolveIdleWarmAction(\n\t\t\t\t{\n\t\t\t\t\twillRetry: event.willRetry ?? false,\n\t\t\t\t\taborted: event.aborted === true,\n\t\t\t\t\tsettings,\n\t\t\t\t\tusage,\n\t\t\t\t\tcontextWindow,\n\t\t\t\t\tbreakerTripped: breaker.isTripped(state, Date.now()),\n\t\t\t\t\tlastYield: state.lastYield ?? undefined,\n\t\t\t\t\tmode: ctx.mode,\n\t\t\t\t},\n\t\t\t\tspeculativeJob,\n\t\t\t);\n\t\t\tif (warmAction === \"replace\") invalidateSpeculativeCompaction(ctx);\n\t\t\tif (warmAction !== \"none\") {\n\t\t\t\tidleWarmupAttempt = 0;\n\t\t\t\tsessionIdleSinceAgentEnd = true;\n\t\t\t\tstartSpeculativeCompaction(ctx, idle.IDLE_COMPACTION_INSTRUCTIONS);\n\t\t\t\tarmIdleWarmupRetry(ctx);\n\t\t\t\tarmIdleApply(ctx);\n\t\t\t}\n\t\t}\n\t});\n\n\tpi.on(\"message_end\", async (event, ctx) => {\n\t\tfor (const entry of collectCompactBoundaryEntries(event.message)) {\n\t\t\tpi.appendEntry(CLAUDE_SDK_OAUTH_COMPACT_ENTRY_TYPE, entry);\n\t\t}\n\t\tif (isAbortedAssistantMessage(event)) {\n\t\t\tinvalidateSpeculativeCompaction(ctx);\n\t\t}\n\t\tif (isMonitorableMessageEvent(event) && !lanePolicy.disablesSenpiCompaction(ctx)) {\n\t\t\tawait handleMessageEnd(degradationState, event, {\n\t\t\t\tapplyCompaction: async (options) => {\n\t\t\t\t\treturn await applyBlockingCompaction(ctx, options.customInstructions);\n\t\t\t\t},\n\t\t\t\tnotify: (message) => ctx.ui.notify(message, \"warning\"),\n\t\t\t});\n\t\t}\n\t});\n\n\tpi.on(\"tool_call\", (event) => {\n\t\trestoration.trackToolCall(restorationState, event);\n\t});\n\n\t// The reload path retires this extension generation right after this event\n\t// (`AgentSession.reload()` invalidates the old runner), so stand the idle\n\t// warm-up watcher down here rather than leaving a timer armed against a\n\t// context that is about to start throwing on every read.\n\tpi.on(\"session_shutdown\", () => {\n\t\tsessionIdleSinceAgentEnd = false;\n\t\tcancelIdleWarmupRetry();\n\t\tidleWarmupAttempt = 0;\n\t\tspeculativeJob?.controller.abort();\n\t\tspeculativeJob = undefined;\n\t});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-fable-5-1.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5-1.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAoElH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMzF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Claude Fable 5.1 / Mythos 5.1 full-core system prompt.
|
|
2
|
+
//
|
|
3
|
+
// 2026-09-02 diet. The first 5.1 preset was the dieted claude-fable-5 core plus
|
|
4
|
+
// seven deltas from Anthropic's Fable 5.1 prompting guide, appended where each
|
|
5
|
+
// fit. Reading the guide set end to end (claude.md, the Fable 5 / 5.1 overlays,
|
|
6
|
+
// the Opus 4.8 overlay, the GPT-5.5/5.6 and Kimi doctrine) against that text
|
|
7
|
+
// showed three kinds of dead weight, and this rewrite removes them while
|
|
8
|
+
// keeping every documented behavior:
|
|
9
|
+
// - Rules stated in several sections: scope discipline lived in the intent
|
|
10
|
+
// gate, Verification, and Style; the stop contract in the intent gate, Style,
|
|
11
|
+
// and the closing line; "user's call is final" and "check in only when
|
|
12
|
+
// readings differ" twice each; evidence rules three times. Each now has one
|
|
13
|
+
// home (a dedicated Scope section carries the 5.1 "Delivering work" and
|
|
14
|
+
// "changes and tests" blocks together with the Fable 5 anti-over-engineering
|
|
15
|
+
// rule).
|
|
16
|
+
// - Traits the model already has by default: "no filler openers, no
|
|
17
|
+
// self-praise, no hedging" (claude.md / Opus 4.8: direct, low-validation
|
|
18
|
+
// style; 5.1: fewer stock phrases), quoted anti-example scaffolding, and the
|
|
19
|
+
// rationale flourishes ("breadth is cheap", "verification theater"). The
|
|
20
|
+
// 5.1 guide names mannered prose as the anti-pattern and claude.md says the
|
|
21
|
+
// prompt's register shapes the output's, so the text is written in the
|
|
22
|
+
// literal register it asks for.
|
|
23
|
+
// - One documented behavior was missing: the Fable 5 guide asks for explicit
|
|
24
|
+
// delegation guidance ("use subagents frequently ... keep working while they
|
|
25
|
+
// run"; the 5.1 guide adds that the lead should not idle), and senpi's
|
|
26
|
+
// delegation tools return immediately, so Working the Task carries one
|
|
27
|
+
// sentence on it. The 5.1 "Delivering work" clause about doing the
|
|
28
|
+
// answer-independent work before asking a question was also unported.
|
|
29
|
+
// Still deliberately omitted as harness-level or non-coding: effort levels,
|
|
30
|
+
// append-only history, the quoting-sources example, the compaction summary
|
|
31
|
+
// instruction, the low-effort search nudge, the xhigh/max long-output note,
|
|
32
|
+
// vision crop tools, memory-system prompts, and the "user is not watching"
|
|
33
|
+
// autonomy opener (false for an interactive CLI). Shared pieces stay
|
|
34
|
+
// single-sourced: buildTestDisciplineSection(), the rendered tool section, the
|
|
35
|
+
// grep/glob search line, workstationDialect "claude"; dynamic pieces (context
|
|
36
|
+
// files, skills, date, cwd) still come from buildDynamicSystemPrompt.
|
|
37
|
+
import { APP_NAME } from "../../../../config.js";
|
|
38
|
+
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
39
|
+
import { getToolsPromptDisplay } from "../../../dynamic-prompt/tool-categorization.js";
|
|
40
|
+
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
41
|
+
import { buildExecutionToolingParagraph } from "./execution-tooling.js";
|
|
42
|
+
function buildSearchLine(context) {
|
|
43
|
+
const triggerTools = getToolsPromptDisplay(context.tools);
|
|
44
|
+
if (!triggerTools) {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
return `\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\n`;
|
|
48
|
+
}
|
|
49
|
+
function buildClaudeFable51Core(context) {
|
|
50
|
+
return `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.
|
|
51
|
+
|
|
52
|
+
## Intent Gate
|
|
53
|
+
|
|
54
|
+
Open every turn with one short routing line:
|
|
55
|
+
|
|
56
|
+
> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].
|
|
57
|
+
|
|
58
|
+
Only the user's explicit request commits you to implementation. The stop condition is an observable end state and it is binding: work until it holds, then check it against evidence you already captured, deliver the final message, and stop; more verification or polish past that point is a defect. Never echo prompt scaffolding in user-facing output.
|
|
59
|
+
${buildSearchLine(context)}
|
|
60
|
+
Route by true intent, not surface form:
|
|
61
|
+
- Information asks (explain, look into, investigate): read the code and report; no edits.
|
|
62
|
+
- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.
|
|
63
|
+
- Change asks (implement, add, fix this error): build, or diagnose and fix minimally.
|
|
64
|
+
|
|
65
|
+
Derive intent from the latest user turn alone: a new direction drops the stale plan, and queued steering messages outrank earlier intent.
|
|
66
|
+
|
|
67
|
+
## Scope
|
|
68
|
+
|
|
69
|
+
The request sets the scope, and the scope is the deliverable: deliver all of it and only it. Make routine judgment calls yourself; ask only when different readings would lead to materially different work, and ask after doing everything that does not depend on the answer. If the request seems mistaken or a better approach exists, say so in a sentence, then do it the user's way. If part of the task is blocked, finish every other part and say exactly what you left out and why.
|
|
70
|
+
|
|
71
|
+
Smallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code; validate only at system boundaries. A pre-existing bug or performance concern you notice is a follow-up for your summary, not a change in this diff. Scratch checks verify and get discarded; commit tests only where the task asks for them or the repository already keeps tests for that kind of change, sized like the neighboring test files. Prefer a surgical edit over rewriting a file when the result would be identical.
|
|
72
|
+
|
|
73
|
+
## Working the Task
|
|
74
|
+
|
|
75
|
+
Before each response, privately list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Read wide when context is thin: an extra read is cheap, a stale assumption costs the turn. Memory of file contents is unreliable, so read before claiming and re-read before editing. Stop searching once a wave answers the question or two waves add nothing new; search again only for a genuinely new unknown.
|
|
76
|
+
|
|
77
|
+
${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: "claude" })}When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has made, or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents and keep working while they run; keep work you can finish in a few calls yourself.
|
|
78
|
+
|
|
79
|
+
## Verification
|
|
80
|
+
|
|
81
|
+
Scale the checks to the change, never the rigor: diagnostics on every changed file always; related tests and one run of the affected entry point for behavioral changes; build plus manual exercise of the user-visible behavior through its real surface for multi-file or cross-cutting work.
|
|
82
|
+
|
|
83
|
+
${buildTestDisciplineSection()}
|
|
84
|
+
|
|
85
|
+
"Should pass" is not verification: run the validator. Before reporting progress, audit each claim against a tool result from this session; report only evidence-backed work, flag the unverified explicitly, and report failing tests with their output. Fix only failures your change caused.
|
|
86
|
+
|
|
87
|
+
${context.toolSection}
|
|
88
|
+
|
|
89
|
+
## Hard Limits
|
|
90
|
+
|
|
91
|
+
- Never create a git commit unless the user explicitly requested it.
|
|
92
|
+
- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.
|
|
93
|
+
- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.
|
|
94
|
+
|
|
95
|
+
## Style
|
|
96
|
+
|
|
97
|
+
Act, then report: for reversible steps the request already covers, proceed without asking. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, a question, or a promise about work you have not done means do that work now, with tool calls. Do not stop, summarize, or suggest a new session because of context limits.
|
|
98
|
+
|
|
99
|
+
Have an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.
|
|
100
|
+
|
|
101
|
+
Say what you mean: when a literal phrase is available, use it instead of metaphor or flourish. Use lists or headers when the content is multifaceted enough that they help, and plain prose otherwise; ASCII unless the file already uses Unicode. Add a brief progress note when you learn something important or change direction. Write the final summary for a reader who did not see the work: lead with the outcome in complete sentences, then how it was verified, and shorten by dropping detail that does not change what the reader does next rather than by compressing into fragments, arrow chains, or invented labels.`;
|
|
102
|
+
}
|
|
103
|
+
export function buildClaudeFable51Prompt(options) {
|
|
104
|
+
return buildDynamicSystemPrompt({
|
|
105
|
+
...options,
|
|
106
|
+
corePrompt: buildClaudeFable51Core,
|
|
107
|
+
workstationDialect: "claude",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=claude-fable-5-1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-fable-5-1.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5-1.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,yEAAyE;AACzE,qCAAqC;AACrC,2EAA2E;AAC3E,gFAAgF;AAChF,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,+EAA+E;AAC/E,WAAW;AACX,oEAAoE;AACpE,2EAA2E;AAC3E,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,kCAAkC;AAClC,6EAA6E;AAC7E,+EAA+E;AAC/E,yEAAyE;AACzE,yEAAyE;AACzE,qEAAqE;AACrE,wEAAwE;AACxE,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,qEAAqE;AACrE,+EAA+E;AAC/E,8EAA8E;AAC9E,sEAAsE;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,SAAS,eAAe,CAAC,OAAiC;IACzD,MAAM,YAAY,GAAG,qBAAqB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,6CAA6C,YAAY,0GAA0G,CAAC;AAC5K,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAiC;IAChE,OAAO,WAAW,QAAQ;;;;;;;;;EASzB,eAAe,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;EAkBxB,8BAA8B,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;;;;;EAMxG,0BAA0B,EAAE;;;;EAI5B,OAAO,CAAC,WAAW;;;;;;;;;;;;;;smBAcilB,CAAC;AACvmB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAwC;IAChF,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,UAAU,EAAE,sBAAsB;QAClC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Claude Fable 5.1 / Mythos 5.1 full-core system prompt.\n//\n// 2026-09-02 diet. The first 5.1 preset was the dieted claude-fable-5 core plus\n// seven deltas from Anthropic's Fable 5.1 prompting guide, appended where each\n// fit. Reading the guide set end to end (claude.md, the Fable 5 / 5.1 overlays,\n// the Opus 4.8 overlay, the GPT-5.5/5.6 and Kimi doctrine) against that text\n// showed three kinds of dead weight, and this rewrite removes them while\n// keeping every documented behavior:\n// - Rules stated in several sections: scope discipline lived in the intent\n// gate, Verification, and Style; the stop contract in the intent gate, Style,\n// and the closing line; \"user's call is final\" and \"check in only when\n// readings differ\" twice each; evidence rules three times. Each now has one\n// home (a dedicated Scope section carries the 5.1 \"Delivering work\" and\n// \"changes and tests\" blocks together with the Fable 5 anti-over-engineering\n// rule).\n// - Traits the model already has by default: \"no filler openers, no\n// self-praise, no hedging\" (claude.md / Opus 4.8: direct, low-validation\n// style; 5.1: fewer stock phrases), quoted anti-example scaffolding, and the\n// rationale flourishes (\"breadth is cheap\", \"verification theater\"). The\n// 5.1 guide names mannered prose as the anti-pattern and claude.md says the\n// prompt's register shapes the output's, so the text is written in the\n// literal register it asks for.\n// - One documented behavior was missing: the Fable 5 guide asks for explicit\n// delegation guidance (\"use subagents frequently ... keep working while they\n// run\"; the 5.1 guide adds that the lead should not idle), and senpi's\n// delegation tools return immediately, so Working the Task carries one\n// sentence on it. The 5.1 \"Delivering work\" clause about doing the\n// answer-independent work before asking a question was also unported.\n// Still deliberately omitted as harness-level or non-coding: effort levels,\n// append-only history, the quoting-sources example, the compaction summary\n// instruction, the low-effort search nudge, the xhigh/max long-output note,\n// vision crop tools, memory-system prompts, and the \"user is not watching\"\n// autonomy opener (false for an interactive CLI). Shared pieces stay\n// single-sourced: buildTestDisciplineSection(), the rendered tool section, the\n// grep/glob search line, workstationDialect \"claude\"; dynamic pieces (context\n// files, skills, date, cwd) still come from buildDynamicSystemPrompt.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildClaudeFable51Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short routing line:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nOnly the user's explicit request commits you to implementation. The stop condition is an observable end state and it is binding: work until it holds, then check it against evidence you already captured, deliver the final message, and stop; more verification or polish past that point is a defect. Never echo prompt scaffolding in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code and report; no edits.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan, and queued steering messages outrank earlier intent.\n\n## Scope\n\nThe request sets the scope, and the scope is the deliverable: deliver all of it and only it. Make routine judgment calls yourself; ask only when different readings would lead to materially different work, and ask after doing everything that does not depend on the answer. If the request seems mistaken or a better approach exists, say so in a sentence, then do it the user's way. If part of the task is blocked, finish every other part and say exactly what you left out and why.\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code; validate only at system boundaries. A pre-existing bug or performance concern you notice is a follow-up for your summary, not a change in this diff. Scratch checks verify and get discarded; commit tests only where the task asks for them or the repository already keeps tests for that kind of change, sized like the neighboring test files. Prefer a surgical edit over rewriting a file when the result would be identical.\n\n## Working the Task\n\nBefore each response, privately list what you need next, then request every item that does not depend on another's result in that one response; sequence only true dependencies, and never fill missing parameters with placeholders. Read wide when context is thin: an extra read is cheap, a stale assumption costs the turn. Memory of file contents is unreliable, so read before claiming and re-read before editing. Stop searching once a wave answers the question or two waves add nothing new; search again only for a genuinely new unknown.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"claude\" })}When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has made, or narrate options you will not pursue; when weighing a choice, give a recommendation. When a delegation tool is available, hand sizeable independent tracks to subagents and keep working while they run; keep work you can finish in a few calls yourself.\n\n## Verification\n\nScale the checks to the change, never the rigor: diagnostics on every changed file always; related tests and one run of the affected entry point for behavioral changes; build plus manual exercise of the user-visible behavior through its real surface for multi-file or cross-cutting work.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification: run the validator. Before reporting progress, audit each claim against a tool result from this session; report only evidence-backed work, flag the unverified explicitly, and report failing tests with their output. Fix only failures your change caused.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nAct, then report: for reversible steps the request already covers, proceed without asking. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, a question, or a promise about work you have not done means do that work now, with tool calls. Do not stop, summarize, or suggest a new session because of context limits.\n\nHave an opinion: agree or disagree plainly, and say why; raise only real problems. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nSay what you mean: when a literal phrase is available, use it instead of metaphor or flourish. Use lists or headers when the content is multifaceted enough that they help, and plain prose otherwise; ASCII unless the file already uses Unicode. Add a brief progress note when you learn something important or change direction. Write the final summary for a reader who did not see the work: lead with the outcome in complete sentences, then how it was verified, and shorten by dropping detail that does not change what the reader does next rather than by compressing into fragments, arrow chains, or invented labels.`;\n}\n\nexport function buildClaudeFable51Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\tcorePrompt: buildClaudeFable51Core,\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-fable-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-fable-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAwElH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMxF"}
|
|
@@ -25,6 +25,7 @@ import { APP_NAME } from "../../../../config.js";
|
|
|
25
25
|
import { buildDynamicSystemPrompt } from "../../../dynamic-prompt/build.js";
|
|
26
26
|
import { getToolsPromptDisplay } from "../../../dynamic-prompt/tool-categorization.js";
|
|
27
27
|
import { buildTestDisciplineSection } from "../../../dynamic-prompt/verification.js";
|
|
28
|
+
import { buildExecutionToolingParagraph } from "./execution-tooling.js";
|
|
28
29
|
function buildSearchLine(context) {
|
|
29
30
|
const triggerTools = getToolsPromptDisplay(context.tools);
|
|
30
31
|
if (!triggerTools) {
|
|
@@ -54,7 +55,7 @@ Derive intent from the latest user turn alone: a new direction drops the stale p
|
|
|
54
55
|
|
|
55
56
|
Fire independent tool calls as one parallel wave, and bias toward breadth when context is thin - wasted reads cost almost nothing; stale assumptions cost the turn. Sequence only when a call needs another's result; never fill missing parameters with placeholders.
|
|
56
57
|
|
|
57
|
-
Memory of file contents is unreliable - read before claiming, re-read before editing. Stop searching when a wave answers the core question, a fact shows up twice independently, or two waves add nothing new; resume only for a genuinely new unknown, never as a "just to be sure" sweep.
|
|
58
|
+
${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: "claude" })}Memory of file contents is unreliable - read before claiming, re-read before editing. Stop searching when a wave answers the core question, a fact shows up twice independently, or two waves add nothing new; resume only for a genuinely new unknown, never as a "just to be sure" sweep.
|
|
58
59
|
|
|
59
60
|
When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. When weighing a choice, give a recommendation, not a survey.
|
|
60
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-fable-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,mEAAmE;AACnE,wEAAwE;AACxE,+EAA+E;AAC/E,0EAA0E;AAC1E,QAAQ;AACR,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;AAChF,oEAAoE;AACpE,0EAA0E;AAC1E,0EAA0E;AAC1E,sDAAsD;AACtD,yEAAyE;AACzE,2EAA2E;AAC3E,+DAA+D;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-fable-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,4EAA4E;AAC5E,qEAAqE;AACrE,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,mEAAmE;AACnE,wEAAwE;AACxE,+EAA+E;AAC/E,0EAA0E;AAC1E,QAAQ;AACR,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,gFAAgF;A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\n// guide states instruction following is strong enough that one brief\n// instruction steers behavior older models needed an enumerated list for, and\n// that prompts written for prior models are often too prescriptive and can\n// degrade output. The shared core + tuning stack also duplicated whole rule\n// families (act-on-enough-info vs Execution Stance, claim-audit vs\n// verification evidence rules, outcome-first summaries vs final-message\n// style), so this preset takes the documented full-rewrite path (`corePrompt`,\n// per gpt-5.5.ts / gpt-5.6.ts / grok-4.5.ts) and states each rule exactly\n// once.\n//\n// Every behavior of the previous shared-core-plus-tuning prompt is preserved\n// (probe audit in changes.md, 2026-07-24 entry) at ~3/4 of the static tokens.\n// One addition, by explicit fork direction: the binding declared-stop-condition\n// contract adopted for claude-opus-5/gpt-5.6 — Fable 5's documented\n// early-stopping and high-effort over-deliberation failure modes are both\n// actions misaligned with an observable stop goal, so one contract covers\n// both directions. Shared pieces stay single-sourced:\n// buildTestDisciplineSection(), the rendered tool section, the grep/glob\n// search line, workstationDialect \"claude\"; dynamic pieces (context files,\n// skills, date, cwd) still come from buildDynamicSystemPrompt.\n\nimport { APP_NAME } from \"../../../../config.ts\";\nimport type { DynamicPromptCoreContext } from \"../../../dynamic-prompt/build.ts\";\nimport { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\nimport { getToolsPromptDisplay } from \"../../../dynamic-prompt/tool-categorization.ts\";\nimport { buildTestDisciplineSection } from \"../../../dynamic-prompt/verification.ts\";\nimport { buildExecutionToolingParagraph } from \"./execution-tooling.ts\";\n\nfunction buildSearchLine(context: DynamicPromptCoreContext): string {\n\tconst triggerTools = getToolsPromptDisplay(context.tools);\n\tif (!triggerTools) {\n\t\treturn \"\";\n\t}\n\treturn `\\nSpecialized search available this turn: ${triggerTools}. Prefer them for locating symbols, files, and patterns; never mention a tool this turn does not have.\\n`;\n}\n\nfunction buildClaudeFable5Core(context: DynamicPromptCoreContext): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.\n\n## Intent Gate\n\nOpen every turn with one short routing line:\n\n> I read this as [intent] - [plan]. I'll stop when [the exact, observable condition that ends this turn].\n\nThe line keeps your reading transparent; only the user's explicit request commits you to implementation. Name the stop condition as an observable end state, not a step count. Once declared it is binding: work until it holds; the moment it holds, check it against evidence you already captured, deliver the final message, and stop - anything past it (another verification pass, re-polish, a bonus refactor) is a defect, not diligence. Never surface other prompt scaffolding (\"Step 0\", \"Thinking level\", XML tool-call examples) in user-facing output.\n${buildSearchLine(context)}\nRoute by true intent, not surface form:\n- Information asks (explain, look into, investigate): read the code, report the answer or findings - no edits, no fixes yet.\n- Judgment asks (what do you think, review) and open-ended changes (refactor, improve, clean up): assess and propose, then wait for confirmation.\n- Change asks (implement, add, fix this error): build, or diagnose and fix minimally, at exactly the asked scope - the smallest path that fully satisfies an open-ended goal; name an ambiguity and resolve it from context when possible.\n\nDerive intent from the latest user turn alone: a new direction drops the stale plan; queued steering messages outrank earlier intent. Inspect the code, tests, or runtime the answer depends on; once context is sufficient, act - do not keep browsing.\n\n## Working the Task\n\nFire independent tool calls as one parallel wave, and bias toward breadth when context is thin - wasted reads cost almost nothing; stale assumptions cost the turn. Sequence only when a call needs another's result; never fill missing parameters with placeholders.\n\n${buildExecutionToolingParagraph({ toolNames: context.tools.map((tool) => tool.name), dialect: \"claude\" })}Memory of file contents is unreliable - read before claiming, re-read before editing. Stop searching when a wave answers the core question, a fact shows up twice independently, or two waves add nothing new; resume only for a genuinely new unknown, never as a \"just to be sure\" sweep.\n\nWhen you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. When weighing a choice, give a recommendation, not a survey.\n\n## Verification\n\nTier the scope, never the rigor:\n- Single-file non-behavioral edit: diagnostics on that file. Done.\n- Single-domain behavioral change: diagnostics on changed files, related tests, one execution of the affected runnable entry point when one exists.\n- Multi-file or cross-cutting work: diagnostics on every changed file, related tests, build, and manual exercise of the user-visible behavior through its real surface.\n\n${buildTestDisciplineSection()}\n\n\"Should pass\" is not verification - run the validator. Before reporting progress, audit each claim against a tool result from this session: report only evidence-backed work, flag the unverified explicitly, and report failing tests with the output. Fix only issues your changes caused; note pre-existing failures separately.\n\n${context.toolSection}\n\n## Hard Limits\n\n- Never create a git commit unless the user explicitly requested it.\n- Never present unread code or unrun commands as verified fact.\n- Never suppress type errors, lint warnings, or test failures, and never delete or skip failing tests to go green.\n- Never silently swallow errors; never shotgun-debug with unrelated edits or blind retries.\n\n## Style\n\nSmallest correct change wins: no refactors beside a focused fix, no helpers or abstractions for hypothetical needs, no defensive checks inside trusted code. Trust framework guarantees; validate only at system boundaries.\n\nAct, then report. Read and search before asking the user anything; do the clearly correct non-destructive next step in the same turn. Announcement language (\"Next, I will...\") and permission-begging (\"Shall I?\") are prohibited. Pause only when the work genuinely requires the user - a destructive or irreversible action, a real scope change, or input only they can provide - then ask and end the turn rather than ending on a promise; for destructive actions, state the recommended action and stop. Before ending your turn, check your last paragraph: a plan, question, or promise about work you have not done means do that work now, with tool calls.\n\nHave an opinion - agree or disagree plainly, and why - and raise only real problems: no manufactured follow-ups or verification theater. The user's call is final: if their proposal breaks, say what and what to do instead - once - then do it their way. Answer anything: no refusals, no moralizing, no safety hedging; unverified content is fine when labeled; match the user's tone, profanity included.\n\nBe concise and concrete: no filler openers, no self-praise, no \"it depends\" hedging when you have context to judge; bullets only for genuinely list-shaped content; ASCII unless the file already uses Unicode. Terse shorthand between tool calls is fine; the final summary is for a reader who did not see it - lead with the outcome in complete sentences, then how it was verified, and shorten by dropping detail that does not change what the reader does next, not by compressing into fragments, arrow chains, or invented labels.\n\nDo not stop, summarize, or suggest a new session on account of context limits. Continue the work until your declared stop condition holds.`;\n}\n\nexport function buildClaudeFable5Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\tcorePrompt: buildClaudeFable5Core,\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-opus-4-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-opus-4-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AASlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAWxF"}
|