@cat-factory/server 0.222.2 → 0.224.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/agents/ContainerAgentExecutor.d.ts +9 -12
- package/dist/agents/ContainerAgentExecutor.d.ts.map +1 -1
- package/dist/agents/ContainerAgentExecutor.js +7 -24
- package/dist/agents/ContainerAgentExecutor.js.map +1 -1
- package/dist/agents/mcpOAuthClientSecret.d.ts +27 -0
- package/dist/agents/mcpOAuthClientSecret.d.ts.map +1 -0
- package/dist/agents/mcpOAuthClientSecret.js +46 -0
- package/dist/agents/mcpOAuthClientSecret.js.map +1 -0
- package/dist/agents/mcpOAuthTokenSource.d.ts +55 -0
- package/dist/agents/mcpOAuthTokenSource.d.ts.map +1 -0
- package/dist/agents/mcpOAuthTokenSource.js +60 -0
- package/dist/agents/mcpOAuthTokenSource.js.map +1 -0
- package/dist/agents/toolServers.d.ts +55 -1
- package/dist/agents/toolServers.d.ts.map +1 -1
- package/dist/agents/toolServers.js +132 -4
- package/dist/agents/toolServers.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +11 -0
- package/dist/app.js.map +1 -1
- package/dist/auth/oidc/OidcClient.d.ts +86 -0
- package/dist/auth/oidc/OidcClient.d.ts.map +1 -0
- package/dist/auth/oidc/OidcClient.js +271 -0
- package/dist/auth/oidc/OidcClient.js.map +1 -0
- package/dist/auth/oidc/claims.d.ts +97 -0
- package/dist/auth/oidc/claims.d.ts.map +1 -0
- package/dist/auth/oidc/claims.js +149 -0
- package/dist/auth/oidc/claims.js.map +1 -0
- package/dist/auth/oidc/discovery.d.ts +51 -0
- package/dist/auth/oidc/discovery.d.ts.map +1 -0
- package/dist/auth/oidc/discovery.js +165 -0
- package/dist/auth/oidc/discovery.js.map +1 -0
- package/dist/auth/signing.d.ts +9 -0
- package/dist/auth/signing.d.ts.map +1 -1
- package/dist/auth/signing.js +9 -0
- package/dist/auth/signing.js.map +1 -1
- package/dist/config/misconfiguredApp.d.ts.map +1 -1
- package/dist/config/misconfiguredApp.js +14 -1
- package/dist/config/misconfiguredApp.js.map +1 -1
- package/dist/config/problems.d.ts +5 -0
- package/dist/config/problems.d.ts.map +1 -1
- package/dist/config/problems.js +6 -1
- package/dist/config/problems.js.map +1 -1
- package/dist/config/sso.d.ts +39 -0
- package/dist/config/sso.d.ts.map +1 -0
- package/dist/config/sso.js +169 -0
- package/dist/config/sso.js.map +1 -0
- package/dist/config/types.d.ts +41 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/http/env.d.ts +26 -1
- package/dist/http/env.d.ts.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/auth/AuthController.d.ts +0 -18
- package/dist/modules/auth/AuthController.d.ts.map +1 -1
- package/dist/modules/auth/AuthController.js +18 -150
- package/dist/modules/auth/AuthController.js.map +1 -1
- package/dist/modules/auth/loginFlow.d.ts +56 -0
- package/dist/modules/auth/loginFlow.d.ts.map +1 -0
- package/dist/modules/auth/loginFlow.js +162 -0
- package/dist/modules/auth/loginFlow.js.map +1 -0
- package/dist/modules/auth/ssoRoutes.d.ts +4 -0
- package/dist/modules/auth/ssoRoutes.d.ts.map +1 -0
- package/dist/modules/auth/ssoRoutes.js +294 -0
- package/dist/modules/auth/ssoRoutes.js.map +1 -0
- package/dist/modules/localSettings/MothershipConnectController.js +1 -1
- package/dist/modules/localSettings/MothershipConnectController.js.map +1 -1
- package/dist/modules/publicApi/PublicDebugController.d.ts.map +1 -1
- package/dist/modules/publicApi/PublicDebugController.js +5 -0
- package/dist/modules/publicApi/PublicDebugController.js.map +1 -1
- package/dist/modules/toolServers/McpOAuthCompletionController.d.ts +4 -0
- package/dist/modules/toolServers/McpOAuthCompletionController.d.ts.map +1 -0
- package/dist/modules/toolServers/McpOAuthCompletionController.js +125 -0
- package/dist/modules/toolServers/McpOAuthCompletionController.js.map +1 -0
- package/dist/modules/toolServers/ToolServerController.d.ts.map +1 -1
- package/dist/modules/toolServers/ToolServerController.js +80 -4
- package/dist/modules/toolServers/ToolServerController.js.map +1 -1
- package/dist/modules/toolServers/declaredToolServers.d.ts +15 -1
- package/dist/modules/toolServers/declaredToolServers.d.ts.map +1 -1
- package/dist/modules/toolServers/declaredToolServers.js +22 -2
- package/dist/modules/toolServers/declaredToolServers.js.map +1 -1
- package/dist/modules/toolServers/mcpOAuthRedirect.d.ts +27 -0
- package/dist/modules/toolServers/mcpOAuthRedirect.d.ts.map +1 -0
- package/dist/modules/toolServers/mcpOAuthRedirect.js +35 -0
- package/dist/modules/toolServers/mcpOAuthRedirect.js.map +1 -0
- package/dist/modules/toolServers/probeToolServer.d.ts +8 -1
- package/dist/modules/toolServers/probeToolServer.d.ts.map +1 -1
- package/dist/modules/toolServers/probeToolServer.js +51 -1
- package/dist/modules/toolServers/probeToolServer.js.map +1 -1
- package/dist/modules/workspaces/WorkspaceMemberController.d.ts.map +1 -1
- package/dist/modules/workspaces/WorkspaceMemberController.js +3 -3
- package/dist/modules/workspaces/WorkspaceMemberController.js.map +1 -1
- package/dist/persistence/rpc-allowlist.d.ts.map +1 -1
- package/dist/persistence/rpc-allowlist.js +16 -0
- package/dist/persistence/rpc-allowlist.js.map +1 -1
- package/dist/telemetry/machineTelemetryRead.d.ts +8 -3
- package/dist/telemetry/machineTelemetryRead.d.ts.map +1 -1
- package/dist/telemetry/machineTelemetryRead.js +6 -1
- package/dist/telemetry/machineTelemetryRead.js.map +1 -1
- package/package.json +10 -9
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { listToolServersContract, probeToolServerContract } from '@cat-factory/contracts';
|
|
1
|
+
import { disconnectToolServerOAuthContract, listToolServersContract, probeToolServerContract, startToolServerOAuthContract, } from '@cat-factory/contracts';
|
|
2
|
+
import { NotFoundError, ValidationError } from '@cat-factory/kernel';
|
|
2
3
|
import { buildHonoRoute } from '@toad-contracts/hono';
|
|
3
4
|
import { Hono } from 'hono';
|
|
5
|
+
import { createMcpOAuthTokenSource } from '../../agents/mcpOAuthTokenSource.js';
|
|
6
|
+
import { requireCapability } from '../../http/guards.js';
|
|
4
7
|
import { requireWorkspacePermissionIncludingReads } from '../../http/workspaceAccess.js';
|
|
5
8
|
import { param } from '../../http/params.js';
|
|
6
9
|
import { requestLogger } from '../../http/requestLogging.js';
|
|
7
|
-
import { collectDeclaredToolServers } from './declaredToolServers.js';
|
|
10
|
+
import { collectDeclaredToolServers, resolveDeclaredToolServers } from './declaredToolServers.js';
|
|
8
11
|
import { probeToolServer } from './probeToolServer.js';
|
|
12
|
+
import { requireMcpOAuthRedirectUrl } from './mcpOAuthRedirect.js';
|
|
9
13
|
/**
|
|
10
14
|
* TOOL SERVER (MCP) OPERABILITY: what this deployment declared, and whether one of them answers.
|
|
11
15
|
*
|
|
@@ -33,9 +37,21 @@ export function toolServerController() {
|
|
|
33
37
|
const gate = requireWorkspacePermissionIncludingReads('secrets.manage');
|
|
34
38
|
app.use('/tool-servers', gate);
|
|
35
39
|
app.use('/tool-servers/*', gate);
|
|
36
|
-
buildHonoRoute(app, listToolServersContract, (c) => {
|
|
40
|
+
buildHonoRoute(app, listToolServersContract, async (c) => {
|
|
37
41
|
const container = c.get('container');
|
|
38
|
-
|
|
42
|
+
// ONE read of the workspace's grants for the whole inventory, indexed by server id — the
|
|
43
|
+
// declarations are the deployment's entire registry, so a per-row lookup here would be an N+1
|
|
44
|
+
// over it. Absent store ⇒ an empty map, and each OAuth declaration renders as not connected,
|
|
45
|
+
// which is the true state of a deployment that cannot keep a grant.
|
|
46
|
+
const grants = container.mcpOAuth
|
|
47
|
+
? await container.mcpOAuth.listStatuses(param(c, 'workspaceId'))
|
|
48
|
+
: new Map();
|
|
49
|
+
return c.json({
|
|
50
|
+
servers: collectDeclaredToolServers({
|
|
51
|
+
agentKindRegistry: container.agentKindRegistry,
|
|
52
|
+
oauthGrants: grants,
|
|
53
|
+
}),
|
|
54
|
+
}, 200);
|
|
39
55
|
});
|
|
40
56
|
buildHonoRoute(app, probeToolServerContract, async (c) => {
|
|
41
57
|
const container = c.get('container');
|
|
@@ -49,9 +65,69 @@ export function toolServerController() {
|
|
|
49
65
|
...(container.toolSecretResolver
|
|
50
66
|
? { resolveToolSecrets: container.toolSecretResolver }
|
|
51
67
|
: {}),
|
|
68
|
+
// The same token source a dispatch mints with, so an OAuth server's verdict is about this
|
|
69
|
+
// board's grant rather than about an unauthenticated request nobody makes.
|
|
70
|
+
...(container.mcpOAuth
|
|
71
|
+
? {
|
|
72
|
+
resolveToolServerOAuth: createMcpOAuthTokenSource({
|
|
73
|
+
oauth: container.mcpOAuth,
|
|
74
|
+
...(container.toolSecretResolver
|
|
75
|
+
? { resolveToolSecrets: container.toolSecretResolver }
|
|
76
|
+
: {}),
|
|
77
|
+
logger: requestLogger(c),
|
|
78
|
+
}),
|
|
79
|
+
}
|
|
80
|
+
: {}),
|
|
52
81
|
logger: requestLogger(c),
|
|
53
82
|
}), 200);
|
|
54
83
|
});
|
|
84
|
+
// Begin an interactive grant. Everything that can refuse does so BEFORE a browser leaves the
|
|
85
|
+
// app: an id nothing declares (404), a server that does not authenticate with OAuth or does so
|
|
86
|
+
// with the machine grant (422), a deployment with no grant store or no registered redirect URL
|
|
87
|
+
// (503). A refusal after the redirect would land on a vendor's error page instead.
|
|
88
|
+
buildHonoRoute(app, startToolServerOAuthContract, async (c) => {
|
|
89
|
+
const container = c.get('container');
|
|
90
|
+
const oauthService = requireCapability(container.mcpOAuth, 'Tool-server OAuth is not configured: this deployment has no encryption key, so it has ' +
|
|
91
|
+
'nowhere to keep a grant.');
|
|
92
|
+
const definition = requireOAuthServer(container.agentKindRegistry, c.req.valid('param').id);
|
|
93
|
+
return c.json(await oauthService.startAuthorization({
|
|
94
|
+
workspaceId: param(c, 'workspaceId'),
|
|
95
|
+
serverId: definition.id,
|
|
96
|
+
serverUrl: definition.url,
|
|
97
|
+
oauth: definition.oauth,
|
|
98
|
+
userId: c.get('user')?.id ?? null,
|
|
99
|
+
redirectUri: requireMcpOAuthRedirectUrl(container),
|
|
100
|
+
}), 200);
|
|
101
|
+
});
|
|
102
|
+
buildHonoRoute(app, disconnectToolServerOAuthContract, async (c) => {
|
|
103
|
+
const container = c.get('container');
|
|
104
|
+
const oauthService = requireCapability(container.mcpOAuth, 'Tool-server OAuth is not configured: this deployment has no encryption key, so it has ' +
|
|
105
|
+
'nowhere to keep a grant.');
|
|
106
|
+
// The id is NOT re-checked against a live declaration. A grant outlives the declaration that
|
|
107
|
+
// created it (a deployment retires a server, or renames it in a refactor), and the row is then
|
|
108
|
+
// a live vendor token nobody can reach — so the one action that removes it must not be gated
|
|
109
|
+
// on the registry still naming it.
|
|
110
|
+
await oauthService.disconnect(param(c, 'workspaceId'), c.req.valid('param').id);
|
|
111
|
+
return c.body(null, 204);
|
|
112
|
+
});
|
|
55
113
|
return app;
|
|
56
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The declared server behind an id, narrowed to one that can actually be granted.
|
|
117
|
+
*
|
|
118
|
+
* Both refusals are the operator's to act on and neither is the same as the other: an id nothing
|
|
119
|
+
* declares means the deployment changed under the panel they are looking at (404), while a server
|
|
120
|
+
* that declares no OAuth — or declares it on a transport with no request to authorise — means the
|
|
121
|
+
* button was rendered for a row it does not apply to (422, with a `reason` the SPA translates).
|
|
122
|
+
*/
|
|
123
|
+
function requireOAuthServer(registry, serverId) {
|
|
124
|
+
const declared = resolveDeclaredToolServers(registry).get(serverId);
|
|
125
|
+
if (!declared)
|
|
126
|
+
throw new NotFoundError('Tool server', serverId);
|
|
127
|
+
const { oauth, transport, id } = declared.definition;
|
|
128
|
+
if (!oauth || transport.kind !== 'http') {
|
|
129
|
+
throw new ValidationError(`Tool server '${serverId}' does not authenticate with OAuth, so there is nothing to grant.`, { reason: 'tool_server_without_oauth' });
|
|
130
|
+
}
|
|
131
|
+
return { id, url: transport.url, oauth };
|
|
132
|
+
}
|
|
57
133
|
//# sourceMappingURL=ToolServerController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolServerController.js","sourceRoot":"","sources":["../../../src/modules/toolServers/ToolServerController.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ToolServerController.js","sourceRoot":"","sources":["../../../src/modules/toolServers/ToolServerController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,wCAAwC,EAAE,MAAM,+BAA+B,CAAA;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAU,CAAA;IAC9B,+FAA+F;IAC/F,iGAAiG;IACjG,iGAAiG;IACjG,2EAA2E;IAC3E,MAAM,IAAI,GAAG,wCAAwC,CAAC,gBAAgB,CAAC,CAAA;IACvE,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;IAC9B,GAAG,CAAC,GAAG,CA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A;AAC1C,CAAC"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import type { AgentKind, McpServerDefinition } from '@cat-factory/kernel';
|
|
2
2
|
import type { AgentKindRegistry } from '@cat-factory/agents';
|
|
3
|
-
import type { ToolServerNotProbeableReason, ToolServerView } from '@cat-factory/contracts';
|
|
3
|
+
import type { ToolServerNotProbeableReason, ToolServerOAuthStatus, ToolServerView } from '@cat-factory/contracts';
|
|
4
|
+
/**
|
|
5
|
+
* The non-secret half of a stored grant, as `McpOAuthService.listStatuses` returns it: everything
|
|
6
|
+
* `ToolServerOAuthStatus` holds except the two fields the DECLARATION decides (`grant`) and this
|
|
7
|
+
* projection derives (`connected`).
|
|
8
|
+
*/
|
|
9
|
+
export type StoredOAuthGrants = ReadonlyMap<string, Omit<ToolServerOAuthStatus, 'grant' | 'connected'>>;
|
|
4
10
|
export interface CollectDeclaredToolServersInput {
|
|
5
11
|
agentKindRegistry: AgentKindRegistry;
|
|
12
|
+
/**
|
|
13
|
+
* This workspace's grants, keyed by server id — read ONCE for the whole inventory rather than
|
|
14
|
+
* per row, because the rows are the deployment's entire registry.
|
|
15
|
+
*
|
|
16
|
+
* Omitted ⇒ no grant store is wired, and every OAuth declaration renders as not connected, which
|
|
17
|
+
* is the true state of a deployment that has nowhere to keep a grant.
|
|
18
|
+
*/
|
|
19
|
+
oauthGrants?: StoredOAuthGrants;
|
|
6
20
|
}
|
|
7
21
|
/** One declared server: the definition this surface answers for, and the kinds that reach it. */
|
|
8
22
|
export interface DeclaredToolServer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaredToolServers.d.ts","sourceRoot":"","sources":["../../../src/modules/toolServers/declaredToolServers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAOzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"declaredToolServers.d.ts","sourceRoot":"","sources":["../../../src/modules/toolServers/declaredToolServers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAOzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAa/B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,CACzC,MAAM,EACN,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,WAAW,CAAC,CACnD,CAAA;AAED,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,iBAAiB,CAAA;IACpC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAChC;AAED,iGAAiG;AACjG,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,mBAAmB,CAAA;IAC/B,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,iBAAiB,GAC1B,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAejC;AAED,2EAA2E;AAC3E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,+BAA+B,GACrC,cAAc,EAAE,CAMlB;AAsED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,mBAAmB,GAC9B,4BAA4B,GAAG,SAAS,CAS1C"}
|
|
@@ -43,11 +43,11 @@ export function resolveDeclaredToolServers(registry) {
|
|
|
43
43
|
/** Every declared tool server, projected non-secretly and sorted by id. */
|
|
44
44
|
export function collectDeclaredToolServers(input) {
|
|
45
45
|
return [...resolveDeclaredToolServers(input.agentKindRegistry).values()]
|
|
46
|
-
.map((declared) => toView(declared.definition, declared.declaredBy))
|
|
46
|
+
.map((declared) => toView(declared.definition, declared.declaredBy, input.oauthGrants ?? new Map()))
|
|
47
47
|
.sort((a, b) => a.id.localeCompare(b.id));
|
|
48
48
|
}
|
|
49
49
|
/** Project one definition into its non-secret operator-facing view. */
|
|
50
|
-
function toView(definition, declaredBy) {
|
|
50
|
+
function toView(definition, declaredBy, grants) {
|
|
51
51
|
const notProbeable = notProbeableReason(definition);
|
|
52
52
|
return {
|
|
53
53
|
id: definition.id,
|
|
@@ -65,10 +65,30 @@ function toView(definition, declaredBy) {
|
|
|
65
65
|
required: secret.required !== false,
|
|
66
66
|
...(secret.usage ? { usage: secret.usage } : {}),
|
|
67
67
|
})),
|
|
68
|
+
...oauthStatus(definition, grants),
|
|
68
69
|
probeable: notProbeable === undefined,
|
|
69
70
|
...(notProbeable ? { notProbeableReason: notProbeable } : {}),
|
|
70
71
|
};
|
|
71
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The OAuth half of a row: the declaration's grant type, joined to whether THIS workspace holds a
|
|
75
|
+
* grant for it.
|
|
76
|
+
*
|
|
77
|
+
* Absent for a server that declares no OAuth, which is what keeps the Connect affordance off every
|
|
78
|
+
* row it does not apply to. `connected` is derived from the presence of a stored grant rather than
|
|
79
|
+
* stored as a flag, so a disconnect that removed the row cannot leave a row claiming otherwise.
|
|
80
|
+
*/
|
|
81
|
+
function oauthStatus(definition, grants) {
|
|
82
|
+
const oauth = definition.oauth;
|
|
83
|
+
if (!oauth)
|
|
84
|
+
return {};
|
|
85
|
+
const stored = grants.get(definition.id);
|
|
86
|
+
// The stored half is spread FIRST so the two derived fields cannot be overwritten by it. The
|
|
87
|
+
// summary is a JSON blob parsed back out of a row, so its shape is a claim rather than a
|
|
88
|
+
// guarantee, and a drifted one must not be able to say a server is `connected` when no row was
|
|
89
|
+
// read or to rename the grant the DECLARATION states.
|
|
90
|
+
return { oauth: { ...stored, grant: oauth.grant, connected: Boolean(stored) } };
|
|
91
|
+
}
|
|
72
92
|
/**
|
|
73
93
|
* What the declaration points at, for recognition on the surface.
|
|
74
94
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaredToolServers.js","sourceRoot":"","sources":["../../../src/modules/toolServers/declaredToolServers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,GACd,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"declaredToolServers.js","sourceRoot":"","sources":["../../../src/modules/toolServers/declaredToolServers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,GACd,MAAM,qBAAqB,CAAA;AAO5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAwCxE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAA2B;IAE3B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA8B,CAAA;IAEtD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,qBAAqB,EAAE,EAAE,CAAC;QACpD,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YAC3D,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YACxC,IAAI,QAAQ;gBAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;;gBACvC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC1E,CAAC;IACH,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CA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AI,KAAK,MAAM;QAAE,OAAO,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9F,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAA;IAC5C,OAAO,aAAa,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;AAC/E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA+B;IAE/B,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,iBAAiB,CAAA;IACnE,MAAM,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,CAAA;IACpC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;QAAE,OAAO,iBAAiB,CAAA;IACvD,iGAAiG;IACjG,kGAAkG;IAClG,qEAAqE;IACrE,IAAI,oBAAoB,CAAC,GAAG,CAAC;QAAE,OAAO,qBAAqB,CAAA;IAC3D,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ServerContainer } from '../../http/env.js';
|
|
2
|
+
/**
|
|
3
|
+
* The path in the SPA that a vendor's authorization server redirects an operator's browser to.
|
|
4
|
+
*
|
|
5
|
+
* A page in the APP rather than a route on this backend, and that is a security decision rather
|
|
6
|
+
* than a routing preference. A redirect target is reached by a third-party browser navigation,
|
|
7
|
+
* which carries no bearer token, so a backend route receiving it could never tell who was
|
|
8
|
+
* completing the grant; the page re-presents the vendor's `code` and `state` over the authenticated
|
|
9
|
+
* API instead (`completeToolServerOAuthContract`), where the session, the user binding and the
|
|
10
|
+
* `secrets.manage` re-check all apply. Exported for the docs and tests that must state the exact
|
|
11
|
+
* string an operator registers at the vendor.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MCP_OAUTH_CALLBACK_PATH = "/mcp-oauth-callback";
|
|
14
|
+
/**
|
|
15
|
+
* The configured redirect URL, or the refusal that names what to configure.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately not derived from the incoming request. The value has to match, to the byte, what
|
|
18
|
+
* the deployment registered as its OAuth client's redirect URI, and a `Host`-derived string is a
|
|
19
|
+
* different value behind every proxy, preview URL and private hostname a deployment sits behind —
|
|
20
|
+
* so deriving it turns a one-time configuration step into an exchange that fails at the vendor
|
|
21
|
+
* with `redirect_uri_mismatch`, which names nothing on this side.
|
|
22
|
+
*
|
|
23
|
+
* A 503 with its own `reason` rather than a generic unavailability, because the deployment IS
|
|
24
|
+
* otherwise wired: the store exists, the declaration is sound, and one variable is missing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function requireMcpOAuthRedirectUrl(container: ServerContainer): string;
|
|
27
|
+
//# sourceMappingURL=mcpOAuthRedirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpOAuthRedirect.d.ts","sourceRoot":"","sources":["../../../src/modules/toolServers/mcpOAuthRedirect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,CAAA;AAE5D;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAW7E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UnavailableError } from '@cat-factory/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* The path in the SPA that a vendor's authorization server redirects an operator's browser to.
|
|
4
|
+
*
|
|
5
|
+
* A page in the APP rather than a route on this backend, and that is a security decision rather
|
|
6
|
+
* than a routing preference. A redirect target is reached by a third-party browser navigation,
|
|
7
|
+
* which carries no bearer token, so a backend route receiving it could never tell who was
|
|
8
|
+
* completing the grant; the page re-presents the vendor's `code` and `state` over the authenticated
|
|
9
|
+
* API instead (`completeToolServerOAuthContract`), where the session, the user binding and the
|
|
10
|
+
* `secrets.manage` re-check all apply. Exported for the docs and tests that must state the exact
|
|
11
|
+
* string an operator registers at the vendor.
|
|
12
|
+
*/
|
|
13
|
+
export const MCP_OAUTH_CALLBACK_PATH = '/mcp-oauth-callback';
|
|
14
|
+
/**
|
|
15
|
+
* The configured redirect URL, or the refusal that names what to configure.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately not derived from the incoming request. The value has to match, to the byte, what
|
|
18
|
+
* the deployment registered as its OAuth client's redirect URI, and a `Host`-derived string is a
|
|
19
|
+
* different value behind every proxy, preview URL and private hostname a deployment sits behind —
|
|
20
|
+
* so deriving it turns a one-time configuration step into an exchange that fails at the vendor
|
|
21
|
+
* with `redirect_uri_mismatch`, which names nothing on this side.
|
|
22
|
+
*
|
|
23
|
+
* A 503 with its own `reason` rather than a generic unavailability, because the deployment IS
|
|
24
|
+
* otherwise wired: the store exists, the declaration is sound, and one variable is missing.
|
|
25
|
+
*/
|
|
26
|
+
export function requireMcpOAuthRedirectUrl(container) {
|
|
27
|
+
const url = container.mcpOAuthRedirectUrl?.trim();
|
|
28
|
+
if (!url) {
|
|
29
|
+
throw new UnavailableError('Tool-server OAuth needs a redirect URL. Set MCP_OAUTH_REDIRECT_URL to this deployment’s ' +
|
|
30
|
+
`public app URL followed by ${MCP_OAUTH_CALLBACK_PATH}, and register the same value as ` +
|
|
31
|
+
'the OAuth client’s redirect URI at the vendor.', 'mcp_oauth_redirect_url_not_configured');
|
|
32
|
+
}
|
|
33
|
+
return url;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=mcpOAuthRedirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpOAuthRedirect.js","sourceRoot":"","sources":["../../../src/modules/toolServers/mcpOAuthRedirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAGtD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,qBAAqB,CAAA;AAE5D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,0BAA0B,CAAC,SAA0B;IACnE,MAAM,GAAG,GAAG,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAA;IACjD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,gBAAgB,CACxB,0FAA0F;YACxF,8BAA8B,uBAAuB,mCAAmC;YACxF,gDAAgD,EAClD,uCAAuC,CACxC,CAAA;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Logger, ToolSecretResolver } from '@cat-factory/kernel';
|
|
1
|
+
import type { Logger, McpOAuthTokenSource, ToolSecretResolver } from '@cat-factory/kernel';
|
|
2
2
|
import type { ToolServerProbeResult } from '@cat-factory/contracts';
|
|
3
3
|
import type { AgentKindRegistry } from '@cat-factory/agents';
|
|
4
4
|
import { type McpProbeDeps } from './mcpProbe.js';
|
|
@@ -14,6 +14,13 @@ export interface ProbeToolServerInput {
|
|
|
14
14
|
* path already applies to the same state.
|
|
15
15
|
*/
|
|
16
16
|
resolveToolSecrets?: ToolSecretResolver;
|
|
17
|
+
/**
|
|
18
|
+
* The facade's OAuth token source — the SAME one a dispatch mints an `Authorization` header
|
|
19
|
+
* with. Absent ⇒ the deployment has no grant store, and a server declaring OAuth is reported as
|
|
20
|
+
* `oauth_not_connected` rather than probed unauthenticated, which would report a working server
|
|
21
|
+
* as a 401 and send the operator to the wrong fix.
|
|
22
|
+
*/
|
|
23
|
+
resolveToolServerOAuth?: McpOAuthTokenSource;
|
|
17
24
|
logger?: Logger;
|
|
18
25
|
/** Injected for tests; forwarded to the protocol client. */
|
|
19
26
|
probe?: McpProbeDeps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probeToolServer.d.ts","sourceRoot":"","sources":["../../../src/modules/toolServers/probeToolServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,
|
|
1
|
+
{"version":3,"file":"probeToolServer.d.ts","sourceRoot":"","sources":["../../../src/modules/toolServers/probeToolServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EAGnB,kBAAkB,EACnB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAG5D,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,eAAe,CAAA;AAuBrE,MAAM,WAAW,oBAAoB;IACnC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,WAAW,EAAE,MAAM,CAAA;IACnB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,mBAAmB,CAAA;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAqDjG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NotFoundError, isValidMcpToolName, noopLogger, runBestEffort } from '@cat-factory/kernel';
|
|
2
2
|
import { isReservedPlatformEnvKey, reservedEnvKeyMessage } from '@cat-factory/contracts';
|
|
3
3
|
import { MCP_PROBE_TOOL_NAME_CAP } from '@cat-factory/contracts';
|
|
4
|
+
import { mergeHeaders } from '../../agents/toolServers.js';
|
|
4
5
|
import { notProbeableReason, resolveDeclaredToolServers } from './declaredToolServers.js';
|
|
5
6
|
import { probeMcpHttpServer } from './mcpProbe.js';
|
|
6
7
|
/**
|
|
@@ -25,13 +26,21 @@ export async function probeToolServer(input) {
|
|
|
25
26
|
const credentials = await resolveCredentials(input, definition);
|
|
26
27
|
if (!credentials.ok)
|
|
27
28
|
return { serverId, ...credentials.failure };
|
|
29
|
+
const granted = await resolveOAuthHeader(input, definition, definition.transport.url);
|
|
30
|
+
if (!granted.ok)
|
|
31
|
+
return { serverId, ...granted.failure };
|
|
28
32
|
const outcome = await probeMcpHttpServer({
|
|
29
33
|
url: definition.transport.url,
|
|
30
34
|
// The declaration's own headers and the RESOLVED CREDENTIAL stay apart, because the protocol
|
|
31
35
|
// client treats them differently at a redirect: a hop off the declared origin is refused while
|
|
32
36
|
// a credential is riding, and a non-secret `x-tenant` is no reason to refuse anything.
|
|
33
37
|
headers: { ...definition.transport.headers },
|
|
34
|
-
|
|
38
|
+
// The granted token joins the CREDENTIAL side, not the declaration's own headers: it is the
|
|
39
|
+
// secret a cross-origin redirect must not carry, which is the whole reason the probe keeps
|
|
40
|
+
// the two apart. Last, so it wins a header a static credential also names — the same
|
|
41
|
+
// precedence the dispatch applies (through the same case-insensitive merge, so the probe
|
|
42
|
+
// cannot report on a header pair the dispatch would collapse), and boot warns about it.
|
|
43
|
+
credentialHeaders: mergeHeaders(credentials.headers, granted.headers),
|
|
35
44
|
}, input.probe);
|
|
36
45
|
if (outcome.status !== 'ok') {
|
|
37
46
|
input.logger?.warn('tool server probe failed', {
|
|
@@ -96,6 +105,47 @@ function checkAllowedTools(definition, tools, toolsComplete) {
|
|
|
96
105
|
},
|
|
97
106
|
};
|
|
98
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Mint the access token an OAuth-declaring server needs, as the header its declaration named.
|
|
110
|
+
*
|
|
111
|
+
* The two failure statuses are the probe's whole value here. `oauth_not_connected` says nobody has
|
|
112
|
+
* granted this board access, which is a Connect button rather than anything about the endpoint;
|
|
113
|
+
* `oauth_token_failed` says a grant IS on file and produced nothing, which is a revocation, an
|
|
114
|
+
* expiry, or an authorization server having a bad day. Probing anyway and reporting the 401 would
|
|
115
|
+
* collapse both into "your credential is wrong", the one diagnosis that is false in both cases.
|
|
116
|
+
*/
|
|
117
|
+
async function resolveOAuthHeader(input, definition, serverUrl) {
|
|
118
|
+
const oauth = definition.oauth;
|
|
119
|
+
if (!oauth)
|
|
120
|
+
return { ok: true, headers: {} };
|
|
121
|
+
const source = input.resolveToolServerOAuth;
|
|
122
|
+
if (!source) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
failure: {
|
|
126
|
+
status: 'oauth_not_connected',
|
|
127
|
+
error: 'This deployment has no encryption key, so it has nowhere to keep an OAuth grant and ' +
|
|
128
|
+
'no run can authenticate against this server either.',
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const result = await source.accessToken({
|
|
133
|
+
workspaceId: input.workspaceId,
|
|
134
|
+
serverId: definition.id,
|
|
135
|
+
serverUrl,
|
|
136
|
+
oauth,
|
|
137
|
+
});
|
|
138
|
+
if (result.status === 'ok')
|
|
139
|
+
return { ok: true, headers: { [result.header]: result.value } };
|
|
140
|
+
if (result.status === 'not_connected')
|
|
141
|
+
return { ok: false, failure: { status: 'oauth_not_connected' } };
|
|
142
|
+
input.logger?.warn('tool server probe could not obtain an oauth token', {
|
|
143
|
+
toolServerId: definition.id,
|
|
144
|
+
workspaceId: input.workspaceId,
|
|
145
|
+
detail: result.error,
|
|
146
|
+
});
|
|
147
|
+
return { ok: false, failure: { status: 'oauth_token_failed', error: result.error } };
|
|
148
|
+
}
|
|
99
149
|
/**
|
|
100
150
|
* Resolve the declared credentials into request headers, or report why the probe cannot proceed.
|
|
101
151
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probeToolServer.js","sourceRoot":"","sources":["../../../src/modules/toolServers/probeToolServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"probeToolServer.js","sourceRoot":"","sources":["../../../src/modules/toolServers/probeToolServer.ts"],"names":[],"m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AAC,MAAM,CAAC,GAAG,MAAM,CAAC,cAAc;YAC5C,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC;YACpD,CAAC,CAAC,KAAK,CAAA;IACX,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceMemberController.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/WorkspaceMemberController.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAyB/C,wBAAgB,yBAAyB,IAAI,IAAI,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"WorkspaceMemberController.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/WorkspaceMemberController.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAyB/C,wBAAgB,yBAAyB,IAAI,IAAI,CAAC,MAAM,CAAC,CAuDxD"}
|
|
@@ -37,20 +37,20 @@ export function workspaceMemberController() {
|
|
|
37
37
|
const service = requireMemberService(c);
|
|
38
38
|
requirePermission(c, 'members.manage');
|
|
39
39
|
const { workspaceId, userId } = c.req.valid('param');
|
|
40
|
-
const member = await service.setRole(workspaceId, userId, c.req.valid('json').role);
|
|
40
|
+
const member = await service.setRole(workspaceId, userId, c.req.valid('json').role, c.get('user')?.id ?? null);
|
|
41
41
|
return c.json(member, 200);
|
|
42
42
|
});
|
|
43
43
|
buildHonoRoute(app, removeWorkspaceMemberContract, async (c) => {
|
|
44
44
|
const service = requireMemberService(c);
|
|
45
45
|
requirePermission(c, 'members.manage');
|
|
46
46
|
const { workspaceId, userId } = c.req.valid('param');
|
|
47
|
-
await service.remove(workspaceId, userId);
|
|
47
|
+
await service.remove(workspaceId, userId, c.get('user')?.id ?? null);
|
|
48
48
|
return c.body(null, 204);
|
|
49
49
|
});
|
|
50
50
|
buildHonoRoute(app, setWorkspaceAccessModeContract, async (c) => {
|
|
51
51
|
const service = requireMemberService(c);
|
|
52
52
|
requirePermission(c, 'members.manage');
|
|
53
|
-
const workspace = await service.setAccessMode(param(c, 'workspaceId'), c.req.valid('json').accessMode);
|
|
53
|
+
const workspace = await service.setAccessMode(param(c, 'workspaceId'), c.req.valid('json').accessMode, c.get('user')?.id ?? null);
|
|
54
54
|
return c.json(workspace, 200);
|
|
55
55
|
});
|
|
56
56
|
return app;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceMemberController.js","sourceRoot":"","sources":["../../../src/modules/workspaces/WorkspaceMemberController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,8EAA8E;AAC9E,uFAAuF;AACvF,sFAAsF;AACtF,qFAAqF;AACrF,sFAAsF;AACtF,iFAAiF;AACjF,+DAA+D;AAC/D,EAAE;AACF,0FAA0F;AAC1F,qFAAqF;AACrF,8EAA8E;AAE9E,8FAA8F;AAC9F,SAAS,oBAAoB,CAAmB,CAAa;IAC3D,OAAO,iBAAiB,CACtB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,sBAAsB,EACzC,wCAAwC,CACzC,CAAA;AACH,CAAC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AAA;QACpD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"WorkspaceMemberController.js","sourceRoot":"","sources":["../../../src/modules/workspaces/WorkspaceMemberController.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,8EAA8E;AAC9E,uFAAuF;AACvF,sFAAsF;AACtF,qFAAqF;AACrF,sFAAsF;AACtF,iFAAiF;AACjF,+DAA+D;AAC/D,EAAE;AACF,0FAA0F;AAC1F,qFAAqF;AACrF,8EAA8E;AAE9E,8FAA8F;AAC9F,SAAS,oBAAoB,CAAmB,CAAa;IAC3D,OAAO,iBAAiB,CACtB,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,sBAAsB,EACzC,wCAAwC,CACzC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAU,CAAA;IAE9B,wFAAwF;IACxF,cAAc,CAAC,GAAG,EAAE,4BAA4B,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAA;QACvC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA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O,MAAM,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"rpc-allowlist.d.ts","sourceRoot":"","sources":["../../src/persistence/rpc-allowlist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAgBtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,0BAA0B,EAAE,sBAopCxC,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oCAAoC,YAC/C,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,kCAAkC,CAC1B,CAAA;AAEV,yEAAyE;AACzE,MAAM,MAAM,+BAA+B,GAAG,CAAC,OAAO,oCAAoC,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -853,6 +853,22 @@ export const REMOTE_PERSISTENCE_METHODS = {
|
|
|
853
853
|
deleteIfRev: { scope: { kind: 'workspace', arg: 0 } },
|
|
854
854
|
delete: { scope: { kind: 'workspace', arg: 0 } },
|
|
855
855
|
},
|
|
856
|
+
// The PER-WORKSPACE OAUTH GRANTS a board holds against remote MCP tool servers. Sealed exactly
|
|
857
|
+
// like the credentials above (opened in the service under the LOCAL key), so no token crosses
|
|
858
|
+
// the machine API, and `remote` for the identical reason: the grant is org state a RUN resolves,
|
|
859
|
+
// and a mothership-mode node has no `db` to keep it in — a connection an operator made on the
|
|
860
|
+
// mothership has to reach the dispatch that needs the token. The connect/disconnect CRUD and the
|
|
861
|
+
// dispatch's refresh are the SAME methods; everything is workspace-scoped on arg0 except the
|
|
862
|
+
// record-based `upsert`/`compareAndSwap`, which bind on the record's `workspaceId` FIELD. The
|
|
863
|
+
// rev-guarded `compareAndSwap` is what makes a refresh safe across two nodes rather than two
|
|
864
|
+
// requests, which is precisely the case a mothership deployment makes ordinary.
|
|
865
|
+
mcpOAuthGrantRepository: {
|
|
866
|
+
get: { scope: { kind: 'workspace', arg: 0 } },
|
|
867
|
+
listByWorkspace: { scope: { kind: 'workspace', arg: 0 } },
|
|
868
|
+
upsert: { scope: { kind: 'workspaceField', arg: 0 } },
|
|
869
|
+
compareAndSwap: { scope: { kind: 'workspaceField', arg: 0 } },
|
|
870
|
+
delete: { scope: { kind: 'workspace', arg: 0 } },
|
|
871
|
+
},
|
|
856
872
|
// The per-service PRE-PR VALIDATION CHECKS, keyed by service-frame block like
|
|
857
873
|
// `releaseHealthConfigRepository` above. Nothing sealed — the commands are operator-authored
|
|
858
874
|
// shell strings that run inside the run's own container — so the plain record crosses the
|