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

Function create_workspace

plugins/codex-security/scripts/workbench_db.py:1147–1216  ·  view source on GitHub ↗
(connection: sqlite3.Connection, args: argparse.Namespace)

Source from the content-addressed store, hash-verified

1145
1146
1147def create_workspace(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]:
1148 workspace_id = require_uuid(args.workspace_id, "workspace-id")
1149 timestamp = now()
1150 target_path = optional_text(args.target_path, maximum=4096)
1151 default_scope = optional_text(args.scope, maximum=4096) or "."
1152 diff_target_kind = args.diff_target_kind if args.mode == "diff" else None
1153 diff_base_revision = (
1154 optional_text(args.diff_base_revision, maximum=512) if args.mode == "diff" else None
1155 )
1156 diff_head_revision = (
1157 optional_text(args.diff_head_revision, maximum=512) if args.mode == "diff" else None
1158 )
1159 diff_content_digest = (
1160 optional_text(args.diff_content_digest, maximum=128) if args.mode == "diff" else None
1161 )
1162 if target_path:
1163 try:
1164 inspected = inspect_setup_values(
1165 target_path,
1166 default_scope,
1167 args.mode,
1168 diff_target_kind,
1169 diff_base_revision,
1170 diff_head_revision,
1171 diff_content_digest,
1172 )
1173 target_path = inspected["target"]["targetPath"]
1174 default_scope = inspected["scope"]
1175 if inspected["diffTarget"]:
1176 diff_target_kind = inspected["diffTarget"]["kind"]
1177 diff_base_revision = inspected["diffTarget"]["baseRevision"]
1178 diff_head_revision = inspected["diffTarget"]["headRevision"]
1179 diff_content_digest = inspected["diffTarget"].get("contentDigest")
1180 except SystemExit:
1181 pass
1182 preflight_json = capability_preflight_json(
1183 capability_preflight_input(
1184 args.capability_preflight_json, args.capability_preflight_json_file
1185 ),
1186 checked_target_path=target_path,
1187 checked_mode=args.mode,
1188 )
1189 with connection:
1190 connection.execute(
1191 """
1192 INSERT INTO workspaces (
1193 id, thread_id, target_path, target_title, target_summary, default_scope, default_mode,
1194 user_context, diff_target_kind, diff_base_revision, diff_head_revision,
1195 diff_content_digest, capability_preflight_json, created_at, updated_at
1196 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1197 """,
1198 (
1199 workspace_id,
1200 optional_text(args.thread_id, maximum=512),
1201 target_path,
1202 optional_text(args.target_title, maximum=200),
1203 optional_text(args.target_summary, maximum=2400),
1204 default_scope,

Callers 1

mainFunction · 0.85

Calls 8

require_uuidFunction · 0.90
optional_textFunction · 0.90
nowFunction · 0.85
inspect_setup_valuesFunction · 0.85
workspace_stateFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected