sidekick-shared 0.19.0 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,11 +27,12 @@ npm install sidekick-shared
27
27
  | **Search** | Cross-session full-text search, advanced filtering (substring, fuzzy, regex, date) |
28
28
  | **Aggregation** | Event aggregation, frequency tracking, activity heatmaps, pattern extraction |
29
29
  | **Session Context** | Provider-neutral context evidence snapshots (`buildSessionContextSnapshot()`, `calculateSessionContextPressure()`, `createSessionContextProjector()`, `readSessionContextSnapshot()`): layered evidence sources, low/medium/high context pressure, and observed capabilities (tools, MCP servers, permission mode, rate limits) |
30
+ | **Assistant Turns** | Browser-safe process/answer projection for provider-normalized assistant turns (`segmentAssistantTurn()`, `assistantTurnEventsFromSessionEvents()`), including reasoning blocks, compact tool groups, and Claude `Task` subagent refs without prompt leakage |
30
31
  | **Report** | Self-contained HTML session report generation |
31
32
  | **Credentials** | Claude Max OAuth credential reading from `~/.claude/.credentials.json` |
32
33
  | **Quota** | Claude Max subscription quota fetching (5-hour and 7-day windows) and Codex rate-limit extraction from event streams |
33
34
  | **Provider Status** | API health checking via status.claude.com and status.openai.com (indicator, components, incidents) |
