hoomanjs 1.29.2 → 1.31.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/README.md +216 -69
- package/dist/acp/acp-agent.d.ts +5 -5
- package/dist/acp/acp-agent.js +55 -54
- package/dist/acp/acp-agent.js.map +1 -1
- package/dist/acp/approvals.d.ts +3 -3
- package/dist/acp/approvals.js +73 -115
- package/dist/acp/approvals.js.map +1 -1
- package/dist/acp/sessions/options.js +11 -25
- package/dist/acp/sessions/options.js.map +1 -1
- package/dist/acp/utils/tool-kind.js +1 -5
- package/dist/acp/utils/tool-kind.js.map +1 -1
- package/dist/chat/app.d.ts +5 -1
- package/dist/chat/app.js +469 -234
- package/dist/chat/app.js.map +1 -1
- package/dist/chat/approvals.d.ts +4 -3
- package/dist/chat/approvals.js +11 -45
- package/dist/chat/approvals.js.map +1 -1
- package/dist/chat/components/BottomChrome.d.ts +52 -0
- package/dist/chat/components/BottomChrome.js +12 -0
- package/dist/chat/components/BottomChrome.js.map +1 -0
- package/dist/chat/components/ChatMessage.d.ts +2 -2
- package/dist/chat/components/ChatMessage.js +5 -6
- package/dist/chat/components/ChatMessage.js.map +1 -1
- package/dist/chat/components/ChromePicker.d.ts +17 -0
- package/dist/chat/components/ChromePicker.js +35 -0
- package/dist/chat/components/ChromePicker.js.map +1 -0
- package/dist/chat/components/EmptyChatBanner.js +2 -3
- package/dist/chat/components/EmptyChatBanner.js.map +1 -1
- package/dist/chat/components/StatusBar.d.ts +1 -2
- package/dist/chat/components/StatusBar.js +8 -5
- package/dist/chat/components/StatusBar.js.map +1 -1
- package/dist/chat/components/ThoughtEvent.d.ts +7 -0
- package/dist/chat/components/ThoughtEvent.js +30 -0
- package/dist/chat/components/ThoughtEvent.js.map +1 -0
- package/dist/chat/components/TodoPanel.js +52 -2
- package/dist/chat/components/TodoPanel.js.map +1 -1
- package/dist/chat/components/ToolEvent.js +1 -1
- package/dist/chat/components/ToolEvent.js.map +1 -1
- package/dist/chat/components/Transcript.d.ts +11 -2
- package/dist/chat/components/Transcript.js +78 -4
- package/dist/chat/components/Transcript.js.map +1 -1
- package/dist/chat/components/markdown/BlockRenderer.js +7 -7
- package/dist/chat/components/markdown/BlockRenderer.js.map +1 -1
- package/dist/chat/components/markdown/MarkdownMessage.js +1 -1
- package/dist/chat/components/markdown/MarkdownMessage.js.map +1 -1
- package/dist/chat/components/shared.js +2 -0
- package/dist/chat/components/shared.js.map +1 -1
- package/dist/chat/index.d.ts +4 -0
- package/dist/chat/index.js +21 -4
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/steering.d.ts +20 -0
- package/dist/chat/steering.js +67 -0
- package/dist/chat/steering.js.map +1 -0
- package/dist/chat/types.d.ts +5 -1
- package/dist/cli.js +91 -13
- package/dist/cli.js.map +1 -1
- package/dist/configure/app.d.ts +1 -1
- package/dist/configure/app.js +581 -303
- package/dist/configure/app.js.map +1 -1
- package/dist/configure/components/MenuScreen.d.ts +4 -2
- package/dist/configure/components/MenuScreen.js +33 -6
- package/dist/configure/components/MenuScreen.js.map +1 -1
- package/dist/configure/components/SelectMenuItem.d.ts +1 -0
- package/dist/configure/components/SelectMenuItem.js +19 -10
- package/dist/configure/components/SelectMenuItem.js.map +1 -1
- package/dist/configure/index.js +4 -2
- package/dist/configure/index.js.map +1 -1
- package/dist/configure/types.d.ts +14 -12
- package/dist/configure/utils.d.ts +2 -0
- package/dist/configure/utils.js +21 -2
- package/dist/configure/utils.js.map +1 -1
- package/dist/core/agent/index.d.ts +3 -3
- package/dist/core/agent/index.js +26 -29
- package/dist/core/agent/index.js.map +1 -1
- package/dist/core/agent/mode-aware-tool-registry.js +2 -1
- package/dist/core/agent/mode-aware-tool-registry.js.map +1 -1
- package/dist/core/approvals/intervention.d.ts +34 -0
- package/dist/core/approvals/intervention.js +94 -0
- package/dist/core/approvals/intervention.js.map +1 -0
- package/dist/core/config.d.ts +49 -28
- package/dist/core/config.js +85 -26
- package/dist/core/config.js.map +1 -1
- package/dist/core/context/index.d.ts +11 -2
- package/dist/core/context/index.js +54 -4
- package/dist/core/context/index.js.map +1 -1
- package/dist/core/context/model-extractor.d.ts +13 -0
- package/dist/core/context/model-extractor.js +98 -0
- package/dist/core/context/model-extractor.js.map +1 -0
- package/dist/core/index.d.ts +6 -2
- package/dist/core/index.js +6 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/mcp/config.d.ts +28 -0
- package/dist/core/mcp/index.d.ts +5 -3
- package/dist/core/mcp/index.js +4 -2
- package/dist/core/mcp/index.js.map +1 -1
- package/dist/core/mcp/manager.d.ts +14 -1
- package/dist/core/mcp/manager.js +76 -4
- package/dist/core/mcp/manager.js.map +1 -1
- package/dist/core/mcp/oauth/callback-server.d.ts +16 -0
- package/dist/core/mcp/oauth/callback-server.js +134 -0
- package/dist/core/mcp/oauth/callback-server.js.map +1 -0
- package/dist/core/mcp/oauth/identity.d.ts +9 -0
- package/dist/core/mcp/oauth/identity.js +31 -0
- package/dist/core/mcp/oauth/identity.js.map +1 -0
- package/dist/core/mcp/oauth/index.d.ts +11 -0
- package/dist/core/mcp/oauth/index.js +15 -0
- package/dist/core/mcp/oauth/index.js.map +1 -0
- package/dist/core/mcp/oauth/provider.d.ts +43 -0
- package/dist/core/mcp/oauth/provider.js +203 -0
- package/dist/core/mcp/oauth/provider.js.map +1 -0
- package/dist/core/mcp/oauth/service.d.ts +29 -0
- package/dist/core/mcp/oauth/service.js +139 -0
- package/dist/core/mcp/oauth/service.js.map +1 -0
- package/dist/core/mcp/oauth/store.d.ts +14 -0
- package/dist/core/mcp/oauth/store.js +86 -0
- package/dist/core/mcp/oauth/store.js.map +1 -0
- package/dist/core/mcp/oauth/types.d.ts +87 -0
- package/dist/core/mcp/oauth/types.js +45 -0
- package/dist/core/mcp/oauth/types.js.map +1 -0
- package/dist/core/mcp/types.d.ts +56 -0
- package/dist/core/mcp/types.js +3 -0
- package/dist/core/mcp/types.js.map +1 -1
- package/dist/core/memory/file-store.d.ts +24 -0
- package/dist/core/memory/file-store.js +151 -0
- package/dist/core/memory/file-store.js.map +1 -0
- package/dist/core/memory/index.d.ts +2 -5
- package/dist/core/memory/index.js +2 -3
- package/dist/core/memory/index.js.map +1 -1
- package/dist/core/memory/runtime.d.ts +4 -0
- package/dist/core/memory/runtime.js +37 -0
- package/dist/core/memory/runtime.js.map +1 -0
- package/dist/core/models/anthropic.js +24 -1
- package/dist/core/models/anthropic.js.map +1 -1
- package/dist/core/models/moonshot.js +33 -1
- package/dist/core/models/moonshot.js.map +1 -1
- package/dist/core/modes/definitions.d.ts +19 -0
- package/dist/core/modes/definitions.js +99 -0
- package/dist/core/modes/definitions.js.map +1 -0
- package/dist/core/modes/index.d.ts +3 -0
- package/dist/core/modes/index.js +4 -0
- package/dist/core/modes/index.js.map +1 -0
- package/dist/core/modes/registry.d.ts +9 -0
- package/dist/core/modes/registry.js +57 -0
- package/dist/core/modes/registry.js.map +1 -0
- package/dist/core/modes/schema.d.ts +5 -0
- package/dist/core/modes/schema.js +6 -0
- package/dist/core/modes/schema.js.map +1 -0
- package/dist/core/prompts/agents/research.md +8 -8
- package/dist/core/prompts/bundled.d.ts +3 -0
- package/dist/core/prompts/bundled.js +14 -0
- package/dist/core/prompts/bundled.js.map +1 -0
- package/dist/core/prompts/environment.d.ts +0 -1
- package/dist/core/prompts/environment.js +0 -2
- package/dist/core/prompts/environment.js.map +1 -1
- package/dist/core/prompts/index.d.ts +1 -4
- package/dist/core/prompts/index.js +1 -7
- package/dist/core/prompts/index.js.map +1 -1
- package/dist/core/prompts/modes/agent.md +3 -0
- package/dist/core/prompts/modes/ask.md +5 -3
- package/dist/core/prompts/modes/plan.md +2 -2
- package/dist/core/prompts/runtime.d.ts +10 -0
- package/dist/core/prompts/runtime.js +136 -0
- package/dist/core/prompts/runtime.js.map +1 -0
- package/dist/core/prompts/session-mode-appendix.d.ts +3 -9
- package/dist/core/prompts/session-mode-appendix.js +32 -69
- package/dist/core/prompts/session-mode-appendix.js.map +1 -1
- package/dist/core/prompts/static/environment.md +2 -2
- package/dist/core/prompts/static/filesystem.md +2 -0
- package/dist/core/prompts/static/init.md +25 -0
- package/dist/core/prompts/static/memory.md +9 -123
- package/dist/core/prompts/static/planning.md +1 -1
- package/dist/core/prompts/static/skills.md +6 -5
- package/dist/core/prompts/static/subagents.md +2 -2
- package/dist/core/prompts/static/web-search.md +2 -1
- package/dist/core/prompts/system.js +12 -29
- package/dist/core/prompts/system.js.map +1 -1
- package/dist/core/skills/built-in/hooman-config/SKILL.md +105 -32
- package/dist/core/skills/built-in/hooman-skills/SKILL.md +1 -1
- package/dist/core/skills/index.d.ts +1 -0
- package/dist/core/skills/index.js +1 -0
- package/dist/core/skills/index.js.map +1 -1
- package/dist/core/skills/plugin.d.ts +7 -0
- package/dist/core/skills/plugin.js +40 -0
- package/dist/core/skills/plugin.js.map +1 -0
- package/dist/core/state/agent-app-state.d.ts +1 -1
- package/dist/core/state/agent-app-state.js +1 -1
- package/dist/core/state/session-mode.d.ts +2 -9
- package/dist/core/state/session-mode.js +4 -12
- package/dist/core/state/session-mode.js.map +1 -1
- package/dist/core/state/tool-approvals.d.ts +4 -8
- package/dist/core/state/tool-approvals.js +14 -76
- package/dist/core/state/tool-approvals.js.map +1 -1
- package/dist/core/subagents/index.d.ts +3 -0
- package/dist/core/subagents/index.js +4 -0
- package/dist/core/subagents/index.js.map +1 -0
- package/dist/core/subagents/research.d.ts +16 -0
- package/dist/core/subagents/research.js +58 -0
- package/dist/core/subagents/research.js.map +1 -0
- package/dist/core/{agents → subagents}/runner.d.ts +6 -5
- package/dist/core/{agents → subagents}/runner.js +8 -10
- package/dist/core/subagents/runner.js.map +1 -0
- package/dist/core/{agents/tools.d.ts → subagents/tool.d.ts} +6 -6
- package/dist/core/{agents/tools.js → subagents/tool.js} +14 -16
- package/dist/core/subagents/tool.js.map +1 -0
- package/dist/core/tools/filesystem.d.ts +1 -0
- package/dist/core/tools/filesystem.js +38 -3
- package/dist/core/tools/filesystem.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/plan.js +2 -6
- package/dist/core/tools/plan.js.map +1 -1
- package/dist/core/tools/time.js +1 -1
- package/dist/core/tools/time.js.map +1 -1
- package/dist/core/utils/browser.d.ts +1 -0
- package/dist/core/utils/browser.js +25 -0
- package/dist/core/utils/browser.js.map +1 -0
- package/dist/core/utils/paths.d.ts +2 -4
- package/dist/core/utils/paths.js +2 -4
- package/dist/core/utils/paths.js.map +1 -1
- package/dist/daemon/approvals.d.ts +2 -2
- package/dist/daemon/approvals.js +51 -56
- package/dist/daemon/approvals.js.map +1 -1
- package/dist/daemon/index.js +9 -6
- package/dist/daemon/index.js.map +1 -1
- package/dist/exec/approvals.d.ts +2 -4
- package/dist/exec/approvals.js +16 -48
- package/dist/exec/approvals.js.map +1 -1
- package/dist/index.d.ts +13 -18
- package/dist/index.js +9 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -18
- package/dist/chat/components/ScrollView.d.ts +0 -106
- package/dist/chat/components/ScrollView.js +0 -80
- package/dist/chat/components/ScrollView.js.map +0 -1
- package/dist/chat/components/TranscriptViewport.d.ts +0 -9
- package/dist/chat/components/TranscriptViewport.js +0 -124
- package/dist/chat/components/TranscriptViewport.js.map +0 -1
- package/dist/core/agents/definitions.d.ts +0 -12
- package/dist/core/agents/definitions.js +0 -20
- package/dist/core/agents/definitions.js.map +0 -1
- package/dist/core/agents/index.d.ts +0 -4
- package/dist/core/agents/index.js +0 -5
- package/dist/core/agents/index.js.map +0 -1
- package/dist/core/agents/registry.d.ts +0 -5
- package/dist/core/agents/registry.js +0 -84
- package/dist/core/agents/registry.js.map +0 -1
- package/dist/core/agents/runner.js.map +0 -1
- package/dist/core/agents/tools.js.map +0 -1
- package/dist/core/inference/embedder.d.ts +0 -26
- package/dist/core/inference/embedder.js +0 -85
- package/dist/core/inference/embedder.js.map +0 -1
- package/dist/core/inference/index.d.ts +0 -9
- package/dist/core/inference/index.js +0 -13
- package/dist/core/inference/index.js.map +0 -1
- package/dist/core/inference/loader.d.ts +0 -16
- package/dist/core/inference/loader.js +0 -129
- package/dist/core/inference/loader.js.map +0 -1
- package/dist/core/inference/reranker.d.ts +0 -28
- package/dist/core/inference/reranker.js +0 -66
- package/dist/core/inference/reranker.js.map +0 -1
- package/dist/core/memory/brain.d.ts +0 -25
- package/dist/core/memory/brain.js +0 -137
- package/dist/core/memory/brain.js.map +0 -1
- package/dist/core/memory/database.d.ts +0 -4
- package/dist/core/memory/database.js +0 -87
- package/dist/core/memory/database.js.map +0 -1
- package/dist/core/memory/tools.d.ts +0 -16
- package/dist/core/memory/tools.js +0 -110
- package/dist/core/memory/tools.js.map +0 -1
- package/dist/core/memory/types.d.ts +0 -11
- package/dist/core/memory/types.js +0 -2
- package/dist/core/memory/types.js.map +0 -1
- package/dist/core/prompts/skills.d.ts +0 -15
- package/dist/core/prompts/skills.js +0 -92
- package/dist/core/prompts/skills.js.map +0 -1
- package/dist/core/prompts/static/wiki.md +0 -25
- package/dist/core/wiki/converters.d.ts +0 -12
- package/dist/core/wiki/converters.js +0 -73
- package/dist/core/wiki/converters.js.map +0 -1
- package/dist/core/wiki/database.d.ts +0 -39
- package/dist/core/wiki/database.js +0 -177
- package/dist/core/wiki/database.js.map +0 -1
- package/dist/core/wiki/index.d.ts +0 -7
- package/dist/core/wiki/index.js +0 -5
- package/dist/core/wiki/index.js.map +0 -1
- package/dist/core/wiki/storage.d.ts +0 -38
- package/dist/core/wiki/storage.js +0 -206
- package/dist/core/wiki/storage.js.map +0 -1
- package/dist/core/wiki/tools.d.ts +0 -5
- package/dist/core/wiki/tools.js +0 -32
- package/dist/core/wiki/tools.js.map +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { auth, } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
+
import { openBrowser } from "../../utils/browser.js";
|
|
3
|
+
import { startCallbackServer } from "./callback-server.js";
|
|
4
|
+
import { HoomanMcpOAuthProvider } from "./provider.js";
|
|
5
|
+
import { Store } from "./store.js";
|
|
6
|
+
import { createRemoteTransportFingerprint } from "./identity.js";
|
|
7
|
+
export class Service {
|
|
8
|
+
store;
|
|
9
|
+
clientLabel;
|
|
10
|
+
providers = new Map();
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.store = options.store ?? new Store();
|
|
13
|
+
this.clientLabel = options.clientLabel;
|
|
14
|
+
}
|
|
15
|
+
getProvider(serverName, transport) {
|
|
16
|
+
const key = createRemoteTransportFingerprint(serverName, transport);
|
|
17
|
+
let provider = this.providers.get(key);
|
|
18
|
+
if (!provider) {
|
|
19
|
+
provider = new HoomanMcpOAuthProvider({
|
|
20
|
+
serverName,
|
|
21
|
+
transport,
|
|
22
|
+
store: this.store,
|
|
23
|
+
clientLabel: this.clientLabel,
|
|
24
|
+
});
|
|
25
|
+
this.providers.set(key, provider);
|
|
26
|
+
}
|
|
27
|
+
return provider;
|
|
28
|
+
}
|
|
29
|
+
async hasTokens(serverName, transport) {
|
|
30
|
+
return ((await this.getProvider(serverName, transport).tokens()) !== undefined);
|
|
31
|
+
}
|
|
32
|
+
async beginAuthorization(serverName, transport) {
|
|
33
|
+
const provider = this.getProvider(serverName, transport);
|
|
34
|
+
provider.resetFlow();
|
|
35
|
+
const callbackServer = await this.createCallbackServer(transport);
|
|
36
|
+
provider.setRedirectUrl(callbackServer.redirectUri);
|
|
37
|
+
let authorizationUrl;
|
|
38
|
+
try {
|
|
39
|
+
const result = await auth(provider, {
|
|
40
|
+
serverUrl: transport.url,
|
|
41
|
+
});
|
|
42
|
+
if (result !== "REDIRECT") {
|
|
43
|
+
await callbackServer.close();
|
|
44
|
+
throw new Error(`"${serverName}" is already authorized.`);
|
|
45
|
+
}
|
|
46
|
+
authorizationUrl = provider.takeAuthorizationUrl();
|
|
47
|
+
if (!authorizationUrl) {
|
|
48
|
+
throw new Error("OAuth provider did not produce an authorization URL.");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
await callbackServer.close().catch(() => undefined);
|
|
53
|
+
provider.resetFlow();
|
|
54
|
+
throw wrapAuthError(`Failed to start OAuth flow for "${serverName}"`, error);
|
|
55
|
+
}
|
|
56
|
+
let settled = false;
|
|
57
|
+
const cancel = async () => {
|
|
58
|
+
if (settled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
settled = true;
|
|
62
|
+
provider.resetFlow();
|
|
63
|
+
await callbackServer.close().catch(() => undefined);
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
authorizationUrl,
|
|
67
|
+
complete: async ({ signal, timeoutMs } = {}) => {
|
|
68
|
+
if (settled) {
|
|
69
|
+
throw new Error("OAuth flow already completed or cancelled.");
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const { code, state } = await callbackServer.waitForCode({
|
|
73
|
+
signal,
|
|
74
|
+
timeoutMs,
|
|
75
|
+
});
|
|
76
|
+
const expectedState = provider.expectedState();
|
|
77
|
+
if (expectedState && state !== expectedState) {
|
|
78
|
+
throw new Error("OAuth state mismatch.");
|
|
79
|
+
}
|
|
80
|
+
const result = await auth(provider, {
|
|
81
|
+
serverUrl: transport.url,
|
|
82
|
+
authorizationCode: code,
|
|
83
|
+
});
|
|
84
|
+
if (result !== "AUTHORIZED") {
|
|
85
|
+
throw new Error(`OAuth exchange returned "${result}".`);
|
|
86
|
+
}
|
|
87
|
+
settled = true;
|
|
88
|
+
provider.resetFlow();
|
|
89
|
+
await callbackServer.close();
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
await cancel();
|
|
93
|
+
throw wrapAuthError(`OAuth flow for "${serverName}" failed`, error);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
cancel,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async authenticate(serverName, transport) {
|
|
100
|
+
const flow = await this.beginAuthorization(serverName, transport);
|
|
101
|
+
await openBrowser(flow.authorizationUrl.toString());
|
|
102
|
+
await flow.complete();
|
|
103
|
+
}
|
|
104
|
+
async logout(serverName, transport, scope = "all") {
|
|
105
|
+
await this.getProvider(serverName, transport).invalidateCredentials(scope);
|
|
106
|
+
}
|
|
107
|
+
async status(serverName, transport) {
|
|
108
|
+
const tokens = await this.getProvider(serverName, transport).tokens();
|
|
109
|
+
if (!tokens) {
|
|
110
|
+
return "unauthenticated";
|
|
111
|
+
}
|
|
112
|
+
if (tokens.expires_in !== undefined && tokens.expires_in <= 0) {
|
|
113
|
+
return "expired";
|
|
114
|
+
}
|
|
115
|
+
return "authenticated";
|
|
116
|
+
}
|
|
117
|
+
async createCallbackServer(transport) {
|
|
118
|
+
const redirectUri = transport.oauth?.redirectUri;
|
|
119
|
+
if (redirectUri) {
|
|
120
|
+
const url = new URL(redirectUri);
|
|
121
|
+
return startCallbackServer({
|
|
122
|
+
port: url.port ? Number(url.port) : undefined,
|
|
123
|
+
path: url.pathname,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return startCallbackServer({
|
|
127
|
+
port: transport.oauth?.callbackPort,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function wrapAuthError(prefix, error) {
|
|
132
|
+
if (error instanceof Error) {
|
|
133
|
+
const wrapped = new Error(`${prefix}: ${error.message}`);
|
|
134
|
+
wrapped.cause = error;
|
|
135
|
+
return wrapped;
|
|
136
|
+
}
|
|
137
|
+
return new Error(`${prefix}: ${String(error)}`);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/core/mcp/oauth/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,GAEL,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAuB,MAAM,sBAAsB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Aa,CAAC,MAAc,EAAE,KAAc;IACnD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,GAAG,MAAM,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,GAAG,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type StoredMcpOAuthEntry, type StoredMcpOAuthFile } from "./types.js";
|
|
2
|
+
export declare class Store {
|
|
3
|
+
private readonly path;
|
|
4
|
+
constructor(path?: string);
|
|
5
|
+
get filePath(): string;
|
|
6
|
+
read(): Promise<StoredMcpOAuthFile>;
|
|
7
|
+
list(): Promise<Record<string, StoredMcpOAuthEntry>>;
|
|
8
|
+
get(key: string): Promise<StoredMcpOAuthEntry | undefined>;
|
|
9
|
+
set(key: string, entry: StoredMcpOAuthEntry): Promise<void>;
|
|
10
|
+
update(key: string, updater: (current: StoredMcpOAuthEntry | undefined) => StoredMcpOAuthEntry | undefined): Promise<void>;
|
|
11
|
+
delete(key: string): Promise<void>;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
private write;
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { mcpOauthJsonPath } from "../../utils/paths.js";
|
|
4
|
+
import { StoredMcpOAuthFileSchema, } from "./types.js";
|
|
5
|
+
export class Store {
|
|
6
|
+
path;
|
|
7
|
+
constructor(path = mcpOauthJsonPath()) {
|
|
8
|
+
this.path = path;
|
|
9
|
+
}
|
|
10
|
+
get filePath() {
|
|
11
|
+
return this.path;
|
|
12
|
+
}
|
|
13
|
+
async read() {
|
|
14
|
+
try {
|
|
15
|
+
const raw = await readFile(this.path, "utf8");
|
|
16
|
+
return StoredMcpOAuthFileSchema.parse(JSON.parse(raw));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (isMissingFile(error)) {
|
|
20
|
+
return { entries: {} };
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async list() {
|
|
26
|
+
const data = await this.read();
|
|
27
|
+
return { ...data.entries };
|
|
28
|
+
}
|
|
29
|
+
async get(key) {
|
|
30
|
+
const data = await this.read();
|
|
31
|
+
return data.entries[key];
|
|
32
|
+
}
|
|
33
|
+
async set(key, entry) {
|
|
34
|
+
const data = await this.read();
|
|
35
|
+
data.entries[key] = entry;
|
|
36
|
+
await this.write(data);
|
|
37
|
+
}
|
|
38
|
+
async update(key, updater) {
|
|
39
|
+
const data = await this.read();
|
|
40
|
+
const next = updater(data.entries[key]);
|
|
41
|
+
if (next) {
|
|
42
|
+
data.entries[key] = next;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
delete data.entries[key];
|
|
46
|
+
}
|
|
47
|
+
await this.write(data);
|
|
48
|
+
}
|
|
49
|
+
async delete(key) {
|
|
50
|
+
const data = await this.read();
|
|
51
|
+
if (!data.entries[key]) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
delete data.entries[key];
|
|
55
|
+
await this.write(data);
|
|
56
|
+
}
|
|
57
|
+
async clear() {
|
|
58
|
+
try {
|
|
59
|
+
await unlink(this.path);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (!isMissingFile(error)) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async write(data) {
|
|
68
|
+
const parsed = StoredMcpOAuthFileSchema.parse(data);
|
|
69
|
+
if (Object.keys(parsed.entries).length === 0) {
|
|
70
|
+
await this.clear();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await mkdir(dirname(this.path), { recursive: true });
|
|
74
|
+
await writeFile(this.path, JSON.stringify(parsed, null, 2), {
|
|
75
|
+
encoding: "utf8",
|
|
76
|
+
mode: 0o600,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function isMissingFile(error) {
|
|
81
|
+
return (typeof error === "object" &&
|
|
82
|
+
error !== null &&
|
|
83
|
+
"code" in error &&
|
|
84
|
+
error.code === "ENOENT");
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/core/mcp/oauth/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,wBAAwB,GAGzB,MAAM,YAAY,CAAC;AAEpB,MAAM,OAAO,KAAK;IACoB;IAApC,YAAoC,OAAe,gBAAgB,EAAE;QAAjC,SAAI,GAAJ,IAAI,CAA6B;IAAG,CAAC;IAEzE,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,EAAE,OAAO,EAAE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Schema: z.ZodObject<{
|
|
3
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
4
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
6
|
+
authorizationUrl: z.ZodOptional<z.ZodURL>;
|
|
7
|
+
tokenUrl: z.ZodOptional<z.ZodURL>;
|
|
8
|
+
issuer: z.ZodOptional<z.ZodURL>;
|
|
9
|
+
registrationUrl: z.ZodOptional<z.ZodURL>;
|
|
10
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
|
+
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
redirectUri: z.ZodOptional<z.ZodURL>;
|
|
13
|
+
callbackPort: z.ZodOptional<z.ZodInt>;
|
|
14
|
+
tokenParamName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const StoredMcpOAuthTokensSchema: z.ZodObject<{
|
|
17
|
+
accessToken: z.ZodString;
|
|
18
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
19
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
21
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const StoredMcpOAuthClientSchema: z.ZodObject<{
|
|
24
|
+
clientId: z.ZodString;
|
|
25
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
26
|
+
clientIdIssuedAt: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
clientSecretExpiresAt: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
redirectUris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export declare const StoredMcpOAuthDiscoverySchema: z.ZodObject<{
|
|
31
|
+
authorizationServerUrl: z.ZodOptional<z.ZodString>;
|
|
32
|
+
resourceMetadataUrl: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const StoredMcpOAuthEntrySchema: z.ZodObject<{
|
|
35
|
+
serverName: z.ZodString;
|
|
36
|
+
serverUrl: z.ZodString;
|
|
37
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
accessToken: z.ZodString;
|
|
39
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
40
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
42
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
clientId: z.ZodString;
|
|
46
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
47
|
+
clientIdIssuedAt: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
clientSecretExpiresAt: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
redirectUris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
discovery: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
authorizationServerUrl: z.ZodOptional<z.ZodString>;
|
|
53
|
+
resourceMetadataUrl: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
updatedAt: z.ZodNumber;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export declare const StoredMcpOAuthFileSchema: z.ZodObject<{
|
|
58
|
+
entries: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
59
|
+
serverName: z.ZodString;
|
|
60
|
+
serverUrl: z.ZodString;
|
|
61
|
+
tokens: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
accessToken: z.ZodString;
|
|
63
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
64
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
66
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
clientId: z.ZodString;
|
|
70
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
71
|
+
clientIdIssuedAt: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
clientSecretExpiresAt: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
redirectUris: z.ZodOptional<z.ZodArray<z.ZodURL>>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
discovery: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
authorizationServerUrl: z.ZodOptional<z.ZodString>;
|
|
77
|
+
resourceMetadataUrl: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, z.core.$strip>>;
|
|
79
|
+
updatedAt: z.ZodNumber;
|
|
80
|
+
}, z.core.$strip>>>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export type McpOAuthConfig = z.infer<typeof McpOAuthConfigSchema>;
|
|
83
|
+
export type StoredMcpOAuthTokens = z.infer<typeof StoredMcpOAuthTokensSchema>;
|
|
84
|
+
export type StoredMcpOAuthClient = z.infer<typeof StoredMcpOAuthClientSchema>;
|
|
85
|
+
export type StoredMcpOAuthDiscovery = z.infer<typeof StoredMcpOAuthDiscoverySchema>;
|
|
86
|
+
export type StoredMcpOAuthEntry = z.infer<typeof StoredMcpOAuthEntrySchema>;
|
|
87
|
+
export type StoredMcpOAuthFile = z.infer<typeof StoredMcpOAuthFileSchema>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const McpOAuthConfigSchema = z.object({
|
|
3
|
+
enabled: z.boolean().optional(),
|
|
4
|
+
clientId: z.string().min(1).optional(),
|
|
5
|
+
clientSecret: z.string().min(1).optional(),
|
|
6
|
+
authorizationUrl: z.url().optional(),
|
|
7
|
+
tokenUrl: z.url().optional(),
|
|
8
|
+
issuer: z.url().optional(),
|
|
9
|
+
registrationUrl: z.url().optional(),
|
|
10
|
+
scopes: z.array(z.string().min(1)).optional(),
|
|
11
|
+
audiences: z.array(z.string().min(1)).optional(),
|
|
12
|
+
redirectUri: z.url().optional(),
|
|
13
|
+
callbackPort: z.int().min(1).max(65535).optional(),
|
|
14
|
+
tokenParamName: z.string().min(1).optional(),
|
|
15
|
+
});
|
|
16
|
+
export const StoredMcpOAuthTokensSchema = z.object({
|
|
17
|
+
accessToken: z.string().min(1),
|
|
18
|
+
refreshToken: z.string().min(1).optional(),
|
|
19
|
+
expiresAt: z.number().finite().optional(),
|
|
20
|
+
scope: z.string().min(1).optional(),
|
|
21
|
+
tokenType: z.string().min(1).optional(),
|
|
22
|
+
});
|
|
23
|
+
export const StoredMcpOAuthClientSchema = z.object({
|
|
24
|
+
clientId: z.string().min(1),
|
|
25
|
+
clientSecret: z.string().min(1).optional(),
|
|
26
|
+
clientIdIssuedAt: z.number().finite().optional(),
|
|
27
|
+
clientSecretExpiresAt: z.number().finite().optional(),
|
|
28
|
+
redirectUris: z.array(z.url()).optional(),
|
|
29
|
+
});
|
|
30
|
+
export const StoredMcpOAuthDiscoverySchema = z.object({
|
|
31
|
+
authorizationServerUrl: z.string().min(1).optional(),
|
|
32
|
+
resourceMetadataUrl: z.string().min(1).optional(),
|
|
33
|
+
});
|
|
34
|
+
export const StoredMcpOAuthEntrySchema = z.object({
|
|
35
|
+
serverName: z.string().min(1),
|
|
36
|
+
serverUrl: z.string().min(1),
|
|
37
|
+
tokens: StoredMcpOAuthTokensSchema.optional(),
|
|
38
|
+
client: StoredMcpOAuthClientSchema.optional(),
|
|
39
|
+
discovery: StoredMcpOAuthDiscoverySchema.optional(),
|
|
40
|
+
updatedAt: z.number().finite(),
|
|
41
|
+
});
|
|
42
|
+
export const StoredMcpOAuthFileSchema = z.object({
|
|
43
|
+
entries: z.record(z.string().min(1), StoredMcpOAuthEnt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AC,CAAC,QAAQ,EAAE;IACpD,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAClD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,MAAM,EAAE,0BAA0B,CAAC,QAAQ,EAAE;IAC7C,MAAM,EAAE,0BAA0B,CAAC,QAAQ,EAAE;IAC7C,SAAS,EAAE,6BAA6B,CAAC,QAAQ,EAAE;IACnD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;CAC5E,CAAC,CAAC"}
|
package/dist/core/mcp/types.d.ts
CHANGED
|
@@ -12,12 +12,40 @@ export declare const StreamableHttpSchema: z.ZodObject<{
|
|
|
12
12
|
type: z.ZodLiteral<"streamable-http">;
|
|
13
13
|
url: z.ZodURL;
|
|
14
14
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
15
|
+
oauth: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
18
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
19
|
+
authorizationUrl: z.ZodOptional<z.ZodURL>;
|
|
20
|
+
tokenUrl: z.ZodOptional<z.ZodURL>;
|
|
21
|
+
issuer: z.ZodOptional<z.ZodURL>;
|
|
22
|
+
registrationUrl: z.ZodOptional<z.ZodURL>;
|
|
23
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
redirectUri: z.ZodOptional<z.ZodURL>;
|
|
26
|
+
callbackPort: z.ZodOptional<z.ZodInt>;
|
|
27
|
+
tokenParamName: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
15
29
|
}, z.core.$strip>;
|
|
16
30
|
/** MCP remote server over SSE + POST messages (legacy transport). */
|
|
17
31
|
export declare const SseSchema: z.ZodObject<{
|
|
18
32
|
type: z.ZodLiteral<"sse">;
|
|
19
33
|
url: z.ZodURL;
|
|
20
34
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
35
|
+
oauth: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
38
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
39
|
+
authorizationUrl: z.ZodOptional<z.ZodURL>;
|
|
40
|
+
tokenUrl: z.ZodOptional<z.ZodURL>;
|
|
41
|
+
issuer: z.ZodOptional<z.ZodURL>;
|
|
42
|
+
registrationUrl: z.ZodOptional<z.ZodURL>;
|
|
43
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
redirectUri: z.ZodOptional<z.ZodURL>;
|
|
46
|
+
callbackPort: z.ZodOptional<z.ZodInt>;
|
|
47
|
+
tokenParamName: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
21
49
|
}, z.core.$strip>;
|
|
22
50
|
export declare const McpTransportSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
23
51
|
type: z.ZodLiteral<"stdio">;
|
|
@@ -29,10 +57,38 @@ export declare const McpTransportSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
29
57
|
type: z.ZodLiteral<"streamable-http">;
|
|
30
58
|
url: z.ZodURL;
|
|
31
59
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
60
|
+
oauth: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
64
|
+
authorizationUrl: z.ZodOptional<z.ZodURL>;
|
|
65
|
+
tokenUrl: z.ZodOptional<z.ZodURL>;
|
|
66
|
+
issuer: z.ZodOptional<z.ZodURL>;
|
|
67
|
+
registrationUrl: z.ZodOptional<z.ZodURL>;
|
|
68
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
redirectUri: z.ZodOptional<z.ZodURL>;
|
|
71
|
+
callbackPort: z.ZodOptional<z.ZodInt>;
|
|
72
|
+
tokenParamName: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
32
74
|
}, z.core.$strip>, z.ZodObject<{
|
|
33
75
|
type: z.ZodLiteral<"sse">;
|
|
34
76
|
url: z.ZodURL;
|
|
35
77
|
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
78
|
+
oauth: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
81
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
82
|
+
authorizationUrl: z.ZodOptional<z.ZodURL>;
|
|
83
|
+
tokenUrl: z.ZodOptional<z.ZodURL>;
|
|
84
|
+
issuer: z.ZodOptional<z.ZodURL>;
|
|
85
|
+
registrationUrl: z.ZodOptional<z.ZodURL>;
|
|
86
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
|
+
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
redirectUri: z.ZodOptional<z.ZodURL>;
|
|
89
|
+
callbackPort: z.ZodOptional<z.ZodInt>;
|
|
90
|
+
tokenParamName: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>>;
|
|
36
92
|
}, z.core.$strip>], "type">;
|
|
37
93
|
export type Stdio = z.infer<typeof StdioSchema>;
|
|
38
94
|
export type StreamableHttp = z.infer<typeof StreamableHttpSchema>;
|
package/dist/core/mcp/types.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { McpOAuthConfigSchema } from "./oauth/types.js";
|
|
2
3
|
const headersOrEnvVarsSchema = z.record(z.string(), z.string()).optional();
|
|
3
4
|
/** MCP stdio server: subprocess with JSON-RPC over stdin/stdout. */
|
|
4
5
|
export const StdioSchema = z.object({
|
|
@@ -13,12 +14,14 @@ export const StreamableHttpSchema = z.object({
|
|
|
13
14
|
type: z.literal("streamable-http"),
|
|
14
15
|
url: z.url(),
|
|
15
16
|
headers: headersOrEnvVarsSchema,
|
|
17
|
+
oauth: McpOAuthConfigSchema.optional(),
|
|
16
18
|
});
|
|
17
19
|
/** MCP remote server over SSE + POST messages (legacy transport). */
|
|
18
20
|
export const SseSchema = z.object({
|
|
19
21
|
type: z.literal("sse"),
|
|
20
22
|
url: z.url(),
|
|
21
23
|
headers: headersOrEnvVarsSchema,
|
|
24
|
+
oauth: McpOAuthConfigSchema.optional(),
|
|
22
25
|
});
|
|
23
26
|
export const McpTransportSchema = z.discriminatedUnion("type", [
|
|
24
27
|
StdioSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources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GAAG,EAAE;IACZ,OAAO,EAAE,sBAAsB;IAC/B,KAAK,EAAE,oBAAoB,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC7D,WAAW;IACX,oBAAoB;IACpB,SAAS;CACV,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JSONValue, MemoryEntry, MemoryStore, SearchOptions } from "@strands-agents/sdk";
|
|
2
|
+
type FileMemoryStoreConfig = {
|
|
3
|
+
baseDir: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
maxSearchResults?: number;
|
|
7
|
+
writable?: boolean;
|
|
8
|
+
extraction?: MemoryStore["extraction"];
|
|
9
|
+
};
|
|
10
|
+
export declare class FileMemoryStore implements MemoryStore {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description?: string;
|
|
13
|
+
readonly maxSearchResults?: number;
|
|
14
|
+
readonly writable: boolean;
|
|
15
|
+
readonly extraction?: MemoryStore["extraction"];
|
|
16
|
+
private readonly baseDir;
|
|
17
|
+
constructor(config: FileMemoryStoreConfig);
|
|
18
|
+
search(query: string, options?: SearchOptions): Promise<MemoryEntry[]>;
|
|
19
|
+
add(content: string, metadata?: Record<string, JSONValue>): Promise<void>;
|
|
20
|
+
private readEntries;
|
|
21
|
+
private appendEntry;
|
|
22
|
+
private scopeFilePath;
|
|
23
|
+
}
|
|
24
|
+
export {};
|