@slashfi/agents-sdk 0.40.1 → 0.41.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/adk-error.d.ts +35 -0
- package/dist/adk-error.d.ts.map +1 -0
- package/dist/adk-error.js +68 -0
- package/dist/adk-error.js.map +1 -0
- package/dist/adk-tools.d.ts +31 -0
- package/dist/adk-tools.d.ts.map +1 -0
- package/dist/adk-tools.js +140 -0
- package/dist/adk-tools.js.map +1 -0
- package/dist/adk.js +114 -9
- package/dist/adk.js.map +1 -1
- package/dist/call-agent-schema.d.ts +96 -96
- package/dist/cjs/adk-error.js +75 -0
- package/dist/cjs/adk-error.js.map +1 -0
- package/dist/cjs/adk-tools.js +143 -0
- package/dist/cjs/adk-tools.js.map +1 -0
- package/dist/cjs/config-store.js +149 -53
- package/dist/cjs/config-store.js.map +1 -1
- package/dist/cjs/define-config.js.map +1 -1
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/registry-consumer.js +1 -0
- package/dist/cjs/registry-consumer.js.map +1 -1
- package/dist/config-store.d.ts +46 -7
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +149 -53
- package/dist/config-store.js.map +1 -1
- package/dist/define-config.d.ts +17 -0
- package/dist/define-config.d.ts.map +1 -1
- package/dist/define-config.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/registry-consumer.d.ts +2 -0
- package/dist/registry-consumer.d.ts.map +1 -1
- package/dist/registry-consumer.js +1 -0
- package/dist/registry-consumer.js.map +1 -1
- package/package.json +1 -1
- package/src/adk-error.ts +80 -0
- package/src/adk-tools.ts +156 -0
- package/src/adk.ts +104 -7
- package/src/config-store.ts +216 -59
- package/src/define-config.ts +23 -0
- package/src/index.ts +8 -0
- package/src/registry-consumer.ts +4 -0
package/src/adk-tools.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADK Tools — expose an Adk instance as MCP ToolDefinitions.
|
|
3
|
+
*
|
|
4
|
+
* Used by atlas-environments (@config agent) and atlas-runtime
|
|
5
|
+
* to register adk ref/registry operations as MCP tools.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Standalone — no scopes
|
|
10
|
+
* const tools = createAdkTools({ resolveScope: () => adk });
|
|
11
|
+
*
|
|
12
|
+
* // Atlas — user/tenant scopes
|
|
13
|
+
* const tools = createAdkTools({
|
|
14
|
+
* resolveScope: (scope) => scope === 'tenant' ? tenantAdk : userAdk,
|
|
15
|
+
* scopes: ['user', 'tenant'],
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { defineTool } from "./define.js";
|
|
21
|
+
import type { ToolDefinition, ToolContext } from "./types.js";
|
|
22
|
+
import type { Adk } from "./config-store.js";
|
|
23
|
+
import type { RefEntry, RegistryEntry } from "./define-config.js";
|
|
24
|
+
|
|
25
|
+
export interface CreateAdkToolsOptions<TCtx extends ToolContext = ToolContext> {
|
|
26
|
+
/**
|
|
27
|
+
* Resolve an Adk instance from the scope string and tool context.
|
|
28
|
+
* Called per-operation. TCtx is your environment's context type.
|
|
29
|
+
*/
|
|
30
|
+
resolveScope: (scope: string | undefined, ctx: TCtx) => Adk | Promise<Adk>;
|
|
31
|
+
/** Allowed scope values. If set, added as enum to the JSON schema. */
|
|
32
|
+
scopes?: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createAdkTools<TCtx extends ToolContext = ToolContext>(opts: CreateAdkToolsOptions<TCtx>): ToolDefinition<TCtx>[] {
|
|
36
|
+
const { resolveScope, scopes } = opts;
|
|
37
|
+
|
|
38
|
+
const scopeSchema = scopes
|
|
39
|
+
? { type: "string" as const, enum: scopes, description: "Config scope to operate on" }
|
|
40
|
+
: { type: "string" as const, description: "Config scope (optional)" };
|
|
41
|
+
|
|
42
|
+
const refTool = defineTool({
|
|
43
|
+
name: "ref",
|
|
44
|
+
description:
|
|
45
|
+
"Manage agent refs. Operations: add, remove, list, get, update, inspect, call, auth, auth-status, resources, read.",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object" as const,
|
|
48
|
+
properties: {
|
|
49
|
+
operation: {
|
|
50
|
+
type: "string",
|
|
51
|
+
enum: ["add", "remove", "list", "get", "update", "inspect", "call", "auth", "auth-status", "resources", "read"],
|
|
52
|
+
},
|
|
53
|
+
scope: scopeSchema,
|
|
54
|
+
ref: { type: "string" },
|
|
55
|
+
name: { type: "string" },
|
|
56
|
+
scheme: { type: "string" },
|
|
57
|
+
url: { type: "string" },
|
|
58
|
+
as: { type: "string" },
|
|
59
|
+
sourceRegistry: { type: "object", properties: { url: { type: "string" }, agentPath: { type: "string" } } },
|
|
60
|
+
config: { type: "object" },
|
|
61
|
+
tool: { type: "string" },
|
|
62
|
+
params: { type: "object" },
|
|
63
|
+
full: { type: "boolean" },
|
|
64
|
+
uris: { type: "array", items: { type: "string" } },
|
|
65
|
+
apiKey: { type: "string" },
|
|
66
|
+
},
|
|
67
|
+
required: ["operation"],
|
|
68
|
+
},
|
|
69
|
+
execute: async (input: Record<string, unknown>, ctx) => {
|
|
70
|
+
const adk = await resolveScope(input.scope as string | undefined, ctx as TCtx);
|
|
71
|
+
const op = input.operation as string;
|
|
72
|
+
|
|
73
|
+
switch (op) {
|
|
74
|
+
case "add": {
|
|
75
|
+
const entry: Record<string, unknown> = { ref: input.ref };
|
|
76
|
+
if (input.scheme) entry.scheme = input.scheme;
|
|
77
|
+
if (input.url) entry.url = input.url;
|
|
78
|
+
if (input.as) entry.as = input.as;
|
|
79
|
+
if (input.sourceRegistry) entry.sourceRegistry = input.sourceRegistry;
|
|
80
|
+
if (input.config) entry.config = input.config;
|
|
81
|
+
return adk.ref.add(entry as unknown as RefEntry);
|
|
82
|
+
}
|
|
83
|
+
case "remove":
|
|
84
|
+
return { removed: await adk.ref.remove(input.name as string) };
|
|
85
|
+
case "list":
|
|
86
|
+
return { refs: await adk.ref.list() };
|
|
87
|
+
case "get":
|
|
88
|
+
return await adk.ref.get(input.name as string);
|
|
89
|
+
case "update":
|
|
90
|
+
return { updated: await adk.ref.update(input.name as string, input as unknown as Partial<RefEntry>) };
|
|
91
|
+
case "inspect":
|
|
92
|
+
return await adk.ref.inspect(input.name as string, { full: input.full as boolean });
|
|
93
|
+
case "call":
|
|
94
|
+
return await adk.ref.call(input.name as string, input.tool as string, input.params as Record<string, unknown>);
|
|
95
|
+
case "auth":
|
|
96
|
+
return await adk.ref.auth(input.name as string, { apiKey: input.apiKey as string });
|
|
97
|
+
case "auth-status":
|
|
98
|
+
return await adk.ref.authStatus(input.name as string);
|
|
99
|
+
case "resources":
|
|
100
|
+
return await adk.ref.resources(input.name as string);
|
|
101
|
+
case "read":
|
|
102
|
+
return await adk.ref.read(input.name as string, input.uris as string[]);
|
|
103
|
+
default:
|
|
104
|
+
throw new Error(`Unknown ref operation: ${op}`);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
}) as ToolDefinition<TCtx>;
|
|
108
|
+
|
|
109
|
+
const registryTool = defineTool({
|
|
110
|
+
name: "registry",
|
|
111
|
+
description:
|
|
112
|
+
"Manage registry connections. Operations: add, remove, list, browse, inspect, test.",
|
|
113
|
+
inputSchema: {
|
|
114
|
+
type: "object" as const,
|
|
115
|
+
properties: {
|
|
116
|
+
operation: {
|
|
117
|
+
type: "string",
|
|
118
|
+
enum: ["add", "remove", "list", "browse", "inspect", "test"],
|
|
119
|
+
},
|
|
120
|
+
scope: scopeSchema,
|
|
121
|
+
url: { type: "string" },
|
|
122
|
+
name: { type: "string" },
|
|
123
|
+
query: { type: "string" },
|
|
124
|
+
auth: { type: "object" },
|
|
125
|
+
},
|
|
126
|
+
required: ["operation"],
|
|
127
|
+
},
|
|
128
|
+
execute: async (input: Record<string, unknown>, ctx) => {
|
|
129
|
+
const adk = await resolveScope(input.scope as string | undefined, ctx as TCtx);
|
|
130
|
+
const op = input.operation as string;
|
|
131
|
+
|
|
132
|
+
switch (op) {
|
|
133
|
+
case "add": {
|
|
134
|
+
const entry: Record<string, unknown> = { url: input.url, name: input.name };
|
|
135
|
+
if (input.auth) entry.auth = input.auth;
|
|
136
|
+
await adk.registry.add(entry as unknown as RegistryEntry);
|
|
137
|
+
return { added: true, name: input.name, url: input.url };
|
|
138
|
+
}
|
|
139
|
+
case "remove":
|
|
140
|
+
return { removed: await adk.registry.remove(input.name as string) };
|
|
141
|
+
case "list":
|
|
142
|
+
return { registries: await adk.registry.list() };
|
|
143
|
+
case "browse":
|
|
144
|
+
return { agents: await adk.registry.browse(input.name as string, input.query as string) };
|
|
145
|
+
case "inspect":
|
|
146
|
+
return await adk.registry.inspect(input.name as string);
|
|
147
|
+
case "test":
|
|
148
|
+
return { results: await adk.registry.test(input.name as string) };
|
|
149
|
+
default:
|
|
150
|
+
throw new Error(`Unknown registry operation: ${op}`);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return [refTool, registryTool as unknown as ToolDefinition<TCtx>];
|
|
156
|
+
}
|
package/src/adk.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { pack, publish } from "./pack.js";
|
|
|
30
30
|
import { createAdk } from "./config-store.js";
|
|
31
31
|
import { createLocalFsStore, getLocalEncryptionKey } from "./local-fs.js";
|
|
32
32
|
import type { Adk } from "./config-store.js";
|
|
33
|
+
import { AdkError, getError, getRecentErrors } from "./adk-error.js";
|
|
33
34
|
|
|
34
35
|
const args = process.argv.slice(2);
|
|
35
36
|
const command = args[0];
|
|
@@ -78,6 +79,7 @@ function printUsage() {
|
|
|
78
79
|
adk — Agent Development Kit
|
|
79
80
|
|
|
80
81
|
Usage:
|
|
82
|
+
adk proxy <op> [options] Manage remote adk proxies
|
|
81
83
|
adk registry <op> [options] Manage registry connections
|
|
82
84
|
adk ref <op> [options] Manage agent refs
|
|
83
85
|
adk codegen [options] Generate agent from MCP server
|
|
@@ -87,6 +89,11 @@ Usage:
|
|
|
87
89
|
adk use <agent> [options] Execute a tool on a generated agent
|
|
88
90
|
adk list List all generated agents
|
|
89
91
|
|
|
92
|
+
Proxy operations:
|
|
93
|
+
adk proxy add <url> --name <name> [--type mcp|registry] [--agent @config] [--default]
|
|
94
|
+
adk proxy remove <name>
|
|
95
|
+
adk proxy list
|
|
96
|
+
|
|
90
97
|
Registry operations:
|
|
91
98
|
adk registry add <url> --name <name> [--auth-type bearer|api-key|none]
|
|
92
99
|
adk registry remove <name>
|
|
@@ -368,6 +375,59 @@ function runList() {
|
|
|
368
375
|
// Registry CLI
|
|
369
376
|
// ============================================
|
|
370
377
|
|
|
378
|
+
// ============================================
|
|
379
|
+
// Proxy CLI
|
|
380
|
+
// ============================================
|
|
381
|
+
|
|
382
|
+
async function runProxy() {
|
|
383
|
+
const op = args[1];
|
|
384
|
+
const adk = getAdk();
|
|
385
|
+
|
|
386
|
+
switch (op) {
|
|
387
|
+
case "add": {
|
|
388
|
+
const url = args[2];
|
|
389
|
+
const name = getArg("--name");
|
|
390
|
+
if (!url || !name) { console.error("Usage: adk proxy add <url> --name <name> [--type mcp|registry] [--agent @config] [--default]"); process.exit(1); }
|
|
391
|
+
const type = (getArg("--type") ?? (url.startsWith("http") ? "mcp" : "registry")) as "mcp" | "registry";
|
|
392
|
+
const agent = getArg("--agent");
|
|
393
|
+
const isDefault = hasFlag("--default");
|
|
394
|
+
await adk.proxy.add({ name, url, type, ...(agent && { agent }), ...(isDefault && { default: true }) });
|
|
395
|
+
console.log(`Added proxy: ${name} → ${url}${isDefault ? " (default)" : ""}`);
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
case "remove": {
|
|
399
|
+
const name = args[2];
|
|
400
|
+
if (!name) { console.error("Usage: adk proxy remove <name>"); process.exit(1); }
|
|
401
|
+
const removed = await adk.proxy.remove(name);
|
|
402
|
+
console.log(removed ? `Removed: ${name}` : `Not found: ${name}`);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case "list": {
|
|
406
|
+
const proxies = await adk.proxy.list();
|
|
407
|
+
if (proxies.length === 0) {
|
|
408
|
+
console.log("No proxies configured.");
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
console.log(`\n${proxies.length} proxy(s)\n`);
|
|
412
|
+
for (const p of proxies) {
|
|
413
|
+
const def = p.default ? " (default)" : "";
|
|
414
|
+
console.log(` ${p.name}${def}`);
|
|
415
|
+
console.log(` ${p.url} [${p.type}${p.agent ? ` → ${p.agent}` : ""}]`);
|
|
416
|
+
console.log();
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
default:
|
|
421
|
+
console.error(`Unknown proxy operation: ${op}`);
|
|
422
|
+
console.error("Operations: add, remove, list");
|
|
423
|
+
process.exit(1);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// ============================================
|
|
428
|
+
// Registry CLI
|
|
429
|
+
// ============================================
|
|
430
|
+
|
|
371
431
|
async function runRegistry() {
|
|
372
432
|
const op = args[1];
|
|
373
433
|
const adk = getAdk();
|
|
@@ -480,11 +540,19 @@ async function runRef() {
|
|
|
480
540
|
entry.sourceRegistry = { url: reg.url, agentPath: refArg };
|
|
481
541
|
}
|
|
482
542
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
543
|
+
try {
|
|
544
|
+
const { security } = await adk.ref.add(entry as import("./define-config.js").RefEntry);
|
|
545
|
+
console.log(`Added ref: ${alias ?? refArg}`);
|
|
546
|
+
if (security && security.type !== "none") {
|
|
547
|
+
console.log(`\n Auth required: ${security.type}`);
|
|
548
|
+
console.log(` Run: adk ref auth ${alias ?? refArg}`);
|
|
549
|
+
}
|
|
550
|
+
} catch (err) {
|
|
551
|
+
if (err instanceof AdkError) {
|
|
552
|
+
console.error(err.toAgentString());
|
|
553
|
+
process.exit(1);
|
|
554
|
+
}
|
|
555
|
+
throw err;
|
|
488
556
|
}
|
|
489
557
|
break;
|
|
490
558
|
}
|
|
@@ -561,8 +629,17 @@ async function runRef() {
|
|
|
561
629
|
console.log(`\n${icon} ${status.name}`);
|
|
562
630
|
console.log(` auth type: ${status.security?.type ?? "none"}`);
|
|
563
631
|
console.log(` complete: ${status.complete}`);
|
|
564
|
-
|
|
565
|
-
|
|
632
|
+
for (const [field, info] of Object.entries(status.fields)) {
|
|
633
|
+
const fieldIcon = info.present ? "\x1b[32m\u2713\x1b[0m"
|
|
634
|
+
: info.resolvable ? "\x1b[36m\u2192\x1b[0m"
|
|
635
|
+
: info.automated ? "\x1b[33m~\x1b[0m"
|
|
636
|
+
: "\x1b[31m\u2717\x1b[0m";
|
|
637
|
+
const source = info.present ? "stored"
|
|
638
|
+
: info.resolvable ? "resolvable"
|
|
639
|
+
: info.automated ? "automated"
|
|
640
|
+
: "missing";
|
|
641
|
+
console.log(` ${fieldIcon} ${field}: ${source}${info.required ? "" : " (optional)"}`);
|
|
642
|
+
}
|
|
566
643
|
console.log();
|
|
567
644
|
break;
|
|
568
645
|
}
|
|
@@ -622,6 +699,26 @@ async function runRef() {
|
|
|
622
699
|
// ============================================
|
|
623
700
|
|
|
624
701
|
switch (command) {
|
|
702
|
+
case "error": {
|
|
703
|
+
const errorId = args[1];
|
|
704
|
+
if (!errorId) {
|
|
705
|
+
const errors = getRecentErrors();
|
|
706
|
+
if (errors.length === 0) { console.log("No recent errors."); break; }
|
|
707
|
+
console.log(`\n${errors.length} recent error(s)\n`);
|
|
708
|
+
for (const e of errors.slice(-10)) {
|
|
709
|
+
console.log(` ${e.errorId} [${e.code}] ${e.message}`);
|
|
710
|
+
}
|
|
711
|
+
console.log();
|
|
712
|
+
} else {
|
|
713
|
+
const err = getError(errorId);
|
|
714
|
+
if (!err) { console.error(`Error not found: ${errorId}`); process.exit(1); }
|
|
715
|
+
console.log(err.toDebugString());
|
|
716
|
+
}
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
case "proxy":
|
|
720
|
+
await runProxy();
|
|
721
|
+
break;
|
|
625
722
|
case "registry":
|
|
626
723
|
await runRegistry();
|
|
627
724
|
break;
|