approval-box 0.1.28 → 0.1.30

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +26 -15
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -11816,7 +11816,7 @@ var require_dist = __commonJS({
11816
11816
 
11817
11817
  // src/cli.ts
11818
11818
  var import_qrcode = __toESM(require_lib(), 1);
11819
- import { cpSync, existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync3 } from "node:fs";
11819
+ import { cpSync, existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
11820
11820
  import { hostname } from "node:os";
11821
11821
  import { join as join10 } from "node:path";
11822
11822
  import { createInterface } from "node:readline/promises";
@@ -11914,7 +11914,7 @@ var Api = class {
11914
11914
  };
11915
11915
 
11916
11916
  // src/config.ts
11917
- import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
11917
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
11918
11918
  import { dirname, join } from "node:path";
11919
11919
  var OFFICIAL_SERVER = "https://approval-box.kitepon.dev";
11920
11920
  var configFile = () => join(home(), "config.json");
@@ -11927,12 +11927,23 @@ function requireConfig() {
11927
11927
  if (!config?.token) throw new Error("Approval Box\u306B\u3064\u306A\u304C\u3063\u3066\u3044\u307E\u305B\u3093\u3002npx approval-box setup \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
11928
11928
  return config;
11929
11929
  }
11930
- function writeJsonFile(file, value) {
11930
+ function writeJsonFile(file, value, options = {}) {
11931
11931
  mkdirSync(dirname(file), { recursive: true, mode: 448 });
11932
11932
  const temp = `${file}.${process.pid}.tmp`;
11933
- writeFileSync(temp, `${JSON.stringify(value, null, 2)}
11933
+ try {
11934
+ writeFileSync(temp, `${JSON.stringify(value, null, 2)}
11934
11935
  `, { mode: 384 });
11935
- renameSync(temp, file);
11936
+ renameSync(temp, file);
11937
+ } catch (error) {
11938
+ if (options.discardTemporaryOnError) {
11939
+ try {
11940
+ rmSync(temp, { force: true });
11941
+ } catch {
11942
+ process.stderr.write("approval-box: \u4FDD\u5B58\u306B\u5931\u6557\u3057\u305F\u4E00\u6642\u30D5\u30A1\u30A4\u30EB\u3092\u56DE\u53CE\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\n");
11943
+ }
11944
+ }
11945
+ throw error;
11946
+ }
11936
11947
  }
11937
11948
  function writeConfig(config) {
11938
11949
  writeJsonFile(configFile(), config);
@@ -12022,12 +12033,12 @@ async function channelAnswerState(channelId, deliveryId, codex = provider) {
12022
12033
  }
12023
12034
 
12024
12035
  // src/daemon.ts
12025
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync2 } from "node:fs";
12036
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync3 } from "node:fs";
12026
12037
  import { join as join5 } from "node:path";
12027
12038
 
12028
12039
  // src/attachments.ts
12029
12040
  import { createHash } from "node:crypto";
12030
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync2, rmSync, statSync, writeFileSync as writeFileSync3 } from "node:fs";
12041
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync3 } from "node:fs";
12031
12042
  import { join as join3 } from "node:path";
12032
12043
  var KEEP_DAYS = 30;
12033
12044
  var attachmentsRoot = () => join3(home(), "attachments");
@@ -12063,7 +12074,7 @@ function pruneAttachments() {
12063
12074
  for (const name of readdirSync(root)) {
12064
12075
  const dir = join3(root, name);
12065
12076
  try {
12066
- if (statSync(dir).mtimeMs < before) rmSync(dir, { recursive: true, force: true });
12077
+ if (statSync(dir).mtimeMs < before) rmSync2(dir, { recursive: true, force: true });
12067
12078
  } catch {
12068
12079
  }
12069
12080
  }
@@ -12265,7 +12276,7 @@ async function runDaemon() {
12265
12276
  const releaseLock = () => {
12266
12277
  try {
12267
12278
  const lock = JSON.parse(readFileSync3(lockFile(), "utf8"));
12268
- if (lock.pid === process.pid) rmSync2(lockFile(), { force: true });
12279
+ if (lock.pid === process.pid) rmSync3(lockFile(), { force: true });
12269
12280
  } catch {
12270
12281
  }
12271
12282
  };
@@ -12432,7 +12443,7 @@ function setCursorPermissions(enable) {
12432
12443
  const ours = new Set(CURSOR_TOOLS.map((tool) => `Mcp(${MCP_SERVER}:${tool})`));
12433
12444
  const allow = (permissions.allow ?? []).filter((rule) => !ours.has(rule));
12434
12445
  if (enable) allow.push(...ours);
12435
- writeJsonFile(file, { ...current, permissions: { ...permissions, allow, deny: permissions.deny ?? [] } });
12446
+ writeJsonFile(file, { ...current, permissions: { ...permissions, allow, deny: permissions.deny ?? [] } }, { discardTemporaryOnError: true });
12436
12447
  }
12437
12448
  var CURSOR_CONTEXT = "cursor-context";
12438
12449
  function setCursorContext(enable) {
@@ -12447,7 +12458,7 @@ function setCursorContext(enable) {
12447
12458
  if (enable) rest.push({ command: `${cursorParentHookCommand({ command: stableNode(), script: runtimeEntry("cli") })} ${CURSOR_CONTEXT}`, timeout: 10 });
12448
12459
  if (rest.length) hooks.sessionStart = rest;
12449
12460
  else delete hooks.sessionStart;
12450
- writeJsonFile(target, { version: 1, ...current, hooks });
12461
+ writeJsonFile(target, { version: 1, ...current, hooks }, { discardTemporaryOnError: true });
12451
12462
  }
12452
12463
  var cursorContextRegistered = () => JSON.stringify(readJson(join7(cursorDir(), "hooks.json")).hooks ?? {}).includes(` ${CURSOR_CONTEXT}"`);
12453
12464
  var registration = () => ({ command: stableNode(), args: [runtimeEntry("cli"), "mcp"] });
@@ -12465,7 +12476,7 @@ function setMcpJson(file, value) {
12465
12476
  const servers = { ...current.mcpServers ?? {} };
12466
12477
  if (value) servers[MCP_SERVER] = value;
12467
12478
  else delete servers[MCP_SERVER];
12468
- writeJsonFile(file, { ...current, mcpServers: servers });
12479
+ writeJsonFile(file, { ...current, mcpServers: servers }, { discardTemporaryOnError: true });
12469
12480
  }
12470
12481
  async function withCodexConfig(fn) {
12471
12482
  return withCodexReceiver(PROFILE, { thread_id: "00000000-0000-4000-8000-000000000000", codex_home: codexHome() }, fn);
@@ -16017,7 +16028,7 @@ function claudeChannelIsCurrent(profile, channelId, parent) {
16017
16028
  }
16018
16029
 
16019
16030
  // src/version.ts
16020
- var VERSION = true ? "0.1.28" : "0.0.0-dev";
16031
+ var VERSION = true ? "0.1.30" : "0.0.0-dev";
16021
16032
  function osName() {
16022
16033
  return process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : process.platform;
16023
16034
  }
@@ -16407,7 +16418,7 @@ async function ask(question) {
16407
16418
  function installRuntime() {
16408
16419
  const target = join10(home(), "runtime", VERSION);
16409
16420
  if (runtimeDir() !== target) {
16410
- rmSync3(target, { recursive: true, force: true });
16421
+ rmSync4(target, { recursive: true, force: true });
16411
16422
  mkdirSync5(target, { recursive: true });
16412
16423
  cpSync(runtimeDir(), target, { recursive: true });
16413
16424
  }
@@ -16556,7 +16567,7 @@ async function uninstall() {
16556
16567
  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}`);
16557
16568
  }
16558
16569
  }
16559
- rmSync3(join10(home(), "config.json"), { force: true });
16570
+ rmSync4(join10(home(), "config.json"), { force: true });
16560
16571
  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");
16561
16572
  }
16562
16573
  async function status() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "approval-box",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
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",