foundr-companion 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/adapters.d.mts +33 -0
- package/dist/bridge/adapters.d.mts.map +1 -0
- package/dist/bridge/adapters.mjs +159 -0
- package/dist/bridge/adapters.mjs.map +1 -0
- package/dist/bridge/bridge-auth.d.mts +5 -0
- package/dist/bridge/bridge-auth.d.mts.map +1 -0
- package/dist/bridge/bridge-auth.mjs +24 -0
- package/dist/bridge/bridge-auth.mjs.map +1 -0
- package/dist/bridge/codex-app-server-adapter.d.mts +37 -0
- package/dist/bridge/codex-app-server-adapter.d.mts.map +1 -0
- package/dist/bridge/codex-app-server-adapter.mjs +401 -0
- package/dist/bridge/codex-app-server-adapter.mjs.map +1 -0
- package/dist/bridge/daemon.mjs +190 -0
- package/dist/bridge/foundr-codex-reply.d.mts +96 -0
- package/dist/bridge/foundr-codex-reply.d.mts.map +1 -0
- package/dist/bridge/foundr-codex-reply.mjs +542 -0
- package/dist/bridge/foundr-codex-reply.mjs.map +1 -0
- package/dist/bridge/listener-flags.d.mts +5 -0
- package/dist/bridge/listener-flags.d.mts.map +1 -0
- package/dist/bridge/listener-flags.mjs +18 -0
- package/dist/bridge/listener-flags.mjs.map +1 -0
- package/dist/bridge/listener-loop.d.mts +58 -0
- package/dist/bridge/listener-loop.d.mts.map +1 -0
- package/dist/bridge/listener-loop.mjs +424 -0
- package/dist/bridge/listener-loop.mjs.map +1 -0
- package/dist/bridge/logout.d.mts +8 -0
- package/dist/bridge/logout.d.mts.map +1 -0
- package/dist/bridge/logout.mjs +35 -0
- package/dist/bridge/logout.mjs.map +1 -0
- package/dist/bridge/mcp-client.d.mts +97 -0
- package/dist/bridge/mcp-client.d.mts.map +1 -0
- package/dist/bridge/mcp-client.mjs +290 -0
- package/dist/bridge/mcp-client.mjs.map +1 -0
- package/dist/bridge/oauth-provider.d.mts +32 -0
- package/dist/bridge/oauth-provider.d.mts.map +1 -0
- package/dist/bridge/oauth-provider.mjs +94 -0
- package/dist/bridge/oauth-provider.mjs.map +1 -0
- package/dist/bridge/public-room-mention-listener-loop.d.mts +120 -0
- package/dist/bridge/public-room-mention-listener-loop.d.mts.map +1 -0
- package/dist/bridge/public-room-mention-listener-loop.mjs +225 -0
- package/dist/bridge/public-room-mention-listener-loop.mjs.map +1 -0
- package/dist/bridge/realtime-wake.d.mts +11 -0
- package/dist/bridge/realtime-wake.d.mts.map +1 -0
- package/dist/bridge/realtime-wake.mjs +134 -0
- package/dist/bridge/realtime-wake.mjs.map +1 -0
- package/dist/bridge/work-mission-listener-loop.d.mts +100 -0
- package/dist/bridge/work-mission-listener-loop.d.mts.map +1 -0
- package/dist/bridge/work-mission-listener-loop.mjs +737 -0
- package/dist/bridge/work-mission-listener-loop.mjs.map +1 -0
- package/dist/cli-parse.d.ts +27 -0
- package/dist/cli-parse.d.ts.map +1 -0
- package/dist/cli-parse.js +47 -0
- package/dist/cli-parse.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +232 -0
- package/dist/cli.js.map +1 -0
- package/dist/codex-preflight.d.ts +44 -0
- package/dist/codex-preflight.d.ts.map +1 -0
- package/dist/codex-preflight.js +74 -0
- package/dist/codex-preflight.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/launchd.d.ts +78 -0
- package/dist/launchd.d.ts.map +1 -0
- package/dist/launchd.js +118 -0
- package/dist/launchd.js.map +1 -0
- package/dist/paths.d.ts +30 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +26 -0
- package/dist/paths.js.map +1 -0
- package/install.sh +117 -0
- package/package.json +29 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { createServer } from 'node:http'
|
|
2
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
|
|
3
|
+
import { UnauthorizedError } from '@modelcontextprotocol/sdk/client/auth.js'
|
|
4
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
|
|
5
|
+
|
|
6
|
+
const CLIENT_INFO = { name: 'foundr-local-bridge', version: '0.1.0' }
|
|
7
|
+
|
|
8
|
+
export function createOAuthCallbackWaiter({ port = 17893 } = {}) {
|
|
9
|
+
let server
|
|
10
|
+
let settled = false
|
|
11
|
+
let readySettled = false
|
|
12
|
+
let resolveReady
|
|
13
|
+
let rejectReady
|
|
14
|
+
|
|
15
|
+
const ready = new Promise((resolve, reject) => {
|
|
16
|
+
resolveReady = () => {
|
|
17
|
+
if (readySettled) return
|
|
18
|
+
readySettled = true
|
|
19
|
+
resolve()
|
|
20
|
+
}
|
|
21
|
+
rejectReady = (error) => {
|
|
22
|
+
if (readySettled) return
|
|
23
|
+
readySettled = true
|
|
24
|
+
reject(error)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const closeServer = (onClose = () => {}) => {
|
|
29
|
+
if (!server) {
|
|
30
|
+
onClose()
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
if (server.listening) {
|
|
34
|
+
server.close(onClose)
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
onClose()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const closeWhenListening = () => {
|
|
41
|
+
if (!server) return
|
|
42
|
+
if (server.listening) {
|
|
43
|
+
server.close()
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
server.once('listening', () => server.close())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const code = new Promise((resolveCode, rejectCode) => {
|
|
50
|
+
const settle = (fn, value) => {
|
|
51
|
+
if (settled) return
|
|
52
|
+
settled = true
|
|
53
|
+
if (fn === rejectCode) {
|
|
54
|
+
rejectReady(value)
|
|
55
|
+
}
|
|
56
|
+
closeServer(() => fn(value))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
server = createServer((req, res) => {
|
|
60
|
+
try {
|
|
61
|
+
const url = new URL(req.url ?? '/', `http://127.0.0.1:${port}`)
|
|
62
|
+
const oauthError = url.searchParams.get('error')
|
|
63
|
+
const errorDescription = url.searchParams.get('error_description')
|
|
64
|
+
const authCode = url.searchParams.get('code')
|
|
65
|
+
|
|
66
|
+
if (oauthError) {
|
|
67
|
+
throw new Error(errorDescription ? `${oauthError}: ${errorDescription}` : oauthError)
|
|
68
|
+
}
|
|
69
|
+
if (!authCode) {
|
|
70
|
+
throw new Error('missing OAuth code')
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
res.writeHead(200, { 'content-type': 'text/plain; charset=utf-8' })
|
|
74
|
+
res.end('Foundr World bridge authorized. You can close this tab.\n')
|
|
75
|
+
settle(resolveCode, authCode)
|
|
76
|
+
} catch (error) {
|
|
77
|
+
res.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' })
|
|
78
|
+
res.end(`${error instanceof Error ? error.message : String(error)}\n`)
|
|
79
|
+
settle(rejectCode, error)
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
server.on('error', (error) => settle(rejectCode, error))
|
|
84
|
+
server.listen(port, '127.0.0.1', resolveReady)
|
|
85
|
+
})
|
|
86
|
+
void code.catch(() => {})
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
ready,
|
|
90
|
+
code,
|
|
91
|
+
close() {
|
|
92
|
+
if (settled) return
|
|
93
|
+
settled = true
|
|
94
|
+
closeWhenListening()
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function waitForOAuthCallback({ port = 17893 } = {}) {
|
|
100
|
+
return createOAuthCallbackWaiter({ port }).code
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function createTransport(mcpUrl, authProvider) {
|
|
104
|
+
const protectionBypass = vercelProtectionBypass()
|
|
105
|
+
const requestInit = protectionBypass
|
|
106
|
+
? { headers: { 'x-vercel-protection-bypass': protectionBypass } }
|
|
107
|
+
: undefined
|
|
108
|
+
|
|
109
|
+
return new StreamableHTTPClientTransport(new URL(mcpUrl), {
|
|
110
|
+
authProvider,
|
|
111
|
+
...(requestInit ? { requestInit } : {}),
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function vercelProtectionBypass() {
|
|
116
|
+
return (
|
|
117
|
+
process.env.FOUNDR_VERCEL_PROTECTION_BYPASS ||
|
|
118
|
+
process.env.VERCEL_AUTOMATION_BYPASS_SECRET ||
|
|
119
|
+
process.env.VERCEL_PROTECTION_BYPASS ||
|
|
120
|
+
''
|
|
121
|
+
).trim()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function withVercelProtectionBypass(url) {
|
|
125
|
+
const protectionBypass = vercelProtectionBypass()
|
|
126
|
+
if (!protectionBypass) return url
|
|
127
|
+
|
|
128
|
+
const nextUrl = new URL(url.toString())
|
|
129
|
+
nextUrl.searchParams.set('x-vercel-protection-bypass', protectionBypass)
|
|
130
|
+
nextUrl.searchParams.set('x-vercel-set-bypass-cookie', 'true')
|
|
131
|
+
return nextUrl
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function directJsonUrl(mcpUrl, path) {
|
|
135
|
+
const origin = new URL(mcpUrl).origin
|
|
136
|
+
return new URL(path, origin).toString()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function parseJsonResponse(response) {
|
|
140
|
+
const text = await response.text()
|
|
141
|
+
if (!text) return {}
|
|
142
|
+
try {
|
|
143
|
+
return JSON.parse(text)
|
|
144
|
+
} catch {
|
|
145
|
+
return { message: text }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function directJsonError({ response, payload }) {
|
|
150
|
+
const code = typeof payload?.code === 'string'
|
|
151
|
+
? payload.code
|
|
152
|
+
: response.status === 401 || response.status === 403
|
|
153
|
+
? 'AUTH_FAILED'
|
|
154
|
+
: `HTTP_${response.status}`
|
|
155
|
+
const message = typeof payload?.message === 'string'
|
|
156
|
+
? payload.message
|
|
157
|
+
: response.statusText || 'direct JSON request failed'
|
|
158
|
+
const error = new Error(`${code}: ${message}`)
|
|
159
|
+
error.code = code
|
|
160
|
+
error.status = response.status
|
|
161
|
+
error.payload = payload
|
|
162
|
+
return error
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function callDirectJson({
|
|
166
|
+
mcpUrl,
|
|
167
|
+
authProvider,
|
|
168
|
+
path,
|
|
169
|
+
body = {},
|
|
170
|
+
fetchImpl = globalThis.fetch,
|
|
171
|
+
} = {}) {
|
|
172
|
+
const accessToken = authProvider?.tokens?.()?.access_token
|
|
173
|
+
if (!accessToken) {
|
|
174
|
+
const error = new Error('AUTH_FAILED: missing bearer token')
|
|
175
|
+
error.code = 'AUTH_FAILED'
|
|
176
|
+
throw error
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const headers = {
|
|
180
|
+
accept: 'application/json',
|
|
181
|
+
authorization: `Bearer ${accessToken}`,
|
|
182
|
+
'content-type': 'application/json',
|
|
183
|
+
}
|
|
184
|
+
const protectionBypass = vercelProtectionBypass()
|
|
185
|
+
if (protectionBypass) headers['x-vercel-protection-bypass'] = protectionBypass
|
|
186
|
+
|
|
187
|
+
const response = await fetchImpl(directJsonUrl(mcpUrl, path), {
|
|
188
|
+
method: 'POST',
|
|
189
|
+
headers,
|
|
190
|
+
body: JSON.stringify(body),
|
|
191
|
+
})
|
|
192
|
+
const payload = await parseJsonResponse(response)
|
|
193
|
+
if (!response.ok) throw directJsonError({ response, payload })
|
|
194
|
+
return payload
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function firstTextContent(result) {
|
|
198
|
+
return result.content?.find(
|
|
199
|
+
(item) => item?.type === 'text' && typeof item.text === 'string',
|
|
200
|
+
)?.text?.trim() ?? ''
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function parseMaybeJson(text) {
|
|
204
|
+
if (!text) return undefined
|
|
205
|
+
try {
|
|
206
|
+
return JSON.parse(text)
|
|
207
|
+
} catch {
|
|
208
|
+
return undefined
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function toolErrorMessage(result) {
|
|
213
|
+
const text = firstTextContent(result)
|
|
214
|
+
const parsed = parseMaybeJson(text)
|
|
215
|
+
const code = parsed?.code ?? parsed?.error?.code
|
|
216
|
+
const message = parsed?.message ?? parsed?.error?.message ?? parsed?.error ?? text
|
|
217
|
+
|
|
218
|
+
if (code && message) return `${code}: ${message}`
|
|
219
|
+
return message || 'MCP tool returned an error'
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function parseToolResult(result) {
|
|
223
|
+
if (result.isError) {
|
|
224
|
+
throw new Error(toolErrorMessage(result))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const text = firstTextContent(result)
|
|
228
|
+
return text ? JSON.parse(text) : {}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function createInteractiveAuthProvider(authProvider, getOAuthCallback) {
|
|
232
|
+
if (!authProvider) return authProvider
|
|
233
|
+
|
|
234
|
+
const provider = Object.create(authProvider)
|
|
235
|
+
provider.redirectToAuthorization = async (url) => {
|
|
236
|
+
const oauthCallback = getOAuthCallback()
|
|
237
|
+
await oauthCallback.ready
|
|
238
|
+
return authProvider.redirectToAuthorization?.(url)
|
|
239
|
+
}
|
|
240
|
+
return provider
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export async function createMcpClient({
|
|
244
|
+
mcpUrl,
|
|
245
|
+
authProvider,
|
|
246
|
+
clientFactory = () => new Client(CLIENT_INFO, { capabilities: {} }),
|
|
247
|
+
transportFactory = createTransport,
|
|
248
|
+
oauthCallbackFactory = createOAuthCallbackWaiter,
|
|
249
|
+
} = {}) {
|
|
250
|
+
const client = clientFactory()
|
|
251
|
+
let pendingOAuthCallback
|
|
252
|
+
const getOAuthCallback = () => {
|
|
253
|
+
pendingOAuthCallback ??= oauthCallbackFactory()
|
|
254
|
+
return pendingOAuthCallback
|
|
255
|
+
}
|
|
256
|
+
const interactiveAuthProvider = createInteractiveAuthProvider(authProvider, getOAuthCallback)
|
|
257
|
+
let transport = transportFactory(mcpUrl, interactiveAuthProvider)
|
|
258
|
+
|
|
259
|
+
try {
|
|
260
|
+
await client.connect(transport)
|
|
261
|
+
pendingOAuthCallback?.close()
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (!(error instanceof UnauthorizedError)) {
|
|
264
|
+
pendingOAuthCallback?.close()
|
|
265
|
+
throw error
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const oauthCallback = pendingOAuthCallback ?? getOAuthCallback()
|
|
269
|
+
const authCode = await oauthCallback.code
|
|
270
|
+
await transport.finishAuth(authCode)
|
|
271
|
+
await client.close().catch(() => {})
|
|
272
|
+
|
|
273
|
+
pendingOAuthCallback = undefined
|
|
274
|
+
transport = transportFactory(mcpUrl, interactiveAuthProvider)
|
|
275
|
+
await client.connect(transport)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
client,
|
|
280
|
+
async callTool(name, args = {}) {
|
|
281
|
+
return parseToolResult(await client.callTool({ name, arguments: args }))
|
|
282
|
+
},
|
|
283
|
+
async callJson(path, body = {}) {
|
|
284
|
+
return callDirectJson({ mcpUrl, authProvider, path, body })
|
|
285
|
+
},
|
|
286
|
+
async close() {
|
|
287
|
+
await client.close()
|
|
288
|
+
},
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.mjs","sourceRoot":"","sources":["../../src/bridge/mcp-client.mjs"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,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,oBAAoB,uBAApB,oBAAoB,CAAE,KAAK,EAAE,CAAA;YAC7B,MAAM,KAAK,CAAA;QACb,CAAC;QAED,MAAM,aAAa,GAAG,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,gBAAgB,EAAE,CAAA;QAChE,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,IAAI,CAAA;QACzC,MAAM,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QACpC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAEpC,oBAAoB,GAAG,SAAS,CAAA;QAChC,SAAS,GAAG,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;QAC7D,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACjC,CAAC;IAED,OAAO;QACL,MAAM;QACN,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE;YAC5B,OAAO,eAAe,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAC1E,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE;YAC5B,OAAO,cAAc,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAC7D,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class FileBackedOAuthProvider {
|
|
2
|
+
constructor({ mcpUrl, agentName, auth, onRedirect, onChange }?: {
|
|
3
|
+
agentName?: string | undefined;
|
|
4
|
+
auth?: {} | undefined;
|
|
5
|
+
});
|
|
6
|
+
mcpUrl: any;
|
|
7
|
+
agentName: string;
|
|
8
|
+
auth: {};
|
|
9
|
+
onRedirect: any;
|
|
10
|
+
onChange: any;
|
|
11
|
+
get redirectUrl(): string;
|
|
12
|
+
get clientMetadata(): {
|
|
13
|
+
client_name: string;
|
|
14
|
+
redirect_uris: string[];
|
|
15
|
+
grant_types: string[];
|
|
16
|
+
response_types: string[];
|
|
17
|
+
token_endpoint_auth_method: string;
|
|
18
|
+
scope: string;
|
|
19
|
+
};
|
|
20
|
+
clientInformation(): any;
|
|
21
|
+
notifyChange(): Promise<void>;
|
|
22
|
+
saveClientInformation(info: any): Promise<void>;
|
|
23
|
+
tokens(): any;
|
|
24
|
+
saveTokens(tokens: any): Promise<void>;
|
|
25
|
+
redirectToAuthorization(url: any): any;
|
|
26
|
+
saveCodeVerifier(verifier: any): Promise<void>;
|
|
27
|
+
codeVerifier(): any;
|
|
28
|
+
saveDiscoveryState(state: any): Promise<void>;
|
|
29
|
+
discoveryState(): any;
|
|
30
|
+
invalidateCredentials(scope: any): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=oauth-provider.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider.d.mts","sourceRoot":"","sources":["../../src/bridge/oauth-provider.mjs"],"names":[],"mappings":"AAOA;IACE;;;OAMC;IALC,YAAoB;IACpB,kBAA0B;IAC1B,SAAsB;IACtB,gBAA4B;IAC5B,cAAwB;IAG1B,0BAEC;IAED;;;;;;;MASC;IAED,yBAEC;IAED,8BAEC;IAED,gDAGC;IAED,cAEC;IAED,uCAGC;IAED,uCAEC;IAED,+CAGC;IAED,oBAKC;IAED,8CAGC;IAED,sBAEC;IAED,iDAcC;CACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const DEFAULT_MCP_SCOPES = ['mcp:brief', 'mcp:backlog', 'mcp:work-missions']
|
|
2
|
+
|
|
3
|
+
function bridgeScope() {
|
|
4
|
+
const configured = String(process.env.FOUNDR_MCP_SCOPES || '').trim()
|
|
5
|
+
return configured || DEFAULT_MCP_SCOPES.join(' ')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class FileBackedOAuthProvider {
|
|
9
|
+
constructor({ mcpUrl, agentName = 'Local Agent', auth = {}, onRedirect, onChange } = {}) {
|
|
10
|
+
this.mcpUrl = mcpUrl
|
|
11
|
+
this.agentName = agentName
|
|
12
|
+
this.auth = auth ?? {}
|
|
13
|
+
this.onRedirect = onRedirect
|
|
14
|
+
this.onChange = onChange
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get redirectUrl() {
|
|
18
|
+
return 'http://127.0.0.1:17893/callback'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get clientMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
client_name: `Foundr Local Bridge (${this.agentName})`,
|
|
24
|
+
redirect_uris: [this.redirectUrl],
|
|
25
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
26
|
+
response_types: ['code'],
|
|
27
|
+
token_endpoint_auth_method: 'none',
|
|
28
|
+
scope: bridgeScope(),
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
clientInformation() {
|
|
33
|
+
return this.auth.clientInformation
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async notifyChange() {
|
|
37
|
+
await this.onChange?.({ ...this.auth })
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async saveClientInformation(info) {
|
|
41
|
+
this.auth.clientInformation = info
|
|
42
|
+
await this.notifyChange()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
tokens() {
|
|
46
|
+
return this.auth.tokens
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async saveTokens(tokens) {
|
|
50
|
+
this.auth.tokens = tokens
|
|
51
|
+
await this.notifyChange()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
redirectToAuthorization(url) {
|
|
55
|
+
return this.onRedirect?.(url)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async saveCodeVerifier(verifier) {
|
|
59
|
+
this.auth.codeVerifier = verifier
|
|
60
|
+
await this.notifyChange()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
codeVerifier() {
|
|
64
|
+
if (!this.auth.codeVerifier) {
|
|
65
|
+
throw new Error('No OAuth code verifier saved')
|
|
66
|
+
}
|
|
67
|
+
return this.auth.codeVerifier
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async saveDiscoveryState(state) {
|
|
71
|
+
this.auth.discoveryState = state
|
|
72
|
+
await this.notifyChange()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
discoveryState() {
|
|
76
|
+
return this.auth.discoveryState
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async invalidateCredentials(scope) {
|
|
80
|
+
if (scope === 'all' || scope === 'client') {
|
|
81
|
+
delete this.auth.clientInformation
|
|
82
|
+
}
|
|
83
|
+
if (scope === 'all' || scope === 'tokens') {
|
|
84
|
+
delete this.auth.tokens
|
|
85
|
+
}
|
|
86
|
+
if (scope === 'all' || scope === 'verifier') {
|
|
87
|
+
delete this.auth.codeVerifier
|
|
88
|
+
}
|
|
89
|
+
if (scope === 'all' || scope === 'discovery') {
|
|
90
|
+
delete this.auth.discoveryState
|
|
91
|
+
}
|
|
92
|
+
await this.notifyChange()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-provider.mjs","sourceRoot":"","sources":["../../src/bridge/oauth-provider.mjs"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAA;AAE5E,SAAS,WAAW;IAClB,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IACrE,OAAO,UAAU,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,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AK,KAAK,WAAW,EAAE,CAAC;YAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAA;QACjC,CAAC;QACD,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export function publicRoomMentionEnvelope(mention: any, agent?: null): {
|
|
2
|
+
kind: string;
|
|
3
|
+
thread: {
|
|
4
|
+
id: string;
|
|
5
|
+
kind: string;
|
|
6
|
+
};
|
|
7
|
+
room: {
|
|
8
|
+
id: any;
|
|
9
|
+
handle: any;
|
|
10
|
+
};
|
|
11
|
+
mention: {
|
|
12
|
+
id: any;
|
|
13
|
+
expires_at: any;
|
|
14
|
+
};
|
|
15
|
+
message: {
|
|
16
|
+
id: any;
|
|
17
|
+
body: any;
|
|
18
|
+
sender_public_id: any;
|
|
19
|
+
sender_display_name: any;
|
|
20
|
+
created_at: any;
|
|
21
|
+
};
|
|
22
|
+
delivery: {
|
|
23
|
+
id: any;
|
|
24
|
+
agent_key_id: any;
|
|
25
|
+
};
|
|
26
|
+
agent: null;
|
|
27
|
+
};
|
|
28
|
+
export function isPublicRoomMentionWakePayload(payload: any): boolean;
|
|
29
|
+
export function runOnePublicRoomMentionIteration({ client, adapter, agent, }: {
|
|
30
|
+
client: any;
|
|
31
|
+
adapter: any;
|
|
32
|
+
agent?: null | undefined;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
timed_out: boolean;
|
|
35
|
+
replied: number;
|
|
36
|
+
skipped: number;
|
|
37
|
+
failed: number;
|
|
38
|
+
unsupported: boolean;
|
|
39
|
+
chat_id?: undefined;
|
|
40
|
+
error?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
timed_out: boolean;
|
|
43
|
+
replied: number;
|
|
44
|
+
skipped: number;
|
|
45
|
+
failed: number;
|
|
46
|
+
unsupported?: undefined;
|
|
47
|
+
chat_id?: undefined;
|
|
48
|
+
error?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
replied: number;
|
|
51
|
+
skipped: number;
|
|
52
|
+
failed: number;
|
|
53
|
+
timed_out?: undefined;
|
|
54
|
+
unsupported?: undefined;
|
|
55
|
+
chat_id?: undefined;
|
|
56
|
+
error?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
replied: number;
|
|
59
|
+
skipped: number;
|
|
60
|
+
failed: number;
|
|
61
|
+
chat_id: any;
|
|
62
|
+
timed_out?: undefined;
|
|
63
|
+
unsupported?: undefined;
|
|
64
|
+
error?: undefined;
|
|
65
|
+
} | {
|
|
66
|
+
replied: number;
|
|
67
|
+
skipped: number;
|
|
68
|
+
failed: number;
|
|
69
|
+
error: string;
|
|
70
|
+
timed_out?: undefined;
|
|
71
|
+
unsupported?: undefined;
|
|
72
|
+
chat_id?: undefined;
|
|
73
|
+
}>;
|
|
74
|
+
export function runOnePublicRoomMentionWakeIteration({ client, adapter, agent, wake, }: {
|
|
75
|
+
client: any;
|
|
76
|
+
adapter: any;
|
|
77
|
+
agent?: null | undefined;
|
|
78
|
+
wake: any;
|
|
79
|
+
}): Promise<{
|
|
80
|
+
timed_out: boolean;
|
|
81
|
+
replied: number;
|
|
82
|
+
skipped: number;
|
|
83
|
+
failed: number;
|
|
84
|
+
unsupported: boolean;
|
|
85
|
+
chat_id?: undefined;
|
|
86
|
+
error?: undefined;
|
|
87
|
+
} | {
|
|
88
|
+
timed_out: boolean;
|
|
89
|
+
replied: number;
|
|
90
|
+
skipped: number;
|
|
91
|
+
failed: number;
|
|
92
|
+
unsupported?: undefined;
|
|
93
|
+
chat_id?: undefined;
|
|
94
|
+
error?: undefined;
|
|
95
|
+
} | {
|
|
96
|
+
replied: number;
|
|
97
|
+
skipped: number;
|
|
98
|
+
failed: number;
|
|
99
|
+
timed_out?: undefined;
|
|
100
|
+
unsupported?: undefined;
|
|
101
|
+
chat_id?: undefined;
|
|
102
|
+
error?: undefined;
|
|
103
|
+
} | {
|
|
104
|
+
replied: number;
|
|
105
|
+
skipped: number;
|
|
106
|
+
failed: number;
|
|
107
|
+
chat_id: any;
|
|
108
|
+
timed_out?: undefined;
|
|
109
|
+
unsupported?: undefined;
|
|
110
|
+
error?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
replied: number;
|
|
113
|
+
skipped: number;
|
|
114
|
+
failed: number;
|
|
115
|
+
error: string;
|
|
116
|
+
timed_out?: undefined;
|
|
117
|
+
unsupported?: undefined;
|
|
118
|
+
chat_id?: undefined;
|
|
119
|
+
}>;
|
|
120
|
+
//# sourceMappingURL=public-room-mention-listener-loop.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-room-mention-listener-loop.d.mts","sourceRoot":"","sources":["../../src/bridge/public-room-mention-listener-loop.mjs"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BC;AAED,sEAWC;AAgDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CC"}
|