Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Record externally completed agent config imports (#34981)

charlesgong-openaice803c45aed4
diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json
index 8b8c2bd584..8588a34069 100644
--- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json
+++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json
@@ -911,6 +911,98 @@
},
"type": "object"
},
+ "ExternalAgentConfigImportHistoryRecordParams": {
+ "properties": {
+ "itemTypeResults": {
+ "description": "Completed results grouped by imported item type.",
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportTypeResult"
+ },
+ "type": "array"
+ },
+ "providerId": {
+ "description": "Opaque provider identifier for the externally completed import.",
+ "type": "string"
+ }
+ },
+ "required": [
+ "itemTypeResults",
+ "providerId"
+ ],
+ "type": "object"
+ },
+ "ExternalAgentConfigImportItemTypeFailure": {
+ "properties": {
+ "cwd": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "errorType": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "failureStage": {
+ "type": "string"
+ },
+ "itemType": {
+ "$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
+ },
+ "message": {
+ "type": "string"
+ },
+ "source": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "subErrorType": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "failureStage",
+ "itemType",
+ "message"
+ ],
+ "type": "object"
+ },
+ "ExternalAgentConfigImportItemTypeSuccess": {
+ "properties": {
+ "cwd": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "itemType": {
+ "$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
+ },
+ "source": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "target": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "itemType"
+ ],
+ "type": "object"
+ },
"ExternalAgentConfigImportParams": {
"properties": {
"migrationItems": {
@@ -927,7 +1019,7 @@
]
},
"providerId": {
- "description": "Opaque provider identifier supplied by the caller for analytics attribution. This does not select the migration source.",
+ "description": "Opaque provider identifier supplied by the caller for analytics attribution and import history display. This does not select the migration source.",
"type": [
"string",
"null"
@@ -946,6 +1038,31 @@
],
"type": "object"
},
+ "ExternalAgentConfigImportTypeResult": {
+ "properties": {
+ "failures": {
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportItemTypeFailure"
+ },
+ "type": "array"
+ },
+ "itemType": {
+ "$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
+ },
+ "successes": {
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportItemTypeSuccess"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "failures",
+ "itemType",
+ "successes"
+ ],
+ "type": "object"
+ },
"ExternalAgentConfigMigrationItem": {
"properties": {
"cwd": {
@@ -7076,6 +7193,30 @@
"title": "ExternalAgentConfig/importRequest",
"type": "object"
},
+ {
+ "properties": {
+ "id": {
+ "$ref": "#/definitions/RequestId"
+ },
+ "method": {
+ "enum": [
+ "externalAgentConfig/import/recordHistory"
+ ],
+ "title": "ExternalAgentConfig/import/recordHistoryRequestMethod",
+ "type": "string"
+ },
+ "params": {
+ "$ref": "#/definitions/ExternalAgentConfigImportHistoryRecordParams"
+ }
+ },
+ "required": [
+ "id",
+ "method",
+ "params"
+ ],
+ "title": "ExternalAgentConfig/import/recordHistoryRequest",
+ "type": "object"
+ },
{
"properties": {
"id": {
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
index 62505923e0..4cea1b4a09 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
@@ -2195,6 +2195,30 @@
"title": "ExternalAgentConfig/importRequest",
"type": "object"
},
+ {
+ "properties": {
+ "id": {
+ "$ref": "#/definitions/v2/RequestId"
+ },
+ "method": {
+ "enum": [
+ "externalAgentConfig/import/recordHistory"
+ ],
+ "title": "ExternalAgentConfig/import/recordHistoryRequestMethod",
+ "type": "string"
+ },
+ "params": {
+ "$ref": "#/definitions/v2/ExternalAgentConfigImportHistoryRecordParams"
+ }
+ },
+ "required": [
+ "id",
+ "method",
+ "params"
+ ],
+ "title": "ExternalAgentConfig/import/recordHistoryRequest",
+ "type": "object"
+ },
{
"properties": {
"id": {
@@ -9741,6 +9765,12 @@
"importId": {
"type": "string"
},
+ "providerId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
"successes": {
"items": {
"$ref": "#/definitions/v2/ExternalAgentConfigImportItemTypeSuccess"
@@ -9756,6 +9786,41 @@
],
"type": "object"
},
+ "ExternalAgentConfigImportHistoryRecordParams": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "properties": {
+ "itemTypeResults": {
+ "description": "Completed results grouped by imported item type.",
+ "items": {
+ "$ref": "#/definitions/v2/ExternalAgentConfigImportTypeResult"
+ },
+ "type": "array"
+ },
+ "providerId": {
+ "description": "Opaque provider identifier for the externally completed import.",
+ "type": "string"
+ }
+ },
+ "required": [
+ "itemTypeResults",
+ "providerId"
+ ],
+ "title": "ExternalAgentConfigImportHistoryRecordParams",
+ "type": "object"
+ },
+ "ExternalAgentConfigImportHistoryRecordResponse": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "properties": {
+ "importId": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "importId"
+ ],
+ "title": "ExternalAgentConfigImportHistoryRecordResponse",
+ "type": "object"
+ },
"ExternalAgentConfigImportItemTypeFailure": {
"properties": {
"cwd": {
@@ -9845,7 +9910,7 @@
]
},
"providerId": {
- "description": "Opaque provider identifier supplied by the caller for analytics attribution. This does not select the migration source.",
+ "description": "Opaque provider identifier supplied by the caller for analytics attribution and import history display. This does not select the migration source.",
"type": [
"string",
"null"
diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
index 6087a29298..41846f0c51 100644
--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json
@@ -3334,6 +3334,30 @@
"title": "ExternalAgentConfig/importRequest",
"type": "object"
},
+ {
+ "properties": {
+ "id": {
+ "$ref": "#/definitions/RequestId"
+ },
+ "method": {
+ "enum": [
+ "externalAgentConfig/import/recordHistory"
+ ],
+ "title": "ExternalAgentConfig/import/recordHistoryRequestMethod",
+ "type": "string"
+ },
+ "params": {
+ "$ref": "#/definitions/ExternalAgentConfigImportHistoryRecordParams"
+ }
+ },
+ "required": [
+ "id",
+ "method",
+ "params"
+ ],
+ "title": "ExternalAgentConfig/import/recordHistoryRequest",
+ "type": "object"
+ },
{
"properties": {
"id": {
@@ -5919,6 +5943,12 @@
"importId": {
"type": "string"
},
+ "providerId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
"successes": {
"items": {
"$ref": "#/definitions/ExternalAgentConfigImportItemTypeSuccess"
@@ -5934,6 +5964,41 @@
],
"type": "object"
},
+ "ExternalAgentConfigImportHistoryRecordParams": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "properties": {
+ "itemTypeResults": {
+ "description": "Completed results grouped by imported item type.",
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportTypeResult"
+ },
+ "type": "array"
+ },
+ "providerId": {
+ "description": "Opaque provider identifier for the externally completed import.",
+ "type": "string"
+ }
+ },
+ "required": [
+ "itemTypeResults",
+ "providerId"
+ ],
+ "title": "ExternalAgentConfigImportHistoryRecordParams",
+ "type": "object"
+ },
+ "ExternalAgentConfigImportHistoryRecordResponse": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "properties": {
+ "importId": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "importId"
+ ],
+ "title": "ExternalAgentConfigImportHistoryRecordResponse",
+ "type": "object"
+ },
"ExternalAgentConfigImportItemTypeFailure": {
"properties": {
"cwd": {
@@ -6023,7 +6088,7 @@
]
},
"providerId": {
- "description": "Opaque provider identifier supplied by the caller for analytics attribution. This does not select the migration source.",
+ "description": "Opaque provider identifier supplied by the caller for analytics attribution and import history display. This does not select the migration source.",
"type": [
"string",
"null"
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoriesReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoriesReadResponse.json
index 336a2de02c..0e88e3f882 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoriesReadResponse.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoriesReadResponse.json
@@ -16,6 +16,12 @@
"importId": {
"type": "string"
},
+ "providerId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
"successes": {
"items": {
"$ref": "#/definitions/ExternalAgentConfigImportItemTypeSuccess"
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoryRecordParams.json b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoryRecordParams.json
new file mode 100644
index 0000000000..8902c2916d
--- /dev/null
+++ b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoryRecordParams.json
@@ -0,0 +1,136 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "definitions": {
+ "ExternalAgentConfigImportItemTypeFailure": {
+ "properties": {
+ "cwd": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "errorType": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "failureStage": {
+ "type": "string"
+ },
+ "itemType": {
+ "$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
+ },
+ "message": {
+ "type": "string"
+ },
+ "source": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "subErrorType": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "failureStage",
+ "itemType",
+ "message"
+ ],
+ "type": "object"
+ },
+ "ExternalAgentConfigImportItemTypeSuccess": {
+ "properties": {
+ "cwd": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "itemType": {
+ "$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
+ },
+ "source": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "target": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "itemType"
+ ],
+ "type": "object"
+ },
+ "ExternalAgentConfigImportTypeResult": {
+ "properties": {
+ "failures": {
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportItemTypeFailure"
+ },
+ "type": "array"
+ },
+ "itemType": {
+ "$ref": "#/definitions/ExternalAgentConfigMigrationItemType"
+ },
+ "successes": {
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportItemTypeSuccess"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "failures",
+ "itemType",
+ "successes"
+ ],
+ "type": "object"
+ },
+ "ExternalAgentConfigMigrationItemType": {
+ "enum": [
+ "AGENTS_MD",
+ "CONFIG",
+ "SKILLS",
+ "PLUGINS",
+ "MCP_SERVER_CONFIG",
+ "SUBAGENTS",
+ "HOOKS",
+ "COMMANDS",
+ "MEMORY",
+ "SESSIONS"
+ ],
+ "type": "string"
+ }
+ },
+ "properties": {
+ "itemTypeResults": {
+ "description": "Completed results grouped by imported item type.",
+ "items": {
+ "$ref": "#/definitions/ExternalAgentConfigImportTypeResult"
+ },
+ "type": "array"
+ },
+ "providerId": {
+ "description": "Opaque provider identifier for the externally completed import.",
+ "type": "string"
+ }
+ },
+ "required": [
+ "itemTypeResults",
+ "providerId"
+ ],
+ "title": "ExternalAgentConfigImportHistoryRecordParams",
+ "type": "object"
+}
\ No newline at end of file
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoryRecordResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoryRecordResponse.json
new file mode 100644
index 0000000000..8a52fe3c0c
--- /dev/null
+++ b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportHistoryRecordResponse.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "properties": {
+ "importId": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "importId"
+ ],
+ "title": "ExternalAgentConfigImportHistoryRecordResponse",
+ "type": "object"
+}
\ No newline at end of file
diff --git a/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportParams.json b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportParams.json
index 0c890f14b2..41c0d42148 100644
--- a/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportParams.json
+++ b/codex-rs/app-server-protocol/schema/json/v2/ExternalAgentConfigImportParams.json
@@ -218,7 +218,7 @@
]
},
"providerId": {
- "description": "Opaque provider identifier supplied by the caller for analytics attribution. This does not select the migration source.",
+ "description": "Opaque provider identifier supplied by the caller for analytics attribution and import history display. This does not select the migration source.",
"type": [
"string",
"null"
diff --git a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts
index bcfcaf6d4d..b67f518ac4 100644
--- a/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/ClientRequest.ts
@@ -22,6 +22,7 @@ import type { ConsumeAccountRateLimitResetCreditParams } from "./v2/ConsumeAccou
import type { ExperimentalFeatureEnablementSetParams } from "./v2/ExperimentalFeatureEnablementSetParams";
import type { ExperimentalFeatureListParams } from "./v2/ExperimentalFeatureListParams";
import type { ExternalAgentConfigDetectParams } from "./v2/ExternalAgentConfigDetectParams";
+import type { ExternalAgentConfigImportHistoryRecordParams } from "./v2/ExternalAgentConfigImportHistoryRecordParams";
import type { ExternalAgentConfigImportParams } from "./v2/ExternalAgentConfigImportParams";
import type { FeedbackUploadParams } from "./v2/FeedbackUploadParams";
import type { FsCopyParams } from "./v2/FsCopyParams";
@@ -90,4 +91,4 @@ import type { WindowsSandboxSetupStartParams } from "./v2/WindowsSandboxSetupSta
/**
* Request from the client to the server.
*/
-export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/delete", id: RequestId, params: ThreadDeleteParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/goal/set", id: RequestId, params: ThreadGoalSetParams, } | { "method": "thread/goal/get", id: RequestId, params: ThreadGoalGetParams, } | { "method": "thread/goal/clear", id: RequestId, params: ThreadGoalClearParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/approveGuardianDeniedAction", id: RequestId, params: ThreadApproveGuardianDeniedActionParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "thread/inject_items", id: RequestId, params: ThreadInjectItemsParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "skills/extraRoots/set", id: RequestId, params: SkillsExtraRootsSetParams, } | { "method": "hooks/list", id: RequestId, params: HooksListParams, } | { "method": "marketplace/add", id: RequestId, params: MarketplaceAddParams, } | { "method": "marketplace/remove", id: RequestId, params: MarketplaceRemoveParams, } | { "method": "marketplace/upgrade", id: RequestId, params: MarketplaceUpgradeParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/installed", id: RequestId, params: PluginInstalledParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "plugin/skill/read", id: RequestId, params: PluginSkillReadParams, } | { "method": "plugin/share/save", id: RequestId, params: PluginShareSaveParams, } | { "method": "plugin/share/updateTargets", id: RequestId, params: PluginShareUpdateTargetsParams, } | { "method": "plugin/share/list", id: RequestId, params: PluginShareListParams, } | { "method": "plugin/share/checkout", id: RequestId, params: PluginShareCheckoutParams, } | { "method": "plugin/share/delete", id: RequestId, params: PluginShareDeleteParams, } | { "method": "app/read", id: RequestId, params: AppsReadParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "app/installed", id: RequestId, params: AppsInstalledParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "modelProvider/capabilities/read", id: RequestId, params: ModelProviderCapabilitiesReadParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "permissionProfile/list", id: RequestId, params: PermissionProfileListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "windowsSandbox/readiness", id: RequestId, params: undefined, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "account/rateLimitResetCredit/consume", id: RequestId, params: ConsumeAccountRateLimitResetCreditParams, } | { "method": "account/usage/read", id: RequestId, params: undefined, } | { "method": "account/workspaceMessages/read", id: RequestId, params: undefined, } | { "method": "account/sendAddCreditsNudgeEmail", id: RequestId, params: SendAddCreditsNudgeEmailParams, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "externalAgentConfig/import/readHistories", id: RequestId, params: undefined, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, };
+export type ClientRequest ={ "method": "initialize", id: RequestId, params: InitializeParams, } | { "method": "thread/start", id: RequestId, params: ThreadStartParams, } | { "method": "thread/resume", id: RequestId, params: ThreadResumeParams, } | { "method": "thread/fork", id: RequestId, params: ThreadForkParams, } | { "method": "thread/archive", id: RequestId, params: ThreadArchiveParams, } | { "method": "thread/delete", id: RequestId, params: ThreadDeleteParams, } | { "method": "thread/unsubscribe", id: RequestId, params: ThreadUnsubscribeParams, } | { "method": "thread/name/set", id: RequestId, params: ThreadSetNameParams, } | { "method": "thread/goal/set", id: RequestId, params: ThreadGoalSetParams, } | { "method": "thread/goal/get", id: RequestId, params: ThreadGoalGetParams, } | { "method": "thread/goal/clear", id: RequestId, params: ThreadGoalClearParams, } | { "method": "thread/metadata/update", id: RequestId, params: ThreadMetadataUpdateParams, } | { "method": "thread/unarchive", id: RequestId, params: ThreadUnarchiveParams, } | { "method": "thread/compact/start", id: RequestId, params: ThreadCompactStartParams, } | { "method": "thread/shellCommand", id: RequestId, params: ThreadShellCommandParams, } | { "method": "thread/approveGuardianDeniedAction", id: RequestId, params: ThreadApproveGuardianDeniedActionParams, } | { "method": "thread/rollback", id: RequestId, params: ThreadRollbackParams, } | { "method": "thread/list", id: RequestId, params: ThreadListParams, } | { "method": "thread/loaded/list", id: RequestId, params: ThreadLoadedListParams, } | { "method": "thread/read", id: RequestId, params: ThreadReadParams, } | { "method": "thread/inject_items", id: RequestId, params: ThreadInjectItemsParams, } | { "method": "skills/list", id: RequestId, params: SkillsListParams, } | { "method": "skills/extraRoots/set", id: RequestId, params: SkillsExtraRootsSetParams, } | { "method": "hooks/list", id: RequestId, params: HooksListParams, } | { "method": "marketplace/add", id: RequestId, params: MarketplaceAddParams, } | { "method": "marketplace/remove", id: RequestId, params: MarketplaceRemoveParams, } | { "method": "marketplace/upgrade", id: RequestId, params: MarketplaceUpgradeParams, } | { "method": "plugin/list", id: RequestId, params: PluginListParams, } | { "method": "plugin/installed", id: RequestId, params: PluginInstalledParams, } | { "method": "plugin/read", id: RequestId, params: PluginReadParams, } | { "method": "plugin/skill/read", id: RequestId, params: PluginSkillReadParams, } | { "method": "plugin/share/save", id: RequestId, params: PluginShareSaveParams, } | { "method": "plugin/share/updateTargets", id: RequestId, params: PluginShareUpdateTargetsParams, } | { "method": "plugin/share/list", id: RequestId, params: PluginShareListParams, } | { "method": "plugin/share/checkout", id: RequestId, params: PluginShareCheckoutParams, } | { "method": "plugin/share/delete", id: RequestId, params: PluginShareDeleteParams, } | { "method": "app/read", id: RequestId, params: AppsReadParams, } | { "method": "app/list", id: RequestId, params: AppsListParams, } | { "method": "app/installed", id: RequestId, params: AppsInstalledParams, } | { "method": "fs/readFile", id: RequestId, params: FsReadFileParams, } | { "method": "fs/writeFile", id: RequestId, params: FsWriteFileParams, } | { "method": "fs/createDirectory", id: RequestId, params: FsCreateDirectoryParams, } | { "method": "fs/getMetadata", id: RequestId, params: FsGetMetadataParams, } | { "method": "fs/readDirectory", id: RequestId, params: FsReadDirectoryParams, } | { "method": "fs/remove", id: RequestId, params: FsRemoveParams, } | { "method": "fs/copy", id: RequestId, params: FsCopyParams, } | { "method": "fs/watch", id: RequestId, params: FsWatchParams, } | { "method": "fs/unwatch", id: RequestId, params: FsUnwatchParams, } | { "method": "skills/config/write", id: RequestId, params: SkillsConfigWriteParams, } | { "method": "plugin/install", id: RequestId, params: PluginInstallParams, } | { "method": "plugin/uninstall", id: RequestId, params: PluginUninstallParams, } | { "method": "turn/start", id: RequestId, params: TurnStartParams, } | { "method": "turn/steer", id: RequestId, params: TurnSteerParams, } | { "method": "turn/interrupt", id: RequestId, params: TurnInterruptParams, } | { "method": "review/start", id: RequestId, params: ReviewStartParams, } | { "method": "model/list", id: RequestId, params: ModelListParams, } | { "method": "modelProvider/capabilities/read", id: RequestId, params: ModelProviderCapabilitiesReadParams, } | { "method": "experimentalFeature/list", id: RequestId, params: ExperimentalFeatureListParams, } | { "method": "permissionProfile/list", id: RequestId, params: PermissionProfileListParams, } | { "method": "experimentalFeature/enablement/set", id: RequestId, params: ExperimentalFeatureEnablementSetParams, } | { "method": "mcpServer/oauth/login", id: RequestId, params: McpServerOauthLoginParams, } | { "method": "config/mcpServer/reload", id: RequestId, params: undefined, } | { "method": "mcpServerStatus/list", id: RequestId, params: ListMcpServerStatusParams, } | { "method": "mcpServer/resource/read", id: RequestId, params: McpResourceReadParams, } | { "method": "mcpServer/tool/call", id: RequestId, params: McpServerToolCallParams, } | { "method": "windowsSandbox/setupStart", id: RequestId, params: WindowsSandboxSetupStartParams, } | { "method": "windowsSandbox/readiness", id: RequestId, params: undefined, } | { "method": "account/login/start", id: RequestId, params: LoginAccountParams, } | { "method": "account/login/cancel", id: RequestId, params: CancelLoginAccountParams, } | { "method": "account/logout", id: RequestId, params: undefined, } | { "method": "account/rateLimits/read", id: RequestId, params: undefined, } | { "method": "account/rateLimitResetCredit/consume", id: RequestId, params: ConsumeAccountRateLimitResetCreditParams, } | { "method": "account/usage/read", id: RequestId, params: undefined, } | { "method": "account/workspaceMessages/read", id: RequestId, params: undefined, } | { "method": "account/sendAddCreditsNudgeEmail", id: RequestId, params: SendAddCreditsNudgeEmailParams, } | { "method": "feedback/upload", id: RequestId, params: FeedbackUploadParams, } | { "method": "command/exec", id: RequestId, params: CommandExecParams, } | { "method": "command/exec/write", id: RequestId, params: CommandExecWriteParams, } | { "method": "command/exec/terminate", id: RequestId, params: CommandExecTerminateParams, } | { "method": "command/exec/resize", id: RequestId, params: CommandExecResizeParams, } | { "method": "config/read", id: RequestId, params: ConfigReadParams, } | { "method": "externalAgentConfig/detect", id: RequestId, params: ExternalAgentConfigDetectParams, } | { "method": "externalAgentConfig/import", id: RequestId, params: ExternalAgentConfigImportParams, } | { "method": "externalAgentConfig/import/recordHistory", id: RequestId, params: ExternalAgentConfigImportHistoryRecordParams, } | { "method": "externalAgentConfig/import/readHistories", id: RequestId, params: undefined, } | { "method": "config/value/write", id: RequestId, params: ConfigValueWriteParams, } | { "method": "config/batchWrite", id: RequestId, params: ConfigBatchWriteParams, } | { "method": "configRequirements/read", id: RequestId, params: undefined, } | { "method": "account/read", id: RequestId, params: GetAccountParams, } | { "method": "getConversationSummary", id: RequestId, params: GetConversationSummaryParams, } | { "method": "gitDiffToRemote", id: RequestId, params: GitDiffToRemoteParams, } | { "method": "getAuthStatus", id: RequestId, params: GetAuthStatusParams, } | { "method": "fuzzyFileSearch", id: RequestId, params: FuzzyFileSearchParams, };
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistory.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistory.ts
index 37273fc96c..0531aa6f61 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistory.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistory.ts
@@ -4,4 +4,4 @@
import type { ExternalAgentConfigImportItemTypeFailure } from "./ExternalAgentConfigImportItemTypeFailure";
import type { ExternalAgentConfigImportItemTypeSuccess } from "./ExternalAgentConfigImportItemTypeSuccess";
-export type ExternalAgentConfigImportHistory = { importId: string, completedAtMs: bigint, successes: Array<ExternalAgentConfigImportItemTypeSuccess>, failures: Array<ExternalAgentConfigImportItemTypeFailure>, };
+export type ExternalAgentConfigImportHistory = { importId: string, providerId: string | null, completedAtMs: bigint, successes: Array<ExternalAgentConfigImportItemTypeSuccess>, failures: Array<ExternalAgentConfigImportItemTypeFailure>, };
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistoryRecordParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistoryRecordParams.ts
new file mode 100644
index 0000000000..71a20b6563
--- /dev/null
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistoryRecordParams.ts
@@ -0,0 +1,14 @@
+// GENERATED CODE! DO NOT MODIFY BY HAND!
+
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+import type { ExternalAgentConfigImportTypeResult } from "./ExternalAgentConfigImportTypeResult";
+
+export type ExternalAgentConfigImportHistoryRecordParams = {
+/**
+ * Opaque provider identifier for the externally completed import.
+ */
+providerId: string,
+/**
+ * Completed results grouped by imported item type.
+ */
+itemTypeResults: Array<ExternalAgentConfigImportTypeResult>, };
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistoryRecordResponse.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistoryRecordResponse.ts
new file mode 100644
index 0000000000..dbb14d614c
--- /dev/null
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportHistoryRecordResponse.ts
@@ -0,0 +1,5 @@
+// GENERATED CODE! DO NOT MODIFY BY HAND!
+
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+
+export type ExternalAgentConfigImportHistoryRecordResponse = { importId: string, };
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportParams.ts
index 957cf2541c..ebe23a72fd 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportParams.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportParams.ts
@@ -9,8 +9,8 @@ export type ExternalAgentConfigImportParams = { migrationItems: Array<ExternalAg
*/
source?: string | null,
/**
- * Opaque provider identifier supplied by the caller for analytics attribution. This does not
- * select the migration source.
+ * Opaque provider identifier supplied by the caller for analytics attribution and import
+ * history display. This does not select the migration source.
*/
providerId?: string | null,
/**
diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
index 820d399306..a418fbf3fa 100644
--- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
+++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
@@ -119,6 +119,8 @@ export type { ExternalAgentConfigDetectResponse } from "./ExternalAgentConfigDet
export type { ExternalAgentConfigImportCompletedNotification } from "./ExternalAgentConfigImportCompletedNotification";
export type { ExternalAgentConfigImportHistoriesReadResponse } from "./ExternalAgentConfigImportHistoriesReadResponse";
export type { ExternalAgentConfigImportHistory } from "./ExternalAgentConfigImportHistory";
+export type { ExternalAgentConfigImportHistoryRecordParams } from "./ExternalAgentConfigImportHistoryRecordParams";
+export type { ExternalAgentConfigImportHistoryRecordResponse } from "./ExternalAgentConfigImportHistoryRecordResponse";
export type { ExternalAgentConfigImportItemTypeFailure } from "./ExternalAgentConfigImportItemTypeFailure";
export type { ExternalAgentConfigImportItemTypeSuccess } from "./ExternalAgentConfigImportItemTypeSuccess";
export type { ExternalAgentConfigImportParams } from "./ExternalAgentConfigImportParams";
diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs
index 359eb65efa..1f624e529c 100644
--- a/codex-rs/app-server-protocol/src/protocol/common.rs
+++ b/codex-rs/app-server-protocol/src/protocol/common.rs
@@ -1155,6 +1155,11 @@ client_request_definitions! {
serialization: global("config"),
response: v2::ExternalAgentConfigImportResponse,
},
+ ExternalAgentConfigImportHistoryRecord => "externalAgentConfig/import/recordHistory" {
+ params: v2::ExternalAgentConfigImportHistoryRecordParams,
+ serialization: global("config"),
+ response: v2::ExternalAgentConfigImportHistoryRecordResponse,
+ },
ExternalAgentConfigImportHistoriesRead => "externalAgentConfig/import/readHistories" {
params: #[ts(type = "undefined")] #[serde(skip_serializing_if = "Option::is_none")] Option<()>,
serialization: global_shared_read("config"),
diff --git a/codex-rs/app-server-protocol/src/protocol/v2/config.rs b/codex-rs/app-server-protocol/src/protocol/v2/config.rs
index 9b5604adfa..e196ba7115 100644
--- a/codex-rs/app-server-protocol/src/protocol/v2/config.rs
+++ b/codex-rs/app-server-protocol/src/protocol/v2/config.rs
@@ -741,8 +741,8 @@ pub struct ExternalAgentConfigImportParams {
/// Optional identifier for the product that initiated the import.
#[ts(optional = nullable)]
pub source: Option<String>,
- /// Opaque provider identifier supplied by the caller for analytics attribution. This does not
- /// select the migration source.
+ /// Opaque provider identifier supplied by the caller for analytics attribution and import
+ /// history display. This does not select the migration source.
#[ts(optional = nullable)]
pub provider_id: Option<String>,
/// Migration-source selector used to produce the migration items. Pass the same value to
@@ -790,11 +790,29 @@ pub struct ExternalAgentConfigImportTypeResult {
pub failures: Vec<ExternalAgentConfigImportItemTypeFailure>,
}
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export_to = "v2/")]
+pub struct ExternalAgentConfigImportHistoryRecordParams {
+ /// Opaque provider identifier for the externally completed import.
+ pub provider_id: String,
+ /// Completed results grouped by imported item type.
+ pub item_type_results: Vec<ExternalAgentConfigImportTypeResult>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export_to = "v2/")]
+pub struct ExternalAgentConfigImportHistoryRecordResponse {
+ pub import_id: String,
+}
+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ExternalAgentConfigImportHistory {
pub import_id: String,
+ pub provider_id: Option<String>,
pub completed_at_ms: i64,
pub successes: Vec<ExternalAgentConfigImportItemTypeSuccess>,
pub failures: Vec<ExternalAgentConfigImportItemTypeFailure>,
diff --git a/codex-rs/app-server/src/external_agent_migration/processor.rs b/codex-rs/app-server/src/external_agent_migration/processor.rs
index d1f2e11600..568ca110f0 100644
--- a/codex-rs/app-server/src/external_agent_migration/processor.rs
+++ b/codex-rs/app-server/src/external_agent_migration/processor.rs
@@ -14,10 +14,13 @@ use codex_app_server_protocol::ExternalAgentConfigDetectParams;
use codex_app_server_protocol::ExternalAgentConfigDetectResponse;
use codex_app_server_protocol::ExternalAgentConfigImportCompletedNotification;
use codex_app_server_protocol::ExternalAgentConfigImportHistoriesReadResponse;
+use codex_app_server_protocol::ExternalAgentConfigImportHistoryRecordParams;
+use codex_app_server_protocol::ExternalAgentConfigImportHistoryRecordResponse;
use codex_app_server_protocol::ExternalAgentConfigImportItemTypeFailure as ProtocolImportFailure;
use codex_app_server_protocol::ExternalAgentConfigImportParams;
use codex_app_server_protocol::ExternalAgentConfigImportProgressNotification;
use codex_app_server_protocol::ExternalAgentConfigImportResponse;
+use codex_app_server_protocol::ExternalAgentConfigImportTypeResult as ProtocolImportTypeResult;
use codex_app_server_protocol::ExternalAgentConfigMigrationItem;
use codex_app_server_protocol::ExternalAgentConfigMigrationItemType;
use codex_app_server_protocol::ExternalAgentImportedConnectorCandidate;
@@ -172,7 +175,7 @@ impl ExternalAgentConfigRequestProcessor {
}
let import_id = Uuid::new_v4().to_string();
let analytics_source = params.source.clone().unwrap_or_default();
- let provider_id = params.provider_id.clone().unwrap_or_default();
+ let provider_id = params.provider_id.clone();
let migration_service = self
.migration_service
.with_migration_source(params.migration_source.as_deref());
@@ -378,6 +381,27 @@ impl ExternalAgentConfigRequestProcessor {
Ok(ExternalAgentConfigImportHistoriesReadResponse { data, connectors })
}
+ pub(crate) async fn record_import_history(
+ &self,
+ params: ExternalAgentConfigImportHistoryRecordParams,
+ ) -> Result<ExternalAgentConfigImportHistoryRecordResponse, JSONRPCErrorError> {
+ let state_db = self
+ .state_db
+ .as_ref()
+ .ok_or_else(|| internal_error("state database is unavailable"))?;
+ let import_id = Uuid::new_v4().to_string();
+ record_import_history(
+ state_db,
+ import_id.as_str(),
+ Some(params.provider_id.as_str()),
+ &params.item_type_results,
+ )
+ .await
+ .map_err(|err| internal_error(format!("failed to record import history: {err}")))?;
+
+ Ok(ExternalAgentConfigImportHistoryRecordResponse { import_id })
+ }
+
fn validate_pending_session_imports(
&self,
params: &ExternalAgentConfigImportParams,
@@ -483,7 +507,7 @@ async fn send_completed_import_notification(
analytics_events_client: &AnalyticsEventsClient,
import_id: String,
analytics_source: String,
- provider_id: String,
+ provider_id: Option<String>,
item_results: &[CoreImportItemResult],
) {
let notification = completed_notification(import_id, item_results);
@@ -491,11 +515,13 @@ async fn send_completed_import_notification(
track_completed_import_notification(
analytics_events_client,
&analytics_source,
- &provider_id,
+ provider_id.as_deref().unwrap_or_default(),
&notification,
);
if let Some(state_db) = state_db
- && let Err(err) = record_completed_import_notification(state_db, &notification).await
+ && let Err(err) =
+ record_completed_import_notification(state_db, provider_id.as_deref(), &notification)
+ .await
{
tracing::warn!(
import_id = %notification.import_id,
@@ -586,10 +612,25 @@ fn analytics_migration_item_type(item_type: ExternalAgentConfigMigrationItemType
async fn record_completed_import_notification(
state_db: &StateDbHandle,
+ provider_id: Option<&str>,
notification: &ExternalAgentConfigImportCompletedNotification,
) -> anyhow::Result<()> {
- let successes = notification
- .item_type_results
+ record_import_history(
+ state_db,
+ notification.import_id.as_str(),
+ provider_id,
+ &notification.item_type_results,
+ )
+ .await
+}
+
+async fn record_import_history(
+ state_db: &StateDbHandle,
+ import_id: &str,
+ provider_id: Option<&str>,
+ item_type_results: &[ProtocolImportTypeResult],
+) -> anyhow::Result<()> {
+ let successes = item_type_results
.iter()
.flat_map(|type_result| type_result.successes.iter())
.map(|success| {
@@ -601,8 +642,7 @@ async fn record_completed_import_notification(
})
})
.collect::<anyhow::Result<Vec<_>>>()?;
- let failures = notification
- .item_type_results
+ let failures = item_type_results
.iter()
.flat_map(|type_result| type_result.failures.iter())
.map(|failure| {
@@ -619,7 +659,8 @@ async fn record_completed_import_notification(
.collect::<anyhow::Result<Vec<_>>>()?;
state_db
.record_external_agent_config_import_completed(
- notification.import_id.as_str(),
+ import_id,
+ provider_id,
&successes,
&failures,
)
diff --git a/codex-rs/app-server/src/external_agent_migration/protocol.rs b/codex-rs/app-server/src/external_agent_migration/protocol.rs
index b2411b2683..06289ac671 100644
--- a/codex-rs/app-server/src/external_agent_migration/protocol.rs
+++ b/codex-rs/app-server/src/external_agent_migration/protocol.rs
@@ -210,6 +210,7 @@ pub(super) fn protocol_import_history(
Ok(ExternalAgentConfigImportHistory {
import_id: record.import_id,
+ provider_id: record.provider_id,
completed_at_ms: record.completed_at_ms,
successes,
failures,
diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rs
index 69fb4f7210..a8935cdd92 100644
--- a/codex-rs/app-server/src/message_processor.rs
+++ b/codex-rs/app-server/src/message_processor.rs
@@ -896,6 +896,11 @@ impl MessageProcessor {
.import(request_id.clone(), params)
.await
.map(|()| None),
+ ClientRequest::ExternalAgentConfigImportHistoryRecord { params, .. } => self
+ .external_agent_config_processor
+ .record_import_history(params)
+ .await
+ .map(|response| Some(response.into())),
ClientRequest::ExternalAgentConfigImportHistoriesRead { .. } => self
.external_agent_config_processor
.read_import_histories()
diff --git a/codex-rs/app-server/tests/suite/v2/external_agent_config.rs b/codex-rs/app-server/tests/suite/v2/external_agent_config.rs
index 73ebb6723a..08fa545bee 100644
--- a/codex-rs/app-server/tests/suite/v2/external_agent_config.rs
+++ b/codex-rs/app-server/tests/suite/v2/external_agent_config.rs
@@ -10,6 +10,7 @@ use app_test_support::write_chatgpt_auth;
use codex_app_server_protocol::ExternalAgentConfigDetectResponse;
use codex_app_server_protocol::ExternalAgentConfigImportCompletedNotification;
use codex_app_server_protocol::ExternalAgentConfigImportHistoriesReadResponse;
+use codex_app_server_protocol::ExternalAgentConfigImportHistoryRecordResponse;
use codex_app_server_protocol::ExternalAgentConfigImportProgressNotification;
use codex_app_server_protocol::ExternalAgentConfigImportResponse;
use codex_app_server_protocol::ExternalAgentConfigMigrationItemType;
@@ -590,6 +591,73 @@ async fn external_agent_config_import_sends_completion_notification_for_sync_onl
Ok(())
}
+#[tokio::test]
+async fn external_agent_config_records_externally_completed_import_history() -> Result<()> {
+ let codex_home = TempDir::new()?;
+ let sqlite_home = TempDir::new()?;
+ let home_dir = codex_home.path().display().to_string();
+ let sqlite_home_dir = sqlite_home.path().display().to_string();
+ let mut mcp = TestAppServer::builder()
+ .with_codex_home(codex_home.path())
+ .without_auto_env()
+ .with_env_overrides(&[
+ ("HOME", Some(home_dir.as_str())),
+ ("CODEX_SQLITE_HOME", Some(sqlite_home_dir.as_str())),
+ ])
+ .build_initialized_with_timeout(DEFAULT_TIMEOUT)
+ .await?;
+
+ let request_id = mcp
+ .send_raw_request(
+ "externalAgentConfig/import/recordHistory",
+ Some(serde_json::json!({
+ "providerId": "external-provider",
+ "itemTypeResults": [{
+ "itemType": "SESSIONS",
+ "successes": [{
+ "itemType": "SESSIONS",
+ "cwd": "/repo",
+ "source": "/source/session.jsonl",
+ "target": "thread-1",
+ }],
+ "failures": [],
+ }],
+ })),
+ )
+ .await?;
+ let record_response: ExternalAgentConfigImportHistoryRecordResponse =
+ timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
+ assert!(!record_response.import_id.is_empty());
+
+ let request_id = mcp
+ .send_raw_request(
+ "externalAgentConfig/import/readHistories",
+ /*params*/ None,
+ )
+ .await?;
+ let history_response: ExternalAgentConfigImportHistoriesReadResponse =
+ timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
+ let entry = history_response
+ .data
+ .iter()
+ .find(|entry| entry.import_id == record_response.import_id)
+ .expect("externally completed import history entry should be available");
+ assert_eq!(entry.provider_id.as_deref(), Some("external-provider"));
+ assert!(entry.completed_at_ms > 0);
+ assert_eq!(
+ serde_json::to_value(&entry.successes)?,
+ serde_json::json!([{
+ "itemType": "SESSIONS",
+ "cwd": "/repo",
+ "source": "/source/session.jsonl",
+ "target": "thread-1",
+ }])
+ );
+ assert_eq!(entry.failures, Vec::new());
+
+ Ok(())
+}
+
#[tokio::test]
async fn external_agent_memory_import_requires_feature_config() -> Result<()> {
let codex_home = TempDir::new()?;
diff --git a/codex-rs/state/migrations/0044_external_agent_config_imports_provider_id.sql b/codex-rs/state/migrations/0044_external_agent_config_imports_provider_id.sql
new file mode 100644
index 0000000000..2fc16008a9
--- /dev/null
+++ b/codex-rs/state/migrations/0044_external_agent_config_imports_provider_id.sql
@@ -0,0 +1,2 @@
+ALTER TABLE external_agent_config_imports
+ADD COLUMN provider_id TEXT;
diff --git a/codex-rs/state/src/runtime/external_agent_config_imports.rs b/codex-rs/state/src/runtime/external_agent_config_imports.rs
index c6c41feed4..3e4aab3a65 100644
--- a/codex-rs/state/src/runtime/external_agent_config_imports.rs
+++ b/codex-rs/state/src/runtime/external_agent_config_imports.rs
@@ -35,6 +35,7 @@ pub struct ExternalAgentConfigImportDetailsRecord {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExternalAgentConfigImportHistoryRecord {
pub import_id: String,
+ pub provider_id: Option<String>,
pub completed_at_ms: i64,
pub successes: Vec<ExternalAgentConfigImportSuccessRecord>,
pub failures: Vec<ExternalAgentConfigImportFailureRecord>,
@@ -44,6 +45,7 @@ impl StateRuntime {
pub async fn record_external_agent_config_import_completed(
&self,
import_id: &str,
+ provider_id: Option<&str>,
successes: &[ExternalAgentConfigImportSuccessRecord],
failures: &[ExternalAgentConfigImportFailureRecord],
) -> anyhow::Result<()> {
@@ -51,17 +53,20 @@ impl StateRuntime {
r#"
INSERT INTO external_agent_config_imports (
import_id,
+ provider_id,
completed_at_ms,
successes,
failures
-) VALUES (?, ?, ?, ?)
+) VALUES (?, ?, ?, ?, ?)
ON CONFLICT(import_id) DO UPDATE SET
+ provider_id = excluded.provider_id,
completed_at_ms = excluded.completed_at_ms,
successes = excluded.successes,
failures = excluded.failures
"#,
)
.bind(import_id)
+ .bind(provider_id)
.bind(datetime_to_epoch_millis(Utc::now()))
.bind(serde_json::to_string(successes)?)
.bind(serde_json::to_string(failures)?)
@@ -106,6 +111,7 @@ WHERE import_id = ?
r#"
SELECT
import_id,
+ provider_id,
completed_at_ms,
successes,
failures
@@ -119,11 +125,13 @@ ORDER BY completed_at_ms DESC, import_id ASC
rows.into_iter()
.map(|row| {
let import_id: String = row.try_get("import_id")?;
+ let provider_id: Option<String> = row.try_get("provider_id")?;
let completed_at_ms: i64 = row.try_get("completed_at_ms")?;
let successes: String = row.try_get("successes")?;
let failures: String = row.try_get("failures")?;
Ok(ExternalAgentConfigImportHistoryRecord {
import_id,
+ provider_id,
completed_at_ms,
successes: serde_json::from_str(&successes)?,
failures: serde_json::from_str(&failures)?,
diff --git a/codex-rs/state/src/runtime/external_agent_config_imports_tests.rs b/codex-rs/state/src/runtime/external_agent_config_imports_tests.rs
index 5546a0f8f8..9680744599 100644
--- a/codex-rs/state/src/runtime/external_agent_config_imports_tests.rs
+++ b/codex-rs/state/src/runtime/external_agent_config_imports_tests.rs
@@ -9,6 +9,7 @@ async fn records_completion_by_import_id() -> anyhow::Result<()> {
runtime
.record_external_agent_config_import_completed(
"import-1",
+ Some("provider-1"),
&[ExternalAgentConfigImportSuccessRecord {
item_type: "CONFIG".to_string(),
cwd: None,
@@ -21,6 +22,7 @@ async fn records_completion_by_import_id() -> anyhow::Result<()> {
runtime
.record_external_agent_config_import_completed(
"import-1",
+ Some("provider-2"),
&[
ExternalAgentConfigImportSuccessRecord {
item_type: "CONFIG".to_string(),
@@ -84,6 +86,7 @@ async fn records_completion_by_import_id() -> anyhow::Result<()> {
.into_iter()
.map(|record| (
record.import_id,
+ record.provider_id,
record.successes,
record.failures,
record.completed_at_ms > 0
@@ -91,6 +94,7 @@ async fn records_completion_by_import_id() -> anyhow::Result<()> {
.collect::<Vec<_>>(),
vec![(
"import-1".to_string(),
+ Some("provider-2".to_string()),
vec![
ExternalAgentConfigImportSuccessRecord {
item_type: "CONFIG".to_string(),
@@ -126,10 +130,20 @@ async fn reads_all_history_records() -> anyhow::Result<()> {
let runtime = StateRuntime::init(unique_temp_dir(), "test-provider".to_string()).await?;
runtime
- .record_external_agent_config_import_completed("import-1", &[], &[])
+ .record_external_agent_config_import_completed(
+ "import-1",
+ /*provider_id*/ None,
+ &[],
+ &[],
+ )
.await?;
runtime
- .record_external_agent_config_import_completed("import-2", &[], &[])
+ .record_external_agent_config_import_completed(
+ "import-2",
+ /*provider_id*/ None,
+ &[],
+ &[],
+ )
.await?;
let mut records = runtime