@agentconnect.md/cli 1.17.0 → 1.18.0-rc.10

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import fs, { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
3
+ import fs, { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
4
4
  import path, { basename, dirname, join, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { EventEmitter } from "node:events";
@@ -8113,11 +8113,19 @@ const IntegrationDiscordConfig = object({
8113
8113
  * signing secret). `appId` is a semi-public identifier (`cli_…`); `appSecret` is
8114
8114
  * plaintext secret material — NEVER log it. `botOpenId` is the bot's own open_id
8115
8115
  * for @-mention routing; lazily resolved by the daemon via `bot/info` if absent.
8116
+ *
8117
+ * `region` selects the open-platform gateway the daemon SDK (and CP verifier)
8118
+ * talk to — `'feishu'` = mainland China (`open.feishu.cn`, the SDK default) vs
8119
+ * `'lark'` = international (`open.larksuite.com`). Same app model, different host;
8120
+ * an app is registered in exactly one region. Defaults to `'feishu'` so existing
8121
+ * installs are unaffected.
8116
8122
  */
8123
+ const FeishuRegion = _enum(["feishu", "lark"]);
8117
8124
  const IntegrationFeishuConfig = object({
8118
8125
  appId: string(),
8119
8126
  appSecret: string(),
8120
8127
  botOpenId: string().optional(),
8128
+ region: FeishuRegion.default("feishu"),
8121
8129
  allowedUserIds: array(string()).default([]),
8122
8130
  bindRules: array(IntegrationBindRule).default([])
8123
8131
  });
@@ -8625,6 +8633,10 @@ const RegisterReq = object({
8625
8633
  integrations: array(object({
8626
8634
  integrationId: string(),
8627
8635
  origin: _enum(["cp", "unknown"])
8636
+ })).default([]),
8637
+ stagedAgents: array(object({
8638
+ agentId: string(),
8639
+ moveId: string().uuid().optional()
8628
8640
  })).default([])
8629
8641
  })
8630
8642
  });
@@ -14803,10 +14815,31 @@ function assertValidControlPlane(raw) {
14803
14815
  if (typeof cp.key !== "string" || cp.key.length === 0) throw new Error("invalid config: controlPlane.key must be a non-empty string");
14804
14816
  if (raw.daemonId !== void 0 && typeof raw.daemonId !== "string") throw new Error("invalid config: daemonId must be a string");
14805
14817
  }
14818
+ function protectCredentialsFile(file) {
14819
+ if (!existsSync(file)) return;
14820
+ try {
14821
+ if ((statSync(file).mode & 511) !== 384) chmodSync(file, 384);
14822
+ } catch (err) {
14823
+ if (process.platform !== "win32") throw err;
14824
+ }
14825
+ }
14826
+ function writeCredentialsFile(file, raw) {
14827
+ mkdirSync(dirname(file), {
14828
+ recursive: true,
14829
+ mode: 448
14830
+ });
14831
+ protectCredentialsFile(file);
14832
+ writeFileSync(file, JSON.stringify(raw, null, 2) + "\n", {
14833
+ encoding: "utf8",
14834
+ mode: 384
14835
+ });
14836
+ protectCredentialsFile(file);
14837
+ }
14806
14838
  /** Merge url/token into config.json (validated), returning the written path. */
14807
14839
  function persistCredentials(opts) {
14808
14840
  const root = resolveRoot(opts.root);
14809
14841
  const file = opts.configPath ?? configPath(root);
14842
+ protectCredentialsFile(file);
14810
14843
  const raw = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : { version: 1 };
14811
14844
  raw.controlPlane = {
14812
14845
  ...raw.controlPlane ?? {},
@@ -14816,8 +14849,7 @@ function persistCredentials(opts) {
14816
14849
  };
14817
14850
  if (opts.daemonId) raw.daemonId = opts.daemonId;
14818
14851
  assertValidControlPlane(raw);
14819
- mkdirSync(dirname(file), { recursive: true });
14820
- writeFileSync(file, JSON.stringify(raw, null, 2) + "\n");
14852
+ writeCredentialsFile(file, raw);
14821
14853
  return file;
14822
14854
  }
14823
14855
  /**