@agent-native/core 0.198.3-nightly-20260930124743 → 0.198.3
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/cli/create-tui.js +31 -9
- package/dist/cli/create.js +14 -0
- package/dist/cli/design-connect.js +10 -2
- package/dist/cli/migration-codemod.js +2 -1
- package/dist/cli/skills.js +15 -32
- package/dist/cli/upgrade.d.ts +3 -2
- package/dist/cli/upgrade.js +3 -0
- package/dist/cli/workspacify.js +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.d.ts +3 -0
- package/dist/db/client.js +7 -4
- package/dist/db/create-get-db.js +478 -3
- package/dist/deploy/workspace-deploy.js +18 -5
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/jobs/actions/manage-recurring-job.d.ts +1 -1
- package/dist/localization/core-messages/supplemental/ar-SA.js +2 -0
- package/dist/localization/core-messages/supplemental/de-DE.js +2 -0
- package/dist/localization/core-messages/supplemental/en-US.js +2 -0
- package/dist/localization/core-messages/supplemental/es-ES.js +2 -0
- package/dist/localization/core-messages/supplemental/fr-FR.js +2 -0
- package/dist/localization/core-messages/supplemental/hi-IN.js +2 -0
- package/dist/localization/core-messages/supplemental/ja-JP.js +2 -0
- package/dist/localization/core-messages/supplemental/ko-KR.js +2 -0
- package/dist/localization/core-messages/supplemental/pt-BR.js +2 -0
- package/dist/localization/core-messages/supplemental/zh-CN.js +2 -0
- package/dist/localization/core-messages/supplemental/zh-TW.js +2 -0
- package/dist/localization/mcp-settings-messages.d.ts +2 -0
- package/dist/mcp/connect-route.js +57 -10
- package/dist/mcp/oauth-route.js +4 -21
- package/dist/mcp/org-choice.d.ts +26 -0
- package/dist/mcp/org-choice.js +36 -0
- package/dist/observability/routes.d.ts +1 -1
- package/dist/org/handlers.d.ts +1 -1
- package/dist/org/index.d.ts +1 -1
- package/dist/org/index.js +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +10 -10
- package/dist/provider-api/actions/provider-api.d.ts +12 -12
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +10 -10
- package/dist/server/agent-engine-default-model-route.d.ts +2 -2
- package/dist/server/agent-engine-ollama-models-route.d.ts +2 -2
- package/dist/server/credential-provider.js +5 -0
- package/dist/sharing/access.js +4 -3
- package/dist/vite/client.js +11 -3
- package/package.json +4 -4
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "Révoquer",
|
|
38
38
|
couldNotRevoke: "Impossible de révoquer le jeton.",
|
|
39
39
|
authorizeDevice: "Autoriser l’appareil",
|
|
40
|
+
organization: "Organisation",
|
|
41
|
+
invalidOrganization: "Choisissez une organisation dont vous êtes membre.",
|
|
40
42
|
fullCatalogRequested: "Cet appareil demande l’accès au catalogue complet des actions.",
|
|
41
43
|
createToken: "Créer un jeton de connexion",
|
|
42
44
|
authorizingDevice: "Autorisation de l’appareil...",
|
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "Revoke करें",
|
|
38
38
|
couldNotRevoke: "Token revoke नहीं किया जा सका।",
|
|
39
39
|
authorizeDevice: "डिवाइस को अनुमति दें",
|
|
40
|
+
organization: "संगठन",
|
|
41
|
+
invalidOrganization: "ऐसा संगठन चुनें जिसके आप सदस्य हैं।",
|
|
40
42
|
fullCatalogRequested: "यह डिवाइस पूरे एक्शन कैटलॉग तक पहुंच का अनुरोध कर रहा है।",
|
|
41
43
|
createToken: "कनेक्शन token बनाएँ",
|
|
42
44
|
authorizingDevice: "डिवाइस को अनुमति दी जा रही है...",
|
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "取り消す",
|
|
38
38
|
couldNotRevoke: "トークンを取り消せませんでした。",
|
|
39
39
|
authorizeDevice: "デバイスを承認",
|
|
40
|
+
organization: "組織",
|
|
41
|
+
invalidOrganization: "所属している組織を選択してください。",
|
|
40
42
|
fullCatalogRequested: "このデバイスは、すべてのアクションカタログへのアクセスを要求しています。",
|
|
41
43
|
createToken: "接続トークンを作成",
|
|
42
44
|
authorizingDevice: "デバイスを承認中...",
|
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "취소",
|
|
38
38
|
couldNotRevoke: "토큰을 취소할 수 없습니다.",
|
|
39
39
|
authorizeDevice: "기기 승인",
|
|
40
|
+
organization: "조직",
|
|
41
|
+
invalidOrganization: "소속된 조직을 선택하세요.",
|
|
40
42
|
fullCatalogRequested: "이 기기는 전체 작업 카탈로그에 대한 액세스를 요청하고 있습니다.",
|
|
41
43
|
createToken: "연결 토큰 생성",
|
|
42
44
|
authorizingDevice: "기기 승인 중...",
|
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "Revogar",
|
|
38
38
|
couldNotRevoke: "Não foi possível revogar o token.",
|
|
39
39
|
authorizeDevice: "Autorizar dispositivo",
|
|
40
|
+
organization: "Organização",
|
|
41
|
+
invalidOrganization: "Escolha uma organização da qual você faz parte.",
|
|
40
42
|
fullCatalogRequested: "Este dispositivo está solicitando acesso ao catálogo completo de ações.",
|
|
41
43
|
createToken: "Criar token de conexão",
|
|
42
44
|
authorizingDevice: "Autorizando dispositivo...",
|
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "撤销",
|
|
38
38
|
couldNotRevoke: "无法撤销令牌。",
|
|
39
39
|
authorizeDevice: "授权设备",
|
|
40
|
+
organization: "组织",
|
|
41
|
+
invalidOrganization: "请选择你所属的组织。",
|
|
40
42
|
fullCatalogRequested: "此设备正在请求访问完整的操作目录。",
|
|
41
43
|
createToken: "创建连接令牌",
|
|
42
44
|
authorizingDevice: "正在授权设备...",
|
|
@@ -37,6 +37,8 @@ export const mcpConnectMessages = {
|
|
|
37
37
|
revoke: "撤銷",
|
|
38
38
|
couldNotRevoke: "無法撤銷權杖。",
|
|
39
39
|
authorizeDevice: "授權裝置",
|
|
40
|
+
organization: "組織",
|
|
41
|
+
invalidOrganization: "請選擇你所屬的組織。",
|
|
40
42
|
fullCatalogRequested: "此裝置正在要求存取完整的動作目錄。",
|
|
41
43
|
createToken: "建立連線權杖",
|
|
42
44
|
authorizingDevice: "正在授權裝置...",
|
|
@@ -11,6 +11,7 @@ import { readBody } from "../server/h3-helpers.js";
|
|
|
11
11
|
import { MCP_CONNECT_MCP_URL_TEMPLATE, getMcpConnectGuides, getMcpStaticTokenFallback, interpolateMcpConnectTemplate, resolveMcpConnectGuideId, } from "../shared/mcp-connect-content.js";
|
|
12
12
|
import { recordMintedToken, listTokens, revokeToken, normalizeServiceName, serviceIdentityEmail, createDeviceCode, getDeviceCode, getDeviceCodeByUserCode, approveDeviceCode, consumeDeviceCode, claimDeviceCodeForMint, finishDeviceCodeMint, releaseDeviceCodeMint, expireDeviceCode, MCP_CONNECT_OAUTH_CLIENT_ID, MCP_CONNECT_SCOPE, DEFAULT_TOKEN_TTL_DAYS, MIN_TOKEN_TTL_DAYS, MAX_TOKEN_TTL_DAYS, DEVICE_CODE_TTL_MS, } from "./connect-store.js";
|
|
13
13
|
import { MCP_OAUTH_DEFAULT_SCOPE, signMcpOAuthAccessToken, } from "./oauth-token.js";
|
|
14
|
+
import { resolveMcpOrgChoices } from "./org-choice.js";
|
|
14
15
|
import { MCP_PUBLIC_ROUTE_PREFIX } from "./route-paths.js";
|
|
15
16
|
const DEVICE_POLL_INTERVAL_S = 3;
|
|
16
17
|
const USER_CODE_RE = /^[A-Z2-7]{4}-[A-Z2-7]{4}$/;
|
|
@@ -287,7 +288,7 @@ function renderConnectGuide(guide, activeGuideId, values, copyLabel) {
|
|
|
287
288
|
return `<div class="tab-panel${guide.id === activeGuideId ? " is-active" : ""}" role="tabpanel" id="mcp-guide-panel-${guideId}" aria-labelledby="mcp-guide-tab-${guideId}" data-panel="${guideId}">${content}</div>`;
|
|
288
289
|
}
|
|
289
290
|
function renderConnectPage(params) {
|
|
290
|
-
const { connectBasePath, email, appName, appUrl, serverId, userCode, catalogScope, locale, requestedGuide, } = params;
|
|
291
|
+
const { connectBasePath, email, appName, appUrl, serverId, userCode, catalogScope, locale, requestedGuide, organizations, defaultOrganizationId, } = params;
|
|
291
292
|
const direction = localeDirection(locale);
|
|
292
293
|
const messages = mcpSettingsMessagesForLocale(locale);
|
|
293
294
|
const connectMessages = messages.mcpConnect;
|
|
@@ -316,6 +317,19 @@ function renderConnectPage(params) {
|
|
|
316
317
|
const guidePanelsHtml = guides
|
|
317
318
|
.map((guide) => renderConnectGuide(guide, activeGuideId, connectTemplateValues, messages.mcpCopy))
|
|
318
319
|
.join("\n");
|
|
320
|
+
const organizationSelectorHtml = safeUserCode && organizations.length > 1
|
|
321
|
+
? `<div class="field">
|
|
322
|
+
<label for="organizationId">${localize(connectMessages.organization)}</label>
|
|
323
|
+
<div class="select-wrap">
|
|
324
|
+
<select id="organizationId">
|
|
325
|
+
${organizations
|
|
326
|
+
.map((organization) => `<option value="${escapeHtml(organization.id)}"${organization.id === defaultOrganizationId ? " selected" : ""}>${escapeHtml(organization.name)}${organization.domain ? ` (${escapeHtml(organization.domain)})` : ""}</option>`)
|
|
327
|
+
.join("")}
|
|
328
|
+
</select>
|
|
329
|
+
<span class="chev" aria-hidden="true"></span>
|
|
330
|
+
</div>
|
|
331
|
+
</div>`
|
|
332
|
+
: "";
|
|
319
333
|
const setupHtml = safeUserCode
|
|
320
334
|
? ""
|
|
321
335
|
: `
|
|
@@ -426,7 +440,7 @@ function renderConnectPage(params) {
|
|
|
426
440
|
display: flex; align-items: center; justify-content: space-between;
|
|
427
441
|
gap: 0.75rem; border: 1px solid var(--border);
|
|
428
442
|
border-radius: 8px; padding: 0.5rem 0.65rem; margin: 0 0 0.9rem;
|
|
429
|
-
background: var(--panel-soft); color: var(--muted);
|
|
443
|
+
background: var(--panel-soft); color: var(--muted); line-height: 1.2rem;
|
|
430
444
|
}
|
|
431
445
|
.device-strip .label {
|
|
432
446
|
font-size: 0.76rem; font-weight: 560; color: var(--subtle);
|
|
@@ -503,12 +517,25 @@ function renderConnectPage(params) {
|
|
|
503
517
|
.field:last-child { margin-bottom: 0; }
|
|
504
518
|
.field label { display: block; font-size: 0.78rem; color: var(--muted);
|
|
505
519
|
margin-bottom: 0.35rem; }
|
|
506
|
-
.field input {
|
|
520
|
+
.field input, .field select {
|
|
507
521
|
width: 100%; padding: 0.6rem 0.7rem; font: inherit; color: var(--text);
|
|
508
522
|
background: var(--panel-2); border: 1px solid var(--border-strong);
|
|
509
523
|
border-radius: 8px;
|
|
510
524
|
}
|
|
511
|
-
.
|
|
525
|
+
.select-wrap { position: relative; }
|
|
526
|
+
.select-wrap select {
|
|
527
|
+
appearance: none; -webkit-appearance: none;
|
|
528
|
+
padding: 0.5rem 2.4rem 0.5rem 0.65rem; font-size: 0.78rem;
|
|
529
|
+
line-height: 1.2rem; cursor: pointer;
|
|
530
|
+
}
|
|
531
|
+
.select-wrap .chev {
|
|
532
|
+
position: absolute; top: 50%; right: 1rem; width: 7px; height: 7px;
|
|
533
|
+
border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
|
|
534
|
+
transform: translateY(-70%) rotate(45deg); pointer-events: none;
|
|
535
|
+
transition: transform 0.15s ease;
|
|
536
|
+
}
|
|
537
|
+
.select-wrap:has(select:open) .chev { transform: translateY(-30%) rotate(225deg); }
|
|
538
|
+
.field input:focus-visible, .field select:focus-visible {
|
|
512
539
|
outline: none; border-color: var(--ring);
|
|
513
540
|
box-shadow: 0 0 0 3px rgba(250,250,250,0.12);
|
|
514
541
|
}
|
|
@@ -718,6 +745,7 @@ function renderConnectPage(params) {
|
|
|
718
745
|
? `<div id="staticTokenMint">
|
|
719
746
|
<div id="msg" class="msg" role="status" aria-live="polite"></div>
|
|
720
747
|
<div id="mintForm">
|
|
748
|
+
${organizationSelectorHtml}
|
|
721
749
|
<button id="authorizeBtn" class="primary">${localize(connectMessages.authorizeDevice)}</button>
|
|
722
750
|
</div>
|
|
723
751
|
</div>`
|
|
@@ -864,6 +892,7 @@ function renderConnectPage(params) {
|
|
|
864
892
|
if (response.status === 404) return COPY.unknownDeviceCode;
|
|
865
893
|
if (response.status === 410) return COPY.expiredDeviceCode;
|
|
866
894
|
if (response.status === 409) return COPY.alreadyUsedDeviceCode;
|
|
895
|
+
if (response.status === 403) return COPY.invalidOrganization;
|
|
867
896
|
return COPY.couldNotAuthorize;
|
|
868
897
|
}
|
|
869
898
|
|
|
@@ -930,7 +959,13 @@ function renderConnectPage(params) {
|
|
|
930
959
|
clearMsg();
|
|
931
960
|
try {
|
|
932
961
|
if (USER_CODE) {
|
|
933
|
-
var
|
|
962
|
+
var orgSelect = document.getElementById("organizationId");
|
|
963
|
+
var a = await postJson(
|
|
964
|
+
"/device/authorize",
|
|
965
|
+
orgSelect
|
|
966
|
+
? { user_code: USER_CODE, org_id: orgSelect.value }
|
|
967
|
+
: { user_code: USER_CODE },
|
|
968
|
+
);
|
|
934
969
|
if (!a.ok) {
|
|
935
970
|
resetButtonLoading(btn);
|
|
936
971
|
showMsg(deviceAuthorizationError(a));
|
|
@@ -1050,6 +1085,8 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1050
1085
|
catalogScope: null,
|
|
1051
1086
|
locale,
|
|
1052
1087
|
requestedGuide: requestUrl?.searchParams.get("guide") ?? null,
|
|
1088
|
+
organizations: [],
|
|
1089
|
+
defaultOrganizationId: undefined,
|
|
1053
1090
|
}));
|
|
1054
1091
|
}
|
|
1055
1092
|
let userCode = null;
|
|
@@ -1064,6 +1101,9 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1064
1101
|
deviceCode.expiresAt >= Date.now()
|
|
1065
1102
|
? deviceCode.catalogScope
|
|
1066
1103
|
: null;
|
|
1104
|
+
const { organizations, defaultOrganizationId } = userCode
|
|
1105
|
+
? await resolveMcpOrgChoices(event, session)
|
|
1106
|
+
: { organizations: [], defaultOrganizationId: undefined };
|
|
1067
1107
|
return html(renderConnectPage({
|
|
1068
1108
|
connectBasePath: basePath,
|
|
1069
1109
|
email: session.email,
|
|
@@ -1074,6 +1114,8 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1074
1114
|
catalogScope,
|
|
1075
1115
|
locale,
|
|
1076
1116
|
requestedGuide: requestUrl?.searchParams.get("guide") ?? null,
|
|
1117
|
+
organizations,
|
|
1118
|
+
defaultOrganizationId,
|
|
1077
1119
|
}));
|
|
1078
1120
|
}
|
|
1079
1121
|
if (sub === "/token") {
|
|
@@ -1094,9 +1136,10 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1094
1136
|
? "full"
|
|
1095
1137
|
: undefined;
|
|
1096
1138
|
try {
|
|
1139
|
+
const { defaultOrganizationId } = await resolveMcpOrgChoices(event, session);
|
|
1097
1140
|
const { token } = await mintConnectToken({
|
|
1098
1141
|
email: session.email,
|
|
1099
|
-
orgId:
|
|
1142
|
+
orgId: defaultOrganizationId,
|
|
1100
1143
|
label,
|
|
1101
1144
|
ttlDays,
|
|
1102
1145
|
appUrl,
|
|
@@ -1157,10 +1200,14 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1157
1200
|
if (!USER_CODE_RE.test(userCode)) {
|
|
1158
1201
|
return json({ error: "Invalid user code." }, 400);
|
|
1159
1202
|
}
|
|
1160
|
-
const
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1203
|
+
const requestedOrgId = typeof body.org_id === "string" && body.org_id ? body.org_id : undefined;
|
|
1204
|
+
const { organizations, defaultOrganizationId } = await resolveMcpOrgChoices(event, session, requestedOrgId);
|
|
1205
|
+
if (requestedOrgId !== undefined &&
|
|
1206
|
+
!organizations.some(({ id }) => id === requestedOrgId)) {
|
|
1207
|
+
return json({ error: "Choose an organization you belong to." }, 403);
|
|
1208
|
+
}
|
|
1209
|
+
const selectedOrgId = requestedOrgId ?? defaultOrganizationId ?? null;
|
|
1210
|
+
const result = await approveDeviceCode(userCode, session.email, selectedOrgId);
|
|
1164
1211
|
if (result === "not_found") {
|
|
1165
1212
|
return json({ error: "Unknown device code." }, 404);
|
|
1166
1213
|
}
|
package/dist/mcp/oauth-route.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
2
2
|
import { getHeader, getMethod, getQuery, setResponseStatus } from "h3";
|
|
3
|
-
import {
|
|
3
|
+
import { getOrgDomain } from "../org/context.js";
|
|
4
4
|
import { getConfiguredLoginHtml, getSession } from "../server/auth.js";
|
|
5
5
|
import { getAuthSecret } from "../server/better-auth-instance.js";
|
|
6
6
|
import { readBody } from "../server/h3-helpers.js";
|
|
7
7
|
import { applicationTypeForRedirectUris, isAllowedOAuthRedirectUri, isUrlBasedOAuthClientId, matchesRegisteredRedirectUri, resolveOAuthClientMetadataDocument, } from "./oauth-client-metadata.js";
|
|
8
8
|
import { createOAuthCode, createOAuthRefreshToken, consumeOAuthCode, generateOpaqueToken, getOAuthClient, getOAuthCode, getOAuthRefreshToken, registerOAuthClient, touchOAuthRefreshToken, } from "./oauth-store.js";
|
|
9
9
|
import { MCP_OAUTH_ACCESS_TOKEN_TTL_SECONDS, MCP_OAUTH_SCOPES, normalizeOAuthScope, signMcpOAuthAccessToken, } from "./oauth-token.js";
|
|
10
|
+
import { resolveMcpOrgChoices } from "./org-choice.js";
|
|
10
11
|
import { MCP_LEGACY_ROUTE_PREFIX, MCP_PUBLIC_ROUTE_PREFIX, MCP_ROUTE_PREFIXES, } from "./route-paths.js";
|
|
11
12
|
const MCP_OAUTH_RESOURCE_SCOPES = MCP_OAUTH_SCOPES.filter((scope) => scope !== "offline_access");
|
|
12
13
|
const MCP_OAUTH_RESOURCE_SCOPE = MCP_OAUTH_RESOURCE_SCOPES.join(" ");
|
|
@@ -597,27 +598,9 @@ async function handleAuthorize(event, options) {
|
|
|
597
598
|
error: "invalid_scope",
|
|
598
599
|
});
|
|
599
600
|
}
|
|
600
|
-
const
|
|
601
|
-
const requestedOrganizationId = method === "POST" && params.organization_id !== undefined
|
|
601
|
+
const { organizations, defaultOrganizationId } = await resolveMcpOrgChoices(event, session, method === "POST" && params.organization_id !== undefined
|
|
602
602
|
? params.organization_id || null
|
|
603
|
-
:
|
|
604
|
-
let memberships = await listOrgMembershipsForEvent(event, session.email, requestedOrganizationId);
|
|
605
|
-
// A token issued with no org stays org-less for its whole life, even after
|
|
606
|
-
// the app later creates the org, so resolve an account without one to its
|
|
607
|
-
// domain or default org before offering the choice.
|
|
608
|
-
const ensuredOrgId = memberships?.length === 0 ? (await getOrgContext(event)).orgId : null;
|
|
609
|
-
if (ensuredOrgId) {
|
|
610
|
-
memberships = await listOrgMembershipsForEvent(event, session.email, ensuredOrgId);
|
|
611
|
-
}
|
|
612
|
-
const organizations = memberships?.map((membership) => ({
|
|
613
|
-
id: membership.orgId,
|
|
614
|
-
name: membership.orgName,
|
|
615
|
-
domain: membership.allowedDomain,
|
|
616
|
-
})) ??
|
|
617
|
-
(session.orgId
|
|
618
|
-
? [{ id: session.orgId, name: "Organization", domain: null }]
|
|
619
|
-
: []);
|
|
620
|
-
const defaultOrganizationId = [activeOrgSetting?.orgId, ensuredOrgId, session.orgId].find((id) => id && organizations.some((org) => org.id === id)) ?? organizations[0]?.id;
|
|
603
|
+
: undefined);
|
|
621
604
|
if (method === "GET") {
|
|
622
605
|
return html(renderConsentPage({
|
|
623
606
|
appName: options.appName || options.appId || "Agent-Native",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { H3Event } from "h3";
|
|
2
|
+
export interface McpOrgOption {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
domain: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface McpOrgChoices {
|
|
8
|
+
organizations: McpOrgOption[];
|
|
9
|
+
defaultOrganizationId: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The organizations an MCP connection (OAuth consent or device approval) can
|
|
13
|
+
* be bound to, and the one to preselect. For an account with no memberships,
|
|
14
|
+
* this resolves (and may create) its domain or default org the same way any
|
|
15
|
+
* other page load would, so the connection isn't scoped to no org for its
|
|
16
|
+
* whole life.
|
|
17
|
+
*
|
|
18
|
+
* `requestedOrganizationId`: `undefined` means no explicit pick (use the
|
|
19
|
+
* caller's stored/session org), `null` means the OAuth caller explicitly
|
|
20
|
+
* asked for personal scope, and a string is an explicit org pick to resolve
|
|
21
|
+
* membership for.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveMcpOrgChoices(event: H3Event, session: {
|
|
24
|
+
email: string;
|
|
25
|
+
orgId?: string | null;
|
|
26
|
+
}, requestedOrganizationId?: string | null): Promise<McpOrgChoices>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getActiveOrgSettingForEvent, getOrgContext, listOrgMembershipsForEvent, } from "../org/context.js";
|
|
2
|
+
/**
|
|
3
|
+
* The organizations an MCP connection (OAuth consent or device approval) can
|
|
4
|
+
* be bound to, and the one to preselect. For an account with no memberships,
|
|
5
|
+
* this resolves (and may create) its domain or default org the same way any
|
|
6
|
+
* other page load would, so the connection isn't scoped to no org for its
|
|
7
|
+
* whole life.
|
|
8
|
+
*
|
|
9
|
+
* `requestedOrganizationId`: `undefined` means no explicit pick (use the
|
|
10
|
+
* caller's stored/session org), `null` means the OAuth caller explicitly
|
|
11
|
+
* asked for personal scope, and a string is an explicit org pick to resolve
|
|
12
|
+
* membership for.
|
|
13
|
+
*/
|
|
14
|
+
export async function resolveMcpOrgChoices(event, session, requestedOrganizationId) {
|
|
15
|
+
const activeOrgSetting = await getActiveOrgSettingForEvent(event, session.email);
|
|
16
|
+
let memberships = await listOrgMembershipsForEvent(event, session.email, requestedOrganizationId !== undefined
|
|
17
|
+
? requestedOrganizationId
|
|
18
|
+
: (activeOrgSetting?.orgId ?? session.orgId ?? null));
|
|
19
|
+
// A token issued with no org stays org-less for its whole life, even after
|
|
20
|
+
// the app later creates the org, so resolve an account without one to its
|
|
21
|
+
// domain or default org before offering the choice.
|
|
22
|
+
const ensuredOrgId = memberships?.length === 0 ? (await getOrgContext(event)).orgId : null;
|
|
23
|
+
if (ensuredOrgId) {
|
|
24
|
+
memberships = await listOrgMembershipsForEvent(event, session.email, ensuredOrgId);
|
|
25
|
+
}
|
|
26
|
+
const organizations = memberships?.map((membership) => ({
|
|
27
|
+
id: membership.orgId,
|
|
28
|
+
name: membership.orgName,
|
|
29
|
+
domain: membership.allowedDomain,
|
|
30
|
+
})) ??
|
|
31
|
+
(session.orgId
|
|
32
|
+
? [{ id: session.orgId, name: "Organization", domain: null }]
|
|
33
|
+
: []);
|
|
34
|
+
const defaultOrganizationId = [activeOrgSetting?.orgId, ensuredOrgId, session.orgId].find((id) => id && organizations.some((org) => org.id === id)) ?? organizations[0]?.id;
|
|
35
|
+
return { organizations, defaultOrganizationId };
|
|
36
|
+
}
|
package/dist/org/handlers.d.ts
CHANGED
|
@@ -72,9 +72,9 @@ export declare const setWorkspaceAppDefaultVisibilityHandler: import("h3").Event
|
|
|
72
72
|
}>>;
|
|
73
73
|
export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
74
74
|
success: boolean;
|
|
75
|
+
id?: undefined;
|
|
75
76
|
name?: undefined;
|
|
76
77
|
role?: undefined;
|
|
77
|
-
id?: undefined;
|
|
78
78
|
} | {
|
|
79
79
|
success?: undefined;
|
|
80
80
|
id: string;
|
package/dist/org/index.d.ts
CHANGED
|
@@ -312,5 +312,5 @@ export declare const setAppRoleHandler: import("h3").EventHandlerWithFetch<impor
|
|
|
312
312
|
email: string;
|
|
313
313
|
roles: any[];
|
|
314
314
|
}>>;
|
|
315
|
-
export { isFreeEmailProvider } from "./free-email-providers.js";
|
|
315
|
+
export { FREE_EMAIL_PROVIDER_DOMAINS, isFreeEmailProvider, } from "./free-email-providers.js";
|
|
316
316
|
export { isOrgMember } from "./membership.js";
|
package/dist/org/index.js
CHANGED
|
@@ -75,5 +75,5 @@ export const setWorkspaceAppDefaultVisibilityHandler = lazyFunction(loadOrgHandl
|
|
|
75
75
|
export const setOrgVisualIdentityHandler = lazyFunction(loadOrgHandlers, "setOrgVisualIdentityHandler");
|
|
76
76
|
export const listAppRolesHandler = lazyFunction(loadOrgAppRolesHandlers, "listAppRolesHandler");
|
|
77
77
|
export const setAppRoleHandler = lazyFunction(loadOrgAppRolesHandlers, "setAppRoleHandler");
|
|
78
|
-
export { isFreeEmailProvider } from "./free-email-providers.js";
|
|
78
|
+
export { FREE_EMAIL_PROVIDER_DOMAINS, isFreeEmailProvider, } from "./free-email-providers.js";
|
|
79
79
|
export { isOrgMember } from "./membership.js";
|
|
@@ -76,8 +76,9 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
76
76
|
}>>;
|
|
77
77
|
}, z.core.$strip>>, {
|
|
78
78
|
id?: undefined;
|
|
79
|
-
|
|
79
|
+
message?: undefined;
|
|
80
80
|
found?: undefined;
|
|
81
|
+
deleted?: undefined;
|
|
81
82
|
providers: {
|
|
82
83
|
id: string;
|
|
83
84
|
label: string;
|
|
@@ -91,42 +92,41 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
91
92
|
provider?: undefined;
|
|
92
93
|
registered?: undefined;
|
|
93
94
|
label?: undefined;
|
|
94
|
-
message?: undefined;
|
|
95
95
|
} | {
|
|
96
96
|
id?: undefined;
|
|
97
|
+
message?: undefined;
|
|
97
98
|
deleted?: undefined;
|
|
98
|
-
count?: undefined;
|
|
99
99
|
providers?: undefined;
|
|
100
|
+
count?: undefined;
|
|
100
101
|
found: boolean;
|
|
101
102
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
102
103
|
registered?: undefined;
|
|
103
104
|
label?: undefined;
|
|
104
|
-
message?: undefined;
|
|
105
105
|
} | {
|
|
106
|
+
message?: undefined;
|
|
106
107
|
deleted?: undefined;
|
|
107
|
-
count?: undefined;
|
|
108
108
|
providers?: undefined;
|
|
109
|
+
count?: undefined;
|
|
109
110
|
provider?: undefined;
|
|
110
111
|
found: boolean;
|
|
111
112
|
id: string;
|
|
112
113
|
registered?: undefined;
|
|
113
114
|
label?: undefined;
|
|
114
|
-
message?: undefined;
|
|
115
115
|
} | {
|
|
116
|
+
message?: undefined;
|
|
116
117
|
found?: undefined;
|
|
117
|
-
count?: undefined;
|
|
118
118
|
providers?: undefined;
|
|
119
|
+
count?: undefined;
|
|
119
120
|
provider?: undefined;
|
|
120
121
|
deleted: boolean;
|
|
121
122
|
id: string;
|
|
122
123
|
registered?: undefined;
|
|
123
124
|
label?: undefined;
|
|
124
|
-
message?: undefined;
|
|
125
125
|
} | {
|
|
126
|
-
deleted?: undefined;
|
|
127
126
|
found?: undefined;
|
|
128
|
-
|
|
127
|
+
deleted?: undefined;
|
|
129
128
|
providers?: undefined;
|
|
129
|
+
count?: undefined;
|
|
130
130
|
provider?: undefined;
|
|
131
131
|
registered: boolean;
|
|
132
132
|
id: string;
|
|
@@ -312,6 +312,8 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
312
312
|
scope?: "org" | "user" | undefined;
|
|
313
313
|
}, {
|
|
314
314
|
id?: undefined;
|
|
315
|
+
provider?: undefined;
|
|
316
|
+
deleted?: undefined;
|
|
315
317
|
message?: undefined;
|
|
316
318
|
found?: undefined;
|
|
317
319
|
providers: {
|
|
@@ -324,46 +326,44 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
324
326
|
updatedAt: number;
|
|
325
327
|
}[];
|
|
326
328
|
count: number;
|
|
327
|
-
provider?: undefined;
|
|
328
|
-
deleted?: undefined;
|
|
329
329
|
registered?: undefined;
|
|
330
330
|
label?: undefined;
|
|
331
331
|
} | {
|
|
332
332
|
id?: undefined;
|
|
333
|
+
deleted?: undefined;
|
|
334
|
+
count?: undefined;
|
|
333
335
|
message?: undefined;
|
|
334
336
|
providers?: undefined;
|
|
335
|
-
count?: undefined;
|
|
336
337
|
found: boolean;
|
|
337
338
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
338
|
-
deleted?: undefined;
|
|
339
339
|
registered?: undefined;
|
|
340
340
|
label?: undefined;
|
|
341
341
|
} | {
|
|
342
|
+
provider?: undefined;
|
|
343
|
+
deleted?: undefined;
|
|
344
|
+
count?: undefined;
|
|
342
345
|
message?: undefined;
|
|
343
346
|
providers?: undefined;
|
|
344
|
-
count?: undefined;
|
|
345
|
-
provider?: undefined;
|
|
346
347
|
found: boolean;
|
|
347
348
|
id: string;
|
|
348
|
-
deleted?: undefined;
|
|
349
349
|
registered?: undefined;
|
|
350
350
|
label?: undefined;
|
|
351
351
|
} | {
|
|
352
|
+
provider?: undefined;
|
|
353
|
+
count?: undefined;
|
|
352
354
|
message?: undefined;
|
|
353
355
|
found?: undefined;
|
|
354
356
|
providers?: undefined;
|
|
355
|
-
count?: undefined;
|
|
356
|
-
provider?: undefined;
|
|
357
357
|
deleted: boolean;
|
|
358
358
|
id: string;
|
|
359
359
|
registered?: undefined;
|
|
360
360
|
label?: undefined;
|
|
361
361
|
} | {
|
|
362
|
-
found?: undefined;
|
|
363
|
-
providers?: undefined;
|
|
364
|
-
count?: undefined;
|
|
365
362
|
provider?: undefined;
|
|
366
363
|
deleted?: undefined;
|
|
364
|
+
count?: undefined;
|
|
365
|
+
found?: undefined;
|
|
366
|
+
providers?: undefined;
|
|
367
367
|
registered: boolean;
|
|
368
368
|
id: string;
|
|
369
369
|
label: string;
|
|
@@ -73,7 +73,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
73
73
|
offset?: unknown;
|
|
74
74
|
limit?: unknown;
|
|
75
75
|
}, {
|
|
76
|
-
deleted?: undefined;
|
|
77
76
|
jobs: {
|
|
78
77
|
id: string;
|
|
79
78
|
name: string;
|
|
@@ -84,6 +83,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
84
83
|
updatedAt: string;
|
|
85
84
|
}[];
|
|
86
85
|
total: number;
|
|
86
|
+
deleted?: undefined;
|
|
87
87
|
jobId?: undefined;
|
|
88
88
|
} | {
|
|
89
89
|
jobs?: undefined;
|
|
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
91
91
|
deleted: boolean;
|
|
92
92
|
jobId: string;
|
|
93
93
|
} | {
|
|
94
|
-
deleted?: undefined;
|
|
95
94
|
jobs?: undefined;
|
|
96
95
|
total?: undefined;
|
|
96
|
+
deleted?: undefined;
|
|
97
97
|
jobId?: undefined;
|
|
98
98
|
hits: Record<string, unknown>[];
|
|
99
99
|
offset: number;
|
|
@@ -39,8 +39,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
|
|
|
39
39
|
error: string;
|
|
40
40
|
}>;
|
|
41
41
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
42
|
-
error: string;
|
|
43
42
|
ok?: undefined;
|
|
43
|
+
error: string;
|
|
44
44
|
} | {
|
|
45
45
|
error?: undefined;
|
|
46
46
|
ok: boolean;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -55,39 +55,39 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
|
|
|
55
55
|
} | {
|
|
56
56
|
error: string;
|
|
57
57
|
errorCode?: undefined;
|
|
58
|
-
ok?: undefined;
|
|
59
58
|
status?: undefined;
|
|
59
|
+
ok?: undefined;
|
|
60
60
|
} | {
|
|
61
61
|
error: string;
|
|
62
62
|
errorCode: string;
|
|
63
|
-
ok?: undefined;
|
|
64
63
|
status?: undefined;
|
|
64
|
+
ok?: undefined;
|
|
65
65
|
} | {
|
|
66
|
-
error?: undefined;
|
|
67
66
|
errorCode?: undefined;
|
|
68
67
|
ok: boolean;
|
|
69
68
|
status: string;
|
|
69
|
+
error?: undefined;
|
|
70
70
|
} | {
|
|
71
|
-
ok?: undefined;
|
|
72
71
|
error: string;
|
|
73
72
|
removed?: undefined;
|
|
73
|
+
ok?: undefined;
|
|
74
74
|
} | {
|
|
75
|
-
error?: undefined;
|
|
76
75
|
ok: boolean;
|
|
77
76
|
removed: boolean;
|
|
77
|
+
error?: undefined;
|
|
78
78
|
}>>;
|
|
79
79
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
80
|
-
ok?: undefined;
|
|
81
80
|
error: string;
|
|
82
81
|
note?: undefined;
|
|
82
|
+
ok?: undefined;
|
|
83
83
|
} | {
|
|
84
|
-
error?: undefined;
|
|
85
84
|
ok: boolean;
|
|
86
85
|
note?: undefined;
|
|
87
|
-
} | {
|
|
88
86
|
error?: undefined;
|
|
87
|
+
} | {
|
|
89
88
|
ok: boolean;
|
|
90
89
|
note: string;
|
|
90
|
+
error?: undefined;
|
|
91
91
|
} | {
|
|
92
92
|
note?: undefined;
|
|
93
93
|
ok: boolean;
|
|
@@ -115,11 +115,11 @@ export declare function createAdHocSecretHandler(): import("h3").EventHandlerWit
|
|
|
115
115
|
} | {
|
|
116
116
|
error: string;
|
|
117
117
|
} | {
|
|
118
|
-
error?: undefined;
|
|
119
118
|
ok: boolean;
|
|
120
119
|
key: string;
|
|
121
|
-
} | {
|
|
122
120
|
error?: undefined;
|
|
121
|
+
} | {
|
|
123
122
|
ok: boolean;
|
|
124
123
|
removed: boolean;
|
|
124
|
+
error?: undefined;
|
|
125
125
|
}>>;
|
|
@@ -9,16 +9,16 @@ export declare const AGENT_ENGINE_API_KEY_ACTION_NAME = "agent-engine-api-key";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function createAgentEngineDisconnectHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
11
11
|
error: string;
|
|
12
|
-
scope?: undefined;
|
|
13
12
|
ok?: undefined;
|
|
13
|
+
scope?: undefined;
|
|
14
14
|
} | {
|
|
15
15
|
ok: boolean;
|
|
16
16
|
error: any;
|
|
17
17
|
scope?: undefined;
|
|
18
18
|
} | {
|
|
19
|
+
error?: undefined;
|
|
19
20
|
ok: boolean;
|
|
20
21
|
scope: "org" | "user";
|
|
21
|
-
error?: undefined;
|
|
22
22
|
}>>;
|
|
23
23
|
export interface DefaultModelSelectionRequest {
|
|
24
24
|
engine: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
2
2
|
error: string;
|
|
3
|
-
models?: undefined;
|
|
4
3
|
ok?: undefined;
|
|
4
|
+
models?: undefined;
|
|
5
5
|
} | {
|
|
6
|
+
error?: undefined;
|
|
6
7
|
ok: boolean;
|
|
7
8
|
models: string[];
|
|
8
|
-
error?: undefined;
|
|
9
9
|
}>>;
|