@oked/claude-agent-sdk 0.4.0 → 0.6.0
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/index.js +25 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -12,10 +12,24 @@
|
|
|
12
12
|
* via `OKED_API_KEY` (or `~/.oked/config.json`); see README.
|
|
13
13
|
*
|
|
14
14
|
* Failure semantics mirror the other OKed integrations: fail safe. Auth
|
|
15
|
-
* errors deny; backend-unreachable degrades
|
|
16
|
-
* any unexpected error denies. Never let an agent proceed when in doubt.
|
|
15
|
+
* errors and receipts that do not verify deny; backend-unreachable degrades
|
|
16
|
+
* per tier (`degradedDecision`); any unexpected error denies. Never let an agent proceed when in doubt.
|
|
17
17
|
*/
|
|
18
|
-
import { OKedClient, classify, describe, describeFields, degradedDecision, OKedAuthError, OKedBackendUnreachableError, DEFAULT_APPROVAL_TIMEOUT_MS, } from "@oked/sdk";
|
|
18
|
+
import { OKedClient, classify, describe, describeFields, degradedDecision, OKedAuthError, OKedBackendUnreachableError, OKedReceiptError, DEFAULT_APPROVAL_TIMEOUT_MS, } from "@oked/sdk";
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
// This package's version, read from its package.json at runtime (dist/*.js
|
|
23
|
+
// sits one dir below it) so receipts name the exact client that asked.
|
|
24
|
+
const CLIENT_ID = (() => {
|
|
25
|
+
try {
|
|
26
|
+
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
27
|
+
return `@oked/claude-agent-sdk@${JSON.parse(readFileSync(pkgPath, "utf-8")).version}`;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return "@oked/claude-agent-sdk";
|
|
31
|
+
}
|
|
32
|
+
})();
|
|
19
33
|
function log(msg) {
|
|
20
34
|
process.stderr.write(`[OKed] ${msg}\n`);
|
|
21
35
|
}
|
|
@@ -47,7 +61,7 @@ export const okedPreToolUseHook = async (rawInput) => {
|
|
|
47
61
|
const toolName = input.tool_name;
|
|
48
62
|
const toolInput = (input.tool_input ?? {});
|
|
49
63
|
const tier = classify(toolName, toolInput);
|
|
50
|
-
const client = new OKedClient();
|
|
64
|
+
const client = new OKedClient({ client: CLIENT_ID, source: "claude-agent-sdk" });
|
|
51
65
|
// Presence ping (throttled to once/day on disk, never throws). Fired before
|
|
52
66
|
// the safe/warning return so installs that only run safe actions still
|
|
53
67
|
// register for retention. Fire-and-forget: this is a long-lived process, so
|
|
@@ -67,8 +81,8 @@ export const okedPreToolUseHook = async (rawInput) => {
|
|
|
67
81
|
log("OKED_API_KEY not set - deferring to the agent's built-in permission flow.");
|
|
68
82
|
return ask();
|
|
69
83
|
}
|
|
70
|
-
const description = describe(toolName, toolInput);
|
|
71
|
-
const fields = describeFields(toolName, toolInput) ?? undefined;
|
|
84
|
+
const description = describe(toolName, toolInput, { cwd: input.cwd });
|
|
85
|
+
const fields = describeFields(toolName, toolInput, { cwd: input.cwd }) ?? undefined;
|
|
72
86
|
log(`${toolName}: "${description}" - ${tier}`);
|
|
73
87
|
log("Requesting approval... (check your phone)");
|
|
74
88
|
try {
|
|
@@ -89,6 +103,11 @@ export const okedPreToolUseHook = async (rawInput) => {
|
|
|
89
103
|
return deny(`Denied via OKed: ${description}`);
|
|
90
104
|
}
|
|
91
105
|
catch (err) {
|
|
106
|
+
if (err instanceof OKedReceiptError) {
|
|
107
|
+
// A decision we cannot prove is not a decision — always deny.
|
|
108
|
+
log(`Approval receipt did not verify (${err.problems.join(", ")}) - action denied`);
|
|
109
|
+
return deny(`OKed: the approval receipt did not verify (${err.problems.join(", ")}); action denied`);
|
|
110
|
+
}
|
|
92
111
|
if (err instanceof OKedAuthError) {
|
|
93
112
|
// Auth misconfig is not an outage — always deny.
|
|
94
113
|
log("Invalid API key - action denied");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/claude-agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "OKed for the Claude Agent SDK. A ready-made PreToolUse hook that gates sensitive tool calls behind a human approval push to your phone.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@oked/sdk": "0.
|
|
35
|
+
"@oked/sdk": "0.6.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@anthropic-ai/claude-agent-sdk": "^0.1.0",
|