eve 0.76.3 → 0.78.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/CHANGELOG.md +43 -0
- package/dist/src/channel/adapter.d.ts +13 -4
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/send-input.d.ts +6 -2
- package/dist/src/channel/send-input.js +1 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/chunks/{use-eve-agent-BtKWTEpm.js → use-eve-agent-B8brxCk-.js} +46 -28
- package/dist/src/chunks/{use-eve-agent-jI6EsYAu.js → use-eve-agent-BSYe_Re7.js} +46 -28
- package/dist/src/cli/commands/vercel-non-interactive.d.ts +5 -3
- package/dist/src/cli/commands/vercel-non-interactive.js +1 -1
- package/dist/src/client/eve-agent-store.d.ts +2 -2
- package/dist/src/client/message-response.d.ts +2 -0
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +9 -9
- package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +6 -1
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +16 -3
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.d.ts +681 -348
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +56 -42
- package/dist/src/compiled/@ai-sdk/openai/index.js +5 -3
- package/dist/src/compiled/@ai-sdk/otel/index.js +3 -3
- package/dist/src/compiled/@ai-sdk/provider/index.d.ts +49 -15
- package/dist/src/compiled/@ai-sdk/provider/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/provider-utils/index.d.ts +4 -1
- package/dist/src/compiled/_chunks/workflow/{dist-DXLdlucM.js → dist-C8k3N3BQ.js} +2 -4
- package/dist/src/compiled/_chunks/workflow/dist-DsNhwdzf.js +1 -0
- package/dist/src/compiled/_chunks/workflow/experimental-decision-DlvnsBD-.js +3 -0
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/context/dynamic-model-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +16 -0
- package/dist/src/context/keys.js +1 -1
- package/dist/src/evals/judge.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/types.d.ts +14 -1
- package/dist/src/execution/agent-sessions/steps.d.ts +2 -0
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/catalog/connection-entry.js +1 -1
- package/dist/src/execution/catalog/search.js +1 -1
- package/dist/src/execution/catalog/step-catalog.d.ts +12 -3
- package/dist/src/execution/catalog/step-catalog.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +1 -2
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-container.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.d.ts +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-lifecycle.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/read-file.d.ts +5 -5
- package/dist/src/execution/sandbox/read-file.js +2 -2
- package/dist/src/execution/sandbox/session.d.ts +6 -0
- package/dist/src/execution/sandbox/session.js +2 -2
- package/dist/src/execution/session/active-turn.d.ts +9 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/end-sandbox-step.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +1 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +11 -4
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-inbox/inbox.d.ts +3 -0
- package/dist/src/execution/session-inbox/inbox.js +1 -1
- package/dist/src/execution/session-workflow-tool-run.d.ts +14 -12
- package/dist/src/execution/session-workflow-tool-run.js +1 -1
- package/dist/src/execution/tasks/start.d.ts +14 -1
- package/dist/src/execution/tasks/start.js +1 -1
- package/dist/src/execution/tasks/steps.d.ts +7 -4
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/apply-run-messages-step.d.ts +20 -0
- package/dist/src/execution/tools/workflow/apply-run-messages-step.js +1 -0
- package/dist/src/execution/tools/workflow/ask.d.ts +0 -1
- package/dist/src/execution/tools/workflow/ask.js +1 -1
- package/dist/src/execution/tools/workflow/interrupt.d.ts +5 -2
- package/dist/src/execution/tools/workflow/interrupt.js +1 -1
- package/dist/src/execution/tools/workflow/messages.d.ts +14 -0
- package/dist/src/execution/tools/workflow/messages.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +18 -6
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/start.d.ts +10 -0
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/step.js +1 -1
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +12 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -1
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/web-fetch/request.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +18 -3
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/attachment-staging.d.ts +13 -12
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/compaction/step.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/hitl/approvals.d.ts +4 -7
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/approved-calls.d.ts +11 -0
- package/dist/src/harness/hitl/approved-calls.js +1 -1
- package/dist/src/harness/hitl/candidates.d.ts +0 -4
- package/dist/src/harness/hitl/candidates.js +1 -1
- package/dist/src/harness/hitl/delivery.d.ts +0 -1
- package/dist/src/harness/hitl/delivery.js +1 -1
- package/dist/src/harness/hitl/index.d.ts +2 -2
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.d.ts +2 -2
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/errors.d.ts +10 -0
- package/dist/src/harness/model-call/errors.js +1 -1
- package/dist/src/harness/model-call/run.js +1 -1
- package/dist/src/harness/session-machine/state.d.ts +0 -2
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/harness/session-machine/view.d.ts +0 -3
- package/dist/src/harness/session-machine/view.js +1 -1
- package/dist/src/harness/step/after-model.js +1 -1
- package/dist/src/harness/token-estimate.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/attachments/data.d.ts +29 -10
- package/dist/src/internal/attachments/data.js +1 -1
- package/dist/src/internal/attachments/errors.d.ts +2 -2
- package/dist/src/internal/attachments/media-metadata.d.ts +15 -0
- package/dist/src/internal/attachments/media-metadata.js +1 -1
- package/dist/src/internal/attachments/public-link.d.ts +5 -0
- package/dist/src/internal/attachments/public-link.js +1 -0
- package/dist/src/internal/attachments/sandbox-refs.d.ts +7 -6
- package/dist/src/internal/attachments/sandbox-refs.js +1 -1
- package/dist/src/internal/attachments/url-refs.js +1 -1
- package/dist/src/protocol/message.d.ts +7 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/public/channels/attachment-error.d.ts +14 -0
- package/dist/src/public/channels/attachment-error.js +1 -0
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -1
- package/dist/src/public/channels/discord/defaults.js +1 -1
- package/dist/src/public/channels/github/defaults.js +1 -1
- package/dist/src/public/channels/index.d.ts +2 -0
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/channels/linear/defaults.js +1 -1
- package/dist/src/public/channels/slack/api.d.ts +10 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/approval-cards.js +1 -1
- package/dist/src/public/channels/slack/attachments.d.ts +29 -19
- package/dist/src/public/channels/slack/attachments.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +1 -1
- package/dist/src/public/channels/slack/inbound.d.ts +6 -0
- package/dist/src/public/channels/slack/inbound.js +1 -1
- package/dist/src/public/channels/slack/interaction-cards.d.ts +6 -0
- package/dist/src/public/channels/slack/interaction-cards.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/teams/defaults.js +1 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/defaults.js +1 -1
- package/dist/src/public/channels/telegram/telegramChannel.js +1 -1
- package/dist/src/public/channels/twilio/defaults.js +1 -1
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/web-options.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +2 -1
- package/dist/src/shared/channel-definition.d.ts +16 -4
- package/dist/src/svelte/index.d.ts +0 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/read-file.d.ts +3 -2
- package/dist/src/tools/provided/read-file.js +2 -2
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/vue/index.d.ts +0 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +12 -4
- package/docs/channels/chat-sdk.mdx +1 -1
- package/docs/channels/custom.mdx +30 -3
- package/docs/channels/eve.mdx +34 -0
- package/docs/channels/slack.mdx +5 -1
- package/docs/concepts/built-in-tools.md +10 -10
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/evals/overview.mdx +1 -1
- package/docs/guides/client/streaming.mdx +1 -1
- package/docs/guides/dynamic-capabilities.md +6 -2
- package/docs/memory/custom-provider.md +3 -1
- package/docs/sandbox/index.mdx +10 -4
- package/docs/tools/human-in-the-loop.md +1 -1
- package/docs/tools/overview.mdx +1 -1
- package/package.json +11 -11
- package/dist/src/compiled/_chunks/workflow/experimental-decision-BrfWf6-n.js +0 -3
- package/dist/src/context/caller-scope.d.ts +0 -7
- package/dist/src/context/caller-scope.js +0 -1
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.d.ts +0 -13
- package/dist/src/execution/tools/workflow/emit-workflow-tool-run-report-step.js +0 -1
- package/dist/src/harness/hitl/approved-call-callers.d.ts +0 -14
- package/dist/src/harness/hitl/approved-call-callers.js +0 -1
- package/dist/src/internal/attachments/refs.d.ts +0 -55
- package/dist/src/internal/attachments/refs.js +0 -1
|
@@ -70,350 +70,6 @@ declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
70
70
|
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
|
71
71
|
export declare function validateJSONRPCMessage(message: unknown): JSONRPCMessage;
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region src/tool/oauth-types.d.ts
|
|
74
|
-
/**
|
|
75
|
-
* OAuth 2.1 token response
|
|
76
|
-
*/
|
|
77
|
-
declare const OAuthTokensSchema: z.ZodObject<{
|
|
78
|
-
access_token: z.ZodString;
|
|
79
|
-
id_token: z.ZodOptional<z.ZodString>;
|
|
80
|
-
token_type: z.ZodString;
|
|
81
|
-
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
82
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
83
|
-
refresh_token: z.ZodOptional<z.ZodString>;
|
|
84
|
-
issuer: z.ZodOptional<z.ZodString>;
|
|
85
|
-
authorization_server: z.ZodOptional<z.ZodString>;
|
|
86
|
-
token_endpoint: z.ZodOptional<z.ZodString>;
|
|
87
|
-
}, z.core.$strip>;
|
|
88
|
-
declare const OAuthMetadataSchema: z.ZodObject<{
|
|
89
|
-
issuer: z.ZodString;
|
|
90
|
-
authorization_endpoint: z.ZodString;
|
|
91
|
-
token_endpoint: z.ZodString;
|
|
92
|
-
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
93
|
-
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
-
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
-
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
96
|
-
response_types_supported: z.ZodArray<z.ZodString>;
|
|
97
|
-
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
|
-
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
-
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
|
-
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
101
|
-
}, z.core.$loose>;
|
|
102
|
-
/**
|
|
103
|
-
* OpenID Connect Discovery metadata that may include OAuth 2.0 fields
|
|
104
|
-
* This schema represents the real-world scenario where OIDC providers
|
|
105
|
-
* return a mix of OpenID Connect and OAuth 2.0 metadata fields
|
|
106
|
-
*/
|
|
107
|
-
declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
|
|
108
|
-
issuer: z.ZodString;
|
|
109
|
-
authorization_endpoint: z.ZodString;
|
|
110
|
-
token_endpoint: z.ZodString;
|
|
111
|
-
userinfo_endpoint: z.ZodOptional<z.ZodString>;
|
|
112
|
-
jwks_uri: z.ZodString;
|
|
113
|
-
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
114
|
-
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
-
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
-
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
117
|
-
response_types_supported: z.ZodArray<z.ZodString>;
|
|
118
|
-
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
119
|
-
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
120
|
-
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
121
|
-
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
|
-
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
123
|
-
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
124
|
-
}, z.core.$loose>;
|
|
125
|
-
declare const OAuthClientInformationSchema: z.ZodObject<{
|
|
126
|
-
client_id: z.ZodString;
|
|
127
|
-
client_secret: z.ZodOptional<z.ZodString>;
|
|
128
|
-
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
129
|
-
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
130
|
-
issuer: z.ZodOptional<z.ZodString>;
|
|
131
|
-
authorization_server: z.ZodOptional<z.ZodString>;
|
|
132
|
-
token_endpoint: z.ZodOptional<z.ZodString>;
|
|
133
|
-
}, z.core.$strip>;
|
|
134
|
-
declare const OAuthClientMetadataSchema: z.ZodObject<{
|
|
135
|
-
redirect_uris: z.ZodArray<z.ZodString>;
|
|
136
|
-
application_type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"native">, z.ZodLiteral<"web">]>>;
|
|
137
|
-
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
138
|
-
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
|
-
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
140
|
-
client_name: z.ZodOptional<z.ZodString>;
|
|
141
|
-
client_uri: z.ZodOptional<z.ZodString>;
|
|
142
|
-
logo_uri: z.ZodOptional<z.ZodString>;
|
|
143
|
-
scope: z.ZodOptional<z.ZodString>;
|
|
144
|
-
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
-
tos_uri: z.ZodOptional<z.ZodString>;
|
|
146
|
-
policy_uri: z.ZodOptional<z.ZodString>;
|
|
147
|
-
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
148
|
-
jwks: z.ZodOptional<z.ZodAny>;
|
|
149
|
-
software_id: z.ZodOptional<z.ZodString>;
|
|
150
|
-
software_version: z.ZodOptional<z.ZodString>;
|
|
151
|
-
software_statement: z.ZodOptional<z.ZodString>;
|
|
152
|
-
}, z.core.$strip>;
|
|
153
|
-
type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
|
|
154
|
-
type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
|
|
155
|
-
type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
|
|
156
|
-
type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
|
|
157
|
-
type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
|
|
158
|
-
type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/error/oauth-error.d.ts
|
|
161
|
-
declare const symbol$1: unique symbol;
|
|
162
|
-
/**
|
|
163
|
-
* An error occurred with the MCP client within the OAuth flow.
|
|
164
|
-
*/
|
|
165
|
-
export declare class MCPClientOAuthError extends AISDKError {
|
|
166
|
-
private readonly [symbol$1];
|
|
167
|
-
constructor({ name, message, cause }: {
|
|
168
|
-
name?: string;
|
|
169
|
-
message: string;
|
|
170
|
-
cause?: unknown;
|
|
171
|
-
});
|
|
172
|
-
static isInstance(error: unknown): error is MCPClientOAuthError;
|
|
173
|
-
}
|
|
174
|
-
declare const mismatchSymbol: unique symbol;
|
|
175
|
-
export declare class AuthorizationServerMismatchError extends MCPClientOAuthError {
|
|
176
|
-
private readonly [mismatchSymbol];
|
|
177
|
-
static errorCode: string;
|
|
178
|
-
constructor({ message, cause }: {
|
|
179
|
-
message: string;
|
|
180
|
-
cause?: unknown;
|
|
181
|
-
});
|
|
182
|
-
static isInstance(error: unknown): error is AuthorizationServerMismatchError;
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/tool/oauth.d.ts
|
|
186
|
-
type AuthResult = 'AUTHORIZED' | 'REDIRECT';
|
|
187
|
-
interface OAuthAuthorizationServerInformation {
|
|
188
|
-
issuer?: string;
|
|
189
|
-
authorizationServerUrl: string;
|
|
190
|
-
tokenEndpoint: string;
|
|
191
|
-
}
|
|
192
|
-
interface OAuthClientProvider {
|
|
193
|
-
/**
|
|
194
|
-
* Returns current access token if present; undefined otherwise.
|
|
195
|
-
*/
|
|
196
|
-
tokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;
|
|
197
|
-
saveTokens(tokens: OAuthTokens): void | Promise<void>;
|
|
198
|
-
redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
|
|
199
|
-
saveCodeVerifier(codeVerifier: string): void | Promise<void>;
|
|
200
|
-
codeVerifier(): string | Promise<string>;
|
|
201
|
-
/**
|
|
202
|
-
* Adds custom client authentication to OAuth token requests.
|
|
203
|
-
*
|
|
204
|
-
* This optional method allows implementations to customize how client credentials
|
|
205
|
-
* are included in token exchange and refresh requests. When provided, this method
|
|
206
|
-
* is called instead of the default authentication logic, giving full control over
|
|
207
|
-
* the authentication mechanism.
|
|
208
|
-
*
|
|
209
|
-
* Common use cases include:
|
|
210
|
-
* - Supporting authentication methods beyond the standard OAuth 2.0 methods
|
|
211
|
-
* - Adding custom headers for proprietary authentication schemes
|
|
212
|
-
* - Implementing client assertion-based authentication (e.g., JWT bearer tokens)
|
|
213
|
-
*
|
|
214
|
-
* @param headers - The request headers (can be modified to add authentication)
|
|
215
|
-
* @param params - The request body parameters (can be modified to add credentials)
|
|
216
|
-
* @param url - The token endpoint URL being called
|
|
217
|
-
* @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods
|
|
218
|
-
*/
|
|
219
|
-
addClientAuthentication?(headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata): void | Promise<void>;
|
|
220
|
-
/**
|
|
221
|
-
* If implemented, provides a way for the client to invalidate (e.g. delete) the specified
|
|
222
|
-
* credentials, in the case where the server has indicated that they are no longer valid.
|
|
223
|
-
* This avoids requiring the user to intervene manually.
|
|
224
|
-
*
|
|
225
|
-
* For token invalidation, context identifies the token generation being invalidated
|
|
226
|
-
* when available. Providers sharing storage must atomically compare and delete
|
|
227
|
-
* that generation so a concurrent refresh's tokens are preserved. Omitting or
|
|
228
|
-
* ignoring context retains unconditional invalidation.
|
|
229
|
-
*/
|
|
230
|
-
invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier', context?: {
|
|
231
|
-
tokens: OAuthTokens;
|
|
232
|
-
}): void | Promise<void>;
|
|
233
|
-
get redirectUrl(): string | URL;
|
|
234
|
-
get clientMetadata(): OAuthClientMetadata;
|
|
235
|
-
clientInformation(): OAuthClientInformation | undefined | Promise<OAuthClientInformation | undefined>;
|
|
236
|
-
/**
|
|
237
|
-
* Returns whether the current client information was obtained through
|
|
238
|
-
* dynamic client registration.
|
|
239
|
-
*
|
|
240
|
-
* Return `true` only when the current client information was saved after a
|
|
241
|
-
* dynamic registration response. When this method is omitted or returns
|
|
242
|
-
* `false`, the client information is treated as pre-registered and is not
|
|
243
|
-
* automatically invalidated after client authentication errors.
|
|
244
|
-
*/
|
|
245
|
-
isClientInformationDynamicallyRegistered?(): boolean | Promise<boolean>;
|
|
246
|
-
saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise<void>;
|
|
247
|
-
authorizationServerInformation?(): OAuthAuthorizationServerInformation | undefined | Promise<OAuthAuthorizationServerInformation | undefined>;
|
|
248
|
-
saveAuthorizationServerInformation?(authorizationServerInformation: OAuthAuthorizationServerInformation): void | Promise<void>;
|
|
249
|
-
/**
|
|
250
|
-
* Validates an authorization server URL discovered from MCP protected resource
|
|
251
|
-
* metadata before the client fetches its OAuth metadata.
|
|
252
|
-
*/
|
|
253
|
-
validateAuthorizationServerURL?(serverUrl: string | URL, authorizationServerUrl: string | URL): void | Promise<void>;
|
|
254
|
-
state?(): string | Promise<string>;
|
|
255
|
-
saveState?(state: string): void | Promise<void>;
|
|
256
|
-
storedState?(): string | undefined | Promise<string | undefined>;
|
|
257
|
-
validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
|
|
258
|
-
}
|
|
259
|
-
export declare class UnauthorizedError extends Error {
|
|
260
|
-
constructor(message?: string);
|
|
261
|
-
}
|
|
262
|
-
export declare function auth(provider: OAuthClientProvider, options: {
|
|
263
|
-
serverUrl: string | URL;
|
|
264
|
-
authorizationCode?: string;
|
|
265
|
-
callbackState?: string;
|
|
266
|
-
/**
|
|
267
|
-
* Value of the `iss` parameter from the authorization response.
|
|
268
|
-
*/
|
|
269
|
-
callbackIssuer?: string;
|
|
270
|
-
scope?: string;
|
|
271
|
-
resourceMetadataUrl?: URL;
|
|
272
|
-
fetchFn?: FetchFunction;
|
|
273
|
-
}): Promise<AuthResult>;
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/tool/mcp-transport.d.ts
|
|
276
|
-
/**
|
|
277
|
-
* Transport interface for MCP (Model Context Protocol) communication.
|
|
278
|
-
* Maps to the `Transport` interface in the MCP spec.
|
|
279
|
-
*/
|
|
280
|
-
type MCPTransportSendOptions = {
|
|
281
|
-
/**
|
|
282
|
-
* Cancels the transport operation for this message.
|
|
283
|
-
*/
|
|
284
|
-
signal?: AbortSignal;
|
|
285
|
-
/**
|
|
286
|
-
* Request-specific HTTP headers produced from MCP tool parameters.
|
|
287
|
-
*/
|
|
288
|
-
headers?: Record<string, string>;
|
|
289
|
-
/**
|
|
290
|
-
* Associates an outgoing message with an incoming request.
|
|
291
|
-
*/
|
|
292
|
-
relatedRequestId?: string | number;
|
|
293
|
-
/**
|
|
294
|
-
* Resumes a previously interrupted request.
|
|
295
|
-
*/
|
|
296
|
-
resumptionToken?: string;
|
|
297
|
-
/**
|
|
298
|
-
* Receives updated resumption tokens from transports that support them.
|
|
299
|
-
*/
|
|
300
|
-
onresumptiontoken?: (token: string) => void;
|
|
301
|
-
};
|
|
302
|
-
type MCPTransportCloseOptions = {
|
|
303
|
-
/**
|
|
304
|
-
* Cancels transport cleanup.
|
|
305
|
-
*/
|
|
306
|
-
signal?: AbortSignal;
|
|
307
|
-
};
|
|
308
|
-
interface MCPTransport {
|
|
309
|
-
/**
|
|
310
|
-
* Whether this transport can probe for stateless MCP protocol versions.
|
|
311
|
-
*
|
|
312
|
-
* Custom transports default to the legacy initialization flow unless they
|
|
313
|
-
* explicitly opt in.
|
|
314
|
-
*/
|
|
315
|
-
supportsProtocolVersionDiscovery?: boolean;
|
|
316
|
-
/**
|
|
317
|
-
* Whether this transport mirrors x-mcp-header tool parameters into request
|
|
318
|
-
* headers.
|
|
319
|
-
*/
|
|
320
|
-
supportsMcpToolParameterHeaders?: boolean;
|
|
321
|
-
/**
|
|
322
|
-
* Initialize and start the transport
|
|
323
|
-
*/
|
|
324
|
-
start(): Promise<void>;
|
|
325
|
-
/**
|
|
326
|
-
* Send a JSON-RPC message through the transport
|
|
327
|
-
* @param message The JSON-RPC message to send
|
|
328
|
-
* @param options Optional request-scoped cancellation options
|
|
329
|
-
*/
|
|
330
|
-
send(message: JSONRPCMessage, options?: MCPTransportSendOptions): Promise<void>;
|
|
331
|
-
/**
|
|
332
|
-
* Clean up and close the transport
|
|
333
|
-
* @param options Optional cancellation options for transport cleanup
|
|
334
|
-
*/
|
|
335
|
-
close(options?: MCPTransportCloseOptions): Promise<void>;
|
|
336
|
-
/**
|
|
337
|
-
* Event handler for transport closure
|
|
338
|
-
*/
|
|
339
|
-
onclose?: () => void;
|
|
340
|
-
/**
|
|
341
|
-
* Event handler for transport errors
|
|
342
|
-
*/
|
|
343
|
-
onerror?: (error: Error) => void;
|
|
344
|
-
/**
|
|
345
|
-
* Event handler for received messages
|
|
346
|
-
*/
|
|
347
|
-
onmessage?: (message: JSONRPCMessage) => void;
|
|
348
|
-
/**
|
|
349
|
-
* The protocol version negotiated during initialization.
|
|
350
|
-
*/
|
|
351
|
-
protocolVersion?: string;
|
|
352
|
-
/**
|
|
353
|
-
* Set the protocol version negotiated during initialization.
|
|
354
|
-
*/
|
|
355
|
-
setProtocolVersion?(version: string): void;
|
|
356
|
-
}
|
|
357
|
-
type MCPTransportConfig = {
|
|
358
|
-
type: 'sse' | 'http';
|
|
359
|
-
/**
|
|
360
|
-
* The URL of the MCP server.
|
|
361
|
-
*/
|
|
362
|
-
url: string;
|
|
363
|
-
/**
|
|
364
|
-
* Additional HTTP headers to be sent with requests.
|
|
365
|
-
*/
|
|
366
|
-
headers?: Record<string, string>;
|
|
367
|
-
/**
|
|
368
|
-
* An optional OAuth client provider to use for authentication for MCP servers.
|
|
369
|
-
*/
|
|
370
|
-
authProvider?: OAuthClientProvider;
|
|
371
|
-
/**
|
|
372
|
-
* Controls how HTTP redirects are handled for transport requests.
|
|
373
|
-
* - `'follow'`: Follow redirects automatically (standard fetch behavior).
|
|
374
|
-
* - `'error'`: Reject any redirect response with an error.
|
|
375
|
-
* @default 'error'
|
|
376
|
-
*/
|
|
377
|
-
redirect?: 'follow' | 'error';
|
|
378
|
-
/**
|
|
379
|
-
* Initial MCP session id to send with resumed Streamable HTTP requests after
|
|
380
|
-
* initialization.
|
|
381
|
-
* Only used by the HTTP transport.
|
|
382
|
-
*/
|
|
383
|
-
initialSessionId?: string;
|
|
384
|
-
/**
|
|
385
|
-
* Initial MCP protocol version to send before initialize negotiates one.
|
|
386
|
-
* Only used by the HTTP transport.
|
|
387
|
-
*/
|
|
388
|
-
initialProtocolVersion?: string;
|
|
389
|
-
/**
|
|
390
|
-
* Called when the Streamable HTTP server creates, changes, or clears the MCP
|
|
391
|
-
* session id.
|
|
392
|
-
* Only used by the HTTP transport.
|
|
393
|
-
*/
|
|
394
|
-
onSessionIdChange?: (sessionId: string | undefined) => void;
|
|
395
|
-
/**
|
|
396
|
-
* Called when a Streamable HTTP request returns 404 for an existing MCP
|
|
397
|
-
* session id. The transport clears the session id before reporting the
|
|
398
|
-
* underlying HTTP error.
|
|
399
|
-
* Only used by the HTTP transport.
|
|
400
|
-
*/
|
|
401
|
-
onSessionExpired?: (sessionId: string) => void;
|
|
402
|
-
/**
|
|
403
|
-
* Whether close() should send DELETE for the current MCP session id.
|
|
404
|
-
* Set to false when the application intends to reattach to the session later.
|
|
405
|
-
* Only used by the HTTP transport.
|
|
406
|
-
* @default true
|
|
407
|
-
*/
|
|
408
|
-
terminateSessionOnClose?: boolean;
|
|
409
|
-
/**
|
|
410
|
-
* Optional custom fetch implementation to use for HTTP requests.
|
|
411
|
-
* Useful for runtimes that need a request-local fetch.
|
|
412
|
-
* @default globalThis.fetch
|
|
413
|
-
*/
|
|
414
|
-
fetch?: FetchFunction;
|
|
415
|
-
};
|
|
416
|
-
//#endregion
|
|
417
73
|
//#region src/tool/types.d.ts
|
|
418
74
|
type McpProviderMetadata = {
|
|
419
75
|
clientName?: string;
|
|
@@ -472,7 +128,7 @@ declare const RequestSchema: z.ZodObject<{
|
|
|
472
128
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
473
129
|
}, z.core.$loose>>;
|
|
474
130
|
}, z.core.$strip>;
|
|
475
|
-
type Request = z.infer<typeof RequestSchema>;
|
|
131
|
+
type Request$1 = z.infer<typeof RequestSchema>;
|
|
476
132
|
type RequestOptions = {
|
|
477
133
|
signal?: AbortSignal;
|
|
478
134
|
timeout?: number;
|
|
@@ -489,6 +145,9 @@ declare const InitializeResultSchema: z.ZodObject<{
|
|
|
489
145
|
resultType: z.ZodOptional<z.ZodString>;
|
|
490
146
|
protocolVersion: z.ZodString;
|
|
491
147
|
capabilities: z.ZodObject<{
|
|
148
|
+
events: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
149
|
+
listChanged: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
150
|
+
}, z.core.$loose>>>;
|
|
492
151
|
experimental: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
493
152
|
logging: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
494
153
|
completions: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
@@ -514,7 +173,7 @@ declare const InitializeResultSchema: z.ZodObject<{
|
|
|
514
173
|
instructions: z.ZodOptional<z.ZodString>;
|
|
515
174
|
}, z.core.$loose>;
|
|
516
175
|
type InitializeResult = z.infer<typeof InitializeResultSchema>;
|
|
517
|
-
type PaginatedRequest = Request & {
|
|
176
|
+
type PaginatedRequest = Request$1 & {
|
|
518
177
|
params?: BaseParams & {
|
|
519
178
|
cursor?: string;
|
|
520
179
|
};
|
|
@@ -825,8 +484,609 @@ export declare const ElicitResultSchema: z.ZodObject<{
|
|
|
825
484
|
}, z.core.$loose>;
|
|
826
485
|
type ElicitResult = z.infer<typeof ElicitResultSchema>;
|
|
827
486
|
//#endregion
|
|
487
|
+
//#region src/tool/mcp-event-types.d.ts
|
|
488
|
+
declare const MCPEventDefinitionSchema: z.ZodObject<{
|
|
489
|
+
name: z.ZodString;
|
|
490
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
491
|
+
delivery: z.ZodArray<z.ZodEnum<{
|
|
492
|
+
webhook: "webhook";
|
|
493
|
+
poll: "poll";
|
|
494
|
+
push: "push";
|
|
495
|
+
}>>;
|
|
496
|
+
inputSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
497
|
+
payloadSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
498
|
+
}, z.core.$loose>;
|
|
499
|
+
type MCPEventDefinition = z.infer<typeof MCPEventDefinitionSchema>;
|
|
500
|
+
declare const ListEventsResultSchema: z.ZodObject<{
|
|
501
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
502
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
503
|
+
events: z.ZodArray<z.ZodObject<{
|
|
504
|
+
name: z.ZodString;
|
|
505
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
506
|
+
delivery: z.ZodArray<z.ZodEnum<{
|
|
507
|
+
webhook: "webhook";
|
|
508
|
+
poll: "poll";
|
|
509
|
+
push: "push";
|
|
510
|
+
}>>;
|
|
511
|
+
inputSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
512
|
+
payloadSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
513
|
+
}, z.core.$loose>>;
|
|
514
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
515
|
+
}, z.core.$loose>;
|
|
516
|
+
type ListEventsResult = z.infer<typeof ListEventsResultSchema>;
|
|
517
|
+
declare const SubscribeEventResultSchema: z.ZodObject<{
|
|
518
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
519
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
520
|
+
id: z.ZodString;
|
|
521
|
+
refreshBefore: z.ZodNullable<z.ZodISODateTime>;
|
|
522
|
+
cursor: z.ZodPipe<z.ZodOptional<z.ZodNullable<z.ZodString>>, z.ZodTransform<string | null, string | null | undefined>>;
|
|
523
|
+
truncated: z.ZodBoolean;
|
|
524
|
+
}, z.core.$loose>;
|
|
525
|
+
type SubscribeEventResult = z.infer<typeof SubscribeEventResultSchema>;
|
|
526
|
+
declare const MCPEventSchema: z.ZodObject<{
|
|
527
|
+
eventId: z.ZodString;
|
|
528
|
+
name: z.ZodString;
|
|
529
|
+
timestamp: z.ZodISODateTime;
|
|
530
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
531
|
+
cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
532
|
+
}, z.core.$loose>;
|
|
533
|
+
type MCPEvent = z.infer<typeof MCPEventSchema>;
|
|
534
|
+
declare const MCPEventControlSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
535
|
+
type: z.ZodLiteral<"gap">;
|
|
536
|
+
cursor: z.ZodString;
|
|
537
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
538
|
+
type: z.ZodLiteral<"terminated">;
|
|
539
|
+
error: z.ZodObject<{
|
|
540
|
+
code: z.ZodNumber;
|
|
541
|
+
message: z.ZodString;
|
|
542
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
543
|
+
}, z.core.$loose>;
|
|
544
|
+
}, z.core.$loose>]>, z.ZodTransform<{
|
|
545
|
+
[x: string]: unknown;
|
|
546
|
+
type: "terminated";
|
|
547
|
+
error: {
|
|
548
|
+
[x: string]: unknown;
|
|
549
|
+
code: number;
|
|
550
|
+
message: string;
|
|
551
|
+
data?: unknown;
|
|
552
|
+
};
|
|
553
|
+
} | {
|
|
554
|
+
truncated: true;
|
|
555
|
+
type: "gap";
|
|
556
|
+
cursor: string;
|
|
557
|
+
}, {
|
|
558
|
+
[x: string]: unknown;
|
|
559
|
+
type: "gap";
|
|
560
|
+
cursor: string;
|
|
561
|
+
} | {
|
|
562
|
+
[x: string]: unknown;
|
|
563
|
+
type: "terminated";
|
|
564
|
+
error: {
|
|
565
|
+
[x: string]: unknown;
|
|
566
|
+
code: number;
|
|
567
|
+
message: string;
|
|
568
|
+
data?: unknown;
|
|
569
|
+
};
|
|
570
|
+
}>>;
|
|
571
|
+
type MCPEventControl = z.infer<typeof MCPEventControlSchema>;
|
|
572
|
+
/** Persisted privately by the application, including the signing secret. */
|
|
573
|
+
type MCPEventSubscription = {
|
|
574
|
+
key: string;
|
|
575
|
+
id?: string;
|
|
576
|
+
name: string;
|
|
577
|
+
arguments: JSONObject;
|
|
578
|
+
definition: MCPEventDefinition;
|
|
579
|
+
delivery: {
|
|
580
|
+
mode: 'webhook';
|
|
581
|
+
url: string;
|
|
582
|
+
secret: string;
|
|
583
|
+
};
|
|
584
|
+
refreshBefore?: string | null;
|
|
585
|
+
cursor: string | null;
|
|
586
|
+
truncated: boolean;
|
|
587
|
+
ttlMs?: number | null;
|
|
588
|
+
maxAgeMs?: number;
|
|
589
|
+
status: 'pending' | 'active';
|
|
590
|
+
};
|
|
591
|
+
/** Subscription metadata safe to pass to event handlers; excludes the secret. */
|
|
592
|
+
type MCPEventSubscriptionInfo = {
|
|
593
|
+
id: string;
|
|
594
|
+
name: string;
|
|
595
|
+
arguments: JSONObject;
|
|
596
|
+
delivery: {
|
|
597
|
+
mode: 'webhook';
|
|
598
|
+
url: string;
|
|
599
|
+
};
|
|
600
|
+
refreshBefore: string | null;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Use durable, private storage scoped to one MCP server and authenticated
|
|
604
|
+
* principal. update must atomically merge only the supplied fields. Never
|
|
605
|
+
* expose these records to a browser: delivery.secret authenticates webhooks.
|
|
606
|
+
*/
|
|
607
|
+
interface MCPEventStore {
|
|
608
|
+
get(key: string): Promise<MCPEventSubscription | undefined>;
|
|
609
|
+
getById(id: string): Promise<MCPEventSubscription | undefined>;
|
|
610
|
+
set(subscription: MCPEventSubscription): Promise<void>;
|
|
611
|
+
update(key: string, patch: Partial<MCPEventSubscription>): Promise<void>;
|
|
612
|
+
delete(key: string): Promise<void>;
|
|
613
|
+
}
|
|
614
|
+
type MCPEventsConfig = {
|
|
615
|
+
store: MCPEventStore;
|
|
616
|
+
adapter?: never;
|
|
617
|
+
/**
|
|
618
|
+
* Optionally validate subscription arguments using an application schema or
|
|
619
|
+
* the server's inputSchema. Throw to reject before persisting or subscribing.
|
|
620
|
+
*/
|
|
621
|
+
validateArguments?: (args: {
|
|
622
|
+
definition: MCPEventDefinition;
|
|
623
|
+
arguments: JSONObject;
|
|
624
|
+
}) => void | PromiseLike<void>;
|
|
625
|
+
} | {
|
|
626
|
+
adapter: MCPEventAdapter;
|
|
627
|
+
store?: never;
|
|
628
|
+
validateArguments?: never;
|
|
629
|
+
};
|
|
630
|
+
type SubscribeEventOptions = {
|
|
631
|
+
name: string;
|
|
632
|
+
arguments?: JSONObject;
|
|
633
|
+
delivery: {
|
|
634
|
+
mode: 'webhook';
|
|
635
|
+
/** HTTPS callback served by createMCPEventWebhook before subscribing. */
|
|
636
|
+
url: string;
|
|
637
|
+
/** Development only: allow HTTP callbacks to literal loopback addresses. */
|
|
638
|
+
allowInsecureLocalhost?: boolean;
|
|
639
|
+
/** Generated securely when omitted; persisted before the subscribe request. */
|
|
640
|
+
secret?: string;
|
|
641
|
+
};
|
|
642
|
+
cursor?: string | null;
|
|
643
|
+
ttlMs?: number | null;
|
|
644
|
+
maxAgeMs?: number;
|
|
645
|
+
options?: RequestOptions;
|
|
646
|
+
};
|
|
647
|
+
type MCPEventSubscriptionOptions = ({
|
|
648
|
+
id: string;
|
|
649
|
+
key?: never;
|
|
650
|
+
} | {
|
|
651
|
+
key: string;
|
|
652
|
+
id?: never;
|
|
653
|
+
}) & {
|
|
654
|
+
options?: RequestOptions;
|
|
655
|
+
};
|
|
656
|
+
interface MCPEvents {
|
|
657
|
+
list(options?: {
|
|
658
|
+
params?: {
|
|
659
|
+
cursor?: string;
|
|
660
|
+
};
|
|
661
|
+
options?: RequestOptions;
|
|
662
|
+
}): Promise<ListEventsResult>;
|
|
663
|
+
subscribe(options: SubscribeEventOptions): Promise<SubscribeEventResult>;
|
|
664
|
+
refresh(options: MCPEventSubscriptionOptions): Promise<SubscribeEventResult>;
|
|
665
|
+
unsubscribe(options: MCPEventSubscriptionOptions): Promise<void>;
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
668
|
+
//#region src/tool/mcp-events-adapter.d.ts
|
|
669
|
+
/** A durable watch owned by the adapter's backend, not an upstream MCP lease. */
|
|
670
|
+
type ManagedSubscription = {
|
|
671
|
+
/** Backend subscription ID; use it for managed lifecycle operations. */
|
|
672
|
+
id: string;
|
|
673
|
+
name: string;
|
|
674
|
+
arguments: JSONObject;
|
|
675
|
+
status: 'pending' | 'active' | 'needs_auth' | 'stopped' | 'expired' | 'failed';
|
|
676
|
+
/** Application monitoring deadline. null means until explicitly stopped. */
|
|
677
|
+
expiresAt: string | null;
|
|
678
|
+
cleanupStatus?: 'pending' | 'complete' | 'exhausted';
|
|
679
|
+
};
|
|
680
|
+
type ManagedSubscribeInput = {
|
|
681
|
+
name: string;
|
|
682
|
+
arguments: JSONObject;
|
|
683
|
+
/** Application metadata, not an authorization grant. */
|
|
684
|
+
context?: JSONObject;
|
|
685
|
+
/** Reuse the original key when recovering an uncertain create result. */
|
|
686
|
+
idempotencyKey: string;
|
|
687
|
+
options?: RequestOptions;
|
|
688
|
+
} & ({
|
|
689
|
+
ttlMs: number;
|
|
690
|
+
expiresAt?: never;
|
|
691
|
+
} | {
|
|
692
|
+
expiresAt: string | null;
|
|
693
|
+
ttlMs?: never;
|
|
694
|
+
});
|
|
695
|
+
/**
|
|
696
|
+
* Bound to an authorized account and destination by the application. The backend
|
|
697
|
+
* owns callback provisioning, verification, persistence, renewal and cleanup.
|
|
698
|
+
* Implementations must honor request options and preserve actionable errors.
|
|
699
|
+
* Cancelling a request does not cancel an already accepted remote subscription.
|
|
700
|
+
*/
|
|
701
|
+
interface MCPEventOperations {
|
|
702
|
+
subscribe(input: ManagedSubscribeInput): Promise<ManagedSubscription>;
|
|
703
|
+
getSubscription(input: {
|
|
704
|
+
id: string;
|
|
705
|
+
options?: RequestOptions;
|
|
706
|
+
}): Promise<ManagedSubscription>;
|
|
707
|
+
listSubscriptions(input?: {
|
|
708
|
+
cursor?: string;
|
|
709
|
+
limit?: number;
|
|
710
|
+
status?: ManagedSubscription['status'];
|
|
711
|
+
options?: RequestOptions;
|
|
712
|
+
}): Promise<{
|
|
713
|
+
subscriptions: ManagedSubscription[];
|
|
714
|
+
nextCursor?: string;
|
|
715
|
+
}>;
|
|
716
|
+
unsubscribe(input: {
|
|
717
|
+
id: string;
|
|
718
|
+
options?: RequestOptions;
|
|
719
|
+
}): Promise<ManagedSubscription>;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Creates bound subscription operations once per client, before the transport starts.
|
|
723
|
+
* Receives transport metadata, not credentials or a live transport instance.
|
|
724
|
+
* HTTP/SSE URLs are the configured endpoints, not resolved redirect targets.
|
|
725
|
+
* Custom transports have no standard URL and receive only their type.
|
|
726
|
+
*/
|
|
727
|
+
interface MCPEventAdapter {
|
|
728
|
+
createAdapter(context: {
|
|
729
|
+
transport: {
|
|
730
|
+
type: 'http' | 'sse';
|
|
731
|
+
url: string;
|
|
732
|
+
} | {
|
|
733
|
+
type: 'custom';
|
|
734
|
+
};
|
|
735
|
+
}): MCPEventOperations;
|
|
736
|
+
}
|
|
737
|
+
/** Catalog discovery uses MCP; all subscription operations use the adapter. */
|
|
738
|
+
interface ManagedMCPEvents extends MCPEventOperations {
|
|
739
|
+
list: MCPEvents['list'];
|
|
740
|
+
}
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region src/tool/oauth-types.d.ts
|
|
743
|
+
/**
|
|
744
|
+
* OAuth 2.1 token response
|
|
745
|
+
*/
|
|
746
|
+
declare const OAuthTokensSchema: z.ZodObject<{
|
|
747
|
+
access_token: z.ZodString;
|
|
748
|
+
id_token: z.ZodOptional<z.ZodString>;
|
|
749
|
+
token_type: z.ZodString;
|
|
750
|
+
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
751
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
752
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
753
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
754
|
+
authorization_server: z.ZodOptional<z.ZodString>;
|
|
755
|
+
token_endpoint: z.ZodOptional<z.ZodString>;
|
|
756
|
+
}, z.core.$strip>;
|
|
757
|
+
declare const OAuthMetadataSchema: z.ZodObject<{
|
|
758
|
+
issuer: z.ZodString;
|
|
759
|
+
authorization_endpoint: z.ZodString;
|
|
760
|
+
token_endpoint: z.ZodString;
|
|
761
|
+
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
762
|
+
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
763
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
764
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
765
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
766
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
767
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
768
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
769
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
770
|
+
}, z.core.$loose>;
|
|
771
|
+
/**
|
|
772
|
+
* OpenID Connect Discovery metadata that may include OAuth 2.0 fields
|
|
773
|
+
* This schema represents the real-world scenario where OIDC providers
|
|
774
|
+
* return a mix of OpenID Connect and OAuth 2.0 metadata fields
|
|
775
|
+
*/
|
|
776
|
+
declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
|
|
777
|
+
issuer: z.ZodString;
|
|
778
|
+
authorization_endpoint: z.ZodString;
|
|
779
|
+
token_endpoint: z.ZodString;
|
|
780
|
+
userinfo_endpoint: z.ZodOptional<z.ZodString>;
|
|
781
|
+
jwks_uri: z.ZodString;
|
|
782
|
+
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
783
|
+
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
784
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
785
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
786
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
787
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
788
|
+
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
789
|
+
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
790
|
+
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
791
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
792
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
793
|
+
}, z.core.$loose>;
|
|
794
|
+
declare const OAuthClientInformationSchema: z.ZodObject<{
|
|
795
|
+
client_id: z.ZodString;
|
|
796
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
797
|
+
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
798
|
+
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
799
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
800
|
+
authorization_server: z.ZodOptional<z.ZodString>;
|
|
801
|
+
token_endpoint: z.ZodOptional<z.ZodString>;
|
|
802
|
+
}, z.core.$strip>;
|
|
803
|
+
declare const OAuthClientMetadataSchema: z.ZodObject<{
|
|
804
|
+
redirect_uris: z.ZodArray<z.ZodString>;
|
|
805
|
+
application_type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"native">, z.ZodLiteral<"web">]>>;
|
|
806
|
+
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
807
|
+
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
808
|
+
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
809
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
810
|
+
client_uri: z.ZodOptional<z.ZodString>;
|
|
811
|
+
logo_uri: z.ZodOptional<z.ZodString>;
|
|
812
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
813
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
814
|
+
tos_uri: z.ZodOptional<z.ZodString>;
|
|
815
|
+
policy_uri: z.ZodOptional<z.ZodString>;
|
|
816
|
+
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
817
|
+
jwks: z.ZodOptional<z.ZodAny>;
|
|
818
|
+
software_id: z.ZodOptional<z.ZodString>;
|
|
819
|
+
software_version: z.ZodOptional<z.ZodString>;
|
|
820
|
+
software_statement: z.ZodOptional<z.ZodString>;
|
|
821
|
+
}, z.core.$strip>;
|
|
822
|
+
type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
|
|
823
|
+
type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
|
|
824
|
+
type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
|
|
825
|
+
type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
|
|
826
|
+
type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
|
|
827
|
+
type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/error/oauth-error.d.ts
|
|
830
|
+
declare const symbol$1: unique symbol;
|
|
831
|
+
/**
|
|
832
|
+
* An error occurred with the MCP client within the OAuth flow.
|
|
833
|
+
*/
|
|
834
|
+
export declare class MCPClientOAuthError extends AISDKError {
|
|
835
|
+
private readonly [symbol$1];
|
|
836
|
+
constructor({ name, message, cause }: {
|
|
837
|
+
name?: string;
|
|
838
|
+
message: string;
|
|
839
|
+
cause?: unknown;
|
|
840
|
+
});
|
|
841
|
+
static isInstance(error: unknown): error is MCPClientOAuthError;
|
|
842
|
+
}
|
|
843
|
+
declare const mismatchSymbol: unique symbol;
|
|
844
|
+
export declare class AuthorizationServerMismatchError extends MCPClientOAuthError {
|
|
845
|
+
private readonly [mismatchSymbol];
|
|
846
|
+
static errorCode: string;
|
|
847
|
+
constructor({ message, cause }: {
|
|
848
|
+
message: string;
|
|
849
|
+
cause?: unknown;
|
|
850
|
+
});
|
|
851
|
+
static isInstance(error: unknown): error is AuthorizationServerMismatchError;
|
|
852
|
+
}
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/tool/oauth.d.ts
|
|
855
|
+
type AuthResult = 'AUTHORIZED' | 'REDIRECT';
|
|
856
|
+
interface OAuthAuthorizationServerInformation {
|
|
857
|
+
issuer?: string;
|
|
858
|
+
authorizationServerUrl: string;
|
|
859
|
+
tokenEndpoint: string;
|
|
860
|
+
}
|
|
861
|
+
interface OAuthClientProvider {
|
|
862
|
+
/**
|
|
863
|
+
* Returns current access token if present; undefined otherwise.
|
|
864
|
+
*/
|
|
865
|
+
tokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;
|
|
866
|
+
saveTokens(tokens: OAuthTokens): void | Promise<void>;
|
|
867
|
+
redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
|
|
868
|
+
saveCodeVerifier(codeVerifier: string): void | Promise<void>;
|
|
869
|
+
codeVerifier(): string | Promise<string>;
|
|
870
|
+
/**
|
|
871
|
+
* Adds custom client authentication to OAuth token requests.
|
|
872
|
+
*
|
|
873
|
+
* This optional method allows implementations to customize how client credentials
|
|
874
|
+
* are included in token exchange and refresh requests. When provided, this method
|
|
875
|
+
* is called instead of the default authentication logic, giving full control over
|
|
876
|
+
* the authentication mechanism.
|
|
877
|
+
*
|
|
878
|
+
* Common use cases include:
|
|
879
|
+
* - Supporting authentication methods beyond the standard OAuth 2.0 methods
|
|
880
|
+
* - Adding custom headers for proprietary authentication schemes
|
|
881
|
+
* - Implementing client assertion-based authentication (e.g., JWT bearer tokens)
|
|
882
|
+
*
|
|
883
|
+
* @param headers - The request headers (can be modified to add authentication)
|
|
884
|
+
* @param params - The request body parameters (can be modified to add credentials)
|
|
885
|
+
* @param url - The token endpoint URL being called
|
|
886
|
+
* @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods
|
|
887
|
+
*/
|
|
888
|
+
addClientAuthentication?(headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata): void | Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* If implemented, provides a way for the client to invalidate (e.g. delete) the specified
|
|
891
|
+
* credentials, in the case where the server has indicated that they are no longer valid.
|
|
892
|
+
* This avoids requiring the user to intervene manually.
|
|
893
|
+
*
|
|
894
|
+
* For token invalidation, context identifies the token generation being invalidated
|
|
895
|
+
* when available. Providers sharing storage must atomically compare and delete
|
|
896
|
+
* that generation so a concurrent refresh's tokens are preserved. Omitting or
|
|
897
|
+
* ignoring context retains unconditional invalidation.
|
|
898
|
+
*/
|
|
899
|
+
invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier', context?: {
|
|
900
|
+
tokens: OAuthTokens;
|
|
901
|
+
}): void | Promise<void>;
|
|
902
|
+
get redirectUrl(): string | URL;
|
|
903
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
904
|
+
clientInformation(): OAuthClientInformation | undefined | Promise<OAuthClientInformation | undefined>;
|
|
905
|
+
/**
|
|
906
|
+
* Returns whether the current client information was obtained through
|
|
907
|
+
* dynamic client registration.
|
|
908
|
+
*
|
|
909
|
+
* Return `true` only when the current client information was saved after a
|
|
910
|
+
* dynamic registration response. When this method is omitted or returns
|
|
911
|
+
* `false`, the client information is treated as pre-registered and is not
|
|
912
|
+
* automatically invalidated after client authentication errors.
|
|
913
|
+
*/
|
|
914
|
+
isClientInformationDynamicallyRegistered?(): boolean | Promise<boolean>;
|
|
915
|
+
saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise<void>;
|
|
916
|
+
authorizationServerInformation?(): OAuthAuthorizationServerInformation | undefined | Promise<OAuthAuthorizationServerInformation | undefined>;
|
|
917
|
+
saveAuthorizationServerInformation?(authorizationServerInformation: OAuthAuthorizationServerInformation): void | Promise<void>;
|
|
918
|
+
/**
|
|
919
|
+
* Validates an authorization server URL discovered from MCP protected resource
|
|
920
|
+
* metadata before the client fetches its OAuth metadata.
|
|
921
|
+
*/
|
|
922
|
+
validateAuthorizationServerURL?(serverUrl: string | URL, authorizationServerUrl: string | URL): void | Promise<void>;
|
|
923
|
+
state?(): string | Promise<string>;
|
|
924
|
+
saveState?(state: string): void | Promise<void>;
|
|
925
|
+
storedState?(): string | undefined | Promise<string | undefined>;
|
|
926
|
+
validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
|
|
927
|
+
}
|
|
928
|
+
export declare class UnauthorizedError extends Error {
|
|
929
|
+
constructor(message?: string);
|
|
930
|
+
}
|
|
931
|
+
export declare function auth(provider: OAuthClientProvider, options: {
|
|
932
|
+
serverUrl: string | URL;
|
|
933
|
+
authorizationCode?: string;
|
|
934
|
+
callbackState?: string;
|
|
935
|
+
/**
|
|
936
|
+
* Value of the `iss` parameter from the authorization response.
|
|
937
|
+
*/
|
|
938
|
+
callbackIssuer?: string;
|
|
939
|
+
scope?: string;
|
|
940
|
+
resourceMetadataUrl?: URL;
|
|
941
|
+
fetchFn?: FetchFunction;
|
|
942
|
+
}): Promise<AuthResult>;
|
|
943
|
+
//#endregion
|
|
944
|
+
//#region src/tool/mcp-transport.d.ts
|
|
945
|
+
/**
|
|
946
|
+
* Transport interface for MCP (Model Context Protocol) communication.
|
|
947
|
+
* Maps to the `Transport` interface in the MCP spec.
|
|
948
|
+
*/
|
|
949
|
+
type MCPTransportSendOptions = {
|
|
950
|
+
/**
|
|
951
|
+
* Cancels the transport operation for this message.
|
|
952
|
+
*/
|
|
953
|
+
signal?: AbortSignal;
|
|
954
|
+
/**
|
|
955
|
+
* Request-specific HTTP headers produced from MCP tool parameters.
|
|
956
|
+
*/
|
|
957
|
+
headers?: Record<string, string>;
|
|
958
|
+
/**
|
|
959
|
+
* Associates an outgoing message with an incoming request.
|
|
960
|
+
*/
|
|
961
|
+
relatedRequestId?: string | number;
|
|
962
|
+
/**
|
|
963
|
+
* Resumes a previously interrupted request.
|
|
964
|
+
*/
|
|
965
|
+
resumptionToken?: string;
|
|
966
|
+
/**
|
|
967
|
+
* Receives updated resumption tokens from transports that support them.
|
|
968
|
+
*/
|
|
969
|
+
onresumptiontoken?: (token: string) => void;
|
|
970
|
+
};
|
|
971
|
+
type MCPTransportCloseOptions = {
|
|
972
|
+
/**
|
|
973
|
+
* Cancels transport cleanup.
|
|
974
|
+
*/
|
|
975
|
+
signal?: AbortSignal;
|
|
976
|
+
};
|
|
977
|
+
interface MCPTransport {
|
|
978
|
+
/**
|
|
979
|
+
* Whether this transport can probe for stateless MCP protocol versions.
|
|
980
|
+
*
|
|
981
|
+
* Custom transports default to the legacy initialization flow unless they
|
|
982
|
+
* explicitly opt in.
|
|
983
|
+
*/
|
|
984
|
+
supportsProtocolVersionDiscovery?: boolean;
|
|
985
|
+
/**
|
|
986
|
+
* Whether this transport mirrors x-mcp-header tool parameters into request
|
|
987
|
+
* headers.
|
|
988
|
+
*/
|
|
989
|
+
supportsMcpToolParameterHeaders?: boolean;
|
|
990
|
+
/**
|
|
991
|
+
* Initialize and start the transport
|
|
992
|
+
*/
|
|
993
|
+
start(): Promise<void>;
|
|
994
|
+
/**
|
|
995
|
+
* Send a JSON-RPC message through the transport
|
|
996
|
+
* @param message The JSON-RPC message to send
|
|
997
|
+
* @param options Optional request-scoped cancellation options
|
|
998
|
+
*/
|
|
999
|
+
send(message: JSONRPCMessage, options?: MCPTransportSendOptions): Promise<void>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Clean up and close the transport
|
|
1002
|
+
* @param options Optional cancellation options for transport cleanup
|
|
1003
|
+
*/
|
|
1004
|
+
close(options?: MCPTransportCloseOptions): Promise<void>;
|
|
1005
|
+
/**
|
|
1006
|
+
* Event handler for transport closure
|
|
1007
|
+
*/
|
|
1008
|
+
onclose?: () => void;
|
|
1009
|
+
/**
|
|
1010
|
+
* Event handler for transport errors
|
|
1011
|
+
*/
|
|
1012
|
+
onerror?: (error: Error) => void;
|
|
1013
|
+
/**
|
|
1014
|
+
* Event handler for received messages
|
|
1015
|
+
*/
|
|
1016
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
1017
|
+
/**
|
|
1018
|
+
* The protocol version negotiated during initialization.
|
|
1019
|
+
*/
|
|
1020
|
+
protocolVersion?: string;
|
|
1021
|
+
/**
|
|
1022
|
+
* Set the protocol version negotiated during initialization.
|
|
1023
|
+
*/
|
|
1024
|
+
setProtocolVersion?(version: string): void;
|
|
1025
|
+
}
|
|
1026
|
+
type MCPTransportConfig = {
|
|
1027
|
+
type: 'sse' | 'http';
|
|
1028
|
+
/**
|
|
1029
|
+
* The URL of the MCP server.
|
|
1030
|
+
*/
|
|
1031
|
+
url: string;
|
|
1032
|
+
/**
|
|
1033
|
+
* Additional HTTP headers to be sent with requests.
|
|
1034
|
+
*/
|
|
1035
|
+
headers?: Record<string, string>;
|
|
1036
|
+
/**
|
|
1037
|
+
* An optional OAuth client provider to use for authentication for MCP servers.
|
|
1038
|
+
*/
|
|
1039
|
+
authProvider?: OAuthClientProvider;
|
|
1040
|
+
/**
|
|
1041
|
+
* Controls how HTTP redirects are handled for transport requests.
|
|
1042
|
+
* - `'follow'`: Follow redirects automatically (standard fetch behavior).
|
|
1043
|
+
* - `'error'`: Reject any redirect response with an error.
|
|
1044
|
+
* @default 'error'
|
|
1045
|
+
*/
|
|
1046
|
+
redirect?: 'follow' | 'error';
|
|
1047
|
+
/**
|
|
1048
|
+
* Initial MCP session id to send with resumed Streamable HTTP requests after
|
|
1049
|
+
* initialization.
|
|
1050
|
+
* Only used by the HTTP transport.
|
|
1051
|
+
*/
|
|
1052
|
+
initialSessionId?: string;
|
|
1053
|
+
/**
|
|
1054
|
+
* Initial MCP protocol version to send before initialize negotiates one.
|
|
1055
|
+
* Only used by the HTTP transport.
|
|
1056
|
+
*/
|
|
1057
|
+
initialProtocolVersion?: string;
|
|
1058
|
+
/**
|
|
1059
|
+
* Called when the Streamable HTTP server creates, changes, or clears the MCP
|
|
1060
|
+
* session id.
|
|
1061
|
+
* Only used by the HTTP transport.
|
|
1062
|
+
*/
|
|
1063
|
+
onSessionIdChange?: (sessionId: string | undefined) => void;
|
|
1064
|
+
/**
|
|
1065
|
+
* Called when a Streamable HTTP request returns 404 for an existing MCP
|
|
1066
|
+
* session id. The transport clears the session id before reporting the
|
|
1067
|
+
* underlying HTTP error.
|
|
1068
|
+
* Only used by the HTTP transport.
|
|
1069
|
+
*/
|
|
1070
|
+
onSessionExpired?: (sessionId: string) => void;
|
|
1071
|
+
/**
|
|
1072
|
+
* Whether close() should send DELETE for the current MCP session id.
|
|
1073
|
+
* Set to false when the application intends to reattach to the session later.
|
|
1074
|
+
* Only used by the HTTP transport.
|
|
1075
|
+
* @default true
|
|
1076
|
+
*/
|
|
1077
|
+
terminateSessionOnClose?: boolean;
|
|
1078
|
+
/**
|
|
1079
|
+
* Optional custom fetch implementation to use for HTTP requests.
|
|
1080
|
+
* Useful for runtimes that need a request-local fetch.
|
|
1081
|
+
* @default globalThis.fetch
|
|
1082
|
+
*/
|
|
1083
|
+
fetch?: FetchFunction;
|
|
1084
|
+
};
|
|
1085
|
+
//#endregion
|
|
828
1086
|
//#region src/tool/mcp-client.d.ts
|
|
829
1087
|
interface MCPClientConfig {
|
|
1088
|
+
/** Experimental events: choose a private durable store or a managed adapter. */
|
|
1089
|
+
experimental_events?: MCPEventsConfig;
|
|
830
1090
|
/** Transport configuration for connecting to the MCP server */
|
|
831
1091
|
transport: MCPTransportConfig | MCPTransport;
|
|
832
1092
|
/**
|
|
@@ -877,8 +1137,23 @@ interface MCPClientConfig {
|
|
|
877
1137
|
*/
|
|
878
1138
|
capabilities?: ClientCapabilities;
|
|
879
1139
|
}
|
|
880
|
-
|
|
1140
|
+
type ManagedMCPClient = Omit<MCPClient, 'experimental_events'> & {
|
|
1141
|
+
readonly experimental_events: ManagedMCPEvents;
|
|
1142
|
+
};
|
|
1143
|
+
export declare function createMCPClient(config: MCPClientConfig & {
|
|
1144
|
+
experimental_events: {
|
|
1145
|
+
adapter: MCPEventAdapter;
|
|
1146
|
+
};
|
|
1147
|
+
}): Promise<ManagedMCPClient>;
|
|
1148
|
+
export declare function createMCPClient(config: MCPClientConfig & {
|
|
1149
|
+
experimental_events?: {
|
|
1150
|
+
adapter?: never;
|
|
1151
|
+
};
|
|
1152
|
+
}): Promise<MCPClient>;
|
|
1153
|
+
export declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient | ManagedMCPClient>;
|
|
881
1154
|
interface MCPClient {
|
|
1155
|
+
/** Experimental event discovery and webhook subscription lifecycle. */
|
|
1156
|
+
readonly experimental_events: MCPEvents;
|
|
882
1157
|
/**
|
|
883
1158
|
* Information about the connected MCP server, as reported during initialization.
|
|
884
1159
|
* @see https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
|
|
@@ -1072,5 +1347,63 @@ export declare class MCPClientError extends AISDKError {
|
|
|
1072
1347
|
static isInstance(error: unknown): error is MCPClientError;
|
|
1073
1348
|
}
|
|
1074
1349
|
//#endregion
|
|
1075
|
-
|
|
1350
|
+
//#region src/tool/mcp-event-webhook.d.ts
|
|
1351
|
+
type MCPEventWebhookOptions = {
|
|
1352
|
+
store: MCPEventStore;
|
|
1353
|
+
/**
|
|
1354
|
+
* Optionally validate event data using an application schema or the server's
|
|
1355
|
+
* payloadSchema. Throw to reject the payload with 400 before onEvent runs.
|
|
1356
|
+
* The event envelope and signature are always checked.
|
|
1357
|
+
*/
|
|
1358
|
+
validatePayload?: (args: {
|
|
1359
|
+
definition: MCPEventDefinition;
|
|
1360
|
+
data: MCPEvent['data'];
|
|
1361
|
+
}) => void | PromiseLike<void>;
|
|
1362
|
+
/**
|
|
1363
|
+
* Resolve only after durable acceptance or successful processing. Deliveries
|
|
1364
|
+
* may be duplicated or reordered; deduplicate by subscription ID + eventId.
|
|
1365
|
+
* Throw to return 503 so the server can retry. The helper does not run agents.
|
|
1366
|
+
*/
|
|
1367
|
+
onEvent: (args: {
|
|
1368
|
+
subscription: MCPEventSubscriptionInfo;
|
|
1369
|
+
event: MCPEvent;
|
|
1370
|
+
}) => Promise<void>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Handles a signed replay gap: some events are no longer available. Reconcile
|
|
1373
|
+
* application state or notify the agent, then resolve after durable acceptance.
|
|
1374
|
+
* The helper saves the fresh cursor and truncated flag; delivery continues.
|
|
1375
|
+
* Throw to return 503 without changing saved state. Deduplicate by subscription
|
|
1376
|
+
* ID + messageId.
|
|
1377
|
+
*/
|
|
1378
|
+
onGap?: (args: {
|
|
1379
|
+
subscription: MCPEventSubscriptionInfo;
|
|
1380
|
+
messageId: string;
|
|
1381
|
+
gap: Extract<MCPEventControl, {
|
|
1382
|
+
type: 'gap';
|
|
1383
|
+
}>;
|
|
1384
|
+
}) => Promise<void>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Handles signed termination: the server has ended the subscription. Inspect
|
|
1387
|
+
* termination.error and notify the agent, then resolve after durable acceptance.
|
|
1388
|
+
* The helper removes the saved subscription after this callback succeeds.
|
|
1389
|
+
* Throw to return 503 without changing saved state. Deduplicate by subscription
|
|
1390
|
+
* ID + messageId.
|
|
1391
|
+
*/
|
|
1392
|
+
onTerminated?: (args: {
|
|
1393
|
+
subscription: MCPEventSubscriptionInfo;
|
|
1394
|
+
messageId: string;
|
|
1395
|
+
termination: Extract<MCPEventControl, {
|
|
1396
|
+
type: 'terminated';
|
|
1397
|
+
}>;
|
|
1398
|
+
}) => Promise<void>;
|
|
1399
|
+
onError?: (error: unknown) => void;
|
|
1400
|
+
};
|
|
1401
|
+
/**
|
|
1402
|
+
* Create a Web Request/Response handler for MCP webhook deliveries. Mount it
|
|
1403
|
+
* at the callback URL before subscribing. Verification is enabled automatically
|
|
1404
|
+
* using the pending delivery secret saved by the client's subscribe method.
|
|
1405
|
+
*/
|
|
1406
|
+
declare function createMCPEventWebhook({ store, validatePayload, onEvent, onGap, onTerminated, onError }: MCPEventWebhookOptions): (request: Request) => Promise<Response>;
|
|
1407
|
+
//#endregion
|
|
1408
|
+
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, type ElicitationRequest, type ListEventsResult as Experimental_ListEventsResult, type MCPEvent as Experimental_MCPEvent, type MCPEventAdapter as Experimental_MCPEventAdapter, type MCPEventControl as Experimental_MCPEventControl, type MCPEventDefinition as Experimental_MCPEventDefinition, type MCPEventOperations as Experimental_MCPEventOperations, type MCPEventStore as Experimental_MCPEventStore, type MCPEventSubscription as Experimental_MCPEventSubscription, type MCPEventSubscriptionInfo as Experimental_MCPEventSubscriptionInfo, type MCPEventWebhookOptions as Experimental_MCPEventWebhookOptions, type MCPEvents as Experimental_MCPEvents, type MCPEventsConfig as Experimental_MCPEventsConfig, type ManagedMCPClient as Experimental_ManagedMCPClient, type ManagedMCPEvents as Experimental_ManagedMCPEvents, type ManagedSubscribeInput as Experimental_ManagedSubscribeInput, type ManagedSubscription as Experimental_ManagedSubscription, type SubscribeEventOptions as Experimental_SubscribeEventOptions, type SubscribeEventResult as Experimental_SubscribeEventResult, type InitializeResult, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPAppResource, type MCPAppResourceCSP, type MCPAppResourceMeta, type MCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as MCPClientCapabilities, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig, type MCPClientConfig as experimental_MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type McpProviderMetadata, type McpToolAnnotations, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, createMCPClient as experimental_createMCPClient, createMCPEventWebhook as experimental_createMCPEventWebhook };
|
|
1076
1409
|
//# sourceMappingURL=index.d.ts.map
|