approval-box 0.1.20 → 0.1.21
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/cli.mjs +24 -11
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -11761,7 +11761,7 @@ var require_dist = __commonJS({
|
|
|
11761
11761
|
var import_qrcode = __toESM(require_lib(), 1);
|
|
11762
11762
|
import { cpSync, existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync3 } from "node:fs";
|
|
11763
11763
|
import { hostname } from "node:os";
|
|
11764
|
-
import { join as
|
|
11764
|
+
import { join as join10 } from "node:path";
|
|
11765
11765
|
import { createInterface } from "node:readline/promises";
|
|
11766
11766
|
|
|
11767
11767
|
// src/api.ts
|
|
@@ -15836,8 +15836,8 @@ var StdioServerTransport = class {
|
|
|
15836
15836
|
};
|
|
15837
15837
|
|
|
15838
15838
|
// src/mcp.ts
|
|
15839
|
-
import { existsSync as existsSync6, readFileSync as
|
|
15840
|
-
import { basename as basename3, join as
|
|
15839
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
|
|
15840
|
+
import { basename as basename3, join as join9 } from "node:path";
|
|
15841
15841
|
|
|
15842
15842
|
// src/request-images.ts
|
|
15843
15843
|
import { open } from "node:fs/promises";
|
|
@@ -15882,8 +15882,21 @@ async function uploadImagePaths(api, paths) {
|
|
|
15882
15882
|
return ids;
|
|
15883
15883
|
}
|
|
15884
15884
|
|
|
15885
|
+
// src/claude-channel.ts
|
|
15886
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
15887
|
+
import { join as join8 } from "node:path";
|
|
15888
|
+
function claudeChannelIsCurrent(profile, channelId, parent) {
|
|
15889
|
+
try {
|
|
15890
|
+
const bound = readChannel(profile, channelId).claude;
|
|
15891
|
+
const now = JSON.parse(readFileSync6(join8(parent.hook_root, parent.request_id, "request.json"), "utf8"));
|
|
15892
|
+
return !!bound && bound.session_id === parent.session_id && bound.parent_pid === now.parent_pid && bound.parent_started_identity === now.parent_started_identity;
|
|
15893
|
+
} catch {
|
|
15894
|
+
return false;
|
|
15895
|
+
}
|
|
15896
|
+
}
|
|
15897
|
+
|
|
15885
15898
|
// src/version.ts
|
|
15886
|
-
var VERSION = true ? "0.1.
|
|
15899
|
+
var VERSION = true ? "0.1.21" : "0.0.0-dev";
|
|
15887
15900
|
function osName() {
|
|
15888
15901
|
return process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : process.platform;
|
|
15889
15902
|
}
|
|
@@ -15995,12 +16008,12 @@ var TOOLS = [
|
|
|
15995
16008
|
];
|
|
15996
16009
|
var VIEWABLE_IMAGES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
15997
16010
|
var MAX_INLINE_IMAGE = 5 * 1024 * 1024;
|
|
15998
|
-
var parentsFile = () =>
|
|
16011
|
+
var parentsFile = () => join9(stateRoot(), "parents.json");
|
|
15999
16012
|
var processChannels = /* @__PURE__ */ new Map();
|
|
16000
16013
|
var lastChannel;
|
|
16001
16014
|
function savedParents() {
|
|
16002
16015
|
try {
|
|
16003
|
-
return existsSync6(parentsFile()) ? JSON.parse(
|
|
16016
|
+
return existsSync6(parentsFile()) ? JSON.parse(readFileSync7(parentsFile(), "utf8")) : {};
|
|
16004
16017
|
} catch {
|
|
16005
16018
|
return {};
|
|
16006
16019
|
}
|
|
@@ -16037,7 +16050,7 @@ async function channelFor(harness, clientName, meta) {
|
|
|
16037
16050
|
if (!parent) throw new Error("Claude Code\u306Ehook\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002npx approval-box setup \u3092\u3084\u308A\u76F4\u3057\u3001Claude Code\u3092\u518D\u8D77\u52D5\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
|
|
16038
16051
|
const key2 = `claude:${parent.session_id}`;
|
|
16039
16052
|
const existing2 = reuse(key2, true);
|
|
16040
|
-
if (existing2) return existing2;
|
|
16053
|
+
if (existing2 && claudeChannelIsCurrent(PROFILE, existing2, parent)) return existing2;
|
|
16041
16054
|
const channel2 = openChannel(PROFILE, parent);
|
|
16042
16055
|
remember(key2, channel2.channel_id, true);
|
|
16043
16056
|
return channel2.channel_id;
|
|
@@ -16196,7 +16209,7 @@ ${JSON.stringify(decision)}`, decision);
|
|
|
16196
16209
|
const head = `${decisionId} \u306E\u6DFB\u4ED8 ${index + 1}: ${meta.name}\uFF08${meta.content_type}\u3001${meta.size}\u30D0\u30A4\u30C8\uFF09\u3092\u4FDD\u5B58\u3057\u307E\u3057\u305F: ${path}`;
|
|
16197
16210
|
const structured = { decision_id: decisionId, attachment: meta, path };
|
|
16198
16211
|
if (VIEWABLE_IMAGES.includes(meta.content_type) && meta.size <= MAX_INLINE_IMAGE) {
|
|
16199
|
-
return { content: [{ type: "text", text: head }, { type: "image", data:
|
|
16212
|
+
return { content: [{ type: "text", text: head }, { type: "image", data: readFileSync7(path).toString("base64"), mimeType: meta.content_type }], structuredContent: structured };
|
|
16200
16213
|
}
|
|
16201
16214
|
return text(head, structured);
|
|
16202
16215
|
}
|
|
@@ -16262,13 +16275,13 @@ async function ask(question) {
|
|
|
16262
16275
|
}
|
|
16263
16276
|
}
|
|
16264
16277
|
function installRuntime() {
|
|
16265
|
-
const target =
|
|
16278
|
+
const target = join10(home(), "runtime", VERSION);
|
|
16266
16279
|
if (runtimeDir() !== target) {
|
|
16267
16280
|
rmSync3(target, { recursive: true, force: true });
|
|
16268
16281
|
mkdirSync5(target, { recursive: true });
|
|
16269
16282
|
cpSync(runtimeDir(), target, { recursive: true });
|
|
16270
16283
|
}
|
|
16271
|
-
return
|
|
16284
|
+
return join10(target, "cli.mjs");
|
|
16272
16285
|
}
|
|
16273
16286
|
function selectedTargets() {
|
|
16274
16287
|
const only = option("only");
|
|
@@ -16413,7 +16426,7 @@ async function uninstall() {
|
|
|
16413
16426
|
out(` \u30B5\u30FC\u30D0\u30FC: \u63A5\u7D9A\u306E\u89E3\u9664\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF08\u30A2\u30D7\u30EA\u306E\u300C\u63A5\u7D9A\u300D\u304B\u3089\u5916\u3057\u3066\u304F\u3060\u3055\u3044\uFF09: ${error.message}`);
|
|
16414
16427
|
}
|
|
16415
16428
|
}
|
|
16416
|
-
rmSync3(
|
|
16429
|
+
rmSync3(join10(home(), "config.json"), { force: true });
|
|
16417
16430
|
out("\nApproval Box\u3092\u5916\u3057\u307E\u3057\u305F\u3002npm install -g \u3067\u5165\u308C\u305F\u5834\u5408\u306F\u3001npm uninstall -g approval-box \u3067\u672C\u4F53\u3082\u6D88\u305B\u307E\u3059\u3002");
|
|
16418
16431
|
}
|
|
16419
16432
|
async function status() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "approval-box",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Approval Box connector: lets Claude Code, Codex, Cursor and Grok ask you for a decision, and steers your answer back into the same session.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://approval-box.kitepon.dev",
|