| 7572 | } |
| 7573 | |
| 7574 | static void uninstall_tiered_agent_profiles(cbm_tiered_profile_set_t profiles, bool dry_run) { |
| 7575 | cbm_graph_access_t access = cbm_tiered_profile_set_access(profiles); |
| 7576 | for (int value = 0; value < (int)CBM_GRAPH_TIER_COUNT; value++) { |
| 7577 | cbm_graph_tier_t tier = (cbm_graph_tier_t)value; |
| 7578 | char path[CLI_BUF_1K]; |
| 7579 | if (cbm_tiered_profile_path(profiles.verify_path, tier, path, sizeof(path)) != CLI_OK) { |
| 7580 | record_agent_config_error(true, profiles.label, "agent_path", profiles.verify_path); |
| 7581 | continue; |
| 7582 | } |
| 7583 | if (dry_run) { |
| 7584 | printf(" %s agent: would remove owned profile %s\n", profiles.label, path); |
| 7585 | continue; |
| 7586 | } |
| 7587 | char *current = |
| 7588 | cbm_render_graph_profile(profiles.dialect, tier, access, profiles.binary_path); |
| 7589 | if (!current) { |
| 7590 | record_agent_config_error(true, profiles.label, "agent_render", path); |
| 7591 | continue; |
| 7592 | } |
| 7593 | cbm_graph_access_t alternate_access = |
| 7594 | access == CBM_GRAPH_ACCESS_DIRECT ? CBM_GRAPH_ACCESS_HANDOFF : CBM_GRAPH_ACCESS_DIRECT; |
| 7595 | char *alternate = cbm_render_graph_profile(profiles.dialect, tier, alternate_access, |
| 7596 | profiles.binary_path); |
| 7597 | char *codex_rc1 = |
| 7598 | profiles.dialect == CBM_GRAPH_DIALECT_CODEX && access == CBM_GRAPH_ACCESS_DIRECT |
| 7599 | ? cbm_render_graph_profile_codex_rc1(tier) |
| 7600 | : NULL; |
| 7601 | const char *released[3]; |
| 7602 | size_t released_count = 0U; |
| 7603 | if (alternate) { |
| 7604 | released[released_count++] = alternate; |
| 7605 | } |
| 7606 | if (codex_rc1) { |
| 7607 | released[released_count++] = codex_rc1; |
| 7608 | } |
| 7609 | if (tier == CBM_GRAPH_TIER_VERIFY && profiles.legacy_verify_content) { |
| 7610 | released[released_count++] = profiles.legacy_verify_content; |
| 7611 | } |
| 7612 | int result = cbm_text_remove_owned_document_any(path, current, released, released_count); |
| 7613 | free(codex_rc1); |
| 7614 | free(alternate); |
| 7615 | free(current); |
| 7616 | if (result < CLI_OK) { |
| 7617 | record_agent_config_error(true, profiles.label, "agent_uninstall", path); |
| 7618 | } else if (result > CLI_OK) { |
| 7619 | printf(" %s agent: preserved modified profile %s\n", profiles.label, path); |
| 7620 | } else { |
| 7621 | printf(" %s agent: removed owned profile %s\n", profiles.label, path); |
| 7622 | } |
| 7623 | } |
| 7624 | } |
| 7625 | |
| 7626 | static void install_tiered_profile_prompts(const char *label, const char *verify_path, |
| 7627 | cbm_graph_profile_dialect_t dialect, |
no test coverage detected