@agent-native/core 0.198.3-nightly-20260930124743 → 0.198.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/cli/create-tui.js +31 -9
  2. package/dist/cli/create.js +14 -0
  3. package/dist/cli/design-connect.js +10 -2
  4. package/dist/cli/migration-codemod.js +2 -1
  5. package/dist/cli/skills.js +15 -32
  6. package/dist/cli/upgrade.d.ts +3 -2
  7. package/dist/cli/upgrade.js +3 -0
  8. package/dist/cli/workspacify.js +1 -1
  9. package/dist/collab/struct-routes.d.ts +1 -1
  10. package/dist/db/client.d.ts +3 -0
  11. package/dist/db/client.js +7 -4
  12. package/dist/db/create-get-db.js +478 -3
  13. package/dist/deploy/workspace-deploy.js +18 -5
  14. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  15. package/dist/jobs/actions/manage-recurring-job.d.ts +1 -1
  16. package/dist/localization/core-messages/supplemental/ar-SA.js +2 -0
  17. package/dist/localization/core-messages/supplemental/de-DE.js +2 -0
  18. package/dist/localization/core-messages/supplemental/en-US.js +2 -0
  19. package/dist/localization/core-messages/supplemental/es-ES.js +2 -0
  20. package/dist/localization/core-messages/supplemental/fr-FR.js +2 -0
  21. package/dist/localization/core-messages/supplemental/hi-IN.js +2 -0
  22. package/dist/localization/core-messages/supplemental/ja-JP.js +2 -0
  23. package/dist/localization/core-messages/supplemental/ko-KR.js +2 -0
  24. package/dist/localization/core-messages/supplemental/pt-BR.js +2 -0
  25. package/dist/localization/core-messages/supplemental/zh-CN.js +2 -0
  26. package/dist/localization/core-messages/supplemental/zh-TW.js +2 -0
  27. package/dist/localization/mcp-settings-messages.d.ts +2 -0
  28. package/dist/mcp/connect-route.js +57 -10
  29. package/dist/mcp/oauth-route.js +4 -21
  30. package/dist/mcp/org-choice.d.ts +26 -0
  31. package/dist/mcp/org-choice.js +36 -0
  32. package/dist/observability/routes.d.ts +1 -1
  33. package/dist/org/handlers.d.ts +1 -1
  34. package/dist/org/index.d.ts +1 -1
  35. package/dist/org/index.js +1 -1
  36. package/dist/provider-api/actions/custom-provider-registration.d.ts +10 -10
  37. package/dist/provider-api/actions/provider-api.d.ts +12 -12
  38. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  39. package/dist/resources/handlers.d.ts +1 -1
  40. package/dist/secrets/routes.d.ts +10 -10
  41. package/dist/server/agent-engine-default-model-route.d.ts +2 -2
  42. package/dist/server/agent-engine-ollama-models-route.d.ts +2 -2
  43. package/dist/server/credential-provider.js +5 -0
  44. package/dist/sharing/access.js +4 -3
  45. package/dist/vite/client.js +11 -3
  46. package/package.json +4 -4
@@ -253,18 +253,37 @@ function fitRows(items, activeIndex, rows) {
253
253
  const start = Math.max(0, Math.min(activeIndex - rows + 1, items.length - rows));
254
254
  return items.slice(start, start + rows);
255
255
  }
