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

Function save_workspace

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

Source from the content-addressed store, hash-verified

1266
1267
1268def save_workspace(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]:
1269 workspace = require_workspace(connection, args.workspace_id)
1270 if workspace["active_scan_id"]:
1271 raise SystemExit("This workspace already has a scan. Open a new workspace to change setup.")
1272 inspected = inspect_setup_values(
1273 args.target_path,
1274 args.scope,
1275 args.mode,
1276 args.diff_target_kind,
1277 args.diff_base_revision,
1278 args.diff_head_revision,
1279 args.diff_content_digest,
1280 )
1281 target = Path(inspected["target"]["targetPath"])
1282 scope = inspected["scope"]
1283 target_path = str(target)
1284 target_changed = workspace["target_path"] != target_path
1285 target_title = target.name if target_changed else workspace["target_title"]
1286 target_summary = (
1287 optional_text(args.target_summary, maximum=2400)
1288 if args.target_summary is not None
1289 else None
1290 if target_changed
1291 else workspace["target_summary"]
1292 )
1293 diff_target = inspected["diffTarget"]
1294 if diff_target and not target_summary:
1295 target_summary = diff_target_summary(diff_target)
1296 timestamp = now()
1297 with connection:
1298 updated = connection.execute(
1299 """
1300 UPDATE workspaces
1301 SET target_path = ?, target_title = ?, target_summary = ?, default_scope = ?,
1302 default_mode = ?, user_context = ?, diff_target_kind = ?,
1303 diff_base_revision = ?, diff_head_revision = ?, diff_content_digest = ?,
1304 diff_resolution_id = NULL, submitted = 1, updated_at = ?
1305 WHERE id = ? AND active_scan_id IS NULL
1306 """,
1307 (
1308 target_path,
1309 target_title,
1310 target_summary,
1311 scope,
1312 args.mode,
1313 optional_text(args.user_context),
1314 diff_target["kind"] if diff_target else None,
1315 diff_target["baseRevision"] if diff_target else None,
1316 diff_target["headRevision"] if diff_target else None,
1317 diff_target.get("contentDigest") if diff_target else None,
1318 timestamp,
1319 workspace["id"],
1320 ),
1321 )
1322 if updated.rowcount != 1:
1323 raise SystemExit(
1324 "This workspace already has a scan. Open a new workspace to change setup."
1325 )

Callers 1

mainFunction · 0.85

Calls 7

optional_textFunction · 0.90
require_workspaceFunction · 0.85
inspect_setup_valuesFunction · 0.85
diff_target_summaryFunction · 0.85
nowFunction · 0.85
workspace_stateFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected