@agent-native/core 0.198.3-nightly-20260930154911 → 0.198.4

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 (106) hide show
  1. package/dist/a2a/types.d.ts +5 -0
  2. package/dist/agent/production-agent.js +26 -1
  3. package/dist/automation/index.d.ts +1 -1
  4. package/dist/catalog.json +1 -0
  5. package/dist/cli/create.js +14 -0
  6. package/dist/cli/migration-codemod.js +2 -1
  7. package/dist/cli/skills.js +15 -32
  8. package/dist/cli/upgrade.d.ts +3 -2
  9. package/dist/cli/upgrade.js +3 -0
  10. package/dist/cli/workspacify.js +1 -1
  11. package/dist/client/chat/agentkit-agent-native.js +15 -15
  12. package/dist/client/chat/runtime.js +5 -3
  13. package/dist/client/feature-flags/types.d.ts +2 -0
  14. package/dist/client/i18n.d.ts +2 -0
  15. package/dist/client/i18n.js +2 -0
  16. package/dist/client/integrations/index.d.ts +1 -0
  17. package/dist/client/integrations/index.js +1 -0
  18. package/dist/client/labs/index.d.ts +1 -1
  19. package/dist/client/labs/use-lab.d.ts +5 -0
  20. package/dist/client/labs/use-lab.js +7 -3
  21. package/dist/client/resources/mcp-connection-resume.d.ts +5 -3
  22. package/dist/client/resources/mcp-connection-resume.js +150 -13
  23. package/dist/client/sse-event-processor.d.ts +6 -0
  24. package/dist/client/uploads/index.d.ts +1 -0
  25. package/dist/client/uploads/index.js +1 -0
  26. package/dist/client/uploads/private-icon.d.ts +10 -0
  27. package/dist/client/uploads/private-icon.js +52 -0
  28. package/dist/collab/routes.d.ts +1 -1
  29. package/dist/collab/struct-routes.d.ts +1 -1
  30. package/dist/db/client.d.ts +3 -0
  31. package/dist/db/client.js +7 -4
  32. package/dist/db/create-get-db.js +478 -3
  33. package/dist/feature-flags/actions/get-feature-flags.js +20 -0
  34. package/dist/feature-flags/actions/list-feature-flags.d.ts +2 -0
  35. package/dist/feature-flags/actions/list-feature-flags.js +5 -0
  36. package/dist/feature-flags/actions/set-feature-flag.js +5 -0
  37. package/dist/file-upload/actions/upload-image.d.ts +2 -2
  38. package/dist/framework-tools.js +2 -0
  39. package/dist/icon-assets/index.d.ts +3 -0
  40. package/dist/icon-assets/index.js +3 -0
  41. package/dist/icon-assets/multipart.d.ts +9 -0
  42. package/dist/icon-assets/multipart.js +60 -0
  43. package/dist/icon-assets/schema.d.ts +194 -0
  44. package/dist/icon-assets/schema.js +16 -0
  45. package/dist/icon-assets/store.d.ts +38 -0
  46. package/dist/icon-assets/store.js +187 -0
  47. package/dist/icon-assets/svg.d.ts +2 -0
  48. package/dist/icon-assets/svg.js +146 -0
  49. package/dist/icon-assets/workspace-transport.d.ts +20 -0
  50. package/dist/icon-assets/workspace-transport.js +122 -0
  51. package/dist/identity/rekey.js +1 -0
  52. package/dist/labs/actions/get-lab-states.d.ts +2 -0
  53. package/dist/labs/actions/get-lab-states.js +14 -0
  54. package/dist/labs/actions/get-labs.js +2 -2
  55. package/dist/labs/actions/set-lab.js +4 -2
  56. package/dist/labs/index.d.ts +1 -1
  57. package/dist/labs/index.js +1 -1
  58. package/dist/labs/registry.d.ts +3 -0
  59. package/dist/labs/registry.js +14 -0
  60. package/dist/labs/server.d.ts +1 -1
  61. package/dist/labs/server.js +1 -1
  62. package/dist/labs/store.d.ts +13 -2
  63. package/dist/labs/store.js +124 -7
  64. package/dist/localization/default-messages.d.ts +2 -0
  65. package/dist/localization/default-messages.js +1 -1
  66. package/dist/localization/icon-picker-messages.d.ts +44 -0
  67. package/dist/localization/icon-picker-messages.js +22 -0
  68. package/dist/mcp-client/oauth-client.d.ts +1 -0
  69. package/dist/mcp-client/oauth-client.js +42 -4
  70. package/dist/mcp-client/oauth-routes.js +15 -2
  71. package/dist/observability/routes.d.ts +9 -9
  72. package/dist/org/actions/list-workspace-icons.d.ts +7 -0
  73. package/dist/org/actions/list-workspace-icons.js +41 -0
  74. package/dist/org/handlers.d.ts +1 -1
  75. package/dist/org/handlers.js +28 -1
  76. package/dist/org/index.d.ts +2 -2
  77. package/dist/org/index.js +1 -1
  78. package/dist/org/migrations.js +21 -0
  79. package/dist/org/plugin.js +42 -0
  80. package/dist/org/private-icon-handlers.d.ts +6 -0
  81. package/dist/org/private-icon-handlers.js +212 -0
  82. package/dist/progress/routes.d.ts +1 -1
  83. package/dist/provider-api/actions/custom-provider-registration.d.ts +10 -10
  84. package/dist/provider-api/actions/provider-api.d.ts +7 -7
  85. package/dist/provider-api/index.d.ts +1 -1
  86. package/dist/provider-api/index.js +26 -6
  87. package/dist/secrets/routes.d.ts +6 -6
  88. package/dist/server/action-discovery.js +5 -0
  89. package/dist/server/agent-chat-plugin.js +14 -0
  90. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  91. package/dist/server/agent-engine-default-model-route.d.ts +2 -2
  92. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  93. package/dist/server/core-routes-plugin.d.ts +1 -1
  94. package/dist/server/core-routes-plugin.js +18 -3
  95. package/dist/server/index.d.ts +1 -1
  96. package/dist/server/index.js +1 -1
  97. package/dist/server/realtime-token.d.ts +1 -1
  98. package/dist/server/workspace-provider-oauth.d.ts +1 -0
  99. package/dist/server/workspace-provider-oauth.js +4 -2
  100. package/dist/sharing/access.js +4 -3
  101. package/dist/templates/chat/app/components/chat/ChatRouteContent.tsx +9 -16
  102. package/dist/triggers/actions/manage-automation.d.ts +5 -5
  103. package/dist/vite/action-types-plugin.js +4 -0
  104. package/dist/vite/client.js +11 -3
  105. package/package.json +8 -10
  106. package/src/templates/chat/app/components/chat/ChatRouteContent.tsx +9 -16
