agent-auth-broker 0.1.0 → 0.1.1
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 +53 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -33,12 +33,57 @@ function resolveConfigPath(configOption) {
|
|
|
33
33
|
if (parent === dir) break;
|
|
34
34
|
dir = parent;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
return getGlobalConfigPath();
|
|
37
|
+
}
|
|
38
|
+
function getDefaultConfigTemplate() {
|
|
39
|
+
return {
|
|
40
|
+
version: "1",
|
|
41
|
+
agents: [
|
|
42
|
+
{
|
|
43
|
+
id: "my-agent",
|
|
44
|
+
name: "My AI Agent"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
credentials: [
|
|
48
|
+
{
|
|
49
|
+
id: "github-main",
|
|
50
|
+
connector: "github",
|
|
51
|
+
token: "${GITHUB_TOKEN}"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
policies: [
|
|
55
|
+
{
|
|
56
|
+
agent: "my-agent",
|
|
57
|
+
credential: "github-main",
|
|
58
|
+
actions: ["*"]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
audit: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
output: "stdout"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
39
66
|
}
|
|
40
67
|
function ensureConfigExists(configPath) {
|
|
41
68
|
if (fs.existsSync(configPath)) return true;
|
|
69
|
+
const globalConfigPath = getGlobalConfigPath();
|
|
70
|
+
if (configPath === globalConfigPath) {
|
|
71
|
+
const globalDir = getGlobalConfigDir();
|
|
72
|
+
if (!fs.existsSync(globalDir)) {
|
|
73
|
+
fs.mkdirSync(globalDir, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
const template = getDefaultConfigTemplate();
|
|
76
|
+
const yaml = stringifyYaml(template, { lineWidth: 120 });
|
|
77
|
+
fs.writeFileSync(globalConfigPath, yaml, "utf-8");
|
|
78
|
+
logSuccess(`\u5DF2\u81EA\u52A8\u521B\u5EFA\u5168\u5C40\u914D\u7F6E\u6587\u4EF6: ${globalConfigPath}`);
|
|
79
|
+
console.log();
|
|
80
|
+
console.log("\u4E0B\u4E00\u6B65\uFF1A");
|
|
81
|
+
console.log(" 1. \u7F16\u8F91\u914D\u7F6E\u6587\u4EF6\u6DFB\u52A0\u4F60\u7684\u51ED\u8BC1\u548C\u7B56\u7565");
|
|
82
|
+
console.log(" 2. \u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF: export GITHUB_TOKEN=your_token");
|
|
83
|
+
console.log(" 3. \u9A8C\u8BC1\u914D\u7F6E: broker validate");
|
|
84
|
+
console.log();
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
42
87
|
logError(`\u627E\u4E0D\u5230\u914D\u7F6E\u6587\u4EF6: ${configPath}`);
|
|
43
88
|
console.log();
|
|
44
89
|
console.log("\u8BF7\u5148\u521D\u59CB\u5316\u914D\u7F6E\u6587\u4EF6:");
|
|
@@ -3226,6 +3271,10 @@ function readBody(req) {
|
|
|
3226
3271
|
// src/commands/ui.ts
|
|
3227
3272
|
var uiCommand = new Command8("ui").description("\u542F\u52A8 File Mode Web UI\uFF0C\u53EF\u89C6\u5316\u7BA1\u7406 broker.yaml").option("-c, --config <path>", "\u914D\u7F6E\u6587\u4EF6\u8DEF\u5F84", void 0).option("-p, --port <port>", "\u670D\u52A1\u7AEF\u53E3", "3200").action((opts) => {
|
|
3228
3273
|
const configPath = resolveConfigPath(opts.config);
|
|
3274
|
+
if (!ensureConfigExists(configPath)) {
|
|
3275
|
+
process.exitCode = 1;
|
|
3276
|
+
return;
|
|
3277
|
+
}
|
|
3229
3278
|
const port = parseInt(opts.port, 10);
|
|
3230
3279
|
if (isNaN(port) || port < 1 || port > 65535) {
|
|
3231
3280
|
console.error("Invalid port number");
|
|
@@ -3391,7 +3440,7 @@ var testCommand = new Command10("test").description("\u6D4B\u8BD5\u8C03\u7528 co
|
|
|
3391
3440
|
|
|
3392
3441
|
// src/index.ts
|
|
3393
3442
|
var program = new Command11();
|
|
3394
|
-
program.name("broker").description("Agent Auth Broker CLI \u2014 AI Agent \u51ED\u8BC1\u7BA1\u7406\u4E0E\u6388\u6743\u4EE3\u7406").version("0.1.
|
|
3443
|
+
program.name("broker").description("Agent Auth Broker CLI \u2014 AI Agent \u51ED\u8BC1\u7BA1\u7406\u4E0E\u6388\u6743\u4EE3\u7406").version("0.1.1");
|
|
3395
3444
|
program.addCommand(initCommand);
|
|
3396
3445
|
program.addCommand(validateCommand);
|
|
3397
3446
|
program.addCommand(diagnoseCommand);
|