@caupulican/pi-adaptative 0.81.24 → 0.81.26

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.
@@ -1 +1 @@
1
- {"version":3,"file":"session-analytics.js","sourceRoot":"","sources":["../../src/core/session-analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAGxB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAEN,yBAAyB,GAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,uCAAuC,EACvC,wBAAwB,GAExB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAElC,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAyB,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,OAAO,EACN,iCAAiC,GAEjC,MAAM,gCAAgC,CAAC;AAExC,MAAM,CAAC,MAAM,oCAAoC,GAAG,0BAA0B,CAAC;AA0C/E,MAAM,OAAO,gBAAgB;IAC5B,iGAAiG;IACzF,kBAAkB,CAAsD;IAChF,0GAA0G;IAClG,gBAAgB,CAMtB;IACF,yGAAyG;IACxF,8BAA8B,GAAG,IAAI,GAAG,EAA2C,CAAC;IAEpF,IAAI,CAAuB;IAE5C,YAA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AAC;QACnB,CAAC;QAED,aAAa,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC;IAAA,CAChB;IAED;;;;OAIG;IACH,oBAAoB,GAAuB;QAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI;aAC7B,WAAW,EAAE;aACb,KAAK,EAAE;aACP,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW;gBAAE,OAAO,KAAK,CAAC;YACzC,MAAM,GAAG,GAAG,CAAqB,CAAC;YAClC,wCAAwC;YACxC,IAAI,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC3E,OAAO,IAAI,CAAC;QAAA,CACZ,CAAC,CAAC;QAEJ,IAAI,CAAC,aAAa;YAAE,OAAO,SAAS,CAAC;QAErC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,MAAM,OAAO,IAAK,aAAkC,CAAC,OAAO,EAAE,CAAC;YACnE,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YACtB,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;IAAA,CAChC;CACD","sourcesContent":["/**\n * Session usage / cost / stats accounting, context-window usage, and session export.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Read-only over the session\n * except for its two owned memo caches (`_spawnedUsageCache`, `_dailyUsageCache`) — it never mutates\n * agent or session state. Single source of truth for \"how much did this session and its spawned\n * subtree spend\" (footer roll-up, print-mode child reporting), the daily cross-session totals, the\n * /context window estimate, and HTML/JSONL export of the current branch.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport type { AgentMessage, AgentState } from \"@caupulican/pi-agent-core\";\nimport {\n\tCURRENT_SESSION_VERSION,\n\tcalculateContextTokens,\n\testimateContextTokens,\n\tgetLatestCompactionEntry,\n\ttype SessionHeader,\n\ttype SessionManager,\n} from \"@caupulican/pi-agent-core/node\";\nimport type {\n\tAssistantMessage,\n\tModel,\n\tToolArgumentExecutionOutcome,\n\tToolArgumentTeachState,\n\tToolArgumentValidationTelemetryEvent,\n\tUsage,\n} from \"@caupulican/pi-ai\";\nimport { getSessionsDir } from \"../config.ts\";\nimport { theme } from \"../modes/interactive/theme/theme.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport {\n\ttype SessionStats,\n\tSPAWNED_USAGE_CUSTOM_TYPE,\n\ttype SpawnedUsageReport,\n\ttype SpawnedUsageTotals,\n} from \"./agent-session.ts\";\nimport {\n\taggregateCurrentSessionCostsFromEntries,\n\tcreateSessionCostSummary,\n\ttype SessionCostSummary,\n} from \"./cost/cost-summary.ts\";\nimport {\n\taggregateDailyUsageFromSessionFiles,\n\taggregateDailyUsageFromSessionRoot,\n\ttype DailyUsageTotals,\n\tformatDailyUsageBreakdown,\n\tgetLocalDayWindow,\n} from \"./cost/daily-usage.ts\";\nimport { exportSessionToHtml, type ToolHtmlRenderer } from \"./export-html/index.ts\";\nimport { createToolHtmlRenderer } from \"./export-html/tool-renderer.ts\";\nimport type { ContextUsage, ToolDefinition } from \"./extensions/index.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport {\n\tisToolArgumentValidationLogRecord,\n\ttype ToolArgumentValidationLogRecord,\n} from \"./tool-recovery-log-records.ts\";\n\nexport const TOOL_ARGUMENT_VALIDATION_CUSTOM_TYPE = \"tool_argument_validation\";\n\nexport interface ToolArgumentValidationTeachEfficacy {\n\trecurrenceBefore: number;\n\trecurrenceAfter: number;\n\trepairedThenSucceeded: number;\n\trepairedThenFailed: number;\n\trepairedThenNotRun: number;\n}\n\nexport interface ToolArgumentValidationStats {\n\tclean: number;\n\trepaired: number;\n\tbounced: number;\n\tfailureModes: Record<string, number>;\n\trepairsApplied: Record<string, number>;\n\ttaught: Record<ToolArgumentTeachState, number>;\n\texecutionOutcome: Record<ToolArgumentExecutionOutcome, number>;\n\tteachEfficacy: Record<string, ToolArgumentValidationTeachEfficacy>;\n}\n\nexport interface ToolArgumentValidationRecord extends ToolArgumentValidationTelemetryEvent {\n\tversion: 1;\n}\n\nexport interface SessionAnalyticsDeps {\n\t/** Live agent state — assistant-message usage and message counts are read from here. */\n\tgetState(): AgentState;\n\t/** All messages (agent state view) — used for context-window estimation and last-assistant text. */\n\tgetMessages(): AgentMessage[];\n\t/** Current session model — its context window bounds the /context estimate. */\n\tgetModel(): Model<any> | undefined;\n\t/** Session log — entries feed spawned-usage roll-up, daily totals, branch export. */\n\tgetSessionManager(): SessionManager;\n\t/** Settings — the export theme is read here. */\n\tgetSettingsManager(): SettingsManager;\n\t/** Resolve a tool definition for the HTML export's custom-tool renderer. */\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Sidecar recovery telemetry log; read on demand so turn handling never writes session custom entries. */\n\tgetToolRecoveryEventLogPath(): string;\n}\n\nexport class SessionAnalytics {\n\t/** Memoized spawned-usage totals, keyed by session entry count (Bug #22: O(1) between turns). */\n\tprivate _spawnedUsageCache?: { entryCount: number; totals: SpawnedUsageTotals };\n\t/** Memoized daily usage totals with a short TTL, keyed by the resolved scope dir and local-day window. */\n\tprivate _dailyUsageCache?: {\n\t\tsessionDir: string;\n\t\twindowStartMs: number;\n\t\twindowEndMs: number;\n\t\texpiresAt: number;\n\t\ttotals: DailyUsageTotals;\n\t};\n\t/** Live recovery telemetry records already snapshotted for the worker; keyed to dedupe sidecar reads. */\n\tprivate readonly _toolArgumentValidationRecords = new Map<string, ToolArgumentValidationLogRecord>();\n\n\tprivate readonly deps: SessionAnalyticsDeps;\n\n\tconstructor(deps: SessionAnalyticsDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tgetSessionStats(): SessionStats {\n\t\tconst state = this.deps.getState();\n\t\tconst userMessages = state.messages.filter((m) => m.role === \"user\").length;\n\t\tconst assistantMessages = state.messages.filter((m) => m.role === \"assistant\").length;\n\t\tconst toolResults = state.messages.filter((m) => m.role === \"toolResult\").length;\n\n\t\tlet toolCalls = 0;\n\t\tlet totalInput = 0;\n\t\tlet totalOutput = 0;\n\t\tlet totalCacheRead = 0;\n\t\tlet totalCacheWrite = 0;\n\t\tlet totalCost = 0;\n\n\t\tfor (const message of state.messages) {\n\t\t\tif (message.role === \"assistant\") {\n\t\t\t\tconst assistantMsg = message as AssistantMessage;\n\t\t\t\ttoolCalls += assistantMsg.content.filter((c) => c.type === \"toolCall\").length;\n\t\t\t\ttotalInput += assistantMsg.usage.input;\n\t\t\t\ttotalOutput += assistantMsg.usage.output;\n\t\t\t\ttotalCacheRead += assistantMsg.usage.cacheRead;\n\t\t\t\ttotalCacheWrite += assistantMsg.usage.cacheWrite;\n\t\t\t\ttotalCost += assistantMsg.usage.cost.total;\n\t\t\t}\n\t\t}\n\n\t\tconst toolArgumentValidation = this.getToolArgumentValidationStats();\n\n\t\treturn {\n\t\t\tsessionFile: this.deps.getSessionManager().getSessionFile(),\n\t\t\tsessionId: this.deps.getSessionManager().getSessionId(),\n\t\t\tuserMessages,\n\t\t\tassistantMessages,\n\t\t\ttoolCalls,\n\t\t\ttoolResults,\n\t\t\ttotalMessages: state.messages.length,\n\t\t\ttokens: {\n\t\t\t\tinput: totalInput,\n\t\t\t\toutput: totalOutput,\n\t\t\t\tcacheRead: totalCacheRead,\n\t\t\t\tcacheWrite: totalCacheWrite,\n\t\t\t\ttotal: totalInput + totalOutput + totalCacheRead + totalCacheWrite,\n\t\t\t},\n\t\t\tcost: totalCost,\n\t\t\tcontextUsage: this.getContextUsage(),\n\t\t\ttoolArgumentValidation,\n\t\t};\n\t}\n\n\trecordToolArgumentValidation(record: ToolArgumentValidationLogRecord): void {\n\t\tthis._toolArgumentValidationRecords.set(record.recordId, record);\n\t}\n\n\tprivate readToolArgumentValidationSidecarRecords(): ToolArgumentValidationLogRecord[] {\n\t\tconst filePath = this.deps.getToolRecoveryEventLogPath();\n\t\tif (!existsSync(filePath)) return [];\n\t\tconst records: ToolArgumentValidationLogRecord[] = [];\n\t\ttry {\n\t\t\tconst sessionId = this.deps.getSessionManager().getSessionId();\n\t\t\tfor (const line of readFileSync(filePath, \"utf-8\").split(\"\\n\")) {\n\t\t\t\tif (line.trim().length === 0) continue;\n\t\t\t\tconst parsed = JSON.parse(line) as unknown;\n\t\t\t\tif (!isToolArgumentValidationLogRecord(parsed) || parsed.sessionId !== sessionId) continue;\n\t\t\t\trecords.push(parsed);\n\t\t\t}\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\treturn records;\n\t}\n\n\tgetToolArgumentValidationStats(): ToolArgumentValidationStats {\n\t\tconst stats: ToolArgumentValidationStats = {\n\t\t\tclean: 0,\n\t\t\trepaired: 0,\n\t\t\tbounced: 0,\n\t\t\tfailureModes: {},\n\t\t\trepairsApplied: {},\n\t\t\ttaught: { none: 0, note: 0, rule: 0 },\n\t\t\texecutionOutcome: { not_run: 0, succeeded: 0, failed: 0 },\n\t\t\tteachEfficacy: {},\n\t\t};\n\n\t\tconst getEfficacy = (record: ToolArgumentValidationRecord, mode: string): ToolArgumentValidationTeachEfficacy => {\n\t\t\tconst key = `${record.provider ?? \"unknown\"}/${record.model ?? \"unknown\"}:${mode}`;\n\t\t\tstats.teachEfficacy[key] ??= {\n\t\t\t\trecurrenceBefore: 0,\n\t\t\t\trecurrenceAfter: 0,\n\t\t\t\trepairedThenSucceeded: 0,\n\t\t\t\trepairedThenFailed: 0,\n\t\t\t\trepairedThenNotRun: 0,\n\t\t\t};\n\t\t\treturn stats.teachEfficacy[key];\n\t\t};\n\n\t\tconst seen = new Set<string>();\n\t\tconst consume = (record: ToolArgumentValidationRecord, key: string): void => {\n\t\t\tif (seen.has(key)) return;\n\t\t\tseen.add(key);\n\t\t\tstats[record.outcome] += 1;\n\t\t\tconst taught = record.taught ?? \"none\";\n\t\t\tconst executionOutcome = record.executionOutcome ?? \"not_run\";\n\t\t\tstats.taught[taught] += 1;\n\t\t\tstats.executionOutcome[executionOutcome] += 1;\n\t\t\tconst modes = new Set([...record.failureModes, ...record.repairsApplied]);\n\t\t\tfor (const mode of record.failureModes) {\n\t\t\t\tstats.failureModes[mode] = (stats.failureModes[mode] ?? 0) + 1;\n\t\t\t}\n\t\t\tfor (const repair of record.repairsApplied) {\n\t\t\t\tstats.repairsApplied[repair] = (stats.repairsApplied[repair] ?? 0) + 1;\n\t\t\t}\n\t\t\tfor (const mode of modes) {\n\t\t\t\tconst efficacy = getEfficacy(record, mode);\n\t\t\t\tif (taught === \"none\") {\n\t\t\t\t\tefficacy.recurrenceBefore++;\n\t\t\t\t} else {\n\t\t\t\t\tefficacy.recurrenceAfter++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (record.outcome === \"repaired\") {\n\t\t\t\tfor (const repair of record.repairsApplied) {\n\t\t\t\t\tconst efficacy = getEfficacy(record, repair);\n\t\t\t\t\tif (executionOutcome === \"succeeded\") efficacy.repairedThenSucceeded++;\n\t\t\t\t\tif (executionOutcome === \"failed\") efficacy.repairedThenFailed++;\n\t\t\t\t\tif (executionOutcome === \"not_run\") efficacy.repairedThenNotRun++;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\tif (entry.type !== \"custom\" || entry.customType !== TOOL_ARGUMENT_VALIDATION_CUSTOM_TYPE) continue;\n\t\t\tconst record = entry.data as ToolArgumentValidationRecord | undefined;\n\t\t\tif (!record || record.version !== 1) continue;\n\t\t\tconsume(record, `legacy:${entry.id}`);\n\t\t}\n\t\tfor (const record of this.readToolArgumentValidationSidecarRecords()) {\n\t\t\tconsume(record, record.recordId);\n\t\t}\n\t\tfor (const record of this._toolArgumentValidationRecords.values()) {\n\t\t\tconsume(record, record.recordId);\n\t\t}\n\n\t\treturn stats;\n\t}\n\n\t/**\n\t * Cumulative usage (full breakdown) for this session's entire spawn subtree: its own\n\t * assistant messages PLUS every `spawned_usage` report it has rolled up. Single source of\n\t * truth for \"how much did this session and everything it spawned spend\" — used by print-mode\n\t * to emit a child's total so a spawner can roll it up via {@link addSpawnedUsage}.\n\t *\n\t * Including the `spawned_usage` reports is what keeps the single-hop invariant intact: a child\n\t * that itself spawned grandchildren must report own + sub-usage in one number, or the parent\n\t * silently under-counts the grandchildren.\n\t */\n\tgetCumulativeUsage(): Usage {\n\t\tlet input = 0;\n\t\tlet output = 0;\n\t\tlet cacheRead = 0;\n\t\tlet cacheWrite = 0;\n\t\tlet totalTokens = 0;\n\t\tlet costInput = 0;\n\t\tlet costOutput = 0;\n\t\tlet costCacheRead = 0;\n\t\tlet costCacheWrite = 0;\n\t\tlet costTotal = 0;\n\t\tconst add = (usage: Usage) => {\n\t\t\tinput += usage.input;\n\t\t\toutput += usage.output;\n\t\t\tcacheRead += usage.cacheRead;\n\t\t\tcacheWrite += usage.cacheWrite;\n\t\t\ttotalTokens += usage.totalTokens;\n\t\t\tcostInput += usage.cost.input;\n\t\t\tcostOutput += usage.cost.output;\n\t\t\tcostCacheRead += usage.cost.cacheRead;\n\t\t\tcostCacheWrite += usage.cost.cacheWrite;\n\t\t\tcostTotal += usage.cost.total;\n\t\t};\n\t\tfor (const message of this.deps.getState().messages) {\n\t\t\tif (message.role !== \"assistant\") continue;\n\t\t\tconst usage = (message as AssistantMessage).usage;\n\t\t\tif (!usage) continue;\n\t\t\tadd(usage);\n\t\t}\n\t\t// Roll up usage this session attributed to its own spawned children (single-hop).\n\t\tconst seenSpawnedReportIds = new Set<string>();\n\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\tif (entry.type !== \"custom\" || entry.customType !== SPAWNED_USAGE_CUSTOM_TYPE) continue;\n\t\t\tconst data = entry.data as SpawnedUsageReport | undefined;\n\t\t\tif (!data?.usage) continue;\n\t\t\tif (data.reportId) {\n\t\t\t\tif (seenSpawnedReportIds.has(data.reportId)) continue;\n\t\t\t\tseenSpawnedReportIds.add(data.reportId);\n\t\t\t}\n\t\t\tadd(data.usage);\n\t\t}\n\t\treturn {\n\t\t\tinput,\n\t\t\toutput,\n\t\t\tcacheRead,\n\t\t\tcacheWrite,\n\t\t\ttotalTokens,\n\t\t\tcost: {\n\t\t\t\tinput: costInput,\n\t\t\t\toutput: costOutput,\n\t\t\t\tcacheRead: costCacheRead,\n\t\t\t\tcacheWrite: costCacheWrite,\n\t\t\t\ttotal: costTotal,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Record usage spent by a spawned/subagent session so the footer can roll it into the\n\t * displayed cost. Persisted as a `CustomEntry` (`customType: \"spawned_usage\"`, Model A) so\n\t * it survives reload and is reconstructed exactly like main usage; a new/forked session\n\t * starts fresh because it owns a new log file.\n\t *\n\t * Idempotent on `opts.reportId`: a re-report (retry, duplicate `agent_end`) with a\n\t * previously-seen id is ignored, so cost cannot be double-counted. Honors the single-hop\n\t * invariant documented on {@link SpawnedUsageReport}.\n\t *\n\t * @returns the id of the appended entry, or `undefined` if the report was a duplicate.\n\t */\n\taddSpawnedUsage(\n\t\tusage: Usage,\n\t\topts?: { label?: string; sourceSessionId?: string; reportId?: string },\n\t): string | undefined {\n\t\tconst reportId = opts?.reportId;\n\t\tif (reportId) {\n\t\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\t\tif (\n\t\t\t\t\tentry.type === \"custom\" &&\n\t\t\t\t\tentry.customType === SPAWNED_USAGE_CUSTOM_TYPE &&\n\t\t\t\t\t(entry.data as SpawnedUsageReport | undefined)?.reportId === reportId\n\t\t\t\t) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst report: SpawnedUsageReport = {\n\t\t\tusage,\n\t\t\tlabel: opts?.label,\n\t\t\tsourceSessionId: opts?.sourceSessionId,\n\t\t\treportId,\n\t\t};\n\t\treturn this.deps.getSessionManager().appendCustomEntry(SPAWNED_USAGE_CUSTOM_TYPE, report);\n\t}\n\n\t/**\n\t * Aggregate all recorded spawned-usage reports (see {@link addSpawnedUsage}). Cached by the session\n\t * entry count so the interactive footer (which calls this every render frame) is O(1) between turns\n\t * instead of an O(N) scan on every keystroke (Bug #22). Recomputes only when entries change.\n\t */\n\tgetSpawnedUsage(): SpawnedUsageTotals {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst entryCount = sessionManager.getEntryCount?.() ?? sessionManager.getEntries().length;\n\t\tif (this._spawnedUsageCache?.entryCount === entryCount) return this._spawnedUsageCache.totals;\n\t\tconst current = aggregateCurrentSessionCostsFromEntries(sessionManager.getEntries());\n\t\tconst totals: SpawnedUsageTotals = { cost: current.subagentCost, reports: current.subagentReports };\n\t\tthis._spawnedUsageCache = { entryCount, totals };\n\t\treturn totals;\n\t}\n\n\tgetCostSummary(now = new Date()): SessionCostSummary {\n\t\tconst window = getLocalDayWindow(now);\n\t\treturn createSessionCostSummary({\n\t\t\tentries: this.deps.getSessionManager().getEntries(),\n\t\t\tdailyTotals: this.getDailyUsageTotals(now),\n\t\t\ttodayWindow: window,\n\t\t});\n\t}\n\n\tgetDailyUsageTotals(now = new Date()): DailyUsageTotals {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst sessionDir = sessionManager.getSessionDir();\n\t\tconst scope = sessionManager.usesDefaultSessionDir() ? getSessionsDir() : sessionDir;\n\t\tconst nowMs = now.getTime();\n\t\tconst window = getLocalDayWindow(now);\n\t\tif (\n\t\t\tthis._dailyUsageCache?.sessionDir === scope &&\n\t\t\tthis._dailyUsageCache.windowStartMs === window.startMs &&\n\t\t\tthis._dailyUsageCache.windowEndMs === window.endMs &&\n\t\t\tthis._dailyUsageCache.expiresAt > nowMs\n\t\t) {\n\t\t\treturn this._dailyUsageCache.totals;\n\t\t}\n\t\tconst totals = sessionManager.usesDefaultSessionDir()\n\t\t\t? aggregateDailyUsageFromSessionRoot(scope, window)\n\t\t\t: aggregateDailyUsageFromSessionFiles(sessionDir, window);\n\t\tthis._dailyUsageCache = {\n\t\t\tsessionDir: scope,\n\t\t\twindowStartMs: window.startMs,\n\t\t\twindowEndMs: window.endMs,\n\t\t\texpiresAt: Math.min(nowMs + 10_000, window.endMs),\n\t\t\ttotals,\n\t\t};\n\t\treturn totals;\n\t}\n\n\tgetDailyUsageBreakdown(formatLabel?: (label: string) => string, now = new Date()): string {\n\t\treturn formatDailyUsageBreakdown(this.getDailyUsageTotals(now), formatLabel);\n\t}\n\n\tgetContextUsage(): ContextUsage | undefined {\n\t\tconst model = this.deps.getModel();\n\t\tif (!model) return undefined;\n\n\t\tconst contextWindow = model.contextWindow ?? 0;\n\t\tif (contextWindow <= 0) return undefined;\n\n\t\t// After compaction, the last assistant usage reflects pre-compaction context size.\n\t\t// We can only trust usage from an assistant that responded after the latest compaction.\n\t\t// If no such assistant exists, context token count is unknown until the next LLM response.\n\t\tconst branchEntries = this.deps.getSessionManager().getBranch();\n\t\tconst latestCompaction = getLatestCompactionEntry(branchEntries);\n\n\t\tif (latestCompaction) {\n\t\t\t// Check if there's a valid assistant usage after the compaction boundary\n\t\t\tconst compactionIndex = branchEntries.lastIndexOf(latestCompaction);\n\t\t\tlet hasPostCompactionUsage = false;\n\t\t\tfor (let i = branchEntries.length - 1; i > compactionIndex; i--) {\n\t\t\t\tconst entry = branchEntries[i];\n\t\t\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\t\t\tconst assistant = entry.message;\n\t\t\t\t\tif (assistant.stopReason !== \"aborted\" && assistant.stopReason !== \"error\") {\n\t\t\t\t\t\tconst contextTokens = calculateContextTokens(assistant.usage);\n\t\t\t\t\t\tif (contextTokens > 0) {\n\t\t\t\t\t\t\thasPostCompactionUsage = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!hasPostCompactionUsage) {\n\t\t\t\treturn { tokens: null, contextWindow, percent: null };\n\t\t\t}\n\t\t}\n\n\t\tconst estimate = estimateContextTokens(this.deps.getMessages());\n\t\tconst percent = (estimate.tokens / contextWindow) * 100;\n\n\t\treturn {\n\t\t\ttokens: estimate.tokens,\n\t\t\tcontextWindow,\n\t\t\tpercent,\n\t\t};\n\t}\n\n\t/**\n\t * Export session to HTML.\n\t * @param outputPath Optional output path (defaults to session directory)\n\t * @returns Path to exported file\n\t */\n\tasync exportToHtml(outputPath?: string): Promise<string> {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst themeName = this.deps.getSettingsManager().getTheme();\n\n\t\t// Create tool renderer if we have an extension runner (for custom tool HTML rendering)\n\t\tconst toolRenderer: ToolHtmlRenderer = createToolHtmlRenderer({\n\t\t\tgetToolDefinition: (name) => this.deps.getToolDefinition(name),\n\t\t\ttheme,\n\t\t\tcwd: sessionManager.getCwd(),\n\t\t});\n\n\t\treturn await exportSessionToHtml(sessionManager, this.deps.getState(), {\n\t\t\toutputPath,\n\t\t\tthemeName,\n\t\t\ttoolRenderer,\n\t\t});\n\t}\n\n\t/**\n\t * Export the current session branch to a JSONL file.\n\t * Writes the session header followed by all entries on the current branch path.\n\t * @param outputPath Target file path. If omitted, generates a timestamped file in cwd.\n\t * @returns The resolved output file path.\n\t */\n\texportToJsonl(outputPath?: string): string {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst filePath = resolvePath(\n\t\t\toutputPath ?? `session-${new Date().toISOString().replace(/[:.]/g, \"-\")}.jsonl`,\n\t\t\tprocess.cwd(),\n\t\t);\n\t\tconst dir = dirname(filePath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: sessionManager.getSessionId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: sessionManager.getCwd(),\n\t\t};\n\n\t\tconst branchEntries = sessionManager.getBranch();\n\t\tconst lines = [JSON.stringify(header)];\n\n\t\t// Re-chain parentIds to form a linear sequence\n\t\tlet prevId: string | null = null;\n\t\tfor (const entry of branchEntries) {\n\t\t\tconst linear = { ...entry, parentId: prevId };\n\t\t\tlines.push(JSON.stringify(linear));\n\t\t\tprevId = entry.id;\n\t\t}\n\n\t\twriteFileSync(filePath, `${lines.join(\"\\n\")}\\n`);\n\t\treturn filePath;\n\t}\n\n\t/**\n\t * Get text content of last assistant message.\n\t * Useful for /copy command.\n\t * @returns Text content, or undefined if no assistant message exists\n\t */\n\tgetLastAssistantText(): string | undefined {\n\t\tconst lastAssistant = this.deps\n\t\t\t.getMessages()\n\t\t\t.slice()\n\t\t\t.reverse()\n\t\t\t.find((m) => {\n\t\t\t\tif (m.role !== \"assistant\") return false;\n\t\t\t\tconst msg = m as AssistantMessage;\n\t\t\t\t// Skip aborted messages with no content\n\t\t\t\tif (msg.stopReason === \"aborted\" && msg.content.length === 0) return false;\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (!lastAssistant) return undefined;\n\n\t\tlet text = \"\";\n\t\tfor (const content of (lastAssistant as AssistantMessage).content) {\n\t\t\tif (content.type === \"text\") {\n\t\t\t\ttext += content.text;\n\t\t\t}\n\t\t}\n\n\t\treturn text.trim() || undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"session-analytics.js","sourceRoot":"","sources":["../../src/core/session-analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAGxB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAE,cAAc,EAAE,MAAM,cA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AAE,OAAO,SAAS,CAAC;QAErC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,MAAM,OAAO,IAAK,aAAkC,CAAC,OAAO,EAAE,CAAC;YACnE,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YACtB,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;IAAA,CAChC;CACD","sourcesContent":["/**\n * Session usage / cost / stats accounting, context-window usage, and session export.\n *\n * Extracted verbatim from agent-session.ts (god-file decomposition). Read-only over the session\n * except for its two owned memo caches (`_spawnedUsageCache`, `_dailyUsageCache`) — it never mutates\n * agent or session state. Single source of truth for \"how much did this session and its spawned\n * subtree spend\" (footer roll-up, print-mode child reporting), the daily cross-session totals, the\n * /context window estimate, and HTML/JSONL export of the current branch.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport type { AgentMessage, AgentState } from \"@caupulican/pi-agent-core\";\nimport {\n\tCURRENT_SESSION_VERSION,\n\tcalculateContextTokens,\n\testimateContextTokens,\n\tgetLatestCompactionEntry,\n\ttype SessionHeader,\n\ttype SessionManager,\n} from \"@caupulican/pi-agent-core/node\";\nimport type {\n\tAssistantMessage,\n\tModel,\n\tToolArgumentExecutionOutcome,\n\tToolArgumentTeachState,\n\tToolArgumentValidationTelemetryEvent,\n\tUsage,\n} from \"@caupulican/pi-ai\";\nimport { getSessionsDir } from \"../config.ts\";\nimport { theme } from \"../modes/interactive/theme/theme.ts\";\nimport { resolvePath } from \"../utils/paths.ts\";\nimport {\n\ttype SessionStats,\n\tSPAWNED_USAGE_CUSTOM_TYPE,\n\ttype SpawnedUsageReport,\n\ttype SpawnedUsageTotals,\n} from \"./agent-session.ts\";\nimport {\n\taggregateCurrentSessionCostsFromEntries,\n\tcreateSessionCostSummary,\n\ttype SessionCostSummary,\n} from \"./cost/cost-summary.ts\";\nimport {\n\taggregateDailyUsageFromSessionFiles,\n\taggregateDailyUsageFromSessionRoot,\n\ttype DailyUsageTotals,\n\tformatDailyUsageBreakdown,\n\tgetLocalDayWindow,\n} from \"./cost/daily-usage.ts\";\nimport { exportSessionToHtml, type ToolHtmlRenderer } from \"./export-html/index.ts\";\nimport { createToolHtmlRenderer } from \"./export-html/tool-renderer.ts\";\nimport type { ContextUsage, ToolDefinition } from \"./extensions/index.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport {\n\tisToolArgumentValidationLogRecord,\n\ttype ToolArgumentValidationLogRecord,\n} from \"./tool-recovery-log-records.ts\";\n\nexport const TOOL_ARGUMENT_VALIDATION_CUSTOM_TYPE = \"tool_argument_validation\";\n\nexport interface ToolArgumentValidationTeachEfficacy {\n\trecurrenceBefore: number;\n\trecurrenceAfter: number;\n\trepairedThenSucceeded: number;\n\trepairedThenFailed: number;\n\trepairedThenNotRun: number;\n}\n\nexport interface ToolArgumentValidationStats {\n\tclean: number;\n\trepaired: number;\n\tbounced: number;\n\tfailureModes: Record<string, number>;\n\trepairsApplied: Record<string, number>;\n\ttaught: Record<ToolArgumentTeachState, number>;\n\texecutionOutcome: Record<ToolArgumentExecutionOutcome, number>;\n\tteachEfficacy: Record<string, ToolArgumentValidationTeachEfficacy>;\n}\n\nexport interface ToolArgumentValidationRecord extends ToolArgumentValidationTelemetryEvent {\n\tversion: 1;\n}\n\nexport interface SessionAnalyticsDeps {\n\t/** Live agent state — assistant-message usage and message counts are read from here. */\n\tgetState(): AgentState;\n\t/** All messages (agent state view) — used for context-window estimation and last-assistant text. */\n\tgetMessages(): AgentMessage[];\n\t/** Current session model — its context window bounds the /context estimate. */\n\tgetModel(): Model<any> | undefined;\n\t/** Session log — entries feed spawned-usage roll-up, daily totals, branch export. */\n\tgetSessionManager(): SessionManager;\n\t/** Settings — the export theme is read here. */\n\tgetSettingsManager(): SettingsManager;\n\t/** Resolve a tool definition for the HTML export's custom-tool renderer. */\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Sidecar recovery telemetry log; read on demand so turn handling never writes session custom entries. */\n\tgetToolRecoveryEventLogPath(): string;\n}\n\nexport class SessionAnalytics {\n\t/** Memoized spawned-usage totals, keyed by session entry count (Bug #22: O(1) between turns). */\n\tprivate _spawnedUsageCache?: { entryCount: number; totals: SpawnedUsageTotals };\n\t/** Memoized daily usage totals with a short TTL, keyed by the resolved scope dir and local-day window. */\n\tprivate _dailyUsageCache?: {\n\t\tsessionDir: string;\n\t\twindowStartMs: number;\n\t\twindowEndMs: number;\n\t\texpiresAt: number;\n\t\ttotals: DailyUsageTotals;\n\t};\n\t/** Live recovery telemetry records already snapshotted for the worker; keyed to dedupe sidecar reads. */\n\tprivate readonly _toolArgumentValidationRecords = new Map<string, ToolArgumentValidationLogRecord>();\n\n\tprivate readonly deps: SessionAnalyticsDeps;\n\n\tconstructor(deps: SessionAnalyticsDeps) {\n\t\tthis.deps = deps;\n\t}\n\n\tgetSessionStats(): SessionStats {\n\t\tconst state = this.deps.getState();\n\t\tconst userMessages = state.messages.filter((m) => m.role === \"user\").length;\n\t\tconst assistantMessages = state.messages.filter((m) => m.role === \"assistant\").length;\n\t\tconst toolResults = state.messages.filter((m) => m.role === \"toolResult\").length;\n\n\t\tlet toolCalls = 0;\n\t\tlet totalInput = 0;\n\t\tlet totalOutput = 0;\n\t\tlet totalCacheRead = 0;\n\t\tlet totalCacheWrite = 0;\n\t\tlet totalCost = 0;\n\n\t\tfor (const message of state.messages) {\n\t\t\tif (message.role === \"assistant\") {\n\t\t\t\tconst assistantMsg = message as AssistantMessage;\n\t\t\t\ttoolCalls += assistantMsg.content.filter((c) => c.type === \"toolCall\").length;\n\t\t\t\ttotalInput += assistantMsg.usage.input;\n\t\t\t\ttotalOutput += assistantMsg.usage.output;\n\t\t\t\ttotalCacheRead += assistantMsg.usage.cacheRead;\n\t\t\t\ttotalCacheWrite += assistantMsg.usage.cacheWrite;\n\t\t\t\ttotalCost += assistantMsg.usage.cost.total;\n\t\t\t}\n\t\t}\n\n\t\tconst toolArgumentValidation = this.getToolArgumentValidationStats();\n\t\tconst compactionGates = this.getCompactionGateStats();\n\n\t\treturn {\n\t\t\tsessionFile: this.deps.getSessionManager().getSessionFile(),\n\t\t\tsessionId: this.deps.getSessionManager().getSessionId(),\n\t\t\tuserMessages,\n\t\t\tassistantMessages,\n\t\t\ttoolCalls,\n\t\t\ttoolResults,\n\t\t\ttotalMessages: state.messages.length,\n\t\t\ttokens: {\n\t\t\t\tinput: totalInput,\n\t\t\t\toutput: totalOutput,\n\t\t\t\tcacheRead: totalCacheRead,\n\t\t\t\tcacheWrite: totalCacheWrite,\n\t\t\t\ttotal: totalInput + totalOutput + totalCacheRead + totalCacheWrite,\n\t\t\t},\n\t\t\tcost: totalCost,\n\t\t\tcontextUsage: this.getContextUsage(),\n\t\t\ttoolArgumentValidation,\n\t\t\tcompactionGates,\n\t\t};\n\t}\n\n\tgetCompactionGateStats(): SessionStats[\"compactionGates\"] {\n\t\tlet gateFailures = 0;\n\t\tlet deterministicGapFills = 0;\n\t\tlet compactionsWithGateFailures = 0;\n\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\tif (entry.type !== \"compaction\") continue;\n\t\t\tconst details = entry.details;\n\t\t\tif (!details || typeof details !== \"object\") continue;\n\t\t\tconst rawGateFailures = (details as { verificationGateFailures?: unknown }).verificationGateFailures;\n\t\t\tconst rawGapFills = (details as { deterministicGapFills?: unknown }).deterministicGapFills;\n\t\t\tconst entryGateFailures =\n\t\t\t\ttypeof rawGateFailures === \"number\" && Number.isFinite(rawGateFailures) ? rawGateFailures : 0;\n\t\t\tconst entryGapFills = typeof rawGapFills === \"number\" && Number.isFinite(rawGapFills) ? rawGapFills : 0;\n\t\t\tgateFailures += entryGateFailures;\n\t\t\tdeterministicGapFills += entryGapFills;\n\t\t\tif (entryGateFailures > 0) compactionsWithGateFailures++;\n\t\t}\n\t\treturn { gateFailures, deterministicGapFills, compactionsWithGateFailures };\n\t}\n\n\trecordToolArgumentValidation(record: ToolArgumentValidationLogRecord): void {\n\t\tthis._toolArgumentValidationRecords.set(record.recordId, record);\n\t}\n\n\tprivate readToolArgumentValidationSidecarRecords(): ToolArgumentValidationLogRecord[] {\n\t\tconst filePath = this.deps.getToolRecoveryEventLogPath();\n\t\tif (!existsSync(filePath)) return [];\n\t\tconst records: ToolArgumentValidationLogRecord[] = [];\n\t\ttry {\n\t\t\tconst sessionId = this.deps.getSessionManager().getSessionId();\n\t\t\tfor (const line of readFileSync(filePath, \"utf-8\").split(\"\\n\")) {\n\t\t\t\tif (line.trim().length === 0) continue;\n\t\t\t\tconst parsed = JSON.parse(line) as unknown;\n\t\t\t\tif (!isToolArgumentValidationLogRecord(parsed) || parsed.sessionId !== sessionId) continue;\n\t\t\t\trecords.push(parsed);\n\t\t\t}\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t\treturn records;\n\t}\n\n\tgetToolArgumentValidationStats(): ToolArgumentValidationStats {\n\t\tconst stats: ToolArgumentValidationStats = {\n\t\t\tclean: 0,\n\t\t\trepaired: 0,\n\t\t\tbounced: 0,\n\t\t\tfailureModes: {},\n\t\t\trepairsApplied: {},\n\t\t\ttaught: { none: 0, note: 0, rule: 0 },\n\t\t\texecutionOutcome: { not_run: 0, succeeded: 0, failed: 0 },\n\t\t\tteachEfficacy: {},\n\t\t};\n\n\t\tconst getEfficacy = (record: ToolArgumentValidationRecord, mode: string): ToolArgumentValidationTeachEfficacy => {\n\t\t\tconst key = `${record.provider ?? \"unknown\"}/${record.model ?? \"unknown\"}:${mode}`;\n\t\t\tstats.teachEfficacy[key] ??= {\n\t\t\t\trecurrenceBefore: 0,\n\t\t\t\trecurrenceAfter: 0,\n\t\t\t\trepairedThenSucceeded: 0,\n\t\t\t\trepairedThenFailed: 0,\n\t\t\t\trepairedThenNotRun: 0,\n\t\t\t};\n\t\t\treturn stats.teachEfficacy[key];\n\t\t};\n\n\t\tconst seen = new Set<string>();\n\t\tconst consume = (record: ToolArgumentValidationRecord, key: string): void => {\n\t\t\tif (seen.has(key)) return;\n\t\t\tseen.add(key);\n\t\t\tstats[record.outcome] += 1;\n\t\t\tconst taught = record.taught ?? \"none\";\n\t\t\tconst executionOutcome = record.executionOutcome ?? \"not_run\";\n\t\t\tstats.taught[taught] += 1;\n\t\t\tstats.executionOutcome[executionOutcome] += 1;\n\t\t\tconst modes = new Set([...record.failureModes, ...record.repairsApplied]);\n\t\t\tfor (const mode of record.failureModes) {\n\t\t\t\tstats.failureModes[mode] = (stats.failureModes[mode] ?? 0) + 1;\n\t\t\t}\n\t\t\tfor (const repair of record.repairsApplied) {\n\t\t\t\tstats.repairsApplied[repair] = (stats.repairsApplied[repair] ?? 0) + 1;\n\t\t\t}\n\t\t\tfor (const mode of modes) {\n\t\t\t\tconst efficacy = getEfficacy(record, mode);\n\t\t\t\tif (taught === \"none\") {\n\t\t\t\t\tefficacy.recurrenceBefore++;\n\t\t\t\t} else {\n\t\t\t\t\tefficacy.recurrenceAfter++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (record.outcome === \"repaired\") {\n\t\t\t\tfor (const repair of record.repairsApplied) {\n\t\t\t\t\tconst efficacy = getEfficacy(record, repair);\n\t\t\t\t\tif (executionOutcome === \"succeeded\") efficacy.repairedThenSucceeded++;\n\t\t\t\t\tif (executionOutcome === \"failed\") efficacy.repairedThenFailed++;\n\t\t\t\t\tif (executionOutcome === \"not_run\") efficacy.repairedThenNotRun++;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\tif (entry.type !== \"custom\" || entry.customType !== TOOL_ARGUMENT_VALIDATION_CUSTOM_TYPE) continue;\n\t\t\tconst record = entry.data as ToolArgumentValidationRecord | undefined;\n\t\t\tif (!record || record.version !== 1) continue;\n\t\t\tconsume(record, `legacy:${entry.id}`);\n\t\t}\n\t\tfor (const record of this.readToolArgumentValidationSidecarRecords()) {\n\t\t\tconsume(record, record.recordId);\n\t\t}\n\t\tfor (const record of this._toolArgumentValidationRecords.values()) {\n\t\t\tconsume(record, record.recordId);\n\t\t}\n\n\t\treturn stats;\n\t}\n\n\t/**\n\t * Cumulative usage (full breakdown) for this session's entire spawn subtree: its own\n\t * assistant messages PLUS every `spawned_usage` report it has rolled up. Single source of\n\t * truth for \"how much did this session and everything it spawned spend\" — used by print-mode\n\t * to emit a child's total so a spawner can roll it up via {@link addSpawnedUsage}.\n\t *\n\t * Including the `spawned_usage` reports is what keeps the single-hop invariant intact: a child\n\t * that itself spawned grandchildren must report own + sub-usage in one number, or the parent\n\t * silently under-counts the grandchildren.\n\t */\n\tgetCumulativeUsage(): Usage {\n\t\tlet input = 0;\n\t\tlet output = 0;\n\t\tlet cacheRead = 0;\n\t\tlet cacheWrite = 0;\n\t\tlet totalTokens = 0;\n\t\tlet costInput = 0;\n\t\tlet costOutput = 0;\n\t\tlet costCacheRead = 0;\n\t\tlet costCacheWrite = 0;\n\t\tlet costTotal = 0;\n\t\tconst add = (usage: Usage) => {\n\t\t\tinput += usage.input;\n\t\t\toutput += usage.output;\n\t\t\tcacheRead += usage.cacheRead;\n\t\t\tcacheWrite += usage.cacheWrite;\n\t\t\ttotalTokens += usage.totalTokens;\n\t\t\tcostInput += usage.cost.input;\n\t\t\tcostOutput += usage.cost.output;\n\t\t\tcostCacheRead += usage.cost.cacheRead;\n\t\t\tcostCacheWrite += usage.cost.cacheWrite;\n\t\t\tcostTotal += usage.cost.total;\n\t\t};\n\t\tfor (const message of this.deps.getState().messages) {\n\t\t\tif (message.role !== \"assistant\") continue;\n\t\t\tconst usage = (message as AssistantMessage).usage;\n\t\t\tif (!usage) continue;\n\t\t\tadd(usage);\n\t\t}\n\t\t// Roll up usage this session attributed to its own spawned children (single-hop).\n\t\tconst seenSpawnedReportIds = new Set<string>();\n\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\tif (entry.type !== \"custom\" || entry.customType !== SPAWNED_USAGE_CUSTOM_TYPE) continue;\n\t\t\tconst data = entry.data as SpawnedUsageReport | undefined;\n\t\t\tif (!data?.usage) continue;\n\t\t\tif (data.reportId) {\n\t\t\t\tif (seenSpawnedReportIds.has(data.reportId)) continue;\n\t\t\t\tseenSpawnedReportIds.add(data.reportId);\n\t\t\t}\n\t\t\tadd(data.usage);\n\t\t}\n\t\treturn {\n\t\t\tinput,\n\t\t\toutput,\n\t\t\tcacheRead,\n\t\t\tcacheWrite,\n\t\t\ttotalTokens,\n\t\t\tcost: {\n\t\t\t\tinput: costInput,\n\t\t\t\toutput: costOutput,\n\t\t\t\tcacheRead: costCacheRead,\n\t\t\t\tcacheWrite: costCacheWrite,\n\t\t\t\ttotal: costTotal,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Record usage spent by a spawned/subagent session so the footer can roll it into the\n\t * displayed cost. Persisted as a `CustomEntry` (`customType: \"spawned_usage\"`, Model A) so\n\t * it survives reload and is reconstructed exactly like main usage; a new/forked session\n\t * starts fresh because it owns a new log file.\n\t *\n\t * Idempotent on `opts.reportId`: a re-report (retry, duplicate `agent_end`) with a\n\t * previously-seen id is ignored, so cost cannot be double-counted. Honors the single-hop\n\t * invariant documented on {@link SpawnedUsageReport}.\n\t *\n\t * @returns the id of the appended entry, or `undefined` if the report was a duplicate.\n\t */\n\taddSpawnedUsage(\n\t\tusage: Usage,\n\t\topts?: { label?: string; sourceSessionId?: string; reportId?: string },\n\t): string | undefined {\n\t\tconst reportId = opts?.reportId;\n\t\tif (reportId) {\n\t\t\tfor (const entry of this.deps.getSessionManager().getEntries()) {\n\t\t\t\tif (\n\t\t\t\t\tentry.type === \"custom\" &&\n\t\t\t\t\tentry.customType === SPAWNED_USAGE_CUSTOM_TYPE &&\n\t\t\t\t\t(entry.data as SpawnedUsageReport | undefined)?.reportId === reportId\n\t\t\t\t) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst report: SpawnedUsageReport = {\n\t\t\tusage,\n\t\t\tlabel: opts?.label,\n\t\t\tsourceSessionId: opts?.sourceSessionId,\n\t\t\treportId,\n\t\t};\n\t\treturn this.deps.getSessionManager().appendCustomEntry(SPAWNED_USAGE_CUSTOM_TYPE, report);\n\t}\n\n\t/**\n\t * Aggregate all recorded spawned-usage reports (see {@link addSpawnedUsage}). Cached by the session\n\t * entry count so the interactive footer (which calls this every render frame) is O(1) between turns\n\t * instead of an O(N) scan on every keystroke (Bug #22). Recomputes only when entries change.\n\t */\n\tgetSpawnedUsage(): SpawnedUsageTotals {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst entryCount = sessionManager.getEntryCount?.() ?? sessionManager.getEntries().length;\n\t\tif (this._spawnedUsageCache?.entryCount === entryCount) return this._spawnedUsageCache.totals;\n\t\tconst current = aggregateCurrentSessionCostsFromEntries(sessionManager.getEntries());\n\t\tconst totals: SpawnedUsageTotals = { cost: current.subagentCost, reports: current.subagentReports };\n\t\tthis._spawnedUsageCache = { entryCount, totals };\n\t\treturn totals;\n\t}\n\n\tgetCostSummary(now = new Date()): SessionCostSummary {\n\t\tconst window = getLocalDayWindow(now);\n\t\treturn createSessionCostSummary({\n\t\t\tentries: this.deps.getSessionManager().getEntries(),\n\t\t\tdailyTotals: this.getDailyUsageTotals(now),\n\t\t\ttodayWindow: window,\n\t\t});\n\t}\n\n\tgetDailyUsageTotals(now = new Date()): DailyUsageTotals {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst sessionDir = sessionManager.getSessionDir();\n\t\tconst scope = sessionManager.usesDefaultSessionDir() ? getSessionsDir() : sessionDir;\n\t\tconst nowMs = now.getTime();\n\t\tconst window = getLocalDayWindow(now);\n\t\tif (\n\t\t\tthis._dailyUsageCache?.sessionDir === scope &&\n\t\t\tthis._dailyUsageCache.windowStartMs === window.startMs &&\n\t\t\tthis._dailyUsageCache.windowEndMs === window.endMs &&\n\t\t\tthis._dailyUsageCache.expiresAt > nowMs\n\t\t) {\n\t\t\treturn this._dailyUsageCache.totals;\n\t\t}\n\t\tconst totals = sessionManager.usesDefaultSessionDir()\n\t\t\t? aggregateDailyUsageFromSessionRoot(scope, window)\n\t\t\t: aggregateDailyUsageFromSessionFiles(sessionDir, window);\n\t\tthis._dailyUsageCache = {\n\t\t\tsessionDir: scope,\n\t\t\twindowStartMs: window.startMs,\n\t\t\twindowEndMs: window.endMs,\n\t\t\texpiresAt: Math.min(nowMs + 10_000, window.endMs),\n\t\t\ttotals,\n\t\t};\n\t\treturn totals;\n\t}\n\n\tgetDailyUsageBreakdown(formatLabel?: (label: string) => string, now = new Date()): string {\n\t\treturn formatDailyUsageBreakdown(this.getDailyUsageTotals(now), formatLabel);\n\t}\n\n\tgetContextUsage(): ContextUsage | undefined {\n\t\tconst model = this.deps.getModel();\n\t\tif (!model) return undefined;\n\n\t\tconst contextWindow = model.contextWindow ?? 0;\n\t\tif (contextWindow <= 0) return undefined;\n\n\t\t// After compaction, the last assistant usage reflects pre-compaction context size.\n\t\t// We can only trust usage from an assistant that responded after the latest compaction.\n\t\t// If no such assistant exists, context token count is unknown until the next LLM response.\n\t\tconst branchEntries = this.deps.getSessionManager().getBranch();\n\t\tconst latestCompaction = getLatestCompactionEntry(branchEntries);\n\n\t\tif (latestCompaction) {\n\t\t\t// Check if there's a valid assistant usage after the compaction boundary\n\t\t\tconst compactionIndex = branchEntries.lastIndexOf(latestCompaction);\n\t\t\tlet hasPostCompactionUsage = false;\n\t\t\tfor (let i = branchEntries.length - 1; i > compactionIndex; i--) {\n\t\t\t\tconst entry = branchEntries[i];\n\t\t\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\t\t\tconst assistant = entry.message;\n\t\t\t\t\tif (assistant.stopReason !== \"aborted\" && assistant.stopReason !== \"error\") {\n\t\t\t\t\t\tconst contextTokens = calculateContextTokens(assistant.usage);\n\t\t\t\t\t\tif (contextTokens > 0) {\n\t\t\t\t\t\t\thasPostCompactionUsage = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!hasPostCompactionUsage) {\n\t\t\t\treturn { tokens: null, contextWindow, percent: null };\n\t\t\t}\n\t\t}\n\n\t\tconst estimate = estimateContextTokens(this.deps.getMessages());\n\t\tconst percent = (estimate.tokens / contextWindow) * 100;\n\n\t\treturn {\n\t\t\ttokens: estimate.tokens,\n\t\t\tcontextWindow,\n\t\t\tpercent,\n\t\t};\n\t}\n\n\t/**\n\t * Export session to HTML.\n\t * @param outputPath Optional output path (defaults to session directory)\n\t * @returns Path to exported file\n\t */\n\tasync exportToHtml(outputPath?: string): Promise<string> {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst themeName = this.deps.getSettingsManager().getTheme();\n\n\t\t// Create tool renderer if we have an extension runner (for custom tool HTML rendering)\n\t\tconst toolRenderer: ToolHtmlRenderer = createToolHtmlRenderer({\n\t\t\tgetToolDefinition: (name) => this.deps.getToolDefinition(name),\n\t\t\ttheme,\n\t\t\tcwd: sessionManager.getCwd(),\n\t\t});\n\n\t\treturn await exportSessionToHtml(sessionManager, this.deps.getState(), {\n\t\t\toutputPath,\n\t\t\tthemeName,\n\t\t\ttoolRenderer,\n\t\t});\n\t}\n\n\t/**\n\t * Export the current session branch to a JSONL file.\n\t * Writes the session header followed by all entries on the current branch path.\n\t * @param outputPath Target file path. If omitted, generates a timestamped file in cwd.\n\t * @returns The resolved output file path.\n\t */\n\texportToJsonl(outputPath?: string): string {\n\t\tconst sessionManager = this.deps.getSessionManager();\n\t\tconst filePath = resolvePath(\n\t\t\toutputPath ?? `session-${new Date().toISOString().replace(/[:.]/g, \"-\")}.jsonl`,\n\t\t\tprocess.cwd(),\n\t\t);\n\t\tconst dir = dirname(filePath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: sessionManager.getSessionId(),\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: sessionManager.getCwd(),\n\t\t};\n\n\t\tconst branchEntries = sessionManager.getBranch();\n\t\tconst lines = [JSON.stringify(header)];\n\n\t\t// Re-chain parentIds to form a linear sequence\n\t\tlet prevId: string | null = null;\n\t\tfor (const entry of branchEntries) {\n\t\t\tconst linear = { ...entry, parentId: prevId };\n\t\t\tlines.push(JSON.stringify(linear));\n\t\t\tprevId = entry.id;\n\t\t}\n\n\t\twriteFileSync(filePath, `${lines.join(\"\\n\")}\\n`);\n\t\treturn filePath;\n\t}\n\n\t/**\n\t * Get text content of last assistant message.\n\t * Useful for /copy command.\n\t * @returns Text content, or undefined if no assistant message exists\n\t */\n\tgetLastAssistantText(): string | undefined {\n\t\tconst lastAssistant = this.deps\n\t\t\t.getMessages()\n\t\t\t.slice()\n\t\t\t.reverse()\n\t\t\t.find((m) => {\n\t\t\t\tif (m.role !== \"assistant\") return false;\n\t\t\t\tconst msg = m as AssistantMessage;\n\t\t\t\t// Skip aborted messages with no content\n\t\t\t\tif (msg.stopReason === \"aborted\" && msg.content.length === 0) return false;\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (!lastAssistant) return undefined;\n\n\t\tlet text = \"\";\n\t\tfor (const content of (lastAssistant as AssistantMessage).content) {\n\t\t\tif (content.type === \"text\") {\n\t\t\t\ttext += content.text;\n\t\t\t}\n\t\t}\n\n\t\treturn text.trim() || undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"report-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK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,CAIjE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAI1D;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAI3G","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}\\n`;\n\tif (costs.subagentReports > 0 || costs.subagentCost > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Today rollover:\")} local midnight\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tif (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"context_audit\")}: ask the agent to inspect provider-visible context contributors\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
1
+ {"version":3,"file":"report-commands.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,oBAAoB,C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,GAAG,IAAI,CAI9D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAIjE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAI1D;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAI3G","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}\\n`;\n\tif (costs.subagentReports > 0 || costs.subagentCost > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Today rollover:\")} local midnight\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tconst compactionGates = stats.compactionGates ?? {\n\t\tgateFailures: 0,\n\t\tdeterministicGapFills: 0,\n\t\tcompactionsWithGateFailures: 0,\n\t};\n\tinfo += `${theme.fg(\"dim\", \"Compaction gate failures:\")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\\n`;\n\tif (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"context_audit\")}: ask the agent to inspect provider-visible context contributors\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
@@ -56,6 +56,12 @@ export function handleUsageCommand(host) {
56
56
  info += `${theme.fg("dim", "Context:")} unknown until next provider usage sample\n`;
57
57
  }
58
58
  info += `${theme.fg("dim", "Auto-compaction:")} ${host.session.autoCompactionEnabled ? "enabled" : "disabled"}\n`;
59
+ const compactionGates = stats.compactionGates ?? {
60
+ gateFailures: 0,
61
+ deterministicGapFills: 0,
62
+ compactionsWithGateFailures: 0,
63
+ };
64
+ info += `${theme.fg("dim", "Compaction gate failures:")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\n`;
59
65
  if (costGuard) {
60
66
  const status = costGuard.over ? "over" : "ok";
61
67
  info += `${theme.fg("dim", "Cost guard:")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\n`;
@@ -1 +1 @@
1
- {"version":3,"file":"report-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAA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;AAAA,CACxB;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAsB,EAAQ;IAC/D,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAsB,EAAQ;IAClE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,6BAA6B,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,aAAa,CAAC,IAAsB,EAAQ;IAC3D,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAAA,CACxB;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAsB,EAAE,KAAuC,EAAQ;IAC5G,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnF,aAAa,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}\\n`;\n\tif (costs.subagentReports > 0 || costs.subagentCost > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Today rollover:\")} local midnight\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tif (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"context_audit\")}: ask the agent to inspect provider-visible context contributors\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
1
+ {"version":3,"file":"report-commands.js","sourceRoot":"","sources":["../../../src/modes/interactive/report-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yB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,UAAU,qBAAqB,CAAC,IAAsB,EAAE,KAAuC,EAAQ;IAC5G,IAAI,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACnF,aAAa,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;AAAA,CACD","sourcesContent":["/**\n * Read-only report and easter-egg commands extracted from interactive-mode.\n *\n * These build informational output (usage/cost summary, changelog, hotkeys\n * table, render debug dump) or render an easter-egg component, appending to the\n * chat container and requesting a render. None mutate agent/session state, so\n * they operate through narrow `host` seams (chat container, TUI, and a few\n * read accessors) while interactive-mode keeps thin delegating wrappers.\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { Container, Keybinding, MarkdownTheme, TUI } from \"@caupulican/pi-tui\";\nimport { Markdown, Spacer, Text, visibleWidth } from \"@caupulican/pi-tui\";\nimport { getDebugLogPath } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport type { AppKeybinding, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type { AutoLearnSettings } from \"../../core/settings-manager.ts\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.ts\";\nimport { getProcessMemoryMb } from \"../../utils/process-memory.ts\";\nimport { ArminComponent } from \"./components/armin.ts\";\nimport { DaxnutsComponent } from \"./components/daxnuts.ts\";\nimport { DynamicBorder } from \"./components/dynamic-border.ts\";\nimport { EarendilAnnouncementComponent } from \"./components/earendil-announcement.ts\";\nimport { formatKeyText } from \"./components/keybinding-hints.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\nexport interface ReportRenderHost {\n\treadonly chatContainer: Container;\n\treadonly ui: TUI;\n}\n\nexport interface UsageReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\tgetCurrentAutoLearnSettings(): Required<AutoLearnSettings>;\n}\n\nexport interface ChangelogReportHost extends ReportRenderHost {\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n}\n\nexport interface HotkeysReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n\treadonly keybindings: KeybindingsManager;\n\tgetMarkdownThemeWithSettings(): MarkdownTheme;\n\tgetAppKeyDisplay(action: AppKeybinding): string;\n\tgetEditorKeyDisplay(action: Keybinding): string;\n}\n\nexport interface DebugReportHost extends ReportRenderHost {\n\treadonly session: AgentSession;\n}\n\nexport function handleUsageCommand(host: UsageReportHost): void {\n\tconst stats = host.session.getSessionStats();\n\tconst costs = host.session.getCostSummary();\n\tconst context = host.session.getContextUsage();\n\tconst autoLearn = host.getCurrentAutoLearnSettings();\n\tconst costGuard = host.session.getLastCostGuardDecision();\n\n\tlet info = `${theme.bold(\"Usage & Optimization\")}\\n\\n`;\n\tinfo += `${theme.bold(\"Session tokens\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Cache write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Cost\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"CURRENT (session):\")} $${costs.currentCost.toFixed(4)}\\n`;\n\tif (costs.subagentReports > 0 || costs.subagentCost > 0) {\n\t\tinfo += `${theme.fg(\"dim\", \"SUBAGENTS (included in CURRENT):\")} $${costs.subagentCost.toFixed(4)} (${costs.subagentReports} reports)\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"TODAY (host local day):\")} $${costs.todayCost.toFixed(4)}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Today rollover:\")} local midnight\\n\\n`;\n\n\tconst processMemory = getProcessMemoryMb();\n\tinfo += `${theme.bold(\"Process\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Memory:\")} rss ${processMemory.rssMb}MB, heap ${processMemory.heapUsedMb}MB, external ${processMemory.externalMb}MB\\n\\n`;\n\n\tinfo += `${theme.bold(\"Optimization state\")}\\n`;\n\tconst contextPercent = context?.percent;\n\tconst contextTokens = context?.tokens;\n\tif (\n\t\tcontext &&\n\t\tcontextPercent !== undefined &&\n\t\tcontextPercent !== null &&\n\t\tcontextTokens !== undefined &&\n\t\tcontextTokens !== null\n\t) {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} ${contextPercent.toFixed(1)}% (${contextTokens.toLocaleString()}/${context.contextWindow.toLocaleString()})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Context:\")} unknown until next provider usage sample\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto-compaction:\")} ${host.session.autoCompactionEnabled ? \"enabled\" : \"disabled\"}\\n`;\n\tconst compactionGates = stats.compactionGates ?? {\n\t\tgateFailures: 0,\n\t\tdeterministicGapFills: 0,\n\t\tcompactionsWithGateFailures: 0,\n\t};\n\tinfo += `${theme.fg(\"dim\", \"Compaction gate failures:\")} ${compactionGates.gateFailures} (${compactionGates.deterministicGapFills} deterministic gap-fill)\\n`;\n\tif (costGuard) {\n\t\tconst status = costGuard.over ? \"over\" : \"ok\";\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} ${status} $${costGuard.estUsd.toFixed(4)}/$${costGuard.thresholdUsd.toFixed(4)} (${costGuard.action})\\n`;\n\t} else {\n\t\tinfo += `${theme.fg(\"dim\", \"Cost guard:\")} disabled\\n`;\n\t}\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn:\")} ${autoLearn.enabled ? \"enabled\" : \"disabled\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Scavenger model:\")} ${autoLearn.model || \"active\"}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Reflection review:\")} ${autoLearn.reflectionReview ? \"enabled\" : \"disabled\"} (${autoLearn.reflectionMinToolCalls} tool-call trigger)\\n`;\n\tinfo += `${theme.fg(\"dim\", \"Auto Learn concurrency:\")} ${autoLearn.maxConcurrentLearners} learner(s), ${autoLearn.cooldownMinutes}m cooldown\\n\\n`;\n\n\tinfo += `${theme.bold(\"Model Router\")}\\n`;\n\tinfo += `${host.session.getModelRouterStatus((label) => theme.fg(\"dim\", label))}\\n\\n`;\n\n\tinfo += `${theme.bold(\"Manual controls\")}\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/compact\")}: compact the active context now\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/settings\")}: adjust Auto Learn, cost guard, compaction, and model-router config\\n`;\n\tinfo += `${theme.fg(\"dim\", \"/auto-learn status|run\")}: inspect or launch background learning\\n`;\n\tinfo += `${theme.fg(\"dim\", \"context_audit\")}: ask the agent to inspect provider-visible context contributors\\n`;\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Text(info, 1, 0));\n\thost.ui.requestRender();\n}\n\nexport function handleChangelogCommand(host: ChangelogReportHost): void {\n\tconst changelogPath = getChangelogPath();\n\tconst allEntries = parseChangelog(changelogPath);\n\n\tconst changelogMarkdown =\n\t\tallEntries.length > 0\n\t\t\t? allEntries\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.map((e) => e.content)\n\t\t\t\t\t.join(\"\\n\\n\")\n\t\t\t: \"No changelog entries found.\";\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleHotkeysCommand(host: HotkeysReportHost): void {\n\t// Navigation keybindings\n\tconst cursorUp = host.getEditorKeyDisplay(\"tui.editor.cursorUp\");\n\tconst cursorDown = host.getEditorKeyDisplay(\"tui.editor.cursorDown\");\n\tconst cursorLeft = host.getEditorKeyDisplay(\"tui.editor.cursorLeft\");\n\tconst cursorRight = host.getEditorKeyDisplay(\"tui.editor.cursorRight\");\n\tconst cursorWordLeft = host.getEditorKeyDisplay(\"tui.editor.cursorWordLeft\");\n\tconst cursorWordRight = host.getEditorKeyDisplay(\"tui.editor.cursorWordRight\");\n\tconst cursorLineStart = host.getEditorKeyDisplay(\"tui.editor.cursorLineStart\");\n\tconst cursorLineEnd = host.getEditorKeyDisplay(\"tui.editor.cursorLineEnd\");\n\tconst jumpForward = host.getEditorKeyDisplay(\"tui.editor.jumpForward\");\n\tconst jumpBackward = host.getEditorKeyDisplay(\"tui.editor.jumpBackward\");\n\tconst pageUp = host.getEditorKeyDisplay(\"tui.editor.pageUp\");\n\tconst pageDown = host.getEditorKeyDisplay(\"tui.editor.pageDown\");\n\n\t// Editing keybindings\n\tconst submit = host.getEditorKeyDisplay(\"tui.input.submit\");\n\tconst newLine = host.getEditorKeyDisplay(\"tui.input.newLine\");\n\tconst deleteWordBackward = host.getEditorKeyDisplay(\"tui.editor.deleteWordBackward\");\n\tconst deleteWordForward = host.getEditorKeyDisplay(\"tui.editor.deleteWordForward\");\n\tconst deleteToLineStart = host.getEditorKeyDisplay(\"tui.editor.deleteToLineStart\");\n\tconst deleteToLineEnd = host.getEditorKeyDisplay(\"tui.editor.deleteToLineEnd\");\n\tconst yank = host.getEditorKeyDisplay(\"tui.editor.yank\");\n\tconst yankPop = host.getEditorKeyDisplay(\"tui.editor.yankPop\");\n\tconst undo = host.getEditorKeyDisplay(\"tui.editor.undo\");\n\tconst tab = host.getEditorKeyDisplay(\"tui.input.tab\");\n\n\t// App keybindings\n\tconst interrupt = host.getAppKeyDisplay(\"app.interrupt\");\n\tconst clear = host.getAppKeyDisplay(\"app.clear\");\n\tconst exit = host.getAppKeyDisplay(\"app.exit\");\n\tconst suspend = host.getAppKeyDisplay(\"app.suspend\");\n\tconst cycleThinkingLevel = host.getAppKeyDisplay(\"app.thinking.cycle\");\n\tconst cycleModelForward = host.getAppKeyDisplay(\"app.model.cycleForward\");\n\tconst selectModel = host.getAppKeyDisplay(\"app.model.select\");\n\tconst expandTools = host.getAppKeyDisplay(\"app.tools.expand\");\n\tconst toggleThinking = host.getAppKeyDisplay(\"app.thinking.toggle\");\n\tconst externalEditor = host.getAppKeyDisplay(\"app.editor.external\");\n\tconst cycleModelBackward = host.getAppKeyDisplay(\"app.model.cycleBackward\");\n\tconst followUp = host.getAppKeyDisplay(\"app.message.followUp\");\n\tconst dequeue = host.getAppKeyDisplay(\"app.message.dequeue\");\n\tconst pasteImage = host.getAppKeyDisplay(\"app.clipboard.pasteImage\");\n\n\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t// Add extension-registered shortcuts\n\tconst extensionRunner = host.session.extensionRunner;\n\tconst shortcuts = extensionRunner.getShortcuts(host.keybindings.getEffectiveConfig());\n\tif (shortcuts.size > 0) {\n\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t}\n\t}\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, host.getMarkdownThemeWithSettings()));\n\thost.chatContainer.addChild(new DynamicBorder());\n\thost.ui.requestRender();\n}\n\nexport function handleDebugCommand(host: DebugReportHost): void {\n\tconst width = host.ui.terminal.columns;\n\tconst height = host.ui.terminal.rows;\n\tconst allLines = host.ui.render(width);\n\n\tconst debugLogPath = getDebugLogPath();\n\tconst debugData = [\n\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t`Terminal: ${width}x${height}`,\n\t\t`Total lines: ${allLines.length}`,\n\t\t\"\",\n\t\t\"=== All rendered lines with visible widths ===\",\n\t\t...allLines.map((line, idx) => {\n\t\t\tconst vw = visibleWidth(line);\n\t\t\tconst escaped = JSON.stringify(line);\n\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t}),\n\t\t\"\",\n\t\t\"=== Agent messages (JSONL) ===\",\n\t\t...host.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\"\",\n\t].join(\"\\n\");\n\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.writeFileSync(debugLogPath, debugData);\n\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(\n\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t);\n\thost.ui.requestRender();\n}\n\nexport function handleArminSaysHi(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new ArminComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function handleDementedDelves(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new EarendilAnnouncementComponent());\n\thost.ui.requestRender();\n}\n\nexport function handleDaxnuts(host: ReportRenderHost): void {\n\thost.chatContainer.addChild(new Spacer(1));\n\thost.chatContainer.addChild(new DaxnutsComponent(host.ui));\n\thost.ui.requestRender();\n}\n\nexport function checkDaxnutsEasterEgg(host: ReportRenderHost, model: { provider: string; id: string }): void {\n\tif (model.provider === \"opencode\" && model.id.toLowerCase().includes(\"kimi-k2.5\")) {\n\t\thandleDaxnuts(host);\n\t}\n}\n"]}
package/docs/usage.md CHANGED
@@ -19,6 +19,8 @@ Footer cost labels match the `/usage`, `/session`, and autonomy status cost line
19
19
  - **TODAY** is this host's active session-storage total for the local calendar day; it rolls over at local midnight.
20
20
  - **SUBAGENTS** appears only when delegated/spawned workers reported cost in the current session, and that amount is already included in **CURRENT**.
21
21
 
22
+ For ChatGPT Plus/Pro via OpenAI Codex OAuth, token usage is still recorded for context/cost estimates, but subscription quota windows come from OpenAI Codex response headers. Those windows reset at the server-provided `x-codex-*-reset-at` epoch seconds and may include multiple metered families; they are not the same as Pi's local-midnight **TODAY** window and are not treated as paid API spend.
23
+
22
24
  The editor can be replaced temporarily by built-in UI such as `/settings` or by custom extension UI.
23
25
 
24
26
  ### Editor Features
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.81.24",
3
+ "version": "0.81.26",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.81.24",
9
+ "version": "0.81.26",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.81.24",
4
+ "version": "0.81.26",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.81.24",
4
+ "version": "0.81.26",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "0.81.24",
3
+ "version": "0.81.26",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "0.81.24",
9
+ "version": "0.81.26",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.81.24",
4
+ "version": "0.81.26",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.81.24",
3
+ "version": "0.81.26",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.81.24",
9
+ "version": "0.81.26",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.81.24",
4
+ "version": "0.81.26",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.81.24",
3
+ "version": "0.81.26",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@caupulican/pi-adaptative",
9
- "version": "0.81.24",
9
+ "version": "0.81.26",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@caupulican/pi-agent-core": "^0.81.24",
13
- "@caupulican/pi-ai": "^0.81.24",
14
- "@caupulican/pi-tui": "^0.81.24",
12
+ "@caupulican/pi-agent-core": "^0.81.26",
13
+ "@caupulican/pi-ai": "^0.81.26",
14
+ "@caupulican/pi-tui": "^0.81.26",
15
15
  "@ff-labs/fff-node": "0.9.6",
16
16
  "@silvia-odwyer/photon-node": "0.3.4",
17
17
  "chalk": "5.6.2",
@@ -475,11 +475,11 @@
475
475
  }
476
476
  },
477
477
  "node_modules/@caupulican/pi-agent-core": {
478
- "version": "0.81.24",
479
- "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.81.24.tgz",
478
+ "version": "0.81.26",
479
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.81.26.tgz",
480
480
  "license": "MIT",
481
481
  "dependencies": {
482
- "@caupulican/pi-ai": "^0.81.24",
482
+ "@caupulican/pi-ai": "^0.81.26",
483
483
  "ignore": "7.0.5",
484
484
  "typebox": "1.1.38",
485
485
  "yaml": "2.9.0"
@@ -489,8 +489,8 @@
489
489
  }
490
490
  },
491
491
  "node_modules/@caupulican/pi-ai": {
492
- "version": "0.81.24",
493
- "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.81.24.tgz",
492
+ "version": "0.81.26",
493
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.81.26.tgz",
494
494
  "license": "MIT",
495
495
  "dependencies": {
496
496
  "@anthropic-ai/sdk": "0.91.1",
@@ -512,8 +512,8 @@
512
512
  }
513
513
  },
514
514
  "node_modules/@caupulican/pi-tui": {
515
- "version": "0.81.24",
516
- "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.81.24.tgz",
515
+ "version": "0.81.26",
516
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.81.26.tgz",
517
517
  "license": "MIT",
518
518
  "dependencies": {
519
519
  "get-east-asian-width": "1.6.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.81.24",
3
+ "version": "0.81.26",
4
4
  "description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -73,9 +73,9 @@
73
73
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
74
74
  },
75
75
  "dependencies": {
76
- "@caupulican/pi-agent-core": "^0.81.24",
77
- "@caupulican/pi-ai": "^0.81.24",
78
- "@caupulican/pi-tui": "^0.81.24",
76
+ "@caupulican/pi-agent-core": "^0.81.26",
77
+ "@caupulican/pi-ai": "^0.81.26",
78
+ "@caupulican/pi-tui": "^0.81.26",
79
79
  "@ff-labs/fff-node": "0.9.6",
80
80
  "@silvia-odwyer/photon-node": "0.3.4",
81
81
  "chalk": "5.6.2",