1
>
/*---------------------------------------------------------------------------------------------
codexGuardianReview.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import type { GuardianApprovalReviewAction } from './protocol/generated/v2/GuardianApprovalReviewAction.js';
7
>
import type { ItemGuardianApprovalReviewCompletedNotification } from './protocol/generated/v2/ItemGuardianApprovalReviewCompletedNotification.js';
8
>
import type { RequestPermissionProfile } from './protocol/generated/v2/RequestPermissionProfile.js';
9
>
import type { JsonValue } from './protocol/generated/serde_json/JsonValue.js';
10
>
import { unwrapShellInvocation } from './codexShellCommand.js';
11
>
12
>
/**
13
>
* Auto-review (guardian) notifications are emitted by the app-server with
14
>
* `ts-rs`-generated camelCase field names. The `thread/approveGuardianDeniedAction`
15
>
* request, however, echoes back a `codex_protocol::protocol::GuardianAssessmentEvent`
16
>
* that is (de)serialized with plain `serde` — which uses **snake_case** for enum
17
>
* variants, enum values, and the tagged-union `type` discriminant. The two shapes
18
>
* therefore diverge (`inProgress` vs `in_progress`, `networkAccess` vs
19
>
* `network_access`, `unifiedExec` vs `unified_exec`, `toolName` vs `tool_name`, …),
20
>
* so we cannot round-trip the notification payload verbatim.
21
>
*
22
>
* These helpers translate the camelCase completed-review notification into the
23
>
* snake_case `GuardianAssessmentEvent` JSON that the app-server can deserialize,
24
>
* and summarise a review action for display on the approval card.
25
>
*/
26
>
27
>
/** camelCase {@link GuardianApprovalReviewStatus} value -> snake_case `GuardianAssessmentStatus`. */
28
function guardianStatusToEvent(status: string): string {
29
switch (status) {