sidekick-shared 0.28.3 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +64 -0
- package/README.md +149 -19
- package/dist/authStatus.d.ts +54 -0
- package/dist/authStatus.js +91 -0
- package/dist/browser.d.ts +12 -6
- package/dist/browser.js +17 -1
- package/dist/codex.d.ts +23 -0
- package/dist/codex.js +44 -0
- package/dist/codexProfiles.d.ts +1 -0
- package/dist/codexProfiles.js +8 -11
- package/dist/esm/authStatus.js +87 -0
- package/dist/esm/browser.js +4 -2
- package/dist/esm/codex.js +18 -0
- package/dist/esm/codexProfiles.js +8 -11
- package/dist/esm/formatting.js +10 -1
- package/dist/esm/index.js +9 -6
- package/dist/esm/modelCatalog.js +2 -1
- package/dist/esm/modelInfo.js +422 -45
- package/dist/esm/node.js +9 -3
- package/dist/esm/parsers/codexParser.js +175 -54
- package/dist/esm/parsers/codexRolloutOrigin.js +107 -0
- package/dist/esm/parsers/openCodeParser.js +83 -21
- package/dist/esm/pricing.js +18 -0
- package/dist/esm/pricingCatalog.js +14 -7
- package/dist/esm/promptHistory.js +66 -4
- package/dist/esm/providerFailure.js +124 -3
- package/dist/esm/providers/codex.js +2 -24
- package/dist/esm/providers/codexDatabase.js +3 -19
- package/dist/esm/providers/codexRollouts.js +24 -1
- package/dist/esm/providers/openCode.js +9 -17
- package/dist/esm/report/htmlReportGenerator.js +42 -5
- package/dist/esm/report/transcriptParser.js +13 -11
- package/dist/esm/schemas/providerFailure.js +3 -1
- package/dist/esm/schemas/transcript.js +4 -0
- package/dist/esm/sessionPromptHistory.js +2 -2
- package/dist/esm/statusline/payload.js +9 -0
- package/dist/esm/testing/credentialGuard.js +87 -5
- package/dist/esm/toolCallOrigins.js +310 -0
- package/dist/esm/transcript.js +42 -3
- package/dist/esm/usage/usageEvents.js +146 -17
- package/dist/esm/usage/usageReports.js +39 -6
- package/dist/esm/watchers/jsonlTail.js +378 -59
- package/dist/formatting.d.ts +26 -1
- package/dist/formatting.js +11 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +35 -12
- package/dist/modelCatalog.js +2 -1
- package/dist/modelInfo.d.ts +185 -16
- package/dist/modelInfo.js +431 -47
- package/dist/node.d.ts +16 -5
- package/dist/node.js +31 -2
- package/dist/parsers/codexParser.d.ts +55 -0
- package/dist/parsers/codexParser.js +175 -54
- package/dist/parsers/codexRolloutOrigin.d.ts +49 -0
- package/dist/parsers/codexRolloutOrigin.js +111 -0
- package/dist/parsers/openCodeParser.d.ts +38 -0
- package/dist/parsers/openCodeParser.js +86 -21
- package/dist/pricing.d.ts +22 -0
- package/dist/pricing.js +50 -0
- package/dist/pricingCatalog.d.ts +10 -0
- package/dist/pricingCatalog.js +13 -6
- package/dist/promptHistory.d.ts +65 -4
- package/dist/promptHistory.js +68 -5
- package/dist/providerFailure.d.ts +44 -0
- package/dist/providerFailure.js +126 -4
- package/dist/providers/codex.d.ts +3 -22
- package/dist/providers/codex.js +3 -26
- package/dist/providers/codexDatabase.d.ts +3 -2
- package/dist/providers/codexDatabase.js +4 -22
- package/dist/providers/codexRollouts.d.ts +22 -0
- package/dist/providers/codexRollouts.js +24 -0
- package/dist/providers/openCode.js +8 -16
- package/dist/report/htmlReportGenerator.js +42 -5
- package/dist/report/transcriptParser.d.ts +10 -1
- package/dist/report/transcriptParser.js +13 -11
- package/dist/schemas/providerFailure.d.ts +39 -0
- package/dist/schemas/providerFailure.js +2 -0
- package/dist/schemas/transcript.d.ts +2 -0
- package/dist/schemas/transcript.js +4 -0
- package/dist/sessionPromptHistory.d.ts +7 -1
- package/dist/sessionPromptHistory.js +1 -1
- package/dist/statusline/payload.d.ts +10 -0
- package/dist/statusline/payload.js +14 -0
- package/dist/testing/credentialGuard.d.ts +14 -0
- package/dist/testing/credentialGuard.js +87 -5
- package/dist/toolCallOrigins.d.ts +70 -0
- package/dist/toolCallOrigins.js +346 -0
- package/dist/transcript.d.ts +12 -0
- package/dist/transcript.js +42 -3
- package/dist/types/opencode.d.ts +2 -0
- package/dist/usage/usageEvents.d.ts +54 -6
- package/dist/usage/usageEvents.js +146 -17
- package/dist/usage/usageReports.d.ts +35 -4
- package/dist/usage/usageReports.js +39 -6
- package/dist/watchers/jsonlTail.d.ts +101 -4
- package/dist/watchers/jsonlTail.js +380 -60
- package/package.json +41 -1
package/dist/node.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export type { HydrateOptions, HydrateResult } from './pricingCatalog';
|
|
|
10
10
|
export { loadObservedContextWindows, recordObservedContextWindow, getObservedContextWindowPath, } from './observedContextWindows';
|
|
11
11
|
export type { ObservedContextWindowOptions, ObservedContextWindowStore, } from './observedContextWindows';
|
|
12
12
|
export { listRecentSessions, readSessionTranscript } from './sessionTranscripts';
|
|
13
|
-
export { collectPromptHistory, isPromptHistorySessionSettled, parsePromptHistoryCursor, } from './promptHistory';
|
|
13
|
+
export { collectPromptHistory, isPromptHistorySessionSettled, parsePromptHistoryCursor, PROMPT_HISTORY_ORDINAL_MAX_RECORD_BYTES, } from './promptHistory';
|
|
14
|
+
export { findToolCallOrigins } from './toolCallOrigins';
|
|
15
|
+
export type { FindToolCallOriginsOptions, ToolCallOrigin } from './toolCallOrigins';
|
|
14
16
|
export type { CollectPromptHistoryOptions, PromptHistoryAnswerState, PromptHistoryBound, PromptHistoryBounds, PromptHistoryCursor, PromptHistoryCursorSession, PromptHistoryEntry, PromptHistoryExclusion, PromptHistoryMetadataStatus, PromptHistoryPendingPrompt, PromptHistoryProvider, PromptHistoryResult, PromptHistoryResumeState, PromptHistoryStats, PromptHistoryUsage, } from './promptHistory';
|
|
15
17
|
export { collectSessionPromptHistory } from './sessionPromptHistory';
|
|
16
18
|
export type { CollectSessionPromptHistoryOptions, PromptHistorySession, PromptHistorySessionPrompt, PromptHistorySessionRef, SessionPromptHistoryBound, SessionPromptHistoryBounds, SessionPromptHistoryInclude, SessionPromptHistoryResult, SessionPromptHistoryStats, } from './sessionPromptHistory';
|
|
@@ -56,8 +58,17 @@ export { SYNTHETIC_MODEL } from './usage/claudeUsageDedupe';
|
|
|
56
58
|
export { CONFIG_DIR_ENV_VAR, getConfigDir, getConfigDirOverride, getDefaultConfigDir, } from './paths';
|
|
57
59
|
export { encodeWorkspacePath as encodeClaudeWorkspacePath, getSessionDirectory as getClaudeSessionDirectory, } from './parsers/sessionPathResolver';
|
|
58
60
|
export { getLiveClaudeHome, getDefaultClaudeHome, isDefaultClaudeHome, getClaudeProjectsDir, } from './claudePaths';
|
|
59
|
-
export { getSystemCodexHome, getCodexMonitoringHomes, resolveSidekickCodexHome, getCodexExecutionEnv, getCodexSessionsDirs, CODEX_SESSIONS_SUBDIR, CODEX_ARCHIVED_SESSIONS_SUBDIR, } from './codexPaths';
|
|
60
|
-
export type { CodexSessionsDirsOptions } from './codexPaths';
|
|
61
|
+
export { getSystemCodexHome, getCodexMonitoringHomes, resolveSidekickCodexHome, getCodexExecutionEnv, getCodexSessionsDirs, getCodexCredentialStoreMode, forceFileCredentialStore, CODEX_SESSIONS_SUBDIR, CODEX_ARCHIVED_SESSIONS_SUBDIR, } from './codexPaths';
|
|
62
|
+
export type { CodexCredentialStoreMode, CodexSessionsDirsOptions } from './codexPaths';
|
|
63
|
+
export { parseAuthJson as parseCodexAuthJson, readAuthIdentityFromRaw as readCodexAuthIdentity, readLastRefresh as readCodexLastRefresh, readAccessTokenExpiry as readCodexAccessTokenExpiry, identitiesMatch as codexIdentitiesMatch, codexRefreshFingerprint, compareCodexAuthFreshness, } from './codexAuth';
|
|
64
|
+
export type { CodexAuthIdentity, CodexAuthJsonFile } from './codexAuth';
|
|
65
|
+
export { atomicWriteJson, atomicWriteJsonSync } from './writers/atomic';
|
|
66
|
+
export { parseClaudeAuthStatus, parseCodexLoginStatus } from './authStatus';
|
|
67
|
+
export type { ParsedClaudeAuthStatus, ParsedCodexLoginStatus } from './authStatus';
|
|
68
|
+
export { codexRolloutOrigin, codexSpawnParentFromSource } from './parsers/codexRolloutOrigin';
|
|
69
|
+
export type { CodexRolloutOrigin } from './parsers/codexRolloutOrigin';
|
|
70
|
+
export { getPricingCatalogInfo, registerModelPricing, clearRegisteredModelPricing, } from './modelInfo';
|
|
71
|
+
export type { PricingCatalogInfo, PricingCatalogSource, RegisterModelPricingOptions, } from './modelInfo';
|
|
61
72
|
export type { ProviderServiceSeverity, ProviderServiceComponent, ProviderServiceIncident, ProviderServiceStatusFailureReason, ObservedProviderServiceStatus, UnavailableProviderServiceStatus, ProviderServiceStatus, FetchProviderServiceStatusOptions, } from './providerServiceStatusTypes';
|
|
62
73
|
export { fetchProviderServiceStatus } from './providerServiceStatus';
|
|
63
74
|
export { classifyTool, TOOL_CATEGORIES } from './toolCategory';
|
|
@@ -65,5 +76,5 @@ export type { ClassifyToolOptions, ToolCategory } from './toolCategory';
|
|
|
65
76
|
export { resolveWorkspaceRoots } from './workspaceRoots';
|
|
66
77
|
export type { ResolveWorkspaceRootsOptions, ResolvedWorkspaceRoots } from './workspaceRoots';
|
|
67
78
|
export { discoverWorktreeSiblings, resolveWorktreeMainRepo } from './parsers/sessionPathResolver';
|
|
68
|
-
export { createJsonlTail, DEFAULT_JSONL_TAIL_MAX_LINE_BYTES, DEFAULT_JSONL_TAIL_READ_BYTES, } from './watchers/jsonlTail';
|
|
69
|
-
export type { JsonlTail, JsonlTailBatch, JsonlTailLine, JsonlTailOptions, JsonlTailReset, JsonlTailResetReason, } from './watchers/jsonlTail';
|
|
79
|
+
export { createJsonlTail, DEFAULT_JSONL_TAIL_MAX_LINE_BYTES, DEFAULT_JSONL_TAIL_READ_BYTES, JSONL_TAIL_CHECKPOINT_VERSION, JsonlTailSymlinkError, } from './watchers/jsonlTail';
|
|
80
|
+
export type { JsonlTail, JsonlTailCheckpoint, JsonlTailReadResult, JsonlTailEntry, JsonlTailRewritePolicy, JsonlTailBatch, JsonlTailLine, JsonlTailOptions, JsonlTailReset, JsonlTailResetReason, } from './watchers/jsonlTail';
|
package/dist/node.js
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* for browser bundles — use `sidekick-shared/browser` there.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
10
|
+
exports.removeSessionSummary = exports.markFileImported = exports.isFileImported = exports.applySessionSummary = exports.subagentTokenTotals = exports.scanSessionSubagents = exports.readMainThreadTokenTotals = exports.combineSessionTokenTotals = exports.collectSessionTokenTotals = exports.pruneUsageCache = exports.getUsageCacheDir = exports.collectUsageEvents = exports.USAGE_CACHE_VERSION = exports.MAX_USAGE_CACHE_FILES = exports.findActiveBillingBlock = exports.computeBillingBlocks = exports.BILLING_BLOCK_DURATION_MS = exports.writeStateFile = exports.readStateFile = exports.quotaToStateFile = exports.getStateFilePath = exports.billingBlockToStateFile = exports.STATE_FILE_SCHEMA_VERSION = exports.STATE_FILE_NAME = exports.sessionFingerprintParts = exports.fingerprintString = exports.readSessionReportInputs = exports.readSessionFileStats = exports.providerContextSizeFn = exports.firstUserPrompt = exports.computeSessionFileStats = exports.isHumanPrompt = exports.humanPromptText = exports.HUMAN_CODEX_SOURCES = exports.HUMAN_CLAUDE_ENTRYPOINTS = exports.collectSessionPromptHistory = exports.findToolCallOrigins = exports.PROMPT_HISTORY_ORDINAL_MAX_RECORD_BYTES = exports.parsePromptHistoryCursor = exports.isPromptHistorySessionSettled = exports.collectPromptHistory = exports.readSessionTranscript = exports.listRecentSessions = exports.getObservedContextWindowPath = exports.recordObservedContextWindow = exports.loadObservedContextWindows = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmContextWindows = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = void 0;
|
|
11
|
+
exports.atomicWriteJson = exports.compareCodexAuthFreshness = exports.codexRefreshFingerprint = exports.codexIdentitiesMatch = exports.readCodexAccessTokenExpiry = exports.readCodexLastRefresh = exports.readCodexAuthIdentity = exports.parseCodexAuthJson = exports.CODEX_ARCHIVED_SESSIONS_SUBDIR = exports.CODEX_SESSIONS_SUBDIR = exports.forceFileCredentialStore = exports.getCodexCredentialStoreMode = exports.getCodexSessionsDirs = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.getCodexMonitoringHomes = exports.getSystemCodexHome = exports.getClaudeProjectsDir = exports.isDefaultClaudeHome = exports.getDefaultClaudeHome = exports.getLiveClaudeHome = exports.getClaudeSessionDirectory = exports.encodeClaudeWorkspacePath = exports.getDefaultConfigDir = exports.getConfigDirOverride = exports.getConfigDir = exports.CONFIG_DIR_ENV_VAR = exports.SYNTHETIC_MODEL = exports.createSessionProviders = exports.splitWatchedPath = exports.DirectoryListingCache = exports.fileFingerprintParts = exports.fileFingerprint = exports.observedSessionSourceFromProvider = exports.ObservedSessionCollector = exports.readSessionPreviewAsync = exports.readSessionPreview = exports.listSessionPreviewsAsync = exports.listSessionPreviews = exports.readCodexHistory = exports.walkRolloutFilesAsync = exports.walkRolloutFiles = exports.findCodexRolloutFile = exports.weekKey = exports.usageBucketKey = exports.summarizeUsageRows = exports.bucketUsage = exports.importSessionHistory = exports.ACTIVE_SESSION_MTIME_THRESHOLD_MS = exports.sessionSummaryFromStats = void 0;
|
|
12
|
+
exports.JsonlTailSymlinkError = exports.JSONL_TAIL_CHECKPOINT_VERSION = exports.DEFAULT_JSONL_TAIL_READ_BYTES = exports.DEFAULT_JSONL_TAIL_MAX_LINE_BYTES = exports.createJsonlTail = exports.resolveWorktreeMainRepo = exports.discoverWorktreeSiblings = exports.resolveWorkspaceRoots = exports.TOOL_CATEGORIES = exports.classifyTool = exports.fetchProviderServiceStatus = exports.clearRegisteredModelPricing = exports.registerModelPricing = exports.getPricingCatalogInfo = exports.codexSpawnParentFromSource = exports.codexRolloutOrigin = exports.parseCodexLoginStatus = exports.parseClaudeAuthStatus = exports.atomicWriteJsonSync = void 0;
|
|
12
13
|
var pricingCatalog_1 = require("./pricingCatalog");
|
|
13
14
|
Object.defineProperty(exports, "hydratePricingCatalog", { enumerable: true, get: function () { return pricingCatalog_1.hydratePricingCatalog; } });
|
|
14
15
|
Object.defineProperty(exports, "normalizeLiteLlmCatalog", { enumerable: true, get: function () { return pricingCatalog_1.normalizeLiteLlmCatalog; } });
|
|
@@ -25,6 +26,9 @@ var promptHistory_1 = require("./promptHistory");
|
|
|
25
26
|
Object.defineProperty(exports, "collectPromptHistory", { enumerable: true, get: function () { return promptHistory_1.collectPromptHistory; } });
|
|
26
27
|
Object.defineProperty(exports, "isPromptHistorySessionSettled", { enumerable: true, get: function () { return promptHistory_1.isPromptHistorySessionSettled; } });
|
|
27
28
|
Object.defineProperty(exports, "parsePromptHistoryCursor", { enumerable: true, get: function () { return promptHistory_1.parsePromptHistoryCursor; } });
|
|
29
|
+
Object.defineProperty(exports, "PROMPT_HISTORY_ORDINAL_MAX_RECORD_BYTES", { enumerable: true, get: function () { return promptHistory_1.PROMPT_HISTORY_ORDINAL_MAX_RECORD_BYTES; } });
|
|
30
|
+
var toolCallOrigins_1 = require("./toolCallOrigins");
|
|
31
|
+
Object.defineProperty(exports, "findToolCallOrigins", { enumerable: true, get: function () { return toolCallOrigins_1.findToolCallOrigins; } });
|
|
28
32
|
var sessionPromptHistory_1 = require("./sessionPromptHistory");
|
|
29
33
|
Object.defineProperty(exports, "collectSessionPromptHistory", { enumerable: true, get: function () { return sessionPromptHistory_1.collectSessionPromptHistory; } });
|
|
30
34
|
var humanPrompt_1 = require("./humanPrompt");
|
|
@@ -126,8 +130,31 @@ Object.defineProperty(exports, "getCodexMonitoringHomes", { enumerable: true, ge
|
|
|
126
130
|
Object.defineProperty(exports, "resolveSidekickCodexHome", { enumerable: true, get: function () { return codexPaths_1.resolveSidekickCodexHome; } });
|
|
127
131
|
Object.defineProperty(exports, "getCodexExecutionEnv", { enumerable: true, get: function () { return codexPaths_1.getCodexExecutionEnv; } });
|
|
128
132
|
Object.defineProperty(exports, "getCodexSessionsDirs", { enumerable: true, get: function () { return codexPaths_1.getCodexSessionsDirs; } });
|
|
133
|
+
Object.defineProperty(exports, "getCodexCredentialStoreMode", { enumerable: true, get: function () { return codexPaths_1.getCodexCredentialStoreMode; } });
|
|
134
|
+
Object.defineProperty(exports, "forceFileCredentialStore", { enumerable: true, get: function () { return codexPaths_1.forceFileCredentialStore; } });
|
|
129
135
|
Object.defineProperty(exports, "CODEX_SESSIONS_SUBDIR", { enumerable: true, get: function () { return codexPaths_1.CODEX_SESSIONS_SUBDIR; } });
|
|
130
136
|
Object.defineProperty(exports, "CODEX_ARCHIVED_SESSIONS_SUBDIR", { enumerable: true, get: function () { return codexPaths_1.CODEX_ARCHIVED_SESSIONS_SUBDIR; } });
|
|
137
|
+
var codexAuth_1 = require("./codexAuth");
|
|
138
|
+
Object.defineProperty(exports, "parseCodexAuthJson", { enumerable: true, get: function () { return codexAuth_1.parseAuthJson; } });
|
|
139
|
+
Object.defineProperty(exports, "readCodexAuthIdentity", { enumerable: true, get: function () { return codexAuth_1.readAuthIdentityFromRaw; } });
|
|
140
|
+
Object.defineProperty(exports, "readCodexLastRefresh", { enumerable: true, get: function () { return codexAuth_1.readLastRefresh; } });
|
|
141
|
+
Object.defineProperty(exports, "readCodexAccessTokenExpiry", { enumerable: true, get: function () { return codexAuth_1.readAccessTokenExpiry; } });
|
|
142
|
+
Object.defineProperty(exports, "codexIdentitiesMatch", { enumerable: true, get: function () { return codexAuth_1.identitiesMatch; } });
|
|
143
|
+
Object.defineProperty(exports, "codexRefreshFingerprint", { enumerable: true, get: function () { return codexAuth_1.codexRefreshFingerprint; } });
|
|
144
|
+
Object.defineProperty(exports, "compareCodexAuthFreshness", { enumerable: true, get: function () { return codexAuth_1.compareCodexAuthFreshness; } });
|
|
145
|
+
var atomic_1 = require("./writers/atomic");
|
|
146
|
+
Object.defineProperty(exports, "atomicWriteJson", { enumerable: true, get: function () { return atomic_1.atomicWriteJson; } });
|
|
147
|
+
Object.defineProperty(exports, "atomicWriteJsonSync", { enumerable: true, get: function () { return atomic_1.atomicWriteJsonSync; } });
|
|
148
|
+
var authStatus_1 = require("./authStatus");
|
|
149
|
+
Object.defineProperty(exports, "parseClaudeAuthStatus", { enumerable: true, get: function () { return authStatus_1.parseClaudeAuthStatus; } });
|
|
150
|
+
Object.defineProperty(exports, "parseCodexLoginStatus", { enumerable: true, get: function () { return authStatus_1.parseCodexLoginStatus; } });
|
|
151
|
+
var codexRolloutOrigin_1 = require("./parsers/codexRolloutOrigin");
|
|
152
|
+
Object.defineProperty(exports, "codexRolloutOrigin", { enumerable: true, get: function () { return codexRolloutOrigin_1.codexRolloutOrigin; } });
|
|
153
|
+
Object.defineProperty(exports, "codexSpawnParentFromSource", { enumerable: true, get: function () { return codexRolloutOrigin_1.codexSpawnParentFromSource; } });
|
|
154
|
+
var modelInfo_1 = require("./modelInfo");
|
|
155
|
+
Object.defineProperty(exports, "getPricingCatalogInfo", { enumerable: true, get: function () { return modelInfo_1.getPricingCatalogInfo; } });
|
|
156
|
+
Object.defineProperty(exports, "registerModelPricing", { enumerable: true, get: function () { return modelInfo_1.registerModelPricing; } });
|
|
157
|
+
Object.defineProperty(exports, "clearRegisteredModelPricing", { enumerable: true, get: function () { return modelInfo_1.clearRegisteredModelPricing; } });
|
|
131
158
|
var providerServiceStatus_1 = require("./providerServiceStatus");
|
|
132
159
|
Object.defineProperty(exports, "fetchProviderServiceStatus", { enumerable: true, get: function () { return providerServiceStatus_1.fetchProviderServiceStatus; } });
|
|
133
160
|
// Tool categories across providers
|
|
@@ -145,3 +172,5 @@ var jsonlTail_1 = require("./watchers/jsonlTail");
|
|
|
145
172
|
Object.defineProperty(exports, "createJsonlTail", { enumerable: true, get: function () { return jsonlTail_1.createJsonlTail; } });
|
|
146
173
|
Object.defineProperty(exports, "DEFAULT_JSONL_TAIL_MAX_LINE_BYTES", { enumerable: true, get: function () { return jsonlTail_1.DEFAULT_JSONL_TAIL_MAX_LINE_BYTES; } });
|
|
147
174
|
Object.defineProperty(exports, "DEFAULT_JSONL_TAIL_READ_BYTES", { enumerable: true, get: function () { return jsonlTail_1.DEFAULT_JSONL_TAIL_READ_BYTES; } });
|
|
175
|
+
Object.defineProperty(exports, "JSONL_TAIL_CHECKPOINT_VERSION", { enumerable: true, get: function () { return jsonlTail_1.JSONL_TAIL_CHECKPOINT_VERSION; } });
|
|
176
|
+
Object.defineProperty(exports, "JsonlTailSymlinkError", { enumerable: true, get: function () { return jsonlTail_1.JsonlTailSymlinkError; } });
|
|
@@ -53,6 +53,37 @@ export interface CodexRolloutParserOptions {
|
|
|
53
53
|
* oldest. Bounds memory on long-running rollouts; default 4096.
|
|
54
54
|
*/
|
|
55
55
|
maxTrackedToolCalls?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Approximate bytes the parser may hold for pending tool calls: exec and
|
|
58
|
+
* MCP calls still waiting for their end event (with their buffered command
|
|
59
|
+
* or arguments) and `apply_patch` calls waiting for their output. Past the
|
|
60
|
+
* budget the oldest pending call is forgotten first, as
|
|
61
|
+
* `maxTrackedToolCalls` does by count, so its end event still emits a tool
|
|
62
|
+
* use but without the forgotten details; a single call larger than the
|
|
63
|
+
* budget is not kept at all. `getPendingStats()` counts the evictions.
|
|
64
|
+
* Default: unlimited.
|
|
65
|
+
*/
|
|
66
|
+
maxPendingBytes?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Metadata-only scan: tool-call inputs are emitted as `{}` plus the
|
|
69
|
+
* `_sidekick*` raw-name keys, tool results carry empty content (their
|
|
70
|
+
* `is_error` and `duration` are kept), reasoning is emitted with empty
|
|
71
|
+
* thinking text, and pending calls buffer no command or arguments. Tool
|
|
72
|
+
* names, ids, timestamps, models, usage, rate limits, and message text are
|
|
73
|
+
* unchanged. For cheap passes over large rollouts; default false.
|
|
74
|
+
*/
|
|
75
|
+
metadataOnly?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** Pending tool-call state counters from {@link CodexRolloutParser.getPendingStats}. */
|
|
78
|
+
export interface CodexPendingStats {
|
|
79
|
+
/** Tool calls waiting for their end or output event. */
|
|
80
|
+
pendingCalls: number;
|
|
81
|
+
/** Approximate bytes they hold; `null` unless `maxPendingBytes` is set. */
|
|
82
|
+
pendingBytes: number | null;
|
|
83
|
+
/** Pending calls forgotten because a table exceeded `maxTrackedToolCalls`. */
|
|
84
|
+
evictedByCount: number;
|
|
85
|
+
/** Pending calls forgotten because `maxPendingBytes` was exceeded. */
|
|
86
|
+
evictedByBytes: number;
|
|
56
87
|
}
|
|
57
88
|
/**
|
|
58
89
|
* Stateful parser for Codex JSONL rollout lines.
|
|
@@ -78,7 +109,17 @@ export declare class CodexRolloutParser {
|
|
|
78
109
|
private emittedToolUseIds;
|
|
79
110
|
private patchExpandedToolUseIds;
|
|
80
111
|
private readonly maxTrackedToolCalls;
|
|
112
|
+
/** Byte budget for pending calls; `null` = unlimited (no accounting). */
|
|
113
|
+
private readonly maxPendingBytes;
|
|
114
|
+
private readonly metadataOnly;
|
|
115
|
+
/** Pending calls in insertion order, for the byte budget. */
|
|
116
|
+
private pendingLedger;
|
|
117
|
+
private pendingBytes;
|
|
118
|
+
private evictedByCount;
|
|
119
|
+
private evictedByBytes;
|
|
81
120
|
constructor(options?: CodexRolloutParserOptions);
|
|
121
|
+
/** Counters for the pending tool-call state and what the caps evicted. */
|
|
122
|
+
getPendingStats(): CodexPendingStats;
|
|
82
123
|
/** Get stored session metadata. */
|
|
83
124
|
getSessionMeta(): CodexSessionMeta | null;
|
|
84
125
|
/** Get current model from turn_context. */
|
|
@@ -95,6 +136,20 @@ export declare class CodexRolloutParser {
|
|
|
95
136
|
convertLine(line: CodexRolloutLine): SessionEvent[];
|
|
96
137
|
/** Reset all parser state. */
|
|
97
138
|
reset(): void;
|
|
139
|
+
/**
|
|
140
|
+
* Stores a pending call, refreshing its position, then enforces the count
|
|
141
|
+
* cap on its table and the byte budget across all pending tables, oldest
|
|
142
|
+
* first.
|
|
143
|
+
*/
|
|
144
|
+
private putPending;
|
|
145
|
+
/** Removes and returns a pending call. */
|
|
146
|
+
private takePending;
|
|
147
|
+
private forgetPendingBytes;
|
|
148
|
+
private ledgerKey;
|
|
149
|
+
/** The emitted tool input: unchanged, or only its `_sidekick*` keys in metadata-only mode. */
|
|
150
|
+
private toolInput;
|
|
151
|
+
/** The emitted tool-result content: unchanged, or empty in metadata-only mode. */
|
|
152
|
+
private toolOutput;
|
|
98
153
|
private handleSessionMeta;
|
|
99
154
|
private handleResponseItem;
|
|
100
155
|
private handleMessage;
|
|
@@ -178,6 +178,10 @@ function extractPatchFilePaths(input) {
|
|
|
178
178
|
}
|
|
179
179
|
/** Default cap on each piece of per-call correlation state the parser keeps. */
|
|
180
180
|
exports.DEFAULT_MAX_TRACKED_TOOL_CALLS = 4096;
|
|
181
|
+
/** Fixed per-entry cost added to each pending call's byte estimate. */
|
|
182
|
+
const PENDING_ENTRY_OVERHEAD_BYTES = 64;
|
|
183
|
+
/** Prefix of the bookkeeping keys the parser stashes inside tool inputs. */
|
|
184
|
+
const SIDEKICK_INPUT_KEY_PREFIX = '_sidekick';
|
|
181
185
|
/** Adds `key`, refreshing its position, and evicts the oldest past `max`. */
|
|
182
186
|
function rememberBounded(set, key, max) {
|
|
183
187
|
set.delete(key);
|
|
@@ -185,12 +189,31 @@ function rememberBounded(set, key, max) {
|
|
|
185
189
|
while (set.size > max)
|
|
186
190
|
set.delete(set.values().next().value);
|
|
187
191
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
function stringBytes(...values) {
|
|
193
|
+
let total = 0;
|
|
194
|
+
for (const value of values)
|
|
195
|
+
if (typeof value === 'string')
|
|
196
|
+
total += value.length;
|
|
197
|
+
return total;
|
|
198
|
+
}
|
|
199
|
+
function approxJsonBytes(value) {
|
|
200
|
+
if (value === undefined)
|
|
201
|
+
return 0;
|
|
202
|
+
try {
|
|
203
|
+
return JSON.stringify(value)?.length ?? 0;
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** Only the `_sidekick*` bookkeeping keys of a tool input. */
|
|
210
|
+
function sidekickKeysOnly(input) {
|
|
211
|
+
const kept = {};
|
|
212
|
+
for (const key of Object.keys(input)) {
|
|
213
|
+
if (key.startsWith(SIDEKICK_INPUT_KEY_PREFIX))
|
|
214
|
+
kept[key] = input[key];
|
|
215
|
+
}
|
|
216
|
+
return kept;
|
|
194
217
|
}
|
|
195
218
|
/**
|
|
196
219
|
* Stateful parser for Codex JSONL rollout lines.
|
|
@@ -216,10 +239,35 @@ class CodexRolloutParser {
|
|
|
216
239
|
emittedToolUseIds = new Set();
|
|
217
240
|
patchExpandedToolUseIds = new Map();
|
|
218
241
|
maxTrackedToolCalls;
|
|
242
|
+
/** Byte budget for pending calls; `null` = unlimited (no accounting). */
|
|
243
|
+
maxPendingBytes;
|
|
244
|
+
metadataOnly;
|
|
245
|
+
/** Pending calls in insertion order, for the byte budget. */
|
|
246
|
+
pendingLedger = new Map();
|
|
247
|
+
pendingBytes = 0;
|
|
248
|
+
evictedByCount = 0;
|
|
249
|
+
evictedByBytes = 0;
|
|
219
250
|
constructor(options = {}) {
|
|
220
251
|
const max = options.maxTrackedToolCalls;
|
|
221
252
|
this.maxTrackedToolCalls =
|
|
222
253
|
typeof max === 'number' && max >= 1 ? Math.floor(max) : exports.DEFAULT_MAX_TRACKED_TOOL_CALLS;
|
|
254
|
+
const maxBytes = options.maxPendingBytes;
|
|
255
|
+
this.maxPendingBytes =
|
|
256
|
+
typeof maxBytes === 'number' && Number.isFinite(maxBytes) && maxBytes >= 1
|
|
257
|
+
? Math.floor(maxBytes)
|
|
258
|
+
: null;
|
|
259
|
+
this.metadataOnly = options.metadataOnly === true;
|
|
260
|
+
}
|
|
261
|
+
/** Counters for the pending tool-call state and what the caps evicted. */
|
|
262
|
+
getPendingStats() {
|
|
263
|
+
return {
|
|
264
|
+
pendingCalls: this.pendingExecCommands.size +
|
|
265
|
+
this.pendingMcpToolCalls.size +
|
|
266
|
+
this.patchExpandedToolUseIds.size,
|
|
267
|
+
pendingBytes: this.maxPendingBytes === null ? null : this.pendingBytes,
|
|
268
|
+
evictedByCount: this.evictedByCount,
|
|
269
|
+
evictedByBytes: this.evictedByBytes,
|
|
270
|
+
};
|
|
223
271
|
}
|
|
224
272
|
/** Get stored session metadata. */
|
|
225
273
|
getSessionMeta() {
|
|
@@ -274,6 +322,72 @@ class CodexRolloutParser {
|
|
|
274
322
|
this.inPlanMode = false;
|
|
275
323
|
this.emittedToolUseIds.clear();
|
|
276
324
|
this.patchExpandedToolUseIds.clear();
|
|
325
|
+
this.pendingLedger.clear();
|
|
326
|
+
this.pendingBytes = 0;
|
|
327
|
+
this.evictedByCount = 0;
|
|
328
|
+
this.evictedByBytes = 0;
|
|
329
|
+
}
|
|
330
|
+
// --- Pending call state ---
|
|
331
|
+
/**
|
|
332
|
+
* Stores a pending call, refreshing its position, then enforces the count
|
|
333
|
+
* cap on its table and the byte budget across all pending tables, oldest
|
|
334
|
+
* first.
|
|
335
|
+
*/
|
|
336
|
+
putPending(table, callId, value, estimateBytes) {
|
|
337
|
+
this.forgetPendingBytes(table, callId);
|
|
338
|
+
table.delete(callId);
|
|
339
|
+
table.set(callId, value);
|
|
340
|
+
while (table.size > this.maxTrackedToolCalls) {
|
|
341
|
+
const oldest = table.keys().next().value;
|
|
342
|
+
table.delete(oldest);
|
|
343
|
+
this.forgetPendingBytes(table, oldest);
|
|
344
|
+
this.evictedByCount += 1;
|
|
345
|
+
}
|
|
346
|
+
if (this.maxPendingBytes === null)
|
|
347
|
+
return;
|
|
348
|
+
const bytes = PENDING_ENTRY_OVERHEAD_BYTES + estimateBytes();
|
|
349
|
+
this.pendingLedger.set(this.ledgerKey(table, callId), {
|
|
350
|
+
table: table,
|
|
351
|
+
callId,
|
|
352
|
+
bytes,
|
|
353
|
+
});
|
|
354
|
+
this.pendingBytes += bytes;
|
|
355
|
+
while (this.pendingBytes > this.maxPendingBytes && this.pendingLedger.size > 0) {
|
|
356
|
+
const [key, oldest] = this.pendingLedger.entries().next().value;
|
|
357
|
+
this.pendingLedger.delete(key);
|
|
358
|
+
this.pendingBytes -= oldest.bytes;
|
|
359
|
+
oldest.table.delete(oldest.callId);
|
|
360
|
+
this.evictedByBytes += 1;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/** Removes and returns a pending call. */
|
|
364
|
+
takePending(table, callId) {
|
|
365
|
+
const value = table.get(callId);
|
|
366
|
+
table.delete(callId);
|
|
367
|
+
this.forgetPendingBytes(table, callId);
|
|
368
|
+
return value;
|
|
369
|
+
}
|
|
370
|
+
forgetPendingBytes(table, callId) {
|
|
371
|
+
if (this.maxPendingBytes === null)
|
|
372
|
+
return;
|
|
373
|
+
const key = this.ledgerKey(table, callId);
|
|
374
|
+
const entry = this.pendingLedger.get(key);
|
|
375
|
+
if (!entry)
|
|
376
|
+
return;
|
|
377
|
+
this.pendingLedger.delete(key);
|
|
378
|
+
this.pendingBytes -= entry.bytes;
|
|
379
|
+
}
|
|
380
|
+
ledgerKey(table, callId) {
|
|
381
|
+
const kind = table === this.pendingExecCommands ? 'e' : table === this.pendingMcpToolCalls ? 'm' : 'p';
|
|
382
|
+
return `${kind}\u0000${callId}`;
|
|
383
|
+
}
|
|
384
|
+
/** The emitted tool input: unchanged, or only its `_sidekick*` keys in metadata-only mode. */
|
|
385
|
+
toolInput(input) {
|
|
386
|
+
return this.metadataOnly ? sidekickKeysOnly(input) : input;
|
|
387
|
+
}
|
|
388
|
+
/** The emitted tool-result content: unchanged, or empty in metadata-only mode. */
|
|
389
|
+
toolOutput(content) {
|
|
390
|
+
return this.metadataOnly ? '' : content;
|
|
277
391
|
}
|
|
278
392
|
// --- Handlers ---
|
|
279
393
|
handleSessionMeta(timestamp, payload) {
|
|
@@ -380,7 +494,9 @@ class CodexRolloutParser {
|
|
|
380
494
|
role: 'assistant',
|
|
381
495
|
id: item.id,
|
|
382
496
|
model: this.currentModel || undefined,
|
|
383
|
-
content: [
|
|
497
|
+
content: [
|
|
498
|
+
{ type: 'thinking', thinking: this.metadataOnly ? '' : summaryTexts.join('\n') },
|
|
499
|
+
],
|
|
384
500
|
},
|
|
385
501
|
timestamp,
|
|
386
502
|
},
|
|
@@ -388,11 +504,13 @@ class CodexRolloutParser {
|
|
|
388
504
|
}
|
|
389
505
|
handleFunctionCall(timestamp, item) {
|
|
390
506
|
let parsedArgs = {};
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
507
|
+
if (!this.metadataOnly) {
|
|
508
|
+
try {
|
|
509
|
+
parsedArgs = JSON.parse(item.arguments);
|
|
510
|
+
}
|
|
511
|
+
catch {
|
|
512
|
+
parsedArgs = { raw: item.arguments };
|
|
513
|
+
}
|
|
396
514
|
}
|
|
397
515
|
const canonicalName = normalizeCodexToolName(item.name);
|
|
398
516
|
const normalizedInput = normalizeCodexToolInput(canonicalName, item.name, parsedArgs);
|
|
@@ -409,7 +527,7 @@ class CodexRolloutParser {
|
|
|
409
527
|
type: 'tool_use',
|
|
410
528
|
id: item.call_id,
|
|
411
529
|
name: canonicalName,
|
|
412
|
-
input: normalizedInput,
|
|
530
|
+
input: this.toolInput(normalizedInput),
|
|
413
531
|
},
|
|
414
532
|
],
|
|
415
533
|
},
|
|
@@ -429,7 +547,7 @@ class CodexRolloutParser {
|
|
|
429
547
|
{
|
|
430
548
|
type: 'tool_result',
|
|
431
549
|
tool_use_id: item.call_id,
|
|
432
|
-
content: item.output,
|
|
550
|
+
content: this.toolOutput(item.output),
|
|
433
551
|
is_error: isError,
|
|
434
552
|
},
|
|
435
553
|
],
|
|
@@ -453,11 +571,11 @@ class CodexRolloutParser {
|
|
|
453
571
|
type: 'tool_use',
|
|
454
572
|
id: item.call_id,
|
|
455
573
|
name: 'Bash',
|
|
456
|
-
input: {
|
|
574
|
+
input: this.toolInput({
|
|
457
575
|
command,
|
|
458
576
|
workdir: item.action?.workdir,
|
|
459
577
|
_sidekickRawToolName: 'local_shell_call',
|
|
460
|
-
},
|
|
578
|
+
}),
|
|
461
579
|
},
|
|
462
580
|
],
|
|
463
581
|
},
|
|
@@ -471,7 +589,7 @@ class CodexRolloutParser {
|
|
|
471
589
|
if (filePaths.length === 0)
|
|
472
590
|
return [];
|
|
473
591
|
const toolUseIds = filePaths.map((fp) => `${item.call_id}-${fp}`);
|
|
474
|
-
|
|
592
|
+
this.putPending(this.patchExpandedToolUseIds, item.call_id, toolUseIds, () => stringBytes(item.call_id, ...toolUseIds));
|
|
475
593
|
for (const id of toolUseIds) {
|
|
476
594
|
rememberBounded(this.emittedToolUseIds, id, this.maxTrackedToolCalls);
|
|
477
595
|
}
|
|
@@ -486,10 +604,10 @@ class CodexRolloutParser {
|
|
|
486
604
|
type: 'tool_use',
|
|
487
605
|
id: `${item.call_id}-${fp}`,
|
|
488
606
|
name: 'Edit',
|
|
489
|
-
input: {
|
|
607
|
+
input: this.toolInput({
|
|
490
608
|
file_path: fp,
|
|
491
609
|
_sidekickRawToolName: 'apply_patch',
|
|
492
|
-
},
|
|
610
|
+
}),
|
|
493
611
|
},
|
|
494
612
|
],
|
|
495
613
|
},
|
|
@@ -497,12 +615,14 @@ class CodexRolloutParser {
|
|
|
497
615
|
}));
|
|
498
616
|
}
|
|
499
617
|
// Generic custom tool
|
|
500
|
-
let parsedInput;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
618
|
+
let parsedInput = {};
|
|
619
|
+
if (!this.metadataOnly) {
|
|
620
|
+
try {
|
|
621
|
+
parsedInput = JSON.parse(item.input);
|
|
622
|
+
}
|
|
623
|
+
catch {
|
|
624
|
+
parsedInput = { raw: item.input };
|
|
625
|
+
}
|
|
506
626
|
}
|
|
507
627
|
const canonicalName = normalizeCodexToolName(item.name);
|
|
508
628
|
const normalizedInput = normalizeCodexToolInput(canonicalName, item.name, parsedInput);
|
|
@@ -519,7 +639,7 @@ class CodexRolloutParser {
|
|
|
519
639
|
type: 'tool_use',
|
|
520
640
|
id: item.call_id,
|
|
521
641
|
name: canonicalName,
|
|
522
|
-
input: normalizedInput,
|
|
642
|
+
input: this.toolInput(normalizedInput),
|
|
523
643
|
},
|
|
524
644
|
],
|
|
525
645
|
},
|
|
@@ -540,8 +660,9 @@ class CodexRolloutParser {
|
|
|
540
660
|
catch {
|
|
541
661
|
isError = parsePlainTextFailure(item.output);
|
|
542
662
|
}
|
|
543
|
-
const toolUseIds = this.patchExpandedToolUseIds
|
|
544
|
-
|
|
663
|
+
const toolUseIds = this.takePending(this.patchExpandedToolUseIds, item.call_id) ?? [
|
|
664
|
+
item.call_id,
|
|
665
|
+
];
|
|
545
666
|
return toolUseIds.map((toolUseId) => ({
|
|
546
667
|
type: 'user',
|
|
547
668
|
message: {
|
|
@@ -551,7 +672,7 @@ class CodexRolloutParser {
|
|
|
551
672
|
{
|
|
552
673
|
type: 'tool_result',
|
|
553
674
|
tool_use_id: toolUseId,
|
|
554
|
-
content: item.output,
|
|
675
|
+
content: this.toolOutput(item.output),
|
|
555
676
|
is_error: isError,
|
|
556
677
|
duration,
|
|
557
678
|
},
|
|
@@ -615,18 +736,15 @@ class CodexRolloutParser {
|
|
|
615
736
|
// response_item/message events which carry richer metadata (id, content parts, role).
|
|
616
737
|
case 'exec_command_begin': {
|
|
617
738
|
const e = event;
|
|
618
|
-
|
|
619
|
-
call_id: e.call_id,
|
|
620
|
-
command: e.command,
|
|
621
|
-
|
|
622
|
-
timestamp,
|
|
623
|
-
}, this.maxTrackedToolCalls);
|
|
739
|
+
const pending = this.metadataOnly
|
|
740
|
+
? { call_id: e.call_id, command: [], timestamp }
|
|
741
|
+
: { call_id: e.call_id, command: e.command, workdir: e.workdir, timestamp };
|
|
742
|
+
this.putPending(this.pendingExecCommands, e.call_id, pending, () => stringBytes(pending.call_id, pending.workdir, pending.timestamp, ...(Array.isArray(pending.command) ? pending.command : [])));
|
|
624
743
|
return [];
|
|
625
744
|
}
|
|
626
745
|
case 'exec_command_end': {
|
|
627
746
|
const e = event;
|
|
628
|
-
const pending = this.pendingExecCommands
|
|
629
|
-
this.pendingExecCommands.delete(e.call_id);
|
|
747
|
+
const pending = this.takePending(this.pendingExecCommands, e.call_id);
|
|
630
748
|
const command = pending?.command?.join(' ') || '';
|
|
631
749
|
const events = [];
|
|
632
750
|
if (!this.emittedToolUseIds.has(e.call_id)) {
|
|
@@ -642,18 +760,20 @@ class CodexRolloutParser {
|
|
|
642
760
|
type: 'tool_use',
|
|
643
761
|
id: e.call_id,
|
|
644
762
|
name: 'Bash',
|
|
645
|
-
input: {
|
|
763
|
+
input: this.toolInput({
|
|
646
764
|
command,
|
|
647
765
|
workdir: pending?.workdir,
|
|
648
766
|
_sidekickRawToolName: 'exec_command',
|
|
649
|
-
},
|
|
767
|
+
}),
|
|
650
768
|
},
|
|
651
769
|
],
|
|
652
770
|
},
|
|
653
771
|
timestamp: pending?.timestamp || timestamp,
|
|
654
772
|
});
|
|
655
773
|
}
|
|
656
|
-
const output =
|
|
774
|
+
const output = this.metadataOnly
|
|
775
|
+
? ''
|
|
776
|
+
: [e.stdout, e.stderr].filter(Boolean).join('\n') || '';
|
|
657
777
|
events.push({
|
|
658
778
|
type: 'user',
|
|
659
779
|
message: {
|
|
@@ -675,19 +795,20 @@ class CodexRolloutParser {
|
|
|
675
795
|
}
|
|
676
796
|
case 'mcp_tool_call_begin': {
|
|
677
797
|
const e = event;
|
|
678
|
-
|
|
798
|
+
const pending = {
|
|
679
799
|
call_id: e.call_id,
|
|
680
800
|
server_name: e.server_name,
|
|
681
801
|
tool_name: e.tool_name,
|
|
682
|
-
arguments: e.arguments,
|
|
802
|
+
arguments: this.metadataOnly ? undefined : e.arguments,
|
|
683
803
|
timestamp,
|
|
684
|
-
}
|
|
804
|
+
};
|
|
805
|
+
this.putPending(this.pendingMcpToolCalls, e.call_id, pending, () => stringBytes(pending.call_id, pending.server_name, pending.tool_name, timestamp) +
|
|
806
|
+
approxJsonBytes(pending.arguments));
|
|
685
807
|
return [];
|
|
686
808
|
}
|
|
687
809
|
case 'mcp_tool_call_end': {
|
|
688
810
|
const e = event;
|
|
689
|
-
const pendingMcp = this.pendingMcpToolCalls
|
|
690
|
-
this.pendingMcpToolCalls.delete(e.call_id);
|
|
811
|
+
const pendingMcp = this.takePending(this.pendingMcpToolCalls, e.call_id);
|
|
691
812
|
const toolName = pendingMcp?.tool_name || 'McpTool';
|
|
692
813
|
const events = [];
|
|
693
814
|
if (!this.emittedToolUseIds.has(e.call_id)) {
|
|
@@ -703,11 +824,11 @@ class CodexRolloutParser {
|
|
|
703
824
|
type: 'tool_use',
|
|
704
825
|
id: e.call_id,
|
|
705
826
|
name: normalizeCodexToolName(toolName),
|
|
706
|
-
input: {
|
|
827
|
+
input: this.toolInput({
|
|
707
828
|
...(pendingMcp?.arguments || {}),
|
|
708
829
|
_sidekickRawToolName: toolName,
|
|
709
830
|
_sidekickMcpServerName: pendingMcp?.server_name,
|
|
710
|
-
},
|
|
831
|
+
}),
|
|
711
832
|
},
|
|
712
833
|
],
|
|
713
834
|
},
|
|
@@ -723,7 +844,7 @@ class CodexRolloutParser {
|
|
|
723
844
|
{
|
|
724
845
|
type: 'tool_result',
|
|
725
846
|
tool_use_id: e.call_id,
|
|
726
|
-
content: e.result || '',
|
|
847
|
+
content: this.toolOutput(e.result || ''),
|
|
727
848
|
is_error: e.is_error || false,
|
|
728
849
|
duration: e.duration_ms,
|
|
729
850
|
},
|
|
@@ -782,12 +903,12 @@ class CodexRolloutParser {
|
|
|
782
903
|
type: 'tool_use',
|
|
783
904
|
id: patchId,
|
|
784
905
|
name: 'Edit',
|
|
785
|
-
input: {
|
|
906
|
+
input: this.toolInput({
|
|
786
907
|
file_path: e.file_path,
|
|
787
908
|
additions: e.additions ?? 0,
|
|
788
909
|
deletions: e.deletions ?? 0,
|
|
789
910
|
_sidekickRawToolName: 'patch_applied',
|
|
790
|
-
},
|
|
911
|
+
}),
|
|
791
912
|
},
|
|
792
913
|
],
|
|
793
914
|
},
|
|
@@ -814,10 +935,10 @@ class CodexRolloutParser {
|
|
|
814
935
|
type: 'tool_use',
|
|
815
936
|
id: `plan-enter-${timestamp}`,
|
|
816
937
|
name: 'EnterPlanMode',
|
|
817
|
-
input: {
|
|
938
|
+
input: this.toolInput({
|
|
818
939
|
source: 'codex_task_started',
|
|
819
940
|
_sidekickRawToolName: 'task_started',
|
|
820
|
-
},
|
|
941
|
+
}),
|
|
821
942
|
},
|
|
822
943
|
],
|
|
823
944
|
},
|
|
@@ -841,10 +962,10 @@ class CodexRolloutParser {
|
|
|
841
962
|
type: 'tool_use',
|
|
842
963
|
id: `plan-exit-${timestamp}`,
|
|
843
964
|
name: 'ExitPlanMode',
|
|
844
|
-
input: {
|
|
965
|
+
input: this.toolInput({
|
|
845
966
|
source: 'codex_task_complete',
|
|
846
967
|
_sidekickRawToolName: 'task_complete',
|
|
847
|
-
},
|
|
968
|
+
}),
|
|
848
969
|
},
|
|
849
970
|
],
|
|
850
971
|
},
|