@oked/sdk 0.6.0 → 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 +93 -0
- package/dist/describe.js +88 -0
- package/dist/kinds.d.ts +1 -1
- package/package.json +2 -2
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,
|
|
@@ -1286,9 +1356,32 @@ function classifyBrowserTool(tool, toolInput, server) {
|
|
|
1286
1356
|
}
|
|
1287
1357
|
return "review";
|
|
1288
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Desktop app folder access (`ccd_directory`): change_directory moves the
|
|
1361
|
+
* session to a folder, request_directory adds a folder to it. The app already
|
|
1362
|
+
* shows its own approval for the exact folder (except in bypass permissions
|
|
1363
|
+
* mode), so a second OKed prompt is approval fatigue. Log it (`warning`), but
|
|
1364
|
+
* keep `review` for a broad or sensitive grant: the filesystem root, the home
|
|
1365
|
+
* folder or one of its parents, secret stores and system folders. Without a
|
|
1366
|
+
* path, request_directory opens a native picker the user drives: `safe`.
|
|
1367
|
+
*/
|
|
1368
|
+
function classifyDirectoryGrant(tool, toolInput) {
|
|
1369
|
+
const dir = typeof toolInput.path === "string" ? toolInput.path.trim() : "";
|
|
1370
|
+
if (!dir)
|
|
1371
|
+
return tool === "request_directory" ? "safe" : "review";
|
|
1372
|
+
const home = os.homedir();
|
|
1373
|
+
const resolved = path.resolve(dir.replace(/^~(?=\/|$)/, home).replace(/^\$\{?HOME\}?(?=\/|$)/, home));
|
|
1374
|
+
const isHomeOrParent = home === resolved || home.startsWith(resolved.endsWith(path.sep) ? resolved : resolved + path.sep);
|
|
1375
|
+
if (isHomeOrParent || isSensitiveWritePath(resolved))
|
|
1376
|
+
return "review";
|
|
1377
|
+
return "warning";
|
|
1378
|
+
}
|
|
1289
1379
|
function classifyMcpTool(toolName, toolInput = {}) {
|
|
1290
1380
|
const parts = toolName.split("__");
|
|
1291
1381
|
const tool = parts[parts.length - 1] || "";
|
|
1382
|
+
if (parts.includes("ccd_directory") && (tool === "change_directory" || tool === "request_directory")) {
|
|
1383
|
+
return classifyDirectoryGrant(tool, toolInput);
|
|
1384
|
+
}
|
|
1292
1385
|
const browserServer = parts.slice(1, -1).find((p) => BROWSER_MCP_SERVERS.has(p));
|
|
1293
1386
|
if (browserServer)
|
|
1294
1387
|
return classifyBrowserTool(tool, toolInput, browserServer);
|
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
|
}
|
|
@@ -858,6 +861,15 @@ function summarizeMcp(toolName, input) {
|
|
|
858
861
|
const parts = toolName.split("__");
|
|
859
862
|
const server = parts[1] || "unknown";
|
|
860
863
|
const tool = parts[2] || "";
|
|
864
|
+
if (parts.includes("ccd_directory") && (tool === "change_directory" || tool === "request_directory")) {
|
|
865
|
+
const dir = typeof input.path === "string" && input.path.trim() ? shortenPath(input.path.trim()) : undefined;
|
|
866
|
+
if (tool === "change_directory") {
|
|
867
|
+
return { title: "Move session to folder", target: dir, footnote: "Claude can read and change files in this folder", kind: "folder_access" };
|
|
868
|
+
}
|
|
869
|
+
return dir
|
|
870
|
+
? { title: "Give session access to folder", target: dir, footnote: "Claude can read and change files in this folder", kind: "folder_access" }
|
|
871
|
+
: { title: "Ask you to pick a folder for this session", kind: "folder_access" };
|
|
872
|
+
}
|
|
861
873
|
const browser = parts.slice(1, -1).find((p) => p === "Claude_Browser" || p === "claude-in-chrome");
|
|
862
874
|
if (browser)
|
|
863
875
|
return summarizeBrowser(parts[parts.length - 1] || "", input, browser);
|
|
@@ -1061,6 +1073,82 @@ function prettyServer(server) {
|
|
|
1061
1073
|
// ───────────────────────────────────────────────────────────────────────
|
|
1062
1074
|
// Fallback
|
|
1063
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
|
+
}
|
|
1064
1152
|
function summarizeFallback(toolName, toolInput) {
|
|
1065
1153
|
const keys = Object.keys(toolInput);
|
|
1066
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" | "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.
|
|
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.
|
|
48
|
+
"@oked/receipt-core": "0.6.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.13.10",
|