@oked/sdk 0.6.1 → 0.6.2

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
@@ -51,6 +51,69 @@ const SAFE_TOOL_ALIASES = new Set([
51
51
  "search_files",
52
52
  "find",
53
53
  ]);
54
+ // Claude Code built-ins that only steer the session itself (its background
55
+ // tasks, todo list, plan mode, tool loading, questions to the user) or show
56
+ // something to the user. They touch no files, network or other process, so a
57
+ // prompt is pure approval fatigue.
58
+ const SAFE_SESSION_TOOLS = new Set([
59
+ "TaskStop",
60
+ "KillShell",
61
+ "TaskOutput",
62
+ "BashOutput",
63
+ "TaskCreate",
64
+ "TaskUpdate",
65
+ "TodoWrite",
66
+ "ToolSearch",
67
+ "Skill",
68
+ "AskUserQuestion",
69
+ "EnterPlanMode",
70
+ "ExitPlanMode",
71
+ "ListAgents",
72
+ "CronList",
73
+ "ScheduleWakeup",
74
+ "LSP",
75
+ "ReportFindings",
76
+ "SendUserFile",
77
+ "PushNotification",
78
+ ]);
79
+ // Claude Code built-ins with a small effect: a new worktree, a session-only
80
+ // scheduled prompt, a message to another agent, a web page fetch. Logged, not
81
+ // prompted; whatever they lead to (the scheduled prompt's tool calls, the other
82
+ // agent's actions) is gated on its own.
83
+ const WARNING_SESSION_TOOLS = new Set([
84
+ "EnterWorktree",
85
+ "CronCreate",
86
+ "CronDelete",
87
+ "SendMessage",
88
+ "WebFetch",
89
+ ]);
90
+ /** Built-ins whose tier depends on their input. Returns null for other tools. */
91
+ function classifySessionTool(toolName, toolInput) {
92
+ switch (toolName) {
93
+ // "keep" leaves everything on disk. "remove" refuses when there is
94
+ // unsaved work, unless discard_changes deletes it for good.
95
+ case "ExitWorktree":
96
+ if (toolInput.action !== "remove")
97
+ return "safe";
98
+ return toolInput.discard_changes === true ? "high_stakes" : "warning";
99
+ // Monitor runs a shell command (classified like Bash) or reads a WebSocket.
100
+ case "Monitor":
101
+ if (typeof toolInput.command === "string")
102
+ return classifyBashCommand(toolInput.command);
103
+ return "warning";
104
+ // Artifact: publishing puts content on claude.ai; delete is permanent;
105
+ // read / list / open / quickstart / pin only look or arrange.
106
+ case "Artifact": {
107
+ const action = typeof toolInput.action === "string" ? toolInput.action : "publish";
108
+ if (action === "delete")
109
+ return "high_stakes";
110
+ if (action === "publish")
111
+ return "review";
112
+ return "safe";
113
+ }
114
+ }
115
+ return null;
116
+ }
54
117
  // Tools that are always review-tier risk (modify local files)
55
118
  const REVIEW_TOOLS = new Set([]);
56
119
  // Tools that are always high stakes
