@agentvalet/register 0.1.6 → 0.1.7
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 +26 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -157,7 +157,9 @@ function parseEvent(data) {
|
|
|
157
157
|
if (data.status === "approved") {
|
|
158
158
|
const agentId = data.agent_id ?? data.agentId;
|
|
159
159
|
if (!agentId) return null;
|
|
160
|
-
|
|
160
|
+
const ownerId = data.owner_id ?? data.ownerId ?? "";
|
|
161
|
+
const grantedPlatforms = data.granted_platforms ?? [];
|
|
162
|
+
return { status: "approved", agentId, ownerId, privateKey: "", grantedPlatforms };
|
|
161
163
|
}
|
|
162
164
|
if (data.status === "rejected") return { status: "rejected" };
|
|
163
165
|
if (data.status === "timeout" || data.status === "expired") return { status: "expired" };
|
|
@@ -273,6 +275,14 @@ function parseEnvFile(content) {
|
|
|
273
275
|
}
|
|
274
276
|
return result;
|
|
275
277
|
}
|
|
278
|
+
function writePermissionsFromEvent(agentId, ownerId, platforms, outputPath = "./.claude/agentvalet-permissions.md") {
|
|
279
|
+
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
280
|
+
const resolvedPath = resolve2(outputPath);
|
|
281
|
+
mkdirSync(dirname2(resolvedPath), { recursive: true });
|
|
282
|
+
writeFileSync(resolvedPath, content, "utf-8");
|
|
283
|
+
embedInClaudeMd(content);
|
|
284
|
+
ensureHook();
|
|
285
|
+
}
|
|
276
286
|
async function runRefresh(options) {
|
|
277
287
|
const outputPath = resolve2(options.outputPath);
|
|
278
288
|
if (options.ifStale) {
|
|
@@ -481,13 +491,14 @@ Approve at: https://agentvalet.ai/registrations
|
|
|
481
491
|
}
|
|
482
492
|
process.exit(2);
|
|
483
493
|
}
|
|
484
|
-
const { agentId, privateKey } = result;
|
|
494
|
+
const { agentId, privateKey, grantedPlatforms } = result;
|
|
495
|
+
const resolvedOwnerId = result.ownerId || ownerId;
|
|
485
496
|
let keyPath;
|
|
486
497
|
let envPath;
|
|
487
498
|
try {
|
|
488
499
|
({ keyPath, envPath } = await saveOutput({
|
|
489
500
|
agentId,
|
|
490
|
-
ownerId,
|
|
501
|
+
ownerId: resolvedOwnerId,
|
|
491
502
|
privateKey: privateKey ?? "",
|
|
492
503
|
apiUrl: opts.apiUrl,
|
|
493
504
|
keyFilePath: opts.keyPath,
|
|
@@ -516,19 +527,20 @@ Source the env file before calling any tool:`);
|
|
|
516
527
|
}
|
|
517
528
|
if (keyWritten) {
|
|
518
529
|
try {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
530
|
+
if (grantedPlatforms && grantedPlatforms.length > 0) {
|
|
531
|
+
writePermissionsFromEvent(agentId, resolvedOwnerId, grantedPlatforms);
|
|
532
|
+
if (!isJson) console.log(chalk2.gray(`Permissions: .claude/agentvalet-permissions.md`));
|
|
533
|
+
} else {
|
|
534
|
+
await runRefresh({
|
|
535
|
+
envFile: opts.output,
|
|
536
|
+
outputPath: ".claude/agentvalet-permissions.md",
|
|
537
|
+
ifStale: false,
|
|
538
|
+
quiet: isJson
|
|
539
|
+
});
|
|
540
|
+
if (!isJson) console.log(chalk2.gray(`Permissions: .claude/agentvalet-permissions.md`));
|
|
527
541
|
}
|
|
528
542
|
} catch {
|
|
529
|
-
if (!isJson)
|
|
530
|
-
console.log(chalk2.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
|
|
531
|
-
}
|
|
543
|
+
if (!isJson) console.log(chalk2.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
|
|
532
544
|
}
|
|
533
545
|
}
|
|
534
546
|
process.exit(0);
|