@agent-dock/cli 0.3.18 → 0.3.19

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.js CHANGED
@@ -18016,10 +18016,18 @@ var AcpxAdapter = class {
18016
18016
 
18017
18017
  // ../../packages/transports/src/index.ts
18018
18018
  import { spawn as spawn5, spawnSync } from "node:child_process";
18019
+ import { accessSync as accessSync2, constants as constants3, statSync as statSync4 } from "node:fs";
18019
18020
  import readline2 from "node:readline";
18020
18021
  import * as pty from "node-pty";
18021
18022
  function commandExists(command) {
18022
- if (command.includes("/") || command.includes("\\")) return spawnSync("test", ["-x", command]).status === 0;
18023
+ if (command.includes("/") || command.includes("\\")) {
18024
+ try {
18025
+ accessSync2(command, constants3.X_OK);
18026
+ return statSync4(command).isFile();
18027
+ } catch {
18028
+ return false;
18029
+ }
18030
+ }
18023
18031
  return spawnSync(process.platform === "win32" ? "where" : "which", [command], { stdio: "ignore" }).status === 0;
18024
18032
  }
18025
18033
  function probeAgent(agent, acpxCommand = "acpx") {
@@ -19658,7 +19666,7 @@ import { fileURLToPath as fileURLToPath5 } from "node:url";
19658
19666
  init_src2();
19659
19667
  init_daemon();
19660
19668
  import { spawn as spawn7 } from "node:child_process";
19661
- import { closeSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync5, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync3 } from "node:fs";
19669
+ import { closeSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync5, rmSync as rmSync2, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
19662
19670
  import { homedir as homedir5 } from "node:os";
19663
19671
  import { dirname as dirname7, join as join8 } from "node:path";
19664
19672
 
@@ -19859,7 +19867,7 @@ var SelfUpdateService = class {
19859
19867
  */
19860
19868
  lockHeld() {
19861
19869
  try {
19862
- if (this.now() - statSync4(this.lockFile).mtimeMs > UPDATE_LOCK_MAX_AGE_MS) return false;
19870
+ if (this.now() - statSync5(this.lockFile).mtimeMs > UPDATE_LOCK_MAX_AGE_MS) return false;
19863
19871
  return pidAlive(Number(readFileSync5(this.lockFile, "utf8").trim()));
19864
19872
  } catch {
19865
19873
  return false;
@@ -19963,7 +19971,7 @@ init_listener();
19963
19971
  // src/lark/security-hooks.ts
19964
19972
  init_service();
19965
19973
  import { access as access2, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
19966
- import { constants as constants3 } from "node:fs";
19974
+ import { constants as constants4 } from "node:fs";
19967
19975
  import { dirname as dirname8, join as join10 } from "node:path";
19968
19976
  var guardVersion = "agentdock-high-risk-guard-v2";
19969
19977
  var quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
@@ -20087,7 +20095,7 @@ async function larkHookStatus(agentId, workspace) {
20087
20095
  const { hooksPath } = paths(adapter, workspace);
20088
20096
  let writable = true;
20089
20097
  try {
20090
- await access2(workspace, constants3.W_OK);
20098
+ await access2(workspace, constants4.W_OK);
20091
20099
  } catch {
20092
20100
  writable = false;
20093
20101
  }
@@ -25067,7 +25075,7 @@ init_side_chat_config();
25067
25075
 
25068
25076
  // src/json-compression.ts
25069
25077
  import { promisify as promisify6 } from "node:util";
25070
- import { brotliCompress, constants as constants4, gzip } from "node:zlib";
25078
+ import { brotliCompress, constants as constants5, gzip } from "node:zlib";
25071
25079
  var brotli = promisify6(brotliCompress);
25072
25080
  var gzipAsync = promisify6(gzip);
25073
25081
  var JSON_COMPRESSION_THRESHOLD = 32 * 1024;
@@ -25093,7 +25101,7 @@ function registerJsonCompression(app, threshold = JSON_COMPRESSION_THRESHOLD) {
25093
25101
  if (size < threshold) return payload;
25094
25102
  const encoding = pickJsonEncoding(request.headers["accept-encoding"]);
25095
25103
  if (!encoding) return payload;
25096
- const body = encoding === "br" ? await brotli(payload, { params: { [constants4.BROTLI_PARAM_MODE]: constants4.BROTLI_MODE_TEXT, [constants4.BROTLI_PARAM_QUALITY]: 4, [constants4.BROTLI_PARAM_SIZE_HINT]: size } }) : await gzipAsync(payload, { level: 6 });
25104
+ const body = encoding === "br" ? await brotli(payload, { params: { [constants5.BROTLI_PARAM_MODE]: constants5.BROTLI_MODE_TEXT, [constants5.BROTLI_PARAM_QUALITY]: 4, [constants5.BROTLI_PARAM_SIZE_HINT]: size } }) : await gzipAsync(payload, { level: 6 });
25097
25105
  reply.header("content-encoding", encoding);
25098
25106
  const vary = String(reply.getHeader("vary") ?? "");
25099
25107
  if (!/(^|,)\s*accept-encoding\s*(,|$)/i.test(vary)) reply.header("vary", vary ? `${vary}, Accept-Encoding` : "Accept-Encoding");
@@ -32364,7 +32372,7 @@ function withContext(percent2) {
32364
32372
 
32365
32373
  // src/assistant/cwd.ts
32366
32374
  init_src2();
32367
- import { accessSync as accessSync2, constants as constants5, statSync as statSync5 } from "node:fs";
32375
+ import { accessSync as accessSync3, constants as constants6, statSync as statSync6 } from "node:fs";
32368
32376
  import { homedir as homedir16 } from "node:os";
32369
32377
  import { isAbsolute as isAbsolute8, resolve as resolve11 } from "node:path";
32370
32378
  function expandHomePath(value) {
@@ -32386,7 +32394,7 @@ function validateCwd(value) {
32386
32394
  const absolute = resolve11(expanded);
32387
32395
  let stats;
32388
32396
  try {
32389
- stats = statSync5(absolute);
32397
+ stats = statSync6(absolute);
32390
32398
  } catch {
32391
32399
  throw new RuntimeError("INVALID_TASK_CWD", `\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${absolute}`, 400);
32392
32400
  }
@@ -32394,7 +32402,7 @@ function validateCwd(value) {
32394
32402
  throw new RuntimeError("INVALID_TASK_CWD", `\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u662F\u6587\u4EF6\u5939\uFF1A${absolute}`, 400);
32395
32403
  }
32396
32404
  try {
32397
- accessSync2(absolute, constants5.R_OK | constants5.X_OK);
32405
+ accessSync3(absolute, constants6.R_OK | constants6.X_OK);
32398
32406
  } catch {
32399
32407
  throw new RuntimeError("INVALID_TASK_CWD", `\u5DE5\u4F5C\u76EE\u5F55\u4E0D\u53EF\u8BBF\u95EE\uFF08\u9700\u8981\u8BFB\u548C\u6267\u884C\u6743\u9650\uFF09\uFF1A${absolute}`, 400);
32400
32408
  }
@@ -34900,16 +34908,27 @@ function sandboxEnv(sandbox, base = process.env) {
34900
34908
  AGENTDOCK_ALLOW_REACTION_TEST: "true",
34901
34909
  agentdock_database: sandbox.database
34902
34910
  };
34903
- env.PATH = [shimDir(sandbox), base.PATH].filter(Boolean).join(delimiter2);
34911
+ const pathKey = process.platform === "win32" ? Object.keys(base).find((key) => key.toUpperCase() === "PATH") ?? "PATH" : "PATH";
34912
+ env[pathKey] = [shimDir(sandbox), base[pathKey]].filter(Boolean).join(delimiter2);
34904
34913
  for (const key of ["agentdock_session_id", "agentdock_group_tools_url", "agentdock_group_tools_token"]) delete env[key];
34905
34914
  for (const key of [DAEMON_ENV_FLAG, DAEMON_CWD_ENV, DAEMON_STARTED_AT_ENV, DAEMON_DIR_ENV]) delete env[key];
34906
34915
  return env;
34907
34916
  }
34908
34917
  var shellQuote5 = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
34909
34918
  function writeCliShim(sandbox, node = process.execPath) {
34910
- if (process.platform === "win32") return;
34911
34919
  const dir = shimDir(sandbox);
34912
34920
  mkdirSync6(dir, { recursive: true });
34921
+ if (process.platform === "win32") {
34922
+ const quote2 = (path5) => `"${path5.replace(/%/g, "%%")}"`;
34923
+ writeFileSync5(
34924
+ join23(dir, "agent-dock.cmd"),
34925
+ `@echo off\r
34926
+ setlocal DisableDelayedExpansion\r
34927
+ ${quote2(node)} ${quote2(sandbox.entrypoint)} %*\r
34928
+ `
34929
+ );
34930
+ return;
34931
+ }
34913
34932
  const file = join23(dir, "agent-dock");
34914
34933
  writeFileSync5(file, `#!/bin/sh
34915
34934
  exec ${shellQuote5(node)} ${shellQuote5(sandbox.entrypoint)} "$@"