@codex-app-sdk/backend 0.17.0 → 0.18.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/dist/chunks/{codex-DzX6RrF2.js → codex-CmHW3ikB.js} +14 -17
- package/dist/chunks/codex-CmHW3ikB.js.map +1 -0
- package/dist/codex/client.d.ts.map +1 -1
- package/dist/codex/generated/ClientRequest.d.ts +81 -5
- package/dist/codex/generated/ClientRequest.d.ts.map +1 -1
- package/dist/codex/generated/ContentItem.d.ts +6 -1
- package/dist/codex/generated/ContentItem.d.ts.map +1 -1
- package/dist/codex/generated/FunctionCallOutputContentItem.d.ts +4 -1
- package/dist/codex/generated/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/dist/codex/generated/ImageGenerationInputImage.d.ts +12 -0
- package/dist/codex/generated/ImageGenerationInputImage.d.ts.map +1 -0
- package/dist/codex/generated/ImageGenerationItem.d.ts +10 -2
- package/dist/codex/generated/ImageGenerationItem.d.ts.map +1 -1
- package/dist/codex/generated/InitializeCapabilities.d.ts +5 -0
- package/dist/codex/generated/InitializeCapabilities.d.ts.map +1 -1
- package/dist/codex/generated/MessagePhase.d.ts +2 -2
- package/dist/codex/generated/MessagePhase.d.ts.map +1 -1
- package/dist/codex/generated/Personality.d.ts +3 -0
- package/dist/codex/generated/Personality.d.ts.map +1 -1
- package/dist/codex/generated/PlanType.d.ts +1 -1
- package/dist/codex/generated/PlanType.d.ts.map +1 -1
- package/dist/codex/generated/RealtimeVoice.d.ts +1 -1
- package/dist/codex/generated/RealtimeVoice.d.ts.map +1 -1
- package/dist/codex/generated/RealtimeVoicesList.d.ts +1 -0
- package/dist/codex/generated/RealtimeVoicesList.d.ts.map +1 -1
- package/dist/codex/generated/ResponseItem.d.ts +14 -0
- package/dist/codex/generated/ResponseItem.d.ts.map +1 -1
- package/dist/codex/generated/ServerNotification.d.ts +16 -0
- package/dist/codex/generated/ServerNotification.d.ts.map +1 -1
- package/dist/codex/generated/ServerNotificationEnvelope.d.ts +16 -0
- package/dist/codex/generated/ServerNotificationEnvelope.d.ts.map +1 -1
- package/dist/codex/generated/ToolExposureSurface.d.ts +5 -0
- package/dist/codex/generated/ToolExposureSurface.d.ts.map +1 -0
- package/dist/codex/generated/index.d.ts +2 -0
- package/dist/codex/generated/index.d.ts.map +1 -1
- package/dist/codex/generated/v2/AccountRoutingOverride.d.ts +5 -0
- package/dist/codex/generated/v2/AccountRoutingOverride.d.ts.map +1 -0
- package/dist/codex/generated/v2/ApplicationRequirements.d.ts +2 -0
- package/dist/codex/generated/v2/ApplicationRequirements.d.ts.map +1 -1
- package/dist/codex/generated/v2/ApplicationStorageRequirements.d.ts +9 -0
- package/dist/codex/generated/v2/ApplicationStorageRequirements.d.ts.map +1 -0
- package/dist/codex/generated/v2/AppsConfig.d.ts +5 -0
- package/dist/codex/generated/v2/AppsConfig.d.ts.map +1 -1
- package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsParams.d.ts +2 -0
- package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsResponse.d.ts +15 -0
- package/dist/codex/generated/v2/BedrockCheckGovCloudRequirementsResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/BrowserUseExtensionRequirements.d.ts +5 -0
- package/dist/codex/generated/v2/BrowserUseExtensionRequirements.d.ts.map +1 -0
- package/dist/codex/generated/v2/BrowserUseRequirements.d.ts +2 -0
- package/dist/codex/generated/v2/BrowserUseRequirements.d.ts.map +1 -1
- package/dist/codex/generated/v2/CodexErrorInfo.d.ts +4 -2
- package/dist/codex/generated/v2/CodexErrorInfo.d.ts.map +1 -1
- package/dist/codex/generated/v2/ConfigBatchWriteParams.d.ts +2 -2
- package/dist/codex/generated/v2/ConfigRequirements.d.ts +19 -3
- package/dist/codex/generated/v2/ConfigRequirements.d.ts.map +1 -1
- package/dist/codex/generated/v2/ConfigRequirementsReadResponse.d.ts +5 -0
- package/dist/codex/generated/v2/ConfigRequirementsReadResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/CyberAccessProgram.d.ts +1 -1
- package/dist/codex/generated/v2/EnvironmentAddParams.d.ts +15 -0
- package/dist/codex/generated/v2/EnvironmentAddParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/EnvironmentSkillsParams.d.ts +7 -0
- package/dist/codex/generated/v2/EnvironmentSkillsParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/FeedbackSaveParams.d.ts +17 -0
- package/dist/codex/generated/v2/FeedbackSaveParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/FeedbackSaveResponse.d.ts +10 -0
- package/dist/codex/generated/v2/FeedbackSaveResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/FeedbackUploadResponse.d.ts +6 -0
- package/dist/codex/generated/v2/FeedbackUploadResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/GatewayOAuthCancelResponse.d.ts +2 -0
- package/dist/codex/generated/v2/GatewayOAuthCancelResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/GatewayOAuthChangedNotification.d.ts +11 -0
- package/dist/codex/generated/v2/GatewayOAuthChangedNotification.d.ts.map +1 -0
- package/dist/codex/generated/v2/GatewayOAuthLoginResponse.d.ts +2 -0
- package/dist/codex/generated/v2/GatewayOAuthLoginResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/GatewayOAuthReadResponse.d.ts +18 -0
- package/dist/codex/generated/v2/GatewayOAuthReadResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/GatewayOAuthStatus.d.ts +2 -0
- package/dist/codex/generated/v2/GatewayOAuthStatus.d.ts.map +1 -0
- package/dist/codex/generated/v2/GetAccountResponse.d.ts +2 -0
- package/dist/codex/generated/v2/GetAccountResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/HookEventName.d.ts +1 -1
- package/dist/codex/generated/v2/HookEventName.d.ts.map +1 -1
- package/dist/codex/generated/v2/ListMcpServerStatusParams.d.ts +4 -0
- package/dist/codex/generated/v2/ListMcpServerStatusParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ManagedHooksRequirements.d.ts +2 -0
- package/dist/codex/generated/v2/ManagedHooksRequirements.d.ts.map +1 -1
- package/dist/codex/generated/v2/McpAppDisplayMode.d.ts +2 -0
- package/dist/codex/generated/v2/McpAppDisplayMode.d.ts.map +1 -0
- package/dist/codex/generated/v2/McpAppUi.d.ts +9 -0
- package/dist/codex/generated/v2/McpAppUi.d.ts.map +1 -0
- package/dist/codex/generated/v2/McpResourceReadParams.d.ts +5 -0
- package/dist/codex/generated/v2/McpResourceReadParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/McpResourceReadTarget.d.ts +8 -0
- package/dist/codex/generated/v2/McpResourceReadTarget.d.ts.map +1 -0
- package/dist/codex/generated/v2/McpServerElicitationRequestParams.d.ts +1 -0
- package/dist/codex/generated/v2/McpServerElicitationRequestParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/McpServerOauthLoginCompletedNotification.d.ts +4 -0
- package/dist/codex/generated/v2/McpServerOauthLoginCompletedNotification.d.ts.map +1 -1
- package/dist/codex/generated/v2/McpServerOauthLoginResponse.d.ts +5 -0
- package/dist/codex/generated/v2/McpServerOauthLoginResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/McpServerStatus.d.ts +14 -0
- package/dist/codex/generated/v2/McpServerStatus.d.ts.map +1 -1
- package/dist/codex/generated/v2/MemoryStatusParams.d.ts +7 -0
- package/dist/codex/generated/v2/MemoryStatusParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/MemoryStatusResponse.d.ts +5 -0
- package/dist/codex/generated/v2/MemoryStatusResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/MisalignmentErrorDetails.d.ts +4 -0
- package/dist/codex/generated/v2/MisalignmentErrorDetails.d.ts.map +1 -1
- package/dist/codex/generated/v2/Model.d.ts +8 -0
- package/dist/codex/generated/v2/Model.d.ts.map +1 -1
- package/dist/codex/generated/v2/ModelAccessPrograms.d.ts +11 -0
- package/dist/codex/generated/v2/ModelAccessPrograms.d.ts.map +1 -0
- package/dist/codex/generated/v2/ModelProviderCapabilitiesReadResponse.d.ts +0 -1
- package/dist/codex/generated/v2/ModelProviderCapabilitiesReadResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/PluginDetail.d.ts +4 -0
- package/dist/codex/generated/v2/PluginDetail.d.ts.map +1 -1
- package/dist/codex/generated/v2/RequestHeader.d.ts +5 -0
- package/dist/codex/generated/v2/RequestHeader.d.ts.map +1 -0
- package/dist/codex/generated/v2/RolloutCompressResponse.d.ts +6 -0
- package/dist/codex/generated/v2/RolloutCompressResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/SkillMetadata.d.ts +2 -2
- package/dist/codex/generated/v2/SkillMetadata.d.ts.map +1 -1
- package/dist/codex/generated/v2/SkillSummary.d.ts +2 -2
- package/dist/codex/generated/v2/SkillSummary.d.ts.map +1 -1
- package/dist/codex/generated/v2/Thread.d.ts +1 -1
- package/dist/codex/generated/v2/ThreadAttachment.d.ts +12 -0
- package/dist/codex/generated/v2/ThreadAttachment.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentAddOutcome.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadAttachmentAddOutcome.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentAddParams.d.ts +11 -0
- package/dist/codex/generated/v2/ThreadAttachmentAddParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentAddResponse.d.ts +10 -0
- package/dist/codex/generated/v2/ThreadAttachmentAddResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentListParams.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadAttachmentListParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentListResponse.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadAttachmentListResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentOperation.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadAttachmentOperation.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentOwner.d.ts +11 -0
- package/dist/codex/generated/v2/ThreadAttachmentOwner.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentOwnerListParams.d.ts +14 -0
- package/dist/codex/generated/v2/ThreadAttachmentOwnerListParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentOwnerListResponse.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadAttachmentOwnerListResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentRemoveParams.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadAttachmentRemoveParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentRemoveResponse.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadAttachmentRemoveResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadAttachmentUpdatedNotification.d.ts +12 -0
- package/dist/codex/generated/v2/ThreadAttachmentUpdatedNotification.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadForkParams.d.ts +13 -0
- package/dist/codex/generated/v2/ThreadForkParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadForkResponse.d.ts +4 -0
- package/dist/codex/generated/v2/ThreadForkResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadGoalClearParams.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadGoalClearParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadGoalMutationOrigin.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadGoalMutationOrigin.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadGoalSetParams.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadGoalSetParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadItem.d.ts +14 -1
- package/dist/codex/generated/v2/ThreadItem.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadItemEntry.d.ts +8 -0
- package/dist/codex/generated/v2/ThreadItemEntry.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadItemsListAnchor.d.ts +8 -0
- package/dist/codex/generated/v2/ThreadItemsListAnchor.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadItemsListCursor.d.ts +6 -0
- package/dist/codex/generated/v2/ThreadItemsListCursor.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadItemsListParams.d.ts +5 -2
- package/dist/codex/generated/v2/ThreadItemsListParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadItemsReadParams.d.ts +12 -0
- package/dist/codex/generated/v2/ThreadItemsReadParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadItemsReadResponse.d.ts +8 -0
- package/dist/codex/generated/v2/ThreadItemsReadResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadListParams.d.ts +6 -0
- package/dist/codex/generated/v2/ThreadListParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadListResponse.d.ts +8 -0
- package/dist/codex/generated/v2/ThreadListResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadPredictionRequestParams.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadPredictionRequestParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadPredictionRequestResponse.d.ts +2 -0
- package/dist/codex/generated/v2/ThreadPredictionRequestResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadPredictionResult.d.ts +7 -0
- package/dist/codex/generated/v2/ThreadPredictionResult.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadPredictionUpdatedNotification.d.ts +7 -0
- package/dist/codex/generated/v2/ThreadPredictionUpdatedNotification.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadReadResponse.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadReadResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadReadState.d.ts +10 -0
- package/dist/codex/generated/v2/ThreadReadState.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadReadStateChangedNotification.d.ts +6 -0
- package/dist/codex/generated/v2/ThreadReadStateChangedNotification.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadReadStateOperation.d.ts +6 -0
- package/dist/codex/generated/v2/ThreadReadStateOperation.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadReadStateUpdateParams.d.ts +10 -0
- package/dist/codex/generated/v2/ThreadReadStateUpdateParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadReadStateUpdateResponse.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadReadStateUpdateResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadRealtimeStartParams.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadRealtimeStartParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadResumeParams.d.ts +4 -0
- package/dist/codex/generated/v2/ThreadResumeParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadResumeResponse.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadResumeResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadSampleCancelParams.d.ts +5 -0
- package/dist/codex/generated/v2/ThreadSampleCancelParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadSampleCancelResponse.d.ts +2 -0
- package/dist/codex/generated/v2/ThreadSampleCancelResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadSampleParams.d.ts +26 -0
- package/dist/codex/generated/v2/ThreadSampleParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadSampleResponse.d.ts +12 -0
- package/dist/codex/generated/v2/ThreadSampleResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/ThreadSearchOccurrencesParams.d.ts +2 -2
- package/dist/codex/generated/v2/ThreadSettings.d.ts +7 -0
- package/dist/codex/generated/v2/ThreadSettings.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadSettingsUpdateParams.d.ts +7 -1
- package/dist/codex/generated/v2/ThreadSettingsUpdateParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadStartParams.d.ts +9 -0
- package/dist/codex/generated/v2/ThreadStartParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadStartResponse.d.ts +4 -0
- package/dist/codex/generated/v2/ThreadStartResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/ThreadUnreadPosition.d.ts +7 -0
- package/dist/codex/generated/v2/ThreadUnreadPosition.d.ts.map +1 -0
- package/dist/codex/generated/v2/Turn.d.ts +7 -1
- package/dist/codex/generated/v2/Turn.d.ts.map +1 -1
- package/dist/codex/generated/v2/TurnStartParams.d.ts +33 -2
- package/dist/codex/generated/v2/TurnStartParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/TurnSteerParams.d.ts +8 -0
- package/dist/codex/generated/v2/TurnSteerParams.d.ts.map +1 -1
- package/dist/codex/generated/v2/TurnToolOutput.d.ts +4 -0
- package/dist/codex/generated/v2/TurnToolOutput.d.ts.map +1 -1
- package/dist/codex/generated/v2/UserInput.d.ts +3 -0
- package/dist/codex/generated/v2/UserInput.d.ts.map +1 -1
- package/dist/codex/generated/v2/UserVerificationCancelParams.d.ts +9 -0
- package/dist/codex/generated/v2/UserVerificationCancelParams.d.ts.map +1 -0
- package/dist/codex/generated/v2/UserVerificationCancelResponse.d.ts +6 -0
- package/dist/codex/generated/v2/UserVerificationCancelResponse.d.ts.map +1 -0
- package/dist/codex/generated/v2/UserVerificationEnrollResponse.d.ts +10 -0
- package/dist/codex/generated/v2/UserVerificationEnrollResponse.d.ts.map +1 -1
- package/dist/codex/generated/v2/WindowsSandboxImplementation.d.ts +2 -0
- package/dist/codex/generated/v2/WindowsSandboxImplementation.d.ts.map +1 -0
- package/dist/codex/generated/v2/WorkspaceRouting.d.ts +7 -0
- package/dist/codex/generated/v2/WorkspaceRouting.d.ts.map +1 -0
- package/dist/codex/generated/v2/index.d.ts +57 -2
- package/dist/codex/generated/v2/index.d.ts.map +1 -1
- package/dist/codex/method-map.d.ts +98 -6
- package/dist/codex/method-map.d.ts.map +1 -1
- package/dist/codex/schema-version.d.ts +1 -1
- package/dist/index.js +439 -457
- package/dist/index.js.map +1 -1
- package/dist/node/codex-surface-turn-actions-controller.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/codex-DzX6RrF2.js.map +0 -1
- package/dist/codex/generated/v2/ThreadRollbackParams.d.ts +0 -14
- package/dist/codex/generated/v2/ThreadRollbackParams.d.ts.map +0 -1
- package/dist/codex/generated/v2/ThreadRollbackResponse.d.ts +0 -12
- package/dist/codex/generated/v2/ThreadRollbackResponse.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, s as r } from "./chunks/codex-
|
|
1
|
+
import { i as e, n as t, r as n, s as r } from "./chunks/codex-CmHW3ikB.js";
|
|
2
2
|
import { execFile as i, execFileSync as a, spawn as o } from "node:child_process";
|
|
3
3
|
import { constants as s } from "node:buffer";
|
|
4
4
|
import { existsSync as c, promises as l, readFileSync as u, readdirSync as d } from "node:fs";
|
|
@@ -1584,10 +1584,10 @@ var vn = "Result returned in structuredContent.", yn = 32 * 1024;
|
|
|
1584
1584
|
function bn(e, t) {
|
|
1585
1585
|
let n = e.status;
|
|
1586
1586
|
if (e.kind === "command") {
|
|
1587
|
-
let r =
|
|
1587
|
+
let r = V(e.input) ? e.input : {}, i = typeof r.cwd == "string" ? r.cwd : t ?? void 0;
|
|
1588
1588
|
return kn(r.commandActions).flatMap((e) => {
|
|
1589
1589
|
if (e.type !== "read") return [];
|
|
1590
|
-
let t =
|
|
1590
|
+
let t = Hn(e.path ?? e.name, i);
|
|
1591
1591
|
return t ? [{
|
|
1592
1592
|
action: "read",
|
|
1593
1593
|
path: t,
|
|
@@ -1596,12 +1596,12 @@ function bn(e, t) {
|
|
|
1596
1596
|
});
|
|
1597
1597
|
}
|
|
1598
1598
|
if (e.kind !== "fileChange") return [];
|
|
1599
|
-
let r =
|
|
1599
|
+
let r = V(e.input) ? e.input : {}, i = e.metadata ?? {};
|
|
1600
1600
|
return (Array.isArray(i.changes) ? i.changes : Array.isArray(r.changes) ? r.changes : []).flatMap((e) => {
|
|
1601
|
-
if (!
|
|
1602
|
-
let r =
|
|
1601
|
+
if (!V(e) || typeof e.path != "string") return [];
|
|
1602
|
+
let r = Vn(e.kind);
|
|
1603
1603
|
if (r === "delete") return [];
|
|
1604
|
-
let i =
|
|
1604
|
+
let i = Hn(e.path, t ?? void 0);
|
|
1605
1605
|
return i ? [{
|
|
1606
1606
|
action: r === "add" ? "create" : "edit",
|
|
1607
1607
|
path: i,
|
|
@@ -1610,7 +1610,7 @@ function bn(e, t) {
|
|
|
1610
1610
|
});
|
|
1611
1611
|
}
|
|
1612
1612
|
function R(e, t = {}) {
|
|
1613
|
-
if (!
|
|
1613
|
+
if (!V(e) || typeof e.id != "string") return null;
|
|
1614
1614
|
if (e.type === "commandExecution") {
|
|
1615
1615
|
let n = typeof e.command == "string" ? e.command : "command", r = z(e.status), i = En(r, e.commandActions, n), a = t.includeCommandOutput && typeof e.aggregatedOutput == "string" ? e.aggregatedOutput : void 0;
|
|
1616
1616
|
return {
|
|
@@ -1637,14 +1637,14 @@ function R(e, t = {}) {
|
|
|
1637
1637
|
};
|
|
1638
1638
|
}
|
|
1639
1639
|
if (e.type === "mcpToolCall") {
|
|
1640
|
-
let t = typeof e.server == "string" ? e.server : "mcp", n = typeof e.tool == "string" ? e.tool : "tool", r =
|
|
1640
|
+
let t = typeof e.server == "string" ? e.server : "mcp", n = typeof e.tool == "string" ? e.tool : "tool", r = Xn(Gn(e.error)), i = H(e.arguments), a = H(e.result);
|
|
1641
1641
|
return {
|
|
1642
1642
|
type: "tool",
|
|
1643
1643
|
id: e.id,
|
|
1644
1644
|
kind: "mcp",
|
|
1645
1645
|
title: `${t}.${n}`,
|
|
1646
1646
|
status: z(e.status),
|
|
1647
|
-
body: r ??
|
|
1647
|
+
body: r ?? Xn(Kn(a)),
|
|
1648
1648
|
...i === void 0 ? {} : { input: i },
|
|
1649
1649
|
...a === void 0 ? {} : { output: a },
|
|
1650
1650
|
metadata: {
|
|
@@ -1657,14 +1657,14 @@ function R(e, t = {}) {
|
|
|
1657
1657
|
};
|
|
1658
1658
|
}
|
|
1659
1659
|
if (e.type === "dynamicToolCall") {
|
|
1660
|
-
let t = typeof e.tool == "string" ? e.tool : "tool", n = typeof e.namespace == "string" ? e.namespace : null, r =
|
|
1660
|
+
let t = typeof e.tool == "string" ? e.tool : "tool", n = typeof e.namespace == "string" ? e.namespace : null, r = H(e.arguments), i = H(e.contentItems);
|
|
1661
1661
|
return {
|
|
1662
1662
|
type: "tool",
|
|
1663
1663
|
id: e.id,
|
|
1664
1664
|
kind: "dynamic",
|
|
1665
1665
|
title: n ? `${n}.${t}` : t,
|
|
1666
1666
|
status: z(e.status),
|
|
1667
|
-
body:
|
|
1667
|
+
body: Xn(Jn(i)),
|
|
1668
1668
|
...r === void 0 ? {} : { input: r },
|
|
1669
1669
|
...i === void 0 ? {} : { output: i },
|
|
1670
1670
|
metadata: {
|
|
@@ -1684,7 +1684,7 @@ function R(e, t = {}) {
|
|
|
1684
1684
|
title: n.length === 1 ? "1 file change" : `${n.length} file changes`,
|
|
1685
1685
|
status: r,
|
|
1686
1686
|
...i ? { statusText: i } : {},
|
|
1687
|
-
body:
|
|
1687
|
+
body: Yn(n),
|
|
1688
1688
|
input: { changes: n },
|
|
1689
1689
|
metadata: {
|
|
1690
1690
|
changes: n,
|
|
@@ -1721,7 +1721,7 @@ function R(e, t = {}) {
|
|
|
1721
1721
|
} : null;
|
|
1722
1722
|
}
|
|
1723
1723
|
function xn(e) {
|
|
1724
|
-
if (!
|
|
1724
|
+
if (!V(e) || e.type !== "commandExecution" || typeof e.command != "string") return !1;
|
|
1725
1725
|
let t = e.command;
|
|
1726
1726
|
return An(t) || jn(t) || Mn(t);
|
|
1727
1727
|
}
|
|
@@ -1742,7 +1742,7 @@ function Cn(e, t) {
|
|
|
1742
1742
|
let n = In("running", t);
|
|
1743
1743
|
return {
|
|
1744
1744
|
itemId: e,
|
|
1745
|
-
body:
|
|
1745
|
+
body: Yn(t),
|
|
1746
1746
|
...n ? { statusText: n } : {},
|
|
1747
1747
|
input: { changes: t },
|
|
1748
1748
|
metadata: { changes: t },
|
|
@@ -1753,7 +1753,7 @@ function Cn(e, t) {
|
|
|
1753
1753
|
title: t.length === 1 ? "1 file change" : `${t.length} file changes`,
|
|
1754
1754
|
status: "running",
|
|
1755
1755
|
...n ? { statusText: n } : {},
|
|
1756
|
-
body:
|
|
1756
|
+
body: Yn(t),
|
|
1757
1757
|
input: { changes: t },
|
|
1758
1758
|
metadata: { changes: t }
|
|
1759
1759
|
}
|
|
@@ -1773,7 +1773,7 @@ function wn(e, t) {
|
|
|
1773
1773
|
};
|
|
1774
1774
|
}
|
|
1775
1775
|
function Tn(e, t, n, r = "completed") {
|
|
1776
|
-
let i =
|
|
1776
|
+
let i = H(t), a = Xn(L(i));
|
|
1777
1777
|
return {
|
|
1778
1778
|
itemId: e,
|
|
1779
1779
|
title: n && n.trim() ? n : void 0,
|
|
@@ -1856,7 +1856,7 @@ function On(e) {
|
|
|
1856
1856
|
return e.path ?? e.name ?? e.query ?? e.command;
|
|
1857
1857
|
}
|
|
1858
1858
|
function kn(e) {
|
|
1859
|
-
return Array.isArray(e) ? e.flatMap((e) => !
|
|
1859
|
+
return Array.isArray(e) ? e.flatMap((e) => !V(e) || e.type !== "read" && e.type !== "listFiles" && e.type !== "search" ? [] : [{
|
|
1860
1860
|
command: typeof e.command == "string" ? e.command : void 0,
|
|
1861
1861
|
name: typeof e.name == "string" ? e.name : void 0,
|
|
1862
1862
|
path: typeof e.path == "string" ? e.path : void 0,
|
|
@@ -1883,7 +1883,7 @@ function Pn(e, t) {
|
|
|
1883
1883
|
return Fn(e, t);
|
|
1884
1884
|
}
|
|
1885
1885
|
function Fn(e, t) {
|
|
1886
|
-
return Nn(B(e.map(
|
|
1886
|
+
return Nn(B(e.map(Wn)), t);
|
|
1887
1887
|
}
|
|
1888
1888
|
function In(e, t) {
|
|
1889
1889
|
let n = Ln(e, t);
|
|
@@ -1891,8 +1891,8 @@ function In(e, t) {
|
|
|
1891
1891
|
}
|
|
1892
1892
|
function Ln(e, t) {
|
|
1893
1893
|
let n = t.flatMap((e) => {
|
|
1894
|
-
if (!
|
|
1895
|
-
let t = typeof e.path == "string" ? e.path : void 0, n =
|
|
1894
|
+
if (!V(e)) return [];
|
|
1895
|
+
let t = typeof e.path == "string" ? e.path : void 0, n = Vn(e.kind), r = zn(e);
|
|
1896
1896
|
return [{
|
|
1897
1897
|
addedLines: r.addedLines,
|
|
1898
1898
|
kind: n,
|
|
@@ -1918,13 +1918,13 @@ function Rn(e) {
|
|
|
1918
1918
|
return e.every((e) => e === "add") ? "create" : e.every((e) => e === "delete") ? "delete" : "edit";
|
|
1919
1919
|
}
|
|
1920
1920
|
function zn(e) {
|
|
1921
|
-
let t = typeof e.diff == "string" ? e.diff : void 0, n =
|
|
1921
|
+
let t = typeof e.diff == "string" ? e.diff : void 0, n = Vn(e.kind);
|
|
1922
1922
|
return n === "add" ? {
|
|
1923
|
-
addedLines:
|
|
1923
|
+
addedLines: Un(t),
|
|
1924
1924
|
removedLines: 0
|
|
1925
1925
|
} : n === "delete" ? {
|
|
1926
1926
|
addedLines: 0,
|
|
1927
|
-
removedLines:
|
|
1927
|
+
removedLines: Un(t)
|
|
1928
1928
|
} : Bn(t);
|
|
1929
1929
|
}
|
|
1930
1930
|
function Bn(e) {
|
|
@@ -1939,54 +1939,54 @@ function Bn(e) {
|
|
|
1939
1939
|
removedLines: n
|
|
1940
1940
|
};
|
|
1941
1941
|
}
|
|
1942
|
-
function
|
|
1942
|
+
function Vn(e) {
|
|
1943
1943
|
if (e === "add" || e === "delete") return e;
|
|
1944
|
-
if (
|
|
1944
|
+
if (V(e) && typeof e.type == "string") return Vn(e.type);
|
|
1945
1945
|
}
|
|
1946
|
-
function
|
|
1946
|
+
function Hn(e, t) {
|
|
1947
1947
|
let n = e?.trim();
|
|
1948
1948
|
if (n) {
|
|
1949
1949
|
if (v(n)) return n;
|
|
1950
1950
|
if (!(!t || !v(t))) return x(t, n);
|
|
1951
1951
|
}
|
|
1952
1952
|
}
|
|
1953
|
-
function
|
|
1953
|
+
function Un(e) {
|
|
1954
1954
|
if (!e) return 0;
|
|
1955
1955
|
let t = e.split(/\r\n|\r|\n/);
|
|
1956
1956
|
for (; t.at(-1) === "";) t.pop();
|
|
1957
1957
|
return t.length;
|
|
1958
1958
|
}
|
|
1959
|
-
function Un(e) {
|
|
1960
|
-
return e.split(/[\\/]/).filter(Boolean).at(-1) ?? e;
|
|
1961
|
-
}
|
|
1962
1959
|
function Wn(e) {
|
|
1963
|
-
|
|
1960
|
+
return e.split(/[\\/]/).filter(Boolean).at(-1) ?? e;
|
|
1964
1961
|
}
|
|
1965
1962
|
function Gn(e) {
|
|
1966
|
-
if (
|
|
1967
|
-
let t = Kn(e.content), n = "structuredContent" in e ? L(e.structuredContent) : void 0;
|
|
1968
|
-
return n ? !t || t.trim() === vn ? n : `${t}\n\n${n}` : t;
|
|
1963
|
+
if (V(e)) return typeof e.message == "string" ? e.message : void 0;
|
|
1969
1964
|
}
|
|
1970
1965
|
function Kn(e) {
|
|
1971
|
-
if (
|
|
1966
|
+
if (!V(e)) return;
|
|
1967
|
+
let t = qn(e.content), n = "structuredContent" in e ? L(e.structuredContent) : void 0;
|
|
1968
|
+
return n ? !t || t.trim() === vn ? n : `${t}\n\n${n}` : t;
|
|
1972
1969
|
}
|
|
1973
1970
|
function qn(e) {
|
|
1974
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
1971
|
+
if (Array.isArray(e)) return e.map((e) => V(e) ? typeof e.text == "string" ? e.text : JSON.stringify(e) : "").filter(Boolean).join("\n\n") || void 0;
|
|
1975
1972
|
}
|
|
1976
1973
|
function Jn(e) {
|
|
1977
|
-
return e.map((e) =>
|
|
1974
|
+
if (Array.isArray(e)) return e.map((e) => V(e) && typeof e.text == "string" ? e.text : JSON.stringify(e)).filter(Boolean).join("\n\n") || void 0;
|
|
1978
1975
|
}
|
|
1979
|
-
function
|
|
1976
|
+
function Yn(e) {
|
|
1977
|
+
return e.map((e) => V(e) ? `${Vn(e.kind) ?? "update"} ${typeof e.path == "string" ? e.path : "unknown"}` : JSON.stringify(e)).join("\n") || void 0;
|
|
1978
|
+
}
|
|
1979
|
+
function V(e) {
|
|
1980
1980
|
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
1981
1981
|
}
|
|
1982
|
-
function
|
|
1982
|
+
function Xn(e) {
|
|
1983
1983
|
return e !== void 0 && Buffer.byteLength(e) <= yn ? e : void 0;
|
|
1984
1984
|
}
|
|
1985
|
-
function
|
|
1986
|
-
if (!(e === void 0 || !
|
|
1985
|
+
function H(e) {
|
|
1986
|
+
if (!(e === void 0 || !Zn(e, yn))) return e;
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1989
|
-
if (
|
|
1988
|
+
function Zn(e, t) {
|
|
1989
|
+
if (Qn(e, t, /* @__PURE__ */ new Set())) return !1;
|
|
1990
1990
|
try {
|
|
1991
1991
|
let n = JSON.stringify(e);
|
|
1992
1992
|
return n !== void 0 && Buffer.byteLength(n) <= t;
|
|
@@ -1994,28 +1994,28 @@ function Xn(e, t) {
|
|
|
1994
1994
|
return !1;
|
|
1995
1995
|
}
|
|
1996
1996
|
}
|
|
1997
|
-
function
|
|
1997
|
+
function Qn(e, t, n) {
|
|
1998
1998
|
if (typeof e == "string") return Buffer.byteLength(e) > t;
|
|
1999
1999
|
if (typeof e != "object" || !e) return !1;
|
|
2000
2000
|
if (n.has(e)) return !0;
|
|
2001
2001
|
n.add(e);
|
|
2002
|
-
let r = (Array.isArray(e) ? e : Object.values(e)).some((e) =>
|
|
2002
|
+
let r = (Array.isArray(e) ? e : Object.values(e)).some((e) => Qn(e, t, n));
|
|
2003
2003
|
return n.delete(e), r;
|
|
2004
2004
|
}
|
|
2005
2005
|
//#endregion
|
|
2006
2006
|
//#region src/node/codex-surface-message-state.ts
|
|
2007
|
-
function
|
|
2007
|
+
function $n(e) {
|
|
2008
2008
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
2009
2009
|
let n = e[t];
|
|
2010
2010
|
if (n?.status === "inProgress") return n.id;
|
|
2011
2011
|
}
|
|
2012
2012
|
return null;
|
|
2013
2013
|
}
|
|
2014
|
-
function
|
|
2015
|
-
let i = [...e], a =
|
|
2014
|
+
function U(e, t, n, r = {}) {
|
|
2015
|
+
let i = [...e], a = K(i, (e) => e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
|
|
2016
2016
|
if (o?.role === "assistant" && o.kind === void 0 && o.status === "streaming") return i;
|
|
2017
2017
|
if (r.forceSegment) {
|
|
2018
|
-
let e =
|
|
2018
|
+
let e = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), t = e >= 0 ? i[e] : void 0;
|
|
2019
2019
|
t?.parts.length === 0 ? i.splice(e, 1) : t && i.splice(e, 1, {
|
|
2020
2020
|
...t,
|
|
2021
2021
|
status: "complete"
|
|
@@ -2035,9 +2035,9 @@ function W(e, t, n, r = {}) {
|
|
|
2035
2035
|
}
|
|
2036
2036
|
}), i;
|
|
2037
2037
|
}
|
|
2038
|
-
function
|
|
2038
|
+
function er(e, t, n, r, i, a) {
|
|
2039
2039
|
if (!i) return [...e];
|
|
2040
|
-
let o =
|
|
2040
|
+
let o = U(e, t, n), s = K(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
|
|
2041
2041
|
if (!c) return o;
|
|
2042
2042
|
let l = [...c.parts], u = l.at(-1);
|
|
2043
2043
|
return u?.type === "text" && u.itemId === r ? l.splice(l.length - 1, 1, {
|
|
@@ -2053,9 +2053,9 @@ function $n(e, t, n, r, i, a) {
|
|
|
2053
2053
|
...c,
|
|
2054
2054
|
status: "streaming",
|
|
2055
2055
|
parts: l
|
|
2056
|
-
}),
|
|
2056
|
+
}), G(o, t);
|
|
2057
2057
|
}
|
|
2058
|
-
function
|
|
2058
|
+
function tr(e, t, n, r, i) {
|
|
2059
2059
|
let a = i.map((e, t) => {
|
|
2060
2060
|
let n = e.trim();
|
|
2061
2061
|
return n ? {
|
|
@@ -2066,16 +2066,16 @@ function er(e, t, n, r, i) {
|
|
|
2066
2066
|
} : null;
|
|
2067
2067
|
}).filter((e) => e !== null);
|
|
2068
2068
|
if (a.length === 0) return [...e];
|
|
2069
|
-
let o =
|
|
2069
|
+
let o = U(e, t, n), s = K(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
|
|
2070
2070
|
if (!c) return o;
|
|
2071
2071
|
let l = c.parts.findIndex((e) => e.type === "reasoning" && e.itemId === r), u = c.parts.filter((e) => e.type !== "reasoning" || e.itemId !== r);
|
|
2072
2072
|
return u.splice(l >= 0 ? l : u.length, 0, ...a), o.splice(s, 1, {
|
|
2073
2073
|
...c,
|
|
2074
2074
|
status: "streaming",
|
|
2075
2075
|
parts: u
|
|
2076
|
-
}),
|
|
2076
|
+
}), G(o, t);
|
|
2077
2077
|
}
|
|
2078
|
-
function
|
|
2078
|
+
function nr(e, t, n, r, i, a) {
|
|
2079
2079
|
let o = [...e];
|
|
2080
2080
|
for (let e = o.length - 1; e >= 0; --e) {
|
|
2081
2081
|
let s = o[e];
|
|
@@ -2091,9 +2091,9 @@ function tr(e, t, n, r, i, a) {
|
|
|
2091
2091
|
}), o.splice(e, 1, {
|
|
2092
2092
|
...s,
|
|
2093
2093
|
parts: l
|
|
2094
|
-
}),
|
|
2094
|
+
}), G(o, t);
|
|
2095
2095
|
}
|
|
2096
|
-
let s =
|
|
2096
|
+
let s = U(o, t, n), c = K(s, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), l = c >= 0 ? s[c] : void 0;
|
|
2097
2097
|
if (!l) return s;
|
|
2098
2098
|
let u = {
|
|
2099
2099
|
type: "text",
|
|
@@ -2104,10 +2104,10 @@ function tr(e, t, n, r, i, a) {
|
|
|
2104
2104
|
return s.splice(c, 1, {
|
|
2105
2105
|
...l,
|
|
2106
2106
|
parts: [...l.parts, u]
|
|
2107
|
-
}),
|
|
2107
|
+
}), G(s, t);
|
|
2108
2108
|
}
|
|
2109
|
-
function
|
|
2110
|
-
return
|
|
2109
|
+
function rr(e, t, n, r) {
|
|
2110
|
+
return G(e.map((e) => {
|
|
2111
2111
|
if (e.role !== "assistant" || e.metadata?.turnId !== n) return e;
|
|
2112
2112
|
let t = e.parts.filter((e) => e.type !== "text" || e.itemId !== r);
|
|
2113
2113
|
return t.length === e.parts.length ? e : {
|
|
@@ -2116,16 +2116,16 @@ function nr(e, t, n, r) {
|
|
|
2116
2116
|
};
|
|
2117
2117
|
}), t);
|
|
2118
2118
|
}
|
|
2119
|
-
function
|
|
2119
|
+
function ir(e) {
|
|
2120
2120
|
let t = /<proposed_plan>([\s\S]*?)<\/proposed_plan>/iu.exec(e), n = t?.[1]?.trim() ?? "";
|
|
2121
2121
|
return !t || !n ? null : {
|
|
2122
2122
|
markdown: n,
|
|
2123
2123
|
visibleText: `${e.slice(0, t.index)}${e.slice(t.index + t[0].length)}`.trim()
|
|
2124
2124
|
};
|
|
2125
2125
|
}
|
|
2126
|
-
function
|
|
2126
|
+
function W(e, t, n, r) {
|
|
2127
2127
|
let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === r.id));
|
|
2128
|
-
a < 0 && (i =
|
|
2128
|
+
a < 0 && (i = U(i, t, n), a = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
|
|
2129
2129
|
let o = a >= 0 ? i[a] : void 0;
|
|
2130
2130
|
if (!o) return i;
|
|
2131
2131
|
let s = [...o.parts], c = s.findIndex((e) => e.type === "tool" && e.id === r.id);
|
|
@@ -2137,7 +2137,7 @@ function G(e, t, n, r) {
|
|
|
2137
2137
|
body: r.body ?? e.body,
|
|
2138
2138
|
input: r.input ?? e.input,
|
|
2139
2139
|
output: r.output ?? e.output,
|
|
2140
|
-
statusText: r.statusText ??
|
|
2140
|
+
statusText: r.statusText ?? dr(e.statusText, r.status),
|
|
2141
2141
|
metadata: {
|
|
2142
2142
|
...e.metadata ?? {},
|
|
2143
2143
|
...r.metadata ?? {}
|
|
@@ -2147,11 +2147,11 @@ function G(e, t, n, r) {
|
|
|
2147
2147
|
return i.splice(a, 1, {
|
|
2148
2148
|
...o,
|
|
2149
2149
|
parts: s
|
|
2150
|
-
}),
|
|
2150
|
+
}), G(i, t);
|
|
2151
2151
|
}
|
|
2152
|
-
function
|
|
2152
|
+
function ar(e, t, n, r, i = r.itemId) {
|
|
2153
2153
|
let a = [...e], o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "media" && e.itemId === r.itemId));
|
|
2154
|
-
o < 0 && r.itemId && (o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === i))), o < 0 && (a =
|
|
2154
|
+
o < 0 && r.itemId && (o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === i))), o < 0 && (a = U(a, t, n), o = K(a, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
|
|
2155
2155
|
let s = o >= 0 ? a[o] : void 0;
|
|
2156
2156
|
if (!s) return a;
|
|
2157
2157
|
let c = [...s.parts], l = c.findIndex((e) => e.type === "media" && e.itemId === r.itemId);
|
|
@@ -2159,25 +2159,25 @@ function ir(e, t, n, r, i = r.itemId) {
|
|
|
2159
2159
|
...s,
|
|
2160
2160
|
status: "streaming",
|
|
2161
2161
|
parts: c
|
|
2162
|
-
}),
|
|
2162
|
+
}), G(a, t);
|
|
2163
2163
|
}
|
|
2164
|
-
function
|
|
2164
|
+
function or(e, t, n, r) {
|
|
2165
2165
|
let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "question" && e.request.id === r.request.id));
|
|
2166
|
-
a < 0 && (i =
|
|
2166
|
+
a < 0 && (i = U(i, t, n), a = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
|
|
2167
2167
|
let o = a >= 0 ? i[a] : void 0;
|
|
2168
2168
|
if (!o) return i;
|
|
2169
2169
|
let s = [...o.parts], c = s.findIndex((e) => e.type === "question" && e.request.id === r.request.id);
|
|
2170
2170
|
return c >= 0 ? s.splice(c, 1, r) : s.push(r), i.splice(a, 1, {
|
|
2171
2171
|
...o,
|
|
2172
2172
|
parts: s
|
|
2173
|
-
}),
|
|
2173
|
+
}), G(i, t);
|
|
2174
2174
|
}
|
|
2175
|
-
function
|
|
2175
|
+
function sr(e, t) {
|
|
2176
2176
|
return e.itemId === t.itemId && e.media.url === t.media.url && e.media.alt === t.media.alt && e.media.mimeType === t.media.mimeType && e.media.prompt === t.media.prompt && e.media.title === t.media.title;
|
|
2177
2177
|
}
|
|
2178
|
-
function
|
|
2178
|
+
function cr(e, t, n, r) {
|
|
2179
2179
|
let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === r.itemId));
|
|
2180
|
-
if (a < 0) return r.fallbackToolPart ?
|
|
2180
|
+
if (a < 0) return r.fallbackToolPart ? cr(W(i, t, n, r.fallbackToolPart), t, n, {
|
|
2181
2181
|
...r,
|
|
2182
2182
|
fallbackToolPart: void 0
|
|
2183
2183
|
}) : i;
|
|
@@ -2203,12 +2203,12 @@ function sr(e, t, n, r) {
|
|
|
2203
2203
|
parts: s
|
|
2204
2204
|
}), i) : i;
|
|
2205
2205
|
}
|
|
2206
|
-
function
|
|
2206
|
+
function lr(e, t, n, r = "streaming") {
|
|
2207
2207
|
if (e.some((e) => e.kind === "compaction" && e.metadata?.turnId === n)) return e.map((e) => r === "complete" && e.kind === "compaction" && e.metadata?.turnId === n ? {
|
|
2208
2208
|
...e,
|
|
2209
2209
|
status: r
|
|
2210
2210
|
} : e);
|
|
2211
|
-
let i = [...e], a =
|
|
2211
|
+
let i = [...e], a = K(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
|
|
2212
2212
|
return o?.parts.length === 0 ? i.splice(a, 1) : o && i.splice(a, 1, {
|
|
2213
2213
|
...o,
|
|
2214
2214
|
status: "complete"
|
|
@@ -2224,16 +2224,16 @@ function cr(e, t, n, r = "streaming") {
|
|
|
2224
2224
|
conversationId: t,
|
|
2225
2225
|
turnId: n
|
|
2226
2226
|
}
|
|
2227
|
-
}),
|
|
2227
|
+
}), G(i, t);
|
|
2228
2228
|
}
|
|
2229
|
-
function
|
|
2229
|
+
function ur(e, t, n) {
|
|
2230
2230
|
let r = n === "completed" ? "completed" : "failed";
|
|
2231
2231
|
return e.map((e) => {
|
|
2232
2232
|
if (e.metadata?.turnId !== t) return e;
|
|
2233
2233
|
let n = !1, i = e.parts.map((e) => e.type !== "tool" || e.status !== "running" ? e : (n = !0, {
|
|
2234
2234
|
...e,
|
|
2235
2235
|
status: r,
|
|
2236
|
-
statusText:
|
|
2236
|
+
statusText: dr(e.statusText, r)
|
|
2237
2237
|
}));
|
|
2238
2238
|
return n ? {
|
|
2239
2239
|
...e,
|
|
@@ -2241,7 +2241,7 @@ function lr(e, t, n) {
|
|
|
2241
2241
|
} : e;
|
|
2242
2242
|
});
|
|
2243
2243
|
}
|
|
2244
|
-
function
|
|
2244
|
+
function dr(e, t) {
|
|
2245
2245
|
if (t === "running" || !e) return e;
|
|
2246
2246
|
try {
|
|
2247
2247
|
let n = JSON.parse(e);
|
|
@@ -2253,27 +2253,27 @@ function ur(e, t) {
|
|
|
2253
2253
|
return e;
|
|
2254
2254
|
}
|
|
2255
2255
|
}
|
|
2256
|
-
function
|
|
2256
|
+
function G(e, t) {
|
|
2257
2257
|
let n = e.map((e, t) => ({
|
|
2258
2258
|
message: e,
|
|
2259
2259
|
index: t
|
|
2260
2260
|
})).filter(({ message: e }) => e.metadata?.conversationId === t).at(-1)?.index ?? -1;
|
|
2261
2261
|
return e.filter((e, r) => e.metadata?.conversationId !== t || r === n || e.role !== "assistant" || e.kind !== void 0 || e.parts.length > 0);
|
|
2262
2262
|
}
|
|
2263
|
-
function
|
|
2263
|
+
function K(e, t) {
|
|
2264
2264
|
for (let n = e.length - 1; n >= 0; --n) {
|
|
2265
2265
|
let r = e[n];
|
|
2266
2266
|
if (r !== void 0 && t(r)) return n;
|
|
2267
2267
|
}
|
|
2268
2268
|
return -1;
|
|
2269
2269
|
}
|
|
2270
|
-
function
|
|
2270
|
+
function fr(e, t) {
|
|
2271
2271
|
return e.includes(t) ? [...e] : [...e, t];
|
|
2272
2272
|
}
|
|
2273
|
-
function
|
|
2273
|
+
function pr(e, t) {
|
|
2274
2274
|
return [e?.trim() ?? "", ...t.map((e) => `${e.status === "completed" ? "- [x]" : "- [ ]"} ${e.step}`)].filter(Boolean).join("\n");
|
|
2275
2275
|
}
|
|
2276
|
-
function
|
|
2276
|
+
function mr(e, t, n) {
|
|
2277
2277
|
return {
|
|
2278
2278
|
type: "tool",
|
|
2279
2279
|
id: `plan-progress-${e}`,
|
|
@@ -2296,19 +2296,19 @@ function pr(e, t, n) {
|
|
|
2296
2296
|
}
|
|
2297
2297
|
//#endregion
|
|
2298
2298
|
//#region src/node/codex-conversation-history.ts
|
|
2299
|
-
var
|
|
2299
|
+
var hr = 16 * 1024 * 1024, gr = /* @__PURE__ */ new Set([
|
|
2300
2300
|
"image/avif",
|
|
2301
2301
|
"image/gif",
|
|
2302
2302
|
"image/jpeg",
|
|
2303
2303
|
"image/png",
|
|
2304
2304
|
"image/webp"
|
|
2305
2305
|
]);
|
|
2306
|
-
function
|
|
2307
|
-
return (Array.isArray(e.turns) ? e.turns : []).flatMap((t) =>
|
|
2306
|
+
function _r(e) {
|
|
2307
|
+
return (Array.isArray(e.turns) ? e.turns : []).flatMap((t) => br(e.id, t));
|
|
2308
2308
|
}
|
|
2309
|
-
function
|
|
2309
|
+
function vr(e, t) {
|
|
2310
2310
|
let n = /* @__PURE__ */ new Map();
|
|
2311
|
-
for (let t of e) for (let e of t.parts) e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path ||
|
|
2311
|
+
for (let t of e) for (let e of t.parts) e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path || Pr(e.attachment.url) && n.set(e.attachment.path, e.attachment.url);
|
|
2312
2312
|
return n.size === 0 ? [...t] : t.map((e) => {
|
|
2313
2313
|
let t = !1, r = e.parts.map((e) => {
|
|
2314
2314
|
if (e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path) return e;
|
|
@@ -2327,9 +2327,9 @@ function _r(e, t) {
|
|
|
2327
2327
|
} : e;
|
|
2328
2328
|
});
|
|
2329
2329
|
}
|
|
2330
|
-
function
|
|
2330
|
+
function yr(e, t) {
|
|
2331
2331
|
let n = new Map(e.filter((e) => e.role === "user" && e.metadata?.promptContent).map((e) => [e.id, e.metadata.promptContent]));
|
|
2332
|
-
return
|
|
2332
|
+
return vr(e, t).map((e) => {
|
|
2333
2333
|
let t = n.get(e.id);
|
|
2334
2334
|
if (!t || e.role !== "user") return e;
|
|
2335
2335
|
let r = ne(t);
|
|
@@ -2346,14 +2346,14 @@ function vr(e, t) {
|
|
|
2346
2346
|
};
|
|
2347
2347
|
});
|
|
2348
2348
|
}
|
|
2349
|
-
function
|
|
2350
|
-
let n = [], r = [], i =
|
|
2349
|
+
function br(e, t) {
|
|
2350
|
+
let n = [], r = [], i = Rr(t.startedAt ?? t.completedAt), a = 0, o = !1, s = /* @__PURE__ */ new Set(), c = () => {
|
|
2351
2351
|
if (r.length === 0) return;
|
|
2352
2352
|
let o = a === 0 ? "" : `-segment-${a}`;
|
|
2353
2353
|
n.push({
|
|
2354
2354
|
id: `assistant-${t.id}${o}`,
|
|
2355
2355
|
role: "assistant",
|
|
2356
|
-
status:
|
|
2356
|
+
status: Lr(t.status),
|
|
2357
2357
|
turnId: t.id,
|
|
2358
2358
|
parts: [...r],
|
|
2359
2359
|
createdAt: i,
|
|
@@ -2365,7 +2365,7 @@ function yr(e, t) {
|
|
|
2365
2365
|
};
|
|
2366
2366
|
for (let a of Array.isArray(t.items) ? t.items : []) {
|
|
2367
2367
|
if (a.type === "userMessage") {
|
|
2368
|
-
let r =
|
|
2368
|
+
let r = Tr(a), l = Dr(a);
|
|
2369
2369
|
if (r.length > 0) {
|
|
2370
2370
|
let u = o, d = u ? null : JSON.stringify(r);
|
|
2371
2371
|
if (d && s.has(d)) continue;
|
|
@@ -2382,7 +2382,7 @@ function yr(e, t) {
|
|
|
2382
2382
|
turnId: t.id,
|
|
2383
2383
|
...l.length > 0 ? {
|
|
2384
2384
|
asyncQuestionRequestIds: l,
|
|
2385
|
-
asyncQuestionAnswers:
|
|
2385
|
+
asyncQuestionAnswers: Or(a)
|
|
2386
2386
|
} : {}
|
|
2387
2387
|
}
|
|
2388
2388
|
});
|
|
@@ -2408,7 +2408,7 @@ function yr(e, t) {
|
|
|
2408
2408
|
continue;
|
|
2409
2409
|
}
|
|
2410
2410
|
if (a.type === "agentMessage") {
|
|
2411
|
-
let n = typeof a.text == "string" ? a.text : "", i =
|
|
2411
|
+
let n = typeof a.text == "string" ? a.text : "", i = Sr(e, t.id, a, !0), s = a.phase === "final_answer" ? ir(n) : null;
|
|
2412
2412
|
s && !i ? s.visibleText && (o = !0, r.push({
|
|
2413
2413
|
type: "text",
|
|
2414
2414
|
text: s.visibleText,
|
|
@@ -2446,15 +2446,15 @@ function yr(e, t) {
|
|
|
2446
2446
|
}
|
|
2447
2447
|
let l = R(a);
|
|
2448
2448
|
l && (o = !0, r.push(l));
|
|
2449
|
-
let u =
|
|
2449
|
+
let u = wr(a);
|
|
2450
2450
|
u.length && (o = !0, r.push(...u));
|
|
2451
2451
|
}
|
|
2452
|
-
return c(), t.status === "inProgress" ? n :
|
|
2452
|
+
return c(), t.status === "inProgress" ? n : ur(n, t.id, t.status);
|
|
2453
2453
|
}
|
|
2454
|
-
function
|
|
2455
|
-
let r =
|
|
2454
|
+
function xr(e, t, n) {
|
|
2455
|
+
let r = Rr(t.startedAt);
|
|
2456
2456
|
if (n.type === "userMessage") {
|
|
2457
|
-
let i =
|
|
2457
|
+
let i = Tr(n), a = Dr(n);
|
|
2458
2458
|
return i.length > 0 ? {
|
|
2459
2459
|
id: n.clientId ?? `user-${e}-${t.id}-${n.id}`,
|
|
2460
2460
|
role: "user",
|
|
@@ -2468,13 +2468,13 @@ function br(e, t, n) {
|
|
|
2468
2468
|
itemId: n.id,
|
|
2469
2469
|
...a.length > 0 ? {
|
|
2470
2470
|
asyncQuestionRequestIds: a,
|
|
2471
|
-
asyncQuestionAnswers:
|
|
2471
|
+
asyncQuestionAnswers: Or(n)
|
|
2472
2472
|
} : {}
|
|
2473
2473
|
}
|
|
2474
2474
|
} : null;
|
|
2475
2475
|
}
|
|
2476
2476
|
if (n.type === "agentMessage" || n.type === "exitedReviewMode") {
|
|
2477
|
-
let i = n.type === "agentMessage" ? n.text : n.review, a = n.type === "agentMessage" && n.phase === "final_answer" ?
|
|
2477
|
+
let i = n.type === "agentMessage" ? n.text : n.review, a = n.type === "agentMessage" && n.phase === "final_answer" ? ir(i) : null, o = n.type === "agentMessage" ? Sr(e, t.id, n, !0) : null, s = [...!o && (a?.visibleText || !a && i) ? [{
|
|
2478
2478
|
type: "text",
|
|
2479
2479
|
text: a?.visibleText ?? i,
|
|
2480
2480
|
itemId: n.id,
|
|
@@ -2483,7 +2483,7 @@ function br(e, t, n) {
|
|
|
2483
2483
|
return s.length > 0 ? {
|
|
2484
2484
|
id: `assistant-${n.id}`,
|
|
2485
2485
|
role: "assistant",
|
|
2486
|
-
status:
|
|
2486
|
+
status: Lr(t.status),
|
|
2487
2487
|
turnId: t.id,
|
|
2488
2488
|
parts: s,
|
|
2489
2489
|
createdAt: r,
|
|
@@ -2507,7 +2507,7 @@ function br(e, t, n) {
|
|
|
2507
2507
|
return i.length > 0 ? {
|
|
2508
2508
|
id: `assistant-${n.id}`,
|
|
2509
2509
|
role: "assistant",
|
|
2510
|
-
status:
|
|
2510
|
+
status: Lr(t.status),
|
|
2511
2511
|
turnId: t.id,
|
|
2512
2512
|
parts: i,
|
|
2513
2513
|
createdAt: r,
|
|
@@ -2519,11 +2519,11 @@ function br(e, t, n) {
|
|
|
2519
2519
|
} : null;
|
|
2520
2520
|
}
|
|
2521
2521
|
let i = [], a = R(n);
|
|
2522
|
-
a && i.push(a), i.push(...
|
|
2522
|
+
a && i.push(a), i.push(...wr(n));
|
|
2523
2523
|
let o = i.length > 0 ? {
|
|
2524
2524
|
id: `assistant-${n.id}`,
|
|
2525
2525
|
role: "assistant",
|
|
2526
|
-
status:
|
|
2526
|
+
status: Lr(t.status),
|
|
2527
2527
|
turnId: t.id,
|
|
2528
2528
|
parts: i,
|
|
2529
2529
|
createdAt: r,
|
|
@@ -2533,9 +2533,9 @@ function br(e, t, n) {
|
|
|
2533
2533
|
itemId: n.id
|
|
2534
2534
|
}
|
|
2535
2535
|
} : null;
|
|
2536
|
-
return !o || t.status === "inProgress" ? o :
|
|
2536
|
+
return !o || t.status === "inProgress" ? o : ur([o], t.id, t.status)[0] ?? null;
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2538
|
+
function Sr(e, t, n, r = !1) {
|
|
2539
2539
|
if (n.delivery !== "async") return null;
|
|
2540
2540
|
let i = n.questions ?? [], a = i.length > 0 ? i.map((e, t) => ({
|
|
2541
2541
|
id: JSON.stringify([
|
|
@@ -2577,9 +2577,9 @@ function xr(e, t, n, r = !1) {
|
|
|
2577
2577
|
...r ? { historical: !0 } : {}
|
|
2578
2578
|
};
|
|
2579
2579
|
}
|
|
2580
|
-
function
|
|
2580
|
+
function Cr(e) {
|
|
2581
2581
|
if (e.type !== "imageGeneration" || R(e)?.status !== "completed") return null;
|
|
2582
|
-
let t = typeof e.savedPath == "string" && v(e.savedPath) ? e.savedPath : null, n = t ?
|
|
2582
|
+
let t = typeof e.savedPath == "string" && v(e.savedPath) ? e.savedPath : null, n = t ? Mr(t) : void 0, r = n && gr.has(n) ? t : null, i = Nr("result" in e && typeof e.result == "string" ? e.result.trim() : ""), a = i?.url ?? (r ? oe(r).href : void 0);
|
|
2583
2583
|
if (!a) return null;
|
|
2584
2584
|
let o = typeof e.revisedPrompt == "string" ? e.revisedPrompt.trim() : "";
|
|
2585
2585
|
return {
|
|
@@ -2594,8 +2594,8 @@ function Sr(e) {
|
|
|
2594
2594
|
}
|
|
2595
2595
|
};
|
|
2596
2596
|
}
|
|
2597
|
-
function
|
|
2598
|
-
let t =
|
|
2597
|
+
function wr(e) {
|
|
2598
|
+
let t = Cr(e);
|
|
2599
2599
|
if (t) return [t];
|
|
2600
2600
|
let n = e.type === "mcpToolCall" && e.status === "completed" ? e.result?.content : e.type === "dynamicToolCall" && e.status === "completed" ? e.contentItems : void 0;
|
|
2601
2601
|
if (!Array.isArray(n)) return [];
|
|
@@ -2604,7 +2604,7 @@ function Cr(e) {
|
|
|
2604
2604
|
if (!t || typeof t != "object" || Array.isArray(t) || r.length >= 8) continue;
|
|
2605
2605
|
let n = t, a = n.type === "image" && typeof n.data == "string" ? n.data : n.type === "inputImage" && typeof n.imageUrl == "string" ? n.imageUrl : "";
|
|
2606
2606
|
if (a.length > i) continue;
|
|
2607
|
-
let o =
|
|
2607
|
+
let o = Nr(a);
|
|
2608
2608
|
o && (i -= o.url.length, r.push({
|
|
2609
2609
|
type: "media",
|
|
2610
2610
|
itemId: r.length ? `${e.id}:image:${r.length}` : e.id,
|
|
@@ -2618,21 +2618,21 @@ function Cr(e) {
|
|
|
2618
2618
|
}
|
|
2619
2619
|
return r;
|
|
2620
2620
|
}
|
|
2621
|
-
function
|
|
2622
|
-
let t = Array.isArray(e.content) ? e.content : [], n = t.some((e) =>
|
|
2621
|
+
function Tr(e) {
|
|
2622
|
+
let t = Array.isArray(e.content) ? e.content : [], n = t.some((e) => q(e) && e.type === "text" && typeof e.text == "string" && e.text.length > 0), r = [], i = [], a = /* @__PURE__ */ new Set(), o = () => {
|
|
2623
2623
|
i.length > 0 && r.push({
|
|
2624
2624
|
type: "text",
|
|
2625
2625
|
text: i.join("\n")
|
|
2626
2626
|
}), i = [];
|
|
2627
2627
|
};
|
|
2628
2628
|
for (let e of t) {
|
|
2629
|
-
if (
|
|
2629
|
+
if (q(e) && e.type === "skill" && typeof e.name == "string") {
|
|
2630
2630
|
if (n) continue;
|
|
2631
2631
|
let t = e.name.toLowerCase();
|
|
2632
2632
|
if (a.has(t)) continue;
|
|
2633
2633
|
a.add(t);
|
|
2634
2634
|
}
|
|
2635
|
-
let t =
|
|
2635
|
+
let t = Er(e), s = Nt(t);
|
|
2636
2636
|
if (s) {
|
|
2637
2637
|
o(), r.push({
|
|
2638
2638
|
type: "attachment",
|
|
@@ -2647,7 +2647,7 @@ function wr(e) {
|
|
|
2647
2647
|
i.push(t);
|
|
2648
2648
|
continue;
|
|
2649
2649
|
}
|
|
2650
|
-
let c =
|
|
2650
|
+
let c = Ar(e);
|
|
2651
2651
|
c && (o(), r.push({
|
|
2652
2652
|
type: "attachment",
|
|
2653
2653
|
attachment: c
|
|
@@ -2655,26 +2655,26 @@ function wr(e) {
|
|
|
2655
2655
|
}
|
|
2656
2656
|
return o(), r;
|
|
2657
2657
|
}
|
|
2658
|
-
function Tr(e) {
|
|
2659
|
-
return !J(e) || typeof e.type != "string" ? "" : e.type === "text" && typeof e.text == "string" ? Or(e.text)?.displayText ?? e.text : e.type === "skill" && typeof e.name == "string" ? `$${e.name}` : "";
|
|
2660
|
-
}
|
|
2661
2658
|
function Er(e) {
|
|
2659
|
+
return !q(e) || typeof e.type != "string" ? "" : e.type === "text" && typeof e.text == "string" ? kr(e.text)?.displayText ?? e.text : e.type === "skill" && typeof e.name == "string" ? `$${e.name}` : "";
|
|
2660
|
+
}
|
|
2661
|
+
function Dr(e) {
|
|
2662
2662
|
let t = /* @__PURE__ */ new Set();
|
|
2663
|
-
for (let n of Array.isArray(e.content) ? e.content : []) if (!(!
|
|
2663
|
+
for (let n of Array.isArray(e.content) ? e.content : []) if (!(!q(n) || n.type !== "text" || typeof n.text != "string")) for (let e of kr(n.text)?.requestIds ?? []) t.add(e);
|
|
2664
2664
|
return [...t];
|
|
2665
2665
|
}
|
|
2666
|
-
function
|
|
2666
|
+
function Or(e) {
|
|
2667
2667
|
let t = {};
|
|
2668
|
-
for (let n of Array.isArray(e.content) ? e.content : []) !
|
|
2668
|
+
for (let n of Array.isArray(e.content) ? e.content : []) !q(n) || n.type !== "text" || typeof n.text != "string" || Object.assign(t, kr(n.text)?.answers);
|
|
2669
2669
|
return t;
|
|
2670
2670
|
}
|
|
2671
|
-
function
|
|
2671
|
+
function kr(e) {
|
|
2672
2672
|
let t = e.match(/^<send_user_message_question_reply>\s*([\s\S]*?)\s*<\/send_user_message_question_reply>$/);
|
|
2673
2673
|
if (!t?.[1]) return null;
|
|
2674
2674
|
try {
|
|
2675
2675
|
let e = JSON.parse(t[1]);
|
|
2676
2676
|
if (!Array.isArray(e)) return null;
|
|
2677
|
-
let n = e.filter((e) =>
|
|
2677
|
+
let n = e.filter((e) => q(e) && typeof e.questionItemId == "string" && typeof e.question == "string" && typeof e.answer == "string");
|
|
2678
2678
|
if (n.length === 0) return null;
|
|
2679
2679
|
let r = n.flatMap((e) => {
|
|
2680
2680
|
try {
|
|
@@ -2692,10 +2692,10 @@ function Or(e) {
|
|
|
2692
2692
|
return null;
|
|
2693
2693
|
}
|
|
2694
2694
|
}
|
|
2695
|
-
function
|
|
2696
|
-
if (!
|
|
2695
|
+
function Ar(e) {
|
|
2696
|
+
if (!q(e) || typeof e.type != "string") return null;
|
|
2697
2697
|
if (e.type === "mention" && typeof e.path == "string") {
|
|
2698
|
-
let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() :
|
|
2698
|
+
let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() : jr(e.path, "File"), n = Mr(e.path);
|
|
2699
2699
|
return {
|
|
2700
2700
|
kind: "file",
|
|
2701
2701
|
name: t,
|
|
@@ -2704,26 +2704,26 @@ function kr(e) {
|
|
|
2704
2704
|
};
|
|
2705
2705
|
}
|
|
2706
2706
|
if (e.type === "image" && typeof e.url == "string") {
|
|
2707
|
-
let t =
|
|
2707
|
+
let t = Mr(e.url);
|
|
2708
2708
|
return {
|
|
2709
2709
|
kind: "image",
|
|
2710
|
-
name:
|
|
2710
|
+
name: jr(e.url, "Image"),
|
|
2711
2711
|
url: e.url,
|
|
2712
2712
|
...t ? { mimeType: t } : {}
|
|
2713
2713
|
};
|
|
2714
2714
|
}
|
|
2715
2715
|
if (e.type === "localImage" && typeof e.path == "string") {
|
|
2716
|
-
let t =
|
|
2716
|
+
let t = Mr(e.path);
|
|
2717
2717
|
return {
|
|
2718
2718
|
kind: "image",
|
|
2719
|
-
name:
|
|
2719
|
+
name: jr(e.path, "Image"),
|
|
2720
2720
|
path: e.path,
|
|
2721
2721
|
...t ? { mimeType: t } : {}
|
|
2722
2722
|
};
|
|
2723
2723
|
}
|
|
2724
2724
|
return null;
|
|
2725
2725
|
}
|
|
2726
|
-
function
|
|
2726
|
+
function jr(e, t) {
|
|
2727
2727
|
try {
|
|
2728
2728
|
let n = /^[a-z][a-z\d+.-]*:/i.test(e) ? new URL(e).pathname : e;
|
|
2729
2729
|
return g(decodeURIComponent(n)).trim() || t;
|
|
@@ -2731,7 +2731,7 @@ function Ar(e, t) {
|
|
|
2731
2731
|
return g(e).trim() || t;
|
|
2732
2732
|
}
|
|
2733
2733
|
}
|
|
2734
|
-
function
|
|
2734
|
+
function Mr(e) {
|
|
2735
2735
|
let t = /^data:([^;,]+)/i.exec(e)?.[1]?.toLowerCase();
|
|
2736
2736
|
if (t) return t;
|
|
2737
2737
|
let n = "";
|
|
@@ -2753,23 +2753,23 @@ function jr(e) {
|
|
|
2753
2753
|
webp: "image/webp"
|
|
2754
2754
|
}[n];
|
|
2755
2755
|
}
|
|
2756
|
-
function
|
|
2756
|
+
function Nr(e) {
|
|
2757
2757
|
if (!e) return null;
|
|
2758
|
-
let t = (/^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]+)$/i.exec(e)?.[1] ?? e).replace(/\s+/g, ""), n = Math.ceil(
|
|
2758
|
+
let t = (/^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]+)$/i.exec(e)?.[1] ?? e).replace(/\s+/g, ""), n = Math.ceil(hr / 3) * 4 + 4;
|
|
2759
2759
|
if (!t || t.length > n || t.length % 4 != 0 || !/^[a-z0-9+/]+={0,2}$/i.test(t)) return null;
|
|
2760
2760
|
let r = Buffer.from(t, "base64");
|
|
2761
|
-
if (r.byteLength === 0 || r.byteLength >
|
|
2762
|
-
let i =
|
|
2761
|
+
if (r.byteLength === 0 || r.byteLength > hr) return null;
|
|
2762
|
+
let i = Fr(r);
|
|
2763
2763
|
return i ? {
|
|
2764
2764
|
url: `data:${i};base64,${t}`,
|
|
2765
2765
|
mimeType: i
|
|
2766
2766
|
} : null;
|
|
2767
2767
|
}
|
|
2768
|
-
function
|
|
2768
|
+
function Pr(e) {
|
|
2769
2769
|
return !!(e && e.length <= 16 * 1024 * 1024 && /^data:image\/(?:avif|bmp|gif|heic|heif|jpe?g|png|webp);base64,[a-z\d+/]+={0,2}$/i.test(e));
|
|
2770
2770
|
}
|
|
2771
|
-
function
|
|
2772
|
-
if (
|
|
2771
|
+
function Fr(e) {
|
|
2772
|
+
if (Ir(e, [
|
|
2773
2773
|
137,
|
|
2774
2774
|
80,
|
|
2775
2775
|
78,
|
|
@@ -2779,7 +2779,7 @@ function Pr(e) {
|
|
|
2779
2779
|
26,
|
|
2780
2780
|
10
|
|
2781
2781
|
])) return "image/png";
|
|
2782
|
-
if (
|
|
2782
|
+
if (Ir(e, [
|
|
2783
2783
|
255,
|
|
2784
2784
|
216,
|
|
2785
2785
|
255
|
|
@@ -2787,50 +2787,50 @@ function Pr(e) {
|
|
|
2787
2787
|
let t = Buffer.from(e.subarray(0, 12)).toString("ascii");
|
|
2788
2788
|
return t.startsWith("GIF87a") || t.startsWith("GIF89a") ? "image/gif" : t.startsWith("RIFF") && t.slice(8, 12) === "WEBP" ? "image/webp" : e.byteLength >= 12 && t.slice(4, 12) === "ftypavif" ? "image/avif" : null;
|
|
2789
2789
|
}
|
|
2790
|
-
function
|
|
2790
|
+
function Ir(e, t) {
|
|
2791
2791
|
return t.every((t, n) => e[n] === t);
|
|
2792
2792
|
}
|
|
2793
|
-
function
|
|
2793
|
+
function Lr(e) {
|
|
2794
2794
|
return e === "inProgress" ? "streaming" : e === "failed" ? "error" : "complete";
|
|
2795
2795
|
}
|
|
2796
|
-
function
|
|
2796
|
+
function Rr(e) {
|
|
2797
2797
|
return typeof e != "number" || !Number.isFinite(e) ? (/* @__PURE__ */ new Date(0)).toISOString() : (/* @__PURE__ */ new Date(e * 1e3)).toISOString();
|
|
2798
2798
|
}
|
|
2799
|
-
function
|
|
2799
|
+
function q(e) {
|
|
2800
2800
|
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
2801
2801
|
}
|
|
2802
2802
|
//#endregion
|
|
2803
2803
|
//#region src/node/codex-raw-response-item-adapter.ts
|
|
2804
|
-
function
|
|
2805
|
-
if (!
|
|
2804
|
+
function zr(e) {
|
|
2805
|
+
if (!Jr(e) || typeof e.type != "string") return null;
|
|
2806
2806
|
if (e.type === "local_shell_call") {
|
|
2807
|
-
let t = R(
|
|
2807
|
+
let t = R(Br(e));
|
|
2808
2808
|
return {
|
|
2809
|
-
type:
|
|
2809
|
+
type: Wr(e.status) ? "item.completed" : "item.started",
|
|
2810
2810
|
payload: { toolPart: t }
|
|
2811
2811
|
};
|
|
2812
2812
|
}
|
|
2813
2813
|
return e.type === "function_call" ? {
|
|
2814
2814
|
type: "item.started",
|
|
2815
|
-
payload: { toolPart: R(
|
|
2816
|
-
} : e.type === "function_call_output" ?
|
|
2815
|
+
payload: { toolPart: R(Vr(e)) }
|
|
2816
|
+
} : e.type === "function_call_output" ? Hr(e.call_id, e.output) : e.type === "custom_tool_call" ? {
|
|
2817
2817
|
type: "item.started",
|
|
2818
2818
|
payload: { toolPart: R({
|
|
2819
2819
|
type: "dynamicToolCall",
|
|
2820
|
-
id:
|
|
2820
|
+
id: Y(e.call_id) ?? J(e),
|
|
2821
2821
|
namespace: null,
|
|
2822
|
-
tool:
|
|
2822
|
+
tool: Y(e.name) ?? "custom_tool",
|
|
2823
2823
|
status: e.status,
|
|
2824
|
-
arguments:
|
|
2824
|
+
arguments: Y(e.input) ?? "",
|
|
2825
2825
|
contentItems: null,
|
|
2826
2826
|
success: null,
|
|
2827
2827
|
durationMs: null
|
|
2828
2828
|
}) }
|
|
2829
|
-
} : e.type === "custom_tool_call_output" ?
|
|
2829
|
+
} : e.type === "custom_tool_call_output" ? Hr(e.call_id, e.output, Y(e.name) ?? void 0) : e.type === "tool_search_call" ? {
|
|
2830
2830
|
type: "item.started",
|
|
2831
2831
|
payload: { toolPart: R({
|
|
2832
2832
|
type: "dynamicToolCall",
|
|
2833
|
-
id:
|
|
2833
|
+
id: Y(e.call_id) ?? J(e),
|
|
2834
2834
|
namespace: "codex",
|
|
2835
2835
|
tool: "tool_search",
|
|
2836
2836
|
status: e.status,
|
|
@@ -2842,20 +2842,20 @@ function Rr(e) {
|
|
|
2842
2842
|
}) }
|
|
2843
2843
|
} : e.type === "tool_search_output" ? {
|
|
2844
2844
|
type: "item.updated",
|
|
2845
|
-
payload: Tn(
|
|
2845
|
+
payload: Tn(Y(e.call_id) ?? J(e), e.tools, "tool_search", e.status)
|
|
2846
2846
|
} : e.type === "web_search_call" ? {
|
|
2847
2847
|
type: "item.completed",
|
|
2848
2848
|
payload: { toolPart: R({
|
|
2849
2849
|
type: "webSearch",
|
|
2850
|
-
id:
|
|
2851
|
-
query:
|
|
2850
|
+
id: J(e),
|
|
2851
|
+
query: Kr(e.action),
|
|
2852
2852
|
action: e.action
|
|
2853
2853
|
}) }
|
|
2854
2854
|
} : e.type === "image_generation_call" ? {
|
|
2855
2855
|
type: "item.completed",
|
|
2856
2856
|
payload: { toolPart: R({
|
|
2857
2857
|
type: "dynamicToolCall",
|
|
2858
|
-
id:
|
|
2858
|
+
id: Y(e.id) ?? J(e),
|
|
2859
2859
|
namespace: null,
|
|
2860
2860
|
tool: "image_generation",
|
|
2861
2861
|
status: e.status,
|
|
@@ -2866,29 +2866,29 @@ function Rr(e) {
|
|
|
2866
2866
|
}) }
|
|
2867
2867
|
} : null;
|
|
2868
2868
|
}
|
|
2869
|
-
function
|
|
2870
|
-
let t =
|
|
2869
|
+
function Br(e) {
|
|
2870
|
+
let t = Jr(e.action) ? e.action : {}, n = Array.isArray(t.command) ? qr(t.command) : Y(t.command) ?? "local shell";
|
|
2871
2871
|
return {
|
|
2872
2872
|
type: "commandExecution",
|
|
2873
|
-
id:
|
|
2873
|
+
id: Y(e.call_id) ?? J(e),
|
|
2874
2874
|
command: n,
|
|
2875
|
-
cwd:
|
|
2875
|
+
cwd: Y(t.working_directory) ?? "",
|
|
2876
2876
|
processId: null,
|
|
2877
2877
|
source: "agent",
|
|
2878
|
-
status:
|
|
2878
|
+
status: Ur(e.status),
|
|
2879
2879
|
commandActions: [],
|
|
2880
2880
|
aggregatedOutput: null,
|
|
2881
2881
|
exitCode: null,
|
|
2882
2882
|
durationMs: null
|
|
2883
2883
|
};
|
|
2884
2884
|
}
|
|
2885
|
-
function
|
|
2886
|
-
let t =
|
|
2887
|
-
return t === "shell_command" &&
|
|
2885
|
+
function Vr(e) {
|
|
2886
|
+
let t = Y(e.name) ?? "function_call", n = Gr(e.arguments), r = Y(e.call_id) ?? J(e);
|
|
2887
|
+
return t === "shell_command" && Jr(n) ? {
|
|
2888
2888
|
type: "commandExecution",
|
|
2889
2889
|
id: r,
|
|
2890
|
-
command:
|
|
2891
|
-
cwd:
|
|
2890
|
+
command: Y(n.command) ?? t,
|
|
2891
|
+
cwd: Y(n.workdir) ?? Y(n.cwd) ?? "",
|
|
2892
2892
|
processId: null,
|
|
2893
2893
|
source: "agent",
|
|
2894
2894
|
status: "inProgress",
|
|
@@ -2899,7 +2899,7 @@ function Br(e) {
|
|
|
2899
2899
|
} : {
|
|
2900
2900
|
type: "dynamicToolCall",
|
|
2901
2901
|
id: r,
|
|
2902
|
-
namespace:
|
|
2902
|
+
namespace: Y(e.namespace),
|
|
2903
2903
|
tool: t,
|
|
2904
2904
|
status: "inProgress",
|
|
2905
2905
|
arguments: n,
|
|
@@ -2908,19 +2908,19 @@ function Br(e) {
|
|
|
2908
2908
|
durationMs: null
|
|
2909
2909
|
};
|
|
2910
2910
|
}
|
|
2911
|
-
function
|
|
2911
|
+
function Hr(e, t, n) {
|
|
2912
2912
|
return {
|
|
2913
2913
|
type: "item.updated",
|
|
2914
|
-
payload: Tn(
|
|
2914
|
+
payload: Tn(Y(e) ?? "raw-response-output", t, n)
|
|
2915
2915
|
};
|
|
2916
2916
|
}
|
|
2917
|
-
function
|
|
2917
|
+
function Ur(e) {
|
|
2918
2918
|
return e === "completed" ? "completed" : e === "incomplete" || e === "failed" || e === "error" ? "failed" : "inProgress";
|
|
2919
2919
|
}
|
|
2920
|
-
function
|
|
2920
|
+
function Wr(e) {
|
|
2921
2921
|
return e === "completed" || e === "failed" || e === "error" || e === "incomplete";
|
|
2922
2922
|
}
|
|
2923
|
-
function
|
|
2923
|
+
function Gr(e) {
|
|
2924
2924
|
if (typeof e != "string") return e;
|
|
2925
2925
|
try {
|
|
2926
2926
|
return JSON.parse(e);
|
|
@@ -2928,54 +2928,54 @@ function Wr(e) {
|
|
|
2928
2928
|
return e;
|
|
2929
2929
|
}
|
|
2930
2930
|
}
|
|
2931
|
-
function Gr(e) {
|
|
2932
|
-
return qr(e) ? X(e.query) ?? X(e.searchTerm) ?? "web search" : "web search";
|
|
2933
|
-
}
|
|
2934
2931
|
function Kr(e) {
|
|
2932
|
+
return Jr(e) ? Y(e.query) ?? Y(e.searchTerm) ?? "web search" : "web search";
|
|
2933
|
+
}
|
|
2934
|
+
function qr(e) {
|
|
2935
2935
|
return e.map((e) => {
|
|
2936
2936
|
let t = String(e);
|
|
2937
2937
|
return /\s/.test(t) ? JSON.stringify(t) : t;
|
|
2938
2938
|
}).join(" ");
|
|
2939
2939
|
}
|
|
2940
|
-
function
|
|
2941
|
-
return (
|
|
2940
|
+
function J(e) {
|
|
2941
|
+
return (Y(e.call_id) ?? Y(e.id)) || `raw-${e.type}`;
|
|
2942
2942
|
}
|
|
2943
|
-
function
|
|
2943
|
+
function Y(e) {
|
|
2944
2944
|
return typeof e == "string" && e.length > 0 ? e : null;
|
|
2945
2945
|
}
|
|
2946
|
-
function
|
|
2946
|
+
function Jr(e) {
|
|
2947
2947
|
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
2948
2948
|
}
|
|
2949
2949
|
//#endregion
|
|
2950
2950
|
//#region src/node/codex-surface-events.ts
|
|
2951
|
-
function
|
|
2951
|
+
function Yr(e, t) {
|
|
2952
2952
|
return `${e}\u0000${t}`;
|
|
2953
2953
|
}
|
|
2954
|
-
function
|
|
2954
|
+
function Xr(e) {
|
|
2955
2955
|
return typeof e == "number" && Number.isFinite(e) ? (/* @__PURE__ */ new Date(e * 1e3)).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
|
|
2956
2956
|
}
|
|
2957
|
-
function
|
|
2957
|
+
function Zr(e) {
|
|
2958
2958
|
return typeof e == "number" && Number.isFinite(e) ? (/* @__PURE__ */ new Date(e * 1e3)).toISOString() : null;
|
|
2959
2959
|
}
|
|
2960
|
-
function
|
|
2960
|
+
function Qr(e) {
|
|
2961
2961
|
return e ? {
|
|
2962
2962
|
message: e.message,
|
|
2963
2963
|
additionalDetails: e.additionalDetails,
|
|
2964
2964
|
codexErrorInfo: e.codexErrorInfo
|
|
2965
2965
|
} : null;
|
|
2966
2966
|
}
|
|
2967
|
-
function
|
|
2967
|
+
function X(e, t = !1) {
|
|
2968
2968
|
return {
|
|
2969
2969
|
id: e.id,
|
|
2970
2970
|
status: e.status,
|
|
2971
|
-
error:
|
|
2971
|
+
error: Qr(e.error),
|
|
2972
2972
|
willRetry: t,
|
|
2973
|
-
startedAt:
|
|
2974
|
-
completedAt:
|
|
2973
|
+
startedAt: Zr(e.startedAt),
|
|
2974
|
+
completedAt: Zr(e.completedAt),
|
|
2975
2975
|
durationMs: e.durationMs ?? null
|
|
2976
2976
|
};
|
|
2977
2977
|
}
|
|
2978
|
-
function
|
|
2978
|
+
function Z(e, t) {
|
|
2979
2979
|
let n = e.findIndex((e) => e.id === t.id);
|
|
2980
2980
|
if (n < 0) return [...e, t];
|
|
2981
2981
|
let r = [...e];
|
|
@@ -2984,18 +2984,18 @@ function Q(e, t) {
|
|
|
2984
2984
|
startedAt: t.startedAt ?? e[n].startedAt
|
|
2985
2985
|
}), r;
|
|
2986
2986
|
}
|
|
2987
|
-
function
|
|
2987
|
+
function $r(e, t) {
|
|
2988
2988
|
return JSON.stringify(e) === JSON.stringify(t);
|
|
2989
2989
|
}
|
|
2990
|
-
function
|
|
2990
|
+
function ei() {
|
|
2991
2991
|
return `user-${globalThis.crypto.randomUUID()}`;
|
|
2992
2992
|
}
|
|
2993
|
-
function
|
|
2993
|
+
function ti() {
|
|
2994
2994
|
return `queued-prompt-${globalThis.crypto.randomUUID()}`;
|
|
2995
2995
|
}
|
|
2996
2996
|
//#endregion
|
|
2997
2997
|
//#region src/node/codex-surface-subagents.ts
|
|
2998
|
-
function
|
|
2998
|
+
function ni(e) {
|
|
2999
2999
|
let t = {};
|
|
3000
3000
|
for (let [n, r] of Object.entries(e.agentsStates)) r && (t[n] = {
|
|
3001
3001
|
status: r.status,
|
|
@@ -3015,7 +3015,7 @@ function ti(e) {
|
|
|
3015
3015
|
}
|
|
3016
3016
|
//#endregion
|
|
3017
3017
|
//#region src/node/codex-surface-items-controller.ts
|
|
3018
|
-
var
|
|
3018
|
+
var ri = class {
|
|
3019
3019
|
host;
|
|
3020
3020
|
commandOutputForwardItemIds = /* @__PURE__ */ new Set();
|
|
3021
3021
|
fileActivityKeys = /* @__PURE__ */ new Set();
|
|
@@ -3033,13 +3033,13 @@ var ni = class {
|
|
|
3033
3033
|
for (let e of this.reviewOutputByTurn.keys()) e.startsWith(t) && this.reviewOutputByTurn.delete(e);
|
|
3034
3034
|
}
|
|
3035
3035
|
isForwardingCommandOutput(e, t) {
|
|
3036
|
-
return this.commandOutputForwardItemIds.has(
|
|
3036
|
+
return this.commandOutputForwardItemIds.has(Yr(e, t));
|
|
3037
3037
|
}
|
|
3038
3038
|
applyAgentDelta(e) {
|
|
3039
3039
|
let t = this.host.requireRuntime(e.threadId);
|
|
3040
3040
|
this.host.markRuntimeTurnActive(t, e.turnId);
|
|
3041
3041
|
let n = t.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.itemId)?.phase;
|
|
3042
|
-
this.host.patchRuntime(e.threadId, { messages:
|
|
3042
|
+
this.host.patchRuntime(e.threadId, { messages: er(t.messages, e.threadId, e.turnId, e.itemId, e.delta, n) });
|
|
3043
3043
|
let r = this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
3044
3044
|
r && this.host.emitEvent("notification", {
|
|
3045
3045
|
type: "message.delta",
|
|
@@ -3057,7 +3057,7 @@ var ni = class {
|
|
|
3057
3057
|
let t = this.host.requireRuntime(e.threadId);
|
|
3058
3058
|
this.host.markRuntimeTurnActive(t, e.turnId);
|
|
3059
3059
|
let n = `${t.planMarkdownByTurn.get(e.turnId) ?? ""}${e.delta}`;
|
|
3060
|
-
t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, { messages:
|
|
3060
|
+
t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, { messages: W(t.messages, e.threadId, e.turnId, mr(e.turnId, n, "running")) }), this.host.emitEvent("notification", {
|
|
3061
3061
|
type: "plan.delta",
|
|
3062
3062
|
conversationId: e.threadId,
|
|
3063
3063
|
turnId: e.turnId,
|
|
@@ -3071,7 +3071,7 @@ var ni = class {
|
|
|
3071
3071
|
applyPlanUpdated(e) {
|
|
3072
3072
|
let t = this.host.requireRuntime(e.threadId);
|
|
3073
3073
|
this.host.markRuntimeTurnActive(t, e.turnId);
|
|
3074
|
-
let n =
|
|
3074
|
+
let n = pr(e.explanation, e.plan), r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3075
3075
|
t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, {
|
|
3076
3076
|
executionPlan: {
|
|
3077
3077
|
turnId: e.turnId,
|
|
@@ -3080,7 +3080,7 @@ var ni = class {
|
|
|
3080
3080
|
markdown: n,
|
|
3081
3081
|
updatedAt: r
|
|
3082
3082
|
},
|
|
3083
|
-
messages:
|
|
3083
|
+
messages: W(t.messages, e.threadId, e.turnId, mr(e.turnId, n, "completed"))
|
|
3084
3084
|
}), this.host.emitEvent("notification", {
|
|
3085
3085
|
type: "plan.updated",
|
|
3086
3086
|
conversationId: e.threadId,
|
|
@@ -3096,13 +3096,13 @@ var ni = class {
|
|
|
3096
3096
|
applyRawResponseItem(e) {
|
|
3097
3097
|
let t = this.host.requireRuntime(e.threadId);
|
|
3098
3098
|
this.host.markRuntimeTurnActive(t, e.turnId);
|
|
3099
|
-
let n =
|
|
3099
|
+
let n = zr(e.item);
|
|
3100
3100
|
if (!n) return;
|
|
3101
3101
|
if (n.type === "item.updated") {
|
|
3102
3102
|
this.applyToolUpdate(e.threadId, e.turnId, n.payload);
|
|
3103
3103
|
return;
|
|
3104
3104
|
}
|
|
3105
|
-
this.host.patchRuntime(e.threadId, { messages:
|
|
3105
|
+
this.host.patchRuntime(e.threadId, { messages: W(t.messages, e.threadId, e.turnId, n.payload.toolPart) });
|
|
3106
3106
|
let r = this.host.messageContainingTool(e.threadId, e.turnId, n.payload.toolPart.id);
|
|
3107
3107
|
r && (this.host.emitEvent("notification", {
|
|
3108
3108
|
type: n.type === "item.completed" ? "tool.completed" : "tool.started",
|
|
@@ -3123,7 +3123,7 @@ var ni = class {
|
|
|
3123
3123
|
startedAt: ("startedAtMs" in e ? e.startedAtMs : e.completedAtMs) / 1e3
|
|
3124
3124
|
};
|
|
3125
3125
|
if (e.item.type === "userMessage") {
|
|
3126
|
-
let t =
|
|
3126
|
+
let t = xr(e.threadId, i, e.item);
|
|
3127
3127
|
if (!t || n.messages.some((e) => e.id === t.id)) return;
|
|
3128
3128
|
let a = n.messages.some((t) => t.role === "assistant" && t.metadata?.turnId === e.turnId && t.parts.length > 0), o = !a && r ? n.messages.map((e) => e.role === "user" && e.kind !== "steer" && !e.turnId && JSON.stringify(e.parts) === JSON.stringify(t.parts)).lastIndexOf(!0) : -1;
|
|
3129
3129
|
if (o >= 0) {
|
|
@@ -3149,7 +3149,7 @@ var ni = class {
|
|
|
3149
3149
|
...t,
|
|
3150
3150
|
kind: "steer"
|
|
3151
3151
|
} : t, c = [...n.messages, s];
|
|
3152
|
-
this.host.patchRuntime(e.threadId, { messages: a ?
|
|
3152
|
+
this.host.patchRuntime(e.threadId, { messages: a ? U(c, e.threadId, e.turnId, { forceSegment: !0 }) : c }), this.host.emitEvent("notification", {
|
|
3153
3153
|
type: "message.appended",
|
|
3154
3154
|
conversationId: e.threadId,
|
|
3155
3155
|
turnId: e.turnId,
|
|
@@ -3160,7 +3160,7 @@ var ni = class {
|
|
|
3160
3160
|
if (e.item.type === "reasoning") {
|
|
3161
3161
|
if (e.item.summary.filter((e) => e.trim().length > 0).length === 0) return;
|
|
3162
3162
|
let t = this.host.assistantMessageForTurn(e.threadId, e.turnId), r = t ? JSON.stringify(t.parts) : null;
|
|
3163
|
-
this.host.patchRuntime(e.threadId, { messages:
|
|
3163
|
+
this.host.patchRuntime(e.threadId, { messages: tr(n.messages, e.threadId, e.turnId, e.item.id, e.item.summary) });
|
|
3164
3164
|
let i = this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
3165
3165
|
if (!i || JSON.stringify(i.parts) === r) return;
|
|
3166
3166
|
this.host.emitEvent("notification", {
|
|
@@ -3172,10 +3172,10 @@ var ni = class {
|
|
|
3172
3172
|
return;
|
|
3173
3173
|
}
|
|
3174
3174
|
if (e.item.type === "agentMessage" && t && n.planMode && e.item.phase === "final_answer") {
|
|
3175
|
-
let t =
|
|
3175
|
+
let t = ir(e.item.text);
|
|
3176
3176
|
if (t) {
|
|
3177
|
-
let r = this.host.assistantMessageForTurn(e.threadId, e.turnId), i =
|
|
3178
|
-
t.visibleText && (i =
|
|
3177
|
+
let r = this.host.assistantMessageForTurn(e.threadId, e.turnId), i = rr(n.messages, e.threadId, e.turnId, e.item.id);
|
|
3178
|
+
t.visibleText && (i = nr(i, e.threadId, e.turnId, e.item.id, t.visibleText, e.item.phase)), i = W(i, e.threadId, e.turnId, mr(e.turnId, t.markdown, "completed")), n.planMarkdownByTurn.set(e.turnId, t.markdown), this.host.patchRuntime(e.threadId, { messages: i });
|
|
3179
3179
|
let a = this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
3180
3180
|
a && this.host.emitEvent("notification", {
|
|
3181
3181
|
type: r ? "message.updated" : "message.appended",
|
|
@@ -3197,11 +3197,11 @@ var ni = class {
|
|
|
3197
3197
|
if (e.item.type === "agentMessage" || e.item.type === "exitedReviewMode") {
|
|
3198
3198
|
let t = e.item.type === "agentMessage" ? e.item.text : e.item.review, r = e.item.type === "agentMessage" ? e.item.phase ?? void 0 : void 0;
|
|
3199
3199
|
if (!t && e.item.type !== "agentMessage") return;
|
|
3200
|
-
let i =
|
|
3200
|
+
let i = Yr(e.threadId, e.turnId);
|
|
3201
3201
|
if (e.item.type === "agentMessage" && this.reviewOutputByTurn.get(i) === t) return;
|
|
3202
3202
|
e.item.type === "exitedReviewMode" && this.reviewOutputByTurn.set(i, t);
|
|
3203
|
-
let a = new Set(n.messages.map((e) => e.id)), o = this.host.assistantMessageForTurn(e.threadId, e.turnId), s = o ? JSON.stringify(o.parts) : null, c = new Set(o?.parts.flatMap((e) => e.type === "question" ? [e.request.id] : []) ?? []), l = n.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.item.id)?.text ?? "", u = e.item.type === "agentMessage" ?
|
|
3204
|
-
if (u && (f =
|
|
3203
|
+
let a = new Set(n.messages.map((e) => e.id)), o = this.host.assistantMessageForTurn(e.threadId, e.turnId), s = o ? JSON.stringify(o.parts) : null, c = new Set(o?.parts.flatMap((e) => e.type === "question" ? [e.request.id] : []) ?? []), l = n.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.item.id)?.text ?? "", u = e.item.type === "agentMessage" ? Sr(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? rr(n.messages, e.threadId, e.turnId, e.item.id) : nr(n.messages, e.threadId, e.turnId, e.item.id, t, r);
|
|
3204
|
+
if (u && (f = or(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u) return;
|
|
3205
3205
|
let p = this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
3206
3206
|
if (p && !a.has(p.id)) this.host.emitEvent("notification", {
|
|
3207
3207
|
type: "message.appended",
|
|
@@ -3245,7 +3245,7 @@ var ni = class {
|
|
|
3245
3245
|
if (e.item.type === "plan") {
|
|
3246
3246
|
if (!t) return;
|
|
3247
3247
|
let r = e.item.text.trim() || n.planMarkdownByTurn.get(e.turnId) || "";
|
|
3248
|
-
n.planMarkdownByTurn.set(e.turnId, r), this.host.patchRuntime(e.threadId, { messages:
|
|
3248
|
+
n.planMarkdownByTurn.set(e.turnId, r), this.host.patchRuntime(e.threadId, { messages: W(n.messages, e.threadId, e.turnId, mr(e.turnId, r, "completed")) }), this.host.emitEvent("notification", {
|
|
3249
3249
|
type: "plan.completed",
|
|
3250
3250
|
conversationId: e.threadId,
|
|
3251
3251
|
turnId: e.turnId,
|
|
@@ -3257,7 +3257,7 @@ var ni = class {
|
|
|
3257
3257
|
return;
|
|
3258
3258
|
}
|
|
3259
3259
|
if (e.item.type === "contextCompaction") {
|
|
3260
|
-
if (this.host.patchRuntime(e.threadId, { messages:
|
|
3260
|
+
if (this.host.patchRuntime(e.threadId, { messages: lr(n.messages, e.threadId, e.turnId, t ? "complete" : "streaming") }), t) {
|
|
3261
3261
|
let t = this.host.requireRuntime(e.threadId).messages.find((t) => t.kind === "compaction" && t.metadata?.turnId === e.turnId);
|
|
3262
3262
|
t && this.host.emitEvent("notification", {
|
|
3263
3263
|
type: "context.compactionCompleted",
|
|
@@ -3283,7 +3283,7 @@ var ni = class {
|
|
|
3283
3283
|
turnId: e.turnId,
|
|
3284
3284
|
payload: {
|
|
3285
3285
|
lifecycle: t ? "completed" : "started",
|
|
3286
|
-
toolCall:
|
|
3286
|
+
toolCall: ni(e.item)
|
|
3287
3287
|
}
|
|
3288
3288
|
});
|
|
3289
3289
|
return;
|
|
@@ -3308,10 +3308,10 @@ var ni = class {
|
|
|
3308
3308
|
let a = this.shouldForwardCommandOutput(e.threadId, t, e.item), o = R(e.item, {
|
|
3309
3309
|
includeCommandOutput: a,
|
|
3310
3310
|
cwd: n.cwd
|
|
3311
|
-
}), s =
|
|
3311
|
+
}), s = wr(e.item);
|
|
3312
3312
|
if (!o && !s.length) return;
|
|
3313
|
-
let c = s.some((e) => !n.messages.some((t) => t.parts.some((t) => t.type === "media" &&
|
|
3314
|
-
for (let t of s) l =
|
|
3313
|
+
let c = s.some((e) => !n.messages.some((t) => t.parts.some((t) => t.type === "media" && sr(t, e)))), l = o ? W(n.messages, e.threadId, e.turnId, o) : [...n.messages];
|
|
3314
|
+
for (let t of s) l = ar(l, e.threadId, e.turnId, t, e.item.id);
|
|
3315
3315
|
this.host.patchRuntime(e.threadId, { messages: l });
|
|
3316
3316
|
let u = o ? this.host.messageContainingTool(e.threadId, e.turnId, o.id) : this.host.assistantMessageForTurn(e.threadId, e.turnId);
|
|
3317
3317
|
u && o && this.host.emitEvent("notification", {
|
|
@@ -3332,7 +3332,7 @@ var ni = class {
|
|
|
3332
3332
|
shouldForwardCommandOutput(e, t, n) {
|
|
3333
3333
|
let r = "id" in n && typeof n.id == "string" ? n.id : null;
|
|
3334
3334
|
if (!r) return !1;
|
|
3335
|
-
let i =
|
|
3335
|
+
let i = Yr(e, r);
|
|
3336
3336
|
if (!t) {
|
|
3337
3337
|
let e = xn(n);
|
|
3338
3338
|
return e ? this.commandOutputForwardItemIds.add(i) : this.commandOutputForwardItemIds.delete(i), e;
|
|
@@ -3343,14 +3343,14 @@ var ni = class {
|
|
|
3343
3343
|
applyToolUpdate(e, t, n) {
|
|
3344
3344
|
let r = this.host.requireRuntime(e);
|
|
3345
3345
|
this.host.markRuntimeTurnActive(r, t);
|
|
3346
|
-
let i = r.cwd &&
|
|
3346
|
+
let i = r.cwd && ii(n) ? {
|
|
3347
3347
|
...n,
|
|
3348
3348
|
metadata: {
|
|
3349
3349
|
...n.metadata,
|
|
3350
3350
|
cwd: r.cwd
|
|
3351
3351
|
}
|
|
3352
3352
|
} : n;
|
|
3353
|
-
this.host.patchRuntime(e, { messages:
|
|
3353
|
+
this.host.patchRuntime(e, { messages: cr(r.messages, e, t, i) });
|
|
3354
3354
|
let a = this.host.messageContainingTool(e, t, n.itemId);
|
|
3355
3355
|
a && this.host.emitEvent("notification", {
|
|
3356
3356
|
type: "tool.updated",
|
|
@@ -3386,7 +3386,7 @@ var ni = class {
|
|
|
3386
3386
|
t.turnIds.includes(e.turn.id) || t.turnIds.push(e.turn.id);
|
|
3387
3387
|
let n = t.activeTurnId !== e.turn.id && t.turnStartPending;
|
|
3388
3388
|
t.activeTurnId === e.turn.id && (t.activeTurnId = null);
|
|
3389
|
-
let r = n || t.activeTurnId !== null, i = e.turn.status === "failed" ? "error" : "complete", a =
|
|
3389
|
+
let r = n || t.activeTurnId !== null, i = e.turn.status === "failed" ? "error" : "complete", a = ur(t.messages, e.turn.id, e.turn.status).map((t) => t.metadata?.turnId === e.turn.id ? {
|
|
3390
3390
|
...t,
|
|
3391
3391
|
status: i
|
|
3392
3392
|
} : t).filter((t) => !(t.role === "assistant" && t.metadata?.turnId === e.turn.id && t.kind === void 0 && t.parts.length === 0));
|
|
@@ -3398,7 +3398,7 @@ var ni = class {
|
|
|
3398
3398
|
},
|
|
3399
3399
|
turnStartPending: n,
|
|
3400
3400
|
messages: a,
|
|
3401
|
-
turns:
|
|
3401
|
+
turns: Z(t.turns, X(e.turn))
|
|
3402
3402
|
}), this.host.patch({ conversations: this.host.getState().conversations.map((n) => n.id === e.threadId ? {
|
|
3403
3403
|
...n,
|
|
3404
3404
|
status: r ? "active" : e.turn.status === "failed" ? "error" : "idle",
|
|
@@ -3412,26 +3412,26 @@ var ni = class {
|
|
|
3412
3412
|
turnId: e.turn.id,
|
|
3413
3413
|
payload: {
|
|
3414
3414
|
status: e.turn.status,
|
|
3415
|
-
error:
|
|
3415
|
+
error: Qr(e.turn.error),
|
|
3416
3416
|
willRetry: !1,
|
|
3417
|
-
startedAt:
|
|
3418
|
-
completedAt:
|
|
3417
|
+
startedAt: Zr(e.turn.startedAt),
|
|
3418
|
+
completedAt: Zr(e.turn.completedAt),
|
|
3419
3419
|
durationMs: e.turn.durationMs ?? null
|
|
3420
3420
|
}
|
|
3421
3421
|
}), this.host.emitConversationActivity(e.threadId, "notification"), t.planMarkdownByTurn.delete(e.turn.id), this.host.sendNextQueuedPrompt(e.threadId);
|
|
3422
3422
|
}
|
|
3423
3423
|
};
|
|
3424
|
-
function
|
|
3424
|
+
function ii(e) {
|
|
3425
3425
|
if (e.fallbackToolPart?.kind === "fileChange") return !0;
|
|
3426
3426
|
let t = e.input, n = e.metadata;
|
|
3427
|
-
return
|
|
3427
|
+
return ai(t) && Array.isArray(t.changes) || ai(n) && Array.isArray(n.changes);
|
|
3428
3428
|
}
|
|
3429
|
-
function
|
|
3429
|
+
function ai(e) {
|
|
3430
3430
|
return typeof e == "object" && !!e;
|
|
3431
3431
|
}
|
|
3432
3432
|
//#endregion
|
|
3433
3433
|
//#region src/node/codex-surface-client-requests-controller.ts
|
|
3434
|
-
var
|
|
3434
|
+
var oi = class {
|
|
3435
3435
|
host;
|
|
3436
3436
|
pending = /* @__PURE__ */ new Map();
|
|
3437
3437
|
constructor(e) {
|
|
@@ -3480,12 +3480,12 @@ var ai = class {
|
|
|
3480
3480
|
"deny"
|
|
3481
3481
|
].includes(r)) throw Error(`Invalid tool confirmation decision '${String(r)}'`);
|
|
3482
3482
|
this.pending.delete(t.id);
|
|
3483
|
-
let i = this.host.requireRuntime(n.threadId), a =
|
|
3483
|
+
let i = this.host.requireRuntime(n.threadId), a = fr(i.answeredClientRequestIds, t.id);
|
|
3484
3484
|
if (n.kind === "ask_user") {
|
|
3485
3485
|
let e = t.payload?.answers ?? {};
|
|
3486
3486
|
n.responder.resolve({ answers: e }), this.host.patchRuntime(n.threadId, {
|
|
3487
3487
|
answeredClientRequestIds: a,
|
|
3488
|
-
messages:
|
|
3488
|
+
messages: cr(i.messages, n.threadId, n.turnId, {
|
|
3489
3489
|
itemId: n.itemId,
|
|
3490
3490
|
output: { answers: e }
|
|
3491
3491
|
})
|
|
@@ -3494,7 +3494,7 @@ var ai = class {
|
|
|
3494
3494
|
let e = r;
|
|
3495
3495
|
n.responder.resolve(et(e)), this.host.patchRuntime(n.threadId, {
|
|
3496
3496
|
answeredClientRequestIds: a,
|
|
3497
|
-
messages:
|
|
3497
|
+
messages: cr(i.messages, n.threadId, n.displayTurnId, {
|
|
3498
3498
|
itemId: n.itemId,
|
|
3499
3499
|
output: { decision: e }
|
|
3500
3500
|
})
|
|
@@ -3533,7 +3533,7 @@ var ai = class {
|
|
|
3533
3533
|
${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ? s[0].answer : s.map((e) => `${e.question}: ${e.answer}`).join("\n");
|
|
3534
3534
|
await this.host.answerAsyncQuestion(a.runtime.threadId, e, t);
|
|
3535
3535
|
}
|
|
3536
|
-
this.host.patchRuntime(a.runtime.threadId, { answeredClientRequestIds:
|
|
3536
|
+
this.host.patchRuntime(a.runtime.threadId, { answeredClientRequestIds: fr(a.runtime.answeredClientRequestIds, t.id) }), this.host.emitEvent("action", {
|
|
3537
3537
|
type: "clientRequest.resolved",
|
|
3538
3538
|
conversationId: a.runtime.threadId,
|
|
3539
3539
|
...a.request.turnId ? { turnId: a.request.turnId } : {},
|
|
@@ -3548,7 +3548,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
|
|
|
3548
3548
|
let n = this.pending.get(e);
|
|
3549
3549
|
if (this.pending.delete(e), n) {
|
|
3550
3550
|
let t = this.host.requireRuntime(n.threadId);
|
|
3551
|
-
this.host.patchRuntime(n.threadId, { answeredClientRequestIds:
|
|
3551
|
+
this.host.patchRuntime(n.threadId, { answeredClientRequestIds: fr(t.answeredClientRequestIds, e) });
|
|
3552
3552
|
}
|
|
3553
3553
|
this.maybeClearWaitingBusy(t), n && this.host.emitEvent("notification", {
|
|
3554
3554
|
type: "clientRequest.resolved",
|
|
@@ -3596,7 +3596,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
|
|
|
3596
3596
|
responder: t
|
|
3597
3597
|
}), this.host.patchRuntime(n, {
|
|
3598
3598
|
busy: !0,
|
|
3599
|
-
messages:
|
|
3599
|
+
messages: W(o.messages, n, r, {
|
|
3600
3600
|
type: "tool",
|
|
3601
3601
|
id: i,
|
|
3602
3602
|
kind: "generic",
|
|
@@ -3695,7 +3695,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
|
|
|
3695
3695
|
};
|
|
3696
3696
|
this.host.patchRuntime(n.threadId, {
|
|
3697
3697
|
busy: !0,
|
|
3698
|
-
messages:
|
|
3698
|
+
messages: W(o.messages, n.threadId, s, f)
|
|
3699
3699
|
});
|
|
3700
3700
|
let p = this.host.messageContainingTool(n.threadId, s, l);
|
|
3701
3701
|
return p && this.host.emitEvent("notification", {
|
|
@@ -3713,8 +3713,8 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
|
|
|
3713
3713
|
payload: { request: structuredClone(d) }
|
|
3714
3714
|
}), this.host.emitConversationActivity(n.threadId, "notification"), !0;
|
|
3715
3715
|
}
|
|
3716
|
-
},
|
|
3717
|
-
function
|
|
3716
|
+
}, si = 256 * 1024;
|
|
3717
|
+
function ci(e) {
|
|
3718
3718
|
return {
|
|
3719
3719
|
id: e.id,
|
|
3720
3720
|
model: e.model,
|
|
@@ -3739,11 +3739,11 @@ function si(e) {
|
|
|
3739
3739
|
}
|
|
3740
3740
|
};
|
|
3741
3741
|
}
|
|
3742
|
-
async function ci(e, t) {
|
|
3743
|
-
return Promise.all(e.filter((e) => e.enabled).map((e) => li(e, t)));
|
|
3744
|
-
}
|
|
3745
3742
|
async function li(e, t) {
|
|
3746
|
-
|
|
3743
|
+
return Promise.all(e.filter((e) => e.enabled).map((e) => ui(e, t)));
|
|
3744
|
+
}
|
|
3745
|
+
async function ui(e, t) {
|
|
3746
|
+
let n = Q(e.interface?.brandColor), r = gi(e.interface?.defaultPrompt), [i, a] = await Promise.all([e.interface?.iconSmall ? t(e.interface.iconSmall) : void 0, e.interface?.iconLarge ? t(e.interface.iconLarge) : void 0]);
|
|
3747
3747
|
return {
|
|
3748
3748
|
name: e.name,
|
|
3749
3749
|
description: e.description,
|
|
@@ -3758,8 +3758,8 @@ async function li(e, t) {
|
|
|
3758
3758
|
enabled: e.enabled
|
|
3759
3759
|
};
|
|
3760
3760
|
}
|
|
3761
|
-
async function
|
|
3762
|
-
let n = e.interface, r =
|
|
3761
|
+
async function di(e, t) {
|
|
3762
|
+
let n = e.interface, r = pi(n?.composerIconUrl), i = pi(n?.logoUrl), a = pi(n?.logoUrlDark), o = Q(n?.displayName) ?? e.name, s = Q(n?.shortDescription), c = Q(n?.longDescription), l = Q(n?.brandColor), u = r ?? i ?? await fi([n?.composerIcon, n?.logo], t), d = r ?? a ?? i ?? await fi([
|
|
3763
3763
|
n?.composerIcon,
|
|
3764
3764
|
n?.logoDark,
|
|
3765
3765
|
n?.logo
|
|
@@ -3776,20 +3776,20 @@ async function ui(e, t) {
|
|
|
3776
3776
|
enabled: e.enabled
|
|
3777
3777
|
};
|
|
3778
3778
|
}
|
|
3779
|
-
async function
|
|
3779
|
+
async function fi(e, t) {
|
|
3780
3780
|
for (let n of e) {
|
|
3781
3781
|
if (!n) continue;
|
|
3782
3782
|
let e = await t(n);
|
|
3783
3783
|
if (e) return e;
|
|
3784
3784
|
}
|
|
3785
3785
|
}
|
|
3786
|
-
function
|
|
3787
|
-
let t =
|
|
3786
|
+
function pi(e) {
|
|
3787
|
+
let t = Q(e);
|
|
3788
3788
|
try {
|
|
3789
3789
|
return new URL(t).protocol === "https:" ? t : void 0;
|
|
3790
3790
|
} catch {}
|
|
3791
3791
|
}
|
|
3792
|
-
function
|
|
3792
|
+
function mi(e) {
|
|
3793
3793
|
switch (_(e).toLowerCase()) {
|
|
3794
3794
|
case ".avif": return "image/avif";
|
|
3795
3795
|
case ".bmp": return "image/bmp";
|
|
@@ -3802,23 +3802,23 @@ function pi(e) {
|
|
|
3802
3802
|
case ".webp": return "image/webp";
|
|
3803
3803
|
}
|
|
3804
3804
|
}
|
|
3805
|
-
function
|
|
3805
|
+
function hi(e, t) {
|
|
3806
3806
|
let n = t.trim();
|
|
3807
3807
|
if (!/^[a-z\d+/]+={0,2}$/i.test(n)) return;
|
|
3808
3808
|
let r = n.replace(/=+$/, "");
|
|
3809
3809
|
if (r.length % 4 == 1) return;
|
|
3810
3810
|
let i = n.length - r.length, a = (4 - r.length % 4) % 4;
|
|
3811
|
-
if (!(i !== 0 && i !== a) && !(Math.floor(r.length * 3 / 4) >
|
|
3811
|
+
if (!(i !== 0 && i !== a) && !(Math.floor(r.length * 3 / 4) > si)) return `data:${e};base64,${`${r}${"=".repeat((4 - r.length % 4) % 4)}`}`;
|
|
3812
3812
|
}
|
|
3813
|
-
function
|
|
3813
|
+
function Q(e) {
|
|
3814
3814
|
return (typeof e == "string" ? e.trim() : void 0) || void 0;
|
|
3815
3815
|
}
|
|
3816
|
-
function
|
|
3816
|
+
function gi(e) {
|
|
3817
3817
|
return typeof e == "string" ? e : void 0;
|
|
3818
3818
|
}
|
|
3819
3819
|
//#endregion
|
|
3820
3820
|
//#region src/node/codex-surface-catalog-controller.ts
|
|
3821
|
-
var
|
|
3821
|
+
var _i = class {
|
|
3822
3822
|
client;
|
|
3823
3823
|
cwd;
|
|
3824
3824
|
host;
|
|
@@ -3853,7 +3853,7 @@ var gi = class {
|
|
|
3853
3853
|
async loadSkills(e = !1, t = "action") {
|
|
3854
3854
|
e && this.iconDataUrls.clear(), this.host.patch({ skillCatalogStatus: "loading" }), this.emitSkills(this.cwd ?? null, [], "loading", t);
|
|
3855
3855
|
try {
|
|
3856
|
-
let n = await
|
|
3856
|
+
let n = await li((await this.client.request("skills/list", {
|
|
3857
3857
|
...this.cwd ? { cwds: [this.cwd] } : {},
|
|
3858
3858
|
forceReload: e
|
|
3859
3859
|
})).data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e));
|
|
@@ -3870,7 +3870,7 @@ var gi = class {
|
|
|
3870
3870
|
}
|
|
3871
3871
|
async listSkills(e = {}) {
|
|
3872
3872
|
await this.host.ensureConnected(), e.forceReload && this.iconDataUrls.clear();
|
|
3873
|
-
let t = await
|
|
3873
|
+
let t = await li((await this.client.request("skills/list", {
|
|
3874
3874
|
...e.cwd ? { cwds: [e.cwd] } : {},
|
|
3875
3875
|
forceReload: e.forceReload ?? !1
|
|
3876
3876
|
})).data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e));
|
|
@@ -3924,7 +3924,7 @@ var gi = class {
|
|
|
3924
3924
|
}), (async () => ({
|
|
3925
3925
|
profiles: await this.requestPermissionProfiles(e),
|
|
3926
3926
|
requirements: (await this.client.request("configRequirements/read", void 0)).requirements
|
|
3927
|
-
}))()]), a = r.status === "fulfilled" ? await
|
|
3927
|
+
}))()]), a = r.status === "fulfilled" ? await li(r.value.data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e)) : [], o = i.status === "fulfilled" ? i.value.profiles : [];
|
|
3928
3928
|
return {
|
|
3929
3929
|
skills: a,
|
|
3930
3930
|
skillCatalogStatus: r.status === "fulfilled" ? "loaded" : "error",
|
|
@@ -3956,7 +3956,7 @@ var gi = class {
|
|
|
3956
3956
|
cursor: n,
|
|
3957
3957
|
includeHidden: e
|
|
3958
3958
|
});
|
|
3959
|
-
t.push(...r.data.map(
|
|
3959
|
+
t.push(...r.data.map(ci)), n = r.nextCursor;
|
|
3960
3960
|
} while (n);
|
|
3961
3961
|
return t;
|
|
3962
3962
|
}
|
|
@@ -4026,7 +4026,7 @@ var gi = class {
|
|
|
4026
4026
|
try {
|
|
4027
4027
|
let t = await this.client.request("plugin/installed", { ...e.length > 0 ? { cwds: [...e] } : {} }), n = /* @__PURE__ */ new Map();
|
|
4028
4028
|
for (let e of t.marketplaces) for (let t of e.plugins) n.has(t.id) || n.set(t.id, t);
|
|
4029
|
-
let r = Kt(this.host.getState().plugins, await Promise.all([...n.values()].map((e) =>
|
|
4029
|
+
let r = Kt(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => di(e, (e) => this.iconDataUrl(e)))));
|
|
4030
4030
|
if (this.host.isClosed() || this.host.authenticationBlocksBootstrap()) return;
|
|
4031
4031
|
this.host.patch({
|
|
4032
4032
|
plugins: r,
|
|
@@ -4057,9 +4057,9 @@ var gi = class {
|
|
|
4057
4057
|
}
|
|
4058
4058
|
async readIconDataUrl(e) {
|
|
4059
4059
|
if (!v(e)) return;
|
|
4060
|
-
let t =
|
|
4060
|
+
let t = mi(e);
|
|
4061
4061
|
if (t) try {
|
|
4062
|
-
return
|
|
4062
|
+
return hi(t, (await this.client.request("fs/readFile", { path: e })).dataBase64);
|
|
4063
4063
|
} catch {
|
|
4064
4064
|
return;
|
|
4065
4065
|
}
|
|
@@ -4067,18 +4067,18 @@ var gi = class {
|
|
|
4067
4067
|
};
|
|
4068
4068
|
//#endregion
|
|
4069
4069
|
//#region src/node/codex-approvals.ts
|
|
4070
|
-
function
|
|
4070
|
+
function vi(e, t) {
|
|
4071
4071
|
let n = [
|
|
4072
4072
|
e.onServerRequest("item/commandExecution/requestApproval", (e, n) => (t({
|
|
4073
|
-
approval:
|
|
4074
|
-
resolve: (t, r) => n.resolve({ decision:
|
|
4073
|
+
approval: yi(e.id, e.params),
|
|
4074
|
+
resolve: (t, r) => n.resolve({ decision: Si(e.params, t, r) })
|
|
4075
4075
|
}), !0)),
|
|
4076
4076
|
e.onServerRequest("item/fileChange/requestApproval", (e, n) => (t({
|
|
4077
|
-
approval:
|
|
4077
|
+
approval: bi(e.id, e.params),
|
|
4078
4078
|
resolve: (e, t) => n.resolve({ decision: e === "deny" ? "decline" : t === "session" ? "acceptForSession" : "accept" })
|
|
4079
4079
|
}), !0)),
|
|
4080
4080
|
e.onServerRequest("item/permissions/requestApproval", (e, n) => (t({
|
|
4081
|
-
approval:
|
|
4081
|
+
approval: xi(e.id, e.params),
|
|
4082
4082
|
resolve: (t, r) => n.resolve({
|
|
4083
4083
|
permissions: t === "deny" ? {} : {
|
|
4084
4084
|
...e.params.permissions.fileSystem ? { fileSystem: e.params.permissions.fileSystem } : {},
|
|
@@ -4116,8 +4116,8 @@ function _i(e, t) {
|
|
|
4116
4116
|
for (let e of n) e();
|
|
4117
4117
|
};
|
|
4118
4118
|
}
|
|
4119
|
-
function
|
|
4120
|
-
let n = t.availableDecisions, r =
|
|
4119
|
+
function yi(e, t) {
|
|
4120
|
+
let n = t.availableDecisions, r = Ci(t.additionalPermissions), i = [...t.networkApprovalContext ? [{
|
|
4121
4121
|
kind: "network",
|
|
4122
4122
|
enabled: !0,
|
|
4123
4123
|
host: t.networkApprovalContext.host,
|
|
@@ -4140,7 +4140,7 @@ function vi(e, t) {
|
|
|
4140
4140
|
} : {}
|
|
4141
4141
|
};
|
|
4142
4142
|
}
|
|
4143
|
-
function
|
|
4143
|
+
function bi(e, t) {
|
|
4144
4144
|
return {
|
|
4145
4145
|
id: String(e),
|
|
4146
4146
|
kind: "file-change",
|
|
@@ -4151,8 +4151,8 @@ function yi(e, t) {
|
|
|
4151
4151
|
...t.reason || t.grantRoot ? { description: t.reason ?? `Write under ${t.grantRoot}` } : {}
|
|
4152
4152
|
};
|
|
4153
4153
|
}
|
|
4154
|
-
function
|
|
4155
|
-
let n =
|
|
4154
|
+
function xi(e, t) {
|
|
4155
|
+
let n = Ci(t.permissions);
|
|
4156
4156
|
return {
|
|
4157
4157
|
id: String(e),
|
|
4158
4158
|
kind: "permissions",
|
|
@@ -4165,13 +4165,13 @@ function bi(e, t) {
|
|
|
4165
4165
|
...n.length ? { requestedPermissions: n } : {}
|
|
4166
4166
|
};
|
|
4167
4167
|
}
|
|
4168
|
-
function
|
|
4168
|
+
function Si(e, t, n) {
|
|
4169
4169
|
let r = e.availableDecisions, i = t === "deny" ? "decline" : n === "session" ? "acceptForSession" : "accept";
|
|
4170
4170
|
if (!r || r.includes(i)) return i;
|
|
4171
4171
|
if (t === "deny" && r.includes("cancel")) return "cancel";
|
|
4172
4172
|
throw Error(`Approval decision '${t}:${n}' is not available for this command`);
|
|
4173
4173
|
}
|
|
4174
|
-
function
|
|
4174
|
+
function Ci(e) {
|
|
4175
4175
|
if (!e) return [];
|
|
4176
4176
|
let t = [];
|
|
4177
4177
|
if (e.network && t.push({
|
|
@@ -4191,12 +4191,12 @@ function Si(e) {
|
|
|
4191
4191
|
for (let n of e.fileSystem.entries ?? []) t.push({
|
|
4192
4192
|
kind: "filesystem",
|
|
4193
4193
|
access: n.access,
|
|
4194
|
-
path:
|
|
4194
|
+
path: wi(n.path)
|
|
4195
4195
|
});
|
|
4196
4196
|
}
|
|
4197
4197
|
return t;
|
|
4198
4198
|
}
|
|
4199
|
-
function
|
|
4199
|
+
function wi(e) {
|
|
4200
4200
|
if (e.type === "path") return e.path;
|
|
4201
4201
|
if (e.type === "glob_pattern") return e.pattern;
|
|
4202
4202
|
let t = e.value;
|
|
@@ -4211,12 +4211,12 @@ function Ci(e) {
|
|
|
4211
4211
|
}
|
|
4212
4212
|
//#endregion
|
|
4213
4213
|
//#region src/node/codex-surface-approvals-controller.ts
|
|
4214
|
-
var
|
|
4214
|
+
var Ti = class {
|
|
4215
4215
|
host;
|
|
4216
4216
|
pending = /* @__PURE__ */ new Map();
|
|
4217
4217
|
unsubscribeHandler;
|
|
4218
4218
|
constructor(e, t) {
|
|
4219
|
-
this.host = t, this.unsubscribeHandler =
|
|
4219
|
+
this.host = t, this.unsubscribeHandler = vi(e, (e) => this.add(e));
|
|
4220
4220
|
}
|
|
4221
4221
|
close() {
|
|
4222
4222
|
this.unsubscribeHandler(), this.pending.clear();
|
|
@@ -4297,7 +4297,7 @@ var wi = class {
|
|
|
4297
4297
|
};
|
|
4298
4298
|
//#endregion
|
|
4299
4299
|
//#region src/node/codex-surface-mcp.ts
|
|
4300
|
-
function
|
|
4300
|
+
function Ei(e) {
|
|
4301
4301
|
if (!Array.isArray(e)) throw TypeError("Codex MCP servers must be an array");
|
|
4302
4302
|
let t = /* @__PURE__ */ new Set();
|
|
4303
4303
|
return e.map((e, n) => {
|
|
@@ -4306,10 +4306,10 @@ function Ti(e) {
|
|
|
4306
4306
|
if (!r || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(r)) throw TypeError(`Codex MCP server ${n + 1} name must match ^[A-Za-z0-9][A-Za-z0-9_-]*$`);
|
|
4307
4307
|
if (t.has(r)) throw Error(`Duplicate Codex MCP server '${r}'`);
|
|
4308
4308
|
t.add(r);
|
|
4309
|
-
let i =
|
|
4309
|
+
let i = Di(e.transport, r), a = e.toolApprovalMode;
|
|
4310
4310
|
if (a !== void 0 && a !== "auto" && a !== "prompt" && a !== "writes" && a !== "approve") throw TypeError(`Codex MCP server '${r}' tool approval mode is invalid`);
|
|
4311
4311
|
if (e.required !== void 0 && typeof e.required != "boolean") throw TypeError(`Codex MCP server '${r}' required flag must be a boolean`);
|
|
4312
|
-
let o = e.enabledTools === void 0 ? void 0 :
|
|
4312
|
+
let o = e.enabledTools === void 0 ? void 0 : Oi(e.enabledTools, `Codex MCP server '${r}' enabled tool`), s = Ai(e.startupTimeoutMs, `Codex MCP server '${r}' startup timeout`), c = Ai(e.toolTimeoutMs, `Codex MCP server '${r}' tool timeout`);
|
|
4313
4313
|
return {
|
|
4314
4314
|
name: r,
|
|
4315
4315
|
transport: i,
|
|
@@ -4321,7 +4321,7 @@ function Ti(e) {
|
|
|
4321
4321
|
};
|
|
4322
4322
|
});
|
|
4323
4323
|
}
|
|
4324
|
-
function
|
|
4324
|
+
function Di(e, t) {
|
|
4325
4325
|
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError(`Codex MCP server '${t}' transport must be an object`);
|
|
4326
4326
|
if (e.type === "http") {
|
|
4327
4327
|
let n = e.url?.trim(), r;
|
|
@@ -4339,7 +4339,7 @@ function Ei(e, t) {
|
|
|
4339
4339
|
if (e.type !== "stdio") throw TypeError(`Codex MCP server '${t}' transport type is invalid`);
|
|
4340
4340
|
let n = e.command?.trim();
|
|
4341
4341
|
if (!n) throw TypeError(`Codex MCP server '${t}' command cannot be empty`);
|
|
4342
|
-
let r = e.args === void 0 ? void 0 :
|
|
4342
|
+
let r = e.args === void 0 ? void 0 : Oi(e.args, `Codex MCP server '${t}' argument`), i = e.cwd?.trim();
|
|
4343
4343
|
if (i !== void 0 && (!i || !v(i))) throw TypeError(`Codex MCP server '${t}' cwd must be an absolute path`);
|
|
4344
4344
|
let a;
|
|
4345
4345
|
if (e.env !== void 0) {
|
|
@@ -4350,7 +4350,7 @@ function Ei(e, t) {
|
|
|
4350
4350
|
a[n] = r;
|
|
4351
4351
|
}
|
|
4352
4352
|
}
|
|
4353
|
-
let o = e.envVars === void 0 ? void 0 :
|
|
4353
|
+
let o = e.envVars === void 0 ? void 0 : ki(e.envVars, t);
|
|
4354
4354
|
return {
|
|
4355
4355
|
type: "stdio",
|
|
4356
4356
|
command: n,
|
|
@@ -4360,7 +4360,7 @@ function Ei(e, t) {
|
|
|
4360
4360
|
...o === void 0 ? {} : { envVars: o }
|
|
4361
4361
|
};
|
|
4362
4362
|
}
|
|
4363
|
-
function
|
|
4363
|
+
function Oi(e, t) {
|
|
4364
4364
|
if (!Array.isArray(e)) throw TypeError(`${t}s must be an array`);
|
|
4365
4365
|
let n = e.map((e) => {
|
|
4366
4366
|
if (typeof e != "string" || !e.trim()) throw TypeError(`${t} cannot be empty`);
|
|
@@ -4368,18 +4368,18 @@ function Di(e, t) {
|
|
|
4368
4368
|
});
|
|
4369
4369
|
return [...new Set(n)];
|
|
4370
4370
|
}
|
|
4371
|
-
function
|
|
4372
|
-
let n =
|
|
4371
|
+
function ki(e, t) {
|
|
4372
|
+
let n = Oi(e, `Codex MCP server '${t}' environment variable`);
|
|
4373
4373
|
for (let e of n) if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) throw TypeError(`Codex MCP server '${t}' environment variable '${e}' is invalid`);
|
|
4374
4374
|
return n;
|
|
4375
4375
|
}
|
|
4376
|
-
function
|
|
4376
|
+
function Ai(e, t) {
|
|
4377
4377
|
if (e !== void 0) {
|
|
4378
4378
|
if (!Number.isFinite(e) || e <= 0) throw TypeError(`${t} must be a positive finite number`);
|
|
4379
4379
|
return e;
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
|
-
function
|
|
4382
|
+
function ji(e) {
|
|
4383
4383
|
let t = {};
|
|
4384
4384
|
for (let n of e) {
|
|
4385
4385
|
let e = n.transport.type === "http" ? { url: n.transport.url } : {
|
|
@@ -4393,7 +4393,7 @@ function Ai(e) {
|
|
|
4393
4393
|
}
|
|
4394
4394
|
return t;
|
|
4395
4395
|
}
|
|
4396
|
-
function
|
|
4396
|
+
function Mi(e, t) {
|
|
4397
4397
|
if (t.length !== 0) for (let n of Object.keys(e)) {
|
|
4398
4398
|
if (n === "mcp_servers") throw Error("Raw mcp_servers config cannot be combined with typed Codex MCP servers");
|
|
4399
4399
|
for (let e of t) {
|
|
@@ -4404,13 +4404,13 @@ function ji(e, t) {
|
|
|
4404
4404
|
}
|
|
4405
4405
|
//#endregion
|
|
4406
4406
|
//#region src/node/codex-surface-extensions-controller.ts
|
|
4407
|
-
var
|
|
4407
|
+
var Ni = class {
|
|
4408
4408
|
extensions;
|
|
4409
4409
|
hostOptionsForThread;
|
|
4410
4410
|
dynamicTools = /* @__PURE__ */ new Map();
|
|
4411
4411
|
defaultMcpServers;
|
|
4412
4412
|
constructor(e, t, n) {
|
|
4413
|
-
this.extensions = e, this.hostOptionsForThread = n, this.defaultMcpServers =
|
|
4413
|
+
this.extensions = e, this.hostOptionsForThread = n, this.defaultMcpServers = Ei(t);
|
|
4414
4414
|
for (let t of e) for (let e of t.dynamicTools ?? []) {
|
|
4415
4415
|
let t = e.name.trim();
|
|
4416
4416
|
if (!t) throw Error("Dynamic tool names cannot be empty");
|
|
@@ -4434,13 +4434,13 @@ var Mi = class {
|
|
|
4434
4434
|
}));
|
|
4435
4435
|
}
|
|
4436
4436
|
async conversationExtension(e, t = {}, n = this.defaultMcpServers) {
|
|
4437
|
-
let r =
|
|
4437
|
+
let r = ji(n), i = [], a;
|
|
4438
4438
|
for (let t of this.extensions) {
|
|
4439
4439
|
if (!t.configureConversation) continue;
|
|
4440
4440
|
let o = await t.configureConversation(e);
|
|
4441
|
-
o.config && (
|
|
4441
|
+
o.config && (Mi(o.config, n), Object.assign(r, o.config)), o.baseInstructions !== void 0 && (a = o.baseInstructions), o.developerInstructions?.trim() && i.push(o.developerInstructions.trim());
|
|
4442
4442
|
}
|
|
4443
|
-
return t.config && (
|
|
4443
|
+
return t.config && (Mi(t.config, n), Object.assign(r, t.config)), t.baseInstructions !== void 0 && (a = t.baseInstructions), t.developerInstructions?.trim() && i.push(t.developerInstructions.trim()), {
|
|
4444
4444
|
...a === void 0 ? {} : { baseInstructions: a },
|
|
4445
4445
|
...Object.keys(r).length === 0 ? {} : { config: r },
|
|
4446
4446
|
...i.length === 0 ? {} : { developerInstructions: i.join("\n\n") }
|
|
@@ -4499,7 +4499,7 @@ var Mi = class {
|
|
|
4499
4499
|
});
|
|
4500
4500
|
}
|
|
4501
4501
|
}
|
|
4502
|
-
},
|
|
4502
|
+
}, Pi = 50, Fi = 25, Ii = 25, Li = class {
|
|
4503
4503
|
client;
|
|
4504
4504
|
conversationLimit;
|
|
4505
4505
|
host;
|
|
@@ -4568,7 +4568,7 @@ var Mi = class {
|
|
|
4568
4568
|
let t = await this.client.request("thread/turns/list", {
|
|
4569
4569
|
threadId: e,
|
|
4570
4570
|
cursor: null,
|
|
4571
|
-
limit:
|
|
4571
|
+
limit: Pi,
|
|
4572
4572
|
sortDirection: "desc",
|
|
4573
4573
|
itemsView: "full"
|
|
4574
4574
|
});
|
|
@@ -4616,7 +4616,7 @@ var Mi = class {
|
|
|
4616
4616
|
let i = new Set(this.host.requireRuntime(e).turnIds), a = await this.client.request("thread/turns/list", {
|
|
4617
4617
|
threadId: e,
|
|
4618
4618
|
cursor: t,
|
|
4619
|
-
limit:
|
|
4619
|
+
limit: Fi,
|
|
4620
4620
|
sortDirection: "desc",
|
|
4621
4621
|
itemsView: "full"
|
|
4622
4622
|
}), o = [...a.data].reverse(), s = new Set(o.map((e) => e.id).filter((e) => !i.has(e)));
|
|
@@ -4647,8 +4647,8 @@ var Mi = class {
|
|
|
4647
4647
|
}
|
|
4648
4648
|
async emitHistoryChunks(e, t) {
|
|
4649
4649
|
for (let n = t.length; n > 0;) {
|
|
4650
|
-
let r = Math.max(0, n -
|
|
4651
|
-
this.host.emitHistoryPrepended(e, t.slice(r, n), "lifecycle"), await
|
|
4650
|
+
let r = Math.max(0, n - Ii);
|
|
4651
|
+
this.host.emitHistoryPrepended(e, t.slice(r, n), "lifecycle"), await Ri(), n = r;
|
|
4652
4652
|
}
|
|
4653
4653
|
}
|
|
4654
4654
|
async refreshCompleteHistory(e) {
|
|
@@ -4684,10 +4684,10 @@ var Mi = class {
|
|
|
4684
4684
|
let i = /* @__PURE__ */ new Set();
|
|
4685
4685
|
r.activeTurnId && i.add(r.activeTurnId);
|
|
4686
4686
|
for (let e of t) e.status === "inProgress" && r.turnIds.includes(e.id) && i.add(e.id);
|
|
4687
|
-
let a = new Set(t.filter((e) => !i.has(e.id)).map((e) => e.id)), o = t.filter((e) => a.has(e.id)), s = r.turnIds.filter((e) => !a.has(e)), c = r.turns.filter((e) => !a.has(e.id)), l = r.messages.filter((e) => e.turnId === void 0 || !a.has(e.turnId)), u =
|
|
4687
|
+
let a = new Set(t.filter((e) => !i.has(e.id)).map((e) => e.id)), o = t.filter((e) => a.has(e.id)), s = r.turnIds.filter((e) => !a.has(e)), c = r.turns.filter((e) => !a.has(e.id)), l = r.messages.filter((e) => e.turnId === void 0 || !a.has(e.turnId)), u = yr(r.messages, o.flatMap((t) => br(e, t)));
|
|
4688
4688
|
this.host.patchRuntime(e, {
|
|
4689
4689
|
turnIds: [...o.map((e) => e.id), ...s],
|
|
4690
|
-
turns: [...o.map((e) =>
|
|
4690
|
+
turns: [...o.map((e) => X(e)), ...c],
|
|
4691
4691
|
messages: [...u, ...l]
|
|
4692
4692
|
});
|
|
4693
4693
|
let d = this.host.requireRuntime(e).turnIds.length, f = this.host.getState();
|
|
@@ -4711,12 +4711,12 @@ var Mi = class {
|
|
|
4711
4711
|
} : t;
|
|
4712
4712
|
}
|
|
4713
4713
|
};
|
|
4714
|
-
function
|
|
4714
|
+
function Ri() {
|
|
4715
4715
|
return new Promise((e) => setTimeout(e, 0));
|
|
4716
4716
|
}
|
|
4717
4717
|
//#endregion
|
|
4718
4718
|
//#region src/node/codex-surface-conversation-settings-controller.ts
|
|
4719
|
-
var
|
|
4719
|
+
var zi = class {
|
|
4720
4720
|
client;
|
|
4721
4721
|
defaults;
|
|
4722
4722
|
host;
|
|
@@ -4789,7 +4789,7 @@ var Ri = class {
|
|
|
4789
4789
|
...n === void 0 ? {} : { tokenBudget: n }
|
|
4790
4790
|
});
|
|
4791
4791
|
if (a.goal.threadId !== e) throw Error(`Codex thread/goal/set returned a goal for '${a.goal.threadId}' instead of '${e}'`);
|
|
4792
|
-
let o =
|
|
4792
|
+
let o = !$r(r.goal, a.goal);
|
|
4793
4793
|
this.host.patchRuntime(e, { goal: { ...a.goal } }), o && this.host.emitEvent("action", {
|
|
4794
4794
|
type: "conversation.goalChanged",
|
|
4795
4795
|
conversationId: e,
|
|
@@ -4811,7 +4811,7 @@ var Ri = class {
|
|
|
4811
4811
|
payload: { goal: null }
|
|
4812
4812
|
});
|
|
4813
4813
|
}
|
|
4814
|
-
},
|
|
4814
|
+
}, Bi = "Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.", Vi = class {
|
|
4815
4815
|
client;
|
|
4816
4816
|
host;
|
|
4817
4817
|
constructor(e, t) {
|
|
@@ -4848,22 +4848,22 @@ var Ri = class {
|
|
|
4848
4848
|
if (i.reviewThreadId !== e) throw Error(`Codex review/start returned unexpected review thread '${i.reviewThreadId}' for inline review on thread '${e}'`);
|
|
4849
4849
|
let a = n.turnIds.includes(i.turn.id);
|
|
4850
4850
|
n.activeTurnId = i.turn.status === "inProgress" ? i.turn.id : null, n.turnIds.includes(i.turn.id) || n.turnIds.push(i.turn.id), this.host.patchConversationTurnCount(e, n.turnIds.length, "action");
|
|
4851
|
-
let o =
|
|
4851
|
+
let o = br(e, i.turn).filter((e) => !n.messages.some((t) => t.id === e.id)).map((e) => e.role === "user" ? {
|
|
4852
4852
|
...e,
|
|
4853
4853
|
parts: r.type === "uncommittedChanges" ? e.parts.map((e) => e.type === "text" && e.text === "current changes" ? {
|
|
4854
4854
|
...e,
|
|
4855
|
-
text:
|
|
4855
|
+
text: Bi
|
|
4856
4856
|
} : e) : e.parts,
|
|
4857
4857
|
metadata: {
|
|
4858
4858
|
...e.metadata,
|
|
4859
4859
|
reviewPrompt: !0
|
|
4860
4860
|
}
|
|
4861
|
-
} : e), s =
|
|
4861
|
+
} : e), s = Hi(n.messages, i.turn.id, o);
|
|
4862
4862
|
this.host.patchRuntime(e, {
|
|
4863
4863
|
busy: n.activeTurnId !== null,
|
|
4864
4864
|
turnStartPending: !1,
|
|
4865
|
-
turns:
|
|
4866
|
-
messages: n.activeTurnId ?
|
|
4865
|
+
turns: Z(n.turns, X(i.turn)),
|
|
4866
|
+
messages: n.activeTurnId ? U(s, e, i.turn.id) : s
|
|
4867
4867
|
});
|
|
4868
4868
|
for (let t of o) this.host.emitEvent("action", {
|
|
4869
4869
|
type: "message.appended",
|
|
@@ -4875,7 +4875,7 @@ var Ri = class {
|
|
|
4875
4875
|
type: "turn.started",
|
|
4876
4876
|
conversationId: e,
|
|
4877
4877
|
turnId: i.turn.id,
|
|
4878
|
-
payload: { startedAt:
|
|
4878
|
+
payload: { startedAt: Xr(i.turn.startedAt) }
|
|
4879
4879
|
}), this.host.emitConversationActivity(e, "action");
|
|
4880
4880
|
} catch (t) {
|
|
4881
4881
|
throw this.host.patchRuntime(e, {
|
|
@@ -4936,28 +4936,10 @@ var Ri = class {
|
|
|
4936
4936
|
async rollbackToTurn(e, t) {
|
|
4937
4937
|
let n = await this.host.ensureThreadReady(e);
|
|
4938
4938
|
if (n.busy) throw Error("Cannot roll back while Codex is responding");
|
|
4939
|
+
if (n.historyMode !== "paginated") throw Error("Legacy conversation history does not support deleting, editing, or retrying turns with app-server 0.164.0. Start a new conversation to use these actions.");
|
|
4939
4940
|
let r = n.turnIds.indexOf(t);
|
|
4940
4941
|
if (r < 0 && (await this.host.hydrateCompleteHistory(e), r = n.turnIds.indexOf(t)), r < 0) throw Error(`Cannot roll back to unknown Codex turn '${t}'`);
|
|
4941
|
-
|
|
4942
|
-
await this.revertPaginatedThread(e, t, r, n);
|
|
4943
|
-
return;
|
|
4944
|
-
}
|
|
4945
|
-
let i = await this.client.request("thread/rollback", {
|
|
4946
|
-
threadId: e,
|
|
4947
|
-
numTurns: n.turnIds.length - r
|
|
4948
|
-
});
|
|
4949
|
-
if (i.thread.id !== e) throw Error(`Codex thread/rollback returned '${i.thread.id}' for requested thread '${e}'`);
|
|
4950
|
-
n.turnIds = i.thread.turns.map((e) => e.id), n.turns = i.thread.turns.map((e) => Z(e)), n.activeTurnId = null;
|
|
4951
|
-
let a = P(i.thread);
|
|
4952
|
-
this.host.patch({ conversations: F(this.host.getState().conversations, a) }), this.host.patchRuntime(e, {
|
|
4953
|
-
messages: vr(n.messages, gr(i.thread)),
|
|
4954
|
-
answeredClientRequestIds: [],
|
|
4955
|
-
busy: !1,
|
|
4956
|
-
turnStartPending: !1,
|
|
4957
|
-
error: null,
|
|
4958
|
-
contextUsage: null,
|
|
4959
|
-
turnGitDiff: null
|
|
4960
|
-
}), this.host.emitSummaryUpserted(a, "updated", "action"), this.host.emitHistoryReplaced(e, "rollback", "action"), this.host.emitConversationActivity(e, "action");
|
|
4942
|
+
await this.revertPaginatedThread(e, t, r, n);
|
|
4961
4943
|
}
|
|
4962
4944
|
async revertPaginatedThread(e, t, n, r) {
|
|
4963
4945
|
let i = await this.client.request("thread/revert", {
|
|
@@ -4993,7 +4975,7 @@ var Ri = class {
|
|
|
4993
4975
|
return e;
|
|
4994
4976
|
}
|
|
4995
4977
|
};
|
|
4996
|
-
function
|
|
4978
|
+
function Hi(e, t, n) {
|
|
4997
4979
|
let r = e.findIndex((e) => e.turnId === t);
|
|
4998
4980
|
return r < 0 ? [...e, ...n] : [
|
|
4999
4981
|
...e.slice(0, r),
|
|
@@ -5003,7 +4985,7 @@ function Vi(e, t, n) {
|
|
|
5003
4985
|
}
|
|
5004
4986
|
//#endregion
|
|
5005
4987
|
//#region src/node/codex-surface-messages-controller.ts
|
|
5006
|
-
var
|
|
4988
|
+
var Ui = class {
|
|
5007
4989
|
client;
|
|
5008
4990
|
host;
|
|
5009
4991
|
constructor(e, t) {
|
|
@@ -5090,13 +5072,13 @@ var Hi = class {
|
|
|
5090
5072
|
this.host.patchRuntime(e, {
|
|
5091
5073
|
busy: i,
|
|
5092
5074
|
turnStartPending: !1,
|
|
5093
|
-
turns:
|
|
5094
|
-
messages: i ?
|
|
5075
|
+
turns: Z(t.turns, X(n.turn)),
|
|
5076
|
+
messages: i ? U(t.messages, e, n.turn.id) : t.messages
|
|
5095
5077
|
}), this.host.patchConversationStatus(e, i ? "active" : "idle", "action"), i && !r && this.host.emitEvent("action", {
|
|
5096
5078
|
type: "turn.started",
|
|
5097
5079
|
conversationId: e,
|
|
5098
5080
|
turnId: n.turn.id,
|
|
5099
|
-
payload: { startedAt:
|
|
5081
|
+
payload: { startedAt: Xr(n.turn.startedAt) }
|
|
5100
5082
|
}), this.host.emitConversationActivity(e, "action");
|
|
5101
5083
|
} catch (t) {
|
|
5102
5084
|
throw this.host.patchRuntime(e, {
|
|
@@ -5112,13 +5094,13 @@ var Hi = class {
|
|
|
5112
5094
|
let s = o ? ie(o) : r?.trim() || t, c = ct(E(ot(o), i.skills), E(a.skills ?? [], i.skills)), l = Jt(a.attachments ?? []);
|
|
5113
5095
|
if (i.busy) {
|
|
5114
5096
|
this.host.patchRuntime(e, { queuedPrompts: [...i.queuedPrompts, {
|
|
5115
|
-
id:
|
|
5097
|
+
id: ti(),
|
|
5116
5098
|
text: s,
|
|
5117
5099
|
...Object.keys(a).length > 0 ? { options: a } : {}
|
|
5118
5100
|
}] }), this.emitQueuedPrompts(e);
|
|
5119
5101
|
return;
|
|
5120
5102
|
}
|
|
5121
|
-
let u =
|
|
5103
|
+
let u = ei(), d = {
|
|
5122
5104
|
id: u,
|
|
5123
5105
|
role: "user",
|
|
5124
5106
|
status: "complete",
|
|
@@ -5176,8 +5158,8 @@ var Hi = class {
|
|
|
5176
5158
|
this.host.patchRuntime(e, {
|
|
5177
5159
|
busy: s,
|
|
5178
5160
|
turnStartPending: !1,
|
|
5179
|
-
turns:
|
|
5180
|
-
messages: s ?
|
|
5161
|
+
turns: Z(i.turns, X(n.turn)),
|
|
5162
|
+
messages: s ? U(d, e, n.turn.id) : d
|
|
5181
5163
|
}), this.host.patchConversationStatus(e, s ? "active" : "idle", "action");
|
|
5182
5164
|
let f = d.find((e) => e.id === u);
|
|
5183
5165
|
f && this.host.emitEvent("action", {
|
|
@@ -5189,7 +5171,7 @@ var Hi = class {
|
|
|
5189
5171
|
type: "turn.started",
|
|
5190
5172
|
conversationId: e,
|
|
5191
5173
|
turnId: n.turn.id,
|
|
5192
|
-
payload: { startedAt:
|
|
5174
|
+
payload: { startedAt: Xr(n.turn.startedAt) }
|
|
5193
5175
|
}), this.host.emitConversationActivity(e, "action");
|
|
5194
5176
|
} catch (t) {
|
|
5195
5177
|
throw this.host.patchRuntime(e, {
|
|
@@ -5207,7 +5189,7 @@ var Hi = class {
|
|
|
5207
5189
|
let i = await this.host.ensureThreadReady(e), a = t.trim(), o = at(n.content), s = ct(E(ot(o), i.skills), E(n.skills ?? [], i.skills)), c = o ? ie(o) : r?.trim() || a;
|
|
5208
5190
|
if (!a) throw Error("Cannot steer with an empty message");
|
|
5209
5191
|
if (!i.activeTurnId) throw Error("There is no active turn to steer");
|
|
5210
|
-
let l = Jt(n.attachments ?? []), u =
|
|
5192
|
+
let l = Jt(n.attachments ?? []), u = ei(), d = {
|
|
5211
5193
|
id: u,
|
|
5212
5194
|
kind: "steer",
|
|
5213
5195
|
role: "user",
|
|
@@ -5227,7 +5209,7 @@ var Hi = class {
|
|
|
5227
5209
|
};
|
|
5228
5210
|
this.host.patchRuntime(e, {
|
|
5229
5211
|
error: null,
|
|
5230
|
-
messages:
|
|
5212
|
+
messages: U([...i.messages, d], e, i.activeTurnId, { forceSegment: !0 })
|
|
5231
5213
|
}), this.host.emitEvent("action", {
|
|
5232
5214
|
type: "message.appended",
|
|
5233
5215
|
conversationId: e,
|
|
@@ -5254,7 +5236,7 @@ var Hi = class {
|
|
|
5254
5236
|
}))
|
|
5255
5237
|
]
|
|
5256
5238
|
}), n = i.turnIds.includes(t.turnId);
|
|
5257
|
-
i.activeTurnId = t.turnId, i.turnIds.includes(t.turnId) || i.turnIds.push(t.turnId), i.turns =
|
|
5239
|
+
i.activeTurnId = t.turnId, i.turnIds.includes(t.turnId) || i.turnIds.push(t.turnId), i.turns = Z(i.turns, {
|
|
5258
5240
|
id: t.turnId,
|
|
5259
5241
|
status: "inProgress",
|
|
5260
5242
|
error: null,
|
|
@@ -5271,7 +5253,7 @@ var Hi = class {
|
|
|
5271
5253
|
turnId: t.turnId
|
|
5272
5254
|
}
|
|
5273
5255
|
} : e);
|
|
5274
|
-
this.host.patchRuntime(e, { messages:
|
|
5256
|
+
this.host.patchRuntime(e, { messages: G(U(r, e, t.turnId), e) }), n || this.host.emitEvent("action", {
|
|
5275
5257
|
type: "turn.started",
|
|
5276
5258
|
conversationId: e,
|
|
5277
5259
|
turnId: t.turnId,
|
|
@@ -5364,7 +5346,7 @@ var Hi = class {
|
|
|
5364
5346
|
if (!e) throw Error("There is no active conversation");
|
|
5365
5347
|
return e;
|
|
5366
5348
|
}
|
|
5367
|
-
},
|
|
5349
|
+
}, Wi = 5, Gi = class {
|
|
5368
5350
|
client;
|
|
5369
5351
|
options;
|
|
5370
5352
|
catalog;
|
|
@@ -5404,7 +5386,7 @@ var Hi = class {
|
|
|
5404
5386
|
...a ? { approvalPreset: a } : {}
|
|
5405
5387
|
}, r.approvalPresets), s = A(i.models, i.selectedModelId), c = e.model ? Pt(i.models, e.model) : s, l = c?.model, u = e.reasoningEffort ?? (c?.id === s?.id ? i.selectedReasoningEffort : c ? j(c) : null) ?? void 0, d = e.serviceTier === void 0 ? c?.id === s?.id ? i.selectedServiceTier ?? null : c?.defaultServiceTier ?? null : e.serviceTier;
|
|
5406
5388
|
Ft(c, u), M(c, d);
|
|
5407
|
-
let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers :
|
|
5389
|
+
let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ei(t.mcpServers), p = await this.extensions.conversationExtension({
|
|
5408
5390
|
operation: "start",
|
|
5409
5391
|
conversationId: null,
|
|
5410
5392
|
cwd: n,
|
|
@@ -5521,7 +5503,7 @@ var Hi = class {
|
|
|
5521
5503
|
...n
|
|
5522
5504
|
}, a = {
|
|
5523
5505
|
...i,
|
|
5524
|
-
mcpServers: i.mcpServers === void 0 ? this.extensions.defaultMcpServers :
|
|
5506
|
+
mcpServers: i.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ei(i.mcpServers)
|
|
5525
5507
|
};
|
|
5526
5508
|
this.hostOptionsByThread.set(e, a);
|
|
5527
5509
|
let o = await this.extensions.conversationExtension({
|
|
@@ -5539,7 +5521,7 @@ var Hi = class {
|
|
|
5539
5521
|
threadId: e,
|
|
5540
5522
|
excludeTurns: !0,
|
|
5541
5523
|
initialTurnsPage: {
|
|
5542
|
-
limit:
|
|
5524
|
+
limit: Wi,
|
|
5543
5525
|
sortDirection: "desc",
|
|
5544
5526
|
itemsView: "full"
|
|
5545
5527
|
},
|
|
@@ -5552,20 +5534,20 @@ var Hi = class {
|
|
|
5552
5534
|
let i = t.initialTurnsPage ?? await this.client.request("thread/turns/list", {
|
|
5553
5535
|
threadId: t.thread.id,
|
|
5554
5536
|
cursor: null,
|
|
5555
|
-
limit:
|
|
5537
|
+
limit: Wi,
|
|
5556
5538
|
sortDirection: "desc",
|
|
5557
5539
|
itemsView: "full"
|
|
5558
5540
|
}), d = [...i.data].reverse(), f = t.cwd ?? t.thread.cwd ?? a.cwd, p = await this.catalog.loadConversationCatalogs(f), m = s.turns.filter((e) => c.get(e.id) !== e), h = s.threadStatus !== u && s.threadStatus ? s.threadStatus : I(t.thread.status), g = d.map((e) => h.type === "idle" && e.status === "inProgress" ? {
|
|
5559
5541
|
...e,
|
|
5560
5542
|
status: "interrupted"
|
|
5561
|
-
} : e), _ = new Map(g.map((e) => [e.id,
|
|
5543
|
+
} : e), _ = new Map(g.map((e) => [e.id, X(e)]));
|
|
5562
5544
|
for (let e of m) _.set(e.id, e);
|
|
5563
|
-
let v = m.length > 0 ? s.activeTurnId : h.type === "active" ?
|
|
5545
|
+
let v = m.length > 0 ? s.activeTurnId : h.type === "active" ? $n(d) : null, y = yr(s.messages, _r({
|
|
5564
5546
|
...t.thread,
|
|
5565
5547
|
turns: g
|
|
5566
5548
|
})), b = new Map(y.map((e) => [e.id, e]));
|
|
5567
5549
|
for (let e of s.messages) l.get(e.id) !== e && b.set(e.id, e);
|
|
5568
|
-
let x = v ?
|
|
5550
|
+
let x = v ? U([...b.values()], t.thread.id, v) : [...b.values()], S = this.host.createRuntime(t.thread.id, {
|
|
5569
5551
|
hydrated: !0,
|
|
5570
5552
|
historyMode: t.thread.historyMode ?? "legacy",
|
|
5571
5553
|
loadingStrategy: a.loadingStrategy ?? this.options.loadingStrategy ?? "lazy",
|
|
@@ -5612,7 +5594,7 @@ var Hi = class {
|
|
|
5612
5594
|
threadStatus: structuredClone(t.threadStatus)
|
|
5613
5595
|
};
|
|
5614
5596
|
}
|
|
5615
|
-
},
|
|
5597
|
+
}, Ki = class {
|
|
5616
5598
|
authentication;
|
|
5617
5599
|
approvals;
|
|
5618
5600
|
catalog;
|
|
@@ -5694,7 +5676,7 @@ var Hi = class {
|
|
|
5694
5676
|
return;
|
|
5695
5677
|
}
|
|
5696
5678
|
case "thread/goal/updated":
|
|
5697
|
-
if (
|
|
5679
|
+
if ($r(this.host.requireRuntime(e.params.threadId).goal, e.params.goal)) return;
|
|
5698
5680
|
this.host.patchRuntime(e.params.threadId, { goal: { ...e.params.goal } }), this.host.emitEvent("notification", {
|
|
5699
5681
|
type: "conversation.goalChanged",
|
|
5700
5682
|
conversationId: e.params.threadId,
|
|
@@ -5750,13 +5732,13 @@ var Hi = class {
|
|
|
5750
5732
|
turnStartPending: !1,
|
|
5751
5733
|
error: null,
|
|
5752
5734
|
turnGitDiff: null,
|
|
5753
|
-
turns:
|
|
5754
|
-
messages:
|
|
5735
|
+
turns: Z(t.turns, X(e.params.turn)),
|
|
5736
|
+
messages: U(t.messages, e.params.threadId, e.params.turn.id, { createdAt: Xr(e.params.turn.startedAt) })
|
|
5755
5737
|
}), this.host.patchConversationStatus(e.params.threadId, "active"), n || this.host.emitEvent("notification", {
|
|
5756
5738
|
type: "turn.started",
|
|
5757
5739
|
conversationId: e.params.threadId,
|
|
5758
5740
|
turnId: e.params.turn.id,
|
|
5759
|
-
payload: { startedAt:
|
|
5741
|
+
payload: { startedAt: Xr(e.params.turn.startedAt) }
|
|
5760
5742
|
}), this.host.emitConversationActivity(e.params.threadId, "notification");
|
|
5761
5743
|
return;
|
|
5762
5744
|
}
|
|
@@ -5808,7 +5790,7 @@ var Hi = class {
|
|
|
5808
5790
|
}
|
|
5809
5791
|
case "thread/compacted": {
|
|
5810
5792
|
let t = this.host.requireRuntime(e.params.threadId);
|
|
5811
|
-
this.host.patchRuntime(e.params.threadId, { messages:
|
|
5793
|
+
this.host.patchRuntime(e.params.threadId, { messages: lr(t.messages, e.params.threadId, e.params.turnId, "complete") });
|
|
5812
5794
|
let n = this.host.requireRuntime(e.params.threadId).messages.find((t) => t.kind === "compaction" && t.metadata?.turnId === e.params.turnId);
|
|
5813
5795
|
this.host.emitEvent("notification", {
|
|
5814
5796
|
type: "context.compactionCompleted",
|
|
@@ -5828,7 +5810,7 @@ var Hi = class {
|
|
|
5828
5810
|
let t = this.host.requireRuntime(e.params.threadId), n = !e.params.willRetry && t.activeTurnId === e.params.turnId;
|
|
5829
5811
|
n && (t.activeTurnId = null), this.host.patchRuntime(e.params.threadId, {
|
|
5830
5812
|
error: e.params.error.message,
|
|
5831
|
-
turns:
|
|
5813
|
+
turns: Z(t.turns, {
|
|
5832
5814
|
...t.turns.find((t) => t.id === e.params.turnId) ?? {
|
|
5833
5815
|
id: e.params.turnId,
|
|
5834
5816
|
status: "inProgress",
|
|
@@ -5837,7 +5819,7 @@ var Hi = class {
|
|
|
5837
5819
|
durationMs: null
|
|
5838
5820
|
},
|
|
5839
5821
|
status: e.params.willRetry ? "inProgress" : "failed",
|
|
5840
|
-
error:
|
|
5822
|
+
error: Qr(e.params.error),
|
|
5841
5823
|
willRetry: e.params.willRetry
|
|
5842
5824
|
}),
|
|
5843
5825
|
...n ? {
|
|
@@ -5849,7 +5831,7 @@ var Hi = class {
|
|
|
5849
5831
|
conversationId: e.params.threadId,
|
|
5850
5832
|
turnId: e.params.turnId,
|
|
5851
5833
|
payload: {
|
|
5852
|
-
error:
|
|
5834
|
+
error: Qr(e.params.error),
|
|
5853
5835
|
willRetry: e.params.willRetry
|
|
5854
5836
|
}
|
|
5855
5837
|
}), this.host.emitConversationActivity(e.params.threadId, "notification");
|
|
@@ -5995,7 +5977,7 @@ var Hi = class {
|
|
|
5995
5977
|
default: return this.host.unknownNotification(e);
|
|
5996
5978
|
}
|
|
5997
5979
|
}
|
|
5998
|
-
},
|
|
5980
|
+
}, qi = class {
|
|
5999
5981
|
approvals;
|
|
6000
5982
|
clientRequests;
|
|
6001
5983
|
host;
|
|
@@ -6056,7 +6038,7 @@ var Hi = class {
|
|
|
6056
6038
|
conversationId: e,
|
|
6057
6039
|
payload: {
|
|
6058
6040
|
historyLoading: n.historyLoading,
|
|
6059
|
-
historyState:
|
|
6041
|
+
historyState: Xi(n),
|
|
6060
6042
|
error: n.error
|
|
6061
6043
|
}
|
|
6062
6044
|
});
|
|
@@ -6150,7 +6132,7 @@ var Hi = class {
|
|
|
6150
6132
|
reason: t,
|
|
6151
6133
|
messages: structuredClone(r.messages),
|
|
6152
6134
|
threadStatus: structuredClone(r.threadStatus),
|
|
6153
|
-
state:
|
|
6135
|
+
state: Ji(r)
|
|
6154
6136
|
}
|
|
6155
6137
|
});
|
|
6156
6138
|
}
|
|
@@ -6162,7 +6144,7 @@ var Hi = class {
|
|
|
6162
6144
|
conversationId: e,
|
|
6163
6145
|
payload: {
|
|
6164
6146
|
messages: structuredClone(t.map((e) => r.get(e.id) ?? e)),
|
|
6165
|
-
state:
|
|
6147
|
+
state: Yi(this.require(e))
|
|
6166
6148
|
}
|
|
6167
6149
|
});
|
|
6168
6150
|
}
|
|
@@ -6173,7 +6155,7 @@ var Hi = class {
|
|
|
6173
6155
|
return [...this.require(e).messages].reverse().find((e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === t) ?? null;
|
|
6174
6156
|
}
|
|
6175
6157
|
markTurnActive(e, t) {
|
|
6176
|
-
e.activeTurnId = t, e.busy = !0, e.turnStartPending = !1, e.turnIds.includes(t) || e.turnIds.push(t), e.turns =
|
|
6158
|
+
e.activeTurnId = t, e.busy = !0, e.turnStartPending = !1, e.turnIds.includes(t) || e.turnIds.push(t), e.turns = Z(e.turns, {
|
|
6177
6159
|
id: t,
|
|
6178
6160
|
status: "inProgress",
|
|
6179
6161
|
error: null,
|
|
@@ -6204,7 +6186,7 @@ var Hi = class {
|
|
|
6204
6186
|
i && this.emitSummaryUpserted(i, "updated", n);
|
|
6205
6187
|
}
|
|
6206
6188
|
};
|
|
6207
|
-
function
|
|
6189
|
+
function Ji(e) {
|
|
6208
6190
|
return structuredClone({
|
|
6209
6191
|
activeTurnId: e.activeTurnId,
|
|
6210
6192
|
answeredClientRequestIds: e.answeredClientRequestIds,
|
|
@@ -6213,21 +6195,21 @@ function qi(e) {
|
|
|
6213
6195
|
error: e.error,
|
|
6214
6196
|
executionPlan: e.executionPlan,
|
|
6215
6197
|
historyLoading: e.historyLoading,
|
|
6216
|
-
historyState:
|
|
6198
|
+
historyState: Xi(e),
|
|
6217
6199
|
turnGitDiff: e.turnGitDiff,
|
|
6218
6200
|
turnIds: e.turnIds,
|
|
6219
6201
|
turns: e.turns
|
|
6220
6202
|
});
|
|
6221
6203
|
}
|
|
6222
|
-
function
|
|
6204
|
+
function Yi(e) {
|
|
6223
6205
|
return structuredClone({
|
|
6224
6206
|
historyLoading: e.historyLoading,
|
|
6225
|
-
historyState:
|
|
6207
|
+
historyState: Xi(e),
|
|
6226
6208
|
turnIds: e.turnIds,
|
|
6227
6209
|
turns: e.turns
|
|
6228
6210
|
});
|
|
6229
6211
|
}
|
|
6230
|
-
function
|
|
6212
|
+
function Xi(e) {
|
|
6231
6213
|
return {
|
|
6232
6214
|
loadingStrategy: e.loadingStrategy,
|
|
6233
6215
|
hasOlder: e.historyHasOlder,
|
|
@@ -6237,7 +6219,7 @@ function Yi(e) {
|
|
|
6237
6219
|
}
|
|
6238
6220
|
//#endregion
|
|
6239
6221
|
//#region src/node/codex-surface-connection-controller.ts
|
|
6240
|
-
var
|
|
6222
|
+
var Zi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_request_user_input"]), Qi = class {
|
|
6241
6223
|
client;
|
|
6242
6224
|
options;
|
|
6243
6225
|
authentication;
|
|
@@ -6300,7 +6282,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6300
6282
|
limit: 100,
|
|
6301
6283
|
threadId: null
|
|
6302
6284
|
});
|
|
6303
|
-
for (let e of n.data)
|
|
6285
|
+
for (let e of n.data) Zi.has(e.name) && !e.enabled && (t[e.name] = !0);
|
|
6304
6286
|
e = n.nextCursor;
|
|
6305
6287
|
} while (e);
|
|
6306
6288
|
Object.keys(t).length > 0 && await this.client.request("experimentalFeature/enablement/set", { enablement: t });
|
|
@@ -6434,7 +6416,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6434
6416
|
error: null
|
|
6435
6417
|
});
|
|
6436
6418
|
}
|
|
6437
|
-
},
|
|
6419
|
+
}, $i = 5, ea = class {
|
|
6438
6420
|
client;
|
|
6439
6421
|
loadingStrategy;
|
|
6440
6422
|
catalog;
|
|
@@ -6448,7 +6430,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6448
6430
|
if ((i.busy || i.activeTurnId) && !r.beforeTurnId && (!r.lastTurnId || r.lastTurnId === i.activeTurnId)) throw Error("Cannot fork a conversation while its current turn is still active");
|
|
6449
6431
|
let a = t.cwd ?? i.cwd ?? n.cwd, o = await this.catalog.loadConversationCatalogs(a ?? void 0), s = this.host.getState(), c = t.model ? Pt(s.models, t.model) : A(s.models, i.selectedModelId);
|
|
6450
6432
|
Ft(c, t.reasoningEffort), M(c, t.serviceTier);
|
|
6451
|
-
let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers :
|
|
6433
|
+
let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ei(n.mcpServers), u = await this.extensions.conversationExtension({
|
|
6452
6434
|
operation: "start",
|
|
6453
6435
|
conversationId: null,
|
|
6454
6436
|
cwd: a ?? void 0,
|
|
@@ -6466,7 +6448,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6466
6448
|
...u.baseInstructions === void 0 ? {} : { baseInstructions: u.baseInstructions },
|
|
6467
6449
|
...u.developerInstructions === void 0 ? {} : { developerInstructions: u.developerInstructions },
|
|
6468
6450
|
...u.config === void 0 ? {} : { config: u.config },
|
|
6469
|
-
...
|
|
6451
|
+
...ta(t, o.approvalPresets)
|
|
6470
6452
|
});
|
|
6471
6453
|
if (!d.thread.id || d.thread.id === e) throw Error(`Codex thread/fork returned an invalid new thread id '${d.thread.id}'`);
|
|
6472
6454
|
t.reasoningEffort && await this.client.request("thread/settings/update", {
|
|
@@ -6477,13 +6459,13 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6477
6459
|
let [f, p] = await Promise.all([this.client.request("thread/turns/list", {
|
|
6478
6460
|
threadId: d.thread.id,
|
|
6479
6461
|
cursor: null,
|
|
6480
|
-
limit:
|
|
6462
|
+
limit: $i,
|
|
6481
6463
|
sortDirection: "desc",
|
|
6482
6464
|
itemsView: "full"
|
|
6483
|
-
}), this.client.request("thread/goal/get", { threadId: d.thread.id }).then((e) => e.goal).catch(() => null)]), m = [...f.data].reverse(), h =
|
|
6465
|
+
}), this.client.request("thread/goal/get", { threadId: d.thread.id }).then((e) => e.goal).catch(() => null)]), m = [...f.data].reverse(), h = $n(m), g = _r({
|
|
6484
6466
|
...d.thread,
|
|
6485
6467
|
turns: m
|
|
6486
|
-
}), _ = h ?
|
|
6468
|
+
}), _ = h ? U(g, d.thread.id, h) : g, v = n.loadingStrategy ?? this.loadingStrategy ?? "lazy", y = this.host.createRuntime(d.thread.id, {
|
|
6487
6469
|
hydrated: !0,
|
|
6488
6470
|
historyMode: d.thread.historyMode ?? "legacy",
|
|
6489
6471
|
loadingStrategy: v,
|
|
@@ -6493,7 +6475,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6493
6475
|
fullHistoryHydrated: f.nextCursor === null,
|
|
6494
6476
|
cwd: d.cwd ?? d.thread.cwd ?? a ?? null,
|
|
6495
6477
|
activeTurnId: h,
|
|
6496
|
-
turns: m.map((e) =>
|
|
6478
|
+
turns: m.map((e) => X(e)),
|
|
6497
6479
|
turnIds: m.map((e) => e.id),
|
|
6498
6480
|
messages: _,
|
|
6499
6481
|
busy: !!h,
|
|
@@ -6519,7 +6501,7 @@ var Xi = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
|
|
|
6519
6501
|
return this.fork(e, n, r, { lastTurnId: t });
|
|
6520
6502
|
}
|
|
6521
6503
|
};
|
|
6522
|
-
function
|
|
6504
|
+
function ta(e, t) {
|
|
6523
6505
|
if (e.approvalPreset) {
|
|
6524
6506
|
if (!t.includes(e.approvalPreset)) throw Error(`Approval preset '${e.approvalPreset}' is not available`);
|
|
6525
6507
|
return Rt(e.approvalPreset);
|
|
@@ -6531,27 +6513,27 @@ function ea(e, t) {
|
|
|
6531
6513
|
}
|
|
6532
6514
|
//#endregion
|
|
6533
6515
|
//#region src/node/codex-markdown-images.ts
|
|
6534
|
-
var
|
|
6516
|
+
var na = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, ra = /* @__PURE__ */ new Set([
|
|
6535
6517
|
".avif",
|
|
6536
6518
|
".gif",
|
|
6537
6519
|
".jpeg",
|
|
6538
6520
|
".jpg",
|
|
6539
6521
|
".png",
|
|
6540
6522
|
".webp"
|
|
6541
|
-
]),
|
|
6523
|
+
]), ia = class {
|
|
6542
6524
|
client;
|
|
6543
6525
|
constructor(e) {
|
|
6544
6526
|
this.client = e;
|
|
6545
6527
|
}
|
|
6546
6528
|
async hydrate(e, t) {
|
|
6547
|
-
let n =
|
|
6548
|
-
return
|
|
6529
|
+
let n = sa(e);
|
|
6530
|
+
return oa(e, (await Promise.all(Array.from(e.matchAll(na), async (e) => {
|
|
6549
6531
|
let r = e.index ?? 0;
|
|
6550
|
-
if (
|
|
6551
|
-
let i = e[2], a =
|
|
6532
|
+
if (ca(r, n)) return null;
|
|
6533
|
+
let i = e[2], a = aa(i, t);
|
|
6552
6534
|
if (!a) return null;
|
|
6553
6535
|
try {
|
|
6554
|
-
let t =
|
|
6536
|
+
let t = Nr((await this.client.request("fs/readFile", { path: a })).dataBase64);
|
|
6555
6537
|
if (!t) return null;
|
|
6556
6538
|
let n = e[0].indexOf("](") + 2;
|
|
6557
6539
|
return {
|
|
@@ -6565,7 +6547,7 @@ var ta = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, na = /* @
|
|
|
6565
6547
|
}))).filter((e) => e !== null));
|
|
6566
6548
|
}
|
|
6567
6549
|
};
|
|
6568
|
-
function
|
|
6550
|
+
function aa(e, t) {
|
|
6569
6551
|
let n = e.trim();
|
|
6570
6552
|
if (!n || /[\u0000-\u001f\u007f]/.test(n)) return null;
|
|
6571
6553
|
let r;
|
|
@@ -6580,18 +6562,18 @@ function ia(e, t) {
|
|
|
6580
6562
|
} catch {
|
|
6581
6563
|
return null;
|
|
6582
6564
|
}
|
|
6583
|
-
if (!
|
|
6565
|
+
if (!ra.has(_(r).toLowerCase())) return null;
|
|
6584
6566
|
if (v(r)) return r;
|
|
6585
6567
|
if (!t || !v(t)) return null;
|
|
6586
6568
|
let i = x(t, r), a = b(t, i);
|
|
6587
6569
|
return a === ".." || a.startsWith(`..${S}`) || v(a) ? null : i;
|
|
6588
6570
|
}
|
|
6589
|
-
function
|
|
6571
|
+
function oa(e, t) {
|
|
6590
6572
|
let n = e;
|
|
6591
6573
|
for (let e of t.sort((e, t) => t.start - e.start)) n = `${n.slice(0, e.start)}${e.value}${n.slice(e.end)}`;
|
|
6592
6574
|
return n;
|
|
6593
6575
|
}
|
|
6594
|
-
function
|
|
6576
|
+
function sa(e) {
|
|
6595
6577
|
let t = [], n = /(^|\n)(```|~~~)/g, r;
|
|
6596
6578
|
for (; (r = n.exec(e)) !== null;) {
|
|
6597
6579
|
let i = r[2], a = r[1], o = r.index + a.length, s = RegExp(`(^|\\n)${i}`, "g");
|
|
@@ -6612,15 +6594,15 @@ function oa(e) {
|
|
|
6612
6594
|
}
|
|
6613
6595
|
return t;
|
|
6614
6596
|
}
|
|
6615
|
-
function
|
|
6597
|
+
function ca(e, t) {
|
|
6616
6598
|
return t.some((t) => e >= t.start && e <= t.end);
|
|
6617
6599
|
}
|
|
6618
|
-
var
|
|
6619
|
-
async function
|
|
6600
|
+
var la = /<context>[\s\S]*?<\/context>\s*/g, ua = /<in-app-browser-context(?:\s[^>]*)?>[\s\S]*?<\/in-app-browser-context>\s*/g, da = /^[ \t]*## My request for Codex:[ \t]*$/m;
|
|
6601
|
+
async function fa(e, t) {
|
|
6620
6602
|
let n = O(t);
|
|
6621
6603
|
return {
|
|
6622
6604
|
conversationId: n,
|
|
6623
|
-
prompts:
|
|
6605
|
+
prompts: pa((await e.request("thread/turns/list", {
|
|
6624
6606
|
threadId: n,
|
|
6625
6607
|
cursor: null,
|
|
6626
6608
|
limit: 100,
|
|
@@ -6629,20 +6611,20 @@ async function da(e, t) {
|
|
|
6629
6611
|
})).data)
|
|
6630
6612
|
};
|
|
6631
6613
|
}
|
|
6632
|
-
function
|
|
6614
|
+
function pa(e) {
|
|
6633
6615
|
return [...e].reverse().flatMap((e) => e.items.flatMap((e) => {
|
|
6634
6616
|
if (e.type !== "userMessage") return [];
|
|
6635
|
-
let t =
|
|
6617
|
+
let t = ma(e.content.flatMap((e) => e.type === "text" ? [e.text] : []).join(""));
|
|
6636
6618
|
return t && t !== "(no user instructions)" ? [t] : [];
|
|
6637
6619
|
}));
|
|
6638
6620
|
}
|
|
6639
|
-
function
|
|
6640
|
-
let t = e.replace(
|
|
6641
|
-
return (n === t ? n : n.replace(
|
|
6621
|
+
function ma(e) {
|
|
6622
|
+
let t = e.replace(la, ""), n = t.replace(ua, "");
|
|
6623
|
+
return (n === t ? n : n.replace(da, "")).trim();
|
|
6642
6624
|
}
|
|
6643
6625
|
//#endregion
|
|
6644
6626
|
//#region src/node/codex-surface-text-generation-controller.ts
|
|
6645
|
-
var
|
|
6627
|
+
var ha = 12e4, ga = class {
|
|
6646
6628
|
client;
|
|
6647
6629
|
defaultCwd;
|
|
6648
6630
|
host;
|
|
@@ -6653,7 +6635,7 @@ var ma = 12e4, ha = class {
|
|
|
6653
6635
|
}
|
|
6654
6636
|
handleNotification(e) {
|
|
6655
6637
|
e.method === "thread/started" && e.params.thread.ephemeral && this.hiddenThreadIds.add(e.params.thread.id);
|
|
6656
|
-
let t =
|
|
6638
|
+
let t = ba(e);
|
|
6657
6639
|
if (!t || !this.hiddenThreadIds.has(t)) return !1;
|
|
6658
6640
|
let n = this.pendingByThread.get(t);
|
|
6659
6641
|
return n && this.consumeNotification(n, e), (e.method === "thread/closed" || e.method === "thread/deleted") && this.hiddenThreadIds.delete(t), !0;
|
|
@@ -6661,7 +6643,7 @@ var ma = 12e4, ha = class {
|
|
|
6661
6643
|
async generate(e, t = {}) {
|
|
6662
6644
|
let n = e.trim();
|
|
6663
6645
|
if (!n) throw Error("Generation prompt cannot be empty");
|
|
6664
|
-
if (t.signal?.aborted) throw
|
|
6646
|
+
if (t.signal?.aborted) throw xa();
|
|
6665
6647
|
await this.host.ensureConnected();
|
|
6666
6648
|
let r = this.host.getSnapshot(), i = A(r.models, r.selectedModelId), a = t.model ? Pt(r.models, t.model) : i, o = a?.model, s = t.reasoningEffort ?? (a?.id === i?.id ? r.selectedReasoningEffort : a ? j(a) : null) ?? void 0, c = t.serviceTier === void 0 ? a?.id === i?.id ? r.selectedServiceTier : a?.defaultServiceTier ?? null : t.serviceTier;
|
|
6667
6649
|
Ft(a, s), M(a, c);
|
|
@@ -6680,15 +6662,15 @@ var ma = 12e4, ha = class {
|
|
|
6680
6662
|
serviceName: "codex_app_sdk",
|
|
6681
6663
|
threadSource: "sdk_ephemeral_generation"
|
|
6682
6664
|
}), u = l.thread.id;
|
|
6683
|
-
if (!l.thread.ephemeral) throw await
|
|
6684
|
-
if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await
|
|
6685
|
-
let d =
|
|
6665
|
+
if (!l.thread.ephemeral) throw await _a(() => this.client.request("thread/delete", { threadId: u })), Error("Codex app-server did not create an ephemeral generation thread");
|
|
6666
|
+
if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await _a(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u), xa();
|
|
6667
|
+
let d = va();
|
|
6686
6668
|
this.pendingByThread.set(u, d);
|
|
6687
|
-
let f = null, p = !1, m = () => d.reject(
|
|
6669
|
+
let f = null, p = !1, m = () => d.reject(xa());
|
|
6688
6670
|
t.signal?.addEventListener("abort", m);
|
|
6689
6671
|
let h = setTimeout(() => {
|
|
6690
6672
|
d.reject(/* @__PURE__ */ Error("Codex ephemeral generation timed out"));
|
|
6691
|
-
}, t.timeoutMs ??
|
|
6673
|
+
}, t.timeoutMs ?? ha);
|
|
6692
6674
|
try {
|
|
6693
6675
|
let e = await this.client.request("turn/start", {
|
|
6694
6676
|
threadId: u,
|
|
@@ -6704,18 +6686,18 @@ var ma = 12e4, ha = class {
|
|
|
6704
6686
|
serviceTier: c,
|
|
6705
6687
|
...t.outputSchema === void 0 ? {} : { outputSchema: t.outputSchema }
|
|
6706
6688
|
});
|
|
6707
|
-
f = e.turn.id, d.turnId = f,
|
|
6689
|
+
f = e.turn.id, d.turnId = f, ya(d, e.turn);
|
|
6708
6690
|
let r = await d.promise;
|
|
6709
6691
|
return p = !0, r;
|
|
6710
6692
|
} finally {
|
|
6711
6693
|
if (clearTimeout(h), t.signal?.removeEventListener("abort", m), this.pendingByThread.delete(u), !p && f) {
|
|
6712
6694
|
let e = f;
|
|
6713
|
-
await
|
|
6695
|
+
await _a(() => this.client.request("turn/interrupt", {
|
|
6714
6696
|
threadId: u,
|
|
6715
6697
|
turnId: e
|
|
6716
6698
|
}));
|
|
6717
6699
|
}
|
|
6718
|
-
await
|
|
6700
|
+
await _a(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u);
|
|
6719
6701
|
}
|
|
6720
6702
|
}
|
|
6721
6703
|
close(e = /* @__PURE__ */ Error("Codex surface closed")) {
|
|
@@ -6738,16 +6720,16 @@ var ma = 12e4, ha = class {
|
|
|
6738
6720
|
}
|
|
6739
6721
|
if (t.method === "turn/completed") {
|
|
6740
6722
|
if (e.turnId && t.params.turn.id !== e.turnId) return;
|
|
6741
|
-
|
|
6723
|
+
ya(e, t.params.turn);
|
|
6742
6724
|
}
|
|
6743
6725
|
}
|
|
6744
6726
|
};
|
|
6745
|
-
async function
|
|
6727
|
+
async function _a(e) {
|
|
6746
6728
|
try {
|
|
6747
6729
|
await e();
|
|
6748
6730
|
} catch {}
|
|
6749
6731
|
}
|
|
6750
|
-
function
|
|
6732
|
+
function va() {
|
|
6751
6733
|
let e, t, n = {
|
|
6752
6734
|
promise: new Promise((n, r) => {
|
|
6753
6735
|
e = n, t = r;
|
|
@@ -6763,7 +6745,7 @@ function _a() {
|
|
|
6763
6745
|
};
|
|
6764
6746
|
return n.promise.catch(() => void 0), n;
|
|
6765
6747
|
}
|
|
6766
|
-
function
|
|
6748
|
+
function ya(e, t) {
|
|
6767
6749
|
for (let n of t.items) {
|
|
6768
6750
|
if (n.type !== "agentMessage") continue;
|
|
6769
6751
|
let t = n.text.trim();
|
|
@@ -6785,17 +6767,17 @@ function va(e, t) {
|
|
|
6785
6767
|
}
|
|
6786
6768
|
e.resolve({ text: n });
|
|
6787
6769
|
}
|
|
6788
|
-
function
|
|
6770
|
+
function ba(e) {
|
|
6789
6771
|
if (e.method === "thread/started") return e.params.thread.id;
|
|
6790
6772
|
let t = e.params;
|
|
6791
6773
|
return typeof t.threadId == "string" ? t.threadId : null;
|
|
6792
6774
|
}
|
|
6793
|
-
function
|
|
6775
|
+
function xa() {
|
|
6794
6776
|
return /* @__PURE__ */ Error("Codex ephemeral generation was aborted");
|
|
6795
6777
|
}
|
|
6796
6778
|
//#endregion
|
|
6797
6779
|
//#region src/node/codex-surface-usage-controller.ts
|
|
6798
|
-
var
|
|
6780
|
+
var Sa = {
|
|
6799
6781
|
status: "unavailable",
|
|
6800
6782
|
reason: "public-runtime-request-evidence-unavailable",
|
|
6801
6783
|
unavailableFields: [
|
|
@@ -6813,7 +6795,7 @@ var xa = {
|
|
|
6813
6795
|
"finality"
|
|
6814
6796
|
],
|
|
6815
6797
|
requests: null
|
|
6816
|
-
},
|
|
6798
|
+
}, Ca = class {
|
|
6817
6799
|
threads = /* @__PURE__ */ new Map();
|
|
6818
6800
|
clear() {
|
|
6819
6801
|
this.threads.clear();
|
|
@@ -6855,16 +6837,16 @@ var xa = {
|
|
|
6855
6837
|
let e = r.executions.get(r.activeTurnId);
|
|
6856
6838
|
e && (e.baseline = null), i && (i.baseline = null);
|
|
6857
6839
|
}
|
|
6858
|
-
i && (
|
|
6840
|
+
i && (!$(a.total) || i.latest && !Ta(i.latest.total, a.total)) && (i.baseline = null);
|
|
6859
6841
|
let s = i?.baseline ? Ea(i.baseline, a.total) : null;
|
|
6860
6842
|
i && s === null && (i.baseline = null);
|
|
6861
6843
|
let c = {
|
|
6862
6844
|
...a,
|
|
6863
6845
|
execution: s,
|
|
6864
6846
|
observedStart: !!i,
|
|
6865
|
-
requestUsage: structuredClone(
|
|
6847
|
+
requestUsage: structuredClone(Sa)
|
|
6866
6848
|
};
|
|
6867
|
-
return i && (i.latest = structuredClone(c)), r.total = !o &&
|
|
6849
|
+
return i && (i.latest = structuredClone(c)), r.total = !o && $(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
|
|
6868
6850
|
...t,
|
|
6869
6851
|
payload: { usage: c }
|
|
6870
6852
|
};
|
|
@@ -6878,21 +6860,21 @@ var xa = {
|
|
|
6878
6860
|
executions: /* @__PURE__ */ new Map()
|
|
6879
6861
|
}, this.threads.set(e, t)), t;
|
|
6880
6862
|
}
|
|
6881
|
-
},
|
|
6863
|
+
}, wa = [
|
|
6882
6864
|
"totalTokens",
|
|
6883
6865
|
"inputTokens",
|
|
6884
6866
|
"cachedInputTokens",
|
|
6885
6867
|
"outputTokens",
|
|
6886
6868
|
"reasoningOutputTokens"
|
|
6887
6869
|
];
|
|
6888
|
-
function
|
|
6889
|
-
return
|
|
6870
|
+
function $(e) {
|
|
6871
|
+
return wa.every((t) => Number.isSafeInteger(e[t]) && e[t] >= 0) && (e.cacheWriteInputTokens === null || Number.isSafeInteger(e.cacheWriteInputTokens) && e.cacheWriteInputTokens >= 0) && e.totalTokens === e.inputTokens + e.outputTokens && e.cachedInputTokens <= e.inputTokens && e.reasoningOutputTokens <= e.outputTokens;
|
|
6890
6872
|
}
|
|
6891
6873
|
function Ta(e, t) {
|
|
6892
|
-
return
|
|
6874
|
+
return wa.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
|
|
6893
6875
|
}
|
|
6894
6876
|
function Ea(e, t) {
|
|
6895
|
-
if (
|
|
6877
|
+
if (!$(e) || !$(t) || !Ta(e, t)) return null;
|
|
6896
6878
|
let n = {
|
|
6897
6879
|
totalTokens: t.totalTokens - e.totalTokens,
|
|
6898
6880
|
inputTokens: t.inputTokens - e.inputTokens,
|
|
@@ -6901,7 +6883,7 @@ function Ea(e, t) {
|
|
|
6901
6883
|
outputTokens: t.outputTokens - e.outputTokens,
|
|
6902
6884
|
reasoningOutputTokens: t.reasoningOutputTokens - e.reasoningOutputTokens
|
|
6903
6885
|
};
|
|
6904
|
-
return
|
|
6886
|
+
return $(n) ? n : null;
|
|
6905
6887
|
}
|
|
6906
6888
|
//#endregion
|
|
6907
6889
|
//#region src/node/codex-surface.ts
|
|
@@ -6936,21 +6918,21 @@ var Da = class {
|
|
|
6936
6918
|
unsubscribeToolInputRequests;
|
|
6937
6919
|
unsubscribeMcpElicitationRequests;
|
|
6938
6920
|
eventSequence = 0;
|
|
6939
|
-
usage = new
|
|
6921
|
+
usage = new Ca();
|
|
6940
6922
|
accountGeneration = 0;
|
|
6941
6923
|
pendingMarkdownImageHydrations = /* @__PURE__ */ new Set();
|
|
6942
6924
|
closed = !1;
|
|
6943
6925
|
state = xt(wt());
|
|
6944
6926
|
constructor(e = {}) {
|
|
6945
|
-
this.options = e, this.extensions = new
|
|
6927
|
+
this.options = e, this.extensions = new Ni(e.extensions ?? [], e.mcpServers ?? [], (e) => this.lifecycle.hostOptions(e));
|
|
6946
6928
|
let n = dn(e);
|
|
6947
|
-
this.client = e.client ?? new t(un(n) ? new Ye(n) : new We(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.markdownImages = new
|
|
6929
|
+
this.client = e.client ?? new t(un(n) ? new Ye(n) : new We(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.markdownImages = new ia(this.client), this.authentication = new pn(this.client, {
|
|
6948
6930
|
bootstrapSurfaceData: (e) => this.connection.bootstrapSurfaceData(e),
|
|
6949
6931
|
clearAuthenticatedSurfaceData: () => this.connection.clearAuthenticatedSurfaceData(),
|
|
6950
6932
|
getSnapshot: () => this.getSnapshot(),
|
|
6951
6933
|
patchAuthentication: (e, t) => this.connection.patchAuthentication(e, t),
|
|
6952
6934
|
reportError: (e) => this.patch({ error: k(e) })
|
|
6953
|
-
}), this.items = new
|
|
6935
|
+
}), this.items = new ri({
|
|
6954
6936
|
assistantMessageForTurn: (e, t) => this.assistantMessageForTurn(e, t),
|
|
6955
6937
|
emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
|
|
6956
6938
|
emitEvent: (e, t) => this.emitEvent(e, t),
|
|
@@ -6964,7 +6946,7 @@ var Da = class {
|
|
|
6964
6946
|
sendNextQueuedPrompt: (e) => {
|
|
6965
6947
|
this.messagesController.sendNextQueuedPrompt(e);
|
|
6966
6948
|
}
|
|
6967
|
-
}), this.approvals = new
|
|
6949
|
+
}), this.approvals = new Ti(this.client, {
|
|
6968
6950
|
activeConversationId: () => this.state.activeConversationId,
|
|
6969
6951
|
createRuntime: (e, t) => this.createRuntime(e, t),
|
|
6970
6952
|
emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
|
|
@@ -6974,7 +6956,7 @@ var Da = class {
|
|
|
6974
6956
|
patch: (e) => this.patch(e),
|
|
6975
6957
|
patchConversationStatus: (e, t) => this.patchConversationStatus(e, t),
|
|
6976
6958
|
patchRuntime: (e, t) => this.patchRuntime(e, t)
|
|
6977
|
-
}), this.clientRequests = new
|
|
6959
|
+
}), this.clientRequests = new oi({
|
|
6978
6960
|
activeConversationId: () => this.state.activeConversationId,
|
|
6979
6961
|
answerAsyncQuestion: (e, t, n) => this.messagesController.answerAsyncQuestion(e, t, n),
|
|
6980
6962
|
emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
|
|
@@ -6984,13 +6966,13 @@ var Da = class {
|
|
|
6984
6966
|
messageContainingTool: (e, t, n) => this.messageContainingTool(e, t, n),
|
|
6985
6967
|
patchRuntime: (e, t) => this.patchRuntime(e, t),
|
|
6986
6968
|
requireRuntime: (e) => this.requireRuntime(e)
|
|
6987
|
-
}), this.runtimeState = new
|
|
6969
|
+
}), this.runtimeState = new qi(this.approvals, this.clientRequests, {
|
|
6988
6970
|
emitEvent: (e, t) => this.emitEvent(e, t),
|
|
6989
6971
|
getState: () => this.state,
|
|
6990
6972
|
notifyConversationListeners: (e) => this.notifyConversationListeners(e),
|
|
6991
6973
|
patch: (e, t) => this.patch(e, t),
|
|
6992
6974
|
schedulePluginRefresh: () => this.catalog.schedulePluginRefresh()
|
|
6993
|
-
}), this.conversationSettings = new
|
|
6975
|
+
}), this.conversationSettings = new zi(this.client, {
|
|
6994
6976
|
approvalMode: e.approvalMode,
|
|
6995
6977
|
approvalPreset: e.approvalPreset,
|
|
6996
6978
|
permissionMode: e.permissionMode
|
|
@@ -7008,7 +6990,7 @@ var Da = class {
|
|
|
7008
6990
|
patch: (e) => this.patch(e),
|
|
7009
6991
|
patchRuntime: (e, t) => this.patchRuntime(e, t),
|
|
7010
6992
|
snapshotForRuntime: (e) => this.snapshotForRuntime(e)
|
|
7011
|
-
}), this.turnActions = new
|
|
6993
|
+
}), this.turnActions = new Vi(this.client, {
|
|
7012
6994
|
createConversation: async () => {
|
|
7013
6995
|
await this.createConversation();
|
|
7014
6996
|
},
|
|
@@ -7025,7 +7007,7 @@ var Da = class {
|
|
|
7025
7007
|
patchConversationTurnCount: (e, t, n) => this.patchConversationTurnCount(e, t, n),
|
|
7026
7008
|
patchRuntime: (e, t) => this.patchRuntime(e, t),
|
|
7027
7009
|
sendMessageToThread: (e, t, n) => this.messagesController.sendToThread(e, t, n)
|
|
7028
|
-
}), this.messagesController = new
|
|
7010
|
+
}), this.messagesController = new Ui(this.client, {
|
|
7029
7011
|
clearGoalForThread: (e) => this.conversationSettings.clearGoalForThread(e),
|
|
7030
7012
|
compactForThread: (e) => this.turnActions.compactForThread(e),
|
|
7031
7013
|
createConversation: async () => {
|
|
@@ -7048,7 +7030,7 @@ var Da = class {
|
|
|
7048
7030
|
startReviewForThread: (e, t) => this.turnActions.startReviewForThread(e, t),
|
|
7049
7031
|
updateSettings: (e) => this.conversationSettings.update(e),
|
|
7050
7032
|
updateSettingsForThread: (e, t) => this.conversationSettings.updateForThread(e, t)
|
|
7051
|
-
}), this.catalog = new
|
|
7033
|
+
}), this.catalog = new _i(this.client, e.cwd, {
|
|
7052
7034
|
authenticationBlocksBootstrap: () => this.authentication.blocksBootstrap(),
|
|
7053
7035
|
emitConversationSkills: (e, t) => this.emitConversationSkills(e, t),
|
|
7054
7036
|
emitEvent: (e, t) => this.emitEvent(e, t),
|
|
@@ -7059,7 +7041,7 @@ var Da = class {
|
|
|
7059
7041
|
patchRuntime: (e, t) => this.patchRuntime(e, t),
|
|
7060
7042
|
preferredApprovalPreset: () => this.conversationSettings.preferredApprovalPreset(),
|
|
7061
7043
|
runtimes: () => this.runtimeState.values()
|
|
7062
|
-
}), this.conversations = new
|
|
7044
|
+
}), this.conversations = new Li(this.client, e.conversationLimit, {
|
|
7063
7045
|
emitHistoryPrepended: (e, t, n) => this.emitHistoryPrepended(e, t, n),
|
|
7064
7046
|
emitSummaryUpserted: (e, t, n) => this.emitSummaryUpserted(e, t, n),
|
|
7065
7047
|
ensureConnected: () => this.ensureConnected(),
|
|
@@ -7071,7 +7053,7 @@ var Da = class {
|
|
|
7071
7053
|
requireRuntime: (e) => this.requireRuntime(e),
|
|
7072
7054
|
runtime: (e) => this.runtimeState.get(e),
|
|
7073
7055
|
schedulePluginRefresh: (e) => this.catalog.schedulePluginRefresh(e)
|
|
7074
|
-
}), this.lifecycle = new
|
|
7056
|
+
}), this.lifecycle = new Gi(this.client, e, this.catalog, this.extensions, this.conversationSettings, this.conversations, {
|
|
7075
7057
|
activateRuntime: (e) => this.activateRuntime(e),
|
|
7076
7058
|
createRuntime: (e, t) => this.createRuntime(e, t),
|
|
7077
7059
|
emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
|
|
@@ -7094,7 +7076,7 @@ var Da = class {
|
|
|
7094
7076
|
runtime: (e) => this.runtimeState.get(e),
|
|
7095
7077
|
runtimeProjection: (e) => this.runtimeProjection(e),
|
|
7096
7078
|
snapshotForRuntime: (e) => this.snapshotForRuntime(e)
|
|
7097
|
-
}), this.forks = new
|
|
7079
|
+
}), this.forks = new ea(this.client, e.loadingStrategy, this.catalog, this.extensions, {
|
|
7098
7080
|
createRuntime: (e, t) => this.createRuntime(e, t),
|
|
7099
7081
|
emitConversationActivity: (e) => this.emitConversationActivity(e, "action"),
|
|
7100
7082
|
emitConversationPermissions: (e) => this.emitConversationPermissions(e, "action"),
|
|
@@ -7108,7 +7090,7 @@ var Da = class {
|
|
|
7108
7090
|
rememberHostOptions: (e, t) => this.lifecycle.rememberHostOptions(e, t),
|
|
7109
7091
|
requireRuntime: (e) => this.requireRuntime(e),
|
|
7110
7092
|
snapshotForRuntime: (e) => this.snapshotForRuntime(e)
|
|
7111
|
-
}), this.connection = new
|
|
7093
|
+
}), this.connection = new Qi(this.client, e, this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, this.lifecycle, this.runtimeState, {
|
|
7112
7094
|
clearConversationHandles: () => this.conversationHandles.clear(),
|
|
7113
7095
|
clearPendingForThread: (e, t, n) => this.clearPendingForThread(e, t, n),
|
|
7114
7096
|
closed: () => this.closed,
|
|
@@ -7120,7 +7102,7 @@ var Da = class {
|
|
|
7120
7102
|
getSnapshot: () => this.getSnapshot(),
|
|
7121
7103
|
getState: () => this.state,
|
|
7122
7104
|
patch: (e) => this.patch(e)
|
|
7123
|
-
}), this.notifications = new
|
|
7105
|
+
}), this.notifications = new Ki(this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, {
|
|
7124
7106
|
clearPendingForThread: (e, t, n) => this.clearPendingForThread(e, t, n),
|
|
7125
7107
|
createRuntime: (e, t) => this.createRuntime(e, t),
|
|
7126
7108
|
emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
|
|
@@ -7144,7 +7126,7 @@ var Da = class {
|
|
|
7144
7126
|
},
|
|
7145
7127
|
snapshotForRuntime: (e) => this.snapshotForRuntime(e),
|
|
7146
7128
|
unknownNotification: (e) => this.handleUnknownNotification(e)
|
|
7147
|
-
}), this.textGeneration = new
|
|
7129
|
+
}), this.textGeneration = new ga(this.client, e.cwd, {
|
|
7148
7130
|
ensureConnected: () => this.ensureConnected(),
|
|
7149
7131
|
getSnapshot: () => this.getSnapshot()
|
|
7150
7132
|
}), this.unsubscribeNotification = this.client.onNotification((e) => {
|
|
@@ -7317,7 +7299,7 @@ var Da = class {
|
|
|
7317
7299
|
return this.lifecycle.readHistory(e);
|
|
7318
7300
|
}
|
|
7319
7301
|
async readConversationPromptHistory(e = this.state.activeConversationId ?? "") {
|
|
7320
|
-
return await this.ensureConnected(),
|
|
7302
|
+
return await this.ensureConnected(), fa(this.client, e);
|
|
7321
7303
|
}
|
|
7322
7304
|
async loadOlderConversationHistory(e = this.state.activeConversationId ?? "") {
|
|
7323
7305
|
return this.conversations.loadOlderHistory(O(e));
|
|
@@ -8069,6 +8051,6 @@ async function za(e, t, n = {}) {
|
|
|
8069
8051
|
};
|
|
8070
8052
|
}
|
|
8071
8053
|
//#endregion
|
|
8072
|
-
export { ja as CodexAppBackend, Aa as CodexAppBackendTtlCache, We as CodexAppServerStdioTransport, Ye as CodexAppServerUnixSocketTransport, Da as CodexSurface,
|
|
8054
|
+
export { ja as CodexAppBackend, Aa as CodexAppBackendTtlCache, We as CodexAppServerStdioTransport, Ye as CodexAppServerUnixSocketTransport, Da as CodexSurface, Cr as codexItemToMediaPart, xr as codexItemToSurfaceMessage, R as codexItemToToolPart, _e as codexRuntimePathEntries, _r as codexThreadToSurfaceMessages, br as codexTurnToSurfaceMessages, Ma as createCodexAppBackend, Oa as createCodexSurface, ge as discoverCodexExecutable, vr as preserveHistoricalAttachmentPreviews, Pa as resolveAppleSpeechAnalyzerPath, ye as resolveCodexRuntime, za as startAppleSpeechSession, Na as transcribeWithAppleSpeechAnalyzer, ve as withCodexRuntimePath };
|
|
8073
8055
|
|
|
8074
8056
|
//# sourceMappingURL=index.js.map
|