256
+ // Ink hands every key in one stdin chunk to the same input handler before
257
+ // React re-renders, so an input handler must read `latest` and update through
258
+ // the setter: the rendered value is stale from the chunk's second key on.
259
+ function useKeypressState(initial) {
260
+ const [rendered, setRendered] = React.useState(initial);
261
+ const latest = React.useRef(rendered);
262
+ const update = (next) => {
263
+ latest.current = next(latest.current);
264
+ setRendered(latest.current);
265
+ };
266
+ return [rendered, update, latest];
267
+ }
268
+ function wizardChoices(state, installedApps) {
269
+ const apps = availableTemplates(state.kind, installedApps);
270
+ const choices = state.step === "start" ? START_CHOICES : apps;
271
+ return {
272
+ multiSelect: state.kind === "chat-workspace" ||
273
+ state.kind === "first-party" ||
274
+ state.kind === "workspace-add",
275
+ apps,
276
+ required: new Set(requiredTemplateNames(state.kind)),
277
+ choices,
278
+ };
279
+ }
256
280
  export function CreateWizard({ options, onFinish, }) {
257
281
  const { exit } = useApp();
258
282
  const { stdout } = useStdout();
259
- const [state, setState] = React.useState(() => initialWizardState(options));
283
+ const [state, setState, latest] = useKeypressState(() => initialWizardState(options));
260
284
  const terminalColumns = Math.max(16, stdout.columns ?? 80);
261
285
  const terminalRows = Math.max(14, stdout.rows ?? 24);
262
- const multiSelect = state.kind === "chat-workspace" ||
263
- state.kind === "first-party" ||
264
- state.kind === "workspace-add";
265
- const apps = availableTemplates(state.kind, options.installedApps ?? []);
266
- const required = new Set(requiredTemplateNames(state.kind));
267
- const choices = state.step === "start" ? START_CHOICES : apps;
286
+ const { multiSelect, required, choices } = wizardChoices(state, options.installedApps ?? []);
268
287
  const listRows = Math.max(3, Math.min(choices.length, Math.floor((terminalRows - 13) / 2)));
269
288
  const visibleChoices = fitRows(choices, state.activeIndex, listRows);
270
289
  const visibleOffset = Math.max(0, choices.indexOf(visibleChoices[0]));
@@ -280,6 +299,7 @@ export function CreateWizard({ options, onFinish, }) {
280
299
  exit();
281
300
  };
282
301
  const complete = () => {
302
+ const state = latest.current;
283
303
  const answer = {
284
304
  kind: state.kind ?? "chat-workspace",
285
305
  name: state.name,
@@ -291,6 +311,8 @@ export function CreateWizard({ options, onFinish, }) {
291
311
  exit();
292
312
  };
293
313
  useInput((input, key) => {
314
+ const state = latest.current;
315
+ const { multiSelect, apps, required, choices } = wizardChoices(state, options.installedApps ?? []);
294
316
  if (state.step === "cancelled")
295
317
  return;
296
318
  if ((key.ctrl && input.toLowerCase() === "c") || key.escape) {
@@ -569,7 +591,7 @@ export async function runCreateWizard(options) {
569
591
  }
570
592
  function InkChoicePrompt({ message, choices, onFinish, }) {
571
593
  const { exit } = useApp();
572
- const [activeIndex, setActiveIndex] = React.useState(0);
594
+ const [activeIndex, setActiveIndex, latestIndex] = useKeypressState(() => 0);
573
595
  useInput((input, key) => {
574
596
  if (key.escape || (key.ctrl && input.toLowerCase() === "c")) {
575
597
  onFinish(null);
@@ -581,7 +603,7 @@ function InkChoicePrompt({ message, choices, onFinish, }) {
581
603
  else if (key.downArrow)
582
604
  setActiveIndex((index) => Math.min(choices.length - 1, index + 1));
583
605
  else if (key.return) {
584
- onFinish(choices[activeIndex]?.value ?? null);
606
+ onFinish(choices[latestIndex.current]?.value ?? null);
585
607
  exit();
586
608
  }
587
609
  });
@@ -7,6 +7,7 @@ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
7
7
  import { DISPATCH_WORKSPACE_ROOT_REDIRECTS, getWorkspaceAppIdValidationError, } from "../shared/workspace-app-id.js";
8
8
  import { setupAgentSymlinks } from "./setup-agents.js";
9
9
  import { coreTemplates, getTemplate, allTemplateNames, } from "./templates-meta.js";
10
+ import { addConfiguredMigrationDependencies } from "./upgrade.js";
10
11
  import { ensureNodePtyBuildDependency, parseWorkspaceScope, workspacifyApp, } from "./workspacify.js";
11
12
  const __filename = fileURLToPath(import.meta.url);
12
13
  const __dirname = path.dirname(__filename);
@@ -553,6 +554,7 @@ async function createWorkspaceInteractive(name, opts, clack) {
553
554
  ...resolution,
554
555
  shape: "workspace",
555
556
  });
557
+ addConfiguredFeatureDependencies(appDir, targetDir);
556
558
  ensureGuardedScaffold(appDir);
557
559
  fixWebManifestName(appDir, appName, templateName, resolution.sourceIdentity);
558
560
  rewriteNetlifyToml(appDir, appName, "workspace");
@@ -795,6 +797,7 @@ async function scaffoldOneAppIntoWorkspace(workspace, appName, templateName, cla
795
797
  ...resolution,
796
798
  shape: "workspace",
797
799
  });
800
+ addConfiguredFeatureDependencies(appDir, workspace.workspaceRoot);
798
801
  ensureScaffoldEmailBrandingConfig(appDir, appName, templateName);
799
802
  ensureGuardedScaffold(appDir);
800
803
  fixWebManifestName(appDir, appName, templateName, resolution.sourceIdentity);
@@ -1630,6 +1633,7 @@ function postProcessStandalone(name, targetDir, templateName, resolution) {
1630
1633
  pkg.optionalDependencies,
1631
1634
  ].some((deps) => Boolean(deps?.["node-pty"]));
1632
1635
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
1636
+ addConfiguredFeatureDependencies(targetDir);
1633
1637
  }
1634
1638
  catch (error) {
1635
1639
  const detail = error instanceof Error ? error.message : String(error);
@@ -1686,6 +1690,16 @@ function postProcessStandalone(name, targetDir, templateName, resolution) {
1686
1690
  fixStandaloneTsconfig(targetDir, templateName);
1687
1691
  setupAgentSymlinks(targetDir);
1688
1692
  }
1693
+ function addConfiguredFeatureDependencies(appDir, workspaceRoot = appDir) {
1694
+ const packageFile = path.join(appDir, "package.json");
1695
+ if (!fs.existsSync(packageFile))
1696
+ return;
1697
+ addConfiguredMigrationDependencies({
1698
+ root: workspaceRoot,
1699
+ kind: workspaceRoot === appDir ? "standalone" : "workspace",
1700
+ packageFiles: [packageFile],
1701
+ });
1702
+ }
1689
1703
  function ensureReactRouterBuildDependencies(pkg) {
1690
1704
  const allDeps = {
1691
1705
  ...pkg.dependencies,
@@ -645,6 +645,13 @@ function isLoopbackOrigin(parsed) {
645
645
  hostname === "::1" ||
646
646
  /^127(?:\.\d{1,3}){3}$/.test(hostname));
647
647
  }
648
+ function sameDevServerOrigin(a, b) {
649
+ return (a.origin === b.origin ||
650
+ (a.protocol === b.protocol &&
651
+ a.port === b.port &&
652
+ isLoopbackOrigin(a) &&
653
+ isLoopbackOrigin(b)));
654
+ }
648
655
  function isApprovedDesignOrigin(rawOrigin, configuredOrigins, opaquePreviewAuthorized = false) {
649
656
  // Sandboxed loopback preview documents have an opaque `null` origin. It is
650
657
  // only approved when this request carries the non-cookie preview token;
@@ -976,16 +983,17 @@ class PreviewSessionCookieJar {
976
983
  }
977
984
  function resolvePreviewSnapshotUrl(devServerUrl, rawUrl) {
978
985
  const base = normalizeHttpUrl(devServerUrl);
986
+ const baseUrl = new URL(base);
979
987
  const parsed = new URL(rawUrl?.trim() || "/", `${base}/`);
980
988
  parsed.hash = "";
981
989
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
982
990
  throw new Error("Snapshot URL must use http(s).");
983
991
  }
984
- if (!sameOrigin(parsed.toString(), base)) {
992
+ if (!sameDevServerOrigin(parsed, baseUrl)) {
985
993
  throw new Error("Snapshot URL must stay on the connected dev server.");
986
994
  }
987
995
  const search = stripQueryPair(parsed.search, FRAME_BRIDGE_KEY_PARAM);
988
- return `${parsed.origin}${parsed.pathname}${search}`;
996
+ return `${baseUrl.origin}${parsed.pathname}${search}`;
989
997
  }
990
998
  function stripPreviewTokenQueryParam(search) {
991
999
  if (!search.includes("previewToken"))
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
2
2
  import fs from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
5
- import { Node, Project, QuoteKind, SyntaxKind, } from "ts-morph";
5
+ import { Node, Project, QuoteKind, StructureKind, SyntaxKind, } from "ts-morph";
6
6
  import { bundledCorePackageVersion, isMigrationManifestActive, loadMigrationManifestsForProject, migrationMoveStatus, resolveMigrationSymbolMove, } from "../package-lifecycle/migration-manifest.js";
7
7
  const SOURCE_EXTENSIONS = new Set([".ts", ".tsx"]);
8
8
  const CSS_EXTENSIONS = new Set([".css"]);
@@ -180,6 +180,7 @@ function recordIntroducedDependency(pending, sourceFile, root, from, to) {
180
180
  }
181
181
  function importedNameStructure(importedName, localName, nextName, typeOnly) {
182
182
  return {
183
+ kind: StructureKind.ImportSpecifier,
183
184
  name: nextName,
184
185
  alias: localName !== nextName
185
186
  ? localName
@@ -546,6 +546,9 @@ const SKILL_INSTRUCTION_CLIENT_LABELS = {
546
546
  "claude-code-cli": "Claude Code",
547
547
  codex: "Shared .agents skills",
548
548
  cowork: "MCP only",
549
+ cursor: "Cursor",
550
+ opencode: "OpenCode",
551
+ "github-copilot": "GitHub Copilot",
549
552
  pi: "Pi",
550
553
  };
551
554
  const SKILL_INSTRUCTION_CLIENT_HINTS = {
@@ -553,12 +556,16 @@ const SKILL_INSTRUCTION_CLIENT_HINTS = {
553
556
  "claude-code-cli": "Also write Claude Code's native .claude/skills and commands files.",
554
557
  codex: "Project scope writes .agents skills/commands for Codex, Pi, Cursor, OpenCode, Copilot, and similar agents; user scope writes Codex's ~/.codex skills/commands.",
555
558
  cowork: "MCP only",
559
+ cursor: "Uses shared project .agents skills and commands.",
560
+ opencode: "Uses shared project .agents skills and commands.",
561
+ "github-copilot": "Uses shared project .agents skills and commands.",
556
562
  pi: "Project scope writes .agents/skills plus .pi/prompts; user scope writes ~/.agents/skills plus ~/.pi/agent/prompts.",
557
563
  };
558
564
  function normalizeKnownSkillTarget(value) {
559
565
  const key = value?.trim().toLowerCase();
560
- if (!key)
566
+ if (!key || !Object.hasOwn(BUILT_IN_APP_SKILL_ALIASES, key)) {
561
567
  return undefined;
568
+ }
562
569
  return BUILT_IN_APP_SKILL_ALIASES[key];
563
570
  }
564
571
  function isKnownSkill(value) {
@@ -894,10 +901,10 @@ function mergeContentLocalFilesManifest(existing, baseDir) {
894
901
  const apps = isJsonRecord(manifest.apps) ? { ...manifest.apps } : {};
895
902
  const contentApp = isJsonRecord(apps.content) ? { ...apps.content } : {};
896
903
  const defaults = defaultContentLocalFilesAppConfig();
897
- if (!Array.isArray(contentApp.roots) || contentApp.roots.length === 0) {
898
- contentApp.roots = defaults.roots;
899
- }
900
- contentApp.roots = contentApp.roots.map((root) => {
904
+ const roots = Array.isArray(contentApp.roots) && contentApp.roots.length > 0
905
+ ? contentApp.roots
906
+ : defaults.roots;
907
+ contentApp.roots = roots.map((root) => {
901
908
  if (!isJsonRecord(root) || typeof root.path !== "string")
902
909
  return root;
903
910
  const source = isJsonRecord(root.source) ? root.source : {};
@@ -1094,7 +1101,7 @@ function removeEmptyParents(start, boundary) {
1094
1101
  }
1095
1102
  }
1096
1103
  function restoreInstallPaths(snapshots, boundary) {
1097
- for (const snapshot of snapshots.toReversed()) {
1104
+ for (const snapshot of snapshots.slice().reverse()) {
1098
1105
  fs.rmSync(snapshot.target, { recursive: true, force: true });
1099
1106
  if (snapshot.existed) {
1100
1107
  fs.mkdirSync(path.dirname(snapshot.target), { recursive: true });
@@ -1609,25 +1616,6 @@ function updateSkillInstallStates(states, dryRun) {
1609
1616
  }
1610
1617
  return updated;
1611
1618
  }
1612
- function normalizeClientIds(values) {
1613
- if (!Array.isArray(values))
1614
- return [];
1615
- const seen = new Set();
1616
- const out = [];
1617
- for (const value of values) {
1618
- if (typeof value !== "string")
1619
- continue;
1620
- const id = value.toLowerCase();
1621
- if (!CLIENTS.includes(id))
1622
- continue;
1623
- const client = id;
1624
- if (seen.has(client))
1625
- continue;
1626
- seen.add(client);
1627
- out.push(client);
1628
- }
1629
- return out;
1630
- }
1631
1619
  function isMcpClientId(value) {
1632
1620
  return CLIENTS.includes(value);
1633
1621
  }
@@ -1949,7 +1937,7 @@ async function promptForPlanMcpUrl() {
1949
1937
  placeholder: "https://my-plan-app.example.com",
1950
1938
  validate(value) {
1951
1939
  try {
1952
- resolveMcpUrlOverride(value);
1940
+ resolveMcpUrlOverride(value ?? "");
1953
1941
  return undefined;
1954
1942
  }
1955
1943
  catch (err) {
@@ -2678,7 +2666,7 @@ async function connectAfterEnsure(installTarget, clients, parsed, options) {
2678
2666
  const clearSpinner = () => {
2679
2667
  if (!spinnerActive)
2680
2668
  return;
2681
- spinner.clear();
2669
+ spinner?.clear();
2682
2670
  spinnerActive = false;
2683
2671
  };
2684
2672
  const writeAuthMessage = () => {
@@ -3627,11 +3615,6 @@ export async function runSkills(argv, options = {}) {
3627
3615
  .map((result) => result.connectCommand)
3628
3616
  .filter((command) => Boolean(command))),
3629
3617
  ];
3630
- const authLine = authConnected
3631
- ? "Authentication: completed."
3632
- : pendingConnectCommands.length
3633
- ? `Authentication: pending — run ${pendingConnectCommands.join(" && ")}`
3634
- : "";
3635
3618
  const githubActions = [
3636
3619
  ...new Set(results
3637
3620
  .map((result) => result.githubActionPath)
@@ -1,5 +1,5 @@
1
1
  import { type SpawnSyncReturns } from "node:child_process";
2
- import { type MigrationManifest, type MigrationDependency } from "../package-lifecycle/migration-manifest.js";
2
+ import { type MigrationDependency } from "../package-lifecycle/migration-manifest.js";
3
3
  declare const PINNABLE_SECTIONS: readonly ["dependencies", "devDependencies", "optionalDependencies"];
4
4
  export type UpgradeCommand = "run" | "check" | "help";
5
5
  export interface UpgradeCliOptions {
@@ -114,8 +114,9 @@ export declare function isPinnedOrLocalVersion(version: string): boolean;
114
114
  export declare function shouldBumpAgentNativeVersion(version: string): boolean;
115
115
  export declare function selectMigrationDependencies(dependencies: MigrationDependency[], environment: NodeJS.ProcessEnv): MigrationDependency[];
116
116
  export declare function readUpgradeEnvironment(projectRoot: string, packageDir: string, shellEnvironment: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
117
- export declare function loadActiveMigrationDependencies(projectRoot: string, packageVersion: string | null, manifests?: MigrationManifest[]): MigrationDependency[];
117
+ export declare function loadActiveMigrationDependencies(projectRoot: string, packageVersion: string | null, manifests?: import("../package-lifecycle/migration-manifest.js").MigrationManifest[]): MigrationDependency[];
118
118
  export declare function planMigrationDependencyAdditions(project: UpgradeProject, shellEnvironment?: NodeJS.ProcessEnv): UpgradeDependencyAddition[];
119
+ export declare function addConfiguredMigrationDependencies(project: UpgradeProject, shellEnvironment?: NodeJS.ProcessEnv): void;
119
120
  export declare function pinResolvedAgentNativeVersions(project: UpgradeProject): AgentNativePinResult;
120
121
  export declare function detectUpgradeProject(cwd: string): UpgradeProject | null;
121
122
  export declare function resolveInstalledPackageVersion(projectRoot: string, packageName: string): string | null;
@@ -384,6 +384,9 @@ function applyMigrationDependencyAdditions(additions) {
384
384
  writeJsonFile(file, read.value);
385
385
  }
386
386
  }
387
+ export function addConfiguredMigrationDependencies(project, shellEnvironment = process.env) {
388
+ applyMigrationDependencyAdditions(planMigrationDependencyAdditions(project, shellEnvironment));
389
+ }
387
390
  export function pinResolvedAgentNativeVersions(project) {
388
391
  const pins = [];
389
392
  const unresolved = [];
@@ -44,7 +44,7 @@ export function ensureNodePtyBuildDependency(workspaceRoot) {
44
44
  "dependencies",
45
45
  "node-gyp",
46
46
  ], NODE_PTY_BUILD_DEPENDENCY);
47
- const updated = document.toString();
47
+ const updated = document.toString({ lineWidth: 0 });
48
48
  if (updated !== current)
49
49
  fs.writeFileSync(workspacePath, updated);
50
50
  }
@@ -1,6 +1,6 @@
1
1
  export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
2
- error: string;
3
2
  ok?: undefined;
3
+ error: string;
4
4
  } | {
5
5
  error?: undefined;
6
6
  ok: boolean;
@@ -53,6 +53,8 @@ export declare function retryOnDdlRace<T>(fn: () => Promise<T>): Promise<T>;
53
53
  export declare function isUniqueViolation(e: any): boolean;
54
54
  export declare function isLocalDatabase(): boolean;
55
55
  export declare function toPostgresParams(sql: string): string;
56
+ export declare function hasExplicitDbTimeout(statement: DbExecStatement): boolean;
57
+ export declare function postgresStatementTimeoutMs(clientTimeoutMs: number): number;
56
58
  export declare function dbExecQueryBudget(statement: DbExecStatement): {
57
59
  timeoutMs: number;
58
60
  maxAttempts: number;
@@ -150,5 +152,6 @@ export declare function pgliteDrizzleClient(url: string, client: any): any;
150
152
  export declare function createDbExec(config?: DbExecConfig): Promise<DbExec>;
151
153
  export declare function annotateMissingTable(err: unknown, sql: unknown): unknown;
152
154
  export declare function withDbExec<T>(exec: DbExec, run: () => T): T;
155
+ export declare function getScopedDbExec(): DbExec | undefined;
153
156
  export declare function getDbExec(): DbExec;
154
157
  export declare function closeDbExec(): Promise<void>;
package/dist/db/client.js CHANGED
@@ -556,13 +556,13 @@ function sqlAndArgs(sql) {
556
556
  const POSTGRES_STATEMENT_TIMEOUT_HEADROOM_MS = 250;
557
557
  const POSTGRES_STATEMENT_TIMEOUT_RESET_MS = 5_000;
558
558
  const POSTGRES_MAX_INT = 2_147_483_647;
559
- function hasExplicitDbTimeout(statement) {
559
+ export function hasExplicitDbTimeout(statement) {
560
560
  if (typeof statement === "string")
561
561
  return false;
562
562
  const timeoutMs = Number(statement.timeoutMs);
563
563
  return Number.isFinite(timeoutMs) && timeoutMs > 0;
564
564
  }
565
- function postgresStatementTimeoutMs(clientTimeoutMs) {
565
+ export function postgresStatementTimeoutMs(clientTimeoutMs) {
566
566
  const safeTimeoutMs = Math.max(1, Math.min(POSTGRES_MAX_INT, Math.floor(clientTimeoutMs)));
567
567
  const headroomMs = Math.min(POSTGRES_STATEMENT_TIMEOUT_HEADROOM_MS, Math.max(1, Math.floor(safeTimeoutMs * 0.1)));
568
568
  return Math.max(1, safeTimeoutMs - headroomMs);
@@ -1063,7 +1063,7 @@ async function executePglite(client, sql) {
1063
1063
  rowsAffected: result.affectedRows ?? result.rowCount ?? 0,
1064
1064
  };
1065
1065
  }
1066
- function runPgliteTransaction(url, client, fn) {
1066
+ async function runPgliteTransaction(url, client, fn) {
1067
1067
  if (getActivePgliteTransactionExec(url)) {
1068
1068
  throw new Error("Nested PGlite transactions are not supported; reuse the active transaction handle.");
1069
1069
  }
@@ -1461,7 +1461,10 @@ export function annotateMissingTable(err, sql) {
1461
1461
  }
1462
1462
  const scopedDbExec = new AsyncLocalStorage();
1463
1463
  export function withDbExec(exec, run) {
1464
- return scopedDbExec.run(exec, run);
1464
+ return scopedDbExec.run(guardSchemaMutations(exec), run);
1465
+ }
1466
+ export function getScopedDbExec() {
1467
+ return scopedDbExec.getStore();
1465
1468
  }
1466
1469
  export function getDbExec() {
1467
1470
  const scoped = scopedDbExec.getStore();