@agentconnect.md/cli 1.17.1-rc.1 → 1.18.0-rc.12
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 +31 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
});
|
|
@@ -14807,10 +14815,31 @@ function assertValidControlPlane(raw) {
|
|
|
14807
14815
|
if (typeof cp.key !== "string" || cp.key.length === 0) throw new Error("invalid config: controlPlane.key must be a non-empty string");
|
|
14808
14816
|
if (raw.daemonId !== void 0 && typeof raw.daemonId !== "string") throw new Error("invalid config: daemonId must be a string");
|
|
14809
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
|
+
}
|
|
14810
14838
|
/** Merge url/token into config.json (validated), returning the written path. */
|
|
14811
14839
|
function persistCredentials(opts) {
|
|
14812
14840
|
const root = resolveRoot(opts.root);
|
|
14813
14841
|
const file = opts.configPath ?? configPath(root);
|
|
14842
|
+
protectCredentialsFile(file);
|
|
14814
14843
|
const raw = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : { version: 1 };
|
|
14815
14844
|
raw.controlPlane = {
|
|
14816
14845
|
...raw.controlPlane ?? {},
|
|
@@ -14820,8 +14849,7 @@ function persistCredentials(opts) {
|
|
|
14820
14849
|
};
|
|
14821
14850
|
if (opts.daemonId) raw.daemonId = opts.daemonId;
|
|
14822
14851
|
assertValidControlPlane(raw);
|
|
14823
|
-
|
|
14824
|
-
writeFileSync(file, JSON.stringify(raw, null, 2) + "\n");
|
|
14852
|
+
writeCredentialsFile(file, raw);
|
|
14825
14853
|
return file;
|
|
14826
14854
|
}
|
|
14827
14855
|
/**
|