@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.
@@ -57,11 +57,24 @@ function ensureWrite(path: string, content: string): void {
57
57
  writeFileSync(path, content, "utf-8");
58
58
  }
59
59
 
60
- function toKebabCase(name: string): string {
61
- return name
62
- .replace(/[^a-zA-Z0-9]+/g, "-")
63
- .replace(/^-|-$/g, "")
64
- .toLowerCase();
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 safeName = toKebabCase(tool.name);
261
- ensureWrite(join(toolsDir, `${safeName}.tool.md`), generateToolMd(tool));
262
- ensureWrite(join(toolsDir, `${safeName}.tool.json`), JSON.stringify(tool, null, 2));
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
- // Response shape varies depending on the call path: direct calls return
298
- // `{success, agentPath, resources}` while proxied calls return
299
- // `{success, result: {success, agentPath, resources}}` (the proxy wraps
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<unknown>;`);
510
+ lines.push(` ): Promise<_AdkCallResult>;`);
487
511
  lines.push(` };`);
488
512
  lines.push(`};`);
489
513
  lines.push(``);
@@ -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
  },