@tangle-network/agent-app 0.60.250 → 0.60.251
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/DesignCanvas-L6J72JQ2.js +15 -0
- package/dist/DesignCanvasEditor-QFQD63MR.js +18 -0
- package/dist/agent-enrollment/drizzle.js +3 -3
- package/dist/agent-enrollment/index.js +3 -3
- package/dist/app-auth/drizzle.d.ts +561 -0
- package/dist/app-auth/drizzle.js +72 -0
- package/dist/app-auth/drizzle.js.map +1 -0
- package/dist/app-auth/index.js +5 -3
- package/dist/app-auth/index.js.map +1 -1
- package/dist/app-oauth/drizzle.d.ts +2080 -0
- package/dist/app-oauth/drizzle.js +161 -0
- package/dist/app-oauth/drizzle.js.map +1 -0
- package/dist/app-oauth/index.d.ts +4 -0
- package/dist/app-oauth/index.js +8 -222
- package/dist/app-oauth/index.js.map +1 -1
- package/dist/app-oauth/issuer.d.ts +133 -0
- package/dist/app-oauth/issuer.js +247 -0
- package/dist/app-oauth/issuer.js.map +1 -0
- package/dist/assistant/index.js +13 -13
- package/dist/chat-react/index.js +4 -4
- package/dist/chat-routes/index.js +37 -67
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/promote-file-part.d.ts +2 -3
- package/dist/chat-store/index.js +4 -4
- package/dist/{chunk-MY3EJJ6Y.js → chunk-4FEH6266.js} +2 -2
- package/dist/{chunk-5Y7Z5G3Y.js → chunk-4GCPADYG.js} +20 -336
- package/dist/chunk-4GCPADYG.js.map +1 -0
- package/dist/{chunk-X556WVBG.js → chunk-4ZSLX3LY.js} +2 -2
- package/dist/chunk-57XPEL7X.js +26 -0
- package/dist/chunk-57XPEL7X.js.map +1 -0
- package/dist/chunk-6Z7TZVKZ.js +26 -0
- package/dist/chunk-6Z7TZVKZ.js.map +1 -0
- package/dist/{chunk-7KKOFMLD.js → chunk-AWIQQEFP.js} +1 -1
- package/dist/chunk-AWIQQEFP.js.map +1 -0
- package/dist/{chunk-VBKP2NLI.js → chunk-BTKI4XMM.js} +2 -2
- package/dist/{chunk-63QAQP7I.js → chunk-CNBVWPQC.js} +7 -7
- package/dist/{chunk-FENBDSIW.js → chunk-CQGEGPY7.js} +75 -3
- package/dist/chunk-CQGEGPY7.js.map +1 -0
- package/dist/chunk-CTREXL3O.js +335 -0
- package/dist/chunk-CTREXL3O.js.map +1 -0
- package/dist/chunk-DLWO3J7D.js +238 -0
- package/dist/chunk-DLWO3J7D.js.map +1 -0
- package/dist/{chunk-LWSJK546.js → chunk-DSMGS4IV.js} +5 -5
- package/dist/{chunk-LWSJK546.js.map → chunk-DSMGS4IV.js.map} +1 -1
- package/dist/{chunk-A3KPDLSF.js → chunk-EFPIHR6F.js} +18 -18
- package/dist/chunk-FRAICFTZ.js +191 -0
- package/dist/chunk-FRAICFTZ.js.map +1 -0
- package/dist/chunk-GS7VWV26.js +61 -0
- package/dist/chunk-GS7VWV26.js.map +1 -0
- package/dist/{chunk-NMSAZFRL.js → chunk-H5GQMLHA.js} +2 -2
- package/dist/{chunk-OQE6WMDP.js → chunk-HN6MZ2XL.js} +5 -5
- package/dist/chunk-HY57QRRW.js +11 -0
- package/dist/chunk-HY57QRRW.js.map +1 -0
- package/dist/{chunk-TCGZFSN5.js → chunk-KH4QSBNI.js} +2 -2
- package/dist/{chunk-JH3CKHF4.js → chunk-KJODHPWM.js} +8 -8
- package/dist/chunk-LSBI5MWS.js +66 -0
- package/dist/chunk-LSBI5MWS.js.map +1 -0
- package/dist/chunk-MDRH3SDA.js +106 -0
- package/dist/chunk-MDRH3SDA.js.map +1 -0
- package/dist/{chunk-VBWYH7UZ.js → chunk-NHYRIM4I.js} +3 -3
- package/dist/{chunk-BYP54FMI.js → chunk-O2RCDK5D.js} +30 -15
- package/dist/{chunk-BYP54FMI.js.map → chunk-O2RCDK5D.js.map} +1 -1
- package/dist/{chunk-EWOJATDS.js → chunk-PDD5A43Y.js} +3 -3
- package/dist/{chunk-23JUSUUB.js → chunk-RZLCBWGG.js} +2 -2
- package/dist/chunk-SFZELD6V.js +52 -0
- package/dist/chunk-SFZELD6V.js.map +1 -0
- package/dist/{chunk-Y4W6GK5X.js → chunk-UGFCLD32.js} +2 -2
- package/dist/{chunk-ZGUXI5SI.js → chunk-VUBJZEZB.js} +2 -2
- package/dist/{chunk-LQYIBL3G.js → chunk-WL7PZK7Q.js} +71 -1
- package/dist/chunk-WL7PZK7Q.js.map +1 -0
- package/dist/{chunk-7HZCFG2A.js → chunk-WP2GYFZ4.js} +38 -1
- package/dist/chunk-WP2GYFZ4.js.map +1 -0
- package/dist/{chunk-JK7R7BZQ.js → chunk-ZWJ3SZ2G.js} +2 -2
- package/dist/crypto/digest.d.ts +2 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.js +6 -2
- package/dist/design-canvas/index.js +5 -3
- package/dist/design-canvas/index.js.map +1 -1
- package/dist/design-canvas-react/engine.js +7 -5
- package/dist/design-canvas-react/index.js +14 -12
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/eval/index.d.ts +4 -0
- package/dist/eval/index.js +125 -0
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/persona-driver.d.ts +37 -0
- package/dist/eval/research-plan.d.ts +25 -0
- package/dist/eval/research-plan.js +55 -0
- package/dist/eval/research-plan.js.map +1 -0
- package/dist/eval/scorecard.d.ts +38 -0
- package/dist/forms/blank.d.ts +2 -2
- package/dist/forms/index.js +4 -5
- package/dist/forms/index.js.map +1 -1
- package/dist/hosted-agent/application.js +2 -2
- package/dist/interactions/index.js +3 -3
- package/dist/knowledge/prelaunch-audit.d.ts +17 -0
- package/dist/knowledge/prelaunch-audit.js +67 -0
- package/dist/knowledge/prelaunch-audit.js.map +1 -0
- package/dist/media/drizzle.d.ts +207 -0
- package/dist/media/drizzle.js +26 -0
- package/dist/media/drizzle.js.map +1 -0
- package/dist/media/generate-request.d.ts +53 -0
- package/dist/media/generation-record.d.ts +68 -0
- package/dist/media/index.d.ts +13 -0
- package/dist/media/index.js +653 -0
- package/dist/media/index.js.map +1 -0
- package/dist/media/model-catalog.d.ts +109 -0
- package/dist/media/router-client.d.ts +40 -0
- package/dist/media/router-generation.d.ts +44 -0
- package/dist/media/speech-script.d.ts +20 -0
- package/dist/openui/index.js +1 -1
- package/dist/operator/index.js +4 -5
- package/dist/operator/index.js.map +1 -1
- package/dist/plans/decision.d.ts +48 -0
- package/dist/plans/drizzle.d.ts +25 -0
- package/dist/plans/drizzle.js +97 -0
- package/dist/plans/drizzle.js.map +1 -0
- package/dist/plans/index.d.ts +1 -1
- package/dist/plans/index.js +11 -3
- package/dist/platform/billing-config.d.ts +22 -0
- package/dist/platform/billing-config.js +36 -0
- package/dist/platform/billing-config.js.map +1 -0
- package/dist/platform/index.js +13 -11
- package/dist/platform/index.js.map +1 -1
- package/dist/preset-cloudflare/index.js +2 -1
- package/dist/preset-cloudflare/index.js.map +1 -1
- package/dist/profile/index.js +4 -5
- package/dist/profile/index.js.map +1 -1
- package/dist/public-consultation/index.d.ts +1 -1
- package/dist/public-consultation/index.js +13 -11
- package/dist/public-consultation/index.js.map +1 -1
- package/dist/runtime/telemetry-cap.d.ts +24 -0
- package/dist/runtime/telemetry-cap.js +36 -0
- package/dist/runtime/telemetry-cap.js.map +1 -0
- package/dist/sandbox/index.js +12 -9
- package/dist/sequences/index.js +4 -2
- package/dist/sequences/index.js.map +1 -1
- package/dist/skills-placement/box.d.ts +50 -0
- package/dist/skills-placement/box.js +204 -0
- package/dist/skills-placement/box.js.map +1 -0
- package/dist/skills-placement/index.js +8 -96
- package/dist/skills-placement/index.js.map +1 -1
- package/dist/spend/budget.d.ts +13 -0
- package/dist/spend/drizzle.d.ts +55 -0
- package/dist/spend/drizzle.js +131 -0
- package/dist/spend/drizzle.js.map +1 -0
- package/dist/spend/index.d.ts +2 -1
- package/dist/spend/index.js +77 -58
- package/dist/spend/index.js.map +1 -1
- package/dist/spend/platform-settlements.d.ts +46 -0
- package/dist/stream/index.js +19 -19
- package/dist/studio/generated-media/index.d.ts +6 -0
- package/dist/studio/generated-media/index.js +590 -0
- package/dist/studio/generated-media/index.js.map +1 -0
- package/dist/studio/generated-media/output.d.ts +27 -0
- package/dist/studio/generated-media/store.d.ts +175 -0
- package/dist/studio-react/download-generations.d.ts +7 -0
- package/dist/studio-react/index.d.ts +1 -0
- package/dist/studio-react/index.js +85 -0
- package/dist/studio-react/index.js.map +1 -1
- package/dist/studio-react/use-studio-route.d.ts +44 -0
- package/dist/teams/invitations-api.d.ts +4 -0
- package/dist/teams/invitations-api.js +44 -32
- package/dist/teams/invitations-api.js.map +1 -1
- package/dist/theme/dom.d.ts +22 -0
- package/dist/theme/dom.js +18 -0
- package/dist/theme/dom.js.map +1 -0
- package/dist/vault/collaboration.d.ts +83 -0
- package/dist/vault/collaboration.js +215 -0
- package/dist/vault/collaboration.js.map +1 -0
- package/dist/vault/server.js +6 -53
- package/dist/vault/server.js.map +1 -1
- package/dist/vault/store/coordinator.d.ts +64 -0
- package/dist/vault/store/index.d.ts +12 -0
- package/dist/vault/store/index.js +1202 -0
- package/dist/vault/store/index.js.map +1 -0
- package/dist/vault/store/paths.d.ts +65 -0
- package/dist/vault/store/revisions.d.ts +211 -0
- package/dist/vault/store/sandbox-sync.d.ts +74 -0
- package/dist/vault/store/store.d.ts +161 -0
- package/dist/vault/store/tree.d.ts +11 -0
- package/dist/web/entry-server.d.ts +7 -0
- package/dist/web/entry-server.js +29 -0
- package/dist/web/entry-server.js.map +1 -0
- package/dist/web/fetch-guard.d.ts +6 -0
- package/dist/web/index.d.ts +3 -0
- package/dist/web/index.js +20 -4
- package/dist/web/mime.d.ts +16 -0
- package/dist/web/rate-limit.d.ts +25 -0
- package/dist/web/timeout.d.ts +9 -0
- package/dist/web-react/agent-profile-editor.js +3 -3
- package/dist/web-react/api-access-panel.d.ts +4 -2
- package/dist/web-react/document.d.ts +41 -0
- package/dist/web-react/document.js +103 -0
- package/dist/web-react/document.js.map +1 -0
- package/dist/web-react/index.js +31 -31
- package/dist/workspace-react/index.js +5 -5
- package/package.json +95 -4
- package/dist/DesignCanvas-OW3W2QXW.js +0 -13
- package/dist/DesignCanvasEditor-TCHZF25W.js +0 -16
- package/dist/chunk-5Y7Z5G3Y.js.map +0 -1
- package/dist/chunk-7HZCFG2A.js.map +0 -1
- package/dist/chunk-7KKOFMLD.js.map +0 -1
- package/dist/chunk-FENBDSIW.js.map +0 -1
- package/dist/chunk-LQYIBL3G.js.map +0 -1
- /package/dist/{DesignCanvas-OW3W2QXW.js.map → DesignCanvas-L6J72JQ2.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-TCHZF25W.js.map → DesignCanvasEditor-QFQD63MR.js.map} +0 -0
- /package/dist/{chunk-MY3EJJ6Y.js.map → chunk-4FEH6266.js.map} +0 -0
- /package/dist/{chunk-X556WVBG.js.map → chunk-4ZSLX3LY.js.map} +0 -0
- /package/dist/{chunk-VBKP2NLI.js.map → chunk-BTKI4XMM.js.map} +0 -0
- /package/dist/{chunk-63QAQP7I.js.map → chunk-CNBVWPQC.js.map} +0 -0
- /package/dist/{chunk-A3KPDLSF.js.map → chunk-EFPIHR6F.js.map} +0 -0
- /package/dist/{chunk-NMSAZFRL.js.map → chunk-H5GQMLHA.js.map} +0 -0
- /package/dist/{chunk-OQE6WMDP.js.map → chunk-HN6MZ2XL.js.map} +0 -0
- /package/dist/{chunk-TCGZFSN5.js.map → chunk-KH4QSBNI.js.map} +0 -0
- /package/dist/{chunk-JH3CKHF4.js.map → chunk-KJODHPWM.js.map} +0 -0
- /package/dist/{chunk-VBWYH7UZ.js.map → chunk-NHYRIM4I.js.map} +0 -0
- /package/dist/{chunk-EWOJATDS.js.map → chunk-PDD5A43Y.js.map} +0 -0
- /package/dist/{chunk-23JUSUUB.js.map → chunk-RZLCBWGG.js.map} +0 -0
- /package/dist/{chunk-Y4W6GK5X.js.map → chunk-UGFCLD32.js.map} +0 -0
- /package/dist/{chunk-ZGUXI5SI.js.map → chunk-VUBJZEZB.js.map} +0 -0
- /package/dist/{chunk-JK7R7BZQ.js.map → chunk-ZWJ3SZ2G.js.map} +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activeAppOAuthConsent,
|
|
3
|
+
appOAuthMetadataResponse,
|
|
4
|
+
appOAuthProtectedResourceMetadata,
|
|
5
|
+
appOAuthTokenResponse,
|
|
6
|
+
createAppOAuthProvider,
|
|
7
|
+
createAppOAuthResourceVerifier
|
|
8
|
+
} from "../chunk-DLWO3J7D.js";
|
|
9
|
+
|
|
10
|
+
// src/app-oauth/issuer.ts
|
|
11
|
+
import { betterAuth } from "better-auth";
|
|
12
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
13
|
+
import { jwt } from "better-auth/plugins";
|
|
14
|
+
import { and, eq, gt, isNull } from "drizzle-orm";
|
|
15
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "[::1]"];
|
|
16
|
+
function applicationOrigin(configured) {
|
|
17
|
+
if (!configured) throw new Error("BETTER_AUTH_URL is required for Agents OAuth");
|
|
18
|
+
const url = new URL(configured);
|
|
19
|
+
if (url.username || url.password || url.search || url.hash || url.pathname !== "/" || url.protocol !== "https:" && !(url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname))) {
|
|
20
|
+
throw new Error("Agents OAuth requires an HTTPS application origin or a local loopback origin");
|
|
21
|
+
}
|
|
22
|
+
return url.origin;
|
|
23
|
+
}
|
|
24
|
+
function createAppOAuthIssuer(options) {
|
|
25
|
+
const { db, tables } = options;
|
|
26
|
+
const { users, sessions, oauthClient, oauthResource, oauthClientResource, oauthConsent, oauthRefreshToken } = tables;
|
|
27
|
+
const env = options.env ?? (() => process.env);
|
|
28
|
+
const loginPage = options.loginPage ?? "/login";
|
|
29
|
+
const consentPage = options.consentPage ?? "/agents/consent";
|
|
30
|
+
const resourcePath = options.resourcePath ?? "/api/agents/mcp";
|
|
31
|
+
const origin = () => applicationOrigin(env().BETTER_AUTH_URL);
|
|
32
|
+
const resource = () => `${origin()}${resourcePath}`;
|
|
33
|
+
const issuer = () => `${origin()}/api/auth`;
|
|
34
|
+
const config = () => ({
|
|
35
|
+
resource: resource(),
|
|
36
|
+
issuer: issuer(),
|
|
37
|
+
scopes: options.scopes,
|
|
38
|
+
defaultClientScope: options.defaultClientScope,
|
|
39
|
+
consentClaim: options.consentClaim
|
|
40
|
+
});
|
|
41
|
+
async function userVerified(userId) {
|
|
42
|
+
const [user] = await db.select({ emailVerified: users.emailVerified }).from(users).where(eq(users.id, userId)).limit(1);
|
|
43
|
+
return user?.emailVerified === true;
|
|
44
|
+
}
|
|
45
|
+
const authority = {
|
|
46
|
+
findConsents: (clientId, userId) => db.select({
|
|
47
|
+
id: oauthConsent.id,
|
|
48
|
+
scopes: oauthConsent.scopes,
|
|
49
|
+
resources: oauthConsent.resources
|
|
50
|
+
}).from(oauthConsent).where(and(eq(oauthConsent.clientId, clientId), eq(oauthConsent.userId, userId))).limit(2),
|
|
51
|
+
clientActive: async (clientId) => (await db.select({ id: oauthClient.id }).from(oauthClient).where(and(eq(oauthClient.clientId, clientId), eq(oauthClient.disabled, false))).limit(1)).length > 0,
|
|
52
|
+
resourceActive: async (identifier) => (await db.select({ id: oauthResource.id }).from(oauthResource).where(and(eq(oauthResource.identifier, identifier), eq(oauthResource.disabled, false))).limit(1)).length > 0,
|
|
53
|
+
clientResourceLinked: async (clientId, identifier) => (await db.select({ id: oauthClientResource.id }).from(oauthClientResource).where(and(
|
|
54
|
+
eq(oauthClientResource.clientId, clientId),
|
|
55
|
+
eq(oauthClientResource.resourceId, identifier)
|
|
56
|
+
)).limit(1)).length > 0,
|
|
57
|
+
sessionActive: async (sessionId, userId) => (await db.select({ id: sessions.id }).from(sessions).where(and(eq(sessions.id, sessionId), eq(sessions.userId, userId), gt(sessions.expiresAt, /* @__PURE__ */ new Date()))).limit(1)).length > 0,
|
|
58
|
+
userActive: userVerified
|
|
59
|
+
};
|
|
60
|
+
const refreshStore = {
|
|
61
|
+
async findByHash(hash) {
|
|
62
|
+
const [row] = await db.select({
|
|
63
|
+
id: oauthRefreshToken.id,
|
|
64
|
+
clientId: oauthRefreshToken.clientId,
|
|
65
|
+
userId: oauthRefreshToken.userId,
|
|
66
|
+
referenceId: oauthRefreshToken.referenceId
|
|
67
|
+
}).from(oauthRefreshToken).where(eq(oauthRefreshToken.token, hash)).limit(1);
|
|
68
|
+
return row ?? null;
|
|
69
|
+
},
|
|
70
|
+
async bindIfUnbound(id, consentId) {
|
|
71
|
+
const bound = await db.update(oauthRefreshToken).set({ referenceId: consentId }).where(and(eq(oauthRefreshToken.id, id), isNull(oauthRefreshToken.referenceId))).returning({ id: oauthRefreshToken.id });
|
|
72
|
+
return bound.length > 0;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function build() {
|
|
76
|
+
const secret = env().BETTER_AUTH_SECRET;
|
|
77
|
+
if (!secret) throw new Error("BETTER_AUTH_SECRET is required for Agents OAuth");
|
|
78
|
+
const applicationUrl = origin();
|
|
79
|
+
return betterAuth({
|
|
80
|
+
appName: options.appName,
|
|
81
|
+
baseURL: applicationUrl,
|
|
82
|
+
secret,
|
|
83
|
+
trustedOrigins: [applicationUrl],
|
|
84
|
+
// Tokens leave only through `tokenResponse`, which binds refresh rows to consent.
|
|
85
|
+
disabledPaths: ["/token"],
|
|
86
|
+
database: drizzleAdapter(db, {
|
|
87
|
+
provider: "sqlite",
|
|
88
|
+
schema: {
|
|
89
|
+
user: users,
|
|
90
|
+
session: sessions,
|
|
91
|
+
account: tables.accounts,
|
|
92
|
+
verification: tables.verifications,
|
|
93
|
+
jwks: tables.jwks,
|
|
94
|
+
oauthClient,
|
|
95
|
+
oauthResource,
|
|
96
|
+
oauthClientResource,
|
|
97
|
+
oauthRefreshToken,
|
|
98
|
+
oauthAccessToken: tables.oauthAccessToken,
|
|
99
|
+
oauthConsent,
|
|
100
|
+
oauthClientAssertion: tables.oauthClientAssertion
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
session: { cookieCache: { enabled: false } },
|
|
104
|
+
advanced: { cookiePrefix: options.cookiePrefix },
|
|
105
|
+
plugins: [
|
|
106
|
+
jwt({ disableSettingJwtHeader: true }),
|
|
107
|
+
// Typed as better-auth's own plugin: a workspace may resolve the provider against a second
|
|
108
|
+
// @better-auth/core copy. Callers use the handler and the JWT plugin's API only.
|
|
109
|
+
createAppOAuthProvider({
|
|
110
|
+
...config(),
|
|
111
|
+
authority,
|
|
112
|
+
loginPage,
|
|
113
|
+
consentPage,
|
|
114
|
+
humanUserEligible: userVerified
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
let built = null;
|
|
120
|
+
function instance() {
|
|
121
|
+
if (built) return built;
|
|
122
|
+
const auth = build();
|
|
123
|
+
const verify = createAppOAuthResourceVerifier({ ...config(), authority, jwksFetch: () => auth.api.getJwks() });
|
|
124
|
+
built = { auth, verify };
|
|
125
|
+
return built;
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
resource,
|
|
129
|
+
issuer,
|
|
130
|
+
auth: () => instance().auth,
|
|
131
|
+
metadataResponse: (request) => appOAuthMetadataResponse(request, instance().auth.handler),
|
|
132
|
+
tokenResponse: (request) => appOAuthTokenResponse(request, {
|
|
133
|
+
...config(),
|
|
134
|
+
authority,
|
|
135
|
+
refreshStore,
|
|
136
|
+
handler: instance().auth.handler
|
|
137
|
+
}),
|
|
138
|
+
verifyRequest: (request) => instance().verify(request),
|
|
139
|
+
async protectedResourceMetadata() {
|
|
140
|
+
const metadata = await appOAuthProtectedResourceMetadata(config(), instance().auth);
|
|
141
|
+
return { ...metadata, resource: resource(), authorization_servers: [issuer()] };
|
|
142
|
+
},
|
|
143
|
+
async grantActive(grant) {
|
|
144
|
+
const { userId, clientId, consentId, sessionId, scopes } = grant;
|
|
145
|
+
if (!userId || !clientId || !consentId || !sessionId || !scopes.length) return false;
|
|
146
|
+
const identifier = resource();
|
|
147
|
+
const checks = await Promise.all([
|
|
148
|
+
authority.clientActive(clientId),
|
|
149
|
+
authority.resourceActive(identifier),
|
|
150
|
+
authority.clientResourceLinked(clientId, identifier),
|
|
151
|
+
authority.userActive(userId),
|
|
152
|
+
authority.sessionActive(sessionId, userId),
|
|
153
|
+
activeAppOAuthConsent({ ...config(), authority }, clientId, userId, scopes).then((consent) => consent?.id === consentId)
|
|
154
|
+
]);
|
|
155
|
+
return checks.every(Boolean);
|
|
156
|
+
},
|
|
157
|
+
loginPage,
|
|
158
|
+
consentPage
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function invalidRequest() {
|
|
162
|
+
return new Response("Invalid authorization request", { status: 400 });
|
|
163
|
+
}
|
|
164
|
+
var UNSAFE_NATIVE_SCHEMES = ["javascript:", "data:", "vbscript:", "blob:", "file:"];
|
|
165
|
+
function safeRedirect(target, policy) {
|
|
166
|
+
try {
|
|
167
|
+
const url = new URL(target);
|
|
168
|
+
if (policy === "native") return !UNSAFE_NATIVE_SCHEMES.includes(url.protocol.toLowerCase());
|
|
169
|
+
return !url.username && !url.password && (url.protocol === "https:" || url.protocol === "http:" && LOOPBACK_HOSTS.includes(url.hostname));
|
|
170
|
+
} catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function redirectTo(location) {
|
|
175
|
+
return new Response(null, { status: 302, headers: { location } });
|
|
176
|
+
}
|
|
177
|
+
function createAppOAuthConsent(options) {
|
|
178
|
+
const { issuer, scopeLabels, redirectPolicy = "web" } = options;
|
|
179
|
+
const rawQuery = (request) => new URL(request.url).search.replace(/^\?/, "");
|
|
180
|
+
async function clientForConsent(request) {
|
|
181
|
+
const query = rawQuery(request);
|
|
182
|
+
if (!query || query.length > 8192) throw invalidRequest();
|
|
183
|
+
const params = new URLSearchParams(query);
|
|
184
|
+
const clientId = params.get("client_id");
|
|
185
|
+
if (!clientId) throw invalidRequest();
|
|
186
|
+
const url = new URL("/api/auth/oauth2/public-client-prelogin", request.url);
|
|
187
|
+
const response = await issuer.auth().handler(new Request(url, { method: "POST", headers: {
|
|
188
|
+
"content-type": "application/json",
|
|
189
|
+
accept: "application/json",
|
|
190
|
+
"x-requested-with": "XMLHttpRequest",
|
|
191
|
+
origin: url.origin,
|
|
192
|
+
cookie: request.headers.get("cookie") ?? ""
|
|
193
|
+
}, body: JSON.stringify({ client_id: clientId, oauth_query: query }) }));
|
|
194
|
+
if (!response.ok) throw invalidRequest();
|
|
195
|
+
const client = await response.json();
|
|
196
|
+
if (client.client_id !== clientId) throw invalidRequest();
|
|
197
|
+
const scopes = (params.get("scope") ?? "").split(/\s+/).filter(Boolean);
|
|
198
|
+
if (!scopes.length || scopes.some((scope) => !Object.hasOwn(scopeLabels, scope)) || params.has("claims")) {
|
|
199
|
+
throw new Response("Unsupported authorization scope", { status: 400 });
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
query,
|
|
203
|
+
clientName: client.client_name || "An application",
|
|
204
|
+
scopes,
|
|
205
|
+
labels: Object.fromEntries(scopes.map((scope) => [scope, scopeLabels[scope]]))
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
async loader(request) {
|
|
210
|
+
const session = await options.getSession(request);
|
|
211
|
+
if (!session?.user?.emailVerified) {
|
|
212
|
+
const next = `${issuer.consentPage}?${rawQuery(request)}`;
|
|
213
|
+
throw redirectTo(`${issuer.loginPage}?redirect=${encodeURIComponent(next)}`);
|
|
214
|
+
}
|
|
215
|
+
return clientForConsent(request);
|
|
216
|
+
},
|
|
217
|
+
async action(request) {
|
|
218
|
+
const origin = request.headers.get("origin");
|
|
219
|
+
const canonicalOrigin = new URL(issuer.resource()).origin;
|
|
220
|
+
if (origin !== canonicalOrigin || new URL(request.url).origin !== canonicalOrigin) {
|
|
221
|
+
throw new Response("Invalid request origin", { status: 403 });
|
|
222
|
+
}
|
|
223
|
+
const session = await options.getSession(request);
|
|
224
|
+
if (!session?.user?.emailVerified) throw new Response("Sign in again", { status: 401 });
|
|
225
|
+
const { query } = await clientForConsent(request);
|
|
226
|
+
const choice = (await request.formData()).get("choice");
|
|
227
|
+
if (choice !== "allow" && choice !== "deny") throw new Response("Invalid decision", { status: 400 });
|
|
228
|
+
const url = new URL("/api/auth/oauth2/consent", request.url);
|
|
229
|
+
const response = await issuer.auth().handler(new Request(url, { method: "POST", headers: {
|
|
230
|
+
"content-type": "application/json",
|
|
231
|
+
accept: "application/json",
|
|
232
|
+
origin,
|
|
233
|
+
cookie: request.headers.get("cookie") ?? ""
|
|
234
|
+
}, body: JSON.stringify({ accept: choice === "allow", oauth_query: query }) }));
|
|
235
|
+
const result = await response.json().catch(() => ({}));
|
|
236
|
+
if (!response.ok) return { error: "The authorization request expired. Return to your app and try again." };
|
|
237
|
+
const target = result.url ?? result.redirect_uri;
|
|
238
|
+
if (!target || !safeRedirect(target, redirectPolicy)) throw new Response("Invalid authorization destination", { status: 502 });
|
|
239
|
+
return redirectTo(target);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
export {
|
|
244
|
+
createAppOAuthConsent,
|
|
245
|
+
createAppOAuthIssuer
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=issuer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/app-oauth/issuer.ts"],"sourcesContent":["/**\n * A product-hosted OAuth issuer for its MCP resource: one better-auth instance\n * with the JWT and OAuth provider plugins over the product's drizzle database,\n * reading the same session cookie as the product's own auth instance, plus the\n * host authority (consent, client, resource, session and user rows) that the\n * `./app-oauth` primitives check before a token is minted or accepted.\n *\n * The product supplies its database, tables (`./app-auth/drizzle` and\n * `./app-oauth/drizzle`), scopes, consent claim and names. The origin and\n * secret are read from `BETTER_AUTH_URL` and `BETTER_AUTH_SECRET` when first\n * used, after the Worker binds its environment.\n */\n\nimport { betterAuth, type BetterAuthPlugin } from 'better-auth'\nimport { drizzleAdapter } from 'better-auth/adapters/drizzle'\nimport { jwt } from 'better-auth/plugins'\nimport { and, eq, gt, isNull } from 'drizzle-orm'\nimport type { AnySQLiteColumn, AnySQLiteTable, BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core'\nimport type { AppOAuthTables } from './drizzle'\nimport {\n activeAppOAuthConsent,\n appOAuthMetadataResponse,\n appOAuthProtectedResourceMetadata,\n appOAuthTokenResponse,\n createAppOAuthProvider,\n createAppOAuthResourceVerifier,\n type AppOAuthAuthority,\n type AppOAuthConfig,\n type AppOAuthPrincipal,\n type AppOAuthRefreshStore,\n} from './index'\n\nconst LOOPBACK_HOSTS = ['localhost', '127.0.0.1', '[::1]']\n\n/** The product's drizzle SQLite database (D1 or any async SQLite driver). */\nexport type AppOAuthIssuerDatabase = BaseSQLiteDatabase<'async', any, any>\n\n/** The auth and OAuth tables the issuer reads and the provider writes. */\nexport interface AppOAuthIssuerTables extends AppOAuthTables {\n users: AnySQLiteTable & { id: AnySQLiteColumn; emailVerified: AnySQLiteColumn }\n sessions: AnySQLiteTable & { id: AnySQLiteColumn; userId: AnySQLiteColumn; expiresAt: AnySQLiteColumn }\n accounts: AnySQLiteTable\n verifications: AnySQLiteTable\n}\n\nexport interface CreateAppOAuthIssuerOptions {\n /** better-auth app name. */\n appName: string\n /** The product auth instance's cookie prefix, so both read one session. */\n cookiePrefix: string\n db: AppOAuthIssuerDatabase\n tables: AppOAuthIssuerTables\n /** OAuth permissions the product offers for its resource. */\n scopes: readonly string[]\n /** Scope granted to a dynamically registered client by default. */\n defaultClientScope: string\n /** Access-token claim holding the consent row ID. Changing it invalidates issued tokens. */\n consentClaim: string\n /** Default '/login'. */\n loginPage?: string\n /** Default '/agents/consent'. */\n consentPage?: string\n /** Path of the protected resource on the product origin. Default '/api/agents/mcp'. */\n resourcePath?: string\n /** Default `process.env`. */\n env?: () => { BETTER_AUTH_URL?: string; BETTER_AUTH_SECRET?: string }\n}\n\n/** An admitted principal's grant, rechecked when later work commits on its behalf. */\nexport interface AppOAuthGrant {\n userId: string\n clientId: string\n consentId: string\n sessionId: string\n scopes: readonly string[]\n}\n\nfunction applicationOrigin(configured: string | undefined): string {\n if (!configured) throw new Error('BETTER_AUTH_URL is required for Agents OAuth')\n const url = new URL(configured)\n if (url.username || url.password || url.search || url.hash || url.pathname !== '/'\n || (url.protocol !== 'https:' && !(url.protocol === 'http:' && LOOPBACK_HOSTS.includes(url.hostname)))) {\n throw new Error('Agents OAuth requires an HTTPS application origin or a local loopback origin')\n }\n return url.origin\n}\n\n/** The issuer's better-auth instance, as products use it. */\nexport interface AppOAuthIssuerAuth {\n handler(request: Request): Promise<Response>\n /** Resolves once better-auth has initialised (seeding the resource row). */\n $context: Promise<unknown>\n}\n\nexport interface AppOAuthIssuer {\n /** The protected resource URL (RFC 8707 audience). */\n resource(): string\n /** The issuer URL, including better-auth's /api/auth base path. */\n issuer(): string\n /** Construct only after the Worker binds its database and env. */\n auth(): AppOAuthIssuerAuth\n /** Issuer metadata without the unsupported DPoP advertisement. */\n metadataResponse(request: Request): Promise<Response>\n /** The token endpoint, binding each refresh row to the current consent. */\n tokenResponse(request: Request): Promise<Response>\n /** Bearer tokens only: DPoP would need a replay store shared across Workers. */\n verifyRequest(request: Request): Promise<AppOAuthPrincipal | null>\n /** RFC 9728 metadata for the resource, without DPoP advertisement. */\n protectedResourceMetadata(): Promise<{ resource: string; authorization_servers: string[]; [key: string]: unknown }>\n /** Whether the grant that admitted a principal is still current. */\n grantActive(grant: AppOAuthGrant): Promise<boolean>\n loginPage: string\n consentPage: string\n}\n\n/** Build the product's OAuth issuer, its token and metadata routes, and its resource verifier. */\nexport function createAppOAuthIssuer(options: CreateAppOAuthIssuerOptions): AppOAuthIssuer {\n const { db, tables } = options\n const { users, sessions, oauthClient, oauthResource, oauthClientResource, oauthConsent, oauthRefreshToken } = tables\n const env = options.env ?? (() => process.env)\n const loginPage = options.loginPage ?? '/login'\n const consentPage = options.consentPage ?? '/agents/consent'\n const resourcePath = options.resourcePath ?? '/api/agents/mcp'\n\n const origin = () => applicationOrigin(env().BETTER_AUTH_URL)\n const resource = () => `${origin()}${resourcePath}`\n const issuer = () => `${origin()}/api/auth`\n const config = (): AppOAuthConfig => ({\n resource: resource(), issuer: issuer(), scopes: options.scopes,\n defaultClientScope: options.defaultClientScope, consentClaim: options.consentClaim,\n })\n\n async function userVerified(userId: string): Promise<boolean> {\n const [user] = await db.select({ emailVerified: users.emailVerified }).from(users)\n .where(eq(users.id, userId)).limit(1)\n return user?.emailVerified === true\n }\n\n const authority: AppOAuthAuthority = {\n findConsents: (clientId, userId) => db.select({ id: oauthConsent.id, scopes: oauthConsent.scopes,\n resources: oauthConsent.resources }).from(oauthConsent)\n .where(and(eq(oauthConsent.clientId, clientId), eq(oauthConsent.userId, userId))).limit(2),\n clientActive: async (clientId) => (await db.select({ id: oauthClient.id }).from(oauthClient)\n .where(and(eq(oauthClient.clientId, clientId), eq(oauthClient.disabled, false))).limit(1)).length > 0,\n resourceActive: async (identifier) => (await db.select({ id: oauthResource.id }).from(oauthResource)\n .where(and(eq(oauthResource.identifier, identifier), eq(oauthResource.disabled, false))).limit(1)).length > 0,\n clientResourceLinked: async (clientId, identifier) => (await db.select({ id: oauthClientResource.id })\n .from(oauthClientResource).where(and(eq(oauthClientResource.clientId, clientId),\n eq(oauthClientResource.resourceId, identifier))).limit(1)).length > 0,\n sessionActive: async (sessionId, userId) => (await db.select({ id: sessions.id }).from(sessions)\n .where(and(eq(sessions.id, sessionId), eq(sessions.userId, userId), gt(sessions.expiresAt, new Date())))\n .limit(1)).length > 0,\n userActive: userVerified,\n }\n\n const refreshStore: AppOAuthRefreshStore = {\n async findByHash(hash) {\n const [row] = await db.select({ id: oauthRefreshToken.id, clientId: oauthRefreshToken.clientId,\n userId: oauthRefreshToken.userId, referenceId: oauthRefreshToken.referenceId })\n .from(oauthRefreshToken).where(eq(oauthRefreshToken.token, hash)).limit(1)\n return row ?? null\n },\n async bindIfUnbound(id, consentId) {\n const bound = await db.update(oauthRefreshToken).set({ referenceId: consentId })\n .where(and(eq(oauthRefreshToken.id, id), isNull(oauthRefreshToken.referenceId)))\n .returning({ id: oauthRefreshToken.id })\n return bound.length > 0\n },\n }\n\n function build() {\n const secret = env().BETTER_AUTH_SECRET\n if (!secret) throw new Error('BETTER_AUTH_SECRET is required for Agents OAuth')\n const applicationUrl = origin()\n return betterAuth({\n appName: options.appName,\n baseURL: applicationUrl,\n secret,\n trustedOrigins: [applicationUrl],\n // Tokens leave only through `tokenResponse`, which binds refresh rows to consent.\n disabledPaths: ['/token'],\n database: drizzleAdapter(db, {\n provider: 'sqlite',\n schema: {\n user: users, session: sessions, account: tables.accounts, verification: tables.verifications,\n jwks: tables.jwks, oauthClient, oauthResource, oauthClientResource, oauthRefreshToken,\n oauthAccessToken: tables.oauthAccessToken, oauthConsent, oauthClientAssertion: tables.oauthClientAssertion,\n },\n }),\n session: { cookieCache: { enabled: false } },\n advanced: { cookiePrefix: options.cookiePrefix },\n plugins: [\n jwt({ disableSettingJwtHeader: true }),\n // Typed as better-auth's own plugin: a workspace may resolve the provider against a second\n // @better-auth/core copy. Callers use the handler and the JWT plugin's API only.\n createAppOAuthProvider({ ...config(), authority, loginPage, consentPage,\n humanUserEligible: userVerified }) as unknown as BetterAuthPlugin,\n ],\n })\n }\n\n let built: { auth: ReturnType<typeof build>; verify: (request: Request) => Promise<AppOAuthPrincipal | null> } | null = null\n function instance() {\n if (built) return built\n const auth = build()\n const verify = createAppOAuthResourceVerifier({ ...config(), authority, jwksFetch: () => auth.api.getJwks() })\n built = { auth, verify }\n return built\n }\n\n return {\n resource,\n issuer,\n auth: () => instance().auth,\n metadataResponse: (request: Request) => appOAuthMetadataResponse(request, instance().auth.handler),\n tokenResponse: (request: Request) => appOAuthTokenResponse(request, {\n ...config(), authority, refreshStore, handler: instance().auth.handler,\n }),\n verifyRequest: (request: Request) => instance().verify(request),\n async protectedResourceMetadata() {\n const metadata = await appOAuthProtectedResourceMetadata(config(), instance().auth)\n // The same values the metadata was built from; restated so the shape is typed.\n return { ...metadata, resource: resource(), authorization_servers: [issuer()] }\n },\n async grantActive(grant: AppOAuthGrant): Promise<boolean> {\n const { userId, clientId, consentId, sessionId, scopes } = grant\n if (!userId || !clientId || !consentId || !sessionId || !scopes.length) return false\n const identifier = resource()\n const checks = await Promise.all([\n authority.clientActive(clientId),\n authority.resourceActive(identifier),\n authority.clientResourceLinked(clientId, identifier),\n authority.userActive(userId),\n authority.sessionActive(sessionId, userId),\n activeAppOAuthConsent({ ...config(), authority }, clientId, userId, scopes)\n .then((consent) => consent?.id === consentId),\n ])\n return checks.every(Boolean)\n },\n loginPage,\n consentPage,\n }\n}\n\nexport interface CreateAppOAuthConsentOptions {\n issuer: AppOAuthIssuer\n /** The product's browser session for this request. */\n getSession(request: Request): Promise<{ user?: { emailVerified?: boolean | null } | null } | null>\n /** Every scope the consent page may show; any other requested scope is refused. */\n scopeLabels: Readonly<Record<string, string>>\n /**\n * Which client destinations may leave the consent page. `'web'` (default)\n * allows only HTTPS or loopback without credentials. `'native'` also allows\n * the private-use URI schemes native apps register (RFC 8252, e.g. an editor's\n * own scheme) and refuses only script, data, blob and file schemes.\n */\n redirectPolicy?: 'web' | 'native'\n}\n\nexport interface AppOAuthConsentView {\n query: string\n clientName: string\n /** The requested scopes, in request order. */\n scopes: string[]\n /** The label of each requested scope. */\n labels: Record<string, string>\n}\n\nfunction invalidRequest(): Response {\n return new Response('Invalid authorization request', { status: 400 })\n}\n\nconst UNSAFE_NATIVE_SCHEMES = ['javascript:', 'data:', 'vbscript:', 'blob:', 'file:']\n\nfunction safeRedirect(target: string, policy: 'web' | 'native'): boolean {\n try {\n const url = new URL(target)\n if (policy === 'native') return !UNSAFE_NATIVE_SCHEMES.includes(url.protocol.toLowerCase())\n return !url.username && !url.password && (url.protocol === 'https:'\n || (url.protocol === 'http:' && LOOPBACK_HOSTS.includes(url.hostname)))\n } catch { return false }\n}\n\nfunction redirectTo(location: string): Response {\n return new Response(null, { status: 302, headers: { location } })\n}\n\n/**\n * Server half of the product's consent page. `loader` throws a redirect to\n * sign-in or a 400; `action` returns `{ error }` for an expired request and\n * otherwise a redirect to the client.\n */\nexport function createAppOAuthConsent(options: CreateAppOAuthConsentOptions) {\n const { issuer, scopeLabels, redirectPolicy = 'web' } = options\n const rawQuery = (request: Request) => new URL(request.url).search.replace(/^\\?/, '')\n\n async function clientForConsent(request: Request): Promise<AppOAuthConsentView> {\n const query = rawQuery(request)\n if (!query || query.length > 8192) throw invalidRequest()\n const params = new URLSearchParams(query)\n const clientId = params.get('client_id')\n if (!clientId) throw invalidRequest()\n const url = new URL('/api/auth/oauth2/public-client-prelogin', request.url)\n const response = await issuer.auth().handler(new Request(url, { method: 'POST', headers: {\n 'content-type': 'application/json', accept: 'application/json',\n 'x-requested-with': 'XMLHttpRequest', origin: url.origin,\n cookie: request.headers.get('cookie') ?? '',\n }, body: JSON.stringify({ client_id: clientId, oauth_query: query }) }))\n if (!response.ok) throw invalidRequest()\n const client = await response.json() as { client_id?: string; client_name?: string }\n if (client.client_id !== clientId) throw invalidRequest()\n const scopes = (params.get('scope') ?? '').split(/\\s+/).filter(Boolean)\n if (!scopes.length || scopes.some((scope) => !Object.hasOwn(scopeLabels, scope)) || params.has('claims')) {\n throw new Response('Unsupported authorization scope', { status: 400 })\n }\n return { query, clientName: client.client_name || 'An application',\n scopes, labels: Object.fromEntries(scopes.map((scope) => [scope, scopeLabels[scope]!])) }\n }\n\n return {\n async loader(request: Request): Promise<AppOAuthConsentView> {\n const session = await options.getSession(request)\n if (!session?.user?.emailVerified) {\n const next = `${issuer.consentPage}?${rawQuery(request)}`\n throw redirectTo(`${issuer.loginPage}?redirect=${encodeURIComponent(next)}`)\n }\n return clientForConsent(request)\n },\n async action(request: Request): Promise<{ error: string } | Response> {\n const origin = request.headers.get('origin')\n const canonicalOrigin = new URL(issuer.resource()).origin\n if (origin !== canonicalOrigin || new URL(request.url).origin !== canonicalOrigin) {\n throw new Response('Invalid request origin', { status: 403 })\n }\n const session = await options.getSession(request)\n if (!session?.user?.emailVerified) throw new Response('Sign in again', { status: 401 })\n const { query } = await clientForConsent(request)\n const choice = (await request.formData()).get('choice')\n if (choice !== 'allow' && choice !== 'deny') throw new Response('Invalid decision', { status: 400 })\n const url = new URL('/api/auth/oauth2/consent', request.url)\n const response = await issuer.auth().handler(new Request(url, { method: 'POST', headers: {\n 'content-type': 'application/json', accept: 'application/json', origin,\n cookie: request.headers.get('cookie') ?? '',\n }, body: JSON.stringify({ accept: choice === 'allow', oauth_query: query }) }))\n const result = await response.json().catch(() => ({})) as { url?: string; redirect_uri?: string }\n if (!response.ok) return { error: 'The authorization request expired. Return to your app and try again.' }\n const target = result.url ?? result.redirect_uri\n if (!target || !safeRedirect(target, redirectPolicy)) throw new Response('Invalid authorization destination', { status: 502 })\n return redirectTo(target)\n },\n }\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAS,kBAAyC;AAClD,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,KAAK,IAAI,IAAI,cAAc;AAgBpC,IAAM,iBAAiB,CAAC,aAAa,aAAa,OAAO;AA6CzD,SAAS,kBAAkB,YAAwC;AACjE,MAAI,CAAC,WAAY,OAAM,IAAI,MAAM,8CAA8C;AAC/E,QAAM,MAAM,IAAI,IAAI,UAAU;AAC9B,MAAI,IAAI,YAAY,IAAI,YAAY,IAAI,UAAU,IAAI,QAAQ,IAAI,aAAa,OACzE,IAAI,aAAa,YAAY,EAAE,IAAI,aAAa,WAAW,eAAe,SAAS,IAAI,QAAQ,IAAK;AACxG,UAAM,IAAI,MAAM,8EAA8E;AAAA,EAChG;AACA,SAAO,IAAI;AACb;AA+BO,SAAS,qBAAqB,SAAsD;AACzF,QAAM,EAAE,IAAI,OAAO,IAAI;AACvB,QAAM,EAAE,OAAO,UAAU,aAAa,eAAe,qBAAqB,cAAc,kBAAkB,IAAI;AAC9G,QAAM,MAAM,QAAQ,QAAQ,MAAM,QAAQ;AAC1C,QAAM,YAAY,QAAQ,aAAa;AACvC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AAI,SAAS,iBAAiB,EAAE,QAAQ,IAAI,CAAC;AACtF,YAAM,EAAE,MAAM,IAAI,MAAM,iBAAiB,OAAO;AAChD,YAAM,UAAU,MAAM,QAAQ,SAAS,GAAG,IAAI,QAAQ;AACtD,UAAI,WAAW,WAAW,WAAW,OAAQ,OAAM,IAAI,SAAS,oBAAoB,EAAE,QAAQ,IAAI,CAAC;AACnG,YAAM,MAAM,IAAI,IAAI,4BAA4B,QAAQ,GAAG;AAC3D,YAAM,WAAW,MAAM,OAAO,KAAK,EAAE,QAAQ,IAAI,QAAQ,KAAK,EAAE,QAAQ,QAAQ,SAAS;AAAA,QACvF,gBAAgB;AAAA,QAAoB,QAAQ;AAAA,QAAoB;AAAA,QAChE,QAAQ,QAAQ,QAAQ,IAAI,QAAQ,KAAK;AAAA,MAC3C,GAAG,MAAM,KAAK,UAAU,EAAE,QAAQ,WAAW,SAAS,aAAa,MAAM,CAAC,EAAE,CAAC,CAAC;AAC9E,YAAM,SAAS,MAAM,SAAS,KAAK,EAAE,MAAM,OAAO,CAAC,EAAE;AACrD,UAAI,CAAC,SAAS,GAAI,QAAO,EAAE,OAAO,uEAAuE;AACzG,YAAM,SAAS,OAAO,OAAO,OAAO;AACpC,UAAI,CAAC,UAAU,CAAC,aAAa,QAAQ,cAAc,EAAG,OAAM,IAAI,SAAS,qCAAqC,EAAE,QAAQ,IAAI,CAAC;AAC7H,aAAO,WAAW,MAAM;AAAA,IAC1B;AAAA,EACF;AACF;","names":[]}
|
package/dist/assistant/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ReasoningRow,
|
|
3
3
|
chatToolCallPart
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-3HUFJ5LO.js";
|
|
4
|
+
} from "../chunk-O2RCDK5D.js";
|
|
6
5
|
import "../chunk-BDEBQ4WO.js";
|
|
6
|
+
import "../chunk-3HUFJ5LO.js";
|
|
7
7
|
import "../chunk-FBVLEGEG.js";
|
|
8
|
+
import "../chunk-HN6MZ2XL.js";
|
|
8
9
|
import "../chunk-Y6PRDUFJ.js";
|
|
9
10
|
import "../chunk-GEYACSFW.js";
|
|
10
11
|
import {
|
|
11
12
|
ChatComposer
|
|
12
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-CNBVWPQC.js";
|
|
13
14
|
import "../chunk-L7MB2LLM.js";
|
|
15
|
+
import "../chunk-G4F2NWZH.js";
|
|
14
16
|
import "../chunk-ZDPUC6CM.js";
|
|
15
17
|
import "../chunk-2HQP2CTA.js";
|
|
16
|
-
import "../chunk-E4AY62T2.js";
|
|
17
|
-
import "../chunk-SJWIZT7B.js";
|
|
18
|
-
import "../chunk-OQE6WMDP.js";
|
|
19
|
-
import "../chunk-G4F2NWZH.js";
|
|
20
18
|
import "../chunk-FUZETA6Z.js";
|
|
21
19
|
import {
|
|
22
20
|
ModelPicker
|
|
23
21
|
} from "../chunk-R4X5474U.js";
|
|
22
|
+
import "../chunk-E4AY62T2.js";
|
|
23
|
+
import "../chunk-SJWIZT7B.js";
|
|
24
24
|
import "../chunk-ATQQCG4I.js";
|
|
25
25
|
import "../chunk-WSEXFTN4.js";
|
|
26
26
|
import {
|
|
@@ -29,17 +29,17 @@ import {
|
|
|
29
29
|
import "../chunk-RASGKEAL.js";
|
|
30
30
|
import "../chunk-FQYAJYPW.js";
|
|
31
31
|
import "../chunk-NHVSO47Q.js";
|
|
32
|
-
import "../chunk-FPNZMIAW.js";
|
|
33
32
|
import "../chunk-B7CL7ENS.js";
|
|
34
|
-
import "../chunk-PV33JZKV.js";
|
|
35
33
|
import "../chunk-AMUXRAUO.js";
|
|
36
|
-
import "../chunk-
|
|
34
|
+
import "../chunk-RZLCBWGG.js";
|
|
37
35
|
import "../chunk-ZVEEWGDK.js";
|
|
38
36
|
import "../chunk-5TSRFF5W.js";
|
|
39
|
-
import "../chunk-
|
|
40
|
-
import "../chunk-ZGUXI5SI.js";
|
|
37
|
+
import "../chunk-VUBJZEZB.js";
|
|
41
38
|
import "../chunk-6VQCFJWP.js";
|
|
42
|
-
import "../chunk-
|
|
39
|
+
import "../chunk-FPNZMIAW.js";
|
|
40
|
+
import "../chunk-PV33JZKV.js";
|
|
41
|
+
import "../chunk-TXD5HXLE.js";
|
|
42
|
+
import "../chunk-WL7PZK7Q.js";
|
|
43
43
|
|
|
44
44
|
// src/assistant/sse.ts
|
|
45
45
|
var SSEChunkParser = class {
|
package/dist/chat-react/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComposerModeControls,
|
|
3
3
|
EntryComposer
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-CNBVWPQC.js";
|
|
5
5
|
import "../chunk-L7MB2LLM.js";
|
|
6
|
-
import "../chunk-2HQP2CTA.js";
|
|
7
|
-
import "../chunk-SJWIZT7B.js";
|
|
8
6
|
import "../chunk-G4F2NWZH.js";
|
|
7
|
+
import "../chunk-2HQP2CTA.js";
|
|
9
8
|
import "../chunk-FUZETA6Z.js";
|
|
10
9
|
import "../chunk-R4X5474U.js";
|
|
10
|
+
import "../chunk-SJWIZT7B.js";
|
|
11
11
|
import "../chunk-RASGKEAL.js";
|
|
12
12
|
import "../chunk-NHVSO47Q.js";
|
|
13
|
-
import "../chunk-FPNZMIAW.js";
|
|
14
13
|
import "../chunk-AMUXRAUO.js";
|
|
15
14
|
import "../chunk-5TSRFF5W.js";
|
|
15
|
+
import "../chunk-FPNZMIAW.js";
|
|
16
16
|
import "../chunk-TXD5HXLE.js";
|
|
17
17
|
export {
|
|
18
18
|
ComposerModeControls,
|
|
@@ -36,15 +36,6 @@ import {
|
|
|
36
36
|
DEFAULT_TERMINAL_TURN_LOCK_GRACE_MS,
|
|
37
37
|
reconcileStaleTurnLock
|
|
38
38
|
} from "../chunk-CCVWR33L.js";
|
|
39
|
-
import {
|
|
40
|
-
createEscalationSpeculator,
|
|
41
|
-
createSandboxRunTool,
|
|
42
|
-
escalationHints,
|
|
43
|
-
flattenHistory,
|
|
44
|
-
readSandboxBinaryBytes,
|
|
45
|
-
statSandboxFileSize
|
|
46
|
-
} from "../chunk-5Y7Z5G3Y.js";
|
|
47
|
-
import "../chunk-4LBCTFBP.js";
|
|
48
39
|
import {
|
|
49
40
|
ModelFailoverExhaustedError,
|
|
50
41
|
buildModelChain,
|
|
@@ -53,8 +44,14 @@ import {
|
|
|
53
44
|
readUpstreamUnavailableCode,
|
|
54
45
|
runWithModelFailover
|
|
55
46
|
} from "../chunk-ZLX4BA27.js";
|
|
56
|
-
import
|
|
57
|
-
|
|
47
|
+
import {
|
|
48
|
+
createEscalationSpeculator,
|
|
49
|
+
createSandboxRunTool,
|
|
50
|
+
escalationHints,
|
|
51
|
+
flattenHistory
|
|
52
|
+
} from "../chunk-4GCPADYG.js";
|
|
53
|
+
import "../chunk-4LBCTFBP.js";
|
|
54
|
+
import "../chunk-DSMGS4IV.js";
|
|
58
55
|
import "../chunk-5BJHKQ33.js";
|
|
59
56
|
import "../chunk-6A7MYOUI.js";
|
|
60
57
|
import "../chunk-O7UX55EU.js";
|
|
@@ -83,24 +80,19 @@ import {
|
|
|
83
80
|
rowIdOf,
|
|
84
81
|
storeSupportsDraftPersistence,
|
|
85
82
|
streamChatRouteAsSandboxEvents
|
|
86
|
-
} from "../chunk-
|
|
87
|
-
import "../chunk-
|
|
88
|
-
import "../chunk-FENBDSIW.js";
|
|
89
|
-
import "../chunk-RN4WPTBH.js";
|
|
90
|
-
import "../chunk-7HZCFG2A.js";
|
|
91
|
-
import "../chunk-Z4RD5UF7.js";
|
|
92
|
-
import "../chunk-YG66IHDU.js";
|
|
83
|
+
} from "../chunk-EFPIHR6F.js";
|
|
84
|
+
import "../chunk-KH4QSBNI.js";
|
|
93
85
|
import {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
import "../chunk-
|
|
86
|
+
sniffMimeFromName
|
|
87
|
+
} from "../chunk-CQGEGPY7.js";
|
|
88
|
+
import "../chunk-RN4WPTBH.js";
|
|
89
|
+
import "../chunk-WP2GYFZ4.js";
|
|
98
90
|
import {
|
|
99
91
|
attachmentInputToPart,
|
|
100
92
|
attachmentKindForMime,
|
|
101
93
|
historyContentWithAttachments,
|
|
102
94
|
toChatMessageParts
|
|
103
|
-
} from "../chunk-
|
|
95
|
+
} from "../chunk-RZLCBWGG.js";
|
|
104
96
|
import "../chunk-ZVEEWGDK.js";
|
|
105
97
|
import {
|
|
106
98
|
ChatTurnInputError,
|
|
@@ -135,9 +127,8 @@ import {
|
|
|
135
127
|
turnResponseEventFor,
|
|
136
128
|
validateSandboxMentionPath
|
|
137
129
|
} from "../chunk-5TSRFF5W.js";
|
|
138
|
-
import
|
|
139
|
-
|
|
140
|
-
} from "../chunk-TXD5HXLE.js";
|
|
130
|
+
import "../chunk-Z4RD5UF7.js";
|
|
131
|
+
import "../chunk-YG66IHDU.js";
|
|
141
132
|
import {
|
|
142
133
|
asRecord,
|
|
143
134
|
asString,
|
|
@@ -150,7 +141,7 @@ import {
|
|
|
150
141
|
normalizePersistedPart,
|
|
151
142
|
normalizeToolEvent,
|
|
152
143
|
terminalizeDanglingAssistantToolUpdates
|
|
153
|
-
} from "../chunk-
|
|
144
|
+
} from "../chunk-VUBJZEZB.js";
|
|
154
145
|
import {
|
|
155
146
|
cancelStatusFor,
|
|
156
147
|
interactionPartKey,
|
|
@@ -161,14 +152,30 @@ import {
|
|
|
161
152
|
parseInteractionCancel,
|
|
162
153
|
parseInteractionRequest
|
|
163
154
|
} from "../chunk-6VQCFJWP.js";
|
|
155
|
+
import {
|
|
156
|
+
coalesceDeltas,
|
|
157
|
+
createBufferedTurnTap
|
|
158
|
+
} from "../chunk-ISP6ZH3G.js";
|
|
159
|
+
import "../chunk-MM6RLOXF.js";
|
|
160
|
+
import "../chunk-XELWWXJJ.js";
|
|
161
|
+
import "../chunk-ORQD4AUO.js";
|
|
162
|
+
import {
|
|
163
|
+
readSandboxBinaryBytes,
|
|
164
|
+
statSandboxFileSize
|
|
165
|
+
} from "../chunk-CTREXL3O.js";
|
|
166
|
+
import "../chunk-FPNZMIAW.js";
|
|
167
|
+
import "../chunk-HY57QRRW.js";
|
|
168
|
+
import {
|
|
169
|
+
isWorkspaceFileExportable
|
|
170
|
+
} from "../chunk-TXD5HXLE.js";
|
|
164
171
|
import {
|
|
165
172
|
parsePlanSubmittedEvent,
|
|
166
173
|
persistedPartToPlan,
|
|
167
174
|
planFollowUpTurnId,
|
|
168
175
|
planToPersistedPart
|
|
169
|
-
} from "../chunk-
|
|
170
|
-
import "../chunk-
|
|
171
|
-
import "../chunk-
|
|
176
|
+
} from "../chunk-WL7PZK7Q.js";
|
|
177
|
+
import "../chunk-6Z7TZVKZ.js";
|
|
178
|
+
import "../chunk-57XPEL7X.js";
|
|
172
179
|
|
|
173
180
|
// src/chat-routes/model-failover-stream.ts
|
|
174
181
|
var TERMINAL_FAILURE_TYPES = /* @__PURE__ */ new Set(["error", "session.run.failed"]);
|
|
@@ -2696,43 +2703,6 @@ function inspectAtomicAttachmentWriteResult(value, ownership) {
|
|
|
2696
2703
|
|
|
2697
2704
|
// src/chat-routes/promote-file-part.ts
|
|
2698
2705
|
var PROMOTE_MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
2699
|
-
var EXT_TO_MIME = {
|
|
2700
|
-
md: "text/markdown",
|
|
2701
|
-
markdown: "text/markdown",
|
|
2702
|
-
txt: "text/plain",
|
|
2703
|
-
log: "text/plain",
|
|
2704
|
-
csv: "text/csv",
|
|
2705
|
-
tsv: "text/tab-separated-values",
|
|
2706
|
-
json: "application/json",
|
|
2707
|
-
yaml: "text/yaml",
|
|
2708
|
-
yml: "text/yaml",
|
|
2709
|
-
xml: "application/xml",
|
|
2710
|
-
html: "text/html",
|
|
2711
|
-
htm: "text/html",
|
|
2712
|
-
pdf: "application/pdf",
|
|
2713
|
-
png: "image/png",
|
|
2714
|
-
jpg: "image/jpeg",
|
|
2715
|
-
jpeg: "image/jpeg",
|
|
2716
|
-
gif: "image/gif",
|
|
2717
|
-
webp: "image/webp",
|
|
2718
|
-
avif: "image/avif",
|
|
2719
|
-
heic: "image/heic",
|
|
2720
|
-
heif: "image/heif",
|
|
2721
|
-
svg: "image/svg+xml",
|
|
2722
|
-
mp4: "video/mp4",
|
|
2723
|
-
webm: "video/webm",
|
|
2724
|
-
mov: "video/quicktime",
|
|
2725
|
-
mp3: "audio/mpeg",
|
|
2726
|
-
wav: "audio/wav",
|
|
2727
|
-
ogg: "audio/ogg",
|
|
2728
|
-
m4a: "audio/mp4",
|
|
2729
|
-
aac: "audio/aac"
|
|
2730
|
-
};
|
|
2731
|
-
function sniffMimeFromName(filename) {
|
|
2732
|
-
const ext = filename.split(".").pop()?.toLowerCase();
|
|
2733
|
-
if (!ext) return "text/plain";
|
|
2734
|
-
return EXT_TO_MIME[ext] ?? "text/plain";
|
|
2735
|
-
}
|
|
2736
2706
|
function base64ToBytes(base64) {
|
|
2737
2707
|
const binary = atob(base64);
|
|
2738
2708
|
const bytes = new Uint8Array(binary.length);
|