approval-box 0.1.27 → 0.1.28
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 +39 -23
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -11940,11 +11940,32 @@ function writeConfig(config) {
|
|
|
11940
11940
|
|
|
11941
11941
|
// src/daemon-launch.ts
|
|
11942
11942
|
import { spawn, spawnSync } from "node:child_process";
|
|
11943
|
-
import {
|
|
11943
|
+
import { writeFileSync as writeFileSync2 } from "node:fs";
|
|
11944
11944
|
import { join as join2, resolve } from "node:path";
|
|
11945
|
+
function daemonBootstrap(entry, cwd, environment = {}) {
|
|
11946
|
+
return `Object.assign(process.env,${JSON.stringify(environment)});
|
|
11947
|
+
const fs=require('node:fs'),file=${JSON.stringify(join2(cwd, "daemon.log"))},fallback=process.stderr.write.bind(process.stderr);
|
|
11948
|
+
process.stderr.write=(chunk,encoding,callback)=>{
|
|
11949
|
+
try {
|
|
11950
|
+
const limit=1024*1024,next=Buffer.from(chunk,typeof encoding==='string'?encoding:undefined).subarray(-limit);
|
|
11951
|
+
const fd=fs.openSync(file,fs.constants.O_CREAT|fs.constants.O_RDWR,0o600);
|
|
11952
|
+
try {
|
|
11953
|
+
const size=fs.fstatSync(fd).size,keep=Math.min(size,limit-next.length),data=Buffer.alloc(keep+next.length);
|
|
11954
|
+
const read=keep?fs.readSync(fd,data,0,keep,size-keep):0;
|
|
11955
|
+
next.copy(data,read);
|
|
11956
|
+
fs.writeFileSync(fd,data.subarray(0,read+next.length));
|
|
11957
|
+
fs.ftruncateSync(fd,read+next.length);
|
|
11958
|
+
} finally { fs.closeSync(fd); }
|
|
11959
|
+
} catch { try { fallback('approval-box: daemon log write failed\\n'); } catch {} }
|
|
11960
|
+
if(typeof encoding==='function')encoding();else if(typeof callback==='function')callback();
|
|
11961
|
+
return true;
|
|
11962
|
+
};
|
|
11963
|
+
process.argv=[process.execPath,${JSON.stringify(entry)},'daemon'];
|
|
11964
|
+
import(require('node:url').pathToFileURL(${JSON.stringify(entry)}).href).catch(error=>{process.stderr.write(String(error)+'\\n');process.exit(1);});`;
|
|
11965
|
+
}
|
|
11945
11966
|
function windowsDaemonLaunchScript(executable, entry, cwd, environment) {
|
|
11946
11967
|
const env = Object.fromEntries(["APPROVAL_BOX_HOME", "HOME", "USERPROFILE", "APPDATA", "LOCALAPPDATA", "PATH", "CODEX_HOME", "GROK_HOME", "CODEX_BIN"].flatMap((key) => environment[key] === void 0 ? [] : [[key, environment[key]]]));
|
|
11947
|
-
const bootstrap =
|
|
11968
|
+
const bootstrap = daemonBootstrap(entry, cwd, env);
|
|
11948
11969
|
const command2 = `"${executable}" -e "eval(Buffer.from('${Buffer.from(bootstrap).toString("base64")}','base64').toString())"`;
|
|
11949
11970
|
const literal2 = (s) => `'${s.replaceAll("'", "''")}'`;
|
|
11950
11971
|
return `$ErrorActionPreference='Stop';$ProgressPreference='SilentlyContinue';$startup=New-CimInstance -ClassName Win32_ProcessStartup -ClientOnly -Property @{ShowWindow=[uint16]0};$result=Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine=${literal2(command2)};CurrentDirectory=${literal2(cwd)};ProcessStartupInformation=$startup};if($result.ReturnValue -ne 0){throw ('daemon creation failed: '+$result.ReturnValue)};$result.ProcessId`;
|
|
@@ -11958,22 +11979,17 @@ function launchDaemon(executable, entry, cwd) {
|
|
|
11958
11979
|
return;
|
|
11959
11980
|
}
|
|
11960
11981
|
const file = join2(cwd, "daemon.log");
|
|
11961
|
-
const
|
|
11962
|
-
|
|
11963
|
-
const
|
|
11964
|
-
child.on("error", (error) => {
|
|
11965
|
-
const line = `approval-box: \u914D\u9001\u30C7\u30FC\u30E2\u30F3\u3092\u8D77\u52D5\u3067\u304D\u307E\u305B\u3093\uFF08DAEMON_LAUNCH_FAILED\uFF09: ${executable}: ${error.message}
|
|
11982
|
+
const child = spawn(executable, ["-e", daemonBootstrap(entry, cwd)], { cwd, detached: true, stdio: "ignore", windowsHide: true });
|
|
11983
|
+
child.on("error", (error) => {
|
|
11984
|
+
const line = `approval-box: \u914D\u9001\u30C7\u30FC\u30E2\u30F3\u3092\u8D77\u52D5\u3067\u304D\u307E\u305B\u3093\uFF08DAEMON_LAUNCH_FAILED\uFF09: ${executable}: ${error.message}
|
|
11966
11985
|
`;
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
} finally {
|
|
11975
|
-
closeSync(log);
|
|
11976
|
-
}
|
|
11986
|
+
try {
|
|
11987
|
+
writeFileSync2(file, Buffer.from(`${(/* @__PURE__ */ new Date()).toISOString()} ${line}`).subarray(-1024 * 1024), { mode: 384 });
|
|
11988
|
+
} catch {
|
|
11989
|
+
}
|
|
11990
|
+
process.stderr.write(line);
|
|
11991
|
+
});
|
|
11992
|
+
child.unref();
|
|
11977
11993
|
}
|
|
11978
11994
|
|
|
11979
11995
|
// src/channel-delivery.ts
|
|
@@ -12011,7 +12027,7 @@ import { join as join5 } from "node:path";
|
|
|
12011
12027
|
|
|
12012
12028
|
// src/attachments.ts
|
|
12013
12029
|
import { createHash } from "node:crypto";
|
|
12014
|
-
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync2, rmSync, statSync, writeFileSync as
|
|
12030
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync2, rmSync, statSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
12015
12031
|
import { join as join3 } from "node:path";
|
|
12016
12032
|
var KEEP_DAYS = 30;
|
|
12017
12033
|
var attachmentsRoot = () => join3(home(), "attachments");
|
|
@@ -12026,7 +12042,7 @@ async function saveAttachment(api, decisionId, meta, index) {
|
|
|
12026
12042
|
const data = await api.download(`/decisions/${encodeURIComponent(decisionId)}/attachments/${encodeURIComponent(meta.id)}`);
|
|
12027
12043
|
if (sha256(data) !== meta.sha256) throw new Error(`${meta.name} \u306E\u4E2D\u8EAB\u304C\u30B5\u30FC\u30D0\u30FC\u306E\u8A18\u9332\u3068\u5408\u3044\u307E\u305B\u3093\uFF08\u53D6\u308A\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\uFF09`);
|
|
12028
12044
|
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
12029
|
-
|
|
12045
|
+
writeFileSync3(file, data, { mode: 384 });
|
|
12030
12046
|
return file;
|
|
12031
12047
|
}
|
|
12032
12048
|
async function saveAll(api, decisionId, items) {
|
|
@@ -12304,7 +12320,7 @@ import { homedir as homedir2 } from "node:os";
|
|
|
12304
12320
|
import { delimiter, dirname as dirname4, join as join7 } from "node:path";
|
|
12305
12321
|
|
|
12306
12322
|
// src/instructions.ts
|
|
12307
|
-
import { existsSync as existsSync4, lstatSync, mkdirSync as mkdirSync4, readFileSync as readFileSync4, readdirSync as readdirSync2, readlinkSync, writeFileSync as
|
|
12323
|
+
import { existsSync as existsSync4, lstatSync, mkdirSync as mkdirSync4, readFileSync as readFileSync4, readdirSync as readdirSync2, readlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
12308
12324
|
import { homedir } from "node:os";
|
|
12309
12325
|
import { dirname as dirname3, join as join6, resolve as resolve2 } from "node:path";
|
|
12310
12326
|
var INSTRUCTION_TEXT = "\u30E6\u30FC\u30B6\u30FC\u306E\u5224\u65AD\u30FB\u627F\u8A8D\u30FB\u64CD\u4F5C\u304C\u5FC5\u8981\u306A\u3068\u304D\u306F\u3001\u6C7A\u88C1\u30B7\u30B9\u30C6\u30E0\u3067\u3042\u308B Approval Box \u306E request_decision \u3067\u3082\u7533\u8ACB\u3059\u308B\u3002\u3053\u308C\u3092\u4F7F\u3048\u3070\u30E6\u30FC\u30B6\u30FC\u304C\u7533\u8ACB\u306B\u6C17\u3065\u304D\u3084\u3059\u3044\u306E\u3067\u3001\u5F37\u304F\u63A8\u5968\u3059\u308B\u3002";
|
|
@@ -12352,7 +12368,7 @@ function writeInstructions(file) {
|
|
|
12352
12368
|
if (managedElsewhere(file)) return "managed_elsewhere";
|
|
12353
12369
|
const current = existsSync4(file) ? readFileSync4(file, "utf8").replace(PATTERN, "\n").trimEnd() : "";
|
|
12354
12370
|
mkdirSync4(dirname3(file), { recursive: true, mode: 448 });
|
|
12355
|
-
|
|
12371
|
+
writeFileSync4(file, current ? `${current}
|
|
12356
12372
|
|
|
12357
12373
|
${BLOCK}` : BLOCK);
|
|
12358
12374
|
return "written";
|
|
@@ -12360,7 +12376,7 @@ ${BLOCK}` : BLOCK);
|
|
|
12360
12376
|
function removeInstructions(file) {
|
|
12361
12377
|
if (!existsSync4(file) || !readFileSync4(file, "utf8").includes(START)) return;
|
|
12362
12378
|
const rest = readFileSync4(file, "utf8").replace(PATTERN, "\n").trimEnd();
|
|
12363
|
-
|
|
12379
|
+
writeFileSync4(file, rest ? `${rest}
|
|
12364
12380
|
` : "");
|
|
12365
12381
|
}
|
|
12366
12382
|
|
|
@@ -16001,7 +16017,7 @@ function claudeChannelIsCurrent(profile, channelId, parent) {
|
|
|
16001
16017
|
}
|
|
16002
16018
|
|
|
16003
16019
|
// src/version.ts
|
|
16004
|
-
var VERSION = true ? "0.1.
|
|
16020
|
+
var VERSION = true ? "0.1.28" : "0.0.0-dev";
|
|
16005
16021
|
function osName() {
|
|
16006
16022
|
return process.platform === "darwin" ? "macos" : process.platform === "win32" ? "windows" : process.platform;
|
|
16007
16023
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "approval-box",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
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",
|