@oked/sdk 0.6.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/classify.js CHANGED
@@ -1376,16 +1376,76 @@ function classifyDirectoryGrant(tool, toolInput) {
1376
1376
  return "review";
1377
1377
  return "warning";
1378
1378
  }
1379
+ /**
1380
+ * Desktop app (`ccd_*`) tools that only change what the app shows or how it
1381
+ * tracks this session: panes, split view, the sidebar, the PR bar, archiving.
1382
+ * sync_with_base_branch merges the base branch into the session's worktree on
1383
+ * the host, the same as a Bash `git merge` or `git pull` (both safe); a push
1384
+ * after it is gated on its own. The app's tools with a real effect stay out
1385
+ * of this table: set_auto_merge (GitHub merges the PR), set_setting,
1386
+ * permission or model changes, worktree clean-up and discards.
1387
+ */
1388
+ const CCD_SAFE_TOOLS = new Map([
1389
+ ["ccd_pr", new Set(["bind_pr", "unbind_pr"])],
1390
+ ["ccd_view", new Set(["show_pane", "close_pane", "set_transcript_view"])],
1391
+ ["ccd_session", new Set(["spawn_task"])],
1392
+ ["ccd_window", new Set(["open_session_in", "close_split", "set_sidebar_collapsed"])],
1393
+ ["ccd_sidebar", new Set([
1394
+ "create_group", "create_section", "rename_group", "rename_section",
1395
+ "move_sessions", "set_pinned", "set_unread", "set_view",
1396
+ ])],
1397
+ ["ccd_host", new Set(["open_in_editor", "reveal_path", "request_keep_awake", "sync_with_base_branch"])],
1398
+ ["ccd_session_mgmt", new Set(["set_session_title", "archive_session", "unarchive_session"])],
1399
+ ]);
1400
+ // claude.ai connectors reach Claude Code as mcp__<uuid>__<tool>, so the server
1401
+ // name does not say which connector it is.
1402
+ const CONNECTOR_SERVER_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1403
+ // Tool names that are a read verb alone (the prefix rules below need "read_").
1404
+ const SAFE_BARE_TOOLS = new Set(["read", "get", "list", "search", "find", "view", "guide", "help"]);
1405
+ function isRecord(v) {
1406
+ return typeof v === "object" && v !== null && !Array.isArray(v);
1407
+ }
1408
+ /**
1409
+ * Claude Docs connector writes: `batch` (create a doc or apply edits to one)
1410
+ * and `update` (edit a tab, rename, change a stored value). They change the
1411
+ * user's own docs on claude.ai, which are private until the user shares them.
1412
+ * Log them (`warning`), no prompt. The input shape identifies the connector,
1413
+ * because its server name is a UUID and the tool names are generic. Sharing
1414
+ * and deletes are not in this rule.
1415
+ */
1416
+ function isClaudeDocsWrite(server, tool, input) {
1417
+ if (!CONNECTOR_SERVER_RE.test(server))
1418
+ return false;
1419
+ if (tool === "batch") {
1420
+ return isRecord(input.container) && typeof input.container.kind === "string" &&
1421
+ (input.batch === undefined || Array.isArray(input.batch));
1422
+ }
1423
+ if (tool === "update") {
1424
+ return isRecord(input.ref) && typeof input.ref.object === "string" && typeof input.ref.id === "string" &&
1425
+ input.payload !== undefined;
1426
+ }
1427
+ return false;
1428
+ }
1379
1429
  function classifyMcpTool(toolName, toolInput = {}) {
1380
1430
  const parts = toolName.split("__");
1381
1431
  const tool = parts[parts.length - 1] || "";
1382
1432
  if (parts.includes("ccd_directory") && (tool === "change_directory" || tool === "request_directory")) {
1383
1433
  return classifyDirectoryGrant(tool, toolInput);
1384
1434
  }
1435
+ if (parts.slice(1, -1).some((p) => CCD_SAFE_TOOLS.get(p)?.has(tool)))
1436
+ return "safe";
1437
+ // The PR bar's CI monitor switches. auto_fix lets the session push fixes,
1438
+ // but each push is gated on its own. Log it, no prompt.
1439
+ if (parts.includes("ccd_pr") && tool === "set_monitor")
1440
+ return "warning";
1441
+ if (parts.length === 3 && isClaudeDocsWrite(parts[1] || "", tool, toolInput))
1442
+ return "warning";
1385
1443
  const browserServer = parts.slice(1, -1).find((p) => BROWSER_MCP_SERVERS.has(p));
1386
1444
  if (browserServer)
1387
1445
  return classifyBrowserTool(tool, toolInput, browserServer);
1388
1446
  // Read-only retrieval verbs.
1447
+ if (SAFE_BARE_TOOLS.has(tool))
1448
+ return "safe";
1389
1449
  if (tool.startsWith("list_") || tool.startsWith("get_") || tool.startsWith("search_") ||
1390
1450
  tool.startsWith("read_") || tool.startsWith("fetch_") || tool.startsWith("query_") ||
1391
1451
  tool.startsWith("find_") || tool.startsWith("view_") || tool.startsWith("show_") ||
package/dist/describe.js CHANGED
@@ -879,7 +879,13 @@ function summarizeBrowser(tool, input, server) {
879
879
  }
880
880
  function summarizeMcp(toolName, input) {
881
881
  const parts = toolName.split("__");
882
- const server = parts[1] || "unknown";
882
+ // claude.ai connectors have a UUID as the server name. The UUID means nothing to the approver.
883
+ // Desktop app tools have internal server names (ccd_host, ccd_pr).
884
+ const server = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(parts[1] || "")
885
+ ? "claude.ai connector"
886
+ : /^ccd_/.test(parts[1] || "")
887
+ ? "Claude desktop app"
888
+ : parts[1] || "unknown";
883
889
  const tool = parts[2] || "";
884
890
  if (parts.includes("ccd_directory") && (tool === "change_directory" || tool === "request_directory")) {
885
891
  const dir = typeof input.path === "string" && input.path.trim() ? shortenPath(input.path.trim()) : undefined;
@@ -959,7 +965,7 @@ function summarizeMcp(toolName, input) {
959
965
  if (tool.startsWith("list_") || tool.startsWith("get_") || tool.startsWith("search_")) {
960
966
  return { title: `${toWords(tool)} via ${server}`, kind: "unknown_tool" };
961
967
  }
962
- return { title: `${toWords(tool)} via ${server}`, kind: "unknown_tool" };
968
+ return { title: `${toSentence(tool)} via ${server}`, kind: "unknown_tool" };
963
969
  }
964
970
  function identifyTarget(input) {
965
971
  const id = input.id ?? input.name ?? input.path ?? input.target ?? input.repo ?? input.repository ?? null;
@@ -1207,6 +1213,13 @@ function formatByteCount(bytes) {
1207
1213
  function toWords(snake) {
1208
1214
  return snake.replace(/_/g, " ").split(" ").map((w) => (w.length <= 3 ? w.toUpperCase() : w)).join(" ");
1209
1215
  }
1216
+ // "set_auto_merge" -> "Set auto merge", "bind_pr" -> "Bind PR": the first word
1217
+ // is a verb, so it is not read as an acronym.
1218
+ function toSentence(snake) {
1219
+ const [first = "", ...rest] = snake.split("_");
1220
+ const head = first.charAt(0).toUpperCase() + first.slice(1).toLowerCase();
1221
+ return rest.length ? `${head} ${toWords(rest.join("_"))}` : head;
1222
+ }
1210
1223
  function shortenPath(filePath) {
1211
1224
  return filePath
1212
1225
  .replace(/^\/home\/[^/]+\//, "~/")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oked/sdk",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "OKed SDK - human approval layer for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@oked/receipt-core": "0.6.3"
48
+ "@oked/receipt-core": "0.6.4"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.13.10",