| 8725 | } |
| 8726 | |
| 8727 | static void uninstall_tiered_agent_profiles(cbm_tiered_profile_set_t profiles, bool dry_run) { |
| 8728 | cbm_graph_access_t access = cbm_tiered_profile_set_access(profiles); |
| 8729 | for (int value = 0; value < (int)CBM_GRAPH_TIER_COUNT; value++) { |
| 8730 | cbm_graph_tier_t tier = (cbm_graph_tier_t)value; |
| 8731 | char path[CLI_BUF_1K]; |
| 8732 | if (cbm_tiered_profile_path(profiles.verify_path, tier, path, sizeof(path)) != CLI_OK) { |
| 8733 | record_agent_config_error(true, profiles.label, "agent_path", profiles.verify_path); |
| 8734 | continue; |
| 8735 | } |
| 8736 | if (dry_run) { |
| 8737 | printf(" %s agent: would remove owned profile %s\n", profiles.label, path); |
| 8738 | continue; |
| 8739 | } |
| 8740 | char *current = |
| 8741 | cbm_render_graph_profile(profiles.dialect, tier, access, profiles.binary_path); |
| 8742 | if (!current) { |
| 8743 | record_agent_config_error(true, profiles.label, "agent_render", path); |
| 8744 | continue; |
| 8745 | } |
| 8746 | cbm_graph_access_t alternate_access = |
| 8747 | access == CBM_GRAPH_ACCESS_DIRECT ? CBM_GRAPH_ACCESS_HANDOFF : CBM_GRAPH_ACCESS_DIRECT; |
| 8748 | char *alternate = cbm_render_graph_profile(profiles.dialect, tier, alternate_access, |
| 8749 | profiles.binary_path); |
| 8750 | char *codex_rc1 = |
| 8751 | profiles.dialect == CBM_GRAPH_DIALECT_CODEX && access == CBM_GRAPH_ACCESS_DIRECT |
| 8752 | ? cbm_render_graph_profile_codex_rc1(tier) |
| 8753 | : NULL; |
| 8754 | const char *released[3]; |
| 8755 | size_t released_count = 0U; |
| 8756 | if (alternate) { |
| 8757 | released[released_count++] = alternate; |
| 8758 | } |
| 8759 | if (codex_rc1) { |
| 8760 | released[released_count++] = codex_rc1; |
| 8761 | } |
| 8762 | if (tier == CBM_GRAPH_TIER_VERIFY && profiles.legacy_verify_content) { |
| 8763 | released[released_count++] = profiles.legacy_verify_content; |
| 8764 | } |
| 8765 | int result = cbm_text_remove_owned_document_any(path, current, released, released_count); |
| 8766 | free(codex_rc1); |
| 8767 | free(alternate); |
| 8768 | free(current); |
| 8769 | if (result < CLI_OK) { |
| 8770 | record_agent_config_error(true, profiles.label, "agent_uninstall", path); |
| 8771 | } else if (result > CLI_OK) { |
| 8772 | printf(" %s agent: preserved modified profile %s\n", profiles.label, path); |
| 8773 | } else { |
| 8774 | printf(" %s agent: removed owned profile %s\n", profiles.label, path); |
| 8775 | } |
| 8776 | } |
| 8777 | } |
| 8778 | |
| 8779 | static void install_tiered_profile_prompts(const char *label, const char *verify_path, |
| 8780 | cbm_graph_profile_dialect_t dialect, |
no test coverage detected