@raybase/core 0.3.6 → 0.3.7
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-ai-chat.js +2 -2
- package/dist/agent-ai-chat.js.map +1 -1
- package/dist/audited-write.d.ts +19 -0
- package/dist/audited-write.d.ts.map +1 -0
- package/dist/audited-write.js +42 -0
- package/dist/audited-write.js.map +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +21 -8
- package/dist/auth.js.map +1 -1
- package/dist/data-client.d.ts +8 -1
- package/dist/data-client.d.ts.map +1 -1
- package/dist/data-client.js +29 -22
- package/dist/data-client.js.map +1 -1
- package/dist/db.d.ts +13 -0
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +3 -2
- package/dist/db.js.map +1 -1
- package/dist/do.d.ts +5 -0
- package/dist/do.d.ts.map +1 -1
- package/dist/do.js +5 -0
- package/dist/do.js.map +1 -1
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +13 -4
- package/dist/email.js.map +1 -1
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +11 -13
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +23 -5
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +180 -44
- package/dist/mcp.js.map +1 -1
- package/dist/operator-mcp.js +1 -1
- package/dist/operator-mcp.js.map +1 -1
- package/dist/same-origin-path.d.ts +37 -0
- package/dist/same-origin-path.d.ts.map +1 -0
- package/dist/same-origin-path.js +29 -0
- package/dist/same-origin-path.js.map +1 -0
- package/dist/storage-client.d.ts.map +1 -1
- package/dist/storage-client.js +44 -28
- package/dist/storage-client.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/dist/vite.d.ts +76 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +121 -0
- package/dist/vite.js.map +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +71 -41
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/worker.js
CHANGED
|
@@ -45,7 +45,7 @@ import { appNowIso, appNowMs, devTimeTravelStateKey, hydrateAppClock, installDev
|
|
|
45
45
|
import { createRaybaseRuntimeEnv, raybaseAgentConversationName, raybaseCoreRuntimeProfile, RaybaseRuntimeProfileConfigurationError, raybaseRuntimeProfile, raybaseRuntimeSettingsAppId, raybaseRuntimeScopeClaims, raybaseRuntimeScope, runtimePolicySubjectId, withRaybaseRuntimeClaims } from "./platform.js";
|
|
46
46
|
import { appUrlForEmail, cloudflareEmailNotificationAdapter, hasRaybaseAuthEmailConfig, isRaybaseAuthEmailFeatureEnabled, raybaseAuthEmailProvider, redactedEmailError, resolveRaybaseAuthEmailConfig, sendRaybaseAuthEmail } from "./email.js";
|
|
47
47
|
import { accessDeniedPage, forgotPasswordPage, loginPage, page, resetPasswordPage, setupPage, signupPage, verifyEmailPage } from "./html.js";
|
|
48
|
-
import { authorizationServerMetadata, authorizeMcpOAuthRequest, mcpMetadataSurface, mcpOAuthConsentContext, beginMcpHostAuthorization, checkMcpRateLimit, completeMcpHostApproval, createMcpHandler, exchangeMcpOAuthToken, handleMcpHostConnect, listMcpGrants, listMcpOAuthClientsForUser, operatorMcpEnabled, operatorMcpEndpoint, protectedResourceMetadata, raybaseMcpSystemTables, registerMcpOAuthClient, revokeMcpGrant, revokeMcpOAuthClient, revokeMcpOAuthToken } from "./mcp.js";
|
|
48
|
+
import { authorizationServerMetadata, authorizeMcpOAuthRequest, mcpAppConnectorScopes, mcpMetadataSurface, mcpOAuthConsentContext, beginMcpHostAuthorization, checkMcpRateLimit, completeMcpHostApproval, createMcpHandler, exchangeMcpOAuthToken, handleMcpHostConnect, listMcpGrants, listMcpOAuthClientsForUser, operatorMcpEnabled, operatorMcpEndpoint, protectedResourceMetadata, raybaseMcpSystemTables, registerMcpOAuthClient, revokeMcpGrant, revokeMcpOAuthClient, revokeMcpOAuthToken } from "./mcp.js";
|
|
49
49
|
import { createCoreOperatorMcpResources, createCoreOperatorMcpTools } from "./operator-mcp.js";
|
|
50
50
|
import { mergeRaybaseRecords, mergeRaybaseRetrieval, mergeRaybaseSearch, resolveRaybaseModules } from "./modules.js";
|
|
51
51
|
import { claimAndRunNotificationDeliveries, compactNotificationThrottleWindows, createNotificationsOperatorEvidenceProvider, createNotificationsRuntime, handleInboundNotification, mergeRaybaseNotifications, notificationAdminSummary, notificationDeliveriesQuery, notificationDeliveryDetail, notificationInboundEventDetail, notificationInboundEventsQuery, notificationThrottleWindowsQuery, notificationJobPrincipal, raybaseNotificationDeliveryJobName, raybaseNotificationRecipientsTableName, raybaseNotificationsTableName, raybaseNotificationServicePrincipal, raybaseNotificationSystemTables, resetNotificationThrottleWindow, retryNotificationDelivery, resolveNotificationConfig, validateNotifications } from "./notifications.js";
|
|
@@ -72,6 +72,7 @@ import { raybaseFilesTableName, validateStorageConfig } from "./storage.js";
|
|
|
72
72
|
import { supportModule } from "./support.js";
|
|
73
73
|
import { adminBrowsableSystemTables, ensureManifestTables, validateSystemTables } from "./system-tables.js";
|
|
74
74
|
import { raybaseLocalDevChromePersonas } from "./local-dev-chrome.js";
|
|
75
|
+
import { sameOriginPath } from "./same-origin-path.js";
|
|
75
76
|
import { RAYBASE_CORE_VERSION, RAYBASE_DATASHEET_GRID_VERSION } from "./version.js";
|
|
76
77
|
export { maxOutstandingComposeRequests } from "./agent-ai-chat.js";
|
|
77
78
|
export { raybaseLocalDevChromePayload, raybaseLocalDevChromePersonas, withRaybaseLocalDevChrome } from "./local-dev-chrome.js";
|
|
@@ -701,12 +702,6 @@ function searchNumber(url, key) {
|
|
|
701
702
|
const numeric = Number(value);
|
|
702
703
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
703
704
|
}
|
|
704
|
-
function safeRelativePath(value, fallback) {
|
|
705
|
-
const path = asString(value).trim();
|
|
706
|
-
if (path.startsWith("/") && !path.startsWith("//"))
|
|
707
|
-
return path;
|
|
708
|
-
return fallback;
|
|
709
|
-
}
|
|
710
705
|
function providerMetadataById(config, externalAuth, providerId) {
|
|
711
706
|
return raybaseExternalProviderMetadata(config, externalAuth).find((provider) => provider.id === providerId) ?? null;
|
|
712
707
|
}
|
|
@@ -1148,7 +1143,7 @@ async function localSeedContext(env, request, user, options, localDevPersonas) {
|
|
|
1148
1143
|
})).for({
|
|
1149
1144
|
user,
|
|
1150
1145
|
adminOverride: true,
|
|
1151
|
-
audit: (entry) => audit(
|
|
1146
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata),
|
|
1152
1147
|
notify: realtimeEnabled
|
|
1153
1148
|
? async (change) => {
|
|
1154
1149
|
if (!("seq" in change))
|
|
@@ -2349,7 +2344,22 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
2349
2344
|
const runtimeJobs = runtimeJobsFor(options, resolvedModules);
|
|
2350
2345
|
const runtimeNotifications = runtimeNotificationsFor(options, resolvedModules);
|
|
2351
2346
|
const inferenceProviderFactory = selectedInferenceProviderFactory(options.config, resolvedModules);
|
|
2352
|
-
const
|
|
2347
|
+
const appMcpTools = [...resolvedModules.mcpTools, ...(options.mcp?.tools ?? [])];
|
|
2348
|
+
const appMcpResources = [...resolvedModules.mcpResources, ...(options.mcp?.resources ?? [])];
|
|
2349
|
+
const moduleMcpScopes = {
|
|
2350
|
+
operatorPermissions: resolvedModules.operatorPermissions,
|
|
2351
|
+
// What a machine credential for the app connector may hold.
|
|
2352
|
+
appScopes: mcpEnabled
|
|
2353
|
+
? mcpAppConnectorScopes({
|
|
2354
|
+
schema: options.schema,
|
|
2355
|
+
appMigrations: options.appMigrations,
|
|
2356
|
+
search: runtimeSearch,
|
|
2357
|
+
tools: appMcpTools,
|
|
2358
|
+
resources: appMcpResources,
|
|
2359
|
+
generatedTools: options.mcp?.generatedTools
|
|
2360
|
+
})
|
|
2361
|
+
: []
|
|
2362
|
+
};
|
|
2353
2363
|
const runtimeOptions = { ...options, settings: runtimeSettings, actions: runtimeActions, agents: runtimeAgents, jobs: runtimeJobs, retrieval: runtimeRetrieval, search: runtimeSearch, notifications: runtimeNotifications };
|
|
2354
2364
|
const resetLocalAppWorld = async (env, request, user, localDevPersonas) => {
|
|
2355
2365
|
const control = raybaseAuthExecutor(env);
|
|
@@ -2368,6 +2378,9 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
2368
2378
|
};
|
|
2369
2379
|
const passwordSecretLifecycle = passwordSecretLifecycleFor(options.backups);
|
|
2370
2380
|
const settingsDefinitions = settingsDefinitionsFor(runtimeOptions, aiEnabled, runtimeProfile);
|
|
2381
|
+
// The local seed runs once per database: concurrent first requests share
|
|
2382
|
+
// one run, keyed like the default model seed below.
|
|
2383
|
+
const localSeedsInFlight = new Map();
|
|
2371
2384
|
const defaultAiModelSeeded = new Set();
|
|
2372
2385
|
const defaultAiModelSeedPromises = new Map();
|
|
2373
2386
|
const ensureDefaultAiModelSeeded = async (env, control) => {
|
|
@@ -4050,7 +4063,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
4050
4063
|
const agentDb = createRaybaseDb(input.env, options.schema, options.appMigrations, runtimeDbOptions(input.env));
|
|
4051
4064
|
const clientFor = (source) => agentDb.for({
|
|
4052
4065
|
user: executionUser,
|
|
4053
|
-
audit: (entry) => auditTagged(
|
|
4066
|
+
audit: (entry, auditDb) => auditTagged(auditDb, input.actor, runAs, entry.action, entry.target.type, entry.target.id ?? undefined, {
|
|
4054
4067
|
...metadataObject(entry.metadata),
|
|
4055
4068
|
...auditMetadata
|
|
4056
4069
|
}),
|
|
@@ -4676,8 +4689,8 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
4676
4689
|
schema: options.schema,
|
|
4677
4690
|
appMigrations: options.appMigrations,
|
|
4678
4691
|
search: runtimeSearch,
|
|
4679
|
-
tools:
|
|
4680
|
-
resources:
|
|
4692
|
+
tools: appMcpTools,
|
|
4693
|
+
resources: appMcpResources,
|
|
4681
4694
|
generatedTools: options.mcp?.generatedTools,
|
|
4682
4695
|
resolveContext: options.mcp?.resolveContext,
|
|
4683
4696
|
scopeOptions: mcpHostGrantScopes,
|
|
@@ -4994,7 +5007,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
4994
5007
|
const provider = providerMetadataById(options.config, externalAuth, providerId);
|
|
4995
5008
|
if (!provider || !externalAuth?.providerIds.includes(provider.id))
|
|
4996
5009
|
throw new Error("External auth provider is not configured");
|
|
4997
|
-
const callbackURL =
|
|
5010
|
+
const callbackURL = sameOriginPath(asString(body.callbackURL).trim(), "/");
|
|
4998
5011
|
// Better Auth keeps `disableImplicitSignUp` on every Raybase provider, so
|
|
4999
5012
|
// a first-time visitor only gets an account when the redirect explicitly
|
|
5000
5013
|
// asks for one. In public signup mode that ask is the whole point of the
|
|
@@ -5049,7 +5062,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
5049
5062
|
request: requestWithPendingCookie,
|
|
5050
5063
|
passwordSecretLifecycle
|
|
5051
5064
|
});
|
|
5052
|
-
const callbackURL =
|
|
5065
|
+
const callbackURL = sameOriginPath(asString(body.callbackURL).trim(), "/api/auth/raybase/provider/complete");
|
|
5053
5066
|
const { url, headers } = await startProviderRedirect({ auth, request: requestWithPendingCookie, provider, callbackURL, requestSignUp: true });
|
|
5054
5067
|
await audit(control, null, "auth.provider.pending.create", "_auth_pending", pending.pending.id, { providerId: provider.id, purpose });
|
|
5055
5068
|
const response = jsonWithSetCookie({ url, redirect: true }, pending.cookie);
|
|
@@ -5220,7 +5233,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
5220
5233
|
throw new Error("Dev sessions are local-only");
|
|
5221
5234
|
const auth = createRaybaseAuth(c.env, options.config, { passwordSecretLifecycle });
|
|
5222
5235
|
const session = await createDevSession(auth, c.req.raw, c.env, options.config);
|
|
5223
|
-
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions);
|
|
5236
|
+
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions, localSeedsInFlight);
|
|
5224
5237
|
return responseWithAuthHeaders({ ok: true, user: session.user }, session.headers);
|
|
5225
5238
|
}
|
|
5226
5239
|
catch (error) {
|
|
@@ -5439,7 +5452,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
5439
5452
|
const session = await getRuntimeSession(c.req.raw, c.env, options.config).catch(() => null)
|
|
5440
5453
|
?? await hostAgentSession(c.req.raw, c.env);
|
|
5441
5454
|
if (session && isLocal(c.env)) {
|
|
5442
|
-
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions);
|
|
5455
|
+
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions, localSeedsInFlight);
|
|
5443
5456
|
}
|
|
5444
5457
|
return session;
|
|
5445
5458
|
};
|
|
@@ -6543,7 +6556,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6543
6556
|
throw new Error("Authentication required");
|
|
6544
6557
|
}
|
|
6545
6558
|
if (session && isLocal(c.env)) {
|
|
6546
|
-
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions);
|
|
6559
|
+
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions, localSeedsInFlight);
|
|
6547
6560
|
}
|
|
6548
6561
|
if (route.auth === "admin" && session && !isAdmin(session.user, options.config)) {
|
|
6549
6562
|
throw new Error("Admin role required");
|
|
@@ -6572,7 +6585,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6572
6585
|
const data = db.for({
|
|
6573
6586
|
user: actor,
|
|
6574
6587
|
adminOverride: route.auth === "admin",
|
|
6575
|
-
audit: user ? (entry) => audit(
|
|
6588
|
+
audit: user ? (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata) : undefined,
|
|
6576
6589
|
notify: notifyRealtime(c.env),
|
|
6577
6590
|
realtime: realtimeEnabled ? realtimeConfig : undefined
|
|
6578
6591
|
});
|
|
@@ -6711,7 +6724,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6711
6724
|
return c.html(accessDeniedPage(options.config), 403);
|
|
6712
6725
|
}
|
|
6713
6726
|
if (isLocal(c.env)) {
|
|
6714
|
-
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions);
|
|
6727
|
+
await seedLocalIfNeeded(c.env, c.req.raw, session.user, runtimeOptions, localSeedsInFlight);
|
|
6715
6728
|
}
|
|
6716
6729
|
return next();
|
|
6717
6730
|
}
|
|
@@ -6851,7 +6864,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6851
6864
|
const client = db.for({
|
|
6852
6865
|
user,
|
|
6853
6866
|
adminOverride: true,
|
|
6854
|
-
audit: (entry) => audit(
|
|
6867
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
6855
6868
|
});
|
|
6856
6869
|
const ai = createRaybaseAI({
|
|
6857
6870
|
env: c.env,
|
|
@@ -6912,7 +6925,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6912
6925
|
const client = db.for({
|
|
6913
6926
|
user,
|
|
6914
6927
|
adminOverride: true,
|
|
6915
|
-
audit: (entry) => audit(
|
|
6928
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
6916
6929
|
});
|
|
6917
6930
|
const result = await reindexSearchIndex({
|
|
6918
6931
|
schema: options.schema,
|
|
@@ -6961,7 +6974,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6961
6974
|
user,
|
|
6962
6975
|
adminOverride,
|
|
6963
6976
|
adminOrgId: adminOverride ? c.req.query("adminOrgId") : undefined,
|
|
6964
|
-
audit: (entry) => audit(
|
|
6977
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
6965
6978
|
});
|
|
6966
6979
|
return c.json(await client.list(c.req.param("bucket"), storageListOptionsFromRequest(c.req.raw, adminOverride)));
|
|
6967
6980
|
}
|
|
@@ -6983,7 +6996,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
6983
6996
|
user,
|
|
6984
6997
|
adminOverride,
|
|
6985
6998
|
adminOrgId: adminOverride ? c.req.query("adminOrgId") : undefined,
|
|
6986
|
-
audit: (entry) => audit(
|
|
6999
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
6987
7000
|
});
|
|
6988
7001
|
return c.json(await client.create(c.req.param("bucket"), c.req.raw), 201);
|
|
6989
7002
|
}
|
|
@@ -7005,7 +7018,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7005
7018
|
user,
|
|
7006
7019
|
adminOverride,
|
|
7007
7020
|
adminOrgId: adminOverride ? c.req.query("adminOrgId") : undefined,
|
|
7008
|
-
audit: (entry) => audit(
|
|
7021
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
7009
7022
|
});
|
|
7010
7023
|
return await client.download(c.req.param("bucket"), c.req.param("id"));
|
|
7011
7024
|
}
|
|
@@ -7027,7 +7040,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7027
7040
|
user,
|
|
7028
7041
|
adminOverride,
|
|
7029
7042
|
adminOrgId: adminOverride ? c.req.query("adminOrgId") : undefined,
|
|
7030
|
-
audit: (entry) => audit(
|
|
7043
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
7031
7044
|
});
|
|
7032
7045
|
const file = await client.get(c.req.param("bucket"), c.req.param("id"), { includeHidden: adminOverride });
|
|
7033
7046
|
return file ? c.json(file) : jsonError(new Error("Not found"), 404);
|
|
@@ -7050,7 +7063,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7050
7063
|
user,
|
|
7051
7064
|
adminOverride,
|
|
7052
7065
|
adminOrgId: adminOverride ? c.req.query("adminOrgId") : undefined,
|
|
7053
|
-
audit: (entry) => audit(
|
|
7066
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
7054
7067
|
});
|
|
7055
7068
|
return c.json(await client.update(c.req.param("bucket"), c.req.param("id"), await jsonBody(c)));
|
|
7056
7069
|
}
|
|
@@ -7072,7 +7085,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7072
7085
|
user,
|
|
7073
7086
|
adminOverride,
|
|
7074
7087
|
adminOrgId: adminOverride ? c.req.query("adminOrgId") : undefined,
|
|
7075
|
-
audit: (entry) => audit(
|
|
7088
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
7076
7089
|
});
|
|
7077
7090
|
return c.json(await client.delete(c.req.param("bucket"), c.req.param("id")));
|
|
7078
7091
|
}
|
|
@@ -7140,7 +7153,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7140
7153
|
const client = db.for({
|
|
7141
7154
|
user: executionUser,
|
|
7142
7155
|
source: { surface: "http", route: route.path, requestId: c.req.header("cf-ray") ?? undefined, actionName: route.action.name },
|
|
7143
|
-
audit: (entry) => recordAudit(
|
|
7156
|
+
audit: (entry, auditDb) => recordAudit(auditDb, { actor: principal, action: entry.action, target: entry.target, metadata: entry.metadata, source: entry.source }),
|
|
7144
7157
|
notify: notifyRealtime(c.env),
|
|
7145
7158
|
realtime: realtimeConfig
|
|
7146
7159
|
});
|
|
@@ -7249,7 +7262,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7249
7262
|
const client = db.for({
|
|
7250
7263
|
user,
|
|
7251
7264
|
adminOverride,
|
|
7252
|
-
audit: (entry) => audit(
|
|
7265
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
7253
7266
|
});
|
|
7254
7267
|
const listOptions = listOptionsFromRequest(c.req.raw, dataSchema, c.req.param("table"));
|
|
7255
7268
|
const tableSearchIndexes = adminOverride && listOptions.search ? searchIndexesForTable(runtimeSearch, c.req.param("table")) : [];
|
|
@@ -7300,7 +7313,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7300
7313
|
const client = createRaybaseDb(c.env, adminOverride ? adminDataSchema(options.schema, manifestTables) : options.schema, options.appMigrations, runtimeDbOptions(c.env)).for({
|
|
7301
7314
|
user,
|
|
7302
7315
|
adminOverride,
|
|
7303
|
-
audit: (entry) => audit(
|
|
7316
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata),
|
|
7304
7317
|
notify: notifyRealtime(c.env),
|
|
7305
7318
|
realtime: realtimeConfig
|
|
7306
7319
|
});
|
|
@@ -7318,7 +7331,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7318
7331
|
const client = createRaybaseDb(c.env, adminOverride ? adminDataSchema(options.schema, manifestTables) : options.schema, options.appMigrations, runtimeDbOptions(c.env)).for({
|
|
7319
7332
|
user,
|
|
7320
7333
|
adminOverride,
|
|
7321
|
-
audit: (entry) => audit(
|
|
7334
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata),
|
|
7322
7335
|
notify: notifyRealtime(c.env),
|
|
7323
7336
|
realtime: realtimeConfig
|
|
7324
7337
|
});
|
|
@@ -7336,7 +7349,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
7336
7349
|
const client = createRaybaseDb(c.env, adminOverride ? adminDataSchema(options.schema, manifestTables) : options.schema, options.appMigrations, runtimeDbOptions(c.env)).for({
|
|
7337
7350
|
user,
|
|
7338
7351
|
adminOverride,
|
|
7339
|
-
audit: (entry) => audit(
|
|
7352
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata),
|
|
7340
7353
|
notify: notifyRealtime(c.env),
|
|
7341
7354
|
realtime: realtimeConfig
|
|
7342
7355
|
});
|
|
@@ -10996,7 +11009,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
10996
11009
|
const control = raybaseAuthExecutor(c.env);
|
|
10997
11010
|
const client = createRaybaseDb(c.env, options.schema, options.appMigrations, runtimeDbOptions(c.env)).for({
|
|
10998
11011
|
user,
|
|
10999
|
-
audit: (entry) => audit(
|
|
11012
|
+
audit: (entry, auditDb) => audit(auditDb, actorId(user), entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata),
|
|
11000
11013
|
notify: notifyRealtime(c.env),
|
|
11001
11014
|
realtime: realtimeConfig
|
|
11002
11015
|
});
|
|
@@ -11238,7 +11251,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
11238
11251
|
const request = new Request(`https://raybase.local/api/raybase/agents/${encodeURIComponent(agent.name)}/follow-ups/${encodeURIComponent(row.id)}/lapse`);
|
|
11239
11252
|
const client = createRaybaseDb(env, options.schema, options.appMigrations, runtimeDbOptions(env)).for({
|
|
11240
11253
|
user: serviceUser,
|
|
11241
|
-
audit: (entry) => auditTagged(
|
|
11254
|
+
audit: (entry, auditDb) => auditTagged(auditDb, actor, actor, entry.action, entry.target.type, entry.target.id ?? undefined, entry.metadata)
|
|
11242
11255
|
});
|
|
11243
11256
|
const agents = createAgentInvocationRuntime({
|
|
11244
11257
|
env,
|
|
@@ -11517,7 +11530,7 @@ function createRaybaseRuntimeHandlers(options, runtimeProfile, resolvedModules =
|
|
|
11517
11530
|
user: executionUser,
|
|
11518
11531
|
// A service job acts as that service, so fromService(name) policies match it.
|
|
11519
11532
|
...(runAs.kind === "service" ? { principal: runAs } : {}),
|
|
11520
|
-
audit: (entry) => auditTagged(
|
|
11533
|
+
audit: (entry, auditDb) => auditTagged(auditDb, actor, runAs, entry.action, entry.target.type, entry.target.id ?? undefined, {
|
|
11521
11534
|
...(entry.metadata && typeof entry.metadata === "object" ? entry.metadata : { value: entry.metadata }),
|
|
11522
11535
|
jobRunId: run.id,
|
|
11523
11536
|
jobName: job.name
|
|
@@ -13012,13 +13025,30 @@ function createRaybaseAgentStaticRuntime(options, resolvedModules, runtimeProfil
|
|
|
13012
13025
|
})
|
|
13013
13026
|
};
|
|
13014
13027
|
}
|
|
13015
|
-
|
|
13028
|
+
/**
|
|
13029
|
+
* Runs the app's local seed the first time a signed-in request reaches a local
|
|
13030
|
+
* database. Simultaneous first requests (a page that opens a widget lists and
|
|
13031
|
+
* starts conversations at once) share one run: the first starts it, the rest
|
|
13032
|
+
* wait for it, rather than each seeding and colliding on the seed's users. A
|
|
13033
|
+
* failed run is not remembered, so the next request tries again.
|
|
13034
|
+
*/
|
|
13035
|
+
async function seedLocalIfNeeded(env, request, user, options, inFlight) {
|
|
13016
13036
|
if (!options.seed)
|
|
13017
13037
|
return;
|
|
13018
|
-
const
|
|
13019
|
-
const
|
|
13020
|
-
if (
|
|
13021
|
-
return;
|
|
13022
|
-
|
|
13038
|
+
const key = `${raybaseRuntimeSettingsAppId(env)}\0${raybaseRuntimeScope(env)?.scopeId ?? "default"}`;
|
|
13039
|
+
const running = inFlight.get(key);
|
|
13040
|
+
if (running)
|
|
13041
|
+
return running;
|
|
13042
|
+
const run = (async () => {
|
|
13043
|
+
const control = raybaseAuthExecutor(env);
|
|
13044
|
+
const existing = await control.first(`SELECT "key" FROM "_state" WHERE "key" = ?`, [localSeedStateKey]);
|
|
13045
|
+
if (existing)
|
|
13046
|
+
return;
|
|
13047
|
+
await runLocalSeed(env, request, user, options);
|
|
13048
|
+
})().finally(() => {
|
|
13049
|
+
inFlight.delete(key);
|
|
13050
|
+
});
|
|
13051
|
+
inFlight.set(key, run);
|
|
13052
|
+
return run;
|
|
13023
13053
|
}
|
|
13024
13054
|
//# sourceMappingURL=worker.js.map
|