@slashfi/agents-sdk 0.75.0 → 0.76.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.
@@ -34,6 +34,30 @@ export type RegistryAuth =
34
34
  | { type: "api-key"; key?: string; header?: string }
35
35
  | { type: "jwt"; issuer?: string };
36
36
 
37
+ /**
38
+ * Proxy configuration for a registry.
39
+ *
40
+ * When set, ref operations (`auth`, `auth-status`, `call`, `inspect`,
41
+ * `resources`, `read`, `refresh-token`) for refs sourced from this
42
+ * registry are forwarded to a server-side agent that implements the
43
+ * adk-tools surface. Use this for cloud-hosted registries that own
44
+ * OAuth client credentials and/or user tokens on behalf of consumers
45
+ * (e.g. `api.twin.slash.com/mcp`).
46
+ *
47
+ * - `mode: 'required'` — all ref ops MUST route through the proxy agent.
48
+ * Local handshake (`ref.authLocal`) is refused for refs from this
49
+ * registry because the local environment has no way to build an
50
+ * authorize URL without the server's client credentials.
51
+ * - `mode: 'optional'` — proxy is the default; callers may opt out via
52
+ * `{ preferLocal: true }` on a per-op basis when they already hold
53
+ * local credentials.
54
+ */
55
+ export interface RegistryProxy {
56
+ mode: 'required' | 'optional';
57
+ /** Agent path to forward to. Defaults to `@config`. */
58
+ agent?: string;
59
+ }
60
+
37
61
  /** A registry endpoint the consumer connects to */
38
62
  export interface RegistryEntry {
39
63
  /** Registry URL (e.g., 'https://registry.slash.com') */
@@ -53,6 +77,13 @@ export interface RegistryEntry {
53
77
 
54
78
  /** Connection status — set by validation/test, used to filter active entries */
55
79
  status?: 'active' | 'inactive' | 'error';
80
+
81
+ /**
82
+ * If set, ref ops for refs sourced from this registry are forwarded
83
+ * to a server-side adk-tools agent (default `@config`) instead of
84
+ * running locally. See {@link RegistryProxy}.
85
+ */
86
+ proxy?: RegistryProxy;
56
87
  }
57
88
 
58
89
  // ============================================
@@ -100,35 +131,12 @@ export type RefEntry = {
100
131
  status?: 'active' | 'inactive' | 'error';
101
132
  };
102
133
 
103
- // ============================================
104
- // Proxy Config
105
- // ============================================
106
-
107
- /** A proxy target — remote adk server that handles ref/registry operations */
108
- export interface ProxyEntry {
109
- /** Human-readable name */
110
- name: string;
111
- /** URL of the remote server */
112
- url: string;
113
- /** Connection type: 'mcp' (direct MCP server) or 'registry' (agent on a registry) */
114
- type: 'mcp' | 'registry';
115
- /** For type 'registry': the agent path that implements adk tools (e.g. '@config') */
116
- agent?: string;
117
- /** Auth for connecting to the proxy */
118
- auth?: RegistryAuth;
119
- /** Whether this is the default proxy when no local refs/registries exist */
120
- default?: boolean;
121
- }
122
-
123
134
  // ============================================
124
135
  // Consumer Config
125
136
  // ============================================
126
137
 
127
138
  /** The full consumer configuration */
128
139
  export interface ConsumerConfig {
129
- /** Remote adk proxies — forward operations to a remote server */
130
- proxies?: ProxyEntry[];
131
-
132
140
  /** Registries to connect to, in resolution order */
133
141
  registries?: (string | RegistryEntry)[];
134
142
 
package/src/index.ts CHANGED
@@ -306,7 +306,6 @@ export {
306
306
  export type {
307
307
  RegistryAuth,
308
308
  RegistryEntry,
309
- ProxyEntry,
310
309
  RefConfig,
311
310
  RefEntry,
312
311
  ConsumerConfig,
@@ -427,7 +426,6 @@ export { createAdk } from "./config-store.js";
427
426
  export type {
428
427
  Adk,
429
428
  AdkOptions,
430
- AdkProxyApi,
431
429
  AdkRegistryApi,
432
430
  AdkRefApi,
433
431
  AdkAgentRegistry,
@@ -207,6 +207,16 @@ export interface RegistryConfiguration {
207
207
  jwks_uri?: string;
208
208
  token_endpoint?: string;
209
209
  supported_grant_types?: string[];
210
+ /**
211
+ * When the registry advertises proxy support in its `initialize` response,
212
+ * consumers can auto-populate `RegistryEntry.proxy` at add time so ref ops
213
+ * forward to the server-side adk-tools agent automatically.
214
+ */
215
+ proxy?: {
216
+ mode: "required" | "optional";
217
+ /** Agent path to forward to. Defaults to '@config'. */
218
+ agent?: string;
219
+ };
210
220
  }
211
221
 
212
222
  /** Fields common to every agent reference a registry can return. */
@@ -472,17 +482,34 @@ async function discoverRegistryViaMcp(
472
482
  clientInfo: { name: "agents-sdk-consumer", version: "1.0.0" },
473
483
  })) as {
474
484
  serverInfo?: { name?: string; version?: string };
485
+ capabilities?: {
486
+ registry?: {
487
+ proxy?: {
488
+ mode?: "required" | "optional";
489
+ agent?: string;
490
+ };
491
+ };
492
+ };
475
493
  };
476
494
 
477
495
  await rpc("notifications/initialized").catch(() => {});
478
496
 
479
497
  const issuer = issuerFromMcpUrlAndServerInfo(serverUrl, initResult?.serverInfo);
480
498
 
499
+ const advertisedProxy = initResult?.capabilities?.registry?.proxy;
500
+ const proxy = advertisedProxy?.mode
501
+ ? {
502
+ mode: advertisedProxy.mode,
503
+ ...(advertisedProxy.agent && { agent: advertisedProxy.agent }),
504
+ }
505
+ : undefined;
506
+
481
507
  return {
482
508
  issuer,
483
509
  jwks_uri: `${issuer}/.well-known/jwks.json`,
484
510
  token_endpoint: `${issuer}/oauth/token`,
485
511
  supported_grant_types: ["client_credentials", "jwt_exchange"],
512
+ ...(proxy && { proxy }),
486
513
  };
487
514
  }
488
515
 
package/src/server.ts CHANGED
@@ -206,6 +206,17 @@ 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
+ };
209
220
  };
210
221
  /**
211
222
  * Structured logger for server-side errors (tool-call failures, JWT
@@ -591,6 +602,14 @@ export function createAgentServer(
591
602
  ...(options.registry.oauthCallbackUrl && {
592
603
  oauthCallbackUrl: options.registry.oauthCallbackUrl,
593
604
  }),
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
+ }),
594
613
  },
595
614
  }),
596
615
  },