@agentvalet/register 0.1.7 → 0.1.9
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 +50 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -223,25 +223,20 @@ ${platformSections}
|
|
|
223
223
|
|
|
224
224
|
## How to call a platform
|
|
225
225
|
|
|
226
|
-
All platform calls **must** go through
|
|
226
|
+
All platform calls **must** go through the \`mcp__agent-authority__use_platform\` MCP tool.
|
|
227
227
|
|
|
228
|
-
|
|
228
|
+
**NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls. The MCP tool handles all authentication internally.
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
"method": "POST",
|
|
239
|
-
"scope": "<scope>",
|
|
240
|
-
"data": { ... }
|
|
241
|
-
}
|
|
230
|
+
\`\`\`
|
|
231
|
+
mcp__agent-authority__use_platform({
|
|
232
|
+
platform: "<platformId>",
|
|
233
|
+
endpoint: "<endpoint>",
|
|
234
|
+
method: "POST",
|
|
235
|
+
scope: "<scope>",
|
|
236
|
+
data: { ... }
|
|
237
|
+
})
|
|
242
238
|
\`\`\`
|
|
243
239
|
|
|
244
|
-
Run \`node test-agent.mjs\` for a live smoke-test.
|
|
245
240
|
To refresh this file: \`agentvalet-register refresh\`
|
|
246
241
|
`;
|
|
247
242
|
}
|
|
@@ -381,12 +376,48 @@ function ensureHook() {
|
|
|
381
376
|
}
|
|
382
377
|
const hooks = settings.hooks ?? {};
|
|
383
378
|
const ups = hooks.UserPromptSubmit ?? [];
|
|
384
|
-
const
|
|
379
|
+
const hookAlreadyWired = ups.some(
|
|
385
380
|
(entry) => entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER))
|
|
386
381
|
);
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
382
|
+
if (!hookAlreadyWired) {
|
|
383
|
+
const newEntry = { matcher: "", hooks: [{ type: "command", command: HOOK_COMMAND }] };
|
|
384
|
+
settings.hooks = { ...hooks, UserPromptSubmit: [...ups, newEntry] };
|
|
385
|
+
}
|
|
386
|
+
const mcpServers = settings.mcpServers ?? {};
|
|
387
|
+
if (!mcpServers["agent-authority"]) {
|
|
388
|
+
const envPath = resolve2(".env.agentvalet");
|
|
389
|
+
if (existsSync(envPath)) {
|
|
390
|
+
try {
|
|
391
|
+
const envVars = parseEnvFile(readFileSync(envPath, "utf-8"));
|
|
392
|
+
const agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
393
|
+
const ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
394
|
+
const apiUrl = envVars["AGENTVALET_API_URL"] ?? "https://api.agentvalet.ai";
|
|
395
|
+
const keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
396
|
+
if (agentId && ownerId && keyPath) {
|
|
397
|
+
mcpServers["agent-authority"] = {
|
|
398
|
+
command: "npx",
|
|
399
|
+
args: ["-y", "@agentvalet/mcp-server"],
|
|
400
|
+
env: {
|
|
401
|
+
AGENT_ID: agentId,
|
|
402
|
+
OWNER_ID: ownerId,
|
|
403
|
+
PROXY_URL: apiUrl,
|
|
404
|
+
AGENT_PRIVATE_KEY_PATH: keyPath
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
settings.mcpServers = mcpServers;
|
|
408
|
+
}
|
|
409
|
+
} catch {
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const perms = settings.permissions ?? {};
|
|
414
|
+
const allow = perms.allow ?? [];
|
|
415
|
+
const mcpAllows = ["mcp__agent-authority__list_platforms", "mcp__agent-authority__use_platform"];
|
|
416
|
+
const missing = mcpAllows.filter((e) => !allow.includes(e));
|
|
417
|
+
if (missing.length > 0) {
|
|
418
|
+
perms.allow = [...allow, ...missing];
|
|
419
|
+
settings.permissions = perms;
|
|
420
|
+
}
|
|
390
421
|
mkdirSync(dirname2(settingsPath), { recursive: true });
|
|
391
422
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
392
423
|
}
|