MCPcopy
hub / github.com/openai/plugins / workspace_state

Function workspace_state

plugins/codex-security/scripts/workbench_db.py:2906–2967  ·  view source on GitHub ↗
(
    connection: sqlite3.Connection, workspace_id: str, *, thread_id: str | None = None
)

Source from the content-addressed store, hash-verified

2904
2905
2906def workspace_state(
2907 connection: sqlite3.Connection, workspace_id: str, *, thread_id: str | None = None
2908) -> dict[str, Any]:
2909 workspace = require_workspace(connection, workspace_id)
2910 if thread_id is not None and workspace["thread_id"] != optional_text(thread_id, maximum=512):
2911 raise SystemExit("Codex Security workspace not found in this thread.")
2912 persisted_diff_target = stored_diff_target(workspace)
2913 result: dict[str, Any] = {
2914 "id": workspace["id"],
2915 "diffTarget": persisted_diff_target,
2916 "diffResolutionId": workspace["diff_resolution_id"],
2917 "mode": workspace["default_mode"],
2918 "recentTargets": [],
2919 "scope": workspace["default_scope"],
2920 "setup": {"submitted": bool(workspace["submitted"])},
2921 "setupValidation": {"error": None, "valid": bool(workspace["submitted"])},
2922 "targetPath": workspace["target_path"],
2923 "targetSummary": workspace["target_summary"],
2924 "targetTitle": workspace["target_title"],
2925 "updatedAt": workspace["updated_at"],
2926 "userContext": workspace["user_context"],
2927 }
2928 if workspace["capability_preflight_json"]:
2929 result["capabilityPreflight"] = json.loads(workspace["capability_preflight_json"])
2930 if workspace["active_scan_id"]:
2931 result["results"] = scan_result(
2932 connection, require_scan(connection, workspace["active_scan_id"])
2933 )
2934 return result
2935
2936 target_metadata = None
2937 setup_error = None
2938 validated_diff_target = None
2939 if workspace["target_path"]:
2940 try:
2941 inspected = inspect_setup_values(
2942 workspace["target_path"],
2943 workspace["default_scope"],
2944 workspace["default_mode"],
2945 workspace["diff_target_kind"],
2946 workspace["diff_base_revision"],
2947 workspace["diff_head_revision"],
2948 workspace["diff_content_digest"],
2949 )
2950 target_metadata = inspected["target"]["targetMetadata"]
2951 validated_diff_target = inspected["diffTarget"]
2952 except SystemExit as exc:
2953 setup_error = str(exc)
2954 try:
2955 target = require_target(workspace["target_path"])
2956 target_metadata = git_target_metadata(target)
2957 except SystemExit:
2958 pass
2959 result["diffTarget"] = validated_diff_target or persisted_diff_target
2960 result["recentTargets"] = recent_targets(connection)
2961 result["setupValidation"] = {
2962 "error": setup_error,
2963 "valid": setup_error is None and bool(target_metadata),

Callers 15

create_workspaceFunction · 0.85
latest_workspaceFunction · 0.85
save_workspaceFunction · 0.85
set_capability_preflightFunction · 0.85
begin_diff_resolutionFunction · 0.85
cancel_diff_resolutionFunction · 0.85
set_diff_targetFunction · 0.85
start_scanFunction · 0.85
cancel_scanFunction · 0.85
claim_handoff_deliveryFunction · 0.85
release_handoff_deliveryFunction · 0.85
mark_handoff_deliveredFunction · 0.85

Calls 9

optional_textFunction · 0.90
git_target_metadataFunction · 0.90
require_workspaceFunction · 0.85
stored_diff_targetFunction · 0.85
scan_resultFunction · 0.85
require_scanFunction · 0.85
inspect_setup_valuesFunction · 0.85
require_targetFunction · 0.85
recent_targetsFunction · 0.85

Tested by

no test coverage detected