blun-king-cli 9.1.607 → 9.1.608

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.607",
3
+ "version": "9.1.608",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {
package/worker-host.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // BLUN_BUILD_INPUT_SHA256:9c2732198b7a858bcd8b66604ad503ed8e359fcaa2b196011f9954a3caa53dba
2
+ // BLUN_BUILD_INPUT_SHA256:47510c4534e220288a7d413e8081ba7b69d9557c15c1b1e47eb83e2417b79e59
3
3
  import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
4
4
  import { dirname as __cjsShimDirname } from 'node:path';
5
5
  const __filename = __cjsShimFileURLToPath(import.meta.url);
@@ -10129,7 +10129,18 @@ async function readOwner(lockDirectory) {
10129
10129
  const marker = join(lockDirectory, name);
10130
10130
  const stats = await lstat(marker);
10131
10131
  if (!stats.isFile() || stats.isSymbolicLink() || stats.size > 2048) throw unavailable();
10132
- const record = JSON.parse(await readFile(marker, "utf8"));
10132
+ let content;
10133
+ try {
10134
+ content = await readFile(marker, "utf8");
10135
+ } catch (error) {
10136
+ if (process.platform === "win32" && codeOf(error) === "EPERM") try {
10137
+ await lstat(marker);
10138
+ } catch (inspectionError) {
10139
+ if (codeOf(inspectionError) === "ENOENT") throw inspectionError;
10140
+ }
10141
+ throw error;
10142
+ }
10143
+ const record = JSON.parse(content);
10133
10144
  if (record === null || record.version !== 1 || record.ownerId !== match[1] || !Number.isSafeInteger(record.pid) || record.pid <= 0 || record.hostname !== hostname()) throw unavailable();
10134
10145
  return {
10135
10146
  name,
@@ -10327,13 +10338,29 @@ function isRecord$9(value) {
10327
10338
  }
10328
10339
  //#endregion
10329
10340
  //#region ../../packages/oauth/src/windows-command-worker.ts
10341
+ function prepareWindowsCommand(executable, args, platform = process.platform) {
10342
+ const target = args[0];
10343
+ if (platform !== "win32" || win32.basename(executable).toLowerCase() !== "icacls.exe" || !target || !win32.isAbsolute(target) || !win32.basename(target)) return { args };
10344
+ const save = args.length === 4 && args[1] === "/save" && args[3] === "/Q" && !!args[2] && win32.isAbsolute(args[2]);
10345
+ const repair = [
10346
+ "/inheritance:r",
10347
+ "/grant:r",
10348
+ "/remove",
10349
+ "/remove:d"
10350
+ ].includes(args[1] ?? "") && args.at(-1) === "/Q";
10351
+ if (!save && !repair) return { args };
10352
+ return {
10353
+ args: [win32.basename(target), ...args.slice(1)],
10354
+ cwd: win32.dirname(target)
10355
+ };
10356
+ }
10330
10357
  const SOURCE = `
10331
10358
  const { parentPort } = require('node:worker_threads');
10332
10359
  const { execFileSync } = require('node:child_process');
10333
- parentPort.on('message', ({ id, executable, args }) => {
10360
+ parentPort.on('message', ({ id, executable, args, cwd }) => {
10334
10361
  try {
10335
10362
  const stdout = execFileSync(executable, args, {
10336
- encoding: 'utf8', shell: false, windowsHide: true,
10363
+ encoding: 'utf8', shell: false, windowsHide: true, cwd,
10337
10364
  stdio: ['ignore', 'pipe', 'pipe'],
10338
10365
  });
10339
10366
  parentPort.postMessage({ id, stdout });
@@ -10399,7 +10426,7 @@ function runWindowsCommand(executable, args) {
10399
10426
  state.worker.postMessage({
10400
10427
  id,
10401
10428
  executable,
10402
- args: [...args]
10429
+ ...prepareWindowsCommand(executable, [...args])
10403
10430
  });
10404
10431
  } catch (error) {
10405
10432
  state.pending.delete(id);
@@ -10632,7 +10659,7 @@ var AsyncWindowsPrivateAcl = class {
10632
10659
  return this.userSid;
10633
10660
  }
10634
10661
  async save(target) {
10635
- const file = join(tmpdir(), `blun-private-acl-${process.pid}-${randomBytes(16).toString("hex")}.txt`);
10662
+ const file = join(tmpdir(), `${randomBytes(16).toString("hex")}.txt`);
10636
10663
  try {
10637
10664
  await this.run("icacls.exe", [
10638
10665
  target,
@@ -10763,7 +10790,7 @@ var WindowsPrivateAcl = class {
10763
10790
  return this.userSid;
10764
10791
  }
10765
10792
  transferPath() {
10766
- return join(tmpdir(), `blun-private-acl-${process.pid}-${randomBytes(16).toString("hex")}.txt`);
10793
+ return join(tmpdir(), `${randomBytes(16).toString("hex")}.txt`);
10767
10794
  }
10768
10795
  removeTransferFile(file) {
10769
10796
  try {
@@ -16368,8 +16395,19 @@ async function mutateConfigFile(filePath, transform) {
16368
16395
  try {
16369
16396
  await writer.assertOwned();
16370
16397
  const { config, result } = transform(readConfigFileForUpdate(canonical));
16371
- await writer.assertOwned();
16372
- await writeConfigFile(canonical, config);
16398
+ for (let attempt = 0;; attempt += 1) {
16399
+ await writer.assertOwned();
16400
+ try {
16401
+ await writeConfigFile(canonical, config);
16402
+ break;
16403
+ } catch (error) {
16404
+ const failure = error;
16405
+ if (process.platform !== "win32" || attempt >= 9 || failure?.code !== "EPERM" || failure.syscall !== "rename" || typeof failure.dest !== "string" || resolve(failure.dest) !== canonical) throw error;
16406
+ await new Promise((resolve) => {
16407
+ setTimeout(resolve, 25);
16408
+ });
16409
+ }
16410
+ }
16373
16411
  return result;
16374
16412
  } finally {
16375
16413
  await writer.release();