34
- | **Schemas** | Zod schemas for runtime JSONL event validation (`sessionEventSchema`, `messageUsageSchema`, `sessionMessageSchema`) |
35
+ | **Schemas** | Zod schemas for runtime validation of data crossing process/IPC boundaries — JSONL session events (`sessionEventSchema`, `messageUsageSchema`, `sessionMessageSchema`), assistant turns, quota, account status, and quota history — plus `extractSessionEvents()` to unwrap `progress`-wrapped events. Also published fs-free via the [`sidekick-shared/schemas`](#supported-import-paths) subpath |
35
36
  | **Extractors** | Pure functions for single-event processing: `extractTokenUsage()`, `extractToolCall()` (top-level `tool_use`), `extractToolCalls()` (assistant content blocks) |
36
37
  | **Model Info & Pricing** | Model family parsing (Anthropic / OpenAI / Google, including legacy `claude-3-opus-…` and `claude-3-5-sonnet-…` IDs), context-window lookup (including Fable 5 / Opus 4.8 / Opus 4.7 / Sonnet 4.7 1M and GPT-5.x variants), pricing tables with optional LiteLLM hydration, null-aware cost (`calculateCost()`), provenance-preserving cost (`calculateCostWithProvenance()`, `mergeCostSources()`), and display helpers (`shortModelName()`, `getModelDisplayInfo()`, `compareModelIds()`, `sortModelIds()`, `formatCost()`) |
37
38
  | **Quota Polling** | `QuotaPoller` class with exponential backoff, active/idle intervals, and cached fallback |
@@ -48,12 +49,13 @@ npm install sidekick-shared
48
49
  | Path | Runtime | What it exposes |
49
50
  |-----------------------------------|-----------------------------|--------------------------------------------------------------------|
50
51
  | `sidekick-shared` | Node (CLI, extension host) | Full public API (readers, providers, parsers, pricing, …). |
51
- | `sidekick-shared/browser` | **Browser / webview** | Pure helpers: context-window lookup, model parsing, cost math. |
52
+ | `sidekick-shared/browser` | **Browser / webview** | Pure helpers: context-window lookup, model parsing, cost math, assistant turn projection. |
52
53
  | `sidekick-shared/node` | Node only | LiteLLM pricing catalog hydration (`fs` + `path`). |
53
54
  | `sidekick-shared/phrases` | Any runtime | Phrase arrays + `getRandomPhrase()`. |
54
55
  | `sidekick-shared/modelContext` | Any runtime | Direct access to the context-window module. |
55
56
  | `sidekick-shared/modelInfo` | Any runtime | Direct access to model parsing and cost math. |
56
57
  | `sidekick-shared/formatting` | Any runtime | Direct access to pure token and duration display helpers. |
58
+ | `sidekick-shared/schemas` | Any runtime | Pure Zod boundary schemas (session events, assistant turns, quota, account status, quota history) — fs-free, no Node builtins. |
57
59
 
58
60
  ### Browser / webview runtimes
59
61
 
@@ -68,6 +70,7 @@ import {
68
70
  formatCost,
69
71
  formatTokenCount,
70
72
  formatDurationMs,
73
+ segmentAssistantTurn,
71
74
  } from 'sidekick-shared/browser';
72
75
  ```
73
76
 
@@ -201,6 +204,23 @@ if (provider) {
201
204
 
202
205
  Use `createSessionContextProjector()` for incremental updates as new events stream in, or `calculateSessionContextPressure(contextTokens, contextWindow)` for the pressure band alone.
203
206
 
207
+ ### Project an assistant turn into Process + Answer
208
+
209
+ Build a compact UI-safe projection from provider-normalized turn events. The final contiguous text run becomes `answer`; earlier narration, tools, and reasoning stay in `process` / `reasoningBlocks`.
210
+
211
+ ```typescript
212
+ import {
213
+ assistantTurnEventsFromSessionEvents,
214
+ segmentAssistantTurn,
215
+ } from 'sidekick-shared/browser';
216
+
217
+ const projection = segmentAssistantTurn(assistantTurnEventsFromSessionEvents(sessionEvents));
218
+
219
+ console.log(projection.answer);
220
+ console.log(projection.process.steps);
221
+ console.log(projection.subagents); // Claude Task spawns, prompt text omitted
222
+ ```
223
+
204
224
  ### Format shared dashboard values
205
225
 
206
226
  ```typescript
@@ -223,6 +243,8 @@ const parser = new JsonlParser(
223
243
  parser.processChunk(rawData);
224
244
  ```
225
245
 
246
+ The boundary schemas — `sessionEventSchema` plus the quota, account-status, and quota-history schemas — are also importable fs-free from `sidekick-shared/schemas`, which keeps Zod out of bundles that only need the pure math/formatting helpers. `extractSessionEvents()` from the same subpath unwraps Claude Code `progress`-wrapped events into canonical `SessionEvent[]`.
247
+
226
248
  ### Tail raw JSONL events incrementally
227
249
 
228
250
  Use `createJsonlTail()` when a consumer needs raw parsed events and owns its own aggregation lifecycle. `onBatchComplete` fires once after each drained byte chunk, which lets callers defer expensive UI or metrics updates until parsing for that chunk is complete.
package/dist/browser.d.ts CHANGED
@@ -12,5 +12,7 @@ export { formatDurationMs, formatTokenCount } from './formatting';
12
12
  export type { FormatDurationMsOptions, FormatTokenCountOptions } from './formatting';
13
13
  export { buildSessionContextSnapshot, calculateSessionContextPressure, createSessionContextProjector, } from './context/sessionContext';
14
14
  export type { BuildSessionContextSnapshotOptions, SessionContextCapabilities, SessionContextLayerBreakdown, SessionContextPressure, SessionContextProjector, SessionContextSnapshot, SessionContextSource, SessionContextSourceType, } from './context/sessionContext';
15
+ export { assistantTurnEventsFromSessionEvents, extractTurnSubagents, isAssistantTurnSubagentTool, reasoningSummary, segmentAssistantTurn, } from './turns/assistantTurn';
16
+ export type { AssistantTurnEvent, AssistantTurnEventType, AssistantTurnProcess, AssistantTurnProcessStep, AssistantTurnProjection, AssistantTurnSubagent, AssistantTurnSubagentStatus, AssistantTurnToolRef, ExtractTurnSubagentsOptions, ReasoningSummary, SegmentAssistantTurnOptions, } from './turns/assistantTurn';
15
17
  export { parseModelId, getModelPricing, getModelInfo, calculateCost, calculateCostWithPricing, calculateCostWithProvenance, mergeCostSources, shortModelName, getModelDisplayInfo, compareModelIds, sortModelIds, formatCost, } from './modelInfo';
16
18
  export type { ModelPricing, CostTokenUsage, CostSource, CostProvenanceInput, CostWithProvenance, ModelProvider, ParsedModelId, ModelInfo, ModelDisplayInfo, } from './modelInfo';
package/dist/browser.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * For pricing hydration (LiteLLM catalog refresh), use `sidekick-shared/node`.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.formatTokenCount = exports.formatDurationMs = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = void 0;
12
+ exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.segmentAssistantTurn = exports.reasoningSummary = exports.isAssistantTurnSubagentTool = exports.extractTurnSubagents = exports.assistantTurnEventsFromSessionEvents = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.formatTokenCount = exports.formatDurationMs = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = void 0;
13
13
  var modelContext_1 = require("./modelContext");
14
14
  Object.defineProperty(exports, "getModelContextWindowSize", { enumerable: true, get: function () { return modelContext_1.getModelContextWindowSize; } });
15
15
  Object.defineProperty(exports, "DEFAULT_CONTEXT_WINDOW", { enumerable: true, get: function () { return modelContext_1.DEFAULT_CONTEXT_WINDOW; } });
@@ -20,6 +20,12 @@ var sessionContext_1 = require("./context/sessionContext");
20
20
  Object.defineProperty(exports, "buildSessionContextSnapshot", { enumerable: true, get: function () { return sessionContext_1.buildSessionContextSnapshot; } });
21
21
  Object.defineProperty(exports, "calculateSessionContextPressure", { enumerable: true, get: function () { return sessionContext_1.calculateSessionContextPressure; } });
22
22
  Object.defineProperty(exports, "createSessionContextProjector", { enumerable: true, get: function () { return sessionContext_1.createSessionContextProjector; } });
23
+ var assistantTurn_1 = require("./turns/assistantTurn");
24
+ Object.defineProperty(exports, "assistantTurnEventsFromSessionEvents", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnEventsFromSessionEvents; } });
25
+ Object.defineProperty(exports, "extractTurnSubagents", { enumerable: true, get: function () { return assistantTurn_1.extractTurnSubagents; } });
26
+ Object.defineProperty(exports, "isAssistantTurnSubagentTool", { enumerable: true, get: function () { return assistantTurn_1.isAssistantTurnSubagentTool; } });
27
+ Object.defineProperty(exports, "reasoningSummary", { enumerable: true, get: function () { return assistantTurn_1.reasoningSummary; } });
28
+ Object.defineProperty(exports, "segmentAssistantTurn", { enumerable: true, get: function () { return assistantTurn_1.segmentAssistantTurn; } });
23
29
  var modelInfo_1 = require("./modelInfo");
24
30
  Object.defineProperty(exports, "parseModelId", { enumerable: true, get: function () { return modelInfo_1.parseModelId; } });
25
31
  Object.defineProperty(exports, "getModelPricing", { enumerable: true, get: function () { return modelInfo_1.getModelPricing; } });
package/dist/index.d.ts CHANGED
@@ -52,6 +52,8 @@ export { composeContext } from './context/composer';
52
52
  export type { Fidelity, ContextResult } from './context/composer';
53
53
  export { buildSessionContextSnapshot, calculateSessionContextPressure, createSessionContextProjector, readSessionContextSnapshot, } from './context/sessionContext';
54
54
  export type { BuildSessionContextSnapshotOptions, ReadSessionContextSnapshotOptions, SessionContextCapabilities, SessionContextLayerBreakdown, SessionContextPressure, SessionContextProjector, SessionContextSnapshot, SessionContextSource, SessionContextSourceType, } from './context/sessionContext';
55
+ export { assistantTurnEventsFromSessionEvents, extractTurnSubagents, isAssistantTurnSubagentTool, reasoningSummary, segmentAssistantTurn, } from './turns/assistantTurn';
56
+ export type { AssistantTurnEvent, AssistantTurnEventType, AssistantTurnProcess, AssistantTurnProcessStep, AssistantTurnProjection, AssistantTurnSubagent, AssistantTurnSubagentStatus, AssistantTurnToolRef, ExtractTurnSubagentsOptions, ReasoningSummary, SegmentAssistantTurnOptions, } from './turns/assistantTurn';
55
57
  export { PlanExtractor, parsePlanMarkdown as parsePlanMarkdownShared, extractProposedPlan as extractProposedPlanShared } from './parsers/planExtractor';
56
58
  export type { ExtractedPlan, ExtractedPlanStep } from './parsers/planExtractor';
57
59
  export { parseChangelog } from './parsers/changelogParser';
@@ -122,7 +124,11 @@ export { hydratePricingCatalog, normalizeLiteLlmCatalog, LITELLM_CATALOG_URL } f
122
124
  export type { HydrateOptions, HydrateResult } from './pricingCatalog';
123
125
  export { extractTokenUsage } from './extractors/tokenUsage';
124
126
  export { extractToolCall, extractToolCalls } from './extractors/toolCall';
125
- export { messageUsageSchema, sessionMessageSchema, sessionEventSchema, permissionModeSchema, } from './schemas/sessionEvent';
127
+ export { messageUsageSchema, sessionMessageSchema, sessionEventSchema, permissionModeSchema, extractSessionEvents, } from './schemas/sessionEvent';
128
+ export { quotaWindowSchema, quotaStateSchema, quotaFailureKindSchema, quotaProviderIdSchema, quotaSourceSchema, peakHoursStateSchema, quotaFailureDescriptorSchema, runtimeQuotaProviderSchema, providerQuotaStateSchema, claudeProviderQuotaStateSchema, codexProviderQuotaStateSchema, providerQuotaMapSchema, } from './schemas/quota';
129
+ export { quotaHistoryRuntimeProviderSchema, quotaHistorySampleSchema, quotaHistoryDailyBucketSchema, } from './schemas/quotaHistory';
130
+ export { activeProviderAccountStatusSchema, activeAccountStatusSchema, } from './schemas/accountStatus';
131
+ export { assistantTurnEventSchema, assistantTurnEventTypeSchema, assistantTurnNarrationStepSchema, assistantTurnProcessSchema, assistantTurnProcessStepSchema, assistantTurnProjectionSchema, assistantTurnSubagentSchema, assistantTurnSubagentStatusSchema, assistantTurnToolGroupStepSchema, assistantTurnToolRefSchema, } from './schemas/assistantTurn';
126
132
  export { fetchProviderStatus, fetchOpenAIStatus } from './providerStatus';
127
133
  export type { ProviderStatusState } from './providerStatus';
128
134
  export { createPeakHoursNotApplicableState, fetchPeakHoursStatus, isClaudeCodeSessionProvider, scopePeakHoursToSessionProvider, } from './peakHours';
package/dist/index.js CHANGED
@@ -4,9 +4,10 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.findActiveClaudeSession = exports.discoverSessionDirectory = exports.getClaudeSessionDirectory = exports.encodeClaudeWorkspacePath = exports.detectSessionActivity = exports.extractTaskInfo = exports.scanSubagentDir = exports.normalizeCodexToolInput = exports.normalizeCodexToolName = exports.extractPatchFilePaths = exports.CodexRolloutParser = exports.parseDbPartData = exports.parseDbMessageData = exports.convertOpenCodeMessage = exports.detectPlanModeFromText = exports.normalizeToolInput = exports.normalizeToolName = exports.TRUNCATION_PATTERNS = exports.JsonlParser = exports.CodexProvider = exports.OpenCodeProvider = exports.ClaudeCodeProvider = exports.getAllDetectedProviders = exports.detectProvider = exports.readClaudeCodePlanFiles = exports.getPlanAnalytics = exports.writePlans = exports.getLatestPlan = exports.readPlans = exports.readLatestHandoff = exports.readHistory = exports.readNotes = exports.readDecisions = exports.readTasks = exports.getProjectSlugRaw = exports.getProjectSlug = exports.encodeWorkspacePath = exports.getGlobalDataPath = exports.getProjectDataPath = exports.getConfigDir = exports.MAX_PLANS_PER_PROJECT = exports.PLAN_SCHEMA_VERSION = exports.createEmptyTokenTotals = exports.HISTORICAL_DATA_SCHEMA_VERSION = exports.STALENESS_THRESHOLDS = exports.IMPORTANCE_DECAY_FACTORS = exports.KNOWLEDGE_NOTE_SCHEMA_VERSION = exports.DECISION_LOG_SCHEMA_VERSION = exports.normalizeTaskStatus = exports.TASK_PERSISTENCE_SCHEMA_VERSION = void 0;
7
- exports.EventAggregator = exports.getRandomPhrase = exports.PHRASE_CATEGORIES = exports.ALL_PHRASES = exports.HIGHLIGHT_CSS = exports.clearHighlightCache = exports.highlightEvent = exports.formatSessionJson = exports.formatSessionMarkdown = exports.formatSessionText = exports.classifyNoise = exports.shouldMergeWithPrevious = exports.classifyFollowEvent = exports.classifyMessage = exports.getSoftNoiseReason = exports.isHardNoiseFollowEvent = exports.isHardNoise = exports.formatToolSummary = exports.formatTokenCount = exports.formatDurationMs = exports.createJsonlTail = exports.toFollowEvents = exports.createWatcher = exports.parseChangelog = exports.extractProposedPlanShared = exports.parsePlanMarkdownShared = exports.PlanExtractor = exports.readSessionContextSnapshot = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.composeContext = exports.FilterEngine = exports.searchSessions = exports.CodexDatabase = exports.OpenCodeDatabase = exports.discoverDebugLogs = exports.collapseDuplicates = exports.filterByLevel = exports.parseDebugLog = exports.scanSubagentTraces = exports.findAllSessionsWithWorktrees = exports.discoverWorktreeSiblings = exports.resolveWorktreeMainRepo = exports.getAllClaudeProjectFolders = exports.decodeEncodedPath = exports.getMostRecentlyActiveSessionDir = exports.findSubdirectorySessionDirs = exports.findSessionsInDirectory = exports.findAllClaudeSessions = void 0;
8
- exports.fetchQuota = exports.removeCodexAccount = exports.switchToCodexAccount = exports.finalizeCodexAccount = exports.prepareCodexAccount = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.getActiveAccountStatus = exports.removeSavedAccountProfile = exports.replaceSavedAccountProfiles = exports.setActiveSavedAccount = exports.upsertSavedAccountProfile = exports.getActiveSavedAccount = exports.listSavedAccountProfiles = exports.writeSavedAccountRegistry = exports.readSavedAccountRegistry = exports.getAccountsDir = exports.isMultiAccountEnabled = exports.getActiveAccount = exports.listAccounts = exports.removeAccount = exports.switchToAccount = exports.addCurrentAccount = exports.readActiveClaudeAccount = exports.writeAccountRegistry = exports.readAccountRegistry = exports.ensureDefaultAccounts = exports.readClaudeMaxAccessTokenSync = exports.readClaudeMaxCredentials = exports.writeActiveCredentials = exports.readActiveCredentials = exports.openInBrowser = exports.parseTranscriptFromEvents = exports.parseTranscript = exports.generateHtmlReport = exports.PatternExtractor = exports.HeatmapTracker = exports.FrequencyTracker = exports.getSnapshotPath = exports.isSnapshotValid = exports.deleteSnapshot = exports.loadSnapshot = exports.saveSnapshot = exports.parseTodoDependencies = void 0;
9
- exports.scopePeakHoursToSessionProvider = exports.isClaudeCodeSessionProvider = exports.fetchPeakHoursStatus = exports.createPeakHoursNotApplicableState = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.extractToolCalls = exports.extractToolCall = exports.extractTokenUsage = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = exports.MultiProviderQuotaService = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = exports.fetchCodexQuotaFromApi = exports.getWorkspaceIdFromPath = exports.pruneQuotaHistory = exports.readQuotaHistoryDailyBuckets = exports.readQuotaHistoryRange = exports.appendQuotaHistorySample = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = void 0;
7
+ exports.clearHighlightCache = exports.highlightEvent = exports.formatSessionJson = exports.formatSessionMarkdown = exports.formatSessionText = exports.classifyNoise = exports.shouldMergeWithPrevious = exports.classifyFollowEvent = exports.classifyMessage = exports.getSoftNoiseReason = exports.isHardNoiseFollowEvent = exports.isHardNoise = exports.formatToolSummary = exports.formatTokenCount = exports.formatDurationMs = exports.createJsonlTail = exports.toFollowEvents = exports.createWatcher = exports.parseChangelog = exports.extractProposedPlanShared = exports.parsePlanMarkdownShared = exports.PlanExtractor = exports.segmentAssistantTurn = exports.reasoningSummary = exports.isAssistantTurnSubagentTool = exports.extractTurnSubagents = exports.assistantTurnEventsFromSessionEvents = exports.readSessionContextSnapshot = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.composeContext = exports.FilterEngine = exports.searchSessions = exports.CodexDatabase = exports.OpenCodeDatabase = exports.discoverDebugLogs = exports.collapseDuplicates = exports.filterByLevel = exports.parseDebugLog = exports.scanSubagentTraces = exports.findAllSessionsWithWorktrees = exports.discoverWorktreeSiblings = exports.resolveWorktreeMainRepo = exports.getAllClaudeProjectFolders = exports.decodeEncodedPath = exports.getMostRecentlyActiveSessionDir = exports.findSubdirectorySessionDirs = exports.findSessionsInDirectory = exports.findAllClaudeSessions = void 0;
8
+ exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.getActiveAccountStatus = exports.removeSavedAccountProfile = exports.replaceSavedAccountProfiles = exports.setActiveSavedAccount = exports.upsertSavedAccountProfile = exports.getActiveSavedAccount = exports.listSavedAccountProfiles = exports.writeSavedAccountRegistry = exports.readSavedAccountRegistry = exports.getAccountsDir = exports.isMultiAccountEnabled = exports.getActiveAccount = exports.listAccounts = exports.removeAccount = exports.switchToAccount = exports.addCurrentAccount = exports.readActiveClaudeAccount = exports.writeAccountRegistry = exports.readAccountRegistry = exports.ensureDefaultAccounts = exports.readClaudeMaxAccessTokenSync = exports.readClaudeMaxCredentials = exports.writeActiveCredentials = exports.readActiveCredentials = exports.openInBrowser = exports.parseTranscriptFromEvents = exports.parseTranscript = exports.generateHtmlReport = exports.PatternExtractor = exports.HeatmapTracker = exports.FrequencyTracker = exports.getSnapshotPath = exports.isSnapshotValid = exports.deleteSnapshot = exports.loadSnapshot = exports.saveSnapshot = exports.parseTodoDependencies = exports.EventAggregator = exports.getRandomPhrase = exports.PHRASE_CATEGORIES = exports.ALL_PHRASES = exports.HIGHLIGHT_CSS = void 0;
9
+ exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.extractToolCalls = exports.extractToolCall = exports.extractTokenUsage = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = exports.MultiProviderQuotaService = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = exports.fetchCodexQuotaFromApi = exports.getWorkspaceIdFromPath = exports.pruneQuotaHistory = exports.readQuotaHistoryDailyBuckets = exports.readQuotaHistoryRange = exports.appendQuotaHistorySample = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = exports.fetchQuota = exports.removeCodexAccount = exports.switchToCodexAccount = exports.finalizeCodexAccount = exports.prepareCodexAccount = void 0;
10
+ exports.scopePeakHoursToSessionProvider = exports.isClaudeCodeSessionProvider = exports.fetchPeakHoursStatus = exports.createPeakHoursNotApplicableState = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.quotaSourceSchema = void 0;
10
11
  var taskPersistence_1 = require("./types/taskPersistence");
11
12
  Object.defineProperty(exports, "TASK_PERSISTENCE_SCHEMA_VERSION", { enumerable: true, get: function () { return taskPersistence_1.TASK_PERSISTENCE_SCHEMA_VERSION; } });
12
13
  Object.defineProperty(exports, "normalizeTaskStatus", { enumerable: true, get: function () { return taskPersistence_1.normalizeTaskStatus; } });
@@ -123,6 +124,13 @@ Object.defineProperty(exports, "buildSessionContextSnapshot", { enumerable: true
123
124
  Object.defineProperty(exports, "calculateSessionContextPressure", { enumerable: true, get: function () { return sessionContext_1.calculateSessionContextPressure; } });
124
125
  Object.defineProperty(exports, "createSessionContextProjector", { enumerable: true, get: function () { return sessionContext_1.createSessionContextProjector; } });
125
126
  Object.defineProperty(exports, "readSessionContextSnapshot", { enumerable: true, get: function () { return sessionContext_1.readSessionContextSnapshot; } });
127
+ // Assistant turn projection
128
+ var assistantTurn_1 = require("./turns/assistantTurn");
129
+ Object.defineProperty(exports, "assistantTurnEventsFromSessionEvents", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnEventsFromSessionEvents; } });
130
+ Object.defineProperty(exports, "extractTurnSubagents", { enumerable: true, get: function () { return assistantTurn_1.extractTurnSubagents; } });
131
+ Object.defineProperty(exports, "isAssistantTurnSubagentTool", { enumerable: true, get: function () { return assistantTurn_1.isAssistantTurnSubagentTool; } });
132
+ Object.defineProperty(exports, "reasoningSummary", { enumerable: true, get: function () { return assistantTurn_1.reasoningSummary; } });
133
+ Object.defineProperty(exports, "segmentAssistantTurn", { enumerable: true, get: function () { return assistantTurn_1.segmentAssistantTurn; } });
126
134
  // Plan Extraction
127
135
  var planExtractor_1 = require("./parsers/planExtractor");
128
136
  Object.defineProperty(exports, "PlanExtractor", { enumerable: true, get: function () { return planExtractor_1.PlanExtractor; } });
@@ -295,6 +303,41 @@ Object.defineProperty(exports, "messageUsageSchema", { enumerable: true, get: fu
295
303
  Object.defineProperty(exports, "sessionMessageSchema", { enumerable: true, get: function () { return sessionEvent_1.sessionMessageSchema; } });
296
304
  Object.defineProperty(exports, "sessionEventSchema", { enumerable: true, get: function () { return sessionEvent_1.sessionEventSchema; } });
297
305
  Object.defineProperty(exports, "permissionModeSchema", { enumerable: true, get: function () { return sessionEvent_1.permissionModeSchema; } });
306
+ Object.defineProperty(exports, "extractSessionEvents", { enumerable: true, get: function () { return sessionEvent_1.extractSessionEvents; } });
307
+ // Schemas — Zod runtime validation for quota / provider quota / peak hours
308
+ var quota_2 = require("./schemas/quota");
309
+ Object.defineProperty(exports, "quotaWindowSchema", { enumerable: true, get: function () { return quota_2.quotaWindowSchema; } });
310
+ Object.defineProperty(exports, "quotaStateSchema", { enumerable: true, get: function () { return quota_2.quotaStateSchema; } });
311
+ Object.defineProperty(exports, "quotaFailureKindSchema", { enumerable: true, get: function () { return quota_2.quotaFailureKindSchema; } });
312
+ Object.defineProperty(exports, "quotaProviderIdSchema", { enumerable: true, get: function () { return quota_2.quotaProviderIdSchema; } });
313
+ Object.defineProperty(exports, "quotaSourceSchema", { enumerable: true, get: function () { return quota_2.quotaSourceSchema; } });
314
+ Object.defineProperty(exports, "peakHoursStateSchema", { enumerable: true, get: function () { return quota_2.peakHoursStateSchema; } });
315
+ Object.defineProperty(exports, "quotaFailureDescriptorSchema", { enumerable: true, get: function () { return quota_2.quotaFailureDescriptorSchema; } });
316
+ Object.defineProperty(exports, "runtimeQuotaProviderSchema", { enumerable: true, get: function () { return quota_2.runtimeQuotaProviderSchema; } });
317
+ Object.defineProperty(exports, "providerQuotaStateSchema", { enumerable: true, get: function () { return quota_2.providerQuotaStateSchema; } });
318
+ Object.defineProperty(exports, "claudeProviderQuotaStateSchema", { enumerable: true, get: function () { return quota_2.claudeProviderQuotaStateSchema; } });
319
+ Object.defineProperty(exports, "codexProviderQuotaStateSchema", { enumerable: true, get: function () { return quota_2.codexProviderQuotaStateSchema; } });
320
+ Object.defineProperty(exports, "providerQuotaMapSchema", { enumerable: true, get: function () { return quota_2.providerQuotaMapSchema; } });
321
+ // Schemas — Zod runtime validation for quota history
322
+ var quotaHistory_2 = require("./schemas/quotaHistory");
323
+ Object.defineProperty(exports, "quotaHistoryRuntimeProviderSchema", { enumerable: true, get: function () { return quotaHistory_2.quotaHistoryRuntimeProviderSchema; } });
324
+ Object.defineProperty(exports, "quotaHistorySampleSchema", { enumerable: true, get: function () { return quotaHistory_2.quotaHistorySampleSchema; } });
325
+ Object.defineProperty(exports, "quotaHistoryDailyBucketSchema", { enumerable: true, get: function () { return quotaHistory_2.quotaHistoryDailyBucketSchema; } });
326
+ // Schemas — Zod runtime validation for account status
327
+ var accountStatus_2 = require("./schemas/accountStatus");
328
+ Object.defineProperty(exports, "activeProviderAccountStatusSchema", { enumerable: true, get: function () { return accountStatus_2.activeProviderAccountStatusSchema; } });
329
+ Object.defineProperty(exports, "activeAccountStatusSchema", { enumerable: true, get: function () { return accountStatus_2.activeAccountStatusSchema; } });
330
+ var assistantTurn_2 = require("./schemas/assistantTurn");
331
+ Object.defineProperty(exports, "assistantTurnEventSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnEventSchema; } });
332
+ Object.defineProperty(exports, "assistantTurnEventTypeSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnEventTypeSchema; } });
333
+ Object.defineProperty(exports, "assistantTurnNarrationStepSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnNarrationStepSchema; } });
334
+ Object.defineProperty(exports, "assistantTurnProcessSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnProcessSchema; } });
335
+ Object.defineProperty(exports, "assistantTurnProcessStepSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnProcessStepSchema; } });
336
+ Object.defineProperty(exports, "assistantTurnProjectionSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnProjectionSchema; } });
337
+ Object.defineProperty(exports, "assistantTurnSubagentSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnSubagentSchema; } });
338
+ Object.defineProperty(exports, "assistantTurnSubagentStatusSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnSubagentStatusSchema; } });
339
+ Object.defineProperty(exports, "assistantTurnToolGroupStepSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnToolGroupStepSchema; } });
340
+ Object.defineProperty(exports, "assistantTurnToolRefSchema", { enumerable: true, get: function () { return assistantTurn_2.assistantTurnToolRefSchema; } });
298
341
  // Provider Status
299
342
  var providerStatus_1 = require("./providerStatus");
300
343
  Object.defineProperty(exports, "fetchProviderStatus", { enumerable: true, get: function () { return providerStatus_1.fetchProviderStatus; } });
@@ -7,6 +7,9 @@ export declare const DEFAULT_CONTEXT_WINDOW = 200000;
7
7
  /**
8
8
  * Returns the context window size for a model ID.
9
9
  *
10
+ * Input is trimmed and lowercased before lookup, so padded or mixed-case
11
+ * IDs (e.g. "Claude-Opus-4-8 ") resolve without caller-side normalization.
12
+ *
10
13
  * Lookup order:
11
14
  * 1. Explicit "[1m]" suffix (Claude Code's 1M-variant marker) → 1_000_000
12
15
  * 2. Exact match against MODEL_CONTEXT_SIZES
@@ -56,6 +56,9 @@ exports.DEFAULT_CONTEXT_WINDOW = 200_000;
56
56
  /**
57
57
  * Returns the context window size for a model ID.
58
58
  *
59
+ * Input is trimmed and lowercased before lookup, so padded or mixed-case
60
+ * IDs (e.g. "Claude-Opus-4-8 ") resolve without caller-side normalization.
61
+ *
59
62
  * Lookup order:
60
63
  * 1. Explicit "[1m]" suffix (Claude Code's 1M-variant marker) → 1_000_000
61
64
  * 2. Exact match against MODEL_CONTEXT_SIZES
@@ -71,7 +74,8 @@ function getModelContextWindowSize(modelId) {
71
74
  return 1_000_000;
72
75
  // Strip the suffix if present, so the normal lookup still succeeds when
73
76
  // a caller passes e.g. "claude-opus-4-7[1m]" and we've already handled it.
74
- const normalized = modelId.replace(/\[1m\]/gi, '');
77
+ // Trim/lowercase so padded or mixed-case IDs match the lowercase table keys.
78
+ const normalized = modelId.replace(/\[1m\]/gi, '').trim().toLowerCase();
75
79
  // Exact match
76
80
  if (MODEL_CONTEXT_SIZES[normalized] !== undefined) {
77
81
  return MODEL_CONTEXT_SIZES[normalized];
@@ -89,6 +89,9 @@ export declare function _clearPricingOverrides(): void;
89
89
  /**
90
90
  * Parses a model ID into {provider, family, version}.
91
91
  *
92
+ * Input is trimmed and lowercased before matching, so padded or mixed-case
93
+ * IDs (e.g. " Claude-Opus-4-8 ") parse without caller-side normalization.
94
+ *
92
95
  * Recognizes Anthropic (Claude), OpenAI (GPT + o-series), and Google (Gemini).
93
96
  * Returns null for anything else — callers should treat that as "unknown model".
94
97
  */
@@ -101,6 +104,11 @@ export declare function parseModelId(modelId: string): ParsedModelId | null;
101
104
  * 2. Static PRICING_TABLE.
102
105
  * 3. `null` — unknown model. Callers MUST handle this.
103
106
  *
107
+ * The ID is first looked up verbatim (minus the "[1m]" suffix) — override
108
+ * keys from the LiteLLM catalog are stored as published and may be
109
+ * mixed-case — then retried trimmed/lowercased so padded or mixed-case IDs
110
+ * resolve against the lowercase tables.
111
+ *
104
112
  * @returns Pricing for the model, or null if unknown. No silent fallback.
105
113
  */
106
114
  export declare function getModelPricing(modelId: string): ModelPricing | null;
package/dist/modelInfo.js CHANGED
@@ -266,13 +266,16 @@ const GEMINI_RE = /^gemini-([0-9][0-9.A-Za-z-]*)/i;
266
266
  /**
267
267
  * Parses a model ID into {provider, family, version}.
268
268
  *
269
+ * Input is trimmed and lowercased before matching, so padded or mixed-case
270
+ * IDs (e.g. " Claude-Opus-4-8 ") parse without caller-side normalization.
271
+ *
269
272
  * Recognizes Anthropic (Claude), OpenAI (GPT + o-series), and Google (Gemini).
270
273
  * Returns null for anything else — callers should treat that as "unknown model".
271
274
  */
272
275
  function parseModelId(modelId) {
273
276
  if (!modelId)
274
277
  return null;
275
- const normalized = modelId.replace(/\[1m\]/gi, '');
278
+ const normalized = modelId.replace(/\[1m\]/gi, '').trim().toLowerCase();
276
279
  const claude = normalized.match(CLAUDE_RE);
277
280
  if (claude) {
278
281
  return { provider: 'anthropic', family: claude[1].toLowerCase(), version: claude[2] };
@@ -309,6 +312,20 @@ function findLongestPrefix(keys, modelId) {
309
312
  }
310
313
  return null;
311
314
  }
315
+ /** Override-then-static lookup, exact then longest-prefix at each stage. */
316
+ function lookupPricing(modelId) {
317
+ if (overrideTable[modelId])
318
+ return overrideTable[modelId];
319
+ const overridePrefix = findLongestPrefix(overrideSortedKeys, modelId);
320
+ if (overridePrefix)
321
+ return overrideTable[overridePrefix];
322
+ if (PRICING_TABLE[modelId])
323
+ return PRICING_TABLE[modelId];
324
+ const staticPrefix = findLongestPrefix(STATIC_SORTED_KEYS, modelId);
325
+ if (staticPrefix)
326
+ return PRICING_TABLE[staticPrefix];
327
+ return null;
328
+ }
312
329
  /**
313
330
  * Gets pricing for a model ID.
314
331
  *
@@ -317,26 +334,22 @@ function findLongestPrefix(keys, modelId) {
317
334
  * 2. Static PRICING_TABLE.
318
335
  * 3. `null` — unknown model. Callers MUST handle this.
319
336
  *
337
+ * The ID is first looked up verbatim (minus the "[1m]" suffix) — override
338
+ * keys from the LiteLLM catalog are stored as published and may be
339
+ * mixed-case — then retried trimmed/lowercased so padded or mixed-case IDs
340
+ * resolve against the lowercase tables.
341
+ *
320
342
  * @returns Pricing for the model, or null if unknown. No silent fallback.
321
343
  */
322
344
  function getModelPricing(modelId) {
323
345
  if (!modelId)
324
346
  return null;
325
- const normalized = modelId.replace(/\[1m\]/gi, '');
326
- // 1. Overrides (exact then longest-prefix)
327
- if (overrideTable[normalized])
328
- return overrideTable[normalized];
329
- const overridePrefix = findLongestPrefix(overrideSortedKeys, normalized);
330
- if (overridePrefix)
331
- return overrideTable[overridePrefix];
332
- // 2. Static (exact then longest-prefix)
333
- if (PRICING_TABLE[normalized])
334
- return PRICING_TABLE[normalized];
335
- const staticPrefix = findLongestPrefix(STATIC_SORTED_KEYS, normalized);
336
- if (staticPrefix)
337
- return PRICING_TABLE[staticPrefix];
338
- // 3. Unknown
339
- return null;
347
+ const stripped = modelId.replace(/\[1m\]/gi, '');
348
+ const direct = lookupPricing(stripped);
349
+ if (direct)
350
+ return direct;
351
+ const normalized = stripped.trim().toLowerCase();
352
+ return normalized === stripped ? null : lookupPricing(normalized);
340
353
  }
341
354
  /**
342
355
  * Returns comprehensive metadata for a model ID.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Zod schemas for runtime validation of active account status.
3
+ *
4
+ * These schemas mirror the TypeScript interfaces in `accountStatus.ts`
5
+ * (keep in sync when those change). They let consumers validate account
6
+ * status payloads at process/IPC boundaries without hand-mirroring the
7
+ * interfaces.
8
+ *
9
+ * @module schemas/accountStatus
10
+ */
11
+ import { z } from 'zod';
12
+ export declare const activeProviderAccountStatusSchema: z.ZodObject<{
13
+ present: z.ZodBoolean;
14
+ email: z.ZodOptional<z.ZodString>;
15
+ label: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export declare const activeAccountStatusSchema: z.ZodObject<{
18
+ ok: z.ZodBoolean;
19
+ claude: z.ZodObject<{
20
+ present: z.ZodBoolean;
21
+ email: z.ZodOptional<z.ZodString>;
22
+ label: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ codex: z.ZodObject<{
25
+ present: z.ZodBoolean;
26
+ email: z.ZodOptional<z.ZodString>;
27
+ label: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ error: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strip>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * Zod schemas for runtime validation of active account status.
4
+ *
5
+ * These schemas mirror the TypeScript interfaces in `accountStatus.ts`
6
+ * (keep in sync when those change). They let consumers validate account
7
+ * status payloads at process/IPC boundaries without hand-mirroring the
8
+ * interfaces.
9
+ *
10
+ * @module schemas/accountStatus
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = void 0;
14
+ const zod_1 = require("zod");
15
+ // ── ActiveProviderAccountStatus ──
16
+ exports.activeProviderAccountStatusSchema = zod_1.z.object({
17
+ present: zod_1.z.boolean(),
18
+ email: zod_1.z.string().optional(),
19
+ label: zod_1.z.string().optional(),
20
+ });
21
+ // ── ActiveAccountStatus ──
22
+ exports.activeAccountStatusSchema = zod_1.z.object({
23
+ ok: zod_1.z.boolean(),
24
+ claude: exports.activeProviderAccountStatusSchema,
25
+ codex: exports.activeProviderAccountStatusSchema,
26
+ error: zod_1.z.string().optional(),
27
+ });
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Zod schemas for browser-safe assistant turn projections.
3
+ *
4
+ * These schemas mirror `turns/assistantTurn.ts` and validate the compact
5
+ * process/answer shape used at UI and IPC boundaries.
6
+ */
7
+ import { z } from 'zod';
8
+ export declare const assistantTurnEventTypeSchema: z.ZodEnum<{
9
+ status: "status";
10
+ tool_use: "tool_use";
11
+ tool_result: "tool_result";
12
+ error: "error";
13
+ text: "text";
14
+ progress: "progress";
15
+ thinking: "thinking";
16
+ delta: "delta";
17
+ }>;
18
+ export declare const assistantTurnEventSchema: z.ZodObject<{
19
+ eventType: z.ZodEnum<{
20
+ status: "status";
21
+ tool_use: "tool_use";
22
+ tool_result: "tool_result";
23
+ error: "error";
24
+ text: "text";
25
+ progress: "progress";
26
+ thinking: "thinking";
27
+ delta: "delta";
28
+ }>;
29
+ content: z.ZodString;
30
+ deltaKind: z.ZodOptional<z.ZodEnum<{
31
+ text: "text";
32
+ thinking: "thinking";
33
+ tool_input: "tool_input";
34
+ }>>;
35
+ toolName: z.ZodOptional<z.ZodString>;
36
+ toolInput: z.ZodOptional<z.ZodUnknown>;
37
+ toolUseId: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export declare const assistantTurnToolRefSchema: z.ZodObject<{
40
+ toolName: z.ZodString;
41
+ toolInput: z.ZodOptional<z.ZodString>;
42
+ toolUseId: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>;
44
+ export declare const assistantTurnNarrationStepSchema: z.ZodObject<{
45
+ kind: z.ZodLiteral<"narration">;
46
+ text: z.ZodString;
47
+ }, z.core.$strip>;
48
+ export declare const assistantTurnToolGroupStepSchema: z.ZodObject<{
49
+ kind: z.ZodLiteral<"toolGroup">;
50
+ tools: z.ZodArray<z.ZodObject<{
51
+ toolName: z.ZodString;
52
+ toolInput: z.ZodOptional<z.ZodString>;
53
+ toolUseId: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>;
56
+ export declare const assistantTurnProcessStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
+ kind: z.ZodLiteral<"narration">;
58
+ text: z.ZodString;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ kind: z.ZodLiteral<"toolGroup">;
61
+ tools: z.ZodArray<z.ZodObject<{
62
+ toolName: z.ZodString;
63
+ toolInput: z.ZodOptional<z.ZodString>;
64
+ toolUseId: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strip>>;
66
+ }, z.core.$strip>], "kind">;
67
+ export declare const assistantTurnProcessSchema: z.ZodObject<{
68
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
69
+ kind: z.ZodLiteral<"narration">;
70
+ text: z.ZodString;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ kind: z.ZodLiteral<"toolGroup">;
73
+ tools: z.ZodArray<z.ZodObject<{
74
+ toolName: z.ZodString;
75
+ toolInput: z.ZodOptional<z.ZodString>;
76
+ toolUseId: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>>;
78
+ }, z.core.$strip>], "kind">>;
79
+ }, z.core.$strip>;
80
+ export declare const assistantTurnSubagentStatusSchema: z.ZodEnum<{
81
+ completed: "completed";
82
+ failed: "failed";
83
+ running: "running";
84
+ }>;
85
+ export declare const assistantTurnSubagentSchema: z.ZodObject<{
86
+ id: z.ZodString;
87
+ label: z.ZodString;
88
+ agentType: z.ZodOptional<z.ZodString>;
89
+ status: z.ZodEnum<{
90
+ completed: "completed";
91
+ failed: "failed";
92
+ running: "running";
93
+ }>;
94
+ }, z.core.$strip>;
95
+ export declare const assistantTurnProjectionSchema: z.ZodObject<{
96
+ schemaVersion: z.ZodLiteral<1>;
97
+ answer: z.ZodString;
98
+ reasoning: z.ZodString;
99
+ reasoningBlocks: z.ZodArray<z.ZodString>;
100
+ process: z.ZodObject<{
101
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
102
+ kind: z.ZodLiteral<"narration">;
103
+ text: z.ZodString;
104
+ }, z.core.$strip>, z.ZodObject<{
105
+ kind: z.ZodLiteral<"toolGroup">;
106
+ tools: z.ZodArray<z.ZodObject<{
107
+ toolName: z.ZodString;
108
+ toolInput: z.ZodOptional<z.ZodString>;
109
+ toolUseId: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strip>>;
111
+ }, z.core.$strip>], "kind">>;
112
+ }, z.core.$strip>;
113
+ subagents: z.ZodArray<z.ZodObject<{
114
+ id: z.ZodString;
115
+ label: z.ZodString;
116
+ agentType: z.ZodOptional<z.ZodString>;
117
+ status: z.ZodEnum<{
118
+ completed: "completed";
119
+ failed: "failed";
120
+ running: "running";
121
+ }>;
122
+ }, z.core.$strip>>;
123
+ }, z.core.$strip>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Zod schemas for browser-safe assistant turn projections.
4
+ *
5
+ * These schemas mirror `turns/assistantTurn.ts` and validate the compact
6
+ * process/answer shape used at UI and IPC boundaries.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.assistantTurnProjectionSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnProcessSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnToolRefSchema = exports.assistantTurnEventSchema = exports.assistantTurnEventTypeSchema = void 0;
10
+ const zod_1 = require("zod");
11
+ exports.assistantTurnEventTypeSchema = zod_1.z.enum([
12
+ 'text',
13
+ 'thinking',
14
+ 'tool_use',
15
+ 'tool_result',
16
+ 'status',
17
+ 'error',
18
+ 'delta',
19
+ 'progress',
20
+ ]);
21
+ exports.assistantTurnEventSchema = zod_1.z.object({
22
+ eventType: exports.assistantTurnEventTypeSchema,
23
+ content: zod_1.z.string(),
24
+ deltaKind: zod_1.z.enum(['text', 'thinking', 'tool_input']).optional(),
25
+ toolName: zod_1.z.string().optional(),
26
+ toolInput: zod_1.z.unknown().optional(),
27
+ toolUseId: zod_1.z.string().optional(),
28
+ });
29
+ exports.assistantTurnToolRefSchema = zod_1.z.object({
30
+ toolName: zod_1.z.string(),
31
+ toolInput: zod_1.z.string().optional(),
32
+ toolUseId: zod_1.z.string().optional(),
33
+ });
34
+ exports.assistantTurnNarrationStepSchema = zod_1.z.object({
35
+ kind: zod_1.z.literal('narration'),
36
+ text: zod_1.z.string(),
37
+ });
38
+ exports.assistantTurnToolGroupStepSchema = zod_1.z.object({
39
+ kind: zod_1.z.literal('toolGroup'),
40
+ tools: zod_1.z.array(exports.assistantTurnToolRefSchema),
41
+ });
42
+ exports.assistantTurnProcessStepSchema = zod_1.z.discriminatedUnion('kind', [
43
+ exports.assistantTurnNarrationStepSchema,
44
+ exports.assistantTurnToolGroupStepSchema,
45
+ ]);
46
+ exports.assistantTurnProcessSchema = zod_1.z.object({
47
+ steps: zod_1.z.array(exports.assistantTurnProcessStepSchema),
48
+ });
49
+ exports.assistantTurnSubagentStatusSchema = zod_1.z.enum([
50
+ 'running',
51
+ 'completed',
52
+ 'failed',
53
+ ]);
54
+ exports.assistantTurnSubagentSchema = zod_1.z.object({
55
+ id: zod_1.z.string(),
56
+ label: zod_1.z.string(),
57
+ agentType: zod_1.z.string().optional(),
58
+ status: exports.assistantTurnSubagentStatusSchema,
59
+ });
60
+ exports.assistantTurnProjectionSchema = zod_1.z.object({
61
+ schemaVersion: zod_1.z.literal(1),
62
+ answer: zod_1.z.string(),
63
+ reasoning: zod_1.z.string(),
64
+ reasoningBlocks: zod_1.z.array(zod_1.z.string()),
65
+ process: exports.assistantTurnProcessSchema,
66
+ subagents: zod_1.z.array(exports.assistantTurnSubagentSchema),
67
+ });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Schemas entry (`sidekick-shared/schemas`).
3
+ *
4
+ * Pure zod runtime validation for the data shapes that cross process/IPC
5
+ * boundaries: session events, quota state, quota history, account status,
6
+ * and assistant turn projections. No node:fs / node:path — safe to bundle
7
+ * for browser runtimes, and lean enough that importing it does not drag in
8
+ * the rest of the library.
9
+ *
10
+ * The mirrored TypeScript interfaces are re-exported as types so this
11
+ * subpath is self-sufficient for boundary-validation modules.
12
+ */
13
+ export { messageUsageSchema, sessionMessageSchema, sessionEventSchema, permissionModeSchema, extractSessionEvents, } from './sessionEvent';
14
+ export type { MessageUsage, SessionMessage, SessionEvent, PermissionMode, } from '../types/sessionEvent';
15
+ export { quotaWindowSchema, quotaStateSchema, quotaFailureKindSchema, quotaProviderIdSchema, quotaSourceSchema, peakHoursStateSchema, quotaFailureDescriptorSchema, runtimeQuotaProviderSchema, providerQuotaStateSchema, claudeProviderQuotaStateSchema, codexProviderQuotaStateSchema, providerQuotaMapSchema, } from './quota';
16
+ export type { QuotaWindow, QuotaState } from '../quota';
17
+ export type { PeakHoursState } from '../peakHours';
18
+ export type { QuotaFailureDescriptor } from '../quotaPresentation';
19
+ export type { ProviderQuotaState, ProviderQuotaMap, RuntimeQuotaProvider, } from '../providerQuota';
20
+ export { quotaHistoryRuntimeProviderSchema, quotaHistorySampleSchema, quotaHistoryDailyBucketSchema, } from './quotaHistory';
21
+ export type { QuotaHistoryRuntimeProvider, QuotaHistorySample, QuotaHistoryDailyBucket, } from '../quotaHistory';
22
+ export { activeProviderAccountStatusSchema, activeAccountStatusSchema, } from './accountStatus';
23
+ export type { ActiveProviderAccountStatus, ActiveAccountStatus, } from '../accountStatus';
24
+ export { assistantTurnEventSchema, assistantTurnEventTypeSchema, assistantTurnNarrationStepSchema, assistantTurnProcessSchema, assistantTurnProcessStepSchema, assistantTurnProjectionSchema, assistantTurnSubagentSchema, assistantTurnSubagentStatusSchema, assistantTurnToolGroupStepSchema, assistantTurnToolRefSchema, } from './assistantTurn';
25
+ export type { AssistantTurnEvent, AssistantTurnEventType, AssistantTurnProcess, AssistantTurnProcessStep, AssistantTurnProjection, AssistantTurnSubagent, AssistantTurnSubagentStatus, AssistantTurnToolRef, } from '../turns/assistantTurn';