@slashfi/agents-sdk 0.81.0 → 0.83.0
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.js +3 -28
- package/dist/adk.js.map +1 -1
- package/dist/cjs/config-store.js +6 -205
- package/dist/cjs/config-store.js.map +1 -1
- package/dist/cjs/define-config.js.map +1 -1
- package/dist/cjs/materialize.js +34 -13
- package/dist/cjs/materialize.js.map +1 -1
- package/dist/cjs/registry-consumer.js +0 -8
- package/dist/cjs/registry-consumer.js.map +1 -1
- package/dist/cjs/server.js +0 -8
- package/dist/cjs/server.js.map +1 -1
- package/dist/config-store.d.ts +0 -14
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +6 -205
- package/dist/config-store.js.map +1 -1
- package/dist/define-config.d.ts +0 -29
- package/dist/define-config.d.ts.map +1 -1
- package/dist/define-config.js.map +1 -1
- package/dist/materialize.d.ts.map +1 -1
- package/dist/materialize.js +34 -13
- package/dist/materialize.js.map +1 -1
- package/dist/registry-consumer.d.ts +0 -10
- package/dist/registry-consumer.d.ts.map +1 -1
- package/dist/registry-consumer.js +0 -8
- package/dist/registry-consumer.js.map +1 -1
- package/dist/server.d.ts +0 -11
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +0 -8
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/src/adk.ts +3 -31
- package/src/config-store.test.ts +0 -185
- package/src/config-store.ts +6 -254
- package/src/define-config.ts +0 -31
- package/src/materialize.ts +37 -13
- package/src/registry-consumer.ts +0 -27
- package/src/server.ts +0 -19
package/src/materialize.ts
CHANGED
|
@@ -57,11 +57,24 @@ function ensureWrite(path: string, content: string): void {
|
|
|
57
57
|
writeFileSync(path, content, "utf-8");
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Sanitize a tool name for use as a filename — strictly conservative.
|
|
62
|
+
* Replaces only characters that would break filesystems (`/`, `\`, NUL)
|
|
63
|
+
* with `_`. Camel case, dashes, underscores, dots, and the actual tool
|
|
64
|
+
* name are preserved verbatim so:
|
|
65
|
+
*
|
|
66
|
+
* - `find ~/.adk/refs/<ref>/tools` shows the canonical tool names
|
|
67
|
+
* (e.g. `listMessages.tool.md`, not `listmessages.tool.md`).
|
|
68
|
+
* - Agents copying a slug from the filename can paste it into
|
|
69
|
+
* `adk ref call <ref> <tool>` without round-tripping through a
|
|
70
|
+
* case-folding step.
|
|
71
|
+
*
|
|
72
|
+
* Registries already mint tool names that are valid identifiers
|
|
73
|
+
* (camelCase, snake_case, kebab-case), so this rarely substitutes
|
|
74
|
+
* anything in practice — it's a safety net for malformed names.
|
|
75
|
+
*/
|
|
76
|
+
function toFilenameSlug(name: string): string {
|
|
77
|
+
return name.replace(/[/\\\0]/g, "_");
|
|
65
78
|
}
|
|
66
79
|
|
|
67
80
|
function pascalCase(s: string): string {
|
|
@@ -257,9 +270,12 @@ export async function materializeRef(
|
|
|
257
270
|
|
|
258
271
|
// Write .tool.md files (primary output — readable by LLMs)
|
|
259
272
|
for (const tool of tools) {
|
|
260
|
-
const
|
|
261
|
-
ensureWrite(join(toolsDir, `${
|
|
262
|
-
ensureWrite(
|
|
273
|
+
const slug = toFilenameSlug(tool.name);
|
|
274
|
+
ensureWrite(join(toolsDir, `${slug}.tool.md`), generateToolMd(tool));
|
|
275
|
+
ensureWrite(
|
|
276
|
+
join(toolsDir, `${slug}.tool.json`),
|
|
277
|
+
JSON.stringify(tool, null, 2),
|
|
278
|
+
);
|
|
263
279
|
}
|
|
264
280
|
toolCount = tools.length;
|
|
265
281
|
|
|
@@ -294,10 +310,9 @@ export async function materializeRef(
|
|
|
294
310
|
// to actually fetch the body. Then the per-resource field is `content`,
|
|
295
311
|
// not `text` (per `CallAgentReadResourcesResponse`).
|
|
296
312
|
//
|
|
297
|
-
//
|
|
298
|
-
// `{success,
|
|
299
|
-
//
|
|
300
|
-
// the inner registry response). Unwrap both shapes the same way.
|
|
313
|
+
// The unwrap below tolerates both `{success, resources}` (direct) and
|
|
314
|
+
// `{success, result: {resources}}` (registries that wrap responses
|
|
315
|
+
// through their MCP `tools/call` envelope) without caring which.
|
|
301
316
|
try {
|
|
302
317
|
type ResourceListEntry = {
|
|
303
318
|
uri?: string;
|
|
@@ -479,11 +494,20 @@ export function generateRootTypes(
|
|
|
479
494
|
lines.push(` T extends _AdkToolsOf<A>,`);
|
|
480
495
|
lines.push(`> = AdkAgentRegistry[A][T] extends { params: infer P } ? P : Record<string, unknown>;`);
|
|
481
496
|
lines.push(``);
|
|
497
|
+
// adk.ref.call resolves to a discriminated success/error envelope.
|
|
498
|
+
// Typing this here (instead of as `Promise<unknown>`) lets scripts do
|
|
499
|
+
// `if (res.success) { res.result… }` without casting to `any`. The
|
|
500
|
+
// success.result stays `unknown` since registries don't publish output
|
|
501
|
+
// schemas — narrowing it is the script's responsibility.
|
|
502
|
+
lines.push(`type _AdkCallResult =`);
|
|
503
|
+
lines.push(` | { success: true; result: unknown }`);
|
|
504
|
+
lines.push(` | { success: false; error: string };`);
|
|
505
|
+
lines.push(``);
|
|
482
506
|
lines.push(`declare const adk: {`);
|
|
483
507
|
lines.push(` ref: {`);
|
|
484
508
|
lines.push(` call<A extends _AdkAgentPath, T extends _AdkToolsOf<A>>(`);
|
|
485
509
|
lines.push(` name: A, tool: T, params: _AdkParamsOf<A, T>`);
|
|
486
|
-
lines.push(` ): Promise<
|
|
510
|
+
lines.push(` ): Promise<_AdkCallResult>;`);
|
|
487
511
|
lines.push(` };`);
|
|
488
512
|
lines.push(`};`);
|
|
489
513
|
lines.push(``);
|
package/src/registry-consumer.ts
CHANGED
|
@@ -209,16 +209,6 @@ export interface RegistryConfiguration {
|
|
|
209
209
|
jwks_uri?: string;
|
|
210
210
|
token_endpoint?: string;
|
|
211
211
|
supported_grant_types?: string[];
|
|
212
|
-
/**
|
|
213
|
-
* When the registry advertises proxy support in its `initialize` response,
|
|
214
|
-
* consumers can auto-populate `RegistryEntry.proxy` at add time so ref ops
|
|
215
|
-
* forward to the server-side adk-tools agent automatically.
|
|
216
|
-
*/
|
|
217
|
-
proxy?: {
|
|
218
|
-
mode: "required" | "optional";
|
|
219
|
-
/** Agent path to forward to. Defaults to '@config'. */
|
|
220
|
-
agent?: string;
|
|
221
|
-
};
|
|
222
212
|
}
|
|
223
213
|
|
|
224
214
|
/** Fields common to every agent reference a registry can return. */
|
|
@@ -498,34 +488,17 @@ async function discoverRegistryViaMcp(
|
|
|
498
488
|
clientInfo: { name: "agents-sdk-consumer", version: "1.0.0" },
|
|
499
489
|
})) as {
|
|
500
490
|
serverInfo?: { name?: string; version?: string };
|
|
501
|
-
capabilities?: {
|
|
502
|
-
registry?: {
|
|
503
|
-
proxy?: {
|
|
504
|
-
mode?: "required" | "optional";
|
|
505
|
-
agent?: string;
|
|
506
|
-
};
|
|
507
|
-
};
|
|
508
|
-
};
|
|
509
491
|
};
|
|
510
492
|
|
|
511
493
|
await rpc("notifications/initialized").catch(() => {});
|
|
512
494
|
|
|
513
495
|
const issuer = issuerFromMcpUrlAndServerInfo(serverUrl, initResult?.serverInfo);
|
|
514
496
|
|
|
515
|
-
const advertisedProxy = initResult?.capabilities?.registry?.proxy;
|
|
516
|
-
const proxy = advertisedProxy?.mode
|
|
517
|
-
? {
|
|
518
|
-
mode: advertisedProxy.mode,
|
|
519
|
-
...(advertisedProxy.agent && { agent: advertisedProxy.agent }),
|
|
520
|
-
}
|
|
521
|
-
: undefined;
|
|
522
|
-
|
|
523
497
|
return {
|
|
524
498
|
issuer,
|
|
525
499
|
jwks_uri: `${issuer}/.well-known/jwks.json`,
|
|
526
500
|
token_endpoint: `${issuer}/oauth/token`,
|
|
527
501
|
supported_grant_types: ["client_credentials", "jwt_exchange"],
|
|
528
|
-
...(proxy && { proxy }),
|
|
529
502
|
};
|
|
530
503
|
}
|
|
531
504
|
|
package/src/server.ts
CHANGED
|
@@ -206,17 +206,6 @@ export interface AgentServerOptions {
|
|
|
206
206
|
features?: string[];
|
|
207
207
|
/** OAuth callback URL for shared OAuth flows */
|
|
208
208
|
oauthCallbackUrl?: string;
|
|
209
|
-
/**
|
|
210
|
-
* Announce that ref operations for agents sourced from this registry
|
|
211
|
-
* should be forwarded to a server-side adk-tools agent instead of
|
|
212
|
-
* running locally. Consumers pick this up during `registry.add` and
|
|
213
|
-
* auto-populate `RegistryEntry.proxy` — no user flag needed.
|
|
214
|
-
*/
|
|
215
|
-
proxy?: {
|
|
216
|
-
mode: "required" | "optional";
|
|
217
|
-
/** Agent path to forward to. Defaults to '@config'. */
|
|
218
|
-
agent?: string;
|
|
219
|
-
};
|
|
220
209
|
};
|
|
221
210
|
/**
|
|
222
211
|
* Structured logger for server-side errors (tool-call failures, JWT
|
|
@@ -602,14 +591,6 @@ export function createAgentServer(
|
|
|
602
591
|
...(options.registry.oauthCallbackUrl && {
|
|
603
592
|
oauthCallbackUrl: options.registry.oauthCallbackUrl,
|
|
604
593
|
}),
|
|
605
|
-
...(options.registry.proxy && {
|
|
606
|
-
proxy: {
|
|
607
|
-
mode: options.registry.proxy.mode,
|
|
608
|
-
...(options.registry.proxy.agent && {
|
|
609
|
-
agent: options.registry.proxy.agent,
|
|
610
|
-
}),
|
|
611
|
-
},
|
|
612
|
-
}),
|
|
613
594
|
},
|
|
614
595
|
}),
|
|
615
596
|
},
|