@agent-native/core 0.207.0 → 0.207.1-nightly-20261012011809
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/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.js +220 -45
- package/dist/agent/thread-message-projection.d.ts +3 -0
- package/dist/agent/thread-message-projection.js +136 -3
- package/dist/automation/index.d.ts +1 -1
- package/dist/chat-threads/store.d.ts +1 -0
- package/dist/chat-threads/store.js +14 -4
- package/dist/cli/connect.d.ts +1 -0
- package/dist/cli/connect.js +8 -3
- package/dist/client/chat/agentkit-agent-native.js +151 -77
- package/dist/client/chat/runtime.js +61 -2
- package/dist/client/onboarding/first-run-status.js +0 -4
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/jobs/actions/manage-recurring-job.d.ts +1 -1
- package/dist/mcp/agent-connected.d.ts +13 -0
- package/dist/mcp/agent-connected.js +63 -0
- package/dist/mcp/connect-app-label.d.ts +11 -0
- package/dist/mcp/connect-app-label.js +33 -0
- package/dist/mcp/connect-route.js +41 -33
- package/dist/mcp/connect-store.d.ts +6 -1
- package/dist/mcp/connect-store.js +10 -2
- package/dist/mcp/oauth-route.js +17 -5
- package/dist/mcp/oauth-store.d.ts +2 -0
- package/dist/mcp/oauth-store.js +5 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/org/index.d.ts +2 -2
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +9 -9
- package/dist/provider-api/actions/provider-api.d.ts +11 -11
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +5 -5
- package/dist/server/agent-chat-plugin.js +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agent-engine-default-model-route.d.ts +2 -2
- package/dist/server/core-routes-plugin.d.ts +1 -1
- package/dist/shared/mcp-connect-content.d.ts +1 -0
- package/dist/shared/mcp-connect-content.js +3 -0
- package/dist/sharing/actions/list-resource-shares.d.ts +1 -1
- package/dist/tracking/registry.d.ts +1 -0
- package/dist/tracking/registry.js +1 -1
- package/dist/triggers/actions/manage-automation.d.ts +7 -7
- package/docs/content/agent-native-toolkit.mdx +42 -38
- package/docs/content/components.mdx +29 -18
- package/docs/content/notifications.mdx +1 -1
- package/docs/content/progress.mdx +1 -1
- package/docs/content/sharing.mdx +1 -1
- package/docs/content/toolkit-agent-ux.mdx +17 -2
- package/docs/content/toolkit-command-navigation.mdx +4 -2
- package/docs/content/toolkit-comments-review.mdx +1 -1
- package/docs/content/toolkit-context-knowledge.mdx +14 -16
- package/docs/content/toolkit-editors-canvases.mdx +24 -7
- package/docs/content/toolkit-history.mdx +13 -26
- package/docs/content/toolkit-org-team.mdx +4 -4
- package/docs/content/toolkit-resources.mdx +3 -1
- package/docs/content/toolkit-settings.mdx +1 -1
- package/docs/content/toolkit-setup-connections.mdx +1 -1
- package/docs/content/toolkit-sharing.mdx +6 -6
- package/docs/content/toolkit-ui.mdx +11 -0
- package/package.json +4 -4
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { getMethod, getHeader } from "h3";
|
|
3
|
-
import { getAppConfig } from "../app-config/index.js";
|
|
4
|
-
import { isAgentNativeDeploymentEnvironment } from "../config.js";
|
|
5
3
|
import { mcpSettingsMessagesForLocale } from "../localization/mcp-settings-messages.js";
|
|
6
4
|
import { resolveLocaleFromRequest } from "../localization/server.js";
|
|
7
5
|
import { localeDirection, normalizeLocaleCode, } from "../localization/shared.js";
|
|
@@ -10,11 +8,12 @@ import { getConfiguredAppBasePath } from "../server/app-base-path.js";
|
|
|
10
8
|
import { getSession, getConfiguredLoginHtml, isLoopbackRequest, } from "../server/auth.js";
|
|
11
9
|
import { CREDENTIAL_MEMBERSHIP_UNAVAILABLE_MESSAGE } from "../server/credential-membership-unavailable.js";
|
|
12
10
|
import { readDeployCredentialEnv } from "../server/credential-provider.js";
|
|
13
|
-
import { resolveDeployEnvironment } from "../server/deploy-environment.js";
|
|
14
11
|
import { publicFrameworkPath } from "../server/framework-route-prefix.js";
|
|
15
12
|
import { readBody } from "../server/h3-helpers.js";
|
|
16
13
|
import { FRAMEWORK_INTERNAL_ROUTE_PREFIX } from "../shared/framework-route-prefix.js";
|
|
17
14
|
import { buildMcpInstallLink, derivedMcpServerBaseName, getMcpConnectGuides, getMcpStaticTokenFallback, interpolateMcpConnectTemplate, mcpConnectServerName, resolveMcpConnectGuideId, } from "../shared/mcp-connect-content.js";
|
|
15
|
+
import { deviceFlowClients, trackAgentConnected } from "./agent-connected.js";
|
|
16
|
+
import { connectAppLabel, connectEnvironment } from "./connect-app-label.js";
|
|
18
17
|
import { ensureConnectTables, recordMintedToken, listTokens, revokeToken, normalizeServiceName, serviceIdentityEmail, createDeviceCode, getDeviceCode, getDeviceCodeByUserCode, approveDeviceCode, consumeDeviceCode, claimDeviceCodeForMint, finishDeviceCodeMint, expireDeviceCode, MCP_CONNECT_OAUTH_CLIENT_ID, DEFAULT_TOKEN_TTL_DAYS, MIN_TOKEN_TTL_DAYS, MAX_TOKEN_TTL_DAYS, MAX_SERVICE_TOKEN_TTL_DAYS, DEVICE_CODE_TTL_MS, } from "./connect-store.js";
|
|
19
18
|
import { McpCredentialIssuanceError, withMcpCredentialIssuance, } from "./credential-issuance.js";
|
|
20
19
|
import { getMcpOAuthIssuer, resolveMcpOAuthIssuer } from "./oauth-route.js";
|
|
@@ -78,31 +77,6 @@ function joinAppPath(basePath, path) {
|
|
|
78
77
|
return basePath;
|
|
79
78
|
return `${basePath}${path.startsWith("/") ? path : `/${path}`}`;
|
|
80
79
|
}
|
|
81
|
-
function appLabel(origin, options, environment) {
|
|
82
|
-
const app = getAppConfig().app;
|
|
83
|
-
const declared = options.appId ?? app.id ?? app.template ?? app.slug;
|
|
84
|
-
if (declared)
|
|
85
|
-
return declared;
|
|
86
|
-
// Deployed functions run without npm's `npm_package_name`, so first-party
|
|
87
|
-
// apps usually land here. A beta lane is `beta.<app>.agent-native.com`: its
|
|
88
|
-
// leading label names the lane, and every beta app would share it. Only a
|
|
89
|
-
// beta deployment drops it, so no production name changes.
|
|
90
|
-
try {
|
|
91
|
-
const host = new URL(origin).hostname;
|
|
92
|
-
const h = environment === "beta" ? host.replace(/^beta\./, "") : host;
|
|
93
|
-
return h.split(".")[0] || h;
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return options.appName || "app";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function connectEnvironment() {
|
|
100
|
-
const environment = resolveDeployEnvironment();
|
|
101
|
-
if (!isAgentNativeDeploymentEnvironment(environment)) {
|
|
102
|
-
throw new Error(`Unknown deployment environment "${environment}"`);
|
|
103
|
-
}
|
|
104
|
-
return environment;
|
|
105
|
-
}
|
|
106
80
|
/**
|
|
107
81
|
* The one name and URL every connect surface hands to an MCP client: this
|
|
108
82
|
* page, the device-flow payload, the settings tab, share dialogs (through the
|
|
@@ -111,10 +85,10 @@ function connectEnvironment() {
|
|
|
111
85
|
export function resolveMcpConnectIdentity(appUrl, options) {
|
|
112
86
|
const environment = connectEnvironment();
|
|
113
87
|
const baseName = options.serverName?.trim() ||
|
|
114
|
-
derivedMcpServerBaseName(
|
|
88
|
+
derivedMcpServerBaseName(connectAppLabel(appUrl, options, environment), environment);
|
|
115
89
|
return {
|
|
116
90
|
serverName: mcpConnectServerName(baseName, environment),
|
|
117
|
-
appName: options.appName ||
|
|
91
|
+
appName: options.appName || connectAppLabel(appUrl, options, environment),
|
|
118
92
|
appUrl,
|
|
119
93
|
mcpUrl: mcpResourceUrl(appUrl),
|
|
120
94
|
environment,
|
|
@@ -1217,7 +1191,8 @@ function renderConnectPage(params) {
|
|
|
1217
1191
|
var ttlEl = document.getElementById("ttl");
|
|
1218
1192
|
var label = labelEl ? labelEl.value || undefined : undefined;
|
|
1219
1193
|
var ttlDays = ttlEl ? parseInt(ttlEl.value, 10) || undefined : undefined;
|
|
1220
|
-
var
|
|
1194
|
+
var activeGuide = document.querySelector('[data-tab].is-active');
|
|
1195
|
+
var m = await postJson("/token", { label: label, ttlDays: ttlDays, client: activeGuide ? activeGuide.getAttribute("data-tab") : undefined });
|
|
1221
1196
|
if (!m.ok) {
|
|
1222
1197
|
resetButtonLoading(btn);
|
|
1223
1198
|
showMsg(COPY.couldNotCreate);
|
|
@@ -1350,6 +1325,13 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1350
1325
|
requestOrigin: origin,
|
|
1351
1326
|
...(catalogScope ? { catalogScope } : {}),
|
|
1352
1327
|
});
|
|
1328
|
+
await trackAgentConnected({
|
|
1329
|
+
email: session.email,
|
|
1330
|
+
origin: issuer,
|
|
1331
|
+
appId: options.appId,
|
|
1332
|
+
client: typeof body.client === "string" ? body.client : null,
|
|
1333
|
+
method: "mcp",
|
|
1334
|
+
});
|
|
1353
1335
|
return json(mcpResultPayload(identity, { token }));
|
|
1354
1336
|
}
|
|
1355
1337
|
catch (err) {
|
|
@@ -1378,7 +1360,21 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1378
1360
|
typeof body.fullCatalog !== "boolean") {
|
|
1379
1361
|
return json({ error: "fullCatalog must be a boolean." }, 400);
|
|
1380
1362
|
}
|
|
1381
|
-
|
|
1363
|
+
if (body.client !== undefined &&
|
|
1364
|
+
(typeof body.client !== "string" || body.client.length > 500)) {
|
|
1365
|
+
return json({ error: "Invalid request body." }, 400);
|
|
1366
|
+
}
|
|
1367
|
+
if (body.purpose !== undefined &&
|
|
1368
|
+
body.purpose !== "agent" &&
|
|
1369
|
+
body.purpose !== "credential") {
|
|
1370
|
+
return json({ error: "Invalid request body." }, 400);
|
|
1371
|
+
}
|
|
1372
|
+
const row = await createDeviceCode(body.fullCatalog === true ? "full" : null, {
|
|
1373
|
+
...(typeof body.client === "string" ? { client: body.client } : {}),
|
|
1374
|
+
...(body.purpose === "agent" || body.purpose === "credential"
|
|
1375
|
+
? { purpose: body.purpose }
|
|
1376
|
+
: {}),
|
|
1377
|
+
});
|
|
1382
1378
|
const verificationUri = `${issuer}${MCP_PUBLIC_ROUTE_PREFIX}/connect`;
|
|
1383
1379
|
return json({
|
|
1384
1380
|
device_code: row.deviceCode,
|
|
@@ -1468,7 +1464,8 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1468
1464
|
canUseDevOpenConnect(event);
|
|
1469
1465
|
const orgDomain = await resolveOrgDomain(row.orgId ?? undefined);
|
|
1470
1466
|
await prepareConnectIssuance();
|
|
1471
|
-
|
|
1467
|
+
let connected = false;
|
|
1468
|
+
const response = await withMcpCredentialIssuance({
|
|
1472
1469
|
email: row.ownerEmail,
|
|
1473
1470
|
orgId: row.orgId,
|
|
1474
1471
|
requestOrigin: origin,
|
|
@@ -1519,11 +1516,22 @@ export async function handleMcpConnect(event, subpath, options = {}) {
|
|
|
1519
1516
|
if (!(await finishDeviceCodeMint(deviceCode, jti, tx))) {
|
|
1520
1517
|
throw new McpCredentialIssuanceError("unavailable");
|
|
1521
1518
|
}
|
|
1519
|
+
connected = true;
|
|
1522
1520
|
return json({
|
|
1523
1521
|
status: "approved",
|
|
1524
1522
|
...mcpResultPayload(identity, { token }),
|
|
1525
1523
|
});
|
|
1526
1524
|
});
|
|
1525
|
+
if (connected && row.purpose !== "credential") {
|
|
1526
|
+
await trackAgentConnected({
|
|
1527
|
+
email: row.ownerEmail,
|
|
1528
|
+
origin: issuer,
|
|
1529
|
+
appId: options.appId,
|
|
1530
|
+
client: deviceFlowClients(row.client ?? null),
|
|
1531
|
+
method: "mcp",
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
return response;
|
|
1527
1535
|
}
|
|
1528
1536
|
catch (err) {
|
|
1529
1537
|
if (err instanceof McpCredentialIssuanceError)
|
|
@@ -109,11 +109,16 @@ export interface DeviceCodeRow {
|
|
|
109
109
|
status: "pending" | "approved" | "minting" | "consumed" | "expired";
|
|
110
110
|
tokenJti: string | null;
|
|
111
111
|
catalogScope: "full" | null;
|
|
112
|
+
client?: string | null;
|
|
113
|
+
purpose?: "agent" | "credential" | null;
|
|
112
114
|
createdAt: number | null;
|
|
113
115
|
expiresAt: number | null;
|
|
114
116
|
consumedAt: number | null;
|
|
115
117
|
}
|
|
116
|
-
export declare function createDeviceCode(catalogScope?: "full" | null
|
|
118
|
+
export declare function createDeviceCode(catalogScope?: "full" | null, connection?: {
|
|
119
|
+
client?: string;
|
|
120
|
+
purpose?: "agent" | "credential";
|
|
121
|
+
}): Promise<DeviceCodeRow>;
|
|
117
122
|
export declare function getDeviceCode(deviceCode: string, exec?: DbExec): Promise<DeviceCodeRow | null>;
|
|
118
123
|
export declare function getDeviceCodeByUserCode(userCode: string, exec?: DbExec): Promise<DeviceCodeRow | null>;
|
|
119
124
|
export declare function approveDeviceCode(userCode: string, ownerEmail: string, orgId: string | null, exec?: DbExec): Promise<DeviceCodeRow | "not_found" | "expired" | "already">;
|
|
@@ -68,6 +68,8 @@ export async function ensureTable() {
|
|
|
68
68
|
await ensureColumnExists("mcp_connect_tokens", "created_by", `ALTER TABLE mcp_connect_tokens ADD COLUMN IF NOT EXISTS created_by TEXT`);
|
|
69
69
|
await ensureTableExists("mcp_device_codes", createDeviceCodesSql);
|
|
70
70
|
await ensureColumnExists("mcp_device_codes", "catalog_scope", `ALTER TABLE mcp_device_codes ADD COLUMN IF NOT EXISTS catalog_scope TEXT`);
|
|
71
|
+
await ensureColumnExists("mcp_device_codes", "client", `ALTER TABLE mcp_device_codes ADD COLUMN IF NOT EXISTS client TEXT`);
|
|
72
|
+
await ensureColumnExists("mcp_device_codes", "purpose", `ALTER TABLE mcp_device_codes ADD COLUMN IF NOT EXISTS purpose TEXT`);
|
|
71
73
|
})().catch((err) => {
|
|
72
74
|
_initPromise = undefined;
|
|
73
75
|
throw err;
|
|
@@ -284,7 +286,7 @@ function generateUserCode() {
|
|
|
284
286
|
function generateDeviceCode() {
|
|
285
287
|
return randomBytes(32).toString("base64url");
|
|
286
288
|
}
|
|
287
|
-
export async function createDeviceCode(catalogScope = null) {
|
|
289
|
+
export async function createDeviceCode(catalogScope = null, connection = {}) {
|
|
288
290
|
await ensureTable();
|
|
289
291
|
const client = getDbExec();
|
|
290
292
|
const now = Date.now();
|
|
@@ -308,7 +310,7 @@ export async function createDeviceCode(catalogScope = null) {
|
|
|
308
310
|
const userCode = generateUserCode();
|
|
309
311
|
const expiresAt = now + DEVICE_CODE_TTL_MS;
|
|
310
312
|
await client.execute({
|
|
311
|
-
sql: `INSERT INTO mcp_device_codes (device_code, user_code, owner_email, org_id, status, token_jti, catalog_scope, created_at, expires_at, consumed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
313
|
+
sql: `INSERT INTO mcp_device_codes (device_code, user_code, owner_email, org_id, status, token_jti, catalog_scope, created_at, expires_at, consumed_at, client, purpose) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
312
314
|
args: [
|
|
313
315
|
deviceCode,
|
|
314
316
|
userCode,
|
|
@@ -320,6 +322,8 @@ export async function createDeviceCode(catalogScope = null) {
|
|
|
320
322
|
now,
|
|
321
323
|
expiresAt,
|
|
322
324
|
null,
|
|
325
|
+
connection.client ?? null,
|
|
326
|
+
connection.purpose ?? null,
|
|
323
327
|
],
|
|
324
328
|
});
|
|
325
329
|
return {
|
|
@@ -330,6 +334,8 @@ export async function createDeviceCode(catalogScope = null) {
|
|
|
330
334
|
status: "pending",
|
|
331
335
|
tokenJti: null,
|
|
332
336
|
catalogScope,
|
|
337
|
+
client: connection.client ?? null,
|
|
338
|
+
purpose: connection.purpose ?? null,
|
|
333
339
|
createdAt: now,
|
|
334
340
|
expiresAt,
|
|
335
341
|
consumedAt: null,
|
|
@@ -344,6 +350,8 @@ function mapDeviceRow(r) {
|
|
|
344
350
|
status: (r.status ?? "pending"),
|
|
345
351
|
tokenJti: (r.token_jti ?? r.tokenJti ?? null),
|
|
346
352
|
catalogScope: (r.catalog_scope ?? r.catalogScope) === "full" ? "full" : null,
|
|
353
|
+
client: r.client ?? null,
|
|
354
|
+
purpose: r.purpose ?? null,
|
|
347
355
|
createdAt: numOrNull(r.created_at ?? r.createdAt),
|
|
348
356
|
expiresAt: numOrNull(r.expires_at ?? r.expiresAt),
|
|
349
357
|
consumedAt: numOrNull(r.consumed_at ?? r.consumedAt),
|
package/dist/mcp/oauth-route.js
CHANGED
|
@@ -8,6 +8,7 @@ import { getAuthSecret } from "../server/better-auth-instance.js";
|
|
|
8
8
|
import { CREDENTIAL_MEMBERSHIP_UNAVAILABLE_MESSAGE } from "../server/credential-membership-unavailable.js";
|
|
9
9
|
import { getOrigin } from "../server/google-oauth.js";
|
|
10
10
|
import { readBody } from "../server/h3-helpers.js";
|
|
11
|
+
import { trackAgentConnected } from "./agent-connected.js";
|
|
11
12
|
import { McpCredentialIssuanceError, withMcpCredentialIssuance, } from "./credential-issuance.js";
|
|
12
13
|
import { applicationTypeForRedirectUris, isAllowedOAuthRedirectUri, isUrlBasedOAuthClientId, matchesRegisteredRedirectUri, resolveOAuthClientMetadataDocument, } from "./oauth-client-metadata.js";
|
|
13
14
|
import { createOAuthCode, createOAuthRefreshToken, consumeOAuthCode, ensureOAuthTables, generateOpaqueToken, getOAuthClient, getOAuthCode, getOAuthRefreshToken, registerOAuthClient, revokeOAuthRefreshToken, touchOAuthRefreshToken, } from "./oauth-store.js";
|
|
@@ -725,6 +726,7 @@ async function handleAuthorize(event, options) {
|
|
|
725
726
|
requestOrigin: getOrigin(event),
|
|
726
727
|
}, (tx) => createOAuthCode({
|
|
727
728
|
clientId,
|
|
729
|
+
clientName: client.clientName,
|
|
728
730
|
redirectUri,
|
|
729
731
|
codeChallenge: params.code_challenge,
|
|
730
732
|
codeChallengeMethod: "S256",
|
|
@@ -805,7 +807,7 @@ function grantUnavailableError(description) {
|
|
|
805
807
|
response.headers.set("Retry-After", "5");
|
|
806
808
|
return response;
|
|
807
809
|
}
|
|
808
|
-
async function handleAuthorizationCodeGrant(event, body) {
|
|
810
|
+
async function handleAuthorizationCodeGrant(event, body, options) {
|
|
809
811
|
const code = body.code;
|
|
810
812
|
const clientId = body.client_id;
|
|
811
813
|
const redirectUri = body.redirect_uri;
|
|
@@ -834,7 +836,7 @@ async function handleAuthorizationCodeGrant(event, body) {
|
|
|
834
836
|
if (!issuer)
|
|
835
837
|
return oauthError("server_error", "Unable to derive issuer", 500);
|
|
836
838
|
try {
|
|
837
|
-
|
|
839
|
+
const response = await withMcpCredentialIssuance({
|
|
838
840
|
email: row.ownerEmail,
|
|
839
841
|
orgId: row.orgId,
|
|
840
842
|
requestOrigin: getOrigin(event),
|
|
@@ -853,6 +855,16 @@ async function handleAuthorizationCodeGrant(event, body) {
|
|
|
853
855
|
grantCreatedAtMs: consumed.createdAt,
|
|
854
856
|
}, tx));
|
|
855
857
|
});
|
|
858
|
+
if (response.status === 200) {
|
|
859
|
+
await trackAgentConnected({
|
|
860
|
+
email: row.ownerEmail,
|
|
861
|
+
origin: issuer,
|
|
862
|
+
appId: options.appId,
|
|
863
|
+
client: row.clientName ?? null,
|
|
864
|
+
method: "oauth",
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
return response;
|
|
856
868
|
}
|
|
857
869
|
catch (error) {
|
|
858
870
|
if (error instanceof McpCredentialIssuanceError &&
|
|
@@ -935,14 +947,14 @@ async function handleRefreshTokenGrant(event, body) {
|
|
|
935
947
|
return grantUnavailableError(CREDENTIAL_MEMBERSHIP_UNAVAILABLE_MESSAGE);
|
|
936
948
|
}
|
|
937
949
|
}
|
|
938
|
-
async function handleToken(event) {
|
|
950
|
+
async function handleToken(event, options) {
|
|
939
951
|
if (getMethod(event) !== "POST") {
|
|
940
952
|
return oauthError("invalid_request", "Method not allowed", 405);
|
|
941
953
|
}
|
|
942
954
|
const body = await readOAuthParams(event);
|
|
943
955
|
switch (body.grant_type) {
|
|
944
956
|
case "authorization_code":
|
|
945
|
-
return handleAuthorizationCodeGrant(event, body);
|
|
957
|
+
return handleAuthorizationCodeGrant(event, body, options);
|
|
946
958
|
case "refresh_token":
|
|
947
959
|
return handleRefreshTokenGrant(event, body);
|
|
948
960
|
default:
|
|
@@ -955,7 +967,7 @@ export async function handleMcpOAuth(event, subpath, options = {}) {
|
|
|
955
967
|
if (path === "authorize")
|
|
956
968
|
return await handleAuthorize(event, options);
|
|
957
969
|
if (path === "token")
|
|
958
|
-
return await handleToken(event);
|
|
970
|
+
return await handleToken(event, options);
|
|
959
971
|
if (path === "register")
|
|
960
972
|
return await handleRegister(event);
|
|
961
973
|
setResponseStatus(event, 404);
|
|
@@ -24,6 +24,7 @@ export interface OAuthClientRow {
|
|
|
24
24
|
createdAt: number | null;
|
|
25
25
|
}
|
|
26
26
|
export interface OAuthCodeRow {
|
|
27
|
+
clientName: string | null;
|
|
27
28
|
code: string;
|
|
28
29
|
clientId: string;
|
|
29
30
|
redirectUri: string;
|
|
@@ -68,6 +69,7 @@ export declare function registerOAuthClient(params: {
|
|
|
68
69
|
export declare function getOAuthClient(clientId: string): Promise<OAuthClientRow | null>;
|
|
69
70
|
export declare function createOAuthCode(params: {
|
|
70
71
|
clientId: string;
|
|
72
|
+
clientName?: string | null;
|
|
71
73
|
redirectUri: string;
|
|
72
74
|
codeChallenge: string;
|
|
73
75
|
codeChallengeMethod: string;
|
package/dist/mcp/oauth-store.js
CHANGED
|
@@ -106,6 +106,7 @@ export async function ensureTable() {
|
|
|
106
106
|
await ensureTableExists("mcp_oauth_clients", createClientsSql);
|
|
107
107
|
await ensureColumnExists("mcp_oauth_clients", "application_type", `ALTER TABLE mcp_oauth_clients ADD COLUMN IF NOT EXISTS application_type TEXT`);
|
|
108
108
|
await ensureTableExists("mcp_oauth_codes", createCodesSql);
|
|
109
|
+
await ensureColumnExists("mcp_oauth_codes", "client_name", `ALTER TABLE mcp_oauth_codes ADD COLUMN IF NOT EXISTS client_name TEXT`);
|
|
109
110
|
// Legacy owners may already have been transferred; leave their bindings unset.
|
|
110
111
|
await ensureColumnExists("mcp_oauth_codes", "issued_for_email", `ALTER TABLE mcp_oauth_codes ADD COLUMN IF NOT EXISTS issued_for_email TEXT`);
|
|
111
112
|
await ensureTableExists("mcp_oauth_refresh_tokens", createRefreshTokensSql);
|
|
@@ -180,6 +181,7 @@ function mapClientRow(row) {
|
|
|
180
181
|
}
|
|
181
182
|
function mapCodeRow(row) {
|
|
182
183
|
return {
|
|
184
|
+
clientName: row.client_name ?? row.clientName ?? null,
|
|
183
185
|
code: row.code,
|
|
184
186
|
clientId: row.client_id ?? row.clientId,
|
|
185
187
|
redirectUri: row.redirect_uri ?? row.redirectUri,
|
|
@@ -296,7 +298,7 @@ export async function createOAuthCode(params, db) {
|
|
|
296
298
|
const now = Date.now();
|
|
297
299
|
const expiresAt = now + MCP_OAUTH_CODE_TTL_MS;
|
|
298
300
|
const result = await client.execute({
|
|
299
|
-
sql: `INSERT INTO mcp_oauth_codes (code, client_id, redirect_uri, code_challenge, code_challenge_method, owner_email, issued_for_email, org_id, org_domain, scope, resource, created_at, expires_at, consumed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
301
|
+
sql: `INSERT INTO mcp_oauth_codes (code, client_id, redirect_uri, code_challenge, code_challenge_method, owner_email, issued_for_email, org_id, org_domain, scope, resource, created_at, expires_at, consumed_at, client_name) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
300
302
|
args: [
|
|
301
303
|
code,
|
|
302
304
|
params.clientId,
|
|
@@ -312,6 +314,7 @@ export async function createOAuthCode(params, db) {
|
|
|
312
314
|
now,
|
|
313
315
|
expiresAt,
|
|
314
316
|
null,
|
|
317
|
+
params.clientName ?? null,
|
|
315
318
|
],
|
|
316
319
|
});
|
|
317
320
|
if (result.rowsAffected !== 1) {
|
|
@@ -319,6 +322,7 @@ export async function createOAuthCode(params, db) {
|
|
|
319
322
|
}
|
|
320
323
|
return {
|
|
321
324
|
code,
|
|
325
|
+
clientName: params.clientName ?? null,
|
|
322
326
|
clientId: params.clientId,
|
|
323
327
|
redirectUri: params.redirectUri,
|
|
324
328
|
codeChallenge: params.codeChallenge,
|
package/dist/org/index.d.ts
CHANGED
|
@@ -177,15 +177,15 @@ export declare const getMyOrgHandler: import("h3").EventHandlerWithFetch<import(
|
|
|
177
177
|
soloDeploymentAdmin: boolean | undefined;
|
|
178
178
|
}>>;
|
|
179
179
|
export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
180
|
-
success: boolean;
|
|
181
180
|
name?: undefined;
|
|
181
|
+
success: boolean;
|
|
182
182
|
id?: undefined;
|
|
183
183
|
role?: undefined;
|
|
184
184
|
} | {
|
|
185
|
+
success?: undefined;
|
|
185
186
|
id: string;
|
|
186
187
|
name: string;
|
|
187
188
|
role: import("./types.js").OrgRole;
|
|
188
|
-
success?: undefined;
|
|
189
189
|
}>>;
|
|
190
190
|
export declare const updateOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
191
191
|
orgId: string;
|
|
@@ -75,10 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
75
75
|
user: "user";
|
|
76
76
|
}>>;
|
|
77
77
|
}, z.core.$strip>>, {
|
|
78
|
-
message?: undefined;
|
|
79
|
-
id?: undefined;
|
|
80
78
|
provider?: undefined;
|
|
79
|
+
id?: undefined;
|
|
81
80
|
deleted?: undefined;
|
|
81
|
+
message?: undefined;
|
|
82
82
|
providers: {
|
|
83
83
|
id: string;
|
|
84
84
|
label: string;
|
|
@@ -93,30 +93,30 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
93
93
|
registered?: undefined;
|
|
94
94
|
label?: undefined;
|
|
95
95
|
} | {
|
|
96
|
-
message?: undefined;
|
|
97
96
|
id?: undefined;
|
|
97
|
+
count?: undefined;
|
|
98
98
|
deleted?: undefined;
|
|
99
|
+
message?: undefined;
|
|
99
100
|
providers?: undefined;
|
|
100
|
-
count?: undefined;
|
|
101
101
|
found: boolean;
|
|
102
102
|
provider: import("../custom-registry.js").CustomProviderConfig;
|
|
103
103
|
registered?: undefined;
|
|
104
104
|
label?: undefined;
|
|
105
105
|
} | {
|
|
106
|
-
message?: undefined;
|
|
107
106
|
provider?: undefined;
|
|
107
|
+
count?: undefined;
|
|
108
108
|
deleted?: undefined;
|
|
109
|
+
message?: undefined;
|
|
109
110
|
providers?: undefined;
|
|
110
|
-
count?: undefined;
|
|
111
111
|
found: boolean;
|
|
112
112
|
id: string;
|
|
113
113
|
registered?: undefined;
|
|
114
114
|
label?: undefined;
|
|
115
115
|
} | {
|
|
116
|
-
message?: undefined;
|
|
117
116
|
provider?: undefined;
|
|
118
|
-
providers?: undefined;
|
|
119
117
|
count?: undefined;
|
|
118
|
+
message?: undefined;
|
|
119
|
+
providers?: undefined;
|
|
120
120
|
found?: undefined;
|
|
121
121
|
deleted: boolean;
|
|
122
122
|
id: string;
|
|
@@ -124,9 +124,9 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
|
|
|
124
124
|
label?: undefined;
|
|
125
125
|
} | {
|
|
126
126
|
provider?: undefined;
|
|
127
|
+
count?: undefined;
|
|
127
128
|
deleted?: undefined;
|
|
128
129
|
providers?: undefined;
|
|
129
|
-
count?: undefined;
|
|
130
130
|
found?: undefined;
|
|
131
131
|
registered: boolean;
|
|
132
132
|
id: string;
|
|
@@ -311,9 +311,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
311
311
|
notes?: string | undefined;
|
|
312
312
|
scope?: "org" | "user" | undefined;
|
|
313
313
|
}, {
|
|
314
|
-
provider?: undefined;
|
|
315
314
|
message?: undefined;
|
|
316
315
|
id?: undefined;
|
|
316
|
+
deleted?: undefined;
|
|
317
317
|
providers: {
|
|
318
318
|
id: string;
|
|
319
319
|
label: string;
|
|
@@ -324,46 +324,46 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
|
|
|
324
324
|
updatedAt: number;
|
|
325
325
|
}[];
|
|
326
326
|
count: number;
|
|
327
|
+
provider?: undefined;
|
|
327
328
|
found?: undefined;
|
|
328
|
-
deleted?: undefined;
|
|
329
329
|
registered?: undefined;
|
|
330
330
|
label?: undefined;
|
|
331
331
|
} | {
|
|
332
|
-
count?: undefined;
|
|
333
332
|
message?: undefined;
|
|
334
333
|
id?: undefined;
|
|
334
|
+
deleted?: undefined;
|
|
335
|
+
count?: undefined;
|
|
335
336
|
providers?: 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
|
-
count?: undefined;
|
|
344
342
|
message?: undefined;
|
|
343
|
+
deleted?: undefined;
|
|
344
|
+
count?: undefined;
|
|
345
345
|
providers?: undefined;
|
|
346
|
+
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;
|
|
354
352
|
message?: undefined;
|
|
353
|
+
count?: undefined;
|
|
355
354
|
providers?: undefined;
|
|
355
|
+
provider?: undefined;
|
|
356
356
|
found?: undefined;
|
|
357
357
|
deleted: boolean;
|
|
358
358
|
id: string;
|
|
359
359
|
registered?: undefined;
|
|
360
360
|
label?: undefined;
|
|
361
361
|
} | {
|
|
362
|
-
|
|
362
|
+
deleted?: undefined;
|
|
363
363
|
count?: undefined;
|
|
364
364
|
providers?: undefined;
|
|
365
|
+
provider?: undefined;
|
|
365
366
|
found?: undefined;
|
|
366
|
-
deleted?: undefined;
|
|
367
367
|
registered: boolean;
|
|
368
368
|
id: string;
|
|
369
369
|
label: string;
|
|
@@ -73,6 +73,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
73
73
|
offset?: unknown;
|
|
74
74
|
limit?: unknown;
|
|
75
75
|
}, {
|
|
76
|
+
deleted?: undefined;
|
|
76
77
|
jobs: {
|
|
77
78
|
id: string;
|
|
78
79
|
name: string;
|
|
@@ -83,7 +84,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
|
|
|
83
84
|
updatedAt: string;
|
|
84
85
|
}[];
|
|
85
86
|
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;
|
|
94
95
|
jobs?: undefined;
|
|
95
96
|
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
|
-
ok?: undefined;
|
|
43
42
|
error: string;
|
|
43
|
+
ok?: undefined;
|
|
44
44
|
} | {
|
|
45
45
|
error?: undefined;
|
|
46
46
|
ok: boolean;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -58,20 +58,20 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
|
|
|
58
58
|
error: string;
|
|
59
59
|
errorCode?: undefined;
|
|
60
60
|
retryable?: undefined;
|
|
61
|
-
ok?: undefined;
|
|
62
61
|
status?: undefined;
|
|
62
|
+
ok?: undefined;
|
|
63
63
|
} | {
|
|
64
64
|
error: string;
|
|
65
65
|
errorCode: string;
|
|
66
66
|
retryable?: undefined;
|
|
67
|
-
ok?: undefined;
|
|
68
67
|
status?: undefined;
|
|
68
|
+
ok?: undefined;
|
|
69
69
|
} | {
|
|
70
70
|
error: string;
|
|
71
71
|
errorCode: string;
|
|
72
72
|
retryable: boolean;
|
|
73
|
-
ok?: undefined;
|
|
74
73
|
status?: undefined;
|
|
74
|
+
ok?: undefined;
|
|
75
75
|
} | {
|
|
76
76
|
errorCode?: undefined;
|
|
77
77
|
retryable?: undefined;
|
|
@@ -79,18 +79,18 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
|
|
|
79
79
|
status: string;
|
|
80
80
|
error?: undefined;
|
|
81
81
|
} | {
|
|
82
|
-
ok?: undefined;
|
|
83
82
|
error: string;
|
|
84
83
|
removed?: undefined;
|
|
84
|
+
ok?: undefined;
|
|
85
85
|
} | {
|
|
86
86
|
ok: boolean;
|
|
87
87
|
removed: boolean;
|
|
88
88
|
error?: undefined;
|
|
89
89
|
}>>;
|
|
90
90
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
91
|
-
ok?: undefined;
|
|
92
91
|
error: string;
|
|
93
92
|
note?: undefined;
|
|
93
|
+
ok?: undefined;
|
|
94
94
|
} | {
|
|
95
95
|
ok: boolean;
|
|
96
96
|
note?: undefined;
|
|
@@ -2766,7 +2766,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2766
2766
|
};
|
|
2767
2767
|
repo = appendThreadDebugHistory(repo, debug);
|
|
2768
2768
|
const meta = extractThreadMeta(repo);
|
|
2769
|
-
await updateThreadData(threadId, JSON.stringify(repo), thread.title, meta.preview || thread.preview, repo.messages.length);
|
|
2769
|
+
await updateThreadData(threadId, JSON.stringify(repo), thread.title, meta.preview || thread.preview, repo.messages.length, { trustedRunSequenceResetIds: new Set([run.runId]) });
|
|
2770
2770
|
});
|
|
2771
2771
|
// Checkpoint creation is part of durable turn completion. The helper
|
|
2772
2772
|
// catches and reports its own failures, so a broken app checkpoint does
|
|
@@ -8,17 +8,17 @@ export declare const AGENT_ENGINE_API_KEY_ACTION_NAME = "agent-engine-api-key";
|
|
|
8
8
|
* resolveEngine's credential detection.
|
|
9
9
|
*/
|
|
10
10
|
export declare function createAgentEngineDisconnectHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
11
|
+
ok?: undefined;
|
|
11
12
|
error: string;
|
|
12
13
|
scope?: undefined;
|
|
13
|
-
ok?: 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;
|
|
@@ -584,8 +584,8 @@ export declare function createPublicRemoteAgentsHandler(discover?: PublicAgentDi
|
|
|
584
584
|
error: string;
|
|
585
585
|
agents?: undefined;
|
|
586
586
|
} | {
|
|
587
|
-
error?: undefined;
|
|
588
587
|
agents: Omit<import("./agent-discovery.js").DiscoveredAgent, "auth" | "kind">[];
|
|
588
|
+
error?: undefined;
|
|
589
589
|
}>>;
|
|
590
590
|
export declare function getBuilderConnectErrorDisposition(error: unknown, connectAttemptId: string | null): "correlated" | "legacy" | null;
|
|
591
591
|
export declare function getBuilderConnectErrorKey(ownerEmail: string, connectAttemptId?: string | null): string;
|
|
@@ -56,6 +56,7 @@ export declare const MCP_CONNECT_GUIDES: readonly McpConnectGuide[];
|
|
|
56
56
|
export declare const MCP_CONNECT_HOSTS: readonly McpConnectHost[];
|
|
57
57
|
export declare const MCP_CONNECT_HOST_SEARCH_TEXT: string;
|
|
58
58
|
export declare function resolveMcpConnectGuideId(query: string | null | undefined): McpConnectGuideId;
|
|
59
|
+
export declare function resolveMcpConnectHostId(query: string): string | undefined;
|
|
59
60
|
export declare function matchesMcpConnectHost(query: string): boolean;
|
|
60
61
|
export declare function getMcpConnectGuides(locale: LocaleCode): readonly McpConnectGuide[];
|
|
61
62
|
export declare const MCP_STATIC_TOKEN_FALLBACK: {
|