agentfootprint 9.65.0 → 9.67.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/adapters/identity/agentcore.js +118 -2
- package/dist/adapters/identity/agentcore.js.map +1 -1
- package/dist/adapters/mcp/agentcore.js +156 -0
- package/dist/adapters/mcp/agentcore.js.map +1 -0
- package/dist/adapters/observability/agentcore.js +61 -1
- package/dist/adapters/observability/agentcore.js.map +1 -1
- package/dist/adapters/observability/otel.js +12 -3
- package/dist/adapters/observability/otel.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +115 -1
- package/dist/esm/adapters/identity/agentcore.js +117 -2
- package/dist/esm/adapters/identity/agentcore.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcore.d.ts +143 -0
- package/dist/esm/adapters/mcp/agentcore.js +149 -0
- package/dist/esm/adapters/mcp/agentcore.js.map +1 -0
- package/dist/esm/adapters/observability/agentcore.d.ts +50 -0
- package/dist/esm/adapters/observability/agentcore.js +59 -0
- package/dist/esm/adapters/observability/agentcore.js.map +1 -1
- package/dist/esm/adapters/observability/otel.d.ts +73 -3
- package/dist/esm/adapters/observability/otel.js +12 -3
- package/dist/esm/adapters/observability/otel.js.map +1 -1
- package/dist/esm/identity.d.ts +1 -1
- package/dist/esm/identity.js +5 -1
- package/dist/esm/identity.js.map +1 -1
- package/dist/esm/observability-providers.d.ts +1 -1
- package/dist/esm/observability-providers.js +5 -1
- package/dist/esm/observability-providers.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +2 -0
- package/dist/esm/tool-providers/index.js +5 -0
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/identity.js +5 -1
- package/dist/identity.js.map +1 -1
- package/dist/observability-providers.js +6 -1
- package/dist/observability-providers.js.map +1 -1
- package/dist/tool-providers/index.js +13 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/types/adapters/identity/agentcore.d.ts +115 -1
- package/dist/types/adapters/identity/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcore.d.ts +144 -0
- package/dist/types/adapters/mcp/agentcore.d.ts.map +1 -0
- package/dist/types/adapters/observability/agentcore.d.ts +50 -0
- package/dist/types/adapters/observability/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/observability/otel.d.ts +73 -3
- package/dist/types/adapters/observability/otel.d.ts.map +1 -1
- package/dist/types/identity.d.ts +1 -1
- package/dist/types/identity.d.ts.map +1 -1
- package/dist/types/observability-providers.d.ts +1 -1
- package/dist/types/observability-providers.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +2 -0
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -103,7 +103,7 @@ export interface AgentCoreIdentityClientLike {
|
|
|
103
103
|
getResourceOauth2Token(input: {
|
|
104
104
|
readonly resourceCredentialProviderName: string;
|
|
105
105
|
readonly scopes: readonly string[];
|
|
106
|
-
readonly oauth2Flow: 'M2M' | 'USER_FEDERATION';
|
|
106
|
+
readonly oauth2Flow: 'M2M' | 'USER_FEDERATION' | 'ON_BEHALF_OF_TOKEN_EXCHANGE';
|
|
107
107
|
readonly forceAuthentication: boolean;
|
|
108
108
|
readonly workloadIdentityToken?: string;
|
|
109
109
|
}): Promise<AgentCoreOauthResponse>;
|
|
@@ -126,6 +126,25 @@ export interface AgentCoreIdentityClientLike {
|
|
|
126
126
|
}): Promise<{
|
|
127
127
|
readonly workloadAccessToken?: string;
|
|
128
128
|
}>;
|
|
129
|
+
/** Optional — required only for services named in `apiKeyServices`. AgentCore
|
|
130
|
+
* keeps API keys in the same vault as OAuth tokens, behind a different
|
|
131
|
+
* operation, so this is a sibling of `getResourceOauth2Token` rather than a
|
|
132
|
+
* mode of it. */
|
|
133
|
+
getResourceApiKey?(input: {
|
|
134
|
+
readonly resourceCredentialProviderName: string;
|
|
135
|
+
/** REQUIRED on the wire — `GetResourceApiKeyRequest` declares it non-optional. */
|
|
136
|
+
readonly workloadIdentityToken: string;
|
|
137
|
+
}): Promise<{
|
|
138
|
+
readonly apiKey?: string;
|
|
139
|
+
}>;
|
|
140
|
+
/** Optional — required only by {@link completeAgentCoreAuthorization}. Tells
|
|
141
|
+
* AgentCore that the person behind `sessionId` finished consenting, which is
|
|
142
|
+
* what releases the token into the vault for the next vend. */
|
|
143
|
+
completeResourceTokenAuth?(input: {
|
|
144
|
+
readonly sessionId: string;
|
|
145
|
+
readonly userToken?: string;
|
|
146
|
+
readonly userId?: string;
|
|
147
|
+
}): Promise<void>;
|
|
129
148
|
}
|
|
130
149
|
export interface AgentCoreIdentityOptions {
|
|
131
150
|
readonly region?: string;
|
|
@@ -165,6 +184,42 @@ export interface AgentCoreIdentityOptions {
|
|
|
165
184
|
readonly principal?: string;
|
|
166
185
|
readonly tenant?: string;
|
|
167
186
|
}) => string | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* How a `mode: 'user'` request gets its token (9.66.0). Default `'consent'`.
|
|
189
|
+
*
|
|
190
|
+
* `'consent'` — AgentCore's `USER_FEDERATION`. If the vault has no grant
|
|
191
|
+
* for this (workload, user), the result is an
|
|
192
|
+
* `authorization-required` with a URL to send the person to.
|
|
193
|
+
* They approve once; later calls return a token directly.
|
|
194
|
+
* `'exchange'` — AgentCore's `ON_BEHALF_OF_TOKEN_EXCHANGE`. The person's
|
|
195
|
+
* own login is TRADED for a scoped downstream token, with no
|
|
196
|
+
* consent screen at any point.
|
|
197
|
+
*
|
|
198
|
+
* `'exchange'` is not simply the nicer one. It works only where the
|
|
199
|
+
* downstream provider was configured for it (an on-behalf-of exchange grant
|
|
200
|
+
* on the credential provider) and where trading the user's session for
|
|
201
|
+
* downstream access is a decision your organisation has already made — the
|
|
202
|
+
* consent screen is what asks the person, and this flow is the deployment
|
|
203
|
+
* saying it does not need to. Choose it deliberately.
|
|
204
|
+
*
|
|
205
|
+
* `mode: 'machine'` is unaffected: M2M has no user to act for.
|
|
206
|
+
*/
|
|
207
|
+
readonly userFlow?: 'consent' | 'exchange';
|
|
208
|
+
/**
|
|
209
|
+
* Services whose credential is an API KEY, not an OAuth token (9.66.0).
|
|
210
|
+
*
|
|
211
|
+
* AgentCore's vault holds both kinds behind two different operations, and the
|
|
212
|
+
* provider NAME alone does not say which — so a request for a service named
|
|
213
|
+
* here is vended with `GetResourceApiKey` and comes back as an
|
|
214
|
+
* {@link apiKey} credential. Everything else takes the OAuth path.
|
|
215
|
+
*
|
|
216
|
+
* There is no auto-detection on purpose: guessing would mean calling one
|
|
217
|
+
* operation, catching a failure, and retrying with the other, which turns a
|
|
218
|
+
* configuration mistake into two round-trips and an ambiguous error.
|
|
219
|
+
*/
|
|
220
|
+
readonly apiKeyServices?: readonly string[];
|
|
221
|
+
/** Header an API-key credential is sent in. Default `'x-api-key'`. */
|
|
222
|
+
readonly apiKeyHeader?: string;
|
|
168
223
|
/** Stable provider id (default 'agentcore-identity'). */
|
|
169
224
|
readonly id?: string;
|
|
170
225
|
/** Test seam — inject a client implementing {@link AgentCoreIdentityClientLike}.
|
|
@@ -184,6 +239,65 @@ export interface BedrockAgentCoreIdentitySdkModule {
|
|
|
184
239
|
readonly GetResourceOauth2TokenCommand?: new (input: unknown) => unknown;
|
|
185
240
|
readonly GetWorkloadAccessTokenForUserIdCommand?: new (input: unknown) => unknown;
|
|
186
241
|
readonly GetWorkloadAccessTokenForJWTCommand?: new (input: unknown) => unknown;
|
|
242
|
+
readonly GetResourceApiKeyCommand?: new (input: unknown) => unknown;
|
|
243
|
+
readonly CompleteResourceTokenAuthCommand?: new (input: unknown) => unknown;
|
|
187
244
|
}
|
|
188
245
|
/** Build a {@link CredentialProvider} backed by AWS Bedrock AgentCore Identity. */
|
|
189
246
|
export declare function agentCoreIdentity(options?: AgentCoreIdentityOptions): CredentialProvider;
|
|
247
|
+
/** Connection options for {@link completeAgentCoreAuthorization}. */
|
|
248
|
+
export interface CompleteAgentCoreAuthorizationOptions {
|
|
249
|
+
/** The 3LO round-trip this completes — the `sessionId` from the
|
|
250
|
+
* `authorization-required` result the agent returned. */
|
|
251
|
+
readonly sessionId: string;
|
|
252
|
+
/** The person's own IdP-issued JWT, if your callback has it. Preferred: it is
|
|
253
|
+
* the artifact their provider signed. */
|
|
254
|
+
readonly userToken?: string;
|
|
255
|
+
/** The user id you asserted for them, when no JWT is available. Exactly one
|
|
256
|
+
* of `userToken` / `userId` is required. */
|
|
257
|
+
readonly userId?: string;
|
|
258
|
+
readonly region?: string;
|
|
259
|
+
/** Test seam — same client surface the provider uses. */
|
|
260
|
+
readonly _client?: AgentCoreIdentityClientLike;
|
|
261
|
+
/** @internal Test injection — the AWS SDK module. */
|
|
262
|
+
readonly _sdk?: BedrockAgentCoreIdentitySdkModule;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Tell AgentCore the person finished consenting, so the token lands in the vault.
|
|
266
|
+
*
|
|
267
|
+
* ── Where this runs, and why it is not a provider method ─────────────────────
|
|
268
|
+
* A 3LO consent has three actors and two processes. The agent asks for a
|
|
269
|
+
* credential and gets back `authorization-required` with a URL and a session
|
|
270
|
+
* id; the PERSON opens that URL in their browser and approves; AgentCore then
|
|
271
|
+
* redirects their browser to a callback route **your web app** owns. That route
|
|
272
|
+
* is where this belongs — a different process from the agent run, often a
|
|
273
|
+
* different service — so it takes its own connection options rather than
|
|
274
|
+
* pretending to be a method on a provider that route has never seen.
|
|
275
|
+
*
|
|
276
|
+
* Your route's job before calling this is the part nobody else can do: confirm
|
|
277
|
+
* the browser session really belongs to the user you are about to name. This
|
|
278
|
+
* function is the handshake, not the authentication.
|
|
279
|
+
*
|
|
280
|
+
* ── After it returns ─────────────────────────────────────────────────────────
|
|
281
|
+
* Nothing is handed back — success is an empty acknowledgement. The token now
|
|
282
|
+
* exists in the vault for that (workload, user), and the way to obtain it is to
|
|
283
|
+
* run the agent's request again: the next `getCredential` for that service
|
|
284
|
+
* returns `issued` where the last one returned `authorization-required`. In
|
|
285
|
+
* agentfootprint terms the consent is a PAUSE, and this is what makes the
|
|
286
|
+
* resume succeed.
|
|
287
|
+
*
|
|
288
|
+
* The authorization URL and its session are short-lived (AWS documents ten
|
|
289
|
+
* minutes) — a person who wanders off has to start the consent again, and the
|
|
290
|
+
* refusal you get is AgentCore's, not this adapter's.
|
|
291
|
+
*
|
|
292
|
+
* @example An Express-style callback route
|
|
293
|
+
* app.get('/oauth/callback', async (req, res) => {
|
|
294
|
+
* const user = await requireSignedInUser(req); // yours, and load-bearing
|
|
295
|
+
* await completeAgentCoreAuthorization({
|
|
296
|
+
* sessionId: String(req.query.session),
|
|
297
|
+
* userId: user.id,
|
|
298
|
+
* region: 'us-east-1',
|
|
299
|
+
* });
|
|
300
|
+
* res.send('Approved — you can return to the assistant.');
|
|
301
|
+
* });
|
|
302
|
+
*/
|
|
303
|
+
export declare function completeAgentCoreAuthorization(options: CompleteAgentCoreAuthorizationOptions): Promise<void>;
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
* `getCredential` first runs (or never, if you inject `_client` / `_sdk`).
|
|
84
84
|
*/
|
|
85
85
|
import { lazyRequire } from '../../lib/lazyRequire.js';
|
|
86
|
-
import { bearer } from '../../identity/kinds.js';
|
|
86
|
+
import { apiKey, bearer } from '../../identity/kinds.js';
|
|
87
87
|
/**
|
|
88
88
|
* Re-raise a failed SDK call **without its text** (9.12.0).
|
|
89
89
|
*
|
|
@@ -220,6 +220,20 @@ function createIdentityClient(options) {
|
|
|
220
220
|
async getWorkloadAccessTokenForUserId(input) {
|
|
221
221
|
return ((await send(mod.GetWorkloadAccessTokenForUserIdCommand, 'GetWorkloadAccessTokenForUserIdCommand', input)) ?? {});
|
|
222
222
|
},
|
|
223
|
+
async getResourceApiKey(input) {
|
|
224
|
+
const r = (await send(mod.GetResourceApiKeyCommand, 'GetResourceApiKeyCommand', input));
|
|
225
|
+
return { ...(r?.apiKey !== undefined && { apiKey: r.apiKey }) };
|
|
226
|
+
},
|
|
227
|
+
async completeResourceTokenAuth(input) {
|
|
228
|
+
// `CompleteResourceTokenAuthRequest` is `{ sessionUri, userIdentifier }`,
|
|
229
|
+
// where userIdentifier is a UNION with exactly one member set — the
|
|
230
|
+
// person's own token, or the id the agent asserts for them. Success is an
|
|
231
|
+
// empty 200, so there is nothing to map back.
|
|
232
|
+
await send(mod.CompleteResourceTokenAuthCommand, 'CompleteResourceTokenAuthCommand', {
|
|
233
|
+
sessionUri: input.sessionId,
|
|
234
|
+
userIdentifier: input.userToken !== undefined ? { userToken: input.userToken } : { userId: input.userId },
|
|
235
|
+
});
|
|
236
|
+
},
|
|
223
237
|
async getWorkloadAccessTokenForJWT(input) {
|
|
224
238
|
// `GetWorkloadAccessTokenForJWTRequest` is `{ workloadName, userToken }`,
|
|
225
239
|
// both required, and the response is `{ workloadAccessToken }` — verified
|
|
@@ -307,14 +321,50 @@ export function agentCoreIdentity(options = {}) {
|
|
|
307
321
|
}
|
|
308
322
|
return requireWorkloadAccessToken(await c.getWorkloadAccessTokenForUserId({ workloadName: options.workloadName, userId }), 'GetWorkloadAccessTokenForUserId');
|
|
309
323
|
};
|
|
324
|
+
const userFlow = options.userFlow ?? 'consent';
|
|
325
|
+
const apiKeyServices = new Set(options.apiKeyServices ?? []);
|
|
326
|
+
const apiKeyHeader = options.apiKeyHeader ?? 'x-api-key';
|
|
310
327
|
return {
|
|
311
328
|
id: options.id ?? 'agentcore-identity',
|
|
312
329
|
async getCredential(req) {
|
|
313
330
|
const workloadIdentityToken = await resolveWorkloadToken(req);
|
|
331
|
+
// An API-key service never touches the OAuth path: different operation,
|
|
332
|
+
// different credential kind, and no consent round-trip exists for it.
|
|
333
|
+
if (apiKeyServices.has(req.service)) {
|
|
334
|
+
const c = getClient();
|
|
335
|
+
if (!c.getResourceApiKey) {
|
|
336
|
+
throw new Error(`agentCoreIdentity: '${req.service}' is listed in \`apiKeyServices\` but the ` +
|
|
337
|
+
'injected `_client` has no getResourceApiKey. Implement it, or drop the service ' +
|
|
338
|
+
'from the list to vend it as OAuth.');
|
|
339
|
+
}
|
|
340
|
+
if (!workloadIdentityToken) {
|
|
341
|
+
// Required on `GetResourceApiKeyRequest`, exactly as on the OAuth
|
|
342
|
+
// call — verified against the real SDK's types, not assumed. Sending
|
|
343
|
+
// without one buys an opaque ValidationException; this names the two
|
|
344
|
+
// ways to supply it instead.
|
|
345
|
+
throw new Error(`agentCoreIdentity: GetResourceApiKey for '${req.service}' requires a workload ` +
|
|
346
|
+
'identity token, and none was available for this request.\n' +
|
|
347
|
+
' Inside AgentCore Runtime the container is given one — pass it as ' +
|
|
348
|
+
'`workloadIdentityToken`.\n' +
|
|
349
|
+
' Elsewhere, configure `workloadName` so a per-user token is resolved first.');
|
|
350
|
+
}
|
|
351
|
+
const keyRes = await c.getResourceApiKey({
|
|
352
|
+
resourceCredentialProviderName: req.service,
|
|
353
|
+
workloadIdentityToken,
|
|
354
|
+
});
|
|
355
|
+
if (!keyRes.apiKey) {
|
|
356
|
+
throw new Error(`agentCoreIdentity: GetResourceApiKey for '${req.service}' returned no key.`);
|
|
357
|
+
}
|
|
358
|
+
return { status: 'issued', credential: apiKey(keyRes.apiKey, apiKeyHeader) };
|
|
359
|
+
}
|
|
314
360
|
const res = await getClient().getResourceOauth2Token({
|
|
315
361
|
resourceCredentialProviderName: req.service,
|
|
316
362
|
scopes: req.scopes ?? [],
|
|
317
|
-
oauth2Flow: req.mode === 'user'
|
|
363
|
+
oauth2Flow: req.mode === 'user'
|
|
364
|
+
? userFlow === 'exchange'
|
|
365
|
+
? 'ON_BEHALF_OF_TOKEN_EXCHANGE'
|
|
366
|
+
: 'USER_FEDERATION'
|
|
367
|
+
: 'M2M',
|
|
318
368
|
forceAuthentication: req.forceReauth ?? false,
|
|
319
369
|
...(workloadIdentityToken && { workloadIdentityToken }),
|
|
320
370
|
});
|
|
@@ -338,4 +388,69 @@ export function agentCoreIdentity(options = {}) {
|
|
|
338
388
|
},
|
|
339
389
|
};
|
|
340
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Tell AgentCore the person finished consenting, so the token lands in the vault.
|
|
393
|
+
*
|
|
394
|
+
* ── Where this runs, and why it is not a provider method ─────────────────────
|
|
395
|
+
* A 3LO consent has three actors and two processes. The agent asks for a
|
|
396
|
+
* credential and gets back `authorization-required` with a URL and a session
|
|
397
|
+
* id; the PERSON opens that URL in their browser and approves; AgentCore then
|
|
398
|
+
* redirects their browser to a callback route **your web app** owns. That route
|
|
399
|
+
* is where this belongs — a different process from the agent run, often a
|
|
400
|
+
* different service — so it takes its own connection options rather than
|
|
401
|
+
* pretending to be a method on a provider that route has never seen.
|
|
402
|
+
*
|
|
403
|
+
* Your route's job before calling this is the part nobody else can do: confirm
|
|
404
|
+
* the browser session really belongs to the user you are about to name. This
|
|
405
|
+
* function is the handshake, not the authentication.
|
|
406
|
+
*
|
|
407
|
+
* ── After it returns ─────────────────────────────────────────────────────────
|
|
408
|
+
* Nothing is handed back — success is an empty acknowledgement. The token now
|
|
409
|
+
* exists in the vault for that (workload, user), and the way to obtain it is to
|
|
410
|
+
* run the agent's request again: the next `getCredential` for that service
|
|
411
|
+
* returns `issued` where the last one returned `authorization-required`. In
|
|
412
|
+
* agentfootprint terms the consent is a PAUSE, and this is what makes the
|
|
413
|
+
* resume succeed.
|
|
414
|
+
*
|
|
415
|
+
* The authorization URL and its session are short-lived (AWS documents ten
|
|
416
|
+
* minutes) — a person who wanders off has to start the consent again, and the
|
|
417
|
+
* refusal you get is AgentCore's, not this adapter's.
|
|
418
|
+
*
|
|
419
|
+
* @example An Express-style callback route
|
|
420
|
+
* app.get('/oauth/callback', async (req, res) => {
|
|
421
|
+
* const user = await requireSignedInUser(req); // yours, and load-bearing
|
|
422
|
+
* await completeAgentCoreAuthorization({
|
|
423
|
+
* sessionId: String(req.query.session),
|
|
424
|
+
* userId: user.id,
|
|
425
|
+
* region: 'us-east-1',
|
|
426
|
+
* });
|
|
427
|
+
* res.send('Approved — you can return to the assistant.');
|
|
428
|
+
* });
|
|
429
|
+
*/
|
|
430
|
+
export async function completeAgentCoreAuthorization(options) {
|
|
431
|
+
if (!options.sessionId) {
|
|
432
|
+
throw new Error('completeAgentCoreAuthorization: `sessionId` is required — it is the `sessionId` from ' +
|
|
433
|
+
'the `authorization-required` result that started this consent.');
|
|
434
|
+
}
|
|
435
|
+
if ((options.userToken === undefined) === (options.userId === undefined)) {
|
|
436
|
+
// Both or neither. Naming a person twice is ambiguous; naming them zero
|
|
437
|
+
// times completes a consent for nobody.
|
|
438
|
+
throw new Error('completeAgentCoreAuthorization: pass exactly one of `userToken` (the person’s own JWT, ' +
|
|
439
|
+
'preferred) or `userId` (an id you assert for them).');
|
|
440
|
+
}
|
|
441
|
+
const client = options._client ??
|
|
442
|
+
createIdentityClient({
|
|
443
|
+
...(options.region !== undefined && { region: options.region }),
|
|
444
|
+
...(options._sdk !== undefined && { _sdk: options._sdk }),
|
|
445
|
+
});
|
|
446
|
+
if (!client.completeResourceTokenAuth) {
|
|
447
|
+
throw new Error('completeAgentCoreAuthorization: the injected `_client` has no ' +
|
|
448
|
+
'completeResourceTokenAuth. Implement it, or omit `_client` to use the SDK.');
|
|
449
|
+
}
|
|
450
|
+
await client.completeResourceTokenAuth({
|
|
451
|
+
sessionId: options.sessionId,
|
|
452
|
+
...(options.userToken !== undefined && { userToken: options.userToken }),
|
|
453
|
+
...(options.userId !== undefined && { userId: options.userId }),
|
|
454
|
+
});
|
|
455
|
+
}
|
|
341
456
|
//# sourceMappingURL=agentcore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/identity/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["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AC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,EAAE,CAAC;QACzE,wEAAwE;QACxE,wCAAwC;QACxC,MAAM,IAAI,KAAK,CACb,yFAAyF;YACvF,qDAAqD,CACxD,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GACV,OAAO,CAAC,OAAO;QACf,oBAAoB,CAAC;YACnB,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;YAC/D,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;SAC1D,CAAC,CAAC;IACL,IAAI,CAAC,MAAM,CAAC,yBAAyB,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,gEAAgE;YAC9D,4EAA4E,CAC/E,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,CAAC,yBAAyB,CAAC;QACrC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QACxE,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KAChE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters/mcp/agentcore — reaching an AWS Bedrock **AgentCore Gateway**.
|
|
3
|
+
*
|
|
4
|
+
* ── What lives here, and why it is one file ──────────────────────────────────
|
|
5
|
+
* A Gateway is an MCP server, and `mcpClient` + `gatewayTransport` already know
|
|
6
|
+
* how to talk to one of those. Neither knows — and neither should learn — the
|
|
7
|
+
* handful of facts that are AgentCore's alone: the hostname its endpoints take,
|
|
8
|
+
* the name of the tool that searches its catalogue, the header that groups a
|
|
9
|
+
* caller's requests into one policy session, and the service name a SigV4
|
|
10
|
+
* signature is computed against. Those four facts are this file, and this file
|
|
11
|
+
* is the only place in the library that holds them.
|
|
12
|
+
*
|
|
13
|
+
* `gatewayTransport` says of itself: *"Nothing here is vendor-specific."* That
|
|
14
|
+
* stays true precisely because this exists next to it.
|
|
15
|
+
*
|
|
16
|
+
* ── What it does NOT do ──────────────────────────────────────────────────────
|
|
17
|
+
* It does not manage a Gateway. Creating one, adding targets, attaching a
|
|
18
|
+
* policy engine, enabling semantic search — all control-plane operations on
|
|
19
|
+
* `bedrock-agentcore-control`, all things an operator does once with the
|
|
20
|
+
* console, the CLI or their IaC. This is the CLIENT side: an agent using a
|
|
21
|
+
* gateway somebody already stood up.
|
|
22
|
+
*
|
|
23
|
+
* @example An agent whose tools come from a Gateway
|
|
24
|
+
* import { mcpClient } from 'agentfootprint/providers';
|
|
25
|
+
* import { agentCoreGatewayTransport } from 'agentfootprint/providers';
|
|
26
|
+
* import { agentCoreIdentity } from 'agentfootprint/security';
|
|
27
|
+
*
|
|
28
|
+
* const gateway = await mcpClient({
|
|
29
|
+
* name: 'gateway',
|
|
30
|
+
* transport: agentCoreGatewayTransport({
|
|
31
|
+
* gatewayId: 'my-gateway-a1b2c3d4e5',
|
|
32
|
+
* region: 'us-east-1',
|
|
33
|
+
* credentials: agentCoreIdentity({ region: 'us-east-1' }),
|
|
34
|
+
* }),
|
|
35
|
+
* });
|
|
36
|
+
* const tools = await gateway.tools();
|
|
37
|
+
*/
|
|
38
|
+
import { type FetchLike } from '../../lib/mcp/gatewayTransport.js';
|
|
39
|
+
import type { McpGatewayTransport } from '../../lib/mcp/types.js';
|
|
40
|
+
import type { CredentialProvider } from '../../identity/types.js';
|
|
41
|
+
import type { Tool } from '../../core/tools.js';
|
|
42
|
+
/**
|
|
43
|
+
* The Gateway's built-in semantic tool search, by its exact wire name.
|
|
44
|
+
*
|
|
45
|
+
* It is an ordinary MCP tool — `tools/call` with `{ query }` — that returns the
|
|
46
|
+
* catalogue entries closest to a natural-language description. It matters at
|
|
47
|
+
* the scale where listing every tool into a prompt stops being sensible.
|
|
48
|
+
*
|
|
49
|
+
* **It can only be enabled when the Gateway is CREATED**, never afterwards, so
|
|
50
|
+
* its absence from a catalogue is a fact about that gateway rather than a
|
|
51
|
+
* transient condition to retry.
|
|
52
|
+
*/
|
|
53
|
+
export declare const AGENTCORE_GATEWAY_SEARCH_TOOL = "x_amz_bedrock_agentcore_search";
|
|
54
|
+
/**
|
|
55
|
+
* The header that groups a caller's requests into ONE policy session.
|
|
56
|
+
*
|
|
57
|
+
* AgentCore's temporal policies decide on SEQUENCES of actions — "not after
|
|
58
|
+
* three refunds", "only once this was approved" — and a sequence needs a
|
|
59
|
+
* boundary. This header is that boundary, and without it every request is its
|
|
60
|
+
* own history of one, which quietly makes every sequence rule unenforceable.
|
|
61
|
+
*/
|
|
62
|
+
export declare const AGENTCORE_POLICY_SESSION_HEADER = "x-amzn-bedrock-agentcore-policy-session-id";
|
|
63
|
+
/** The service name a SigV4 signature for a Gateway is computed against. */
|
|
64
|
+
export declare const AGENTCORE_SIGV4_SERVICE = "bedrock-agentcore";
|
|
65
|
+
export interface AgentCoreGatewayUrlOptions {
|
|
66
|
+
/** The gateway's id, as the console and `CreateGateway`'s response give it. */
|
|
67
|
+
readonly gatewayId: string;
|
|
68
|
+
/** The region it lives in, e.g. `'us-east-1'`. */
|
|
69
|
+
readonly region: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The MCP endpoint of a Gateway.
|
|
73
|
+
*
|
|
74
|
+
* `https://{gatewayId}.gateway.bedrock-agentcore.{region}.amazonaws.com/mcp` —
|
|
75
|
+
* a shape nobody remembers correctly, which is the entire reason it is a
|
|
76
|
+
* function and not a line in a README.
|
|
77
|
+
*/
|
|
78
|
+
export declare function agentCoreGatewayUrl(options: AgentCoreGatewayUrlOptions): string;
|
|
79
|
+
export interface AgentCoreGatewayTransportOptions extends AgentCoreGatewayUrlOptions {
|
|
80
|
+
/** Who vends the token. `agentCoreIdentity()` is the usual answer. */
|
|
81
|
+
readonly credentials: CredentialProvider;
|
|
82
|
+
/** The downstream service id your provider keys on. Default `'gateway'`. */
|
|
83
|
+
readonly service?: string;
|
|
84
|
+
/** OAuth scopes, when the provider uses them. */
|
|
85
|
+
readonly scopes?: readonly string[];
|
|
86
|
+
/** `machine` (default) or `user`, for a gateway that acts on someone's behalf. */
|
|
87
|
+
readonly mode?: 'machine' | 'user';
|
|
88
|
+
/**
|
|
89
|
+
* The policy session this caller's requests belong to — a string, or a
|
|
90
|
+
* function consulted PER REQUEST.
|
|
91
|
+
*
|
|
92
|
+
* **Prefer the function on any transport more than one person shares.** A
|
|
93
|
+
* fixed string on a shared transport merges every caller's action history
|
|
94
|
+
* into a single policy session, which is not a small mistake: it makes one
|
|
95
|
+
* person's earlier actions count against another person's rule. Passing
|
|
96
|
+
* `() => currentSessionId` keeps the boundary where it belongs, and returning
|
|
97
|
+
* `undefined` sends no header at all.
|
|
98
|
+
*/
|
|
99
|
+
readonly policySessionId?: string | (() => string | undefined);
|
|
100
|
+
/** Extra static headers. **No secrets** — these live as long as the transport. */
|
|
101
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
102
|
+
/** Your own `fetch`, called underneath the per-request vending. */
|
|
103
|
+
readonly fetch?: FetchLike;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* An MCP transport pointed at an AgentCore Gateway.
|
|
107
|
+
*
|
|
108
|
+
* A configuration of {@link gatewayTransport}: the endpoint built from your
|
|
109
|
+
* gateway's id and region, and — when you name one — the policy session header
|
|
110
|
+
* stamped on every request. Token vending, the once-and-dropped secrecy rule
|
|
111
|
+
* and the rotation behaviour are all the neutral transport's, unchanged.
|
|
112
|
+
*/
|
|
113
|
+
export declare function agentCoreGatewayTransport(options: AgentCoreGatewayTransportOptions): McpGatewayTransport;
|
|
114
|
+
/**
|
|
115
|
+
* The Gateway's semantic search tool, if this gateway has one.
|
|
116
|
+
*
|
|
117
|
+
* Returns `undefined` rather than throwing, because absence is a legitimate and
|
|
118
|
+
* PERMANENT answer: semantic search is enabled when a Gateway is created and
|
|
119
|
+
* cannot be turned on afterwards, so there is nothing to retry.
|
|
120
|
+
*
|
|
121
|
+
* ── Why this finds the tool instead of calling it ────────────────────────────
|
|
122
|
+
* The obvious convenience would be `search(gateway, 'refund an order')`, and it
|
|
123
|
+
* is deliberately not here. Executing a tool needs a `ToolExecutionContext` —
|
|
124
|
+
* the call id, the iteration, the credential seam, the artifact store — and
|
|
125
|
+
* that object belongs to the agent loop. A helper would have to invent one,
|
|
126
|
+
* and a call made on an invented context is a call that appears in no trace:
|
|
127
|
+
* the model would be handed a shortlist nobody can later explain the origin of,
|
|
128
|
+
* which is the opposite of what this library is for.
|
|
129
|
+
*
|
|
130
|
+
* So the search tool is registered like any other tool, the model calls it when
|
|
131
|
+
* the catalogue is too large to reason about, and that call is an ordinary
|
|
132
|
+
* tool call in the trace — visible, attributable, and replayable.
|
|
133
|
+
*
|
|
134
|
+
* @example Give the model the catalogue's own search
|
|
135
|
+
* const tools = await gateway.tools();
|
|
136
|
+
* const search = gatewaySearchTool(tools);
|
|
137
|
+
* Agent.create({ provider, model })
|
|
138
|
+
* .tools(search ? [search] : tools) // search it, or list it
|
|
139
|
+
* .build();
|
|
140
|
+
*/
|
|
141
|
+
export declare function gatewaySearchTool(tools: readonly Tool[]): Tool | undefined;
|
|
142
|
+
/** Whether this gateway's catalogue can be searched rather than listed. */
|
|
143
|
+
export declare function hasGatewaySearch(tools: readonly Tool[]): boolean;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters/mcp/agentcore — reaching an AWS Bedrock **AgentCore Gateway**.
|
|
3
|
+
*
|
|
4
|
+
* ── What lives here, and why it is one file ──────────────────────────────────
|
|
5
|
+
* A Gateway is an MCP server, and `mcpClient` + `gatewayTransport` already know
|
|
6
|
+
* how to talk to one of those. Neither knows — and neither should learn — the
|
|
7
|
+
* handful of facts that are AgentCore's alone: the hostname its endpoints take,
|
|
8
|
+
* the name of the tool that searches its catalogue, the header that groups a
|
|
9
|
+
* caller's requests into one policy session, and the service name a SigV4
|
|
10
|
+
* signature is computed against. Those four facts are this file, and this file
|
|
11
|
+
* is the only place in the library that holds them.
|
|
12
|
+
*
|
|
13
|
+
* `gatewayTransport` says of itself: *"Nothing here is vendor-specific."* That
|
|
14
|
+
* stays true precisely because this exists next to it.
|
|
15
|
+
*
|
|
16
|
+
* ── What it does NOT do ──────────────────────────────────────────────────────
|
|
17
|
+
* It does not manage a Gateway. Creating one, adding targets, attaching a
|
|
18
|
+
* policy engine, enabling semantic search — all control-plane operations on
|
|
19
|
+
* `bedrock-agentcore-control`, all things an operator does once with the
|
|
20
|
+
* console, the CLI or their IaC. This is the CLIENT side: an agent using a
|
|
21
|
+
* gateway somebody already stood up.
|
|
22
|
+
*
|
|
23
|
+
* @example An agent whose tools come from a Gateway
|
|
24
|
+
* import { mcpClient } from 'agentfootprint/providers';
|
|
25
|
+
* import { agentCoreGatewayTransport } from 'agentfootprint/providers';
|
|
26
|
+
* import { agentCoreIdentity } from 'agentfootprint/security';
|
|
27
|
+
*
|
|
28
|
+
* const gateway = await mcpClient({
|
|
29
|
+
* name: 'gateway',
|
|
30
|
+
* transport: agentCoreGatewayTransport({
|
|
31
|
+
* gatewayId: 'my-gateway-a1b2c3d4e5',
|
|
32
|
+
* region: 'us-east-1',
|
|
33
|
+
* credentials: agentCoreIdentity({ region: 'us-east-1' }),
|
|
34
|
+
* }),
|
|
35
|
+
* });
|
|
36
|
+
* const tools = await gateway.tools();
|
|
37
|
+
*/
|
|
38
|
+
import { gatewayTransport } from '../../lib/mcp/gatewayTransport.js';
|
|
39
|
+
/**
|
|
40
|
+
* The Gateway's built-in semantic tool search, by its exact wire name.
|
|
41
|
+
*
|
|
42
|
+
* It is an ordinary MCP tool — `tools/call` with `{ query }` — that returns the
|
|
43
|
+
* catalogue entries closest to a natural-language description. It matters at
|
|
44
|
+
* the scale where listing every tool into a prompt stops being sensible.
|
|
45
|
+
*
|
|
46
|
+
* **It can only be enabled when the Gateway is CREATED**, never afterwards, so
|
|
47
|
+
* its absence from a catalogue is a fact about that gateway rather than a
|
|
48
|
+
* transient condition to retry.
|
|
49
|
+
*/
|
|
50
|
+
export const AGENTCORE_GATEWAY_SEARCH_TOOL = 'x_amz_bedrock_agentcore_search';
|
|
51
|
+
/**
|
|
52
|
+
* The header that groups a caller's requests into ONE policy session.
|
|
53
|
+
*
|
|
54
|
+
* AgentCore's temporal policies decide on SEQUENCES of actions — "not after
|
|
55
|
+
* three refunds", "only once this was approved" — and a sequence needs a
|
|
56
|
+
* boundary. This header is that boundary, and without it every request is its
|
|
57
|
+
* own history of one, which quietly makes every sequence rule unenforceable.
|
|
58
|
+
*/
|
|
59
|
+
export const AGENTCORE_POLICY_SESSION_HEADER = 'x-amzn-bedrock-agentcore-policy-session-id';
|
|
60
|
+
/** The service name a SigV4 signature for a Gateway is computed against. */
|
|
61
|
+
export const AGENTCORE_SIGV4_SERVICE = 'bedrock-agentcore';
|
|
62
|
+
/**
|
|
63
|
+
* The MCP endpoint of a Gateway.
|
|
64
|
+
*
|
|
65
|
+
* `https://{gatewayId}.gateway.bedrock-agentcore.{region}.amazonaws.com/mcp` —
|
|
66
|
+
* a shape nobody remembers correctly, which is the entire reason it is a
|
|
67
|
+
* function and not a line in a README.
|
|
68
|
+
*/
|
|
69
|
+
export function agentCoreGatewayUrl(options) {
|
|
70
|
+
const { gatewayId, region } = options;
|
|
71
|
+
if (!gatewayId || !region) {
|
|
72
|
+
throw new TypeError('agentCoreGatewayUrl: both `gatewayId` and `region` are required — the endpoint hostname ' +
|
|
73
|
+
'is built from the two.');
|
|
74
|
+
}
|
|
75
|
+
return `https://${gatewayId}.gateway.bedrock-agentcore.${region}.amazonaws.com/mcp`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* An MCP transport pointed at an AgentCore Gateway.
|
|
79
|
+
*
|
|
80
|
+
* A configuration of {@link gatewayTransport}: the endpoint built from your
|
|
81
|
+
* gateway's id and region, and — when you name one — the policy session header
|
|
82
|
+
* stamped on every request. Token vending, the once-and-dropped secrecy rule
|
|
83
|
+
* and the rotation behaviour are all the neutral transport's, unchanged.
|
|
84
|
+
*/
|
|
85
|
+
export function agentCoreGatewayTransport(options) {
|
|
86
|
+
const { policySessionId, fetch: innerFetch } = options;
|
|
87
|
+
// The header is stamped in the `fetch` seam rather than in `headers` because
|
|
88
|
+
// the seam runs per request. That is what lets the session id come from a
|
|
89
|
+
// function, which is what keeps two people on one transport in two sessions.
|
|
90
|
+
const stampPolicySession = policySessionId === undefined
|
|
91
|
+
? innerFetch
|
|
92
|
+
: async (input, init) => {
|
|
93
|
+
const id = typeof policySessionId === 'function' ? policySessionId() : policySessionId;
|
|
94
|
+
const next = id === undefined || id === ''
|
|
95
|
+
? init
|
|
96
|
+
: {
|
|
97
|
+
...init,
|
|
98
|
+
headers: {
|
|
99
|
+
...init?.headers,
|
|
100
|
+
[AGENTCORE_POLICY_SESSION_HEADER]: id,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
return innerFetch ? innerFetch(input, next) : globalThis.fetch(input, next);
|
|
104
|
+
};
|
|
105
|
+
return gatewayTransport({
|
|
106
|
+
url: agentCoreGatewayUrl(options),
|
|
107
|
+
credentials: options.credentials,
|
|
108
|
+
...(options.service !== undefined && { service: options.service }),
|
|
109
|
+
...(options.scopes !== undefined && { scopes: options.scopes }),
|
|
110
|
+
...(options.mode !== undefined && { mode: options.mode }),
|
|
111
|
+
...(options.headers !== undefined && { headers: options.headers }),
|
|
112
|
+
...(stampPolicySession !== undefined && { fetch: stampPolicySession }),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The Gateway's semantic search tool, if this gateway has one.
|
|
117
|
+
*
|
|
118
|
+
* Returns `undefined` rather than throwing, because absence is a legitimate and
|
|
119
|
+
* PERMANENT answer: semantic search is enabled when a Gateway is created and
|
|
120
|
+
* cannot be turned on afterwards, so there is nothing to retry.
|
|
121
|
+
*
|
|
122
|
+
* ── Why this finds the tool instead of calling it ────────────────────────────
|
|
123
|
+
* The obvious convenience would be `search(gateway, 'refund an order')`, and it
|
|
124
|
+
* is deliberately not here. Executing a tool needs a `ToolExecutionContext` —
|
|
125
|
+
* the call id, the iteration, the credential seam, the artifact store — and
|
|
126
|
+
* that object belongs to the agent loop. A helper would have to invent one,
|
|
127
|
+
* and a call made on an invented context is a call that appears in no trace:
|
|
128
|
+
* the model would be handed a shortlist nobody can later explain the origin of,
|
|
129
|
+
* which is the opposite of what this library is for.
|
|
130
|
+
*
|
|
131
|
+
* So the search tool is registered like any other tool, the model calls it when
|
|
132
|
+
* the catalogue is too large to reason about, and that call is an ordinary
|
|
133
|
+
* tool call in the trace — visible, attributable, and replayable.
|
|
134
|
+
*
|
|
135
|
+
* @example Give the model the catalogue's own search
|
|
136
|
+
* const tools = await gateway.tools();
|
|
137
|
+
* const search = gatewaySearchTool(tools);
|
|
138
|
+
* Agent.create({ provider, model })
|
|
139
|
+
* .tools(search ? [search] : tools) // search it, or list it
|
|
140
|
+
* .build();
|
|
141
|
+
*/
|
|
142
|
+
export function gatewaySearchTool(tools) {
|
|
143
|
+
return tools.find((t) => t.schema.name === AGENTCORE_GATEWAY_SEARCH_TOOL);
|
|
144
|
+
}
|
|
145
|
+
/** Whether this gateway's catalogue can be searched rather than listed. */
|
|
146
|
+
export function hasGatewaySearch(tools) {
|
|
147
|
+
return gatewaySearchTool(tools) !== undefined;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=agentcore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../../src/adapters/mcp/agentcore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAA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