@@ -317,6 +380,13 @@ export function classify(toolName, toolInput) {
317
380
  return "high_stakes";
318
381
  if (REVIEW_TOOLS.has(toolName))
319
382
  return "review";
383
+ if (SAFE_SESSION_TOOLS.has(toolName))
384
+ return "safe";
385
+ if (WARNING_SESSION_TOOLS.has(toolName))
386
+ return "warning";
387
+ const sessionTier = classifySessionTool(toolName, toolInput);
388
+ if (sessionTier !== null)
389
+ return sessionTier;
320
390
  // File-editing tools: a write/edit can't act on its own — whatever later
321
391
  // executes it is classified separately — so it's `warning` (logged, no
322
392
  // prompt) everywhere EXCEPT sensitive targets (system dirs, secret stores,
package/dist/describe.js CHANGED
@@ -62,6 +62,9 @@ function summarize(toolName, toolInput, ctx) {
62
62
  case "Agent":
63
63
  return summarizeAgent(toolInput);
64
64
  }
65
+ const session = summarizeSessionTool(toolName, toolInput);
66
+ if (session)
67
+ return session;
65
68
  if (toolName.startsWith("mcp__")) {
66
69
  return summarizeMcp(toolName, toolInput);
67
70
  }
@@ -1070,6 +1073,82 @@ function prettyServer(server) {
1070
1073
  // ───────────────────────────────────────────────────────────────────────
1071
1074
  // Fallback
1072
1075
  // ───────────────────────────────────────────────────────────────────────
1076
+ /**
1077
+ * Claude Code built-ins. Their names (`TaskStop`, `CronCreate`, …) and raw
1078
+ * fields (`task_id: bkm34a6nc`) mean nothing on an approval card, so say what
1079
+ * the step does. Returns null for other tools.
1080
+ */
1081
+ function summarizeSessionTool(toolName, input) {
1082
+ const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
1083
+ switch (toolName) {
1084
+ case "TaskStop":
1085
+ case "KillShell":
1086
+ return {
1087
+ title: "Stop background task",
1088
+ target: str(input.task_id) ?? str(input.shell_id),
1089
+ footnote: "Only a task this session started",
1090
+ kind: "session_control",
1091
+ };
1092
+ case "EnterWorktree":
1093
+ return { title: "Create a git worktree for this session", target: str(input.name), kind: "worktree" };
1094
+ case "ExitWorktree":
1095
+ if (input.action !== "remove")
1096
+ return { title: "Leave worktree (keep it on disk)", kind: "worktree" };
1097
+ return input.discard_changes === true
1098
+ ? { title: "Delete worktree and discard its changes", footnote: "Uncommitted files and unmerged commits are lost", kind: "worktree" }
1099
+ : { title: "Delete worktree", footnote: "Refused if it has unsaved changes", kind: "worktree" };
1100
+ case "CronCreate": {
1101
+ const prompt = str(input.prompt);
1102
+ return {
1103
+ title: input.recurring === false ? "Schedule a one-time prompt" : "Schedule a recurring prompt",
1104
+ target: str(input.cron),
1105
+ body: prompt ? truncateBody(prompt) : undefined,
1106
+ kind: "schedule",
1107
+ };
1108
+ }
1109
+ case "CronDelete":
1110
+ return { title: "Delete scheduled prompt", target: str(input.id) ?? str(input.job_id), kind: "schedule" };
1111
+ case "SendMessage": {
1112
+ const message = str(input.message);
1113
+ return {
1114
+ title: str(input.to) ? `Send message to agent "${truncate(str(input.to), 40)}"` : "Send message to agent",
1115
+ body: message ? truncateBody(message) : undefined,
1116
+ kind: "agent_message",
1117
+ };
1118
+ }
1119
+ case "WebFetch": {
1120
+ const url = str(input.url);
1121
+ return { title: "Fetch web page", target: url ? truncate(url, 80) : undefined, kind: "web_fetch" };
1122
+ }
1123
+ case "Monitor": {
1124
+ const cmd = str(input.command);
1125
+ const ws = str(input.ws?.url);
1126
+ return {
1127
+ title: str(input.description) ? `Watch: ${truncate(str(input.description), 60)}` : "Start background watcher",
1128
+ target: ws ? truncate(ws, 80) : undefined,
1129
+ body: cmd ? truncateBody(cmd) : undefined,
1130
+ kind: "monitor",
1131
+ };
1132
+ }
1133
+ case "Artifact": {
1134
+ const action = str(input.action) ?? "publish";
1135
+ const target = str(input.url) ?? (str(input.file_path) ? shortenPath(str(input.file_path)) : undefined);
1136
+ if (action === "delete") {
1137
+ return { title: "Delete page from claude.ai", target, footnote: "The link stops working for everyone", kind: "artifact" };
1138
+ }
1139
+ if (action === "publish") {
1140
+ return {
1141
+ title: str(input.url) ? "Update page on claude.ai" : "Publish page to claude.ai",
1142
+ target,
1143
+ footnote: "Private to you until you share it",
1144
+ kind: "artifact",
1145
+ };
1146
+ }
1147
+ return { title: `${action.replace(/_/g, " ")} page on claude.ai`.replace(/^./, (c) => c.toUpperCase()), target, kind: "artifact" };
1148
+ }
1149
+ }
1150
+ return null;
1151
+ }
1073
1152
  function summarizeFallback(toolName, toolInput) {
1074
1153
  const keys = Object.keys(toolInput);
1075
1154
  if (!keys.length)
package/dist/kinds.d.ts CHANGED
@@ -7,4 +7,4 @@
7
7
  * classifier that produced them.
8
8
  */
9
9
  export declare const CLASSIFIER_VERSION = "v2";
10
- export type OperationKind = "file_create" | "file_append" | "file_edit" | "file_touch" | "file_copy" | "file_move" | "file_delete" | "sql_drop" | "sql_truncate" | "sql_alter" | "sql_create" | "sql_delete_rows" | "sql_delete_all_rows" | "sql_update_rows" | "sql_update_every_row" | "sql_insert" | "sql_query" | "git_push" | "git_force_push" | "git_reset_hard" | "git_clean" | "git_checkout" | "git_restore" | "git_commit" | "git_pr_create" | "ssh_remote" | "http_get" | "http_post" | "http_put" | "http_delete" | "http_pipe_to_shell" | "docker_up" | "docker_down" | "docker_rm" | "docker_rmi" | "docker_prune" | "npm_install" | "npm_run" | "npm_test" | "npm_publish" | "npm_unpublish" | "npx_deploy" | "kill_process" | "sudo" | "chmod_777" | "email_send" | "email_delete" | "email_purge" | "payment_charge" | "payment_create" | "chat_message" | "mcp_delete" | "mcp_update" | "mcp_create" | "mcp_post" | "mcp_publish" | "mcp_send" | "mcp_submit_form" | "mcp_fill" | "mcp_submit" | "mcp_query" | "browser_navigate" | "browser_interact" | "browser_script" | "browser_dev_server" | "folder_access" | "agent_launch" | "shell_pipeline" | "unknown_bash" | "unknown_tool";
10
+ export type OperationKind = "file_create" | "file_append" | "file_edit" | "file_touch" | "file_copy" | "file_move" | "file_delete" | "sql_drop" | "sql_truncate" | "sql_alter" | "sql_create" | "sql_delete_rows" | "sql_delete_all_rows" | "sql_update_rows" | "sql_update_every_row" | "sql_insert" | "sql_query" | "git_push" | "git_force_push" | "git_reset_hard" | "git_clean" | "git_checkout" | "git_restore" | "git_commit" | "git_pr_create" | "ssh_remote" | "http_get" | "http_post" | "http_put" | "http_delete" | "http_pipe_to_shell" | "docker_up" | "docker_down" | "docker_rm" | "docker_rmi" | "docker_prune" | "npm_install" | "npm_run" | "npm_test" | "npm_publish" | "npm_unpublish" | "npx_deploy" | "kill_process" | "sudo" | "chmod_777" | "email_send" | "email_delete" | "email_purge" | "payment_charge" | "payment_create" | "chat_message" | "mcp_delete" | "mcp_update" | "mcp_create" | "mcp_post" | "mcp_publish" | "mcp_send" | "mcp_submit_form" | "mcp_fill" | "mcp_submit" | "mcp_query" | "browser_navigate" | "browser_interact" | "browser_script" | "browser_dev_server" | "folder_access" | "session_control" | "worktree" | "schedule" | "agent_message" | "web_fetch" | "monitor" | "artifact" | "agent_launch" | "shell_pipeline" | "unknown_bash" | "unknown_tool";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oked/sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
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.1"
48
+ "@oked/receipt-core": "0.6.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.13.10",