@sema-agent/core
Version:
Stateless, task-oriented AI agent core
94 lines (93 loc) • 2.94 kB
JavaScript
export const CLASSIFIER_CATEGORIES = Object.freeze([
"account_standing_rule_changes",
"auto_mode_bypass",
"blind_apply",
"browser_file_upload_exfil",
"browser_input_exfil",
"browser_js_exfil",
"browser_navigate_exfil",
"browser_shortcut_execution",
"chatops_trigger_comments",
"ci_bypass",
"cloud_storage_mass_delete",
"cluster_wide_workload_creation",
"code_from_external",
"code_that_leaks_when_run",
"command_network_lists",
"containment_escape",
"cowork_delete_grant",
"cowork_folder_access",
"cowork_run_routine_now",
"cowork_scheduled_task_delete",
"cowork_scheduled_task_write",
"cowork_skill_persistence",
"create_public_surface",
"create_rce_surface",
"create_unsafe_agents",
"credential_exploration",
"credential_leakage",
"credential_materialization",
"data_exfiltration",
"dns_domain_cert_changes",
"excess_sensitive_detail",
"exfil_scouting",
"expose_local_services",
"external_ingress_tunnel",
"external_system_writes",
"feature_flag_writes",
"git_destructive",
"instruction_poisoning",
"interfere_with_workloads",
"irreversible_deletion_general",
"irreversible_local_destruction",
"live_shared_artifact_sensitive_delta",
"logging_audit_tampering",
"merge_without_review",
"modify_shared_resources",
"node_lifecycle_operations",
"out_of_place_publication",
"package_registry_bypass",
"permission_grant",
"pii_data_handling",
"production_deploy",
"production_reads",
"protected_scope_iac_apply",
"public_data_sharing_upload",
"real_world_transactions",
"remote_repoint",
"remote_shell_writes",
"safety_bypass_flag",
"sandbox_network_callback",
"secret_store_writes",
"security_test_removal",
"security_weaken",
"self_approval",
"self_modification",
"sensitive_remote_exec",
"sensitive_source_provenance",
"session_transcript_tampering",
"shared_cluster_mutation",
"shared_scratch_sweep",
"third_party_attack",
"tls_auth_weaken",
"tmux_self_drive",
"traffic_redirection",
"unauthorized_persistence",
"unrequested_artifact_publish",
"unrequested_commit_in_a_connected_app",
"untrusted_code_integration",
"unverifiable_deletion_scope",
"unverifiable_deletion_target",
]);
const CLASSIFIER_CATEGORY_SET = new Set(CLASSIFIER_CATEGORIES);
export function isClassifierCategory(v) {
return CLASSIFIER_CATEGORY_SET.has(v);
}
const CATEGORY_TAG = /<category>([a-z0-9 &_-]{1,64})<\/category>/gi;
export function classifierCategoryOf(strippedReply) {
const tags = [...strippedReply.matchAll(CATEGORY_TAG)];
if (tags.length !== 1)
return undefined;
const word = tags[0][1].toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
return isClassifierCategory(word) ? word : undefined;
}