@k2b/cloud 0.47.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/_internal/app-access-manager-sql.ts +10 -0
- package/src/_internal/app-access-resources.ts +2 -1
- package/src/_internal/app-capabilities.ts +73 -0
- package/src/_internal/app-event-catalog.ts +1 -1
- package/src/_internal/app-queries.ts +1 -1
- package/src/_internal/application-package.ts +2 -1
- package/src/_internal/bounded-json.ts +7 -1
- package/src/_internal/capabilities.ts +25 -2
- package/src/_internal/define-app.ts +33 -2
- package/src/_internal/heartbeat.ts +2 -0
- package/src/_internal/nats-connection.ts +10 -9
- package/src/_internal/process-sync.ts +6 -6
- package/src/_internal/public-surface.ts +76 -0
- package/src/_internal/purpose-name.ts +7 -0
- package/src/_internal/registry-validation.ts +1 -0
- package/src/_internal/registry.ts +49 -3
- package/src/_internal/workload-credential.ts +2 -1
- package/src/ai/app-skill-store.ts +2 -1
- package/src/ai/app-skills.ts +2 -1
- package/src/ai/approvals.ts +2 -1
- package/src/ai/chat-tasks.ts +2 -1
- package/src/ai/credentials.ts +2 -1
- package/src/ai/dictation-runtime.ts +1 -1
- package/src/ai/dictations.ts +1 -1
- package/src/ai/files-store.ts +2 -1
- package/src/ai/inference-calls.ts +2 -1
- package/src/ai/map-store.ts +1 -1
- package/src/ai/map-tool.ts +1 -1
- package/src/ai/memories.ts +1 -1
- package/src/ai/memory-learning-runs.ts +1 -1
- package/src/ai/memory-learning.ts +1 -1
- package/src/ai/memory-workflow-evidence.ts +1 -1
- package/src/ai/message-queue.ts +2 -1
- package/src/ai/migrate.ts +1 -1
- package/src/ai/model-access-migrate.ts +1 -1
- package/src/ai/model-access.ts +1 -1
- package/src/ai/model-catalog.ts +1 -1
- package/src/ai/model-delete.ts +1 -1
- package/src/ai/model-usage.ts +2 -1
- package/src/ai/open-questions.ts +1 -1
- package/src/ai/openai-api-slots.ts +2 -1
- package/src/ai/prefs.ts +2 -1
- package/src/ai/projects.ts +2 -1
- package/src/ai/provider-connections.ts +1 -1
- package/src/ai/quota-limits.ts +2 -1
- package/src/ai/quota-provider.ts +2 -1
- package/src/ai/quota-report.ts +2 -1
- package/src/ai/quotas-migrate.ts +2 -1
- package/src/ai/quotas.ts +2 -1
- package/src/ai/request-headers.ts +2 -1
- package/src/ai/review-content.ts +2 -1
- package/src/ai/skill-search.ts +2 -1
- package/src/ai/skills.ts +2 -1
- package/src/ai/store.ts +2 -1
- package/src/ai/structured-runs.ts +2 -1
- package/src/ai/tool-audit.ts +2 -1
- package/src/ai/turn-timing.ts +1 -1
- package/src/ai/usage.ts +2 -1
- package/src/ai/web-provenance.ts +2 -1
- package/src/api/admin-ai-quotas.ts +1 -1
- package/src/api/admin-ai.ts +1 -1
- package/src/api/admin-app-domains.ts +62 -0
- package/src/api/admin-app-keys.ts +47 -3
- package/src/api/admin-core-settings.ts +1 -1
- package/src/api/admin-outgoing-mail.ts +1 -1
- package/src/api/app-bootstrap.ts +153 -0
- package/src/api/app-events.ts +1 -1
- package/src/api/auth.ts +1 -1
- package/src/api/authenticate-app-request.ts +129 -0
- package/src/api/capabilities.ts +87 -6
- package/src/api/index.ts +7 -0
- package/src/api/me.ts +1 -1
- package/src/api/search.bench.ts +1 -1
- package/src/app-pwa/service.ts +2 -1
- package/src/app-pwa/transaction.ts +4 -2
- package/src/capabilities/claims.ts +2 -1
- package/src/capabilities/executions.ts +8 -4
- package/src/capabilities/geo-client.ts +1 -1
- package/src/capabilities/migrate.ts +3 -1
- package/src/capabilities/resource-readers.ts +2 -2
- package/src/capabilities/response.ts +2 -1
- package/src/capabilities/server-invoke.ts +73 -20
- package/src/capabilities/server.ts +2 -1
- package/src/cli/admin/app-domains.ts +140 -0
- package/src/cli/admin/app-keys.ts +25 -3
- package/src/cli/admin/index.ts +107 -88
- package/src/config/env.ts +10 -4
- package/src/contracts/app-domains.ts +91 -0
- package/src/contracts/app-status.ts +104 -0
- package/src/contracts/capabilities.ts +37 -2
- package/src/contracts/index.ts +1 -0
- package/src/contracts/outgoing-mail.ts +1 -1
- package/src/contracts/registry.ts +2 -0
- package/src/events/app-event-delivery.ts +1 -1
- package/src/events/live-delivery.ts +2 -1
- package/src/index.ts +1 -0
- package/src/runtime/bootstrap-client.ts +195 -0
- package/src/runtime/bootstrap-protocol.ts +67 -0
- package/src/runtime/clients.ts +6 -2
- package/src/runtime/connections.ts +9 -0
- package/src/server/app-key.ts +14 -0
- package/src/server/index.ts +2 -0
- package/src/server/ratelimit.ts +1 -1
- package/src/server/services/access.ts +2 -1
- package/src/services/account-category-policy.ts +1 -1
- package/src/services/account-lifecycle/audit.ts +1 -1
- package/src/services/account-lifecycle/index.ts +1 -1
- package/src/services/account-lifecycle/ipa-backfill.ts +2 -1
- package/src/services/accounts/app.ts +1 -1
- package/src/services/accounts/avatar.ts +1 -1
- package/src/services/accounts/base-group.ts +1 -1
- package/src/services/accounts/directory-shares.ts +1 -1
- package/src/services/accounts/duplicate-emails.ts +1 -1
- package/src/services/accounts/entities.ts +2 -1
- package/src/services/accounts/group-sql.ts +2 -1
- package/src/services/accounts/groups.ts +1 -1
- package/src/services/accounts/identities.ts +13 -11
- package/src/services/accounts/ipa-data.ts +1 -1
- package/src/services/accounts/local-groups.ts +2 -1
- package/src/services/accounts/machine-group-management.ts +2 -1
- package/src/services/accounts/posix.ts +13 -12
- package/src/services/accounts/request-policy.ts +2 -1
- package/src/services/accounts/switching.ts +1 -1
- package/src/services/accounts/users.ts +2 -1
- package/src/services/announcements/index.ts +1 -1
- package/src/services/app-access-management.ts +3 -9
- package/src/services/app-access.ts +2 -1
- package/src/services/app-admin-facts.ts +160 -0
- package/src/services/app-approval.ts +34 -30
- package/src/services/app-bootstrap.ts +217 -0
- package/src/services/app-details.ts +3 -2
- package/src/services/app-domain-check.ts +152 -0
- package/src/services/app-domains.ts +172 -0
- package/src/services/app-events/accept.ts +5 -5
- package/src/services/app-events/admin.ts +15 -15
- package/src/services/app-events/declarations.ts +6 -3
- package/src/services/app-events/deliver.ts +6 -6
- package/src/services/app-events.ts +3 -2
- package/src/services/app-keys.ts +45 -11
- package/src/services/approvals/content.ts +1 -1
- package/src/services/approvals/index.ts +2 -1
- package/src/services/approvals/list.ts +1 -1
- package/src/services/approvals/migrate.ts +1 -1
- package/src/services/audit/index.ts +2 -1
- package/src/services/auth-flows/ipa.ts +1 -1
- package/src/services/auth-flows/magic-link.ts +1 -1
- package/src/services/auth-flows/password-reset.ts +1 -1
- package/src/services/auth-flows/proxy-return.ts +1 -1
- package/src/services/downstream-budget.ts +2 -2
- package/src/services/geo/admin.ts +13 -12
- package/src/services/geo/identity.ts +46 -0
- package/src/services/geo/ledger.ts +118 -106
- package/src/services/geo/migrate.ts +2 -1
- package/src/services/geo/route-chain.ts +3 -3
- package/src/services/geo/service.ts +4 -24
- package/src/services/geoip/index.ts +5 -5
- package/src/services/geoip/store.ts +24 -21
- package/src/services/help/index.ts +2 -1
- package/src/services/help/store.ts +2 -1
- package/src/services/identity/app-request.ts +44 -0
- package/src/services/identity/constants.ts +1 -0
- package/src/services/identity/index.ts +1 -0
- package/src/services/identity/invocation-actor.ts +2 -1
- package/src/services/identity/invocation-token.ts +112 -0
- package/src/services/identity/key-ring.ts +2 -2
- package/src/services/identity/resource-readers.ts +1 -1
- package/src/services/identity/routes.ts +11 -3
- package/src/services/identity/runtime-config.ts +14 -3
- package/src/services/identity/workload-auth.ts +2 -0
- package/src/services/identity/workload-runtime.ts +3 -3
- package/src/services/index.ts +4 -0
- package/src/services/ipa/groups.ts +1 -1
- package/src/services/ipa/profile.ts +1 -1
- package/src/services/ipa/search.ts +1 -1
- package/src/services/ipa/sync.ts +1 -1
- package/src/services/ipa/users.ts +1 -1
- package/src/services/known-browsers.ts +2 -1
- package/src/services/legal-consent.ts +1 -1
- package/src/services/links/index.ts +16 -0
- package/src/services/links/runtime.ts +44 -0
- package/src/services/links/store.ts +105 -0
- package/src/services/logging/index.ts +13 -8
- package/src/services/logging/redaction.ts +6 -1
- package/src/services/logging/trace.ts +9 -9
- package/src/services/logging/web-vitals.ts +1 -1
- package/src/services/mandates/index.ts +2 -1
- package/src/services/notifications/batches.ts +1 -1
- package/src/services/notifications/browser.ts +1 -1
- package/src/services/notifications/catalog.ts +1 -1
- package/src/services/notifications/dispatcher.ts +1 -1
- package/src/services/notifications/index.ts +1 -1
- package/src/services/notifications/observability.ts +2 -1
- package/src/services/notifications/platform.ts +1 -1
- package/src/services/notifications/quiet.ts +1 -1
- package/src/services/notifications/user.ts +1 -1
- package/src/services/oauth-tokens.ts +1 -1
- package/src/services/outbox.ts +15 -14
- package/src/services/outgoing-mail/admin.ts +1 -1
- package/src/services/outgoing-mail/dispatcher.ts +1 -1
- package/src/services/outgoing-mail/drain.ts +2 -1
- package/src/services/outgoing-mail/enqueue.ts +2 -1
- package/src/services/outgoing-mail/messages.ts +2 -1
- package/src/services/outgoing-mail/retention.ts +1 -1
- package/src/services/outgoing-mail/send.ts +1 -1
- package/src/services/outgoing-mail/store.ts +2 -1
- package/src/services/panel-context-consent.ts +32 -28
- package/src/services/providers/local/auth.ts +1 -1
- package/src/services/providers/local/users.ts +1 -1
- package/src/services/pwa-devices.ts +2 -1
- package/src/services/rail-preferences.ts +16 -12
- package/src/services/rail-shortcuts.ts +12 -10
- package/src/services/request-cache-redis.ts +3 -3
- package/src/services/service-account-credentials.ts +2 -1
- package/src/services/service-accounts.ts +2 -1
- package/src/services/session/index.ts +2 -1
- package/src/services/session/user.ts +2 -1
- package/src/services/settings/core-settings.ts +20 -0
- package/src/services/settings/crypto.ts +2 -2
- package/src/services/settings/index.ts +1 -1
- package/src/services/settings/store.ts +6 -1
- package/src/services/settings/versions.ts +2 -1
- package/src/services/weather/forecast.ts +2 -1
- package/src/services/weather/locations.ts +1 -1
- package/src/services/weather/migrate.ts +2 -1
- package/src/services/weather/short-id.ts +2 -1
- package/src/services/webauthn.ts +1 -1
- package/src/ssr/admin-navigation.ts +0 -1
- package/src/ssr/compact-shell.browser-harness.ts +2 -0
- package/src/ssr/platform-messages.ts +0 -2
- package/src/start.ts +35 -14
- package/src/workflows/ai/store.ts +2 -1
- package/src/workflows/store/budget.ts +2 -1
- package/src/workflows/store/definitions.ts +2 -1
- package/src/workflows/store/events.ts +2 -1
- package/src/workflows/store/observability.ts +2 -1
- package/src/workflows/store/retention.ts +2 -1
- package/src/workflows/store/runs.ts +2 -1
- package/src/workflows/store/transaction.ts +2 -1
- package/src/workflows/store/worker.ts +2 -1
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* env-backed entries into Postgres. Startup never replaces an existing row;
|
|
10
10
|
* env bootstrap only fills missing keys.
|
|
11
11
|
*/
|
|
12
|
+
import { redis, sql } from "../../runtime/clients";
|
|
12
13
|
|
|
13
|
-
import { redis, sql } from "bun";
|
|
14
14
|
import { bindSettingValue, replaceSettingValue, unwrapSettingValue } from "./binding";
|
|
15
15
|
import { decryptValue, encryptValue, getAppSecret } from "./crypto";
|
|
16
16
|
import { resolveSettingPresentation, SETTINGS, SETTINGS_MAP, type SettingDef, validateSettingValue } from "./defaults";
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* snapshot exposed via `c.get("settings")` (built by snapshot.ts middleware).
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { sql } from "bun";
|
|
17
16
|
import { HTTPException } from "hono/http-exception";
|
|
18
17
|
import { hasRole, type User } from "../../contracts/shared";
|
|
18
|
+
import { sql } from "../../runtime/clients";
|
|
19
|
+
import { connections } from "../../runtime/connections";
|
|
19
20
|
import { claimCacheFill, completeCacheFill, MISSING_SETTING } from "../cache-fill";
|
|
20
21
|
import { stripImageDataUrlMetadata } from "../image-metadata";
|
|
21
22
|
import { toPgTextArray } from "../postgres";
|
|
@@ -89,6 +90,8 @@ export const readKeyState = async (key: string, db: SqlClient = sql): Promise<Se
|
|
|
89
90
|
export const bulkRead = async (keys: readonly string[]): Promise<Map<string, unknown>> => {
|
|
90
91
|
const result = new Map<string, unknown>();
|
|
91
92
|
if (keys.length === 0) return result;
|
|
93
|
+
// Missing startup is a programming error, never a cache outage or unreadable row.
|
|
94
|
+
connections();
|
|
92
95
|
// Bound access is read with its endpoint in one database snapshot. Never
|
|
93
96
|
// resolve it from an independently cached secret.
|
|
94
97
|
const boundKeys = keys.filter((key) => settingOwners(key).length > 0);
|
|
@@ -163,6 +166,7 @@ export const bulkRead = async (keys: readonly string[]): Promise<Map<string, unk
|
|
|
163
166
|
export const readStates = async (keys: readonly string[], db: SqlClient = sql): Promise<Map<string, SettingRead>> => {
|
|
164
167
|
const result = new Map<string, SettingRead>();
|
|
165
168
|
if (keys.length === 0) return result;
|
|
169
|
+
connections();
|
|
166
170
|
const snapshotKeys = [...new Set(keys.flatMap((key) => [key, ...settingOwners(key).map((owner) => owner.key)]))];
|
|
167
171
|
const rows = await db<StoredRow[]>`SELECT key, value FROM settings.entries WHERE key = ANY(${toPgTextArray(snapshotKeys)}::text[])`;
|
|
168
172
|
const byKey = new Map(rows.map((row) => [row.key, row]));
|
|
@@ -206,6 +210,7 @@ const knownKeysWith = (extraKnownKeys: readonly string[]) =>
|
|
|
206
210
|
Array.from(new Set([...allKnownKeys(), ...retainedLegacyKeys, ...extraKnownKeys]));
|
|
207
211
|
|
|
208
212
|
export const listLegacyKeys = async (extraKnownKeys: readonly string[] = []): Promise<LegacySettingRow[]> => {
|
|
213
|
+
connections();
|
|
209
214
|
const knownKeys = knownKeysWith(extraKnownKeys);
|
|
210
215
|
const rows = await sql<LegacyStoredRow[]>`
|
|
211
216
|
SELECT key, value, updated_at
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { redis } from "
|
|
1
|
+
import { redis } from "../../runtime/clients";
|
|
2
|
+
|
|
2
3
|
import { logger } from "../logging";
|
|
3
4
|
import { coreSettings } from "../settings/api";
|
|
4
5
|
import type { CurrentWeather, DailyForecast, HourlyForecast, WeatherData, WeatherIcon } from "./types";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { err, fail, ok, type PageParams, type Paginated, paginate, type Result } from "@k2b/stdlib";
|
|
2
|
-
import { sql } from "bun";
|
|
3
2
|
import type { GeoProvenance } from "../../contracts/geo";
|
|
3
|
+
import { sql } from "../../runtime/clients";
|
|
4
4
|
import { logger } from "../logging";
|
|
5
5
|
import { withWeatherLocationShortId } from "./short-id";
|
|
6
6
|
|
package/src/services/webauthn.ts
CHANGED
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
verifyRegistrationResponse,
|
|
11
11
|
type WebAuthnCredential,
|
|
12
12
|
} from "@simplewebauthn/server";
|
|
13
|
-
import { redis, sql } from "bun";
|
|
14
13
|
import type { User, WebAuthnPasskey } from "../contracts/shared";
|
|
14
|
+
import { redis, sql } from "../runtime/clients";
|
|
15
15
|
import { accounts } from "./accounts";
|
|
16
16
|
import { audit } from "./audit";
|
|
17
17
|
import { logger } from "./logging";
|
|
@@ -70,7 +70,6 @@ export const buildAdminGroups = (apps: readonly RuntimeContext["apps"][number][]
|
|
|
70
70
|
links: [
|
|
71
71
|
{ href: "/admin", icon: "ti-dashboard", label: t.overview },
|
|
72
72
|
{ href: "/admin/apps", icon: "ti-apps", label: t.apps },
|
|
73
|
-
{ href: "/admin/app-credentials", icon: "ti-key", label: t.appCredentials },
|
|
74
73
|
{ href: "/admin/rail", icon: "ti-layout-sidebar", label: t.rail },
|
|
75
74
|
{ href: "/admin/announcements", icon: "ti-speakerphone", label: t.announcements },
|
|
76
75
|
],
|
|
@@ -23,6 +23,7 @@ const { defineApp } = await import("../_internal/define-app");
|
|
|
23
23
|
const { person } = await import("../_internal/define-app.test-fixture");
|
|
24
24
|
const railSnapshot = await import("../services/rail-snapshot");
|
|
25
25
|
const settingsMiddleware = await import("../server/middleware/settings");
|
|
26
|
+
const help = await import("./help");
|
|
26
27
|
const { defaultRailPreferences } = await import("../contracts/rail-preferences");
|
|
27
28
|
const { default: WorkspaceNavigation } = await import("./WorkspaceNavigation.island");
|
|
28
29
|
const { default: Layout } = await import("./Layout");
|
|
@@ -367,6 +368,7 @@ export function installCompactShellHarness(launch: typeof launchBrowser) {
|
|
|
367
368
|
spies.push(
|
|
368
369
|
spyOn(railSnapshot, "readRailSnapshot").mockResolvedValue(defaultRailPreferences()),
|
|
369
370
|
spyOn(settingsMiddleware, "preloadLayoutAnnouncements").mockResolvedValue(undefined),
|
|
371
|
+
spyOn(help, "preloadLayoutHelp").mockResolvedValue(null),
|
|
370
372
|
);
|
|
371
373
|
const build = await Bun.build({ entrypoints: [resolve(import.meta.dir, "../../../../styles.css")], plugins: [tailwind] });
|
|
372
374
|
if (!build.success) throw new AggregateError(build.logs, "Could not compile the global stylesheet.");
|
|
@@ -40,7 +40,6 @@ export const platformMessages = i18n.define({
|
|
|
40
40
|
general: "General",
|
|
41
41
|
rail: "App bar",
|
|
42
42
|
announcements: "Announcements",
|
|
43
|
-
appCredentials: "App credentials",
|
|
44
43
|
ai: "AI",
|
|
45
44
|
observability: "Observability",
|
|
46
45
|
baseSettings: "Base settings",
|
|
@@ -147,7 +146,6 @@ export const platformMessages = i18n.define({
|
|
|
147
146
|
general: "Allgemein",
|
|
148
147
|
rail: "App-Leiste",
|
|
149
148
|
announcements: "Ankündigungen",
|
|
150
|
-
appCredentials: "App-Schlüssel",
|
|
151
149
|
ai: "KI",
|
|
152
150
|
observability: "Observability",
|
|
153
151
|
baseSettings: "Grundeinstellungen",
|
package/src/start.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// Keep this entry independent of the platform barrel and application modules.
|
|
2
|
+
import { parseAppKey } from "./app-key";
|
|
3
|
+
import { env } from "./config/env";
|
|
4
|
+
import { bootstrapConnections } from "./runtime/bootstrap-client";
|
|
5
|
+
import type { BootstrapResponse } from "./runtime/bootstrap-protocol";
|
|
2
6
|
import { initializeClients } from "./runtime/clients";
|
|
3
7
|
import { bindConnections, hasConnections } from "./runtime/connections";
|
|
4
8
|
import { resolveConnections } from "./runtime/resolve-connections";
|
|
@@ -9,24 +13,41 @@ export type PlatformStartOptions = {
|
|
|
9
13
|
source?: "env";
|
|
10
14
|
};
|
|
11
15
|
|
|
16
|
+
let initializing = false;
|
|
17
|
+
|
|
12
18
|
/** Initialize before importing any application module, also in dev and data workers. */
|
|
13
19
|
export const initializePlatform = async ({ appId, source }: PlatformStartOptions): Promise<void> => {
|
|
14
20
|
if (!/^[a-z][a-z0-9-]{0,79}$/.test(appId)) throw new Error("Platform start requires a valid appId");
|
|
15
|
-
if (hasConnections()) throw new Error("Platform has already started");
|
|
16
|
-
|
|
17
|
-
// Slice 6b seam: validate the app key and fetch missing values from Core here,
|
|
18
|
-
// then pass the typed response to resolveConnections({ appId, core }).
|
|
19
|
-
// A present key must never silently fall back to the legacy env mode.
|
|
20
|
-
if (source !== "env" && (process.env.CLOUD_APP_KEY?.trim() || process.env.CLOUD_APP_KEY_FILE?.trim())) {
|
|
21
|
-
throw new Error("Core connection bootstrap is not available yet");
|
|
22
|
-
}
|
|
23
|
-
const resolved = resolveConnections({ appId });
|
|
24
|
-
bindConnections(resolved);
|
|
21
|
+
if (initializing || hasConnections()) throw new Error("Platform has already started");
|
|
22
|
+
initializing = true;
|
|
25
23
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const keyValue = env.CLOUD_APP_KEY;
|
|
25
|
+
const envOnly = source === "env" || appId === "core" || appId === "gateway";
|
|
26
|
+
if (keyValue && envOnly) throw new Error("App keys are forbidden in forced env mode (including Core and Gateway)");
|
|
27
|
+
let bootstrap: BootstrapResponse | undefined;
|
|
28
|
+
if (keyValue) {
|
|
29
|
+
// Parsing never prints the private value. A present invalid key cannot fall back to env.
|
|
30
|
+
const key = parseAppKey(keyValue);
|
|
31
|
+
if (key.appId !== appId) throw new Error("App-key appId does not match the declared application");
|
|
32
|
+
bootstrap = await bootstrapConnections(key, env.CLOUD_CORE_INTERNAL_ORIGIN);
|
|
33
|
+
}
|
|
34
|
+
const resolved = resolveConnections({ appId, core: bootstrap?.connections });
|
|
35
|
+
resolved.bootstrap = {
|
|
36
|
+
mode: bootstrap ? "core" : "env",
|
|
37
|
+
...(bootstrap ? { keyId: bootstrap.identity.keyId } : {}),
|
|
38
|
+
sources: resolved.sources,
|
|
39
|
+
keyFormat: "cloud-app-key-v1",
|
|
40
|
+
protocol: 1,
|
|
41
|
+
};
|
|
42
|
+
bindConnections(resolved);
|
|
43
|
+
try {
|
|
44
|
+
await initializeClients();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
bindConnections(undefined);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
} finally {
|
|
50
|
+
initializing = false;
|
|
30
51
|
}
|
|
31
52
|
};
|
|
32
53
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SQL } from "bun";
|
|
2
2
|
import { AI_TASK_REQUEST_MAX_BYTES, AiTaskInputTooLargeError, assertAiTaskRequestSize } from "../../ai/task-contracts";
|
|
3
|
+
import { sql } from "../../runtime/clients";
|
|
3
4
|
import type { AccessSubject } from "../../server/services/access";
|
|
4
5
|
import { type AiResolvedModelRef, AiResolvedModelRefSchema } from "../../shared/ai-models";
|
|
5
6
|
import type { WorkflowJsonValue } from "../contracts";
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* rather than something a hash has to detect — whatever the plan turns out to
|
|
17
17
|
* do, it still cannot exceed what was approved.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import type { SQL } from "bun";
|
|
20
|
+
import { sql } from "../../runtime/clients";
|
|
20
21
|
import { withTransaction } from "./transaction";
|
|
21
22
|
|
|
22
23
|
/** Caps keyed by dimension — `{ emails: 100, httpRequests: 50 }`. */
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* edit, and an activation that pins one cannot be left pointing at a plan that
|
|
10
10
|
* no longer exists.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import type { SQL } from "bun";
|
|
13
|
+
import { sql } from "../../runtime/clients";
|
|
13
14
|
import type { WorkflowBoundPlan, WorkflowDiagnostic, WorkflowJsonValue } from "../contracts";
|
|
14
15
|
import { validateWorkflowEffectBudget } from "./budget";
|
|
15
16
|
import { withTransaction } from "./transaction";
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* is an event. Nothing needs its own registration path.
|
|
12
12
|
*/
|
|
13
13
|
import { Buffer } from "node:buffer";
|
|
14
|
-
import {
|
|
14
|
+
import type { SQL } from "bun";
|
|
15
|
+
import { sql } from "../../runtime/clients";
|
|
15
16
|
import type { WorkflowJsonValue } from "../contracts";
|
|
16
17
|
import { createWorkflowRun } from "./runs";
|
|
17
18
|
import { withTransaction } from "./transaction";
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* matched nothing and said nothing, and a run that started long after the
|
|
12
12
|
* occurrence that caused it.
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import type { SQL } from "bun";
|
|
15
|
+
import { sql } from "../../runtime/clients";
|
|
15
16
|
import type { WorkflowInvocationMode, WorkflowJsonValue, WorkflowRunState } from "../contracts";
|
|
16
17
|
import type { WorkflowEffectBudget } from "./budget";
|
|
17
18
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SQL } from "bun";
|
|
2
|
+
import { sql } from "../../runtime/clients";
|
|
2
3
|
import { logger } from "../../services/logging";
|
|
3
4
|
import { toPgUuidArray } from "../../services/postgres";
|
|
4
5
|
import { withTransaction } from "./transaction";
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* that lost its lease writes with a stale generation and every one of its
|
|
17
17
|
* updates matches zero rows. Nothing here trusts wall-clock ordering.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import type { SQL } from "bun";
|
|
20
|
+
import { sql } from "../../runtime/clients";
|
|
20
21
|
import type { WorkflowBoundPlan, WorkflowDependency, WorkflowInvocationMode, WorkflowJsonValue, WorkflowRunState } from "../contracts";
|
|
21
22
|
import type {
|
|
22
23
|
WorkflowCoordinatorFinishState,
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* handle only has `savepoint` when it *is* a transaction, which is what makes
|
|
11
11
|
* this reliable rather than a convention callers have to remember.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import type { SQL } from "bun";
|
|
14
|
+
import { sql } from "../../runtime/clients";
|
|
14
15
|
|
|
15
16
|
type Savepointed = SQL & { savepoint: <T>(fn: (tx: SQL) => Promise<T>) => Promise<T> };
|
|
16
17
|
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* about *when* something runs, *which* plan it runs, and what happens if the
|
|
12
12
|
* process dies belongs here.
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import type { SQL } from "bun";
|
|
15
|
+
import { sql } from "../../runtime/clients";
|
|
15
16
|
import type { WorkflowActor, WorkflowInvocationMode, WorkflowJsonValue } from "../contracts";
|
|
16
17
|
import { hashWorkflowJson } from "../language/canonical";
|
|
17
18
|
import type { DefinedWorkflowModule } from "../module";
|