@agentvalet/register 0.1.6 → 0.1.8
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 +36 -29
- 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" };
|
|
@@ -221,25 +223,20 @@ ${platformSections}
|
|
|
221
223
|
|
|
222
224
|
## How to call a platform
|
|
223
225
|
|
|
224
|
-
All platform calls **must** go through
|
|
226
|
+
All platform calls **must** go through the \`mcp__agent-authority__use_platform\` MCP tool.
|
|
225
227
|
|
|
226
|
-
|
|
228
|
+
**NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls. The MCP tool handles all authentication internally.
|
|
227
229
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
"method": "POST",
|
|
237
|
-
"scope": "<scope>",
|
|
238
|
-
"data": { ... }
|
|
239
|
-
}
|
|
230
|
+
\`\`\`
|
|
231
|
+
mcp__agent-authority__use_platform({
|
|
232
|
+
platform: "<platformId>",
|
|
233
|
+
endpoint: "<endpoint>",
|
|
234
|
+
method: "POST",
|
|
235
|
+
scope: "<scope>",
|
|
236
|
+
data: { ... }
|
|
237
|
+
})
|
|
240
238
|
\`\`\`
|
|
241
239
|
|
|
242
|
-
Run \`node test-agent.mjs\` for a live smoke-test.
|
|
243
240
|
To refresh this file: \`agentvalet-register refresh\`
|
|
244
241
|
`;
|
|
245
242
|
}
|
|
@@ -273,6 +270,14 @@ function parseEnvFile(content) {
|
|
|
273
270
|
}
|
|
274
271
|
return result;
|
|
275
272
|
}
|
|
273
|
+
function writePermissionsFromEvent(agentId, ownerId, platforms, outputPath = "./.claude/agentvalet-permissions.md") {
|
|
274
|
+
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
275
|
+
const resolvedPath = resolve2(outputPath);
|
|
276
|
+
mkdirSync(dirname2(resolvedPath), { recursive: true });
|
|
277
|
+
writeFileSync(resolvedPath, content, "utf-8");
|
|
278
|
+
embedInClaudeMd(content);
|
|
279
|
+
ensureHook();
|
|
280
|
+
}
|
|
276
281
|
async function runRefresh(options) {
|
|
277
282
|
const outputPath = resolve2(options.outputPath);
|
|
278
283
|
if (options.ifStale) {
|
|
@@ -481,13 +486,14 @@ Approve at: https://agentvalet.ai/registrations
|
|
|
481
486
|
}
|
|
482
487
|
process.exit(2);
|
|
483
488
|
}
|
|
484
|
-
const { agentId, privateKey } = result;
|
|
489
|
+
const { agentId, privateKey, grantedPlatforms } = result;
|
|
490
|
+
const resolvedOwnerId = result.ownerId || ownerId;
|
|
485
491
|
let keyPath;
|
|
486
492
|
let envPath;
|
|
487
493
|
try {
|
|
488
494
|
({ keyPath, envPath } = await saveOutput({
|
|
489
495
|
agentId,
|
|
490
|
-
ownerId,
|
|
496
|
+
ownerId: resolvedOwnerId,
|
|
491
497
|
privateKey: privateKey ?? "",
|
|
492
498
|
apiUrl: opts.apiUrl,
|
|
493
499
|
keyFilePath: opts.keyPath,
|
|
@@ -516,19 +522,20 @@ Source the env file before calling any tool:`);
|
|
|
516
522
|
}
|
|
517
523
|
if (keyWritten) {
|
|
518
524
|
try {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
525
|
+
if (grantedPlatforms && grantedPlatforms.length > 0) {
|
|
526
|
+
writePermissionsFromEvent(agentId, resolvedOwnerId, grantedPlatforms);
|
|
527
|
+
if (!isJson) console.log(chalk2.gray(`Permissions: .claude/agentvalet-permissions.md`));
|
|
528
|
+
} else {
|
|
529
|
+
await runRefresh({
|
|
530
|
+
envFile: opts.output,
|
|
531
|
+
outputPath: ".claude/agentvalet-permissions.md",
|
|
532
|
+
ifStale: false,
|
|
533
|
+
quiet: isJson
|
|
534
|
+
});
|
|
535
|
+
if (!isJson) console.log(chalk2.gray(`Permissions: .claude/agentvalet-permissions.md`));
|
|
527
536
|
}
|
|
528
537
|
} catch {
|
|
529
|
-
if (!isJson)
|
|
530
|
-
console.log(chalk2.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
|
|
531
|
-
}
|
|
538
|
+
if (!isJson) console.log(chalk2.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
|
|
532
539
|
}
|
|
533
540
|
}
|
|
534
541
|
process.exit(0);
|