@agimon-ai/doompi-autocompact 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/checkpointWorker.cjs +2 -0
  4. package/dist/checkpointWorker.cjs.map +1 -0
  5. package/dist/checkpointWorker.d.cts +1 -0
  6. package/dist/checkpointWorker.d.mts +1 -0
  7. package/dist/checkpointWorker.mjs +2 -0
  8. package/dist/checkpointWorker.mjs.map +1 -0
  9. package/dist/constants.cjs +2 -0
  10. package/dist/constants.cjs.map +1 -0
  11. package/dist/constants.mjs +2 -0
  12. package/dist/constants.mjs.map +1 -0
  13. package/dist/extension.cjs +50 -0
  14. package/dist/extension.cjs.map +1 -0
  15. package/dist/extension.d.cts +36 -0
  16. package/dist/extension.d.cts.map +1 -0
  17. package/dist/extension.d.mts +36 -0
  18. package/dist/extension.d.mts.map +1 -0
  19. package/dist/extension.mjs +50 -0
  20. package/dist/extension.mjs.map +1 -0
  21. package/dist/extensions/pi.cjs +2 -0
  22. package/dist/extensions/pi.cjs.map +1 -0
  23. package/dist/extensions/pi.d.cts +2 -0
  24. package/dist/extensions/pi.d.mts +2 -0
  25. package/dist/extensions/pi.mjs +2 -0
  26. package/dist/extensions/pi.mjs.map +1 -0
  27. package/dist/index.cjs +1 -0
  28. package/dist/index.d.cts +4 -0
  29. package/dist/index.d.mts +4 -0
  30. package/dist/index.mjs +1 -0
  31. package/dist/logSinkTelemetry.cjs +2 -0
  32. package/dist/logSinkTelemetry.cjs.map +1 -0
  33. package/dist/logSinkTelemetry.d.cts +26 -0
  34. package/dist/logSinkTelemetry.d.cts.map +1 -0
  35. package/dist/logSinkTelemetry.d.mts +26 -0
  36. package/dist/logSinkTelemetry.d.mts.map +1 -0
  37. package/dist/logSinkTelemetry.mjs +2 -0
  38. package/dist/logSinkTelemetry.mjs.map +1 -0
  39. package/dist/policy.cjs +8 -0
  40. package/dist/policy.cjs.map +1 -0
  41. package/dist/policy.d.cts +6 -0
  42. package/dist/policy.d.cts.map +1 -0
  43. package/dist/policy.d.mts +6 -0
  44. package/dist/policy.d.mts.map +1 -0
  45. package/dist/policy.mjs +8 -0
  46. package/dist/policy.mjs.map +1 -0
  47. package/dist/standard.cjs +2 -0
  48. package/dist/standard.cjs.map +1 -0
  49. package/dist/standard.d.cts +8 -0
  50. package/dist/standard.d.cts.map +1 -0
  51. package/dist/standard.d.mts +8 -0
  52. package/dist/standard.d.mts.map +1 -0
  53. package/dist/standard.mjs +2 -0
  54. package/dist/standard.mjs.map +1 -0
  55. package/dist/summarizationModel.cjs +2 -0
  56. package/dist/summarizationModel.cjs.map +1 -0
  57. package/dist/summarizationModel.d.cts +10 -0
  58. package/dist/summarizationModel.d.cts.map +1 -0
  59. package/dist/summarizationModel.d.mts +10 -0
  60. package/dist/summarizationModel.d.mts.map +1 -0
  61. package/dist/summarizationModel.mjs +2 -0
  62. package/dist/summarizationModel.mjs.map +1 -0
  63. package/dist/types.d.cts +5 -0
  64. package/dist/types.d.cts.map +1 -0
  65. package/dist/types.d.mts +5 -0
  66. package/dist/types.d.mts.map +1 -0
  67. package/package.json +59 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.mjs","names":[],"sources":["../src/extension.ts"],"sourcesContent":["import { Worker } from 'node:worker_threads';\n\nimport { getHarnessState, loadDoomConfig, type PlanningAgentConfig } from '@agimon-ai/doompi-config';\nimport { registerDoomFooterContribution } from '@agimon-ai/doompi-ui/footer';\nimport { resolveSessionKey } from '@agimon-ai/doompi-task/store/paths';\nimport { TaskStore } from '@agimon-ai/doompi-task/store/taskStore';\nimport type { Task } from '@agimon-ai/doompi-task/store/types';\nimport { readActiveNativeTeamSnapshot, type NativeTeamMemberSnapshot } from '@agimon-ai/doompi-team/api/team-snapshot';\nimport type { ExtensionAPI, ExtensionContext, SessionEntry } from '@earendil-works/pi-coding-agent';\nimport {\n buildSessionContext,\n DEFAULT_COMPACTION_SETTINGS,\n sessionEntryToContextMessages,\n} from '@earendil-works/pi-coding-agent';\nimport {\n CHECKPOINT_MESSAGE_TYPE,\n CONTEXT_MESSAGE_TYPE,\n MAX_INVALID_CHECKPOINT_ATTEMPTS,\n RESUME_MESSAGE_TYPE,\n RUNTIME_STATE_MESSAGE_TYPE,\n STATE_CUSTOM_TYPE,\n STATE_VERSION,\n} from './constants.ts';\nimport {\n baselineUsageIsSettled,\n checkpointRequestDetails,\n checkpointSummaryFromEntry,\n createInitialState,\n createRequestId,\n fileDetailsFromUnknown,\n fileOperationsFromMessages,\n isStructuredCheckpoint,\n latestCheckpointArtifactEntry,\n mergeFileDetails,\n parseCheckpointDecision,\n parseState,\n projectContextMessages,\n retainedMessagesAfterSnapshot,\n thresholdTokens,\n withCanonicalFileSections,\n} from './policy.ts';\nimport { AUTOCOMPACT_EVENT, createAutocompactTelemetry } from './logSinkTelemetry.ts';\nimport type { AutocompactEventAttributes, AutocompactTelemetry } from './logSinkTelemetry.ts';\nimport { parseModelReference, type SummarizationModel } from './summarizationModel.ts';\nexport { parseModelReference, resolveSummarizationModel } from './summarizationModel.ts';\nexport type { ModelReference, SummarizationModel } from './summarizationModel.ts';\nimport type { AutocompactContextDetails, AutocompactPass, AutocompactState } from './types.ts';\n\nconst ROOT_WORKING_LEAF = '@root';\nconst PLAN_DOCUMENT_ENTRY = 'agent-harness-plan-document';\nconst FOOTER_SOURCE = 'doom-autocompact';\nconst FOOTER_ORDER = 20;\nconst STATUS_KEY = 'doom-autocompact';\nconst STATE_PHASE = {\n waiting: 'waiting',\n checkpointPending: 'checkpoint_pending',\n checkpointReady: 'checkpoint_ready',\n compacting: 'compacting',\n} as const;\ntype CheckpointCapture = 'none' | 'pass1' | 'committed' | 'deferred' | 'invalid';\ntype CheckpointMessages = ReturnType<typeof buildSessionContext>['messages'];\n\ninterface PlanSnapshot {\n content: string;\n path: string;\n}\n\ninterface TaskSnapshot {\n tasks: Task[];\n error?: string;\n}\n\ninterface TeamSnapshot {\n members?: NativeTeamMemberSnapshot[];\n error?: string;\n}\n\ninterface SteeringSnapshot {\n plan?: PlanSnapshot;\n taskSnapshot: TaskSnapshot;\n teamSnapshot: TeamSnapshot;\n readFiles: string[];\n modifiedFiles: string[];\n}\n\ninterface RuntimeTaskSnapshot {\n id: number;\n status: Task['status'];\n subject: string;\n activeForm?: string;\n owner?: string;\n blockedBy?: number[];\n delegation?: {\n agent: string;\n state: NonNullable<Task['delegation']>['state'];\n error?: string;\n };\n}\n\ninterface RuntimeStateSnapshot {\n planPath?: string;\n tasks: RuntimeTaskSnapshot[];\n taskError?: string;\n teamAvailable: boolean;\n teamMembers: NativeTeamMemberSnapshot[];\n teamError?: string;\n}\n\ninterface CheckpointGenerationInput {\n messages: CheckpointMessages;\n instructions: string;\n previousCheckpoint?: string;\n context: ExtensionContext;\n signal: AbortSignal;\n}\n\ninterface CheckpointWorkerResult {\n checkpoint?: string;\n error?: string;\n}\n\ninterface AutocompactDependencies {\n generateCheckpoint?: (input: CheckpointGenerationInput) => Promise<string>;\n readTaskSnapshot?: (context: ExtensionContext) => TaskSnapshot;\n readTeamSnapshot?: () => TeamSnapshot;\n resolveModel?: (context: ExtensionContext) => SummarizationModel | undefined;\n telemetry?: AutocompactTelemetry;\n doomIntegrations?: boolean;\n}\n\nfunction telemetryAttributes(\n context: ExtensionContext,\n attributes: AutocompactEventAttributes = {},\n): AutocompactEventAttributes {\n return {\n 'pi.session.id': context.sessionManager.getSessionId(),\n ...attributes,\n };\n}\n\nfunction latestPersistedState(branch: SessionEntry[]): AutocompactState | undefined {\n for (let index = branch.length - 1; index >= 0; index -= 1) {\n const entry = branch[index];\n if (entry?.type !== 'custom' || entry.customType !== STATE_CUSTOM_TYPE) continue;\n const parsed = parseState(entry.data);\n if (parsed) return parsed;\n }\n return undefined;\n}\n\nfunction workingLeafId(ctx: ExtensionContext): string {\n for (const entry of ctx.sessionManager.getBranch().toReversed()) {\n if (entry.type === 'custom' && entry.customType === STATE_CUSTOM_TYPE) continue;\n if (entry.type === 'label') continue;\n return entry.id;\n }\n return ROOT_WORKING_LEAF;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction latestPlanSnapshot(branch: SessionEntry[]): PlanSnapshot | undefined {\n for (const entry of branch.toReversed()) {\n if (entry.type !== 'custom' || entry.customType !== PLAN_DOCUMENT_ENTRY) continue;\n if (!entry.data || typeof entry.data !== 'object') return undefined;\n const data = entry.data as Record<string, unknown>;\n if (typeof data.content !== 'string' || typeof data.path !== 'string') return undefined;\n return { content: data.content, path: data.path };\n }\n return undefined;\n}\n\nfunction readTaskSnapshotWithDoomTask(context: ExtensionContext): TaskSnapshot {\n const failures: string[] = [];\n try {\n const store = new TaskStore({\n cwd: context.cwd,\n report: {\n error: (event, error) => failures.push(`${event}: ${errorMessage(error)}`),\n warn: (event, error) => failures.push(`${event}: ${errorMessage(error)}`),\n event: () => undefined,\n },\n });\n store.configureSession(resolveSessionKey(context.sessionManager.getSessionId()));\n const tasks = store.read().tasks;\n return { tasks, ...(failures.length > 0 ? { error: failures.join('; ') } : {}) };\n } catch (error) {\n return { tasks: [], error: errorMessage(error) };\n }\n}\n\nfunction readTeamSnapshotWithDoomTeam(): TeamSnapshot {\n try {\n const snapshot = readActiveNativeTeamSnapshot();\n return snapshot ? { members: snapshot.members } : {};\n } catch (error) {\n return { error: errorMessage(error) };\n }\n}\n\nfunction activeTaskSnapshots(snapshot: TaskSnapshot): RuntimeTaskSnapshot[] {\n return snapshot.tasks\n .filter((task) => task.status === 'pending' || task.status === 'in_progress' || task.status === 'failed')\n .map((task) => ({\n id: task.id,\n status: task.status,\n subject: task.subject,\n ...(task.activeForm ? { activeForm: task.activeForm } : {}),\n ...(task.owner ? { owner: task.owner } : {}),\n ...(task.blockedBy?.length ? { blockedBy: task.blockedBy } : {}),\n ...(task.delegation\n ? {\n delegation: {\n agent: task.delegation.agent,\n state: task.delegation.state,\n ...(task.delegation.result?.error ? { error: task.delegation.result.error } : {}),\n },\n }\n : {}),\n }));\n}\n\nfunction formatRuntimeTasks(tasks: RuntimeTaskSnapshot[], error?: string): string {\n const lines = tasks.map((task) => {\n const details = [\n task.activeForm ? `active: ${task.activeForm}` : undefined,\n task.owner ? `owner: ${task.owner}` : undefined,\n task.blockedBy?.length ? `blocked by: ${task.blockedBy.join(', ')}` : undefined,\n task.delegation ? `delegation: ${task.delegation.agent} (${task.delegation.state})` : undefined,\n task.delegation?.error ? `error: ${task.delegation.error}` : undefined,\n ].filter((value): value is string => Boolean(value));\n return `- #${task.id} [${task.status}] ${task.subject}${details.length > 0 ? ` | ${details.join(' | ')}` : ''}`;\n });\n if (error) lines.push(`- Task snapshot error: ${error}`);\n return lines.length > 0 ? lines.join('\\n') : '(no active tasks)';\n}\n\nfunction formatTeamSnapshot(snapshot: TeamSnapshot): string {\n const lines = (snapshot.members ?? []).map((member) => {\n const details = [\n `role: ${member.role}`,\n member.agent ? `agent: ${member.agent}` : undefined,\n member.runId ? `run: ${member.runId}` : undefined,\n member.task ? `task ${member.task.id}: ${member.task.subject}` : undefined,\n ].filter((value): value is string => Boolean(value));\n return `- ${member.name} | ${details.join(' | ')}`;\n });\n if (snapshot.error) lines.push(`- Team snapshot error: ${snapshot.error}`);\n if (lines.length > 0) return lines.join('\\n');\n return snapshot.members ? '(no active team members)' : '(team runtime unavailable)';\n}\n\nfunction runtimeStateSnapshot(\n branch: SessionEntry[],\n taskSnapshot: TaskSnapshot,\n teamSnapshot: TeamSnapshot,\n): RuntimeStateSnapshot {\n const plan = latestPlanSnapshot(branch);\n return {\n ...(plan ? { planPath: plan.path } : {}),\n tasks: activeTaskSnapshots(taskSnapshot),\n ...(taskSnapshot.error ? { taskError: taskSnapshot.error } : {}),\n teamAvailable: Boolean(teamSnapshot.members),\n teamMembers: teamSnapshot.members ?? [],\n ...(teamSnapshot.error ? { teamError: teamSnapshot.error } : {}),\n };\n}\n\nfunction formatRuntimeState(snapshot: RuntimeStateSnapshot): string {\n const plan = snapshot.planPath\n ? `Source: ${snapshot.planPath}\\nExact plan content is restored separately by Doom Plan.`\n : '(no active plan document)';\n const teamSnapshot: TeamSnapshot = {\n ...(snapshot.teamAvailable ? { members: snapshot.teamMembers } : {}),\n ...(snapshot.teamError ? { error: snapshot.teamError } : {}),\n };\n return `<compaction-runtime-state>\nAuthoritative runtime state captured when compaction committed. Use it to resume coordination without reconstructing state from the summary.\n<active-plan>\n${plan}\n</active-plan>\n<active-tasks>\n${formatRuntimeTasks(snapshot.tasks, snapshot.taskError)}\n</active-tasks>\n<active-team>\n${formatTeamSnapshot(teamSnapshot)}\n</active-team>\n</compaction-runtime-state>`;\n}\n\nfunction runtimeTelemetryAttributes(snapshot: RuntimeStateSnapshot): AutocompactEventAttributes {\n return {\n 'autocompact.runtime.plan_present': Boolean(snapshot.planPath),\n 'autocompact.runtime.task_count': snapshot.tasks.length,\n 'autocompact.runtime.team_available': snapshot.teamAvailable,\n 'autocompact.runtime.team_member_count': snapshot.teamMembers.length,\n };\n}\n\nfunction steeringEnvelope(snapshot: SteeringSnapshot): string {\n const plan = snapshot.plan\n ? `Source: ${snapshot.plan.path}\\n\\n${snapshot.plan.content}`\n : '(no active plan document)';\n const importantContext = [\n snapshot.readFiles.length > 0 ? `Read files: ${snapshot.readFiles.join(', ')}` : undefined,\n snapshot.modifiedFiles.length > 0 ? `Modified files: ${snapshot.modifiedFiles.join(', ')}` : undefined,\n ].filter((value): value is string => Boolean(value));\n\n return `<compaction-steering priority=\"user,plan,tasks,team,important-context,recent-messages\">\n<user-prompt source=\"conversation\">\nTreat the user's explicit goals, constraints, corrections, and preferences in the conversation as authoritative. Newer user instructions override older ones.\n</user-prompt>\n<active-plan>\n${plan}\n</active-plan>\n<active-tasks>\n${formatRuntimeTasks(activeTaskSnapshots(snapshot.taskSnapshot), snapshot.taskSnapshot.error)}\n</active-tasks>\n<active-team>\n${formatTeamSnapshot(snapshot.teamSnapshot)}\n</active-team>\n<important-context>\n${importantContext.length > 0 ? importantContext.join('\\n') : '(none recorded outside the conversation)'}\n</important-context>\n</compaction-steering>`;\n}\n\nfunction checkpointInstructions(pass: AutocompactPass, steering: SteeringSnapshot): string {\n const decision =\n pass === 2\n ? 'Start with exactly <shouldCompact>true</shouldCompact> or <shouldCompact>false</shouldCompact>. Use true when the staged summary safely retains the important parent context. Use false only when it is not yet sufficient for safe compaction.\\n\\n'\n : '';\n\n // Summarization is a tool-less single LLM call, so instructions describe only what to\n // produce. Directives aimed at an implementing agent leak into the checkpoint body.\n return `Create Doom autocompact checkpoint pass ${pass}.\n\n${steeringEnvelope(steering)}\n\nApply the steering evidence in priority order. Do not invent plan, task, or team state. Preserve verified facts and mark unresolved inference explicitly. Newer evidence replaces superseded information.\n\n${decision}Return only the decision tag when required, followed by a concise structured checkpoint using every heading below. Keep exact goals, constraints, decisions, blockers, commands, errors, file paths, validation evidence, and the immediate next action. Separate verified facts from unresolved inference.\n\n## Goal\n## Constraints & Preferences\n## Progress\n### Done\n### In Progress\n### Blocked\n## Key Decisions\n## Next Steps\n## Critical Context`;\n}\n\nfunction messagesForCheckpoint(\n pass: AutocompactPass,\n branch: SessionEntry[],\n previousSnapshotLeafId: string | undefined,\n): CheckpointMessages {\n const projected = projectContextMessages(buildSessionContext(branch).messages, branch).messages;\n if (pass === 1 || !previousSnapshotLeafId) return projected;\n const snapshotIndex = branch.findIndex((entry) => entry.id === previousSnapshotLeafId);\n if (snapshotIndex === -1) return projected;\n return branch\n .slice(snapshotIndex + 1)\n .filter((entry) => entry.type !== 'custom_message' || entry.customType !== CHECKPOINT_MESSAGE_TYPE)\n .flatMap((entry) => sessionEntryToContextMessages(entry));\n}\n\nfunction runCheckpointWorker(workerInput: Record<string, unknown>, signal: AbortSignal): Promise<string> {\n return new Promise((resolve, reject) => {\n const worker = new Worker(new URL('./checkpointWorker.mjs', import.meta.url), { workerData: workerInput });\n let settled = false;\n\n const settle = (complete: () => void): void => {\n if (settled) return;\n settled = true;\n signal.removeEventListener('abort', abort);\n complete();\n };\n const abort = (): void => {\n settle(() => {\n void worker.terminate();\n reject(signal.reason instanceof Error ? signal.reason : new Error('Autocompact summarization aborted.'));\n });\n };\n\n worker.once('message', (result: CheckpointWorkerResult) => {\n settle(() => {\n if (typeof result.checkpoint === 'string') resolve(result.checkpoint);\n else reject(new Error(result.error ?? 'Autocompact summarization worker returned no checkpoint.'));\n });\n });\n worker.once('error', (error) => settle(() => reject(error)));\n worker.once('exit', (code) => {\n if (code !== 0) settle(() => reject(new Error(`Autocompact summarization worker exited with code ${code}.`)));\n });\n signal.addEventListener('abort', abort, { once: true });\n worker.unref();\n if (signal.aborted) abort();\n });\n}\n\nfunction subagentModelConfig(cwd: string): PlanningAgentConfig | undefined {\n try {\n return loadDoomConfig(getHarnessState().root ?? cwd).modes?.planning?.subagents;\n } catch {\n process.emitWarning(\n 'Doom autocompact planning configuration could not be loaded; using the active session model instead.',\n );\n return undefined;\n }\n}\n\n/** Explicit Doom model selection honors the configured planning subagent model. */\nexport function resolveDoomSummarizationModel(ctx: ExtensionContext): SummarizationModel | undefined {\n const configured = subagentModelConfig(ctx.cwd);\n const reference = configured?.model ? parseModelReference(configured.model) : undefined;\n const configuredModel = reference ? ctx.modelRegistry.find(reference.provider, reference.modelId) : undefined;\n const model = configuredModel ?? ctx.model;\n if (!model) return undefined;\n const thinkingLevel =\n configured?.thinking ?? (configuredModel ? reference?.thinking : undefined) ?? ctx.thinkingLevel;\n return { model, ...(thinkingLevel ? { thinkingLevel } : {}) };\n}\n\nasync function generateCheckpointWithPi(\n input: CheckpointGenerationInput,\n resolveModel: (context: ExtensionContext) => SummarizationModel | undefined,\n): Promise<string> {\n const selection = resolveModel(input.context);\n if (!selection) throw new Error('No active model is available for autocompact summarization.');\n const auth = await input.context.modelRegistry.getApiKeyAndHeaders(selection.model);\n if (!auth.ok) throw new Error(auth.error);\n return runCheckpointWorker(\n {\n messages: input.messages,\n model: selection.model,\n reserveTokens: DEFAULT_COMPACTION_SETTINGS.reserveTokens,\n apiKey: auth.apiKey,\n headers: auth.headers,\n instructions: input.instructions,\n previousCheckpoint: input.previousCheckpoint,\n thinkingLevel: selection.thinkingLevel,\n env: auth.env,\n },\n input.signal,\n );\n}\n\nfunction notify(ctx: ExtensionContext | undefined, message: string, level: 'info' | 'warning' | 'error' = 'info') {\n if (ctx?.hasUI) ctx.ui.notify(message, level);\n}\n\nexport function registerAutocompactExtension(pi: ExtensionAPI, dependencies: AutocompactDependencies = {}): void {\n const resolveModel = dependencies.resolveModel ?? resolveDoomSummarizationModel;\n const generateCheckpoint =\n dependencies.generateCheckpoint ??\n ((input: CheckpointGenerationInput) => generateCheckpointWithPi(input, resolveModel));\n const readTaskSnapshot = dependencies.readTaskSnapshot ?? readTaskSnapshotWithDoomTask;\n const readTeamSnapshot = dependencies.readTeamSnapshot ?? readTeamSnapshotWithDoomTeam;\n const telemetry = dependencies.telemetry ?? createAutocompactTelemetry();\n const doomIntegrations = dependencies.doomIntegrations ?? true;\n const appliedContextRequests = new Set<string>();\n const invalidContextLeaves = new Set<string>();\n let state = createInitialState();\n let currentContext: ExtensionContext | undefined;\n let checkpointController: AbortController | undefined;\n const footerContribution = doomIntegrations\n ? registerDoomFooterContribution(pi, {\n source: FOOTER_SOURCE,\n id: 'autocompact',\n order: FOOTER_ORDER,\n })\n : { update: () => undefined, dispose: () => undefined };\n\n /** Compaction runs off the main thread, so the phase is the only signal the user gets. */\n const refreshStatus = (ctx?: ExtensionContext): void => {\n const phase =\n state.phase === STATE_PHASE.checkpointPending\n ? 'summarizing'\n : state.phase === STATE_PHASE.checkpointReady\n ? 'applying'\n : undefined;\n footerContribution.update(\n phase ? { fullText: `Compacting p${state.pass}`, compactText: `C${state.pass}` } : undefined,\n );\n const target = ctx ?? currentContext;\n if (target?.hasUI) target.ui.setStatus(STATUS_KEY, phase ? `Compacting pass ${state.pass} (${phase})…` : undefined);\n };\n\n // Every phase transition persists, so this is the one place that keeps the status honest.\n const persist = (): void => {\n pi.appendEntry(STATE_CUSTOM_TYPE, { ...state });\n refreshStatus();\n };\n\n const clearPendingCheckpoint = (): void => {\n delete state.requestId;\n delete state.snapshotLeafId;\n delete state.snapshotTokens;\n delete state.pendingCheckpoint;\n delete state.compactionPass;\n };\n\n const completeQueuedPass = (pass: AutocompactPass): void => {\n state.checkpointQueue = state.checkpointQueue.filter((queuedPass) => queuedPass !== pass);\n };\n\n const restore = (ctx: ExtensionContext): void => {\n state = latestPersistedState(ctx.sessionManager.getBranch()) ?? createInitialState();\n const resumablePending =\n state.phase === STATE_PHASE.checkpointReady && state.requestId && state.snapshotLeafId && state.pendingCheckpoint;\n if (resumablePending || state.phase === STATE_PHASE.waiting) return;\n\n checkpointController?.abort();\n checkpointController = undefined;\n state.phase = STATE_PHASE.waiting;\n clearPendingCheckpoint();\n persist();\n };\n\n const resumeAgent = (message: string): void => {\n pi.sendMessage(\n {\n customType: RESUME_MESSAGE_TYPE,\n content: `${message} Continue from the compacted checkpoint's immediate next action without repeating completed work.`,\n display: false,\n details: { version: STATE_VERSION, cycle: state.cycle, pass: state.pass },\n },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n };\n\n const failCheckpoint = (requestId: string, error: unknown): void => {\n if (requestId !== state.requestId || state.phase !== STATE_PHASE.checkpointPending) return;\n const failedLeafId = state.snapshotLeafId;\n state.phase = STATE_PHASE.waiting;\n if (failedLeafId) state.lastAttemptLeafId = failedLeafId;\n clearPendingCheckpoint();\n persist();\n notify(\n currentContext,\n `Doom autocompact summarization pass ${state.pass} failed: ${error instanceof Error ? error.message : String(error)}`,\n 'error',\n );\n };\n\n const reportSnapshotFailures = (\n ctx: ExtensionContext,\n taskSnapshot: TaskSnapshot,\n teamSnapshot: TeamSnapshot,\n attributes: AutocompactEventAttributes,\n ): void => {\n if (taskSnapshot.error) {\n notify(ctx, `Doom autocompact task steering degraded: ${taskSnapshot.error}`, 'warning');\n void telemetry.recordWarning(AUTOCOMPACT_EVENT.taskSnapshotDegraded, new Error(taskSnapshot.error), attributes);\n }\n if (teamSnapshot.error) {\n notify(ctx, `Doom autocompact team steering degraded: ${teamSnapshot.error}`, 'warning');\n void telemetry.recordWarning(AUTOCOMPACT_EVENT.teamSnapshotDegraded, new Error(teamSnapshot.error), attributes);\n }\n };\n\n const preserveRuntimeState = (\n ctx: ExtensionContext,\n branch: SessionEntry[],\n attributes: AutocompactEventAttributes,\n ): RuntimeStateSnapshot => {\n const taskSnapshot = readTaskSnapshot(ctx);\n const teamSnapshot = readTeamSnapshot();\n reportSnapshotFailures(ctx, taskSnapshot, teamSnapshot, attributes);\n const snapshot = runtimeStateSnapshot(branch, taskSnapshot, teamSnapshot);\n pi.sendMessage({\n customType: RUNTIME_STATE_MESSAGE_TYPE,\n content: formatRuntimeState(snapshot),\n display: false,\n details: { version: 1, ...snapshot },\n });\n return snapshot;\n };\n\n const commitCheckpoint = (pass: 2 | 3, ctx: ExtensionContext): boolean => {\n if (!state.requestId || !state.snapshotLeafId || !state.pendingCheckpoint) return false;\n const branch = ctx.sessionManager.getBranch();\n const projected = projectContextMessages(buildSessionContext(branch).messages, branch).messages;\n const fileDetails = mergeFileDetails(state, fileOperationsFromMessages(projected));\n const requestId = state.requestId;\n const cycle = state.cycle;\n const summary = withCanonicalFileSections(state.pendingCheckpoint, fileDetails);\n const details: AutocompactContextDetails = {\n ...fileDetails,\n doomAutocompact: {\n version: STATE_VERSION,\n cycle,\n pass,\n requestId,\n snapshotLeafId: state.snapshotLeafId,\n tokensBefore: state.snapshotTokens ?? ctx.getContextUsage()?.tokens ?? 0,\n },\n retainedMessages: retainedMessagesAfterSnapshot(branch, state.snapshotLeafId),\n };\n\n notify(ctx, `Doom autocompact pass ${pass} context commit started.`);\n const committedWhileIdle = ctx.isIdle();\n pi.sendMessage({ customType: CONTEXT_MESSAGE_TYPE, content: summary, display: false, details });\n const contextMessageLeafId = workingLeafId(ctx);\n const runtimeAttributes = telemetryAttributes(ctx, {\n 'autocompact.request.id': requestId,\n 'autocompact.cycle': cycle,\n 'autocompact.pass': pass,\n });\n const runtimeSnapshot = preserveRuntimeState(ctx, branch, runtimeAttributes);\n // Mid-run the marker is queued as a steering message, so its entry id is not resolvable yet.\n if (committedWhileIdle) pi.setLabel(contextMessageLeafId, `autocompact:c${cycle}:p${pass}`);\n\n state.readFiles = fileDetails.readFiles;\n state.modifiedFiles = fileDetails.modifiedFiles;\n delete state.latestCheckpointSnapshotLeafId;\n state.phase = STATE_PHASE.waiting;\n state.checkpointQueue = [];\n // A compacted context is a fresh ladder: passes abandoned in the previous cycle are eligible again.\n state.exhaustedPasses = [];\n state.invalidAttempts = 0;\n state.baselinePending = true;\n delete state.lastAttemptLeafId;\n clearPendingCheckpoint();\n state.cycle += 1;\n state.pass = 1;\n persist();\n void telemetry.recordEvent(\n AUTOCOMPACT_EVENT.contextCommitted,\n telemetryAttributes(ctx, {\n 'autocompact.request.id': requestId,\n 'autocompact.cycle': cycle,\n 'autocompact.pass': pass,\n 'autocompact.snapshot_leaf_id': details.doomAutocompact.snapshotLeafId,\n 'autocompact.tokens_before': details.doomAutocompact.tokensBefore,\n 'autocompact.message_count.before': projected.length,\n 'autocompact.message_count.retained': details.retainedMessages.length,\n 'autocompact.apply_mode': committedWhileIdle ? 'idle' : 'turn_end',\n ...runtimeTelemetryAttributes(runtimeSnapshot),\n }),\n );\n notify(ctx, `Doom autocompact context committed. Baseline will be captured from the next settled context.`);\n // A mid-run commit needs no resume steer: the agent is already continuing.\n if (committedWhileIdle) resumeAgent('Asynchronous compaction completed.');\n return true;\n };\n\n const requestCheckpoint = (pass: AutocompactPass, ctx: ExtensionContext, tokensBefore: number): void => {\n const branch = ctx.sessionManager.getBranch();\n const snapshotLeafId = workingLeafId(ctx);\n const requestId = createRequestId(ctx.sessionManager.getSessionId(), state.cycle, pass, snapshotLeafId);\n const previousCheckpoint = pass > 1 ? checkpointSummaryFromEntry(latestCheckpointArtifactEntry(branch)) : undefined;\n const messages = messagesForCheckpoint(pass, branch, state.latestCheckpointSnapshotLeafId);\n const taskSnapshot = readTaskSnapshot(ctx);\n const teamSnapshot = readTeamSnapshot();\n const attributes = telemetryAttributes(ctx, {\n 'autocompact.request.id': requestId,\n 'autocompact.cycle': state.cycle,\n 'autocompact.pass': pass,\n 'autocompact.snapshot_leaf_id': snapshotLeafId,\n 'autocompact.tokens_before': tokensBefore,\n 'autocompact.message_count.before': messages.length,\n });\n reportSnapshotFailures(ctx, taskSnapshot, teamSnapshot, attributes);\n\n state.phase = STATE_PHASE.checkpointPending;\n state.pass = pass;\n state.requestId = requestId;\n state.snapshotLeafId = snapshotLeafId;\n state.snapshotTokens = tokensBefore;\n delete state.pendingCheckpoint;\n delete state.compactionPass;\n delete state.lastAttemptLeafId;\n persist();\n\n checkpointController?.abort();\n checkpointController = new AbortController();\n const checkpointSignal = checkpointController.signal;\n notify(ctx, `Doom autocompact summarization pass ${pass} started.`);\n void telemetry\n .runInSpan('doom_autocompact.checkpoint', attributes, async () => {\n await telemetry.recordEvent(AUTOCOMPACT_EVENT.checkpointStarted, attributes);\n try {\n const checkpoint = await generateCheckpoint({\n messages,\n instructions: checkpointInstructions(pass, {\n plan: latestPlanSnapshot(branch),\n taskSnapshot,\n teamSnapshot,\n readFiles: state.readFiles,\n modifiedFiles: state.modifiedFiles,\n }),\n ...(previousCheckpoint ? { previousCheckpoint } : {}),\n context: ctx,\n signal: checkpointSignal,\n });\n if (!checkpoint.trim()) throw new Error('Summarization returned an empty checkpoint.');\n await telemetry.recordEvent(AUTOCOMPACT_EVENT.checkpointCompleted, {\n ...attributes,\n 'autocompact.checkpoint.characters': checkpoint.length,\n });\n return checkpoint;\n } catch (error) {\n await telemetry.recordError(AUTOCOMPACT_EVENT.checkpointFailed, error, attributes);\n throw error;\n }\n })\n .then((checkpoint) => {\n if (requestId !== state.requestId || state.phase !== STATE_PHASE.checkpointPending) return;\n state.phase = STATE_PHASE.checkpointReady;\n state.pendingCheckpoint = checkpoint.trim();\n persist();\n notify(currentContext, `Doom autocompact summarization pass ${pass} completed.`);\n if (currentContext) processProgress(currentContext);\n })\n .catch((error: unknown) => failCheckpoint(requestId, error));\n };\n\n const evaluateUsage = (ctx: ExtensionContext): boolean => {\n if (state.phase !== STATE_PHASE.waiting || ctx.hasPendingMessages()) return false;\n const usage = ctx.getContextUsage();\n if (!usage || usage.tokens === null) return false;\n if (state.baselinePending) {\n // Reported usage still describes the pre-compaction context until an assistant\n // responds against the projected one, and capturing it early poisons every threshold.\n if (!baselineUsageIsSettled(ctx.sessionManager.getBranch())) return false;\n state.baselineTokens = usage.tokens;\n state.baselinePending = false;\n persist();\n notify(ctx, `Doom autocompact baseline captured at ${state.baselineTokens} tokens.`);\n return false;\n }\n const leafId = workingLeafId(ctx);\n if (state.lastAttemptLeafId === leafId) return false;\n\n for (const pass of [1, 2, 3] as const) {\n if (pass < state.pass || state.checkpointQueue.includes(pass) || state.exhaustedPasses.includes(pass)) continue;\n if (usage.tokens >= thresholdTokens(pass, usage.contextWindow, state.baselineTokens)) {\n state.checkpointQueue.push(pass);\n }\n }\n const nextPass = state.checkpointQueue[0];\n if (!nextPass) return false;\n requestCheckpoint(nextPass, ctx, usage.tokens);\n return true;\n };\n\n // Staged checkpoints seed the next summarization pass only. They are appended as plain\n // session entries so they never enter the agent's LLM context: delivering them as messages\n // reads like a user instruction and derails the run (\"Checkpoint acknowledged...\").\n const stageCheckpoint = (pass: 1 | 2, summary: string): void => {\n const checkpointSnapshotLeafId = state.snapshotLeafId;\n pi.appendEntry(CHECKPOINT_MESSAGE_TYPE, {\n ...checkpointRequestDetails(state.cycle, pass, state.requestId ?? 'completed'),\n summary,\n });\n if (checkpointSnapshotLeafId) state.latestCheckpointSnapshotLeafId = checkpointSnapshotLeafId;\n };\n\n const captureReadyCheckpoint = (ctx: ExtensionContext): CheckpointCapture => {\n if (state.phase !== STATE_PHASE.checkpointReady || !state.requestId || !state.pendingCheckpoint) return 'none';\n const pass = state.pass;\n const decision = parseCheckpointDecision(state.pendingCheckpoint);\n if (!isStructuredCheckpoint(decision.summary)) {\n const failedLeafId = state.snapshotLeafId;\n const invalidRequestId = state.requestId;\n // A queued pass is retried once per new leaf, so an output the summarizer never formats\n // correctly would otherwise burn a full summarization call every turn for the session.\n const attempts = state.invalidAttempts + 1;\n const exhausted = attempts >= MAX_INVALID_CHECKPOINT_ATTEMPTS;\n state.phase = STATE_PHASE.waiting;\n if (failedLeafId) state.lastAttemptLeafId = failedLeafId;\n if (exhausted) {\n completeQueuedPass(pass);\n state.exhaustedPasses = [...state.exhaustedPasses, pass];\n state.invalidAttempts = 0;\n } else {\n state.invalidAttempts = attempts;\n }\n clearPendingCheckpoint();\n persist();\n const error = new Error(`Summarization pass ${pass} returned an incomplete checkpoint.`);\n notify(\n ctx,\n exhausted\n ? `Doom autocompact summarization pass ${pass} returned an incomplete checkpoint ${attempts} times and was abandoned.`\n : `Doom autocompact summarization pass ${pass} returned an incomplete checkpoint.`,\n 'error',\n );\n void telemetry.recordError(\n AUTOCOMPACT_EVENT.checkpointInvalid,\n error,\n telemetryAttributes(ctx, {\n 'autocompact.cycle': state.cycle,\n 'autocompact.pass': pass,\n 'autocompact.checkpoint.attempts': attempts,\n 'autocompact.checkpoint.exhausted': exhausted,\n ...(invalidRequestId ? { 'autocompact.request.id': invalidRequestId } : {}),\n }),\n );\n return 'invalid';\n }\n\n state.invalidAttempts = 0;\n\n if (pass === 1) {\n stageCheckpoint(1, decision.summary);\n completeQueuedPass(1);\n state.phase = STATE_PHASE.waiting;\n state.pass = 2;\n clearPendingCheckpoint();\n persist();\n return 'pass1';\n }\n\n if (pass === 2 && decision.shouldCompact !== true) {\n stageCheckpoint(2, decision.summary);\n completeQueuedPass(2);\n state.phase = STATE_PHASE.waiting;\n state.pass = 3;\n clearPendingCheckpoint();\n persist();\n return 'deferred';\n }\n\n state.pendingCheckpoint = decision.summary;\n return commitCheckpoint(pass, ctx) ? 'committed' : 'invalid';\n };\n\n function processProgress(ctx: ExtensionContext): void {\n currentContext = ctx;\n if (!ctx.isIdle()) return;\n if (captureReadyCheckpoint(ctx) !== 'committed') evaluateUsage(ctx);\n }\n\n pi.on('context', (event, ctx) => {\n const projection = projectContextMessages(event.messages, ctx.sessionManager.getBranch());\n if (projection.invalidMarker) {\n const leafId = ctx.sessionManager.getLeafId() ?? ROOT_WORKING_LEAF;\n if (!invalidContextLeaves.has(leafId)) {\n invalidContextLeaves.add(leafId);\n void telemetry.recordError(\n AUTOCOMPACT_EVENT.contextMarkerInvalid,\n new Error('Doom autocompact context marker is malformed.'),\n telemetryAttributes(ctx, { 'autocompact.leaf_id': leafId }),\n );\n }\n return undefined;\n }\n if (!projection.marker) return undefined;\n if (!appliedContextRequests.has(projection.marker.requestId)) {\n appliedContextRequests.add(projection.marker.requestId);\n void telemetry.recordEvent(\n AUTOCOMPACT_EVENT.contextApplied,\n telemetryAttributes(ctx, {\n 'autocompact.request.id': projection.marker.requestId,\n 'autocompact.cycle': projection.marker.cycle,\n 'autocompact.pass': projection.marker.pass,\n 'autocompact.snapshot_leaf_id': projection.marker.snapshotLeafId,\n 'autocompact.tokens_before': projection.marker.tokensBefore,\n 'autocompact.message_count.before': event.messages.length,\n 'autocompact.message_count.after': projection.messages.length,\n 'autocompact.message_count.retained': projection.retainedMessageCount,\n }),\n );\n }\n return { messages: projection.messages };\n });\n\n pi.on('session_start', (_event, ctx) => {\n currentContext = ctx;\n restore(ctx);\n processProgress(ctx);\n });\n\n pi.on('session_tree', (_event, ctx) => {\n currentContext = ctx;\n restore(ctx);\n processProgress(ctx);\n });\n\n pi.on('turn_end', (event, ctx) => {\n currentContext = ctx;\n if (ctx.isIdle()) {\n processProgress(ctx);\n return;\n }\n // A ready checkpoint must be applied without waiting for the run to finish, otherwise\n // context keeps growing past the window for the rest of a long autonomous run. Tool\n // results confirm the run continues, so the queued marker lands before the next request.\n const canApplyDuringRun =\n state.phase === STATE_PHASE.checkpointReady && (event.toolResults?.length ?? 0) > 0 && !ctx.hasPendingMessages();\n if (canApplyDuringRun && captureReadyCheckpoint(ctx) !== 'none') return;\n evaluateUsage(ctx);\n });\n\n pi.on('agent_settled', (_event, ctx) => {\n processProgress(ctx);\n });\n\n pi.on('session_before_compact', (event) => {\n if (event.reason !== 'threshold') return undefined;\n // Native compaction stays cancelled while our own machinery is working, and stays\n // available as the emergency backstop once that machinery has stalled or declined.\n const machineryActive =\n state.phase === STATE_PHASE.checkpointPending ||\n state.phase === STATE_PHASE.checkpointReady ||\n state.baselinePending;\n return machineryActive ? { cancel: true } : undefined;\n });\n\n pi.on('session_compact', (event, ctx) => {\n // Native compaction supersedes any summarization still in flight.\n checkpointController?.abort();\n checkpointController = undefined;\n const eventDetails = fileDetailsFromUnknown(event.compactionEntry.details);\n const cumulative = mergeFileDetails(state, undefined, eventDetails);\n state.readFiles = cumulative.readFiles;\n state.modifiedFiles = cumulative.modifiedFiles;\n delete state.latestCheckpointSnapshotLeafId;\n // Reported usage still describes the pre-compaction context here too, so the baseline\n // waits for the first assistant response measured against the compacted one.\n state.baselinePending = true;\n state.phase = STATE_PHASE.waiting;\n clearPendingCheckpoint();\n state.checkpointQueue = [];\n state.exhaustedPasses = [];\n state.invalidAttempts = 0;\n delete state.lastAttemptLeafId;\n\n pi.setLabel(event.compactionEntry.id, `autocompact:c${state.cycle}:external`);\n const completedCycle = state.cycle;\n const runtimeAttributes = telemetryAttributes(ctx, {\n 'autocompact.cycle': completedCycle,\n 'autocompact.native.reason': event.reason,\n });\n const runtimeSnapshot = preserveRuntimeState(ctx, ctx.sessionManager.getBranch(), runtimeAttributes);\n state.cycle += 1;\n state.pass = 1;\n persist();\n void telemetry.recordEvent(\n AUTOCOMPACT_EVENT.nativeCompactionCompleted,\n telemetryAttributes(ctx, {\n 'autocompact.cycle': completedCycle,\n 'autocompact.native.reason': event.reason,\n 'autocompact.native.from_extension': event.fromExtension,\n 'autocompact.tokens_before': event.compactionEntry.tokensBefore,\n ...runtimeTelemetryAttributes(runtimeSnapshot),\n }),\n );\n notify(\n ctx,\n `Doom autocompact completed. Baseline will be captured from the next settled context. Next pass: ${state.pass}.`,\n );\n });\n\n pi.on('session_shutdown', async () => {\n checkpointController?.abort();\n checkpointController = undefined;\n footerContribution.dispose();\n currentContext = undefined;\n appliedContextRequests.clear();\n invalidContextLeaves.clear();\n state = createInitialState();\n await telemetry.shutdown();\n });\n}\n"],"mappings":"y0CAgDA,MAAM,EAAoB,QAKpB,EAAc,CAClB,QAAS,UACT,kBAAmB,qBACnB,gBAAiB,mBACjB,WAAY,aACb,CAwED,SAAS,EACP,EACA,EAAyC,EAAE,CACf,CAC5B,MAAO,CACL,gBAAiB,EAAQ,eAAe,cAAc,CACtD,GAAG,EACJ,CAGH,SAAS,GAAqB,EAAsD,CAClF,IAAK,IAAI,EAAQ,EAAO,OAAS,EAAG,GAAS,EAAG,IAAY,CAC1D,IAAM,EAAQ,EAAO,GACrB,GAAI,GAAO,OAAS,UAAY,EAAM,aAAA,yBAAkC,SACxE,IAAM,EAAS,EAAW,EAAM,KAAK,CACrC,GAAI,EAAQ,OAAO,GAKvB,SAAS,EAAc,EAA+B,CACpD,IAAK,IAAM,KAAS,EAAI,eAAe,WAAW,CAAC,YAAY,CACzD,OAAM,OAAS,UAAY,EAAM,aAAA,2BACjC,EAAM,OAAS,QACnB,OAAO,EAAM,GAEf,OAAO,EAGT,SAAS,EAAa,EAAwB,CAC5C,OAAO,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CAG/D,SAAS,EAAmB,EAAkD,CAC5E,IAAK,IAAM,KAAS,EAAO,YAAY,CAAE,CACvC,GAAI,EAAM,OAAS,UAAY,EAAM,aAAe,8BAAqB,SACzE,GAAI,CAAC,EAAM,MAAQ,OAAO,EAAM,MAAS,SAAU,OACnD,IAAM,EAAO,EAAM,KAEnB,OADI,OAAO,EAAK,SAAY,UAAY,OAAO,EAAK,MAAS,SAAU,OAChE,CAAE,QAAS,EAAK,QAAS,KAAM,EAAK,KAAM,EAKrD,SAAS,EAA6B,EAAyC,CAC7E,IAAM,EAAqB,EAAE,CAC7B,GAAI,CACF,IAAM,EAA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,SAAS,CAC5B,EAAiB,IAAA,GACjB,EAAuB,OAAO,CAC9B,EAAqB,OAAO,CAC5B,EAAQ,GAAoB,CAC5B,MAAM,EAAU,UAAU,EAC1B"}
@@ -0,0 +1,2 @@
1
+ var e=require(`../standard.cjs`).registerStandardAutocompactExtension;module.exports=e;
2
+ //# sourceMappingURL=pi.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.cjs","names":["registerStandardAutocompactExtension"],"sources":["../../src/extensions/pi.ts"],"sourcesContent":["import { registerStandardAutocompactExtension } from '../standard.ts';\n\nexport default registerStandardAutocompactExtension;\n"],"mappings":"AAEA,IAAA,4BAAeA,CAAAA"}
@@ -0,0 +1,2 @@
1
+ import { registerStandardAutocompactExtension } from "../standard.cjs";
2
+ export = registerStandardAutocompactExtension;
@@ -0,0 +1,2 @@
1
+ import { registerStandardAutocompactExtension } from "../standard.mjs";
2
+ export { registerStandardAutocompactExtension as default };
@@ -0,0 +1,2 @@
1
+ import{registerStandardAutocompactExtension as e}from"../standard.mjs";var t=e;export{t as default};
2
+ //# sourceMappingURL=pi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.mjs","names":[],"sources":["../../src/extensions/pi.ts"],"sourcesContent":["import { registerStandardAutocompactExtension } from '../standard.ts';\n\nexport default registerStandardAutocompactExtension;\n"],"mappings":"uEAEA,IAAA,EAAe"}
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./policy.cjs`),t=require(`./extension.cjs`);exports.registerAutocompactExtension=t.registerAutocompactExtension,exports.thresholdTokens=e.thresholdTokens;
@@ -0,0 +1,4 @@
1
+ import { registerAutocompactExtension } from "./extension.cjs";
2
+ import { AutocompactPass } from "./types.cjs";
3
+ import { thresholdTokens } from "./policy.cjs";
4
+ export { type AutocompactPass, registerAutocompactExtension, thresholdTokens };
@@ -0,0 +1,4 @@
1
+ import { registerAutocompactExtension } from "./extension.mjs";
2
+ import { AutocompactPass } from "./types.mjs";
3
+ import { thresholdTokens } from "./policy.mjs";
4
+ export { type AutocompactPass, registerAutocompactExtension, thresholdTokens };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{thresholdTokens as e}from"./policy.mjs";import{registerAutocompactExtension as t}from"./extension.mjs";export{t as registerAutocompactExtension,e as thresholdTokens};
@@ -0,0 +1,2 @@
1
+ let e=require(`@agimon-ai/doompi-telemetry`);const t={checkpointStarted:`doom_autocompact.checkpoint_started`,checkpointCompleted:`doom_autocompact.checkpoint_completed`,checkpointFailed:`doom_autocompact.checkpoint_failed`,checkpointInvalid:`doom_autocompact.checkpoint_invalid`,taskSnapshotDegraded:`doom_autocompact.task_snapshot_degraded`,teamSnapshotDegraded:`doom_autocompact.team_snapshot_degraded`,contextCommitted:`doom_autocompact.context_committed`,contextApplied:`doom_autocompact.context_applied`,contextMarkerInvalid:`doom_autocompact.context_marker_invalid`,nativeCompactionCompleted:`doom_autocompact.native_compaction_completed`};function n(t={}){let n=(0,e.createDoomTelemetry)({serviceName:`doom-autocompact`,packageName:`@agimon-ai/doompi-autocompact`,cwd:t.cwd,workspaceRoot:t.workspaceRoot,env:t.env,telemetryFactory:t.telemetryFactory,warn:t.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,r)=>n.recordError(e,t,r),recordWarning:(e,t,r)=>n.recordWarning(e,t,r),recordEvent:(e,t)=>n.recordEvent(e,t),runInSpan:(e,t,r)=>n.runInSpan(e,t,r),flush:()=>n.flush(),shutdown:()=>n.shutdown()}}exports.AUTOCOMPACT_EVENT=t,exports.createAutocompactTelemetry=n;
2
+ //# sourceMappingURL=logSinkTelemetry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.cjs","names":[],"sources":["../src/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-autocompact';\nconst PACKAGE_NAME = '@agimon-ai/doompi-autocompact';\n\nexport const AUTOCOMPACT_EVENT = {\n checkpointStarted: 'doom_autocompact.checkpoint_started',\n checkpointCompleted: 'doom_autocompact.checkpoint_completed',\n checkpointFailed: 'doom_autocompact.checkpoint_failed',\n checkpointInvalid: 'doom_autocompact.checkpoint_invalid',\n taskSnapshotDegraded: 'doom_autocompact.task_snapshot_degraded',\n teamSnapshotDegraded: 'doom_autocompact.team_snapshot_degraded',\n contextCommitted: 'doom_autocompact.context_committed',\n contextApplied: 'doom_autocompact.context_applied',\n contextMarkerInvalid: 'doom_autocompact.context_marker_invalid',\n nativeCompactionCompleted: 'doom_autocompact.native_compaction_completed',\n} as const;\n\nexport type AutocompactEventName = (typeof AUTOCOMPACT_EVENT)[keyof typeof AUTOCOMPACT_EVENT];\nexport type AutocompactEventAttributes = Record<string, string | number | boolean>;\n\nexport interface AutocompactTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface AutocompactTelemetry {\n recordError(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;\n recordWarning(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;\n recordEvent(event: AutocompactEventName, attributes?: AutocompactEventAttributes): Promise<void>;\n runInSpan<T>(name: string, attributes: AutocompactEventAttributes, callback: () => Promise<T>): Promise<T>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createAutocompactTelemetry(options: AutocompactTelemetryOptions = {}): AutocompactTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n runInSpan: (name, attributes, callback) => telemetry.runInSpan(name, attributes, callback),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n"],"mappings":"6CAEA,MAGa,EAAoB,CAC/B,kBAAmB,sCACnB,oBAAqB,wCACrB,iBAAkB,qCAClB,kBAAmB,sCACnB,qBAAsB,0CACtB,qBAAsB,0CACtB,iBAAkB,qCAClB,eAAgB,mCAChB,qBAAsB,0CACtB,0BAA2B,+CAC5B,CAsBD,SAAgB,EAA2B,EAAuC,EAAE,CAAwB,CAC1G,IAAM,GAAA,EAAA,EAAA,qBAA+C,CACnD,YAAa,mBACb,YAAa,gCACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,GACf,CAAC,CACF,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,EAAW,CAC1F,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,EAAW,CAC9F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,EAAW,CAC5E,WAAY,EAAM,EAAY,IAAa,EAAU,UAAU,EAAM,EAAY,EAAS,CAC1F,UAAa,EAAU,OAAO,CAC9B,aAAgB,EAAU,UAAU,CACrC"}
@@ -0,0 +1,26 @@
1
+ //#region src/logSinkTelemetry.d.ts
2
+ declare const AUTOCOMPACT_EVENT: {
3
+ readonly checkpointStarted: "doom_autocompact.checkpoint_started";
4
+ readonly checkpointCompleted: "doom_autocompact.checkpoint_completed";
5
+ readonly checkpointFailed: "doom_autocompact.checkpoint_failed";
6
+ readonly checkpointInvalid: "doom_autocompact.checkpoint_invalid";
7
+ readonly taskSnapshotDegraded: "doom_autocompact.task_snapshot_degraded";
8
+ readonly teamSnapshotDegraded: "doom_autocompact.team_snapshot_degraded";
9
+ readonly contextCommitted: "doom_autocompact.context_committed";
10
+ readonly contextApplied: "doom_autocompact.context_applied";
11
+ readonly contextMarkerInvalid: "doom_autocompact.context_marker_invalid";
12
+ readonly nativeCompactionCompleted: "doom_autocompact.native_compaction_completed";
13
+ };
14
+ type AutocompactEventName = (typeof AUTOCOMPACT_EVENT)[keyof typeof AUTOCOMPACT_EVENT];
15
+ type AutocompactEventAttributes = Record<string, string | number | boolean>;
16
+ interface AutocompactTelemetry {
17
+ recordError(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;
18
+ recordWarning(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;
19
+ recordEvent(event: AutocompactEventName, attributes?: AutocompactEventAttributes): Promise<void>;
20
+ runInSpan<T>(name: string, attributes: AutocompactEventAttributes, callback: () => Promise<T>): Promise<T>;
21
+ flush(): Promise<void>;
22
+ shutdown(): Promise<void>;
23
+ }
24
+ //#endregion
25
+ export { AutocompactTelemetry };
26
+ //# sourceMappingURL=logSinkTelemetry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.d.cts","names":[],"sources":["../src/logSinkTelemetry.ts"],"mappings":";cAKa,iBAAA;EAAA;;;;;;;;;;;KAaD,oBAAA,WAA+B,iBAAA,eAAgC,iBAAA;AAAA,KAC/D,0BAAA,GAA6B,MAAA;AAAA,UAUxB,oBAAA;EACf,WAAA,CAAY,KAAA,EAAO,oBAAA,EAAsB,KAAA,WAAgB,UAAA,GAAa,0BAAA,GAA6B,OAAA;EACnG,aAAA,CAAc,KAAA,EAAO,oBAAA,EAAsB,KAAA,WAAgB,UAAA,GAAa,0BAAA,GAA6B,OAAA;EACrG,WAAA,CAAY,KAAA,EAAO,oBAAA,EAAsB,UAAA,GAAa,0BAAA,GAA6B,OAAA;EACnF,SAAA,IAAa,IAAA,UAAc,UAAA,EAAY,0BAAA,EAA4B,QAAA,QAAgB,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,CAAA;EACxG,KAAA,IAAS,OAAA;EACT,QAAA,IAAY,OAAA;AAAA"}
@@ -0,0 +1,26 @@
1
+ //#region src/logSinkTelemetry.d.ts
2
+ declare const AUTOCOMPACT_EVENT: {
3
+ readonly checkpointStarted: "doom_autocompact.checkpoint_started";
4
+ readonly checkpointCompleted: "doom_autocompact.checkpoint_completed";
5
+ readonly checkpointFailed: "doom_autocompact.checkpoint_failed";
6
+ readonly checkpointInvalid: "doom_autocompact.checkpoint_invalid";
7
+ readonly taskSnapshotDegraded: "doom_autocompact.task_snapshot_degraded";
8
+ readonly teamSnapshotDegraded: "doom_autocompact.team_snapshot_degraded";
9
+ readonly contextCommitted: "doom_autocompact.context_committed";
10
+ readonly contextApplied: "doom_autocompact.context_applied";
11
+ readonly contextMarkerInvalid: "doom_autocompact.context_marker_invalid";
12
+ readonly nativeCompactionCompleted: "doom_autocompact.native_compaction_completed";
13
+ };
14
+ type AutocompactEventName = (typeof AUTOCOMPACT_EVENT)[keyof typeof AUTOCOMPACT_EVENT];
15
+ type AutocompactEventAttributes = Record<string, string | number | boolean>;
16
+ interface AutocompactTelemetry {
17
+ recordError(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;
18
+ recordWarning(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;
19
+ recordEvent(event: AutocompactEventName, attributes?: AutocompactEventAttributes): Promise<void>;
20
+ runInSpan<T>(name: string, attributes: AutocompactEventAttributes, callback: () => Promise<T>): Promise<T>;
21
+ flush(): Promise<void>;
22
+ shutdown(): Promise<void>;
23
+ }
24
+ //#endregion
25
+ export { AutocompactTelemetry };
26
+ //# sourceMappingURL=logSinkTelemetry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../src/logSinkTelemetry.ts"],"mappings":";cAKa,iBAAA;EAAA;;;;;;;;;;;KAaD,oBAAA,WAA+B,iBAAA,eAAgC,iBAAA;AAAA,KAC/D,0BAAA,GAA6B,MAAA;AAAA,UAUxB,oBAAA;EACf,WAAA,CAAY,KAAA,EAAO,oBAAA,EAAsB,KAAA,WAAgB,UAAA,GAAa,0BAAA,GAA6B,OAAA;EACnG,aAAA,CAAc,KAAA,EAAO,oBAAA,EAAsB,KAAA,WAAgB,UAAA,GAAa,0BAAA,GAA6B,OAAA;EACrG,WAAA,CAAY,KAAA,EAAO,oBAAA,EAAsB,UAAA,GAAa,0BAAA,GAA6B,OAAA;EACnF,SAAA,IAAa,IAAA,UAAc,UAAA,EAAY,0BAAA,EAA4B,QAAA,QAAgB,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,CAAA;EACxG,KAAA,IAAS,OAAA;EACT,QAAA,IAAY,OAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ import{createDoomTelemetry as e}from"@agimon-ai/doompi-telemetry";const t={checkpointStarted:`doom_autocompact.checkpoint_started`,checkpointCompleted:`doom_autocompact.checkpoint_completed`,checkpointFailed:`doom_autocompact.checkpoint_failed`,checkpointInvalid:`doom_autocompact.checkpoint_invalid`,taskSnapshotDegraded:`doom_autocompact.task_snapshot_degraded`,teamSnapshotDegraded:`doom_autocompact.team_snapshot_degraded`,contextCommitted:`doom_autocompact.context_committed`,contextApplied:`doom_autocompact.context_applied`,contextMarkerInvalid:`doom_autocompact.context_marker_invalid`,nativeCompactionCompleted:`doom_autocompact.native_compaction_completed`};function n(t={}){let n=e({serviceName:`doom-autocompact`,packageName:`@agimon-ai/doompi-autocompact`,cwd:t.cwd,workspaceRoot:t.workspaceRoot,env:t.env,telemetryFactory:t.telemetryFactory,warn:t.warn,enableLogs:!0,enableTraces:!0});return{recordError:(e,t,r)=>n.recordError(e,t,r),recordWarning:(e,t,r)=>n.recordWarning(e,t,r),recordEvent:(e,t)=>n.recordEvent(e,t),runInSpan:(e,t,r)=>n.runInSpan(e,t,r),flush:()=>n.flush(),shutdown:()=>n.shutdown()}}export{t as AUTOCOMPACT_EVENT,n as createAutocompactTelemetry};
2
+ //# sourceMappingURL=logSinkTelemetry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSinkTelemetry.mjs","names":[],"sources":["../src/logSinkTelemetry.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/doompi-telemetry';\n\nconst SERVICE_NAME = 'doom-autocompact';\nconst PACKAGE_NAME = '@agimon-ai/doompi-autocompact';\n\nexport const AUTOCOMPACT_EVENT = {\n checkpointStarted: 'doom_autocompact.checkpoint_started',\n checkpointCompleted: 'doom_autocompact.checkpoint_completed',\n checkpointFailed: 'doom_autocompact.checkpoint_failed',\n checkpointInvalid: 'doom_autocompact.checkpoint_invalid',\n taskSnapshotDegraded: 'doom_autocompact.task_snapshot_degraded',\n teamSnapshotDegraded: 'doom_autocompact.team_snapshot_degraded',\n contextCommitted: 'doom_autocompact.context_committed',\n contextApplied: 'doom_autocompact.context_applied',\n contextMarkerInvalid: 'doom_autocompact.context_marker_invalid',\n nativeCompactionCompleted: 'doom_autocompact.native_compaction_completed',\n} as const;\n\nexport type AutocompactEventName = (typeof AUTOCOMPACT_EVENT)[keyof typeof AUTOCOMPACT_EVENT];\nexport type AutocompactEventAttributes = Record<string, string | number | boolean>;\n\nexport interface AutocompactTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface AutocompactTelemetry {\n recordError(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;\n recordWarning(event: AutocompactEventName, error: unknown, attributes?: AutocompactEventAttributes): Promise<void>;\n recordEvent(event: AutocompactEventName, attributes?: AutocompactEventAttributes): Promise<void>;\n runInSpan<T>(name: string, attributes: AutocompactEventAttributes, callback: () => Promise<T>): Promise<T>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createAutocompactTelemetry(options: AutocompactTelemetryOptions = {}): AutocompactTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n runInSpan: (name, attributes, callback) => telemetry.runInSpan(name, attributes, callback),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n"],"mappings":"kEAEA,MAGa,EAAoB,CAC/B,kBAAmB,sCACnB,oBAAqB,wCACrB,iBAAkB,qCAClB,kBAAmB,sCACnB,qBAAsB,0CACtB,qBAAsB,0CACtB,iBAAkB,qCAClB,eAAgB,mCAChB,qBAAsB,0CACtB,0BAA2B,+CAC5B,CAsBD,SAAgB,EAA2B,EAAuC,EAAE,CAAwB,CAC1G,IAAM,EAA2B,EAAoB,CACnD,YAAa,mBACb,YAAa,gCACb,IAAK,EAAQ,IACb,cAAe,EAAQ,cACvB,IAAK,EAAQ,IACb,iBAAkB,EAAQ,iBAC1B,KAAM,EAAQ,KACd,WAAY,GACZ,aAAc,GACf,CAAC,CACF,MAAO,CACL,aAAc,EAAO,EAAO,IAAe,EAAU,YAAY,EAAO,EAAO,EAAW,CAC1F,eAAgB,EAAO,EAAO,IAAe,EAAU,cAAc,EAAO,EAAO,EAAW,CAC9F,aAAc,EAAO,IAAe,EAAU,YAAY,EAAO,EAAW,CAC5E,WAAY,EAAM,EAAY,IAAa,EAAU,UAAU,EAAM,EAAY,EAAS,CAC1F,UAAa,EAAU,OAAO,CAC9B,aAAgB,EAAU,UAAU,CACrC"}
@@ -0,0 +1,8 @@
1
+ const e=require(`./constants.cjs`);let t=require(`@earendil-works/pi-coding-agent`);const n=/<shouldCompact>\s*(true|false)\s*<\/shouldCompact>/i,r=/\n*<(?:read-files|modified-files)>[\s\S]*?<\/(?:read-files|modified-files)>/g;function i(e){return typeof e==`object`&&!!e}function a(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function o(e){return e===1||e===2||e===3}function s(e){if(!(e.type!==`message`||e.message.role!==`assistant`))return e.message.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
2
+ `).trim()||void 0}function c(e){return i(e)&&typeof e.role==`string`}function l(e){if(!i(e)||!a(e.readFiles)||!a(e.modifiedFiles)||!Array.isArray(e.retainedMessages)||!e.retainedMessages.every(c)||!i(e.doomAutocompact))return;let t=e.doomAutocompact;if(!(t.version!==2||t.pass!==2&&t.pass!==3||typeof t.cycle!=`number`||typeof t.requestId!=`string`||typeof t.snapshotLeafId!=`string`||typeof t.tokensBefore!=`number`))return{readFiles:[...e.readFiles],modifiedFiles:[...e.modifiedFiles],retainedMessages:[...e.retainedMessages],doomAutocompact:{version:2,cycle:t.cycle,pass:t.pass,requestId:t.requestId,snapshotLeafId:t.snapshotLeafId,tokensBefore:t.tokensBefore}}}function u(){return{version:2,cycle:1,pass:1,phase:`waiting`,checkpointQueue:[],exhaustedPasses:[],invalidAttempts:0,baselineTokens:0,baselinePending:!1,readFiles:[],modifiedFiles:[]}}function d(n,r,i=0){let a=e.COMPACTION_THRESHOLDS[n],o=Math.max(0,Math.min(i,r)),s=r-o,c=o+Math.min(Math.floor(s*a.ratio),a.capTokens),l=r-t.DEFAULT_COMPACTION_SETTINGS.reserveTokens;return l>o?Math.min(c,l):c}function f(e){return e.findLast(e=>e.type===`compaction`||e.type===`custom`&&e.customType===`doom-autocompact-checkpoint`||e.type===`custom_message`&&(e.customType===`doom-autocompact-checkpoint`||e.customType===`doom-autocompact-context`))}function p(e){let t=e.findLastIndex(e=>e.type===`compaction`||e.type===`custom_message`&&e.customType===`doom-autocompact-context`);return e.slice(t+1).some(e=>{if(e.type!==`message`||e.message.role!==`assistant`)return!1;let{stopReason:t,usage:n}=e.message;return t===`aborted`||t===`error`||!n?!1:(n.totalTokens||n.input+n.output+n.cacheRead+n.cacheWrite)>0})}function m(e,n){let r=e.findIndex(e=>e.id===n);return r===-1?[]:e.slice(r+1).filter(e=>e.type!==`custom_message`||e.customType!==`doom-autocompact-checkpoint`).flatMap(e=>(0,t.sessionEntryToContextMessages)(e))}function h(e,t){let n=t.findLastIndex(e=>e.type===`compaction`),r=t.slice(n+1).findLast(e=>e.type===`custom_message`&&e.customType===`doom-autocompact-context`);if(!r||r.type!==`custom_message`)return{messages:e,retainedMessageCount:0};let i=l(r.details),a=v(r);if(!i||!a)return{messages:e,invalidMarker:!0,retainedMessageCount:0};let o=e.findLastIndex(e=>e.role===`custom`&&e.customType===`doom-autocompact-context`&&l(e.details)?.doomAutocompact.requestId===i.doomAutocompact.requestId);return o===-1?{messages:e,invalidMarker:!0,retainedMessageCount:0}:{messages:[{role:`compactionSummary`,summary:a,tokensBefore:i.doomAutocompact.tokensBefore,timestamp:e[o]?.timestamp??Date.now()},...i.retainedMessages,...e.slice(o+1)],marker:i.doomAutocompact,retainedMessageCount:i.retainedMessages.length}}function g(e){let t={read:new Set,written:new Set,edited:new Set};for(let n of e)if(n.role===`assistant`)for(let e of n.content){if(e.type!==`toolCall`)continue;let n=typeof e.arguments.path==`string`?e.arguments.path:void 0;n&&(e.name===`read`?t.read.add(n):e.name===`write`?t.written.add(n):e.name===`edit`&&t.edited.add(n))}return t}function _(e){if(!i(e)||e.version!==2||typeof e.cycle!=`number`||!o(e.pass)||e.phase!==`waiting`&&e.phase!==`checkpoint_pending`&&e.phase!==`checkpoint_ready`&&e.phase!==`compacting`)return;let t=e.baselineTokens??0;if(typeof t!=`number`||t<0)return;let n=e.baselinePending??!1;if(typeof n!=`boolean`)return;let r=e.checkpointQueue??[];if(!Array.isArray(r)||!r.every(o)||r.some((e,t)=>t>0&&e<=r[t-1]))return;let s=e.exhaustedPasses??[];if(!Array.isArray(s)||!s.every(o))return;let c=e.invalidAttempts??0;if(!(typeof c!=`number`||c<0)&&!(!a(e.readFiles)||!a(e.modifiedFiles))&&!(e.requestId!==void 0&&typeof e.requestId!=`string`)&&!(e.compactionPass!==void 0&&e.compactionPass!==2&&e.compactionPass!==3)&&!(`latestCheckpointEntryId`in e)&&!(e.latestCheckpointSnapshotLeafId!==void 0&&typeof e.latestCheckpointSnapshotLeafId!=`string`)&&!(e.lastAttemptLeafId!==void 0&&typeof e.lastAttemptLeafId!=`string`)&&!(e.snapshotLeafId!==void 0&&typeof e.snapshotLeafId!=`string`)&&!(e.snapshotTokens!==void 0&&(typeof e.snapshotTokens!=`number`||e.snapshotTokens<0))&&!(e.pendingCheckpoint!==void 0&&typeof e.pendingCheckpoint!=`string`))return{version:2,cycle:e.cycle,pass:e.pass,phase:e.phase,checkpointQueue:[...r],exhaustedPasses:[...s],invalidAttempts:c,baselineTokens:t,baselinePending:n,readFiles:[...e.readFiles],modifiedFiles:[...e.modifiedFiles],...e.requestId?{requestId:e.requestId}:{},...e.compactionPass?{compactionPass:e.compactionPass}:{},...e.latestCheckpointSnapshotLeafId?{latestCheckpointSnapshotLeafId:e.latestCheckpointSnapshotLeafId}:{},...e.lastAttemptLeafId?{lastAttemptLeafId:e.lastAttemptLeafId}:{},...e.snapshotLeafId?{snapshotLeafId:e.snapshotLeafId}:{},...e.snapshotTokens===void 0?{}:{snapshotTokens:e.snapshotTokens},...e.pendingCheckpoint?{pendingCheckpoint:e.pendingCheckpoint}:{}}}function v(e){if(e)return e.type===`compaction`?e.summary.trim()||void 0:e.type===`custom`?i(e.data)&&typeof e.data.summary==`string`&&e.data.summary.trim()||void 0:e.type===`custom_message`?(typeof e.content==`string`?e.content:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
3
+ `)).trim()||void 0:s(e)}function y(e){let t=e.match(n),r=e.replace(n,``).trim();return t?{summary:r,shouldCompact:t[1]?.toLowerCase()===`true`}:{summary:r}}function b(t){return e.CHECKPOINT_HEADINGS.every(e=>t.includes(e))}function x(e,t,n,r){return`${e}:${t}:${n}:${r??`root`}`}function S(e,t,n){return{version:2,cycle:e,pass:t,requestId:n}}function C(e,t,n){let r=new Set([...e.modifiedFiles,...n?.modifiedFiles??[],...t?[...t.edited,...t.written]:[]]),i=new Set([...e.readFiles,...n?.readFiles??[],...t?[...t.read]:[]]);for(let e of r)i.delete(e);return{readFiles:[...i].sort(),modifiedFiles:[...r].sort()}}function w(e){if(!(!i(e)||!a(e.readFiles)||!a(e.modifiedFiles)))return{readFiles:e.readFiles,modifiedFiles:e.modifiedFiles}}function T(e,t){let n=[];t.readFiles.length>0&&n.push(`<read-files>\n${t.readFiles.join(`
4
+ `)}\n</read-files>`),t.modifiedFiles.length>0&&n.push(`<modified-files>\n${t.modifiedFiles.join(`
5
+ `)}\n</modified-files>`);let i=e.replace(r,``).trim();return n.length>0?`${i}\n\n${n.join(`
6
+
7
+ `)}`:i}exports.baselineUsageIsSettled=p,exports.checkpointRequestDetails=S,exports.checkpointSummaryFromEntry=v,exports.createInitialState=u,exports.createRequestId=x,exports.fileDetailsFromUnknown=w,exports.fileOperationsFromMessages=g,exports.isStructuredCheckpoint=b,exports.latestCheckpointArtifactEntry=f,exports.mergeFileDetails=C,exports.parseCheckpointDecision=y,exports.parseState=_,exports.projectContextMessages=h,exports.retainedMessagesAfterSnapshot=m,exports.thresholdTokens=d,exports.withCanonicalFileSections=T;
8
+ //# sourceMappingURL=policy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.cjs","names":["COMPACTION_THRESHOLDS","DEFAULT_COMPACTION_SETTINGS","CHECKPOINT_HEADINGS"],"sources":["../src/policy.ts"],"sourcesContent":["import {\n DEFAULT_COMPACTION_SETTINGS,\n sessionEntryToContextMessages,\n type FileOperations,\n type SessionEntry,\n} from '@earendil-works/pi-coding-agent';\nimport {\n CHECKPOINT_HEADINGS,\n CHECKPOINT_MESSAGE_TYPE,\n COMPACTION_THRESHOLDS,\n CONTEXT_MESSAGE_TYPE,\n STATE_VERSION,\n} from './constants.ts';\nimport type {\n AutocompactContextDetails,\n AutocompactFileDetails,\n AutocompactMessage,\n AutocompactPass,\n AutocompactState,\n CheckpointDecision,\n CheckpointRequestDetails,\n ContextProjection,\n} from './types.ts';\n\nconst SHOULD_COMPACT_PATTERN = /<shouldCompact>\\s*(true|false)\\s*<\\/shouldCompact>/i;\nconst FILE_SECTION_PATTERN = /\\n*<(?:read-files|modified-files)>[\\s\\S]*?<\\/(?:read-files|modified-files)>/g;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === 'string');\n}\n\nfunction isPass(value: unknown): value is AutocompactPass {\n return value === 1 || value === 2 || value === 3;\n}\n\nfunction assistantText(entry: SessionEntry): string | undefined {\n if (entry.type !== 'message' || entry.message.role !== 'assistant') return undefined;\n const text = entry.message.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n')\n .trim();\n return text || undefined;\n}\n\nfunction isAutocompactMessage(value: unknown): value is AutocompactMessage {\n return isRecord(value) && typeof value.role === 'string';\n}\n\nexport function contextDetailsFromUnknown(value: unknown): AutocompactContextDetails | undefined {\n if (!isRecord(value) || !isStringArray(value.readFiles) || !isStringArray(value.modifiedFiles)) return undefined;\n if (!Array.isArray(value.retainedMessages) || !value.retainedMessages.every(isAutocompactMessage)) return undefined;\n if (!isRecord(value.doomAutocompact)) return undefined;\n const marker = value.doomAutocompact;\n if (\n marker.version !== STATE_VERSION ||\n (marker.pass !== 2 && marker.pass !== 3) ||\n typeof marker.cycle !== 'number' ||\n typeof marker.requestId !== 'string' ||\n typeof marker.snapshotLeafId !== 'string' ||\n typeof marker.tokensBefore !== 'number'\n )\n return undefined;\n return {\n readFiles: [...value.readFiles],\n modifiedFiles: [...value.modifiedFiles],\n retainedMessages: [...value.retainedMessages],\n doomAutocompact: {\n version: STATE_VERSION,\n cycle: marker.cycle,\n pass: marker.pass,\n requestId: marker.requestId,\n snapshotLeafId: marker.snapshotLeafId,\n tokensBefore: marker.tokensBefore,\n },\n };\n}\n\nexport function createInitialState(): AutocompactState {\n return {\n version: STATE_VERSION,\n cycle: 1,\n pass: 1,\n phase: 'waiting',\n checkpointQueue: [],\n exhaustedPasses: [],\n invalidAttempts: 0,\n baselineTokens: 0,\n baselinePending: false,\n readFiles: [],\n modifiedFiles: [],\n };\n}\n\nexport function thresholdTokens(pass: AutocompactPass, contextWindow: number, baselineTokens = 0): number {\n const threshold = COMPACTION_THRESHOLDS[pass];\n const baseline = Math.max(0, Math.min(baselineTokens, contextWindow));\n const remaining = contextWindow - baseline;\n const staged = baseline + Math.min(Math.floor(remaining * threshold.ratio), threshold.capTokens);\n // Pi compacts natively above `contextWindow - reserveTokens`. A staged threshold above that\n // point can never fire, so the ladder would silently degrade into native compaction: on a\n // 200k window the raw pass 3 ratio lands at 190_000, while Pi already compacted at 183_616.\n const nativeTrigger = contextWindow - DEFAULT_COMPACTION_SETTINGS.reserveTokens;\n return nativeTrigger > baseline ? Math.min(staged, nativeTrigger) : staged;\n}\n\nexport function latestCheckpointArtifactEntry(branchEntries: SessionEntry[]): SessionEntry | undefined {\n return branchEntries.findLast(\n (entry) =>\n entry.type === 'compaction' ||\n // Staged checkpoints are plain entries so they stay out of the agent's LLM context.\n (entry.type === 'custom' && entry.customType === CHECKPOINT_MESSAGE_TYPE) ||\n // Legacy sessions staged checkpoints as custom messages; committed markers still are.\n (entry.type === 'custom_message' &&\n (entry.customType === CHECKPOINT_MESSAGE_TYPE || entry.customType === CONTEXT_MESSAGE_TYPE)),\n );\n}\n\nexport function baselineUsageIsSettled(branchEntries: SessionEntry[]): boolean {\n const boundaryIndex = branchEntries.findLastIndex(\n (entry) =>\n entry.type === 'compaction' || (entry.type === 'custom_message' && entry.customType === CONTEXT_MESSAGE_TYPE),\n );\n return branchEntries.slice(boundaryIndex + 1).some((entry) => {\n if (entry.type !== 'message' || entry.message.role !== 'assistant') return false;\n const { stopReason, usage } = entry.message;\n if (stopReason === 'aborted' || stopReason === 'error' || !usage) return false;\n return (usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite) > 0;\n });\n}\n\nexport function retainedMessagesAfterSnapshot(\n branchEntries: SessionEntry[],\n snapshotLeafId: string,\n): AutocompactMessage[] {\n const snapshotIndex = branchEntries.findIndex((entry) => entry.id === snapshotLeafId);\n if (snapshotIndex === -1) return [];\n return branchEntries\n .slice(snapshotIndex + 1)\n .filter((entry) => entry.type !== 'custom_message' || entry.customType !== CHECKPOINT_MESSAGE_TYPE)\n .flatMap((entry) => sessionEntryToContextMessages(entry));\n}\n\nexport function projectContextMessages(\n messages: AutocompactMessage[],\n branchEntries: SessionEntry[],\n): ContextProjection {\n const nativeCompactionIndex = branchEntries.findLastIndex((entry) => entry.type === 'compaction');\n const markerEntry = branchEntries\n .slice(nativeCompactionIndex + 1)\n .findLast((entry) => entry.type === 'custom_message' && entry.customType === CONTEXT_MESSAGE_TYPE);\n if (!markerEntry || markerEntry.type !== 'custom_message') {\n return { messages, retainedMessageCount: 0 };\n }\n\n const details = contextDetailsFromUnknown(markerEntry.details);\n const summary = checkpointSummaryFromEntry(markerEntry);\n if (!details || !summary) return { messages, invalidMarker: true, retainedMessageCount: 0 };\n\n const markerMessageIndex = messages.findLastIndex(\n (message) =>\n message.role === 'custom' &&\n message.customType === CONTEXT_MESSAGE_TYPE &&\n contextDetailsFromUnknown(message.details)?.doomAutocompact.requestId === details.doomAutocompact.requestId,\n );\n if (markerMessageIndex === -1) return { messages, invalidMarker: true, retainedMessageCount: 0 };\n\n const summaryMessage: AutocompactMessage = {\n role: 'compactionSummary',\n summary,\n tokensBefore: details.doomAutocompact.tokensBefore,\n timestamp: messages[markerMessageIndex]?.timestamp ?? Date.now(),\n };\n return {\n messages: [summaryMessage, ...details.retainedMessages, ...messages.slice(markerMessageIndex + 1)],\n marker: details.doomAutocompact,\n retainedMessageCount: details.retainedMessages.length,\n };\n}\n\nexport function fileOperationsFromMessages(messages: AutocompactMessage[]): FileOperations {\n const fileOps: FileOperations = { read: new Set(), written: new Set(), edited: new Set() };\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const block of message.content) {\n if (block.type !== 'toolCall') continue;\n const path = typeof block.arguments.path === 'string' ? block.arguments.path : undefined;\n if (!path) continue;\n if (block.name === 'read') fileOps.read.add(path);\n else if (block.name === 'write') fileOps.written.add(path);\n else if (block.name === 'edit') fileOps.edited.add(path);\n }\n }\n return fileOps;\n}\n\nexport function parseState(value: unknown): AutocompactState | undefined {\n if (!isRecord(value)) return undefined;\n if (value.version !== STATE_VERSION || typeof value.cycle !== 'number' || !isPass(value.pass)) return undefined;\n if (\n value.phase !== 'waiting' &&\n value.phase !== 'checkpoint_pending' &&\n value.phase !== 'checkpoint_ready' &&\n value.phase !== 'compacting'\n )\n return undefined;\n const baselineTokens = value.baselineTokens ?? 0;\n if (typeof baselineTokens !== 'number' || baselineTokens < 0) return undefined;\n const baselinePending = value.baselinePending ?? false;\n if (typeof baselinePending !== 'boolean') return undefined;\n const checkpointQueue = value.checkpointQueue ?? [];\n if (\n !Array.isArray(checkpointQueue) ||\n !checkpointQueue.every(isPass) ||\n checkpointQueue.some((pass, index) => index > 0 && pass <= checkpointQueue[index - 1]!)\n )\n return undefined;\n // Sessions persisted before bounded retry landed simply have no attempt history to restore.\n const exhaustedPasses = value.exhaustedPasses ?? [];\n if (!Array.isArray(exhaustedPasses) || !exhaustedPasses.every(isPass)) return undefined;\n const invalidAttempts = value.invalidAttempts ?? 0;\n if (typeof invalidAttempts !== 'number' || invalidAttempts < 0) return undefined;\n if (!isStringArray(value.readFiles) || !isStringArray(value.modifiedFiles)) return undefined;\n if (value.requestId !== undefined && typeof value.requestId !== 'string') return undefined;\n if (value.compactionPass !== undefined && value.compactionPass !== 2 && value.compactionPass !== 3) return undefined;\n if ('latestCheckpointEntryId' in value) return undefined;\n if (value.latestCheckpointSnapshotLeafId !== undefined && typeof value.latestCheckpointSnapshotLeafId !== 'string')\n return undefined;\n if (value.lastAttemptLeafId !== undefined && typeof value.lastAttemptLeafId !== 'string') return undefined;\n if (value.snapshotLeafId !== undefined && typeof value.snapshotLeafId !== 'string') return undefined;\n if (value.snapshotTokens !== undefined && (typeof value.snapshotTokens !== 'number' || value.snapshotTokens < 0))\n return undefined;\n if (value.pendingCheckpoint !== undefined && typeof value.pendingCheckpoint !== 'string') return undefined;\n\n return {\n version: STATE_VERSION,\n cycle: value.cycle,\n pass: value.pass,\n phase: value.phase,\n checkpointQueue: [...checkpointQueue],\n exhaustedPasses: [...exhaustedPasses],\n invalidAttempts,\n baselineTokens,\n baselinePending,\n readFiles: [...value.readFiles],\n modifiedFiles: [...value.modifiedFiles],\n ...(value.requestId ? { requestId: value.requestId } : {}),\n ...(value.compactionPass ? { compactionPass: value.compactionPass } : {}),\n ...(value.latestCheckpointSnapshotLeafId\n ? { latestCheckpointSnapshotLeafId: value.latestCheckpointSnapshotLeafId }\n : {}),\n ...(value.lastAttemptLeafId ? { lastAttemptLeafId: value.lastAttemptLeafId } : {}),\n ...(value.snapshotLeafId ? { snapshotLeafId: value.snapshotLeafId } : {}),\n ...(value.snapshotTokens !== undefined ? { snapshotTokens: value.snapshotTokens } : {}),\n ...(value.pendingCheckpoint ? { pendingCheckpoint: value.pendingCheckpoint } : {}),\n };\n}\n\nexport function checkpointSummaryFromEntry(entry: SessionEntry | undefined): string | undefined {\n if (!entry) return undefined;\n if (entry.type === 'compaction') return entry.summary.trim() || undefined;\n if (entry.type === 'custom') {\n return isRecord(entry.data) && typeof entry.data.summary === 'string'\n ? entry.data.summary.trim() || undefined\n : undefined;\n }\n if (entry.type === 'custom_message') {\n const content =\n typeof entry.content === 'string'\n ? entry.content\n : entry.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n return content.trim() || undefined;\n }\n return assistantText(entry);\n}\n\nexport function parseCheckpointDecision(response: string): CheckpointDecision {\n const match = response.match(SHOULD_COMPACT_PATTERN);\n const summary = response.replace(SHOULD_COMPACT_PATTERN, '').trim();\n if (!match) return { summary };\n return { summary, shouldCompact: match[1]?.toLowerCase() === 'true' };\n}\n\nexport function isStructuredCheckpoint(summary: string): boolean {\n return CHECKPOINT_HEADINGS.every((heading) => summary.includes(heading));\n}\n\nexport function createRequestId(\n sessionId: string,\n cycle: number,\n pass: AutocompactPass,\n leafId: string | null,\n): string {\n return `${sessionId}:${cycle}:${pass}:${leafId ?? 'root'}`;\n}\n\nexport function checkpointRequestDetails(\n cycle: number,\n pass: AutocompactPass,\n requestId: string,\n): CheckpointRequestDetails {\n return { version: STATE_VERSION, cycle, pass, requestId };\n}\n\nexport function mergeFileDetails(\n current: AutocompactFileDetails,\n fileOps?: FileOperations,\n additional?: AutocompactFileDetails,\n): AutocompactFileDetails {\n const modified = new Set([\n ...current.modifiedFiles,\n ...(additional?.modifiedFiles ?? []),\n ...(fileOps ? [...fileOps.edited, ...fileOps.written] : []),\n ]);\n const read = new Set([...current.readFiles, ...(additional?.readFiles ?? []), ...(fileOps ? [...fileOps.read] : [])]);\n for (const path of modified) read.delete(path);\n return { readFiles: [...read].sort(), modifiedFiles: [...modified].sort() };\n}\n\nexport function fileDetailsFromUnknown(value: unknown): AutocompactFileDetails | undefined {\n if (!isRecord(value) || !isStringArray(value.readFiles) || !isStringArray(value.modifiedFiles)) return undefined;\n return { readFiles: value.readFiles, modifiedFiles: value.modifiedFiles };\n}\n\nexport function withCanonicalFileSections(summary: string, details: AutocompactFileDetails): string {\n const sections: string[] = [];\n if (details.readFiles.length > 0) sections.push(`<read-files>\\n${details.readFiles.join('\\n')}\\n</read-files>`);\n if (details.modifiedFiles.length > 0) {\n sections.push(`<modified-files>\\n${details.modifiedFiles.join('\\n')}\\n</modified-files>`);\n }\n const normalized = summary.replace(FILE_SECTION_PATTERN, '').trim();\n return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9F,MAAO,CAAE,UAAW,EAAM,UAAW,cAAe,EAAM,cAAe,CAG3E,SAAgB,EAA0B,EAAiB,EAAyC,CAClG,IAAM,EAAqB,EAAE,CACzB,EAAQ,UAAU,OAAS,GAAG,EAAS,KAAK,iBAAiB,EAAQ,UAAU,KAAK;EAAK,CAAC,iBAAiB,CAC3G,EAAQ,cAAc,OAAS,GACjC,EAAS,KAAK,qBAAqB,EAAQ,cAAc,KAAK;EAAK,CAAC,qBAAqB,CAE3F,IAAM,EAAa,EAAQ,QAAQ,EAAsB,GAAG,CAAC,MAAM,CACnE,OAAO,EAAS,OAAS,EAAI,GAAG,EAAW,MAAM,EAAS,KAAK;;EAAO,GAAK"}
@@ -0,0 +1,6 @@
1
+ import { AutocompactPass } from "./types.cjs";
2
+ //#region src/policy.d.ts
3
+ declare function thresholdTokens(pass: AutocompactPass, contextWindow: number, baselineTokens?: number): number;
4
+ //#endregion
5
+ export { thresholdTokens };
6
+ //# sourceMappingURL=policy.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.cts","names":[],"sources":["../src/policy.ts"],"mappings":";;iBAkGgB,eAAA,CAAgB,IAAA,EAAM,eAAA,EAAiB,aAAA,UAAuB,cAAA"}
@@ -0,0 +1,6 @@
1
+ import { AutocompactPass } from "./types.mjs";
2
+ //#region src/policy.d.ts
3
+ declare function thresholdTokens(pass: AutocompactPass, contextWindow: number, baselineTokens?: number): number;
4
+ //#endregion
5
+ export { thresholdTokens };
6
+ //# sourceMappingURL=policy.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.mts","names":[],"sources":["../src/policy.ts"],"mappings":";;iBAkGgB,eAAA,CAAgB,IAAA,EAAM,eAAA,EAAiB,aAAA,UAAuB,cAAA"}
@@ -0,0 +1,8 @@
1
+ import{CHECKPOINT_HEADINGS as e,COMPACTION_THRESHOLDS as t}from"./constants.mjs";import{DEFAULT_COMPACTION_SETTINGS as n,sessionEntryToContextMessages as r}from"@earendil-works/pi-coding-agent";const i=/<shouldCompact>\s*(true|false)\s*<\/shouldCompact>/i,a=/\n*<(?:read-files|modified-files)>[\s\S]*?<\/(?:read-files|modified-files)>/g;function o(e){return typeof e==`object`&&!!e}function s(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function c(e){return e===1||e===2||e===3}function l(e){if(!(e.type!==`message`||e.message.role!==`assistant`))return e.message.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
2
+ `).trim()||void 0}function u(e){return o(e)&&typeof e.role==`string`}function d(e){if(!o(e)||!s(e.readFiles)||!s(e.modifiedFiles)||!Array.isArray(e.retainedMessages)||!e.retainedMessages.every(u)||!o(e.doomAutocompact))return;let t=e.doomAutocompact;if(!(t.version!==2||t.pass!==2&&t.pass!==3||typeof t.cycle!=`number`||typeof t.requestId!=`string`||typeof t.snapshotLeafId!=`string`||typeof t.tokensBefore!=`number`))return{readFiles:[...e.readFiles],modifiedFiles:[...e.modifiedFiles],retainedMessages:[...e.retainedMessages],doomAutocompact:{version:2,cycle:t.cycle,pass:t.pass,requestId:t.requestId,snapshotLeafId:t.snapshotLeafId,tokensBefore:t.tokensBefore}}}function f(){return{version:2,cycle:1,pass:1,phase:`waiting`,checkpointQueue:[],exhaustedPasses:[],invalidAttempts:0,baselineTokens:0,baselinePending:!1,readFiles:[],modifiedFiles:[]}}function p(e,r,i=0){let a=t[e],o=Math.max(0,Math.min(i,r)),s=r-o,c=o+Math.min(Math.floor(s*a.ratio),a.capTokens),l=r-n.reserveTokens;return l>o?Math.min(c,l):c}function m(e){return e.findLast(e=>e.type===`compaction`||e.type===`custom`&&e.customType===`doom-autocompact-checkpoint`||e.type===`custom_message`&&(e.customType===`doom-autocompact-checkpoint`||e.customType===`doom-autocompact-context`))}function h(e){let t=e.findLastIndex(e=>e.type===`compaction`||e.type===`custom_message`&&e.customType===`doom-autocompact-context`);return e.slice(t+1).some(e=>{if(e.type!==`message`||e.message.role!==`assistant`)return!1;let{stopReason:t,usage:n}=e.message;return t===`aborted`||t===`error`||!n?!1:(n.totalTokens||n.input+n.output+n.cacheRead+n.cacheWrite)>0})}function g(e,t){let n=e.findIndex(e=>e.id===t);return n===-1?[]:e.slice(n+1).filter(e=>e.type!==`custom_message`||e.customType!==`doom-autocompact-checkpoint`).flatMap(e=>r(e))}function _(e,t){let n=t.findLastIndex(e=>e.type===`compaction`),r=t.slice(n+1).findLast(e=>e.type===`custom_message`&&e.customType===`doom-autocompact-context`);if(!r||r.type!==`custom_message`)return{messages:e,retainedMessageCount:0};let i=d(r.details),a=b(r);if(!i||!a)return{messages:e,invalidMarker:!0,retainedMessageCount:0};let o=e.findLastIndex(e=>e.role===`custom`&&e.customType===`doom-autocompact-context`&&d(e.details)?.doomAutocompact.requestId===i.doomAutocompact.requestId);return o===-1?{messages:e,invalidMarker:!0,retainedMessageCount:0}:{messages:[{role:`compactionSummary`,summary:a,tokensBefore:i.doomAutocompact.tokensBefore,timestamp:e[o]?.timestamp??Date.now()},...i.retainedMessages,...e.slice(o+1)],marker:i.doomAutocompact,retainedMessageCount:i.retainedMessages.length}}function v(e){let t={read:new Set,written:new Set,edited:new Set};for(let n of e)if(n.role===`assistant`)for(let e of n.content){if(e.type!==`toolCall`)continue;let n=typeof e.arguments.path==`string`?e.arguments.path:void 0;n&&(e.name===`read`?t.read.add(n):e.name===`write`?t.written.add(n):e.name===`edit`&&t.edited.add(n))}return t}function y(e){if(!o(e)||e.version!==2||typeof e.cycle!=`number`||!c(e.pass)||e.phase!==`waiting`&&e.phase!==`checkpoint_pending`&&e.phase!==`checkpoint_ready`&&e.phase!==`compacting`)return;let t=e.baselineTokens??0;if(typeof t!=`number`||t<0)return;let n=e.baselinePending??!1;if(typeof n!=`boolean`)return;let r=e.checkpointQueue??[];if(!Array.isArray(r)||!r.every(c)||r.some((e,t)=>t>0&&e<=r[t-1]))return;let i=e.exhaustedPasses??[];if(!Array.isArray(i)||!i.every(c))return;let a=e.invalidAttempts??0;if(!(typeof a!=`number`||a<0)&&!(!s(e.readFiles)||!s(e.modifiedFiles))&&!(e.requestId!==void 0&&typeof e.requestId!=`string`)&&!(e.compactionPass!==void 0&&e.compactionPass!==2&&e.compactionPass!==3)&&!(`latestCheckpointEntryId`in e)&&!(e.latestCheckpointSnapshotLeafId!==void 0&&typeof e.latestCheckpointSnapshotLeafId!=`string`)&&!(e.lastAttemptLeafId!==void 0&&typeof e.lastAttemptLeafId!=`string`)&&!(e.snapshotLeafId!==void 0&&typeof e.snapshotLeafId!=`string`)&&!(e.snapshotTokens!==void 0&&(typeof e.snapshotTokens!=`number`||e.snapshotTokens<0))&&!(e.pendingCheckpoint!==void 0&&typeof e.pendingCheckpoint!=`string`))return{version:2,cycle:e.cycle,pass:e.pass,phase:e.phase,checkpointQueue:[...r],exhaustedPasses:[...i],invalidAttempts:a,baselineTokens:t,baselinePending:n,readFiles:[...e.readFiles],modifiedFiles:[...e.modifiedFiles],...e.requestId?{requestId:e.requestId}:{},...e.compactionPass?{compactionPass:e.compactionPass}:{},...e.latestCheckpointSnapshotLeafId?{latestCheckpointSnapshotLeafId:e.latestCheckpointSnapshotLeafId}:{},...e.lastAttemptLeafId?{lastAttemptLeafId:e.lastAttemptLeafId}:{},...e.snapshotLeafId?{snapshotLeafId:e.snapshotLeafId}:{},...e.snapshotTokens===void 0?{}:{snapshotTokens:e.snapshotTokens},...e.pendingCheckpoint?{pendingCheckpoint:e.pendingCheckpoint}:{}}}function b(e){if(e)return e.type===`compaction`?e.summary.trim()||void 0:e.type===`custom`?o(e.data)&&typeof e.data.summary==`string`&&e.data.summary.trim()||void 0:e.type===`custom_message`?(typeof e.content==`string`?e.content:e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
3
+ `)).trim()||void 0:l(e)}function x(e){let t=e.match(i),n=e.replace(i,``).trim();return t?{summary:n,shouldCompact:t[1]?.toLowerCase()===`true`}:{summary:n}}function S(t){return e.every(e=>t.includes(e))}function C(e,t,n,r){return`${e}:${t}:${n}:${r??`root`}`}function w(e,t,n){return{version:2,cycle:e,pass:t,requestId:n}}function T(e,t,n){let r=new Set([...e.modifiedFiles,...n?.modifiedFiles??[],...t?[...t.edited,...t.written]:[]]),i=new Set([...e.readFiles,...n?.readFiles??[],...t?[...t.read]:[]]);for(let e of r)i.delete(e);return{readFiles:[...i].sort(),modifiedFiles:[...r].sort()}}function E(e){if(!(!o(e)||!s(e.readFiles)||!s(e.modifiedFiles)))return{readFiles:e.readFiles,modifiedFiles:e.modifiedFiles}}function D(e,t){let n=[];t.readFiles.length>0&&n.push(`<read-files>\n${t.readFiles.join(`
4
+ `)}\n</read-files>`),t.modifiedFiles.length>0&&n.push(`<modified-files>\n${t.modifiedFiles.join(`
5
+ `)}\n</modified-files>`);let r=e.replace(a,``).trim();return n.length>0?`${r}\n\n${n.join(`
6
+
7
+ `)}`:r}export{h as baselineUsageIsSettled,w as checkpointRequestDetails,b as checkpointSummaryFromEntry,f as createInitialState,C as createRequestId,E as fileDetailsFromUnknown,v as fileOperationsFromMessages,S as isStructuredCheckpoint,m as latestCheckpointArtifactEntry,T as mergeFileDetails,x as parseCheckpointDecision,y as parseState,_ as projectContextMessages,g as retainedMessagesAfterSnapshot,p as thresholdTokens,D as withCanonicalFileSections};
8
+ //# sourceMappingURL=policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.mjs","names":[],"sources":["../src/policy.ts"],"sourcesContent":["import {\n DEFAULT_COMPACTION_SETTINGS,\n sessionEntryToContextMessages,\n type FileOperations,\n type SessionEntry,\n} from '@earendil-works/pi-coding-agent';\nimport {\n CHECKPOINT_HEADINGS,\n CHECKPOINT_MESSAGE_TYPE,\n COMPACTION_THRESHOLDS,\n CONTEXT_MESSAGE_TYPE,\n STATE_VERSION,\n} from './constants.ts';\nimport type {\n AutocompactContextDetails,\n AutocompactFileDetails,\n AutocompactMessage,\n AutocompactPass,\n AutocompactState,\n CheckpointDecision,\n CheckpointRequestDetails,\n ContextProjection,\n} from './types.ts';\n\nconst SHOULD_COMPACT_PATTERN = /<shouldCompact>\\s*(true|false)\\s*<\\/shouldCompact>/i;\nconst FILE_SECTION_PATTERN = /\\n*<(?:read-files|modified-files)>[\\s\\S]*?<\\/(?:read-files|modified-files)>/g;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((item) => typeof item === 'string');\n}\n\nfunction isPass(value: unknown): value is AutocompactPass {\n return value === 1 || value === 2 || value === 3;\n}\n\nfunction assistantText(entry: SessionEntry): string | undefined {\n if (entry.type !== 'message' || entry.message.role !== 'assistant') return undefined;\n const text = entry.message.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n')\n .trim();\n return text || undefined;\n}\n\nfunction isAutocompactMessage(value: unknown): value is AutocompactMessage {\n return isRecord(value) && typeof value.role === 'string';\n}\n\nexport function contextDetailsFromUnknown(value: unknown): AutocompactContextDetails | undefined {\n if (!isRecord(value) || !isStringArray(value.readFiles) || !isStringArray(value.modifiedFiles)) return undefined;\n if (!Array.isArray(value.retainedMessages) || !value.retainedMessages.every(isAutocompactMessage)) return undefined;\n if (!isRecord(value.doomAutocompact)) return undefined;\n const marker = value.doomAutocompact;\n if (\n marker.version !== STATE_VERSION ||\n (marker.pass !== 2 && marker.pass !== 3) ||\n typeof marker.cycle !== 'number' ||\n typeof marker.requestId !== 'string' ||\n typeof marker.snapshotLeafId !== 'string' ||\n typeof marker.tokensBefore !== 'number'\n )\n return undefined;\n return {\n readFiles: [...value.readFiles],\n modifiedFiles: [...value.modifiedFiles],\n retainedMessages: [...value.retainedMessages],\n doomAutocompact: {\n version: STATE_VERSION,\n cycle: marker.cycle,\n pass: marker.pass,\n requestId: marker.requestId,\n snapshotLeafId: marker.snapshotLeafId,\n tokensBefore: marker.tokensBefore,\n },\n };\n}\n\nexport function createInitialState(): AutocompactState {\n return {\n version: STATE_VERSION,\n cycle: 1,\n pass: 1,\n phase: 'waiting',\n checkpointQueue: [],\n exhaustedPasses: [],\n invalidAttempts: 0,\n baselineTokens: 0,\n baselinePending: false,\n readFiles: [],\n modifiedFiles: [],\n };\n}\n\nexport function thresholdTokens(pass: AutocompactPass, contextWindow: number, baselineTokens = 0): number {\n const threshold = COMPACTION_THRESHOLDS[pass];\n const baseline = Math.max(0, Math.min(baselineTokens, contextWindow));\n const remaining = contextWindow - baseline;\n const staged = baseline + Math.min(Math.floor(remaining * threshold.ratio), threshold.capTokens);\n // Pi compacts natively above `contextWindow - reserveTokens`. A staged threshold above that\n // point can never fire, so the ladder would silently degrade into native compaction: on a\n // 200k window the raw pass 3 ratio lands at 190_000, while Pi already compacted at 183_616.\n const nativeTrigger = contextWindow - DEFAULT_COMPACTION_SETTINGS.reserveTokens;\n return nativeTrigger > baseline ? Math.min(staged, nativeTrigger) : staged;\n}\n\nexport function latestCheckpointArtifactEntry(branchEntries: SessionEntry[]): SessionEntry | undefined {\n return branchEntries.findLast(\n (entry) =>\n entry.type === 'compaction' ||\n // Staged checkpoints are plain entries so they stay out of the agent's LLM context.\n (entry.type === 'custom' && entry.customType === CHECKPOINT_MESSAGE_TYPE) ||\n // Legacy sessions staged checkpoints as custom messages; committed markers still are.\n (entry.type === 'custom_message' &&\n (entry.customType === CHECKPOINT_MESSAGE_TYPE || entry.customType === CONTEXT_MESSAGE_TYPE)),\n );\n}\n\nexport function baselineUsageIsSettled(branchEntries: SessionEntry[]): boolean {\n const boundaryIndex = branchEntries.findLastIndex(\n (entry) =>\n entry.type === 'compaction' || (entry.type === 'custom_message' && entry.customType === CONTEXT_MESSAGE_TYPE),\n );\n return branchEntries.slice(boundaryIndex + 1).some((entry) => {\n if (entry.type !== 'message' || entry.message.role !== 'assistant') return false;\n const { stopReason, usage } = entry.message;\n if (stopReason === 'aborted' || stopReason === 'error' || !usage) return false;\n return (usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite) > 0;\n });\n}\n\nexport function retainedMessagesAfterSnapshot(\n branchEntries: SessionEntry[],\n snapshotLeafId: string,\n): AutocompactMessage[] {\n const snapshotIndex = branchEntries.findIndex((entry) => entry.id === snapshotLeafId);\n if (snapshotIndex === -1) return [];\n return branchEntries\n .slice(snapshotIndex + 1)\n .filter((entry) => entry.type !== 'custom_message' || entry.customType !== CHECKPOINT_MESSAGE_TYPE)\n .flatMap((entry) => sessionEntryToContextMessages(entry));\n}\n\nexport function projectContextMessages(\n messages: AutocompactMessage[],\n branchEntries: SessionEntry[],\n): ContextProjection {\n const nativeCompactionIndex = branchEntries.findLastIndex((entry) => entry.type === 'compaction');\n const markerEntry = branchEntries\n .slice(nativeCompactionIndex + 1)\n .findLast((entry) => entry.type === 'custom_message' && entry.customType === CONTEXT_MESSAGE_TYPE);\n if (!markerEntry || markerEntry.type !== 'custom_message') {\n return { messages, retainedMessageCount: 0 };\n }\n\n const details = contextDetailsFromUnknown(markerEntry.details);\n const summary = checkpointSummaryFromEntry(markerEntry);\n if (!details || !summary) return { messages, invalidMarker: true, retainedMessageCount: 0 };\n\n const markerMessageIndex = messages.findLastIndex(\n (message) =>\n message.role === 'custom' &&\n message.customType === CONTEXT_MESSAGE_TYPE &&\n contextDetailsFromUnknown(message.details)?.doomAutocompact.requestId === details.doomAutocompact.requestId,\n );\n if (markerMessageIndex === -1) return { messages, invalidMarker: true, retainedMessageCount: 0 };\n\n const summaryMessage: AutocompactMessage = {\n role: 'compactionSummary',\n summary,\n tokensBefore: details.doomAutocompact.tokensBefore,\n timestamp: messages[markerMessageIndex]?.timestamp ?? Date.now(),\n };\n return {\n messages: [summaryMessage, ...details.retainedMessages, ...messages.slice(markerMessageIndex + 1)],\n marker: details.doomAutocompact,\n retainedMessageCount: details.retainedMessages.length,\n };\n}\n\nexport function fileOperationsFromMessages(messages: AutocompactMessage[]): FileOperations {\n const fileOps: FileOperations = { read: new Set(), written: new Set(), edited: new Set() };\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const block of message.content) {\n if (block.type !== 'toolCall') continue;\n const path = typeof block.arguments.path === 'string' ? block.arguments.path : undefined;\n if (!path) continue;\n if (block.name === 'read') fileOps.read.add(path);\n else if (block.name === 'write') fileOps.written.add(path);\n else if (block.name === 'edit') fileOps.edited.add(path);\n }\n }\n return fileOps;\n}\n\nexport function parseState(value: unknown): AutocompactState | undefined {\n if (!isRecord(value)) return undefined;\n if (value.version !== STATE_VERSION || typeof value.cycle !== 'number' || !isPass(value.pass)) return undefined;\n if (\n value.phase !== 'waiting' &&\n value.phase !== 'checkpoint_pending' &&\n value.phase !== 'checkpoint_ready' &&\n value.phase !== 'compacting'\n )\n return undefined;\n const baselineTokens = value.baselineTokens ?? 0;\n if (typeof baselineTokens !== 'number' || baselineTokens < 0) return undefined;\n const baselinePending = value.baselinePending ?? false;\n if (typeof baselinePending !== 'boolean') return undefined;\n const checkpointQueue = value.checkpointQueue ?? [];\n if (\n !Array.isArray(checkpointQueue) ||\n !checkpointQueue.every(isPass) ||\n checkpointQueue.some((pass, index) => index > 0 && pass <= checkpointQueue[index - 1]!)\n )\n return undefined;\n // Sessions persisted before bounded retry landed simply have no attempt history to restore.\n const exhaustedPasses = value.exhaustedPasses ?? [];\n if (!Array.isArray(exhaustedPasses) || !exhaustedPasses.every(isPass)) return undefined;\n const invalidAttempts = value.invalidAttempts ?? 0;\n if (typeof invalidAttempts !== 'number' || invalidAttempts < 0) return undefined;\n if (!isStringArray(value.readFiles) || !isStringArray(value.modifiedFiles)) return undefined;\n if (value.requestId !== undefined && typeof value.requestId !== 'string') return undefined;\n if (value.compactionPass !== undefined && value.compactionPass !== 2 && value.compactionPass !== 3) return undefined;\n if ('latestCheckpointEntryId' in value) return undefined;\n if (value.latestCheckpointSnapshotLeafId !== undefined && typeof value.latestCheckpointSnapshotLeafId !== 'string')\n return undefined;\n if (value.lastAttemptLeafId !== undefined && typeof value.lastAttemptLeafId !== 'string') return undefined;\n if (value.snapshotLeafId !== undefined && typeof value.snapshotLeafId !== 'string') return undefined;\n if (value.snapshotTokens !== undefined && (typeof value.snapshotTokens !== 'number' || value.snapshotTokens < 0))\n return undefined;\n if (value.pendingCheckpoint !== undefined && typeof value.pendingCheckpoint !== 'string') return undefined;\n\n return {\n version: STATE_VERSION,\n cycle: value.cycle,\n pass: value.pass,\n phase: value.phase,\n checkpointQueue: [...checkpointQueue],\n exhaustedPasses: [...exhaustedPasses],\n invalidAttempts,\n baselineTokens,\n baselinePending,\n readFiles: [...value.readFiles],\n modifiedFiles: [...value.modifiedFiles],\n ...(value.requestId ? { requestId: value.requestId } : {}),\n ...(value.compactionPass ? { compactionPass: value.compactionPass } : {}),\n ...(value.latestCheckpointSnapshotLeafId\n ? { latestCheckpointSnapshotLeafId: value.latestCheckpointSnapshotLeafId }\n : {}),\n ...(value.lastAttemptLeafId ? { lastAttemptLeafId: value.lastAttemptLeafId } : {}),\n ...(value.snapshotLeafId ? { snapshotLeafId: value.snapshotLeafId } : {}),\n ...(value.snapshotTokens !== undefined ? { snapshotTokens: value.snapshotTokens } : {}),\n ...(value.pendingCheckpoint ? { pendingCheckpoint: value.pendingCheckpoint } : {}),\n };\n}\n\nexport function checkpointSummaryFromEntry(entry: SessionEntry | undefined): string | undefined {\n if (!entry) return undefined;\n if (entry.type === 'compaction') return entry.summary.trim() || undefined;\n if (entry.type === 'custom') {\n return isRecord(entry.data) && typeof entry.data.summary === 'string'\n ? entry.data.summary.trim() || undefined\n : undefined;\n }\n if (entry.type === 'custom_message') {\n const content =\n typeof entry.content === 'string'\n ? entry.content\n : entry.content\n .filter((block) => block.type === 'text')\n .map((block) => block.text)\n .join('\\n');\n return content.trim() || undefined;\n }\n return assistantText(entry);\n}\n\nexport function parseCheckpointDecision(response: string): CheckpointDecision {\n const match = response.match(SHOULD_COMPACT_PATTERN);\n const summary = response.replace(SHOULD_COMPACT_PATTERN, '').trim();\n if (!match) return { summary };\n return { summary, shouldCompact: match[1]?.toLowerCase() === 'true' };\n}\n\nexport function isStructuredCheckpoint(summary: string): boolean {\n return CHECKPOINT_HEADINGS.every((heading) => summary.includes(heading));\n}\n\nexport function createRequestId(\n sessionId: string,\n cycle: number,\n pass: AutocompactPass,\n leafId: string | null,\n): string {\n return `${sessionId}:${cycle}:${pass}:${leafId ?? 'root'}`;\n}\n\nexport function checkpointRequestDetails(\n cycle: number,\n pass: AutocompactPass,\n requestId: string,\n): CheckpointRequestDetails {\n return { version: STATE_VERSION, cycle, pass, requestId };\n}\n\nexport function mergeFileDetails(\n current: AutocompactFileDetails,\n fileOps?: FileOperations,\n additional?: AutocompactFileDetails,\n): AutocompactFileDetails {\n const modified = new Set([\n ...current.modifiedFiles,\n ...(additional?.modifiedFiles ?? []),\n ...(fileOps ? [...fileOps.edited, ...fileOps.written] : []),\n ]);\n const read = new Set([...current.readFiles, ...(additional?.readFiles ?? []), ...(fileOps ? [...fileOps.read] : [])]);\n for (const path of modified) read.delete(path);\n return { readFiles: [...read].sort(), modifiedFiles: [...modified].sort() };\n}\n\nexport function fileDetailsFromUnknown(value: unknown): AutocompactFileDetails | undefined {\n if (!isRecord(value) || !isStringArray(value.readFiles) || !isStringArray(value.modifiedFiles)) return undefined;\n return { readFiles: value.readFiles, modifiedFiles: value.modifiedFiles };\n}\n\nexport function withCanonicalFileSections(summary: string, details: AutocompactFileDetails): string {\n const sections: string[] = [];\n if (details.readFiles.length > 0) sections.push(`<read-files>\\n${details.readFiles.join('\\n')}\\n</read-files>`);\n if (details.modifiedFiles.length > 0) {\n sections.push(`<modified-files>\\n${details.modifiedFiles.join('\\n')}\\n</modified-files>`);\n }\n const normalized = summary.replace(FILE_SECTION_PATTERN, '').trim();\n return sections.length > 0 ? `${normalized}\\n\\n${sections.join('\\n\\n')}` : normalized;\n}\n"],"mappings":"kMAwBA,MAAM,EAAyB,sDACzB,EAAuB,+EAE7B,SAAS,EAAS,EAAkD,CAClE,OAAO,OAAO,GAAU,YAAY,EAGtC,SAAS,EAAc,EAAmC,CACxD,OAAO,MAAM,QAAQ,EAAM,EAAI,EAAM,MAAO,GAAS,OAAO,GAAS,SAAS,CAGhF,SAAS,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,EAAQ,QAAQ,EAAsB,GAAG,CAAC,MAAM,CACnE,OAAO,EAAS,OAAS,EAAI,GAAG,EAAW,MAAM,EAAS,KAAK;;EAAO,GAAK"}
@@ -0,0 +1,2 @@
1
+ const e=require(`./summarizationModel.cjs`),t=require(`./extension.cjs`),n={recordError:async()=>void 0,recordWarning:async()=>void 0,recordEvent:async()=>void 0,runInSpan:async(e,t,n)=>n(),flush:async()=>void 0,shutdown:async()=>void 0};function r(r){t.registerAutocompactExtension(r,{resolveModel:e.resolveSummarizationModel,readTaskSnapshot:()=>({tasks:[]}),readTeamSnapshot:()=>({members:[]}),telemetry:n,doomIntegrations:!1})}exports.registerStandardAutocompactExtension=r;
2
+ //# sourceMappingURL=standard.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.cjs","names":["resolveSummarizationModel"],"sources":["../src/standard.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\nimport { registerAutocompactExtension } from './extension.ts';\nimport type { AutocompactTelemetry } from './logSinkTelemetry.ts';\nimport { resolveSummarizationModel } from './summarizationModel.ts';\n\nconst standardTelemetry: AutocompactTelemetry = {\n recordError: async () => undefined,\n recordWarning: async () => undefined,\n recordEvent: async () => undefined,\n runInSpan: async (_name, _attributes, callback) => callback(),\n flush: async () => undefined,\n shutdown: async () => undefined,\n};\n\n/** Standard Pi composition with active-model selection and empty optional Doom snapshots. */\nexport function registerStandardAutocompactExtension(pi: ExtensionAPI): void {\n registerAutocompactExtension(pi, {\n resolveModel: resolveSummarizationModel,\n readTaskSnapshot: () => ({ tasks: [] }),\n readTeamSnapshot: () => ({ members: [] }),\n telemetry: standardTelemetry,\n doomIntegrations: false,\n });\n}\n"],"mappings":"yEAMM,EAA0C,CAC9C,YAAa,SAAY,IAAA,GACzB,cAAe,SAAY,IAAA,GAC3B,YAAa,SAAY,IAAA,GACzB,UAAW,MAAO,EAAO,EAAa,IAAa,GAAU,CAC7D,MAAO,SAAY,IAAA,GACnB,SAAU,SAAY,IAAA,GACvB,CAGD,SAAgB,EAAqC,EAAwB,CAC3E,EAAA,6BAA6B,EAAI,CAC/B,aAAcA,EAAAA,0BACd,sBAAyB,CAAE,MAAO,EAAE,CAAE,EACtC,sBAAyB,CAAE,QAAS,EAAE,CAAE,EACxC,UAAW,EACX,iBAAkB,GACnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+
3
+ //#region src/standard.d.ts
4
+ /** Standard Pi composition with active-model selection and empty optional Doom snapshots. */
5
+ declare function registerStandardAutocompactExtension(pi: ExtensionAPI): void;
6
+ //#endregion
7
+ export { registerStandardAutocompactExtension };
8
+ //# sourceMappingURL=standard.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.d.cts","names":[],"sources":["../src/standard.ts"],"mappings":";;;;iBAgBgB,oCAAA,CAAqC,EAAA,EAAI,YAAA"}
@@ -0,0 +1,8 @@
1
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+
3
+ //#region src/standard.d.ts
4
+ /** Standard Pi composition with active-model selection and empty optional Doom snapshots. */
5
+ declare function registerStandardAutocompactExtension(pi: ExtensionAPI): void;
6
+ //#endregion
7
+ export { registerStandardAutocompactExtension };
8
+ //# sourceMappingURL=standard.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.d.mts","names":[],"sources":["../src/standard.ts"],"mappings":";;;;iBAgBgB,oCAAA,CAAqC,EAAA,EAAI,YAAA"}
@@ -0,0 +1,2 @@
1
+ import{resolveSummarizationModel as e}from"./summarizationModel.mjs";import{registerAutocompactExtension as t}from"./extension.mjs";const n={recordError:async()=>void 0,recordWarning:async()=>void 0,recordEvent:async()=>void 0,runInSpan:async(e,t,n)=>n(),flush:async()=>void 0,shutdown:async()=>void 0};function r(r){t(r,{resolveModel:e,readTaskSnapshot:()=>({tasks:[]}),readTeamSnapshot:()=>({members:[]}),telemetry:n,doomIntegrations:!1})}export{r as registerStandardAutocompactExtension};
2
+ //# sourceMappingURL=standard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.mjs","names":[],"sources":["../src/standard.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\n\nimport { registerAutocompactExtension } from './extension.ts';\nimport type { AutocompactTelemetry } from './logSinkTelemetry.ts';\nimport { resolveSummarizationModel } from './summarizationModel.ts';\n\nconst standardTelemetry: AutocompactTelemetry = {\n recordError: async () => undefined,\n recordWarning: async () => undefined,\n recordEvent: async () => undefined,\n runInSpan: async (_name, _attributes, callback) => callback(),\n flush: async () => undefined,\n shutdown: async () => undefined,\n};\n\n/** Standard Pi composition with active-model selection and empty optional Doom snapshots. */\nexport function registerStandardAutocompactExtension(pi: ExtensionAPI): void {\n registerAutocompactExtension(pi, {\n resolveModel: resolveSummarizationModel,\n readTaskSnapshot: () => ({ tasks: [] }),\n readTeamSnapshot: () => ({ members: [] }),\n telemetry: standardTelemetry,\n doomIntegrations: false,\n });\n}\n"],"mappings":"oIAMA,MAAM,EAA0C,CAC9C,YAAa,SAAY,IAAA,GACzB,cAAe,SAAY,IAAA,GAC3B,YAAa,SAAY,IAAA,GACzB,UAAW,MAAO,EAAO,EAAa,IAAa,GAAU,CAC7D,MAAO,SAAY,IAAA,GACnB,SAAU,SAAY,IAAA,GACvB,CAGD,SAAgB,EAAqC,EAAwB,CAC3E,EAA6B,EAAI,CAC/B,aAAc,EACd,sBAAyB,CAAE,MAAO,EAAE,CAAE,EACtC,sBAAyB,CAAE,QAAS,EAAE,CAAE,EACxC,UAAW,EACX,iBAAkB,GACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ const e=/:(off|minimal|low|medium|high|xhigh|max)$/;function t(t){let n=t.trim(),r=e.exec(n)?.[1],i=n.replace(e,``),a=i.indexOf(`/`);if(!(a<=0||a>=i.length-1))return{provider:i.slice(0,a),modelId:i.slice(a+1),...r?{thinking:r}:{}}}function n(e){if(e.model)return{model:e.model,...e.thinkingLevel?{thinkingLevel:e.thinkingLevel}:{}}}exports.parseModelReference=t,exports.resolveSummarizationModel=n;
2
+ //# sourceMappingURL=summarizationModel.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizationModel.cjs","names":[],"sources":["../src/summarizationModel.ts"],"sourcesContent":["import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nconst THINKING_SUFFIX_PATTERN = /:(off|minimal|low|medium|high|xhigh|max)$/;\n\nexport interface SummarizationModel {\n model: NonNullable<ExtensionContext['model']>;\n thinkingLevel?: NonNullable<ExtensionContext['thinkingLevel']>;\n}\n\nexport interface ModelReference {\n provider: string;\n modelId: string;\n thinking?: NonNullable<ExtensionContext['thinkingLevel']>;\n}\n\n/** Splits a `provider/model` reference, tolerating the optional thinking suffix. */\nexport function parseModelReference(reference: string): ModelReference | undefined {\n const trimmed = reference.trim();\n const thinking = THINKING_SUFFIX_PATTERN.exec(trimmed)?.[1] as SummarizationModel['thinkingLevel'];\n const identity = trimmed.replace(THINKING_SUFFIX_PATTERN, '');\n const separator = identity.indexOf('/');\n if (separator <= 0 || separator >= identity.length - 1) return undefined;\n return {\n provider: identity.slice(0, separator),\n modelId: identity.slice(separator + 1),\n ...(thinking ? { thinking } : {}),\n };\n}\n\n/** Standard Pi model selection never consults Doom configuration. */\nexport function resolveSummarizationModel(ctx: ExtensionContext): SummarizationModel | undefined {\n if (!ctx.model) return undefined;\n return {\n model: ctx.model,\n ...(ctx.thinkingLevel ? { thinkingLevel: ctx.thinkingLevel } : {}),\n };\n}\n"],"mappings":"AAEA,MAAM,EAA0B,4CAchC,SAAgB,EAAoB,EAA+C,CACjF,IAAM,EAAU,EAAU,MAAM,CAC1B,EAAW,EAAwB,KAAK,EAAQ,GAAG,GACnD,EAAW,EAAQ,QAAQ,EAAyB,GAAG,CACvD,EAAY,EAAS,QAAQ,IAAI,CACnC,QAAa,GAAK,GAAa,EAAS,OAAS,GACrD,MAAO,CACL,SAAU,EAAS,MAAM,EAAG,EAAU,CACtC,QAAS,EAAS,MAAM,EAAY,EAAE,CACtC,GAAI,EAAW,CAAE,WAAU,CAAG,EAAE,CACjC,CAIH,SAAgB,EAA0B,EAAuD,CAC1F,KAAI,MACT,MAAO,CACL,MAAO,EAAI,MACX,GAAI,EAAI,cAAgB,CAAE,cAAe,EAAI,cAAe,CAAG,EAAE,CAClE"}
@@ -0,0 +1,10 @@
1
+ import { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+
3
+ //#region src/summarizationModel.d.ts
4
+ interface SummarizationModel {
5
+ model: NonNullable<ExtensionContext['model']>;
6
+ thinkingLevel?: NonNullable<ExtensionContext['thinkingLevel']>;
7
+ }
8
+ //#endregion
9
+ export { SummarizationModel };
10
+ //# sourceMappingURL=summarizationModel.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizationModel.d.cts","names":[],"sources":["../src/summarizationModel.ts"],"mappings":";;;UAIiB,kBAAA;EACf,KAAA,EAAO,WAAA,CAAY,gBAAA;EACnB,aAAA,GAAgB,WAAA,CAAY,gBAAA;AAAA"}
@@ -0,0 +1,10 @@
1
+ import { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+
3
+ //#region src/summarizationModel.d.ts
4
+ interface SummarizationModel {
5
+ model: NonNullable<ExtensionContext['model']>;
6
+ thinkingLevel?: NonNullable<ExtensionContext['thinkingLevel']>;
7
+ }
8
+ //#endregion
9
+ export { SummarizationModel };
10
+ //# sourceMappingURL=summarizationModel.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizationModel.d.mts","names":[],"sources":["../src/summarizationModel.ts"],"mappings":";;;UAIiB,kBAAA;EACf,KAAA,EAAO,WAAA,CAAY,gBAAA;EACnB,aAAA,GAAgB,WAAA,CAAY,gBAAA;AAAA"}
@@ -0,0 +1,2 @@
1
+ const e=/:(off|minimal|low|medium|high|xhigh|max)$/;function t(t){let n=t.trim(),r=e.exec(n)?.[1],i=n.replace(e,``),a=i.indexOf(`/`);if(!(a<=0||a>=i.length-1))return{provider:i.slice(0,a),modelId:i.slice(a+1),...r?{thinking:r}:{}}}function n(e){if(e.model)return{model:e.model,...e.thinkingLevel?{thinkingLevel:e.thinkingLevel}:{}}}export{t as parseModelReference,n as resolveSummarizationModel};
2
+ //# sourceMappingURL=summarizationModel.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarizationModel.mjs","names":[],"sources":["../src/summarizationModel.ts"],"sourcesContent":["import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nconst THINKING_SUFFIX_PATTERN = /:(off|minimal|low|medium|high|xhigh|max)$/;\n\nexport interface SummarizationModel {\n model: NonNullable<ExtensionContext['model']>;\n thinkingLevel?: NonNullable<ExtensionContext['thinkingLevel']>;\n}\n\nexport interface ModelReference {\n provider: string;\n modelId: string;\n thinking?: NonNullable<ExtensionContext['thinkingLevel']>;\n}\n\n/** Splits a `provider/model` reference, tolerating the optional thinking suffix. */\nexport function parseModelReference(reference: string): ModelReference | undefined {\n const trimmed = reference.trim();\n const thinking = THINKING_SUFFIX_PATTERN.exec(trimmed)?.[1] as SummarizationModel['thinkingLevel'];\n const identity = trimmed.replace(THINKING_SUFFIX_PATTERN, '');\n const separator = identity.indexOf('/');\n if (separator <= 0 || separator >= identity.length - 1) return undefined;\n return {\n provider: identity.slice(0, separator),\n modelId: identity.slice(separator + 1),\n ...(thinking ? { thinking } : {}),\n };\n}\n\n/** Standard Pi model selection never consults Doom configuration. */\nexport function resolveSummarizationModel(ctx: ExtensionContext): SummarizationModel | undefined {\n if (!ctx.model) return undefined;\n return {\n model: ctx.model,\n ...(ctx.thinkingLevel ? { thinkingLevel: ctx.thinkingLevel } : {}),\n };\n}\n"],"mappings":"AAEA,MAAM,EAA0B,4CAchC,SAAgB,EAAoB,EAA+C,CACjF,IAAM,EAAU,EAAU,MAAM,CAC1B,EAAW,EAAwB,KAAK,EAAQ,GAAG,GACnD,EAAW,EAAQ,QAAQ,EAAyB,GAAG,CACvD,EAAY,EAAS,QAAQ,IAAI,CACnC,QAAa,GAAK,GAAa,EAAS,OAAS,GACrD,MAAO,CACL,SAAU,EAAS,MAAM,EAAG,EAAU,CACtC,QAAS,EAAS,MAAM,EAAY,EAAE,CACtC,GAAI,EAAW,CAAE,WAAU,CAAG,EAAE,CACjC,CAIH,SAAgB,EAA0B,EAAuD,CAC1F,KAAI,MACT,MAAO,CACL,MAAO,EAAI,MACX,GAAI,EAAI,cAAgB,CAAE,cAAe,EAAI,cAAe,CAAG,EAAE,CAClE"}
@@ -0,0 +1,5 @@
1
+ //#region src/types.d.ts
2
+ type AutocompactPass = 1 | 2 | 3;
3
+ //#endregion
4
+ export { AutocompactPass };
5
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"mappings":";KAEY,eAAA"}
@@ -0,0 +1,5 @@
1
+ //#region src/types.d.ts
2
+ type AutocompactPass = 1 | 2 | 3;
3
+ //#endregion
4
+ export { AutocompactPass };
5
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";KAEY,eAAA"}