@@ -1,7 +1,9 @@
1
1
  const MCP_CONNECTION_RESUME_STORAGE_KEY = "agent-native:mcp-connection-resume";
2
2
  const MCP_CONNECTION_RESUME_EVENT = "agent-native:mcp-connection-complete";
3
+ const MCP_CONNECTION_RESUME_COMPLETION_STORAGE_PREFIX = "agent-native:mcp-connection-completion:";
3
4
  const MCP_CONNECTION_RESUME_TTL_MS = 10 * 60 * 1_000;
4
5
  const MCP_CONNECTION_RESUME_MAX_MESSAGE_LENGTH = 24_000;
6
+ const completedResumeIds = new Set();
5
7
  function currentReturnUrl() {
6
8
  if (typeof window === "undefined")
7
9
  return "/";
@@ -17,7 +19,27 @@ function getSessionStorage() {
17
19
  return null;
18
20
  }
19
21
  }
20
- export function saveMcpConnectionResume(message, agentKit) {
22
+ function getLocalStorage() {
23
+ if (typeof window === "undefined")
24
+ return null;
25
+ try {
26
+ return window.localStorage;
27
+ }
28
+ catch {
29
+ // coercion-ok: callers fail closed when local storage is unavailable.
30
+ return null;
31
+ }
32
+ }
33
+ function clearCompletionMarker(completionId) {
34
+ completedResumeIds.delete(completionId);
35
+ try {
36
+ getLocalStorage()?.removeItem(MCP_CONNECTION_RESUME_COMPLETION_STORAGE_PREFIX + completionId);
37
+ }
38
+ catch {
39
+ // coercion-ok: stale markers cannot complete the newer opaque attempt.
40
+ }
41
+ }
42
+ export function saveMcpConnectionResume(message, agentKit, completionId) {
21
43
  const trimmedMessage = message.trim();
22
44
  if (!trimmedMessage ||
23
45
  trimmedMessage.length > MCP_CONNECTION_RESUME_MAX_MESSAGE_LENGTH) {
@@ -30,28 +52,57 @@ export function saveMcpConnectionResume(message, agentKit) {
30
52
  message: trimmedMessage,
31
53
  returnUrl: currentReturnUrl(),
32
54
  createdAt: Date.now(),
55
+ ...(completionId ? { completionId } : {}),
33
56
  ...(agentKit ? { agentKit } : {}),
34
57
  };
58
+ const previousCompletionId = readStoredMcpConnectionResume()?.completionId;
35
59
  try {
36
60
  storage.setItem(MCP_CONNECTION_RESUME_STORAGE_KEY, JSON.stringify(request));
37
- return true;
38
61
  }
39
62
  catch {
40
63
  return false;
41
64
  }
65
+ if (previousCompletionId)
66
+ clearCompletionMarker(previousCompletionId);
67
+ return true;
42
68
  }
43
- export function clearMcpConnectionResume() {
69
+ function removeStoredMcpConnectionResume(completionId) {
44
70
  const storage = getSessionStorage();
45
71
  if (!storage)
46
72
  return;
73
+ let storedCompletionId;
74
+ let raw;
75
+ try {
76
+ raw = storage.getItem(MCP_CONNECTION_RESUME_STORAGE_KEY);
77
+ }
78
+ catch {
79
+ return;
80
+ }
81
+ if (raw) {
82
+ try {
83
+ const request = JSON.parse(raw);
84
+ if (typeof request.completionId === "string") {
85
+ storedCompletionId = request.completionId;
86
+ }
87
+ }
88
+ catch {
89
+ // coercion-ok: malformed records are removed below and cannot be resumed.
90
+ }
91
+ }
92
+ if (completionId && storedCompletionId !== completionId)
93
+ return;
47
94
  try {
48
95
  storage.removeItem(MCP_CONNECTION_RESUME_STORAGE_KEY);
49
96
  }
50
97
  catch {
51
- // Ignore storage-denied browsers; the pending request is best effort.
98
+ // Keep its completion marker so a readable request can still be retried.
99
+ return;
52
100
  }
101
+ const completedId = completionId ?? storedCompletionId;
102
+ if (completedId)
103
+ clearCompletionMarker(completedId);
53
104
  }
54
- export function consumeMcpConnectionResume(returnUrl = currentReturnUrl()) {
105
+ function readStoredMcpConnectionResume() {
55
106
  const storage = getSessionStorage();
56
107
  if (!storage)
57
108
  return null;
@@ -63,14 +114,16 @@ export function consumeMcpConnectionResume(returnUrl = currentReturnUrl()) {
63
114
  request = JSON.parse(raw);
64
115
  }
65
116
  catch {
66
- clearMcpConnectionResume();
117
+ removeStoredMcpConnectionResume();
67
118
  return null;
68
119
  }
69
120
  if (!request ||
70
121
  typeof request.message !== "string" ||
71
122
  typeof request.returnUrl !== "string" ||
72
- typeof request.createdAt !== "number") {
73
- clearMcpConnectionResume();
123
+ typeof request.createdAt !== "number" ||
124
+ (request.completionId !== undefined &&
125
+ (typeof request.completionId !== "string" || !request.completionId))) {
126
+ removeStoredMcpConnectionResume();
74
127
  return null;
75
128
  }
76
129
  if (request.agentKit !== undefined &&
@@ -81,26 +134,110 @@ export function consumeMcpConnectionResume(returnUrl = currentReturnUrl()) {
81
134
  !request.agentKit.runId.trim() ||
82
135
  typeof request.agentKit.requestId !== "string" ||
83
136
  !request.agentKit.requestId.trim())) {
84
- clearMcpConnectionResume();
137
+ removeStoredMcpConnectionResume();
85
138
  return null;
86
139
  }
87
140
  if (Date.now() - request.createdAt > MCP_CONNECTION_RESUME_TTL_MS) {
88
- clearMcpConnectionResume();
141
+ removeStoredMcpConnectionResume();
89
142
  return null;
90
143
  }
144
+ return request;
145
+ }
146
+ function isCompletionRecorded(completionId) {
147
+ if (completedResumeIds.has(completionId))
148
+ return true;
149
+ const storage = getLocalStorage();
150
+ if (!storage)
151
+ return false;
152
+ try {
153
+ return (storage.getItem(MCP_CONNECTION_RESUME_COMPLETION_STORAGE_PREFIX + completionId) === "1");
154
+ }
155
+ catch {
156
+ // coercion-ok: unreadable completion state fails closed and keeps the request pending.
157
+ return false;
158
+ }
159
+ }
160
+ export function getPendingMcpConnectionResume(returnUrl = currentReturnUrl()) {
161
+ const request = readStoredMcpConnectionResume();
162
+ if (!request)
163
+ return null;
91
164
  if (request.returnUrl !== returnUrl)
92
165
  return null;
93
- clearMcpConnectionResume();
166
+ if (request.completionId && !isCompletionRecorded(request.completionId)) {
167
+ return null;
168
+ }
94
169
  return request;
95
170
  }
96
- export function notifyMcpConnectionComplete() {
171
+ export function clearMcpConnectionResume(expected) {
172
+ const current = readStoredMcpConnectionResume();
173
+ if (typeof expected === "string" && current?.completionId !== expected) {
174
+ return;
175
+ }
176
+ if (expected &&
177
+ typeof expected !== "string" &&
178
+ (!current ||
179
+ current.createdAt !== expected.createdAt ||
180
+ current.returnUrl !== expected.returnUrl ||
181
+ current.message !== expected.message ||
182
+ current.completionId !== expected.completionId ||
183
+ current.agentKit?.threadId !== expected.agentKit?.threadId ||
184
+ current.agentKit?.runId !== expected.agentKit?.runId ||
185
+ current.agentKit?.requestId !== expected.agentKit?.requestId)) {
186
+ return;
187
+ }
188
+ removeStoredMcpConnectionResume(typeof expected === "string" ? expected : current?.completionId);
189
+ }
190
+ export function consumeMcpConnectionResume(returnUrl = currentReturnUrl()) {
191
+ const request = getPendingMcpConnectionResume(returnUrl);
192
+ if (request)
193
+ clearMcpConnectionResume(request);
194
+ return request;
195
+ }
196
+ export function notifyMcpConnectionComplete(completionId) {
97
197
  if (typeof window === "undefined")
98
198
  return;
199
+ if (completionId) {
200
+ const request = readStoredMcpConnectionResume();
201
+ if (request?.completionId !== completionId)
202
+ return;
203
+ completedResumeIds.add(completionId);
204
+ try {
205
+ getLocalStorage()?.setItem(MCP_CONNECTION_RESUME_COMPLETION_STORAGE_PREFIX + completionId, "1");
206
+ }
207
+ catch {
208
+ // coercion-ok: the active page can use this signal; reloads fail closed.
209
+ }
210
+ }
99
211
  window.dispatchEvent(new Event(MCP_CONNECTION_RESUME_EVENT));
100
212
  }
101
213
  export function addMcpConnectionCompleteListener(listener) {
102
214
  if (typeof window === "undefined")
103
215
  return () => { };
216
+ const onStorage = (event) => {
217
+ if (event.key?.startsWith(MCP_CONNECTION_RESUME_COMPLETION_STORAGE_PREFIX) &&
218
+ event.newValue !== null) {
219
+ listener();
220
+ }
221
+ };
222
+ const onMessage = (event) => {
223
+ if (event.origin !== window.location.origin ||
224
+ typeof event.data !== "object" ||
225
+ event.data === null ||
226
+ !("type" in event.data) ||
227
+ event.data.type !== "agent-native:workspace-connection-complete" ||
228
+ !("completionId" in event.data) ||
229
+ typeof event.data.completionId !== "string" ||
230
+ !event.source) {
231
+ return;
232
+ }
233
+ notifyMcpConnectionComplete(event.data.completionId);
234
+ };
104
235
  window.addEventListener(MCP_CONNECTION_RESUME_EVENT, listener);
105
- return () => window.removeEventListener(MCP_CONNECTION_RESUME_EVENT, listener);
236
+ window.addEventListener("storage", onStorage);
237
+ window.addEventListener("message", onMessage);
238
+ return () => {
239
+ window.removeEventListener(MCP_CONNECTION_RESUME_EVENT, listener);
240
+ window.removeEventListener("storage", onStorage);
241
+ window.removeEventListener("message", onMessage);
242
+ };
106
243
  }
@@ -108,6 +108,12 @@ export interface SSEEvent {
108
108
  provider?: string;
109
109
  connectionReason?: "connect" | "grant" | "reauthorize" | "admin_required";
110
110
  appId?: string;
111
+ source?: {
112
+ id: string;
113
+ kind?: string;
114
+ label?: string;
115
+ uri?: string;
116
+ };
111
117
  error?: string;
112
118
  message?: string;
113
119
  seq?: number;
@@ -2,3 +2,4 @@ export { uploadEditorImage, type EditorImageUploadFn, type EditorImageUploadResu
2
2
  export { useUploadResource } from "./use-upload-resource.js";
3
3
  export { useFileUploadStatus } from "./use-file-upload-status.js";
4
4
  export { fetchFileUploadStatus } from "../client-status-requests.js";
5
+ export { uploadWorkspacePrivateIcon, workspacePrivateIconLibraryUrl, workspacePrivateIconUrl, } from "./private-icon.js";
@@ -2,3 +2,4 @@ export { uploadEditorImage, } from "./upload-editor-image.js";
2
2
  export { useUploadResource } from "./use-upload-resource.js";
3
3
  export { useFileUploadStatus } from "./use-file-upload-status.js";
4
4
  export { fetchFileUploadStatus } from "../client-status-requests.js";
5
+ export { uploadWorkspacePrivateIcon, workspacePrivateIconLibraryUrl, workspacePrivateIconUrl, } from "./private-icon.js";
@@ -0,0 +1,10 @@
1
+ import type { IconValue } from "../../icons/index.js";
2
+ export declare function workspacePrivateIconUrl(orgId: string, image: Extract<IconValue, {
3
+ kind: "image";
4
+ }>): string | undefined;
5
+ export declare function workspacePrivateIconLibraryUrl(orgId: string, image: Extract<IconValue, {
6
+ kind: "image";
7
+ }>): string | undefined;
8
+ export declare function uploadWorkspacePrivateIcon(file: File): Promise<Extract<IconValue, {
9
+ kind: "image";
10
+ }>>;
@@ -0,0 +1,52 @@
1
+ import { agentNativePath } from "../api-path.js";
2
+ export function workspacePrivateIconUrl(orgId, image) {
3
+ if (image.authority === "url")
4
+ return image.assetId;
5
+ if (image.authority !== "private-icon" || !orgId)
6
+ return undefined;
7
+ return agentNativePath(`/_agent-native/org/private-icons/${encodeURIComponent(orgId)}/${encodeURIComponent(image.assetId)}`);
8
+ }
9
+ export function workspacePrivateIconLibraryUrl(orgId, image) {
10
+ if (image.authority === "url")
11
+ return image.assetId;
12
+ if (image.authority !== "private-icon" || !orgId)
13
+ return undefined;
14
+ return agentNativePath(`/_agent-native/org/private-icons/library/${encodeURIComponent(orgId)}/${encodeURIComponent(image.assetId)}`);
15
+ }
16
+ export async function uploadWorkspacePrivateIcon(file) {
17
+ const form = new FormData();
18
+ form.set("file", file);
19
+ const response = await fetch(agentNativePath("/_agent-native/org/private-icons"), {
20
+ method: "POST",
21
+ credentials: "include",
22
+ body: form,
23
+ });
24
+ if (!response.ok) {
25
+ const body = response.headers
26
+ .get("content-type")
27
+ ?.includes("application/json")
28
+ ? await response.json()
29
+ : null;
30
+ const message = body &&
31
+ typeof body === "object" &&
32
+ "message" in body &&
33
+ typeof body.message === "string"
34
+ ? body.message
35
+ : `Workspace icon upload failed (${response.status}).`;
36
+ throw new Error(message);
37
+ }
38
+ const body = await response.json();
39
+ if (!body ||
40
+ typeof body !== "object" ||
41
+ !("id" in body) ||
42
+ typeof body.id !== "string") {
43
+ throw new Error("Workspace icon upload returned an invalid asset ID.");
44
+ }
45
+ return {
46
+ version: 1,
47
+ kind: "image",
48
+ authority: "private-icon",
49
+ assetId: body.id,
50
+ alt: file.name.replace(/\.[^./\\]+$/, ""),
51
+ };
52
+ }
@@ -16,8 +16,8 @@ export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import
16
16
  }>>;
17
17
  export declare const postCollabText: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
18
18
  ok?: undefined;
19
- error: string;
20
19
  text?: undefined;
20
+ error: string;
21
21
  } | {
22
22
  error?: undefined;
23
23
  ok: boolean;
@@ -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();