agentfootprint 7.13.0 → 7.15.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/hosting/agentcore.js +350 -0
- package/dist/adapters/hosting/agentcore.js.map +1 -0
- package/dist/adapters/memory/agentcore.js +125 -1
- package/dist/adapters/memory/agentcore.js.map +1 -1
- package/dist/adapters/security/agentcore.js +0 -0
- package/dist/adapters/security/agentcore.js.map +1 -0
- package/dist/core/Agent.js +79 -2
- package/dist/core/Agent.js.map +1 -1
- package/dist/esm/adapters/hosting/agentcore.d.ts +199 -0
- package/dist/esm/adapters/hosting/agentcore.js +321 -0
- package/dist/esm/adapters/hosting/agentcore.js.map +1 -0
- package/dist/esm/adapters/memory/agentcore.d.ts +88 -2
- package/dist/esm/adapters/memory/agentcore.js +125 -1
- package/dist/esm/adapters/memory/agentcore.js.map +1 -1
- package/dist/esm/adapters/security/agentcore.d.ts +157 -0
- package/dist/esm/adapters/security/agentcore.js +0 -0
- package/dist/esm/adapters/security/agentcore.js.map +1 -0
- package/dist/esm/core/Agent.d.ts +47 -0
- package/dist/esm/core/Agent.js +79 -2
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/hosting/envelope.d.ts +33 -0
- package/dist/esm/hosting/envelope.js +49 -0
- package/dist/esm/hosting/envelope.js.map +1 -0
- package/dist/esm/hosting/errors.d.ts +78 -0
- package/dist/esm/hosting/errors.js +119 -0
- package/dist/esm/hosting/errors.js.map +1 -0
- package/dist/esm/hosting/httpHost.d.ts +121 -0
- package/dist/esm/hosting/httpHost.js +248 -0
- package/dist/esm/hosting/httpHost.js.map +1 -0
- package/dist/esm/hosting/index.d.ts +60 -0
- package/dist/esm/hosting/index.js +58 -0
- package/dist/esm/hosting/index.js.map +1 -0
- package/dist/esm/hosting/memorySessions.d.ts +22 -0
- package/dist/esm/hosting/memorySessions.js +31 -0
- package/dist/esm/hosting/memorySessions.js.map +1 -0
- package/dist/esm/hosting/nodeHost.d.ts +71 -0
- package/dist/esm/hosting/nodeHost.js +78 -0
- package/dist/esm/hosting/nodeHost.js.map +1 -0
- package/dist/esm/hosting/standingAgent.d.ts +62 -0
- package/dist/esm/hosting/standingAgent.js +192 -0
- package/dist/esm/hosting/standingAgent.js.map +1 -0
- package/dist/esm/hosting/types.d.ts +206 -0
- package/dist/esm/hosting/types.js +21 -0
- package/dist/esm/hosting/types.js.map +1 -0
- package/dist/esm/hosting-providers.d.ts +50 -0
- package/dist/esm/hosting-providers.js +50 -0
- package/dist/esm/hosting-providers.js.map +1 -0
- package/dist/esm/lib/mcp/gatewayTransport.d.ts +103 -0
- package/dist/esm/lib/mcp/gatewayTransport.js +123 -0
- package/dist/esm/lib/mcp/gatewayTransport.js.map +1 -0
- package/dist/esm/lib/mcp/index.d.ts +2 -1
- package/dist/esm/lib/mcp/index.js +1 -0
- package/dist/esm/lib/mcp/index.js.map +1 -1
- package/dist/esm/lib/mcp/mcpClient.js +10 -2
- package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
- package/dist/esm/lib/mcp/types.d.ts +45 -1
- package/dist/esm/memory/store/types.d.ts +22 -0
- package/dist/esm/memory-providers.d.ts +1 -1
- package/dist/esm/memory-providers.js.map +1 -1
- package/dist/esm/security/index.d.ts +10 -1
- package/dist/esm/security/index.js +14 -1
- package/dist/esm/security/index.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +6 -2
- package/dist/esm/tool-providers/index.js +5 -1
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/hosting/envelope.js +54 -0
- package/dist/hosting/envelope.js.map +1 -0
- package/dist/hosting/errors.js +126 -0
- package/dist/hosting/errors.js.map +1 -0
- package/dist/hosting/httpHost.js +276 -0
- package/dist/hosting/httpHost.js.map +1 -0
- package/dist/hosting/index.js +73 -0
- package/dist/hosting/index.js.map +1 -0
- package/dist/hosting/memorySessions.js +35 -0
- package/dist/hosting/memorySessions.js.map +1 -0
- package/dist/hosting/nodeHost.js +82 -0
- package/dist/hosting/nodeHost.js.map +1 -0
- package/dist/hosting/standingAgent.js +196 -0
- package/dist/hosting/standingAgent.js.map +1 -0
- package/dist/hosting/types.js +22 -0
- package/dist/hosting/types.js.map +1 -0
- package/dist/hosting-providers.js +57 -0
- package/dist/hosting-providers.js.map +1 -0
- package/dist/lib/mcp/gatewayTransport.js +129 -0
- package/dist/lib/mcp/gatewayTransport.js.map +1 -0
- package/dist/lib/mcp/index.js +4 -1
- package/dist/lib/mcp/index.js.map +1 -1
- package/dist/lib/mcp/mcpClient.js +10 -2
- package/dist/lib/mcp/mcpClient.js.map +1 -1
- package/dist/memory-providers.js.map +1 -1
- package/dist/security/index.js +16 -2
- package/dist/security/index.js.map +1 -1
- package/dist/tool-providers/index.js +7 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/types/adapters/hosting/agentcore.d.ts +200 -0
- package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -0
- package/dist/types/adapters/memory/agentcore.d.ts +88 -2
- package/dist/types/adapters/memory/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/security/agentcore.d.ts +158 -0
- package/dist/types/adapters/security/agentcore.d.ts.map +1 -0
- package/dist/types/core/Agent.d.ts +47 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/hosting/envelope.d.ts +34 -0
- package/dist/types/hosting/envelope.d.ts.map +1 -0
- package/dist/types/hosting/errors.d.ts +79 -0
- package/dist/types/hosting/errors.d.ts.map +1 -0
- package/dist/types/hosting/httpHost.d.ts +122 -0
- package/dist/types/hosting/httpHost.d.ts.map +1 -0
- package/dist/types/hosting/index.d.ts +61 -0
- package/dist/types/hosting/index.d.ts.map +1 -0
- package/dist/types/hosting/memorySessions.d.ts +23 -0
- package/dist/types/hosting/memorySessions.d.ts.map +1 -0
- package/dist/types/hosting/nodeHost.d.ts +72 -0
- package/dist/types/hosting/nodeHost.d.ts.map +1 -0
- package/dist/types/hosting/standingAgent.d.ts +63 -0
- package/dist/types/hosting/standingAgent.d.ts.map +1 -0
- package/dist/types/hosting/types.d.ts +207 -0
- package/dist/types/hosting/types.d.ts.map +1 -0
- package/dist/types/hosting-providers.d.ts +51 -0
- package/dist/types/hosting-providers.d.ts.map +1 -0
- package/dist/types/lib/mcp/gatewayTransport.d.ts +104 -0
- package/dist/types/lib/mcp/gatewayTransport.d.ts.map +1 -0
- package/dist/types/lib/mcp/index.d.ts +2 -1
- package/dist/types/lib/mcp/index.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/lib/mcp/types.d.ts +45 -1
- package/dist/types/lib/mcp/types.d.ts.map +1 -1
- package/dist/types/memory/store/types.d.ts +22 -0
- package/dist/types/memory/store/types.d.ts.map +1 -1
- package/dist/types/memory-providers.d.ts +1 -1
- package/dist/types/memory-providers.d.ts.map +1 -1
- package/dist/types/security/index.d.ts +10 -1
- package/dist/types/security/index.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +6 -2
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/package.json +27 -1
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* agent run, so it emits nothing at all.
|
|
22
22
|
*/
|
|
23
23
|
import type { Tool } from '../../core/tools.js';
|
|
24
|
+
import type { CredentialProvider } from '../../identity/types.js';
|
|
24
25
|
/**
|
|
25
26
|
* `stdio` transport — spawns a local subprocess and speaks MCP over
|
|
26
27
|
* its stdin/stdout. Best for development, single-user scenarios, and
|
|
@@ -54,7 +55,50 @@ export interface McpHttpTransport {
|
|
|
54
55
|
/** Optional auth headers (e.g., `Authorization: Bearer ...`). */
|
|
55
56
|
readonly headers?: Readonly<Record<string, string>>;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
/**
|
|
59
|
+
* `gateway` transport — MCP over Streamable HTTP, with the auth headers vended
|
|
60
|
+
* **per request** by a {@link CredentialProvider} instead of fixed at connect
|
|
61
|
+
* time.
|
|
62
|
+
*
|
|
63
|
+
* The difference from `http` is entirely about time. `http` takes the headers
|
|
64
|
+
* you hand it once and reuses them for the life of the connection, which is
|
|
65
|
+
* exactly right for a static API key and exactly wrong for a token with an
|
|
66
|
+
* expiry: a long-lived agent outlives its bearer token, and the failure is a
|
|
67
|
+
* burst of 401s an hour into a session that worked fine when you tested it.
|
|
68
|
+
* This transport asks the provider on every request, so a rotated, refreshed
|
|
69
|
+
* or newly-consented token is simply the one used next.
|
|
70
|
+
*
|
|
71
|
+
* **The token is never stored by this transport.** It is vended, applied to one
|
|
72
|
+
* outgoing request, and dropped — it is not cached between requests, not held
|
|
73
|
+
* on the transport object, and not written to any event, error message or log.
|
|
74
|
+
* Build it with `gatewayTransport(...)` rather than by hand.
|
|
75
|
+
*/
|
|
76
|
+
export interface McpGatewayTransport {
|
|
77
|
+
readonly transport: 'gateway';
|
|
78
|
+
/** The MCP endpoint URL. */
|
|
79
|
+
readonly url: string;
|
|
80
|
+
/**
|
|
81
|
+
* Who vends the token. Anything satisfying the `CredentialProvider` port —
|
|
82
|
+
* `agentCoreIdentity()` for a managed token vault, `staticTokens()` in dev.
|
|
83
|
+
*/
|
|
84
|
+
readonly credentials: CredentialProvider;
|
|
85
|
+
/** The downstream service id the provider understands, e.g. `'gateway'`. */
|
|
86
|
+
readonly service: string;
|
|
87
|
+
/** OAuth scopes to request, when the provider uses them. */
|
|
88
|
+
readonly scopes?: readonly string[];
|
|
89
|
+
/** `machine` (2-legged, the default) or `user` (3-legged, on behalf of a user). */
|
|
90
|
+
readonly mode?: 'machine' | 'user';
|
|
91
|
+
/**
|
|
92
|
+
* Extra headers sent alongside the vended ones (a tenant id, a correlation
|
|
93
|
+
* id). Applied FIRST, so a vended auth header always wins — a static header
|
|
94
|
+
* can never quietly shadow the credential.
|
|
95
|
+
*
|
|
96
|
+
* Put no secrets here: these are held for the life of the transport, which is
|
|
97
|
+
* the property the vended ones exist to avoid.
|
|
98
|
+
*/
|
|
99
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
100
|
+
}
|
|
101
|
+
export type McpTransport = McpStdioTransport | McpHttpTransport | McpGatewayTransport;
|
|
58
102
|
export interface McpClientOptions {
|
|
59
103
|
/**
|
|
60
104
|
* Logical name for observability + tool-call routing. Surfaces in
|
|
@@ -85,6 +85,21 @@ export interface SearchOptions {
|
|
|
85
85
|
* they're doing.
|
|
86
86
|
*/
|
|
87
87
|
readonly embedderId?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The natural-language form of the same query, when the caller has it.
|
|
90
|
+
*
|
|
91
|
+
* `search()` takes a VECTOR because the reference backends rank locally
|
|
92
|
+
* by cosine. Several managed stores do not work that way: they embed
|
|
93
|
+
* and rank **server-side** and their retrieval API takes text, so a
|
|
94
|
+
* vector is the one thing they cannot use. Those adapters read this
|
|
95
|
+
* field, and say so by name when it is missing rather than quietly
|
|
96
|
+
* ranking nothing.
|
|
97
|
+
*
|
|
98
|
+
* Stores that rank locally IGNORE it — the vector stays authoritative
|
|
99
|
+
* and results are unchanged whether you pass it or not. Supply both
|
|
100
|
+
* whenever you have both, and any store can serve the query.
|
|
101
|
+
*/
|
|
102
|
+
readonly text?: string;
|
|
88
103
|
}
|
|
89
104
|
/**
|
|
90
105
|
* A `MemoryEntry` annotated with its similarity score. Returned by
|
|
@@ -218,6 +233,13 @@ export interface MemoryStore {
|
|
|
218
233
|
* Fine for dev / tests. Production needs a real vector DB.
|
|
219
234
|
* - **pgvector**: `ORDER BY embedding <=> query LIMIT k`.
|
|
220
235
|
* - **Pinecone / Qdrant / Weaviate**: native vector query API.
|
|
236
|
+
*
|
|
237
|
+
* **Server-side stores.** Some backends embed and rank on their own
|
|
238
|
+
* side and their retrieval API takes TEXT, not a vector. Those
|
|
239
|
+
* adapters read `options.text` (see {@link SearchOptions.text}) and
|
|
240
|
+
* refuse by name when it is absent — a vector is genuinely unusable
|
|
241
|
+
* to them, and returning an empty result would look like "no matches"
|
|
242
|
+
* instead of "wrong query form".
|
|
221
243
|
*/
|
|
222
244
|
search?<T = unknown>(identity: MemoryIdentity, query: readonly number[], options?: SearchOptions): Promise<readonly ScoredEntry<T>[]>;
|
|
223
245
|
}
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
* import { RedisStore, AgentCoreStore } from 'agentfootprint/memory-providers';
|
|
34
34
|
*/
|
|
35
35
|
export { RedisStore, type RedisStoreOptions, type RedisLikeClient, type RedisLikePipeline, } from './adapters/memory/redis.js';
|
|
36
|
-
export { AgentCoreStore, type AgentCoreStoreOptions, type AgentCoreLikeClient, } from './adapters/memory/agentcore.js';
|
|
36
|
+
export { AgentCoreStore, type AgentCoreStoreOptions, type AgentCoreLikeClient, type AgentCoreEvent, type AgentCoreMemoryRecord, } from './adapters/memory/agentcore.js';
|
|
37
37
|
export { BedrockAgentMemory, type BedrockAgentMemoryOptions, type BedrockAgentMemoryLikeClient, type BedrockAgentSummary, } from './adapters/memory/bedrockAgentMemory.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-providers.js","sourceRoot":"","sources":["../../src/memory-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,sEAAsE;AACtE,sEAAsE;AACtE,wDAAwD;AACxD,OAAO,EACL,UAAU,GAIX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"memory-providers.js","sourceRoot":"","sources":["../../src/memory-providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,sEAAsE;AACtE,sEAAsE;AACtE,wDAAwD;AACxD,OAAO,EACL,UAAU,GAIX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,cAAc,GAKf,MAAM,gCAAgC,CAAC;AAExC,8EAA8E;AAC9E,yEAAyE;AACzE,OAAO,EACL,kBAAkB,GAInB,MAAM,yCAAyC,CAAC"}
|
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
* Today's surface is small and data-driven on purpose: one role
|
|
11
11
|
* allowlist primitive that satisfies BOTH the v2.4 `PermissionChecker`
|
|
12
12
|
* interface AND a sync `isAllowed(toolId)` predicate for use with
|
|
13
|
-
* `gatedTools` from `agentfootprint/tool-providers
|
|
13
|
+
* `gatedTools` from `agentfootprint/tool-providers` — plus
|
|
14
|
+
* `agentCorePolicy()`, the same port answered by a remote policy store.
|
|
15
|
+
*
|
|
16
|
+
* A local allowlist and a remote policy engine differ in one way that
|
|
17
|
+
* matters here: the local one can answer synchronously, so it doubles
|
|
18
|
+
* as a `gatedTools` predicate; a remote one cannot, so it plugs in ONLY
|
|
19
|
+
* as `permissionChecker`. That is not a limitation of either — the gate
|
|
20
|
+
* decides what the model is shown, the checker decides what actually
|
|
21
|
+
* runs, and they compose without knowing about each other.
|
|
14
22
|
*
|
|
15
23
|
* Future additions (capability gating, gate_open flows, audit logs)
|
|
16
24
|
* land here without expanding the public root barrel.
|
|
@@ -41,4 +49,5 @@ export type { PolicyHaltContext } from './PolicyHaltError.js';
|
|
|
41
49
|
export { extractSequence, SYNTHETIC_DENY_PREFIX } from './extractSequence.js';
|
|
42
50
|
export type { ExtractSequenceOptions } from './extractSequence.js';
|
|
43
51
|
export { redactThinkingBlocks, REDACTED_PLACEHOLDER } from './thinkingRedaction.js';
|
|
52
|
+
export { agentCorePolicy, type AgentCorePolicyOptions, type AgentCorePolicyClientLike, type AgentCorePolicyEvaluation, type AgentCorePolicyUnavailable, type BedrockAgentCorePolicySdkModule, } from '../adapters/security/agentcore.js';
|
|
44
53
|
export type { PermissionChecker, PermissionRequest, PermissionDecision, ToolCallEntry, ToolResultContent, } from '../adapters/types.js';
|
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
* Today's surface is small and data-driven on purpose: one role
|
|
11
11
|
* allowlist primitive that satisfies BOTH the v2.4 `PermissionChecker`
|
|
12
12
|
* interface AND a sync `isAllowed(toolId)` predicate for use with
|
|
13
|
-
* `gatedTools` from `agentfootprint/tool-providers
|
|
13
|
+
* `gatedTools` from `agentfootprint/tool-providers` — plus
|
|
14
|
+
* `agentCorePolicy()`, the same port answered by a remote policy store.
|
|
15
|
+
*
|
|
16
|
+
* A local allowlist and a remote policy engine differ in one way that
|
|
17
|
+
* matters here: the local one can answer synchronously, so it doubles
|
|
18
|
+
* as a `gatedTools` predicate; a remote one cannot, so it plugs in ONLY
|
|
19
|
+
* as `permissionChecker`. That is not a limitation of either — the gate
|
|
20
|
+
* decides what the model is shown, the checker decides what actually
|
|
21
|
+
* runs, and they compose without knowing about each other.
|
|
14
22
|
*
|
|
15
23
|
* Future additions (capability gating, gate_open flows, audit logs)
|
|
16
24
|
* land here without expanding the public root barrel.
|
|
@@ -38,4 +46,9 @@ export { PermissionPolicy } from './PermissionPolicy.js';
|
|
|
38
46
|
export { PolicyHaltError } from './PolicyHaltError.js';
|
|
39
47
|
export { extractSequence, SYNTHETIC_DENY_PREFIX } from './extractSequence.js';
|
|
40
48
|
export { redactThinkingBlocks, REDACTED_PLACEHOLDER } from './thinkingRedaction.js';
|
|
49
|
+
// A remote policy engine behind the same port. Lazy peer-dep: importing this
|
|
50
|
+
// barrel loads no AWS SDK — only constructing the checker and letting it
|
|
51
|
+
// evaluate does. Same home as `PermissionPolicy` because it is the same job,
|
|
52
|
+
// just asked of somebody else.
|
|
53
|
+
export { agentCorePolicy, } from '../adapters/security/agentcore.js';
|
|
41
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEpF,6EAA6E;AAC7E,yEAAyE;AACzE,6EAA6E;AAC7E,+BAA+B;AAC/B,OAAO,EACL,eAAe,GAMhB,MAAM,mCAAmC,CAAC"}
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* 2. Tool sources (re-exported from existing modules)
|
|
13
13
|
* - `mcpClient(opts)` — connect to an MCP server (real)
|
|
14
14
|
* - `mockMcpClient({ tools })` — in-memory MCP source for dev / tests
|
|
15
|
+
* - `gatewayTransport({ url, credentials, service })` — an MCP
|
|
16
|
+
* transport whose auth headers are vended PER REQUEST by a
|
|
17
|
+
* `CredentialProvider`, for endpoints behind a token with an
|
|
18
|
+
* expiry. The token is used once and never stored.
|
|
15
19
|
*
|
|
16
20
|
* 3. Tool sink — the other direction
|
|
17
21
|
* - `mcpServe(tools, opts)` — expose your own `Tool[]` AS an MCP
|
|
@@ -43,5 +47,5 @@ export { staticTools } from './staticTools.js';
|
|
|
43
47
|
export { gatedTools } from './gatedTools.js';
|
|
44
48
|
export { skillScopedTools } from './skillScopedTools.js';
|
|
45
49
|
export type { ToolProvider, ToolDispatchContext, ToolGatePredicate } from './types.js';
|
|
46
|
-
export { mcpClient, mcpServe, mockMcpClient } from '../lib/mcp/index.js';
|
|
47
|
-
export type { McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, MockMcpClientOptions, MockMcpTool, McpServeOptions, McpServeHandle, McpServeTransport, McpStdioServeTransport, McpHttpServeTransport, McpSdkServer, } from '../lib/mcp/index.js';
|
|
50
|
+
export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, GatewayAuthorizationRequiredError, } from '../lib/mcp/index.js';
|
|
51
|
+
export type { GatewayTransportOptions, McpClient, McpClientOptions, McpSdkClient, McpTransport, McpStdioTransport, McpHttpTransport, McpGatewayTransport, MockMcpClientOptions, MockMcpTool, McpServeOptions, McpServeHandle, McpServeTransport, McpStdioServeTransport, McpHttpServeTransport, McpSdkServer, } from '../lib/mcp/index.js';
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* 2. Tool sources (re-exported from existing modules)
|
|
13
13
|
* - `mcpClient(opts)` — connect to an MCP server (real)
|
|
14
14
|
* - `mockMcpClient({ tools })` — in-memory MCP source for dev / tests
|
|
15
|
+
* - `gatewayTransport({ url, credentials, service })` — an MCP
|
|
16
|
+
* transport whose auth headers are vended PER REQUEST by a
|
|
17
|
+
* `CredentialProvider`, for endpoints behind a token with an
|
|
18
|
+
* expiry. The token is used once and never stored.
|
|
15
19
|
*
|
|
16
20
|
* 3. Tool sink — the other direction
|
|
17
21
|
* - `mcpServe(tools, opts)` — expose your own `Tool[]` AS an MCP
|
|
@@ -45,5 +49,5 @@ export { skillScopedTools } from './skillScopedTools.js';
|
|
|
45
49
|
// Re-export tool sources from the MCP module so consumers find them in
|
|
46
50
|
// one place. This subpath is the ONLY place `mcpClient` is public — the
|
|
47
51
|
// top-level barrel does not re-export it.
|
|
48
|
-
export { mcpClient, mcpServe, mockMcpClient } from '../lib/mcp/index.js';
|
|
52
|
+
export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, GatewayAuthorizationRequiredError, } from '../lib/mcp/index.js';
|
|
49
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tool-providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,uEAAuE;AACvE,wEAAwE;AACxE,0CAA0C;AAC1C,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,iCAAiC,GAClC,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* hosting/envelope — pack a conversation for storage, and refuse to unpack one
|
|
4
|
+
* you cannot read.
|
|
5
|
+
*
|
|
6
|
+
* Two functions and one rule: **an unknown format is refused by name, never
|
|
7
|
+
* guessed at.** A store outlives the code that wrote to it. Somebody will
|
|
8
|
+
* deploy a newer runtime, it will write a newer format, and an older instance
|
|
9
|
+
* still running will read it. The only honest thing that older instance can do
|
|
10
|
+
* is say which format it found, which ones it knows, and stop — because
|
|
11
|
+
* "restore what I can and hope" means an agent answering from a conversation
|
|
12
|
+
* that is missing whatever the older reader did not understand.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.readEnvelope = exports.toEnvelope = void 0;
|
|
16
|
+
const runCheckpoint_js_1 = require("../core/runCheckpoint.js");
|
|
17
|
+
/** Every format this runtime can read. Add, never redefine. */
|
|
18
|
+
const KNOWN_FORMATS = ['conversation-v1'];
|
|
19
|
+
/**
|
|
20
|
+
* Pack a conversation checkpoint for storage.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const conversation = agent.checkpoint();
|
|
24
|
+
* if (conversation) await sessions.persist(sessionId, toEnvelope(conversation));
|
|
25
|
+
*/
|
|
26
|
+
function toEnvelope(checkpoint) {
|
|
27
|
+
return { format: 'conversation-v1', data: checkpoint, savedAt: Date.now() };
|
|
28
|
+
}
|
|
29
|
+
exports.toEnvelope = toEnvelope;
|
|
30
|
+
/**
|
|
31
|
+
* Unpack a stored envelope back into a conversation checkpoint.
|
|
32
|
+
*
|
|
33
|
+
* Takes `unknown` on purpose: what comes back from a store is bytes somebody
|
|
34
|
+
* else wrote, in a format this runtime may not know, and typing the parameter
|
|
35
|
+
* as the happy shape would be assuming the very thing that needs checking.
|
|
36
|
+
*
|
|
37
|
+
* @throws TypeError naming the format when it is one this runtime cannot read,
|
|
38
|
+
* and naming the missing field when the conversation inside is malformed.
|
|
39
|
+
*/
|
|
40
|
+
function readEnvelope(envelope) {
|
|
41
|
+
if (!envelope || typeof envelope !== 'object') {
|
|
42
|
+
throw new TypeError(`[hosting] stored session is not an envelope (got ${envelope === null ? 'null' : typeof envelope}). ` + `Expected { format, data, savedAt } as written by toEnvelope().`);
|
|
43
|
+
}
|
|
44
|
+
const found = envelope.format;
|
|
45
|
+
if (typeof found !== 'string' || !KNOWN_FORMATS.includes(found)) {
|
|
46
|
+
throw new TypeError(`[hosting] unknown checkpoint format '${String(found)}'. ` +
|
|
47
|
+
`This runtime reads: ${KNOWN_FORMATS.join(', ')}. ` +
|
|
48
|
+
`Refusing rather than restoring a conversation it cannot read — a newer envelope ` +
|
|
49
|
+
`needs a runtime that knows the format that wrote it.`);
|
|
50
|
+
}
|
|
51
|
+
return (0, runCheckpoint_js_1.validateCheckpoint)(envelope.data);
|
|
52
|
+
}
|
|
53
|
+
exports.readEnvelope = readEnvelope;
|
|
54
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/hosting/envelope.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,+DAAuF;AAGvF,+DAA+D;AAC/D,MAAM,aAAa,GAAsB,CAAC,iBAAiB,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,UAA8B;IACvD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAC9E,CAAC;AAFD,gCAEC;AAED;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAC,QAAiB;IAC5C,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CACjB,oDACE,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,QACtC,KAAK,GAAG,gEAAgE,CACzE,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAI,QAAwC,CAAC,MAAM,CAAC;IAC/D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CACjB,wCAAwC,MAAM,CAAC,KAAK,CAAC,KAAK;YACxD,uBAAuB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACnD,kFAAkF;YAClF,sDAAsD,CACzD,CAAC;IACJ,CAAC;IACD,OAAO,IAAA,qCAAkB,EAAE,QAA+B,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAlBD,oCAkBC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* hosting/errors — the refusals, authored once so every adapter refuses in the
|
|
4
|
+
* same words.
|
|
5
|
+
*
|
|
6
|
+
* A refusal that varies by adapter is a refusal nobody can write a test or a
|
|
7
|
+
* runbook against. These three carry a stable `code`, name WHO refused, and say
|
|
8
|
+
* what the caller should do instead. Adapters map the codes onto whatever their
|
|
9
|
+
* transport uses to say "no" — that mapping is the adapter's business and lives
|
|
10
|
+
* in the adapter, never here.
|
|
11
|
+
*
|
|
12
|
+
* `requireCapability` is the fourth refusal and the only one that is a
|
|
13
|
+
* programming mistake rather than a runtime condition, so it throws a plain
|
|
14
|
+
* `Error`: nothing branches on "I forgot to feature-detect", it just needs to
|
|
15
|
+
* say so loudly and name the adapter it is talking about.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.requireCapability = exports.PauseNotCarriedError = exports.ConcurrentRunError = exports.HostClosedError = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Thrown when a request arrives at a host that is shutting down or shut down.
|
|
21
|
+
*
|
|
22
|
+
* `close()` lets in-flight work finish and refuses everything after it; this is
|
|
23
|
+
* what "everything after it" receives.
|
|
24
|
+
*/
|
|
25
|
+
class HostClosedError extends Error {
|
|
26
|
+
code = 'ERR_HOST_CLOSED';
|
|
27
|
+
/** Which adapter refused. */
|
|
28
|
+
hostName;
|
|
29
|
+
constructor(hostName) {
|
|
30
|
+
super(`[hosting] the '${hostName}' host is closed and is not accepting new requests. ` +
|
|
31
|
+
`In-flight requests were allowed to finish; this one arrived after close() was called. ` +
|
|
32
|
+
`Serve again on a fresh host to accept new work.`);
|
|
33
|
+
this.name = 'HostClosedError';
|
|
34
|
+
this.hostName = hostName;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.HostClosedError = HostClosedError;
|
|
38
|
+
/**
|
|
39
|
+
* Thrown when a request arrives for a session that already has a run in flight
|
|
40
|
+
* and the policy is `'reject'`.
|
|
41
|
+
*
|
|
42
|
+
* The refusal is about the SESSION, not about load: two turns of one
|
|
43
|
+
* conversation racing each other would each answer from the state the other is
|
|
44
|
+
* about to replace. A request for any OTHER session is never refused — it
|
|
45
|
+
* simply waits.
|
|
46
|
+
*/
|
|
47
|
+
class ConcurrentRunError extends Error {
|
|
48
|
+
code = 'ERR_CONCURRENT_RUN';
|
|
49
|
+
/** The session that already has a run going. */
|
|
50
|
+
sessionId;
|
|
51
|
+
/** The run that is already going, when it has announced itself. */
|
|
52
|
+
activeRunId;
|
|
53
|
+
constructor(sessionId, activeRunId) {
|
|
54
|
+
super(`[hosting] session '${sessionId}' already has a run in flight` +
|
|
55
|
+
(activeRunId ? ` (run '${activeRunId}')` : '') +
|
|
56
|
+
`. Refusing rather than running two turns of one conversation at once — ` +
|
|
57
|
+
`they would each answer from state the other is about to replace. ` +
|
|
58
|
+
`Wait for the active run, or build the standing agent with ` +
|
|
59
|
+
`onConcurrentInvoke: 'enqueue' to queue this turn behind it instead.`);
|
|
60
|
+
this.name = 'ConcurrentRunError';
|
|
61
|
+
this.sessionId = sessionId;
|
|
62
|
+
if (activeRunId !== undefined)
|
|
63
|
+
this.activeRunId = activeRunId;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ConcurrentRunError = ConcurrentRunError;
|
|
67
|
+
/**
|
|
68
|
+
* Raised when a run paused to ask a person something and the reply cannot carry
|
|
69
|
+
* a pause.
|
|
70
|
+
*
|
|
71
|
+
* **The run did not fail.** A pause is unfinished work: the agent stopped to ask
|
|
72
|
+
* and is waiting for an answer. What cannot happen here is storing it — the
|
|
73
|
+
* `'conversation-v1'` envelope holds a conversation, and a paused run is a
|
|
74
|
+
* conversation plus an engine checkpoint. So nothing is written, and the
|
|
75
|
+
* session keeps exactly the conversation it had before this request.
|
|
76
|
+
*/
|
|
77
|
+
class PauseNotCarriedError extends Error {
|
|
78
|
+
code = 'ERR_PAUSE_NOT_CARRIED';
|
|
79
|
+
/** The tool that asked, when the run recorded which one it was. */
|
|
80
|
+
toolName;
|
|
81
|
+
/** The session whose stored conversation was left untouched. */
|
|
82
|
+
sessionId;
|
|
83
|
+
constructor(toolName, sessionId) {
|
|
84
|
+
super(`[hosting] the run paused to ask a person about ` +
|
|
85
|
+
(toolName ? `'${toolName}'` : 'a tool') +
|
|
86
|
+
` and this reply cannot carry a pause. ` +
|
|
87
|
+
`The run did not fail — it is unfinished, waiting on an answer. ` +
|
|
88
|
+
`Nothing was written: ` +
|
|
89
|
+
(sessionId ? `session '${sessionId}'` : 'the session') +
|
|
90
|
+
` still holds the conversation it held before this request. ` +
|
|
91
|
+
`The 'conversation-v1' envelope stores a conversation; a paused run is a ` +
|
|
92
|
+
`conversation plus an engine checkpoint, and storing half of it would be worse ` +
|
|
93
|
+
`than storing none. Carry the pause yourself with agent.run() / agent.resume().`);
|
|
94
|
+
this.name = 'PauseNotCarriedError';
|
|
95
|
+
if (toolName !== undefined)
|
|
96
|
+
this.toolName = toolName;
|
|
97
|
+
if (sessionId !== undefined)
|
|
98
|
+
this.sessionId = sessionId;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.PauseNotCarriedError = PauseNotCarriedError;
|
|
102
|
+
/**
|
|
103
|
+
* Assert that a host can do something, and throw a corrective error naming the
|
|
104
|
+
* adapter when it cannot.
|
|
105
|
+
*
|
|
106
|
+
* This is the feature-detection law with teeth: capabilities are read, never
|
|
107
|
+
* assumed, and asking for one that is absent tells you which adapter you are
|
|
108
|
+
* actually holding rather than failing quietly somewhere downstream.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* requireCapability(host, 'streaming'); // throws unless this host streams
|
|
112
|
+
*
|
|
113
|
+
* // or branch instead of insisting:
|
|
114
|
+
* if (host.capabilities.includes('streaming')) { ... }
|
|
115
|
+
*/
|
|
116
|
+
function requireCapability(host, capability) {
|
|
117
|
+
if (host.capabilities.includes(capability))
|
|
118
|
+
return;
|
|
119
|
+
const has = host.capabilities.length > 0 ? host.capabilities.join(', ') : 'none';
|
|
120
|
+
throw new Error(`[hosting] the '${host.name}' host does not support '${capability}'. ` +
|
|
121
|
+
`It reports: ${has}. Feature-detect with ` +
|
|
122
|
+
`host.capabilities.includes('${capability}') and fall back, or serve on a host ` +
|
|
123
|
+
`that has it — capabilities are read from the adapter, never assumed from its name.`);
|
|
124
|
+
}
|
|
125
|
+
exports.requireCapability = requireCapability;
|
|
126
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/hosting/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH;;;;;GAKG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAC/B,IAAI,GAAG,iBAA0B,CAAC;IAC3C,6BAA6B;IACpB,QAAQ,CAAS;IAE1B,YAAY,QAAgB;QAC1B,KAAK,CACH,kBAAkB,QAAQ,sDAAsD;YAC9E,wFAAwF;YACxF,iDAAiD,CACpD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAdD,0CAcC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAClC,IAAI,GAAG,oBAA6B,CAAC;IAC9C,gDAAgD;IACvC,SAAS,CAAS;IAC3B,mEAAmE;IAC1D,WAAW,CAAU;IAE9B,YAAY,SAAiB,EAAE,WAAoB;QACjD,KAAK,CACH,sBAAsB,SAAS,+BAA+B;YAC5D,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,WAAW,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,yEAAyE;YACzE,mEAAmE;YACnE,4DAA4D;YAC5D,qEAAqE,CACxE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAChE,CAAC;CACF;AApBD,gDAoBC;AAED;;;;;;;;;GASG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IACpC,IAAI,GAAG,uBAAgC,CAAC;IACjD,mEAAmE;IAC1D,QAAQ,CAAU;IAC3B,gEAAgE;IACvD,SAAS,CAAU;IAE5B,YAAY,QAAiB,EAAE,SAAkB;QAC/C,KAAK,CACH,iDAAiD;YAC/C,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;YACvC,wCAAwC;YACxC,iEAAiE;YACjE,uBAAuB;YACvB,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,SAAS,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC;YACtD,6DAA6D;YAC7D,0EAA0E;YAC1E,gFAAgF;YAChF,gFAAgF,CACnF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACrD,IAAI,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC1D,CAAC;CACF;AAxBD,oDAwBC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAAC,IAAe,EAAE,UAA0B;IAC3E,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO;IACnD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACjF,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,CAAC,IAAI,4BAA4B,UAAU,KAAK;QACpE,eAAe,GAAG,wBAAwB;QAC1C,+BAA+B,UAAU,uCAAuC;QAChF,oFAAoF,CACvF,CAAC;AACJ,CAAC;AATD,8CASC"}
|